mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-16 03:48:24 +00:00
08e7bcb7ab
Conflicts: app/config/core.php cake/console/libs/acl.php cake/console/templates/skel/config/core.php cake/console/templates/skel/webroot/test.php cake/dispatcher.php cake/libs/view/errors/missing_action.ctp cake/libs/view/helpers/form.php cake/tests/cases/libs/cache/memcache.test.php cake/tests/cases/libs/controller/controller.test.php cake/tests/cases/libs/log/file_log.test.php cake/tests/cases/libs/model/cake_schema.test.php cake/tests/cases/libs/router.test.php cake/tests/cases/libs/view/helpers/ajax.test.php cake/tests/groups/bake.group.php cake/tests/groups/behaviors.group.php cake/tests/groups/i18n.group.php cake/tests/groups/javascript.group.php cake/tests/lib/reporter/cake_cli_reporter.php
140 lines
No EOL
5.4 KiB
PHP
140 lines
No EOL
5.4 KiB
PHP
<?php
|
|
/**
|
|
* Bake Template for Controller action generation.
|
|
*
|
|
* PHP 5
|
|
*
|
|
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
|
* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
|
*
|
|
* Licensed under The MIT License
|
|
* Redistributions of files must retain the above copyright notice.
|
|
*
|
|
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
|
* @link http://cakephp.org CakePHP(tm) Project
|
|
* @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)
|
|
*/
|
|
?>
|
|
|
|
public function <?php echo $admin ?>index() {
|
|
$this-><?php echo $currentModelName ?>->recursive = 0;
|
|
$this->set('<?php echo $pluralName ?>', $this->paginate());
|
|
}
|
|
|
|
public function <?php echo $admin ?>view($id = null) {
|
|
if (!$id) {
|
|
<?php if ($wannaUseSession): ?>
|
|
$this->Session->setFlash(__('Invalid <?php echo strtolower($singularHumanName) ?>'));
|
|
$this->redirect(array('action' => 'index'));
|
|
<?php else: ?>
|
|
$this->flash(__('Invalid <?php echo strtolower($singularHumanName); ?>'), array('action' => 'index'));
|
|
<?php endif; ?>
|
|
}
|
|
$this->set('<?php echo $singularName; ?>', $this-><?php echo $currentModelName; ?>->read(null, $id));
|
|
}
|
|
|
|
<?php $compact = array(); ?>
|
|
public 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 strtolower($singularHumanName); ?> has been saved'));
|
|
$this->redirect(array('action' => 'index'));
|
|
<?php else: ?>
|
|
$this->flash(__('<?php echo ucfirst(strtolower($currentModelName)); ?> saved.'), array('action' => 'index'));
|
|
<?php endif; ?>
|
|
} else {
|
|
<?php if ($wannaUseSession): ?>
|
|
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> could not be saved. Please, try again.'));
|
|
<?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(); ?>
|
|
public function <?php echo $admin; ?>edit($id = null) {
|
|
if (!$id && empty($this->data)) {
|
|
<?php if ($wannaUseSession): ?>
|
|
$this->Session->setFlash(__('Invalid <?php echo strtolower($singularHumanName); ?>'));
|
|
$this->redirect(array('action' => 'index'));
|
|
<?php else: ?>
|
|
$this->flash(sprintf(__('Invalid <?php echo strtolower($singularHumanName); ?>')), 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 strtolower($singularHumanName); ?> has been saved'));
|
|
$this->redirect(array('action' => 'index'));
|
|
<?php else: ?>
|
|
$this->flash(__('The <?php echo strtolower($singularHumanName); ?> has been saved.'), array('action' => 'index'));
|
|
<?php endif; ?>
|
|
} else {
|
|
<?php if ($wannaUseSession): ?>
|
|
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> could not be saved. Please, try again.'));
|
|
<?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;
|
|
?>
|
|
}
|
|
|
|
public function <?php echo $admin; ?>delete($id = null) {
|
|
if (!$id) {
|
|
<?php if ($wannaUseSession): ?>
|
|
$this->Session->setFlash(__('Invalid id for <?php echo strtolower($singularHumanName); ?>'));
|
|
$this->redirect(array('action'=>'index'));
|
|
<?php else: ?>
|
|
$this->flash(sprintf(__('Invalid <?php echo strtolower($singularHumanName); ?>')), array('action' => 'index'));
|
|
<?php endif; ?>
|
|
}
|
|
if ($this-><?php echo $currentModelName; ?>->delete($id)) {
|
|
<?php if ($wannaUseSession): ?>
|
|
$this->Session->setFlash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> deleted'));
|
|
$this->redirect(array('action'=>'index'));
|
|
<?php else: ?>
|
|
$this->flash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> deleted'), array('action' => 'index'));
|
|
<?php endif; ?>
|
|
}
|
|
<?php if ($wannaUseSession): ?>
|
|
$this->Session->setFlash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> was not deleted'));
|
|
<?php else: ?>
|
|
$this->flash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> was not deleted'), array('action' => 'index'));
|
|
<?php endif; ?>
|
|
$this->redirect(array('action' => 'index'));
|
|
}
|