Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch '1.3' into 1.3-console

  • Loading branch information...
commit 982f1615597fea5e088b0fc1d93b390a9e1f0191 2 parents 5b8b992 + c017f80
@AD7six AD7six authored
Showing with 2,475 additions and 786 deletions.
  1. +3 −3 app/config/bootstrap.php
  2. +5 −0 app/config/core.php
  3. +8 −1 app/webroot/test.php
  4. +1 −0  cake/basics.php
  5. +5 −0 cake/bootstrap.php
  6. +134 −115 cake/console/cake.php
  7. +131 −94 cake/console/libs/acl.php
  8. +1 −1  cake/console/libs/api.php
  9. +1 −1  cake/console/libs/bake.php
  10. +2 −2 cake/console/libs/schema.php
  11. +49 −40 cake/console/libs/shell.php
  12. +2 −2 cake/console/libs/tasks/fixture.php
  13. +1 −2  cake/console/libs/tasks/model.php
  14. +4 −4 cake/console/libs/tasks/project.php
  15. +1 −1  cake/console/libs/tasks/view.php
  16. +3 −3 cake/console/libs/templates/default/views/form.ctp
  17. +4 −2 cake/console/libs/templates/default/views/home.ctp
  18. +2 −2 cake/console/libs/templates/default/views/index.ctp
  19. +9 −9 cake/console/libs/templates/default/views/view.ctp
  20. +1 −1  cake/console/libs/templates/skel/app_helper.php
  21. +5 −0 cake/console/libs/templates/skel/config/core.php
  22. +0 −1  cake/console/libs/templates/skel/views/layouts/flash.ctp
  23. +1 −1  cake/console/libs/templates/skel/webroot/css.php
  24. +8 −1 cake/console/libs/templates/skel/webroot/test.php
  25. +3 −12 cake/console/libs/testsuite.php
  26. +1 −1  cake/dispatcher.php
  27. +1 −1  cake/libs/cake_session.php
  28. +8 −8 cake/libs/configure.php
  29. +1 −1  cake/libs/controller/components/acl.php
  30. +7 −7 cake/libs/controller/components/cookie.php
  31. +1 −1  cake/libs/controller/components/request_handler.php
  32. +1 −2  cake/libs/debugger.php
  33. +1 −1  cake/libs/file.php
  34. +1 −1  cake/libs/folder.php
  35. +11 −4 cake/libs/http_socket.php
  36. +3 −2 cake/libs/inflector.php
  37. +3 −3 cake/libs/l10n.php
  38. +4 −1 cake/libs/magic_db.php
  39. +1 −1  cake/libs/model/behaviors/acl.php
  40. +1 −1  cake/libs/model/behaviors/containable.php
  41. +4 −4 cake/libs/model/cake_schema.php
  42. +7 −7 cake/libs/model/datasources/datasource.php
  43. +32 −19 cake/libs/model/datasources/dbo/dbo_mssql.php
  44. +17 −19 cake/libs/model/datasources/dbo/dbo_mysqli.php
  45. +19 −15 cake/libs/model/datasources/dbo/dbo_oracle.php
  46. +4 −2 cake/libs/model/datasources/dbo_source.php
  47. +2 −2 cake/libs/model/model.php
  48. +1 −1  cake/libs/multibyte.php
  49. +4 −3 cake/libs/object.php
  50. +9 −10 cake/libs/router.php
  51. +18 −18 cake/libs/security.php
  52. +1 −1  cake/libs/set.php
  53. +1 −1  cake/libs/validation.php
  54. +3 −3 cake/libs/view/errors/missing_action.ctp
  55. +3 −3 cake/libs/view/errors/missing_component_class.ctp
  56. +2 −2 cake/libs/view/errors/missing_component_file.ctp
  57. +3 −3 cake/libs/view/errors/missing_controller.ctp
  58. +2 −2 cake/libs/view/errors/missing_helper_class.ctp
  59. +4 −5 cake/libs/view/errors/missing_helper_file.ctp
  60. +3 −3 cake/libs/view/errors/missing_layout.ctp
  61. +2 −2 cake/libs/view/errors/missing_model.ctp
  62. +2 −2 cake/libs/view/errors/missing_scaffolddb.ctp
  63. +2 −2 cake/libs/view/errors/missing_table.ctp
  64. +2 −2 cake/libs/view/errors/missing_view.ctp
  65. +2 −2 cake/libs/view/errors/private_action.ctp
  66. +1 −1  cake/libs/view/errors/scaffold_error.ctp
  67. +1 −3 cake/libs/view/helpers/ajax.php
  68. +9 −0 cake/libs/view/helpers/javascript.php
  69. +14 −20 cake/libs/view/helpers/paginator.php
  70. +0 −1  cake/libs/view/helpers/xml.php
  71. +3 −1 cake/libs/view/pages/home.ctp
  72. +2 −2 cake/libs/view/scaffolds/edit.ctp
  73. +2 −2 cake/libs/view/scaffolds/index.ctp
  74. +8 −8 cake/libs/view/scaffolds/view.ctp
  75. +1 −1  cake/libs/view/theme.php
  76. +11 −9 cake/libs/xml.php
  77. +3 −2 cake/tests/cases/basics.test.php
  78. +461 −24 cake/tests/cases/console/cake.test.php
  79. +92 −3 cake/tests/cases/console/libs/acl.test.php
  80. +105 −14 cake/tests/cases/console/libs/shell.test.php
  81. +7 −3 cake/tests/cases/console/libs/tasks/db_config.test.php
  82. +15 −2 cake/tests/cases/console/libs/tasks/fixture.test.php
  83. +26 −5 cake/tests/cases/console/libs/tasks/test.test.php
  84. +3 −3 cake/tests/cases/libs/cake_test_fixture.test.php
  85. +1 −0  cake/tests/cases/libs/controller/components/cookie.test.php
  86. +2 −2 cake/tests/cases/libs/http_socket.test.php
  87. +13 −0 cake/tests/cases/libs/inflector.test.php
  88. +1 −1  cake/tests/cases/libs/l10n.test.php
  89. +3 −14 cake/tests/cases/libs/magic_db.test.php
  90. +61 −58 cake/tests/cases/libs/model/behaviors/containable.test.php
  91. +12 −9 cake/tests/cases/libs/model/behaviors/translate.test.php
  92. +351 −10 cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php
  93. +3 −0  cake/tests/cases/libs/model/datasources/dbo_source.test.php
  94. +11 −1 cake/tests/cases/libs/model/model_delete.test.php
  95. +25 −0 cake/tests/cases/libs/model/model_integration.test.php
  96. +36 −8 cake/tests/cases/libs/model/model_read.test.php
  97. +4 −0 cake/tests/cases/libs/model/model_validation.test.php
  98. +59 −11 cake/tests/cases/libs/model/model_write.test.php
  99. +69 −0 cake/tests/cases/libs/router.test.php
  100. +2 −2 cake/tests/cases/libs/sanitize.test.php
  101. +0 −1  cake/tests/cases/libs/set.test.php
  102. +1 −45 cake/tests/cases/libs/view/helpers/ajax.test.php
  103. +20 −0 cake/tests/cases/libs/view/helpers/cache.test.php
  104. +0 −12 cake/tests/cases/libs/view/helpers/js.test.php
  105. +392 −34 cake/tests/cases/libs/view/helpers/paginator.test.php
  106. +37 −1 cake/tests/cases/libs/view/helpers/xml.test.php
  107. +19 −0 cake/tests/cases/libs/xml.test.php
  108. +1 −1  cake/tests/fixtures/uuid_tree_fixture.php
  109. +0 −1  cake/tests/lib/cake_reporter.php
  110. +2 −0  cake/tests/lib/cake_test_fixture.php
  111. +1 −2  cake/tests/test_app/views/layouts/cache_layout.ctp
  112. +1 −1  cake/tests/test_app/views/layouts/email/text/default.ctp
  113. +3 −1 cake/tests/test_app/views/pages/home.ctp
  114. +3 −1 cake/tests/test_app/views/posts/test_nocache_tags.ctp
View
6 app/config/bootstrap.php
@@ -44,8 +44,8 @@
/**
* As of 1.3, additional rules for the inflector are added below
*
- * Inflector::rule('singular', array('rules' => array(), irregular' => array(), 'uninflected' => array()));
- * Inflector::rule('plural', array('rules' => array(), 'irregular' => array(), 'uninflected' => array()));
+ * Inflector::rules('singular', array('rules' => array(), 'irregular' => array(), 'uninflected' => array()));
+ * Inflector::rules('plural', array('rules' => array(), 'irregular' => array(), 'uninflected' => array()));
*
*/
-?>
+?>
View
5 app/config/core.php
@@ -185,6 +185,11 @@
Configure::write('Acl.classname', 'DbAcl');
Configure::write('Acl.database', 'default');
/**
+ * If you are on PHP 5.3 uncomment this line and correct your server timezone
+ * to fix the date & time related errors.
+ */
+ //date_default_timezone_set('UTC');
+/**
*
* Cache Engine Configuration
* Default settings provided below
View
9 app/webroot/test.php
@@ -24,7 +24,14 @@
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
-error_reporting(E_ALL);
+/**
+ * PHP 5.3 raises many notices in bootstrap.
+ */
+if (!defined('E_DEPRECATED')) {
+ define('E_DEPRECATED', 8192);
+}
+error_reporting(E_ALL & ~E_DEPRECATED);
+
set_time_limit(0);
ini_set('memory_limit','128M');
ini_set('display_errors', 1);
View
1  cake/basics.php
@@ -89,6 +89,7 @@ function config() {
* </code>
*
* @param string $name Filename without the .php part
+ * @deprecated
*/
function uses() {
$args = func_get_args();
View
5 cake/bootstrap.php
@@ -22,6 +22,11 @@
if (!defined('PHP5')) {
define('PHP5', (PHP_VERSION >= 5));
}
+if (!defined('E_DEPRECATED')) {
+ define('E_DEPRECATED', 8192);
+}
+error_reporting(E_ALL & ~E_DEPRECATED);
+
require CORE_PATH . 'cake' . DS . 'basics.php';
$TIME_START = getMicrotime();
require CORE_PATH . 'cake' . DS . 'config' . DS . 'paths.php';
View
249 cake/console/cake.php
@@ -1,7 +1,5 @@
#!/usr/bin/php -q
<?php
-/* SVN FILE: $Id$ */
-
/**
* Command-line code generation utility to automate programmer chores.
*
@@ -26,7 +24,9 @@
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
-
+if (!defined('E_DEPRECATED')) {
+ define('E_DEPRECATED', 8192);
+}
/**
* Shell dispatcher
*
@@ -135,15 +135,21 @@ function ShellDispatcher($args = array()) {
/**
* Constructor
*
- * @param array $args the argv.
+ * The execution of the script is stopped after dispatching the request with
+ * a status code of either 0 or 1 according to the result of the dispatch.
+ *
+ * @param array $args the argv
+ * @return void
+ * @access public
*/
function __construct($args = array()) {
set_time_limit(0);
+
$this->__initConstants();
$this->parseParams($args);
$this->_initEnvironment();
$this->__buildPaths();
- $this->_stop($this->dispatch());
+ $this->_stop($this->dispatch() === false ? 1 : 0);
}
/**
@@ -305,118 +311,134 @@ function clear() {
/**
* Dispatches a CLI request
*
+ * @return boolean
* @access public
*/
function dispatch() {
- if (isset($this->args[0])) {
+ $arg = $this->shiftArgs();
+
+ if (!$arg) {
+ $this->help();
+ return false;
+ }
+ if ($arg == 'help') {
+ $this->help();
+ return true;
+ }
+
+ if (strpos($arg, '.') !== false) {
+ list($plugin, $shell) = explode('.', $arg);
+ } else {
$plugin = null;
- $shell = $this->args[0];
- if (strpos($shell, '.') !== false) {
- list($plugin, $shell) = explode('.', $this->args[0]);
- }
+ $shell = $arg;
+ }
+ $this->shell = $shell;
+ $this->shellName = Inflector::camelize($shell);
+ $this->shellClass = $this->shellName . 'Shell';
- $this->shell = $shell;
- $this->shiftArgs();
- $this->shellName = Inflector::camelize($this->shell);
- $this->shellClass = $this->shellName . 'Shell';
+ $arg = null;
- if ($this->shell === 'help') {
- $this->help();
- } else {
- $loaded = false;
- foreach ($this->shellPaths as $path) {
- $this->shellPath = $path . $this->shell . '.php';
-
- $isPlugin = ($plugin && strpos($path, DS . $plugin . DS . 'vendors' . DS . 'shells' . DS) !== false);
- if (($isPlugin && file_exists($this->shellPath)) || (!$plugin && file_exists($this->shellPath))) {
- $loaded = true;
- break;
- }
- }
+ if (isset($this->args[0])) {
+ $arg = $this->args[0];
+ $this->shellCommand = Inflector::variable($arg);
+ }
- if ($loaded) {
- if (!class_exists('Shell')) {
- require CONSOLE_LIBS . 'shell.php';
- }
- require $this->shellPath;
- if (class_exists($this->shellClass)) {
- $command = null;
- if (isset($this->args[0])) {
- $command = $this->args[0];
- }
- $this->shellCommand = Inflector::variable($command);
- $shell = new $this->shellClass($this);
-
- if (strtolower(get_parent_class($shell)) == 'shell') {
- $shell->initialize();
- $shell->loadTasks();
-
- foreach ($shell->taskNames as $task) {
- if (strtolower(get_parent_class($shell)) == 'shell') {
- $shell->{$task}->initialize();
- $shell->{$task}->loadTasks();
- }
- }
-
- $task = Inflector::camelize($command);
- if (in_array($task, $shell->taskNames)) {
- $this->shiftArgs();
- $shell->{$task}->startup();
- if (isset($this->args[0]) && $this->args[0] == 'help') {
- if (method_exists($shell->{$task}, 'help')) {
- $shell->{$task}->help();
- $this->_stop();
- } else {
- $this->help();
- }
- }
- return $shell->{$task}->execute();
- }
- }
+ $Shell = $this->_getShell($plugin);
- $classMethods = get_class_methods($shell);
+ if (!$Shell) {
+ $title = sprintf(__('Error: Class %s could not be loaded.', true), $this->shellClass);
+ $this->stderr($title . "\n");
+ return false;
+ }
- $privateMethod = $missingCommand = false;
- if ((in_array($command, $classMethods) || in_array(strtolower($command), $classMethods)) && strpos($command, '_', 0) === 0) {
- $privateMethod = true;
- }
+ $methods = array();
- if (!in_array($command, $classMethods) && !in_array(strtolower($command), $classMethods)) {
- $missingCommand = true;
- }
+ if (is_a($Shell, 'Shell')) {
+ $Shell->initialize();
+ $Shell->loadTasks();
- $protectedCommands = array(
- 'initialize','in','out','err','hr',
- 'createfile', 'isdir','copydir','object','tostring',
- 'requestaction','log','cakeerror', 'shelldispatcher',
- '__initconstants','__initenvironment','__construct',
- 'dispatch','__bootstrap','getinput','stdout','stderr','parseparams','shiftargs'
- );
+ foreach ($Shell->taskNames as $task) {
+ if (is_a($Shell->{$task}, 'Shell')) {
+ $Shell->{$task}->initialize();
+ $Shell->{$task}->loadTasks();
+ }
+ }
- if (in_array(strtolower($command), $protectedCommands)) {
- $missingCommand = true;
- }
+ $task = Inflector::camelize($arg);
- if ($missingCommand && method_exists($shell, 'main')) {
- $shell->startup();
- return $shell->main();
- } elseif (!$privateMethod && method_exists($shell, $command)) {
- $this->shiftArgs();
- $shell->startup();
- return $shell->{$command}();
- } else {
- $this->stderr("Unknown {$this->shellName} command '$command'.\nFor usage, try 'cake {$this->shell} help'.\n\n");
- }
+ if (in_array($task, $Shell->taskNames)) {
+ $this->shiftArgs();
+ $Shell->{$task}->startup();
+
+ if (isset($this->args[0]) && $this->args[0] == 'help') {
+ if (method_exists($Shell->{$task}, 'help')) {
+ $Shell->{$task}->help();
} else {
- $this->stderr('Class '.$this->shellClass.' could not be loaded');
+ $this->help();
}
- } else {
- $this->help();
+ return true;
}
+ return $Shell->{$task}->execute();
+ }
+ $methods = array_diff(get_class_methods('Shell'), array('help'));
+ }
+ $methods = array_diff(get_class_methods($Shell), $methods);
+ $added = in_array(strtolower($arg), array_map('strtolower', $methods));
+ $private = $arg[0] == '_' && method_exists($Shell, $arg);
+
+ if (!$private) {
+ if ($added) {
+ $this->shiftArgs();
+ $Shell->startup();
+ return $Shell->{$arg}();
+ }
+ if (method_exists($Shell, 'main')) {
+ $Shell->startup();
+ return $Shell->main();
+ }
+ }
+
+ $title = sprintf(__('Error: Unknown %1$s command %2$s.', true), $this->shellName, $arg);
+ $message = sprintf(__('For usage try `cake %s help`', true), $this->shell);
+ $this->stderr($title . "\n" . $message . "\n");
+ return false;
+ }
+/**
+ * Get shell to use, either plugin shell or application shell
+ *
+ * All paths in the shellPaths property are searched.
+ * shell, shellPath and shellClass properties are taken into account.
+ *
+ * @param string $plugin Optionally the name of a plugin
+ * @return mixed False if no shell could be found or an object on success
+ * @access protected
+ */
+ function _getShell($plugin = null) {
+ foreach ($this->shellPaths as $path) {
+ $this->shellPath = $path . $this->shell . '.php';
+ $pluginShellPath = DS . $plugin . DS . 'vendors' . DS . 'shells' . DS;
+
+ if ((strpos($path, $pluginShellPath) !== false || !$plugin) && file_exists($this->shellPath)) {
+ $loaded = true;
+ break;
}
- } else {
- $this->help();
}
+ if (!isset($loaded)) {
+ return false;
+ }
+
+ if (!class_exists('Shell')) {
+ require CONSOLE_LIBS . 'shell.php';
+ }
+
+ if (!class_exists($this->shellClass)) {
+ require $this->shellPath;
+ }
+ if (!class_exists($this->shellClass)) {
+ return false;
+ }
+ $Shell = new $this->shellClass($this);
+ return $Shell;
}
/**
@@ -475,7 +497,7 @@ function stdout($string, $newline = true) {
* @access public
*/
function stderr($string) {
- fwrite($this->stderr, 'Error: '. $string);
+ fwrite($this->stderr, $string);
}
/**
@@ -486,13 +508,15 @@ function stderr($string) {
*/
function parseParams($params) {
$this->__parseParams($params);
-
$defaults = array('app' => 'app', 'root' => dirname(dirname(dirname(__FILE__))), 'working' => null, 'webroot' => 'webroot');
-
$params = array_merge($defaults, array_intersect_key($this->params, $defaults));
-
- $isWin = array_filter(array_map('strpos', $params, array('\\')));
-
+ $isWin = false;
+ foreach ($defaults as $default => $value) {
+ if (strpos($params[$default], '\\') !== false) {
+ $isWin = true;
+ break;
+ }
+ }
$params = str_replace('\\', '/', $params);
if (!empty($params['working']) && (!isset($this->args[0]) || isset($this->args[0]) && $this->args[0]{0} !== '.')) {
@@ -504,7 +528,7 @@ function parseParams($params) {
}
}
- if ($params['app'][0] == '/' || preg_match('/([a-zA-Z])(:)/i', $params['app'], $matches)) {
+ if ($params['app'][0] == '/' || preg_match('/([a-z])(:)/i', $params['app'], $matches)) {
$params['root'] = dirname($params['app']);
} elseif (strpos($params['app'], '/')) {
$params['root'] .= '/' . dirname($params['app']);
@@ -521,7 +545,7 @@ function parseParams($params) {
}
/**
- * Helper for recursively paraing params
+ * Helper for recursively parsing params
*
* @return array params
* @access private
@@ -555,16 +579,11 @@ function __parseParams($params) {
/**
* Removes first argument and shifts other arguments up
*
- * @return boolean False if there are no arguments
+ * @return mixed Null if there are no arguments otherwise the shifted argument
* @access public
*/
function shiftArgs() {
- if (empty($this->args)) {
- return false;
- }
- unset($this->args[0]);
- $this->args = array_values($this->args);
- return true;
+ return array_shift($this->args);
}
/**
@@ -603,6 +622,7 @@ function help() {
} else {
sort($shells);
foreach ($shells as $shell) {
+
if ($shell !== 'shell.php') {
$this->stdout("\t " . str_replace('.php', '', $shell));
}
@@ -612,7 +632,6 @@ function help() {
}
$this->stdout("\nTo run a command, type 'cake shell_name [args]'");
$this->stdout("To get help on a specific command, type 'cake shell_name help'");
- $this->_stop();
}
/**
View
225 cake/console/libs/acl.php
@@ -137,52 +137,29 @@ function main() {
* @access public
*/
function create() {
-
$this->_checkArgs(3, 'create');
$this->checkNodeType();
extract($this->__dataVars());
$class = ucfirst($this->args[0]);
- $object = new $class();
-
- if (preg_match('/^([\w]+)\.(.*)$/', $this->args[1], $matches) && count($matches) == 3) {
- $parent = array(
- 'model' => $matches[1],
- 'foreign_key' => $matches[2],
- );
- } else {
- $parent = $this->args[1];
- }
+ $parent = $this->parseIdentifier($this->args[1]);
if (!empty($parent) && $parent != '/' && $parent != 'root') {
- @$parent = $object->node($parent);
- if (empty($parent)) {
- $this->err(sprintf(__('Could not find parent node using reference "%s"', true), $this->args[1]));
- return;
- } else {
- $parent = Set::extract($parent, "0.{$class}.id");
- }
+ $parent = $this->_getNodeId($class, $parent);
} else {
$parent = null;
}
- if (preg_match('/^([\w]+)\.(.*)$/', $this->args[2], $matches) && count($matches) == 3) {
- $data = array(
- 'model' => $matches[1],
- 'foreign_key' => $matches[2],
- );
- } else {
- if (!($this->args[2] == '/')) {
- $data = array('alias' => $this->args[2]);
- } else {
- $this->error(__('/ can not be used as an alias!', true), __('\t/ is the root, please supply a sub alias', true));
- }
+ $data = $this->parseIdentifier($this->args[2]);
+ if (is_string($data) && $data != '/') {
+ $data = array('alias' => $data);
+ } elseif (is_string($data)) {
+ $this->error(__('/ can not be used as an alias!', true), __("\t/ is the root, please supply a sub alias", true));
}
$data['parent_id'] = $parent;
- $object->create();
-
- if ($object->save($data)) {
+ $this->Acl->{$class}->create();
+ if ($this->Acl->{$class}->save($data)) {
$this->out(sprintf(__("New %s '%s' created.\n", true), $class, $this->args[2]), true);
} else {
$this->err(sprintf(__("There was a problem creating a new %s '%s'.", true), $class, $this->args[2]));
@@ -198,7 +175,11 @@ function delete() {
$this->_checkArgs(2, 'delete');
$this->checkNodeType();
extract($this->__dataVars());
- if (!$this->Acl->{$class}->delete($this->args[1])) {
+
+ $identifier = $this->parseIdentifier($this->args[1]);
+ $nodeId = $this->_getNodeId($class, $identifier);
+
+ if (!$this->Acl->{$class}->delete($nodeId)) {
$this->error(__("Node Not Deleted", true), sprintf(__("There was an error deleting the %s. Check that the node exists", true), $class) . ".\n");
}
$this->out(sprintf(__("%s deleted", true), $class) . ".\n", true);
@@ -213,10 +194,13 @@ function setParent() {
$this->_checkArgs(3, 'setParent');
$this->checkNodeType();
extract($this->__dataVars());
+ $target = $this->parseIdentifier($this->args[1]);
+ $parent = $this->parseIdentifier($this->args[2]);
+
$data = array(
$class => array(
- 'id' => $this->args[1],
- 'parent_id' => $this->args[2]
+ 'id' => $this->_getNodeId($class, $target),
+ 'parent_id' => $this->_getNodeId($class, $parent)
)
);
$this->Acl->{$class}->create();
@@ -378,64 +362,81 @@ function initdb() {
* @access public
*/
function help() {
- $head = __("Usage: cake acl <command> <arg1> <arg2>...", true) . "\n";
+ $head = "-----------------------------------------------\n";
+ $head .= __("Usage: cake acl <command> <arg1> <arg2>...", true) . "\n";
$head .= "-----------------------------------------------\n";
- $head .= __("Commands:", true) . "\n\n";
+ $head .= __("Commands:", true) . "\n";
$commands = array(
- 'create' => "\tcreate aro|aco <parent> <node>\n" .
- "\t\t" . __("Creates a new ACL object <node> under the parent specified by <parent>, an id/alias.", true) . "\n" .
- "\t\t" . __("The <parent> and <node> references can be in one of the following formats:", true) . "\n" .
- "\t\t\t- " . __("<model>.<id> - The node will be bound to a specific record of the given model", true) . "\n" .
- "\t\t\t- " . __("<alias> - The node will be given a string alias (or path, in the case of <parent>),", true) . "\n" .
- "\t\t\t " . __("i.e. 'John'. When used with <parent>, this takes the form of an alias path,", true) . "\n" .
- "\t\t\t " . __("i.e. <group>/<subgroup>/<parent>.", true) . "\n" .
- "\t\t" . __("To add a node at the root level, enter 'root' or '/' as the <parent> parameter.", true) . "\n",
-
- 'delete' => "\tdelete aro|aco <node>\n" .
- "\t\t" . __("Deletes the ACL object with the given <node> reference (see 'create' for info on node references).", true) . "\n",
-
- 'setparent' => "\tsetParent aro|aco <node> <parent>\n" .
- "\t\t" . __("Moves the ACL object specified by <node> beneath the parent ACL object specified by <parent>.", true) . "\n" .
- "\t\t" . __("To identify the node and parent, use the row id.", true) . "\n",
-
- 'getpath' => "\tgetPath aro|aco <node>\n" .
- "\t\t" . __("Returns the path to the ACL object specified by <node>. This command", true) . "\n" .
- "\t\t" . __("is useful in determining the inhertiance of permissions for a certain", true) . "\n" .
- "\t\t" . __("object in the tree.", true) . "\n" .
- "\t\t" . __("For more detailed parameter usage info, see help for the 'create' command.", true) . "\n",
-
- 'check' => "\tcheck <aro_id> <aco_id> [<aco_action>] " . __("or", true) . " all\n" .
- "\t\t" . __("Use this command to check ACL permissions.", true) . "\n" .
- "\t\t" . __("For more detailed parameter usage info, see help for the 'create' command.", true) . "\n",
-
- 'grant' => "\tgrant <aro_id> <aco_id> [<aco_action>] " . __("or", true) . " all\n" .
- "\t\t" . __("Use this command to grant ACL permissions. Once executed, the ARO", true) . "\n" .
- "\t\t" . __("specified (and its children, if any) will have ALLOW access to the", true) . "\n" .
- "\t\t" . __("specified ACO action (and the ACO's children, if any).", true) . "\n" .
- "\t\t" . __("For more detailed parameter usage info, see help for the 'create' command.", true) . "\n",
-
- 'deny' => "\tdeny <aro_id> <aco_id> [<aco_action>]" . __("or", true) . " all\n" .
- "\t\t" . __("Use this command to deny ACL permissions. Once executed, the ARO", true) . "\n" .
- "\t\t" . __("specified (and its children, if any) will have DENY access to the", true) . "\n" .
- "\t\t" . __("specified ACO action (and the ACO's children, if any).", true) . "\n" .
- "\t\t" . __("For more detailed parameter usage info, see help for the 'create' command.", true) . "\n",
-
- 'inherit' => "\tinherit <aro_id> <aco_id> [<aco_action>]" . __("or", true) . " all\n" .
- "\t\t" . __("Use this command to force a child ARO object to inherit its", true) . "\n" .
- "\t\t" . __("permissions settings from its parent.", true) . "\n" .
- "\t\t" . __("For more detailed parameter usage info, see help for the 'create' command.", true) . "\n",
-
- 'view' => "\tview aro|aco [<node>]\n" .
- "\t\t" . __("The view command will return the ARO or ACO tree. The optional", true) . "\n" .
- "\t\t" . __("id/alias parameter allows you to return only a portion of the requested tree.", true) . "\n" .
- "\t\t" . __("For more detailed parameter usage info, see help for the 'create' command.", true) . "\n",
-
- 'initdb' => "\tinitdb\n".
- "\t\t" . __("Uses this command : cake schema run create DbAcl", true) . "\n",
-
- 'help' => "\thelp [<command>]\n" .
- "\t\t" . __("Displays this help message, or a message on a specific command.", true) . "\n"
+ 'create' => "create aro|aco <parent> <node>\n" .
+ "\t" . __("Creates a new ACL object <node> under the parent", true) . "\n" .
+ "\t" . __("specified by <parent>, an id/alias.", true) . "\n" .
+ "\t" . __("The <parent> and <node> references can be", true) . "\n" .
+ "\t" . __("in one of the following formats:", true) . "\n\n" .
+ "\t\t- " . __("<model>.<id> - The node will be bound to a", true) . "\n" .
+ "\t\t" . __("specific record of the given model.", true) . "\n\n" .
+ "\t\t- " . __("<alias> - The node will be given a string alias,", true) . "\n" .
+ "\t\t" . __(" (or path, in the case of <parent>)", true) . "\n" .
+ "\t\t " . __("i.e. 'John'. When used with <parent>,", true) . "\n" .
+ "\t\t" . __("this takes the form of an alias path,", true) . "\n" .
+ "\t\t " . __("i.e. <group>/<subgroup>/<parent>.", true) . "\n\n" .
+ "\t" . __("To add a node at the root level,", true) . "\n" .
+ "\t" . __("enter 'root' or '/' as the <parent> parameter.", true) . "\n",
+
+ 'delete' => "delete aro|aco <node>\n" .
+ "\t" . __("Deletes the ACL object with the given <node> reference", true) . "\n" .
+ "\t" . __("For more detailed parameter usage info,", true) . "\n" .
+ "\t" . __("see help for the 'create' command.", true),
+
+ 'setparent' => "setParent aro|aco <node> <parent>\n" .
+ "\t" . __("Moves the ACL object specified by <node> beneath", true) . "\n" .
+ "\t" . __("the parent ACL object specified by <parent>.", true) . "\n" .
+ "\t" . __("For more detailed parameter usage info,", true) . "\n" .
+ "\t" . __("see help for the 'create' command.", true),
+
+ 'getpath' => "getPath aro|aco <node>\n" .
+ "\t" . __("Returns the path to the ACL object specified by <node>. This command", true) . "\n" .
+ "\t" . __("is useful in determining the inhertiance of permissions for a certain", true) . "\n" .
+ "\t" . __("object in the tree.", true) . "\n" .
+ "\t" . __("For more detailed parameter usage info,", true) . "\n" .
+ "\t" . __("see help for the 'create' command.", true),
+
+ 'check' => "check <aro_id> <aco_id> [<aco_action>] " . __("or", true) . " all\n" .
+ "\t" . __("Use this command to check ACL permissions.", true) . "\n" .
+ "\t" . __("For more detailed parameter usage info,", true) . "\n" .
+ "\t" . __("see help for the 'create' command.", true),
+
+ 'grant' => "grant <aro_id> <aco_id> [<aco_action>] " . __("or", true) . " all\n" .
+ "\t" . __("Use this command to grant ACL permissions. Once executed, the ARO", true) . "\n" .
+ "\t" . __("specified (and its children, if any) will have ALLOW access to the", true) . "\n" .
+ "\t" . __("specified ACO action (and the ACO's children, if any).", true) . "\n" .
+ "\t" . __("For more detailed parameter usage info,", true) . "\n" .
+ "\t" . __("see help for the 'create' command.", true),
+
+ 'deny' => "deny <aro_id> <aco_id> [<aco_action>]" . __("or", true) . " all\n" .
+ "\t" . __("Use this command to deny ACL permissions. Once executed, the ARO", true) . "\n" .
+ "\t" . __("specified (and its children, if any) will have DENY access to the", true) . "\n" .
+ "\t" . __("specified ACO action (and the ACO's children, if any).", true) . "\n" .
+ "\t" . __("For more detailed parameter usage info,", true) . "\n" .
+ "\t" . __("see help for the 'create' command.", true),
+
+ 'inherit' => "inherit <aro_id> <aco_id> [<aco_action>]" . __("or", true) . " all\n" .
+ "\t" . __("Use this command to force a child ARO object to inherit its", true) . "\n" .
+ "\t" . __("permissions settings from its parent.", true) . "\n" .
+ "\t" . __("For more detailed parameter usage info,", true) . "\n" .
+ "\t" . __("see help for the 'create' command.", true),
+
+ 'view' => "view aro|aco [<node>]\n" .
+ "\t" . __("The view command will return the ARO or ACO tree.", true) . "\n" .
+ "\t" . __("The optional id/alias parameter allows you to return\n\tonly a portion of the requested tree.", true) . "\n" .
+ "\t" . __("For more detailed parameter usage info,", true) . "\n" .
+ "\t" . __("see help for the 'create' command.", true),
+
+ 'initdb' => "initdb\n".
+ "\t" . __("Uses this command : cake schema run create DbAcl", true),
+
+ 'help' => "help [<command>]\n" .
+ "\t" . __("Displays this help message, or a message on a specific command.", true)
);
$this->out($head);
@@ -443,8 +444,8 @@ function help() {
foreach ($commands as $cmd) {
$this->out("{$cmd}\n\n");
}
- } elseif (isset($commands[low($this->args[0])])) {
- $this->out($commands[low($this->args[0])] . "\n\n");
+ } elseif (isset($commands[strtolower($this->args[0])])) {
+ $this->out($commands[strtolower($this->args[0])] . "\n\n");
} else {
$this->out(sprintf(__("Command '%s' not found", true), $this->args[0]));
}
@@ -477,7 +478,7 @@ function nodeExists() {
return false;
}
extract($this->__dataVars($this->args[0]));
- $key = (ife(is_numeric($this->args[1]), $secondary_id, 'alias'));
+ $key = is_numeric($this->args[1]) ? $secondary_id : 'alias';
$conditions = array($class . '.' . $key => $this->args[1]);
$possibility = $this->Acl->{$class}->find('all', compact('conditions'));
if (empty($possibility)) {
@@ -487,6 +488,42 @@ function nodeExists() {
}
/**
+ * Parse an identifier into Model.foriegnKey or an alias.
+ * Takes an identifier determines its type and returns the result as used by other methods.
+ *
+ * @param string $identifier Identifier to parse
+ * @return mixed a string for aliases, and an array for model.foreignKey
+ **/
+ function parseIdentifier($identifier) {
+ if (preg_match('/^([\w]+)\.(.*)$/', $identifier, $matches)) {
+ return array(
+ 'model' => $matches[1],
+ 'foreign_key' => $matches[2],
+ );
+ }
+ return $identifier;
+ }
+
+/**
+ * Get the node for a given identifier. $identifier can either be a string alias
+ * or an array of properties to use in AcoNode::node()
+ *
+ * @param string $class Class type you want (Aro/Aco)
+ * @param mixed $identifier A mixed identifier for finding the node.
+ * @return int Integer of NodeId. Will trigger an error if nothing is found.
+ **/
+ function _getNodeId($class, $identifier) {
+ $node = $this->Acl->{$class}->node($identifier);
+ if (empty($node)) {
+ if (is_array($identifier)) {
+ $identifier = var_export($identifier, true);
+ }
+ $this->error(sprintf(__('Could not find node using reference "%s"', true), $identifier));
+ }
+ return Set::extract($node, "0.{$class}.id");
+ }
+
+/**
* get params for standard Acl methods
*
* @return array aro, aco, action
@@ -533,7 +570,7 @@ function __dataVars($type = null) {
}
$vars = array();
$class = ucwords($type);
- $vars['secondary_id'] = ife(strtolower($class) == 'aro', 'foreign_key', 'object_id');
+ $vars['secondary_id'] = (strtolower($class) == 'aro') ? 'foreign_key' : 'object_id';
$vars['data_name'] = $type;
$vars['table_name'] = $type . 's';
$vars['class'] = $class;
View
2  cake/console/libs/api.php
@@ -47,7 +47,7 @@ class ApiShell extends Shell {
*
* @access public
*/
- function initialize () {
+ function initialize() {
$this->paths = array_merge($this->paths, array(
'behavior' => LIBS . 'model' . DS . 'behaviors' . DS,
'cache' => LIBS . 'cache' . DS,
View
2  cake/console/libs/bake.php
@@ -157,7 +157,7 @@ function all() {
$object = new $model();
$modelExists = true;
} else {
- App::import('Model');
+ App::import('Model', 'Model', false);
$object = new Model(array('name' => $name, 'ds' => $this->connection));
}
View
4 cake/console/libs/schema.php
@@ -27,7 +27,7 @@
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
App::import('File');
-App::import('Model', 'CakeSchema');
+App::import('Model', 'CakeSchema', false);
/**
* Schema is a command-line database management utility for automating programmer chores.
@@ -208,7 +208,7 @@ function dump() {
}
}
$db =& ConnectionManager::getDataSource($this->Schema->connection);
- $contents = "#". $Schema->name ." sql generated on: " . date('Y-m-d H:i:s') . " : ". time()."\n\n";
+ $contents = "#" . $Schema->name . " sql generated on: " . date('Y-m-d H:i:s') . " : " . time() . "\n\n";
$contents .= $db->dropSchema($Schema) . "\n\n". $db->createSchema($Schema);
if ($write) {
if (strpos($write, '.sql') === false) {
View
89 cake/console/libs/shell.php
@@ -320,7 +320,7 @@ function loadTasks() {
}
if (!isset($this->{$taskName})) {
- $this->err("Task '".$taskName."' could not be loaded");
+ $this->err("Task '" . $taskName . "' could not be loaded");
$this->_stop();
}
}
@@ -363,69 +363,78 @@ function in($prompt, $options = null, $default = null) {
}
/**
- * Outputs to the stdout filehandle.
+ * Outputs a single or multiple messages to stdout.
*
- * @param string $string String to output.
- * @param boolean $newline If true, the outputs gets an added newline.
+ * @param mixed $message A string or a an array of strings to output
+ * @param mixed $after Appended to message, if true a newline is used
* @access public
*/
- function out($string, $newline = true) {
- if (is_array($string)) {
- $str = '';
- foreach ($string as $message) {
- $str .= $message ."\n";
- }
- $string = $str;
+ function out($message, $after = true) {
+ if (is_array($message)) {
+ $message = implode($this->nl(), $message);
}
- return $this->Dispatch->stdout($string, $newline);
+ $this->Dispatch->stdout($message . $this->nl($after), false);
}
/**
- * Outputs to the stderr filehandle.
+ * Outputs a single or multiple error messages to stderr.
*
- * @param string $string Error text to output.
+ * @param mixed $message A string or a an array of strings to output
+ * @param mixed $after Appended to message, if true a newline is used
* @access public
*/
- function err($string) {
- if (is_array($string)) {
- $str = '';
- foreach ($string as $message) {
- $str .= $message ."\n";
- }
- $string = $str;
+ function err($message, $after = true) {
+ if (is_array($message)) {
+ $message = implode($this->nl(), $message);
}
- return $this->Dispatch->stderr($string."\n");
+ $this->Dispatch->stderr($message . $this->nl($after));
}
/**
- * Outputs a series of minus characters to the standard output, acts as a visual separator.
+ * Returns a single or multiple linefeeds sequences.
*
- * @param boolean $newline If true, the outputs gets an added newline.
+ * @param mixed $format If true returns a linefeed sequence, if false null,
+ * if a string is given that is returned,
+ * if an integer is given it is used as a multiplier to return multiple linefeed sequences
* @access public
+ * @return string
*/
- function hr($newline = false) {
- if ($newline) {
- $this->out("\n");
+ function nl($format = true) {
+ if (is_string($format)) {
+ return $format . "\n";
}
- $this->out('---------------------------------------------------------------');
- if ($newline) {
- $this->out("\n");
+ if (is_int($format)) {
+ return str_repeat("\n", $format);
}
+ return $format ? "\n" : null;
}
/**
- * Displays a formatted error message and exits the application
+ * Outputs a series of minus characters to the standard output, acts as a visual separator.
*
- * @param string $title Title of the error message
- * @param string $msg Error message
+ * @param mixed $surround If true, the outputs gets surrounded by newlines.
* @access public
*/
- function error($title, $msg) {
- $out = "$title\n";
- $out .= "$msg\n";
- $out .= "\n";
- $this->err($out);
- $this->_stop();
+ function hr($surround = false) {
+ $this->out(null, $surround);
+ $this->out('---------------------------------------------------------------');
+ $this->out(null, $surround);
+ }
+/**
+ * Displays a formatted error message
+ * and exits the application with status code 1
+ *
+ * @param string $title Title of the error
+ * @param string $message An optional error message
+ * @access public
+ */
+ function error($title, $message = null) {
+ $this->err(sprintf(__('Error: %s', true), $title));
+
+ if (!empty($message)) {
+ $this->err($message);
+ }
+ $this->_stop(1);
}
/**
@@ -466,7 +475,7 @@ function createFile ($path, $contents) {
}
}
if (!class_exists('File')) {
- uses('file');
+ require LIBS . 'file.php';
}
if ($File = new File($path, true)) {
View
4 cake/console/libs/tasks/fixture.php
@@ -74,7 +74,7 @@ function __construct(&$dispatch) {
parent::__construct($dispatch);
$this->path = $this->params['working'] . DS . 'tests' . DS . 'fixtures' . DS;
if (!class_exists('CakeSchema')) {
- App::import('Model', 'CakeSchema');
+ App::import('Model', 'CakeSchema', false);
}
}
@@ -384,7 +384,7 @@ function _getRecordsFromTable($modelName, $useTable = null) {
while (!$condition) {
$condition = $this->in($prompt, null, 'WHERE 1=1 LIMIT 10');
}
- App::import('Core', 'Model');
+ App::import('Model', 'Model', false);
$modelObject =& new Model(array('name' => $modelName, 'table' => $useTable, 'ds' => $this->connection));
$records = $modelObject->find('all', array(
'conditions' => $condition,
View
3  cake/console/libs/tasks/model.php
@@ -20,7 +20,7 @@
* @since CakePHP(tm) v 1.2
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
-App::import('Model', 'ConnectionManager');
+App::import('Model', 'Model', false);
/**
* Task class for creating and updating model files.
@@ -82,7 +82,6 @@ class ModelTask extends Shell {
* @return void
**/
function startup() {
- App::import('Core', 'Model');
parent::startup();
}
View
8 cake/console/libs/tasks/project.php
@@ -155,7 +155,7 @@ function bake($path, $skel = null, $skip = array('empty')) {
$this->out(sprintf(__("Created: %s in %s", true), $app, $path));
$this->hr();
} else {
- $this->err(" '".$app."' could not be created properly");
+ $this->err(" '" . $app . "' could not be created properly");
return false;
}
@@ -200,7 +200,7 @@ function securitySalt($path) {
$contents = $File->read();
if (preg_match('/([\\t\\x20]*Configure::write\\(\\\'Security.salt\\\',[\\t\\x20\'A-z0-9]*\\);)/', $contents, $match)) {
if (!class_exists('Security')) {
- uses('Security');
+ require LIBS . 'security.php';
}
$string = Security::generateAuthKey();
$result = str_replace($match[0], "\t" . 'Configure::write(\'Security.salt\', \''.$string.'\');', $contents);
@@ -224,7 +224,7 @@ function corePath($path) {
$File =& new File($path . 'webroot' . DS . 'index.php');
$contents = $File->read();
if (preg_match('/([\\t\\x20]*define\\(\\\'CAKE_CORE_INCLUDE_PATH\\\',[\\t\\x20\'A-z0-9]*\\);)/', $contents, $match)) {
- $result = str_replace($match[0], "\t\tdefine('CAKE_CORE_INCLUDE_PATH', '".CAKE_CORE_INCLUDE_PATH."');", $contents);
+ $result = str_replace($match[0], "\t\tdefine('CAKE_CORE_INCLUDE_PATH', '" . CAKE_CORE_INCLUDE_PATH . "');", $contents);
if (!$File->write($result)) {
return false;
}
@@ -235,7 +235,7 @@ function corePath($path) {
$File =& new File($path . 'webroot' . DS . 'test.php');
$contents = $File->read();
if (preg_match('/([\\t\\x20]*define\\(\\\'CAKE_CORE_INCLUDE_PATH\\\',[\\t\\x20\'A-z0-9]*\\);)/', $contents, $match)) {
- $result = str_replace($match[0], "\t\tdefine('CAKE_CORE_INCLUDE_PATH', '".CAKE_CORE_INCLUDE_PATH."');", $contents);
+ $result = str_replace($match[0], "\t\tdefine('CAKE_CORE_INCLUDE_PATH', '" . CAKE_CORE_INCLUDE_PATH . "');", $contents);
if (!$File->write($result)) {
return false;
}
View
2  cake/console/libs/tasks/view.php
@@ -20,7 +20,7 @@
* @since CakePHP(tm) v 1.2
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
-App::import('Core', 'Controller');
+App::import('Controller', 'Controller', false);
/**
* Task class for creating and updating view files.
View
6 cake/console/libs/templates/default/views/form.ctp
@@ -26,7 +26,7 @@
<div class="<?php echo $pluralVar;?> form">
<?php echo "<?php echo \$form->create('{$modelClass}');?>\n";?>
<fieldset>
- <legend><?php echo "<?php __('".Inflector::humanize($action)." {$singularHumanName}');?>";?></legend>
+ <legend><?php echo "<?php __('" . Inflector::humanize($action) . " {$singularHumanName}');?>";?></legend>
<?php
echo "\t<?php\n";
foreach ($fields as $field) {
@@ -59,8 +59,8 @@
foreach ($associations as $type => $data) {
foreach ($data as $alias => $details) {
if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) {
- echo "\t\t<li><?php echo \$html->link(__('List ".Inflector::humanize($details['controller'])."', true), array('controller' => '{$details['controller']}', 'action' => 'index')); ?> </li>\n";
- echo "\t\t<li><?php echo \$html->link(__('New ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n";
+ echo "\t\t<li><?php echo \$html->link(__('List " . Inflector::humanize($details['controller']) . "', true), array('controller' => '{$details['controller']}', 'action' => 'index')); ?> </li>\n";
+ echo "\t\t<li><?php echo \$html->link(__('New " . Inflector::humanize(Inflector::underscore($alias)) . "', true), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n";
$done[] = $details['controller'];
}
}
View
6 cake/console/libs/templates/default/views/home.ctp
@@ -1,5 +1,5 @@
<?php
-$output = "<h2>Sweet, \"".Inflector::humanize($app)."\" got Baked by CakePHP!</h2>\n";
+$output = "<h2>Sweet, \"" . Inflector::humanize($app) . "\" got Baked by CakePHP!</h2>\n";
$output .="
<?php
if (Configure::read() > 0):
@@ -52,7 +52,9 @@ endif;
</p>
<?php
if (!empty(\$filePresent)):
- uses('model' . DS . 'connection_manager');
+ if (!class_exists('ConnectionManager')) {
+ require LIBS . 'model' . DS . 'connection_manager.php';
+ }
\$db = ConnectionManager::getInstance();
\$connected = \$db->getDataSource('default');
?>
View
4 cake/console/libs/templates/default/views/index.ctp
@@ -89,8 +89,8 @@ echo "<?php endforeach; ?>\n";
foreach ($associations as $type => $data) {
foreach ($data as $alias => $details) {
if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) {
- echo "\t\t<li><?php echo \$html->link(__('List ".Inflector::humanize($details['controller'])."', true), array('controller' => '{$details['controller']}', 'action' => 'index')); ?> </li>\n";
- echo "\t\t<li><?php echo \$html->link(__('New ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n";
+ echo "\t\t<li><?php echo \$html->link(__('List " . Inflector::humanize($details['controller']) . "', true), array('controller' => '{$details['controller']}', 'action' => 'index')); ?> </li>\n";
+ echo "\t\t<li><?php echo \$html->link(__('New " . Inflector::humanize(Inflector::underscore($alias)) . "', true), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n";
$done[] = $details['controller'];
}
}
View
18 cake/console/libs/templates/default/views/view.ctp
@@ -33,14 +33,14 @@ foreach ($fields as $field) {
foreach ($associations['belongsTo'] as $alias => $details) {
if ($field === $details['foreignKey']) {
$isKey = true;
- echo "\t\t<dt<?php if (\$i % 2 == 0) echo \$class;?>><?php __('".Inflector::humanize(Inflector::underscore($alias))."'); ?></dt>\n";
+ echo "\t\t<dt<?php if (\$i % 2 == 0) echo \$class;?>><?php __('" . Inflector::humanize(Inflector::underscore($alias)) . "'); ?></dt>\n";
echo "\t\t<dd<?php if (\$i++ % 2 == 0) echo \$class;?>>\n\t\t\t<?php echo \$html->link(\${$singularVar}['{$alias}']['{$details['displayField']}'], array('controller' => '{$details['controller']}', 'action' => 'view', \${$singularVar}['{$alias}']['{$details['primaryKey']}'])); ?>\n\t\t\t&nbsp;\n\t\t</dd>\n";
break;
}
}
}
if ($isKey !== true) {
- echo "\t\t<dt<?php if (\$i % 2 == 0) echo \$class;?>><?php __('".Inflector::humanize($field)."'); ?></dt>\n";
+ echo "\t\t<dt<?php if (\$i % 2 == 0) echo \$class;?>><?php __('" . Inflector::humanize($field) . "'); ?></dt>\n";
echo "\t\t<dd<?php if (\$i++ % 2 == 0) echo \$class;?>>\n\t\t\t<?php echo \${$singularVar}['{$modelClass}']['{$field}']; ?>\n\t\t\t&nbsp;\n\t\t</dd>\n";
}
}
@@ -59,8 +59,8 @@ foreach ($fields as $field) {
foreach ($associations as $type => $data) {
foreach ($data as $alias => $details) {
if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) {
- echo "\t\t<li><?php echo \$html->link(__('List ".Inflector::humanize($details['controller'])."', true), array('controller' => '{$details['controller']}', 'action' => 'index')); ?> </li>\n";
- echo "\t\t<li><?php echo \$html->link(__('New ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n";
+ echo "\t\t<li><?php echo \$html->link(__('List " . Inflector::humanize($details['controller']) . "', true), array('controller' => '{$details['controller']}', 'action' => 'index')); ?> </li>\n";
+ echo "\t\t<li><?php echo \$html->link(__('New " . Inflector::humanize(Inflector::underscore($alias)) . "', true), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n";
$done[] = $details['controller'];
}
}
@@ -72,12 +72,12 @@ foreach ($fields as $field) {
if (!empty($associations['hasOne'])) :
foreach ($associations['hasOne'] as $alias => $details): ?>
<div class="related">
- <h3><?php echo "<?php __('Related ".Inflector::humanize($details['controller'])."');?>";?></h3>
+ <h3><?php echo "<?php __('Related " . Inflector::humanize($details['controller']) . "');?>";?></h3>
<?php echo "<?php if (!empty(\${$singularVar}['{$alias}'])):?>\n";?>
<dl><?php echo "\t<?php \$i = 0; \$class = ' class=\"altrow\"';?>\n";?>
<?php
foreach ($details['fields'] as $field) {
- echo "\t\t<dt<?php if (\$i % 2 == 0) echo \$class;?>><?php __('".Inflector::humanize($field)."');?></dt>\n";
+ echo "\t\t<dt<?php if (\$i % 2 == 0) echo \$class;?>><?php __('" . Inflector::humanize($field) . "');?></dt>\n";
echo "\t\t<dd<?php if (\$i++ % 2 == 0) echo \$class;?>>\n\t<?php echo \${$singularVar}['{$alias}']['{$field}'];?>\n&nbsp;</dd>\n";
}
?>
@@ -85,7 +85,7 @@ if (!empty($associations['hasOne'])) :
<?php echo "<?php endif; ?>\n";?>
<div class="actions">
<ul>
- <li><?php echo "<?php echo \$html->link(__('Edit ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller' => '{$details['controller']}', 'action' => 'edit', \${$singularVar}['{$alias}']['{$details['primaryKey']}'])); ?></li>\n";?>
+ <li><?php echo "<?php echo \$html->link(__('Edit " . Inflector::humanize(Inflector::underscore($alias)) . "', true), array('controller' => '{$details['controller']}', 'action' => 'edit', \${$singularVar}['{$alias}']['{$details['primaryKey']}'])); ?></li>\n";?>
</ul>
</div>
</div>
@@ -111,7 +111,7 @@ foreach ($relations as $alias => $details):
<tr>
<?php
foreach ($details['fields'] as $field) {
- echo "\t\t<th><?php __('".Inflector::humanize($field)."'); ?></th>\n";
+ echo "\t\t<th><?php __('" . Inflector::humanize($field) . "'); ?></th>\n";
}
?>
<th class="actions"><?php echo "<?php __('Actions');?>";?></th>
@@ -144,7 +144,7 @@ echo "\t<?php endforeach; ?>\n";
<?php echo "<?php endif; ?>\n\n";?>
<div class="actions">
<ul>
- <li><?php echo "<?php echo \$html->link(__('New ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller' => '{$details['controller']}', 'action' => 'add'));?>";?> </li>
+ <li><?php echo "<?php echo \$html->link(__('New " . Inflector::humanize(Inflector::underscore($alias)) . "', true), array('controller' => '{$details['controller']}', 'action' => 'add'));?>";?> </li>
</ul>
</div>
</div>
View
2  cake/console/libs/templates/skel/app_helper.php
@@ -26,7 +26,7 @@
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
-App::import('Core', 'Helper');
+App::import('Helper', 'Helper', false);
/**
* This is a placeholder class.
View
5 cake/console/libs/templates/skel/config/core.php
@@ -191,6 +191,11 @@
Configure::write('Acl.database', 'default');
/**
+ * If you are on PHP 5.3 uncomment this line and correct your server timezone
+ * to fix the date & time related errors.
+ */
+ //date_default_timezone_set('UTC');
+/**
*
* Cache Engine Configuration
* Default settings provided below
View
1  cake/console/libs/templates/skel/views/layouts/flash.ctp
@@ -29,7 +29,6 @@
<?php echo $html->charset(); ?>
<title><?php echo $page_title; ?></title>
-
<?php if (Configure::read() == 0) { ?>
<meta http-equiv="Refresh" content="<?php echo $pause?>;url=<?php echo $url?>"/>
<?php } ?>
View
2  cake/console/libs/templates/skel/webroot/css.php
@@ -34,7 +34,7 @@
* Enter description here...
*/
if (!class_exists('File')) {
- uses('file');
+ require LIBS . 'file.php';
}
/**
View
9 cake/console/libs/templates/skel/webroot/test.php
@@ -25,7 +25,14 @@
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
-error_reporting(E_ALL);
+/**
+ * PHP 5.3 raises many notices in bootstrap.
+ */
+if (!defined('E_DEPRECATED')) {
+ define('E_DEPRECATED', 8192);
+}
+error_reporting(E_ALL & ~E_DEPRECATED);
+
set_time_limit(0);
ini_set('memory_limit','128M');
ini_set('display_errors', 1);
View
15 cake/console/libs/testsuite.php
@@ -236,13 +236,8 @@ function __canRun() {
return true;
}
- if ($this->category == 'core') {
- if (file_exists($folder.DS.'cases'.DS.$this->file.'.test.php')) {
- return true;
- }
- if (file_exists($folder.DS.'cases'.DS.'libs'.DS.$this->file.'.test.php')) {
- return true;
- }
+ if ($this->category == 'core' && file_exists($folder.DS.'cases'.DS.'libs'.DS.$this->file.'.test.php')) {
+ return true;
}
if ($isPlugin && file_exists($folder.DS.'cases'.DS.$this->file.'.test.php')) {
@@ -297,11 +292,7 @@ function __run() {
return $result;
}
- if (file_exists(CORE_TEST_CASES . DS . $this->file . '.test.php')) {
- $case = $this->file . '.test.php';
- } else {
- $case = 'libs' . DS . $this->file . '.test.php';
- }
+ $case = 'libs'.DS.$this->file.'.test.php';
if ($this->category == 'app') {
$case = $this->file.'.test.php';
} elseif ($this->isPluginTest) {
View
2  cake/dispatcher.php
@@ -226,7 +226,7 @@ function _invoke(&$controller, $params) {
if (!isset($methods[strtolower($params['action'])])) {
if ($controller->scaffold !== false) {
- App::import('Core', 'Scaffold');
+ App::import('Controller', 'Scaffold', false);
return new Scaffold($controller, $params);
}
return $this->cakeError('missingAction', array(array(
View
2  cake/libs/cake_session.php
@@ -746,7 +746,7 @@ function __read($id) {
return false;
}
- return $row[$model->alias]['data'];
+ return $row[$model->alias]['data'];
}
/**
View
16 cake/libs/configure.php
@@ -107,7 +107,7 @@ function write($config, $value = null) {
if (isset($config['debug'])) {
if ($_this->debug) {
- error_reporting(E_ALL);
+ error_reporting(E_ALL & ~E_DEPRECATED);
if (function_exists('ini_set')) {
ini_set('display_errors', 1);
@@ -844,7 +844,7 @@ function import($type = null, $name = null, $parent = true, $search = array(), $
}
}
- if (!App::import($tempType, $plugin . $class)) {
+ if (!App::import($tempType, $plugin . $class, $parent)) {
return false;
}
}
@@ -866,7 +866,7 @@ function import($type = null, $name = null, $parent = true, $search = array(), $
if ($name != null && !class_exists($name . $ext['class'])) {
if ($load = $_this->__mapped($name . $ext['class'], $type, $plugin)) {
if ($_this->__load($load)) {
- $_this->__overload($type, $name . $ext['class']);
+ $_this->__overload($type, $name . $ext['class'], $parent);
if ($_this->return) {
$value = include $load;
@@ -908,7 +908,7 @@ function import($type = null, $name = null, $parent = true, $search = array(), $
if ($directory !== null) {
$_this->__cache = true;
$_this->__map($directory . $file, $name . $ext['class'], $type, $plugin);
- $_this->__overload($type, $name . $ext['class']);
+ $_this->__overload($type, $name . $ext['class'], $parent);
if ($_this->return) {
$value = include $directory . $file;
@@ -1058,8 +1058,8 @@ function __mapped($name, $type, $plugin) {
* @param string $name Class name to overload
* @access private
*/
- function __overload($type, $name) {
- if (($type === 'Model' || $type === 'Helper') && strtolower($name) != 'schema') {
+ function __overload($type, $name, $parent) {
+ if (($type === 'Model' || $type === 'Helper') && $parent !== false) {
Overloadable::overload($name);
}
}
@@ -1088,10 +1088,10 @@ function __settings($type, $plugin, $parent) {
switch ($load) {
case 'model':
if (!class_exists('Model')) {
- App::import('Model', 'Model', false, App::core('models'));
+ require LIBS . 'model' . DS . 'model.php';
}
if (!class_exists('AppModel')) {
- App::import($type, 'AppModel', false, App::path('models'));
+ App::import($type, 'AppModel', false);
}
if ($plugin) {
if (!class_exists($plugin . 'AppModel')) {
View
2  cake/libs/controller/components/acl.php
@@ -219,7 +219,7 @@ class DbAcl extends AclBase {
function __construct() {
parent::__construct();
if (!class_exists('AclNode')) {
- uses('model' . DS . 'db_acl');
+ require LIBS . 'model' . DS . 'db_acl.php';
}
$this->Aro =& ClassRegistry::init(array('class' => 'Aro', 'alias' => 'Aro'));
$this->Aco =& ClassRegistry::init(array('class' => 'Aco', 'alias' => 'Aco'));
View
14 cake/libs/controller/components/cookie.php
@@ -219,10 +219,10 @@ function write($key, $value = null, $encrypt = true, $expires = null) {
if (count($name) > 1) {
$this->__values[$name[0]][$name[1]] = $value;
- $this->__write("[".$name[0]."][".$name[1]."]", $value);
+ $this->__write("[" . $name[0] . "][" . $name[1] . "]", $value);
} else {
$this->__values[$name[0]] = $value;
- $this->__write("[".$name[0]."]", $value);
+ $this->__write("[" . $name[0] . "]", $value);
}
} else {
foreach ($key as $names => $value) {
@@ -230,10 +230,10 @@ function write($key, $value = null, $encrypt = true, $expires = null) {
if (count($name) > 1) {
$this->__values[$name[0]][$name[1]] = $value;
- $this->__write("[".$name[0]."][".$name[1]."]", $value);
+ $this->__write("[" . $name[0] . "][" . $name[1] . "]", $value);
} else {
$this->__values[$name[0]] = $value;
- $this->__write("[".$name[0]."]", $value);
+ $this->__write("[" . $name[0] . "]", $value);
}
}
}
@@ -296,17 +296,17 @@ function del($key) {
$name = $this->__cookieVarNames($key);
if (count($name) > 1) {
if (isset($this->__values[$name[0]])) {
- $this->__delete("[".$name[0]."][".$name[1]."]");
+ $this->__delete("[" . $name[0] . "][" . $name[1] . "]");
unset($this->__values[$name[0]][$name[1]]);
}
} else {
if (isset($this->__values[$name[0]])) {
if (is_array($this->__values[$name[0]])) {
foreach ($this->__values[$name[0]] as $key => $value) {
- $this->__delete("[".$name[0]."][".$key."]");
+ $this->__delete("[" . $name[0] . "][" . $key . "]");
}
}
- $this->__delete("[".$name[0]."]");
+ $this->__delete("[" . $name[0] . "]");
unset($this->__values[$name[0]]);
}
}
View
2  cake/libs/controller/components/request_handler.php
@@ -581,7 +581,7 @@ function prefers($type = null) {
} elseif (count($types) === 1) {
return ($types[0] === $accepts[0]);
} elseif (count($accepts) === 1) {
- return $accepts[0];
+ return $accepts[0];
}
$acceptedTypes = array();
View
3  cake/libs/debugger.php
@@ -165,7 +165,6 @@ function __construct() {
$this->_templates['js']['code'] = '<div id="{:id}-code" class="cake-code-dump" ';
$this->_templates['js']['code'] .= 'style="display: none;"><pre>{:code}</pre></div>';
-
$e = '<pre class="cake-debug"><b>{:error}</b> ({:code}) : {:description} ';
$e .= '[<b>{:path}</b>, line <b>{:line}]</b></pre>';
$this->_templates['html']['error'] = $e;
@@ -254,7 +253,7 @@ function log($var, $level = LOG_DEBUG) {
* @access public
*/
function handleError($code, $description, $file = null, $line = null, $context = null) {
- if (error_reporting() == 0 || $code === 2048) {
+ if (error_reporting() == 0 || $code === 2048 || $code === 8192) {
return;
}
View
2  cake/libs/file.php
@@ -29,7 +29,7 @@
*
*/
if (!class_exists('Object')) {
- uses('object');
+ require LIBS . 'object.php';
}
if (!class_exists('Folder')) {
require LIBS . 'folder.php';
View
2  cake/libs/folder.php
@@ -29,7 +29,7 @@
*
*/
if (!class_exists('Object')) {
- uses('object');
+ require LIBS . 'object.php';
}
/**
View
15 cake/libs/http_socket.php
@@ -212,10 +212,10 @@ function request($request = array()) {
}
if (isset($this->request['auth']['user']) && isset($this->request['auth']['pass'])) {
- $this->request['header']['Authorization'] = $this->request['auth']['method'] ." ". base64_encode($this->request['auth']['user'] .":".$this->request['auth']['pass']);
+ $this->request['header']['Authorization'] = $this->request['auth']['method'] . " " . base64_encode($this->request['auth']['user'] . ":" . $this->request['auth']['pass']);
}
if (isset($this->request['uri']['user']) && isset($this->request['uri']['pass'])) {
- $this->request['header']['Authorization'] = $this->request['auth']['method'] ." ". base64_encode($this->request['uri']['user'] .":".$this->request['uri']['pass']);
+ $this->request['header']['Authorization'] = $this->request['auth']['method'] . " " . base64_encode($this->request['uri']['user'] . ":" . $this->request['uri']['pass']);
}
if (is_array($this->request['body'])) {
@@ -836,7 +836,7 @@ function _parseHeader($header) {
return false;
}
- preg_match_all("/(.+):(.+)(?:(?<![\t ])".$this->lineBreak."|\$)/Uis", $header, $matches, PREG_SET_ORDER);
+ preg_match_all("/(.+):(.+)(?:(?<![\t ])" . $this->lineBreak . "|\$)/Uis", $header, $matches, PREG_SET_ORDER);
$header = array();
foreach ($matches as $match) {
@@ -877,9 +877,16 @@ function parseCookies($header) {
$cookies = array();
foreach ((array)$header['Set-Cookie'] as $cookie) {
- $parts = preg_split('/(?<![^;]");[ \t]*/', $cookie);
+ if (strpos($cookie, '";"') !== false) {
+ $cookie = str_replace('";"', "{__cookie_replace__}", $cookie);
+ $parts = str_replace("{__cookie_replace__}", '";"', preg_split('/\;/', $cookie));
+ } else {
+ $parts = preg_split('/\;[ \t]*/', $cookie);
+ }
+
list($name, $value) = explode('=', array_shift($parts), 2);
$cookies[$name] = compact('value');
+
foreach ($parts as $part) {
if (strpos($part, '=') !== false) {
list($key, $value) = explode('=', $part);
View
5 cake/libs/inflector.php
@@ -126,7 +126,7 @@ class Inflector extends Object {
'/(alumn|bacill|cact|foc|fung|nucle|radi|stimul|syllab|termin|viri?)i$/i' => '\1us',
'/([ftw]ax)es/' => '\1',
'/(cris|ax|test)es$/i' => '\1is',
- '/(shoe)s$/i' => '\1',
+ '/(shoe|slave)s$/i' => '\1',
'/(o)es$/i' => '\1',
'/ouses$/' => 'ouse',
'/uses$/' => 'us',
@@ -449,10 +449,11 @@ function slug($string, $replacement = '_', $map = array()) {
'/Ü/' => 'Ue',
'/Ö/' => 'Oe',
'/ß/' => 'ss',
- '/[^\w\s]/' => ' ',
+ '/[^\s\p{Ll}\p{Lm}\p{Lo}\p{Lt}\p{Lu}\p{Nd}]/mu' => ' ',
'/\\s+/' => $replacement,
sprintf('/^[%s]+|[%s]+$/', $quotedReplacement, $quotedReplacement) => '',
);
+
$map = array_merge($default, $map);