Beispiel #1
0
    <html lang="<?php 
echo Yii::$app->language;
?>
">

    <head>
        <meta charset="<?php 
echo Yii::$app->charset;
?>
">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <?php 
echo Html::csrfMetaTags();
?>
        <title><?php 
echo Html::encode($this->title);
?>
</title>
        <?php 
$this->head();
?>
    </head>

    <body>
    <?php 
$this->beginBody();
?>

        <header class="page-header">
            <?php 
NavBar::begin(['brandLabel' => 'My Company', 'brandUrl' => Yii::$app->homeUrl, 'fixed' => true, 'wrapperOptions' => ['class' => 'container']]);
Beispiel #2
0
 /**
  * Executes the widget.
  * @return string the result of widget execution to be outputted.
  * @uses [[Icon]]
  */
 public function run()
 {
     $tag = ArrayHelper::remove($this->options, 'tag', 'div');
     $html = Html::beginTag($tag, $this->options);
     if ($this->imageOptions) {
         $src = ArrayHelper::remove($this->imageOptions, 'src', '');
         $html .= Html::img($src, $this->imageOptions);
     }
     $html .= $this->encodeContent ? Html::encode($this->content) : $this->content;
     if ($this->renderIcon) {
         $html .= Icon::widget(['name' => ArrayHelper::getValue($this->icon, 'name', null), 'position' => ArrayHelper::getValue($this->icon, 'position', ''), 'options' => ArrayHelper::getValue($this->icon, 'options', [])]);
     }
     $html .= Html::endTag($tag);
     return $html;
 }
Beispiel #3
0
 /**
  * Renders a widget's item.
  * @param string|array $item the item to render.
  * @return string the rendering result.
  * @throws InvalidConfigException
  */
 public function renderItem($item)
 {
     if (is_string($item)) {
         return $item;
     }
     if (!isset($item['label'])) {
         throw new InvalidConfigException("The 'label' option is required.");
     }
     $encodeLabel = isset($item['encode']) ? $item['encode'] : $this->encodeLabels;
     $label = $encodeLabel ? Html::encode($item['label']) : $item['label'];
     $options = ArrayHelper::getValue($item, 'options', []);
     $items = ArrayHelper::getValue($item, 'items');
     $url = ArrayHelper::getValue($item, 'url', '#');
     $linkOptions = ArrayHelper::getValue($item, 'linkOptions', []);
     if (isset($item['active'])) {
         $active = ArrayHelper::remove($item, 'active', false);
     } else {
         $active = $this->isItemActive($item);
     }
     if (empty($items)) {
         $items = '';
     } else {
         $toggleTarget = 'dropdown_' . md5(uniqid());
         $linkOptions['data-activates'] = $toggleTarget;
         Html::addCssClass($options, ['widget' => 'dropdown']);
         Html::addCssClass($linkOptions, ['widget' => 'dropdown-button']);
         if ($this->dropDownCaret !== '') {
             $label .= ' ' . $this->dropDownCaret;
         }
         if (is_array($items)) {
             if ($this->activateItems) {
                 $items = $this->isChildActive($items, $active);
             }
             $items = $this->renderDropdown($items, $item, $toggleTarget);
         }
     }
     if ($this->activateItems && $active) {
         Html::addCssClass($options, 'active');
     }
     return Html::tag('li', Html::a($label, $url, $linkOptions) . $items, $options);
 }
