diff --git a/public_html/classes/render-adminlte.class.php b/public_html/classes/render-adminlte.class.php index b7c75e5df4f3e0388ca72feb5e6b1bbea0185b03..6360d6662a69d1c6fb3fa5dec1eaf43840d91bf0 100755 --- a/public_html/classes/render-adminlte.class.php +++ b/public_html/classes/render-adminlte.class.php @@ -400,18 +400,71 @@ class renderadminlte { 'linktext'=>['group'=>'content', 'description'=>'used if a url was given: linked text', 'example_value'=>'More info'] ] ], + // ------------------------------------------------------------ + 'input'=>[ + 'label'=>'Form: input', + 'description'=>'Input form fiels', + 'method'=>'getInput', + + 'params'=>[ + 'label' => [ + 'group'=>'styling', + 'description'=>'label for the input field', + 'example_value'=>'Enter your firstname' + ], + 'type'=>['select'=> [ + 'description'=>'type or input field', + 'group'=>'styling', + 'values'=>[ + 'text'=>'text', + 'password'=>'password', + 'email'=>'email', + 'hidden'=>'hidden', + ] + ], + 'example_value'=>'text' + ], + 'class' => [ + 'group'=>'styling', + 'description'=>'optional: css classes', + 'example_value'=>'myclass' + ], + 'prepend' => [ + 'group'=>'styling', + 'description'=>'optional: content on input start', + 'example_value'=>'+' + ], + 'append' => [ + 'group'=>'styling', + 'description'=>'optional: content on input end', + 'example_value'=>':-)' + ], + 'name' => [ + 'group'=>'content', + 'description'=>'name attribute', + 'example_value'=>'firstname' + ], + 'value' => [ + 'group'=>'content', + 'description'=>'Value', + 'example_value'=>'Jack' + ], + ] + ], ]; } /** * helper function: a shortcut for $this->_oHtml->getTag * @param string $sTag name of html tag * @param array $aAttributes array of its attributes + * @param string $sContent content between opening and closing tag + * @param bool $bClosetag flag: write a closing tag or not? default: true */ - protected function _tag($sTag, $aAttributes, $sContent=false){ + protected function _tag($sTag, $aAttributes, $sContent=false, $bClosetag=true){ if ($sContent){ $aAttributes['label']=(isset($aAttributes['label']) ? $aAttributes['label'] : '') . $sContent; } - return $this->_oHtml->getTag($sTag, $aAttributes); + return $this->_oHtml->getTag($sTag, $aAttributes, $bClosetag); } // ---------------------------------------------------------------------- // @@ -1111,45 +1164,61 @@ class renderadminlte { } -/* - -<div class="info-box"> - <span class="info-box-icon bg-info"><i class="far fa-bookmark"></i></span> - <div class="info-box-content"> - <span class="info-box-text">Bookmarks</span> - <span class="info-box-number">41,410</span> - <div class="progress"> - <div class="progress-bar bg-info" style="width: 70%"></div> - </div> - <span class="progress-description"> - 70% Increase in 30 Days - </span> - </div> -</div> - - - - <div class="info-box bg-success"> - <span class="info-box-icon"><i class="far fa-thumbs-up"></i></span> - <div class="info-box-content"> - <span class="info-box-text">Likes</span> - <span class="info-box-number">41,410</span> - <div class="progress"> - <div class="progress-bar" style="width: 70%"></div> - </div> - <span class="progress-description"> - 70% Increase in 30 Days - </span> - </div> - </div> -*/ - - - + /** + * return a text input field: + * https://adminlte.io/themes/v3/pages/forms/general.html + * + * @param type $aOptions hash with keys for all options + * styling: + * - type - field type: text, email, password, hidden + * content + * - label - label tag + * - name - name attribute for sending form + * - value - value in + * @return string + */ + public function GetInput($aOptions){ + $aOptions=$this->_ensureOptions('input', $aOptions); + $aElement=$aOptions; + $aElement['class']='' + . $this->_addClassValue($aOptions['class'], '') + ; + $sFormid=(isset($aOptions['id']) + ? $aOptions['id'] + : (isset($aOptions['name']) ? $aOptions['name'] : 'field' ).'-'.md5(microtime(true)) + ); + $sLabel=''; + $sPrepend=''; + $sAppend=''; + $sLabel.=isset($aOptions['label']) && $aOptions['label'] ? $this->_tag('label', ['for'=>$sFormid], $aOptions['label']) : ''; + $aElement['id']=$sFormid; + foreach(['_infos', 'label'] as $sDeleteKey){ + unset($aElement[$sDeleteKey]); + } + $sWrapperclass='form-group'; + if(isset($aOptions['prepend']) && $aOptions['prepend']){ + $sWrapperclass='input-group'; + $sPrepend=$this->_tag('div',[ 'class'=>'input-group-prepend'], + $this->_tag('span', ['class'=>'input-group-text'] , $aOptions['prepend']) + ); + } + if(isset($aOptions['append']) && $aOptions['append']){ + $sWrapperclass='input-group'; + $sAppend=$this->_tag('div',[ 'class'=>'input-group-append'], + $this->_tag('span', ['class'=>'input-group-text'] , $aOptions['append']) + ); + } + return $this->_tag('div', ['class'=>$sWrapperclass], + $sLabel + .$sPrepend + .$this->_tag('input', $aElement, '', false) + .$sAppend + ); + } }