mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
commit
d05727b6df
9 changed files with 28 additions and 19 deletions
|
@ -42,7 +42,7 @@ $cakeVersion = __d('cake_dev', 'CakePHP %s', Configure::version())
|
|||
</div>
|
||||
<div id="content">
|
||||
|
||||
<?php echo $this->Session->flash(); ?>
|
||||
<?php echo $this->Flash->render(); ?>
|
||||
|
||||
<?php echo $this->fetch('content'); ?>
|
||||
</div>
|
||||
|
|
|
@ -384,9 +384,9 @@ class ControllerTask extends BakeTask {
|
|||
* @return array Components the user wants to use.
|
||||
*/
|
||||
public function doComponents() {
|
||||
$components = array('Paginator');
|
||||
$components = array('Paginator', 'Flash');
|
||||
return array_merge($components, $this->_doPropertyChoices(
|
||||
__d('cake_console', "Would you like this controller to use other components\nbesides PaginatorComponent?"),
|
||||
__d('cake_console', "Would you like this controller to use other components\nbesides PaginatorComponent and FlashComponent?"),
|
||||
__d('cake_console', "Please provide a comma separated list of the component names you'd like to use.\nExample: 'Acl, Security, RequestHandler'")
|
||||
));
|
||||
}
|
||||
|
|
|
@ -53,10 +53,10 @@
|
|||
$this-><?php echo $currentModelName; ?>->create();
|
||||
if ($this-><?php echo $currentModelName; ?>->save($this->request->data)) {
|
||||
<?php if ($wannaUseSession): ?>
|
||||
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> has been saved.'));
|
||||
$this->Flash->success(__('The <?php echo strtolower($singularHumanName); ?> has been saved.'));
|
||||
return $this->redirect(array('action' => 'index'));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> could not be saved. Please, try again.'));
|
||||
$this->Flash->error(__('The <?php echo strtolower($singularHumanName); ?> could not be saved. Please, try again.'));
|
||||
<?php else: ?>
|
||||
return $this->flash(__('The <?php echo strtolower($singularHumanName); ?> has been saved.'), array('action' => 'index'));
|
||||
<?php endif; ?>
|
||||
|
@ -94,10 +94,10 @@
|
|||
if ($this->request->is(array('post', 'put'))) {
|
||||
if ($this-><?php echo $currentModelName; ?>->save($this->request->data)) {
|
||||
<?php if ($wannaUseSession): ?>
|
||||
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> has been saved.'));
|
||||
$this->Flash->success(__('The <?php echo strtolower($singularHumanName); ?> has been saved.'));
|
||||
return $this->redirect(array('action' => 'index'));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> could not be saved. Please, try again.'));
|
||||
$this->Flash->error(__('The <?php echo strtolower($singularHumanName); ?> could not be saved. Please, try again.'));
|
||||
<?php else: ?>
|
||||
return $this->flash(__('The <?php echo strtolower($singularHumanName); ?> has been saved.'), array('action' => 'index'));
|
||||
<?php endif; ?>
|
||||
|
@ -138,9 +138,9 @@
|
|||
$this->request->allowMethod('post', 'delete');
|
||||
if ($this-><?php echo $currentModelName; ?>->delete()) {
|
||||
<?php if ($wannaUseSession): ?>
|
||||
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> has been deleted.'));
|
||||
$this->Flash->success(__('The <?php echo strtolower($singularHumanName); ?> has been deleted.'));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> could not be deleted. Please, try again.'));
|
||||
$this->Flash->error(__('The <?php echo strtolower($singularHumanName); ?> could not be deleted. Please, try again.'));
|
||||
}
|
||||
return $this->redirect(array('action' => 'index'));
|
||||
<?php else: ?>
|
||||
|
|
|
@ -222,7 +222,7 @@ class ControllerTaskTest extends CakeTestCase {
|
|||
public function testDoComponentsNo() {
|
||||
$this->Task->expects($this->any())->method('in')->will($this->returnValue('n'));
|
||||
$result = $this->Task->doComponents();
|
||||
$this->assertSame(array('Paginator'), $result);
|
||||
$this->assertSame(array('Paginator', 'Flash'), $result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -235,7 +235,7 @@ class ControllerTaskTest extends CakeTestCase {
|
|||
$this->Task->expects($this->at(1))->method('in')->will($this->returnValue(' RequestHandler, Security '));
|
||||
|
||||
$result = $this->Task->doComponents();
|
||||
$expected = array('Paginator', 'RequestHandler', 'Security');
|
||||
$expected = array('Paginator', 'Flash', 'RequestHandler', 'Security');
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
|
@ -249,7 +249,7 @@ class ControllerTaskTest extends CakeTestCase {
|
|||
$this->Task->expects($this->at(1))->method('in')->will($this->returnValue(' RequestHandler, Security, , '));
|
||||
|
||||
$result = $this->Task->doComponents();
|
||||
$expected = array('Paginator', 'RequestHandler', 'Security');
|
||||
$expected = array('Paginator', 'Flash', 'RequestHandler', 'Security');
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,10 +33,10 @@
|
|||
if ($this->request->is('post')) {
|
||||
$this->BakeArticle->create();
|
||||
if ($this->BakeArticle->save($this->request->data)) {
|
||||
$this->Session->setFlash(__('The bake article has been saved.'));
|
||||
$this->Flash->success(__('The bake article has been saved.'));
|
||||
return $this->redirect(array('action' => 'index'));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The bake article could not be saved. Please, try again.'));
|
||||
$this->Flash->error(__('The bake article could not be saved. Please, try again.'));
|
||||
}
|
||||
}
|
||||
$bakeTags = $this->BakeArticle->BakeTag->find('list');
|
||||
|
@ -56,10 +56,10 @@
|
|||
}
|
||||
if ($this->request->is(array('post', 'put'))) {
|
||||
if ($this->BakeArticle->save($this->request->data)) {
|
||||
$this->Session->setFlash(__('The bake article has been saved.'));
|
||||
$this->Flash->success(__('The bake article has been saved.'));
|
||||
return $this->redirect(array('action' => 'index'));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The bake article could not be saved. Please, try again.'));
|
||||
$this->Flash->error(__('The bake article could not be saved. Please, try again.'));
|
||||
}
|
||||
} else {
|
||||
$options = array('conditions' => array('BakeArticle.' . $this->BakeArticle->primaryKey => $id));
|
||||
|
@ -83,9 +83,9 @@
|
|||
}
|
||||
$this->request->allowMethod('post', 'delete');
|
||||
if ($this->BakeArticle->delete()) {
|
||||
$this->Session->setFlash(__('The bake article has been deleted.'));
|
||||
$this->Flash->success(__('The bake article has been deleted.'));
|
||||
} else {
|
||||
$this->Session->setFlash(__('The bake article could not be deleted. Please, try again.'));
|
||||
$this->Flash->error(__('The bake article could not be deleted. Please, try again.'));
|
||||
}
|
||||
return $this->redirect(array('action' => 'index'));
|
||||
}
|
||||
|
|
|
@ -1 +1,7 @@
|
|||
<div id="<?php echo $key; ?>Message" class="<?php echo !empty($params['class']) ? $params['class'] : 'message'; ?>"><?php echo $message; ?></div>
|
||||
<?php
|
||||
$class = 'message';
|
||||
if (!empty($params['class'])) {
|
||||
$class .= ' ' . $params['class'];
|
||||
}
|
||||
?>
|
||||
<div id="<?= $key ?>Message" class="<?= h($class) ?>"><?= h($message) ?></div>
|
||||
|
|
1
lib/Cake/View/Elements/Flash/error.ctp
Normal file
1
lib/Cake/View/Elements/Flash/error.ctp
Normal file
|
@ -0,0 +1 @@
|
|||
<div id="<?= $key ?>Message" class="message error"><?= h($message) ?></div>
|
1
lib/Cake/View/Elements/Flash/success.ctp
Normal file
1
lib/Cake/View/Elements/Flash/success.ctp
Normal file
|
@ -0,0 +1 @@
|
|||
<div id="<?= $key ?>Message" class="message success"><?= h($message) ?></div>
|
|
@ -84,6 +84,7 @@ class FlashHelper extends AppHelper {
|
|||
|
||||
$flash = $options + $flash;
|
||||
CakeSession::delete("Message.$key");
|
||||
$flash['key'] = $key;
|
||||
|
||||
return $this->_View->element($flash['element'], $flash);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue