function display($tpl = null)
 {
     $this->loadHelper('html');
     $this->loadHelper('permissions');
     if (!class_exists('shopFunctionsF')) {
         require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
     }
     $model = VmModel::getModel();
     $layoutName = $this->getLayout();
     $task = JRequest::getWord('task', $layoutName);
     $this->task = $task;
     $this->perms = Permissions::getInstance();
     // to add in vmview ?
     $multivendor = Vmconfig::get('multix', 'none');
     $this->multiX = $multivendor !== 'none' && $multivendor != '' ? true : false;
     if ($layoutName == 'edit') {
         $this->loadHelper('shopfunctions');
         $category = $model->getCategory('', false);
         if (isset($category->category_name)) {
             $name = $category->category_name;
         } else {
             $name = '';
         }
         $this->SetViewTitle('CATEGORY', $name);
         $model->addImages($category);
         if ($category->virtuemart_category_id) {
             $this->relationInfo = $model->getRelationInfo($category->virtuemart_category_id);
         }
         $this->parent = $model->getParentCategory($category->virtuemart_category_id);
         $this->jTemplateList = ShopFunctions::renderTemplateList(JText::_('COM_VIRTUEMART_CATEGORY_TEMPLATE_DEFAULT'));
         if (!class_exists('VirtueMartModelConfig')) {
             require JPATH_VM_ADMINISTRATOR . '/models' . DS . 'config.php';
         }
         $this->productLayouts = VirtueMartModelConfig::getLayoutList('productdetails', $category->category_product_layout, 'category_product_layout');
         $this->categoryLayouts = VirtueMartModelConfig::getLayoutList('category', $category->category_layout, 'categorylayout');
         // front autoset parent category
         if (!$category->virtuemart_category_id) {
             $this->parent->virtuemart_category_id = jRequest::getInt('category_parent_id', 0);
         }
         //Nice fix by Joe, the 4. param prevents setting an category itself as child
         // Note Studio42, the fix is not suffisant, you can set the category in a children and get infinit loop in router for eg.
         $this->categorylist = ShopFunctions::categoryListTree(array($this->parent->virtuemart_category_id), 0, 0, (array) $category->virtuemart_category_id);
         if (Vmconfig::get('multix', 'none') !== 'none') {
             $this->vendorList = ShopFunctions::renderVendorList($category->virtuemart_vendor_id, false);
         }
         $this->category = $category;
         $this->addStandardEditViewCommands($category->virtuemart_category_id, $category);
     } else {
         $category_id = JRequest::getInt('filter_category_id');
         if (JRequest::getWord('format', '') === 'raw') {
             $tpl = 'results';
         } else {
             $this->SetViewTitle('CATEGORY_S');
             $this->addStandardDefaultViewCommands();
             $this->categorylist = ShopFunctions::categoryListTreeLoop((array) $category_id, 0, 0);
             if ($this->multiX && $this->adminVendor == 1) {
                 JToolBarHelper::custom('toggle.shared.1', 'publish', 'yes', JText::_('COM_VIRTUEMART_SHARED'), true);
                 JToolBarHelper::custom('toggle.shared.0', 'unpublish', 'no', JText::_('COM_VIRTUEMART_SHARED'), true);
             }
         }
         $this->catmodel = $model;
         $this->addStandardDefaultViewLists($model, 'category_name');
         $this->categories = $model->getCategoryTree($category_id, 0, false, $this->lists['search']);
         $this->pagination = $model->getPagination();
         //we need a function of the FE shopfunctions helper to cut the category descriptions
         jimport('joomla.filter.output');
     }
     parent::display($tpl);
     if ($tpl === 'results') {
         echo $this->AjaxScripts();
     }
 }
Exemple #2
0
 /**
  * Creates structured option fields for all categories
  *
  * @todo: Connect to vendor data
  * @author RolandD, Max Milbers, jseros
  * @param array 	$selectedCategories All category IDs that will be pre-selected
  * @param int 		$cid 		Internally used for recursion
  * @param int 		$level 		Internally used for recursion
  * @return string 	$category_tree HTML: Category tree list
  */
 public static function categoryListTree($selectedCategories = array(), $ispublish = 0, $cid = 0, $level = 0, $disabledFields = array())
 {
     //self::$counter++;
     $publish = false;
     if ($ispublish == 1) {
         $publish = true;
     }
     static $categoryTree = '';
     $virtuemart_vendor_id = 1;
     // 		vmSetStartTime('getCategories');
     $categoryModel = VmModel::getModel('category');
     $level++;
     $categoryModel->_noLimit = TRUE;
     $app = JFactory::getApplication();
     $records = $categoryModel->getCategories($publish, $cid);
     // 		vmTime('getCategories','getCategories');
     $selected = "";
     if (!empty($records)) {
         foreach ($records as $key => $category) {
             $childId = $category->category_child_id;
             if ($childId != $cid) {
                 if (in_array($childId, $selectedCategories)) {
                     $selected = 'selected=\\"selected\\"';
                 } else {
                     $selected = '';
                 }
                 $disabled = '';
                 if (in_array($childId, $disabledFields)) {
                     $disabled = 'disabled="disabled"';
                 }
                 if ($disabled != '' && stristr($_SERVER['HTTP_USER_AGENT'], 'msie')) {
                     //IE7 suffers from a bug, which makes disabled option fields selectable
                 } else {
                     $categoryTree .= '<option ' . $selected . ' ' . $disabled . ' value="' . $childId . '">';
                     $categoryTree .= str_repeat(' - ', $level - 1);
                     $categoryTree .= $category->category_name . '</option>';
                 }
             }
             if ($categoryModel->hasChildren($childId)) {
                 $categoryTree .= ShopFunctions::categoryListTreeLoop($selectedCategories, $childId, $level, $disabledFields);
             }
         }
     }
     return $categoryTree;
 }