protected function renderItems() { $html = trim(ob_get_clean()); if (!empty($html)) { $html = "\n" . $html; } $headers = []; $panes = []; if (!$this->hasActiveTab() && !empty($this->items)) { $this->items[0]['active'] = true; } foreach ($this->items as $n => $item) { if (!isset($item['label'])) { throw new InvalidConfigException("The 'label' option is required."); } $label = $this->encodeLabels ? Html::encode($item['label']) : $item['label']; $headerOptions = array_merge($this->headerOptions, ArrayHelper::getValue($item, 'headerOptions', [])); $linkOptions = array_merge($this->linkOptions, ArrayHelper::getValue($item, 'linkOptions', [])); if (isset($item['items'])) { $label .= ' <b class="caret"></b>'; Html::addCssClass($headerOptions, 'dropdown'); if ($this->renderDropdown($item['items'], $panes)) { Html::addCssClass($headerOptions, 'active'); } Html::addCssClass($linkOptions, 'dropdown-toggle'); $linkOptions['data-toggle'] = 'dropdown'; $header = Html::a($label, "#", $linkOptions) . "\n" . Dropdown::widget(['items' => $item['items'], 'clientOptions' => false, 'view' => $this->getView()]); } elseif (isset($item['content'])) { $options = array_merge($this->itemOptions, ArrayHelper::getValue($item, 'options', [])); $options['id'] = ArrayHelper::getValue($options, 'id', $this->options['id'] . '-tab' . $n); Html::addCssClass($options, 'tab-pane'); if (ArrayHelper::remove($item, 'active')) { Html::addCssClass($options, 'active'); Html::addCssClass($headerOptions, 'active'); } $linkOptions['data-toggle'] = 'tab'; $header = Html::a($label, '#' . $options['id'], $linkOptions); $panes[] = Html::tag('div', $item['content'], $options); } elseif (isset($item['contentId'])) { $options = array_merge($this->itemOptions, ArrayHelper::getValue($item, 'options', [])); $options['id'] = $item['contentId']; Html::addCssClass($options, 'tab-pane'); if (ArrayHelper::remove($item, 'active')) { Html::addCssClass($options, 'active'); Html::addCssClass($headerOptions, 'active'); } $linkOptions['data-toggle'] = 'tab'; $header = Html::a($label, '#' . $options['id'], $linkOptions); $panes[] = ''; //Html::tag('div', $item['content'], $options); } else { throw new InvalidConfigException("Either the 'content' or 'items' option must be set."); } $headers[] = Html::tag('li', $header, $headerOptions); } return Html::tag('ul', implode("\n", $headers), $this->options) . "\n" . Html::tag('div', implode("\n", $panes) . $html, ['class' => 'tab-content']); }
public function testIds() { Dropdown::$counter = 0; $out = Dropdown::widget(['items' => [['label' => 'Page1', 'content' => 'Page1'], ['label' => 'Dropdown1', 'items' => [['label' => 'Page2', 'content' => 'Page2'], ['label' => 'Page3', 'content' => 'Page3']]], ['label' => 'Dropdown2', 'visible' => false, 'items' => [['label' => 'Page4', 'content' => 'Page4'], ['label' => 'Page5', 'content' => 'Page5']]]]]); $expected = <<<EXPECTED <ul id="w0" class="dropdown-menu"><li class="dropdown-header">Page1</li> <li class="dropdown-submenu"><a href="#" tabindex="-1">Dropdown1</a><ul class="dropdown-menu"><li class="dropdown-header">Page2</li> <li class="dropdown-header">Page3</li></ul></li></ul> EXPECTED; $this->assertEqualsWithoutLE($expected, $out); }
/** * Renders tab items as specified on [[items]]. * @return string the rendering result. * @throws InvalidConfigException. */ protected function renderItems() { $headers = []; $panes = []; if (!$this->hasActiveTab() && !empty($this->items)) { $this->items[0]['active'] = true; } foreach ($this->items as $n => $item) { 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']; $headerOptions = array_merge($this->headerOptions, ArrayHelper::getValue($item, 'headerOptions', [])); $linkOptions = array_merge($this->linkOptions, ArrayHelper::getValue($item, 'linkOptions', [])); if (isset($item['items'])) { $label .= ' <b class="caret"></b>'; Html::addCssClass($headerOptions, 'dropdown'); if ($this->renderDropdown($n, $item['items'], $panes)) { Html::addCssClass($headerOptions, 'active'); } Html::addCssClass($linkOptions, 'dropdown-toggle'); $linkOptions['data-toggle'] = 'dropdown'; $header = Html::a($label, "#", $linkOptions) . "\n" . Dropdown::widget(['items' => $item['items'], 'clientOptions' => false, 'view' => $this->getView()]); } else { // ha nem dropdown $options = array_merge($this->itemOptions, ArrayHelper::getValue($item, 'options', [])); $options['id'] = ArrayHelper::getValue($options, 'id', $this->options['id'] . '-tab' . $n); Html::addCssClass($options, 'tab-pane'); if (ArrayHelper::remove($item, 'active')) { Html::addCssClass($options, 'active'); Html::addCssClass($headerOptions, 'active'); } $url = ArrayHelper::getValue($linkOptions, 'href', '#'); if ($url == '#' && !isset($linkOptions['data-toggle'])) { $linkOptions['data-toggle'] = 'tab'; $url .= $options['id']; } $header = Html::a($label, $url, $linkOptions); if ($this->renderTabContent) { $panes[] = Html::tag('div', isset($item['content']) ? $item['content'] : '', $options); } } $headers[] = Html::tag('li', $header, $headerOptions); } return Html::tag('ul', implode("\n", $headers), $this->options) . ($this->renderTabContent ? "\n" . Html::tag('div', implode("\n", $panes), ['class' => 'tab-content']) : ''); }
public function run() { $view = $this->getView(); B3wAsset::register($view); if (!is_array($this->items) || count($this->items) == 0) { return ''; } //----------------------------------------- $this->size = strtolower($this->size); $_sizeClass = in_array($this->size, ['xs', 'sm', 'lg']) ? 'btn-group-' . $this->size : ''; $_sizeBtnClass = in_array($this->size, ['xs', 'sm', 'lg']) ? 'btn-' . $this->size : ''; $this->type = strtolower($this->type); $_typeClass = in_array($this->type, ['default', 'success', 'danger', 'warning', 'info', 'primary']) ? 'btn-' . $this->type : ''; $out = ''; foreach ($this->items as $item) { if (isset($item['items']) && is_array($item['items'])) { $linkOptions = []; $aClasses = ['btn', $_typeClass, 'dropdown-toggle', $_sizeBtnClass]; if (array_key_exists('linkOptions', $item)) { $_ = $item['linkOptions']; if (array_key_exists('class', $_)) { $aClasses = array_merge($aClasses, [$_['class']]); unset($_['class']); } $linkOptions = array_merge($_, ['data-toggle' => 'dropdown']); } $linkOptions['class'] = implode(' ', $aClasses); $groupOptions = array_key_exists('groupOptions', $item) ? $item['groupOptions'] : []; if (array_key_exists('class', $groupOptions)) { $groupOptions['class'] = $groupOptions['class'] . ' btn-group'; } else { $groupOptions['class'] = 'btn-group'; } $groupOptions['role'] = 'group'; $out .= Html::tag('div', Html::a($item['label'] . ' <span class="caret"></span>', '#', $linkOptions) . Dropdown::widget(['items' => $item['items'], 'encodeLabels' => array_key_exists('encodeLabels', $item) ? $item['encodeLabels'] : true]), $groupOptions); } else { $item['linkOptions']['class'] = (isset($item['linkOptions']['class']) ? $item['linkOptions']['class'] : '') . ' btn ' . $_typeClass; $out .= Html::a($item['label'], $item['url'], $item['linkOptions']); } } $this->containerOptions['class'] .= ' btn-group ' . $_sizeClass; $this->containerOptions['role'] = 'group'; return !empty($out) ? Html::tag('div', $out, $this->containerOptions) . ($this->addClearfix ? Html::tag('div', '', ['class' => 'clearfix']) : '') : ''; }
<div class="box box-default"> <div class="box-header with-border"> <h3 class="box-title"><a href="<?php echo Url::to(['/certificates/requests', 'tasks_id' => $current_task ? $current_task->id : null, 'new' => true]); ?> " class="btn btn-default btn-sm btn-flat"><i class="fa fa-plus"></i> Добавить запрос</a></h3> </div> <div class="box-body"> <?php $columns = [['attribute' => 'created_at', 'format' => ['date', 'php:d.m.Y H:i']], ['attribute' => 'Количество запросов', 'value' => function ($data) { return $data->requestAmount; }], ['attribute' => 'state', 'value' => function ($data) { return $data->state ? 'Активна' : 'Неактивна'; }], ['label' => '', 'format' => 'raw', 'contentOptions' => ['class' => 'menu-col skip-export'], 'value' => function ($data) { $items[] = ['label' => 'Подробнее', 'url' => ['/certificates/requests', 'tasks_id' => $data->id]]; $items[] = ['label' => 'Удалить', 'url' => ['#'], 'linkOptions' => ['data-toggle' => 'modal', 'data-target' => '#myModal', 'onclick' => '$("#del-task").attr("href", "del-task?id=' . $data->id . '");']]; Modal::begin(['header' => '<h2>Действительно удалить задачу из списка?</h2>', 'id' => 'myModal']); echo '<div class="panel">Также будут удалены все запросы, связанные с данной задачей.</div>'; echo '<div class="text-center"><ul class="list-inline">' . '<li>' . Html::a('<span class="fa fa-times"></span> Удалить', '', ['id' => 'del-task', 'class' => 'btn btn-sm btn-flat btn-danger']) . '</li>' . '<li>' . Html::a('Отменить', '', ['class' => 'btn btn-sm btn-flat btn-default ', 'data-dismiss' => "modal", 'aria-hidden' => true]) . '</li>' . '</ul></div>'; Modal::end(); return '<div class="dropdown"><span class="btn btn-flat menu-button dropdown-toggle" data-toggle="dropdown" ><i class="fa fa-ellipsis-v"></i></span>' . Dropdown::widget(['items' => $items, 'options' => ['class' => 'wagon-control-ul']]) . '</div>'; }]]; echo GridView::widget(['dataProvider' => $tasks, 'columns' => $columns, 'layout' => '<div class="pull-left">{summary}</div><div class="pull-right">{export}</div>{items}{pager}', 'toolbar' => ['{export}'], 'export' => ['options' => ['class' => 'btn-default btn-xs btn-flat']], 'bordered' => true, 'striped' => false, 'condensed' => true, 'responsive' => false, 'hover' => true, 'exportConfig' => [GridView::TEXT => ['config' => ['colDelimiter' => " | ", 'rowDelimiter' => "\r\n"]], GridView::PDF => ['config' => ['mode' => 'utf-8']], GridView::EXCEL => []]]); ?> </div> </div> </div> <div class="col-sm-6"> </div> </div>
/** * Generates the dropdown menu. * @return string the rendering result. */ protected function renderDropdown() { $config = $this->dropdown; $config['clientOptions'] = false; $config['view'] = $this->getView(); return Dropdown::widget($config); }
/** * @inheritdoc */ public function run() { echo Html::endTag($this->_targetTag) . PHP_EOL; echo Html::beginTag($this->_menuTag, $this->menuContainer) . PHP_EOL; echo Dropdown::widget(['items' => $this->items, 'encodeLabels' => $this->encodeLabels, 'options' => $this->menuOptions]) . PHP_EOL; echo Html::endTag($this->_menuTag); }
/** * Renders tab items as specified in [[items]]. * * @return string the rendering result. */ protected function renderItems() { $headers = $panes = $labels = []; if (!$this->hasActiveTab() && !empty($this->items)) { $this->items[0]['active'] = true; } foreach ($this->items as $n => $item) { if (!ArrayHelper::remove($item, 'visible', true)) { continue; } $label = $this->getLabel($item); $headerOptions = array_merge($this->headerOptions, ArrayHelper::getValue($item, 'headerOptions', [])); $linkOptions = array_merge($this->linkOptions, ArrayHelper::getValue($item, 'linkOptions', [])); $content = ArrayHelper::getValue($item, 'content', ''); if (isset($item['items'])) { foreach ($item['items'] as $subItem) { $subLabel = $this->getLabel($subItem); $labels[] = $this->printHeaderCrumbs ? $label . $this->printCrumbSeparator . $subLabel : $subLabel; } $label .= ' <b class="caret"></b>'; Html::addCssClass($headerOptions, 'dropdown'); if ($this->renderDropdown($n, $item['items'], $panes)) { Html::addCssClass($headerOptions, 'active'); } Html::addCssClass($linkOptions, 'dropdown-toggle'); $linkOptions['data-toggle'] = 'dropdown'; $header = Html::a($label, "#", $linkOptions) . "\n" . Dropdown::widget(['items' => $item['items'], 'clientOptions' => false, 'view' => $this->getView()]); } else { $labels[] = $label; $options = array_merge($this->itemOptions, ArrayHelper::getValue($item, 'options', [])); $options['id'] = ArrayHelper::getValue($options, 'id', $this->options['id'] . '-tab' . $n); $css = 'tab-pane'; $isActive = ArrayHelper::remove($item, 'active'); if ($this->fade) { $css = $isActive ? "{$css} fade in" : "{$css} fade"; } Html::addCssClass($options, $css); if ($isActive) { Html::addCssClass($options, 'active'); Html::addCssClass($headerOptions, 'active'); } if (isset($item['url'])) { $header = Html::a($label, $item['url'], $linkOptions); } else { $linkOptions['data-toggle'] = 'tab'; $linkOptions['role'] = 'tab'; $header = Html::a($label, '#' . $options['id'], $linkOptions); } if ($this->renderTabContent) { $panes[] = Html::tag('div', $content, $options); } } $headers[] = Html::tag('li', $header, $headerOptions); } $outHeader = Html::tag('ul', implode("\n", $headers), $this->options); if ($this->renderTabContent) { $outPane = Html::beginTag('div', ['class' => 'tab-content' . $this->getCss('printable', $this->printable)]); foreach ($panes as $i => $pane) { if ($this->printable) { $outPane .= Html::tag('div', ArrayHelper::getValue($labels, $i), $this->printHeaderOptions) . "\n"; } $outPane .= "{$pane}\n"; } $outPane .= Html::endTag('div'); $tabs = $this->position == self::POS_BELOW ? $outPane . "\n" . $outHeader : $outHeader . "\n" . $outPane; } else { $tabs = $outHeader; } return Html::tag('div', $tabs, $this->containerOptions); }
/** * Renders the given items as a dropdown. * This method is called to create sub-menus. * @param array $items the given items. Please refer to [[Dropdown::items]] for the array structure. * @param array $parentItem the parent item information. Please refer to [[items]] for the structure of this array. * @return string the rendering result. * @since 2.0.1 */ protected function renderDropdown($items, $parentItem) { return Dropdown::widget(['items' => $items, 'encodeLabels' => $this->encodeLabels, 'clientOptions' => false, 'view' => $this->getView()]); }
/** * Generates the dropdown menu. * @return string the rendering result. */ protected function renderItems() { $this->prepareItems(); $config = []; $config['items'] = $this->items; $config['options'] = ['class' => 'dropdown-menu-right']; $config['clientOptions'] = false; $config['view'] = $this->getView(); return Dropdown::widget($config); }
<?php $page->beginContent('bulk-actions'); ?> <?php if (Yii::$app->user->can('support')) { ?> <div class="dropdown" style="display: inline-block"> <button type="button" class="btn btn-sm btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <?php echo Yii::t('hipanel', 'Block'); ?> <span class="caret"></span> </button> <?php echo Dropdown::widget(['encodeLabels' => false, 'options' => ['class' => 'pull-right'], 'items' => [['label' => '<i class="fa fa-toggle-on"></i> ' . Yii::t('hipanel', 'Enable'), 'linkOptions' => ['data-toggle' => 'modal'], 'url' => '#bulk-enable-block-modal'], ['label' => '<i class="fa fa-toggle-off"></i> ' . Yii::t('hipanel', 'Disable'), 'url' => '#bulk-disable-block-modal', 'linkOptions' => ['data-toggle' => 'modal']]]]); ?> <div class="text-left"> <?php echo AjaxModal::widget(['id' => 'bulk-enable-block-modal', 'bulkPage' => true, 'header' => Html::tag('h4', Yii::t('hipanel:client', 'Block clients'), ['class' => 'modal-title']), 'scenario' => 'bulk-enable-block', 'actionUrl' => ['bulk-enable-block-modal'], 'size' => Modal::SIZE_LARGE, 'handleSubmit' => false, 'toggleButton' => false]); ?> <?php echo AjaxModal::widget(['id' => 'bulk-disable-block-modal', 'bulkPage' => true, 'header' => Html::tag('h4', Yii::t('hipanel:client', 'Unblock clients'), ['class' => 'modal-title']), 'scenario' => 'bulk-disable-block', 'actionUrl' => ['bulk-disable-block-modal'], 'size' => Modal::SIZE_LARGE, 'handleSubmit' => false, 'toggleButton' => false]); ?> </div> </div> <?php } ?> <?php if (Yii::$app->user->can('manage')) {
/** * @return mixed */ private function renderDropdown() { return \yii\bootstrap\Dropdown::widget(['items' => $this->items, 'options' => ['class' => 'pull-right']]); }
if (!Yii::$app->user->isGuest) { $notificaciones = new Notificaciones(); $mensajes = $notificaciones->mensajesSinLeer(Yii::$app->user->getId()); $mensajesTotal = $notificaciones->mensajesSinLeerTotal(Yii::$app->user->getId()); //enlaces opcion mensajes $enlaces = []; foreach ($mensajes as $mensaje) { $enlaces[] = ['label' => Html::tag('span', $mensaje->nombreAnuncio(), ['class' => 'anuncio-nombre']) . Html::tag('span', $mensaje->remitente(), ['class' => 'interesado-nombre']) . Html::tag('span', $mensaje->texto(), ['class' => 'interesado-mensaje']) . Html::tag('span', $mensaje->tiempo(), ['class' => 'interesado-tiempo']), 'url' => Yii::$app->urlManagerMicuenta->createAbsoluteUrl('mensaje/' . $mensaje->conversacionId()), 'linkOptions' => ['class' => 'notificacion-usuario', 'id' => $mensaje->conversacionId()]]; } $enlaces[] = ['label' => Yii::t('app', 'Ver todos los mensajes'), 'url' => Yii::$app->urlManagerMicuenta->createAbsoluteUrl('mensajes'), 'linkOptions' => ['class' => 'ver-mensajes']]; } ?> <?php //uso común echo Html::a(Yii::t('app', 'Ayuda'), Yii::$app->urlManagerAyuda->createAbsoluteUrl('/'), ['class' => 'first-item']); //sin autenticación if (Yii::$app->user->isGuest) { echo Html::a(Yii::t('app', 'Crear cuenta'), null, ['class' => 'lnk-crear-cuenta']); echo Html::a(Yii::t('app', 'Iniciar sesión'), null, ['class' => 'lnk-iniciar-sesion']); } //con autenticación if (!Yii::$app->user->isGuest) { //mensajes $enlaceMensaje = !empty($mensajes) ? '#' : Yii::$app->urlManagerMicuenta->createAbsoluteUrl('/mensajes'); $opcionesMensaje = empty($mensajes) ? [] : ['data-toggle' => 'dropdown', 'class' => 'mensaje-open']; $contadorMensaje = $mensajesTotal == 0 ? '' : Html::tag('span', $mensajesTotal, ['class' => 'contador new badge', 'data-toggle' => 'tooltip', 'data-placement' => 'bottom', 'data-original-title' => Yii::t('frontend', '{contador} mensajes sin leer', ['contador' => $mensajesTotal]), 'title' => Yii::t('frontend', '{contador} mensajes sin leer', ['contador' => $mensajesTotal])]); echo Html::tag('div', Html::a(Yii::t('app', 'Mensajes') . $contadorMensaje, $enlaceMensaje, $opcionesMensaje) . Dropdown::widget(['encodeLabels' => false, 'items' => $enlaces]), ['class' => 'dropdown', 'id' => 'rt-opcion-mensaje']); echo Html::a(Yii::t('app', 'Mis anuncios'), Yii::$app->urlManagerMicuenta->createAbsoluteUrl('/'), ['class' => '']); echo Html::tag('div', Html::a(Yii::$app->user->identity->nombre, '#', ['data-toggle' => 'dropdown', 'class' => 'current-open']) . Dropdown::widget(['items' => [['label' => Yii::t('app', 'Mi perfil'), 'url' => Yii::$app->urlManagerMicuenta->createAbsoluteUrl('mis-datos')], ['label' => Yii::t('app', 'Configuración'), 'url' => Yii::$app->urlManagerMicuenta->createAbsoluteUrl('configuracion')], ['label' => 'Cerrar Sesión', 'url' => Yii::$app->urlManager->createUrl('salir'), 'linkOptions' => ['data-method' => 'post']]]]), ['class' => 'dropdown']); }
}, 'template' => '{update} {settings} {rules} {view} {share} {submissions} {report} {analytics} {delete}']]; ?> <div class="form-index"> <div class="row"> <div class="col-md-12"> <?php echo GridView::widget(['id' => 'form-grid', 'dataProvider' => $dataProvider, 'columns' => $gridColumns, 'resizableColumns' => false, 'pjax' => false, 'export' => false, 'responsive' => true, 'bordered' => false, 'striped' => true, 'panelTemplate' => '<div class="panel {type}"> {panelHeading} {panelBefore} {items} <div style="text-align: center">{pager}</div> </div>', 'panel' => ['type' => GridView::TYPE_INFO, 'heading' => Yii::t('app', 'Forms') . ' <small class="panel-subtitle hidden-xs">' . Yii::t('app', 'Build any type of online form') . '</small>', 'footer' => false, 'before' => !empty(Yii::$app->user) && Yii::$app->user->can("admin") ? ActionBar::widget(['grid' => 'form-grid', 'templates' => ['{create}' => ['class' => 'col-xs-6 col-md-8'], '{bulk-actions}' => ['class' => 'col-xs-6 col-md-2 col-md-offset-2']], 'elements' => ['create' => '<div class="btn-group">' . Html::a('<span class="glyphicon glyphicon-plus"></span> ' . Yii::t('app', 'Create Form'), ['create'], ['class' => 'btn btn-primary']) . '<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <span class="caret"></span> <span class="sr-only">Toggle Dropdown</span> </button>' . Dropdown::widget(['items' => $templateItems]) . '</div> ' . Html::a(Yii::t('app', 'Do you want to customize your forms?'), ['/theme'], ['data-toggle' => 'tooltip', 'data-placement' => 'top', 'title' => Yii::t('app', 'No problem at all. With a theme, you can easily add custom CSS styles to your forms, to customize colors, field sizes, backgrounds, fonts, and more.'), 'class' => 'text hidden-xs hidden-sm'])], 'bulkActionsItems' => [Yii::t('app', 'Update Status') => ['status-active' => Yii::t('app', 'Active'), 'status-inactive' => Yii::t('app', 'Inactive')], Yii::t('app', 'General') => ['general-delete' => Yii::t('app', 'Delete')]], 'bulkActionsOptions' => ['options' => ['status-active' => ['url' => Url::toRoute(['update-status', 'status' => 1])], 'status-inactive' => ['url' => Url::toRoute(['update-status', 'status' => 0])], 'general-delete' => ['url' => Url::toRoute('delete-multiple'), 'data-confirm' => Yii::t('app', 'Are you sure you want to delete these forms? All stats, submissions, conditional rules and reports data related to each item will be deleted. This action cannot be undone.')]], 'class' => 'form-control'], 'class' => 'form-control']) : null], 'toolbar' => false]); ?> </div> </div> </div> <?php $js = <<<'SCRIPT' $(function () { $("[data-toggle='tooltip']").tooltip(); }); SCRIPT; // Register tooltip/popover initialization javascript $this->registerJs($js);
<h3 class="page-header"> <span class="page-header">Year Summary KPI : </span> <span id="tahunCreateTitle" class="dropdown"> <a href="#" data-toggle="dropdown" class="dropdown-toggle"><?php echo Html::encode($tahun_create); ?> </a> <?php $start = 2015; $end = date('Y'); $items = []; for ($iTahunCreate = $start; $iTahunCreate <= $end; $iTahunCreate++) { $items[] = ['label' => $iTahunCreate, 'url' => ['', 'tahun_create' => $iTahunCreate]]; } echo Dropdown::widget(['items' => $items]); ?> </span> </h3> <?php /*echo ExportMenu::widget([ 'dataProvider'=>$dataProvider, ]);*/ ?> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'emptyCell' => " ", 'columns' => [['header' => 'Bulan', 'attribute' => 'bulan_create'], ['header' => 'PO Total', 'attribute' => 'po_total'], ['header' => 'Tercapai %', 'attribute' => 'tercapai_persen'], ['header' => 'Tidak Tercapai %', 'attribute' => 'tdk_tercapai_persen'], ['header' => 'Belum Terkirim %', 'attribute' => 'blm_terkirim_persen'], ['header' => 'Total %', 'attribute' => 'total_persen']]]); ?> <?php
use yii\bootstrap\Html; use yii\bootstrap\Dropdown; use kartik\grid\GridView; /** @var $this \yii\web\View */ /** @var $dataProvider \yii\data\ActiveDataProvider */ $this->title = 'Шаблоны писем'; $this->params['breadcrumbs'][] = $this->title; $cols[] = ['attribute' => 'Наименование', 'value' => function ($layout, $index) { return $layout->name; }]; $cols[] = ['attribute' => 'Путь к файлу', 'value' => function ($layout, $index) { return $layout->layout_path; }]; $cols[] = ['label' => '', 'format' => 'raw', 'contentOptions' => ['class' => 'menu-col'], 'options' => ['style' => 'width:50px'], 'value' => function ($layout) { $items[] = ['label' => 'Редактировать', 'url' => ['/broadcast/layout-mng', 'id' => $layout->id]]; return Html::tag('div', '<span class="btn btn-flat menu-button dropdown-toggle" data-toggle="dropdown"><i class="glyphicon glyphicon-option-vertical"></i></span>' . Dropdown::widget(['items' => $items, 'options' => ['class' => 'control-ul']]), ['class' => 'dropdown']); }]; ?> <div class="box box-default"> <div class="box-header with-border"><?php echo Html::a('<i class="fa fa-plus"></i> Новый шаблон', ['/broadcast/layout-mng'], ['class' => 'btn btn-default btn-flat']); ?> </div> <div class="box-body"> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => $cols, 'bordered' => true, 'striped' => false, 'condensed' => true, 'responsive' => false, 'hover' => true]); ?> </div> </div>
/** * 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 ($items !== null) { $linkOptions['data-toggle'] = 'dropdown'; Html::addCssClass($options, 'dropdown'); Html::addCssClass($linkOptions, 'dropdown-toggle'); $label .= ' ' . Html::tag('b', '', ['class' => 'caret']); if (is_array($items)) { if ($this->activateItems) { $items = $this->isChildActive($items, $active); } $items = Dropdown::widget(['items' => $items, 'encodeLabels' => $this->encodeLabels, 'clientOptions' => false, 'view' => $this->getView()]); } } if ($this->activateItems && $active) { Html::addCssClass($options, 'active'); } return Html::tag('li', Html::a($label, $url, $linkOptions) . $items, $options); }
/** * Generates the dropdown menu. * * @return string the rendering result. */ protected function renderDropdown() { $buttons = []; foreach ($this->buttons as $key => $button) { $options = $this->options; unset($options['id']); $url = $this->createUrl($this->key, $key); $label = $this->encodeLabels ? Html::encode($button['label']) : $button['label']; $buttons[] = ['label' => isset($button['icon']) ? Html::icon($button['icon'], ['class' => 'text-' . $button['type']]) . ' ' . $label : $label, 'url' => $url, 'linkOptions' => $options]; } if (count($buttons) <= 1) { return ''; } $splitButton = Button::widget(['label' => '<span class="caret"></span>', 'encodeLabel' => false, 'options' => ['data-toggle' => 'dropdown', 'aria-haspopup' => 'true', 'class' => 'btn-default dropdown-toggle btn-xs']]); return $splitButton . "\n" . Dropdown::widget(['items' => $buttons, 'encodeLabels' => false, 'options' => ['class' => 'pull-right']]); }
/** * Renders tab items as specified on [[items]]. * * @return string the rendering result. * @throws InvalidConfigException. */ protected function renderItems() { $headers = []; $panes = []; if (!$this->hasActiveTab() && !empty($this->items)) { $this->items[0]['active'] = true; } foreach ($this->items as $n => $item) { if (!ArrayHelper::remove($item, 'visible', true)) { continue; } 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']; $headerOptions = array_merge($this->headerOptions, ArrayHelper::getValue($item, 'headerOptions', [])); $linkOptions = array_merge($this->linkOptions, ArrayHelper::getValue($item, 'linkOptions', [])); $content = ArrayHelper::getValue($item, 'content', ''); if (isset($item['items'])) { $label .= ' <b class="caret"></b>'; Html::addCssClass($headerOptions, 'dropdown'); if ($this->renderDropdown($n, $item['items'], $panes)) { Html::addCssClass($headerOptions, 'active'); } Html::addCssClass($linkOptions, 'dropdown-toggle'); $linkOptions['data-toggle'] = 'dropdown'; $header = Html::a($label, "#", $linkOptions) . "\n" . Dropdown::widget(['items' => $item['items'], 'clientOptions' => false, 'view' => $this->getView()]); } else { $options = array_merge($this->itemOptions, ArrayHelper::getValue($item, 'options', [])); $options['id'] = ArrayHelper::getValue($options, 'id', $this->options['id'] . '-tab' . $n); $css = 'tab-pane'; $isActive = ArrayHelper::remove($item, 'active'); if ($this->fade) { $css = $isActive ? "{$css} fade in" : "{$css} fade"; } Html::addCssClass($options, $css); if ($isActive) { Html::addCssClass($options, 'active'); Html::addCssClass($headerOptions, 'active'); } if (isset($item['url'])) { $header = Html::a($label, $item['url'], $linkOptions); } else { $linkOptions['data-toggle'] = 'tab'; $linkOptions['role'] = 'tab'; $header = Html::a($label, '#' . $options['id'], $linkOptions); } if ($this->renderTabContent) { $panes[] = Html::tag('div', $content, $options); } } $headers[] = Html::tag('li', $header, $headerOptions); } $outHeader = Html::tag('ul', implode("\n", $headers), $this->options); if ($this->renderTabContent) { $outPane = Html::tag('div', implode("\n", $panes), ['class' => 'tab-content']); $tabs = $this->position == self::POS_BELOW ? $outPane . "\n" . $outHeader : $outHeader . "\n" . $outPane; } else { $tabs = $outHeader; } return Html::tag('div', $tabs, $this->containerOptions); }
public function renderMenu() { if (!$this->menuColumns) { return ''; } $items = []; /** @var $column DataColumn */ foreach ($this->columns as $column) { if (ArrayHelper::getValue($column->options, 'menu', true)) { $items[] = ['label' => Html::checkbox('', $column->visible, []) . ' ' . strip_tags($column->renderHeaderCell()), 'url' => '#', 'encode' => false]; } } $content = Html::beginTag('div', ['class' => 'dropdown-checkbox btn-group']); $content .= Html::tag('button', $this->menuColumnsBtnLabel, ['class' => ' btn btn-default dropdown-toggle', 'data-toggle' => 'dropdown']); $content .= \yii\bootstrap\Dropdown::widget(['items' => $items, 'options' => ['class' => 'dropdown-checkbox-content']]); $content .= Html::endTag('div'); return $content; }
<?php use yii\helpers\Html; use yii\bootstrap\Dropdown; use yii\widgets\ActiveForm; /** * @var array $options * @var array $formOptions * @var array $dropDownOptions * @var array $buttonOptions */ echo Html::beginTag('div', $options); $form = ActiveForm::begin($formOptions); echo Html::hiddenInput($exportRequestParam); echo Html::button('<i class="glyphicon glyphicon-download-alt"></i>Export<b class="caret"></b>', $buttonOptions); echo Dropdown::widget($dropDownOptions); ActiveForm::end(); echo Html::endTag('div');
$page->endContent(); ?> <?php $page->beginContent('bulk-actions'); ?> <div class="dropdown" style="display: inline-block"> <button type="button" class="btn btn-default dropdown-toggle btn-sm" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <?php echo Yii::t('hipanel:stock', 'Bulk actions'); ?> <span class="caret"></span> </button> <?php echo Dropdown::widget(['encodeLabels' => false, 'items' => [['label' => Yii::t('hipanel:stock', 'Repair'), 'url' => '#', 'linkOptions' => ['data-action' => 'repair']], ['label' => Yii::t('hipanel:stock', 'Copy'), 'url' => '#', 'linkOptions' => ['data-action' => 'copy']], ['label' => Yii::t('hipanel:stock', 'Replace'), 'url' => '#', 'linkOptions' => ['data-action' => 'replace']], ['label' => Yii::t('hipanel:stock', 'Reserve'), 'url' => '#', 'linkOptions' => ['data-action' => 'reserve']], ['label' => Yii::t('hipanel:stock', 'Unreserve'), 'url' => '#', 'linkOptions' => ['data-action' => 'unreserve']], ['label' => Yii::t('hipanel:stock', 'RMA'), 'url' => '#', 'linkOptions' => ['data-action' => 'rma']], '<li role="presentation" class="divider"></li>', ['label' => Yii::t('hipanel:stock', 'Update'), 'url' => '#', 'linkOptions' => ['data-action' => 'update']], ['label' => Yii::t('hipanel:stock', 'Move'), 'url' => '#', 'linkOptions' => ['data-action' => 'move']], ['label' => Yii::t('hipanel:stock', 'Move by one'), 'url' => '#', 'linkOptions' => ['data-action' => 'move-by-one']]]]); ?> </div> <?php echo AjaxModal::widget(['bulkPage' => true, 'id' => 'set-serial-modal', 'scenario' => 'set-serial', 'actionUrl' => ['bulk-set-serial'], 'handleSubmit' => Url::toRoute('set-serial'), 'size' => Modal::SIZE_LARGE, 'header' => Html::tag('h4', Yii::t('hipanel:stock', 'Set serial'), ['class' => 'modal-title']), 'toggleButton' => ['label' => Yii::t('hipanel:stock', 'Set serial'), 'class' => 'btn btn-default btn-sm']]); ?> <?php echo AjaxModal::widget(['bulkPage' => true, 'id' => 'bulk-set-price-modal', 'scenario' => 'bulk-set-price', 'actionUrl' => ['bulk-set-price'], 'size' => Modal::SIZE_LARGE, 'header' => Html::tag('h4', Yii::t('hipanel:stock', 'Set price'), ['class' => 'modal-title']), 'toggleButton' => ['label' => Yii::t('hipanel:stock', 'Set price'), 'class' => 'btn btn-default btn-sm']]); ?> <?php echo $page->renderBulkButton(Yii::t('hipanel:stock', 'Trash'), 'trash', 'danger'); ?> <?php $page->endContent(); ?>
/** * Renders the given items as a dropdown. * This method is called to create sub-menus. * @param array $items the given items. Please refer to [[Dropdown::items]] for the array structure. * @param array $parentItem the parent item information. Please refer to [[items]] for the structure of this array. * @return string the rendering result. * @since 2.0.1 */ protected function renderDropdown($items, $parentItem) { return Dropdown::widget(['options' => ArrayHelper::getValue($parentItem, 'dropDownOptions', []), 'items' => $items, 'encodeLabels' => $this->encodeLabels, 'clientOptions' => false, 'view' => $this->getView()]); }
/** * Executes the widget. * * @return string the result of widget execution to be outputted. */ public function run() { $route = Yii::$app->controller->route; $appLang = Yii::$app->language; $params = Yii::$app->request->get(); $this->isError = $route === Yii::$app->errorHandler->errorAction; if ($this->isError && $this->disableOnError) { return false; } else { array_unshift($params, '/' . $route); foreach (Yii::$app->urlManager->languages as $lang) { $isWildcard = substr($lang, -2) === '-*'; $lang = $isWildcard ? substr($lang, 0, 2) : $lang; $params[$this->langParam] = $lang; $url = $this->redirectHomeOnSwitch ? ['/', $this->langParam => $lang] : $params; if ($lang === $appLang || $isWildcard && substr($appLang, 0, 2) === $lang) { $this->label = $this->getLabel($lang); $this->url = $url; continue; } $this->items[] = ['label' => $this->getLabel($lang), 'url' => $url, 'active' => false]; } return strtr($this->template, ['{label}' => $this->encodeLabels ? Html::encode($this->label) : $this->label, '{url}' => Yii::$app->urlManager->createUrl($this->url), '{items}' => $this->items ? Dropdown::widget(['items' => $this->items, 'encodeLabels' => $this->encodeLabels]) : '']); } }