Ejemplo n.º 1
0
 function get_manufacturers()
 {
     //get ci instance
     $ci = get_instance();
     //get cpath
     $sub_categories = get_sub_categories();
     //get categories id array
     $categories = array($ci->registry->get('cpath'));
     foreach ($sub_categories as $category) {
         $categories[] = $category['id'];
     }
     //load manufacturers_model
     $ci->load->model('manufacturers_model');
     //get manufacturers
     $manufacturers = $ci->manufacturers_model->get_manufacturers($categories);
     //fomat the data
     for ($i = 0; $i < count($manufacturers); $i++) {
         $manufacturers[$i]['url'] = site_url('manufacturer/' . $manufacturers[$i]['id']);
     }
     return $manufacturers;
 }
Ejemplo n.º 2
0
 function sub_category_list($category_id = 0)
 {
     $ci =& get_instance();
     $ci->load->helper('html');
     $ci->load->module('core');
     if ($category_id > 0) {
         $categories = get_sub_categories($category_id);
         if (count($categories) > 0) {
             foreach ($categories as $row) {
                 $row['fetch_pages'] = unserialize($row['fetch_pages']);
                 $total_pages = $ci->core->_get_category_pages($row, 0, 0, TRUE);
                 $result[] = '<a href="' . site_url($row['path_url']) . '">' . $row['name'] . ' (' . $total_pages . ')</a>';
             }
             return ul($result);
         } else {
             return FALSE;
         }
     } else {
         return FALSE;
     }
 }
Ejemplo n.º 3
0
function get_usernumposts_count($userid, $post_status = 'publish')
{
    global $wpdb;
    if ($userid) {
        $propertycat = get_cat_id_from_name(get_option('ptthemes_propertycategory'));
        $propertycatcatids = get_sub_categories($propertycat, 'string');
        $ptthemes_featuredcategory = get_cat_id_from_name(get_option('ptthemes_featuredcategory'));
        $feapropertycatcatids = get_sub_categories($ptthemes_featuredcategory, 'string');
        if ($feapropertycatcatids != '' && $propertycatcatids != '') {
            $propertycatcatids .= ',' . $feapropertycatcatids;
        } else {
            $propertycatcatids = $feapropertycatcatids;
        }
        if ($propertycatcatids) {
            $srch_blog_pids = $wpdb->get_var("SELECT group_concat(tr.object_id) FROM {$wpdb->term_taxonomy} tt join {$wpdb->term_relationships} tr on tr.term_taxonomy_id=tt.term_taxonomy_id where tt.term_id in ({$propertycatcatids})");
            if ($srch_blog_pids) {
                $sub_cat_sql .= " and p.ID in ({$srch_blog_pids}) ";
            }
        }
        $srch_sql = "select count(p.ID) from {$wpdb->posts} p where  p.post_author=\"{$userid}\" and p.post_type='post'  {$sub_cat_sql}";
        if ($post_status == 'all') {
            $srch_sql .= " and p.post_status in ('publish','draft')";
        } else {
            if ($post_status == 'publish') {
                $srch_sql .= " and p.post_status in ('publish')";
            } else {
                if ($post_status == 'draft') {
                    $srch_sql .= " and p.post_status in ('draft')";
                }
            }
        }
        echo $totalpost_count = $wpdb->get_var($srch_sql);
    }
}
Ejemplo n.º 4
0
function get_sub_categories($id = 0)
{
    global $db, $tables;
    $categs = array();
    $rs = $db->Execute("SELECT `ID`, `TITLE` FROM `{$tables['category']['name']}` WHERE `PARENT_ID` = " . $db->qstr($id) . " ORDER BY `TITLE`");
    while (!$rs->EOF) {
        $categs[] = $rs->Fields('ID');
        $categs = array_merge($categs, get_sub_categories($rs->Fields('ID')));
        $rs->MoveNext();
    }
    return $categs;
}
Ejemplo n.º 5
0
 /**
  * Default Function
  *
  * @access public
  * @param string
  */
 public function index()
 {
     //get function arguments
     $arguments = func_get_args();
     //connect arguments to cpath
     $cpath = $this->parse_cpath();
     //if has arguments
     if ($cpath != NULL) {
         //compile cpath from friendly url
         $cpath = $this->category_tree->parse_cpath($cpath);
         //page title
         $this->set_page_title(sprintf(lang('index_heading'), config('STORE_NAME')));
         //check whether cpath is exist
         if (isset($cpath) && !empty($cpath)) {
             //get current category id
             $categories = explode('_', $cpath);
             $current_category_id = end($categories);
             //set global variable
             $this->registry->set('cpath', $cpath);
             $this->registry->set('current_category_id', $current_category_id);
             //model
             $this->load->model('categories_model');
             $this->load->model('products_model');
             $this->load->model('manufacturers_model');
             //breadcrumb
             $categories = $this->category_tree->get_full_cpath_info($cpath);
             foreach ($categories as $categories_id => $categories_name) {
                 $this->template->set_breadcrumb($categories_name, site_url('cpath/' . $categories_id));
             }
             //load the category object
             $this->load->library('category', $current_category_id);
             //set page title
             $data['title'] = $this->category->get_title();
             $this->set_page_title($this->category->get_title());
             //set page keywords
             $meta_keywords = $this->category->get_meta_keywords();
             if (!empty($meta_keywords)) {
                 $this->template->add_meta_tags('keywords', $meta_keywords);
             }
             //set meta description
             $meta_description = $this->category->get_meta_description();
             if (!empty($meta_description)) {
                 $this->template->add_meta_tags('description', $meta_description);
             }
             //set category data
             $data['category'] = $this->category_tree->get_data($current_category_id);
             //get sub categories
             $data['sub_categories'] = get_sub_categories();
             //get manufacturers
             $data['manufacturers'] = get_manufacturers();
             //check whether this category has products
             if ($this->categories_model->has_products($current_category_id)) {
                 $pagesize = $this->input->get('pagesize');
                 $sort = $this->input->get('sort');
                 $view = $this->input->get('view');
                 //get page
                 $filter = array('categories_id' => $current_category_id, 'page' => $this->page_num - 1, 'per_page' => $pagesize !== NULL ? $pagesize : config('MAX_DISPLAY_SEARCH_RESULTS'), 'sort' => $sort);
                 $products = $this->products_model->get_products($filter);
                 //initialize pagination parameters
                 $pagination = $this->get_pagination_config($cpath, $filter);
                 //load pagination library
                 $this->load->library('pagination', $pagination);
                 $this->pagination->initialize($pagination);
                 $data['links'] = $this->pagination->create_links();
                 $data['total_pages'] = sprintf(lang('result_set_number_of_products'), $filter['page'] * $filter['per_page'] + 1, $filter['page'] * $filter['per_page'] + sizeof($products), $pagination['total_rows']);
                 $data['products'] = array();
                 foreach ($products as $product) {
                     $data['products'][] = array('products_id' => $product['products_id'], 'product_name' => $product['products_name'], 'product_price' => $product['products_price'], 'specials_price' => $product['specials_price'], 'tax_class_id' => $product['products_tax_class_id'], 'is_specials' => $product['specials_price'] === NULL ? FALSE : TRUE, 'is_featured' => $product['featured_products_id'] === NULL ? FALSE : TRUE, 'product_image' => $product['image'], 'short_description' => $product['products_short_description']);
                 }
                 $data['has_products'] = true;
                 $data['pagesize'] = $pagesize;
                 $data['sort'] = $sort;
                 $data['view'] = empty($view) && !in_array($view, array('grid', 'list')) ? 'grid' : $view;
                 $data['filter_form_action'] = site_url('cpath/' . $cpath) . '/page';
             } else {
                 $data['has_products'] = false;
             }
             $this->template->build('index/product_listing', $data);
         }
     } else {
         redirect('index');
     }
 }