Example #1
0
 public function index()
 {
     $include = '';
     if (!isset($this->_boxAttributes['showall'])) {
         $showall = 1;
     } else {
         $showall = $this->_boxAttributes['showall'];
         $include = isset($this->_boxAttributes['categoryIds']) ? explode(',', $this->_boxAttributes['categoryIds']) : array();
     }
     $showcount = isset($this->_boxAttributes['showcount']) && $this->_boxAttributes['showcount'] == 1 ? 1 : 0;
     $hideempty = isset($this->_boxAttributes['hideempty']) && $this->_boxAttributes['hideempty'] == 1 ? 1 : 0;
     if (($categories = $this->registry->cache->load('categories')) === FALSE) {
         $categories = App::getModel('CategoriesBox')->getCategoriesTree();
         $this->registry->cache->save('categories', $categories);
     }
     $path = App::getModel('categoriesbox')->getCurrentCategoryPath($this->getParam());
     if ($this->registry->router->getCurrentController() == 'productcart') {
         $path = App::getModel('categoriesbox')->getCategoryPathForProductById($this->registry->core->getParam());
         foreach ($categories as $key => $category) {
             if (in_array($category['id'], $path)) {
                 $categories[$key]['current'] = 1;
             }
             foreach ($category['children'] as $k => $subcategory) {
                 if (in_array($subcategory['id'], $path)) {
                     $categories[$key]['children'][$k]['current'] = 1;
                 }
             }
         }
     }
     if (Session::getActiveForceLogin() == 1 && Session::getActiveClientid() == 0) {
         $categories = array();
     }
     $this->total = count($categories);
     $this->registry->template->assign('categories', $categories);
     $this->registry->template->assign('showcount', $showcount);
     $this->registry->template->assign('path', $path);
     $this->registry->template->assign('showall', $showall);
     $this->registry->template->assign('include', $include);
     $this->registry->template->assign('hideempty', $hideempty);
     $this->registry->template->assign('current', (int) $this->registry->core->getParam());
     return $this->registry->template->fetch($this->loadTemplate('index.tpl'));
 }