Skip to content

Commit

Permalink
Merge branch '2.0' of https://github.com/cakephp/cakephp into 2.0-exc…
Browse files Browse the repository at this point in the history
…eptionrenderer
  • Loading branch information
Thomas Ploch committed May 16, 2011
2 parents c2089a8 + 4ee4e42 commit ea41915
Show file tree
Hide file tree
Showing 97 changed files with 650 additions and 643 deletions.
2 changes: 1 addition & 1 deletion app/webroot/test.php
Expand Up @@ -75,6 +75,6 @@
die(__d('cake', 'Debug setting does not allow access to this url.')); die(__d('cake', 'Debug setting does not allow access to this url.'));
} }


require_once CAKE_TESTS_LIB . 'CakeTestSuiteDispatcher.php'; require_once CAKE . 'TestSuite' . DS . 'CakeTestSuiteDispatcher.php';


CakeTestSuiteDispatcher::run(); CakeTestSuiteDispatcher::run();
9 changes: 6 additions & 3 deletions lib/Cake/Configure/PhpReader.php
Expand Up @@ -34,9 +34,12 @@ class PhpReader implements ConfigReaderInterface {
/** /**
* Constructor for PHP Config file reading. * Constructor for PHP Config file reading.
* *
* @param string $path The path to read config files from. Defaults to CONFIGS * @param string $path The path to read config files from. Defaults to APP . 'Config' . DS
*/ */
public function __construct($path = CONFIGS) { public function __construct($path = null) {
if (!$path) {
$path = APP . 'Config' . DS;
}
$this->_path = $path; $this->_path = $path;
} }


Expand Down Expand Up @@ -81,4 +84,4 @@ public function read($key) {
} }
return $config; return $config;
} }
} }
10 changes: 5 additions & 5 deletions lib/Cake/Console/Command/AclShell.php
Expand Up @@ -20,7 +20,7 @@
App::uses('DbAcl', 'Model'); App::uses('DbAcl', 'Model');


