Пример #1
0
 /**
  * @param \gromver\platform\core\components\MenuRequestInfo $requestInfo
  * @return mixed|null|string
  */
 public function createTagItems($requestInfo)
 {
     if ($path = $requestInfo->menuMap->getMenuPathByRoute('tag/frontend/default/index')) {
         $path .= '/' . (isset($requestInfo->requestParams['alias']) ? $requestInfo->requestParams['alias'] : $requestInfo->requestParams['id']);
         unset($requestInfo->requestParams['id'], $requestInfo->requestParams['alias']);
         return MenuItem::toRoute($path, $requestInfo->requestParams);
     }
 }
Пример #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = MenuItem::find();
     $query->with(['menuType']);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['lft' => SORT_ASC]]]);
     if (!($this->load($params) && $this->validate())) {
         if ($this->excludeRoots) {
             $query->excludeRoots();
         }
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'menu_type_id' => $this->menu_type_id, 'parent_id' => $this->parent_id, 'status' => $this->status, 'link_type' => $this->link_type, 'secure' => $this->secure, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by, 'lft' => $this->lft, 'rgt' => $this->rgt, 'level' => $this->level, 'ordering' => $this->ordering, 'hits' => $this->hits, 'lock' => $this->lock]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'alias', $this->alias])->andFilterWhere(['like', 'path', $this->path])->andFilterWhere(['like', 'note', $this->note])->andFilterWhere(['like', 'link', $this->link])->andFilterWhere(['like', 'link_params', $this->link_params])->andFilterWhere(['like', 'layout_path', $this->layout_path])->andFilterWhere(['like', 'access_rule', $this->access_rule])->andFilterWhere(['like', 'metakey', $this->metakey])->andFilterWhere(['like', 'metadesc', $this->metadesc])->andFilterWhere(['like', 'robots', $this->robots]);
     if ($this->excludeRoots) {
         $query->excludeRoots();
     }
     if ($this->excludeItem && ($item = MenuItem::findOne($this->excludeItem))) {
         /** @var $item MenuItem */
         $query->excludeItem($item);
     }
     return $dataProvider;
 }
Пример #3
0
 /**
  * @param $requestInfo MenuRequestInfo;
  * @return mixed|null|string
  */
 public function createSearch($requestInfo)
 {
     if ($path = $requestInfo->menuMap->getMenuPathByRoute('search/sql/frontend/default/index')) {
         return MenuItem::toRoute($path, $requestInfo->requestParams);
     }
 }
Пример #4
0
 /**
  * Находит путь к пункту меню ссылающемуся на категорию $categoryId, либо ее предка
  * Если путь ведет к предку, то достраиваем путь категории $categoryId
  * @param $categoryId
  * @param $menuMap \gromver\platform\core\components\MenuMap
  * @return null|string
  */
 private function findCategoryMenuPath($categoryId, $menuMap)
 {
     /** @var Category $category */
     if (!isset($this->_categoryPaths[$categoryId])) {
         if ($path = $menuMap->getMenuPathByRoute(MenuItem::toRoute('news/frontend/category/view', ['id' => $categoryId]))) {
             $this->_categoryPaths[$categoryId] = $path;
         } elseif (($category = Category::findOne($categoryId)) && !$category->isRoot() && ($path = $this->findCategoryMenuPath($category->parent_id, $menuMap))) {
             $this->_categoryPaths[$categoryId] = $path . '/' . $category->alias;
         } else {
             $this->_categoryPaths[$categoryId] = false;
         }
     }
     return $this->_categoryPaths[$categoryId];
 }
Пример #5
0
 */
$this->title = Yii::t('gromver.platform', 'Select Menu Item');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="menu-index">

	<?php 
