categorieData Class Reference

Inherits DataStatmentFO, and Interfacedata.

List of all members.

Static Public Member Functions

  • static start ()
  • static resetCacheId ($id)
    delet item in cache
  • static add_where_query ($add)
    Ajout constrainte clause where.
  • static get_query ($id='', $search='', $exclude='', $option='')
    Appel item.
  • static get_item ($id)
    Alias unique ID.
  • static get_path ($current_category_id= '', $value=false)
    Generate a path to categories.
  • static get_count_products_in_category ($category_id, $include_inactive=false)
    Return the number of products and category child in a category TABLES: products, products_to_categories, categories.
  • static get_count_content_in_category ($category_id)
    Return the number of products and category child in a category TABLES: products, products_to_categories, categories.
  • static get_has_category_subcategories ($category_id)
    Return false if not the category has subcategories or nbr category.
  • static get_parent_categories (&$categories, $categories_id)
    Recursively go through the categories and retreive all parent categories IDs TABLES: categories.
  • static get_subcategories (&$subcategories_array, $parent_id=0)
    Return all subcategory IDs.
  • static get_categories ($categories_array= '', $parent_id= '0', $indent= '')
    Construction d'un select sur les catégories actives.

Static Public Attributes

Static Protected Member Functions

  • static statment_query ($content_query, $exclude='', $search='')
    Prepa donnée sortie.
  • static reset_query ()
  • static cstr_query ($orderby='', $limit='', $option='')
    Requeteur.

Static Private Member Functions

  • static add_cache ($id)
    Mise en pile de toutes les element des page de cms.
  • static in_cache ()
    Appel et recup des element du cache.

Static Private Attributes


Detailed Description

Definition at line 97 of file driver.categorie.php.


Member Function Documentation

static categorieData::add_cache ( id  )  [static, private]

Mise en pile de toutes les element des page de cms.

Parameters:
$id int

Definition at line 141 of file driver.categorie.php.

Referenced by statment_query().

00141                                         {
00142     self::$cache[]=$id;
00143   }

static categorieData::add_where_query ( add  )  [static]

Ajout constrainte clause where.

Parameters:
$add 

Definition at line 186 of file driver.categorie.php.

Referenced by get_count_content_in_category(), get_count_products_in_category(), get_has_category_subcategories(), and get_query().

00186 { self::$where_query .=' '.$add.' '; }

categorieData::cstr_query ( orderby = '',
limit = '',
option = '' 
) [static, protected]

Requeteur.

Parameters:
$orderby 
$limit 
$option 

Definition at line 202 of file driver.categorie.php.

Referenced by get_query().

00202                                                                           {
00203     $query="SELECT c.categories_id, parent_id, cd.categories_description, c.categories_image, cd.categories_name, sortchids_products, sortchids_content FROM " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd WHERE c.categories_status='1' AND c.categories_id = cd.categories_id AND cd.language_id = '" . self::$lg_id  . "' ";
00204 
00205     $query .=self::$where_query;
00206     $query .=' ORDER BY ' .(!tep_not_null($orderby)? '  c.sort_order, cd.categories_name  ASC ' : $orderby) ;
00207     if($limit!='0')
00208       $query .=' LIMIT '.(!tep_not_null($limit)? '50' : $limit) ;
00209 
00210     return $query;
00211   }

static categorieData::get_categories ( categories_array = '',
parent_id = '0',
indent = '' 
) [static]

Construction d'un select sur les catégories actives.

Definition at line 426 of file driver.categorie.php.

00426                                                                                               {
00427   global $languages_id;
00428   if (!is_array($categories_array)) $categories_array = array();
00429   $categories_query = tep_db_query("select c.categories_id, cd.categories_name from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where parent_id = '" . (int)$parent_id . "' and c.categories_status='1' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name");
00430   while ($categories = tep_db_fetch_array($categories_query)) {
00431     $categories_array[] = array('id' => $categories['categories_id'], 'text' => $indent . $categories['categories_name']);
00432 
00433     if ($categories['categories_id'] != $parent_id) $categories_array = tep_get_categories($categories_array, $categories['categories_id'], $indent . '  ');
00434   }
00435 
00436   return $categories_array;
00437 }

