Ejemplo n.º 1
0
 protected function launch()
 {
     if ($this->category && !$this->category instanceof Category) {
         $this->category = Category::findOne(intval($this->category));
     }
     echo $this->render($this->layout, ['dataProvider' => new ActiveDataProvider(['query' => $this->category ? $this->category->children()->published()->orderBy(null) : Category::find()->roots()->published(), 'pagination' => false, 'sort' => ['defaultOrder' => [$this->sort => intval($this->dir)]]]), 'itemLayout' => $this->itemLayout]);
 }
Ejemplo n.º 2
0
 public static function filter()
 {
     $filters = [['not' => ['and' => [['type' => ['value' => 'post']], ['term' => ['published' => false]]]]]];
     if ($unpublishedCategories = Category::find()->unpublished()->select('{{%grom_category}}.id')->column()) {
         $filters[] = ['not' => ['and' => [['type' => ['value' => 'post']], ['term' => ['category_id' => $unpublishedCategories]]]]];
     }
     return $filters;
 }
Ejemplo n.º 3
0
 public static function filter()
 {
     $filters = [['not' => ['and' => [['type' => ['value' => 'category']], ['term' => ['published' => false]]]]]];
     if ($unpublishedCategories = \gromver\platform\common\models\Category::find()->unpublished()->select('{{%grom_category}}.id')->column()) {
         $filters[] = ['not' => ['and' => [['type' => ['value' => 'category']], ['term' => ['parent_id' => $unpublishedCategories]]]]];
     }
     return $filters;
 }
Ejemplo n.º 4
0
 /**
  * @param $params
  * @return ActiveDataProvider
  */
 public function search($params, $withRoots = false)
 {
     $query = $withRoots ? Category::find() : Category::find()->noRoots();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['lft' => SORT_ASC]]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['{{%grom_category}}.id' => $this->id, '{{%grom_category}}.parent_id' => $this->parent_id, '{{%grom_category}}.created_at' => $this->created_at, '{{%grom_category}}.updated_at' => $this->updated_at, '{{%grom_category}}.status' => $this->status, '{{%grom_category}}.created_by' => $this->created_by, '{{%grom_category}}.updated_by' => $this->updated_by, '{{%grom_category}}.lft' => $this->lft, '{{%grom_category}}.rgt' => $this->rgt, '{{%grom_category}}.level' => $this->level, '{{%grom_category}}.ordering' => $this->ordering, '{{%grom_category}}.hits' => $this->hits, '{{%grom_category}}.lock' => $this->lock]);
     if ($this->published_at) {
         $query->andWhere('{{%grom_category}}.published_at >= :timestamp', ['timestamp' => $this->published_at]);
     }
     $query->andFilterWhere(['like', '{{%grom_category}}.language', $this->language])->andFilterWhere(['like', '{{%grom_category}}.title', $this->title])->andFilterWhere(['like', '{{%grom_category}}.alias', $this->alias])->andFilterWhere(['like', '{{%grom_category}}.path', $this->path])->andFilterWhere(['like', '{{%grom_category}}.preview_text', $this->preview_text])->andFilterWhere(['like', '{{%grom_category}}.preview_image', $this->preview_image])->andFilterWhere(['like', '{{%grom_category}}.detail_text', $this->detail_text])->andFilterWhere(['like', '{{%grom_category}}.detail_image', $this->detail_image])->andFilterWhere(['like', '{{%grom_category}}.metakey', $this->metakey])->andFilterWhere(['like', '{{%grom_category}}.metadesc', $this->metadesc]);
     if ($this->tags) {
         $query->innerJoinWith('tags')->andFilterWhere(['{{%grom_tag}}.id' => $this->tags]);
     }
     return $dataProvider;
 }
Ejemplo n.º 5
0
 public function actionCategories($selected = '')
 {
     if (isset($_POST['depdrop_parents'])) {
         $parents = $_POST['depdrop_parents'];
         if ($parents != null) {
             $language = $parents[0];
             $out = array_map(function ($value) {
                 return ['id' => $value['id'], 'name' => str_repeat(" • ", $value['level'] - 1) . $value['title']];
             }, Category::find()->noRoots()->language($language)->orderBy('lft')->asArray()->all());
             echo Json::encode(['output' => $out, 'selected' => $selected ? $selected : '']);
             return;
         }
     }
     echo Json::encode(['output' => '', 'selected' => $selected]);
 }
Ejemplo n.º 6
0
 * @var yii\data\ActiveDataProvider $dataProvider
 * @var gromver\platform\backend\modules\news\models\PostSearch $searchModel
 */
$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', 'width' => '50px'], ['attribute' => 'category_id', 'width' => '80px', 'value' => function ($model) {
    return @$model->category->title;
}, 'filter' => \yii\helpers\ArrayHelper::map(\gromver\platform\common\models\Category::find()->noRoots()->orderBy('lft')->all(), 'id', function ($model) {
    return str_repeat(" • ", max($model->level - 2, 0)) . $model->title;
})], ['attribute' => 'language', 'filter' => Yii::$app->getLanguagesList()], ['attribute' => 'title', 'value' => function ($model) {
    /** @var $model \gromver\platform\common\models\Post */
    return $model->title . '<br/>' . Html::tag('small', $model->alias, ['class' => 'text-muted']);
}, 'format' => 'html'], ['attribute' => 'status', 'value' => function ($model) {
    /** @var $model \gromver\platform\common\models\Post */
    return $model->getStatusLabel();
}, 'filter' => \gromver\platform\common\models\Post::statusLabels()], ['attribute' => 'published_at', 'format' => ['date', 'd MMM Y H:mm'], 'width' => '160px', 'filterType' => GridView::FILTER_DATE, 'filterWidgetOptions' => ['options' => ['value' => is_int($searchModel->published_at) ? date('d.m.Y', $searchModel->published_at) : ''], 'pluginOptions' => ['format' => 'dd.mm.yyyy']]], ['attribute' => 'tags', 'value' => function ($model) {
    /** @var $model \gromver\platform\common\models\Post */
    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) {
    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', 'Post: {title}', ['title' => $model->title]), '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]]);
?>
Ejemplo n.º 7
0
 public function actionCategories($update_item_id = null, $selected = '')
 {
     if (isset($_POST['depdrop_parents'])) {
         $parents = $_POST['depdrop_parents'];
         if ($parents != null) {
             $language = $parents[0];
             //исключаем редактируемый пункт и его подпункты из списка
             if (!empty($update_item_id) && ($updateItem = Category::findOne($update_item_id))) {
                 $excludeIds = array_merge([$update_item_id], $updateItem->descendants()->select('id')->column());
             } else {
                 $excludeIds = [];
             }
             $out = array_map(function ($value) {
                 return ['id' => $value['id'], 'name' => str_repeat(" • ", $value['level'] - 1) . $value['title']];
             }, Category::find()->noRoots()->language($language)->orderBy('lft')->andWhere(['not in', 'id', $excludeIds])->asArray()->all());
             /** @var Category $root */
             $root = Category::find()->roots()->one();
             array_unshift($out, ['id' => $root->id, 'name' => Yii::t('gromver.platform', 'Root')]);
             echo Json::encode(['output' => $out, 'selected' => $selected ? $selected : $root->id]);
             return;
         }
     }
     echo Json::encode(['output' => '', 'selected' => $selected]);
 }