Esempio n. 1
0
 /**
  * Get the list of child categories for a given category, is cached
  *
  * @param int $virtuemart_category_id Category id to check for child categories
  * @return object List of objects containing the child categories
  *
  */
 public function getChildCategoryList($vendorId, $virtuemart_category_id, $selectedOrdering = null, $orderDir = null, $useCache = true)
 {
     if (empty($this) or get_class($this) != 'VirtueMartModelCategory') {
         $useCache = false;
     }
     if ($selectedOrdering === null) {
         if ($useCache) {
             $selectedOrdering = $this->_selectedOrdering;
         } else {
             $selectedOrdering = VmConfig::get('browse_cat_orderby_field', 'category_name');
         }
     }
     if (trim($selectedOrdering) == 'c.ordering') {
         $selectedOrdering = 'c.ordering,category_name';
     }
     if (!in_array($selectedOrdering, self::$_validOrderingFields)) {
         $selectedOrdering = 'c.ordering,category_name';
     }
     if ($orderDir === null) {
         if ($useCache) {
             $orderDir = $this->_selectedOrderingDir;
         } else {
             $orderDir = VmConfig::get('cat_brws_orderby_dir', 'ASC');
         }
     }
     $validOrderingDir = array('ASC', 'DESC');
     if (!in_array(strtoupper($orderDir), $validOrderingDir)) {
         $orderDir = 'ASC';
     }
     static $_childCategoryList = array();
     $key = (int) $vendorId . '_' . (int) $virtuemart_category_id . $selectedOrdering . $orderDir . VmConfig::$vmlang;
     //We have here our internal key to preven calling of the cache
     if (!array_key_exists($key, $_childCategoryList)) {
         vmSetStartTime('com_virtuemart_cats');
         if ($useCache) {
             $cache = JFactory::getCache('com_virtuemart_cats', 'callback');
             $cache->setCaching(true);
             vmdebug('Calling cache getChildCategoryListObject');
             $_childCategoryList[$key] = $cache->call(array('VirtueMartModelCategory', 'getChildCategoryListObject'), $vendorId, $virtuemart_category_id, $selectedOrdering, $orderDir, VmConfig::$vmlang);
         } else {
             $_childCategoryList[$key] = VirtueMartModelCategory::getChildCategoryListObject($vendorId, $virtuemart_category_id, $selectedOrdering, $orderDir, VmConfig::$vmlang);
         }
         vmTime('Time to load cats ' . (int) $useCache, 'com_virtuemart_cats');
     }
     return $_childCategoryList[$key];
 }