/** * Load more * * @version 1.0 * @since 1.0 * @access public * @author Nguyen Van Hiep */ public function action_ajaxload() { $cat_id = Input::post('cat_id'); $lang = Input::post('lang'); $current_news_count = Input::post('current_news_count'); $type = Input::post('type'); $cat = Model_Categories::find($cat_id); switch ($type) { case 'ds_sanpham_4col': $show_more = View::forge('customer/cat/show_more_template_ds_sanpham_4col'); $more_arts = Model_Article::load_articles_limit($cat_id, $lang, $current_news_count, 4); break; case 'news': $show_more = View::forge('customer/cat/show_more_template_news'); $more_arts = Model_Article::load_articles_limit($cat_id, $lang, $current_news_count, NEWS_LIMIT); break; case 'ds_monan': $show_more = View::forge('customer/cat/show_more_template_ds_monan'); $more_arts = Model_Article::load_articles_limit($cat_id, $lang, $current_news_count, 8); break; } $count = count($more_arts); $ret = ''; if ($count > 0) { $show_more->current_count = Input::post('current_count', 0); foreach ($more_arts as $art) { ++$show_more->current_count; $show_more->art = $art; $show_more->cat = $cat; $ret .= $show_more; } } return $ret; }
/** * Check if a cat. is child of a parent cat. * * @params int $parent_id Parent-Cat. ID * @params int $child_id Child-Cat. ID * @return boolean * * @version 1.0 * @since 1.0 * @access public * @author Nguyen Van hiep */ public static function is_child($child_id, $parent_id) { if (is_null($child_id)) { return false; } $child = Model_Categories::find($child_id); return $child->parent_id == $parent_id ? true : false; }
public function action_search() { $view = View::forge('customer/search/search'); $view->search = array(); $view->keyword = Input::get('search-keyword', ''); if (!empty($view->keyword)) { $custom_keyword = Input::vn_str_filter($view->keyword); $search_count = $search_article = Model_ArtCat::query()->related('ac2a')->where(DB::expr("content_search_no_mark LIKE '%{$custom_keyword}%'"))->or_where(DB::expr("title_search LIKE '%{$custom_keyword}%'"))->count(); $config = array('pagination_url' => Uri::base() . "search?search-keyword={$custom_keyword}", 'total_items' => $search_count, 'per_page' => 10, 'uri_segment' => 'page', 'num_links' => 3); $pag = Pagination::forge('paging_search', $config); $search_cat = Model_Categories::query()->where(DB::expr("name_search LIKE '%{$custom_keyword}%'"))->order_by('name_search')->get(); foreach ($search_cat as $s) { $parent = Model_Categories::find($s->parent_id); $view->search[] = array('title' => strip_tags($s->name), 'desc' => strip_tags($s->desc), 'link' => Uri::base() . "{$parent->slug}/{$s->slug}.html"); } $search_article = Model_ArtCat::query()->related('ac2a')->where(DB::expr("content_search_no_mark LIKE '%{$custom_keyword}%'"))->or_where(DB::expr("title_search LIKE '%{$custom_keyword}%'"))->order_by('ac2a.title_search')->rows_offset($pag->offset)->rows_limit($pag->per_page)->get(); foreach ($search_article as $s) { // highlight keyword $content = $this->highlight($s->ac2a->content_search, $custom_keyword); // get cat slug if (!empty($s->ac2c->parent_id)) { $parent_cat_slug = Model_Categories::find($s->ac2c->parent_id); $view->search[] = array('title' => strip_tags($s->ac2a->title), 'desc' => $content, 'link' => Uri::base() . "{$s->ac2c->slug}/{$s->ac2a->slug}.html", 'cat' => array('name' => strip_tags($s->ac2c->name), 'desc' => $s->ac2c->desc, 'link' => Uri::base() . "{$parent_cat_slug->slug}/{$s->ac2c->slug}.html")); } else { $view->search[] = array('title' => strip_tags($s->ac2a->title), 'desc' => $content, 'link' => Uri::base() . "{$s->ac2c->slug}/{$s->ac2a->slug}.html"); } } $view->pag = $pag; } $this->template = \View::forge('customer/search/template'); // data to display menu $this->template->cats = Model_Categories::get_cats_home($this->lang); $this->template->pepper_arts = Model_Article::pepper_artilces($this->lang); $this->template->title = __('common.search'); $this->add_css('search.css'); $this->template->content = $view; }
/** * Display detailed page of Article * * @param void * @access public * @author Nguyen Van Hiep * * @version 1.0 * @since 1.0 */ public function action_view() { $art_check = Model_Article::get_art_from_slug(Uri::segment(2)); if (!$art_check) { Response::redirect('common/error'); } $uri = explode('-', Uri::string()); $id = array_pop($uri); $art = Model_Article::find($id); $cat = Model_Categories::get_cat_from_slug(Uri::segment(1)); $related_arts = Model_Article::articles_of_cat_limit($cat->id, $this->lang, $id); if (!$art) { Session::set_flash('error', __('message.art_not_exist')); Response::redirect('common/404'); } $art->views = $art->views + 1; $art->save(); if ($cat->display_type == DS_SANPHAM) { $this->template = \View::forge('customer/template_sanpham_detail'); $view = View::forge('customer/article/detail_sp_slide'); } elseif ($cat->display_type == DS_MONAN) { $this->template = \View::forge('customer/template_monan'); $view = View::forge('customer/article/detail_monan_slide'); } elseif ($cat->display_type == QUY_TRINH_SX) { $view = View::forge('customer/article/detail_quytrinhsx'); } else { $view = View::forge('customer/article/detail'); } $view->art = $art; $view->related_arts = $related_arts; $view->cat = $cat; if (!empty($cat->parent_id)) { $view->p_cat = Model_Categories::find($cat->parent_id); } // data to display menu $this->template->cats = Model_Categories::get_cats_home($this->lang); $this->template->pepper_arts = Model_Article::pepper_artilces($this->lang); $this->template->title = Security::strip_tags($art->title); $this->template->content = $view; }
/** * Ajax: Change active_flag of Cat. * * @param void * * @author Nguyen Van Hiep * @access public * * @version 1.0 * @since 1.0 */ public function action_ajaxflag() { $id = Input::post('id'); $flag = Input::post('flag'); $flag = !$flag; $img = Model_Categories::find($id); $img->active = $flag; //save $img->save(); }