name = 'infiniteajax'; $this->tab = 'front_office_features'; $this->version = '1.3.1'; $this->author = 'Mellow (PrestaShop Forum Member)'; $this->page = basename(__FILE__, '.php'); $this->displayName = $this->l('Infinite Ajax Scroll'); $this->description = $this->l('Infinite scroll with automatic pagination'); parent::__construct(); } function install() { if (!parent::install() || !$this->registerHook('header')) return false; Configuration::updateValue('PS_INFINITE_AJAX_TRESHOLD', 0); Configuration::updateValue('PS_INFINITE_AJAX_HISTORY', 1); Configuration::updateValue('PS_INFINITE_AJAX_BLKLAYRD', 0); Configuration::updateValue('PS_INFINITE_AJAX_LOADING', ''); Configuration::updateValue('PS_INFINITE_AJAX_TRIGGERPAGE', ''); Configuration::updateValue('PS_INFINITE_AJAX_TRIGGER', ''); Configuration::updateValue('PS_INFINITE_AJAX_NONELEFT', ''); Configuration::updateValue('PS_INFINITE_AJAX_NONELEFTLINK', 0); Configuration::updateValue('PS_INFINITE_AJAX_LOADER', 'modules/infiniteajax/images/loader.gif'); Configuration::updateValue('PS_INFINITE_AJAX_PRODLISTELE', 'product_list,ajax_block_product,pagination,pagination_next'); Configuration::updateValue('PS_INFINITE_AJAX_ONRENDERCOMP', 'function(){if(typeof(ajaxCart)!=\'undefined\'){ajaxCart.overrideButtonsInThePage();ajaxCart.refresh()}if(typeof(reloadProductComparison)==\'function\')reloadProductComparison()}'); return true; } function uninstall() { Configuration::deleteByName('PS_INFINITE_AJAX_TRESHOLD'); Configuration::deleteByName('PS_INFINITE_AJAX_HISTORY'); Configuration::deleteByName('PS_INFINITE_AJAX_BLKLAYRD'); Configuration::deleteByName('PS_INFINITE_AJAX_LOADING'); Configuration::deleteByName('PS_INFINITE_AJAX_TRIGGERPAGE'); Configuration::deleteByName('PS_INFINITE_AJAX_TRIGGER'); Configuration::deleteByName('PS_INFINITE_AJAX_NONELEFT'); Configuration::deleteByName('PS_INFINITE_AJAX_NONELEFTLINK'); Configuration::deleteByName('PS_INFINITE_AJAX_LOADER'); Configuration::deleteByName('PS_INFINITE_AJAX_PRODLISTELE'); Configuration::deleteByName('PS_INFINITE_AJAX_ONRENDERCOMP'); if (!parent::uninstall() || !$this->unregisterHook('header')) return false; return true; } public function getLoaders() { $thedir = dirname(__FILE__).'/images/'; $dirimages = opendir($thedir); while ($isitem = readdir($dirimages)) { $theimages[] = $isitem; } sort($theimages); foreach ($theimages as $theimage) if ($theimage != '.' && $theimage != '..' && $theimage != 'Thumbs.db' && $theimage != 'index.php' && $theimage != 'icon' && !is_dir($theimage)) $loaders[] = $theimage; return $loaders; } public function isPhoneDevice() { if (!class_exists('Mobile_Detect')) { if (version_compare(_PS_VERSION_,'1.5','>')) require_once(_PS_TOOL_DIR_.'mobile_Detect/Mobile_Detect.php'); else require_once('Mobile_Detect.php'); } $this->mobile_detect = new Mobile_Detect(); $this->phone_device = false; if ($this->mobile_detect->isMobile() && !$this->mobile_detect->isTablet()) $this->phone_device = true; // * Debug * //if ($this->phone_device == true) echo "This is a Phone or a SmartPhone"; //if ($this->mobile_detect->isTablet()) echo "This is a Tablet"; return $this->phone_device; } function hookheader($params) { global $smarty, $cookie; if ($this->isPhoneDevice()) return; if (version_compare(_PS_VERSION_,'1.5','>')) { $page_name = Tools::getValue('controller'); $id_shop = (int) Context::getContext()->shop->id; $pages_with_productlist = array("category", "manufacturer", "supplier", "search", "pricesdrop", "newproducts", "bestsales"); } else { $pathinfo = pathinfo(__FILE__); $page_name = basename($_SERVER['PHP_SELF'], '.'.$pathinfo['extension']); $id_shop = 0; $pages_with_productlist = array("category", "manufacturer", "supplier", "search", "prices-drop", "new-products", "best-sales"); } // Si il s'agit d'une page affichant une liste de produits if (in_array($page_name, $pages_with_productlist)) { if ($page_name == "manufacturer" AND !((int)Tools::getValue('id_manufacturer') > 0)) return; if ($page_name == "supplier" AND !((int)Tools::getValue('id_supplier') > 0)) return; $blocklayered_activated = false; $isactive_blocklayered = false; if ($page_name == "category") { $id_category = (int)Tools::getValue('id_category'); if (version_compare(_PS_VERSION_,'1.5','>')) $blocklayered_activated = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue("SELECT m.id_module FROM "._DB_PREFIX_."module m, "._DB_PREFIX_."module_shop s WHERE m.name = 'blocklayered' AND m.active = 1 AND m.id_module = s.id_module AND s.id_shop = ".$id_shop); else $blocklayered_activated = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue("SELECT id_module FROM "._DB_PREFIX_."module WHERE name = 'blocklayered' AND active = 1"); if ($blocklayered_activated == true) $isactive_blocklayered = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT id_category FROM '._DB_PREFIX_.'layered_category WHERE id_category = '.$id_category.' AND id_shop = '.$id_shop); // Si il s'agit d'une catégorie avec navigation à facettes, et que l'option est désactivée dans le module if ($isactive_blocklayered == true AND Configuration::get('PS_INFINITE_AJAX_BLKLAYRD') == 0) return; } if (version_compare(_PS_VERSION_,'1.5','>')) { $this->context->controller->addJS(($this->_path).'jquery-ias.js'); $this->context->controller->addCSS(($this->_path).'css/jquery.ias.css', 'all'); } else { Tools::addJS(($this->_path).'jquery-ias.js'); Tools::addCSS(($this->_path).'css/jquery.ias.css', 'all'); } $ListElements = explode(',', Configuration::get('PS_INFINITE_AJAX_PRODLISTELE')); $tresholdMargin = Configuration::get('PS_INFINITE_AJAX_TRESHOLD'); $triggerPageThreshold = Configuration::get('PS_INFINITE_AJAX_TRIGGERPAGE'); $trigger = Configuration::get('PS_INFINITE_AJAX_TRIGGER', (int)$cookie->id_lang); $noneleft = Configuration::get('PS_INFINITE_AJAX_NONELEFT', (int)$cookie->id_lang); $loader = Configuration::get('PS_INFINITE_AJAX_LOADER'); $loadingtext = Configuration::get('PS_INFINITE_AJAX_LOADING', (int)$cookie->id_lang); $RenderCompleteFunction = Configuration::get('PS_INFINITE_AJAX_ONRENDERCOMP'); return " "; } return; } public function getContent() { $this->_html = '