Example #1
0
 /**
  * Renders the button and drop down trigger button.
  *
  * The `btn-primary`, `btn-danger`, `btn-success` and `btn-info` class names are forwarded to
  * the buttons.
  */
 protected function render_inner_html()
 {
     $label = parent::render_inner_html();
     $class_names = array_intersect_key(['btn-primary' => true, 'btn-danger' => true, 'btn-success' => true, 'btn-info' => true], $this->class_names);
     $class = implode(' ', array_keys(array_filter($class_names)));
     return $this->render_splitbutton_label($label, $class) . $this->render_splitbutton_toggle($class) . $this->resolve_options($this[self::OPTIONS]);
 }
Example #2
0
 /**
  * Renders the button and drop down trigger button.
  *
  * The `btn-*` class names are forwarded to the buttons.
  *
  * @inheritdoc
  */
 protected function render_inner_html()
 {
     $label = parent::render_inner_html();
     $class = parent::render_class(array_filter($this->class_names, function ($class_name) {
         return strpos($class_name, 'btn-') === 0 || $class_name === 'disabled';
     }, ARRAY_FILTER_USE_KEY));
     return $this->render_splitbutton_label($label, $class) . $this->render_splitbutton_toggle($class) . $this->resolve_options($this[self::OPTIONS]);
 }
Example #3
0
 /**
  * Renders the actions.
  *
  * If actions are defined as the string "boolean" they are replaced by an array with the
  * buttons `button[data-action="cancel"]` and
  * `button[data-action="ok"][type=submit].btn-primary`.
  *
  * If actions are defined as a boolean, they are replaced by a
  * `button[type=submit][data-action="ok"].btn-primary` element with the label "Send".
  *
  * If actions are defined as an array, the array is concatenated with the glue
  * `<span class="separator">&nbsp;</span>`.
  *
  * Otherwise actions are used as is.
  */
 protected function render_inner_html()
 {
     $html = parent::render_inner_html();
     $actions = $this->actions;
     if ($actions == 'boolean') {
         $actions = [new Button('Cancel', ['data-action' => 'cancel']), new Button('Ok', ['data-action' => 'ok', 'type' => 'submit', 'class' => 'btn-primary'])];
     }
     if (is_array($actions)) {
         foreach ($actions as $name => $action) {
             if (!is_string($name) || !$action instanceof Element || $action['name'] !== null) {
                 continue;
             }
             $action['name'] = $name;
         }
         $actions = implode($actions);
     } else {
         if ($actions === true) {
             $actions = new Button('Ok', ['dataset' => ['action' => 'ok'], 'type' => 'submit', 'class' => 'btn-primary']);
         }
     }
     return $html . $actions;
 }
Example #4
0
 /**
  * Prepends the inner HTML with a description and a legend.
  *
  * If the {@link DESCRIPTION} attribute is defined the HTML is prepend with a
  * `DIV.group-description>DIV.group-description-inner` element. The description is translated
  * within the "group.description" scope. The description is not escaped.
  *
  * If the {@link LEGEND} attribute is defined the HTML is prepend with a `<LEGEND>` element.
  * The legend can be provided as an object in which it is used _as is_, otherwise the legend
  * is translated within the "group.legend" scope, then escaped.
  *
  * The legend element is rendered using the {@link render_group_legend()} method.
  *
  * @inheritdoc
  */
 protected function render_inner_html()
 {
     $html = parent::render_inner_html();
     if ($html === null) {
         throw new ElementIsEmpty();
     }
     $description = $this[self::DESCRIPTION];
     if ($description) {
         $description = $this->t($description, [], ['scope' => 'group.description']);
         $html = $this->render_group_description($description) . $html;
     }
     $legend = $this[self::LEGEND];
     if ($legend) {
         if (is_object($legend)) {
             $legend = (string) $legend;
         } else {
             $legend = escape($this->t($legend, [], ['scope' => 'group.legend']));
         }
         $html = $this->render_group_legend($legend) . $html;
     }
     return $html;
 }
Example #5
0
 protected function render_modal_body()
 {
     return parent::render_inner_html();
 }
Example #6
0
    /**
     * The inner HTML is wrapped in a number of DIV elements, and the title is used a the popover
     * title.
     */
    protected function render_inner_html()
    {
        $content = parent::render_inner_html();
        $title = $this[self::TITLE];
        if ($title) {
            $title = '<h3 class="popover-title">' . escape($title) . '</h3>';
        }
        $actions = $this[self::ACTIONS];
        if ($actions) {
            $actions = $this->render_actions($actions);
        }
        return <<<EOT
<div class="arrow"></div>
<div class="popover-inner">{$title}<div class="popover-content">{$content}</div>{$actions}</div>
EOT;
    }