mirror of
https://github.com/e107inc/e107.git
synced 2025-08-01 20:30:39 +02:00
New setIcon() method added to message handler.
This commit is contained in:
@@ -79,6 +79,12 @@ class eMessage
|
|||||||
*/
|
*/
|
||||||
static $_customTitle = array();
|
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);
|
static $_close = array('info'=>true,'success'=>true,'warning'=>true,'error'=>true,'debug'=>true);
|
||||||
/**
|
/**
|
||||||
@@ -398,6 +404,22 @@ class eMessage
|
|||||||
return $this;
|
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.
|
* Enable the 'x' close functionality of an alert.
|
||||||
@@ -567,10 +589,13 @@ class eMessage
|
|||||||
//$message = array_unique($message); // quick fix for duplicates.
|
//$message = array_unique($message); // quick fix for duplicates.
|
||||||
$message = "<div class='s-message-item'>".implode("</div>\n<div class='s-message-item'>", $message)."</div>";
|
$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 = "<div class='s-message alert alert-block fade in {$type} {$bclass}'>";
|
||||||
$text .= (self::$_close[$type] === true) ? "<a class='close' data-dismiss='alert'>×</a>" : "";
|
$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>
|
<h4 class='s-message-title'>".self::getTitle($type, $mstack)."</h4>
|
||||||
<div class='s-message-body'>
|
<div class='s-message-body'>
|
||||||
{$message}
|
{$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-warning { background-position: -777px -37px; width: 32px; height: 32px; }
|
||||||
i.s-message-info { background-position: -1480px 0; 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-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 .well { background-color: rgba(0,0,0,0.4) }
|
||||||
.s-message-body { padding-left: 42px; }
|
.s-message-body { padding-left: 42px; }
|
||||||
|
Reference in New Issue
Block a user