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

add method getCard

parent 61996e83
No related branches found
No related tags found
No related merge requests found
...@@ -27,6 +27,7 @@ class renderadminlte { ...@@ -27,6 +27,7 @@ class renderadminlte {
'info', 'cyan', 'info', 'cyan',
'warning', 'yellow', 'warning', 'yellow',
'danger', 'red', 'danger', 'red',
'dark',
'black', 'black',
'gray-dark', 'gray-dark',
...@@ -59,9 +60,11 @@ class renderadminlte { ...@@ -59,9 +60,11 @@ class renderadminlte {
], ],
'type'=>[ 'type'=>[
'danger', // red 'danger', // red
'dark', // dark gray
'gray', // gray 'gray', // gray
'info', // aqua 'info', // aqua
'primary', // blue 'primary', // blue
'secondary', // gray
'success', // green 'success', // green
'warning', // yellow 'warning', // yellow
], ],
...@@ -330,6 +333,7 @@ class renderadminlte { ...@@ -330,6 +333,7 @@ class renderadminlte {
/** /**
* show help of standard key in a component key * show help of standard key in a component key
* @param string $skey name of a options key
*/ */
public function showKeyHelp($sKey){ public function showKeyHelp($sKey){
$aDescription=[ $aDescription=[
...@@ -343,7 +347,7 @@ class renderadminlte { ...@@ -343,7 +347,7 @@ class renderadminlte {
]; ];
return [ return [
'key'=>$sKey, 'key'=>$sKey,
'description'=>isset($aDescription[$sKey]) ? $aDescription[$sKey] : '?', 'description'=>isset($aDescription[$sKey]) ? $aDescription[$sKey] : '-',
'valid_values'=>isset($this->_aValidItems[$sKey]) ? implode("|", $this->_aValidItems[$sKey]) : '', 'valid_values'=>isset($this->_aValidItems[$sKey]) ? implode("|", $this->_aValidItems[$sKey]) : '',
]; ];
} }
...@@ -351,7 +355,6 @@ class renderadminlte { ...@@ -351,7 +355,6 @@ class renderadminlte {
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
/** /**
* UNTESTED
* get html code for a badge * get html code for a badge
* *
* Examples * Examples
...@@ -360,13 +363,13 @@ class renderadminlte { ...@@ -360,13 +363,13 @@ class renderadminlte {
* <span class="right badge badge-danger">New</span> * <span class="right badge badge-danger">New</span>
* <span class="badge badge-danger float-right">$350</span> * <span class="badge badge-danger float-right">$350</span>
* *
* @param type $aOptions hash with keys for all options * @param array $aOptions hash with keys for all options
* - bgcolor - background color (without prefix "bg") * - bgcolor - background color (without prefix "bg")
* - class - css class * - class - css class
* - id - optional: id attribute * - id - optional: id attribute
* - text - visible text * - text - visible text
* - title - optional: title attribute * - title - optional: title attribute
* - type - one of [none]|danger|info|primary|success|warning * - type - one of [none]|danger|dark|info|primary|secondary|success|warning
*/ */
public function getBadge($aOptions){ public function getBadge($aOptions){
$_aParams=['bgcolor', 'class', 'id', 'text', 'title', 'type']; $_aParams=['bgcolor', 'class', 'id', 'text', 'title', 'type'];
...@@ -395,7 +398,7 @@ class renderadminlte { ...@@ -395,7 +398,7 @@ class renderadminlte {
* get a button * get a button
* <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
* - type - one of [none]|danger|info|primary|success|warning * - type - one of [none]|danger|dark|info|primary|secondary|success|warning
* - size - one of [none]|lg|sm|xs|flat * - size - one of [none]|lg|sm|xs|flat
* - class - any css class for customizing, eg. "disabled" * - class - any css class for customizing, eg. "disabled"
* - icon * - icon
...@@ -409,7 +412,7 @@ class renderadminlte { ...@@ -409,7 +412,7 @@ class renderadminlte {
} }
$this->_checkValue($sKey, $aOptions[$sKey]); $this->_checkValue($sKey, $aOptions[$sKey]);
} }
$aBtn=[ $aElement=[
'class'=>'btn ' 'class'=>'btn '
.(isset($aOptions['class']) ? ' '.$aOptions['class'] : '') .(isset($aOptions['class']) ? ' '.$aOptions['class'] : '')
.(isset($aOptions['type']) ? ' btn-'.$aOptions['type'] : '') .(isset($aOptions['type']) ? ' btn-'.$aOptions['type'] : '')
...@@ -417,7 +420,7 @@ class renderadminlte { ...@@ -417,7 +420,7 @@ class renderadminlte {
, ,
'label'=>isset($aOptions['text']) ? $aOptions['text'] : '' 'label'=>isset($aOptions['text']) ? $aOptions['text'] : ''
]; ];
return $this->_oHtml->getTag('button', $aBtn); return $this->_oHtml->getTag('button', $aElement);
} }
/** /**
...@@ -446,29 +449,55 @@ class renderadminlte { ...@@ -446,29 +449,55 @@ class renderadminlte {
* <!-- /.card --> * <!-- /.card -->
* *
* @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 * >> styling
* - size - one of [none]|lg|sm|xs|flat * - variant: "default" - titlebar is colored
* "outline" - small stripe on top border is colored
* "fill" - whole card is colored
* "gradient" - whole card is colored with a gradient
* - type - one of [none]|danger|dark|info|primary|secondary|success|warning
* - class - any css class for customizing, eg. "disabled" * - class - any css class for customizing, eg. "disabled"
* - icon *
* - text * >> texts/ html content
* - title - text: title of the card
* - tools - text: titlebar top right elements
* - text - text: content of the card
* - footer - text: footer of the card
* @return string * @return string
*/ */
public function getCard($aOptions){ public function getCard($aOptions){
foreach (array('type', 'size', 'class', 'text', 'icon') as $sKey){ foreach (array('variant', 'type', 'class', 'text', 'icon') as $sKey){
if(!isset($aOptions[$sKey])){ if(!isset($aOptions[$sKey])){
$aOptions[$sKey]=false; $aOptions[$sKey]=false;
} }
$this->_checkValue($sKey, $aOptions[$sKey]); $this->_checkValue($sKey, $aOptions[$sKey]);
} }
$aBtn=[
'class'=>'btn ' // css class prefixes
.(isset($aOptions['class']) ? ' '.$aOptions['class'] : '') $aVariants=[
.(isset($aOptions['type']) ? ' btn-'.$aOptions['type'] : '') 'default' => 'card-',
.(isset($aOptions['size']) ? ' btn-'.$aOptions['size'] : '') 'outline' => 'card-outline card-',
, 'filled' => 'bg-',
'label'=>isset($aOptions['text']) ? $aOptions['text'] : '' 'gradient' => 'bg-gradient-',
]; ];
return $this->_oHtml->getTag('button', $aBtn);
// print_r($aOptions);
$sVariantPrefix=$aVariants[$aOptions['variant']] ? $aVariants[$aOptions['variant']] : $aVariants['default'];
$sClass='card'
.($aOptions['class'] ? ' '.$aOptions['class'] : '')
.($aOptions['type'] ? ' '.$sVariantPrefix.$aOptions['type'] : '')
;
// build parts of the card
$sCardHeader=$this->addWrapper('div', ['class'=>'card-header'],
$this->_oHtml->getTag('h3', ['class'=>'card-title', 'label'=>$aOptions['title']])
. ($aOptions['tools'] ? $this->_oHtml->getTag('div', ['class'=>'card-tools', 'label'=>$aOptions['tools']]) : '')
);
$sCardBody=$this->_oHtml->getTag('div', ['class'=>'card-body', 'label'=>$aOptions['text']]);
$sCardFooter=$aOptions['footer'] ? $this->_oHtml->getTag('div', ['class'=>'card-footer', 'label'=>$aOptions['footer']]) : '';
// merge all
return $this->addWrapper('div', ['class'=>$sClass], $sCardHeader.$sCardBody.$sCardFooter);
} }
......
<?php
$aCard=[
'type'=>'primary',
'variant'=>'fill',
'title'=>'I am a card',
'tools'=>'123',
'text'=>'Hello everybody out there!',
'footer'=>'&copy; Axel',
];
echo $renderAdminLTE->addRow(
'<h2>Cards</h2>'
)
.print_r($renderAdminLTE->showKeyHelp("color"), 1)
.$renderAdminLTE->addRow(
'<h3>Syntax</h3>
<pre>
echo $renderAdminLTE->getCard($aOptions)
</pre>
'
)
/*
.$renderAdminLTE->addRow(
'<h3>Keys</h3>
<table class="table">
<tr>
<th>Key</th>
<th>Description</th>
</tr>
<tr>
<td>bgcolor</td>
<td>background color (without prefix "bg")</td>
</tr>
<tr>
<td>class</td>
<td>any css class for customizing, eg. "disabled"</td>
</tr>
<tr>
<td>id</td>
<td>optional: id attribute</td>
</tr>
<tr>
<td>text</td>
<td>button label text</td>
</tr>
<tr>
<td>title</td>
<td>optional: title attribute</td>
</tr>
<tr>
<td>type</td>
<td>one of [none]|danger|info|primary|success|warning</td>
</tr>
</table>
'
)
.$renderAdminLTE->addRow(
'<h3>Example</h3><pre>
$renderAdminLTE->getBadge([
\'type\'=>\'danger\',
\'title\'=>\'Errors: 5\',
\'text\'=>\'5\',
])
</pre>
'
)
*/
.$renderAdminLTE->addRow(
'<h3>Test</h3>
'
. $renderAdminLTE->getCard($aCard)
.'
<pre>'
. htmlentities($renderAdminLTE->getCard($aCard))
.'
</pre>
</p>
'
)
;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment