Skip to content
Snippets Groups Projects
Commit baa413db authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

add shortcut for getTag

parent b9e8f005
Branches
No related tags found
No related merge requests found
...@@ -119,6 +119,14 @@ class renderadminlte { ...@@ -119,6 +119,14 @@ class renderadminlte {
return true; return true;
} }
/**
* helper function: a shortcut for $this->_oHtml->getTag
* @param string $sTag name of html tag
* @param array $aAttributes array of its attributes
*/
protected function _tag($sTag, $aAttributes){
return $this->_oHtml->getTag($sTag, $aAttributes);
}
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// //
// PUBLIC FUNCTIONS AdminLTE 3.2 // PUBLIC FUNCTIONS AdminLTE 3.2
...@@ -147,7 +155,7 @@ class renderadminlte { ...@@ -147,7 +155,7 @@ class renderadminlte {
*/ */
public function addWrapper($sTag, $aOptions, $sContent){ public function addWrapper($sTag, $aOptions, $sContent){
$aOptions['label']=$sContent; $aOptions['label']=$sContent;
return $this->_oHtml->getTag($sTag, $aOptions)."\n"; return $this->_tag($sTag, $aOptions)."\n";
} }
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
...@@ -189,7 +197,7 @@ class renderadminlte { ...@@ -189,7 +197,7 @@ class renderadminlte {
]); ]);
unset($aLink['children']); // remove from html attributes to draw unset($aLink['children']); // remove from html attributes to draw
} }
$sReturn=$this->_oHtml->getTag('a', $aLink)."\n"; $sReturn=$this->_tag('a', $aLink)."\n";
if($aChildren){ if($aChildren){
$iLevel++; $iLevel++;
$sReturn.=$this->addWrapper( $sReturn.=$this->addWrapper(
...@@ -284,7 +292,7 @@ class renderadminlte { ...@@ -284,7 +292,7 @@ class renderadminlte {
$aLink['label']=$this->addWrapper('p', [], $aLink['label']); $aLink['label']=$this->addWrapper('p', [], $aLink['label']);
$sReturn.=$this->addWrapper( $sReturn.=$this->addWrapper(
'li', ['class'=>$aLiClass], 'li', ['class'=>$aLiClass],
$this->_oHtml->getTag('a', $aLink).$sSubmenu $this->_tag('a', $aLink).$sSubmenu
)."\n"; )."\n";
} }
return $sReturn; return $sReturn;
...@@ -378,6 +386,7 @@ class renderadminlte { ...@@ -378,6 +386,7 @@ class renderadminlte {
/** /**
* return a alert box * return a alert box
* https://adminlte.io/themes/v3/pages/UI/general.html * https://adminlte.io/themes/v3/pages/UI/general.html
*
* @param type $aOptions hash with keys for all options * @param type $aOptions hash with keys for all options
* - type - one of [none]|danger|info|primary|success|warning * - type - one of [none]|danger|info|primary|success|warning
* - dismissible - if dismissible - one of true|false; default: false * - dismissible - if dismissible - one of true|false; default: false
...@@ -401,7 +410,7 @@ class renderadminlte { ...@@ -401,7 +410,7 @@ class renderadminlte {
, ,
'label'=>'' 'label'=>''
. ($aOptions['dismissible'] ? '<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>' : '') . ($aOptions['dismissible'] ? '<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>' : '')
. $this->_oHtml->getTag('h5', [ . $this->_tag('h5', [
'label'=> '' 'label'=> ''
.(isset($aAlertIcons[$aOptions['type']]) ? '<i class="'.$aAlertIcons[$aOptions['type']].'"></i> ' : '') .(isset($aAlertIcons[$aOptions['type']]) ? '<i class="'.$aAlertIcons[$aOptions['type']].'"></i> ' : '')
.$aOptions['title'] .$aOptions['title']
...@@ -409,7 +418,7 @@ class renderadminlte { ...@@ -409,7 +418,7 @@ class renderadminlte {
.$aOptions['text'] .$aOptions['text']
]; ];
return $this->_oHtml->getTag('div', $aElement); return $this->_tag('div', $aElement);
} }
/** /**
...@@ -443,13 +452,14 @@ class renderadminlte { ...@@ -443,13 +452,14 @@ class renderadminlte {
$aElement['title']=$aOptions['title']; $aElement['title']=$aOptions['title'];
$aElement['label']=$aOptions['text']; $aElement['label']=$aOptions['text'];
return $this->_oHtml->getTag('span', $aElement); return $this->_tag('span', $aElement);
} }
/** /**
* Get a button. * Get a button.
* You can use any other key that are not named here. Those keys will be rendered * You can use any other key that are not named here. Those keys will be rendered
* as additional html attributes without modification. * as additional html attributes without modification.
* https://adminlte.io/themes/v3/pages/UI/buttons.html
* *
* <button type="button" class="btn btn-block btn-default">Default</button> * <button type="button" class="btn btn-block btn-default">Default</button>
* @param type $aOptions hash with keys for all options * @param type $aOptions hash with keys for all options
...@@ -470,11 +480,12 @@ class renderadminlte { ...@@ -470,11 +480,12 @@ class renderadminlte {
; ;
$aElement['label']=$aOptions['text'] ? $aOptions['text'] : '&nbsp;'; $aElement['label']=$aOptions['text'] ? $aOptions['text'] : '&nbsp;';
unset($aElement['_infos']); unset($aElement['_infos']);
return $this->_oHtml->getTag('button', $aElement); return $this->_tag('button', $aElement);
} }
/** /**
* get a callout (box with coloered left border; has type, title + text) * get a callout (box with coloered left border; has type, title + text)
* https://adminlte.io/themes/v3/pages/UI/general.html
* *
* @param type $aOptions hash with keys for all options * @param type $aOptions hash with keys for all options
* >> styling * >> styling
...@@ -495,13 +506,14 @@ class renderadminlte { ...@@ -495,13 +506,14 @@ class renderadminlte {
return $this->addWrapper( return $this->addWrapper(
'div', ['class'=>$sClass], 'div', ['class'=>$sClass],
($aOptions['title'] ? $this->_oHtml->getTag('h5', ['label'=>$aOptions['title']]) : '') ($aOptions['title'] ? $this->_tag('h5', ['label'=>$aOptions['title']]) : '')
.($aOptions['text'] ? $this->_oHtml->getTag('p', ['label'=>$aOptions['text']]) : '') .($aOptions['text'] ? $this->_tag('p', ['label'=>$aOptions['text']]) : '')
); );
} }
/** /**
* get a card * get a card
* https://adminlte.io/docs/3.2/components/cards.html
* *
* @param type $aOptions hash with keys for all options * @param type $aOptions hash with keys for all options
* >> styling * >> styling
...@@ -538,12 +550,12 @@ class renderadminlte { ...@@ -538,12 +550,12 @@ class renderadminlte {
// build parts of the card // build parts of the card
$sCardHeader=$this->addWrapper('div', ['class'=>'card-header'], $sCardHeader=$this->addWrapper('div', ['class'=>'card-header'],
$this->_oHtml->getTag('h3', ['class'=>'card-title', 'label'=>$aOptions['title']]) $this->_tag('h3', ['class'=>'card-title', 'label'=>$aOptions['title']])
. ($aOptions['tools'] ? $this->_oHtml->getTag('div', ['class'=>'card-tools', 'label'=>$aOptions['tools']]) : '') . ($aOptions['tools'] ? $this->_tag('div', ['class'=>'card-tools', 'label'=>$aOptions['tools']]) : '')
); );
$sCardBody=$this->_oHtml->getTag('div', ['class'=>'card-body', 'label'=>$aOptions['text']]); $sCardBody=$this->_tag('div', ['class'=>'card-body', 'label'=>$aOptions['text']]);
$sCardFooter=$aOptions['footer'] ? $this->_oHtml->getTag('div', ['class'=>'card-footer', 'label'=>$aOptions['footer']]) : ''; $sCardFooter=$aOptions['footer'] ? $this->_tag('div', ['class'=>'card-footer', 'label'=>$aOptions['footer']]) : '';
// merge all // merge all
return $this->addWrapper('div', ['class'=>$sClass], $sCardHeader.$sCardBody.$sCardFooter); return $this->addWrapper('div', ['class'=>$sClass], $sCardHeader.$sCardBody.$sCardFooter);
...@@ -568,8 +580,6 @@ class renderadminlte { ...@@ -568,8 +580,6 @@ class renderadminlte {
...@@ -752,12 +762,12 @@ class renderadminlte { ...@@ -752,12 +762,12 @@ class renderadminlte {
public function getMenuItem($aOptions, $aLinkOptions){ public function getMenuItem($aOptions, $aLinkOptions){
$sLabel=$this->_oHtml->getTag('a', $aLinkOptions); $sLabel=$this->_tag('a', $aLinkOptions);
// TODO // TODO
// if subelements then add them to $sLabel with recursion // if subelements then add them to $sLabel with recursion
return $this->_oHtml->getTag('li', array( return $this->_tag('li', array(
'class'=>'treeview', 'class'=>'treeview',
'label'=>$sLabel, 'label'=>$sLabel,
)); ));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment