Server : Apache/2.4.18 (Ubuntu) System : Linux canvaswebdesign 3.13.0-71-generic #114-Ubuntu SMP Tue Dec 1 02:34:22 UTC 2015 x86_64 User : oppastar ( 1041) PHP Version : 7.0.33-0ubuntu0.16.04.15 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, Directory : /var/www/rabbithabit.com/public_html/application/controllers/ |
Upload File : |
<?php defined('BASEPATH') OR exit('No direct script access allowed'); class Category extends Public_Controller { public function __construct() { parent::__construct(); } public function get($alias_level1 = NULL, $alias_level2 = NULL, $alias_level3 = NULL) { $this->load->helper('product'); $t_uri_segment = 3; if ($alias_level1 == NULL) { show_404(); } if ($alias_level1 !== NULL && $alias_level1 != 'all-categories' && $alias_level1 != 'new' && $alias_level1 != 'sale') { if($this->session->userdata('site_lang') == 'english') { //check if this category alias exist $this->db->select('id_categories')->from('categories')->where('alias_en', $alias_level1)->where('parent', NULL)->where('status', 1); $count_category_en = $this->db->get()->num_rows(); if ($count_category_en == 0) { //category not exist in english alias. So check to indonesian $this->db->select('id_categories')->from('categories')->where('alias', $alias_level1)->where('parent', NULL)->where('status', 1); $count_category_ind = $this->db->get()->num_rows(); if($count_category_ind == 0) { show_404(); } else { //category exist in indonesian. get category parameter $this->db->select('*')->from('categories')->where('alias', $alias_level1); $level1 = $this->db->get()->row(); $this->data['level1_id'] = $level1->id_categories; $this->data['level1_title'] = $level1->category; $this->data['level1_alias'] = $alias_level1; //change the website session language to indonesian $this->session->set_userdata('site_lang', 'indonesian'); $this->load->helper('language'); $this->lang->load('website','indonesian'); } } else { //category exist for english $this->db->select('*')->from('categories')->where('alias_en', $alias_level1); $level1 = $this->db->get()->row(); $this->data['level1_id'] = $level1->id_categories; $this->data['level1_title'] = $level1->category_en; $this->data['level1_alias'] = $alias_level1; //change the website session language to english $this->session->set_userdata('site_lang', 'english'); $this->load->helper('language'); $this->lang->load('website','english'); } } else { //session userdata is Indonesian //check if this category alias exist $this->db->select('id_categories')->from('categories')->where('alias', $alias_level1)->where('parent', NULL)->where('status', 1); $count_category = $this->db->get()->num_rows(); if ($count_category == 0) { //category not exist in indonesian alias. So check to english $this->db->select('id_categories')->from('categories')->where('alias_en', $alias_level1)->where('parent', NULL)->where('status', 1); $count_category_en = $this->db->get()->num_rows(); if($count_category_en == 0) { show_404(); } else { //category exist in english. get category parameter $this->db->select('*')->from('categories')->where('alias_en', $alias_level1); $level1 = $this->db->get()->row(); $this->data['level1_id'] = $level1->id_categories; $this->data['level1_title'] = $level1->category_en; $this->data['level1_alias'] = $alias_level1; //change the website session language to english $this->session->set_userdata('site_lang', 'english'); $this->load->helper('language'); $this->lang->load('website','english'); } } else { //category exist for indonesian $this->db->select('*')->from('categories')->where('alias', $alias_level1); $level1 = $this->db->get()->row(); $this->data['level1_id'] = $level1->id_categories; $this->data['level1_title'] = $level1->category; $this->data['level1_alias'] = $alias_level1; //change the website session language to indonesian $this->session->set_userdata('site_lang', 'indonesian'); $this->load->helper('language'); $this->lang->load('website','indonesian'); } } } //get id for alias level2 if ($alias_level2 != NULL) { if (is_numeric($alias_level2)) { # the numeric is for pagination. //do nothing... } else { if($this->session->userdata('site_lang') == 'english') { //check if this category alias exist $this->db->select('id_categories')->from('categories')->where('alias_en', $alias_level2)->where('parent', $level1->id_categories)->where('status', 1); $count_category = $this->db->get()->num_rows(); if ($count_category > 0) { //category for english exist //if exist, get the Category Id for level 2 category $this->db->select('id_categories, category_en')->from('categories')->where('alias_en', $alias_level2)->where('parent', $level1->id_categories); $level2 = $this->db->get()->row(); $this->data['level2_id'] = $level2->id_categories; $this->data['level2_title'] = $level2->category_en; $this->data['level2_alias'] = $alias_level2; } else { //category english not exist, check for indonesian //check if this category alias exist $this->db->select('id_categories')->from('categories')->where('alias', $alias_level2)->where('parent', $level1->id_categories)->where('status', 1); $count_category = $this->db->get()->num_rows(); if($count_category > 0) { //category exist $this->db->select('id_categories, category')->from('categories')->where('alias', $alias_level2)->where('parent', $level1->id_categories); $level2 = $this->db->get()->row(); $this->data['level2_id'] = $level2->id_categories; $this->data['level2_title'] = $level2->category; $this->data['level2_alias'] = $alias_level2; } else { //category not exist show_404(); } } } else { //session language is indonesian //check if this category alias exist $this->db->select('id_categories')->from('categories')->where('alias', $alias_level2)->where('parent', $level1->id_categories)->where('status', 1); $count_category = $this->db->get()->num_rows(); if ($count_category > 0) { //category for indonesian exist //if exist, get the Category Id for level 2 category $this->db->select('id_categories, category')->from('categories')->where('alias', $alias_level2)->where('parent', $level1->id_categories); $level2 = $this->db->get()->row(); $this->data['level2_id'] = $level2->id_categories; $this->data['level2_title'] = $level2->category; $this->data['level2_alias'] = $alias_level2; } else { //category indonesian not exist, check for english //check if this category alias exist $this->db->select('id_categories')->from('categories')->where('alias_en', $alias_level2)->where('parent', $level1->id_categories)->where('status', 1); $count_category = $this->db->get()->num_rows(); if($count_category > 0) { //category exist $this->db->select('id_categories, category_en')->from('categories')->where('alias_en', $alias_level2)->where('parent', $level1->id_categories); $level2 = $this->db->get()->row(); $this->data['level2_id'] = $level2->id_categories; $this->data['level2_title'] = $level2->category_en; $this->data['level2_alias'] = $alias_level2; } else { //category not exist show_404(); } } } } } //get id for alias level3 if ($alias_level3 != NULL) { if (is_numeric($alias_level3)) { //Numeric is for pagination. do nothing... } else { if($this->session->userdata('site_lang') == 'english') { //session website english //check if this category alias exist $this->db->select('id_categories')->from('categories')->where('alias_en', $alias_level3)->where('parent', $level2->id_categories)->where('status', 1); $count_category = $this->db->get()->num_rows(); if ($count_category > 0) { //category exist in english //if exist, get the Category Id & label for level 3 category $this->db->select('id_categories, category_en')->from('categories')->where('alias_en', $alias_level3)->where('parent', $level2->id_categories); $level3 = $this->db->get()->row(); $this->data['level3_id'] = $level3->id_categories; $this->data['level3_title'] = $level3->category_en; $this->data['level3_alias'] = $alias_level3; } else { //category not exist in english, check for indonesian $this->db->select('id_categories')->from('categories')->where('alias', $alias_level3)->where('parent', $level2->id_categories)->where('status', 1); $count_category = $this->db->get()->num_rows(); if ($count_category > 0) { //if exist, get the Category Id & label for level 3 category $this->db->select('id_categories, category')->from('categories')->where('alias', $alias_level3)->where('parent', $level2->id_categories); $level3 = $this->db->get()->row(); $this->data['level3_id'] = $level3->id_categories; $this->data['level3_title'] = $level3->category; $this->data['level3_alias'] = $alias_level3; } else { show_404(); } } } else { //session website indonesian //check if this category alias exist $this->db->select('id_categories')->from('categories')->where('alias', $alias_level3)->where('parent', $level2->id_categories)->where('status', 1); $count_category = $this->db->get()->num_rows(); if ($count_category > 0) { //category exist in indonesian //if exist, get the Category Id & label for level 3 category $this->db->select('id_categories, category')->from('categories')->where('alias', $alias_level3)->where('parent', $level2->id_categories); $level3 = $this->db->get()->row(); $this->data['level3_id'] = $level3->id_categories; $this->data['level3_title'] = $level3->category; $this->data['level3_alias'] = $alias_level3; } else { //category not exist in indonesian, check for english $this->db->select('id_categories')->from('categories')->where('alias_en', $alias_level3)->where('parent', $level2->id_categories)->where('status', 1); $count_category = $this->db->get()->num_rows(); if ($count_category > 0) { //if exist, get the Category Id & label for level 3 category $this->db->select('id_categories, category_en')->from('categories')->where('alias_en', $alias_level3)->where('parent', $level2->id_categories); $level3 = $this->db->get()->row(); $this->data['level3_id'] = $level3->id_categories; $this->data['level3_title'] = $level3->category_en; $this->data['level3_alias'] = $alias_level3; } else { show_404(); } } } } } //Load model product_m $this->load->model('product_m'); //get no. of products per page (pagination) from configuration table $this->db->select('products_displayed')->from('configuration')->where('id_configuration', 1); $per_page = $this->db->get()->row(); //user request level 1 category if ($alias_level1 != NULL && $alias_level1 != 'all-categories') { //get category parameters $this->db->select('*')->from('categories')->where('id_categories', $level1->id_categories)->where('parent', NULL); $this->data['category'] = $this->db->get()->row(); $this->data['category_title'] = 'View All'; //check if post sort_product is exist if ($this->input->post('sort_product')) { $this->session->set_userdata('sort_product', $this->input->post('sort_product')); } //PRODUCTS //pagination in action $this->load->library('pagination'); $this->load->helper('pagination_helper'); add_pagination_frontend(base_url() . 'category/' . $alias_level1 . '/', $this->product_m->count_products_by_category($this->data['category']->id_categories), $per_page->products_displayed, $t_uri_segment); $this->data['sort_product_by'] = $this->session->userdata('sort_product'); $this->data['sidebanner_active_category_id'] = $this->data['level1_id']; $this->data['total_products'] = $this->product_m->count_products_by_category($this->data['category']->id_categories); $this->data['products'] = $this->product_m->get_products_by_category($this->data['category']->id_categories, $per_page->products_displayed, $this->uri->segment($t_uri_segment)); } //user request level 2 category if ($alias_level2 != NULL && is_numeric($alias_level2) == FALSE) { //get category parameters $this->db->select('*')->from('categories')->where('id_categories', $level2->id_categories)->where('parent', $level1->id_categories); $this->data['category'] = $this->db->get()->row(); $this->data['category_title'] = $this->data['category']->category; $this->data['category_title_en'] = $this->data['category']->category_en; //check if post sort_product is exist if ($this->input->post('sort_product')) { $this->session->set_userdata('sort_product', $this->input->post('sort_product')); } //PRODUCTS //pagination in action //get no. of products per page (pagination) from configuration table $this->load->library('pagination'); $this->load->helper('pagination_helper'); add_pagination_frontend(base_url() . 'category/' . $alias_level1 . '/' . $alias_level2 . '/', $this->product_m->count_products_by_category($this->data['category']->id_categories), $per_page->products_displayed, 4); $this->data['sort_product_by'] = $this->session->userdata('sort_product'); $this->data['sidebanner_active_category_id'] = $this->data['level2_id']; $this->data['total_products'] = $this->product_m->count_products_by_category($this->data['category']->id_categories); $this->data['products'] = $this->product_m->get_products_by_category($this->data['category']->id_categories, $per_page->products_displayed, $this->uri->segment(4)); } //user request level 3 category if ($alias_level3 != NULL && is_numeric($alias_level3) == FALSE) { //get category parameters $this->db->select('*')->from('categories')->where('id_categories', $level3->id_categories)->where('parent', $level2->id_categories); $this->data['category'] = $this->db->get()->row(); $this->data['category_title'] = $this->data['category']->category; $this->data['category_title_en'] = $this->data['category']->category_en; //check if post sort_product is exist if ($this->input->post('sort_product')) { $this->session->set_userdata('sort_product', $this->input->post('sort_product')); } //PRODUCTS //pagination in action. $this->load->library('pagination'); $this->load->helper('pagination_helper'); add_pagination_frontend(base_url() . 'category/' . $alias_level1 . '/' . $alias_level2 . '/' . $alias_level3 . '/', $this->product_m->count_products_by_category($this->data['category']->id_categories), $per_page->products_displayed, 5); $this->data['sort_product_by'] = $this->session->userdata('sort_product'); $this->data['sidebanner_active_category_id'] = $this->data['level3_id']; $this->data['total_products'] = $this->product_m->count_products_by_category($this->data['category']->id_categories); $this->data['products'] = $this->product_m->get_products_by_category($this->data['category']->id_categories, $config['per_page'], $this->uri->segment($config['uri_segment'])); } //set current category to session, so it can be track to product page if($alias_level1 != 'all-categories') { $this->session->set_userdata('current_viewed_category_id', $this->data['category']->id_categories); } if ($alias_level1 == 'all-categories') { //check if post sort_product is exist if ($this->input->post('sort_product')) { $this->session->set_userdata('sort_product', $this->input->post('sort_product')); } //PRODUCTS //pagination in action. $this->load->library('pagination'); $this->load->helper('pagination_helper'); add_pagination_frontend(base_url() . 'category/all-categories/', $this->product_m->count_products_all(), $per_page->products_displayed, $t_uri_segment); $this->data['sort_product_by'] = $this->session->userdata('sort_product'); $this->data['total_products'] = $this->product_m->count_products_all(); $this->data['products'] = $this->product_m->get_products_all($per_page->products_displayed, $this->uri->segment($t_uri_segment)); //get all categories if($this->session->userdata('site_lang') == 'english') { //to display title on product_list view $this->data['product_list_title'] = 'collections'; $this->db->select('category_en as category, alias_en as alias')->from('categories')->where('parent', NULL)->where('status', '1')->order_by('priority', 'ASC'); } else { //to display title on product_list view $this->data['product_list_title'] = 'koleksi'; $this->db->select('category, alias')->from('categories')->where('parent', NULL)->where('status', '1')->order_by('priority', 'ASC'); } $this->data['categories'] = $this->db->get()->result(); //get SEO $this->data_header['browser_title'] = 'Kategori Produk - ' . ucwords($this->data_header['website_name']); $this->data_header['meta_description'] = 'Kategori Produk - ' . ucwords($this->data_header['website_name']); } elseif ($alias_level1 == 'new') { //check if post sort_product is exist if ($this->input->post('sort_product')) { $this->session->set_userdata('sort_product', $this->input->post('sort_product')); } //PRODUCTS //pagination in action. $this->load->library('pagination'); $this->load->helper('pagination_helper'); add_pagination_frontend(base_url() . 'category/new/', $this->product_m->count_products_new_arrival(), $per_page->products_displayed, $t_uri_segment); $this->data['sort_product_by'] = $this->session->userdata('sort_product'); $this->data['total_products'] = $this->product_m->count_products_new_arrival(); $this->data['products'] = $this->product_m->get_products_new_arrival($per_page->products_displayed, $this->uri->segment($t_uri_segment)); //get all categories if($this->session->userdata('site_lang') == 'english') { //to display title on product_list view $this->data['category_title'] = 'New Collections'; $this->db->select('category_en as category, alias_en as alias')->from('categories')->where('parent', NULL)->where('status', '1')->order_by('priority', 'ASC'); } else { //to display title on product_list view $this->data['category_title'] = 'New Collections'; $this->db->select('category, alias')->from('categories')->where('parent', NULL)->where('status', '1')->order_by('priority', 'ASC'); } $this->data['categories'] = $this->db->get()->result(); //get SEO $this->data_header['browser_title'] = ucwords($this->data_header['website_name']) . ' - New Collection'; $this->data_header['meta_description'] = ucwords($this->data_header['website_name']) . ' - New Collection'; } elseif ($alias_level1 == 'sale') { //check if post sort_product is exist if ($this->input->post('sort_product')) { $this->session->set_userdata('sort_product', $this->input->post('sort_product')); } //PRODUCTS //pagination in action. $this->load->library('pagination'); $this->load->helper('pagination_helper'); add_pagination_frontend(base_url() . 'category/sale/', $this->product_m->count_products_sale(), $per_page->products_displayed, $t_uri_segment); $this->data['sort_product_by'] = $this->session->userdata('sort_product'); $this->data['total_products'] = $this->product_m->count_products_sale(); $this->data['products'] = $this->product_m->get_products_sale($per_page->products_displayed, $this->uri->segment($t_uri_segment)); //get all categories if($this->session->userdata('site_lang') == 'english') { //to display title on product_list view $this->data['category_title'] = 'Sale'; $this->db->select('category_en as category, alias_en as alias')->from('categories')->where('parent', NULL)->where('status', '1')->order_by('priority', 'ASC'); } else { //to display title on product_list view $this->data['category_title'] = 'Sale'; $this->db->select('category, alias')->from('categories')->where('parent', NULL)->where('status', '1')->order_by('priority', 'ASC'); } $this->data['categories'] = $this->db->get()->result(); //get SEO $this->data_header['browser_title'] = ucwords($this->data_header['website_name']) . ' - Sale'; $this->data_header['meta_description'] = ucwords($this->data_header['website_name']) . ' - Sale'; } else { //get SEO if(!empty($this->data['category']->meta_title)) { $this->data_header['browser_title'] = $this->data['category']->meta_title; $this->data_header['meta_description'] = $this->data['category']->meta_description; } else { $this->data_header['browser_title'] = 'Kategori ' . ucwords($this->data['category']->category) . ' - ' . ucwords($this->data_header['website_name']); $this->data_header['meta_description'] = $this->data['category']->meta_description; } //get category description and banner if($this->session->userdata('site_lang') == 'english') { $this->data['description'] = $this->data['category']->description_en; $this->data['title'] = $this->data['category']->category_en; } else { $this->data['description'] = $this->data['category']->description; $this->data['title'] = $this->data['category']->category; } $this->data['banner'] = $this->data['category']->image; } //LOAD LANGUAGE FILES FOR PRODUCT LIST PAGE if($this->session->userdata('site_lang') == 'english') { $this->lang->load('product_detail', 'english'); $this->lang->load('product_list', 'english'); } else { $this->lang->load('product_list', 'indonesian'); $this->lang->load('product_detail', 'indonesian'); } $this->data_header['c_url_alias_en'] = $this->db ->select('alias_en') ->from('categories')->where('id_categories', $this->data['category']->id_categories) ->order_by('priority','ASC')->get()->row()->alias_en; $this->data_header['c_url_alias_ind'] = $this->db ->select('alias') ->from('categories')->where('id_categories', $this->data['category']->id_categories) ->order_by('priority','ASC')->get()->row()->alias; $limit_segment = $this->uri->segment($t_uri_segment); if ($limit_segment == null || $limit_segment == '') { $limit_segment = 0; } $this->data['limit_segment'] = $limit_segment; $this->data['per_page'] = $per_page->products_displayed; $this->data['all_products'] = $this->data['total_products']; $this->data['category_url'] = $config['base_url']; $this->load->view("themes/$this->theme_no/header", $this->data_header); $this->load->view("themes/$this->theme_no/product_list", $this->data); $this->load->view("themes/$this->theme_no/footer", $this->data_footer); } public function index() { // if($this->input->get('search_product')) { $keyword = $this->security->xss_clean($this->input->post('search_product')); $brand = $this->security->xss_clean($this->input->post('brand')); $designer = $this->security->xss_clean($this->input->post('designer')); $price = $this->security->xss_clean($this->input->post('price')); // } if($keyword == NULL && $brand == NULL && $designer == NULL && $price == NULL) {redirect(base_url());} //check if post sort_product is exist if ($this->input->get('sort_product')) { $this->session->set_userdata('sort_product', $this->input->get('sort_product')); } //get no. of products per page (pagination) from configuration table $this->db->select('products_displayed')->from('configuration')->where('id_configuration', 1); $per_page = $this->db->get()->row(); //PRODUCTS //pagination in action $this->load->library('pagination'); $config = array(); $this->load->helper('pagination_helper'); // $config = pagination_format(); $config['base_url'] = base_url() . 'search/index/'; $this->load->model('product_m'); $config['total_rows'] = $this->product_m->count_products_by_search($keyword); $config['per_page'] = (int) $per_page->products_displayed; $config['uri_segment'] = $t_uri_segment; $config['reuse_query_string'] = true; $this->pagination->initialize($config); $this->data['sort_product_by'] = $this->session->userdata('sort_product'); $this->data['total_products'] = $config['total_rows']; if($brand != NULL && $keyword == NULL && $designer == NULL && $price == NULL) { $this->data['products'] = $this->product_m->get_products_by_brand($brand, $config['per_page'], $this->uri->segment($config['uri_segment']),''); } if($keyword != NULL && $brand == NULL && $designer == NULL && $price == NULL) { $this->data['products'] = $this->product_m->get_products_by_search($keyword, $config['per_page'], $this->uri->segment($config['uri_segment'])); } if($designer != NULL && $brand == NULL && $keyword == NULL && $price == NULL) { $this->data['products'] = $this->product_m->get_products_by_designer($designer, $config['per_page'], $this->uri->segment($config['uri_segment']),''); } if($price != NULL && $brand == NULL && $keyword == NULL && $designer == NULL) { $this->data['products'] = $this->product_m->get_products_by_price($price, $config['per_page'], $this->uri->segment($config['uri_segment']),''); } $this->data['keyword'] = $keyword; $this->load->helper('product'); //LOAD LANGUAGE FILES FOR PRODUCT LIST PAGE if($this->session->userdata('site_lang') == 'english') { $this->lang->load('product_detail', 'english'); $this->lang->load('product_list', 'english'); } else { $this->lang->load('product_list', 'indonesian'); $this->lang->load('product_detail', 'indonesian'); } $this->data['category_url'] = 'search'; $this->data['categoryTitle'] = $this->security->xss_clean($this->input->post('category_title')); $this->data['categoryTitle_en'] = $this->security->xss_clean($this->input->post('category_title_en')); $this->data['level1Alias'] = $this->security->xss_clean($this->input->post('level1_alias')); $this->data['level2Alias'] = $this->security->xss_clean($this->input->post('level2_alias')); $this->data['level3Alias'] = $this->security->xss_clean($this->input->post('level3_alias')); //get SEO $this->data_header['browser_title'] = 'Cari Produk ' . ucwords($this->data_header['website_name']); $this->data_header['meta_description'] = 'Cari Produk ' . ucwords($this->data_header['website_name']); $this->load->view("themes/$this->theme_no/header", $this->data_header); $this->load->view("themes/$this->theme_no/product_list", $this->data); $this->load->view("themes/$this->theme_no/footer", $this->data_footer); } }