Skip to content
This repository
Browse code

Merge branch '1.3' into 1.3-console

  • Loading branch information...
commit 982f1615597fea5e088b0fc1d93b390a9e1f0191 2 parents 5b8b992 + c017f80
Andy Dawson authored

Showing 114 changed files with 2,475 additions and 786 deletions. Show diff stats Hide diff stats

  1. 6  app/config/bootstrap.php
  2. 5  app/config/core.php
  3. 9  app/webroot/test.php
  4. 1  cake/basics.php
  5. 5  cake/bootstrap.php
  6. 249  cake/console/cake.php
  7. 225  cake/console/libs/acl.php
  8. 2  cake/console/libs/api.php
  9. 2  cake/console/libs/bake.php
  10. 4  cake/console/libs/schema.php
  11. 89  cake/console/libs/shell.php
  12. 4  cake/console/libs/tasks/fixture.php
  13. 3  cake/console/libs/tasks/model.php
  14. 8  cake/console/libs/tasks/project.php
  15. 2  cake/console/libs/tasks/view.php
  16. 6  cake/console/libs/templates/default/views/form.ctp
  17. 6  cake/console/libs/templates/default/views/home.ctp
  18. 4  cake/console/libs/templates/default/views/index.ctp
  19. 18  cake/console/libs/templates/default/views/view.ctp
  20. 2  cake/console/libs/templates/skel/app_helper.php
  21. 5  cake/console/libs/templates/skel/config/core.php
  22. 1  cake/console/libs/templates/skel/views/layouts/flash.ctp
  23. 2  cake/console/libs/templates/skel/webroot/css.php
  24. 9  cake/console/libs/templates/skel/webroot/test.php
  25. 15  cake/console/libs/testsuite.php
  26. 2  cake/dispatcher.php
  27. 2  cake/libs/cake_session.php
  28. 16  cake/libs/configure.php
  29. 2  cake/libs/controller/components/acl.php
  30. 14  cake/libs/controller/components/cookie.php
  31. 2  cake/libs/controller/components/request_handler.php
  32. 3  cake/libs/debugger.php
  33. 2  cake/libs/file.php
  34. 2  cake/libs/folder.php
  35. 15  cake/libs/http_socket.php
  36. 5  cake/libs/inflector.php
  37. 6  cake/libs/l10n.php
  38. 5  cake/libs/magic_db.php
  39. 2  cake/libs/model/behaviors/acl.php
  40. 2  cake/libs/model/behaviors/containable.php
  41. 8  cake/libs/model/cake_schema.php
  42. 14  cake/libs/model/datasources/datasource.php
  43. 51  cake/libs/model/datasources/dbo/dbo_mssql.php
  44. 36  cake/libs/model/datasources/dbo/dbo_mysqli.php
  45. 34  cake/libs/model/datasources/dbo/dbo_oracle.php
  46. 6  cake/libs/model/datasources/dbo_source.php
  47. 4  cake/libs/model/model.php
  48. 2  cake/libs/multibyte.php
  49. 7  cake/libs/object.php
  50. 19  cake/libs/router.php
  51. 36  cake/libs/security.php
  52. 2  cake/libs/set.php
  53. 2  cake/libs/validation.php
  54. 6  cake/libs/view/errors/missing_action.ctp
  55. 6  cake/libs/view/errors/missing_component_class.ctp
  56. 4  cake/libs/view/errors/missing_component_file.ctp
  57. 6  cake/libs/view/errors/missing_controller.ctp
  58. 4  cake/libs/view/errors/missing_helper_class.ctp
  59. 9  cake/libs/view/errors/missing_helper_file.ctp
  60. 6  cake/libs/view/errors/missing_layout.ctp
  61. 4  cake/libs/view/errors/missing_model.ctp
  62. 4  cake/libs/view/errors/missing_scaffolddb.ctp
  63. 4  cake/libs/view/errors/missing_table.ctp
  64. 4  cake/libs/view/errors/missing_view.ctp
  65. 4  cake/libs/view/errors/private_action.ctp
  66. 2  cake/libs/view/errors/scaffold_error.ctp
  67. 4  cake/libs/view/helpers/ajax.php
  68. 9  cake/libs/view/helpers/javascript.php
  69. 34  cake/libs/view/helpers/paginator.php
  70. 1  cake/libs/view/helpers/xml.php
  71. 4  cake/libs/view/pages/home.ctp
  72. 4  cake/libs/view/scaffolds/edit.ctp
  73. 4  cake/libs/view/scaffolds/index.ctp
  74. 16  cake/libs/view/scaffolds/view.ctp
  75. 2  cake/libs/view/theme.php
  76. 20  cake/libs/xml.php
  77. 5  cake/tests/cases/basics.test.php
  78. 485  cake/tests/cases/console/cake.test.php
  79. 95  cake/tests/cases/console/libs/acl.test.php
  80. 119  cake/tests/cases/console/libs/shell.test.php
  81. 10  cake/tests/cases/console/libs/tasks/db_config.test.php
  82. 17  cake/tests/cases/console/libs/tasks/fixture.test.php
  83. 31  cake/tests/cases/console/libs/tasks/test.test.php
  84. 6  cake/tests/cases/libs/cake_test_fixture.test.php
  85. 1  cake/tests/cases/libs/controller/components/cookie.test.php
  86. 4  cake/tests/cases/libs/http_socket.test.php
  87. 13  cake/tests/cases/libs/inflector.test.php
  88. 2  cake/tests/cases/libs/l10n.test.php
  89. 17  cake/tests/cases/libs/magic_db.test.php
  90. 119  cake/tests/cases/libs/model/behaviors/containable.test.php
  91. 21  cake/tests/cases/libs/model/behaviors/translate.test.php
  92. 361  cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php
  93. 3  cake/tests/cases/libs/model/datasources/dbo_source.test.php
  94. 12  cake/tests/cases/libs/model/model_delete.test.php
  95. 25  cake/tests/cases/libs/model/model_integration.test.php
  96. 44  cake/tests/cases/libs/model/model_read.test.php
  97. 4  cake/tests/cases/libs/model/model_validation.test.php
  98. 70  cake/tests/cases/libs/model/model_write.test.php
  99. 69  cake/tests/cases/libs/router.test.php
  100. 4  cake/tests/cases/libs/sanitize.test.php
  101. 1  cake/tests/cases/libs/set.test.php
  102. 46  cake/tests/cases/libs/view/helpers/ajax.test.php
  103. 20  cake/tests/cases/libs/view/helpers/cache.test.php
  104. 12  cake/tests/cases/libs/view/helpers/js.test.php
  105. 426  cake/tests/cases/libs/view/helpers/paginator.test.php
  106. 38  cake/tests/cases/libs/view/helpers/xml.test.php
  107. 19  cake/tests/cases/libs/xml.test.php
  108. 2  cake/tests/fixtures/uuid_tree_fixture.php
  109. 1  cake/tests/lib/cake_reporter.php
  110. 2  cake/tests/lib/cake_test_fixture.php
  111. 3  cake/tests/test_app/views/layouts/cache_layout.ctp
  112. 2  cake/tests/test_app/views/layouts/email/text/default.ctp
  113. 4  cake/tests/test_app/views/pages/home.ctp
  114. 4  cake/tests/test_app/views/posts/test_nocache_tags.ctp
6  app/config/bootstrap.php
@@ -44,8 +44,8 @@
44 44
 /**
45 45
  * As of 1.3, additional rules for the inflector are added below
46 46
  *
47  
- * Inflector::rule('singular', array('rules' => array(), irregular' => array(), 'uninflected' => array()));
48  
- * Inflector::rule('plural', array('rules' => array(), 'irregular' => array(), 'uninflected' => array()));
  47
+ * Inflector::rules('singular', array('rules' => array(), 'irregular' => array(), 'uninflected' => array()));
  48
+ * Inflector::rules('plural', array('rules' => array(), 'irregular' => array(), 'uninflected' => array()));
49 49
  *
50 50
  */
