Browse Source

Message helper, #16

git-svn-id: svn+ssh://code.netmonsters.ru/svn/majestic/branches/evo@127 4cb57b5f-5bbd-dd11-951b-001d605cbbc5
master
pzinovkin 15 years ago
parent
commit
d7507149e3
  1. 41
      view/helpers/ViewHelperMsg.php

41
view/helpers/ViewHelperMsg.php

@ -0,0 +1,41 @@
<?php
/**
* @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru
* @package Majestic
* @subpackage View
* @since 2010-03-09
* @version SVN: $Id$
* @filesource $URL$
*/
class ViewHelperMsg extends ViewHelper
{
protected $get;
public function msg()
{
return $this;
}
public function success($msg)
{
Session::set(__CLASS__, array('message' => $msg, 'type' => 'success'));
}
public function error($msg)
{
Session::set(__CLASS__, array('message' => $msg, 'type' => 'error'));
}
public function __toString()
{
$msg = Session::get(__CLASS__, false);
if ($msg) {
Session::del(__CLASS__);
return '<div class="' . $msg['type'] . '">' . $this->view->escape($msg['message']) . '</div>';
}
return '&nbsp;';
}
}
Loading…
Cancel
Save