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();
 }
 public function index($setting)
 {
     if (!class_exists('VQMod')) {
         $this->_renderWarning('Mega Filter PRO to work properly requires an installed VQMod.', true);
         return;
     }
     if (version_compare(VQMod::$_vqversion, '2.5.1', '<')) {
         $this->_renderWarning('Mega Filter PRO to work properly requires VQMod in version 2.5.1 or later.<br />Your version of VQMod is too old. Please upgrade it to the latest version.', true);
         return;
     }
     if (!isset($setting['_idx'])) {
         $this->_renderWarning('There is a conflict Mega Filter PRO with your template or other extension - please contact us.');
         return;
     }
     if (empty($setting[$setting['_idx']]['status'])) {
         return;
     }
     if (empty($setting['base_attribs'])) {
         $setting['base_attribs'] = empty($setting[$setting['_idx']]['base_attribs']) ? array() : $setting[$setting['_idx']]['base_attribs'];
     }
     if (empty($setting['attribs'])) {
         $setting['attribs'] = empty($setting[$setting['_idx']]['attribs']) ? array() : $setting[$setting['_idx']]['attribs'];
     }
     if (empty($setting['options'])) {
         $setting['options'] = empty($setting[$setting['_idx']]['options']) ? array() : $setting[$setting['_idx']]['options'];
     }
     if (empty($setting['filters'])) {
         $setting['filters'] = empty($setting[$setting['_idx']]['filters']) ? array() : $setting[$setting['_idx']]['filters'];
     }
     if (empty($setting['categories'])) {
         $setting['categories'] = empty($setting[$setting['_idx']]['categories']) ? array() : $setting[$setting['_idx']]['categories'];
     }
     /**
      * Ustawienia
      */
     $settings = $this->config->get('mega_filter_settings');
     /**
      * Sprawdź szablon
      */
     if (isset($setting[$setting['_idx']]['layout_id']) && is_array($setting[$setting['_idx']]['layout_id'])) {
         /**
          * Sprawdź czy zdefiniowano kategorię 
          */
         if (in_array($settings['layout_c'], $setting[$setting['_idx']]['layout_id']) && isset($this->request->get['path'])) {
             /**
              * Pokaż w kategoriach 
              */
             if (!empty($setting[$setting['_idx']]['category_id'])) {
                 $categories = explode('_', $this->request->get['path']);
                 if (!empty($setting[$setting['_idx']]['category_id_with_childs'])) {
                     $is = false;
                     foreach ($categories as $category_id) {
                         if (in_array($category_id, $setting[$setting['_idx']]['category_id'])) {
                             $is = true;
                             break;
                         }
                     }
                     if (!$is) {
                         return;
                     }
                 } else {
                     $category_id = end($categories);
                     if (!in_array($category_id, $setting[$setting['_idx']]['category_id'])) {
                         return false;
                     }
                 }
             }
             /**
              * Ukryj w kategoriach 
              */
             if (!empty($setting[$setting['_idx']]['hide_category_id'])) {
                 $categories = explode('_', $this->request->get['path']);
                 if (!empty($setting[$setting['_idx']]['hide_category_id_with_childs'])) {
                     foreach ($categories as $category_id) {
                         if (in_array($category_id, $setting[$setting['_idx']]['hide_category_id'])) {
                             return;
                         }
                     }
                 } else {
                     $category_id = array_pop($categories);
                     if (in_array($category_id, $setting[$setting['_idx']]['hide_category_id'])) {
                         return;
                     }
                 }
             }
         }
     }
     /**
      * Sprawdź sklep 
      */
     if (isset($setting[$setting['_idx']]['store_id']) && is_array($setting[$setting['_idx']]['store_id']) && !in_array($this->config->get('config_store_id'), $setting[$setting['_idx']]['store_id'])) {
         return;
     }
     /**
      * Sprawdź grupę
      */
     if (!empty($setting[$setting['_idx']]['customer_groups'])) {
         $customer_group_id = $this->customer->isLogged() ? $this->customer->getGroupId() : $this->config->get('config_customer_group_id');
         if (!in_array($customer_group_id, $setting[$setting['_idx']]['customer_groups'])) {
             return;
         }
     }
     /**
      * Załaduj język 
      */
     $data = $this->language->load('module/mega_filter');
     /**
      * Ustaw tytuł 
      */
     if (isset($setting[$setting['_idx']]['title'][$this->config->get('config_language_id')])) {
         $data['heading_title'] = $setting[$setting['_idx']]['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'])) {
         $attributes = array();
     }
     if (!$attributes) {
         return;
     }
     $scheme_find = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'http://' : 'https://';
     $scheme_replace = $scheme_find == 'https://' ? 'http://' : 'https://';
     $mijo_shop = class_exists('MijoShop') ? true : false;
     $joo_cart = defined('JOOCART_SITE_URL') ? array('site_url' => str_replace($scheme_find, $scheme_replace, JOOCART_SITE_URL), 'main_url' => str_replace($scheme_find, $scheme_replace, $this->url->link('', '', 'SSL'))) : 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';
         $data['hide_container'] = true;
     }
     $data['direction'] = $this->language->get('direction');
     $data['ajaxInfoUrl'] = $this->url->link('module/mega_filter/ajaxinfo', '', 'SSL');
     $data['ajaxResultsUrl'] = $this->url->link('module/mega_filter/results', '', 'SSL');
     $data['ajaxCategoryUrl'] = $this->url->link('module/mega_filter/categories', '', 'SSL');
     $data['ajaxInfoUrl'] = str_replace($scheme_find, $scheme_replace, $data['ajaxInfoUrl']);
     $data['ajaxResultsUrl'] = str_replace($scheme_find, $scheme_replace, $data['ajaxResultsUrl']);
     $data['ajaxCategoryUrl'] = str_replace($scheme_find, $scheme_replace, $data['ajaxCategoryUrl']);
     $data['is_mobile'] = $is_mobile;
     $data['mijo_shop'] = $mijo_shop;
     $data['joo_cart'] = $joo_cart;
     $data['filters'] = $attributes;
     $data['settings'] = $settings;
     $data['params'] = $core->getParseParams();
     $data['price'] = $core->getMinMaxPrice();
     $data['_idx'] = $setting['_idx'];
     $data['_route'] = base64_encode($core->route());
     $data['_routeProduct'] = base64_encode('product/product');
     $data['_routeHome'] = base64_encode('common/home');
     $data['_position'] = $setting['position'];
     $data['getSymbolLeft'] = $this->currency->getSymbolLeft();
     $data['getSymbolRight'] = $this->currency->getSymbolRight();
     $data['requestGet'] = $this->request->get;
     $data['_horizontalInline'] = $setting['position'] == 'content_top' && !empty($setting[$setting['_idx']]['inline_horizontal']) ? true : false;
     $data['smp'] = array('isInstalled' => $this->config->get('smp_is_install'), 'disableConvertUrls' => $this->config->get('smp_disable_convert_urls'));
     $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 {
         //$this->document->addScript('catalog/view/javascript/mf/jquery-ui.min.js?v'.$data['_v']);
         $this->document->addScript('catalog/view/javascript/mf/iscroll.js?v' . $data['_v']);
         $this->document->addScript('catalog/view/javascript/mf/mega_filter.js?v' . $data['_v']);
         $this->document->addStyle('catalog/view/theme/default/stylesheet/mf/jquery-ui.min.css?v' . $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' . $data['_v']);
         } else {
             $this->document->addStyle('catalog/view/theme/default/stylesheet/mf/style.css?v' . $data['_v']);
         }
         $this->document->addStyle('catalog/view/theme/default/stylesheet/mf/style-2.css?v' . $data['_v']);
     }
     /**
      * Szablon 
      */
     if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/mega_filter.tpl')) {
         return $this->load->view($this->config->get('config_template') . '/template/module/mega_filter.tpl', $data);
     } else {
         return $this->load->view('default/template/module/mega_filter.tpl', $data);
     }
 }