51  
-?>
  51
+?>
5  app/config/core.php
@@ -185,6 +185,11 @@
185 185
 	Configure::write('Acl.classname', 'DbAcl');
186 186
 	Configure::write('Acl.database', 'default');
187 187
 /**
  188
+ * If you are on PHP 5.3 uncomment this line and correct your server timezone
  189
+ * to fix the date & time related errors.
  190
+ */
  191
+	//date_default_timezone_set('UTC');
  192
+/**
188 193
  *
189 194
  * Cache Engine Configuration
190 195
  * Default settings provided below
9  app/webroot/test.php
@@ -24,7 +24,14 @@
24 24
  * @lastmodified  $Date$
25 25
  * @license       http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
26 26
  */
27  
-error_reporting(E_ALL);
  27
+/**
  28
+ * PHP 5.3 raises many notices in bootstrap.
  29
+ */
  30
+if (!defined('E_DEPRECATED')) {
  31
+   define('E_DEPRECATED', 8192);
  32
+}
  33
+error_reporting(E_ALL & ~E_DEPRECATED);
  34
+
28 35
 set_time_limit(0);
29 36
 ini_set('memory_limit','128M');
30 37
 ini_set('display_errors', 1);
1  cake/basics.php
@@ -89,6 +89,7 @@ function config() {
89 89
  * </code>
90 90
  *
91 91
  * @param string $name Filename without the .php part
  92
+ * @deprecated
92 93
  */
93 94
 	function uses() {
94 95
 		$args = func_get_args();
5  cake/bootstrap.php
@@ -22,6 +22,11 @@
22 22
 if (!defined('PHP5')) {
23 23
 	define('PHP5', (PHP_VERSION >= 5));
24 24
 }
  25
+if (!defined('E_DEPRECATED')) {
  26
+	define('E_DEPRECATED', 8192);
  27
+}
  28
+error_reporting(E_ALL & ~E_DEPRECATED);
  29
+
25 30
 require CORE_PATH . 'cake' . DS . 'basics.php';
26 31
 $TIME_START = getMicrotime();
27 32
 require CORE_PATH . 'cake' . DS . 'config' . DS . 'paths.php';
249  cake/console/cake.php
... ...
@@ -1,7 +1,5 @@
1 1
 #!/usr/bin/php -q
2 2
 <?php
3  
-/* SVN FILE: $Id$ */
4  
-
5 3
 /**
6 4
  * Command-line code generation utility to automate programmer chores.
7 5
  *
@@ -26,7 +24,9 @@
26 24
  * @lastmodified  $Date$
27 25
  * @license       http://www.opensource.org/licenses/mit-license.php The MIT License
28 26
  */
29  
-
  27
+if (!defined('E_DEPRECATED')) {
  28
+	define('E_DEPRECATED', 8192);
  29
+}
30 30
 /**
31 31
  * Shell dispatcher
32 32
  *
@@ -135,15 +135,21 @@ function ShellDispatcher($args = array()) {
135 135
 /**
136 136
  * Constructor
137 137
  *
138  
- * @param array $args the argv.
  138
+ * The execution of the script is stopped after dispatching the request with
  139
+ * a status code of either 0 or 1 according to the result of the dispatch.
  140
+ *
  141
+ * @param array $args the argv
  142
+ * @return void
  143
+ * @access public
139 144
  */
140 145
 	function __construct($args = array()) {
141 146
 		set_time_limit(0);
  147
+
142 148
 		$this->__initConstants();
143 149
 		$this->parseParams($args);
144 150
 		$this->_initEnvironment();
145 151
 		$this->__buildPaths();
146  
-		$this->_stop($this->dispatch());
  152
+		$this->_stop($this->dispatch() === false ? 1 : 0);
147 153
 	}
148 154
 
149 155
 /**
@@ -305,118 +311,134 @@ function clear() {
305 311
 /**
306 312
  * Dispatches a CLI request
307 313
  *
  314
+ * @return boolean
308 315
  * @access public
309 316
  */
310 317
 	function dispatch() {
311  
-		if (isset($this->args[0])) {
  318
+		$arg = $this->shiftArgs();
  319
+
  320
+		if (!$arg) {
  321
+			$this->help();
  322
+			return false;
  323
+		}
  324
+		if ($arg == 'help') {
  325
+			$this->help();
  326
+			return true;
  327
+		}
  328
+
  329
+		if (strpos($arg, '.') !== false)  {
  330
+			list($plugin, $shell) = explode('.', $arg);
  331
+		} else {
312 332
 			$plugin = null;
313  
-			$shell = $this->args[0];
314  
-			if (strpos($shell, '.') !== false)  {
315  
-				list($plugin, $shell) = explode('.', $this->args[0]);
316  
-			}
  333
+			$shell = $arg;
  334
+		}
  335
+		$this->shell = $shell;
  336
+		$this->shellName = Inflector::camelize($shell);
  337
+		$this->shellClass = $this->shellName . 'Shell';
317 338
 
318  
-			$this->shell = $shell;
319  
-			$this->shiftArgs();
320  
-			$this->shellName = Inflector::camelize($this->shell);
321  
-			$this->shellClass = $this->shellName . 'Shell';
  339
+		$arg = null;
322 340
 
323  
-			if ($this->shell === 'help') {
324  
-				$this->help();
325  
-			} else {
326  
-				$loaded = false;
327  
-				foreach ($this->shellPaths as $path) {
328  
-					$this->shellPath = $path . $this->shell . '.php';
329  
-
330  
-					$isPlugin = ($plugin && strpos($path, DS . $plugin . DS . 'vendors' . DS . 'shells' . DS) !== false);
331  
-					if (($isPlugin && file_exists($this->shellPath)) || (!$plugin && file_exists($this->shellPath))) {
332  
-						$loaded = true;
333  
-						break;
334  
-					}
335  
-				}
  341
+		if (isset($this->args[0])) {
  342
+			$arg = $this->args[0];
  343
+			$this->shellCommand = Inflector::variable($arg);
  344
+		}
336 345
 
337  
-				if ($loaded) {
338  
-					if (!class_exists('Shell')) {
339  
-						require CONSOLE_LIBS . 'shell.php';
340  
-					}
341  
-					require $this->shellPath;
342  
-					if (class_exists($this->shellClass)) {
343  
-						$command = null;
344  
-						if (isset($this->args[0])) {
345  
-							$command = $this->args[0];
346  
-						}
347  
-						$this->shellCommand = Inflector::variable($command);
348  
-						$shell = new $this->shellClass($this);
349  
-
350  
-						if (strtolower(get_parent_class($shell)) == 'shell') {
351  
-							$shell->initialize();
352  
-							$shell->loadTasks();
353  
-
354  
-							foreach ($shell->taskNames as $task) {
355  
-								if (strtolower(get_parent_class($shell)) == 'shell') {
356  
-									$shell->{$task}->initialize();
357  
-									$shell->{$task}->loadTasks();
358  
-								}
359  
-							}
360  
-
361  
-							$task = Inflector::camelize($command);
362  
-							if (in_array($task, $shell->taskNames)) {
363  
-								$this->shiftArgs();
364  
-								$shell->{$task}->startup();
365  
-								if (isset($this->args[0]) && $this->args[0] == 'help') {
366  
-									if (method_exists($shell->{$task}, 'help')) {
367  
-										$shell->{$task}->help();
368  
-										$this->_stop();
369  
-									} else {
370  
-										$this->help();
371  
-									}
372  
-								}
373  
-								return $shell->{$task}->execute();
374  
-							}
375  
-						}
  346
+		$Shell = $this->_getShell($plugin);
376 347
 
377  
-						$classMethods = get_class_methods($shell);
  348
+		if (!$Shell) {
  349
+			$title = sprintf(__('Error: Class %s could not be loaded.', true), $this->shellClass);
  350
+			$this->stderr($title . "\n");
  351
+			return false;
  352
+		}
378 353
 
379  
-						$privateMethod = $missingCommand = false;
380  
-						if ((in_array($command, $classMethods) || in_array(strtolower($command), $classMethods)) && strpos($command, '_', 0) === 0) {
381  
-							$privateMethod = true;
382  
-						}
  354
+		$methods = array();
383 355
 
384  
-						if (!in_array($command, $classMethods) && !in_array(strtolower($command), $classMethods)) {
385  
-							$missingCommand = true;
386  
-						}
  356
+		if (is_a($Shell, 'Shell')) {
  357
+			$Shell->initialize();
  358
+			$Shell->loadTasks();
387 359
 
388  
-						$protectedCommands = array(
389  
-							'initialize','in','out','err','hr',
390  
-							'createfile', 'isdir','copydir','object','tostring',
391  
-							'requestaction','log','cakeerror', 'shelldispatcher',
392  
-							'__initconstants','__initenvironment','__construct',
393  
-							'dispatch','__bootstrap','getinput','stdout','stderr','parseparams','shiftargs'
394  
-						);
  360
+			foreach ($Shell->taskNames as $task) {
  361
+				if (is_a($Shell->{$task}, 'Shell')) {
  362
+					$Shell->{$task}->initialize();
  363
+					$Shell->{$task}->loadTasks();
  364
+				}
  365
+			}
395 366
 
396  
-						if (in_array(strtolower($command), $protectedCommands)) {
397  
-							$missingCommand = true;
398  
-						}
  367
+			$task = Inflector::camelize($arg);
399 368
 
400  
-						if ($missingCommand && method_exists($shell, 'main')) {
401  
-							$shell->startup();
402  
-							return $shell->main();
403  
-						} elseif (!$privateMethod && method_exists($shell, $command)) {
404  
-							$this->shiftArgs();
405  
-							$shell->startup();
406  
-							return $shell->{$command}();
407  
-						} else {
408  
-							$this->stderr("Unknown {$this->shellName} command '$command'.\nFor usage, try 'cake {$this->shell} help'.\n\n");
409  
-						}
  369
+			if (in_array($task, $Shell->taskNames)) {
  370
+				$this->shiftArgs();
  371
+				$Shell->{$task}->startup();
  372
+
  373
+				if (isset($this->args[0]) && $this->args[0] == 'help') {
  374
+					if (method_exists($Shell->{$task}, 'help')) {
  375
+						$Shell->{$task}->help();
410 376
 					} else {
411  
-						$this->stderr('Class '.$this->shellClass.' could not be loaded');
  377
+						$this->help();
412 378
 					}
413  
-				} else {
414  
-					$this->help();
  379
+					return true;
415 380
 				}
  381
+				return $Shell->{$task}->execute();
  382
+			}
  383
+			$methods = array_diff(get_class_methods('Shell'), array('help'));
  384
+		}
  385
+		$methods = array_diff(get_class_methods($Shell), $methods);
  386
+		$added = in_array(strtolower($arg), array_map('strtolower', $methods));
  387
+		$private = $arg[0] == '_' && method_exists($Shell, $arg);
  388
+
  389
+		if (!$private) {
  390
+			if ($added) {
  391
+				$this->shiftArgs();
  392
+				$Shell->startup();
  393
+				return $Shell->{$arg}();
  394
+			}
  395
+			if (method_exists($Shell, 'main')) {
  396
+				$Shell->startup();
  397
+				return $Shell->main();
  398
+			}
  399
+		}
  400
+
  401
+		$title = sprintf(__('Error: Unknown %1$s command %2$s.', true), $this->shellName, $arg);
  402
+		$message = sprintf(__('For usage try `cake %s help`', true), $this->shell);
  403
+		$this->stderr($title . "\n" . $message . "\n");
  404
+		return false;
  405
+	}
  406
+/**
  407
+ * Get shell to use, either plugin shell or application shell
  408
+ *
  409
+ * All paths in the shellPaths property are searched.
  410
+ * shell, shellPath and shellClass properties are taken into account.
  411
+ *
  412
+ * @param string $plugin Optionally the name of a plugin
  413
+ * @return mixed False if no shell could be found or an object on success
  414
+ * @access protected
  415
+ */
  416
+	function _getShell($plugin = null) {
  417
+		foreach ($this->shellPaths as $path) {
  418
+			$this->shellPath = $path . $this->shell . '.php';
  419
+			$pluginShellPath =  DS . $plugin . DS . 'vendors' . DS . 'shells' . DS;
  420
+
  421
+			if ((strpos($path, $pluginShellPath) !== false || !$plugin) && file_exists($this->shellPath)) {
  422
+				$loaded = true;
  423
+				break;
416 424
 			}
417  
-		} else {
418  
-			$this->help();
419 425
 		}
  426
+		if (!isset($loaded)) {
  427
+			return false;
  428
+		}
  429
+
  430
+		if (!class_exists('Shell')) {
  431
+			require CONSOLE_LIBS . 'shell.php';
  432
+		}
  433
+
  434
+		if (!class_exists($this->shellClass)) {
  435
+			require $this->shellPath;
  436
+		}
  437
+		if (!class_exists($this->shellClass)) {
  438
+			return false;
  439
+		}
  440
+		$Shell = new $this->shellClass($this);
  441
+		return $Shell;
420 442
 	}
421 443
 
422 444
 /**
@@ -475,7 +497,7 @@ function stdout($string, $newline = true) {
475 497
  * @access public
476 498
  */
477 499
 	function stderr($string) {
478  
-		fwrite($this->stderr, 'Error: '. $string);
  500
+		fwrite($this->stderr, $string);
479 501
 	}
480 502
 
481 503
 /**
@@ -486,13 +508,15 @@ function stderr($string) {
486 508
  */
487 509
 	function parseParams($params) {
488 510
 		$this->__parseParams($params);
489  
-
490 511
 		$defaults = array('app' => 'app', 'root' => dirname(dirname(dirname(__FILE__))), 'working' => null, 'webroot' => 'webroot');
491  
-
492 512
 		$params = array_merge($defaults, array_intersect_key($this->params, $defaults));
493  
-
494  
-		$isWin = array_filter(array_map('strpos', $params, array('\\')));
495  
-
  513
+		$isWin = false;
  514
+		foreach ($defaults as $default => $value) {
  515
+			if (strpos($params[$default], '\\') !== false) {
  516
+				$isWin = true;
  517
+				break;
  518
+			}
  519
+		}
496 520
 		$params = str_replace('\\', '/', $params);
497 521
 
498 522
 		if (!empty($params['working']) && (!isset($this->args[0]) || isset($this->args[0]) && $this->args[0]{0} !== '.')) {
@@ -504,7 +528,7 @@ function parseParams($params) {
504 528
 			}
505 529
 		}
506 530
 
507  
-		if ($params['app'][0] == '/' || preg_match('/([a-zA-Z])(:)/i', $params['app'], $matches)) {
  531
+		if ($params['app'][0] == '/' || preg_match('/([a-z])(:)/i', $params['app'], $matches)) {
508 532
 			$params['root'] = dirname($params['app']);
509 533
 		} elseif (strpos($params['app'], '/')) {
510 534
 			$params['root'] .= '/' . dirname($params['app']);
@@ -521,7 +545,7 @@ function parseParams($params) {
521 545
 	}
522 546
 
523 547
 /**
524  
- * Helper for recursively paraing params
  548
+ * Helper for recursively parsing params
525 549
  *
526 550
  * @return array params
527 551
  * @access private
@@ -555,16 +579,11 @@ function __parseParams($params) {
555 579
 /**
556 580
  * Removes first argument and shifts other arguments up
557 581
  *
558  
- * @return boolean False if there are no arguments
  582
+ * @return mixed Null if there are no arguments otherwise the shifted argument
559 583
  * @access public
560 584
  */
561 585
 	function shiftArgs() {
562  
-		if (empty($this->args)) {
563  
-			return false;
564  
-		}
565  
-		unset($this->args[0]);
566  
-		$this->args = array_values($this->args);
567  
-		return true;
  586
+		return array_shift($this->args);
568 587
 	}
569 588
 
570 589
 /**
@@ -603,6 +622,7 @@ function help() {
603 622
 				} else {
604 623
 					sort($shells);
605 624
 					foreach ($shells as $shell) {
  625
+
606 626
 						if ($shell !== 'shell.php') {
607 627
 							$this->stdout("\t " . str_replace('.php', '', $shell));
608 628
 						}
@@ -612,7 +632,6 @@ function help() {
612 632
 		}
613 633
 		$this->stdout("\nTo run a command, type 'cake shell_name [args]'");
614 634
 		$this->stdout("To get help on a specific command, type 'cake shell_name help'");
615  
-		$this->_stop();
616 635
 	}
617 636
 
618 637
 /**
225  cake/console/libs/acl.php
@@ -137,52 +137,29 @@ function main() {
137 137
  * @access public
138 138
  */
139 139
 	function create() {
140  
-
141 140
 		$this->_checkArgs(3, 'create');
142 141
 		$this->checkNodeType();
143 142
 		extract($this->__dataVars());
144 143
 
145 144
 		$class = ucfirst($this->args[0]);
146  
-		$object = new $class();
147  
-
148  
-		if (preg_match('/^([\w]+)\.(.*)$/', $this->args[1], $matches) && count($matches) == 3) {
149  
-			$parent = array(
150  
-				'model' => $matches[1],
151  
-				'foreign_key' => $matches[2],
152  
-			);
153  
-		} else {
154  
-			$parent = $this->args[1];
155  
-		}
  145
+		$parent = $this->parseIdentifier($this->args[1]);
156 146
 
157 147
 		if (!empty($parent) && $parent != '/' && $parent != 'root') {
158  
-			@$parent = $object->node($parent);
159  
-			if (empty($parent)) {
160  
-				$this->err(sprintf(__('Could not find parent node using reference "%s"', true), $this->args[1]));
161  
-				return;
162  
-			} else {
163  
-				$parent = Set::extract($parent, "0.{$class}.id");
164  
-			}
  148
+			$parent = $this->_getNodeId($class, $parent);
165 149
 		} else {
166 150
 			$parent = null;
167 151
 		}
168 152
 
169  
-		if (preg_match('/^([\w]+)\.(.*)$/', $this->args[2], $matches) && count($matches) == 3) {
170  
-			$data = array(
171  
-				'model' => $matches[1],
172  
-				'foreign_key' => $matches[2],
173  
-			);
174  
-		} else {
175  
-			if (!($this->args[2] == '/')) {
176  
-				$data = array('alias' => $this->args[2]);
177  
-			} else {
178  
-				$this->error(__('/ can not be used as an alias!', true), __('\t/ is the root, please supply a sub alias', true));
179  
-			}
  153
+		$data = $this->parseIdentifier($this->args[2]);
  154
+		if (is_string($data) && $data != '/') {
  155
+			$data = array('alias' => $data);
  156
+		} elseif (is_string($data)) {
  157
+			$this->error(__('/ can not be used as an alias!', true), __("\t/ is the root, please supply a sub alias", true));
180 158
 		}
181 159
 
182 160
 		$data['parent_id'] = $parent;
183  
-		$object->create();
184  
-
185  
-		if ($object->save($data)) {
  161
+		$this->Acl->{$class}->create();
  162
+		if ($this->Acl->{$class}->save($data)) {
186 163
 			$this->out(sprintf(__("New %s '%s' created.\n", true), $class, $this->args[2]), true);
187 164
 		} else {
188 165
 			$this->err(sprintf(__("There was a problem creating a new %s '%s'.", true), $class, $this->args[2]));
@@ -198,7 +175,11 @@ function delete() {
198 175
 		$this->_checkArgs(2, 'delete');
199 176
 		$this->checkNodeType();
200 177
 		extract($this->__dataVars());
201  
-		if (!$this->Acl->{$class}->delete($this->args[1])) {
  178
+
  179
+		$identifier = $this->parseIdentifier($this->args[1]);
  180
+		$nodeId = $this->_getNodeId($class, $identifier);
  181
+
  182
+		if (!$this->Acl->{$class}->delete($nodeId)) {
202 183
 			$this->error(__("Node Not Deleted", true), sprintf(__("There was an error deleting the %s. Check that the node exists", true), $class) . ".\n");
203 184
 		}
204 185
 		$this->out(sprintf(__("%s deleted", true), $class) . ".\n", true);
@@ -213,10 +194,13 @@ function setParent() {
213 194
 		$this->_checkArgs(3, 'setParent');
214 195
 		$this->checkNodeType();
215 196
 		extract($this->__dataVars());
  197
+		$target = $this->parseIdentifier($this->args[1]);
  198
+		$parent = $this->parseIdentifier($this->args[2]);
  199
+
216 200
 		$data = array(
217 201
 			$class => array(
218  
-				'id' => $this->args[1],
219  
-				'parent_id' => $this->args[2]
  202
+				'id' => $this->_getNodeId($class, $target),
  203
+				'parent_id' => $this->_getNodeId($class, $parent)
220 204
 			)
221 205
 		);
222 206
 		$this->Acl->{$class}->create();
@@ -378,64 +362,81 @@ function initdb() {
378 362
  * @access public
379 363
  */
380 364
 	function help() {
381  
-		$head  = __("Usage: cake acl <command> <arg1> <arg2>...", true) . "\n";
  365
+		$head = "-----------------------------------------------\n";
  366
+		$head .= __("Usage: cake acl <command> <arg1> <arg2>...", true) . "\n";
382 367
 		$head .= "-----------------------------------------------\n";
383  
-		$head .= __("Commands:", true) . "\n\n";
  368
+		$head .= __("Commands:", true) . "\n";
384 369
 
385 370
 		$commands = array(
386  
-			'create' => "\tcreate aro|aco <parent> <node>\n" .
387  
-						"\t\t" . __("Creates a new ACL object <node> under the parent specified by <parent>, an id/alias.", true) . "\n" .
388  
-						"\t\t" . __("The <parent> and <node> references can be in one of the following formats:", true) . "\n" .
389  
-						"\t\t\t- " . __("<model>.<id> - The node will be bound to a specific record of the given model", true) . "\n" .
390  
-						"\t\t\t- " . __("<alias> - The node will be given a string alias (or path, in the case of <parent>),", true) . "\n" .
391  
-						"\t\t\t  " . __("i.e. 'John'.  When used with <parent>, this takes the form of an alias path,", true) . "\n" .
392  
-						"\t\t\t  " . __("i.e. <group>/<subgroup>/<parent>.", true) . "\n" .
393  
-						"\t\t" . __("To add a node at the root level, enter 'root' or '/' as the <parent> parameter.", true) . "\n",
394  
-
395  
-			'delete' =>	"\tdelete aro|aco <node>\n" .
396  
-						"\t\t" . __("Deletes the ACL object with the given <node> reference (see 'create' for info on node references).", true) . "\n",
397  
-
398  
-			'setparent' => "\tsetParent aro|aco <node> <parent>\n" .
399  
-							"\t\t" . __("Moves the ACL object specified by <node> beneath the parent ACL object specified by <parent>.", true) . "\n" .
400  
-							"\t\t" . __("To identify the node and parent, use the row id.", true) . "\n",
401  
-
402  
-			'getpath' => "\tgetPath aro|aco <node>\n" .
403  
-						"\t\t" . __("Returns the path to the ACL object specified by <node>. This command", true) . "\n" .
404  
-						"\t\t" . __("is useful in determining the inhertiance of permissions for a certain", true) . "\n" .
405  
-						"\t\t" . __("object in the tree.", true) . "\n" .
406  
-						"\t\t" . __("For more detailed parameter usage info, see help for the 'create' command.", true) . "\n",
407  
-
408  
-			'check' =>	"\tcheck <aro_id> <aco_id> [<aco_action>] " . __("or", true) . " all\n" .
409  
-						"\t\t" . __("Use this command to check ACL permissions.", true) . "\n" .
410  
-						"\t\t" . __("For more detailed parameter usage info, see help for the 'create' command.", true) . "\n",
411  
-
412  
-			'grant' =>	"\tgrant <aro_id> <aco_id> [<aco_action>] " . __("or", true) . " all\n" .
413  
-						"\t\t" . __("Use this command to grant ACL permissions. Once executed, the ARO", true) . "\n" .
414  
-						"\t\t" . __("specified (and its children, if any) will have ALLOW access to the", true) . "\n" .
415  
-						"\t\t" . __("specified ACO action (and the ACO's children, if any).", true) . "\n" .
416  
-						"\t\t" . __("For more detailed parameter usage info, see help for the 'create' command.", true) . "\n",
417  
-
418  
-			'deny' =>	"\tdeny <aro_id> <aco_id> [<aco_action>]" . __("or", true) . " all\n" .
419  
-						"\t\t" . __("Use this command to deny ACL permissions. Once executed, the ARO", true) . "\n" .
420  
-						"\t\t" . __("specified (and its children, if any) will have DENY access to the", true) . "\n" .
421  
-						"\t\t" . __("specified ACO action (and the ACO's children, if any).", true) . "\n" .
422  
-						"\t\t" . __("For more detailed parameter usage info, see help for the 'create' command.", true) . "\n",
423  
-
424  
-			'inherit' =>	"\tinherit <aro_id> <aco_id> [<aco_action>]" . __("or", true) . " all\n" .
425  
-							"\t\t" . __("Use this command to force a child ARO object to inherit its", true) . "\n" .
426  
-							"\t\t" . __("permissions settings from its parent.", true) . "\n" .
427  
-							"\t\t" . __("For more detailed parameter usage info, see help for the 'create' command.", true) . "\n",
428  
-
429  
-			'view' =>	"\tview aro|aco [<node>]\n" .
430  
-						"\t\t" . __("The view command will return the ARO or ACO tree. The optional", true) . "\n" .
431  
-						"\t\t" . __("id/alias parameter allows you to return only a portion of the requested tree.", true) . "\n" .
432  
-						"\t\t" . __("For more detailed parameter usage info, see help for the 'create' command.", true) . "\n",
433  
-
434  
-			'initdb' =>	"\tinitdb\n".
435  
-						"\t\t" . __("Uses this command : cake schema run create DbAcl", true) . "\n",
436  
-
437  
-			'help' => 	"\thelp [<command>]\n" .
438  
-						"\t\t" . __("Displays this help message, or a message on a specific command.", true) . "\n"
  371
+			'create' => "create aro|aco <parent> <node>\n" .
  372
+				"\t" . __("Creates a new ACL object <node> under the parent", true) . "\n" .
  373
+				"\t" . __("specified by <parent>, an id/alias.", true) . "\n" .
  374
+				"\t" . __("The <parent> and <node> references can be", true) . "\n" .
  375
+				"\t" . __("in one of the following formats:", true) . "\n\n" .
  376
+				"\t\t- " . __("<model>.<id> - The node will be bound to a", true) . "\n" .
  377
+				"\t\t" . __("specific record of the given model.", true) . "\n\n" .
  378
+				"\t\t- " . __("<alias> - The node will be given a string alias,", true) . "\n" .
  379
+				"\t\t" . __(" (or path, in the case of <parent>)", true) . "\n" .
  380
+				"\t\t  " . __("i.e. 'John'.  When used with <parent>,", true) . "\n" .
  381
+				"\t\t" . __("this takes the form of an alias path,", true) . "\n" .
  382
+				"\t\t  " . __("i.e. <group>/<subgroup>/<parent>.", true) . "\n\n" .
  383
+				"\t" . __("To add a node at the root level,", true) . "\n" .
  384
+				"\t" . __("enter 'root' or '/' as the <parent> parameter.", true) . "\n",
  385
+
  386
+			'delete' => "delete aro|aco <node>\n" .
  387
+				"\t" . __("Deletes the ACL object with the given <node> reference", true) . "\n" .
  388
+				"\t" . __("For more detailed parameter usage info,", true) . "\n" .
  389
+				"\t" . __("see help for the 'create' command.", true),
  390
+
  391
+			'setparent' => "setParent aro|aco <node> <parent>\n" .
  392
+				"\t" . __("Moves the ACL object specified by <node> beneath", true) . "\n" .
  393
+				"\t" . __("the parent ACL object specified by <parent>.", true) . "\n" .
  394
+				"\t" . __("For more detailed parameter usage info,", true) . "\n" .
  395
+				"\t" . __("see help for the 'create' command.", true),
  396
+
  397
+			'getpath' => "getPath aro|aco <node>\n" .
  398
+				"\t" . __("Returns the path to the ACL object specified by <node>. This command", true) . "\n" .
  399
+				"\t" . __("is useful in determining the inhertiance of permissions for a certain", true) . "\n" .
  400
+				"\t" . __("object in the tree.", true) . "\n" .
  401
+				"\t" . __("For more detailed parameter usage info,", true) . "\n" .
  402
+				"\t" . __("see help for the 'create' command.", true),
  403
+
  404
+			'check' => "check <aro_id> <aco_id> [<aco_action>] " . __("or", true) . " all\n" .
  405
+				"\t" . __("Use this command to check ACL permissions.", true) . "\n" .
  406
+				"\t" . __("For more detailed parameter usage info,", true) . "\n" .
  407
+				"\t" . __("see help for the 'create' command.", true),
  408
+
  409
+			'grant' => "grant <aro_id> <aco_id> [<aco_action>] " . __("or", true) . " all\n" .
  410
+				"\t" . __("Use this command to grant ACL permissions. Once executed, the ARO", true) . "\n" .
  411
+				"\t" . __("specified (and its children, if any) will have ALLOW access to the", true) . "\n" .
  412
+				"\t" . __("specified ACO action (and the ACO's children, if any).", true) . "\n" .
  413
+				"\t" . __("For more detailed parameter usage info,", true) . "\n" .
  414
+				"\t" . __("see help for the 'create' command.", true),
  415
+
  416
+			'deny' => "deny <aro_id> <aco_id> [<aco_action>]" . __("or", true) . " all\n" .
  417
+				"\t" . __("Use this command to deny ACL permissions. Once executed, the ARO", true) . "\n" .
  418
+				"\t" . __("specified (and its children, if any) will have DENY access to the", true) . "\n" .
  419
+				"\t" . __("specified ACO action (and the ACO's children, if any).", true) . "\n" .
  420
+				"\t" . __("For more detailed parameter usage info,", true) . "\n" .
  421
+				"\t" . __("see help for the 'create' command.", true),
  422
+
  423
+			'inherit' => "inherit <aro_id> <aco_id> [<aco_action>]" . __("or", true) . " all\n" .
  424
+				"\t" . __("Use this command to force a child ARO object to inherit its", true) . "\n" .
  425
+				"\t" . __("permissions settings from its parent.", true) . "\n" .
  426
+				"\t" . __("For more detailed parameter usage info,", true) . "\n" .
  427
+				"\t" . __("see help for the 'create' command.", true),
  428
+
  429
+			'view' => "view aro|aco [<node>]\n" .
  430
+				"\t" . __("The view command will return the ARO or ACO tree.", true) . "\n" .
  431
+				"\t" . __("The optional id/alias parameter allows you to return\n\tonly a portion of the requested tree.", true) . "\n" .
  432
+				"\t" . __("For more detailed parameter usage info,", true) . "\n" .
  433
+				"\t" . __("see help for the 'create' command.", true),
  434
+
  435
+			'initdb' => "initdb\n".
  436
+				"\t" . __("Uses this command : cake schema run create DbAcl", true),
  437
+
  438
+			'help' => "help [<command>]\n" .
  439
+				"\t" . __("Displays this help message, or a message on a specific command.", true)
439 440
 		);
440 441
 
441 442
 		$this->out($head);
@@ -443,8 +444,8 @@ function help() {
443 444
 			foreach ($commands as $cmd) {
444 445
 				$this->out("{$cmd}\n\n");
445 446
 			}
446  
-		} elseif (isset($commands[low($this->args[0])])) {
447  
-			$this->out($commands[low($this->args[0])] . "\n\n");
  447
+		} elseif (isset($commands[strtolower($this->args[0])])) {
  448
+			$this->out($commands[strtolower($this->args[0])] . "\n\n");
448 449
 		} else {
449 450
 			$this->out(sprintf(__("Command '%s' not found", true), $this->args[0]));
450 451
 		}
@@ -477,7 +478,7 @@ function nodeExists() {
477 478
 			return false;
478 479
 		}
479 480
 		extract($this->__dataVars($this->args[0]));
480  
-		$key = (ife(is_numeric($this->args[1]), $secondary_id, 'alias'));
  481
+		$key = is_numeric($this->args[1]) ? $secondary_id : 'alias';
481 482
 		$conditions = array($class . '.' . $key => $this->args[1]);
482 483
 		$possibility = $this->Acl->{$class}->find('all', compact('conditions'));
483 484
 		if (empty($possibility)) {
@@ -487,6 +488,42 @@ function nodeExists() {
487 488
 	}
488 489
 
489 490
 /**
  491
+ * Parse an identifier into Model.foriegnKey or an alias.
  492
+ * Takes an identifier determines its type and returns the result as used by other methods.
  493
+ *
  494
+ * @param string $identifier Identifier to parse
  495
+ * @return mixed a string for aliases, and an array for model.foreignKey
  496
+ **/
  497
+	function parseIdentifier($identifier) {
  498
+		if (preg_match('/^([\w]+)\.(.*)$/', $identifier, $matches)) {
  499
+			return array(
  500
+				'model' => $matches[1],
  501
+				'foreign_key' => $matches[2],
  502
+			);
  503
+		}
  504
+		return $identifier;
  505
+	}
  506
+
  507
+/**
  508
+ * Get the node for a given identifier. $identifier can either be a string alias
  509
+ * or an array of properties to use in AcoNode::node()
  510
+ *
  511
+ * @param string $class Class type you want (Aro/Aco)
  512
+ * @param mixed $identifier A mixed identifier for finding the node.
  513
+ * @return int Integer of NodeId. Will trigger an error if nothing is found.
  514
+ **/
  515
+	function _getNodeId($class, $identifier) {
  516
+		$node = $this->Acl->{$class}->node($identifier);
  517
+		if (empty($node)) {
  518
+			if (is_array($identifier)) {
  519
+				$identifier = var_export($identifier, true);
  520
+			}
  521
+			$this->error(sprintf(__('Could not find node using reference "%s"', true), $identifier));
  522
+		}
  523
+		return Set::extract($node, "0.{$class}.id");
  524
+	}
  525
+
  526
+/**
490 527
  * get params for standard Acl methods
491 528
  *
492 529
  * @return array aro, aco, action
@@ -533,7 +570,7 @@ function __dataVars($type = null) {
533 570
 		}
534 571
 		$vars = array();
535 572
 		$class = ucwords($type);
536  
-		$vars['secondary_id'] = ife(strtolower($class) == 'aro', 'foreign_key', 'object_id');
  573
+		$vars['secondary_id'] = (strtolower($class) == 'aro') ? 'foreign_key' : 'object_id';
537 574
 		$vars['data_name'] = $type;
538 575
 		$vars['table_name'] = $type . 's';
539 576
 		$vars['class'] = $class;
2  cake/console/libs/api.php
@@ -47,7 +47,7 @@ class ApiShell extends Shell {
47 47
  *
48 48
  * @access public
49 49
  */
50  
-	function initialize () {
  50
+	function initialize() {
51 51
 		$this->paths = array_merge($this->paths, array(
52 52
 			'behavior' => LIBS . 'model' . DS . 'behaviors' . DS,
53 53
 			'cache' => LIBS . 'cache' . DS,
2  cake/console/libs/bake.php
@@ -157,7 +157,7 @@ function all() {
157 157
 			$object = new $model();
158 158
 			$modelExists = true;
159 159
 		} else {
160  
-			App::import('Model');
  160
+			App::import('Model', 'Model', false);
161 161
 			$object = new Model(array('name' => $name, 'ds' => $this->connection));
162 162
 		}
163 163
 
4  cake/console/libs/schema.php
@@ -27,7 +27,7 @@
27 27
  * @license       http://www.opensource.org/licenses/mit-license.php The MIT License
28 28
  */
29 29
 App::import('File');
30  
-App::import('Model', 'CakeSchema');
  30
+App::import('Model', 'CakeSchema', false);
31 31
 
32 32
 /**
33 33
  * Schema is a command-line database management utility for automating programmer chores.
@@ -208,7 +208,7 @@ function dump() {
208 208
 			}
209 209
 		}
210 210
 		$db =& ConnectionManager::getDataSource($this->Schema->connection);
211  
-		$contents = "#". $Schema->name ." sql generated on: " . date('Y-m-d H:i:s') . " : ". time()."\n\n";
  211
+		$contents = "#" . $Schema->name . " sql generated on: " . date('Y-m-d H:i:s') . " : " . time() . "\n\n";
212 212
 		$contents .= $db->dropSchema($Schema) . "\n\n". $db->createSchema($Schema);
213 213
 		if ($write) {
214 214
 			if (strpos($write, '.sql') === false) {
89  cake/console/libs/shell.php
@@ -320,7 +320,7 @@ function loadTasks() {
320 320
 			}
321 321
 
322 322
 			if (!isset($this->{$taskName})) {
323  
-				$this->err("Task '".$taskName."' could not be loaded");
  323
+				$this->err("Task '" . $taskName . "' could not be loaded");
324 324
 				$this->_stop();
325 325
 			}
326 326
 		}
@@ -363,69 +363,78 @@ function in($prompt, $options = null, $default = null) {
363 363
 	}
364 364
 
365 365
 /**
366  
- * Outputs to the stdout filehandle.
  366
+ * Outputs a single or multiple messages to stdout.
367 367
  *
368  
- * @param string $string String to output.
369  
- * @param boolean $newline If true, the outputs gets an added newline.
  368
+ * @param mixed $message A string or a an array of strings to output
  369
+ * @param mixed $after Appended to message, if true a newline is used
370 370
  * @access public
371 371
  */
372  
-	function out($string, $newline = true) {
373  
-		if (is_array($string)) {
374  
-			$str = '';
375  
-			foreach ($string as $message) {
376  
-				$str .= $message ."\n";
377  
-			}
378  
-			$string = $str;
  372
+	function out($message, $after = true) {
  373
+		if (is_array($message)) {
  374
+			$message = implode($this->nl(), $message);
379 375
 		}
380  
-		return $this->Dispatch->stdout($string, $newline);
  376
+		$this->Dispatch->stdout($message . $this->nl($after), false);
381 377
 	}
382 378
 
383 379
 /**
384  
- * Outputs to the stderr filehandle.
  380
+ * Outputs a single or multiple error messages to stderr.
385 381
  *
386  
- * @param string $string Error text to output.
  382
+ * @param mixed $message A string or a an array of strings to output
  383
+ * @param mixed $after Appended to message, if true a newline is used
387 384
  * @access public
388 385
  */
389  
-	function err($string) {
390  
-		if (is_array($string)) {
391  
-			$str = '';
392  
-			foreach ($string as $message) {
393  
-				$str .= $message ."\n";
394  
-			}
395  
-			$string = $str;
  386
+	function err($message, $after = true) {
  387
+		if (is_array($message)) {
  388
+			$message = implode($this->nl(), $message);
396 389
 		}
397  
-		return $this->Dispatch->stderr($string."\n");
  390
+		$this->Dispatch->stderr($message . $this->nl($after));
398 391
 	}
399 392
 
400 393
 /**
401  
- * Outputs a series of minus characters to the standard output, acts as a visual separator.
  394
+ * Returns a single or multiple linefeeds sequences.
402 395
  *
403  
- * @param boolean $newline If true, the outputs gets an added newline.
  396
+ * @param mixed $format If true returns a linefeed sequence, if false null,
  397
+ *	if a string is given that is returned,
  398
+ *	if an integer is given it is used as a multiplier to return multiple linefeed sequences
404 399
  * @access public
  400
+ * @return string
405 401
  */
406  
-	function hr($newline = false) {
407  
-		if ($newline) {
408  
-			$this->out("\n");
  402
+	function nl($format = true) {
  403
+		if (is_string($format)) {
  404
+			return $format . "\n";
409 405
 		}
410  
-		$this->out('---------------------------------------------------------------');
411  
-		if ($newline) {
412  
-			$this->out("\n");
  406
+		if (is_int($format)) {
  407
+			return str_repeat("\n", $format);
413 408
 		}
  409
+		return $format ? "\n" : null;
414 410
 	}
415 411
 
416 412
 /**
417  
- * Displays a formatted error message and exits the application
  413
+ * Outputs a series of minus characters to the standard output, acts as a visual separator.
418 414
  *
419  
- * @param string $title Title of the error message
420  
- * @param string $msg Error message
  415
+ * @param mixed $surround If true, the outputs gets surrounded by newlines.
421 416
  * @access public
422 417
  */
423  
-	function error($title, $msg) {
424  
-		$out  = "$title\n";
425  
-		$out .= "$msg\n";
426  
-		$out .= "\n";
427  
-		$this->err($out);
428  
-		$this->_stop();
  418
+	function hr($surround = false) {
  419
+		$this->out(null, $surround);
  420
+		$this->out('---------------------------------------------------------------');
  421
+		$this->out(null, $surround);
  422
+	}
  423
+/**
  424
+ * Displays a formatted error message
  425
+ * and exits the application with status code 1
  426
+ *
  427
+ * @param string $title Title of the error
  428
+ * @param string $message An optional error message
  429
+ * @access public
  430
+ */
  431
+	function error($title, $message = null) {
  432
+		$this->err(sprintf(__('Error: %s', true), $title));
  433
+
  434
+		if (!empty($message)) {
  435
+			$this->err($message);
  436
+		}
  437
+		$this->_stop(1);
429 438
 	}
430 439
 
431 440
 /**
@@ -466,7 +475,7 @@ function createFile ($path, $contents) {
466 475
 			}
467 476
 		}
468 477
 		if (!class_exists('File')) {
469  
-			uses('file');
  478
+			require LIBS . 'file.php';
470 479
 		}
471 480
 
472 481
 		if ($File = new File($path, true)) {
4  cake/console/libs/tasks/fixture.php
@@ -74,7 +74,7 @@ function __construct(&$dispatch) {
74 74
 		parent::__construct($dispatch);
75 75
 		$this->path = $this->params['working'] . DS . 'tests' . DS . 'fixtures' . DS;
76 76
 		if (!class_exists('CakeSchema')) {
77  
-			App::import('Model', 'CakeSchema');
  77
+			App::import('Model', 'CakeSchema', false);
78 78
 		}
79 79
 	}
80 80
 
@@ -384,7 +384,7 @@ function _getRecordsFromTable($modelName, $useTable = null) {
384 384
 		while (!$condition) {
385 385
 			$condition = $this->in($prompt, null, 'WHERE 1=1 LIMIT 10');
386 386
 		}
387  
-		App::import('Core', 'Model');
  387
+		App::import('Model', 'Model', false);
388 388
 		$modelObject =& new Model(array('name' => $modelName, 'table' => $useTable, 'ds' => $this->connection));
389 389
 		$records = $modelObject->find('all', array(
390 390
 			'conditions' => $condition,
3  cake/console/libs/tasks/model.php
@@ -20,7 +20,7 @@
20 20
  * @since         CakePHP(tm) v 1.2
21 21
  * @license       http://www.opensource.org/licenses/mit-license.php The MIT License
22 22
  */
23  
-App::import('Model', 'ConnectionManager');
  23
+App::import('Model', 'Model', false);
24 24
 
25 25
 /**
26 26
  * Task class for creating and updating model files.
@@ -82,7 +82,6 @@ class ModelTask extends Shell {
82 82
  * @return void
83 83
  **/
84 84
 	function startup() {
85  
-		App::import('Core', 'Model');
86 85
 		parent::startup();
87 86
 	}
88 87
 
8  cake/console/libs/tasks/project.php
@@ -155,7 +155,7 @@ function bake($path, $skel = null, $skip = array('empty')) {
155 155
 				$this->out(sprintf(__("Created: %s in %s", true), $app, $path));
156 156
 				$this->hr();
157 157
 			} else {
158  
-				$this->err(" '".$app."' could not be created properly");
  158
+				$this->err(" '" . $app . "' could not be created properly");
159 159
 				return false;
160 160
 			}
161 161
 
@@ -200,7 +200,7 @@ function securitySalt($path) {
200 200
 		$contents = $File->read();
201 201
 		if (preg_match('/([\\t\\x20]*Configure::write\\(\\\'Security.salt\\\',[\\t\\x20\'A-z0-9]*\\);)/', $contents, $match)) {
202 202
 			if (!class_exists('Security')) {
203  
-				uses('Security');
  203
+				require LIBS . 'security.php';
204 204
 			}
205 205
 			$string = Security::generateAuthKey();
206 206
 			$result = str_replace($match[0], "\t" . 'Configure::write(\'Security.salt\', \''.$string.'\');', $contents);
@@ -224,7 +224,7 @@ function corePath($path) {
224 224
 			$File =& new File($path . 'webroot' . DS . 'index.php');
225 225
 			$contents = $File->read();
226 226
 			if (preg_match('/([\\t\\x20]*define\\(\\\'CAKE_CORE_INCLUDE_PATH\\\',[\\t\\x20\'A-z0-9]*\\);)/', $contents, $match)) {
227  
-				$result = str_replace($match[0], "\t\tdefine('CAKE_CORE_INCLUDE_PATH', '".CAKE_CORE_INCLUDE_PATH."');", $contents);
  227
+				$result = str_replace($match[0], "\t\tdefine('CAKE_CORE_INCLUDE_PATH', '" . CAKE_CORE_INCLUDE_PATH . "');", $contents);
228 228
 				if (!$File->write($result)) {
229 229
 					return false;
230 230
 				}
@@ -235,7 +235,7 @@ function corePath($path) {
235 235
 			$File =& new File($path . 'webroot' . DS . 'test.php');
236 236
 			$contents = $File->read();
237 237
 			if (preg_match('/([\\t\\x20]*define\\(\\\'CAKE_CORE_INCLUDE_PATH\\\',[\\t\\x20\'A-z0-9]*\\);)/', $contents, $match)) {
238  
-				$result = str_replace($match[0], "\t\tdefine('CAKE_CORE_INCLUDE_PATH', '".CAKE_CORE_INCLUDE_PATH."');", $contents);
  238
+				$result = str_replace($match[0], "\t\tdefine('CAKE_CORE_INCLUDE_PATH', '" . CAKE_CORE_INCLUDE_PATH . "');", $contents);
239 239
 				if (!$File->write($result)) {
240 240
 					return false;
241 241
 				}
2  cake/console/libs/tasks/view.php
@@ -20,7 +20,7 @@
20 20
  * @since         CakePHP(tm) v 1.2
21 21
  * @license       http://www.opensource.org/licenses/mit-license.php The MIT License
22 22
  */
23  
-App::import('Core', 'Controller');
  23
+App::import('Controller', 'Controller', false);
24 24
 
25 25
 /**
26 26
  * Task class for creating and updating view files.
6  cake/console/libs/templates/default/views/form.ctp
@@ -26,7 +26,7 @@
26 26
 <div class="<?php echo $pluralVar;?> form">
27 27
 <?php echo "<?php echo \$form->create('{$modelClass}');?>\n";?>
28 28
 	<fieldset>
29  
- 		<legend><?php echo "<?php __('".Inflector::humanize($action)." {$singularHumanName}');?>";?></legend>
  29
+ 		<legend><?php echo "<?php __('" . Inflector::humanize($action) . " {$singularHumanName}');?>";?></legend>
30 30
 <?php
31 31
 		echo "\t<?php\n";
32 32
 		foreach ($fields as $field) {
@@ -59,8 +59,8 @@
59 59
 		foreach ($associations as $type => $data) {
60 60
 			foreach ($data as $alias => $details) {
61 61
 				if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) {
62  
-					echo "\t\t<li><?php echo \$html->link(__('List ".Inflector::humanize($details['controller'])."', true), array('controller' => '{$details['controller']}', 'action' => 'index')); ?> </li>\n";
63  
-					echo "\t\t<li><?php echo \$html->link(__('New ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n";
  62
+					echo "\t\t<li><?php echo \$html->link(__('List " . Inflector::humanize($details['controller']) . "', true), array('controller' => '{$details['controller']}', 'action' => 'index')); ?> </li>\n";
  63
+					echo "\t\t<li><?php echo \$html->link(__('New " . Inflector::humanize(Inflector::underscore($alias)) . "', true), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n";
64 64
 					$done[] = $details['controller'];
65 65
 				}
66 66
 			}
6  cake/console/libs/templates/default/views/home.ctp
... ...
@@ -1,5 +1,5 @@
1 1
 <?php
2  
-$output = "<h2>Sweet, \"".Inflector::humanize($app)."\" got Baked by CakePHP!</h2>\n";
  2
+$output = "<h2>Sweet, \"" . Inflector::humanize($app) . "\" got Baked by CakePHP!</h2>\n";
3 3
 $output .="
4 4
 <?php
5 5
 if (Configure::read() > 0):
@@ -52,7 +52,9 @@ endif;
52 52
 </p>
53 53
 <?php
54 54
 if (!empty(\$filePresent)):
55  
- 	uses('model' . DS . 'connection_manager');
  55
+	if (!class_exists('ConnectionManager')) {
  56
+		require LIBS . 'model' . DS . 'connection_manager.php';
  57
+	}
56 58
 	\$db = ConnectionManager::getInstance();
57 59
  	\$connected = \$db->getDataSource('default');
58 60
 ?>
4  cake/console/libs/templates/default/views/index.ctp
@@ -89,8 +89,8 @@ echo "<?php endforeach; ?>\n";
89 89
 	foreach ($associations as $type => $data) {
90 90
 		foreach ($data as $alias => $details) {
91 91
 			if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) {
92  
-				echo "\t\t<li><?php echo \$html->link(__('List ".Inflector::humanize($details['controller'])."', true), array('controller' => '{$details['controller']}', 'action' => 'index')); ?> </li>\n";
93  
-				echo "\t\t<li><?php echo \$html->link(__('New ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n";
  92
+				echo "\t\t<li><?php echo \$html->link(__('List " . Inflector::humanize($details['controller']) . "', true), array('controller' => '{$details['controller']}', 'action' => 'index')); ?> </li>\n";
  93
+				echo "\t\t<li><?php echo \$html->link(__('New " . Inflector::humanize(Inflector::underscore($alias)) . "', true), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n";
94 94
 				$done[] = $details['controller'];
95 95
 			}
96 96
 		}
18  cake/console/libs/templates/default/views/view.ctp
@@ -33,14 +33,14 @@ foreach ($fields as $field) {
33 33
 		foreach ($associations['belongsTo'] as $alias => $details) {
34 34
 			if ($field === $details['foreignKey']) {
35 35
 				$isKey = true;
36  
-				echo "\t\t<dt<?php if (\$i % 2 == 0) echo \$class;?>><?php __('".Inflector::humanize(Inflector::underscore($alias))."'); ?></dt>\n";
  36
+				echo "\t\t<dt<?php if (\$i % 2 == 0) echo \$class;?>><?php __('" . Inflector::humanize(Inflector::underscore($alias)) . "'); ?></dt>\n";
37 37
 				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";
38 38
 				break;
39 39
 			}
40 40
 		}
41 41
 	}
42 42
 	if ($isKey !== true) {
43  
-		echo "\t\t<dt<?php if (\$i % 2 == 0) echo \$class;?>><?php __('".Inflector::humanize($field)."'); ?></dt>\n";
  43
+		echo "\t\t<dt<?php if (\$i % 2 == 0) echo \$class;?>><?php __('" . Inflector::humanize($field) . "'); ?></dt>\n";
44 44
 		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";
45 45
 	}
46 46
 }
@@ -59,8 +59,8 @@ foreach ($fields as $field) {
59 59
 	foreach ($associations as $type => $data) {
60 60
 		foreach ($data as $alias => $details) {
61 61
 			if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) {
62  
-				echo "\t\t<li><?php echo \$html->link(__('List ".Inflector::humanize($details['controller'])."', true), array('controller' => '{$details['controller']}', 'action' => 'index')); ?> </li>\n";
63  
-				echo "\t\t<li><?php echo \$html->link(__('New ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n";
  62
+				echo "\t\t<li><?php echo \$html->link(__('List " . Inflector::humanize($details['controller']) . "', true), array('controller' => '{$details['controller']}', 'action' => 'index')); ?> </li>\n";
  63
+				echo "\t\t<li><?php echo \$html->link(__('New " . Inflector::humanize(Inflector::underscore($alias)) . "', true), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n";
64 64
 				$done[] = $details['controller'];
65 65
 			}
66 66
 		}
@@ -72,12 +72,12 @@ foreach ($fields as $field) {
72 72
 if (!empty($associations[