/** /**
* Shell for ACL management. This console is known to have issues with zend.ze1_compatibility_mode * Shell for ACL management. This console is known to have issues with zend.ze1_compatibility_mode
* being enabled. Be sure to turn it off when using this shell. * being enabled. Be sure to turn it off when using this shell.
* *
* @package cake.console.libs * @package cake.console.libs
Expand Down Expand Up @@ -86,7 +86,7 @@ public function startup() {
$this->args = null; $this->args = null;
return $this->DbConfig->execute(); return $this->DbConfig->execute();
} }
require_once (CONFIGS.'database.php'); require_once (APP . 'Config' . DS . 'database.php');


if (!in_array($this->command, array('initdb'))) { if (!in_array($this->command, array('initdb'))) {
$collection = new ComponentCollection(); $collection = new ComponentCollection();
Expand Down Expand Up @@ -348,13 +348,13 @@ public function initdb() {
*/ */
public function getOptionParser() { public function getOptionParser() {
$parser = parent::getOptionParser(); $parser = parent::getOptionParser();

$type = array( $type = array(
'choices' => array('aro', 'aco'), 'choices' => array('aro', 'aco'),
'required' => true, 'required' => true,
'help' => __d('cake_console', 'Type of node to create.') 'help' => __d('cake_console', 'Type of node to create.')
); );

$parser->description(__d('cake_console', 'A console tool for managing the DbAcl')) $parser->description(__d('cake_console', 'A console tool for managing the DbAcl'))
->addSubcommand('create', array( ->addSubcommand('create', array(
'help' => __d('cake_console', 'Create a new ACL node'), 'help' => __d('cake_console', 'Create a new ACL node'),
Expand Down
16 changes: 8 additions & 8 deletions lib/Cake/Console/Command/ApiShell.php
Expand Up @@ -41,14 +41,14 @@ class ApiShell extends Shell {
*/ */
public function initialize() { public function initialize() {
$this->paths = array_merge($this->paths, array( $this->paths = array_merge($this->paths, array(
'behavior' => LIBS . 'Model' . DS . 'Behavior' . DS, 'behavior' => CAKE . 'Model' . DS . 'Behavior' . DS,
'cache' => LIBS . 'Cache' . DS, 'cache' => CAKE . 'Cache' . DS,
'controller' => LIBS . 'Controller' . DS, 'controller' => CAKE . 'Controller' . DS,
'component' => LIBS . 'Controller' . DS . 'Component' . DS, 'component' => CAKE . 'Controller' . DS . 'Component' . DS,
'helper' => LIBS . 'View' . DS . 'Helper' . DS, 'helper' => CAKE . 'View' . DS . 'Helper' . DS,
'model' => LIBS . 'Model' . DS, 'model' => CAKE . 'Model' . DS,
'view' => LIBS . 'View' . DS, 'view' => CAKE . 'View' . DS,
'core' => LIBS 'core' => CAKE
)); ));
} }


Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Console/Command/ConsoleShell.php
Expand Up @@ -339,7 +339,7 @@ protected function _loadRoutes() {
Router::reload(); Router::reload();
extract(Router::getNamedExpressions()); extract(Router::getNamedExpressions());


if (!@include(CONFIGS . 'routes.php')) { if (!@include(APP . 'Config' . DS . 'routes.php')) {
return false; return false;
} }
Router::parse('/'); Router::parse('/');
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Console/Command/SchemaShell.php
Expand Up @@ -440,7 +440,7 @@ public function getOptionParser() {
); );
$path = array( $path = array(
'help' => __d('cake_console', 'Path to read and write schema.php'), 'help' => __d('cake_console', 'Path to read and write schema.php'),
'default' => CONFIGS . 'Schema' 'default' => APP . 'Config' . 'Schema'
); );
$file = array( $file = array(
'help' => __d('cake_console', 'File name to read and write.'), 'help' => __d('cake_console', 'File name to read and write.'),
Expand Down
5 changes: 3 additions & 2 deletions lib/Cake/Console/Command/Task/ControllerTask.php
Expand Up @@ -36,18 +36,19 @@ class ControllerTask extends BakeTask {
public $tasks = array('Model', 'Test', 'Template', 'DbConfig', 'Project'); public $tasks = array('Model', 'Test', 'Template', 'DbConfig', 'Project');


/** /**
* path to CONTROLLERS directory * path to Controller directory
* *
* @var array * @var array
* @access public * @access public
*/ */
public $path = CONTROLLERS; public $path = null;


/** /**
* Override initialize * Override initialize
* *
*/ */
public function initialize() { public function initialize() {
$this->path = current(App::path('Controller'));
} }


/** /**
Expand Down
12 changes: 10 additions & 2 deletions lib/Cake/Console/Command/Task/ModelTask.php
Expand Up @@ -30,12 +30,12 @@
class ModelTask extends BakeTask { class ModelTask extends BakeTask {


/** /**
* path to MODELS directory * path to Model directory
* *
* @var string * @var string
* @access public * @access public
*/ */
public $path = MODELS; public $path = null;


/** /**
* tasks * tasks
Expand Down Expand Up @@ -69,6 +69,14 @@ class ModelTask extends BakeTask {
*/ */
protected $_validations = array(); protected $_validations = array();


/**
* Override initialize
*
*/
public function initialize() {
$this->path = current(App::path('Model'));
}

/** /**
* Execution method always used for tasks * Execution method always used for tasks
* *
Expand Down
8 changes: 4 additions & 4 deletions lib/Cake/Console/Command/Task/PluginTask.php
Expand Up @@ -28,7 +28,7 @@
class PluginTask extends Shell { class PluginTask extends Shell {


/** /**
* path to CONTROLLERS directory * path to plugins directory
* *
* @var array * @var array
* @access public * @access public
Expand All @@ -41,7 +41,7 @@ class PluginTask extends Shell {
* @return void * @return void
*/ */
function initialize() { function initialize() {
$this->path = APP . 'Plugin' . DS; $this->path = current(App::path('plugins'));
} }


/** /**
Expand Down Expand Up @@ -94,7 +94,7 @@ public function bake($plugin) {
$this->findPath($pathOptions); $this->findPath($pathOptions);
} }
$this->hr(); $this->hr();
$this->out(__d('cake_console', "<info>Plugin Name:</info> %s", $plugin)); $this->out(__d('cake_console', "<info>Plugin Name:</info> %s", $plugin));
$this->out(__d('cake_console', "<info>Plugin Directory:</info> %s", $this->path . $pluginPath)); $this->out(__d('cake_console', "<info>Plugin Directory:</info> %s", $this->path . $pluginPath));
$this->hr(); $this->hr();


Expand Down Expand Up @@ -184,7 +184,7 @@ public function findPath($pathOptions) {
*/ */
public function getOptionParser() { public function getOptionParser() {
$parser = parent::getOptionParser(); $parser = parent::getOptionParser();
return $parser->description(__d('cake_console', return $parser->description(__d('cake_console',
'Create the directory structure, AppModel and AppController classes for a new plugin. ' . 'Create the directory structure, AppModel and AppController classes for a new plugin. ' .
'Can create plugins in any of your bootstrapped plugin paths.' 'Can create plugins in any of your bootstrapped plugin paths.'
))->addArgument('name', array( ))->addArgument('name', array(
Expand Down
12 changes: 6 additions & 6 deletions lib/Cake/Console/Command/Task/ProjectTask.php
Expand Up @@ -82,14 +82,14 @@ public function execute() {
if ($this->securitySalt($path) === true) { if ($this->securitySalt($path) === true) {
$this->out(__d('cake_console', ' * Random hash key created for \'Security.salt\'')); $this->out(__d('cake_console', ' * Random hash key created for \'Security.salt\''));
} else { } else {
$this->err(__d('cake_console', 'Unable to generate random hash for \'Security.salt\', you should change it in %s', CONFIGS . 'core.php')); $this->err(__d('cake_console', 'Unable to generate random hash for \'Security.salt\', you should change it in %s', APP . 'Config' . DS . 'core.php'));
$success = false; $success = false;
} }


if ($this->securityCipherSeed($path) === true) { if ($this->securityCipherSeed($path) === true) {
$this->out(__d('cake_console', ' * Random seed created for \'Security.cipherSeed\'')); $this->out(__d('cake_console', ' * Random seed created for \'Security.cipherSeed\''));
} else { } else {
$this->err(__d('cake_console', 'Unable to generate random seed for \'Security.cipherSeed\', you should change it in %s', CONFIGS . 'core.php')); $this->err(__d('cake_console', 'Unable to generate random seed for \'Security.cipherSeed\', you should change it in %s', APP . 'Config' . DS . 'core.php'));
$success = false; $success = false;
} }


Expand Down Expand Up @@ -202,7 +202,7 @@ function bake($path, $skel = null, $skip = array('empty')) {
public function createHome($dir) { public function createHome($dir) {
$app = basename($dir); $app = basename($dir);
$path = $dir . 'View' . DS . 'pages' . DS; $path = $dir . 'View' . DS . 'pages' . DS;
$source = LIBS . 'Console' . DS . 'templates' . DS .'default' . DS . 'views' . DS . 'home.ctp'; $source = CAKE . 'Console' . DS . 'templates' . DS .'default' . DS . 'views' . DS . 'home.ctp';
include($source); include($source);
return $this->createFile($path.'home.ctp', $output); return $this->createFile($path.'home.ctp', $output);
} }
Expand All @@ -218,7 +218,7 @@ public function consolePath($path) {
$File = new File($path . 'Console' . DS . 'cake.php'); $File = new File($path . 'Console' . DS . 'cake.php');
$contents = $File->read(); $contents = $File->read();
if (preg_match('/(__CAKE_PATH__)/', $contents, $match)) { if (preg_match('/(__CAKE_PATH__)/', $contents, $match)) {
$path = LIBS . 'Console' . DS; $path = CAKE . 'Console' . DS;
$replacement = "'" . str_replace(DS, "' . DIRECTORY_SEPARATOR . '", $path) . "'"; $replacement = "'" . str_replace(DS, "' . DIRECTORY_SEPARATOR . '", $path) . "'";
$result = str_replace($match[0], $replacement, $contents); $result = str_replace($match[0], $replacement, $contents);
if ($File->write($result)) { if ($File->write($result)) {
Expand Down Expand Up @@ -260,7 +260,7 @@ public function securityCipherSeed($path) {
$contents = $File->read(); $contents = $File->read();
if (preg_match('/([\s]*Configure::write\(\'Security.cipherSeed\',[\s\'A-z0-9]*\);)/', $contents, $match)) { if (preg_match('/([\s]*Configure::write\(\'Security.cipherSeed\',[\s\'A-z0-9]*\);)/', $contents, $match)) {
if (!class_exists('Security')) { if (!class_exists('Security')) {
require LIBS . 'Utility' . DS . 'security.php'; require CAKE . 'Utility' . DS . 'security.php';
} }
$string = substr(bin2hex(Security::generateAuthKey()), 0, 30); $string = substr(bin2hex(Security::generateAuthKey()), 0, 30);
$result = str_replace($match[0], "\t" . 'Configure::write(\'Security.cipherSeed\', \''.$string.'\');', $contents); $result = str_replace($match[0], "\t" . 'Configure::write(\'Security.cipherSeed\', \''.$string.'\');', $contents);
Expand Down Expand Up @@ -313,7 +313,7 @@ public function corePath($path) {
* @return boolean Success * @return boolean Success
*/ */
public function cakeAdmin($name) { public function cakeAdmin($name) {
$path = (empty($this->configPath)) ? CONFIGS : $this->configPath; $path = (empty($this->configPath)) ? APP . 'Config' . DS : $this->configPath;
$File = new File($path . 'core.php'); $File = new File($path . 'core.php');
$contents = $File->read(); $contents = $File->read();
if (preg_match('%(\s*[/]*Configure::write\(\'Routing.prefixes\',[\s\'a-z,\)\(]*\);)%', $contents, $match)) { if (preg_match('%(\s*[/]*Configure::write\(\'Routing.prefixes\',[\s\'a-z,\)\(]*\);)%', $contents, $match)) {
Expand Down
7 changes: 4 additions & 3 deletions lib/Cake/Console/Command/Task/ViewTask.php
Expand Up @@ -36,12 +36,12 @@ class ViewTask extends BakeTask {
public $tasks = array('Project', 'Controller', 'DbConfig', 'Template'); public $tasks = array('Project', 'Controller', 'DbConfig', 'Template');


/** /**
* path to VIEWS directory * path to View directory
* *
* @var array * @var array
* @access public * @access public
*/ */
public $path = VIEWS; public $path = null;


/** /**
* Name of the controller being used * Name of the controller being used
Expand Down Expand Up @@ -89,6 +89,7 @@ class ViewTask extends BakeTask {
* *
*/ */
public function initialize() { public function initialize() {
$this->path = current(App::path('View'));
} }


/** /**
Expand Down Expand Up @@ -407,7 +408,7 @@ public function getTemplate($action) {
} }
if (!empty($this->template) && $action != $this->template) { if (!empty($this->template) && $action != $this->template) {
return $this->template; return $this->template;
} }
$template = $action; $template = $action;
$prefixes = Configure::read('Routing.prefixes'); $prefixes = Configure::read('Routing.prefixes');
foreach ((array)$prefixes as $prefix) { foreach ((array)$prefixes as $prefix) {
Expand Down
87 changes: 87 additions & 0 deletions lib/Cake/Console/Command/UpgradeShell.php
Expand Up @@ -338,6 +338,89 @@ public function configure() {
$this->_filesRegexpUpdate($patterns); $this->_filesRegexpUpdate($patterns);
} }


/**
* constants
*
* @access public
* @return void
*/
public function constants() {
$this->_paths = array(
APP
);
if (!empty($this->params['plugin'])) {
$this->_paths = array(App::pluginPath($this->params['plugin']));
}
$patterns = array(
array(
"LIBS -> CAKE",
'/\bLIBS\b/',
'CAKE'
),
array(
"CONFIGS -> APP . 'Config' . DS",
'/\bCONFIGS\b/',
'APP . \'Config\' . DS'
),
array(
"CONTROLLERS -> APP . 'Controller' . DS",
'/\bCONTROLLERS\b/',
'APP . \'Controller\' . DS'
),
array(
"COMPONENTS -> APP . 'Controller' . DS . 'Component' . DS",
'/\bCOMPONENTS\b/',
'APP . \'Controller\' . DS . \'Component\''
),
array(
"MODELS -> APP . 'Model' . DS",
'/\bMODELS\b/',
'APP . \'Model\' . DS'
),
array(
"BEHAVIORS -> APP . 'Model' . DS . 'Behavior' . DS",
'/\bBEHAVIORS\b/',
'APP . \'Model\' . DS . \'Behavior\' . DS'
),
array(
"VIEWS -> APP . 'View' . DS",
'/\bVIEWS\b/',
'APP . \'View\' . DS'
),
array(
"HELPERS -> APP . 'View' . DS . 'Helper' . DS",
'/\bHELPERS\b/',
'APP . \'View\' . DS . \'Helper\' . DS'
),
array(
"LAYOUTS -> APP . 'View' . DS . 'Layouts' . DS",
'/\bLAYOUTS\b/',
'APP . \'View\' . DS . \'Layouts\' . DS'
),
array(
"ELEMENTS -> APP . 'View' . DS . 'Elements' . DS",
'/\bELEMENTS\b/',
'APP . \'View\' . DS . \'Elements\' . DS'
),
array(
"CONSOLE_LIBS -> CAKE . 'Console' . DS",
'/\bCONSOLE_LIBS\b/',
'CAKE . \'Console\' . DS'
),
array(
"CAKE_TESTS_LIB -> CAKE . 'TestSuite' . DS",
'/\bCAKE_TESTS_LIB\b/',
'CAKE . \'TestSuite\' . DS'
),
array(
"CAKE_TESTS -> CAKE . 'Test' . DS",
'/\bCAKE_TESTS\b/',
'CAKE . \'Test\' . DS'
)
);
$this->_filesRegexpUpdate($patterns);
}

/** /**
* Move application php files to where they now should be * Move application php files to where they now should be
* *
Expand Down Expand Up @@ -549,6 +632,10 @@ function getOptionParser() {
->addSubcommand('configure', array( ->addSubcommand('configure', array(
'help' => "Update Configure::read() to Configure::read('debug')", 'help' => "Update Configure::read() to Configure::read('debug')",
'parser' => $subcommandParser 'parser' => $subcommandParser
))
->addSubcommand('constants', array(
'help' => "Replace Obsolete constants",
'parser' => $subcommandParser
)); ));
} }
} }
2 changes: 1 addition & 1 deletion lib/Cake/Console/ShellDispatcher.php
Expand Up @@ -136,7 +136,7 @@ function __bootstrap() {
include_once CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'Console' . DS . 'templates' . DS . 'skel' . DS . 'Config' . DS . 'core.php'; include_once CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'Console' . DS . 'templates' . DS . 'skel' . DS . 'Config' . DS . 'core.php';
App::build(); App::build();
} }
require_once CONSOLE_LIBS . 'ConsoleErrorHandler.php'; require_once CAKE . 'Console' . DS . 'ConsoleErrorHandler.php';
set_exception_handler(array('ConsoleErrorHandler', 'handleException')); set_exception_handler(array('ConsoleErrorHandler', 'handleException'));
set_error_handler(array('ConsoleErrorHandler', 'handleError'), Configure::read('Error.level')); set_error_handler(array('ConsoleErrorHandler', 'handleError'), Configure::read('Error.level'));


Expand Down

0 comments on commit ea41915

Please sign in to comment.