// Merge -> revision 8552
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@8554 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -2160,7 +2160,7 @@ abstract class AdminSelfTab
|
||||
global $currentIndex, $smarty;
|
||||
|
||||
$languages = Language::getLanguages(false);
|
||||
if (function_exists('Tools','clearCache'))
|
||||
if (method_exists('Tools','clearCache'))
|
||||
Tools::clearCache($smarty);
|
||||
|
||||
/* Check required fields */
|
||||
|
||||
@@ -65,6 +65,8 @@ if(!class_exists('Tools',false))
|
||||
eval('class Tools extends Tools14{}');
|
||||
class AdminSelfUpgrade extends AdminSelfTab
|
||||
{
|
||||
public $svn_link = 'http://svn.prestashop.com/trunk';
|
||||
|
||||
public $ajax = false;
|
||||
public $nextResponseType = 'json'; // json, xml
|
||||
public $next = 'N/A';
|
||||
@@ -140,7 +142,10 @@ class AdminSelfUpgrade extends AdminSelfTab
|
||||
*/
|
||||
public static $loopRemoveSamples = 1000;
|
||||
|
||||
// public static $skipAction = array('unzip'=>'listSampleFiles');
|
||||
/* usage : key = the step you want to ski
|
||||
* value = the next step you want instead
|
||||
* example : public static $skipAction = array('download'=>'upgradeFiles');
|
||||
*/
|
||||
public static $skipAction;
|
||||
public $useSvn;
|
||||
|
||||
@@ -312,7 +317,7 @@ class AdminSelfUpgrade extends AdminSelfTab
|
||||
// checkPSVersion will be not
|
||||
$this->upgrader = new Upgrader();
|
||||
$this->upgrader->checkPSVersion();
|
||||
$this->currentParams['install_version'] = $this->upgrader->version_num;
|
||||
$this->nextParams['install_version'] = $this->upgrader->version_num;
|
||||
|
||||
if ($this->upgrader->autoupgrade_module)
|
||||
$this->standalone = true;
|
||||
@@ -668,23 +673,8 @@ $this->standalone = true;
|
||||
file_put_contents($this->nextParams['filesToUpgrade'],serialize($filesToUpgrade));
|
||||
}
|
||||
|
||||
/**
|
||||
* _modelDoUpgrade prepare the call to doUpgrade.php file (like model.php)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function _modelDoUpgrade()
|
||||
public function _modelDo($method)
|
||||
{
|
||||
// a. set logger
|
||||
// it will be used later
|
||||
global $logger;
|
||||
$logger = new FileLogger();
|
||||
if (function_exists('date_default_timezone_set'))
|
||||
date_default_timezone_set('Europe/Paris');
|
||||
// use autoupgrade as log dir
|
||||
$logger->setFilename($this->latestRootDir.'/'.date('Ymd').'_autoupgrade.log');
|
||||
|
||||
// init env.
|
||||
@set_time_limit(0);
|
||||
@ini_set('max_execution_time', '0');
|
||||
// setting the memory limit to 128M only if current is lower
|
||||
@@ -695,78 +685,124 @@ $this->standalone = true;
|
||||
){
|
||||
@ini_set('memory_limit','128M');
|
||||
}
|
||||
require_once($this->prodRootDir.'/config/autoload.php');
|
||||
|
||||
/* Redefine REQUEST_URI if empty (on some webservers...) */
|
||||
if (!isset($_SERVER['REQUEST_URI']) || $_SERVER['REQUEST_URI'] == '')
|
||||
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'];
|
||||
|
||||
if ($tmp = strpos($_SERVER['REQUEST_URI'], '?'))
|
||||
$_SERVER['REQUEST_URI'] = substr($_SERVER['REQUEST_URI'], 0, $tmp);
|
||||
|
||||
$_SERVER['REQUEST_URI'] = str_replace('//', '/', $_SERVER['REQUEST_URI']);
|
||||
|
||||
///////////////////////
|
||||
// Copy from model.php
|
||||
///////////////////////
|
||||
if (!is_object($this->upgrader))
|
||||
$this->upgrader = new Upgrader();
|
||||
|
||||
$upgrader = $this->upgrader;
|
||||
|
||||
$upgrader->checkPSVersion();
|
||||
|
||||
define('INSTALL_VERSION', $this->currentParams['install_version']);
|
||||
// now the install dir to use is in a subdirectory of the admin dir
|
||||
define('INSTALL_PATH', realpath($this->latestRootDir.DIRECTORY_SEPARATOR.'install'));
|
||||
|
||||
define('PS_INSTALLATION_IN_PROGRESS', true);
|
||||
// Note : we don't need ToolsInstall.php
|
||||
// include_once(INSTALL_PATH.'/classes/ToolsInstall.php');
|
||||
|
||||
define('PS_INSTALLATION_IN_PROGRESS', true);
|
||||
require_once(INSTALL_PATH.'/classes/ToolsInstall.php');
|
||||
define('SETTINGS_FILE', $this->prodRootDir . '/config/settings.inc.php');
|
||||
define('DEFINES_FILE', $this->prodRootDir .'/config/defines.inc.php');
|
||||
define('INSTALLER__PS_BASE_URI', substr($_SERVER['REQUEST_URI'], 0, -1 * (strlen($_SERVER['REQUEST_URI']) - strrpos($_SERVER['REQUEST_URI'], '/')) - strlen(substr(dirname($_SERVER['REQUEST_URI']), strrpos(dirname($_SERVER['REQUEST_URI']), '/')+1))));
|
||||
|
||||
// Note : INSTALLER__PS_BASE_URI_ABSOLUTE is not used for upgrade
|
||||
// define('INSTALLER__PS_BASE_URI_ABSOLUTE', 'http://'.ToolsInstall::getHttpHost(false, true).INSTALLER__PS_BASE_URI);
|
||||
define('INSTALLER__PS_BASE_URI_ABSOLUTE', 'http://'.ToolsInstall::getHttpHost(false, true).INSTALLER__PS_BASE_URI);
|
||||
|
||||
// XML Header
|
||||
header('Content-Type: text/xml');
|
||||
require_once(INSTALL_PATH.DIRECTORY_SEPARATOR.'xml'.DIRECTORY_SEPARATOR.'doUpgrade.php');
|
||||
|
||||
//////////////////////////////
|
||||
// End of copy from model.php
|
||||
//////////////////////////////
|
||||
|
||||
}
|
||||
|
||||
// Switching method
|
||||
if (in_array($method, array('doUpgrade', 'createDB', 'checkShopInfos')))
|
||||
{
|
||||
global $logger;
|
||||
$logger = new FileLogger();
|
||||
$logger->setFilename($this->prodRootDir.DIRECTORY_SEPARATOR.'log'.DIRECTORY_SEPARATOR.@date('Ymd').'_installation.log');
|
||||
}
|
||||
switch ($method)
|
||||
{
|
||||
case 'checkConfig' :
|
||||
require_once(INSTALL_PATH.DIRECTORY_SEPARATOR.'xml'.DIRECTORY_SEPARATOR.'checkConfig.php');
|
||||
die();
|
||||
break;
|
||||
|
||||
case 'checkDB' :
|
||||
require_once(INSTALL_PATH.DIRECTORY_SEPARATOR.'xml'.DIRECTORY_SEPARATOR.'checkDB.php');
|
||||
break;
|
||||
|
||||
case 'createDB' :
|
||||
require_once(INSTALL_PATH.DIRECTORY_SEPARATOR.'xml'.DIRECTORY_SEPARATOR.'createDB.php');
|
||||
break;
|
||||
|
||||
case 'checkMail' :
|
||||
require_once(INSTALL_PATH.DIRECTORY_SEPARATOR.'xml'.DIRECTORY_SEPARATOR.'checkMail.php');
|
||||
break;
|
||||
|
||||
case 'checkShopInfos' :
|
||||
require_once(INSTALL_PATH.DIRECTORY_SEPARATOR.'xml'.DIRECTORY_SEPARATOR.'checkShopInfos.php');
|
||||
break;
|
||||
|
||||
case 'doUpgrade' :
|
||||
require_once(INSTALL_PATH.DIRECTORY_SEPARATOR.'xml'.DIRECTORY_SEPARATOR.'doUpgrade.php');
|
||||
break;
|
||||
|
||||
case 'getVersionFromDb' :
|
||||
require_once(INSTALL_PATH.DIRECTORY_SEPARATOR.'xml'.DIRECTORY_SEPARATOR.'getVersionFromDb.php');
|
||||
break;
|
||||
}
|
||||
}
|
||||
public function ajaxProcessUpgradeDb(){
|
||||
|
||||
// @TODO : 1/2/3 have to be done at the beginning !!!!!!!!!!!!!!!!!!!!!!
|
||||
$this->nextParams = $this->currentParams;
|
||||
|
||||
// use something like actual in install-dev
|
||||
// Notice : xml used here ...
|
||||
|
||||
if (!isset($this->currentParams['upgradeDbStep']))
|
||||
{
|
||||
$this->nextParams['upgradeDbStep'] = 1;
|
||||
$this->next = 'upgradeDb';
|
||||
$this->nextDesc = 'upgrading database';
|
||||
$this->nextResponseType = 'xml';
|
||||
}
|
||||
else
|
||||
switch ($this->currentParams['upgradeDbStep'])
|
||||
{
|
||||
default:
|
||||
$this->next = 'upgradeComplete';
|
||||
$this->nextResponseType = 'json';
|
||||
return true;
|
||||
// $this->_model('checkConfig');
|
||||
break;
|
||||
// 1) confirm version is correct(DB)
|
||||
// install/model.php?method=getVersionFromDb&language=0
|
||||
// later
|
||||
|
||||
case '1':
|
||||
$this->_modelDo('getVersionFromDb');
|
||||
break;
|
||||
// 2) confirm config is correct (r/w rights)
|
||||
// install/model.php?method=checkConfig&firsttime=0
|
||||
// later
|
||||
// 3) save current activated modules in nextParams, or don't desactivate them ?
|
||||
// @TODO
|
||||
// 4) upgrade
|
||||
// install/model.php?_=1309193641470&method=doUpgrade&customModule=desactivate
|
||||
if (!empty($this->currentParams['desactivateCustomModule']))
|
||||
$_GET['customModule'] = 'desactivate';
|
||||
if (!$this->_modelDoUpgrade())
|
||||
case '2':
|
||||
if(!$this->_modelDo('checkConfig'))
|
||||
{
|
||||
$this->next = 'error';
|
||||
$this->nextDesc = $this->l('error during upgrade Db');
|
||||
$this->nextDesc = $this->l('error when checking configuration');
|
||||
}
|
||||
break;
|
||||
|
||||
case '3':
|
||||
if (!$this->_modelDo('doUpgrade'))
|
||||
{
|
||||
$this->next = 'error';
|
||||
$this->nextDesc = $this->l('error during upgrade Db. You may need to restore your database');
|
||||
}
|
||||
break;
|
||||
|
||||
case '4':
|
||||
$this->next = 'upgradeComplete';
|
||||
$this->nextResponseType = 'json';
|
||||
$this->nextDesc = $this->l('Way to go ! Upgrade complete.');
|
||||
break;
|
||||
}
|
||||
|
||||
// 5) compare activated modules and reactivate them
|
||||
// @TODO
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@@ -1226,7 +1262,6 @@ $this->standalone = true;
|
||||
{
|
||||
$this->nextParams = $this->currentParams;
|
||||
if ($this->useSvn){
|
||||
$svnLink = 'http://svn.prestashop.com/trunk';
|
||||
$dest = $this->autoupgradePath . DIRECTORY_SEPARATOR . $this->svnDir;
|
||||
|
||||
$svnStatus = svn_status($dest);
|
||||
@@ -1260,10 +1295,10 @@ $this->standalone = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (svn_checkout($svnLink, $dest))
|
||||
if (svn_checkout($this->svn_link, $dest))
|
||||
{
|
||||
$this->next = 'svnExport';
|
||||
$this->nextDesc = sprintf($this->l('SVN Checkout done from %s . now exporting it into latest...'),$svnLink);
|
||||
$this->nextDesc = sprintf($this->l('SVN Checkout done from %s . now exporting it into latest...'),$this->svn_link);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -1661,8 +1696,6 @@ echo '</script>';
|
||||
// update['link'] = download link
|
||||
// @TODO
|
||||
|
||||
if ($this->isUpgradeAllowed())
|
||||
{
|
||||
$this->createCustomToken();
|
||||
if ($this->useSvn)
|
||||
echo '<div class="error"><h1>'.$this->l('Unstable upgrade').'</h1>
|
||||
@@ -1683,15 +1716,8 @@ echo '</script>';
|
||||
</script>
|
||||
<script type="text/javascript" src="'.__PS_BASE_URI__.'modules/autoupgrade/jquery-1.6.2.min.js"></script>';
|
||||
}
|
||||
echo '<script type="text/javascript" src="'.__PS_BASE_URI__.'modules/autoupgrade/jquery.xml2json.js"></script>';
|
||||
echo '<script type="text/javascript">'.$this->_getJsInit().'</script>';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo '<fieldset>
|
||||
<legend>'.$this->l('Update').'</legend>';
|
||||
echo '<p>'.$this->l('You currently don\'t need to use this feature.').'</p>';
|
||||
echo '</fieldset>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1771,24 +1797,67 @@ $(document).ready(function(){
|
||||
|
||||
/**
|
||||
* parseXMLResult is used to handle the return value of the doUpgrade method
|
||||
*
|
||||
* @xmlRet xml return value
|
||||
* @var previousParams contains the precedent post values (to conserve post datas during upgrade db process)
|
||||
*/
|
||||
function parseXMLResult(xmlRet)
|
||||
{
|
||||
ret = $(xmlRet);
|
||||
ret = ret.find("action")[0];
|
||||
if (ret.getAttribute("result") == "ok")
|
||||
{
|
||||
$("#dbResultCheck")
|
||||
.addClass("ok")
|
||||
.removeClass("fail")
|
||||
.html("<p>'.$this->l('upgrade complete. Please check your front-office (try to make an order, check theme)').'</p>")
|
||||
.show("slow");
|
||||
$("#dbCreateResultCheck")
|
||||
.hide("slow");
|
||||
|
||||
// as xml is only after upgradeDb, the next step is always upgradeComplete
|
||||
ret = {next:"upgradeComplete",nextParams:{typeResult:"json"},status:"ok"};
|
||||
function checkConfig(res)
|
||||
{
|
||||
testRequiredList = $(res.testList[0].test);
|
||||
configIsOk = true;
|
||||
|
||||
testRequiredList.each(function()
|
||||
{
|
||||
result = $(this).attr("result");
|
||||
if (result == "fail") configIsOk = false;
|
||||
});
|
||||
|
||||
if (!configIsOk)
|
||||
{
|
||||
alert("Configuration install problem");
|
||||
return "fail";
|
||||
}
|
||||
else
|
||||
return "ok";
|
||||
}
|
||||
|
||||
function handleXMLResult(xmlRet, previousParams)
|
||||
{
|
||||
// use xml2json and put the result in the global var
|
||||
// this will be used in after** javascript functions
|
||||
resGlobal = $.xml2json(xmlRet);
|
||||
|
||||
switch(previousParams.upgradeDbStep)
|
||||
{
|
||||
case 0: // getVersionFromDb
|
||||
result = "ok";
|
||||
break;
|
||||
case 1: // getVersionFromDb
|
||||
result = resGlobal.result;
|
||||
break;
|
||||
case 2: // checkConfig
|
||||
result = checkConfig(resGlobal);
|
||||
break;
|
||||
case 3: // doUpgrade:
|
||||
result = resGlobal.result;
|
||||
break;
|
||||
case 4: // upgradeComplete
|
||||
result = resGlobal.result;
|
||||
break;
|
||||
}
|
||||
|
||||
if (result == "ok")
|
||||
{
|
||||
nextParams = previousParams;
|
||||
nextParams.upgradeDbStep = previousParams.upgradeDbStep+1;
|
||||
if(nextParams.upgradeDbStep >= 4)
|
||||
{
|
||||
resGlobal.next = "upgradeComplete";
|
||||
nextParams.typeResult = "json";
|
||||
}
|
||||
else
|
||||
resGlobal.next = "upgradeDb";
|
||||
resGlobal = {next:resGlobal.next,nextParams:nextParams,status:"ok"};
|
||||
|
||||
}
|
||||
else
|
||||
@@ -1796,22 +1865,35 @@ function parseXMLResult(xmlRet)
|
||||
$("#dbResultCheck")
|
||||
.addClass("fail")
|
||||
.removeClass("ok")
|
||||
.html(txtError[parseInt(ret.getAttribute("error"))])
|
||||
.show("slow");
|
||||
$("#dbCreateResultCheck")
|
||||
.hide("slow");
|
||||
|
||||
// propose rollback if there is an error
|
||||
if (confirm(txtError[parseInt(ret.getAttribute("error"))]+"\r\n\r\n'.$this->l('Do you want to rollback ?').'"))
|
||||
ret = {next:"rollback",nextParams:{typeResult:"json"},status:"error"};
|
||||
if (confirm("An error happen\r\n'.$this->l('Do you want to rollback ?').'"))
|
||||
resGlobal = {next:"rollback",nextParams:{typeResult:"json"},status:"error"};
|
||||
}
|
||||
|
||||
return ret
|
||||
return resGlobal;
|
||||
};
|
||||
|
||||
var resGlobal = {};
|
||||
function afterUpgradeDb()
|
||||
{
|
||||
// console.info("inside afterUpgradeDb");
|
||||
// console.log(resGlobal);
|
||||
|
||||
}
|
||||
function afterUpgradeComplete()
|
||||
{
|
||||
$("#pleaseWait").hide();
|
||||
$("#dbResultCheck")
|
||||
.addClass("ok")
|
||||
.removeClass("fail")
|
||||
.html("<p>'.$this->l('upgrade complete. Please check your front-office (try to make an order, check theme)').'</p>")
|
||||
.show("slow");
|
||||
$("#dbCreateResultCheck")
|
||||
.hide("slow");
|
||||
$("#infoStep").html("<h3>'.$this->l('Upgrade Complete ! ').'</h3>");
|
||||
}
|
||||
/**
|
||||
@@ -1865,12 +1947,12 @@ function doAjaxRequest(action, nextParams){
|
||||
|
||||
if (nextParams.typeResult == "xml")
|
||||
{
|
||||
xmlRes = parseXMLResult(res);
|
||||
res = {};
|
||||
res.next = xmlRes.next;
|
||||
res = handleXMLResult(res,nextParams);
|
||||
// res.next = xmlRes;
|
||||
// if xml, we keep the next params
|
||||
nextParams = myNext;
|
||||
res.status = xmlRes.status;
|
||||
// nextParams = xmlRes;
|
||||
// console.info(nextParams);
|
||||
// res.status = xmlRes.status;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1905,7 +1987,6 @@ function doAjaxRequest(action, nextParams){
|
||||
funcName = "after"+ucFirst(action);
|
||||
if (typeof funcName == "string" &&
|
||||
eval("typeof " + funcName) == "function") {
|
||||
|
||||
eval(funcName+"()");
|
||||
}
|
||||
|
||||
@@ -1927,8 +2008,6 @@ function doAjaxRequest(action, nextParams){
|
||||
}
|
||||
else
|
||||
{
|
||||
//console.log(res);
|
||||
//console.log(jqXHR);
|
||||
updateInfoStep("[Server Error] Status message : " + textStatus);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -393,7 +393,7 @@ abstract class SelfModule
|
||||
{
|
||||
self::$classInModule[$currentClass] = substr(dirname($filePath), strlen($realpathModuleDir)+1);
|
||||
|
||||
$id_lang = (int)($cookie->id_lang);
|
||||
$id_lang = (!isset($cookie) OR !is_object($cookie)) ? (int)(Configuration::get('PS_LANG_DEFAULT')) : (int)($cookie->id_lang);
|
||||
$file = _PS_MODULE_DIR_.self::$classInModule[$currentClass].'/'.Language::getIsoById($id_lang).'.php';
|
||||
if (file_exists($file) AND include_once($file))
|
||||
$_MODULES = !empty($_MODULES) ? array_merge($_MODULES, $_MODULE) : $_MODULE;
|
||||
|
||||
@@ -64,7 +64,6 @@ class Autoupgrade extends Module
|
||||
|
||||
if (!$res
|
||||
OR !Tab::getIdFromClassName('AdminSelfUpgrade')
|
||||
OR !(Hook::get('backOfficeHeader') AND !$this->registerHook('backOfficeHeader'))
|
||||
OR !parent::install()
|
||||
)
|
||||
return false;
|
||||
@@ -79,26 +78,21 @@ class Autoupgrade extends Module
|
||||
if(file_exists(_PS_ADMIN_DIR_.DIRECTORY_SEPARATOR.'tabs'.'AdminUpgrade.php'))
|
||||
{
|
||||
// Should we create the correct AdminUpgrade tab (not the module)
|
||||
$tab = new Tab();
|
||||
$tab->class_name = 'AdminUpgrade';
|
||||
$tab->module = false;
|
||||
$tab->id_parent = 9;
|
||||
$tab->name = array_fill(1,sizeof(Language::getLanguages(false)), 'Upgrade');
|
||||
$res = $tab->save();
|
||||
if($idOldTab = Tab::getIdFromClassName('AdminUpgrade'))
|
||||
{
|
||||
$tab = new Tab($idOldTab);
|
||||
$res &= $tab->delete();
|
||||
}
|
||||
$res &= unlink(_PS_ADMIN_DIR_.DIRECTORY_SEPARATOR.'tabs'.'AdminUpgrade.php');
|
||||
}
|
||||
|
||||
if (file_exists(_PS_ADMIN_DIR_.DIRECTORY_SEPARATOR.'autoupgrade'.DIRECTORY_SEPARATOR.'ajax-upgradetab.php'))
|
||||
$res &= @unlink(_PS_ADMIN_DIR_.DIRECTORY_SEPARATOR.'autoupgrade'.DIRECTORY_SEPARATOR.'ajax-upgradetab.php');
|
||||
if($res OR !parent::uninstall())
|
||||
if (!$res OR !parent::uninstall())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function hookBackOfficeHeader($params)
|
||||
{
|
||||
echo '<link type="text/css" rel="stylesheet" href="../modules/autoupgrade/autoupgrade.css" />';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,4 +8,5 @@ if (substr(Tools::encrypt('blocklayered/index'),0,10) != Tools::getValue('token'
|
||||
die('Bad token');
|
||||
|
||||
$blockLayered = new BlockLayered();
|
||||
echo $blockLayered->indexUrl((int)Tools::getValue('id_category'), (int)Tools::getValue('truncate'));
|
||||
$cursor = Tools::jsonDecode(Tools::getValue('cursor', '{}'), true);
|
||||
echo $blockLayered->indexUrl($cursor, (int)Tools::getValue('ajax'), (int)Tools::getValue('truncate'));
|
||||
@@ -81,10 +81,13 @@ function initSliders()
|
||||
function initLayered()
|
||||
{
|
||||
initSliders();
|
||||
var params = document.location.toString().split('#');
|
||||
var params = document.location.toString();
|
||||
params = friendlyUrl(params, 'long');
|
||||
params = params.split('#');
|
||||
params.shift();
|
||||
$(params).each(function(it, val)
|
||||
{
|
||||
allowReload = true;
|
||||
if (val.split('=')[0] == 'price' || val.split('=')[0] == 'weight')
|
||||
{
|
||||
$("#layered_"+val.split('=')[0]+"_slider").slider('values', 0, val.split('=')[1].split('_')[0]);
|
||||
@@ -102,6 +105,7 @@ function updatelink(link)
|
||||
{
|
||||
baseUrl = link.split('#');
|
||||
linkFilterUpdate = baseUrl[0]+getValueSelected();
|
||||
linkFilterUpdate = friendlyUrl(linkFilterUpdate, 'short');
|
||||
return linkFilterUpdate;
|
||||
}
|
||||
|
||||
@@ -126,6 +130,32 @@ function getValueSelected(){
|
||||
return checkboxChecked;
|
||||
}
|
||||
|
||||
function friendlyUrl(link, encode)
|
||||
{
|
||||
var friendlyTab = {
|
||||
'layered_condition_' : 'cond_',
|
||||
'layered_id_attribute_group_' : 'g_',
|
||||
'id_category_layered=' : 'c=',
|
||||
'layered_manufacturer_' : 'm_',
|
||||
'layered_id_feature_' : 'f_',
|
||||
'layered_category_' : 'cat_',
|
||||
};
|
||||
|
||||
if(encode == 'short'){
|
||||
$.each(friendlyTab, function(key, value) {
|
||||
Expression = new RegExp(key,'g');
|
||||
link = link.replace(Expression, value);
|
||||
});
|
||||
}else{
|
||||
$.each(friendlyTab, function(key, value) {
|
||||
Expression = new RegExp(value,'g');
|
||||
link = link.replace(Expression, key);
|
||||
});
|
||||
}
|
||||
|
||||
return link;
|
||||
}
|
||||
|
||||
function paginationButton() {
|
||||
$('#pagination li').not('.current, .disabled').each( function () {
|
||||
var nbPage = 0;
|
||||
@@ -188,6 +218,12 @@ function openCloseFilter()
|
||||
|
||||
function reloadContent(params_plus)
|
||||
{
|
||||
if (typeof(allowReload) == 'undefined')
|
||||
{
|
||||
allowReload = true;
|
||||
return;
|
||||
}
|
||||
|
||||
window.location = updatelink( window.location.href);
|
||||
for(i = 0; i < ajaxQueries.length; i++)
|
||||
ajaxQueries[i].abort();
|
||||
|
||||
@@ -138,7 +138,7 @@ class BlockLayered extends Module
|
||||
/*
|
||||
* Url indexation
|
||||
*/
|
||||
public function indexUrl($idCategory = null, $truncate = true)
|
||||
public function indexUrl($cursor = array(), $ajax = false, $truncate = true)
|
||||
{
|
||||
if($truncate)
|
||||
Db::getInstance()->execute('TRUNCATE '._DB_PREFIX_.'layered_friendly_url');
|
||||
@@ -177,8 +177,8 @@ class BlockLayered extends Module
|
||||
if (!isset($attributeValues[$attribute['id_lang']][$filter['id_category']]['c'.$attribute['id_name']]))
|
||||
$attributeValues[$attribute['id_lang']][$filter['id_category']]['c'.$attribute['id_name']] = array();
|
||||
$attributeValues[$attribute['id_lang']][$filter['id_category']]['c'.$attribute['id_name']][] = array('name' => $attribute['name'],
|
||||
'id_name' => 'c'.$attribute['id_name'], 'value' => $attribute['value'], 'id_value' => $attribute['id_value'],
|
||||
'category_name' => $filter['link_rewrite'], 'type' => $filter['type']);
|
||||
'id_name' => 'c'.$attribute['id_name'], 'value' => $attribute['value'], 'id_value' => $attribute['id_value'].'_'.$attribute['id_name'],
|
||||
'id_id_value' => $attribute['id_value'], 'category_name' => $filter['link_rewrite'], 'type' => $filter['type']);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -218,30 +218,101 @@ class BlockLayered extends Module
|
||||
$attributeValues[$category['id_lang']] = array();
|
||||
if (!isset($attributeValues[$category['id_lang']][$filter['id_category']]))
|
||||
$attributeValues[$category['id_lang']][$filter['id_category']] = array();
|
||||
if (!isset($attributeValues[$category['id_lang']][$filter['id_category']]['cat'.$category['id_category']]))
|
||||
$attributeValues[$category['id_lang']][$filter['id_category']]['cat'.$category['id_category']] = array();
|
||||
$attributeValues[$category['id_lang']][$filter['id_category']]['cat'.$category['id_category']][] = array('name' => $this->l('Categories'),
|
||||
if (!isset($attributeValues[$category['id_lang']][$filter['id_category']]['category']))
|
||||
$attributeValues[$category['id_lang']][$filter['id_category']]['category'] = array();
|
||||
$attributeValues[$category['id_lang']][$filter['id_category']]['category'][] = array('name' => $this->l('Categories'),
|
||||
'id_name' => null, 'value' => $category['name'], 'id_value' => $category['id_category'],
|
||||
'category_name' => $filter['link_rewrite'], 'type' => $filter['type']);
|
||||
}
|
||||
$filter['id_category'];
|
||||
break;
|
||||
|
||||
case 'manufacturer':
|
||||
// @TODO
|
||||
$manufacturers = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
|
||||
SELECT m.name as name,l.id_lang as id_lang, id_manufacturer
|
||||
FROM '._DB_PREFIX_.'manufacturer m , '._DB_PREFIX_.'lang l
|
||||
');
|
||||
|
||||
foreach ($manufacturers as $manufacturer)
|
||||
{
|
||||
if (!isset($attributeValues[$manufacturer['id_lang']]))
|
||||
$attributeValues[$manufacturer['id_lang']] = array();
|
||||
if (!isset($attributeValues[$manufacturer['id_lang']][$filter['id_category']]))
|
||||
$attributeValues[$manufacturer['id_lang']][$filter['id_category']] = array();
|
||||
if (!isset($attributeValues[$manufacturer['id_lang']][$filter['id_category']]['manufacturer']))
|
||||
$attributeValues[$manufacturer['id_lang']][$filter['id_category']]['manufacturer'] = array();
|
||||
$attributeValues[$manufacturer['id_lang']][$filter['id_category']]['manufacturer'][] = array('name' => $this->translateWord('Manufacturer', $manufacturer['id_lang']),
|
||||
'id_name' => null, 'value' => $manufacturer['name'], 'id_value' => $manufacturer['id_manufacturer'],
|
||||
'category_name' => $filter['link_rewrite'], 'type' => $filter['type']);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'avaibility':
|
||||
// @TODO
|
||||
case 'quantity':
|
||||
foreach (array (0 => $this->translateWord('Not available',(int)$filter['id_lang']), 1 => $this->translateWord('In stock', (int)$filter['id_lang']))
|
||||
as $key => $quantity)
|
||||
$attributeValues[$filter['id_lang']][$filter['id_category']]['quantity'][] = array('name' => $this->translateWord('Availability', (int)$filter['id_lang']),
|
||||
'id_name' => null, 'value' => $quantity, 'id_value' => $key, 'id_id_value' => 0,
|
||||
'category_name' => $filter['link_rewrite'], 'type' => $filter['type']);
|
||||
break;
|
||||
|
||||
case 'condition':
|
||||
foreach (array('new' => $this->translateWord('New', (int)$filter['id_lang']), 'used' => $this->translateWord('Used', (int)$filter['id_lang']),
|
||||
'refurbished' => $this->translateWord('Refurbished', (int)$filter['id_lang']))
|
||||
as $key => $condition)
|
||||
$attributeValues[$filter['id_lang']][$filter['id_category']]['condition'][] = array('name' => $this->translateWord('Condition', (int)$filter['id_lang']),
|
||||
'id_name' => null, 'value' => $condition, 'id_value' => $key,
|
||||
'category_name' => $filter['link_rewrite'], 'type' => $filter['type']);
|
||||
break;
|
||||
}
|
||||
|
||||
// Foreach langs
|
||||
foreach ($attributeValues as $id_lang => $tmp1)
|
||||
{
|
||||
// Foreach categories
|
||||
foreach ($tmp1 as $id_category => $tmp2)
|
||||
$maxExecutionTime = ini_get('max_execution_time') * 0.9; // 90% of safety margin
|
||||
if ($maxExecutionTime > 5)
|
||||
$maxExecutionTime = 5;
|
||||
$startTime = microtime(true);
|
||||
$memoryLimit = (Tools::getMemoryLimit() * 0.9);
|
||||
|
||||
if (empty($cursor))
|
||||
{
|
||||
$cursor = array(
|
||||
'attribute_values' => 0,
|
||||
'tmp1' => 0,
|
||||
'possibility' => 0,
|
||||
'total' => 0
|
||||
);
|
||||
|
||||
if ($ajax)
|
||||
{
|
||||
// Calculation, to eval progression
|
||||
$nbPosibilities = 0;
|
||||
foreach ($attributeValues as $idLang => $tmp1)
|
||||
foreach ($tmp1 as $key => $tmp2)
|
||||
{
|
||||
$nbPosibilitiesTmp = 1;
|
||||
foreach ($tmp2 as $name)
|
||||
{
|
||||
$count = count($name)+1;
|
||||
$nbPosibilitiesTmp *= $count;
|
||||
}
|
||||
$nbPosibilities += $nbPosibilitiesTmp;
|
||||
}
|
||||
$cursor['nb_posibilities'] = $nbPosibilities;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Foreach langs
|
||||
$attributeValuesKeys = array_keys($attributeValues);
|
||||
for (;$cursor['attribute_values'] < count($attributeValuesKeys); $cursor['attribute_values']++)
|
||||
{
|
||||
$id_lang = $attributeValuesKeys[$cursor['attribute_values']];
|
||||
$tmp1 = &$attributeValues[$id_lang];
|
||||
|
||||
// Foreach categories
|
||||
$tmp1Keys = array_keys($tmp1);
|
||||
for(; $cursor['tmp1'] < count($tmp1Keys); $cursor['tmp1']++)
|
||||
{
|
||||
$id_category = $tmp1Keys[$cursor['tmp1']];
|
||||
$tmp2 = &$tmp1[$id_category];
|
||||
|
||||
$cursors = array_fill(0, count($tmp2), 0);
|
||||
$limits = array();
|
||||
$nbName = count($tmp2);
|
||||
@@ -257,53 +328,112 @@ class BlockLayered extends Module
|
||||
}
|
||||
|
||||
// Loop all url posibilities
|
||||
for ($i = 1; $i < $nbPosibilities; $i++)
|
||||
for (; $cursor['possibility'] < $nbPosibilities; $cursor['possibility']++)
|
||||
{
|
||||
if ($memoryLimit < memory_get_peak_usage() OR (microtime(true) - $startTime) > $maxExecutionTime)
|
||||
{
|
||||
if ($ajax)
|
||||
return Tools::jsonEncode(array('cursor' => Tools::jsonEncode($cursor)));
|
||||
Tools::file_get_contents(Tools::getProtocol().Tools::getHttpHost().'/modules/blocklayered/blocklayered-url-indexer.php'.'?token='.substr(Tools::encrypt('blocklayered/index'), 0, 10).'&cursor='.Tools::jsonEncode($cursor));
|
||||
return 1;
|
||||
}
|
||||
|
||||
$cursor['total']++;
|
||||
// generate all parameters posibilities
|
||||
$a = 1;
|
||||
foreach ($cursors as $position => $cursor)
|
||||
foreach ($cursors as $position => $cursorP)
|
||||
{
|
||||
// Get all possible combination (one by group)
|
||||
// 0 means no combinations selected in the group
|
||||
$cursors[$position] = (($i / ($a)) % $limits[$position]);
|
||||
$cursors[$position] = (($cursor['possibility'] / ($a)) % $limits[$position]);
|
||||
$a *= $limits[$position];
|
||||
}
|
||||
|
||||
$link = '';
|
||||
$selectedFilters = array('category' => array());
|
||||
|
||||
// Generate url with selected filters
|
||||
foreach ($cursors as $position => $cursor)
|
||||
foreach ($cursors as $position => $cursorP)
|
||||
{
|
||||
if ($cursor != 0)
|
||||
if ($cursorP != 0)
|
||||
{
|
||||
$link .= '/'.Tools::link_rewrite($tmp2[$position][$cursor-1]['name'].'-'.$tmp2[$position][$cursor-1]['value']);
|
||||
if (!isset($selectedFilters[$tmp2[$position][$cursor-1]['type']]))
|
||||
$selectedFilters[$tmp2[$position][$cursor-1]['type']] = array();
|
||||
$selectedFilters[$tmp2[$position][$cursor-1]['type']][$tmp2[$position][$cursor-1]['id_value']] = $tmp2[$position][$cursor-1]['id_value'];
|
||||
$link .= '/'.Tools::link_rewrite($tmp2[$position][$cursorP-1]['name'].'-'.$tmp2[$position][$cursorP-1]['value']);
|
||||
if (!isset($selectedFilters[$tmp2[$position][$cursorP-1]['type']]))
|
||||
$selectedFilters[$tmp2[$position][$cursorP-1]['type']] = array();
|
||||
if (!isset($tmp2[$position][$cursorP-1]['id_id_value']))
|
||||
$tmp2[$position][$cursorP-1]['id_id_value'] = $tmp2[$position][$cursorP-1]['id_value'];
|
||||
$selectedFilters[$tmp2[$position][$cursorP-1]['type']][$tmp2[$position][$cursorP-1]['id_id_value']] = $tmp2[$position][$cursorP-1]['id_value'];
|
||||
}
|
||||
}
|
||||
|
||||
$urlKey = md5($link);
|
||||
$idLayeredFriendlyUrl = Db::getInstance()->getValue('SELECT id_layered_friendly_url FROM `'._DB_PREFIX_.'layered_friendly_url` WHERE `url_key` = \''.$urlKey.'\'');
|
||||
$idLayeredFriendlyUrl = Db::getInstance()->getValue('SELECT id_layered_friendly_url FROM `'._DB_PREFIX_.'layered_friendly_url` WHERE `id_lang` = '.$id_lang.' AND `url_key` = \''.$urlKey.'\'');
|
||||
if ($idLayeredFriendlyUrl == false)
|
||||
{
|
||||
Db::getInstance()->AutoExecute(_DB_PREFIX_.'layered_friendly_url', array('url_key' => $urlKey, 'data' => serialize($selectedFilters), 'id_lang' => $id_lang), 'INSERT');
|
||||
$idLayeredFriendlyUrl = Db::getInstance()->Insert_ID();
|
||||
}
|
||||
}
|
||||
$cursor['possibility'] = 0;
|
||||
}
|
||||
$cursor['tmp1'] = 0;
|
||||
}
|
||||
if ($ajax)
|
||||
return '{"result": 1}';
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function translateWord($string, $id_lang )
|
||||
{
|
||||
static $_MODULES = array();
|
||||
global $_MODULE;
|
||||
|
||||
$file = _PS_MODULE_DIR_.$this->name.'/'.Language::getIsoById($id_lang).'.php';
|
||||
|
||||
if (!array_key_exists($id_lang,$_MODULES))
|
||||
{
|
||||
if (!file_exists($file))
|
||||
return $string;
|
||||
include $file;
|
||||
$_MODULES[$id_lang] = $_MODULE;
|
||||
}
|
||||
|
||||
$string = str_replace('\'', '\\\'', $string);
|
||||
|
||||
// set array key to lowercase for 1.3 compatibility
|
||||
$_MODULES[$id_lang] = array_change_key_case($_MODULES[$id_lang]);
|
||||
$currentKey = '<{'.strtolower( $this->name).'}'.strtolower(_THEME_NAME_).'>'.strtolower($this->name).'_'.md5($string);
|
||||
$defaultKey = '<{'.strtolower( $this->name).'}prestashop>'.strtolower($this->name).'_'.md5($string);
|
||||
|
||||
if (isset($_MODULES[$id_lang][$currentKey]))
|
||||
$ret = stripslashes($_MODULES[$id_lang][$currentKey]);
|
||||
elseif (isset($_MODULES[$id_lang][Tools::strtolower($currentKey)]))
|
||||
$ret = stripslashes($_MODULES[$id_lang][Tools::strtolower($currentKey)]);
|
||||
elseif (isset($_MODULES[$id_lang][$defaultKey]))
|
||||
$ret = stripslashes($_MODULES[$id_lang][$defaultKey]);
|
||||
elseif (isset($_MODULES[$id_lang][Tools::strtolower($defaultKey)]))
|
||||
$ret = stripslashes($_MODULES[$id_lang][Tools::strtolower($defaultKey)]);
|
||||
else
|
||||
$ret = stripslashes($string);
|
||||
|
||||
return str_replace('"', '"', $ret);
|
||||
}
|
||||
|
||||
public function hookProductListAssign($params)
|
||||
{
|
||||
global $smarty;
|
||||
if (!Configuration::get('PS_LAYERED_INDEXED'))
|
||||
return;
|
||||
$params['hookExecuted'] = true;
|
||||
$params['catProducts'] = array();
|
||||
$selectedFilters = $this->getSelectedFilters();
|
||||
$filterBlock = self::getFilterBlock($selectedFilters);
|
||||
$title = '';
|
||||
if (is_array($filterBlock['title_values']))
|
||||
foreach ($filterBlock['title_values'] as $key => $val)
|
||||
$title .= ' – '.$key.' '.implode('/', $val);
|
||||
|
||||
$smarty->assign('categoryNameComplement', $title);
|
||||
$this->getProducts($selectedFilters, $params['catProducts'], $params['nbProducts'], $p, $n, $pages_nb, $start, $stop, $range);
|
||||
}
|
||||
|
||||
@@ -385,7 +515,6 @@ class BlockLayered extends Module
|
||||
</div>';
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* $cursor $cursor in order to restart indexing from the last state
|
||||
*/
|
||||
@@ -591,9 +720,35 @@ class BlockLayered extends Module
|
||||
|
||||
public function hookHeader($params)
|
||||
{
|
||||
global $smarty, $cookie;
|
||||
|
||||
if (Tools::getValue('id_category', Tools::getValue('id_category_layered', 1)) == 1)
|
||||
return;
|
||||
|
||||
$idLang = (int)$cookie->id_lang;
|
||||
$category = new Category((int)Tools::getValue('id_category'));
|
||||
$categoryMetas = Tools::getMetaTags($idLang, '');
|
||||
$categoryTitle = (empty($category->meta_title[$idLang])?$category->name[$idLang]:$category->meta_title[$idLang]);
|
||||
|
||||
// Generate meta title and meta description
|
||||
$selectedFilters = $this->getSelectedFilters();
|
||||
$filterBlock = self::getFilterBlock($selectedFilters);
|
||||
$title = '';
|
||||
if (is_array($filterBlock['title_values']))
|
||||
foreach ($filterBlock['title_values'] as $key => $val)
|
||||
$title .= $key.' '.implode('/', $val).' – ';
|
||||
$title = rtrim($title, ' – ');
|
||||
$metaComplement = ucfirst(strtolower($title));
|
||||
$metaKeyWordsComplement = str_replace(' – ', ', ', strtolower($title));
|
||||
|
||||
if (!empty($metaComplement))
|
||||
{
|
||||
$smarty->assign('meta_title', str_replace(' - '.Configuration::get('PS_SHOP_NAME'), ' – '.$metaComplement.' - '.Configuration::get('PS_SHOP_NAME'), $categoryMetas['meta_title']));
|
||||
$smarty->assign('meta_description', rtrim($categoryTitle.' – '.$metaComplement.' – '.$categoryMetas['meta_description'], ' – '));
|
||||
}
|
||||
if (!empty($metaKeyWordsComplement))
|
||||
$smarty->assign('meta_keywords', rtrim($categoryTitle.', '.$metaKeyWordsComplement.', '.$categoryMetas['meta_keywords'], ', '));
|
||||
|
||||
Tools::addJS(($this->_path).'blocklayered.js');
|
||||
Tools::addJS(_PS_JS_DIR_.'jquery/jquery-ui-1.8.10.custom.min.js');
|
||||
Tools::addCSS(_PS_CSS_DIR_.'jquery-ui-1.8.10.custom.css', 'all');
|
||||
@@ -795,7 +950,7 @@ class BlockLayered extends Module
|
||||
<script type="text/javascript">
|
||||
$(\'#url-indexer\').click(function() {
|
||||
if (this.cursor == undefined)
|
||||
this.cursor = 0;
|
||||
this.cursor = {};
|
||||
|
||||
if (this.legend == undefined)
|
||||
this.legend = $(this).html();
|
||||
@@ -806,47 +961,51 @@ class BlockLayered extends Module
|
||||
if (this.running == true)
|
||||
return false;
|
||||
|
||||
$(\'.ajax-message\').hide();
|
||||
|
||||
this.running = true;
|
||||
|
||||
this.categories = '.Tools::jsonEncode($categoryList).';
|
||||
|
||||
$(this).html(this.legend+\' (in progress, 0/\'+this.categories.length+\')\');
|
||||
if (typeof(this.restartAllowed) == \'undefined\' || this.restartAllowed)
|
||||
{
|
||||
$(this).html(this.legend+\' (in progress)\');
|
||||
$(\'#indexing-warning\').show();
|
||||
}
|
||||
|
||||
this.restartAllowed = false;
|
||||
|
||||
var first = true;
|
||||
var it = this;
|
||||
$(this.categories).each(function(cursor, idCategory) {
|
||||
it.cursor = cursor;
|
||||
if(cursor == 0) {
|
||||
var truncate = 1;
|
||||
}
|
||||
else {
|
||||
var truncate = 0;
|
||||
}
|
||||
it.idCategory = idCategory;
|
||||
$.ajax({
|
||||
url: it.href.replace(\'&truncate=1\',\'\')+\'&id_category=\'+it.idCategory+\'&truncate=\'+truncate,
|
||||
context: it,
|
||||
url: this.href+\'&ajax=1&cursor=\'+this.cursor,
|
||||
context: this,
|
||||
dataType: \'json\',
|
||||
async: false,
|
||||
success: function(res) {
|
||||
$(this).html(this.legend+\' (in progress, \'+(parseInt(it.cursor)+1)+\'/\'+it.categories.length+\')\');
|
||||
},
|
||||
error: function(res) {
|
||||
alert(\'Indexation failed\');
|
||||
success: function(res)
|
||||
{
|
||||
this.running = false;
|
||||
if (res.result)
|
||||
{
|
||||
this.cursor = 0;
|
||||
$(\'#indexing-warning\').hide();
|
||||
$(it).html(this.legend+\' (failed)\');
|
||||
it.cursor = 0;
|
||||
$(this).html(this.legend);
|
||||
$(\'#ajax-message-ok span\').html(\''.$this->l('Url indexation finished').'\');
|
||||
$(\'#ajax-message-ok\').show();
|
||||
return;
|
||||
}
|
||||
this.cursor = res.cursor;
|
||||
var cursorObj = JSON.parse(this.cursor);
|
||||
$(this).html(this.legend+\' (in progress, \'+(cursorObj.total / cursorObj.nb_posibilities * 100).toFixed(2) +\'%)\');
|
||||
this.click();
|
||||
},
|
||||
error: function(res)
|
||||
{
|
||||
this.restartAllowed = true;
|
||||
$(\'#indexing-warning\').hide();
|
||||
$(\'#ajax-message-ko span\').html(\''.$this->l('Url indexation failed').'\');
|
||||
$(\'#ajax-message-ko\').show();
|
||||
$(this).html(this.legend);
|
||||
|
||||
this.cursor = 0;
|
||||
this.running = false;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$(this).html(this.legend);
|
||||
$(\'#indexing-warning\').hide();
|
||||
this.running = false;
|
||||
|
||||
return false;
|
||||
});
|
||||
$(\'.ajaxcall\').each(function(it, elm) {
|
||||
@@ -1466,9 +1625,14 @@ class BlockLayered extends Module
|
||||
return $this->products;
|
||||
}
|
||||
|
||||
public function generateFiltersBlockNew($selectedFilters = array())
|
||||
public function getFilterBlock($selectedFilters = array())
|
||||
{
|
||||
global $cookie, $smarty;
|
||||
global $cookie;
|
||||
static $cache = null;
|
||||
|
||||
if (is_array($cache)) {
|
||||
return $cache;
|
||||
}
|
||||
|
||||
$id_parent = (int)Tools::getValue('id_category', Tools::getValue('id_category_layered', 1));
|
||||
if ($id_parent == 1)
|
||||
@@ -1476,7 +1640,6 @@ class BlockLayered extends Module
|
||||
|
||||
$parent = new Category((int)$id_parent);
|
||||
|
||||
|
||||
/* Get the filters for the current category */
|
||||
$filters = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('SELECT * FROM '._DB_PREFIX_.'layered_category WHERE id_category = '.(int)$id_parent.' GROUP BY `type`, id_value ORDER BY position ASC');
|
||||
// Remove all empty selected filters
|
||||
@@ -1775,10 +1938,11 @@ class BlockLayered extends Module
|
||||
//generate SEO link
|
||||
$optionCheckedArray = array();
|
||||
$paramGroupSelectedArray = array();
|
||||
$titleValues = array();
|
||||
$link = new Link();
|
||||
|
||||
$linkBase = $link->getCategoryLink($id_parent,Category::getLinkRewrite($id_parent, (int)($cookie->id_lang)), (int)($cookie->id_lang));
|
||||
$filterBlockList = array();
|
||||
|
||||
foreach ($filterBlocks as $typeFilter)
|
||||
{
|
||||
$paramGroupSelected = '';
|
||||
@@ -1788,6 +1952,9 @@ class BlockLayered extends Module
|
||||
{
|
||||
$paramGroupSelected .= '-'.Tools::link_rewrite($value['name']);
|
||||
$paramGroupSelectedArray [Tools::link_rewrite($typeFilter['name'])][] = Tools::link_rewrite($value['name']);
|
||||
if (!isset($titleValues[$typeFilter['name']]))
|
||||
$titleValues[$typeFilter['name']] = array();
|
||||
$titleValues[$typeFilter['name']][] = $value['name'];
|
||||
}
|
||||
else
|
||||
$paramGroupSelectedArray [Tools::link_rewrite($typeFilter['name'])][] = array();
|
||||
@@ -1822,6 +1989,7 @@ class BlockLayered extends Module
|
||||
$typeFilter['values'][$key]['link'] = $linkBase.$parametersLink;
|
||||
}
|
||||
}
|
||||
|
||||
$nFilters = 0;
|
||||
if(isset($selectedFilters['price']))
|
||||
if($priceArray['min'] == $selectedFilters['price'][0] && $priceArray['max'] == $selectedFilters['price'][1])
|
||||
@@ -1833,9 +2001,17 @@ class BlockLayered extends Module
|
||||
foreach ($selectedFilters AS $filters)
|
||||
$nFilters += sizeof($filters);
|
||||
|
||||
$smarty->assign(array('layered_show_qties' => (int)Configuration::get('PS_LAYERED_SHOW_QTIES'), 'id_category_layered' => (int)$id_parent,
|
||||
'selected_filters' => $selectedFilters, 'n_filters' => (int)$nFilters, 'nbr_filterBlocks' => sizeof($filterBlocks), 'filters' => $filterBlocks));
|
||||
$cache = array('layered_show_qties' => (int)Configuration::get('PS_LAYERED_SHOW_QTIES'), 'id_category_layered' => (int)$id_parent,
|
||||
'selected_filters' => $selectedFilters, 'n_filters' => (int)$nFilters, 'nbr_filterBlocks' => sizeof($filterBlocks), 'filters' => $filterBlocks,
|
||||
'title_values' => $titleValues);
|
||||
|
||||
return $cache;
|
||||
}
|
||||
|
||||
public function generateFiltersBlock($selectedFilters)
|
||||
{
|
||||
global $smarty;
|
||||
$smarty->assign($this->getFilterBlock($selectedFilters));
|
||||
return $this->display(__FILE__, 'blocklayered.tpl');
|
||||
}
|
||||
|
||||
@@ -1968,15 +2144,6 @@ class BlockLayered extends Module
|
||||
return array('where' => $queryFilters);
|
||||
}
|
||||
|
||||
/*
|
||||
* This function must be improved
|
||||
* For the moment, we don't "filter filters"
|
||||
*/
|
||||
public function generateFiltersBlock($selectedFilters = array())
|
||||
{
|
||||
return self::generateFiltersBlockNew($selectedFilters);
|
||||
}
|
||||
|
||||
public function ajaxCallBackOffice($categoryBox = array(), $id_layered_filter = NULL)
|
||||
{
|
||||
global $cookie;
|
||||
|
||||
Reference in New Issue
Block a user