function list_all() { $dis['base_url'] = base_url(); $newstopic = new newstopic(); $newstopic->order_by('id', 'desc'); $newstopic->get(); $dis['view'] = 'newstopic/list'; $dis['menu_active'] = 'Dòng sự kiện'; $dis['title'] = "Danh sách dòng sự kiện"; $dis['newstopic'] = $newstopic; $dis['nav_menu'] = array(array("type" => "add", "text" => "Thêm sự kiện", "link" => "{$this->admin_url}newstopics/edit/", "onclick" => "")); $this->viewadmin($dis); }
function isolate_edit($catalogue_id = 0, $news_id = 0) { $newscatalogue = new newscatalogue($catalogue_id); if (!$newscatalogue->exists()) { show_404(); } $news = new article($news_id); if ($_SERVER['REQUEST_METHOD'] == "GET") { if (!$news->exists()) { $news->newscatalogue_id = $catalogue_id; $news->dir = getconfigkey("default_news_dir"); } } else { $this->load->helper('remove_vn_helper'); $this->load->library('file_lib'); $news->title_vietnamese = $this->input->post('title_vietnamese'); $news->title_english = $this->input->post('title_english'); $news->title_japanese = $this->input->post('title_japanese'); $news->title_none = remove_vn($news->title_vietnamese); $news->estatecity_id = $this->input->post('estatecity_id'); $news->estatedistrict_id = $this->input->post('estatedistrict_id'); $news->estatetype_id = $this->input->post('estatetype_id'); $news->equity = $this->input->post('equity'); $news->timeStart = $this->input->post('timeStart'); $news->timeCompleted = $this->input->post('timeCompleted'); $news->investors = $this->input->post('investors'); $news->short_vietnamese = $this->input->post('short_vietnamese'); $news->short_english = $this->input->post('short_english'); $news->full_vietnamese = $this->input->post('txtFull_vietnamese'); $news->full_english = $this->input->post('txtFull_english'); $news->full_japanese = $this->input->post('txtFull_japanese'); $news->hot = $this->input->post('hot'); $news->hotHome = $this->input->post('hotHome'); $news->source = $this->input->post('source'); $news->tag = $this->input->post('tag'); $news->dir = $this->input->post('dir'); $new_image = $this->input->post('newimage'); $news->pagi = $this->input->post('pagi'); $tags = remove_vn($this->input->post('tag') . ' ' . $this->input->post('title_vietnamese') . ' ' . $this->input->post('short_vietnamese')); $tags = explode('-', $tags); $news->tag_search = implode(' ', $tags); if ($_FILES['image']['name'] != "") { $dataupload = $this->file_lib->upload('image', $news->dir); if (!is_array($dataupload)) { flash_message('error', $dataupload); } else { $news->image = $dataupload['file_name']; } } //newstopic $newstp = new newstopic($this->input->post('newstopic')); $newsc = new newscatalogue($this->input->post('newscatalogue')); $isnews = $news->exists(); if (!$news->exists()) { $news->active = 1; } if ($news->save(array($newsc, $newstp))) { // save photo for image $filePath = 'img/news/'; $numfile = $this->input->post('numfile'); foreach ($numfile as $row) { $dataupload = $this->file_lib->upload('image' . $row, $filePath); if (is_array($dataupload)) { $newsphotos = new newsphoto(); $newsphotos->article_id = $news_id; $newsphotos->image = $filePath . $dataupload['file_name']; $newsphotos->name = $this->input->post('name' . $row); $newsphotos->save(); $newsphotos->clear(); flash_message('success', $dataupload['file_name'] . ' đã được thêm.'); } } $this->session->unset_userdata('dir_for_news'); if ($isnews) { flash_message("success", "Cập nhật thành công"); } else { flash_message("success", "Thêm mới thành công"); } if ($news->navigation != "") { $this->session->set_userdata(array(config_item('session_admin') . 'menu_current' => $newscatalogue->navigation)); if (empty($newscatalogue->menu_active)) { $dis['menu_active'] = "Danh sách bài viết"; } else { $dis['menu_active'] = $newscatalogue->menu_active; } } else { $this->session->set_userdata(array(config_item('session_admin') . 'menu_current' => $news->navigation)); if (empty($newscatalogue->menu_active)) { $dis['menu_active'] = "Danh sách bài viết"; } else { $dis['menu_active'] = $news->title_vietnamese; } } redirect($this->admin . 'cnews/isolate_edit/' . $news->newscatalogue->id . '/' . $news->id); } else { flash_message("error", "Lỗi"); } } // get all province $estatecity = new Estatecity(); $estatecity->order_by('position', 'asc'); $estatecity->get_iterated(); $dis['estatecity'] = $estatecity; // get all province $estatecate = new Estatecatalogue(); $estatecate->order_by('position', 'asc'); $estatecate->get_iterated(); $dis['estatecate'] = $estatecate; $newscat = new newscatalogue(); $newscat->where('parentcat_id !=', 'NULL'); $newscat->where('parentcat_id', $newscatalogue->parentcat_id); $newscat->order_by('position', 'asc'); $newscat->get(); $newstopic = new newstopic(); $newstopic->order_by('id', 'desc'); $newstopic->get(); $sitelanguage = new Sitelanguage(); $sitelanguage->order_by('position', 'asc'); $sitelanguage->get(); $dis['sitelanguage'] = $sitelanguage; $dis['newstopic'] = $newstopic; $dis['base_url'] = base_url(); $dis['newscatalogue'] = $newscat; $dis['currentcatalogue'] = $newscatalogue; $dis['title'] = "Thêm/ Sửa tin tức"; $dis['menu_active'] = "Danh sách bài viết"; //specific view for catelogue name "gia pha toan toc" , id =39 if ($catalogue_id == 39) { $dis['view'] = "news/isolate_full_hirarchy_edit"; } else { $dis['view'] = "news/isolate_edit"; } $dis['object'] = $news; $dis['nav_menu'] = array(array("type" => "back", "text" => "Back", "link" => "{$this->admin_url}cnews/isolate_list_by_cat/" . $catalogue_id, "onclick" => "")); if ($news->exists()) { if (!empty($news->navigation)) { $this->session->set_userdata(array(config_item('session_admin') . 'menu_current' => $news->navigation)); $dis['menu_active'] = $news->title_vietnamese; } else { $this->session->set_userdata(array(config_item('session_admin') . 'menu_current' => $newscatalogue->navigation)); if (empty($newscatalogue->menu_active)) { $dis['menu_active'] = $newscatalogue->name_vietnamese; } else { $dis['menu_active'] = $newscatalogue->menu_active; } } } else { $this->session->set_userdata(array(config_item('session_admin') . 'menu_current' => $newscatalogue->navigation)); $dis['menu_active'] = $newscatalogue->name_vietnamese; } if ($this->logged_in_user->adminrole->id == 1) { array_push($dis['nav_menu'], array("type" => "copymove", "text" => "Copy/Move", "link" => "javascript:void(0);", "onclick" => "show_copy()")); } $this->viewadmin($dis); }