Beispiel #1
0
 public function actionGenerateMonth($year, $month)
 {
     $this->month = $month;
     $this->year = $year;
     for ($i = 0; $i <= 12; $i++) {
         $this->znak = $i;
         $model = new Post();
         if ($i == 0) {
             $url = $this->_url_all;
             $this->alt = $this->_alt_all;
             $title = $this->_title_all;
             $meta_title = $this->_meta_title_all;
             $meta_descr = $this->_meta_descr_all;
             $short = $this->_short_all;
             $full = $this->_full_all;
         } else {
             $url = $this->_url;
             $this->alt = $this->_alt;
             $title = $this->_title;
             $meta_title = $this->_meta_title;
             $meta_descr = $this->_meta_descr;
             $short = $this->_short;
             $full = $this->_full;
         }
         $model->author_id = 1;
         $model->category_id = 66;
         $model->date = date('Y-m-d H:i:s');
         $model->url = $this->replace($url);
         $model->title = $this->replace($title);
         $model->meta_title = $this->replace($meta_title);
         $model->meta_descr = $this->replace($meta_descr);
         $model->short = $this->replace($short);
         $model->full = $this->replace($full);
         $model->approve = 0;
         //        var_dump($model->short); die;
         //echo GlobalHelper::rusMonth($month).' '.($i > 0) ? GlobalHelper::rusZodiac($i) : 'Все знаки'.' ';
         if ($model->save()) {
             echo 'OK';
         } else {
             var_dump($model->getErrors());
         }
         echo PHP_EOL;
     }
 }