Skip to content
This repository
Browse code

Moving bake templates into templates/default.

Adding 'console template themes' to TemplateTask.
Adding test cases for console themes.
Moving files around.
  • Loading branch information...
commit ad98139e35b46f17ed742d7985523ca550210b0b 1 parent 9627af2
Mark Story authored July 01, 2009
94  cake/console/libs/tasks/template.php
@@ -2,7 +2,6 @@
2 2
 /**
3 3
  * Template Task can generate templated output Used in other Tasks
4 4
  *
5  
- * 
6 5
  *
7 6
  * PHP versions 4 and 5
8 7
  *
@@ -26,39 +25,48 @@ class TemplateTask extends Shell {
26 25
  * @var array
27 26
  **/
28 27
 	var $templateVars = array();
29  
-	
  28
+
30 29
 /**
31 30
  * Paths to look for templates on.
  31
+ * Contains a list of $theme => $path
32 32
  *
33 33
  * @var array
34 34
  **/
35 35
 	var $templatePaths = array();
  36
+
36 37
 /**
37  
- * Initialize callback
  38
+ * Initialize callback.  Setup paths for the template task.
38 39
  *
39 40
  * @access public
40 41
  * @return void
41 42
  **/
42 43
 	function initialize() {
43  
-		$this->templatePaths = $this->Dispatch->shellPaths;
  44
+		$this->templatePaths = $this->_findThemes();
44 45
 	}
45 46
 
46 47
 /**
47  
- * Find a template 
  48
+ * Find the paths to all the installed shell themes in the app.
48 49
  *
49  
- * @param string $directory Subdirectory to look for ie. 'views', 'objects'
50  
- * @param string $filename lower_case_underscored filename you want.
51  
- * @access public
52  
- * @return string filename or false if scan failed.
  50
+ * Bake themes are directories not named `skel` inside a `vendors/shells/templates` path.
  51
+ *
  52
+ * @return array Array of bake themes that are installed.
53 53
  **/
