From ccc2f53eca61893fbfa7333fc57a992fb15452ff Mon Sep 17 00:00:00 2001 From: Cameron Date: Fri, 21 Feb 2014 06:16:22 -0800 Subject: [PATCH] Added support for custom titles in message handler. --- e107_handlers/message_handler.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/e107_handlers/message_handler.php b/e107_handlers/message_handler.php index 74b0a656c..34397836c 100644 --- a/e107_handlers/message_handler.php +++ b/e107_handlers/message_handler.php @@ -78,6 +78,13 @@ class eMessage * @var array */ protected $_unique = array(); + + /** + * @var array + */ + static $_customTitle = array(); + + /** * Singleton instance @@ -367,12 +374,34 @@ class eMessage */ public static function getTitle($type, $message_stack = 'default') { + if(!empty(self::$_customTitle[$type])) + { + return self::$_customTitle[$type]; + } + if($message_stack && $message_stack != 'default' && defined('EMESSLAN_TITLE_'.strtoupper($type.'_'.$message_stack))) { return constant('EMESSLAN_TITLE_'.strtoupper($type.'_'.$message_stack)); } return defsettrue('EMESSLAN_TITLE_'.strtoupper($type), ''); } + + + /** + * Set a custom title/caption (useful for front-end) + * + * @param string $title + * @param string $type E_MESSAGE_SUCCESS,E_MESSAGE_ERROR, E_MESSAGE_WARNING, E_MESSAGE_INFO + * @example e107::getMessage()->setTitle('Custom Title', E_MESSAGE_INFO); + */ + public function setTitle($title, $type) + { + $tp = e107::getParser(); + self::$_customTitle[$type] = $tp->toText($title); + + return $this; + } + /** * Message getter