first commit

This commit is contained in:
2024-11-11 18:46:54 +01:00
commit a630d17338
25634 changed files with 4923715 additions and 0 deletions

View File

@@ -0,0 +1,91 @@
<?php
/**
* LiteSpeed Cache for Prestashop.
*
* NOTICE OF LICENSE
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see https://opensource.org/licenses/GPL-3.0 .
*
* @author LiteSpeed Technologies
* @copyright Copyright (c) 2020 LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
* @license https://opensource.org/licenses/GPL-3.0
*/
use LiteSpeedCacheEsiModConf as EsiConf;
class LscStCompare extends LscIntegration
{
const NAME = 'stcompare';
protected function init()
{
$confData = [
EsiConf::FLD_PRIV => 1,
EsiConf::FLD_PURGE_CONTROLLERS => 'StCompareCompareModuleFrontController?custom_handler',
EsiConf::FLD_IGNORE_EMPTY => 1,
];
$this->esiConf = new EsiConf(self::NAME, EsiConf::TYPE_INTEGRATED, $confData);
$this->esiConf->setCustomHandler($this);
$this->registerEsiModule();
$this->addCheckPurgeControllerCustomHandler('StCompareCompareModuleFrontController', $this);
return true;
}
public function canInject(&$params)
{
if ($params['pt'] != 'rw') {
return false;
}
if (stripos($params['h'], 'Product') !== false) {
// product level, adjust params
$pid = Tools::getValue('id_product');
$params['id_product'] = $pid;
// item cache is for related esi block, do not save at product id level
}
return true;
}
public function getTags($params)
{
$tags = ['compare'];
if (isset($params['id_product'])) {
$tags[] = 'compare_' . $params['id_product'];
}
return $tags;
}
public function getNoItemCache($params)
{
return isset($params['id_product']);
}
//id_product,StCompareCompareModuleFrontController?action'
protected function checkPurgeControllerCustomHandler($lowercase_controller_class, &$tags)
{
// * @param type $tags = ['pub' => [], 'priv' => []];
if (Tools::getValue('action') == false) {
return;
}
$pid = Tools::getValue('id_product');
if ($pid) {
$tags['priv'][] = "compare_$pid"; // addCompareProduct, deleteCompareProduct
} else {
$tags['priv'][] = 'compare'; // deleteAllCompareProducts
}
}
}
LscStCompare::register();

View File

@@ -0,0 +1,46 @@
<?php
/**
* LiteSpeed Cache for Prestashop.
*
* NOTICE OF LICENSE
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see https://opensource.org/licenses/GPL-3.0 .
*
* @author LiteSpeed Technologies
* @copyright Copyright (c) 2020 LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
* @license https://opensource.org/licenses/GPL-3.0
*/
use LiteSpeedCacheEsiModConf as EsiConf;
class LscStCustomerSignIn extends LscIntegration
{
const NAME = 'stcustomersignin';
protected function init()
{
$confData = [
EsiConf::FLD_PRIV => 1,
EsiConf::FLD_TAG => LiteSpeedCacheConfig::TAG_SIGNIN,
EsiConf::FLD_PURGE_EVENTS => 'actionCustomerLogoutAfter, actionAuthentication',
EsiConf::FLD_RENDER_WIDGETS => '*',
EsiConf::FLD_IGNORE_EMPTY => 1,
];
$this->esiConf = new EsiConf(self::NAME, EsiConf::TYPE_INTEGRATED, $confData);
return $this->registerEsiModule();
}
}
LscStCustomerSignIn::register();

View File

