Example #1
0
 public function eventBeforeDelete($event)
 {
     $items = Article::find()->where(['cat_id' => $this->id])->all();
     if (count($items) > 0) {
         $this->addError('id', Module::t('cat_delete_error'));
         $event->isValid = false;
         return;
     }
     $event->isValid = true;
 }
Example #2
0
 public static function getAvailableNews()
 {
     $articles = Article::find()->where('timestamp_display_from <= :time', ['time' => time()])->all();
     // filter if display time is limited
     foreach ($articles as $key => $article) {
         if ($article->is_display_limit) {
             if ($article->timestamp_display_until <= time()) {
                 unset($articles[$key]);
             }
         }
     }
     return $articles;
 }
Example #3
0
 public function actionDetail($id, $title)
 {
     $model = \newsadmin\models\Article::findOne($id);
     return $this->render('detail', ['model' => $model]);
 }
Example #4
0
 public function extraVars()
 {
     return ['items' => \newsadmin\models\Article::find()->limit($this->getCfgValue('limit', 10))->all()];
 }
Example #5
0
 public function extraVars()
 {
     return ['items' => \newsadmin\models\Article::getAvailableNews($this->getCfgValue('limit', 10))];
 }