You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
885 B

  1. <?php
  2. /**
  3. * @copyright NetMonsters <team@netmonsters.ru>
  4. * @link http://netmonsters.ru
  5. * @package Majestic
  6. * @subpackage View
  7. * @since 2010-03-09
  8. * @version SVN: $Id$
  9. * @filesource $URL$
  10. */
  11. class ViewHelperMsg extends ViewHelper
  12. {
  13. protected $get;
  14. public function msg()
  15. {
  16. return $this;
  17. }
  18. public function success($msg)
  19. {
  20. Session::set(__CLASS__, array('message' => $msg, 'type' => 'success'));
  21. }
  22. public function error($msg)
  23. {
  24. Session::set(__CLASS__, array('message' => $msg, 'type' => 'error'));
  25. }
  26. public function __toString()
  27. {
  28. $msg = Session::get(__CLASS__, false);
  29. if ($msg) {
  30. Session::del(__CLASS__);
  31. return '<div class="' . $msg['type'] . '">' . $this->view->escape($msg['message']) . '</div>';
  32. }
  33. return '&nbsp;';
  34. }
  35. }