Exemplo n.º 1
0
 protected function getInput()
 {
     if (!NNFrameworkFunctions::extensionInstalled('mijoshop')) {
         return '<fieldset class="alert alert-danger">' . JText::_('ERROR') . ': ' . JText::sprintf('NN_FILES_NOT_FOUND', JText::_('NN_MIJOSHOP')) . '</fieldset>';
     }
     $this->params = $this->element->attributes();
     $this->db = JFactory::getDBO();
     $group = $this->get('group', 'categories');
     $tables = $this->db->getTableList();
     if (!in_array($this->db->getPrefix() . 'mijoshop_' . ($group == 'products' ? 'product' : 'category'), $tables)) {
         return '<fieldset class="alert alert-danger">' . JText::_('ERROR') . ': ' . JText::sprintf('NN_TABLE_NOT_FOUND', JText::_('NN_MIJOSHOP')) . '</fieldset>';
     }
     $parameters = NNParameters::getInstance();
     $params = $parameters->getPluginParams('nnframework');
     $this->max_list_count = $params->max_list_count;
     require_once JPATH_ROOT . '/components/com_mijoshop/mijoshop/mijoshop.php';
     $this->store_id = (int) MijoShop::get('opencart')->get('config')->get('config_store_id');
     $this->language_id = (int) MijoShop::get('opencart')->get('config')->get('config_language_id');
     if (!is_array($this->value)) {
         $this->value = explode(',', $this->value);
     }
     $options = $this->{'get' . $group}();
     $size = (int) $this->get('size');
     $multiple = $this->get('multiple');
     if ($group == 'categories') {
         require_once JPATH_PLUGINS . '/system/nnframework/helpers/html.php';
         return nnHtml::selectlist($options, $this->name, $this->value, $this->id, $size, $multiple);
     }
     $attr = '';
     $attr .= ' size="' . (int) $size . '"';
     $attr .= $multiple ? ' multiple="multiple"' : '';
     return JHtml::_('select.genericlist', $options, $this->name, trim($attr), 'value', 'text', $this->value, $this->id);
 }
Exemplo n.º 2
0
	function init(&$parent)
	{
		$input = JFactory::getApplication()->input;

		$category_id = $input->getCmd('path', 0);
		if (strpos($category_id, '_'))
		{
			$category_id = end(explode('_', $category_id));
		}

		$parent->params->item_id = $input->getInt('product_id', 0);
		$parent->params->category_id = $category_id;
		$parent->params->id = ($parent->params->item_id) ? $parent->params->item_id : $parent->params->category_id;

		$view = $input->getCmd('view', '');
		if (empty($view))
		{
			$mijoshop = JPATH_ROOT . '/components/com_mijoshop/mijoshop/mijoshop.php';
			if (!file_exists($mijoshop))
			{
				return;
			}

			require_once($mijoshop);

			$route = $input->getString('route', '');
			$view = MijoShop::get('router')->getView($route);
		}

		$parent->params->view = $view;
	}
Exemplo n.º 3
0
 public function safeQuery($query)
 {
     if (in_array('MijoShop', get_declared_classes())) {
         $prefix = DB_PREFIX;
         $prefix = MijoShop::get('db')->getDbo()->replacePrefix($prefix);
         $query = str_replace(DB_PREFIX, $prefix, $query);
     }
     $result = $this->db->query($query);
     return $result;
 }
Exemplo n.º 4
0
 protected function getInput()
 {
     if ($error = $this->missingFilesOrTables(array('categories' => 'category', 'products' => 'product'))) {
         return $error;
     }
     if (!class_exists('MijoShop')) {
         require_once JPATH_ROOT . '/components/com_mijoshop/mijoshop/mijoshop.php';
     }
     $this->store_id = (int) MijoShop::get('opencart')->get('config')->get('config_store_id');
     $this->language_id = (int) MijoShop::get('opencart')->get('config')->get('config_language_id');
     return $this->getSelectList();
 }
Exemplo n.º 5
0
 function fetchElement()
 {
     $db = JFactory::getDBO();
     $lang = '';
     $config = MijoShop::get('opencart')->get('config');
     if (is_object($config)) {
         $lang = ' AND cd.language_id = ' . $config->get('config_language_id');
     }
     $query = 'SELECT 
                 m.category_id AS id, 
                 cd.name AS name, 
                 cd.name AS title, 
                 m.parent_id AS parent, 
                 m.parent_id as parent_id
             FROM #__mijoshop_category m
             LEFT JOIN #__mijoshop_category_description AS cd ON cd.category_id = m.category_id
             WHERE m.status = 1 ' . $lang . '
             ORDER BY m.sort_order';
     $db->setQuery($query);
     $menuItems = $db->loadObjectList();
     $children = array();
     if ($menuItems) {
         foreach ($menuItems as $v) {
             $pt = $v->parent_id;
             $list = isset($children[$pt]) ? $children[$pt] : array();
             array_push($list, $v);
             $children[$pt] = $list;
         }
     }
     jimport('joomla.html.html.menu');
     $options = JHTML::_('menu.treerecurse', 0, '', array(), $children, 9999, 0, 0);
     $this->_xml->addChild('option', 'Root')->addAttribute('value', 0);
     $optgroup = $this->_xml->addChild('optgroup', '');
     $optgroup->addAttribute('label', 'Categories');
     if (count($options)) {
         foreach ($options as $option) {
             $optgroup->addChild('option', $option->treename)->addAttribute('value', $option->id);
         }
     }
     $this->_value = $this->_form->get($this->_name, $this->_default);
     $html = parent::fetchElement();
     return $html;
 }
 function getObjectInfo($id, $language = null)
 {
     $info = new JCommentsObjectInfo();
     $helper = JPATH_ROOT . '/components/com_mijoshop/mijoshop/mijoshop.php';
     if (is_file($helper)) {
         require_once $helper;
         $db = JFactory::getDbo();
         $query = $db->getQuery(true);
         $query->select('product_id, name');
         $query->from('#__mijoshop_product_description');
         $query->where('product_id = ' . (int) $id);
         $db->setQuery($query);
         $row = $db->loadObject();
         if (!empty($row)) {
             $info->title = $row->name;
             $info->link = MijoShop::get('router')->route('index.php?route=product/product&product_id=' . $id);
         }
     }
     return $info;
 }
Exemplo n.º 7
0
 function getData($number)
 {
     nextendimport('nextend.database.database');
     $db = NextendDatabase::getInstance();
     $data = array();
     require_once JPATH_ROOT . '/components/com_mijoshop/mijoshop/mijoshop.php';
     $config = MijoShop::get('opencart')->get('config');
     $currency = MijoShop::get('opencart')->get('currency');
     if (MijoShop::get('base')->isAdmin('joomla')) {
         global $vqmod;
         if (empty($vqmod)) {
             require_once JPATH_MIJOSHOP_OC . '/vqmod/vqmod.php';
             $vqmod = new VQMod();
         }
         require_once $vqmod->modCheck(DIR_SYSTEM . 'library/tax.php');
         MijoShopOpencart::$tax = new Tax(MijoShopOpencart::$registry);
         MijoShopOpencart::$registry->set('tax', MijoShopOpencart::$tax);
     }
     $tax = MijoShop::get('opencart')->get('tax');
     $router = MijoShop::get('router');
     $language_id = intval($this->_data->get('mijoshopproductssourcelanguage'));
     if (!$language_id) {
         $language_id = intval($config->get('config_language_id'));
     }
     $tmpLng = $config->get('config_language_id');
     $config->set('config_language_id', $language_id);
     MijoShopOpencart::$loader->model('catalog/product');
     $p = new ModelCatalogProduct(MijoShopOpencart::$registry);
     $query = 'SELECT ';
     $query .= 'p.product_id ';
     $query .= 'FROM #__mijoshop_product AS p ';
     $query .= 'LEFT JOIN #__mijoshop_product_description AS pc USING(product_id) ';
     $query .= 'LEFT JOIN #__mijoshop_product_to_category AS ptc USING(product_id) ';
     $query .= 'LEFT JOIN #__mijoshop_product_special AS ps USING(product_id) ';
     $where = array();
     $category = array_map('intval', explode('||', $this->_data->get('mijoshopproductssourcecategory', '')));
     if (!in_array(0, $category) && count($category) > 0) {
         $where[] = 'ptc.category_id IN (' . implode(',', $category) . ') ';
     }
     if ($this->_data->get('mijoshopproductssourcepublished', 1)) {
         $where[] = ' p.status = 1 ';
     }
     if ($this->_data->get('mijoshopproductssourcespecial', 0)) {
         $where[] = ' ps.price IS NOT NULL';
         $jnow = JFactory::getDate();
         $now = version_compare(JVERSION, '1.6.0', '<') ? $jnow->toMySQL() : $jnow->toSql();
         $where[] = ' (ps.date_start = "0000-00-00" OR ps.date_start < \'' . $now . '\')';
         $where[] = ' (ps.date_end = "0000-00-00" OR ps.date_end > \'' . $now . '\')';
     }
     if ($this->_data->get('mijoshopproductssourceinstock', 0)) {
         $where[] = ' p.quantity > 0 ';
     }
     $where[] = ' pc.language_id  = ' . $language_id;
     if (count($where) > 0) {
         $query .= 'WHERE ' . implode(' AND ', $where) . ' ';
     }
     $query .= 'GROUP BY p.product_id ';
     $order = NextendParse::parse($this->_data->get('mijoshopproductsorder1', 'pc.name|*|asc'));
     if ($order[0]) {
         $query .= 'ORDER BY ' . $order[0] . ' ' . $order[1] . ' ';
         $order = NextendParse::parse($this->_data->get('mijoshopproductsorder2', '|*|asc'));
         if ($order[0]) {
             $query .= ', ' . $order[0] . ' ' . $order[1] . ' ';
         }
     }
     $query .= 'LIMIT 0, ' . $number;
     $db->setQuery($query);
     $result = $db->loadAssocList();
     for ($i = 0; $i < count($result); $i++) {
         $pi = $p->getProduct($result[$i]['product_id']);
         $data[$i] = array();
         $data[$i]['title'] = $data[$i]['name'] = $pi['name'];
         $data[$i]['short_description'] = $pi['description'];
         $data[$i]['model'] = $pi['model'];
         $data[$i]['sku'] = $pi['sku'];
         $data[$i]['quantity'] = $pi['quantity'];
         $data[$i]['manufacturer'] = $pi['manufacturer'];
         $data[$i]['rating'] = $pi['rating'];
         $data[$i]['price'] = $currency->format($tax->calculate($pi['price'], $pi['tax_class_id'], $config->get('config_tax')));
         if ((double) $product_info['special']) {
             $data[$i]['special_price'] = $currency->format($tax->calculate($pi['special'], $pi['tax_class_id'], $config->get('config_tax')));
         } else {
             $data[$i]['special_price'] = '';
         }
         if ($config->get('config_tax')) {
             $data[$i]['price_ex_tax'] = $currency->format((double) $pi['special'] ? $pi['special'] : $pi['price']);
         }
         $data[$i]['thumbnail'] = $data[$i]['image'] = NextendFilesystem::pathToAbsoluteURL(DIR_IMAGE) . $pi['image'];
         $data[$i]['addtocart'] = $data[$i]['url'] = $router->route('index.php?option=com_mijoshop&route=product/product&product_id=' . $pi['product_id']);
         $data[$i]['addtocart_label'] = 'View product';
         $data[$i]['category_name'] = 'Not available';
         $data[$i]['category_url'] = '#';
     }
     $config->set('config_language_id', $tmpLng);
     return $data;
 }
Exemplo n.º 8
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();
 }
 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);
     }
 }
Exemplo n.º 10
0
 public function index()
 {
     $this->load->model('setting/setting');
     $this->load->model('module/brainyfilter');
     $this->load->model('localisation/stock_status');
     $this->load->model('localisation/language');
     $this->load->model('design/layout');
     $this->load->model('catalog/category');
     $this->_setupLanguage();
     $isMijoShop = class_exists('MijoShop') && defined('JPATH_MIJOSHOP_OC');
     if ($isMijoShop) {
         MijoShop::get('base')->addHeader(JPATH_MIJOSHOP_OC . '/admin/view/javascript/brainyfilter.js', false);
         MijoShop::get('base')->addHeader(JPATH_MIJOSHOP_OC . '/admin/view/javascript/colorpicker/js/colorpicker.js', false);
     } else {
         $this->document->addScript('view/javascript/brainyfilter.js');
         $this->document->addScript('view/javascript/colorpicker/js/colorpicker.js');
     }
     if (isset($this->request->post['bf'])) {
         $post = $this->_parsePostData();
         if ($this->_validate($post)) {
             $this->_saveSettings($post);
             if ($this->request->post['action'] == 'apply') {
                 $this->redirect($this->url->link('module/brainyfilter', 'token=' . $this->session->data['token'], 'SSL'));
             } else {
                 $this->redirect($this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL'));
             }
         }
     }
     $this->document->setTitle($this->language->get('heading_title'));
     $this->document->addStyle('view/stylesheet/brainyfilter.css');
     $this->document->addStyle('view/javascript/colorpicker/css/colorpicker.css');
     $this->_data['heading_title'] = $this->language->get('heading_title');
     $this->_data['breadcrumbs'] = array();
     $this->_data['breadcrumbs'][] = array('text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'), 'separator' => false);
     $this->_data['breadcrumbs'][] = array('text' => $this->language->get('text_module'), 'href' => $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL'), 'separator' => ' :: ');
     $this->_data['breadcrumbs'][] = array('text' => $this->language->get('heading_title'), 'href' => $this->url->link('module/brainyfilter', 'token=' . $this->session->data['token'], 'SSL'), 'separator' => ' :: ');
     if (isset($this->session->data['success'])) {
         $this->_data['success'] = $this->session->data['success'];
         unset($this->session->data['success']);
     } else {
         $this->_data['success'] = '';
     }
     $this->_data['error_warning'] = $this->error;
     $this->_data['cancel'] = $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL');
     $this->_data['action'] = $this->url->link('module/brainyfilter', 'token=' . $this->session->data['token'], 'SSL');
     $this->_data['refreshAction'] = $this->url->link('module/brainyfilter/refresh', 'token=' . $this->session->data['token'], 'SSL');
     $this->_data['attributeValuesAction'] = $this->url->link('module/brainyfilter/attributeValues', 'token=' . $this->session->data['token'], 'SSL');
     $this->_data['modRefreshAction'] = $this->url->link('module/brainyfilter/modRefreshTrigger', 'token=' . $this->session->data['token'], 'SSL');
     $this->_data['stockStatuses'] = $this->model_localisation_stock_status->getStockStatuses();
     $this->_data['attrGroups'] = $this->model_module_brainyfilter->getAttributes();
     $this->_data['filters'] = $this->model_module_brainyfilter->getFilters();
     $this->_data['options'] = $this->model_module_brainyfilter->getOptions();
     $this->_data['categories'] = $this->model_catalog_category->getCategories(array('start' => 0, 'limit' => 1000));
     $this->_data['category_layouts'] = $this->model_module_brainyfilter->detectCategoryLayouts();
     $this->_data['defaultLayout'] = $this->defaultLayoutSettings;
     $this->_data['defaultLayout']['layout_id'] = $this->model_module_brainyfilter->getDefaultLayout();
     $this->_data['possible_controls'] = array('price' => array('slider' => $this->_data['entry_slider'], 'slider_lbl' => $this->_data['entry_slider_labels_only'], 'slider_lbl_inp' => $this->_data['entry_slider_labels_and_inputs']), 'manufacturer' => array('checkbox' => $this->_data['entry_checkbox'], 'radio' => $this->_data['entry_radio'], 'select' => $this->_data['entry_selectbox']), 'category' => array('checkbox' => $this->_data['entry_checkbox'], 'radio' => $this->_data['entry_radio'], 'select' => $this->_data['entry_selectbox']));
     $layoutsArr = $this->model_design_layout->getLayouts();
     $layouts = array();
     foreach ($layoutsArr as $l) {
         $layouts[$l['layout_id']] = $l['name'];
     }
     $this->_data['layouts'] = $layouts;
     $settings = $this->_applySettings();
     $this->_data['settings'] = $settings;
     $this->_data['basic_settings'] = array();
     $this->_data['isFirstLaunch'] = !$this->config->get('brainyfilter_layout_basic') ? 'true' : 'false';
     foreach ($settings['basic']['behaviour']['sections'] as $section => $set) {
         $item = array('label' => $this->language->get("entry_filter_{$section}"), 'name' => $section);
         if (isset($set['control'])) {
             $item['control'] = $set['control'];
         }
         $this->_data['filterBlocks'][] = $item;
     }
     $this->_data['layoutsCount'] = count($settings) - 1;
     $this->_data['languages'] = $this->model_localisation_language->getLanguages();
     $this->template = 'module/brainyfilter.tpl';
     $this->children = array('common/header', 'common/footer');
     $this->data = $this->_data;
     $this->response->setOutput($this->render());
 }
Exemplo n.º 11
0
 public function index($moduleSettings)
 {
     // the following break point is set in order to prevent extra call of this action
     // while filtering via AJAX. The chain represented below is a reason of this.
     // ajaxfilter() action -> Category controller -> column left modules -> index() action
     if (isset($this->request->get['route']) && $this->request->get['route'] === 'module/brainyfilter/ajaxfilter') {
         return;
     }
     $settings = $this->_getSettings($moduleSettings['bf_layout_id']);
     $data = $this->_prepareFilterInitialData();
     if (isset($this->request->get['route']) && $this->request->get['route'] === 'product/category' && (!isset($settings['categories'][$data['filter_category_id']]) || !$settings['categories'][$data['filter_category_id']])) {
         return;
     }
     $this->language->load('module/brainyfilter');
     $isMijoShop = class_exists('MijoShop') && defined('JPATH_MIJOSHOP_OC');
     if (preg_match('/(iPhone|iPod|iPad|Android)/', $_SERVER['HTTP_USER_AGENT'])) {
         if ($isMijoShop) {
             MijoShop::get('base')->addHeader(JPATH_MIJOSHOP_OC . '/catalog/view/javascript/jquery.ui.touch-punch.min.js', false);
         } else {
             $this->document->addScript('catalog/view/javascript/jquery.ui.touch-punch.min.js');
         }
     }
     if ($isMijoShop) {
         MijoShop::get('base')->addHeader(JPATH_MIJOSHOP_OC . '/catalog/view/javascript/brainyfilter.js', false);
     } else {
         $this->document->addScript('catalog/view/javascript/brainyfilter.js');
     }
     if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/stylesheet/brainyfilter.css')) {
         $this->document->addStyle('catalog/view/theme/' . $this->config->get('config_template') . '/stylesheet/brainyfilter.css');
     } else {
         $this->document->addStyle('catalog/view/theme/default/stylesheet/brainyfilter.css');
     }
     $this->_data['base'] = preg_replace('/https?:\\/\\/[^\\/]+/', '', $this->config->get('config_url'));
     $this->load->model('module/brainyfilter');
     $this->_data['path'] = isset($this->request->get['path']) ? $this->request->get['path'] : "";
     $this->model_module_brainyfilter->setData($data);
     $conditions = $this->model_module_brainyfilter->getConditions();
     $this->_data['selected'] = array();
     foreach ($conditions as $type => $group) {
         if (is_array($group) && count($group)) {
             foreach ($group as $gid => $values) {
                 $guid = substr($type, 0, 1) . $gid;
                 $this->_data['selected'][$guid] = $values;
             }
         }
     }
     $this->_data['heading_title'] = sprintf($this->language->get('heading_title'), $this->config->get('config_name'));
     $this->_data['default_value_select'] = $this->language->get('default_value_select');
     $this->_data['lang_price'] = $this->language->get('price_header');
     $this->_data['lang_categories'] = $this->language->get('categories_header');
     $this->_data['lang_search'] = $this->language->get('entry_search');
     $this->_data['lang_submit'] = $this->language->get('submit');
     $this->_data['min_max'] = $this->language->get('min_max');
     $this->_data['reset'] = $this->language->get('reset');
     $this->_data['lang_show_more'] = $this->language->get('entry_show_more');
     $this->_data['lang_show_less'] = $this->language->get('entry_show_less');
     $this->_data['lang_block_title'] = $this->language->get('entry_block_title');
     $this->_data['lang_empty_slider'] = $this->language->get('empty_slider_value');
     $this->_data['limit_height'] = $settings['behaviour']['limit_height']['enabled'];
     $this->_data['limit_height_opts'] = $settings['behaviour']['limit_height']['height'];
     $this->_data['sliding'] = $settings['behaviour']['limit_items']['enabled'];
     $this->_data['slidingOpts'] = $settings['behaviour']['limit_items']['number_to_show'];
     $this->_data['slidingMin'] = $settings['behaviour']['limit_items']['number_to_hide'];
     $bfSettings['basic'] = $this->config->get('bf_layout_basic');
     $lang = (int) $this->config->get('config_language_id');
     if (!empty($settings["behaviour"]["filter_name"][$lang])) {
         $this->_data['lang_block_title'] = $settings["behaviour"]["filter_name"][$lang];
     } elseif (!empty($bfSettings['basic']["behaviour"]["filter_name"][$lang])) {
         $this->_data['lang_block_title'] = $bfSettings['basic']["behaviour"]["filter_name"][$lang];
     }
     $filters = array();
     $secSettings = $settings['behaviour']['sections'];
     if ($secSettings['attribute']['enabled']) {
         $arr = $this->model_module_brainyfilter->getAttributes();
         $this->_applySettings($arr, 'attributes', $settings);
         if (count($arr)) {
             $filters[] = array('type' => 'attribute', 'order' => (int) $settings['behaviour']['sort_order']['attribute'], 'array' => $arr, 'collapsed' => (bool) $secSettings['attribute']['collapsed']);
         }
     }
     if ($secSettings['option']['enabled']) {
         $arr = $this->model_module_brainyfilter->getOptions();
         $this->_applySettings($arr, 'options', $settings);
         if (count($arr)) {
             $filters[] = array('type' => 'option', 'order' => (int) $settings['behaviour']['sort_order']['option'], 'array' => $arr, 'collapsed' => (bool) $secSettings['option']['collapsed']);
         }
     }
     if ($secSettings['filter']['enabled']) {
         $arr = $this->model_module_brainyfilter->getFilters();
         $this->_applySettings($arr, 'filters', $settings);
         if (count($arr)) {
             $filters[] = array('type' => 'filter', 'order' => (int) $settings['behaviour']['sort_order']['filter'], 'array' => $arr, 'collapsed' => (bool) $secSettings['filter']['collapsed']);
         }
     }
     if ($secSettings['manufacturer']['enabled']) {
         $arr = $this->model_module_brainyfilter->getManufacturers();
         if (count($arr)) {
             $filters[] = array('type' => 'manufacturer', 'order' => (int) $settings['behaviour']['sort_order']['manufacturer'], 'array' => array('0' => array('name' => $this->language->get('manufacturers'), 'type' => $secSettings['manufacturer']['control'], 'values' => $arr)), 'collapsed' => (bool) $secSettings['manufacturer']['collapsed']);
         }
     }
     if ($secSettings['stock_status']['enabled']) {
         $arr = $this->model_module_brainyfilter->getStockStatuses();
         if (count($arr)) {
             $filters[] = array('type' => 'stock_status', 'order' => (int) $settings['behaviour']['sort_order']['stock_status'], 'array' => array('0' => array('name' => $this->language->get('stock_status'), 'type' => 'checkbox', 'values' => $arr)), 'collapsed' => (bool) $secSettings['stock_status']['collapsed']);
         }
     }
     if ($secSettings['rating']['enabled']) {
         $filters[] = array('type' => 'rating', 'order' => (int) $settings['behaviour']['sort_order']['rating'], 'array' => array('0' => array('name' => $this->language->get('rating'), 'values' => array(array('id' => 1, 'name' => '1'), array('id' => 2, 'name' => '2'), array('id' => 3, 'name' => '3'), array('id' => 4, 'name' => '4'), array('id' => 5, 'name' => '5')), 'type' => 'checkbox')), 'collapsed' => (bool) $secSettings['rating']['collapsed']);
     }
     if ($secSettings['price']['enabled']) {
         $minMax = $this->model_module_brainyfilter->getMinMaxCategoryPrice($data);
         $min = floor($this->currency->format($minMax['min'], '', '', false));
         $max = ceil($this->currency->format($minMax['max'], '', '', false));
         //            if ($minMax['max'] > 0) {
         $filters[] = array('type' => 'price', 'control' => $secSettings['price']['control'], 'order' => (int) $settings['behaviour']['sort_order']['price'], 'collapsed' => (bool) $secSettings['price']['collapsed'], 'min' => $min, 'max' => $max);
         //            }
     }
     if ($secSettings['search']['enabled']) {
         $filters[] = array('type' => 'search', 'order' => (int) $settings['behaviour']['sort_order']['search'], 'collapsed' => (bool) $secSettings['search']['collapsed']);
     }
     if ($secSettings['category']['enabled']) {
         $arr = $this->model_module_brainyfilter->getCategories();
         $this->_sortSubCategories($arr);
         $this->_filterSubCategories($arr, $data['filter_category_id']);
         if (count($arr)) {
             $filters[] = array('type' => 'category', 'control' => $secSettings['category']['control'], 'order' => (int) $settings['behaviour']['sort_order']['category'], 'values' => $arr, 'collapsed' => (bool) $secSettings['category']['collapsed']);
         }
     }
     $this->_data['priceMin'] = isset($min) ? $min : 0;
     $this->_data['priceMax'] = isset($max) ? $max : 0;
     $this->_data['lowerlimit'] = isset($conditions->price->inputMin) ? $conditions->price->inputMin : $this->_data['priceMin'];
     $this->_data['upperlimit'] = isset($conditions->price->inputMax) ? $conditions->price->inputMax : $this->_data['priceMax'];
     $this->_data['bfSearch'] = $conditions->search;
     // sort filter sections
     usort($filters, array(__CLASS__, '_sortProperties'));
     $this->_data['filters'] = $filters;
     if ($this->currency->getsymbolleft()) {
         $this->_data['currency_symbol'] = $this->currency->getsymbolleft();
         $this->_data['cur_symbol_side'] = 'left';
     } else {
         $this->_data['currency_symbol'] = $this->currency->getsymbolright();
         $this->_data['cur_symbol_side'] = 'right';
     }
     if (!isset($this->request->get['route']) || $this->request->get['route'] !== 'product/category' && $this->request->get['route'] !== 'product/search' && $this->request->get['route'] !== 'module/brainyfilter/filter') {
         $this->_data['redirectToUrl'] = $this->url->link('module/brainyfilter/filter', isset($this->request->get['path']) ? 'path=' . $this->request->get['path'] : '');
     } else {
         $this->_data['redirectToUrl'] = '';
     }
     $this->_data['currentPath'] = isset($this->request->get['path']) ? $this->request->get['path'] : false;
     $this->_data['settings'] = $settings;
     $this->_data['layout_id'] = $moduleSettings['bf_layout_id'];
     $this->_data['layout_position'] = $moduleSettings['position'];
     if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/brainyfilter.tpl')) {
         $this->template = $this->config->get('config_template') . '/template/module/brainyfilter.tpl';
     } else {
         $this->template = 'default/template/module/brainyfilter.tpl';
     }
     $this->data = $this->_data;
     $this->response->setOutput($this->render());
 }