Skip to content

Commit

Permalink
splitting up the elements for flash messages so that templates do not…
Browse files Browse the repository at this point in the history
… overload admin when they should not. Admin flash mesages can be overloaded by creating the overload files in messages/admin
  • Loading branch information
dogmatic69 committed Jun 27, 2012
1 parent c567ae2 commit ecaf60f
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Controller/AppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,12 @@ public function notice($message, $config = array()) {
'plugin' => $config['plugin']
);

$this->Session->setFlash($message, 'messages/'.$config['level'], $vars);
$element = 'messages/' . $config['level'];
if(isset($this->request->params['admin']) && $this->request->params['admin']) {
$element = 'messages/admin/' . $config['level'];
}

$this->Session->setFlash($message, $element, $vars);
if($config['redirect'] || $config['redirect'] === '') {
if($config['redirect'] === true) {
$config['redirect'] = $this->referer();
Expand Down
16 changes: 16 additions & 0 deletions Core/Assets/View/Elements/messages/admin/error.ctp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<div class="user-warning error">
<?php
echo $this->Html->image(
$this->Image->getRelativePath('notifications', 'stop'),
array('alt' => 'error')
);

if(isset($code) && $code) {
sprintf('<b>%s:</b> %s', $code, $message);
}

else{
echo $message;
}
?>
</div>
16 changes: 16 additions & 0 deletions Core/Assets/View/Elements/messages/admin/success.ctp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<div class="user-warning success">
<?php
echo $this->Html->image(
$this->Image->getRelativePath('notifications', 'success'),
array('alt' => 'success')
);

if(isset($code) && $code) {
sprintf('<b>%s:</b> %s', $code, $message);
}

else{
echo $message;
}
?>
</div>
16 changes: 16 additions & 0 deletions Core/Assets/View/Elements/messages/admin/warning.ctp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<div class="user-warning warning">
<?php
echo $this->Html->image(
$this->Image->getRelativePath('notifications', 'warning'),
array('alt' => 'warning')
);

if(isset($code) && $code) {
sprintf('<b>%s:</b> %s', $code, $message);
}

else{
echo $message;
}
?>
</div>

0 comments on commit ecaf60f

Please sign in to comment.