54  
-	function _findTemplate($directory, $filename) {
55  
-		foreach ($this->templatePaths as $path) {
56  
-			$templatePath = $path . 'templates' . DS . $directory . DS . $filename . '.ctp';
57  
-			if (file_exists($templatePath) && is_file($templatePath)) {
58  
-				return $templatePath;
  54
+	function _findThemes() {
  55
+		$paths = $this->Dispatch->shellPaths;
  56
+		$themes = array();
  57
+		foreach ($paths as $path) {
  58
+			$Folder =& new Folder($path . 'templates', false);
  59
+			$contents = $Folder->read();
  60
+			$subDirs = $contents[0];
  61
+			foreach ($subDirs as $dir) {
  62
+				if (empty($dir) || $dir == 'skel') {
  63
+					continue;
  64
+				}
  65
+				$templateDir = $path . 'templates' . DS . $dir . DS;
  66
+				$themes[$dir] = $templateDir;
59 67
 			}
60 68
 		}
61  
-		return false;
  69
+		return $themes;
62 70
 	}
63 71
 
64 72
 /**
@@ -106,7 +114,8 @@ function generate($directory, $filename, $vars = null) {
106 114
 		if (empty($this->templatePaths)) {
107 115
 			$this->initialize();
108 116
 		}
109  
-		$templateFile = $this->_findTemplate($directory, $filename);
  117
+		$themePath = $this->getThemePath();
  118
+		$templateFile = $this->_findTemplate($themePath, $directory, $filename);
110 119
 		if ($templateFile) {
111 120
 			extract($this->templateVars);
112 121
 			ob_start();
@@ -117,4 +126,57 @@ function generate($directory, $filename, $vars = null) {
117 126
 		}
118 127
 		return '';
119 128
 	}
  129
+
  130
+/**
  131
+ * Find the theme name for the current operation.
  132
+ * If there is only one theme in $templatePaths it will be used.
  133
+ * If there is a -theme param in the cli args, it will be used.
  134
+ * If there is more than one installed theme user interaction will happen
  135
+ *
  136
+ * @return string returns the path to the selected theme.
  137
+ **/
  138
+	function getThemePath() {
  139
+		if (count($this->templatePaths) == 1) {
  140
+			$paths = array_values($this->templatePaths);
  141
+			return $paths[0];
  142
+		}
  143
+		if (!empty($this->params['theme']) && isset($this->templatePaths[$this->params['theme']])) {
  144
+			return $this->templatePaths[$this->params['theme']];
  145
+		}
  146
+		$i = 1;
  147
+		$indexedPaths = array();
  148
+		foreach ($this->templatePaths as $key => $path) {
  149
+			$this->out($i . '. ' . $key);
  150
+			$indexedPaths[$i] = $path;
  151
+			$i++;
  152
+		}
  153
+		$index = $this->in(__('Which bake theme would you like to use?', true), range(1, $i), 1);
  154
+		return $indexedPaths[$index];
  155
+	}
  156
+
  157
+/**
  158
+ * Find a template inside a directory inside a path.
  159
+ * Will scan all other theme dirs if the template is not found in the first directory.
  160
+ *
  161
+ * @param string $path The initial path to look for the file on. If it is not found fallbacks will be used.
  162
+ * @param string $directory Subdirectory to look for ie. 'views', 'objects'
  163
+ * @param string $filename lower_case_underscored filename you want.
  164
+ * @access public
  165
+ * @return string filename will exit program if template is not found.
  166
+ **/
  167
+	function _findTemplate($path, $directory, $filename) {
  168
+		$themeFile = $path . $directory . DS . $filename . '.ctp';
  169
+		if (file_exists($themeFile)) {
  170
+			return $themeFile;
  171
+		}
  172
+		foreach ($this->templatePaths as $path) {
  173
+			$templatePath = $path . $directory . DS . $filename . '.ctp';
  174
+			if (file_exists($templatePath)) {
  175
+				return $templatePath;
  176
+			}
  177
+		}
  178
+		$this->err(sprintf(__('Could not find template for %s, exiting.'), $filename));
  179
+		$this->_stop();
  180
+	}
  181
+
120 182
 }
142  cake/console/libs/templates/default/actions/controller_actions.ctp
... ...
@@ -0,0 +1,142 @@
  1
+<?php
  2
+/**
  3
+ * Bake Template for Controller action generation.
  4
+ *
  5
+ *
  6
+ *
  7
+ * PHP versions 4 and 5
  8
+ *
  9
+ * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  10
+ * Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org)
  11
+ *
  12
+ * Licensed under The MIT License
  13
+ * Redistributions of files must retain the above copyright notice.
  14
+ *
  15
+ * @copyright     Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org)
  16
+ * @link          http://cakephp.org
  17
+ * @package       cake
  18
+ * @subpackage    cake.console.libs.template.objects
  19
+ * @since         CakePHP(tm) v 1.3
  20
+ * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
  21
+ */
  22
+?>
  23
+
  24
+	function <?php echo $admin ?>index() {
  25
+		$this-><?php echo $currentModelName ?>->recursive = 0;
  26
+		$this->set('<?php echo $pluralName ?>', $this->paginate());
  27
+	}
  28
+
  29
+	function <?php echo $admin ?>view($id = null) {
  30
+		if (!$id) {
  31
+<?php if ($wannaUseSession): ?>
  32
+			$this->Session->setFlash(__('Invalid <?php echo $singularHumanName ?>', true));
  33
+			$this->redirect(array('action' => 'index'));
  34
+<?php else: ?>
  35
+			$this->flash(__('Invalid <?php echo $singularHumanName; ?>', true), array('action' => 'index'));
  36
+<?php endif; ?>
  37
+		}
  38
+		$this->set('<?php echo $singularName; ?>', $this-><?php echo $currentModelName; ?>->read(null, $id));
  39
+	}
  40
+
  41
+<?php $compact = array(); ?>
  42
+	function <?php echo $admin ?>add() {
  43
+		if (!empty($this->data)) {
  44
+			$this-><?php echo $currentModelName; ?>->create();
  45
+			if ($this-><?php echo $currentModelName; ?>->save($this->data)) {
  46
+<?php if ($wannaUseSession): ?>
  47
+				$this->Session->setFlash(__('The <?php echo $singularHumanName; ?> has been saved', true));
  48
+				$this->redirect(array('action' => 'index'));
  49
+<?php else: ?>
  50
+				$this->flash(__('<?php echo $currentModelName; ?> saved.', true), array('action' => 'index'));
  51
+<?php endif; ?>
  52
+			} else {
  53
+<?php if ($wannaUseSession): ?>
  54
+				$this->Session->setFlash(__('The <?php echo $singularHumanName; ?> could not be saved. Please, try again.', true));
  55
+<?php endif; ?>
  56
+			}
  57
+		}
  58
+<?php
  59
+	foreach (array('belongsTo', 'hasAndBelongsToMany') as $assoc):
  60
+		foreach ($modelObj->{$assoc} as $associationName => $relation):
  61
+			if (!empty($associationName)):
  62
+				$otherModelName = $this->_modelName($associationName);
  63
+				$otherPluralName = $this->_pluralName($associationName);
  64
+				echo "\t\t\${$otherPluralName} = \$this->{$currentModelName}->{$otherModelName}->find('list');\n";
  65
+				$compact[] = "'{$otherPluralName}'";
  66
+			endif;
  67
+		endforeach;
  68
+	endforeach;
  69
+	if (!empty($compact)):
  70
+		echo "\t\t\$this->set(compact(".join(', ', $compact)."));\n";
  71
+	endif;
  72
+?>
  73
+	}
  74
+
  75
+<?php $compact = array(); ?>
  76
+	function <?php echo $admin; ?>edit($id = null) {
  77
+		if (!$id && empty($this->data)) {
  78
+<?php if ($wannaUseSession): ?>
  79
+			$this->Session->setFlash(__('Invalid <?php echo $singularHumanName; ?>', true));
  80
+			$this->redirect(array('action' => 'index'));
  81
+<?php else: ?>
  82
+			$this->flash(__('Invalid <?php echo $singularHumanName; ?>', true), array('action' => 'index'));
  83
+<?php endif; ?>
  84
+		}
  85
+		if (!empty($this->data)) {
  86
+			if ($this-><?php echo $currentModelName; ?>->save($this->data)) {
  87
+<?php if ($wannaUseSession): ?>
  88
+				$this->Session->setFlash(__('The <?php echo $singularHumanName; ?> has been saved', true));
  89
+				$this->redirect(array('action' => 'index'));
  90
+<?php else: ?>
  91
+				$this->flash(__('The <?php echo $singularHumanName; ?> has been saved.', true), array('action' => 'index'));
  92
+<?php endif; ?>
  93
+			} else {
  94
+<?php if ($wannaUseSession): ?>
  95
+				$this->Session->setFlash(__('The <?php echo $singularHumanName; ?> could not be saved. Please, try again.', true));
  96
+<?php endif; ?>
  97
+			}
  98
+		}
  99
+		if (empty($this->data)) {
  100
+			$this->data = $this-><?php echo $currentModelName; ?>->read(null, $id);
  101
+		}
  102
+<?php
  103
+		foreach (array('belongsTo', 'hasAndBelongsToMany') as $assoc):
  104
+			foreach ($modelObj->{$assoc} as $associationName => $relation):
  105
+				if (!empty($associationName)):
  106
+					$otherModelName = $this->_modelName($associationName);
  107
+					$otherPluralName = $this->_pluralName($associationName);
  108
+					echo "\t\t\${$otherPluralName} = \$this->{$currentModelName}->{$otherModelName}->find('list');\n";
  109
+					$compact[] = "'{$otherPluralName}'";
  110
+				endif;
  111
+			endforeach;
  112
+		endforeach;
  113
+		if (!empty($compact)):
  114
+			echo "\t\t\$this->set(compact(".join(', ', $compact)."));\n";
  115
+		endif;
  116
+	?>
  117
+	}
  118
+
  119
+	function <?php echo $admin; ?>delete($id = null) {
  120
+		if (!$id) {
  121
+<?php if ($wannaUseSession): ?>
  122
+			$this->Session->setFlash(__('Invalid id for <?php echo $singularHumanName; ?>', true));
  123
+			$this->redirect(array('action'=>'index'));
  124
+<?php else: ?>
  125
+			$this->flash(__('Invalid <?php echo $singularHumanName; ?>', true), array('action' => 'index'));
  126
+<?php endif; ?>
  127
+		}
  128
+		if ($this-><?php echo $currentModelName; ?>->del($id)) {
  129
+<?php if ($wannaUseSession): ?>
  130
+			$this->Session->setFlash(__('<?php echo $singularHumanName; ?> deleted', true));
  131
+			$this->redirect(array('action'=>'index'));
  132
+<?php else: ?>
  133
+			$this->flash(__('<?php echo $singularHumanName; ?> deleted', true), array('action' => 'index'));
  134
+<?php endif; ?>
  135
+		}
  136
+<?php if ($wannaUseSession): ?>
  137
+		$this->Session->setFlash(__('<?php echo $singularHumanName; ?> was not deleted', true));
  138
+<?php else: ?>
  139
+		$this->flash(__('<?php echo $singularHumanName; ?> was not deleted', true), array('action' => 'index'));
  140
+<?php endif; ?>
  141
+		$this->redirect(array('action' => 'index'));
  142
+	}
57  cake/console/libs/templates/default/classes/controller.ctp
... ...
@@ -0,0 +1,57 @@
  1
+<?php
  2
+/**
  3
+ * Controller bake template file
  4
+ *
  5
+ * Allows templating of Controllers generated from bake.
  6
+ *
  7
+ * PHP versions 4 and 5
  8
+ *
  9
+ * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  10
+ * Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org)
  11
+ *
  12
+ * Licensed under The MIT License
  13
+ * Redistributions of files must retain the above copyright notice.
  14
+ *
  15
+ * @copyright     Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org)
  16
+ * @link          http://cakephp.org
  17
+ * @package       cake
  18
+ * @subpackage    cake.
  19
+ * @since         CakePHP(tm) v 1.3
  20
+ * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
  21
+ */
  22
+
  23
+echo "<?php\n";
  24
+?>
  25
+class <?php echo $controllerName; ?>Controller extends <?php echo $plugin; ?>AppController {
  26
+
  27
+	var $name = '<?php echo $controllerName; ?>';
  28
+<?php if ($isScaffold): ?>
  29
+	var $scaffold;
  30
+<?php else: ?>
  31
+<?php
  32
+
  33
+echo "\tvar \$helpers = array('Html', 'Form'";
  34
+if (count($helpers)):
  35
+	foreach ($helpers as $help):
  36
+		echo ", '" . Inflector::camelize($help) . "'";
  37
+	endforeach;
  38
+endif;
  39
+echo ");\n";
  40
+
  41
+if (count($components)):
  42
+	echo "\tvar \$components = array(";
  43
+	for ($i = 0, $len = count($components); $i < $len; $i++):
  44
+		if ($i != $len - 1):
  45
+			echo "'" . Inflector::camelize($components[$i]) . "', ";
  46
+		else:
  47
+			echo "'" . Inflector::camelize($components[$i]) . "'";
  48
+		endif;
  49
+	endfor;
  50
+	echo ");\n";
  51
+endif;
  52
+
  53
+echo $actions;
  54
+
  55
+endif; ?>
  56
+}
  57
+<?php echo "?>"; ?>
42  cake/console/libs/templates/default/classes/fixture.ctp
... ...
@@ -0,0 +1,42 @@
  1
+<?php
  2
+/**
  3
+ * Fixture Template file
  4
+ *
  5
+ * Fixture Template used when baking fixtures with bake
  6
+ *
  7
+ * PHP versions 4 and 5
  8
+ *
  9
+ * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  10
+ * Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org)
  11
+ *
  12
+ * Licensed under The MIT License
  13
+ * Redistributions of files must retain the above copyright notice.
  14
+ *
  15
+ * @copyright     Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org)
  16
+ * @link          http://cakephp.org
  17
+ * @package       cake
  18
+ * @subpackage    cake.
  19
+ * @since         CakePHP(tm) v 1.3
  20
+ * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
  21
+ */
  22
+?>
  23
+<?php echo '<?php' . "\n"; ?>
  24
+/* <?php echo $model; ?> Fixture generated on: <?php echo  date('Y-m-d H:m:s') . " : ". time(); ?> */
  25
+class <?php echo $model; ?>Fixture extends CakeTestFixture {
  26
+	var $name = '<?php echo $model; ?>';
  27
+<?php if ($table): ?>
  28
+	var $table = '<?php echo $table; ?>';
  29
+<?php endif; ?>
  30
+<?php if ($import): ?>
  31
+	var $import = <?php echo $import; ?>;
  32
+<?php endif;?>
  33
+
  34
+<?php if ($schema): ?>
  35
+	var $fields = <?php echo $schema; ?>;
  36
+<?php endif;?>
  37
+
  38
+<?php if ($records): ?>
  39
+	var $records = <?php echo $records; ?>;
  40
+<?php endif;?>
  41
+}
  42
+<?php echo '?>'; ?>
127  cake/console/libs/templates/default/classes/model.ctp
... ...
@@ -0,0 +1,127 @@
  1
+<?php
  2
+/**
  3
+ * Model template file.
  4
+ *
  5
+ * Used by bake to create new Model files.
  6
+ *
  7
+ * PHP versions 4 and 5
  8
+ *
  9
+ * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  10
+ * Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org)
  11
+ *
  12
+ * Licensed under The MIT License
  13
+ * Redistributions of files must retain the above copyright notice.
  14
+ *
  15
+ * @copyright     Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org)
  16
+ * @link          http://cakephp.org
  17
+ * @package       cake
  18
+ * @subpackage    cake.console.libs.templates.objects
  19
+ * @since         CakePHP(tm) v 1.3
  20
+ * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
  21
+ */
  22
+
  23
+echo "<?php\n"; ?>
  24
+class <?php echo $name ?> extends <?php echo $plugin; ?>AppModel {
  25
+	var $name = '<?php echo $name; ?>';
  26
+<?php if ($useDbConfig != 'default'): ?>
  27
+	var $useDbConfig = '<?php echo $useDbConfig; ?>';
  28
+<?php endif;?>
  29
+<?php if ($useTable && $useTable !== Inflector::tableize($name)):
  30
+	$table = "'$useTable'";
  31
+	echo "\tvar \$useTable = $table;\n";
  32
+endif;
  33
+if ($primaryKey !== 'id'): ?>
  34
+	var $primaryKey = '<?php echo $primaryKey; ?>';
  35
+<?php endif;
  36
+
  37
+if (!empty($validate)):
  38
+	echo "\tvar \$validate = array(\n";
  39
+	foreach ($validate as $field => $validations):
  40
+		echo "\t\t'$field' => array(\n";
  41
+		foreach ($validations as $key => $validator):
  42
+			echo "\t\t\t'$key' => array('rule' => array('$validator')),\n";
  43
+		endforeach;
  44
+		echo "\t\t),\n";
  45
+	endforeach;
  46
+	echo "\t);\n";
  47
+endif;
  48
+
  49
+?>
  50
+	//The Associations below have been created with all possible keys, those that are not needed can be removed
  51
+<?php
  52
+
  53
+foreach (array('hasOne', 'belongsTo') as $assocType):
  54
+	if (!empty($associations[$assocType])):
  55
+		$typeCount = count($associations[$assocType]);
  56
+		echo "\n\tvar \$$assocType = array(";
  57
+		foreach ($associations[$assocType] as $i => $relation):
  58
+			$out = "\n\t\t'{$relation['alias']}' => array(\n";
  59
+			$out .= "\t\t\t'className' => '{$relation['className']}',\n";
  60
+			$out .= "\t\t\t'foreignKey' => '{$relation['foreignKey']}',\n";
  61
+			$out .= "\t\t\t'conditions' => '',\n";
  62
+			$out .= "\t\t\t'fields' => '',\n";
  63
+			$out .= "\t\t\t'order' => ''\n";
  64
+			$out .= "\t\t)";
  65
+			if ($i + 1 < $typeCount) {
  66
+				$out .= ",";
  67
+			}
  68
+			echo $out;
  69
+		endforeach;
  70
+		echo "\n\t);\n";
  71
+	endif;
  72
+endforeach;
  73
+
  74
+if (!empty($associations['hasMany'])):
  75
+	$belongsToCount = count($associations['hasMany']);
  76
+	echo "\n\tvar \$hasMany = array(";
  77
+	foreach ($associations['hasMany'] as $i => $relation):
  78
+		$out = "\n\t\t'{$relation['alias']}' => array(\n";
  79
+		$out .= "\t\t\t'className' => '{$relation['className']}',\n";
  80
+		$out .= "\t\t\t'foreignKey' => '{$relation['foreignKey']}',\n";
  81
+		$out .= "\t\t\t'dependent' => false,\n";
  82
+		$out .= "\t\t\t'conditions' => '',\n";
  83
+		$out .= "\t\t\t'fields' => '',\n";
  84
+		$out .= "\t\t\t'order' => '',\n";
  85
+		$out .= "\t\t\t'limit' => '',\n";
  86
+		$out .= "\t\t\t'offset' => '',\n";
  87
+		$out .= "\t\t\t'exclusive' => '',\n";
  88
+		$out .= "\t\t\t'finderQuery' => '',\n";
  89
+		$out .= "\t\t\t'counterQuery' => ''\n";
  90
+		$out .= "\t\t)";
  91
+		if ($i + 1 < $belongsToCount) {
  92
+			$out .= ",";
  93
+		}
  94
+		echo $out;
  95
+	endforeach;
  96
+	echo "\n\t);\n\n";
  97
+endif;
  98
+
  99
+if (!empty($associations['hasAndBelongsToMany'])):
  100
+	$habtmCount = count($associations['hasAndBelongsToMany']);
  101
+	echo "\n\tvar \$hasAndBelongsToMany = array(";
  102
+	foreach ($associations['hasAndBelongsToMany'] as $i => $relation):
  103
+		$out = "\n\t\t'{$relation['alias']}' => array(\n";
  104
+		$out .= "\t\t\t'className' => '{$relation['className']}',\n";
  105
+		$out .= "\t\t\t'joinTable' => '{$relation['joinTable']}',\n";
  106
+		$out .= "\t\t\t'foreignKey' => '{$relation['foreignKey']}',\n";
  107
+		$out .= "\t\t\t'associationForeignKey' => '{$relation['associationForeignKey']}',\n";
  108
+		$out .= "\t\t\t'unique' => true,\n";
  109
+		$out .= "\t\t\t'conditions' => '',\n";
  110
+		$out .= "\t\t\t'fields' => '',\n";
  111
+		$out .= "\t\t\t'order' => '',\n";
  112
+		$out .= "\t\t\t'limit' => '',\n";
  113
+		$out .= "\t\t\t'offset' => '',\n";
  114
+		$out .= "\t\t\t'finderQuery' => '',\n";
  115
+		$out .= "\t\t\t'deleteQuery' => '',\n";
  116
+		$out .= "\t\t\t'insertQuery' => ''\n";
  117
+		$out .= "\t\t)";
  118
+		if ($i + 1 < $habtmCount) {
  119
+			$out .= ",";
  120
+		}
  121
+		echo $out;
  122
+	endforeach;
  123
+	echo "\n\t);\n\n";
  124
+endif;
  125
+?>
  126
+}
  127
+<?php echo '?>'; ?>
57  cake/console/libs/templates/default/classes/test.ctp
... ...
@@ -0,0 +1,57 @@
  1
+<?php
  2
+/**
  3
+ * Test Case bake template
  4
+ *
  5
+ *
  6
+ * PHP versions 4 and 5
  7
+ *
  8
+ * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  9
+ * Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org)
  10
+ *
  11
+ * Licensed under The MIT License
  12
+ * Redistributions of files must retain the above copyright notice.
  13
+ *
  14
+ * @copyright     Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org)
  15
+ * @link          http://cakephp.org
  16
+ * @package       cake
  17
+ * @subpackage    cake.console.libs.templates.objects
  18
+ * @since         CakePHP(tm) v 1.3
  19
+ * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
  20
+ */
  21
+echo "<?php\n";
  22
+echo "/* ". $className ." Test cases generated on: " . date('Y-m-d H:m:s') . " : ". time() . "*/\n";
  23
+?>
  24
+App::import('<?php echo $type; ?>', '<?php echo $plugin . $className;?>');
  25
+
  26
+<?php if ($mock and strtolower($type) == 'controller'): ?>
  27
+class Test<?php echo $fullClassName; ?> extends <?php echo $fullClassName; ?> {
  28
+	var $autoRender = false;
  29
+
  30
+	function redirect($url, $status = null, $exit = true) {
  31
+		$this->redirectUrl = $url;
  32
+	}
  33
+}
  34
+
  35
+<?php endif; ?>
  36
+class <?php echo $fullClassName; ?>TestCase extends CakeTestCase {
  37
+<?php if (!empty($fixtures)): ?>
  38
+	var $fixtures = array('<?php echo join("', '", $fixtures); ?>');
  39
+
  40
+<?php endif; ?>
  41
+	function startTest() {
  42
+		$this-><?php echo $className . ' =& ' . $construction; ?>
  43
+	}
  44
+
  45
+	function endTest() {
  46
+		unset($this-><?php echo $className;?>);
  47
+		ClassRegistry::flush();
  48
+	}
  49
+
  50
+<?php foreach ($methods as $method): ?>
  51
+	function test<?php echo Inflector::classify($method); ?>() {
  52
+		
  53
+	}
  54
+
  55
+<?php endforeach;?>
  56
+}
  57
+<?php echo '?>'; ?>
69  cake/console/libs/templates/default/views/form.ctp
... ...
@@ -0,0 +1,69 @@
  1
+<?php
  2
+/* SVN FILE: $Id$ */
  3
+/**
  4
+ *
  5
+ * PHP versions 4 and 5
  6
+ *
  7
+ * CakePHP(tm) :  Rapid Development Framework (http://www.cakephp.org)
  8
+ * Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
  9
+ *
  10
+ * Licensed under The MIT License
  11
+ * Redistributions of files must retain the above copyright notice.
  12
+ *
  13
+ * @filesource
  14
+ * @copyright     Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
  15
+ * @link          http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
  16
+ * @package       cake
  17
+ * @subpackage    cake.cake.console.libs.templates.views
  18
+ * @since         CakePHP(tm) v 1.2.0.5234
  19
+ * @version       $Revision$
  20
+ * @modifiedby    $LastChangedBy$
  21
+ * @lastmodified  $Date$
  22
+ * @license       http://www.opensource.org/licenses/mit-license.php The MIT License
  23
+ */
  24
+?>
  25
+<div class="<?php echo $pluralVar;?> form">
  26
+<?php echo "<?php echo \$form->create('{$modelClass}');?>\n";?>
  27
+	<fieldset>
  28
+ 		<legend><?php echo "<?php __('".Inflector::humanize($action)." {$singularHumanName}');?>";?></legend>
  29
+<?php
  30
+		echo "\t<?php\n";
  31
+		foreach ($fields as $field) {
  32
+			if ($action == 'add' && $field == $primaryKey) {
  33
+				continue;
  34
+			} elseif (!in_array($field, array('created', 'modified', 'updated'))) {
  35
+				echo "\t\techo \$form->input('{$field}');\n";
  36
+			}
  37
+		}
  38
+		if (!empty($associations['hasAndBelongsToMany'])) {
  39
+			foreach ($associations['hasAndBelongsToMany'] as $assocName => $assocData) {
  40
+				echo "\t\techo \$form->input('{$assocName}');\n";
  41
+			}
  42
+		}
  43
+		echo "\t?>\n";
  44
+?>
  45
+	</fieldset>
  46
+<?php
  47
+	echo "<?php echo \$form->end('Submit');?>\n";
  48
+?>
  49
+</div>
  50
+<div class="actions">
  51
+	<ul>
  52
+<?php if ($action != 'add'):?>
  53
+		<li><?php echo "<?php echo \$html->link(__('Delete', true), array('action'=>'delete', \$form->value('{$modelClass}.{$primaryKey}')), null, sprintf(__('Are you sure you want to delete # %s?', true), \$form->value('{$modelClass}.{$primaryKey}'))); ?>";?></li>
  54
+<?php endif;?>
  55
+		<li><?php echo "<?php echo \$html->link(__('List {$pluralHumanName}', true), array('action'=>'index'));?>";?></li>
  56
+<?php
  57
+		$done = array();
  58
+		foreach ($associations as $type => $data) {
  59
+			foreach ($data as $alias => $details) {
  60
+				if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) {
  61
+					echo "\t\t<li><?php echo \$html->link(__('List ".Inflector::humanize($details['controller'])."', true), array('controller'=> '{$details['controller']}', 'action'=>'index')); ?> </li>\n";
  62
+					echo "\t\t<li><?php echo \$html->link(__('New ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller'=> '{$details['controller']}', 'action'=>'add')); ?> </li>\n";
  63
+					$done[] = $details['controller'];
  64
+				}
  65
+			}
  66
+		}
  67
+?>
  68
+	</ul>
  69
+</div>
82  cake/console/libs/templates/default/views/home.ctp
... ...
@@ -0,0 +1,82 @@
  1
+<?php
  2
+$output = "<h2>Sweet, \"".Inflector::humanize($app)."\" got Baked by CakePHP!</h2>\n";
  3
+$output .="
  4
+<?php
  5
+if (Configure::read() > 0):
  6
+	Debugger::checkSessionKey();
  7
+endif;
  8
+?>
  9
+<p>
  10
+<?php
  11
+	if (is_writable(TMP)):
  12
+		echo '<span class=\"notice success\">';
  13
+			__('Your tmp directory is writable.');
  14
+		echo '</span>';
  15
+	else:
  16
+		echo '<span class=\"notice\">';
  17
+			__('Your tmp directory is NOT writable.');
  18
+		echo '</span>';
  19
+	endif;
  20
+?>
  21
+</p>
  22
+<p>
  23
+<?php
  24
+	\$settings = Cache::settings();
  25
+	if (!empty(\$settings)):
  26
+		echo '<span class=\"notice success\">';
  27
+				echo sprintf(__('The %s is being used for caching. To change the config edit APP/config/core.php ', true), '<em>'. \$settings['engine'] . 'Engine</em>');
  28
+		echo '</span>';
  29
+	else:
  30
+		echo '<span class=\"notice\">';
  31
+				__('Your cache is NOT working. Please check the settings in APP/config/core.php');
  32
+		echo '</span>';
  33
+	endif;
  34
+?>
  35
+</p>
  36
+<p>
  37
+<?php
  38
+	\$filePresent = null;
  39
+	if (file_exists(CONFIGS . 'database.php')):
  40
+		echo '<span class=\"notice success\">';
  41
+			__('Your database configuration file is present.');
  42
+			\$filePresent = true;
  43
+		echo '</span>';
  44
+	else:
  45
+		echo '<span class=\"notice\">';
  46
+			__('Your database configuration file is NOT present.');
  47
+			echo '<br/>';
  48
+			__('Rename config/database.php.default to config/database.php');
  49
+		echo '</span>';
  50
+	endif;
  51
+?>
  52
+</p>
  53
+<?php
  54
+if (!empty(\$filePresent)):
  55
+ 	uses('model' . DS . 'connection_manager');
  56
+	\$db = ConnectionManager::getInstance();
  57
+ 	\$connected = \$db->getDataSource('default');
  58
+?>
  59
+<p>
  60
+<?php
  61
+	if (\$connected->isConnected()):
  62
+		echo '<span class=\"notice success\">';
  63
+ 			__('Cake is able to connect to the database.');
  64
+		echo '</span>';
  65
+	else:
  66
+		echo '<span class=\"notice\">';
  67
+			__('Cake is NOT able to connect to the database.');
  68
+		echo '</span>';
  69
+	endif;
  70
+?>
  71
+</p>\n";
  72
+$output .= "<?php endif;?>\n";
  73
+$output .= "<h3><?php __('Editing this Page') ?></h3>\n";
  74
+$output .= "<p>\n";
  75
+$output .= "<?php\n";
  76
+$output .= "\techo sprintf(__('To change the content of this page, edit: %s\n";
  77
+$output .= "\t\tTo change its layout, edit: %s\n";
  78
+$output .= "\t\tYou can also add some CSS styles for your pages at: %s', true),\n";
  79
+$output .= "\t\tAPP . 'views' . DS . 'pages' . DS . 'home.ctp.<br />',  APP . 'views' . DS . 'layouts' . DS . 'default.ctp.<br />', APP . 'webroot' . DS . 'css');\n";
  80
+$output .= "?>\n";
  81
+$output .= "</p>\n";
  82
+?>
99  cake/console/libs/templates/default/views/index.ctp
... ...
@@ -0,0 +1,99 @@
  1
+<?php
  2
+/* SVN FILE: $Id$ */
  3
+/**
  4
+ *
  5
+ * PHP versions 4 and 5
  6
+ *
  7
+ * CakePHP(tm) :  Rapid Development Framework (http://www.cakephp.org)
  8
+ * Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
  9
+ *
  10
+ * Licensed under The MIT License
  11
+ * Redistributions of files must retain the above copyright notice.
  12
+ *
  13
+ * @filesource
  14
+ * @copyright     Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
  15
+ * @link          http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
  16
+ * @package       cake
  17
+ * @subpackage    cake.cake.console.libs.templates.views
  18
+ * @since         CakePHP(tm) v 1.2.0.5234
  19
+ * @version       $Revision$
  20
+ * @modifiedby    $LastChangedBy$
  21
+ * @lastmodified  $Date$
  22
+ * @license       http://www.opensource.org/licenses/mit-license.php The MIT License
  23
+ */
  24
+?>
  25
+<div class="<?php echo $pluralVar;?> index">
  26
+<h2><?php echo "<?php __('{$pluralHumanName}');?>";?></h2>
  27
+<p>
  28
+<?php echo "<?php
  29
+echo \$paginator->counter(array(
  30
+'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
  31
+));
  32
+?>";?>
  33
+</p>
  34
+<table cellpadding="0" cellspacing="0">
  35
+<tr>
  36
+<?php  foreach ($fields as $field):?>
  37
+	<th><?php echo "<?php echo \$paginator->sort('{$field}');?>";?></th>
  38
+<?php endforeach;?>
  39
+	<th class="actions"><?php echo "<?php __('Actions');?>";?></th>
  40
+</tr>
  41
+<?php
  42
+echo "<?php
  43
+\$i = 0;
  44
+foreach (\${$pluralVar} as \${$singularVar}):
  45
+	\$class = null;
  46
+	if (\$i++ % 2 == 0) {
  47
+		\$class = ' class=\"altrow\"';
  48
+	}
  49
+?>\n";
  50
+	echo "\t<tr<?php echo \$class;?>>\n";
  51
+		foreach ($fields as $field) {
  52
+			$isKey = false;
  53
+			if (!empty($associations['belongsTo'])) {
  54
+				foreach ($associations['belongsTo'] as $alias => $details) {
  55
+					if ($field === $details['foreignKey']) {
  56
+						$isKey = true;
  57
+						echo "\t\t<td>\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</td>\n";
  58
+						break;
  59
+					}
  60
+				}
  61
+			}
  62
+			if ($isKey !== true) {
  63
+				echo "\t\t<td>\n\t\t\t<?php echo \${$singularVar}['{$modelClass}']['{$field}']; ?>\n\t\t</td>\n";
  64
+			}
  65
+		}
  66
+
  67
+		echo "\t\t<td class=\"actions\">\n";
  68
+		echo "\t\t\t<?php echo \$html->link(__('View', true), array('action'=>'view', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n";
  69
+	 	echo "\t\t\t<?php echo \$html->link(__('Edit', true), array('action'=>'edit', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n";
  70
+	 	echo "\t\t\t<?php echo \$html->link(__('Delete', true), array('action'=>'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), null, sprintf(__('Are you sure you want to delete # %s?', true), \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n";
  71
+		echo "\t\t</td>\n";
  72
+	echo "\t</tr>\n";
  73
+
  74
+echo "<?php endforeach; ?>\n";
  75
+?>
  76
+</table>
  77
+</div>
  78
+<div class="paging">
  79
+<?php echo "\t<?php echo \$paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>\n";?>
  80
+ | <?php echo "\t<?php echo \$paginator->numbers();?>\n"?>
  81
+<?php echo "\t<?php echo \$paginator->next(__('next', true).' >>', array(), null, array('class'=>'disabled'));?>\n";?>
  82
+</div>
  83
+<div class="actions">
  84
+	<ul>
  85
+		<li><?php echo "<?php echo \$html->link(__('New {$singularHumanName}', true), array('action'=>'add')); ?>";?></li>
  86
+<?php
  87
+	$done = array();
  88
+	foreach ($associations as $type => $data) {
  89
+		foreach ($data as $alias => $details) {
  90
+			if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) {
  91
+				echo "\t\t<li><?php echo \$html->link(__('List ".Inflector::humanize($details['controller'])."', true), array('controller'=> '{$details['controller']}', 'action'=>'index')); ?> </li>\n";
  92
+				echo "\t\t<li><?php echo \$html->link(__('New ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller'=> '{$details['controller']}', 'action'=>'add')); ?> </li>\n";
  93
+				$done[] = $details['controller'];
  94
+			}
  95
+		}
  96
+	}
  97
+?>
  98
+	</ul>
  99
+</div>
150  cake/console/libs/templates/default/views/view.ctp
... ...
@@ -0,0 +1,150 @@
  1
+<?php
  2
+/* SVN FILE: $Id$ */
  3
+/**
  4
+ *
  5
+ * PHP versions 4 and 5
  6
+ *
  7
+ * CakePHP(tm) :  Rapid Development Framework (http://www.cakephp.org)
  8
+ * Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
  9
+ *
  10
+ * Licensed under The MIT License
  11
+ * Redistributions of files must retain the above copyright notice.
  12
+ *
  13
+ * @filesource
  14
+ * @copyright     Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
  15
+ * @link          http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
  16
+ * @package       cake
  17
+ * @subpackage    cake.cake.console.libs.templates.views
  18
+ * @since         CakePHP(tm) v 1.2.0.5234
  19
+ * @version       $Revision$
  20
+ * @modifiedby    $LastChangedBy$
  21
+ * @lastmodified  $Date$
  22
+ * @license       http://www.opensource.org/licenses/mit-license.php The MIT License
  23
+ */
  24
+?>
  25
+<div class="<?php echo $pluralVar;?> view">
  26
+<h2><?php echo "<?php  __('{$singularHumanName}');?>";?></h2>
  27
+	<dl><?php echo "<?php \$i = 0; \$class = ' class=\"altrow\"';?>\n";?>
  28
+<?php
  29
+foreach ($fields as $field) {
  30
+	$isKey = false;
  31
+	if (!empty($associations['belongsTo'])) {
  32
+		foreach ($associations['belongsTo'] as $alias => $details) {
  33
+			if ($field === $details['foreignKey']) {
  34
+				$isKey = true;
  35
+				echo "\t\t<dt<?php if (\$i % 2 == 0) echo \$class;?>><?php __('".Inflector::humanize(Inflector::underscore($alias))."'); ?></dt>\n";
  36
+				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";
  37
+				break;
  38
+			}
  39
+		}
  40
+	}
  41
+	if ($isKey !== true) {
  42
+		echo "\t\t<dt<?php if (\$i % 2 == 0) echo \$class;?>><?php __('".Inflector::humanize($field)."'); ?></dt>\n";
  43
+		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";
  44
+	}
  45
+}
  46
+?>
  47
+	</dl>
  48
+</div>
  49
+<div class="actions">
  50
+	<ul>
  51
+<?php
  52
+	echo "\t\t<li><?php echo \$html->link(__('Edit {$singularHumanName}', true), array('action'=>'edit', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?> </li>\n";
  53
+	echo "\t\t<li><?php echo \$html->link(__('Delete {$singularHumanName}', true), array('action'=>'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), null, sprintf(__('Are you sure you want to delete # %s?', true), \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?> </li>\n";
  54
+	echo "\t\t<li><?php echo \$html->link(__('List {$pluralHumanName}', true), array('action'=>'index')); ?> </li>\n";
  55
+	echo "\t\t<li><?php echo \$html->link(__('New {$singularHumanName}', true), array('action'=>'add')); ?> </li>\n";
  56
+
  57
+	$done = array();
  58
+	foreach ($associations as $type => $data) {
  59
+		foreach ($data as $alias => $details) {
  60
+			if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) {
  61
+				echo "\t\t<li><?php echo \$html->link(__('List ".Inflector::humanize($details['controller'])."', true), array('controller'=> '{$details['controller']}', 'action'=>'index')); ?> </li>\n";
  62
+				echo "\t\t<li><?php echo \$html->link(__('New ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller'=> '{$details['controller']}', 'action'=>'add')); ?> </li>\n";
  63
+				$done[] = $details['controller'];
  64
+			}
  65
+		}
  66
+	}
  67
+?>
  68
+	</ul>
  69
+</div>
  70
+<?php
  71
+if (!empty($associations['hasOne'])) :
  72
+	foreach ($associations['hasOne'] as $alias => $details): ?>
  73
+	<div class="related">
  74
+		<h3><?php echo "<?php  __('Related ".Inflector::humanize($details['controller'])."');?>";?></h3>
  75
