From d7507149e30cdfe72ec5033df1e6aabfffba9a6e Mon Sep 17 00:00:00 2001 From: pzinovkin Date: Sun, 14 Mar 2010 19:48:02 +0000 Subject: [PATCH] Message helper, #16 git-svn-id: svn+ssh://code.netmonsters.ru/svn/majestic/branches/evo@127 4cb57b5f-5bbd-dd11-951b-001d605cbbc5 --- view/helpers/ViewHelperMsg.php | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 view/helpers/ViewHelperMsg.php diff --git a/view/helpers/ViewHelperMsg.php b/view/helpers/ViewHelperMsg.php new file mode 100644 index 0000000..d6317f0 --- /dev/null +++ b/view/helpers/ViewHelperMsg.php @@ -0,0 +1,41 @@ + + * @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 '
' . $this->view->escape($msg['message']) . '
'; + } + return ' '; + } +} \ No newline at end of file