static categorieData::get_count_content_in_category ( category_id  )  [static]

Return the number of products and category child in a category TABLES: products, products_to_categories, categories.

Definition at line 342 of file driver.categorie.php.

00342                                                                      {
00343     $products_count = 0;
00344     $DB=Database::getInstance();
00345 
00346     $products_query = $DB->query("select count(c.content_id) as total from " . TABLE_CONTENT . " c ,  " . TABLE_CONTENT_TO_CATEGORIES . " c2c where c.content_id = c2c.content_id and c2c.categories_id = '" .  (int)$category_id . "' and c.content_status='1' ");
00347 
00348     if($products_query->__get('numRows')>0 ) $products = $products_query->fetchAssoc();
00349     else $products['total']= 0;
00350     $products_count += $products['total'];
00351 
00352     if(!isset(self::$object_data[$category_id]) || !self::get_item($category_id)) return false;
00353     self::$object_data[$category_id]->count_products=(int)$products_count;
00354 
00355     self::add_where_query(" AND parent_id = '" . (int)$category_id . "' ");
00356     $db_list=self::get_query('','','',array('limit'=>'30'));
00357 
00358     foreach($db_list as $cat)
00359       if($cat->key !=(int)$category_id && (int)$category_id ==$cat->parent_id) {
00360         $products_count +=(isset($cat->count_products) ? $cat->count_products : self::get_count_products_in_category($cat->categories_id) );
00361       }
00362 
00363     return $products_count;
00364   }

static categorieData::get_count_products_in_category ( category_id,
include_inactive = false 
) [static]

Return the number of products and category child in a category TABLES: products, products_to_categories, categories.

Definition at line 309 of file driver.categorie.php.

Referenced by get_count_content_in_category().

