예제 #1
0
파일: Buttons.php 프로젝트: Olli/components
 /**
  * compile the button toolbar
  */
 protected function compile()
 {
     if (!$this->bootstrap_buttonStyle) {
         $this->bootstrap_buttonStyle = 'btn-default';
     }
     $buttons = Factory::createFromFieldset($this->bootstrap_buttons);
     $buttons->eachChild(array($this, 'addButtonStyle'));
     $this->Template->buttons = $buttons;
 }
예제 #2
0
 /**
  * Get the buttons toolbar/group.
  *
  * @return Group|Toolbar|string
  */
 public function getButtons()
 {
     if ($this->bootstrap_addModalFooter) {
         $style = $this->bootstrap_buttonStyle ?: 'btn-default';
         $buttons = Factory::createFromFieldset($this->bootstrap_buttons);
         if ($this->formButtons) {
             $old = $buttons;
             $buttons = Factory::createGroup();
             foreach ($this->formButtons as $button) {
                 if (is_string($button)) {
                     $button = new StaticHtml($button);
                 }
                 $buttons->addChild($button);
             }
             foreach ($old->getChildren() as $button) {
                 $buttons->addChild($button);
             }
         }
         $buttons->eachChild(function ($item) use($style) {
             if ($item instanceof Attributes) {
                 $classes = $item->getAttribute('class');
                 $classes = array_filter($classes, function ($class) {
                     return strpos($class, 'btn-') !== false;
                 });
                 if (empty($classes)) {
                     $item->addClass($style);
                 }
             }
         });
         $buttons->removeClass('btn-group');
     } else {
         $buttons = implode('', (array) $this->formButtons);
     }
     return $buttons;
 }