From ccc2f53eca61893fbfa7333fc57a992fb15452ff Mon Sep 17 00:00:00 2001 From: Cameron Date: Fri, 21 Feb 2014 06:16:22 -0800 Subject: [PATCH 1/2] 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 From d3940eafd9c0b9c76571258f9a412d8c89bfb485 Mon Sep 17 00:00:00 2001 From: Cameron Date: Fri, 21 Feb 2014 06:30:25 -0800 Subject: [PATCH 2/2] Avoid checking _header_ and _footer_ layouts for divider shortcode. ie. {---} --- e107_core/templates/header_default.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/e107_core/templates/header_default.php b/e107_core/templates/header_default.php index ddc59ca0a..d1b653424 100644 --- a/e107_core/templates/header_default.php +++ b/e107_core/templates/header_default.php @@ -580,9 +580,21 @@ echo "\n"; { foreach($LAYOUT as $key=>$template) { - list($hd,$ft) = explode("{---}",$template); - $HEADER[$key] = isset($LAYOUT['_header_']) ? $LAYOUT['_header_'] . $hd : $hd; - $FOOTER[$key] = isset($LAYOUT['_footer_']) ? $ft . $LAYOUT['_footer_'] : $ft ; + if($key == '_header_' || $key == '_footer_') + { + continue; + } + + if(strpos($template,'{---}') !==false) + { + list($hd,$ft) = explode("{---}",$template); + $HEADER[$key] = isset($LAYOUT['_header_']) ? $LAYOUT['_header_'] . $hd : $hd; + $FOOTER[$key] = isset($LAYOUT['_footer_']) ? $ft . $LAYOUT['_footer_'] : $ft ; + } + else + { + e107::getMessage()->addDebug('Missing "{---}" in $LAYOUT["'.$key.'"] '); + } } unset($hd,$ft); }