/*<h1><?= Html::encode($this->title) ?></h1>*/
?>

	<?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

	<?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'id' => 'grid', 'pjax' => true, 'pjaxSettings' => ['neverTimeout' => true], 'columns' => [['attribute' => 'id', 'hAlign' => GridView::ALIGN_CENTER, 'vAlign' => GridView::ALIGN_MIDDLE, 'width' => '60px'], ['attribute' => 'menu_type_id', 'vAlign' => GridView::ALIGN_MIDDLE, 'width' => '120px', 'value' => function ($model) {
    /** @var $model \gromver\platform\core\modules\menu\models\MenuItem */
    return $model->menuType->title;
}, 'filter' => \yii\helpers\ArrayHelper::map(\gromver\platform\core\modules\menu\models\MenuType::find()->all(), 'id', 'title')], ['attribute' => 'title', 'vAlign' => GridView::ALIGN_MIDDLE, 'value' => function ($model) {
    /** @var $model \gromver\platform\core\modules\menu\models\MenuItem */
    return str_repeat(" • ", max($model->level - 2, 0)) . $model->title . '<br/>' . Html::tag('small', $model->path, ['class' => 'text-muted']);
}, 'format' => 'html'], ['attribute' => 'status', 'hAlign' => GridView::ALIGN_CENTER, 'vAlign' => GridView::ALIGN_MIDDLE, 'value' => function ($model) {
    /** @var $model \gromver\platform\core\modules\menu\models\MenuItem */
    return $model->getStatusLabel();
}, 'width' => '150px', 'filter' => \gromver\platform\core\modules\menu\models\MenuItem::statusLabels()], ['header' => Yii::t('gromver.platform', 'Action'), 'hAlign' => GridView::ALIGN_CENTER, 'vAlign' => GridView::ALIGN_MIDDLE, 'value' => function ($model) {
    /** @var $model \gromver\platform\core\modules\menu\models\MenuItem */
    return Html::a(Yii::t('gromver.platform', 'Select'), '#', ['class' => 'btn btn-primary btn-xs', 'onclick' => \gromver\widgets\ModalIFrame::postDataJs(['id' => $model->id, 'title' => $model->title, 'description' => Yii::t('gromver.platform', 'Menu Item: {title}', ['title' => $model->title]), 'route' => Yii::$app->urlManager->createUrl($model->getFrontendViewLink()), 'link' => Yii::$app->urlManager->createUrl($model->getFrontendViewLink()), 'value' => $model->id . ':' . $model->alias])]);
}, 'width' => '80px', 'mergeHeader' => true, 'format' => 'raw']], 'responsive' => true, 'hover' => true, 'condensed' => true, 'floatHeader' => true, 'floatHeaderOptions' => ['scrollingTop' => 0], 'bordered' => false, 'panel' => ['heading' => '<h3 class="panel-title"><i class="glyphicon glyphicon-th-list"></i> ' . Html::encode($this->title) . '</h3>', 'type' => 'info', 'after' => Html::a('<i class="glyphicon glyphicon-repeat"></i> ' . Yii::t('gromver.platform', 'Reset List'), [null], ['class' => 'btn btn-info']), 'showFooter' => false]]);
?>

</div>
Пример #6
0
 * @var yii\web\View $this
 * @var yii\data\ActiveDataProvider $dataProvider
 * @var \gromver\platform\news\models\CategorySearch $searchModel
 * @var string $route
 */
$this->title = Yii::t('gromver.platform', 'Select Category');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="category-index">

    <?php 
/*<h1><?= Html::encode($this->title) ?></h1>*/
?>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'id' => 'grid', 'pjax' => true, 'pjaxSettings' => ['neverTimeout' => true], 'columns' => [['attribute' => 'id', 'hAlign' => GridView::ALIGN_CENTER, 'vAlign' => GridView::ALIGN_MIDDLE, 'width' => '60px'], ['attribute' => 'title', 'vAlign' => GridView::ALIGN_MIDDLE, 'value' => function ($model) {
    /** @var $model \gromver\platform\news\models\Category */
    return str_repeat(" • ", max($model->level - 1, 0)) . $model->title . '<br/>' . Html::tag('small', ' — ' . $model->path, ['class' => 'text-muted']);
}, 'format' => 'html'], ['attribute' => 'status', 'hAlign' => GridView::ALIGN_CENTER, 'vAlign' => GridView::ALIGN_MIDDLE, 'value' => function ($model) {
    /** @var $model \gromver\platform\news\models\Category */
    return $model->getStatusLabel();
}, 'width' => '100px', 'filter' => \gromver\platform\news\models\Category::statusLabels()], ['attribute' => 'published_at', 'vAlign' => GridView::ALIGN_MIDDLE, 'format' => ['date', 'd MMM Y H:mm'], 'width' => '160px', 'filterType' => GridView::FILTER_DATE, 'filterWidgetOptions' => ['pluginOptions' => ['format' => 'dd.mm.yyyy'], 'type' => \kartik\date\DatePicker::TYPE_RANGE, 'attribute2' => 'published_at_to']], ['attribute' => 'tags', 'width' => '120px', 'vAlign' => GridView::ALIGN_MIDDLE, 'value' => function ($model) {
    /** @var $model \gromver\platform\news\models\Category */
    return implode(', ', \yii\helpers\ArrayHelper::map($model->tags, 'id', 'title'));
}, 'filterType' => GridView::FILTER_SELECT2, 'filterWidgetOptions' => ['data' => \yii\helpers\ArrayHelper::map(\gromver\platform\core\modules\tag\models\Tag::find()->where(['id' => $searchModel->tags])->all(), 'id', 'title'), 'theme' => \kartik\select2\Select2::THEME_BOOTSTRAP, 'pluginOptions' => ['allowClear' => true, 'placeholder' => Yii::t('gromver.platform', 'Select ...'), 'ajax' => ['url' => \yii\helpers\Url::to(['/tag/backend/default/tag-list'])]]]], ['header' => Yii::t('gromver.platform', 'Action'), 'hAlign' => GridView::ALIGN_CENTER, 'vAlign' => GridView::ALIGN_MIDDLE, 'value' => function ($model) use($route) {
    /** @var $model \gromver\platform\news\models\Category */
    return Html::a(Yii::t('gromver.platform', 'Select'), '#', ['class' => 'btn btn-primary btn-xs', 'onclick' => \gromver\widgets\ModalIFrame::postDataJs(['id' => $model->id, 'title' => $model->title, 'description' => Yii::t('gromver.platform', 'Category: {title}', ['title' => $model->title]), 'route' => \gromver\platform\core\modules\menu\models\MenuItem::toRoute($route, ['id' => $model->id]), 'link' => Yii::$app->urlManager->createUrl($model->getFrontendViewLink()), 'value' => $model->id . ':' . $model->alias])]);
}, 'width' => '80px', 'mergeHeader' => true, 'format' => 'raw']], 'responsive' => true, 'hover' => true, 'condensed' => true, 'floatHeader' => true, 'floatHeaderOptions' => ['scrollingTop' => 0], 'bordered' => false, 'panel' => ['heading' => '<h3 class="panel-title"><i class="glyphicon glyphicon-th-list"></i> ' . Html::encode($this->title) . '</h3>', 'type' => 'info', 'after' => Html::a('<i class="glyphicon glyphicon-repeat"></i> ' . Yii::t('gromver.platform', 'Reset List'), [null], ['class' => 'btn btn-info']), 'showFooter' => false]]);
?>

</div>
Пример #7
0
?>
</a></li>
        <li><a href="#link-options" data-toggle="tab"><?php 
echo Yii::t('gromver.platform', 'Link params');
?>
</a></li>
        <li><a href="#meta-options" data-toggle="tab"><?php 
echo Yii::t('gromver.platform', 'SEO');
?>
</a></li>
    </ul>
    <br/>
    <div class="tab-content">
        <div id="main" class="tab-pane active">
            <?php 
echo $form->field($model, 'link_type')->dropDownList(\gromver\platform\core\modules\menu\models\MenuItem::linkTypeLabels());
?>

            <?php 
$this->registerJs("\$('#" . Html::getInputId($model, 'link_type') . "').change(function (event){\n                if(\$(this).val() === '" . \gromver\platform\core\modules\menu\models\MenuItem::LINK_ROUTE . "') {\n                    \$('a#router').attr('href', " . \yii\helpers\Json::encode(\yii\helpers\Url::toRoute(['routers'])) . ")\n                } else {\n                    \$('a#router').attr('href', " . \yii\helpers\Json::encode(\yii\helpers\Url::toRoute(['select', 'MenuItemSearch[link_type]' => \gromver\platform\core\modules\menu\models\MenuItem::LINK_ROUTE])) . ")\n                }\n            }).change()");
?>

            <?php 
