Esempio n. 1
0
 /** Virtuemart support */
 public static function getCategoryTree($osmap, $parent, &$params, $catid = 0)
 {
     if (!isset($urlBase)) {
         $urlBase = JURI::base();
     }
     $vendorId = 1;
     $m = VirtueMartModelCategory::getInstance('Category', 'VirtueMartModel');
     $cache = JFactory::getCache('com_virtuemart', 'callback');
     $cache->setCaching(true);
     $children = $cache->call(array($m, 'getChildCategoryList'), $vendorId, $catid);
     if (!empty($children)) {
         $osmap->changeLevel(1);
         foreach ($children as $row) {
             $node = new stdclass();
             $node->id = $parent->id;
             $node->uid = $parent->uid . 'c' . $row->virtuemart_category_id;
             $node->browserNav = $parent->browserNav;
             $node->name = stripslashes($row->category_name);
             $node->priority = $params['cat_priority'];
             $node->changefreq = $params['cat_changefreq'];
             $node->expandible = true;
             $node->link = 'index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $row->virtuemart_category_id . '&Itemid=' . $parent->id;
             if ($osmap->printNode($node) !== FALSE) {
                 self::getCategoryTree($osmap, $parent, $params, $row->virtuemart_category_id);
             }
         }
     }
     $osmap->changeLevel(-1);
     if ($params['include_products'] && $catid != 0) {
         $products = self::$productModel->getProductsInCategory($catid);
         if ($params['include_product_images']) {
             self::$categoryModel->addImages($products, 1);
         }
         $osmap->changeLevel(1);
         foreach ($products as $row) {
             $node = new stdclass();
             $node->id = $parent->id;
             $node->uid = $parent->uid . 'c' . $row->virtuemart_category_id . 'p' . $row->virtuemart_product_id;
             $node->browserNav = $parent->browserNav;
             $node->priority = $params['prod_priority'];
             $node->changefreq = $params['prod_changefreq'];
             $node->name = $row->product_name;
             $node->modified = strtotime($row->modified_on);
             $node->expandible = false;
             $node->link = 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $row->virtuemart_product_id . '&virtuemart_category_id=' . $row->virtuemart_category_id . '&Itemid=' . $parent->id;
             if ($params['include_product_images']) {
                 foreach ($row->images as $image) {
                     if (isset($image->file_url)) {
                         $imagenode = new stdClass();
                         $imagenode->src = $urlBase . $image->file_url_thumb;
                         $imagenode->title = $row->product_name;
                         $imagenode->license = $params['product_image_license_url'];
                         $node->images[] = $imagenode;
                     }
                 }
             }
             $osmap->printNode($node);
         }
         $osmap->changeLevel(-1);
     }
 }