@@ -0,0 +1,109 @@
<?php
/**
* LiteSpeed Cache for Prestashop.
*
* NOTICE OF LICENSE
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see https://opensource.org/licenses/GPL-3.0 .
*
* @author LiteSpeed Technologies
* @copyright Copyright (c) 2020 LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
* @license https://opensource.org/licenses/GPL-3.0
*/
use LiteSpeedCacheEsiModConf as EsiConf;
class LscStLovedProduct extends LscIntegration
{
const NAME = 'stlovedproduct';
protected function init()
{
$confData = [
EsiConf::FLD_PRIV => 1,
EsiConf::FLD_PURGE_CONTROLLERS => 'StLovedProductMyLovedModuleFrontController?custom_handler',
EsiConf::FLD_IGNORE_EMPTY => 0,
];
$this->esiConf = new EsiConf(self::NAME, EsiConf::TYPE_INTEGRATED, $confData);
$this->esiConf->setCustomHandler($this);
$this->registerEsiModule();
LiteSpeedCacheConfig::getInstance()->overrideGuestMode();
LiteSpeedCacheConfig::getInstance()->enforceDiffCustomerGroup(2); // $diffCustomerGroup 0: No; 1: Yes; 2: login_out
$this->addCheckPurgeControllerCustomHandler('StLovedProductMyLovedModuleFrontController', $this);
return true;
}
public function canInject(&$params)
{
switch ($params['pt']) { // param type
case 'rw':
if (stripos($params['h'], 'Product') !== false) {
// product level, adjust params
$pid = Tools::getValue('id_product');
$params['id_product'] = $pid;
}
return true;
case 'ch':
return ('hookdisplaySideBar' == $params['mt']);
default:
return false;
}
}
public function getNoItemCache($params)
{
return isset($params['id_product']);
}
public function getTags($params)
{
$tags = ['stloved'];
if ($this->isLoggedIn()) { // private tags
if (isset($params['id_product'])) {
$tags[] = 'public:stloved_' . $params['id_product'];
}
} else { // public tags
if (isset($params['id_product'])) {
$tags[] = 'stloved_' . $params['id_product'];
}
}
return $tags;
}
public function isPrivate($params)
{
// for non-logged-in user, it's public ESI
return $this->isLoggedIn();
}
//id_product,StLovedProductMyLovedModuleFrontController?action'
protected function checkPurgeControllerCustomHandler($lowercase_controller_class, &$tags)
{
// * @param type $tags = ['pub' => [], 'priv' => []];
if (Tools::getValue('action') == false) {
return;
}
$pid = Tools::getValue('id_source');
if ($pid) {
$tags['pub'][] = "stloved_$pid"; // addCompareProduct, deleteCompareProduct
}
$tags['priv'][] = 'stloved'; // private loved ESI block
}
}
LscStLovedProduct::register();

View File

@@ -0,0 +1,49 @@
<?php
/**
* LiteSpeed Cache for Prestashop.
*
* NOTICE OF LICENSE
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see https://opensource.org/licenses/GPL-3.0 .
*
* @author LiteSpeed Technologies
* @copyright Copyright (c) 2020 LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
* @license https://opensource.org/licenses/GPL-3.0
*/
use LiteSpeedCacheEsiModConf as EsiConf;
class LscStNotification extends LscIntegration
{
const NAME = 'stnotification';
protected function init()
{
$confData = [
EsiConf::FLD_PRIV => 1,
EsiConf::FLD_TAG => 'stnotification',
EsiConf::FLD_ASVAR => 1,
EsiConf::FLD_ONLY_CACHE_EMPTY => 1,
EsiConf::FLD_IGNORE_EMPTY => 0,
EsiConf::FLD_RENDER_WIDGETS => '*',
];
$this->esiConf = new EsiConf(self::NAME, EsiConf::TYPE_INTEGRATED, $confData);
$this->registerEsiModule();
LiteSpeedCacheConfig::getInstance()->overrideGuestMode();
return true;
}
}
LscStNotification::register();

View File

@@ -0,0 +1,47 @@
<?php
/**
* LiteSpeed Cache for Prestashop.
*
* NOTICE OF LICENSE
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see https://opensource.org/licenses/GPL-3.0 .
*
* @author LiteSpeed Technologies
* @copyright Copyright (c) 2020 LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
* @license https://opensource.org/licenses/GPL-3.0
*/
use LiteSpeedCacheEsiModConf as EsiConf;
class LscStShoppingcart extends LscIntegration
{
const NAME = 'stshoppingcart';
protected function init()
{
$confData = [
EsiConf::FLD_PRIV => 1,
EsiConf::FLD_TAG => LiteSpeedCacheConfig::TAG_CART,
EsiConf::FLD_PURGE_CONTROLLERS => 'CartController?id_product',
EsiConf::FLD_RENDER_WIDGETS => '*',
EsiConf::FLD_HOOK_METHODS => 'hookdisplaySideBar',
EsiConf::FLD_IGNORE_EMPTY => 1,
];
$this->esiConf = new EsiConf(self::NAME, EsiConf::TYPE_INTEGRATED, $confData);
return $this->registerEsiModule();
}
}
LscStShoppingcart::register();

View File

@@ -0,0 +1,49 @@
<?php
/**
* LiteSpeed Cache for Prestashop.
*
* NOTICE OF LICENSE
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see https://opensource.org/licenses/GPL-3.0 .
*
* @author LiteSpeed Technologies
* @copyright Copyright (c) 2020 LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
* @license https://opensource.org/licenses/GPL-3.0
*/
use LiteSpeedCacheEsiModConf as EsiConf;
class LscStSidebar extends LscIntegration
{
const NAME = 'stsidebar';
protected function init()
{
$confData = [
EsiConf::FLD_PRIV => 1,
EsiConf::FLD_TAG => LiteSpeedCacheConfig::TAG_CART,
EsiConf::FLD_HOOK_METHODS => 'hookdisplayRightBar',
EsiConf::FLD_IGNORE_EMPTY => 1,
];
$this->esiConf = new EsiConf(self::NAME, EsiConf::TYPE_INTEGRATED, $confData);
$this->registerEsiModule();
LiteSpeedCacheConfig::getInstance()->overrideGuestMode();
return true;
}
}
LscStSidebar::register();

View File

@@ -0,0 +1,52 @@
<?php
/**
* LiteSpeed Cache for Prestashop.
*
* NOTICE OF LICENSE
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see https://opensource.org/licenses/GPL-3.0 .
*
* @author LiteSpeed Technologies
* @copyright Copyright (c) 2020 LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
* @license https://opensource.org/licenses/GPL-3.0
*/
use LiteSpeedCacheEsiModConf as EsiConf;
class LscStWishlist extends LscIntegration
{
const NAME = 'stwishlist';
protected function init()
{
$confData = [
EsiConf::FLD_PRIV => 1,
EsiConf::FLD_TAG => 'stwish',
EsiConf::FLD_PURGE_CONTROLLERS => 'stwishlistmywishlistModuleFrontController?action',
EsiConf::FLD_HOOK_METHODS => 'hookdisplaySideBar',
EsiConf::FLD_IGNORE_EMPTY => 0,
];
$this->esiConf = new EsiConf(self::NAME, EsiConf::TYPE_INTEGRATED, $confData);
$this->esiConf->setCustomHandler($this);
$this->registerEsiModule();
LiteSpeedCacheConfig::getInstance()->enforceDiffCustomerGroup(2); // $diffCustomerGroup 0: No; 1: Yes; 2: login_out
return true;
}
}
LscStWishlist::register();

View File

@@ -0,0 +1,47 @@
<?php
/**
* LiteSpeed Cache for Prestashop.
*
* NOTICE OF LICENSE
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see https://opensource.org/licenses/GPL-3.0 .
*
* @author LiteSpeed Technologies
* @copyright Copyright (c) 2020 LiteSpeed Technologies, Inc. (https://www.litespeedtech.com)
* @license https://opensource.org/licenses/GPL-3.0
*/
/**
* This is shared for panda and transform theme from Sunnytoo.com
* You can comment out the ST Modules not used.
* Do not support ViewedProducts, this is not cache friendly
*
*/
include __DIR__ . '/LscStNotification.php';
include __DIR__ . '/LscStShoppingcart.php';
include __DIR__ . '/LscStCustomerSignIn.php';
// You can comment out if you do not use stcompare
include __DIR__ . '/LscStCompare.php';
// You can comment out if you do not use stlovedproduct
include __DIR__ . '/LscStLovedProduct.php';
// You can comment out if you do not use stwishlist
include __DIR__ . '/LscStWishlist.php';
// You can comment out if you do not use stsidebar
include __DIR__ . '/LscStSidebar.php';