Esempio n. 1
0
 /**
  * Renders the index view for the module
  * @return string
  */
 public function actionIndex()
 {
     $query = ContentArticles::find()->published()->orderBy('id DESC');
     $countQuery = clone $query;
     $pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => 3, 'forcePageParam' => false]);
     //$pages->pageSizeParam = false;
     $models = $query->offset($pages->offset)->limit($pages->limit)->all();
     return $this->render('index', ['models' => $models, 'pages' => $pages]);
 }
Esempio n. 2
0
 public function getPhotos()
 {
     if (!$this->_photos) {
         $this->_photos = [];
         foreach (Photo::find()->where(['class' => ContentArticles::className(), 'item_id' => $this->id])->sort()->all() as $model) {
             $this->_photos[] = new PhotoObject($model);
         }
     }
     return $this->_photos;
 }
Esempio n. 3
0
 public function items($options = [])
 {
     if (!$this->_items) {
         $this->_items = [];
         $query = ContentArticles::find()->with('translations')->where(['category_id' => $this->id])->status(ContentArticles::STATUS_PUBLISHED)->sortDate();
         $this->_adp = new ActiveDataProvider(['query' => $query, 'pagination' => !empty($options['pagination']) ? $options['pagination'] : []]);
         foreach ($this->_adp->models as $model) {
             $this->_items[] = new ArticleObject($model);
         }
     }
     return $this->_items;
 }
Esempio n. 4
0
 public function actionView($slug)
 {
     $model = ContentCategory::find()->joinWith(['translations'])->where(['{{%content_category_lang}}.slug' => $slug])->one();
     if ($model === null) {
         throw new NotFoundHttpException(\Yii::t('system', 'The requested page does not exist.'));
     }
     $breadcrumbs = Menu::getBreadcrumbs('content/' . $slug);
     if (count($breadcrumbs) == 0) {
         $breadcrumbs = ['label' => $model->title];
     }
     $dataProvider = new ActiveDataProvider(['query' => ContentArticles::find()->andWhere(['category_id' => $model->id])->orderBy(['published_at' => SORT_DESC])->published(), 'pagination' => ['defaultPageSize' => 10, 'forcePageParam' => false, 'pageSizeParam' => false]]);
     return $this->render('view', ['breadcrumbs' => $breadcrumbs, 'model' => $model, 'dataProvider' => $dataProvider]);
 }
Esempio n. 5
0
 public function actionView($catslug, $slug)
 {
     $categoryModel = ContentCategory::find()->published()->joinWith(['translations'])->andWhere(['{{%content_category_lang}}.slug' => $catslug])->one();
     $model = ContentArticles::find()->published()->joinWith(['translations'])->andWhere(['{{%content_articles_lang}}.slug' => $slug])->one();
     if ($model === null and $categoryModel === null) {
         throw new NotFoundHttpException(\Yii::t('system', 'The requested page does not exist.'));
     }
     $breadcrumbs = Menu::getBreadcrumbs('content/' . $catslug . '/' . $slug);
     if (count($breadcrumbs) == 0) {
         $breadcrumbs = [['label' => $categoryModel->title, 'url' => Url::to(['/content/category/view', 'slug' => $categoryModel->slug])], ['label' => $model->title]];
     }
     return $this->render('view', ['breadcrumbs' => $breadcrumbs, 'model' => $model, 'categoryModel' => $categoryModel]);
 }
Esempio n. 6
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params, $category = null)
 {
     if ($category) {
         $query = ContentArticles::find()->where(['category_id' => $category]);
     } else {
         $query = ContentArticles::find();
     }
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'create_user_id' => $this->create_user_id, 'update_user_id' => $this->update_user_id, 'published_at' => $this->published_at, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'status' => $this->status, 'comment_status' => $this->comment_status, 'access_type' => $this->access_type, 'category_id' => $this->category_id]);
     $query->andFilterWhere(['like', 'create_user_ip', $this->create_user_ip]);
     return $dataProvider;
 }
Esempio n. 7
0
 public function api_items($options = [])
 {
     if (!$this->_items) {
         $this->_items = [];
         $query = ContentArticles::find()->with('translations')->status(ContentArticles::STATUS_PUBLISHED);
         if (!empty($options['where'])) {
             $query->andFilterWhere($options['where']);
         }
         if (!empty($options['tags'])) {
             $query->innerJoinWith('tags', false)->andWhere([Tag::tableName() . '.name' => (new Item())->filterTagValues($options['tags'])])->addGroupBy('item_id');
         }
         if (!empty($options['orderBy'])) {
             $query->orderBy($options['orderBy']);
         } else {
             $query->sortDate();
         }
         $this->_adp = new ActiveDataProvider(['query' => $query, 'pagination' => !empty($options['pagination']) ? $options['pagination'] : []]);
         foreach ($this->_adp->models as $model) {
             $this->_items[] = new ArticleObject($model);
         }
     }
     return $this->_items;
 }
Esempio n. 8
0
<?php

$this->bodyClass = ['news'];
$this->logoCont = '
<div class="logo__text logo__news">ПОСЛЕДНИЕ<br>НОВОСТИ</div>
';
$news = \app\modules\content\models\ContentArticles::find()->published()->where(['category_id' => 1])->all();
$this->setSeoData('News', '', '', '/news.html');
?>



<section class="latest-news section">
    <div class="section__bg">
        <div class="section__content">
            <?php 
foreach ($models as $k => $model) {
    ?>
                <?php 
    echo $this->renderFile('@app/modules/content/views/frontend/default/_item_2.php', ['model' => $model, 'index' => $k]);
    ?>
            <?php 
}
?>
            <?php 
echo \yii\widgets\LinkPager::widget(['pagination' => $pages, 'registerLinkTags' => true]);
?>
        </div>
    </div>
</section>
Esempio n. 9
0
echo !LIVE_EDIT ? \app\modules\text\api\Text::get('developer') : '';
?>
    <?php 
if (LIVE_EDIT) {
    \app\widgets\EditorInline::end();
}
?>
</section>

<section class="latest-news section">
    <div class="container">
        <div class="section__title">
            ПОСЛЕДНИЕ НОВОСТИ
        </div>
    </div>
    <div class="section__bg">
        <div class="section__content">
            <div class="container">
                <div class="row">
                    <?php 
$new = \app\modules\content\models\ContentArticles::find()->published()->limit(1)->orderBy('id DESC')->one();
?>
                    <?php 
echo $this->renderFile('@app/modules/content/views/frontend/default/_item.php', ['model' => $new]);
?>
                </div>
            </div>
        </div>
    </div>
</section>
Esempio n. 10
0
 /**
  * Finds the ContentArticles model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return ContentArticles the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = ContentArticles::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }