예제 #1
0
파일: BSHtml.php 프로젝트: bafio89/qea-u
 /**
  * Generates a button.
  * @param string $type the button type.
  * @param string $label the button label text.
  * @param array $htmlOptions additional HTML attributes.
  * @return string the generated button.
  */
 protected static function btn($type, $label, $htmlOptions = array())
 {
     self::addCssClass('btn', $htmlOptions);
     $color = \bootstrap\helpers\BSArray::popValue('color', $htmlOptions);
     if (!empty($color)) {
         self::addCssClass('btn-' . $color, $htmlOptions);
     } else {
         self::addCssClass('btn-default', $htmlOptions);
     }
     $size = \bootstrap\helpers\BSArray::popValue('size', $htmlOptions);
     if (!empty($size)) {
         self::addCssClass('btn-' . $size, $htmlOptions);
     }
     if (\bootstrap\helpers\BSArray::popValue('block', $htmlOptions, false)) {
         self::addCssClass('btn-block', $htmlOptions);
     }
     if (\bootstrap\helpers\BSArray::popValue('disabled', $htmlOptions, false)) {
         self::addCssClass('disabled', $htmlOptions);
     }
     $loading = \bootstrap\helpers\BSArray::popValue('loading', $htmlOptions);
     if (!empty($loading)) {
         $htmlOptions['data-loading-text'] = $loading;
     }
     if (\bootstrap\helpers\BSArray::popValue('toggle', $htmlOptions, false)) {
         $htmlOptions['data-toggle'] = 'button';
     }
     $icon = \bootstrap\helpers\BSArray::popValue('icon', $htmlOptions);
     $iconOptions = \bootstrap\helpers\BSArray::popValue('iconOptions', $htmlOptions, array());
     if (strpos($type, 'input') === false) {
         if (!empty($icon)) {
             $label = self::icon($icon, $iconOptions) . ' ' . $label;
         }
         $items = \bootstrap\helpers\BSArray::popValue('items', $htmlOptions);
     }
     $navbarbtn = \bootstrap\helpers\BSArray::popValue('type', $htmlOptions, false);
     if ($navbarbtn === BSHtml::BUTTON_TYPE_NAVBARBUTTON) {
         self::addCssClass('navbar-btn', $htmlOptions);
     }
     $dropdownOptions = $htmlOptions;
     \bootstrap\helpers\BSArray::removeValues(array('groupOptions', 'menuOptions', 'dropup'), $htmlOptions);
     self::addSpanClass($htmlOptions);
     // must be called here as parent renders buttons
     self::addPullClass($htmlOptions);
     // must be called here as parent renders buttons
     return isset($items) ? self::btnDropdown($type, $label, $items, $dropdownOptions) : self::createButton($type, $label, $htmlOptions);
 }