1
0
mirror of https://github.com/e107inc/e107.git synced 2025-05-11 06:35:22 +02:00

New setIcon() method added to message handler.

This commit is contained in:
Cameron 2019-05-05 18:08:29 -07:00
parent 1d3d67ca0f
commit 2250d3c2f3
2 changed files with 27 additions and 1 deletions
e107_handlers
e107_themes/bootstrap3

@ -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 @@ class eMessage
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 @@ class eMessage
//$message = array_unique($message); // quick fix for duplicates.
$message = "<div class='s-message-item'>".implode("</div>\n<div class='s-message-item'>", $message)."</div>";
}
$icon = !empty(self::$_customIcon[$type]) ? "s-message-empty fa fa-2x ".self::$_customIcon[$type] : "s-message-".$type;
$text = "<div class='s-message alert alert-block fade in {$type} {$bclass}'>";
$text .= (self::$_close[$type] === true) ? "<a class='close' data-dismiss='alert'>×</a>" : "";
$text .= "<i class='s-message-icon s-message-".$type."'></i>
$text .= "<i class='s-message-icon ".$icon."'></i>
<h4 class='s-message-title'>".self::getTitle($type, $mstack)."</h4>
<div class='s-message-body'>
{$message}

@ -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; }