コード例 #1
0
 public function load($cid)
 {
     static $instances = array();
     if (!isset($instances[$cid])) {
         $this->_item = (object) AceShop::get('db')->getRecord($cid);
         if (!$this->_item) {
             return $this->onLoadArticleError($cid);
         }
         $this->_item->category_id = AceShop::get('db')->getProductCategoryId($cid);
         $link = 'index.php?opiton=com_aceshop&route=product/product&product_id=' . $this->_item->product_id . '&path=' . $this->_item->category_id;
         $this->_item->permalink = $this->prepareLink($link);
         $instances[$cid] = $this->_item;
     }
     $this->_item = $instances[$cid];
     return $this;
 }
コード例 #2
0
 protected function index($setting)
 {
     if (empty($setting['base_attribs'])) {
         $setting['base_attribs'] = array();
     }
     if (empty($setting['attribs'])) {
         $setting['attribs'] = array();
     }
     if (empty($setting['options'])) {
         $setting['options'] = array();
     }
     if (empty($setting['filters'])) {
         $setting['filters'] = array();
     }
     /**
      * Ustawienia
      */
     $settings = $this->config->get('mega_filter_settings');
     /**
      * Sprawdź szablon
      */
     if (isset($setting['layout_id']) && is_array($setting['layout_id'])) {
         /**
          * Sprawdź czy zdefiniowano kategorię 
          */
         if (in_array($settings['layout_c'], $setting['layout_id']) && isset($this->request->get['path'])) {
             /**
              * Pokaż w kategoriach 
              */
             if (!empty($setting['category_id'])) {
                 $categories = explode('_', $this->request->get['path']);
                 if (!empty($setting['category_id_with_childs'])) {
                     $is = false;
                     $category_id = end($categories);
                     foreach ($this->db->query("SELECT * FROM `" . DB_PREFIX . "category_path` WHERE `category_id`='" . $category_id . "'")->rows as $row) {
                         if (isset($row['path'])) {
                             $categories[] = $row['path'];
                         } else {
                             if (isset($row['path_id'])) {
                                 $categories[] = $row['path_id'];
                             }
                         }
                     }
                     foreach ($categories as $category_id) {
                         if (in_array($category_id, $setting['category_id'])) {
                             $is = true;
                             break;
                         }
                     }
                     if (!$is) {
                         return;
                     }
                 } else {
                     $category_id = end($categories);
                     if (!in_array($category_id, $setting['category_id'])) {
                         return false;
                     }
                 }
             }
             /**
              * Ukryj w kategoriach 
              */
             if (!empty($setting['hide_category_id'])) {
                 $categories = explode('_', $this->request->get['path']);
                 if (!empty($setting['hide_category_id_with_childs'])) {
                     foreach ($categories as $category_id) {
                         if (in_array($category_id, $setting['hide_category_id'])) {
                             return;
                         }
                     }
                 } else {
                     $category_id = array_pop($categories);
                     if (in_array($category_id, $setting['hide_category_id'])) {
                         return;
                     }
                 }
             }
         }
     }
     /**
      * Sprawdź sklep 
      */
     if (isset($setting['store_id']) && is_array($setting['store_id']) && !in_array($this->config->get('config_store_id'), $setting['store_id'])) {
         return;
     }
     /**
      * Sprawdź grupę
      */
     if (!empty($setting['customer_groups'])) {
         $customer_group_id = $this->customer->isLogged() ? $this->customer->getCustomerGroupId() : $this->config->get('config_customer_group_id');
         if (!in_array($customer_group_id, $setting['customer_groups'])) {
             return;
         }
     }
     /**
      * Załaduj język 
      */
     $this->data = array_merge($this->data, $this->language->load('module/mega_filter'));
     /**
      * Ustaw tytuł 
      */
     if (isset($setting['title'][$this->config->get('config_language_id')])) {
         $this->data['heading_title'] = $setting['title'][$this->config->get('config_language_id')];
     }
     /**
      * Załaduj modele 
      */
     $this->load->model('module/mega_filter');
     //$t=microtime(true);
     $core = MegaFilterCore::newInstance($this, NULL);
     $cache = NULL;
     if (!empty($settings['cache_enabled'])) {
         $cache = 'idx.' . $setting['_idx'] . '.' . $core->cacheName();
     }
     /**
      * Lista atrybutów 
      */
     if (!$cache || NULL == ($attributes = $this->_getCache($cache))) {
         $attributes = $this->model_module_mega_filter->getAttributes($core, $setting['_idx'], $setting['base_attribs'], $setting['attribs'], $setting['options'], $setting['filters'], empty($setting['categories']) ? array() : $setting['categories']);
         if (!empty($settings['cache_enabled'])) {
             $this->_setCache($cache, $attributes);
         }
     }
     //echo microtime(true)-$t;
     /**
      * Pobierz klucze wg nazw 
      */
     $keys = $this->_keysByAttribs($attributes);
     /**
      * Aktualna trasa 
      */
     $route = isset($this->request->get['route']) ? $this->request->get['route'] : NULL;
     /**
      * Usuń listę branż dla widoku branż 
      */
     if (in_array($route, array('product/manufacturer', 'product/manufacturer/info')) && isset($keys['manufacturers'])) {
         unset($attributes[$keys['manufacturers']]);
     }
     if (in_array($route, array('product/search')) && empty($this->request->get['search']) && empty($this->request->get['tag']) && empty($this->request->get['filter_name'])) {
         $attributes = array();
     }
     if (!$attributes) {
         return;
     }
     $mijo_shop = class_exists('MijoShop') ? true : false;
     $ace_shop = class_exists('AceShop') ? true : false;
     $is_mobile = Mobile_Detect_MFP::create()->isMobile();
     if ($setting['position'] == 'content_top' && !empty($settings['change_top_to_column_on_mobile']) && $is_mobile) {
         $setting['position'] = 'column_left';
         $this->data['hide_container'] = true;
     }
     $this->data['ajaxInfoUrl'] = $this->parseUrl($this->url->link('module/mega_filter/ajaxinfo', '', 'SSL'));
     $this->data['ajaxResultsUrl'] = $this->parseUrl($this->url->link('module/mega_filter/results', '', 'SSL'));
     $this->data['ajaxCategoryUrl'] = $this->parseUrl($this->url->link('module/mega_filter/categories', '', 'SSL'));
     $this->data['is_mobile'] = $is_mobile;
     $this->data['mijo_shop'] = $mijo_shop;
     $this->data['ace_shop'] = $ace_shop;
     $this->data['filters'] = $attributes;
     $this->data['settings'] = $settings;
     $this->data['params'] = $core->getParseParams();
     $this->data['price'] = $core->getMinMaxPrice();
     $this->data['_idx'] = $setting['_idx'];
     $this->data['_route'] = base64_encode($core->route());
     $this->data['_routeProduct'] = base64_encode('product/product');
     $this->data['_routeHome'] = base64_encode('common/home');
     $this->data['_routeInformation'] = base64_encode('information/information');
     $this->data['_routeManufacturerList'] = base64_encode('product/manufacturer');
     $this->data['_position'] = $setting['position'];
     $this->data['_displayOptionsAs'] = $setting['position'] == 'content_top' && !empty($setting['display_options_as']) ? $setting['display_options_as'] : false;
     $this->data['smp'] = array('isInstalled' => $this->config->get('smp_is_install'), 'disableConvertUrls' => $this->config->get('smp_disable_convert_urls'));
     $this->data['_v'] = $this->config->get('mfilter_version') ? $this->config->get('mfilter_version') : '1';
     if ($mijo_shop) {
         MijoShop::getClass('base')->addHeader(JPATH_MIJOSHOP_OC . '/catalog/view/javascript/mf/iscroll.js', false);
         MijoShop::getClass('base')->addHeader(JPATH_MIJOSHOP_OC . '/catalog/view/javascript/mf/mega_filter.js', false);
         if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/stylesheet/mf/style.css')) {
             MijoShop::get()->addHeader(JPATH_MIJOSHOP_OC . '/catalog/view/theme/' . $this->config->get('config_template') . '/stylesheet/mf/style.css');
         } else {
             MijoShop::get()->addHeader(JPATH_MIJOSHOP_OC . '/catalog/view/theme/default/stylesheet/mf/style.css');
         }
         MijoShop::get()->addHeader(JPATH_MIJOSHOP_OC . '/catalog/view/theme/default/stylesheet/mf/style-2.css');
     } else {
         if ($ace_shop) {
             AceShop::getClass('base')->addHeader(JPATH_ACESHOP_OC . '/catalog/view/javascript/mf/iscroll.js', false);
             AceShop::getClass('base')->addHeader(JPATH_ACESHOP_OC . '/catalog/view/javascript/mf/mega_filter.js', false);
             if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/stylesheet/mf/style.css')) {
                 AceShop::get()->addHeader(JPATH_ACESHOP_OC . '/catalog/view/theme/' . $this->config->get('config_template') . '/stylesheet/mf/style.css');
             } else {
                 AceShop::get()->addHeader(JPATH_ACESHOP_OC . '/catalog/view/theme/default/stylesheet/mf/style.css');
             }
             AceShop::get()->addHeader(JPATH_ACESHOP_OC . '/catalog/view/theme/default/stylesheet/mf/style-2.css');
         } else {
             $this->document->addScript('catalog/view/javascript/mf/iscroll.js?v' . $this->data['_v']);
             $this->document->addScript('catalog/view/javascript/mf/mega_filter.js?v' . $this->data['_v']);
             if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/stylesheet/mf/style.css')) {
                 $this->document->addStyle('catalog/view/theme/' . $this->config->get('config_template') . '/stylesheet/mf/style.css?v' . $this->data['_v']);
             } else {
                 $this->document->addStyle('catalog/view/theme/default/stylesheet/mf/style.css?v' . $this->data['_v']);
             }
             $this->document->addStyle('catalog/view/theme/default/stylesheet/mf/style-2.css?v' . $this->data['_v']);
         }
     }
     /**
      * Szablon 
      */
     if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/mega_filter.tpl')) {
         $this->template = $this->config->get('config_template') . '/template/module/mega_filter.tpl';
     } else {
         $this->template = 'default/template/module/mega_filter.tpl';
     }
     $this->config->set('mfp_is_activated', '1');
     $this->render();
 }