Skip to content

Commit

Permalink
dev: make display of flash messages always use the widget, cleaning u…
Browse files Browse the repository at this point in the history
…p admincontroller and header view

dev: also added helper to application;  when used consequent we can move away from session or display more then one flash message
  • Loading branch information
mennodekker committed Jan 22, 2013
1 parent 09e148d commit 429c14c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 17 deletions.
2 changes: 2 additions & 0 deletions application/controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,12 +312,14 @@ public function _getAdminHeader($sMetaHeaders = false)
if (!empty(Yii::app()->session['dateformat']))
$aData['formatdata'] = getDateFormatData(Yii::app()->session['dateformat']);

/* Handled by a widget now so this code is obsolete
// Prepare flashmessage
if (!empty(Yii::app()->session['flashmessage']) && Yii::app()->session['flashmessage'] != '')
{
$aData['flashmessage'] = Yii::app()->session['flashmessage'];
unset(Yii::app()->session['flashmessage']);
}
*/

$aData['css_admin_includes'] = $this->_css_admin_includes(array(), true);

Expand Down
19 changes: 19 additions & 0 deletions application/core/LSYii_Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,25 @@ public function setConfig($name, $value)
{
$this->config[$name] = $value;
}

/**
* Set a 'flash message'.
*
* A flahs message will be shown on the next request and can contain a message
* to tell that the action was successful or not. The message is displayed and
* cleared when it is shown in the view using the widget:
* <code>
* $this->widget('application.extensions.FlashMessage.FlashMessage');
* </code>
*
* @param string $message
* @return LSYii_Application Provides a fluent interface
*/
public function setFlashMessage($message)
{
$this->session['flashmessage'] = $message;
return $this;
}

/**
* Loads a config from a file
Expand Down
21 changes: 4 additions & 17 deletions application/views/admin/super/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,8 @@
</script>
<?php } ?>
<div class='wrapper'>
<?php if(isset($flashmessage)) { ?>
<div id="flashmessage" style="display:none;">

<div id="themeroller" class="ui-state-highlight ui-corner-all">
<!-- close link -->
<a class="ui-notify-close" href="#">
<span class="ui-icon ui-icon-close" style="float:right">&nbsp;</span>
</a>

<!-- alert icon -->
<span style="float:left; margin:2px 5px 0 0;" class="ui-icon ui-icon-info">&nbsp;</span>
<p><?php echo $flashmessage; ?></p><br>
</div>

<!-- other templates here, maybe.. -->
</div>
<?php } ?>
<?php
// Show possible flash messages
$this->widget('application.extensions.FlashMessage.FlashMessage');
?>
<div class='maintitle'><?php echo $sitename; ?></div>

0 comments on commit 429c14c

Please sign in to comment.