1
0
mirror of https://github.com/e107inc/e107.git synced 2025-06-09 04:28:29 +02:00

Added support for custom titles in message handler.

This commit is contained in:
Cameron 2014-02-21 06:16:22 -08:00
parent fa26a3fb24
commit ccc2f53eca

View File

@ -79,6 +79,13 @@ class eMessage
*/ */
protected $_unique = array(); protected $_unique = array();
/**
* @var array
*/
static $_customTitle = array();
/** /**
* Singleton instance * Singleton instance
* *
@ -367,6 +374,11 @@ class eMessage
*/ */
public static function getTitle($type, $message_stack = 'default') 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))) if($message_stack && $message_stack != 'default' && defined('EMESSLAN_TITLE_'.strtoupper($type.'_'.$message_stack)))
{ {
return constant('EMESSLAN_TITLE_'.strtoupper($type.'_'.$message_stack)); return constant('EMESSLAN_TITLE_'.strtoupper($type.'_'.$message_stack));
@ -374,6 +386,23 @@ class eMessage
return defsettrue('EMESSLAN_TITLE_'.strtoupper($type), ''); 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 * Message getter
* *