00309                                                                                                  {
00310 
00311 //     if(isset(self::$object_data[$category_id]->count_products)) return self::$object_data[$category_id]->count_products;
00312 
00313     $products_count = 0;
00314     $DB=Database::getInstance();
00315     if ($include_inactive == true) {
00316       $products_query = $DB->query("select count(p.products_id) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$category_id . "'");
00317     } else {
00318       $products_query = $DB->query("select count(p.products_id) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p.products_status = '1' and p2c.categories_id = '" .(int) $category_id . "' ");
00319     }
00320     if($products_query->__get('numRows')>0 ) $products = $products_query->fetchAssoc();
00321     else $products['total']= 0;
00322     $products_count += $products['total'];
00323 
00324     if(!isset(self::$object_data[$category_id]) || !self::get_item($category_id)) return false;
00325     self::$object_data[$category_id]->count_products=(int)$products_count;
00326 
00327     self::add_where_query(" AND parent_id = '" . (int)$category_id . "' ");
00328     $db_list=self::get_query('','','',array('limit'=>'30'));
00329 
00330     foreach($db_list as $cat)
00331       if($cat->key !=(int)$category_id && (int)$category_id ==$cat->parent_id) {
00332         $products_count +=(isset($cat->count_products) ? $cat->count_products : self::get_count_products_in_category($cat->categories_id) );
00333       }
00334 
00335     return $products_count;
00336   }

static categorieData::get_has_category_subcategories ( category_id  )  [static]

Return false if not the category has subcategories or nbr category.

Definition at line 369 of file driver.categorie.php.

00369                                                                       {
00370 
00371     self::add_where_query(" AND  parent_id = '" . (int)$category_id . "' ");
00372     $db_list=self::get_query();
00373 
00374     if (($count=count($db_list)) &&  $count > 0)  return $count;
00375     else  return 0;
00376 
00377   }

static categorieData::get_item ( id  )  [static]

Alias unique ID.

Parameters:
$id int

Definition at line 246 of file driver.categorie.php.

00246                                       {
00247     self::reset_query();
00248     $db_list=self::get_query($id);
00249 
00250     if(is_numeric($id) && isset($db_list[(int)$id])){
00251       return $db_list[$id];
00252     }else{
00253       $db_list=self::get_query('',$id);
00254       foreach($db_list as $item)
00255         if((string)$id==(string)$item->name)return $item;
00256     }
00257     return false;
00258   }

static categorieData::get_parent_categories ( &$  categories,
categories_id 
) [static]

Recursively go through the categories and retreive all parent categories IDs TABLES: categories.

Definition at line 383 of file driver.categorie.php.

00383                                                                              {
00384 
00385   if(!isset(self::$object_data[$categories_id]->parent_array)) {
00386     $db_list=self::get_query((int)$categories_id);
00387     foreach($db_list as $cats) {
00388       if ($cats->parent_id == 0) return true;
00389       $categories[sizeof($categories)] = $cats->parent_id;
00390       if ($cats->parent_id != $categories_id) {
00391         self::get_parent_categories($categories, $cats->parent_id);
00392       }
00393     }
00394 //     self::$object_data[$categories_id]->parent_array=$categories;
00395   } else  $categories=self::$object_data[$categories_id]->parent_array;
00396 
00397 
00398 //     $parent_categories_query = tep_db_query("select parent_id from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$categories_id . "' ");
00399 //     while ($parent_categories = tep_db_fetch_array($parent_categories_query)) {
00400 //       if ($parent_categories['parent_id'] == 0) return true;
00401 //       $categories[sizeof($categories)] = $parent_categories['parent_id'];
00402 //       if ($parent_categories['parent_id'] != $categories_id) {
00403 //      self::tep_get_parent_categories($categories, $parent_categories['parent_id']);
00404 //       }
00405 //     }
00406 
00407   }

categorieData::get_path ( current_category_id = '',
value = false 
) [static]

Generate a path to categories.

Parameters:
$current_category_id int cat ID
$value bool si false, sortie string "cPath=1_3" si true, sortie string "1_3"

Definition at line 266 of file driver.categorie.php.

00266                                                                           {
00267       global $cPath_array;
00268 
00269       if (tep_not_null($current_category_id)) {
00270         $cp_size = sizeof($cPath_array);
00271         if ($cp_size == 0) {
00272           $cPath_new = $current_category_id;
00273         } else {
00274           $cPath_new = '';
00275           $last_category_query = tep_db_query("select parent_id from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$cPath_array[($cp_size-1)] . "'");
00276           $last_category = tep_db_fetch_array($last_category_query);
00277 
00278           $current_category_query = tep_db_query("select parent_id from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$current_category_id . "'");
00279           $current_category = tep_db_fetch_array($current_category_query);
00280 
00281           if ($last_category['parent_id'] == $current_category['parent_id']) {
00282             for ($i=0; $i<($cp_size-1); $i++) {
00283               $cPath_new .= '_' . $cPath_array[$i];
00284             }
00285           } else {
00286             for ($i=0; $i<$cp_size; $i++) {
00287               $cPath_new .= '_' . $cPath_array[$i];
00288             }
00289           }
00290           $cPath_new .= '_' . $current_category_id;
00291 
00292           if (substr($cPath_new, 0, 1) == '_') {
00293             $cPath_new = substr($cPath_new, 1);
00294           }
00295         }
00296       } else {
00297         $cPath_new = implode('_', $cPath_array);
00298       }
00299 
00300     if ($value) return 'cPath=' . $cPath_new;
00301     else return $cPath_new;
00302   }

static categorieData::get_query ( id = '',
search = '',
exclude = '',
option = '' 
) [static]

Appel item.

Parameters:
$id int l'Id
$search string content_name le nom du titre
$exclude array tableau d'exclusion de nom
$option array option

soit id soit sherach name key

Definition at line 225 of file driver.categorie.php.

Referenced by get_count_content_in_category(), get_count_products_in_category(), get_has_category_subcategories(), get_item(), and get_parent_categories().

00225                                                                              {
00226     global $languages_id;
00227 
00228     self::start();
00229     $DB=Database::getInstance();
00230     self::$lg_id=(int)$languages_id;
00231     $search=tep_db_prepare_input($search);
00232 
00234     self::add_where_query((tep_not_null($id) && is_numeric($id) ? " AND c.categories_id = '" . (int)$id . "' ": (!empty($search)?" AND cd.categories_name LIKE '%" . tep_db_input($search) . "%' ":'') ));
00235     $sql=self::cstr_query( (isset($option['orderby'])?(string)$option['orderby']:''),(isset($option['limit'])?(int)$option['limit']:''),(array)@$option) ;
00236 
00237     $content_query = $DB->query($sql);
00238     self::reset_query();
00239     return self::statment_query($content_query,$exclude,$search);
00240   }

static categorieData::get_subcategories ( &$  subcategories_array,
parent_id = 0 
) [static]

Return all subcategory IDs.

Recursivite TABLES: categories

Definition at line 414 of file driver.categorie.php.

00414                                                                                 {
00415   $subcategories_query = tep_db_query("select categories_id from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$parent_id . "' and categories_status='1' ");
00416   while ($subcategories = tep_db_fetch_array($subcategories_query)) {
00417     $subcategories_array[sizeof($subcategories_array)] = $subcategories['categories_id'];
00418     if ($subcategories['categories_id'] != $parent_id)
00419       tep_get_subcategories($subcategories_array, $subcategories['categories_id']);
00420   }
00421 }

static categorieData::in_cache (  )  [static, private]

Appel et recup des element du cache.

Definition at line 148 of file driver.categorie.php.

00148                                     {
00149     return implode("," ,self::$cache);
00150   }

categorieData::reset_query (  )  [static, protected]

Definition at line 191 of file driver.categorie.php.

Referenced by get_item(), and get_query().

00191 { self::$where_query=''; }

static categorieData::resetCacheId ( id  )  [static]

delet item in cache

Parameters:
$id integer id cat

Definition at line 130 of file driver.categorie.php.

00130                                           {
00131     foreach(self::$cache as $k=>$v)
00132       if($v==$id) {
00133         unset(self::$cache[$k]);
00134     }
00135   }

static categorieData::start (  )  [static]

Definition at line 119 of file driver.categorie.php.

Referenced by get_query().

00119                                 {
00120     global $languages_id;
00121     self::$lg_id=(int)$languages_id;
00122     $DB=Database::getInstance();
00123     self::$obj_language = $DB->query("select code from " . TABLE_LANGUAGES . " where languages_id='" .self::$lg_id . "'");
00124   }

static categorieData::statment_query ( content_query,
exclude = '',
search = '' 
) [static, protected]

Prepa donnée sortie.

Parameters:
$content_query 
$exclude array
$search string

Definition at line 158 of file driver.categorie.php.

Referenced by get_query().

00158                                                                                  {
00159 
00160     $display_lang=self::$obj_language->fetchAssoc();
00161     if (empty($exclude))$exclude=array();
00162     $tabl=$res=array();
00163     while ($content = $content_query->fetchAssoc()) {
00164       if(count(self::$cache)>0 && in_array($content['categories_id'],self::$cache) ) $tabl[$content['categories_id']]=self::$object_data[$content['categories_id']];
00165       elseif (!in_array($content['categories_name'],$exclude)) {
00166         $res=$content;
00167         $res['href']=tep_href_link(FILENAME_PRODUCT_INFO,'categories_id=' . $content['categories_id'] . '&amp;language=' . $display_lang['code']);
00168         $res['key']=$content['categories_id'];
00169         $res['id']=$content['categories_id'];
00170         $res['title']=$content['categories_name'];
00171         $res['name']=$content['categories_name'];
00172 
00173         $res=categorie::get_option_data($res);
00174 
00175         self::$object_data[$content['categories_id']]=$tabl[$content['categories_id']]=new objectInfo($res);
00176         self::add_cache($content['categories_id']);
00177       }
00178     }
00179     return $tabl;
00180   }


Member Data Documentation

categorieData::$array_data = array() [static]

array cache

Definition at line 111 of file driver.categorie.php.

categorieData::$cache = array() [static]

array

Definition at line 106 of file driver.categorie.php.

categorieData::$lg_id [static]

int

Definition at line 102 of file driver.categorie.php.

categorieData::$obj_language [static]

obj res db

Definition at line 104 of file driver.categorie.php.

categorieData::$object_data [static]

object cache

Definition at line 109 of file driver.categorie.php.

categorieData::$where_query = '' [static, private]

string

Definition at line 114 of file driver.categorie.php.


The documentation for this class was generated from the following file: