From 2250d3c2f3d3d01eb4385eed81e84e90bf1ba0c4 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sun, 5 May 2019 18:08:29 -0700 Subject: [PATCH] New setIcon() method added to message handler. --- e107_handlers/message_handler.php | 27 +++++++++++++++++++++++++- e107_themes/bootstrap3/admin_style.css | 1 + 2 files changed, 27 insertions(+), 1 deletion(-) 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 = "
".implode("
\n
", $message)."
"; } + + $icon = !empty(self::$_customIcon[$type]) ? "s-message-empty fa fa-2x ".self::$_customIcon[$type] : "s-message-".$type; + $text = "
"; $text .= (self::$_close[$type] === true) ? "×" : ""; - $text .= " + $text .= "

".self::getTitle($type, $mstack)."

{$message} diff --git a/e107_themes/bootstrap3/admin_style.css b/e107_themes/bootstrap3/admin_style.css index 70303440df..bd5f1a6723 100644 --- a/e107_themes/bootstrap3/admin_style.css +++ b/e107_themes/bootstrap3/admin_style.css @@ -583,6 +583,7 @@ i.s-message-error { background-position: -925px 0; width: 32px; height: 32px; } i.s-message-warning { background-position: -777px -37px; width: 32px; height: 32px; } i.s-message-info { background-position: -1480px 0; width: 32px; height: 32px; } i.s-message-debug { background-position: -1480px 0; width: 32px; height: 32px; } +i.s-message-empty { background:none; } .s-message .well { background-color: rgba(0,0,0,0.4) } .s-message-body { padding-left: 42px; }