Beispiel #4
0
 /**
  * Executes the widget.
  * @return string the result of widget execution to be outputted.
  * @uses [[renderIcon]]
  */
 public function run()
 {
     if ($this->label !== false) {
         $label = $this->encodeLabel ? Html::encode($this->label) : $this->label;
     } else {
         $label = '';
     }
     $content = $this->renderIcon() . $label;
     return $this->tagName === 'button' ? Html::button($content, $this->options) : Html::tag($this->tagName, $content, $this->options);
 }
 /**
  * Renders a single breadcrumb item.
  * @param array $link the link to be rendered. It must contain the "label" element. The "url" element is optional.
  * @param string $template the template to be used to rendered the link. The token "{link}" will be replaced by the link.
  * @return string the rendering result
  * @throws InvalidConfigException if `$link` does not have "label" element.
  */
 protected function renderItem($link, $template)
 {
     $encodeLabel = ArrayHelper::remove($link, 'encode', $this->encodeLabels);
     if (array_key_exists('label', $link)) {
         $label = $encodeLabel ? Html::encode($link['label']) : $link['label'];
     } else {
         throw new InvalidConfigException('The "label" element is required for each link.');
     }
     if (isset($link['template'])) {
         $template = $link['template'];
     }
     if (isset($link['url'])) {
         $options = $link;
         Html::addCssClass($options, ['link' => 'breadcrumb']);
         unset($options['template'], $options['label'], $options['url']);
         $link = Html::a($label, $link['url'], $options);
     } else {
         $link = $label;
     }
     return strtr($template, ['{link}' => $link]);
 }
 /**
  * Renders the HTML markup for the on/off label.
  *
  * This method also renders the corresponding icons, if set.
  *
  * @param string $state the state to used. Use "off" or "on".
  * @return string the rendered label.
  * @uses [[Icon|Icon]]
  */
 protected function renderLabel($state)
 {
     $icon = $this->renderIcon($state);
     $encodeProperty = "encode" . ucfirst($state) . "Text";
     $textProperty = "{$state}Text";
     $label = $this->{$encodeProperty} ? Html::encode($this->{$textProperty}) : $this->{$textProperty};
     $label .= $icon;
     $html = [];
     $html[] = Html::beginTag('span', ['class' => "{$state}Label"]);
     $html[] = $label;
     $html[] = Html::endTag('span');
     return implode("\n", $html);
 }
 /**
  * Renders a list representing the single button items.
  * @return string
  * @throws InvalidConfigException
  */
 protected function renderItems()
 {
     $elements = [];
     $items = $this->items;
     foreach ($items as $item) {
         if (isset($item['visible']) && !$item['visible']) {
             continue;
         }
         if (is_string($item)) {
             $elements[] = $item;
             continue;
         }
         if (!array_key_exists('label', $item)) {
             throw new InvalidConfigException("The 'label' option is required.");
         }
         $encodeLabel = isset($item['encode']) ? $item['encode'] : $this->encodeLabels;
         $label = $encodeLabel ? Html::encode($item['label']) : $item['label'];
         $itemOptions = ArrayHelper::getValue($item, 'options', []);
         $linkOptions = ArrayHelper::getValue($item, 'linkOptions', []);
         $url = array_key_exists('url', $item) ? $item['url'] : null;
         if ($url === null) {
             $content = $label;
         } else {
             $content = Html::a($label, $url, $linkOptions);
         }
         $elements[] = Html::tag('li', $content, $itemOptions);
     }
     return Html::tag('ul', implode("\n", $elements), $this->itemsContainerOptions);
 }
 /**
  * Renders menu items.
  *
  * @param array $items the menu items to be rendered
  * @param array $options the container HTML attributes
  * @return string the rendering result.
  * @throws InvalidConfigException if the label option is not specified in one of the items.
  * @used-by [[run()]]
  */
 protected function renderItems($items, $options = [])
 {
     $lines = [];
     foreach ($items as $item) {
         if (isset($item['visible']) && !$item['visible']) {
             continue;
         }
         if (is_string($item)) {
             $lines[] = $item;
             continue;
         }
         if (!array_key_exists('label', $item)) {
             throw new InvalidConfigException("The 'label' option is required.");
         }
         $encodeLabel = isset($item['encode']) ? $item['encode'] : $this->encodeLabels;
         $label = $encodeLabel ? Html::encode($item['label']) : $item['label'];
         $itemOptions = ArrayHelper::getValue($item, 'options', []);
         $linkOptions = ArrayHelper::getValue($item, 'linkOptions', []);
         $linkOptions['tabindex'] = '-1';
         $url = array_key_exists('url', $item) ? $item['url'] : null;
         if (empty($item['items'])) {
             if ($url === null) {
                 $content = $label;
                 Html::addCssClass($itemOptions, ['widget' => 'dropdown-header']);
             } else {
                 $content = Html::a($label, $url, $linkOptions);
             }
         } else {
             $submenuOptions = $this->submenuOptions;
             if (isset($item['submenuOptions'])) {
                 $submenuOptions = array_merge($submenuOptions, $item['submenuOptions']);
             }
             $content = Html::a($label, $url === null ? '#' : $url, $linkOptions) . $this->renderItems($item['items'], $submenuOptions);
             Html::addCssClass($itemOptions, ['widget' => 'dropdown-submenu']);
         }
         $lines[] = Html::tag('li', $content, $itemOptions);
     }
     return Html::tag('ul', implode("\n", $lines), $options);
 }