public function parseTagCloud($requestInfo) { if (preg_match('/^\\d+$/', $requestInfo->requestRoute)) { return ['grom/tag/default/view', ['id' => $requestInfo->requestRoute]]; } else { return ['grom/tag/default/view', ['id' => Tag::find()->select('id')->where(['alias' => $requestInfo->requestRoute])->scalar()]]; } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Tag::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by, 'hits' => $this->hits, 'lock' => $this->lock]); $query->andFilterWhere(['like', 'language', $this->language])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'alias', $this->alias])->andFilterWhere(['like', 'group', $this->group])->andFilterWhere(['like', 'metakey', $this->metakey])->andFilterWhere(['like', 'metadesc', $this->metadesc]); return $dataProvider; }
public function actionTagList($query = null, $language = null) { $result = Tag::find()->select('id AS value, title AS text, group AS optgroup')->filterWhere(['like', 'title', urldecode($query)])->andFilterWhere(['language' => $language])->limit(20)->asArray()->all(); echo Json::encode($result); }
* @var string $route */ $this->title = Yii::t('gromver.platform', 'Select Page'); $this->params['breadcrumbs'][] = $this->title; ?> <div class="page-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', 'width' => '50px'], ['attribute' => 'language', 'width' => '50px', 'filter' => Yii::$app->getLanguagesList()], ['attribute' => 'title', 'value' => function ($model) { /** @var $model \gromver\platform\common\models\Page */ return $model->title . '<br/>' . Html::tag('small', $model->alias, ['class' => 'text-muted']); }, 'format' => 'html'], ['attribute' => 'status', 'value' => function ($model, $index, $widget) { /** @var $model \gromver\platform\common\models\Page */ return $model->getStatusLabel(); }, 'filter' => \gromver\platform\common\models\Page::statusLabels()], ['attribute' => 'tags', 'value' => function ($model) { /** @var $model \gromver\platform\common\models\Page */ return implode(', ', \yii\helpers\ArrayHelper::map($model->tags, 'id', 'title')); }, 'filterType' => \dosamigos\selectize\Selectize::className(), 'filterWidgetOptions' => ['items' => \yii\helpers\ArrayHelper::map(\gromver\platform\common\models\Tag::find()->where(['id' => $searchModel->tags])->all(), 'id', 'title', 'group'), 'clientOptions' => ['maxItems' => 1], 'url' => ['/grom/default/tag-list']]], ['value' => function ($model) use($route) { return Html::a(Yii::t('gromver.platform', 'Select'), '#', ['class' => 'btn btn-primary btn-xs', 'onclick' => \gromver\widgets\ModalIFrame::emitDataJs(['id' => $model->id, 'description' => Yii::t('gromver.platform', 'Page: {title}', ['title' => $model->title]), 'link' => \gromver\platform\common\models\MenuItem::toRoute($route, ['id' => $model->id]), 'value' => $model->id . ':' . $model->alias])]); }, '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>
public function parseAllPosts($requestInfo) { if ($requestInfo->requestRoute == 'rss') { return ['grom/news/post/rss', []]; } elseif (preg_match("#^(\\d{4})/(\\d{1,2})/(\\d{1,2})\$#", $requestInfo->requestRoute, $matches)) { //новости за определенную дату return ['grom/news/post/day', ['year' => $matches[1], 'month' => $matches[2], 'day' => $matches[3]]]; } elseif (preg_match("#^((.*)/)(([^/]+)\\.{$this->postSuffix})\$#", $requestInfo->requestRoute, $matches)) { //ищем пост $categoryPath = $matches[2]; //путь категории поста $postAlias = $matches[4]; //алиас поста $category = Category::findOne(['path' => $categoryPath, 'language' => $requestInfo->menuMap->language]); if ($category && ($postId = Post::find()->select('id')->where(['alias' => $postAlias, 'category_id' => $category->id])->scalar())) { return ['grom/news/post/view', ['id' => $postId]]; } } elseif (preg_match("#^(tag/([^/]+))\$#", $requestInfo->requestRoute, $matches)) { //ищем тег $tagAlias = $matches[2]; if ($tagId = Tag::find()->select('id')->where(['alias' => $tagAlias])->scalar()) { return ['grom/tag/default/posts', ['id' => $tagId]]; } } }
'modelClass' => 'Page', ]), ['create'], ['class' => 'btn btn-success']) ?> </p>*/ ?> <?php echo GridView::widget(['id' => 'table-grid', 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'pjax' => true, 'pjaxSettings' => ['neverTimeout' => true], 'columns' => [['class' => 'yii\\grid\\CheckboxColumn'], ['attribute' => 'id', 'width' => '50px'], ['attribute' => 'language', 'width' => '80px', 'value' => function ($model) { /** @var $model \gromver\platform\common\models\Page */ return \gromver\platform\backend\widgets\Translator::widget(['model' => $model]); }, 'format' => 'raw', 'filter' => Yii::$app->getLanguagesList()], 'title', 'alias', ['attribute' => 'status', 'value' => function ($model) { /** @var $model \gromver\platform\common\models\Page */ return $model->status === \gromver\platform\common\models\Page::STATUS_PUBLISHED ? Html::a('<i class="glyphicon glyphicon-ok-circle"></i>', \yii\helpers\Url::to(['unpublish', 'id' => $model->id]), ['class' => 'btn btn-default btn-xs', 'data-pjax' => '0', 'data-method' => 'post']) : Html::a('<i class="glyphicon glyphicon-remove-circle"></i>', \yii\helpers\Url::to(['publish', 'id' => $model->id]), ['class' => 'btn btn-default btn-xs', 'data-pjax' => '0', 'data-method' => 'post']); }, 'filter' => \gromver\platform\common\models\Post::statusLabels(), 'format' => 'raw', 'width' => '80px'], ['attribute' => 'tags', 'value' => function ($model) { /** @var $model \gromver\platform\common\models\Page */ return implode(', ', \yii\helpers\ArrayHelper::map($model->tags, 'id', 'title')); }, 'filterType' => \dosamigos\selectize\Selectize::className(), 'filterWidgetOptions' => ['items' => \yii\helpers\ArrayHelper::map(\gromver\platform\common\models\Tag::find()->where(['id' => $searchModel->tags])->all(), 'id', 'title', 'group'), 'clientOptions' => ['maxItems' => 1], 'url' => ['/grom/tag/default/tag-list']]], ['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'], ['class' => 'btn btn-success', 'data-pjax' => '0']), 'after' => 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 processAction(el) { var $el = $(el), $grid = $('#table-grid'), selection = $grid.yiiGridView('getSelectedRows') if(!selection.length) { alert(<?php echo json_encode(Yii::t('gromver.platform', 'Select items.')); ?> ) return }
// echo $this->render('_search', ['model' => $searchModel]); ?> <?php /*<p> <?= Html::a(Yii::t('gromver.platform', 'Create {modelClass}', [ 'modelClass' => 'Tag', ]), ['create'], ['class' => 'btn btn-success']) ?> </p>*/ ?> <?php echo GridView::widget(['id' => 'table-grid', 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'pjax' => true, 'pjaxSettings' => ['neverTimeout' => true], 'columns' => [['class' => 'yii\\grid\\CheckboxColumn'], ['attribute' => 'id', 'width' => '50px'], ['attribute' => 'language', 'width' => '80px', 'value' => function ($model) { /** @var $model \gromver\platform\common\models\Tag */ return \gromver\platform\backend\widgets\Translator::widget(['model' => $model]); }, 'format' => 'html', 'filter' => Yii::$app->getLanguagesList()], 'title', 'alias', ['attribute' => 'group', 'filter' => \yii\helpers\ArrayHelper::map(\gromver\platform\common\models\Tag::find()->groupBy('group')->andWhere('[[group]]!="" AND [[group]] IS NOT NULL')->all(), 'group', 'group')], ['attribute' => 'status', 'value' => function ($model) { /** @var $model \gromver\platform\common\models\Tag */ return $model->status === \gromver\platform\common\models\Tag::STATUS_PUBLISHED ? Html::a('<i class="glyphicon glyphicon-ok-circle"></i>', \yii\helpers\Url::to(['unpublish', 'id' => $model->id]), ['class' => 'btn btn-default btn-xs', 'data-pjax' => '0', 'data-method' => 'post']) : Html::a('<i class="glyphicon glyphicon-remove-circle"></i>', \yii\helpers\Url::to(['publish', 'id' => $model->id]), ['class' => 'btn btn-default btn-xs', 'data-pjax' => '0', 'data-method' => 'post']); }, 'filter' => \gromver\platform\common\models\Tag::statusLabels(), 'format' => 'raw', 'width' => '80px'], ['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'], ['class' => 'btn btn-success', 'data-pjax' => 0]), 'after' => 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 processAction(el) { var $el = $(el), $grid = $('#table-grid'), selection = $grid.yiiGridView('getSelectedRows') if(!selection.length) { alert(<?php echo json_encode(Yii::t('gromver.platform', 'Select items.')); ?>