/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Tag::find()->with(['translations']);
     $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;
 }
Example #2
0
 */
$this->title = Yii::t('gromver.platform', 'Select Post');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="post-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' => 'category_id', 'vAlign' => GridView::ALIGN_MIDDLE, 'width' => '80px', 'value' => function ($model) {
    return @$model->category->title;
}, 'filter' => \yii\helpers\ArrayHelper::map(\gromver\platform\basic\modules\news\models\Category::find()->excludeRoots()->orderBy('lft')->all(), 'id', function ($model) {
    return str_repeat(" • ", max($model->level - 2, 0)) . $model->title;
})], ['attribute' => 'language', 'hAlign' => GridView::ALIGN_CENTER, 'vAlign' => GridView::ALIGN_MIDDLE, 'width' => '60px', 'filter' => Yii::$app->getAcceptedLanguagesList()], ['attribute' => 'title', 'vAlign' => GridView::ALIGN_MIDDLE, 'value' => function ($model) {
    /** @var $model \gromver\platform\basic\modules\news\models\Post */
    return $model->title . '<br/>' . Html::tag('small', $model->alias, ['class' => 'text-muted']);
}, 'format' => 'html'], ['attribute' => 'status', 'vAlign' => GridView::ALIGN_MIDDLE, 'value' => function ($model) {
    /** @var $model \gromver\platform\basic\modules\news\models\Post */
    return $model->getStatusLabel();
}, 'width' => '100px', 'filter' => \gromver\platform\basic\modules\news\models\Post::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\basic\modules\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\basic\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(['/grom/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\basic\modules\news\models\Post */
    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', 'Post: {title}', ['title' => $model->title]), 'route' => \gromver\platform\basic\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>
Example #3
0
    'modelClass' => 'Category',
]), ['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' => 'language', 'hAlign' => GridView::ALIGN_CENTER, 'vAlign' => GridView::ALIGN_MIDDLE, 'width' => '80px', 'value' => function ($model) {
    /** @var \gromver\platform\basic\modules\news\models\Category $model */
    return \gromver\platform\basic\modules\main\widgets\TranslationsBackend::widget(['model' => $model]);
}, 'format' => 'raw', 'filter' => Yii::$app->getAcceptedLanguagesList()], ['attribute' => 'title', 'vAlign' => GridView::ALIGN_MIDDLE, 'value' => function ($model) {
    /** @var \gromver\platform\basic\modules\news\models\Category $model */
    return str_repeat(" • ", max($model->level - 2, 0)) . $model->title . '<br/>' . Html::tag('small', ' — ' . $model->path, ['class' => 'text-muted']);
}, 'format' => 'html'], ['attribute' => 'tags', 'width' => '120px', 'vAlign' => GridView::ALIGN_MIDDLE, 'value' => function ($model) {
    /** @var $model \gromver\platform\basic\modules\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\basic\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(['/grom/tag/backend/default/tag-list'])]]]], ['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' => 'status', 'hAlign' => GridView::ALIGN_CENTER, 'vAlign' => GridView::ALIGN_MIDDLE, 'value' => function ($model, $index, $widget) {
    /** @var $model \gromver\platform\basic\modules\news\models\Category */
    return $model->status === \gromver\platform\basic\modules\news\models\Category::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-danger btn-xs', 'data-pjax' => '0', 'data-method' => 'post']);
}, 'filter' => \gromver\platform\basic\modules\news\models\Category::statusLabels(), 'format' => 'raw', 'width' => '100px'], ['attribute' => 'ordering', 'hAlign' => GridView::ALIGN_CENTER, 'vAlign' => GridView::ALIGN_MIDDLE, 'value' => function ($model, $index) {
    /** @var \gromver\platform\basic\modules\news\models\Category $model */
    return Html::input('text', 'order', $model->ordering, ['class' => 'form-control']);
}, 'format' => 'raw', 'width' => '100px'], ['header' => Yii::t('gromver.platform', 'Posts'), 'hAlign' => GridView::ALIGN_CENTER, 'vAlign' => GridView::ALIGN_MIDDLE, 'value' => function ($model) {
    /** @var \gromver\platform\basic\modules\news\models\Category $model */
    return Html::a('(' . $model->getPosts()->count() . ')', ['/grom/news/backend/post/index', 'PostSearch[category_id]' => $model->id], ['data-pjax' => 0]);
}, 'mergeHeader' => true, 'format' => 'raw'], ['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-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),
 /**
  * @param \gromver\platform\basic\components\MenuRequestInfo $requestInfo
  * @return array
  */
 public function parseAllPosts($requestInfo)
 {
     if ($requestInfo->requestRoute == 'rss') {
         return ['grom/news/frontend/post/rss', []];
     } elseif (preg_match("#^(\\d{4})/(\\d{1,2})/(\\d{1,2})\$#", $requestInfo->requestRoute, $matches)) {
         //новости за определенную дату
         return ['grom/news/frontend/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];
         //алиас поста
         /** @var Category $category */
         $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/frontend/post/view', ['id' => $postId]];
         }
     } elseif (preg_match("#^(tag/([^/]+))\$#", $requestInfo->requestRoute, $matches)) {
         //ищем тег
         $tagAlias = $matches[2];
         if ($tagId = Tag::find()->select('id')->where(['alias' => $tagAlias, 'language' => \Yii::$app->language])->scalar()) {
             //return ['grom/tag/frontend/default/posts', ['tag_id' => $tagId]];
             return ['grom/news/frontend/post/tag', ['tag_id' => $tagId]];
         }
     }
 }
Example #5
0
 * @var yii\data\ActiveDataProvider $dataProvider
 * @var gromver\platform\basic\modules\tag\models\TagSearch $searchModel
 * @var string $route
 */
$this->title = Yii::t('gromver.platform', 'Select Tag');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="tag-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' => 'language', 'hAlign' => GridView::ALIGN_CENTER, 'vAlign' => GridView::ALIGN_MIDDLE, 'width' => '60px', 'filter' => Yii::$app->getAcceptedLanguagesList()], ['attribute' => 'title', 'vAlign' => GridView::ALIGN_MIDDLE, 'value' => function ($model) {
    /** @var $model \gromver\platform\basic\modules\tag\models\Tag */
    return $model->title . '<br/>' . Html::tag('small', $model->alias, ['class' => 'text-muted']);
}, 'format' => 'html'], ['attribute' => 'group', 'width' => '150px', 'vAlign' => GridView::ALIGN_MIDDLE, 'filterType' => GridView::FILTER_SELECT2, 'filterWidgetOptions' => ['data' => \yii\helpers\ArrayHelper::map(\gromver\platform\basic\modules\tag\models\Tag::find()->groupBy('group')->andWhere('[[group]] != "" AND [[group]] IS NOT NULL')->all(), 'group', 'group'), 'theme' => \kartik\select2\Select2::THEME_BOOTSTRAP, 'pluginOptions' => ['allowClear' => true, 'multiple' => false, 'placeholder' => Yii::t('gromver.platform', 'Select ...')]]], ['attribute' => 'status', 'vAlign' => GridView::ALIGN_MIDDLE, 'value' => function ($model) {
    /** @var $model \gromver\platform\basic\modules\tag\models\Tag */
    return $model->getStatusLabel();
}, 'width' => '100px', 'filter' => \gromver\platform\basic\modules\tag\models\Tag::statusLabels()], ['header' => Yii::t('gromver.platform', 'Action'), 'hAlign' => GridView::ALIGN_CENTER, 'vAlign' => GridView::ALIGN_MIDDLE, 'value' => function ($model) use($route) {
    /** @var $model \gromver\platform\basic\modules\tag\models\Tag */
    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', 'Tag: {title}', ['title' => $model->title]), 'route' => \gromver\platform\basic\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>
Example #6
0
        <div class="col-sm-6">
            <?php 
echo $form->field($model, 'alias', ['wrapperOptions' => ['class' => 'col-sm-9']])->textInput(['maxlength' => 255, 'placeholder' => Yii::t('gromver.platform', 'Auto-generate')]);
?>
        </div>
    </div>

    <div class="row">
        <div class="col-sm-6">
            <?php 
echo $form->field($model, 'language', ['wrapperOptions' => ['class' => 'col-sm-9']])->dropDownList(Yii::$app->getAcceptedLanguagesList(), ['prompt' => Yii::t('gromver.platform', 'Select ...')]);
?>
        </div>
        <div class="col-sm-6">
            <?php 
echo $form->field($model, 'group', ['wrapperOptions' => ['class' => 'col-sm-9']])->widget(\kartik\select2\Select2::className(), ['theme' => \kartik\select2\Select2::THEME_BOOTSTRAP, 'data' => \yii\helpers\ArrayHelper::map(\gromver\platform\basic\modules\tag\models\Tag::find()->groupBy('group')->andWhere('[[group]] != "" AND [[group]] IS NOT NULL')->all(), 'group', 'group'), 'pluginOptions' => ['tags' => true, 'allowClear' => true, 'multiple' => false, 'placeholder' => Yii::t('gromver.platform', 'Select ...')]]);
?>
        </div>
    </div>

    <div class="row">
        <div class="col-sm-6">
            <?php 
echo $form->field($model, 'status', ['wrapperOptions' => ['class' => 'col-sm-9']])->dropDownList(['' => Yii::t('gromver.platform', 'Select ...')] + $model->statusLabels());
?>
        </div>
        <div class="col-sm-6">

        </div>
    </div>
 /**
  * Отдает список групп тегов для Select2 виджета
  * @param string|null $q
  * @return array
  */
 public function actionTagGroupList($q = null)
 {
     \Yii::$app->response->format = Response::FORMAT_JSON;
     $results = Tag::find()->select('group AS id, group AS text')->andFilterWhere(['like', 'group', urldecode($q)])->groupBy('group')->limit(20)->asArray()->all();
     return ['results' => $results];
 }