예제 #1
0
 protected function getOptions()
 {
     //check com_vituemart existed
     $path = JPATH_ADMINISTRATOR . '/components/com_virtuemart';
     if (!is_dir($path) || !file_exists(JPATH_ADMINISTRATOR . '/components/com_virtuemart/helpers/config.php')) {
         $this->options[] = JHtml::_('select.option', '', JText::_('COM_VIRTUEMART_NOT_EXIST'));
     } else {
         // Initialize variables
         require_once JPATH_ADMINISTRATOR . '/components/com_virtuemart/helpers/config.php';
         require_once JPATH_ADMINISTRATOR . '/components/com_virtuemart/models/category.php';
         VmConfig::loadConfig();
         $categoryModel = new VirtueMartModelCategory();
         $categoryModel->_noLimit = true;
         $categories = $categoryModel->getCategories();
         if (count($categories)) {
             // iterating
             $temp_options = array();
             foreach ($categories as $item) {
                 array_push($temp_options, array($item->virtuemart_category_id, $item->category_name, $item->category_parent_id));
             }
             foreach ($temp_options as $option) {
                 if ($option[2] == 0) {
                     $this->options[] = JHtml::_('select.option', $option[0], $option[1]);
                     $this->recursive_options($temp_options, 1, $option[0]);
                 }
             }
         }
     }
     return $this->options;
 }
 /**
  * @param XmapDisplayerInterface $xmap
  * @param stdCLass $parent
  * @param array $params
  * @param int $catid
  */
 public static function getCategoryTree($xmap, stdClass $parent, array &$params, $catid = 0)
 {
     // TODO refactor
     if (!isset($urlBase)) {
         $urlBase = JURI::base();
     }
     $vendorId = 1;
     $children = VmModel::getModel('category')->getChildCategoryList($vendorId, $catid);
     $xmap->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 ($xmap->printNode($node) !== false) {
             self::getCategoryTree($xmap, $parent, $params, $row->virtuemart_category_id);
         }
     }
     $xmap->changeLevel(-1);
     if ($params['include_products'] && $catid != 0) {
         $products = self::$productModel->getProductsInCategory($catid);
         if ($params['include_product_images']) {
             self::$categoryModel->addImages($products, 1);
         }
         $xmap->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;
                     }
                 }
             }
             $xmap->printNode($node);
         }
         $xmap->changeLevel(-1);
     }
 }
예제 #3
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];
 }
예제 #4
0
 public function display($tpl = null)
 {
     $this->addHelperPath(JPATH_VM_ADMINISTRATOR . DS . 'helpers');
     require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
     //dont remove that file it is actually in every view
     $show_prices = VmConfig::get('show_prices', 1);
     if ($show_prices == '1') {
         if (!class_exists('calculationHelper')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'calculationh.php';
         }
     }
     /*
      * get the category
      * This only needs in order to avoid undefined variables
      */
     if (!class_exists('VirtueMartModelCategory')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'category.php';
     }
     $vendorId = 1;
     $jinput = JFactory::getApplication()->input;
     $categories = $jinput->get('virtuemart_category_id', array(), 'array');
     /*If there is only one category selected and is not zero, display children categories*/
     if (count($categories) == 1 && $categories[0] > 0) {
         $categoryId = $categories[0];
         $category_haschildren = true;
     } else {
         $categoryId = 0;
         $category_haschildren = false;
     }
     $categoryModel = new VirtueMartModelCategory();
     $category = $categoryModel->getCategory($categoryId);
     $category->haschildren = $category_haschildren;
     if ($category_haschildren) {
         $category->children = $categoryModel->getChildCategoryList($vendorId, $categoryId);
         $categoryModel->addImages($category->children);
     }
     /*
      * show base price variables
      */
     if (!class_exists('Permissions')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'permissions.php';
     }
     $showBasePrice = Permissions::getInstance()->check('admin');
     //todo add config settings
     /*
      * get the products from the cf model
      */
     $products = $this->get('ProductListing');
     $model = $this->getModel();
     $model->addImages($products);
     //add stock
     foreach ($products as $product) {
         $product->stock = $model->getStockIndicator($product);
     }
     //currency
     if ($products) {
         if (!class_exists('CurrencyDisplay')) {
             require_once JPATH_VM_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'currencydisplay.php';
         }
         $currency = CurrencyDisplay::getInstance();
         $this->assignRef('currency', $currency);
     }
     //rating
     if (method_exists('VmModel', 'getModel')) {
         $ratingModel = VmModel::getModel('ratings');
         $showRating = $ratingModel->showRating();
     }
     //Pagination
     $u = JFactory::getURI();
     $query = $u->getQuery();
     //$paginationAction=JRoute::_(JURI::base().'index.php?virtuemart_category_id[0]=3&virtuemart_category_id[1]=1&virtuemart_category_id[2]=5&option=com_customfilters&view=products');
     $pagination = $model->getPagination(true);
     //my model's pagination
     //get some component parameters
     $params = JComponentHelper::getParams('com_customfilters');
     $perRow = $params->get('prod_per_row', 3);
     /*
      * Get the order by list
      */
     $orderByList = $this->get('OrderByList');
     $search = null;
     $this->assignRef('show_prices', $show_prices);
     $this->assignRef('orderByList', $orderByList);
     $this->assignRef('products', $products);
     $this->assignRef('category', $category);
     $this->assignRef('showBasePrice', $showBasePrice);
     $this->assignRef('show_prices', $show_prices);
     $this->assignRef('vmPagination', $pagination);
     $this->assignRef('paginationAction', $paginationAction);
     $this->assignRef('perRow', $perRow);
     $this->assignRef('search', $search);
     $this->assignRef('showRating', $showRating);
     $template = VmConfig::get('vmtemplate', 'default');
     if (is_dir(JPATH_THEMES . DS . $template)) {
         $mainframe = JFactory::getApplication();
         $mainframe->set('setTemplate', $template);
     }
     //$this->setLayoutExt('com_virtuemart');
     $this->_prepareDocument();
     //
     parent::display($tpl);
 }
예제 #5
0
 function getVmCats()
 {
     if (!class_exists('VirtueMartModelConfig')) {
         require JPATH_VM_ADMINISTRATOR . 'models/config.php';
     }
     if (!class_exists('VmHTML')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'html.php';
     }
     if (!class_exists('shopFunctionsF')) {
         require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
     }
     if (!class_exists('VirtueMartModelCategory')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'category.php';
     }
     JRequest::setVar('limit', 9999999);
     JRequest::setVar('limitstart', 0);
     $model = new VirtueMartModelCategory();
     $model->_limitstart = 0;
     $model->_limit = 999999;
     $model->_noLimit = true;
     $categories = $model->getCategoryTree(0, 0, false, '');
     $re = array();
     foreach ($categories as $cat) {
         $re[$cat->virtuemart_category_id] = $cat;
     }
     $all = array();
     foreach ($categories as $cat) {
         $all[$cat->virtuemart_category_id] =& $cat->category_name;
         $current =& $all[$cat->virtuemart_category_id];
         if (!empty($cat->category_parent_id)) {
             if (isset($re[$cat->category_parent_id])) {
                 $this->recurseVmCat($re[$cat->category_parent_id], $current, $all, $re);
             }
         }
     }
     return $all;
 }