Пример #1
0
 public function action_view($truyen_id = 0, $slug = '')
 {
     $story = TruyenCuoi::bll()->getById($truyen_id, Doctrine::HYDRATE_RECORD);
     if (!$story) {
         Request::instance()->redirect(Route::url('truyen_cuoi/index'));
     }
     $story->hits++;
     $story->save();
     //get categories
     $cats = TruyenCuoiCategory::bll()->getAllCats_Select();
     $cat_listing = View::factory('front/xjtjn_truyencuoi/_category_head_list', array('cats' => $cats))->render();
     $panel1 = View::factory('front/xjtjn_truyencuoi/view', array('story' => $story->toArray(), 'categories' => $cat_listing));
     $panel2_content = View::factory('front/xjtjn_truyencuoi/list_panel2', array('truyens' => TruyenCuoi::bll()->getTopCuoiForListing()))->render();
     $panel2_1 = View::factory('front/xjtjn_truyencuoi/_panel2_2', array('section_title' => 'Cười nhiều nhất', 'content' => $panel2_content));
     $panel2_2 = View::factory('front/xjtjn_truyencuoi/_panel2_2', array('section_title' => 'Ngó nhiều nhất', 'content' => $panel2_content));
     $panel2 = "<div class='panel photo left' style='width: 300px; margin-left: 10px; margin-right:0;'>" . $panel2_1 . $panel2_2 . "</div>";
     $panel3 = "<div style='float:left;'>" . View::factory('front/xjtjn_truyencuoi/_banner_143') . "</div>";
     $this->template->content = $panel1 . $panel2 . $panel3;
 }
Пример #2
0
 /**
  * Update a story content
  * @param integer $story_id
  */
 public function action_story_update($story_id = 0)
 {
     $this->template->title = __("Sửa truyện cười");
     $this->template->section_title = __("Sửa thông tin truyện cười");
     $data = array();
     $story = TruyenCuoi::bll()->getById($story_id, Doctrine::HYDRATE_RECORD);
     if (!$story) {
         Request::instance()->redirect('/admin/truyencuoi/index');
     }
     if (Request::$method == "POST") {
         $cat_id = intval($_POST['cat_id']);
         $post = $story->validate_update($_POST);
         if ($post->check()) {
             $post = $post->as_array();
             $story->cat_id = $post['cat_id'];
             $story->title = $post['title'];
             $story->summary = $post['summary'];
             $story->content = $post['content'];
             $story->meta_keys = $post['meta_keys'];
             $story->meta_desc = $post['meta_desc'];
             $story->slug = $post['slug'];
             $story->source_uri = $post['source_uri'];
             $story->save();
             Message::success(__("Sửa nội dung truyện cười thành công!"));
             Request::instance()->redirect('/admin/truyencuoi/by_category/' . $story->cat_id);
         } else {
             $_POST = $post->as_array();
             $data['errors'] = $post->errors();
         }
     }
     $data['story'] = $story;
     $data['category'] = TruyenCuoiCategory::bll()->getAllCats_Select();
     $this->template->content = View::factory('/admin/truyencuoi/story_edit', $data);
 }