public function actionCatchDef($url = null) { ///////////////////////// $links = Links::find()->where(['categories_id' => 3])->all(); $ads = TorAds::find()->all(); ///////////////////////// $link = Links::findOne(['url' => '/' . $url]); if (!$link) { return $this->render('/site/develop', ['links' => $links, 'ads' => $ads]); } $link = Links::findOne(['url' => '/' . $url]); if (!$link) { return $this->render('/site/develop'); } $this->layout = $link->layout->name; Yii::$app->view->registerMetaTag(['description' => $link->description]); Yii::$app->view->registerMetaTag(['keywords' => $link->keywords]); $parent = Links::findOne($link->parent); if (isset($link->id)) { $content = false; for ($c = 0; $c < count($link->contents); $c++) { $reg = '/\\{\\{(.*)\\}\\}/'; $content = preg_replace_callback('/(\\{{)(\\S+)(}})/', "self::getModule", $link->contents[0]->content); $content = preg_replace_callback('/(\\[\\[)(\\S+)(]])/', "self::getWidget", $content); } } return $this->render($link->view->name, ['link' => $link, 'content' => $content]); }
public function topMenu() { $items = array(); $links = Links::find()->where(['categories_id' => $this->categories_id, 'level' => 1])->orderBy(['seq' => SORT_ASC])->all(); $url = '/' . Yii::$app->request->get('url'); foreach ($links as $link) { $items[] = ['label' => $link->anchor, 'url' => $link->url, 'active' => $link->url == $url ? true : false]; } return $items; }
public function getLinksId($parent = null) { $links = Links::find()->where(['parent' => $parent])->all(); /** @var $link Links */ foreach ($links as $link) { $this->links_id[] = $link->id; if ($link->child_exist == 1) { $this->getLinksId($link->id); } } }
public function torMenu($parent = null, $level = 1) { $links = Links::find()->where(['categories_id' => $this->categories_id, 'parent' => $parent])->orderBy(['seq' => SORT_ASC])->all(); $items = Html::beginTag('ul', ['class' => 'tor-nav-' . $level . ' ' . ($level > 2 ? 'list-unstyled' : 'list-inline')]); /** @var $link Links */ foreach ($links as $link) { $items .= '<li>' . Html::a($link->anchor, $link->url); if ($link->child_exist == 1) { if ($link->level == 1) { $items .= '<span class="caret"></span>' . Html::tag('div', $this->torMenu($link->id, $link->level + 1), ['class' => 'tor-sub-nav']); } else { $items .= $this->torMenu($link->id, $link->level + 1); } } $items .= '</li>'; } $items .= Html::endTag('ul'); return $items; }
public function getLinks($parent) { $links = \common\models\main\Links::find()->innerJoinWith('category')->where(['categories_id' => $this->categories_id])->andWhere(['categories.visible' => 1])->andWhere(['parent' => $parent])->orderBy(['seq' => SORT_ASC])->all(); if (!$links) { return '<em class="text-muted">Ссылки не добавлены</em>'; } $html = Html::beginTag('ul', ['class' => 'list-unstyled']); /** * @var $i * @var $link \common\models\main\Links */ foreach ($links as $i => $link) { $html .= Html::tag('li', Html::beginTag('div', ['class' => 'row']) . Html::tag('div', Html::a($link->anchor, ['/map/content', 'links_id' => $link->id], ['style' => ($link->state == 0 ? 'text-decoration: line-through; color: #aaa;' : '') . (Yii::$app->request->get('links_id') == $link->id || Yii::$app->request->get('parent_links_id') == $link->id ? 'font-weight: bold;' : '')]), ['class' => 'col-sm-9']) . Html::tag('div', ButtonDropdown::widget(['label' => '<i class="fa fa-cog"></i>', 'dropdown' => ['items' => [['label' => 'Параметры', 'url' => ['/map/links', 'categories_id' => Yii::$app->request->get('categories_id'), 'action' => 'ch', 'id' => $link->id]], ['label' => 'Ретактор контента', 'url' => ['/map/content', 'links_id' => $link->id]], ['label' => 'Добавить дочернюю ссылку', 'url' => ['/map/links', 'categories_id' => Yii::$app->request->get('categories_id'), 'parent' => $link->id, 'action' => 'add']]]], 'encodeLabel' => false, 'options' => ['class' => 'btn-default btn-xs']]), ['class' => 'col-sm-3 action text-right']) . Html::endTag('div')); if ($link->child_exist == '1') { $childs = \common\models\main\Links::find()->innerJoinWith('category')->where(['categories_id' => $this->categories_id])->andWhere(['categories.visible' => 1])->andWhere(['parent' => $link->id])->count(); if ($childs > 0) { $html .= $this->getLinks($link->id); } } } $html .= Html::endTag('ul'); return $html; }
public function actionCategories() { if (Yii::$app->request->isAjax) { Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; $categories_id = Yii::$app->request->post('categories_id'); $links = Links::find()->where(['categories_id' => $categories_id])->orderBy(['seq' => SORT_ASC])->all(); return ['success' => true, 'links' => $links, 'level' => $links[0]->level]; } }