+	<?php echo "<?php if (!empty(\${$singularVar}['{$alias}'])):?>\n";?>
  76
+		<dl><?php echo "\t<?php \$i = 0; \$class = ' class=\"altrow\"';?>\n";?>
  77
+	<?php
  78
+			foreach ($details['fields'] as $field) {
  79
+				echo "\t\t<dt<?php if (\$i % 2 == 0) echo \$class;?>><?php __('".Inflector::humanize($field)."');?></dt>\n";
  80
+				echo "\t\t<dd<?php if (\$i++ % 2 == 0) echo \$class;?>>\n\t<?php echo \${$singularVar}['{$alias}']['{$field}'];?>\n&nbsp;</dd>\n";
  81
+			}
  82
+	?>
  83
+		</dl>
  84
+	<?php echo "<?php endif; ?>\n";?>
  85
+		<div class="actions">
  86
+			<ul>
  87
+				<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";?>
  88
+			</ul>
  89
+		</div>
  90
+	</div>
  91
+	<?php
  92
+	endforeach;
  93
+endif;
  94
+if (empty($associations['hasMany'])) {
  95
+	$associations['hasMany'] = array();
  96
+}
  97
+if (empty($associations['hasAndBelongsToMany'])) {
  98
+	$associations['hasAndBelongsToMany'] = array();
  99
+}
  100
+$relations = array_merge($associations['hasMany'], $associations['hasAndBelongsToMany']);
  101
+$i = 0;
  102
+foreach ($relations as $alias => $details):
  103
+	$otherSingularVar = Inflector::variable($alias);
  104
+	$otherPluralHumanName = Inflector::humanize($details['controller']);
  105
+	?>
  106
+<div class="related">
  107
+	<h3><?php echo "<?php __('Related {$otherPluralHumanName}');?>";?></h3>
  108
+	<?php echo "<?php if (!empty(\${$singularVar}['{$alias}'])):?>\n";?>
  109
+	<table cellpadding = "0" cellspacing = "0">
  110
+	<tr>
  111
+<?php
  112
+			foreach ($details['fields'] as $field) {
  113
+				echo "\t\t<th><?php __('".Inflector::humanize($field)."'); ?></th>\n";
  114
+			}
  115
+?>
  116
+		<th class="actions"><?php echo "<?php __('Actions');?>";?></th>
  117
+	</tr>
  118
+<?php
  119
+echo "\t<?php
  120
+		\$i = 0;
  121
+		foreach (\${$singularVar}['{$alias}'] as \${$otherSingularVar}):
  122
+			\$class = null;
  123
+			if (\$i++ % 2 == 0) {
  124
+				\$class = ' class=\"altrow\"';
  125
+			}
  126
