diff --git a/e107_handlers/message_handler.php b/e107_handlers/message_handler.php index f427700154..45404cd060 100644 --- a/e107_handlers/message_handler.php +++ b/e107_handlers/message_handler.php @@ -79,6 +79,12 @@ class eMessage */ static $_customTitle = array(); + /** + * Custom font-awesome icon + * @var array + */ + static $_customIcon = array(); + static $_close = array('info'=>true,'success'=>true,'warning'=>true,'error'=>true,'debug'=>true); /** @@ -398,6 +404,22 @@ public function setTitle($title, $type) return $this; } + /** + * Set a custom icon (useful for front-end) + * + * @param string $fa FontAwesome reference. eg. fa-cog + * @param string $type E_MESSAGE_SUCCESS,E_MESSAGE_ERROR, E_MESSAGE_WARNING, E_MESSAGE_INFO + * @return $this + * @example e107::getMessage()->setIcon('fa-cog', E_MESSAGE_INFO); + */ + public function setIcon($fa, $type) + { + $tp = e107::getParser(); + self::$_customIcon[$type] = $tp->toText($fa); + + return $this; + } + /** * Enable the 'x' close functionality of an alert. @@ -567,10 +589,13 @@ public static function formatMessage($mstack, $type, $message) //$message = array_unique($message); // quick fix for duplicates. $message = "
\n "; } + + $icon = !empty(self::$_customIcon[$type]) ? "s-message-empty fa fa-2x ".self::$_customIcon[$type] : "s-message-".$type; + $text = "