$linkLabel = Html::activeLabel($model, 'link');
$linkInputId = Html::getInputId($model, 'link');
echo $form->field($model, 'link', ['template' => "{label}\n{beginWrapper}\n<div class=\"input-group\">{input}{controls}</div>\n{error}\n{endWrapper}\n{hint}", 'parts' => ['{controls}' => \gromver\widgets\ModalIFrame::widget(['options' => ['id' => 'router', 'class' => 'input-group-btn'], 'url' => ['routers'], 'label' => Html::tag('span', '<span class="glyphicon glyphicon-folder-open"></span>', ['class' => 'btn btn-default']), 'dataHandler' => "function(data){\n                                    \$('#{$linkInputId}').val(data.route)\n                                }"])]])->textInput(['maxlength' => 1024]);
?>

            <?php 
echo $form->field($model, 'access_rule')->dropDownList(\yii\helpers\ArrayHelper::map(Yii::$app->authManager->getRoles(), 'name', 'name'), ['prompt' => 'Не выбрано']);
?>
Пример #8
0
 /**
  * Creates a URL according to the given route and parameters.
  * @param UrlManager $manager the URL manager
  * @param string $route the route. It should not have slashes at the beginning or the end.
  * @param array $params the parameters
  * @return string|boolean the created URL, or false if this rule cannot be used for creating this URL.
  */
 public function createUrl($manager, $route, $params)
 {
     $menuMap = $this->menuManager->getMenuMap();
     if ($path = $menuMap->getMenuPathByRoute(MenuItem::toRoute($route, $params))) {
         return $path;
     }
     $requestInfo = new MenuRequestInfo(['menuMap' => $menuMap, 'requestRoute' => $route, 'requestParams' => $params]);
     foreach ($this->_createUrlRules as $rule) {
         if ($result = $rule->process($requestInfo, $this)) {
             return $result;
         }
     }
     return false;
 }
Пример #9
0
 /**
  * Renders the content of a menu item.
  * Note that the container and the sub-menus are not rendered here.
  * @param array $item the menu item to be rendered. Please refer to [[items]] to see what data might be in the item.
  * @return string the rendering result
  */
 protected function renderItem($item)
 {
     $routers = '';
     $header = '';
     if (isset($item['label'])) {
         $template = ArrayHelper::getValue($item, 'headerTemplate', $this->headerTemplate);
         $header = strtr($template, ['{icon}' => $item['icon'], '{label}' => $item['label']]);
     }
     foreach ($item['items'] as $router) {
         $template = ArrayHelper::getValue($router, 'template', $this->routerTemplate);
         $routerContent = strtr($template, ['{icon}' => $router['icon'], '{link}' => isset($router['url']) ? Html::a($router['label'], $router['url']) : Html::a($router['label'], '#', ['onclick' => ModalIFrame::postDataJs(['route' => MenuItem::toRoute($router['route']), 'link' => Yii::$app->urlManager->createUrl($router['route'])])])]);
         $routerOptions = array_merge($this->routerOptions, $router['options']);
         $routers .= Html::tag(ArrayHelper::remove($routerOptions, 'tag', 'div'), $routerContent, $routerOptions);
     }
     $template = ArrayHelper::getValue($item, 'template', $this->itemTemplate);
     return strtr($template, ['{header}' => $header, '{routers}' => $routers]);
 }
Пример #10
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     //$this->initI18N();
     //$this->bootstrap = array_merge($this->bootstrap, ['main']);
     parent::init();
     $this->_modulesConfigDependency = new ExpressionDependency(['expression' => '\\Yii::$app->getModulesHash()']);
     DbState::bootstrap();
     Yii::$container->set('gromver\\models\\fields\\EditorField', ['controller' => 'media/manager', 'editorOptions' => ['filebrowserBrowseUrl' => ['/menu/backend/item/ckeditor-select'], 'autoGrow_onStartup' => true, 'autoGrow_bottomSpace' => 50]]);
     Yii::$container->set('gromver\\models\\fields\\MediaField', ['controller' => 'media/manager']);
     Yii::$container->set('gromver\\modulequery\\ModuleQuery', ['cache' => $this->cache, 'cacheDependency' => $this->_modulesConfigDependency]);
     Yii::$container->set('gromver\\platform\\core\\components\\MenuMap', ['cache' => $this->cache, 'cacheDependency' => DbState::dependency(MenuItem::tableName())]);
     Yii::$container->set('gromver\\platform\\core\\components\\MenuUrlRule', ['cache' => $this->cache, 'cacheDependency' => $this->_modulesConfigDependency]);
     Yii::$container->set('gromver\\platform\\core\\modules\\main\\widgets\\Desktop', ['cache' => $this->cache, 'cacheDependency' => $this->_modulesConfigDependency]);
     Yii::$container->set('gromver\\platform\\core\\components\\ParamsManager', ['cache' => $this->cache, 'cacheDependency' => $this->_modulesConfigDependency]);
     $this->urlManager->addRules($this->defaultUrlRules);
     $this->set('menuManager', \Yii::createObject(MenuManager::className()));
     // пропускаем \gromver\models\fields\events\ListItemsEvent событие, через ModuleEvent - не факт, что нужно, но почему бы и нет
     Event::on('\\gromver\\models\\fields\\ListField', 'fetchItems', function ($event) {
         /** @var $event \gromver\models\fields\events\ListItemsEvent */
         $additionalItems = @$this->listFieldItems[$event->model->getSourceClass() . '::' . $event->attribute];
         if (is_array($additionalItems)) {
             $event->items = array_merge($event->items, $additionalItems);
         }
     });
     $this->applyDefaultMetadata();
 }
Пример #11
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getItems()
 {
     return $this->hasMany(MenuItem::className(), ['menu_type_id' => 'id'])->orderBy('lft');
 }
Пример #12
0
    'modelClass' => 'Menu',
]), ['create'], ['class' => 'btn btn-success']) ?>
    </p>*/
?>

    <?php 
echo GridView::widget(['id' => 'table-grid', 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'pjax' => true, 'pjaxSettings' => ['neverTimeout' => true], 'columns' => [['class' => '\\kartik\\grid\\CheckboxColumn'], ['attribute' => 'id', 'hAlign' => GridView::ALIGN_CENTER, 'vAlign' => GridView::ALIGN_MIDDLE, 'width' => '60px'], ['attribute' => 'menu_type_id', 'vAlign' => GridView::ALIGN_MIDDLE, 'width' => '100px', 'value' => function ($model) {
    /** @var $model \gromver\platform\core\modules\menu\models\MenuItem */
    return $model->menuType->title;
}, 'filter' => \yii\helpers\ArrayHelper::map(\gromver\platform\core\modules\menu\models\MenuType::find()->all(), 'id', 'title')], ['attribute' => 'title', 'vAlign' => GridView::ALIGN_MIDDLE, 'value' => function ($model) {
    /** @var $model \gromver\platform\core\modules\menu\models\MenuItem */
    return str_repeat(" • ", max($model->level - 2, 0)) . $model->title . '<br/>' . Html::tag('small', $model->path);
}, 'format' => 'html'], ['attribute' => 'link', 'vAlign' => GridView::ALIGN_MIDDLE], ['attribute' => 'status', 'hAlign' => GridView::ALIGN_CENTER, 'vAlign' => GridView::ALIGN_MIDDLE, 'value' => function ($model) {
    /** @var $model \gromver\platform\core\modules\menu\models\MenuItem */
    return Html::beginTag('div', ['class' => 'btn-group']) . Html::a('<i class="glyphicon glyphicon-star"></i>', \yii\helpers\Url::to(['status', 'id' => $model->id, 'status' => $model::STATUS_MAIN_PAGE]), ['class' => 'btn btn-xs' . ($model::STATUS_MAIN_PAGE == $model->status ? ' btn-success active' : ' btn-default'), 'data-pjax' => 0, 'data-method' => 'post']) . Html::a('<i class="glyphicon glyphicon-ok-circle"></i>', \yii\helpers\Url::to(['status', 'id' => $model->id, 'status' => $model::STATUS_PUBLISHED]), ['class' => 'btn btn-xs' . ($model::STATUS_PUBLISHED == $model->status ? ' btn-primary active' : ' btn-default'), 'data-pjax' => 0, 'data-method' => 'post']) . Html::a('<i class="glyphicon glyphicon-remove-circle"></i>', \yii\helpers\Url::to(['status', 'id' => $model->id, 'status' => $model::STATUS_UNPUBLISHED]), ['class' => 'btn btn-xs' . ($model::STATUS_UNPUBLISHED == $model->status ? ' btn-default active' : ' btn-default'), 'data-pjax' => 0, 'data-method' => 'post']) . Html::endTag('div');
}, 'filter' => \gromver\platform\core\modules\menu\models\MenuItem::statusLabels(), 'width' => '100px', 'format' => 'raw'], ['attribute' => 'ordering', 'vAlign' => GridView::ALIGN_MIDDLE, 'value' => function ($model) {
    /** @var $model \gromver\platform\core\modules\menu\models\MenuItem */
    return Html::input('text', 'order', $model->ordering, ['class' => 'form-control']);
}, 'format' => 'raw', 'width' => '50px'], ['class' => 'kartik\\grid\\ActionColumn', 'deleteOptions' => ['data-method' => 'delete']]], 'responsive' => true, 'hover' => true, 'condensed' => true, 'floatHeader' => true, 'bordered' => false, 'panel' => ['heading' => '<h3 class="panel-title"><i class="glyphicon glyphicon-th-list"></i> ' . Html::encode($this->title) . ' </h3>', 'type' => 'info', 'before' => Html::a('<i class="glyphicon glyphicon-plus"></i> ' . Yii::t('gromver.platform', 'Add'), ['create', 'menuTypeId' => $searchModel->menu_type_id], ['class' => 'btn btn-success', 'data-pjax' => '0']), 'after' => Html::a('<i class="glyphicon glyphicon-sort-by-attributes"></i> ' . Yii::t('gromver.platform', 'Ordering'), ['ordering'], ['class' => 'btn btn-default', 'data-pjax' => '0', 'onclick' => 'processOrdering(this); return false']) . ' ' . Html::a('<i class="glyphicon glyphicon-trash"></i> ' . Yii::t('gromver.platform', 'Delete'), ['bulk-delete'], ['class' => 'btn btn-danger', 'data-pjax' => '0', 'onclick' => 'processAction(this); return false']) . ' ' . Html::a('<i class="glyphicon glyphicon-repeat"></i> ' . Yii::t('gromver.platform', 'Reset List'), ['index'], ['class' => 'btn btn-info']), 'showFooter' => false]]);
?>

</div>

<script>
    function processOrdering(el) {
        var $el = $(el),
            $grid = $('#table-grid'),
            selection = $grid.yiiGridView('getSelectedRows'),
            data = {}
        if(!selection.length) {
            alert(<?php 
Пример #13
0
 /**
  * Finds the MenuItem model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return MenuItem the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = MenuItem::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException(Yii::t('gromver.platform', 'The requested page does not exist.'));
     }
 }
Пример #14
0
 /**
  * @param string $link
  * @return MenuItem
  */
 public function getMenuByLink($link)
 {
     $menuId = array_search($link, $this->_links);
     return $menuId ? MenuItem::findOne($menuId) : null;
 }
Пример #15
0
 /**
  * @return array
  */
 protected function items()
 {
     $rawItems = MenuItem::find()->type($this->type)->published()->orderBy('lft')->all();
     if (count($rawItems)) {
         return $this->prepareItems($rawItems, $rawItems[0]->level);
     }
     return [];
 }
Пример #16
0
 /**
  * Находит путь к пункту меню ссылающемуся на категорию $categoryId, либо ее предка
  * Если путь ведет к предку, то достраиваем путь категории $categoryId
  * @param $pageId
  * @param $menuMap \gromver\platform\core\components\MenuMap
  * @return null|string
  */
 private function findPageMenuPath($pageId, $menuMap)
 {
     /** @var Page $page */
     if (!isset($this->_pagePaths[$pageId])) {
         if ($path = $menuMap->getMenuPathByRoute(MenuItem::toRoute('page/frontend/default/guide', ['id' => $pageId]))) {
             $this->_pagePaths[$pageId] = $path;
         } elseif (($page = Page::findOne($pageId)) && !$page->isRoot() && ($path = $this->findPageMenuPath($page->parent_id, $menuMap))) {
             $this->_pagePaths[$pageId] = $path . '/' . $page->alias;
         } else {
             $this->_pagePaths[$pageId] = false;
         }
     }
     return $this->_pagePaths[$pageId];
 }