mirror of
https://github.com/brmlab/brmsklad.git
synced 2025-10-29 23:33:58 +01:00
Upgrade CakePHP from 2.2.5 to 2.9.5
This commit is contained in:
parent
5a580df460
commit
235a541597
793 changed files with 60746 additions and 23753 deletions
|
|
@ -2,25 +2,23 @@
|
|||
/**
|
||||
* The Project Task handles creating the base application
|
||||
*
|
||||
*
|
||||
* PHP 5
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @since CakePHP(tm) v 1.2
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
App::uses('AppShell', 'Console/Command');
|
||||
App::uses('File', 'Utility');
|
||||
App::uses('Folder', 'Utility');
|
||||
App::uses('String', 'Utility');
|
||||
App::uses('CakeText', 'Utility');
|
||||
App::uses('Security', 'Utility');
|
||||
|
||||
/**
|
||||
|
|
@ -66,7 +64,7 @@ class ProjectTask extends AppShell {
|
|||
}
|
||||
|
||||
$response = false;
|
||||
while ($response == false && is_dir($project) === true && file_exists($project . 'Config' . 'core.php')) {
|
||||
while (!$response && is_dir($project) === true && file_exists($project . 'Config' . 'core.php')) {
|
||||
$prompt = __d('cake_console', '<warning>A project already exists in this location:</warning> %s Overwrite?', $project);
|
||||
$response = $this->in($prompt, array('y', 'n'), 'n');
|
||||
if (strtolower($response) === 'n') {
|
||||
|
|
@ -92,6 +90,13 @@ class ProjectTask extends AppShell {
|
|||
$success = false;
|
||||
}
|
||||
|
||||
if ($this->cachePrefix($path)) {
|
||||
$this->out(__d('cake_console', ' * Cache prefix set'));
|
||||
} else {
|
||||
$this->err(__d('cake_console', 'The cache prefix was <error>NOT</error> set'));
|
||||
$success = false;
|
||||
}
|
||||
|
||||
if ($this->consolePath($path) === true) {
|
||||
$this->out(__d('cake_console', ' * app/Console/cake.php path set.'));
|
||||
} else {
|
||||
|
|
@ -109,8 +114,8 @@ class ProjectTask extends AppShell {
|
|||
}
|
||||
$success = $this->corePath($path, $hardCode) === true;
|
||||
if ($success) {
|
||||
$this->out(__d('cake_console', ' * CAKE_CORE_INCLUDE_PATH set to %s in webroot/index.php', CAKE_CORE_INCLUDE_PATH));
|
||||
$this->out(__d('cake_console', ' * CAKE_CORE_INCLUDE_PATH set to %s in webroot/test.php', CAKE_CORE_INCLUDE_PATH));
|
||||
$this->out(__d('cake_console', ' * CAKE_CORE_INCLUDE_PATH set to %s in %s', CAKE_CORE_INCLUDE_PATH, 'webroot/index.php'));
|
||||
$this->out(__d('cake_console', ' * CAKE_CORE_INCLUDE_PATH set to %s in %s', CAKE_CORE_INCLUDE_PATH, 'webroot/test.php'));
|
||||
} else {
|
||||
$this->err(__d('cake_console', 'Unable to set CAKE_CORE_INCLUDE_PATH, you should change it in %s', $path . 'webroot' . DS . 'index.php'));
|
||||
$success = false;
|
||||
|
|
@ -122,7 +127,7 @@ class ProjectTask extends AppShell {
|
|||
$Folder = new Folder($path);
|
||||
if (!$Folder->chmod($path . 'tmp', 0777)) {
|
||||
$this->err(__d('cake_console', 'Could not set permissions on %s', $path . DS . 'tmp'));
|
||||
$this->out(__d('cake_console', 'chmod -R 0777 %s', $path . DS . 'tmp'));
|
||||
$this->out('chmod -R 0777 ' . $path . DS . 'tmp');
|
||||
$success = false;
|
||||
}
|
||||
if ($success) {
|
||||
|
|
@ -137,7 +142,7 @@ class ProjectTask extends AppShell {
|
|||
/**
|
||||
* Checks PHP's include_path for CakePHP.
|
||||
*
|
||||
* @return boolean Indicates whether or not CakePHP exists on include_path
|
||||
* @return bool Indicates whether or not CakePHP exists on include_path
|
||||
*/
|
||||
public function cakeOnIncludePath() {
|
||||
$paths = explode(PATH_SEPARATOR, ini_get('include_path'));
|
||||
|
|
@ -207,7 +212,7 @@ class ProjectTask extends AppShell {
|
|||
}
|
||||
|
||||
foreach ($Folder->messages() as $message) {
|
||||
$this->out(String::wrap(' * ' . $message), 1, Shell::VERBOSE);
|
||||
$this->out(CakeText::wrap(' * ' . $message), 1, Shell::VERBOSE);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
@ -226,14 +231,14 @@ class ProjectTask extends AppShell {
|
|||
* and points app/console/cake.php to the right place
|
||||
*
|
||||
* @param string $path Project path.
|
||||
* @return boolean success
|
||||
* @return bool success
|
||||
*/
|
||||
public function consolePath($path) {
|
||||
$File = new File($path . 'Console' . DS . 'cake.php');
|
||||
$contents = $File->read();
|
||||
if (preg_match('/(__CAKE_PATH__)/', $contents, $match)) {
|
||||
$root = strpos(CAKE_CORE_INCLUDE_PATH, '/') === 0 ? " \$ds . '" : "'";
|
||||
$replacement = $root . str_replace(DS, "' . \$ds . '", trim(CAKE_CORE_INCLUDE_PATH, DS)) . "'";
|
||||
$root = strpos(CAKE_CORE_INCLUDE_PATH, '/') === 0 ? " DS . '" : "'";
|
||||
$replacement = $root . str_replace(DS, "' . DS . '", trim(CAKE_CORE_INCLUDE_PATH, DS)) . "'";
|
||||
$result = str_replace($match[0], $replacement, $contents);
|
||||
if ($File->write($result)) {
|
||||
return true;
|
||||
|
|
@ -247,7 +252,7 @@ class ProjectTask extends AppShell {
|
|||
* Generates and writes 'Security.salt'
|
||||
*
|
||||
* @param string $path Project path
|
||||
* @return boolean Success
|
||||
* @return bool Success
|
||||
*/
|
||||
public function securitySalt($path) {
|
||||
$File = new File($path . 'Config' . DS . 'core.php');
|
||||
|
|
@ -267,7 +272,7 @@ class ProjectTask extends AppShell {
|
|||
* Generates and writes 'Security.cipherSeed'
|
||||
*
|
||||
* @param string $path Project path
|
||||
* @return boolean Success
|
||||
* @return bool Success
|
||||
*/
|
||||
public function securityCipherSeed($path) {
|
||||
$File = new File($path . 'Config' . DS . 'core.php');
|
||||
|
|
@ -284,12 +289,29 @@ class ProjectTask extends AppShell {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes cache prefix using app's name
|
||||
*
|
||||
* @param string $dir Path to project
|
||||
* @return bool Success
|
||||
*/
|
||||
public function cachePrefix($dir) {
|
||||
$app = basename($dir);
|
||||
$File = new File($dir . 'Config' . DS . 'core.php');
|
||||
$contents = $File->read();
|
||||
if (preg_match('/(\$prefix = \'myapp_\';)/', $contents, $match)) {
|
||||
$result = str_replace($match[0], '$prefix = \'' . $app . '_\';', $contents);
|
||||
return $File->write($result);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates and writes CAKE_CORE_INCLUDE_PATH
|
||||
*
|
||||
* @param string $path Project path
|
||||
* @param boolean $hardCode Wether or not define calls should be hardcoded.
|
||||
* @return boolean Success
|
||||
* @param bool $hardCode Whether or not define calls should be hardcoded.
|
||||
* @return bool Success
|
||||
*/
|
||||
public function corePath($path, $hardCode = true) {
|
||||
if (dirname($path) !== CAKE_CORE_INCLUDE_PATH) {
|
||||
|
|
@ -309,8 +331,8 @@ class ProjectTask extends AppShell {
|
|||
* Replaces the __CAKE_PATH__ placeholder in the template files.
|
||||
*
|
||||
* @param string $filename The filename to operate on.
|
||||
* @param boolean $hardCode Whether or not the define should be uncommented.
|
||||
* @return boolean Success
|
||||
* @param bool $hardCode Whether or not the define should be uncommented.
|
||||
* @return bool Success
|
||||
*/
|
||||
protected function _replaceCorePath($filename, $hardCode) {
|
||||
$contents = file_get_contents($filename);
|
||||
|
|
@ -318,6 +340,11 @@ class ProjectTask extends AppShell {
|
|||
$root = strpos(CAKE_CORE_INCLUDE_PATH, '/') === 0 ? " DS . '" : "'";
|
||||
$corePath = $root . str_replace(DS, "' . DS . '", trim(CAKE_CORE_INCLUDE_PATH, DS)) . "'";
|
||||
|
||||
$composer = ROOT . DS . APP_DIR . DS . 'Vendor' . DS . 'cakephp' . DS . 'cakephp' . DS . 'lib';
|
||||
if (file_exists($composer)) {
|
||||
$corePath = " ROOT . DS . APP_DIR . DS . 'Vendor' . DS . 'cakephp' . DS . 'cakephp' . DS . 'lib'";
|
||||
}
|
||||
|
||||
$result = str_replace('__CAKE_PATH__', $corePath, $contents, $count);
|
||||
if ($hardCode) {
|
||||
$result = str_replace('//define(\'CAKE_CORE', 'define(\'CAKE_CORE', $result);
|
||||
|
|
@ -325,17 +352,14 @@ class ProjectTask extends AppShell {
|
|||
if (!file_put_contents($filename, $result)) {
|
||||
return false;
|
||||
}
|
||||
if ($count == 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return (bool)$count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables Configure::read('Routing.prefixes') in /app/Config/core.php
|
||||
*
|
||||
* @param string $name Name to use as admin routing
|
||||
* @return boolean Success
|
||||
* @return bool Success
|
||||
*/
|
||||
public function cakeAdmin($name) {
|
||||
$path = (empty($this->configPath)) ? APP . 'Config' . DS : $this->configPath;
|
||||
|
|
@ -346,12 +370,9 @@ class ProjectTask extends AppShell {
|
|||
if ($File->write($result)) {
|
||||
Configure::write('Routing.prefixes', array($name));
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -363,7 +384,7 @@ class ProjectTask extends AppShell {
|
|||
$admin = '';
|
||||
$prefixes = Configure::read('Routing.prefixes');
|
||||
if (!empty($prefixes)) {
|
||||
if (count($prefixes) == 1) {
|
||||
if (count($prefixes) === 1) {
|
||||
return $prefixes[0] . '_';
|
||||
}
|
||||
if ($this->interactive) {
|
||||
|
|
@ -382,16 +403,20 @@ class ProjectTask extends AppShell {
|
|||
}
|
||||
if ($this->interactive) {
|
||||
$this->hr();
|
||||
$this->out(__d('cake_console', 'You need to enable Configure::write(\'Routing.prefixes\',array(\'admin\')) in /app/Config/core.php to use prefix routing.'));
|
||||
$this->out(__d('cake_console', 'You need to enable %s in %s to use prefix routing.',
|
||||
'Configure::write(\'Routing.prefixes\', array(\'admin\'))',
|
||||
'/app/Config/core.php'));
|
||||
$this->out(__d('cake_console', 'What would you like the prefix route to be?'));
|
||||
$this->out(__d('cake_console', 'Example: www.example.com/admin/controller'));
|
||||
while ($admin == '') {
|
||||
$this->out(__d('cake_console', 'Example: %s', 'www.example.com/admin/controller'));
|
||||
while (!$admin) {
|
||||
$admin = $this->in(__d('cake_console', 'Enter a routing prefix:'), null, 'admin');
|
||||
}
|
||||
if ($this->cakeAdmin($admin) !== true) {
|
||||
$this->out(__d('cake_console', '<error>Unable to write to</error> /app/Config/core.php.'));
|
||||
$this->out(__d('cake_console', 'You need to enable Configure::write(\'Routing.prefixes\',array(\'admin\')) in /app/Config/core.php to use prefix routing.'));
|
||||
$this->_stop();
|
||||
$this->out(__d('cake_console', '<error>Unable to write to</error> %s.', '/app/Config/core.php'));
|
||||
$this->out(__d('cake_console', 'You need to enable %s in %s to use prefix routing.',
|
||||
'Configure::write(\'Routing.prefixes\', array(\'admin\'))',
|
||||
'/app/Config/core.php'));
|
||||
return $this->_stop();
|
||||
}
|
||||
return $admin . '_';
|
||||
}
|
||||
|
|
@ -399,23 +424,30 @@ class ProjectTask extends AppShell {
|
|||
}
|
||||
|
||||
/**
|
||||
* get the option parser.
|
||||
* Gets the option parser instance and configures it.
|
||||
*
|
||||
* @return ConsoleOptionParser
|
||||
*/
|
||||
public function getOptionParser() {
|
||||
$parser = parent::getOptionParser();
|
||||
return $parser->description(
|
||||
__d('cake_console', 'Generate a new CakePHP project skeleton.')
|
||||
)->addArgument('name', array(
|
||||
'help' => __d('cake_console', 'Application directory to make, if it starts with "/" the path is absolute.')
|
||||
))->addOption('empty', array(
|
||||
'boolean' => true,
|
||||
'help' => __d('cake_console', 'Create empty files in each of the directories. Good if you are using git')
|
||||
))->addOption('skel', array(
|
||||
'default' => current(App::core('Console')) . 'Templates' . DS . 'skel',
|
||||
'help' => __d('cake_console', 'The directory layout to use for the new application skeleton. Defaults to cake/Console/Templates/skel of CakePHP used to create the project.')
|
||||
));
|
||||
|
||||
$parser->description(
|
||||
__d('cake_console', 'Generate a new CakePHP project skeleton.')
|
||||
)->addArgument('name', array(
|
||||
'help' => __d('cake_console', 'Application directory to make, if it starts with "/" the path is absolute.')
|
||||
))->addOption('empty', array(
|
||||
'boolean' => true,
|
||||
'help' => __d('cake_console', 'Create empty files in each of the directories. Good if you are using git')
|
||||
))->addOption('theme', array(
|
||||
'short' => 't',
|
||||
'help' => __d('cake_console', 'Theme to use when baking code.')
|
||||
))->addOption('skel', array(
|
||||
'default' => current(App::core('Console')) . 'Templates' . DS . 'skel',
|
||||
'help' => __d('cake_console', 'The directory layout to use for the new application skeleton.' .
|
||||
' Defaults to cake/Console/Templates/skel of CakePHP used to create the project.')
|
||||
));
|
||||
|
||||
return $parser;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue