From 13e4c6ae41000623340cf799c8a39cca26e18564 Mon Sep 17 00:00:00 2001 From: "Hahn Axel (hahn)" <axel.hahn@iml.unibe.ch> Date: Thu, 8 Dec 2022 17:23:27 +0100 Subject: [PATCH] add getAlert() --- public_html/classes/render-adminlte.class.php | 52 ++++++++++++++++--- 1 file changed, 46 insertions(+), 6 deletions(-) diff --git a/public_html/classes/render-adminlte.class.php b/public_html/classes/render-adminlte.class.php index 414026a..960687a 100755 --- a/public_html/classes/render-adminlte.class.php +++ b/public_html/classes/render-adminlte.class.php @@ -354,6 +354,47 @@ class renderadminlte { // ---------------------------------------------------------------------- + + /** + * return a alert box + * https://adminlte.io/themes/v3/pages/UI/general.html + * @param type $aOptions hash with keys for all options + * - type - one of [none]|danger|info|primary|success|warning + * - dismissible - if dismissible - one of true|false; default: false + * - title + * - text + * @return string + */ + public function getAlert($aOptions){ + foreach (array('type','dismissible', 'title', 'text') as $sKey){ + if(!isset($aOptions[$sKey])){ + $aOptions[$sKey]=false; + } + $this->_checkValue($sKey, $aOptions[$sKey]); + } + $aAlertIcons=[ + 'danger'=>'icon fas fa-ban', + 'info'=>'icon fas fa-info', + 'warning'=>'icon fas fa-exclamation-triangle', + 'success'=>'icon fas fa-check', + ]; + + $aElement=[ + 'class'=>'alert' + . ($aOptions['type'] ? ' alert-'.$aOptions['type'] : '') + . ($aOptions['dismissible'] ? ' alert-dismissible' : '') + , + 'label'=>'' + . ($aOptions['dismissible'] ? '<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>' : '') + . $this->_oHtml->getTag('h5', [], + (isset($aAlertIcons[$aOptions['type']]) ? '<i class=""></i> ' : '') + .$aOptions['text'] + ) + ]; + + return $this->_oHtml->getTag('div', $aElement); + } + /** * get html code for a badge * @@ -472,11 +513,11 @@ class renderadminlte { $this->_checkValue($sKey, $aOptions[$sKey]); } - // css class prefixes + // css class prefixes based on "variant" value $aVariants=[ - 'default' => 'card-', - 'outline' => 'card-outline card-', - 'filled' => 'bg-', + 'default' => 'card-', + 'outline' => 'card-outline card-', + 'fill' => 'bg-', 'gradient' => 'bg-gradient-', ]; @@ -498,7 +539,6 @@ class renderadminlte { // merge all return $this->addWrapper('div', ['class'=>$sClass], $sCardHeader.$sCardBody.$sCardFooter); - } @@ -546,7 +586,7 @@ class renderadminlte { * - text * @return string */ - public function getAlert($aOptions){ + public function MIGRATED__getAlert($aOptions){ foreach (array('type','dismissible', 'title', 'text') as $sKey){ if(!isset($aOptions[$sKey])){ $aOptions[$sKey]=false; -- GitLab