+		?>\n";
  127
+		echo "\t\t<tr<?php echo \$class;?>>\n";
  128
+
  129
+				foreach ($details['fields'] as $field) {
  130
+					echo "\t\t\t<td><?php echo \${$otherSingularVar}['{$field}'];?></td>\n";
  131
+				}
  132
+
  133
+				echo "\t\t\t<td class=\"actions\">\n";
  134
+				echo "\t\t\t\t<?php echo \$html->link(__('View', true), array('controller'=> '{$details['controller']}', 'action'=>'view', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
  135
+				echo "\t\t\t\t<?php echo \$html->link(__('Edit', true), array('controller'=> '{$details['controller']}', 'action'=>'edit', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
  136
+				echo "\t\t\t\t<?php echo \$html->link(__('Delete', true), array('controller'=> '{$details['controller']}', 'action'=>'delete', \${$otherSingularVar}['{$details['primaryKey']}']), null, sprintf(__('Are you sure you want to delete # %s?', true), \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
  137
+				echo "\t\t\t</td>\n";
  138
+			echo "\t\t</tr>\n";
  139
+
  140
+echo "\t<?php endforeach; ?>\n";
  141
+?>
  142
+	</table>
  143
+<?php echo "<?php endif; ?>\n\n";?>
  144
+	<div class="actions">
  145
+		<ul>
  146
+			<li><?php echo "<?php echo \$html->link(__('New ".Inflector::humanize(Inflector::underscore($alias))."', true), array('controller'=> '{$details['controller']}', 'action'=>'add'));?>";?> </li>
  147
+		</ul>
  148
+	</div>
  149
+</div>
  150
+<?php endforeach;?>
66  cake/tests/cases/console/libs/tasks/template.test.php
@@ -33,9 +33,7 @@
33 33
 	ob_end_clean();
34 34
 }
35 35
 
36  
-if (!class_exists('TemplateTask')) {
37  
-	require_once CAKE . 'console' .  DS . 'libs' . DS . 'tasks' . DS . 'template.php';
38  
-}
  36
+require_once CAKE . 'console' .  DS . 'libs' . DS . 'tasks' . DS . 'template.php';
39 37
 
40 38
 Mock::generatePartial(
41 39
 	'ShellDispatcher', 'TestTemplateTaskMockShellDispatcher',
@@ -96,13 +94,40 @@ function testSet() {
96 94
 	}
97 95
 
98 96
 /**
99  
- * test Initialize
  97
+ * test finding themes installed in 
100 98
  *
101 99
  * @return void
102 100
  **/
103  
-	function testInitialize() {
  101
+	function testFindingInstalledThemesForBake() {
  102
+		$consoleLibs = CAKE_CORE_INCLUDE_PATH . DS . CONSOLE_LIBS;
  103
+		$this->Task->Dispatch->shellPaths = array($consoleLibs);
104 104
 		$this->Task->initialize();
105  
-		$this->assertEqual($this->Task->templatePaths, $this->Task->Dispatch->shellPaths);
  105
+		$this->assertEqual($this->Task->templatePaths, array('default' => $consoleLibs . 'templates' . DS . 'default' . DS));
  106
+	}
  107
+
  108
+/**
  109
+ * test getting the correct theme name.  Ensure that with only one theme, or a theme param
  110
+ * that the user is not bugged.  If there are more, find and return the correct theme name
  111
+ *
  112
+ * @return void
  113
+ **/
  114
+	function testGetThemePath() {
  115
+		$defaultTheme = CAKE_CORE_INCLUDE_PATH . DS . CONSOLE_LIBS . 'templates' . DS . 'default' .DS;
  116
+		$this->Task->templatePaths = array('default' => $defaultTheme);
  117
+		$this->Task->expectCallCount('in', 1);
  118
+
  119
+		$result = $this->Task->getThemePath();
  120
+		$this->assertEqual($result, $defaultTheme);
  121
+
  122
+		$this->Task->templatePaths = array('default' => $defaultTheme, 'other' => '/some/path');
  123
+		$this->Task->params['theme'] = 'other';
  124
+		$result = $this->Task->getThemePath();
  125
+		$this->assertEqual($result, '/some/path');
  126
+
  127
+		$this->Task->params = array();
  128
+		$this->Task->setReturnValueAt(0, 'in', '1');
  129
+		$result = $this->Task->getThemePath();
  130
+		$this->assertEqual($result, $defaultTheme);
106 131
 	}
107 132
 
108 133
 /**
@@ -111,12 +136,37 @@ function testInitialize() {
111 136
  * @return void
112 137
  **/
113 138
 	function testGenerate() {
114  
-		$this->Task->templatePaths = array(
  139
+		$this->Task->Dispatch->shellPaths = array(
115 140
 			TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS .  'test_app' . DS . 'vendors' . DS . 'shells' . DS
116 141
 		);
117  
-		$result = $this->Task->generate('objects', 'test_object', array('test' => 'foo'));
  142
+		$this->Task->initialize();
  143
+		$result = $this->Task->generate('classes', 'test_object', array('test' => 'foo'));
118 144
 		$expected = "I got rendered\nfoo";
119 145
 		$this->assertEqual($result, $expected);
120 146
 	}
  147
+
  148
+/**
  149
+ * test generate with a missing template in the chosen theme.
  150
+ * ensure fallback to default works.
  151
+ *
  152
+ * @return void
  153
+ **/
  154
+	function testGenerateWithTemplateFallbacks() {
  155
+		$this->Task->Dispatch->shellPaths = array(
  156
+			TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS