/**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $article = new article();
     $article->title = Input::get('title');
     $article->short_description = Input::get('short_description');
     $article->image = Input::get('image');
     $article->description = Input::get('description');
     $article->category_id = Input::GET('category_id');
     $article->save();
     return View::make('pages.Admin.Article.alert')->with('pesan', $article->title . ' Saved');
 }
Example #2
0
 /**
  *  添加文章
  */
 public function actionAddarc()
 {
     if ($_POST) {
         $article = new article();
         $article->title = $_POST['titles'];
         $article->article = $_POST['Html'];
         $article->cataId = $_POST['cata'];
         $article->remark = substr(strip_tags($_POST['info']), 0, 150);
         $article->time = date('Y-m-d H:i:s', time());
         $article->creater = Yii::app()->session['USER_ACCOUNT']['id'];
         $article->save(false);
         if ($AID = $article->attributes['id']) {
             foreach ($_POST['Tags'] as $key => $value) {
                 CActiveRecord::$db->createCommand()->insert('tagsasarticle', array('articleId' => $AID, 'tagsId' => $value, 'time' => date('Y-m-d H:i:s', time())));
             }
             exit('文章发表成功!');
         }
     }
     /**
      * 查询出分类列表
      */
     $Sql = 'SELECT * FROM `catalog`';
     $QueryRow = CActiveRecord::$db->createCommand($Sql)->queryAll();
     $QueryRow = $this->SelectdOrder($QueryRow, 0, 0);
     $this->ArrayToObject($QueryRow);
     /**
      * 查询出tags标签信息
      */
     $Sql = 'Select * from `tags` limit 0,8';
     $Tags = CACtiveRecord::$db->createCommand($Sql)->queryAll();
     $this->ArrayToObject($Tags);
     $this->render('insert', array('SelectAll' => $QueryRow, 'tagsbox' => $Tags));
 }
Example #3
0
 /**
  * Cnews::recycle()
  * 
  * @param integer $id
  * @param mixed $value
  * @return
  */
 function isolate_recycle($id = 0, $value)
 {
     if ($id != 0) {
         $news = new article($id);
         if (!$news->exists()) {
             show_404();
         }
         $news->recycle = ($news->recycle + 1) % 2;
         $news->save();
         $news->unset_home();
         if ($news->recycle == 1) {
             flash_message('success', "Xóa thành công.");
         } else {
             flash_message('success', "Phục hồi thành công.");
         }
     } else {
         $arr = $this->input->post('checkinput');
         foreach ($arr as $row) {
             $news = new article($row);
             $id = $news->id;
             $news->recycle = $value;
             $news->save();
             $news->unset_home();
             $news->clear();
         }
         if ($value == 1) {
             flash_message('success', "Xóa thành công.");
         } else {
             flash_message('success', "Phục hồi thành công.");
         }
     }
     $n = new Article($id);
     $newscatalogue = $n->newscatalogue;
     $this->session->set_userdata(array(config_item('session_admin') . 'menu_current' => $newscatalogue->navigation));
     if (empty($newscatalogue->menu_active)) {
         $dis['menu_active'] = "Tin";
     } else {
         $dis['menu_active'] = $newscatalogue->menu_active;
     }
     redirect($this->admin . "cnews/isolate_list_by_cat/" . $newscatalogue->id);
 }
Example #4
0
 function up_position_home()
 {
     $max = new article();
     $max->select_max('home_hot_position');
     $max->where('home_hot_position <', $this->home_hot_position);
     $max->where('home_hot', 1);
     $max->get();
     $o = new article();
     $o->where('home_hot_position', $max->home_hot_position);
     $o->where('home_hot', 1);
     $o->get();
     if ($o->result_count() > 0) {
         $tg = $this->home_hot_position;
         $this->home_hot_position = $o->home_hot_position;
         $o->home_hot_position = $tg;
         $o->save();
         $this->save();
         $this->arrange_position_home();
         return true;
     } else {
         return false;
     }
 }