Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moving bake templates into templates/default.
Adding 'console template themes' to TemplateTask. Adding test cases for console themes. Moving files around.
- Loading branch information
Showing
13 changed files
with
963 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
142 changes: 142 additions & 0 deletions
142
cake/console/libs/templates/default/actions/controller_actions.ctp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
<?php | ||
/** | ||
* Bake Template for Controller action generation. | ||
* | ||
* | ||
* | ||
* PHP versions 4 and 5 | ||
* | ||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org) | ||
* Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* | ||
* Licensed under The MIT License | ||
* Redistributions of files must retain the above copyright notice. | ||
* | ||
* @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* @link http://cakephp.org | ||
* @package cake | ||
* @subpackage cake.console.libs.template.objects | ||
* @since CakePHP(tm) v 1.3 | ||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) | ||
*/ | ||
?> | ||
|
||
function <?php echo $admin ?>index() { | ||
$this-><?php echo $currentModelName ?>->recursive = 0; | ||
$this->set('<?php echo $pluralName ?>', $this->paginate()); | ||
} | ||
|
||
function <?php echo $admin ?>view($id = null) { | ||
if (!$id) { | ||
<?php if ($wannaUseSession): ?> | ||
$this->Session->setFlash(__('Invalid <?php echo $singularHumanName ?>', true)); | ||
$this->redirect(array('action' => 'index')); | ||
<?php else: ?> | ||
$this->flash(__('Invalid <?php echo $singularHumanName; ?>', true), array('action' => 'index')); | ||
<?php endif; ?> | ||
} | ||
$this->set('<?php echo $singularName; ?>', $this-><?php echo $currentModelName; ?>->read(null, $id)); | ||
} | ||
|
||
<?php $compact = array(); ?> | ||
function <?php echo $admin ?>add() { | ||
if (!empty($this->data)) { | ||
$this-><?php echo $currentModelName; ?>->create(); | ||
if ($this-><?php echo $currentModelName; ?>->save($this->data)) { | ||
<?php if ($wannaUseSession): ?> | ||
$this->Session->setFlash(__('The <?php echo $singularHumanName; ?> has been saved', true)); | ||
$this->redirect(array('action' => 'index')); | ||
<?php else: ?> | ||
$this->flash(__('<?php echo $currentModelName; ?> saved.', true), array('action' => 'index')); | ||
<?php endif; ?> | ||
} else { | ||
<?php if ($wannaUseSession): ?> | ||
$this->Session->setFlash(__('The <?php echo $singularHumanName; ?> could not be saved. Please, try again.', true)); | ||
<?php endif; ?> | ||
} | ||
} | ||
<?php | ||
foreach (array('belongsTo', 'hasAndBelongsToMany') as $assoc): | ||
foreach ($modelObj->{$assoc} as $associationName => $relation): | ||
if (!empty($associationName)): | ||
$otherModelName = $this->_modelName($associationName); | ||
$otherPluralName = $this->_pluralName($associationName); | ||
echo "\t\t\${$otherPluralName} = \$this->{$currentModelName}->{$otherModelName}->find('list');\n"; | ||
$compact[] = "'{$otherPluralName}'"; | ||
endif; | ||
endforeach; | ||
endforeach; | ||
if (!empty($compact)): | ||
echo "\t\t\$this->set(compact(".join(', ', $compact)."));\n"; | ||
endif; | ||
?> | ||
} | ||
|
||
<?php $compact = array(); ?> | ||
function <?php echo $admin; ?>edit($id = null) { | ||
if (!$id && empty($this->data)) { | ||
<?php if ($wannaUseSession): ?> | ||
$this->Session->setFlash(__('Invalid <?php echo $singularHumanName; ?>', true)); | ||
$this->redirect(array('action' => 'index')); | ||
<?php else: ?> | ||
$this->flash(__('Invalid <?php echo $singularHumanName; ?>', true), array('action' => 'index')); | ||
<?php endif; ?> | ||
} | ||
if (!empty($this->data)) { | ||
if ($this-><?php echo $currentModelName; ?>->save($this->data)) { | ||
<?php if ($wannaUseSession): ?> | ||
$this->Session->setFlash(__('The <?php echo $singularHumanName; ?> has been saved', true)); | ||
$this->redirect(array('action' => 'index')); | ||
<?php else: ?> | ||
$this->flash(__('The <?php echo $singularHumanName; ?> has been saved.', true), array('action' => 'index')); | ||
<?php endif; ?> | ||
} else { | ||
<?php if ($wannaUseSession): ?> | ||
$this->Session->setFlash(__('The <?php echo $singularHumanName; ?> could not be saved. Please, try again.', true)); | ||
<?php endif; ?> | ||
} | ||
} | ||
if (empty($this->data)) { | ||
$this->data = $this-><?php echo $currentModelName; ?>->read(null, $id); | ||
} | ||
<?php | ||
foreach (array('belongsTo', 'hasAndBelongsToMany') as $assoc): | ||
foreach ($modelObj->{$assoc} as $associationName => $relation): | ||
if (!empty($associationName)): | ||
$otherModelName = $this->_modelName($associationName); | ||
$otherPluralName = $this->_pluralName($associationName); | ||
echo "\t\t\${$otherPluralName} = \$this->{$currentModelName}->{$otherModelName}->find('list');\n"; | ||
$compact[] = "'{$otherPluralName}'"; | ||
endif; | ||
endforeach; | ||
endforeach; | ||
if (!empty($compact)): | ||
echo "\t\t\$this->set(compact(".join(', ', $compact)."));\n"; | ||
endif; | ||
?> | ||
} | ||
|
||
function <?php echo $admin; ?>delete($id = null) { | ||
if (!$id) { | ||
<?php if ($wannaUseSession): ?> | ||
$this->Session->setFlash(__('Invalid id for <?php echo $singularHumanName; ?>', true)); | ||
$this->redirect(array('action'=>'index')); | ||
<?php else: ?> | ||
$this->flash(__('Invalid <?php echo $singularHumanName; ?>', true), array('action' => 'index')); | ||
<?php endif; ?> | ||
} | ||
if ($this-><?php echo $currentModelName; ?>->del($id)) { | ||
<?php if ($wannaUseSession): ?> | ||
$this->Session->setFlash(__('<?php echo $singularHumanName; ?> deleted', true)); | ||
$this->redirect(array('action'=>'index')); | ||
<?php else: ?> | ||
$this->flash(__('<?php echo $singularHumanName; ?> deleted', true), array('action' => 'index')); | ||
<?php endif; ?> | ||
} | ||
<?php if ($wannaUseSession): ?> | ||
$this->Session->setFlash(__('<?php echo $singularHumanName; ?> was not deleted', true)); | ||
<?php else: ?> | ||
$this->flash(__('<?php echo $singularHumanName; ?> was not deleted', true), array('action' => 'index')); | ||
<?php endif; ?> | ||
$this->redirect(array('action' => 'index')); | ||
} |
57 changes: 57 additions & 0 deletions
57
cake/console/libs/templates/default/classes/controller.ctp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
/** | ||
* Controller bake template file | ||
* | ||
* Allows templating of Controllers generated from bake. | ||
* | ||
* PHP versions 4 and 5 | ||
* | ||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org) | ||
* Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* | ||
* Licensed under The MIT License | ||
* Redistributions of files must retain the above copyright notice. | ||
* | ||
* @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* @link http://cakephp.org | ||
* @package cake | ||
* @subpackage cake. | ||
* @since CakePHP(tm) v 1.3 | ||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) | ||
*/ | ||
|
||
echo "<?php\n"; | ||
?> | ||
class <?php echo $controllerName; ?>Controller extends <?php echo $plugin; ?>AppController { | ||
|
||
var $name = '<?php echo $controllerName; ?>'; | ||
<?php if ($isScaffold): ?> | ||
var $scaffold; | ||
<?php else: ?> | ||
<?php | ||
|
||
echo "\tvar \$helpers = array('Html', 'Form'"; | ||
if (count($helpers)): | ||
foreach ($helpers as $help): | ||
echo ", '" . Inflector::camelize($help) . "'"; | ||
endforeach; | ||
endif; | ||
echo ");\n"; | ||
|
||
if (count($components)): | ||
echo "\tvar \$components = array("; | ||
for ($i = 0, $len = count($components); $i < $len; $i++): | ||
if ($i != $len - 1): | ||
echo "'" . Inflector::camelize($components[$i]) . "', "; | ||
else: | ||
echo "'" . Inflector::camelize($components[$i]) . "'"; | ||
endif; | ||
endfor; | ||
echo ");\n"; | ||
endif; | ||
|
||
echo $actions; | ||
|
||
endif; ?> | ||
} | ||
<?php echo "?>"; ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
/** | ||
* Fixture Template file | ||
* | ||
* Fixture Template used when baking fixtures with bake | ||
* | ||
* PHP versions 4 and 5 | ||
* | ||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org) | ||
* Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* | ||
* Licensed under The MIT License | ||
* Redistributions of files must retain the above copyright notice. | ||
* | ||
* @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* @link http://cakephp.org | ||
* @package cake | ||
* @subpackage cake. | ||
* @since CakePHP(tm) v 1.3 | ||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) | ||
*/ | ||
?> | ||
<?php echo '<?php' . "\n"; ?> | ||
/* <?php echo $model; ?> Fixture generated on: <?php echo date('Y-m-d H:m:s') . " : ". time(); ?> */ | ||
class <?php echo $model; ?>Fixture extends CakeTestFixture { | ||
var $name = '<?php echo $model; ?>'; | ||
<?php if ($table): ?> | ||
var $table = '<?php echo $table; ?>'; | ||
<?php endif; ?> | ||
<?php if ($import): ?> | ||
var $import = <?php echo $import; ?>; | ||
<?php endif;?> | ||
|
||
<?php if ($schema): ?> | ||
var $fields = <?php echo $schema; ?>; | ||
<?php endif;?> | ||
|
||
<?php if ($records): ?> | ||
var $records = <?php echo $records; ?>; | ||
<?php endif;?> | ||
} | ||
<?php echo '?>'; ?> |
Oops, something went wrong.