kartik\export\ExportMenu::renderExportMenu PHP Метод

renderExportMenu() публичный Метод

Renders the export menu
public renderExportMenu ( ) : string
Результат string the export menu markup
    public function renderExportMenu()
    {
        $items = $this->asDropdown ? [] : '';
        foreach ($this->exportConfig as $format => $settings) {
            if (empty($settings) || $settings === false) {
                continue;
            }
            $label = '';
            if (!empty($settings['icon'])) {
                $css = $this->fontAwesome ? 'fa fa-' : 'glyphicon glyphicon-';
                $iconOptions = ArrayHelper::getValue($settings, 'iconOptions', []);
                Html::addCssClass($iconOptions, $css . $settings['icon']);
                $label = Html::tag('i', '', $iconOptions) . ' ';
            }
            if (!empty($settings['label'])) {
                $label .= $settings['label'];
            }
            $fmt = strtolower($format);
            $linkOptions = ArrayHelper::getValue($settings, 'linkOptions', []);
            $linkOptions['id'] = $this->options['id'] . '-' . $fmt;
            $linkOptions['data-format'] = $format;
            $options = ArrayHelper::getValue($settings, 'options', []);
            Html::addCssClass($linkOptions, "export-full-{$fmt}");
            if ($this->asDropdown) {
                $items[] = ['label' => $label, 'url' => '#', 'linkOptions' => $linkOptions, 'options' => $options];
            } else {
                $tag = ArrayHelper::remove($options, 'tag', 'li');
                if ($tag !== false) {
                    $items .= Html::tag($tag, Html::a($label, '#', $linkOptions), $options);
                } else {
                    $items .= Html::a($label, '#', $linkOptions);
                }
            }
        }
        $form = $this->render($this->exportFormView, ['options' => $this->exportFormOptions, 'exportType' => $this->_exportType, 'columnSelectorEnabled' => $this->_columnSelectorEnabled, 'exportRequestParam' => $this->exportRequestParam, 'exportTypeParam' => self::PARAM_EXPORT_TYPE, 'exportColsParam' => self::PARAM_EXPORT_COLS, 'colselFlagParam' => self::PARAM_COLSEL_FLAG]);
        if ($this->asDropdown) {
            $icon = ArrayHelper::remove($this->dropdownOptions, 'icon', '<i class="glyphicon glyphicon-export"></i>');
            $label = ArrayHelper::remove($this->dropdownOptions, 'label', '');
            $label = empty($label) ? $icon : $icon . ' ' . $label;
            if (empty($this->dropdownOptions['title'])) {
                $this->dropdownOptions['title'] = Yii::t('kvexport', 'Export data in selected format');
            }
            $menuOptions = ArrayHelper::remove($this->dropdownOptions, 'menuOptions', []);
            $itemsBefore = ArrayHelper::remove($this->dropdownOptions, 'itemsBefore', []);
            $itemsAfter = ArrayHelper::remove($this->dropdownOptions, 'itemsAfter', []);
            $items = ArrayHelper::merge($itemsBefore, $items, $itemsAfter);
            $content = strtr($this->template, ['{menu}' => ButtonDropdown::widget(['label' => $label, 'dropdown' => ['items' => $items, 'encodeLabels' => false, 'options' => $menuOptions], 'options' => $this->dropdownOptions, 'encodeLabel' => false]), '{columns}' => $this->renderColumnSelector()]) . "\n" . $form;
            return Html::tag('div', $content, $this->container);
        } else {
            return $items . "\n" . $form;
        }
    }