diff --git a/.vscode/ftp-kr.sync.cache.json b/.vscode/ftp-kr.sync.cache.json index 93787ae5..bbc757a0 100644 --- a/.vscode/ftp-kr.sync.cache.json +++ b/.vscode/ftp-kr.sync.cache.json @@ -116,21 +116,21 @@ }, "google-merchant_id-1.xml": { "type": "-", - "size": 62453577, + "size": 62380647, "lmtime": 0, "modified": true }, "google-merchant_id-2.xml": { "type": "-", - "size": 2687503, + "size": 2691879, "lmtime": 0, "modified": true }, ".htaccess": { "type": "-", - "size": 13595, + "size": 12165, "lmtime": 0, - "modified": false + "modified": true }, ".htaccess.2025-05-22-1747946142": { "type": "-", @@ -346,20 +346,20 @@ "components": {}, "dr_materac.css": { "type": "-", - "size": 81186, - "lmtime": 1753549288918, + "size": 81513, + "lmtime": 1753954558589, "modified": false }, "dr_materac.css.map": { "type": "-", - "size": 230130, - "lmtime": 1753549288918, + "size": 231003, + "lmtime": 1753954558589, "modified": false }, "dr_materac.scss": { "type": "-", - "size": 105034, - "lmtime": 1753549288326, + "size": 105413, + "lmtime": 1753954558025, "modified": false }, "index.php": { diff --git a/override/.htaccess b/override/.htaccess new file mode 100644 index 00000000..3de9e400 --- /dev/null +++ b/override/.htaccess @@ -0,0 +1,10 @@ +# Apache 2.2 + + Order deny,allow + Deny from all + + +# Apache 2.4 + + Require all denied + diff --git a/override/classes/CMSCategory.php b/override/classes/CMSCategory.php new file mode 100644 index 00000000..76344796 --- /dev/null +++ b/override/classes/CMSCategory.php @@ -0,0 +1,34 @@ +controller; + if ($ctrl instanceof CmsController && !CmsController::$initialized && !$this->active && Tools::getIsset('id_employee') && Tools::getIsset('adtoken')) { + $tab = 'AdminCmsContent'; + if (Tools::getAdminToken($tab . (int) Tab::getIdFromClassName($tab) . (int) Tools::getValue('id_employee')) == Tools::getValue('adtoken')) { + $this->active = 1; + } + } + } +} diff --git a/override/classes/Cart.php b/override/classes/Cart.php new file mode 100644 index 00000000..2ec607d4 --- /dev/null +++ b/override/classes/Cart.php @@ -0,0 +1,56 @@ +getDiscountTotal($withTaxes); + if($type==Cart::ONLY_DISCOUNTS) + $total = $total+$totalDiscount; + else + $total= $total - $totalDiscount; + } + if(Module::isEnabled('ets_payment_with_fee')) + { + if($only_cart || $type!=Cart::BOTH) + return $total; + if($type== Cart::BOTH) + { + $custom_payment = Module::getInstanceByName('ets_payment_with_fee'); + $fee = $custom_payment->getFeePayOrderTotal($products,$withTaxes); + } + else + $fee = 0; + if($fee_payment) + return $fee; + return $fee + $total; + } + return $total; + } +} \ No newline at end of file diff --git a/override/classes/CartRule.php b/override/classes/CartRule.php new file mode 100644 index 00000000..880e55f4 --- /dev/null +++ b/override/classes/CartRule.php @@ -0,0 +1,65 @@ +haveCartRuleToday(); + } + else + return true; + } + /* + * module: ets_promotion + * date: 2023-11-25 09:55:38 + * version: 1.1.9 + */ + public static function getCustomerCartRules($id_lang, $id_customer, $active = false, $includeGeneric = true, $inStock = false, Cart $cart = null, $free_shipping_only = false, $highlight_only = false) + { + $result = parent::getCustomerCartRules($id_lang,$id_customer,$active,$includeGeneric,$inStock,$cart,$free_shipping_only,$highlight_only); + Module::getInstanceByName('ets_promotion')->getCustomerCartRules($result,$id_customer,$highlight_only); + return $result; + } + /* + * module: ets_promotion + * date: 2023-11-25 09:55:38 + * version: 1.1.9 + */ + public function delete() + { + $r = parent::delete(); + if(!Configuration::getGlobalValue('PS_CART_RULE_FEATURE_ACTIVE')) + { + Configuration::updateGlobalValue( + 'PS_CART_RULE_FEATURE_ACTIVE', + CartRule::isCurrentlyUsed('cart_rule', true) || Ets_pr_rule::isCurrentlyUsed('ets_pr_rule', true) + ); + } + return $r; + } +} \ No newline at end of file diff --git a/override/classes/Category.php b/override/classes/Category.php new file mode 100644 index 00000000..99e43d1a --- /dev/null +++ b/override/classes/Category.php @@ -0,0 +1,34 @@ +controller; + if ($ctrl instanceof CategoryController && !CategoryController::$initialized && !$this->active && Tools::getIsset('id_employee') && Tools::getIsset('adtoken')) { + $tab = 'AdminCategories'; + if (Tools::getAdminToken($tab . (int) Tab::getIdFromClassName($tab) . (int) Tools::getValue('id_employee')) == Tools::getValue('adtoken')) { + $this->active = 1; + } + } + } +} diff --git a/override/classes/Dispatcher.php b/override/classes/Dispatcher.php new file mode 100644 index 00000000..c069d586 --- /dev/null +++ b/override/classes/Dispatcher.php @@ -0,0 +1,280 @@ + +* @copyright 2018 Areama +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of Areama +*/ +class Dispatcher extends DispatcherCore +{ + /* + * module: arseopro + * date: 2025-05-30 11:21:28 + * version: 1.8.8 + */ + protected static $moduleInstance; + + /* + * module: arseopro + * date: 2025-05-30 11:21:28 + * version: 1.8.8 + */ + public function arSeoProOverrideVersion() + { + return '1.8.8'; + } + + /* + * module: arseopro + * date: 2025-05-30 11:21:28 + * version: 1.8.8 + */ + public function getModuleInstance() + { + if (self::$moduleInstance == null) { + self::$moduleInstance = Module::getInstanceByName('arseopro'); + } + return self::$moduleInstance; + } + + /* + * module: arseopro + * date: 2025-05-30 11:21:28 + * version: 1.8.8 + */ + public function getRoutes() + { + return $this->routes; + } + /* + * module: arseopro + * date: 2025-05-30 11:21:28 + * version: 1.8.8 + */ + public function getRequestUri() + { + return $this->request_uri; + } + /* + * module: arseopro + * date: 2025-05-30 11:21:28 + * version: 1.8.8 + */ + protected function loadRoutes($id_shop = null) + { + parent::loadRoutes($id_shop); + if (Module::isEnabled('arseopro')) { + $module = Module::getInstanceByName('arseopro'); + $this->routes = $module->getUrlConfig()->dispatcherLoadRoutes($this->routes, $this); + } + } + /* + * module: arseopro + * date: 2025-05-30 11:21:28 + * version: 1.8.8 + */ + protected function setRequestUri() + { + parent::setRequestUri(); + $remove_enabled = Configuration::get('ARS_REMOVE_DEF_LANG'); + $current_iso_lang = Tools::getValue('isolang'); + if ($this->use_routes && Language::isMultiLanguageActivated() && !$current_iso_lang && $remove_enabled) { + $_GET['isolang'] = Language::getIsoById(Configuration::get('PS_LANG_DEFAULT')); + } + } + /* + * module: arseopro + * date: 2025-05-30 11:21:28 + * version: 1.8.8 + */ + public function arSEOredirect() + { + if (Module::isInstalled('arseopro') && Module::isEnabled('arseopro') && Configuration::get('ARSR_ENABLE')) { + $module = $this->getModuleInstance(); + $module->redirect(); + } + } + + /* + * module: arseopro + * date: 2025-05-30 11:21:28 + * version: 1.8.8 + */ + public function getController($id_shop = null) + { + if (!Module::isEnabled('arseopro')) { + return parent::getController($id_shop); + } + if (defined('_PS_ADMIN_DIR_')) { + $_GET['controllerUri'] = Tools::getvalue('controller'); + } + + $this->arSEOredirect(); + + if ($this->controller) { + $_GET['controller'] = $this->controller; + return $this->controller; + } + if (isset(Context::getContext()->shop) && $id_shop === null) { + $id_shop = (int)Context::getContext()->shop->id; + } + $id_lang = Context::getContext()->language->id; + $controller = Tools::getValue('controller'); + if (isset($controller) && is_string($controller) && preg_match('/^([0-9a-z_-]+)\?(.*)=(.*)$/Ui', $controller, $m)) { + $controller = $m[1]; + if (isset($_GET['controller'])) { + $_GET[$m[2]] = $m[3]; + } elseif (isset($_POST['controller'])) { + $_POST[$m[2]] = $m[3]; + } + } + if (!Validate::isControllerName($controller)) { + $controller = false; + } + if ($this->use_routes && !$controller && !defined('_PS_ADMIN_DIR_')) { + if (!$this->request_uri) { + return Tools::strtolower($this->controller_not_found); + } + $controller = $this->controller_not_found; + $test_request_uri = preg_replace('/(=http:\/\/)/', '=', $this->request_uri); + if (!preg_match('/\.(gif|jpe?g|png|css|js|ico)$/i', parse_url($test_request_uri, PHP_URL_PATH))) { + if ($this->empty_route) { + $this->addRoute( + $this->empty_route['routeID'], + $this->empty_route['rule'], + $this->empty_route['controller'], + $id_lang, + array(), + array(), + $id_shop + ); + } + list($uri) = explode('?', $this->request_uri); + if (Tools::file_exists_cache(_PS_ROOT_DIR_.$uri)) { + return $controller; + } + if (isset($this->routes[$id_shop][$id_lang])) { + $maybe = array(); + $lastRoute = array(); + foreach ($this->routes[$id_shop][$id_lang] as $route_id => $route) { + if (preg_match($route['regexp'], $uri, $m)) { + if (Module::isEnabled('arseopro')) { + $module = Module::getInstanceByName('arseopro'); + if ($module->getUrlConfig()->isRouteExists($route_id)) { + $m = $module->getUrlConfig()->normalizeRegexResult($m); + $preDispatcher = $module->getUrlConfig()->getRoutePreDispatcher($route_id); + if ($preDispatcher && Tools::isCallable(array($preDispatcher['module'], $preDispatcher['function']))) { + $modulePreDispatcher = call_user_func(array( + $preDispatcher['module'], + $preDispatcher['function'] + ), $uri, $route_id, $route, $m, $id_lang, $id_shop); + $info = $module->getUrlConfig()->getEmptyPreDispatcherResponse(); + if (is_array($modulePreDispatcher)) { + $info = array_merge($info, $modulePreDispatcher); + } + } else { + $info = $module->getUrlConfig()->preDispatch($uri, $route_id, $route, $m, $id_lang, $id_shop); + } + $lastRoute = array( + 'route_id' => $route_id, + 'm' => $m, + 'route' => $route, + 'useIfProbably' => $info->useIfProbably + ); + + if ($info->controllerMatched) { + if ($info->id && $info->property) { + $_GET[$info->property] = $info->id; + } + } else { + if ($info->controllerProbably) { + $maybe[$route_id] = array( + 'm' => $m, + 'route' => $route, + 'useIfProbably' => $info->useIfProbably + ); + } + continue; + } + } + } + + $maybe = array(); + $lastRoute = array(); + foreach ($m as $k => $v) { + if (!is_numeric($k)) { + $_GET[$k] = $v; + } + } + $controller = $route['controller'] ? $route['controller'] : Tools::getValue('controller'); + if (!empty($route['params'])) { + foreach ($route['params'] as $k => $v) { + $_GET[$k] = $v; + } + } + if (preg_match('#module-([a-z0-9_-]+)-([a-z0-9_]+)$#i', $controller, $m)) { + $_GET['module'] = $m[1]; + $_GET['fc'] = 'module'; + $controller = $m[2]; + } + if (Tools::getValue('fc') == 'module') { + $this->front_controller = self::FC_MODULE; + } + break; + } + } + + if (!$maybe && $lastRoute) { + $maybe[$lastRoute['route_id']] = $lastRoute; + } + if ($maybe) { + foreach ($maybe as $routeData) { + $m = $routeData['m']; + $route = $routeData['route']; + if ($routeData['useIfProbably']) { + foreach ($m as $k => $v) { + if (!is_numeric($k)) { + $_GET[$k] = $v; + } + } + $controller = $route['controller'] ? $route['controller'] : Tools::getValue('controller'); + if (!empty($route['params'])) { + foreach ($route['params'] as $k => $v) { + $_GET[$k] = $v; + } + } + if (preg_match('#module-([a-z0-9_-]+)-([a-z0-9_]+)$#i', $controller, $m)) { + $_GET['module'] = $m[1]; + $_GET['fc'] = 'module'; + $controller = $m[2]; + } + if (Tools::getValue('fc') == 'module') { + $this->front_controller = self::FC_MODULE; + } + break; + } + } + } + } + } + if ($controller == 'index' || preg_match('/^\/index.php(?:\?.*)?$/', $this->request_uri)) { + $controller = $this->useDefaultController(); + } + } + $this->controller = str_replace('-', '', $controller); + $_GET['controller'] = $this->controller; + return $this->controller; + } +} diff --git a/override/classes/Hook.php b/override/classes/Hook.php new file mode 100644 index 00000000..564e3123 --- /dev/null +++ b/override/classes/Hook.php @@ -0,0 +1,73 @@ +blockModuleCache($modulesToInvoke, $hookName); + } + return !empty($modulesToInvoke) ? $modulesToInvoke : false; + } + /* + * module: cookiesplus + * date: 2025-03-31 23:34:24 + * version: 1.6.0 + */ + public static function coreCallHook($module, $method, $params) + { + $headersBeforeExecution = headers_list(); + $display = parent::coreCallHook($module, $method, $params); + if (Module::isEnabled('cookiesplus')) { + $forceDisplay = false; + $cookiesPlus = Module::getInstanceByName('cookiesplus'); + $cookiesPlus->blockModuleCode([ + 'display' => &$display, + 'module' => &$module, + 'hookName' => &$method, + 'params' => &$params, + 'forceDisplay' => &$forceDisplay, + 'headersBeforeExecution' => $headersBeforeExecution, + ]); + if ($forceDisplay) { + return $display; + } + } + return $display; + } + /* + * module: cookiesplus + * date: 2025-03-31 23:34:24 + * version: 1.6.0 + */ + public static function coreRenderWidget($module, $hook_name, $params) + { + $headersBeforeExecution = headers_list(); + $display = parent::coreRenderWidget($module, $hook_name, $params); + if (Module::isEnabled('cookiesplus')) { + $forceDisplay = false; + $cookiesPlus = Module::getInstanceByName('cookiesplus'); + $cookiesPlus->blockModuleCode([ + 'display' => &$display, + 'module' => &$module, + 'hookName' => &$hook_name, + 'params' => &$params, + 'forceDisplay' => &$forceDisplay, + 'headersBeforeExecution' => $headersBeforeExecution, + ]); + if ($forceDisplay) { + return $display; + } + } + return $display; + } +} diff --git a/override/classes/Link.php b/override/classes/Link.php new file mode 100644 index 00000000..250c39f2 --- /dev/null +++ b/override/classes/Link.php @@ -0,0 +1,429 @@ + +* @copyright 2018 Areama +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of Areama +*/ +class Link extends LinkCore +{ + /* + * module: arseopro + * date: 2025-05-30 11:21:28 + * version: 1.8.8 + */ + public static $cacheDisableDefaultAttributeAnchor; + /* + * module: arseopro + * date: 2025-05-30 11:21:28 + * version: 1.8.8 + */ + public static $cacheDisableAnchor; + /* + * module: arseopro + * date: 2025-05-30 11:21:28 + * version: 1.8.8 + */ + public static $cacheDisableDefaultAttribute; + /* + * module: arseopro + * date: 2025-05-30 11:21:28 + * version: 1.8.8 + */ + public static $cacheDisableAnchorIds; + + /* + * module: arseopro + * date: 2025-05-30 11:21:28 + * version: 1.8.8 + */ + public function arSeoProOverrideVersion() + { + return '1.8.8'; + } + + /* + * module: arseopro + * date: 2025-05-30 11:21:28 + * version: 1.8.8 + */ + protected function getLangLink($id_lang = null, Context $context = null, $id_shop = null) + { + if (!Module::isEnabled('arseopro')) { + return parent::getLangLink($id_lang, $context, $id_shop); + } + if (Configuration::get('ARS_REMOVE_DEF_LANG', null, null, $id_shop) && + Language::isMultiLanguageActivated()) { + if (!$id_lang) { + $id_lang = $context->language->id; + } + if ($id_lang == Configuration::get('PS_LANG_DEFAULT', null, null, $id_shop)) { + return ''; + } + } + return parent::getLangLink($id_lang, $context, $id_shop); + } + /* + * module: arseopro + * date: 2025-05-30 11:21:28 + * version: 1.8.8 + */ + public function getCategoryLink( + $category, + $alias = null, + $id_lang = null, + $selected_filters = null, + $id_shop = null, + $relative_protocol = false + ) { + if (!Module::isEnabled('arseopro')) { + return parent::getCategoryLink($category, $alias, $id_lang, $selected_filters, $id_shop, $relative_protocol); + } + + if (!$id_lang) { + $id_lang = Context::getContext()->language->id; + } + $url = $this->getBaseLink($id_shop, null, $relative_protocol).$this->getLangLink($id_lang, null, $id_shop); + if (!is_object($category)) { + if (is_array($category) && isset($category['id_category'])) { + $category = new Category($category['id_category'], $id_lang); + } elseif ((int)$category) { + $category = new Category((int)$category, $id_lang); + } else { + return null; + throw new PrestaShopException('Invalid category vars'); + } + } + $params = array(); + $params['id'] = $category->id; + $params['rewrite'] = (!$alias) ? $category->link_rewrite : $alias; + $params['meta_keywords'] = Tools::str2url($category->getFieldByLang('meta_keywords')); + $params['meta_title'] = Tools::str2url($category->getFieldByLang('meta_title')); + $dispatcher = Dispatcher::getInstance(); + if ($dispatcher->hasKeyword('category_rule', $id_lang, 'categories', $id_shop)) { + $cats = array(); + foreach ($category->getParentsCategories($id_lang) as $cat) { + if (!in_array($cat['id_category'], Link::$category_disable_rewrite)) { + $cats[] = $cat['link_rewrite']; + } + } + $cats = array_reverse($cats); + array_pop($cats); + $params['categories'] = implode('/', $cats); + } + $selected_filters = is_null($selected_filters) ? '' : $selected_filters; + if (empty($selected_filters)) { + $rule = 'category_rule'; + } else { + $rule = 'layered_rule'; + $params['selected_filters'] = $selected_filters; + } + return $url.Dispatcher::getInstance()->createUrl($rule, $id_lang, $params, $this->allow, '', $id_shop); + } + /* + * module: arseopro + * date: 2025-05-30 11:21:28 + * version: 1.8.8 + */ + public function getCMSCategoryLink( + $cms_category, + $alias = null, + $id_lang = null, + $id_shop = null, + $relative_protocol = false + ) { + if (!Module::isEnabled('arseopro')) { + return parent::getCMSCategoryLink($cms_category, $alias, $id_lang, $id_shop, $relative_protocol); + } + + if (!$id_lang) { + $id_lang = Context::getContext()->language->id; + } + $url = $this->getBaseLink($id_shop, null, $relative_protocol).$this->getLangLink($id_lang, null, $id_shop); + $dispatcher = Dispatcher::getInstance(); + if (!is_object($cms_category)) { + $cms_category = new CMSCategory((int)$cms_category, $id_lang); + } + $params = array(); + $params['id'] = $cms_category->id; + $params['rewrite'] = $cms_category->link_rewrite; + if (is_array($params['rewrite']) && isset($params['rewrite'][(int)$id_lang])) { + $params['rewrite'] = $params['rewrite'][(int)$id_lang]; + } + if ($alias) { + $params['rewrite'] = $alias; + } + $params['meta_keywords'] = $cms_category->meta_keywords; + if (is_array($params['meta_keywords']) && isset($params['meta_keywords'][(int)$id_lang])) { + $params['meta_keywords'] = Tools::str2url($params['meta_keywords'][(int)$id_lang]); + } + $params['meta_title'] = $cms_category->meta_title; + if (is_array($params['meta_title']) && isset($params['meta_title'][(int)$id_lang])) { + $params['meta_title'] = Tools::str2url($params['meta_title'][(int)$id_lang]); + } + if ($dispatcher->hasKeyword('cms_category_rule', $id_lang, 'categories', $id_shop)) { + $cats = array(); + if (Module::isEnabled('arseopro')) { + $module = Module::getInstanceByName('arseopro'); + $categories = $module->getUrlConfig()->cmsCategory->getCMSCategoryParentCategories($cms_category->id, $id_lang); + if ($categories) { + foreach ($categories as $cat) { + $cats[] = $cat['link_rewrite']; + } + $cats = array_reverse($cats); + array_pop($cats); + } + } + $params['categories'] = implode('/', $cats); + } + return $url.$dispatcher->createUrl('cms_category_rule', $id_lang, $params, $this->allow, '', $id_shop); + } + /* + * module: arseopro + * date: 2025-05-30 11:21:28 + * version: 1.8.8 + */ + public function getCMSLink( + $cms, + $alias = null, + $ssl = null, + $id_lang = null, + $id_shop = null, + $relative_protocol = false + ) { + if (!Module::isEnabled('arseopro')) { + return parent::getCMSLink($cms, $alias, $ssl, $id_lang, $id_shop, $relative_protocol); + } + + if (!$id_lang) { + $id_lang = Context::getContext()->language->id; + } + $url = $this->getBaseLink($id_shop, $ssl, $relative_protocol).$this->getLangLink($id_lang, null, $id_shop); + $dispatcher = Dispatcher::getInstance(); + if (!is_object($cms)) { + $cms = new CMS((int)$cms, $id_lang); + } + $params = array(); + $params['id'] = $cms->id; + $params['rewrite'] = $cms->link_rewrite; + if (is_array($params['rewrite']) && isset($params['rewrite'][(int)$id_lang])) { + $params['rewrite'] = $params['rewrite'][(int)$id_lang]; + } + if ($alias) { + $params['rewrite'] = $alias; + } + $params['meta_keywords'] = $cms->meta_keywords; + if (is_array($params['meta_keywords']) && isset($params['meta_keywords'][(int)$id_lang])) { + $params['meta_keywords'] = Tools::str2url($params['meta_keywords'][(int)$id_lang]); + } + $params['meta_title'] = $cms->meta_title; + if (is_array($params['meta_title']) && isset($params['meta_title'][(int)$id_lang])) { + $params['meta_title'] = Tools::str2url($params['meta_title'][(int)$id_lang]); + } + if ($dispatcher->hasKeyword('cms_rule', $id_lang, 'categories', $id_shop)) { + $cats = array(); + $cms_category = new CMSCategory($cms->id_cms_category, $id_lang); + if (Validate::isLoadedObject($cms_category)) { + if (Module::isEnabled('arseopro')) { + $module = Module::getInstanceByName('arseopro'); + $categories = $module->getUrlConfig()->cmsCategory->getCMSCategoryParentCategories($cms_category->id, $id_lang); + if ($categories) { + foreach ($categories as $cat) { + $cats[] = $cat['link_rewrite']; + } + $cats = array_reverse($cats); + } + } + } + $params['categories'] = implode('/', $cats); + } + return $url.$dispatcher->createUrl('cms_rule', $id_lang, $params, $this->allow, '', $id_shop); + } + + /* + * module: arseopro + * date: 2025-05-30 11:21:28 + * version: 1.8.8 + */ + public function getProductLink( + $product, + $alias = null, + $category = null, + $ean13 = null, + $idLang = null, + $idShop = null, + $idProductAttribute = null, + $force_routes = false, + $relativeProtocol = false, + $withIdInAnchor = false, + $extraParams = array(), + $addAnchor = true + ) { + if (!Module::isEnabled('arseopro')) { + return parent::getProductLink($product, $alias, $category, $ean13, $idLang, $idShop, $idProductAttribute, $force_routes, $relativeProtocol, $withIdInAnchor, $extraParams, $addAnchor); + } + + $dispatcher = Dispatcher::getInstance(); + if (!$idLang) { + $idLang = Context::getContext()->language->id; + } + $url = $this->getBaseLink($idShop, null, $relativeProtocol) . $this->getLangLink($idLang, null, $idShop); + $params = array(); + if (!is_object($product)) { + if (is_array($product) && isset($product['id_product'])) { + $params['id'] = $product['id_product']; + } elseif ((int) $product) { + $params['id'] = $product; + } else { + throw new PrestaShopException('Invalid product vars'); + } + } else { + $params['id'] = $product->id; + } + if (!is_object($product)) { + $product = $this->getProductObject($product, $idLang, $idShop); + } + if (self::isDefaultAttributeDisabled()) { + if ($idProductAttribute == $product->cache_default_attribute) { + $params['id_product_attribute'] = 0; + } else { + $params['id_product_attribute'] = $idProductAttribute; + } + } else { + $params['id_product_attribute'] = $idProductAttribute; + } + if ($params['id_product_attribute'] == 0 && (!$dispatcher->hasKeyword('product_rule', $idLang, 'id_product_attribute', $idShop))) { + unset($params['id_product_attribute']); + } + if (!$alias) { + $product = $this->getProductObject($product, $idLang, $idShop); + } + $params['rewrite'] = (!$alias) ? $product->getFieldByLang('link_rewrite') : $alias; + if (!$ean13) { + $product = $this->getProductObject($product, $idLang, $idShop); + } + $params['ean13'] = (!$ean13) ? $product->ean13 : $ean13; + if ($dispatcher->hasKeyword('product_rule', $idLang, 'meta_keywords', $idShop)) { + $product = $this->getProductObject($product, $idLang, $idShop); + $params['meta_keywords'] = Tools::str2url($product->getFieldByLang('meta_keywords')); + } + if ($dispatcher->hasKeyword('product_rule', $idLang, 'meta_title', $idShop)) { + $product = $this->getProductObject($product, $idLang, $idShop); + $params['meta_title'] = Tools::str2url($product->getFieldByLang('meta_title')); + } + if ($dispatcher->hasKeyword('product_rule', $idLang, 'manufacturer', $idShop)) { + $product = $this->getProductObject($product, $idLang, $idShop); + $params['manufacturer'] = Tools::str2url($product->isFullyLoaded ? $product->manufacturer_name : Manufacturer::getNameById($product->id_manufacturer)); + } + if ($dispatcher->hasKeyword('product_rule', $idLang, 'supplier', $idShop)) { + $product = $this->getProductObject($product, $idLang, $idShop); + $params['supplier'] = Tools::str2url($product->isFullyLoaded ? $product->supplier_name : Supplier::getNameById($product->id_supplier)); + } + if ($dispatcher->hasKeyword('product_rule', $idLang, 'price', $idShop)) { + $product = $this->getProductObject($product, $idLang, $idShop); + $params['price'] = $product->isFullyLoaded ? $product->price : Product::getPriceStatic($product->id, false, null, 6, null, false, true, 1, false, null, null, null, $product->specificPrice); + } + if ($dispatcher->hasKeyword('product_rule', $idLang, 'tags', $idShop)) { + $product = $this->getProductObject($product, $idLang, $idShop); + $params['tags'] = Tools::str2url($product->getTags($idLang)); + } + if ($dispatcher->hasKeyword('product_rule', $idLang, 'category', $idShop)) { + if (!$category) { + $product = $this->getProductObject($product, $idLang, $idShop); + } + $params['category'] = (!$category) ? $product->category : $category; + } + if ($dispatcher->hasKeyword('product_rule', $idLang, 'reference', $idShop)) { + $product = $this->getProductObject($product, $idLang, $idShop); + $params['reference'] = Tools::str2url($product->reference); + } + if ($dispatcher->hasKeyword('product_rule', $idLang, 'categories', $idShop)) { + $product = $this->getProductObject($product, $idLang, $idShop); + $params['category'] = (!$category) ? $product->category : $category; + $cats = array(); + foreach ($product->getParentCategories($idLang) as $cat) { + if (!in_array($cat['id_category'], Link::$category_disable_rewrite)) { + $cats[] = $cat['link_rewrite']; + } + } + $params['categories'] = implode('/', $cats); + } + if ($idProductAttribute) { + $product = $this->getProductObject($product, $idLang, $idShop); + } + if (($product->cache_default_attribute == $idProductAttribute && self::isDefaultAttributeAnchorDisabled()) || self::isAnchorDisabled()) { + $anchor = ''; + } else { + if (self::isAnchorIdsDisabled()) { + $anchor = $addAnchor && $idProductAttribute ? $product->getAnchor((int) $idProductAttribute, false) : ''; + } else { + $anchor = $addAnchor && $idProductAttribute ? $product->getAnchor((int) $idProductAttribute, (bool) $withIdInAnchor) : ''; + } + } + return $url . $dispatcher->createUrl('product_rule', $idLang, array_merge($params, $extraParams), $force_routes, $anchor, $idShop); + } + + /* + * module: arseopro + * date: 2025-05-30 11:21:28 + * version: 1.8.8 + */ + public static function isAnchorDisabled() + { + if (self::$cacheDisableAnchor === null) { + self::$cacheDisableAnchor = Configuration::get('ARSP_DISABLE_ANCHOR'); + } + return self::$cacheDisableAnchor; + } + + /* + * module: arseopro + * date: 2025-05-30 11:21:28 + * version: 1.8.8 + */ + public static function isDefaultAttributeAnchorDisabled() + { + if (self::$cacheDisableDefaultAttributeAnchor === null) { + self::$cacheDisableDefaultAttributeAnchor = Configuration::get('ARSP_DISABLE_DEFAULT_ATTR_ANCHOR'); + } + return self::$cacheDisableDefaultAttributeAnchor; + } + + /* + * module: arseopro + * date: 2025-05-30 11:21:28 + * version: 1.8.8 + */ + public static function isDefaultAttributeDisabled() + { + if (self::$cacheDisableDefaultAttribute === null) { + self::$cacheDisableDefaultAttribute = Configuration::get('ARSP_DISABLE_DEFAULT_ATTR'); + } + return self::$cacheDisableDefaultAttribute; + } + + /* + * module: arseopro + * date: 2025-05-30 11:21:28 + * version: 1.8.8 + */ + public static function isAnchorIdsDisabled() + { + if (self::$cacheDisableAnchorIds === null) { + self::$cacheDisableAnchorIds = Configuration::get('ARSP_REMOVE_ANCHOR_ID'); + } + return self::$cacheDisableAnchorIds; + } +} diff --git a/override/classes/Manufacturer.php b/override/classes/Manufacturer.php new file mode 100644 index 00000000..888edd78 --- /dev/null +++ b/override/classes/Manufacturer.php @@ -0,0 +1,34 @@ +controller; + if ($ctrl instanceof ManufacturerController && !ManufacturerController::$initialized && !$this->active && Tools::getIsset('id_employee') && Tools::getIsset('adtoken')) { + $tab = 'AdminManufacturers'; + if (Tools::getAdminToken($tab . (int) Tab::getIdFromClassName($tab) . (int) Tools::getValue('id_employee')) == Tools::getValue('adtoken')) { + $this->active = 1; + } + } + } +} diff --git a/override/classes/Smarty/index.php b/override/classes/Smarty/index.php new file mode 100644 index 00000000..f799c144 --- /dev/null +++ b/override/classes/Smarty/index.php @@ -0,0 +1,35 @@ + + * @copyright 2007-2018 PrestaShop SA + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + * International Registered Trademark & Property of PrestaShop SA + */ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; diff --git a/override/classes/Supplier.php b/override/classes/Supplier.php new file mode 100644 index 00000000..bed01bca --- /dev/null +++ b/override/classes/Supplier.php @@ -0,0 +1,34 @@ +controller; + if ($ctrl instanceof SupplierController && !SupplierController::$initialized && !$this->active && Tools::getIsset('id_employee') && Tools::getIsset('adtoken')) { + $tab = 'AdminSuppliers'; + if (Tools::getAdminToken($tab . (int) Tab::getIdFromClassName($tab) . (int) Tools::getValue('id_employee')) == Tools::getValue('adtoken')) { + $this->active = 1; + } + } + } +} diff --git a/override/classes/assets/index.php b/override/classes/assets/index.php new file mode 100644 index 00000000..f799c144 --- /dev/null +++ b/override/classes/assets/index.php @@ -0,0 +1,35 @@ + + * @copyright 2007-2018 PrestaShop SA + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + * International Registered Trademark & Property of PrestaShop SA + */ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; diff --git a/override/classes/cache/index.php b/override/classes/cache/index.php new file mode 100644 index 00000000..f799c144 --- /dev/null +++ b/override/classes/cache/index.php @@ -0,0 +1,35 @@ + + * @copyright 2007-2018 PrestaShop SA + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + * International Registered Trademark & Property of PrestaShop SA + */ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; diff --git a/override/classes/checkout/index.php b/override/classes/checkout/index.php new file mode 100644 index 00000000..f799c144 --- /dev/null +++ b/override/classes/checkout/index.php @@ -0,0 +1,35 @@ + + * @copyright 2007-2018 PrestaShop SA + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + * International Registered Trademark & Property of PrestaShop SA + */ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; diff --git a/override/classes/container/index.php b/override/classes/container/index.php new file mode 100644 index 00000000..f799c144 --- /dev/null +++ b/override/classes/container/index.php @@ -0,0 +1,35 @@ + + * @copyright 2007-2018 PrestaShop SA + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + * International Registered Trademark & Property of PrestaShop SA + */ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; diff --git a/override/classes/controller/FrontController.php b/override/classes/controller/FrontController.php new file mode 100644 index 00000000..cf056cc5 --- /dev/null +++ b/override/classes/controller/FrontController.php @@ -0,0 +1,209 @@ +parseOutputContent($html); + return; + } + parent::smartyOutputContent($content); + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /* + * module: arseopro + * date: 2025-05-30 11:21:28 + * version: 1.8.8 + */ + protected static $moduleInstance; + /* + * module: arseopro + * date: 2025-05-30 11:21:28 + * version: 1.8.8 + */ + public function arSeoProOverrideVersion() + { + return '1.8.8'; + } + + + /* + * module: arseopro + * date: 2025-05-30 11:21:28 + * version: 1.8.8 + */ + public function getModuleInstance() + { + if (self::$moduleInstance == null) { + self::$moduleInstance = Module::getInstanceByName('arseopro'); + } + return self::$moduleInstance; + } + + /* + * module: arseopro + * date: 2025-05-30 11:21:28 + * version: 1.8.8 + */ + public function getTemplateVarShop() + { + $shop = parent::getTemplateVarShop(); + $shop['favicon'] = $this->getShopFavicon(); + return $shop; + } + + /* + * module: arseopro + * date: 2025-05-30 11:21:28 + * version: 1.8.8 + */ + public function getTemplateVarUrls() + { + $urls = parent::getTemplateVarUrls(); + if (Module::isEnabled('arseopro') && Configuration::get('ARS_REMOVE_DEF_LANG')) { + if (Context::getContext()->language->id != Configuration::get('PS_LANG_DEFAULT')) { + $urls['base_url'] .= $_GET['isolang'] . '/' ; + } + } + return $urls; + } + + /* + * module: arseopro + * date: 2025-05-30 11:21:28 + * version: 1.8.8 + */ + public function getShopFavicon() + { + $icon = Configuration::get('PS_FAVICON'); + $favicon = ($icon) ? _PS_IMG_.$icon : ''; + if (Module::isEnabled('arseopro')) { + $module = $this->getModuleInstance(); + $module->getFaviconConfig()->loadFromConfig(); + if ($module->getFaviconConfig()->icon) { + $filename = pathinfo($module->getFaviconConfig()->icon, PATHINFO_FILENAME); + $ext = pathinfo($module->getFaviconConfig()->icon, PATHINFO_EXTENSION); + $favicon = $module->getUploadsUrl() . $filename . '_96x96.' . $ext; + } + } + return $favicon; + } + + /* + * module: arseopro + * date: 2025-05-30 11:21:28 + * version: 1.8.8 + */ + public function initLogoAndFavicon() + { + $res = parent::initLogoAndFavicon(); + $res['favicon_url'] = $this->getShopFavicon(); + return $res; + } + /* + * module: arseopro + * date: 2025-05-30 11:21:28 + * version: 1.8.8 + */ + protected function canonicalRedirection($canonical_url = '') + { + $params = array(); + if (Module::isEnabled('arseopro')) { + $module = $this->getModuleInstance(); + $data = $module->getUrlConfig()->canonicalUrl($canonical_url); + $canonical_url = $data['url']; + if (isset($data['params']) && is_array($data['params']) && $data['params']) { + $params = $data['params']; + } + } + parent::canonicalRedirection($canonical_url); + if ($params) { + $_GET = array_merge($_GET, $params); + } + } + /* + * module: arseopro + * date: 2025-05-30 11:21:28 + * version: 1.8.8 + */ + protected function updateQueryString(array $extraParams = null) + { + if (!Module::isEnabled('arseopro')) { + return parent::updateQueryString($extraParams); + } + $uriWithoutParams = explode('?', $_SERVER['REQUEST_URI']); + if (isset($uriWithoutParams[0])) { + $uriWithoutParams = $uriWithoutParams[0]; + } + $url = Tools::getCurrentUrlProtocolPrefix().Tools::getHttpHost().$uriWithoutParams; + if (Module::isEnabled('arseopro')) { + $module = $this->getModuleInstance(); + $url = $module->getUrlConfig()->overrideUpdateQueryStringBaseUrl($url, $extraParams); + } + $params = array(); + parse_str($_SERVER['QUERY_STRING'], $params); + if (null !== $extraParams) { + foreach ($extraParams as $key => $value) { + if (null === $value) { + unset($params[$key]); + } else { + $params[$key] = $value; + } + } + } + ksort($params); + if (null !== $extraParams) { + foreach ($params as $key => $param) { + if (null === $param || '' === $param) { + unset($params[$key]); + } + } + } else { + $params = array(); + } + $queryString = str_replace('%2F', '/', http_build_query($params)); + return $url . ($queryString? "?{$queryString}" : ''); + } +} diff --git a/override/classes/controller/ProductListingFrontController.php b/override/classes/controller/ProductListingFrontController.php new file mode 100644 index 00000000..93889109 --- /dev/null +++ b/override/classes/controller/ProductListingFrontController.php @@ -0,0 +1,12 @@ + + * @copyright 2007-2018 PrestaShop SA + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + * International Registered Trademark & Property of PrestaShop SA + */ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; diff --git a/override/classes/db/index.php b/override/classes/db/index.php new file mode 100644 index 00000000..f799c144 --- /dev/null +++ b/override/classes/db/index.php @@ -0,0 +1,35 @@ + + * @copyright 2007-2018 PrestaShop SA + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + * International Registered Trademark & Property of PrestaShop SA + */ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; diff --git a/override/classes/exception/index.php b/override/classes/exception/index.php new file mode 100644 index 00000000..f799c144 --- /dev/null +++ b/override/classes/exception/index.php @@ -0,0 +1,35 @@ + + * @copyright 2007-2018 PrestaShop SA + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + * International Registered Trademark & Property of PrestaShop SA + */ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; diff --git a/override/classes/form/index.php b/override/classes/form/index.php new file mode 100644 index 00000000..f799c144 --- /dev/null +++ b/override/classes/form/index.php @@ -0,0 +1,35 @@ + + * @copyright 2007-2018 PrestaShop SA + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + * International Registered Trademark & Property of PrestaShop SA + */ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; diff --git a/override/classes/helper/index.php b/override/classes/helper/index.php new file mode 100644 index 00000000..c09cf92a --- /dev/null +++ b/override/classes/helper/index.php @@ -0,0 +1,35 @@ + + * @copyright 2007-2018 PrestaShop SA + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + * International Registered Trademark & Property of PrestaShop SA + */ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; diff --git a/override/classes/index.php b/override/classes/index.php new file mode 100644 index 00000000..f799c144 --- /dev/null +++ b/override/classes/index.php @@ -0,0 +1,35 @@ + + * @copyright 2007-2018 PrestaShop SA + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + * International Registered Trademark & Property of PrestaShop SA + */ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; diff --git a/override/classes/lang/index.php b/override/classes/lang/index.php new file mode 100644 index 00000000..f799c144 --- /dev/null +++ b/override/classes/lang/index.php @@ -0,0 +1,35 @@ + + * @copyright 2007-2018 PrestaShop SA + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + * International Registered Trademark & Property of PrestaShop SA + */ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; diff --git a/override/classes/log/index.php b/override/classes/log/index.php new file mode 100644 index 00000000..f799c144 --- /dev/null +++ b/override/classes/log/index.php @@ -0,0 +1,35 @@ + + * @copyright 2007-2018 PrestaShop SA + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + * International Registered Trademark & Property of PrestaShop SA + */ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; diff --git a/override/classes/module/index.php b/override/classes/module/index.php new file mode 100644 index 00000000..f799c144 --- /dev/null +++ b/override/classes/module/index.php @@ -0,0 +1,35 @@ + + * @copyright 2007-2018 PrestaShop SA + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + * International Registered Trademark & Property of PrestaShop SA + */ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; diff --git a/override/classes/order/Order.php b/override/classes/order/Order.php new file mode 100644 index 00000000..e64054ef --- /dev/null +++ b/override/classes/order/Order.php @@ -0,0 +1,51 @@ +shop->id; + + $reference = Db::getInstance()->getValue( 'SELECT reference FROM ' . _DB_PREFIX_.'orders WHERE id_shop = ' . $id_shop . ' ORDER BY id_order DESC' ); + + if ( $id_shop == 1 ) + $reference = str_replace( 'D', '', $reference ); + elseif ( $id_shop == 2 ) + $reference = str_replace( 'L', '', $reference ); + + $reference = str_pad( (int)$reference + 1, 8, '000000000', STR_PAD_LEFT ); + + if ( $id_shop == 1 ) + $reference_number = 'D' . $reference; + elseif ( $id_shop == 2 ) + $reference_number = 'L' . $reference; + + while ( $count = Db::getInstance()->getValue( 'SELECT COUNT(0) FROM ' . _DB_PREFIX_.'orders WHERE reference = \'' . $reference_number . '\'' ) ) + { + $reference++; + $reference = str_pad( (int)$reference + 1, 8, '000000000', STR_PAD_LEFT ); + + if ( $id_shop == 1 ) + $reference_number = 'D' . $reference; + elseif ( $id_shop == 2 ) + $reference_number = 'L' . $reference; + } + + return $reference_number; + } +} diff --git a/override/classes/order/index.php b/override/classes/order/index.php new file mode 100644 index 00000000..f799c144 --- /dev/null +++ b/override/classes/order/index.php @@ -0,0 +1,35 @@ + + * @copyright 2007-2018 PrestaShop SA + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + * International Registered Trademark & Property of PrestaShop SA + */ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; diff --git a/override/classes/pdf/index.php b/override/classes/pdf/index.php new file mode 100644 index 00000000..f799c144 --- /dev/null +++ b/override/classes/pdf/index.php @@ -0,0 +1,35 @@ + + * @copyright 2007-2018 PrestaShop SA + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + * International Registered Trademark & Property of PrestaShop SA + */ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; diff --git a/override/classes/range/index.php b/override/classes/range/index.php new file mode 100644 index 00000000..c09cf92a --- /dev/null +++ b/override/classes/range/index.php @@ -0,0 +1,35 @@ + + * @copyright 2007-2018 PrestaShop SA + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + * International Registered Trademark & Property of PrestaShop SA + */ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; diff --git a/override/classes/shop/index.php b/override/classes/shop/index.php new file mode 100644 index 00000000..f799c144 --- /dev/null +++ b/override/classes/shop/index.php @@ -0,0 +1,35 @@ + + * @copyright 2007-2018 PrestaShop SA + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + * International Registered Trademark & Property of PrestaShop SA + */ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; diff --git a/override/classes/stock/index.php b/override/classes/stock/index.php new file mode 100644 index 00000000..f799c144 --- /dev/null +++ b/override/classes/stock/index.php @@ -0,0 +1,35 @@ + + * @copyright 2007-2018 PrestaShop SA + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + * International Registered Trademark & Property of PrestaShop SA + */ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; diff --git a/override/classes/tax/index.php b/override/classes/tax/index.php new file mode 100644 index 00000000..f799c144 --- /dev/null +++ b/override/classes/tax/index.php @@ -0,0 +1,35 @@ + + * @copyright 2007-2018 PrestaShop SA + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + * International Registered Trademark & Property of PrestaShop SA + */ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; diff --git a/override/classes/tree/index.php b/override/classes/tree/index.php new file mode 100644 index 00000000..f799c144 --- /dev/null +++ b/override/classes/tree/index.php @@ -0,0 +1,35 @@ + + * @copyright 2007-2018 PrestaShop SA + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + * International Registered Trademark & Property of PrestaShop SA + */ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; diff --git a/override/classes/webservice/index.php b/override/classes/webservice/index.php new file mode 100644 index 00000000..f799c144 --- /dev/null +++ b/override/classes/webservice/index.php @@ -0,0 +1,35 @@ + + * @copyright 2007-2018 PrestaShop SA + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + * International Registered Trademark & Property of PrestaShop SA + */ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; diff --git a/override/controllers/admin/AdminCartRulesController.php b/override/controllers/admin/AdminCartRulesController.php new file mode 100644 index 00000000..25a1ba26 --- /dev/null +++ b/override/controllers/admin/AdminCartRulesController.php @@ -0,0 +1,42 @@ +checkExitCode($code,$this->errors)) + return true; + } + } + if(Module::isEnabled('etsdiscountcombinations')) + Module::getInstanceByName('etsdiscountcombinations')->postProcessCartRule(); + return parent::postProcess(); + } +} \ No newline at end of file diff --git a/override/controllers/admin/AdminProductsController.php b/override/controllers/admin/AdminProductsController.php new file mode 100644 index 00000000..77bd7c24 --- /dev/null +++ b/override/controllers/admin/AdminProductsController.php @@ -0,0 +1,43 @@ + +* @copyright 2012-2016 Patryk Marek - PrestaDev.pl +* @link http://prestadev.pl +* @package PD Facebook Dynamic Ads Feed Pro - PrestaShop 1.5.x and 1.6.x Module +* @version 1.0.2 +* @license License is for use in domain / or one multistore enviroment (do not modify or reuse this code or part of it) if you want any changes please contact with me at info@prestadev.pl +* @date 27-11-2016 +*/ +class AdminProductsController extends AdminProductsControllerCore +{ + /* + * module: pdgooglemerchantcenterpro + * date: 2023-06-30 14:41:38 + * version: 2.5.8 + */ + public function initProcess() + { + if (Tools::isSubmit('in_google_shoppingproduct')) { + $id_product = (int)Tools::getValue('id_product'); + $context = Context::getContext(); + $id_shop = $context->language->id; + $id_lang = $context->shop->id; + if (is_numeric($id_product)) { + $obj = new Product($id_product, false, $id_lang, $id_shop); + $obj->in_google_shopping = $obj->in_google_shopping ? 0 : 1; + $obj->update(); + } + } + + parent::initProcess(); + } +} \ No newline at end of file diff --git a/override/controllers/admin/index.php b/override/controllers/admin/index.php new file mode 100644 index 00000000..f799c144 --- /dev/null +++ b/override/controllers/admin/index.php @@ -0,0 +1,35 @@ + + * @copyright 2007-2018 PrestaShop SA + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + * International Registered Trademark & Property of PrestaShop SA + */ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; diff --git a/override/controllers/admin/templates/index.php b/override/controllers/admin/templates/index.php new file mode 100644 index 00000000..f799c144 --- /dev/null +++ b/override/controllers/admin/templates/index.php @@ -0,0 +1,35 @@ + + * @copyright 2007-2018 PrestaShop SA + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + * International Registered Trademark & Property of PrestaShop SA + */ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; diff --git a/override/controllers/front/AuthController.php b/override/controllers/front/AuthController.php new file mode 100644 index 00000000..59059440 --- /dev/null +++ b/override/controllers/front/AuthController.php @@ -0,0 +1,31 @@ +context->controller->errors ) ) { + parent::initContent(); + } else { + $register_form = $this + ->makeCustomerForm() + ->setGuestAllowed(false) + ->fillWith(Tools::getAllValues()); + FrontController::initContent(); + $this->context->smarty->assign([ + 'register_form' => $register_form->getProxy(), + 'hook_create_account_top' => Hook::exec('displayCustomerAccountFormTop') + ]); + $this->setTemplate('customer/registration'); + } + } else { + parent::initContent(); + } + } +} diff --git a/override/controllers/front/CartController.php b/override/controllers/front/CartController.php new file mode 100644 index 00000000..00d77ede --- /dev/null +++ b/override/controllers/front/CartController.php @@ -0,0 +1,62 @@ +errors && ($code = Tools::getValue('discount_name')) && Validate::isCleanHtml($code) && !CartRule::cartRuleExists($code)) { + Module::getInstanceByName('ets_promotion')->addCartRule($this->errors,$code); + } + if(Tools::isSubmit('deletePromotionDiscountRule') && ($id_ets_rule = Tools::getValue('deletePromotionDiscountRule')) && Validate::isUnsignedId($id_ets_rule) ) + { + Module::getInstanceByName('ets_promotion')->deleteCartRule($id_ets_rule); + } + } + /* + * module: ets_promotion + * date: 2023-11-25 09:55:39 + * version: 1.1.9 + */ + public function displayAjaxRefresh() + { + if (Configuration::isCatalogMode()) { + return; + } + ob_end_clean(); + header('Content-Type: application/json'); + header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0'); + die(json_encode([ + 'cart_detailed' => Module::isEnabled('ets_extraoptions') ? $this->context->smarty->fetch(_PS_MODULE_DIR_.'ets_extraoptions/views/templates/hook/checkout/cart-detailed.tpl'): $this->render('checkout/_partials/cart-detailed'), + 'cart_detailed_totals' => $this->render('checkout/_partials/cart-detailed-totals'), + 'cart_summary_items_subtotal' => $this->render('checkout/_partials/cart-summary-items-subtotal'), + 'cart_summary_subtotals_container' => $this->render('checkout/_partials/cart-summary-subtotals'), + 'cart_summary_totals' => $this->render('checkout/_partials/cart-summary-totals'), + 'cart_detailed_actions' => $this->render('checkout/_partials/cart-detailed-actions'), + 'cart_voucher' => $this->context->smarty->fetch(_PS_MODULE_DIR_.'ets_promotion/views/templates/hook/checkout/cart-voucher.tpl'), + 'cart_sumary_products' => $this->context->smarty->fetch(_PS_MODULE_DIR_.'ets_promotion/views/templates/hook/checkout/cart_sumary_products.tpl'), + ])); + } +} \ No newline at end of file diff --git a/override/controllers/front/CmsController.php b/override/controllers/front/CmsController.php new file mode 100644 index 00000000..39ff0d2c --- /dev/null +++ b/override/controllers/front/CmsController.php @@ -0,0 +1,438 @@ += 8) { + return 7; + } + return $exp[1]; + } + if ($part == 2) { + return $exp[2]; + } + if ($part == 3) { + return $exp[3]; + } + } + + public function initContent() + { + if ($this->assignCase == 1) { + $cmsVar = $this->objectPresenter->present($this->cms); + $filteredCmsContent = Hook::exec( + 'filterCmsContent', + array('object' => $cmsVar), + $id_module = null, + $array_return = false, + $check_exceptions = true, + $use_push = false, + $id_shop = null, + $chain = true + ); + if (!empty($filteredCmsContent['object'])) { + $cmsVar = $filteredCmsContent['object']; + } + if ((bool)Module::isEnabled('appagebuilder')) { + $appagebuilder = Module::getInstanceByName('appagebuilder'); + $cmsVar['content'] = $appagebuilder->buildShortCode($cmsVar['content']); + } + $cmsVar['content'] = $this->returnContent($cmsVar['content']); + $this->context->smarty->assign(array( + 'cms' => $cmsVar, + )); + if ($this->cms->indexation == 0) { + $this->context->smarty->assign('nobots', true); + } + $this->setTemplate( + 'cms/page', + array('entity' => 'cms', 'id' => $this->cms->id) + ); + } elseif ($this->assignCase == 2) { + $cmsCategoryVar = $this->getTemplateVarCategoryCms(); + $filteredCmsCategoryContent = Hook::exec( + 'filterCmsCategoryContent', + array('object' => $cmsCategoryVar), + $id_module = null, + $array_return = false, + $check_exceptions = true, + $use_push = false, + $id_shop = null, + $chain = true + ); + if (!empty($filteredCmsCategoryContent['object'])) { + $cmsCategoryVar = $filteredCmsCategoryContent['object']; + } + $this->context->smarty->assign($cmsCategoryVar); + $this->setTemplate('cms/category'); + } + FrontController::initContent(); + + unset($id_module); + unset($array_return); + unset($check_exceptions); + unset($use_push); + unset($id_shop); + unset($chain); + } + /* + * module: leoslideshow + * date: 2022-10-25 14:25:30 + * version: 1.0.4 + */ + public function display() + { + if ((bool) Module::isEnabled('leoslideshow')) { + $leoslideshow = Module::getInstanceByName('leoslideshow'); + $leoslideshow->processCMS(); + } + return parent::display(); + } + + public function returnProduct($id_product) + { + $x = (array)new Product($id_product, true, $this->context->language->id); + if (is_int($x['id'])) { + $productss[$id_product] = $x; + $productss[$id_product]['id_product'] = $id_product; + } + + $products = Product::getProductsProperties($this->context->language->id, $productss); + $assembler = new ProductAssembler($this->context); + $presenterFactory = new ProductPresenterFactory($this->context); + $presentationSettings = $presenterFactory->getPresentationSettings(); + $presenter = new ProductListingPresenter( + new ImageRetriever( + $this->context->link + ), + $this->context->link, + new PriceFormatter(), + new ProductColorsRetriever(), + $this->context->getTranslator() + ); + + $products_for_template = []; + foreach ($products as $rawProduct) { + $products_for_template[] = $presenter->present( + $presentationSettings, + $assembler->assembleProduct($rawProduct), + $this->context->language + ); + } + + $this->context->smarty->assign('products', $products_for_template); + $this->context->smarty->assign('feedtype', "cmsSingleProductFeed"); + return $this->context->smarty->fetch('module:cmsproducts/products.tpl'); + } + + public function returnProducts($id_product) + { + $explode_products = explode(",", $id_product); + foreach ($explode_products AS $idp) { + $explode[] = $idp; + foreach ($explode as $tproduct) { + if ($tproduct != '') { + $x = (array)new Product($tproduct, true, $this->context->language->id); + if (is_int($x['id'])) { + $productss[$tproduct] = $x; + $productss[$tproduct]['id_product'] = $tproduct; + } + } + } + } + $products = Product::getProductsProperties($this->context->language->id, $productss); + $assembler = new ProductAssembler($this->context); + $presenterFactory = new ProductPresenterFactory($this->context); + $presentationSettings = $presenterFactory->getPresentationSettings(); + $presenter = new ProductListingPresenter( + new ImageRetriever( + $this->context->link + ), + $this->context->link, + new PriceFormatter(), + new ProductColorsRetriever(), + $this->context->getTranslator() + ); + + $products_for_template = []; + foreach ($products as $rawProduct) { + $products_for_template[] = $presenter->present( + $presentationSettings, + $assembler->assembleProduct($rawProduct), + $this->context->language + ); + } + + $this->context->smarty->assign('products', ($this->psversion() == 7 ? $products_for_template : $products)); + $this->context->smarty->assign('feedtype', "cmsProductsFeed"); + return $this->context->smarty->fetch('module:cmsproducts/products.tpl'); + } + + public function getProductsByCategoryAndLimit($categoryId = 156, $productsLimit = 4) + { + $products = Product::getProducts($this->context->language->id, 0, $productsLimit, 'id_product', 'ASC', $categoryId); + + $assembler = new ProductAssembler($this->context); + $presenterFactory = new ProductPresenterFactory($this->context); + $presentationSettings = $presenterFactory->getPresentationSettings(); + $presenter = new ProductListingPresenter( + new ImageRetriever( + $this->context->link + ), + $this->context->link, + new PriceFormatter(), + new ProductColorsRetriever(), + $this->context->getTranslator() + ); + + $products_for_template = []; + foreach ($products as $rawProduct) { + $products_for_template[] = $presenter->present( + $presentationSettings, + $assembler->assembleProduct($rawProduct), + $this->context->language + ); + } + + $this->context->smarty->assign('products', ($this->psversion() == 7 ? $products_for_template : $products)); + $this->context->smarty->assign('feedtype', "cmsProductsFeed"); + return $this->context->smarty->fetch('module:cmsproducts/products.tpl'); + } + + public function returnCarouselHpp($block) + { + return $this->displayCarouselHpp($block); + } + + public function returnProductsHpp($block) + { + if (class_exists("Hpp")) { + $hpp = new Hpp(); + if (method_exists($hpp, 'returnProducts')) { + return $this->displayHpp($hpp->returnProducts($block), $block); + } else { + return $this->noModuleMessage("Homepage Products Pro"); + } + } else { + return $this->noModuleMessage("Homepage Products Pro"); + } + } + + public function returnCcarousel($block) + { + $ccarousel = Module::getInstanceByName('ccarousel'); + if ($ccarousel != false) { + $ccarousel = new ccarousel(); + if (method_exists($ccarousel, 'shortcode')) { + return $ccarousel->shortcode($block); + } else { + return $this->noModuleMessage("Custom contents carousel"); + } + } else { + return $this->noModuleMessage("Custom contents carousel"); + } + } + + public function returnProductsRpp($block) + { + if (class_exists("Ppb")) { + $rpp = new Ppb(); + if (method_exists($rpp, 'returnProducts')) { + return $this->displayRpp($rpp->returnProducts($block)); + } else { + return $this->noModuleMessage("Related Products Pro"); + } + } else { + return $this->noModuleMessage("Related Products Pro"); + } + } + + public function returnHtmlboxpro($block) + { + if (class_exists("htmlboxpro")) { + $hbp = new htmlboxpro(); + $hb = new hbox(); + if (method_exists($hbp, 'prepare_variables')) { + $hb = new hbox($block, $this->context->language->id); + if ($hb->id != NULL && is_numeric($hb->id)) { + $contents = $hbp->prepare_variables('', $hb->body, array()); + $this->context->smarty->assign('cmsproducts_htmlboxpro', $contents); + return $this->context->smarty->fetch('module:cmsproducts/html.tpl'); + } else { + // + } + } else { + //return $this->noModuleMessage("Html box pro"); + } + } else { + //return $this->noModuleMessage("Html box pro"); + } + } + + public function returnProductsDiffTool($id) + { + if (class_exists("beforeafter")) { + $bf = new beforeafter(); + if (method_exists($bf, 'displayOnCms')) { + $_GET['id_product'] = (int)$id; + $this->context->controller->addJS($this->_path . '../beforeafter/js/jquery.event.move.js', 'all'); + $this->context->controller->addJS($this->_path . '../beforeafter/js/jquery.twentytwenty.js', 'all'); + $this->context->controller->addCSS($this->_path . '../beforeafter/css/twentytwenty.css'); + + return $bf->displayOnCms(array()); + } else { + return $this->noModuleMessage("Before and after"); + } + } else { + return $this->noModuleMessage("Before and after"); + } + } + + public function displayRpp($products) + { + if (count($products) <= 0) { + $this->context->smarty->assign('feedtype', "noProducts"); + } else { + $this->context->smarty->assign('products', $products); + $this->context->smarty->assign('feedtype', "rppfeed"); + } + $contents = $this->context->smarty->fetch('module:cmsproducts/products.tpl'); + return $contents; + } + + public function displayHpp($products, $id = 0) + { + if (count($products) <= 0) { + $this->context->smarty->assign('feedtype', "noProducts"); + } else { + $this->context->smarty->assign('products', $products); + if (class_exists('HppBlock')) { + $this->context->smarty->assign('id_hpp', $id); + $block = new HppBlock($id, $this->context->language->id); + $this->context->smarty->assign('block', $block); + } + $this->context->smarty->assign('feedtype', "hppfeed"); + $this->context->smarty->assign('id_hpp_block', 'hpp'.$id); + } + $contents = $this->context->smarty->fetch('module:cmsproducts/products.tpl') . $this->displayCarouselHpp($id); + return $contents; + } + + public function displayCarouselHpp($id = 0) + { + $this->context->smarty->assign('id_hpp', $id); + if (class_exists('HppBlock')) { + $block = new HppBlock($id, $this->context->language->id); + $this->context->smarty->assign('block', $block); + $contents = $this->context->smarty->fetch('module:cmsproducts/products-carousel.tpl'); + return $contents; + } + } + + public function noModuleMessage($module) + { + $products = false; + $this->context->smarty->assign('products', $products); + $this->context->smarty->assign('module', $module); + $this->context->smarty->assign('feedtype', "error"); + $contents = $this->context->smarty->fetch('module:cmsproducts/products.tpl'); + return $contents; + } + + public function returnlastReviews() + { + if (Module::isInstalled('lastreviews') && Module::isEnabled('lastreviews')) { + $module = Module::getInstanceByName('lastreviews'); + if (method_exists($module, 'showOnCmsPage')) { + return $module->showOnCmsPage(); + } + } + return $this->noModuleMessage("[Last Product Reviews by Mypresta]"); + } + + public function returnContent($contents) + { + preg_match_all('/\[ccarousel\:[(0-9\,)]+\]/i', $contents, $matches); + foreach ($matches[0] as $index => $match) { + $explode = explode(":", $match); + $contents = str_replace($match, $this->returnCcarousel(str_replace("]", "", $explode[1])), $contents); + } + + preg_match_all('/\{products\:[(0-9\,)]+\}/i', $contents, $matches); + foreach ($matches[0] as $index => $match) { + $explode = explode(":", $match); + $contents = str_replace($match, $this->returnProducts(str_replace("}", "", $explode[1])), $contents); + } + + preg_match_all('/\{product\:[(0-9\,)]+\}/i', $contents, $matches); + foreach ($matches[0] as $index => $match) { + $explode = explode(":", $match); + $contents = str_replace($match, $this->returnProduct(str_replace("}", "", $explode[1])), $contents); + } + + preg_match_all('/\{products_from_category_and_limit\:[(0-9\,0-9\)]+\}/i', $contents, $matches); + foreach ($matches[0] as $index => $match) { + $explode = explode(":", $match); + $params = explode(",", str_replace("}", "", $explode[1])); + + if (count($params) == 2) { + $categoryId = (int)$params[0]; + $productsLimit = (int)$params[1]; + $contents = str_replace($match, $this->getProductsByCategoryAndLimit($categoryId, $productsLimit), $contents); + } + } + + preg_match_all('/\{hpp\:[(0-9)]+\}/i', $contents, $matches); + foreach ($matches[0] as $index => $match) { + $explode = explode(":", $match); + $contents = str_replace($match, $this->returnProductsHpp(str_replace("}", "", $explode[1])), $contents); + } + + preg_match_all('/\{carousel\:[(0-9)]+\}/i', $contents, $matches); + foreach ($matches[0] as $index => $match) { + $explode = explode(":", $match); + $contents = str_replace($match, $this->returnCarouselHpp(str_replace("}", "", $explode[1])), $contents); + } + + preg_match_all('/\{rpp\:[(0-9)]+\}/i', $contents, $matches); + foreach ($matches[0] as $index => $match) { + $explode = explode(":", $match); + $contents = str_replace($match, $this->returnProductsRpp(str_replace("}", "", $explode[1])), $contents); + } + + preg_match_all('/\{lastreviews\}/i', $contents, $matches); + foreach ($matches[0] as $index => $match) { + $contents = str_replace($match, $this->returnlastReviews(str_replace("}", "")), $contents); + } + + preg_match_all('/\{htmlboxpro\:[(0-9)]+\}/i', $contents, $matches); + foreach ($matches[0] as $index => $match) { + $explode = explode(":", $match); + $contents = str_replace($match, $this->returnHtmlboxpro(str_replace("}", "", $explode[1])), $contents); + } + + preg_match_all('/\{diff\:[(0-9)]+\}/i', $contents, $matches); + foreach ($matches[0] as $index => $match) { + $explode = explode(":", $match); + $contents = str_replace($match, $this->returnProductsDiffTool(str_replace("}", "", $explode[1])), $contents); + } + + return $contents; + } +} diff --git a/override/controllers/front/OrderController.php b/override/controllers/front/OrderController.php new file mode 100644 index 00000000..ed295b56 --- /dev/null +++ b/override/controllers/front/OrderController.php @@ -0,0 +1,41 @@ +cart_presenter->present( + $this->context->cart + ); + ob_end_clean(); + header('Content-Type: application/json'); + $this->ajaxRender(json_encode([ + 'preview' => $this->context->smarty->fetch(_PS_MODULE_DIR_.'ets_promotion/views/templates/hook/checkout/cart-summary.tpl',null,null, [ + 'cart' => $cart, + 'static_token' => Tools::getToken(false), + ]), + ])); + } +} \ No newline at end of file diff --git a/override/controllers/front/ProductController.php b/override/controllers/front/ProductController.php new file mode 100644 index 00000000..7ef73566 --- /dev/null +++ b/override/controllers/front/ProductController.php @@ -0,0 +1,32 @@ + + * @copyright 2007-2015 Apollotheme + * @license http://apollotheme.com - prestashop template provider + */ +class ProductController extends ProductControllerCore +{ + /* + * module: appagebuilder + * date: 2022-10-25 14:25:30 + * version: 2.2.0 + */ + public function getTemplateVarProduct() + { + $product = parent::getTemplateVarProduct(); + if ((bool)Module::isEnabled('appagebuilder')) { + $appagebuilder = Module::getInstanceByName('appagebuilder'); + $product['description'] = $appagebuilder->buildShortCode($product['description']); + $product['description_short'] = $appagebuilder->buildShortCode($product['description_short']); + } + return $product; + } +} diff --git a/override/controllers/front/index.php b/override/controllers/front/index.php new file mode 100644 index 00000000..f799c144 --- /dev/null +++ b/override/controllers/front/index.php @@ -0,0 +1,35 @@ + + * @copyright 2007-2018 PrestaShop SA + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + * International Registered Trademark & Property of PrestaShop SA + */ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; diff --git a/override/controllers/front/listing/CategoryController.php b/override/controllers/front/listing/CategoryController.php new file mode 100644 index 00000000..b12199ed --- /dev/null +++ b/override/controllers/front/listing/CategoryController.php @@ -0,0 +1,42 @@ + + * @copyright 2007-2017 PrestaShop SA + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + * International Registered Trademark & Property of PrestaShop SA + */ +class CategoryController extends CategoryControllerCore +{ + /* + * module: appagebuilder + * date: 2022-10-25 14:25:30 + * version: 2.2.0 + */ + protected function getTemplateVarCategory() + { + $category = parent::getTemplateVarCategory(); + if ((bool)Module::isEnabled('appagebuilder')) { + $appagebuilder = Module::getInstanceByName('appagebuilder'); + $category['description'] = $appagebuilder->buildShortCode($category['description']); + } + return $category; + } +} diff --git a/override/controllers/front/listing/index.php b/override/controllers/front/listing/index.php new file mode 100644 index 00000000..f799c144 --- /dev/null +++ b/override/controllers/front/listing/index.php @@ -0,0 +1,35 @@ + + * @copyright 2007-2018 PrestaShop SA + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + * International Registered Trademark & Property of PrestaShop SA + */ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; diff --git a/override/controllers/index.php b/override/controllers/index.php new file mode 100644 index 00000000..f799c144 --- /dev/null +++ b/override/controllers/index.php @@ -0,0 +1,35 @@ + + * @copyright 2007-2018 PrestaShop SA + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + * International Registered Trademark & Property of PrestaShop SA + */ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; diff --git a/override/index.php b/override/index.php new file mode 100644 index 00000000..f799c144 --- /dev/null +++ b/override/index.php @@ -0,0 +1,35 @@ + + * @copyright 2007-2018 PrestaShop SA + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + * International Registered Trademark & Property of PrestaShop SA + */ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; diff --git a/override/modules/af_producttagspro/controllers/front/index.php b/override/modules/af_producttagspro/controllers/front/index.php new file mode 100644 index 00000000..16984982 --- /dev/null +++ b/override/modules/af_producttagspro/controllers/front/index.php @@ -0,0 +1,19 @@ +context->language->id); + if (empty($tag)) { + $tag_name = str_replace('-', ' ', Tools::getValue('tagName')); + $tag_id = AdvancedTagsModel::getIdTagByName($tag_name, $this->context->language->id); + } else { + $tag_id = $tag['adtag_id_tag']; + } + if (!$tag_id) { + $tag_id = null; + } + return $tag_id; + } + + /** + * List all URLs generated by this controller for the current shop context and the specified language. + * This is used by the Jresta-Cache-Warmer service to generate the cache of these pages. + * @param $id_lang int ID of the language + * @return string[] All URLs to warmup + */ + public static function getJprestaAllURLs($id_lang) { + $context = Context::getContext(); + $links = []; + $afsp = Module::getInstanceByName('af_producttagspro'); + if ($afsp) { + if (Group::isFeatureActive()) { + $groups = FrontController::getCurrentCustomerGroups(); + + $tags = JPresta\SpeedPack\JprestaUtils::dbSelectRows(' + SELECT t.name, adTag.`adtag_link_rewrite` + FROM `' . _DB_PREFIX_ . 'tag_count` pt + LEFT JOIN `' . _DB_PREFIX_ . 'tag` t ON (t.id_tag = pt.id_tag) + LEFT JOIN `' . _DB_PREFIX_ . 'af_advanced_tags` adTag ON (adTag.adtag_id_tag = t.id_tag) + WHERE (adTag.`adtag_is_show` = 1 OR adTag.`adtag_is_show` IS NULL) AND pt.`id_group` ' . (count($groups) ? 'IN (' . implode(',', $groups) . ')' : '= 1') . ' + AND pt.`id_lang` = ' . (int) $id_lang . ' AND pt.`id_shop` = ' . (int) $context->shop->id); + } else { + $tags = JPresta\SpeedPack\JprestaUtils::dbSelectRows(' + SELECT t.name + FROM `' . _DB_PREFIX_ . 'tag_count` pt + LEFT JOIN `' . _DB_PREFIX_ . 'tag` t ON (t.id_tag = pt.id_tag) + LEFT JOIN `' . _DB_PREFIX_ . 'af_advanced_tags` adTag ON (adTag.adtag_id_tag = t.id_tag) + WHERE (adTag.`adtag_is_show` = 1 OR adTag.`adtag_is_show` IS NULL) AND pt.id_group = 0 AND pt.`id_lang` = ' . (int) $id_lang . ' AND pt.`id_shop` = ' . (int) $context->shop->id); + } + foreach ($tags as $tag) { + $links[] = $afsp->getUrlFrontTag($tag['name'], isset($tag['adtag_link_rewrite']) ? $tag['adtag_link_rewrite'] : null, $id_lang); + } + } + return $links; + } + + /** + * An estimated number of URLs that will be returned by self::getJprestaAllURLs() for the current shop context. + * Since we don't have the id_lang parameter we recommend to return the number of URLs for the language that have + * the most URLs. + * @return int The estimated number of URLs to warmup for the current shop context + */ + public static function getJprestaAllURLsCount() { + $queryCountPages = ' + SELECT COUNT(*) + FROM `' . _DB_PREFIX_ . 'tag_count` pt + LEFT JOIN `' . _DB_PREFIX_ . 'tag` t ON (t.id_tag = pt.id_tag) + LEFT JOIN `' . _DB_PREFIX_ . 'af_advanced_tags` adTag ON (adTag.adtag_id_tag = t.id_tag) + WHERE (adTag.`adtag_is_show` = 1 OR adTag.`adtag_is_show` IS NULL) AND pt.id_group = '.(Group::isFeatureActive() ? 1 : 0).' AND pt.`id_lang` = ' . (int) Configuration::get('PS_LANG_DEFAULT') . ' AND pt.`id_shop` = ' . (int) Shop::getContextShopID(); + return (int) JPresta\SpeedPack\JprestaUtils::dbGetValue($queryCountPages); + } +} diff --git a/override/modules/af_producttagspro/controllers/index.php b/override/modules/af_producttagspro/controllers/index.php new file mode 100644 index 00000000..16984982 --- /dev/null +++ b/override/modules/af_producttagspro/controllers/index.php @@ -0,0 +1,19 @@ +getSitemapLinks($id_lang, (int)Shop::getContextShopID()); + if (is_array($links)) { + return $links; + } + } + } + return []; + } + + /** + * An estimated number of URLs that will be returned by self::getJprestaAllURLs() for the current shop context. + * Since we don't have the id_lang parameter we recommend to return the number of URLs for the language that have + * the most URLs. + * @return int The estimated number of URLs to warmup for the current shop context + */ + public static function getJprestaAllURLsCount() { + $queryCountPages = 'SELECT COUNT(DISTINCT p.id_seopage) FROM `'._DB_PREFIX_.'af_seopage` p INNER JOIN `'._DB_PREFIX_.'af_seopage_lang` l ON p.id_seopage = l.id_seopage WHERE p.active=1 AND l.id_shop=' . (int) Shop::getContextShopID(); + return (int) JPresta\SpeedPack\JprestaUtils::dbGetValue($queryCountPages); + } +} diff --git a/override/modules/af_seopages/controllers/index.php b/override/modules/af_seopages/controllers/index.php new file mode 100644 index 00000000..16984982 --- /dev/null +++ b/override/modules/af_seopages/controllers/index.php @@ -0,0 +1,19 @@ +context->controller->errors)) { + parent::sendMessage(); + } + } +} \ No newline at end of file diff --git a/override/modules/ets_blog/controllers/front/blog.php b/override/modules/ets_blog/controllers/front/blog.php new file mode 100644 index 00000000..cf5bc027 --- /dev/null +++ b/override/modules/ets_blog/controllers/front/blog.php @@ -0,0 +1,39 @@ +language->id, $faqCategoryId, $faqId, true); + return $faq[0] ? (int) $faq[0]['id_gomakoil_faq'] : null; + } + else if ($faqCategoryId) { + $cat = faqsCategory::getCategoryByName((int) Shop::getContextShopID(), Context::getContext()->language->id, $faqCategoryId); + return $cat[0] ? (int) $cat[0]['id_gomakoil_faq_category'] : null; + } + else { + return null; + } + } + + /** + * List all URLs generated by this controller for the current shop context and the specified language. + * This is used by the Jresta-Cache-Warmer service to generate the cache of these pages. + * @param $id_lang int ID of the language + * @return string[] All URLs to warmup + */ + public static function getJprestaAllURLs($id_lang) + { + $id_shop = (int)Shop::getContextShopID(); + $links = []; + // URL of the root + $baseUrl = $links[] = Context::getContext()->link->getModuleLink('faqs', 'display', [], $id_shop, $id_lang); + // URLs of categories + $cats = JPresta\SpeedPack\JprestaUtils::dbSelectRows(' + SELECT c.id_gomakoil_faq_category, cl.link_rewrite + FROM `' . _DB_PREFIX_ . 'gomakoil_faq_category` c + LEFT JOIN `' . _DB_PREFIX_ . 'gomakoil_faq_category_shop` cs ON (c.id_gomakoil_faq_category = cs.id_gomakoil_faq_category) + LEFT JOIN `' . _DB_PREFIX_ . 'gomakoil_faq_category_lang` cl ON (c.id_gomakoil_faq_category = cl.id_gomakoil_faq_category) + WHERE c.active=1 AND cs.id_shop=' . (int)$id_shop . ' AND cl.id_lang=' . (int)$id_lang); + foreach ($cats as $cat) { + if (!faqs::getRewriteSettings()) { + $links[] = $baseUrl . '&category=' . $cat['link_rewrite']; + } else { + $links[] = $baseUrl . $cat['link_rewrite'] . '.html'; + } + // URLs of FAQs + $faqs = JPresta\SpeedPack\JprestaUtils::dbSelectRows(' + SELECT fl.link_rewrite + FROM `' . _DB_PREFIX_ . 'gomakoil_faq` f + LEFT JOIN `' . _DB_PREFIX_ . 'gomakoil_faq_shop` fs ON (f.id_gomakoil_faq = fs.id_gomakoil_faq) + LEFT JOIN `' . _DB_PREFIX_ . 'gomakoil_faq_lang` fl ON (f.id_gomakoil_faq = fl.id_gomakoil_faq) + WHERE f.active=1 AND f.id_gomakoil_faq_category=' . (int)$cat['id_gomakoil_faq_category'] . ' AND fs.id_shop=' . (int)$id_shop . ' AND fl.id_lang=' . (int)$id_lang); + foreach ($faqs as $faq) { + if (!faqs::getRewriteSettings()) { + $links[] = $baseUrl . '&category=' . $cat['link_rewrite'] . '&question=' . $faq['link_rewrite']; + } else { + $links[] = $baseUrl . $cat['link_rewrite'] . '/' . $faq['link_rewrite'] . '.html'; + } + } + } + return $links; + } + + /** + * An estimated number of URLs that will be returned by self::getJprestaAllURLs() for the current shop context. + * Since we don't have the id_lang parameter we recommend to return the number of URLs for the language that have + * the most URLs. + * @return int The estimated number of URLs to warmup for the current shop context + */ + public static function getJprestaAllURLsCount() { + $queryCountPagesCat = ' + SELECT COUNT(*) + FROM `' . _DB_PREFIX_ . 'gomakoil_faq_category` c + LEFT JOIN `' . _DB_PREFIX_ . 'gomakoil_faq_category_shop` cs ON (c.id_gomakoil_faq_category = cs.id_gomakoil_faq_category) + WHERE c.`active` = 1 AND cs.`id_shop` = ' . (int) Shop::getContextShopID(); + $queryCountPagesFaq = ' + SELECT COUNT(*) + FROM `' . _DB_PREFIX_ . 'gomakoil_faq` f + LEFT JOIN `' . _DB_PREFIX_ . 'gomakoil_faq_shop` fs ON (f.id_gomakoil_faq = fs.id_gomakoil_faq) + WHERE f.`active` = 1 AND fs.`id_shop` = ' . (int) Shop::getContextShopID(); + $countPagesRoot = 1; + return (int) JPresta\SpeedPack\JprestaUtils::dbGetValue($queryCountPagesCat) + + (int) JPresta\SpeedPack\JprestaUtils::dbGetValue($queryCountPagesFaq) + + $countPagesRoot; + } +} diff --git a/override/modules/faqs/controllers/front/index.php b/override/modules/faqs/controllers/front/index.php new file mode 100644 index 00000000..16984982 --- /dev/null +++ b/override/modules/faqs/controllers/front/index.php @@ -0,0 +1,19 @@ +link->getPageLink('module-hifaq-faq', null, $id_lang, ['type' => null]); + } else { + $urls[] = $context->link->getModuleLink('hifaq', 'faq', ['type' => null]); + } + return $urls; + } + + /** + * An estimated number of URLs that will be returned by self::getJprestaAllURLs() for the current shop context. + * Since we don't have the id_lang parameter we recommend to return the number of URLs for the language that have + * the most URLs. + * @return int The estimated number of URLs to warmup for the current shop context + */ + public static function getJprestaAllURLsCount() { + return 1; + } +} diff --git a/override/modules/hifaq/controllers/front/faqcategory.php b/override/modules/hifaq/controllers/front/faqcategory.php new file mode 100644 index 00000000..2ba49d00 --- /dev/null +++ b/override/modules/hifaq/controllers/front/faqcategory.php @@ -0,0 +1,79 @@ +link->getPageLink('module-hifaq-faqcategory', null, $id_lang, ['faqc_link_rewrite' => $faq['friendly_url']]); + } else { + $urls[] = $context->link->getModuleLink('hifaq', 'faqcategory', ['faqc_link_rewrite' => $faq['friendly_url']], null, $id_lang); + } + } + return $urls; + } + + /** + * An estimated number of URLs that will be returned by self::getJprestaAllURLs() for the current shop context. + * Since we don't have the id_lang parameter we recommend to return the number of URLs for the language that have + * the most URLs. + * @return int The estimated number of URLs to warmup for the current shop context + */ + public static function getJprestaAllURLsCount() { + $sql = 'SELECT COUNT(*) + FROM `' . _DB_PREFIX_ . 'hifaqcategory` f + LEFT JOIN `' . _DB_PREFIX_ . 'hifaqcategory_lang` fl ON f.id=fl.id + LEFT JOIN `' . _DB_PREFIX_ . 'hifaqcategory_shop` fs ON f.id=fs.id + WHERE f.active=1 AND fl.id_lang=' . (int)Configuration::get('PS_LANG_DEFAULT') . ' AND fs.id_shop=' . (int)Shop::getContextShopID(); + return (int) JPresta\SpeedPack\JprestaUtils::dbGetValue($sql); + } +} diff --git a/override/modules/hifaq/controllers/front/faqdetails.php b/override/modules/hifaq/controllers/front/faqdetails.php new file mode 100644 index 00000000..240c1071 --- /dev/null +++ b/override/modules/hifaq/controllers/front/faqdetails.php @@ -0,0 +1,79 @@ +link->getPageLink('module-hifaq-faqdetails', null, $id_lang, ['faq_link_rewrite' => $faq['friendly_url']]); + } else { + $urls[] = $context->link->getModuleLink('hifaq', 'faqdetails', [], null, $id_lang) . '&faq_link_rewrite=' . $faq['friendly_url']; + } + } + return $urls; + } + + /** + * An estimated number of URLs that will be returned by self::getJprestaAllURLs() for the current shop context. + * Since we don't have the id_lang parameter we recommend to return the number of URLs for the language that have + * the most URLs. + * @return int The estimated number of URLs to warmup for the current shop context + */ + public static function getJprestaAllURLsCount() { + $sql = 'SELECT COUNT(*) + FROM `' . _DB_PREFIX_ . 'hifaq` f + LEFT JOIN `' . _DB_PREFIX_ . 'hifaq_lang` fl ON f.id_faq=fl.id_faq + LEFT JOIN `' . _DB_PREFIX_ . 'hifaq_shop` fs ON f.id_faq=fs.id_faq + WHERE f.active=1 AND fl.id_lang=' . (int)Configuration::get('PS_LANG_DEFAULT') . ' AND fs.id_shop=' . (int)Shop::getContextShopID(); + return (int) JPresta\SpeedPack\JprestaUtils::dbGetValue($sql); + } +} diff --git a/override/modules/hifaq/controllers/front/index.php b/override/modules/hifaq/controllers/front/index.php new file mode 100644 index 00000000..16984982 --- /dev/null +++ b/override/modules/hifaq/controllers/front/index.php @@ -0,0 +1,19 @@ + + * @copyright 2007-2018 PrestaShop SA + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + * International Registered Trademark & Property of PrestaShop SA + */ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; diff --git a/override/modules/ph_simpleblog/controllers/front/author.php b/override/modules/ph_simpleblog/controllers/front/author.php new file mode 100644 index 00000000..d1ae6182 --- /dev/null +++ b/override/modules/ph_simpleblog/controllers/front/author.php @@ -0,0 +1,40 @@ +id; + } + return $id; + } +} diff --git a/override/modules/ph_simpleblog/controllers/front/category.php b/override/modules/ph_simpleblog/controllers/front/category.php new file mode 100644 index 00000000..b5b833c8 --- /dev/null +++ b/override/modules/ph_simpleblog/controllers/front/category.php @@ -0,0 +1,69 @@ +context->language->id); + if (Validate::isLoadedObject($simpleBlogCategory)) { + $id = $simpleBlogCategory->id; + } + } + return $id; + } + + /** + * List all URLs generated by this controller for the current shop context and the specified language. + * This is used by the Jresta-Cache-Warmer service to generate the cache of these pages. + * @param $id_lang int ID of the language + * @return string[] All URLs to warmup + */ + public static function getJprestaAllURLs($id_lang) { + $urls = []; + $categories = SimpleBlogCategory::getCategories($id_lang, true, true, (int) Shop::getContextShopID()); + foreach ($categories as $category) { + $urls[] = $category['url']; + } + return $urls; + } + + /** + * An estimated number of URLs that will be returned by self::getJprestaAllURLs() for the current shop context. + * Since we don't have the id_lang parameter we recommend to return the number of URLs for the language that have + * the most URLs. + * @return int The estimated number of URLs to warmup for the current shop context + */ + public static function getJprestaAllURLsCount() { + $queryCountCategories = 'SELECT count(*) FROM `'._DB_PREFIX_.'simpleblog_category` WHERE active=1'; + return (int) JPresta\SpeedPack\JprestaUtils::dbGetValue($queryCountCategories); + } +} diff --git a/override/modules/ph_simpleblog/controllers/front/index.php b/override/modules/ph_simpleblog/controllers/front/index.php new file mode 100644 index 00000000..16984982 --- /dev/null +++ b/override/modules/ph_simpleblog/controllers/front/index.php @@ -0,0 +1,19 @@ +link->getModuleLink( + 'ph_simpleblog', + 'list', + [], + null, + $id_lang); + return $urls; + } + + /** + * An estimated number of URLs that will be returned by self::getJprestaAllURLs() for the current shop context. + * Since we don't have the id_lang parameter we recommend to return the number of URLs for the language that have + * the most URLs. + * @return int The estimated number of URLs to warmup for the current shop context + */ + public static function getJprestaAllURLsCount() { + return 1; + } +} diff --git a/override/modules/ph_simpleblog/controllers/front/single.php b/override/modules/ph_simpleblog/controllers/front/single.php new file mode 100644 index 00000000..0466d14c --- /dev/null +++ b/override/modules/ph_simpleblog/controllers/front/single.php @@ -0,0 +1,94 @@ + 'ph_simpleblog__single', + 'id' => $this->getJprestaModelObjectId(), + 'delete_linking_pages' => false, + 'action_origin' => 'method-post' + ]); + } + parent::init(); + } + + /** + * @return string The ObjectModel class name to be used by Page Cache Ultimate module to refresh the cache of pages generated by this controller + */ + public static function getJprestaModelObjectClassName() + { + return 'SimpleBlogPost'; + } + + /** + * @return int|null The ID of the current ObjectModel (if any) to be used by Page Cache Ultimate module to refresh the cache of pages generated by this controller + */ + public function getJprestaModelObjectId() + { + // Get Post by link_rewrite + $simpleblog_post_rewrite = Tools::getValue('rewrite'); + + if (!$simpleblog_post_rewrite || !Validate::isLinkRewrite($simpleblog_post_rewrite)) { + return null; + } + + $simpleBlogPost = SimpleBlogPost::getByRewrite( + $simpleblog_post_rewrite, + (int) Context::getContext()->language->id, + Tools::getValue('sb_category') + ); + return $simpleBlogPost ? $simpleBlogPost->id : null; + } + + + /** + * List all URLs generated by this controller for the current shop context and the specified language. + * This is used by the Jresta-Cache-Warmer service to generate the cache of these pages. + * @param $id_lang int ID of the language + * @return string[] All URLs to warmup + */ + public static function getJprestaAllURLs($id_lang) { + $urls = []; + $finder = new BlogPostsFinder(); + $finder->setIdShop((int) Shop::getContextShopID()); + $finder->setIdLang($id_lang); + $finder->setCheckForAccess(false); + + $posts = $finder->findPosts(); + + foreach ($posts as $post) { + $urls[] = $post['url']; + } + + return $urls; + } + + /** + * An estimated number of URLs that will be returned by self::getJprestaAllURLs() for the current shop context. + * Since we don't have the id_lang parameter we recommend to return the number of URLs for the language that have + * the most URLs. + * @return int The estimated number of URLs to warmup for the current shop context + */ + public static function getJprestaAllURLsCount() { + $queryCountArticle = 'SELECT count(*) FROM `'._DB_PREFIX_.'simpleblog_post` sbp INNER JOIN `'._DB_PREFIX_.'simpleblog_post_shop` sbps ON sbp.id_simpleblog_post = sbps.id_simpleblog_post WHERE sbp.active=1 AND sbp.date_add <= \'' . SimpleBlogHelper::now(Configuration::get('PH_BLOG_TIMEZONE')) . '\' AND sbps.id_shop=' . (int) Shop::getContextShopID(); + return (int) JPresta\SpeedPack\JprestaUtils::dbGetValue($queryCountArticle); + } +} diff --git a/override/modules/ph_simpleblog/controllers/index.php b/override/modules/ph_simpleblog/controllers/index.php new file mode 100644 index 00000000..16984982 --- /dev/null +++ b/override/modules/ph_simpleblog/controllers/index.php @@ -0,0 +1,19 @@ + (int) $child['id_prestablog_news'], + 'seo' => $child['link_rewrite'], + 'titre' => $child['title'], + 'id_lang' => (int) $child['id_lang'], + ] + ); + } + + // Categories + $urlsInfos = CategoriesClass::getListeNoArbo(1, (int) $id_lang); + foreach ($urlsInfos as $child) { + $urls[] = PrestaBlog::prestablogUrl([ + 'c' => (int)$child['id_prestablog_categorie'], + 'titre' => ($child['link_rewrite'] != '' ? $child['link_rewrite'] : $child['title']), + 'id_lang' => (int)$child['id_lang'], + ]); + } + return $urls; + } + + /** + * An estimated number of URLs that will be returned by self::getJprestaAllURLs() for the current shop context. + * Since we don't have the id_lang parameter we recommend to return the number of URLs for the language that have + * the most URLs. + * @return int The estimated number of URLs to warmup for the current shop context + */ + public static function getJprestaAllURLsCount() { + $queryCountArticle = 'SELECT count(*) FROM `'._DB_PREFIX_.'prestablog_news` WHERE actif=1 AND id_shop=' . (int) Shop::getContextShopID(); + $queryCountCategories = 'SELECT count(*) FROM `'._DB_PREFIX_.'prestablog_categorie` WHERE actif=1 AND id_shop=' . (int) Shop::getContextShopID(); + return (int) JPresta\SpeedPack\JprestaUtils::dbGetValue($queryCountArticle) + (int) JPresta\SpeedPack\JprestaUtils::dbGetValue($queryCountCategories); + } +} diff --git a/override/modules/prestablog/controllers/front/index.php b/override/modules/prestablog/controllers/front/index.php new file mode 100644 index 00000000..16984982 --- /dev/null +++ b/override/modules/prestablog/controllers/front/index.php @@ -0,0 +1,19 @@ +context->language->id); + } + return $id_post; + } +} diff --git a/override/modules/ybc_blog/controllers/front/index.php b/override/modules/ybc_blog/controllers/front/index.php new file mode 100644 index 00000000..16984982 --- /dev/null +++ b/override/modules/ybc_blog/controllers/front/index.php @@ -0,0 +1,19 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + */ + +namespace PrestaShop\PrestaShop\Core\Product\Search\Exception; + +use PrestaShop\PrestaShop\Core\Exception\CoreException; + +/** + * Thrown when sort order direction is not valid + */ +class InvalidSortOrderDirectionException extends CoreException +{ + /** + * @param string $direction the invalid direction + */ + public function __construct($direction) + { + $message = sprintf( + 'Invalid SortOrder direction `%s`. Expecting one of: `ASC`, `DESC`, or `RANDOM`.', + $direction + ); + + parent::__construct($message, 0, null); + } +} diff --git a/src/Core/Product/Search/Facet.php b/src/Core/Product/Search/Facet.php new file mode 100644 index 00000000..94d7c533 --- /dev/null +++ b/src/Core/Product/Search/Facet.php @@ -0,0 +1,233 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + */ + +namespace PrestaShop\PrestaShop\Core\Product\Search; + +/** + * We call a facet a set of filters combined with logical operators. + */ +class Facet +{ + /** + * @var string the facet label + */ + private $label = ''; + + /** + * @var string the facet type + */ + private $type = ''; + + /** + * @var bool if true, the facet is displayed + */ + private $displayed = true; + + /** + * @var array the facet properties + */ + private $properties = []; + + /** + * @var array the facet filters + */ + private $filters = []; + + /** + * @var bool if true, allows the multiple selection + */ + private $multipleSelectionAllowed = true; + + /** + * @var string the widget type + */ + private $widgetType = 'radio'; + + /** + * @return array an array representation of the facet + */ + public function toArray() + { + return [ + 'label' => $this->label, + 'displayed' => $this->displayed, + 'type' => $this->type, + 'properties' => $this->properties, + 'filters' => array_map(function (Filter $filter) { + return $filter->toArray(); + }, $this->filters), + 'multipleSelectionAllowed' => $this->multipleSelectionAllowed, + 'widgetType' => $this->widgetType, + ]; + } + + /** + * @param string $label the facet label + * + * @return $this + */ + public function setLabel($label) + { + $this->label = $label; + + return $this; + } + + /** + * @return string the facet label + */ + public function getLabel() + { + return $this->label; + } + + /** + * @param string $type the facet type + * + * @return $this + */ + public function setType($type) + { + $this->type = $type; + + return $this; + } + + /** + * @return string the facet type + */ + public function getType() + { + return $this->type; + } + + /** + * @param string $name the facet property name + * @param mixed $value the facet property value + * + * @return $this + */ + public function setProperty($name, $value) + { + $this->properties[$name] = $value; + + return $this; + } + + /** + * @param string $name the facet property name + * + * @return mixed|null + */ + public function getProperty($name) + { + if (!array_key_exists($name, $this->properties)) { + return null; + } + + return $this->properties[$name]; + } + + /** + * @param Filter $filter the facet filter + * + * @return $this + */ + public function addFilter(Filter $filter) + { + $this->filters[] = $filter; + + return $this; + } + + /** + * @return array the list of facet filters + */ + public function getFilters() + { + return $this->filters; + } + + /** + * @param bool $isAllowed allows/disallows the multiple selection + * + * @return $this + */ + public function setMultipleSelectionAllowed($isAllowed = true) + { + $this->multipleSelectionAllowed = $isAllowed; + + return $this; + } + + /** + * @return bool returns true if multiple selection is allowed + */ + public function isMultipleSelectionAllowed() + { + return $this->multipleSelectionAllowed; + } + + /** + * @param bool $displayed sets the display of the facet + * + * @return $this + */ + public function setDisplayed($displayed = true) + { + $this->displayed = $displayed; + + return $this; + } + + /** + * @return bool returns true if the facet is displayed + */ + public function isDisplayed() + { + return $this->displayed; + } + + /** + * @param string $widgetType sets the widget type of the facet + * + * @return $this + */ + public function setWidgetType($widgetType) + { + $this->widgetType = $widgetType; + + return $this; + } + + /** + * @return string returns the facet widget type + */ + public function getWidgetType() + { + return $this->widgetType; + } +} diff --git a/src/Core/Product/Search/FacetCollection.php b/src/Core/Product/Search/FacetCollection.php new file mode 100644 index 00000000..56fe02f7 --- /dev/null +++ b/src/Core/Product/Search/FacetCollection.php @@ -0,0 +1,73 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + */ + +namespace PrestaShop\PrestaShop\Core\Product\Search; + +/** + * Stores a list of facets. + */ +class FacetCollection +{ + /** + * @var array the list of facets + */ + private $facets = []; + + /** + * @param Facet $facet the facet to add + * + * @return $this + */ + public function addFacet(Facet $facet) + { + $this->facets[] = $facet; + + return $this; + } + + /** + * @param array $facets the facets to add + * + * @return $this + */ + public function setFacets(array $facets) + { + $this->facets = []; + foreach ($facets as $facet) { + $this->addFacet($facet); + } + + return $this; + } + + /** + * @return array returns the list of facets + */ + public function getFacets() + { + return $this->facets; + } +} diff --git a/src/Core/Product/Search/FacetsRendererInterface.php b/src/Core/Product/Search/FacetsRendererInterface.php new file mode 100644 index 00000000..2d619955 --- /dev/null +++ b/src/Core/Product/Search/FacetsRendererInterface.php @@ -0,0 +1,55 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + */ + +namespace PrestaShop\PrestaShop\Core\Product\Search; + +/** + * Define how we render facets and active filters. + */ +interface FacetsRendererInterface +{ + /** + * @param ProductSearchContext $context + * @param ProductSearchResult $result + * + * @return string HTML content is expected here + */ + public function renderFacets( + ProductSearchContext $context, + ProductSearchResult $result + ); + + /** + * @param ProductSearchContext $context + * @param ProductSearchResult $result + * + * @return string HTML content is expected here + */ + public function renderActiveFilters( + ProductSearchContext $context, + ProductSearchResult $result + ); +} diff --git a/src/Core/Product/Search/Filter.php b/src/Core/Product/Search/Filter.php new file mode 100644 index 00000000..a723940b --- /dev/null +++ b/src/Core/Product/Search/Filter.php @@ -0,0 +1,254 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + */ + +namespace PrestaShop\PrestaShop\Core\Product\Search; + +class Filter +{ + /** + * @var string the filter label + */ + private $label = ''; + + /** + * @var string internal type, used by query logic + */ + private $type = ''; + + /** + * @var bool whether or not the filter is used in the query + */ + private $active = false; + + /** + * @var bool whether or not the filter is displayed + */ + private $displayed = true; + + /** + * @var array the filter properties + */ + private $properties = []; + + /** + * @var int the filter magnitude + */ + private $magnitude = 0; + + /** + * @var mixed the filter value + */ + private $value; + + /** + * @var array the filter next encoded facets + */ + private $nextEncodedFacets = []; + + /** + * @return array an array representation of the filter + */ + public function toArray() + { + return [ + 'label' => $this->label, + 'type' => $this->type, + 'active' => $this->active, + 'displayed' => $this->displayed, + 'properties' => $this->properties, + 'magnitude' => $this->magnitude, + 'value' => $this->value, + 'nextEncodedFacets' => $this->nextEncodedFacets, + ]; + } + + /** + * @param string $label the filter label + * + * @return $this + */ + public function setLabel($label) + { + $this->label = $label; + + return $this; + } + + /** + * @return string the filter label + */ + public function getLabel() + { + return $this->label; + } + + /** + * @param string $type the filter type + * + * @return $this + */ + public function setType($type) + { + $this->type = $type; + + return $this; + } + + /** + * @return string the filter type + */ + public function getType() + { + return $this->type; + } + + /** + * @param string $name the filter property name + * @param mixed $value the filter property value + * + * @return $this + */ + public function setProperty($name, $value) + { + $this->properties[$name] = $value; + + return $this; + } + + /** + * @param string $name the filter property name + * + * @return mixed|null + */ + public function getProperty($name) + { + if (!array_key_exists($name, $this->properties)) { + return null; + } + + return $this->properties[$name]; + } + + /** + * @param mixed $value + * + * @return $this + */ + public function setValue($value) + { + $this->value = $value; + + return $this; + } + + /** + * @return mixed + */ + public function getValue() + { + return $this->value; + } + + /** + * @param int $magnitude the filter magnitude + * + * @return $this + */ + public function setMagnitude($magnitude) + { + $this->magnitude = (int) $magnitude; + + return $this; + } + + /** + * @return int the filter magnitude + */ + public function getMagnitude() + { + return $this->magnitude; + } + + /** + * @param bool $active sets the activation of the filter + * + * @return $this + */ + public function setActive($active = true) + { + $this->active = $active; + + return $this; + } + + /** + * @return bool returns true if the filter is active + */ + public function isActive() + { + return $this->active; + } + + /** + * @param bool $displayed sets the display of the filter + * + * @return $this + */ + public function setDisplayed($displayed = true) + { + $this->displayed = $displayed; + + return $this; + } + + /** + * @return bool returns true if the filter is displayed + */ + public function isDisplayed() + { + return $this->displayed; + } + + /** + * @param array $nextEncodedFacets + * + * @return $this + */ + public function setNextEncodedFacets($nextEncodedFacets) + { + $this->nextEncodedFacets = $nextEncodedFacets; + + return $this; + } + + /** + * @return array + */ + public function getNextEncodedFacets() + { + return $this->nextEncodedFacets; + } +} diff --git a/src/Core/Product/Search/Pagination.php b/src/Core/Product/Search/Pagination.php new file mode 100644 index 00000000..1d4bb161 --- /dev/null +++ b/src/Core/Product/Search/Pagination.php @@ -0,0 +1,173 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + */ + +namespace PrestaShop\PrestaShop\Core\Product\Search; + +class Pagination +{ + /** + * @var int the total number of pages for this query + */ + private $pagesCount; + + /** + * @var int the index of the returned page + */ + private $page; + + /** + * @param int $pagesCount + * + * @return $this + */ + public function setPagesCount($pagesCount) + { + if (!is_int($pagesCount)) { + trigger_error(sprintf('Integer value is expected, got `%s`', gettype($pagesCount)), E_USER_NOTICE); + $pagesCount = (int) $pagesCount; + } + + $this->pagesCount = $pagesCount; + + return $this; + } + + /** + * @return int + */ + public function getPagesCount() + { + return $this->pagesCount; + } + + /** + * @param int $page + * + * @return $this + */ + public function setPage($page) + { + if (!is_int($page)) { + trigger_error(sprintf('Integer value is expected, got `%s`', gettype($page)), E_USER_NOTICE); + $page = (int) $page; + } + + $this->page = $page; + + return $this; + } + + /** + * @return int + */ + public function getPage() + { + return $this->page; + } + + /** + * @param int $page + * @param string $type + * + * @return array + */ + private function buildPageLink($page, $type = 'page') + { + $current = $page === $this->getPage(); + + return [ + 'type' => $type, + 'page' => $page, + 'clickable' => !$current, + 'current' => $type === 'page' ? $current : false, + ]; + } + + /** + * @return array + */ + private function buildSpacer() + { + return [ + 'type' => 'spacer', + 'page' => null, + 'clickable' => false, + 'current' => false, + ]; + } + + /** + * @return array + */ + public function buildLinks() + { + $links = []; + + $addPageLink = function ($page) use (&$links) { + static $lastPage = null; + + if ($page < 1 || $page > $this->getPagesCount()) { + return; + } + + if (null !== $lastPage && $page > $lastPage + 1) { + $links[] = $this->buildSpacer(); + } + + if ($page !== $lastPage) { + $links[] = $this->buildPageLink($page); + } + + $lastPage = $page; + }; + + $boundaryContextLength = 1; + $pageContextLength = 3; + + $links[] = $this->buildPageLink(max(1, $this->getPage() - 1), 'previous'); + + for ($i = 0; $i < $boundaryContextLength; ++$i) { + $addPageLink(1 + $i); + } + + $start = max(1, $this->getPage() - (int) floor(($pageContextLength - 1) / 2)); + if ($start + $pageContextLength > $this->getPagesCount()) { + $start = $this->getPagesCount() - $pageContextLength + 1; + } + + for ($i = 0; $i < $pageContextLength; ++$i) { + $addPageLink($start + $i); + } + + for ($i = 0; $i < $boundaryContextLength; ++$i) { + $addPageLink($this->getPagesCount() - $boundaryContextLength + 1 + $i); + } + + $links[] = $this->buildPageLink(min($this->getPagesCount(), $this->getPage() + 1), 'next'); + + return $links; + } +} diff --git a/src/Core/Product/Search/ProductSearchContext.php b/src/Core/Product/Search/ProductSearchContext.php new file mode 100644 index 00000000..13352b8c --- /dev/null +++ b/src/Core/Product/Search/ProductSearchContext.php @@ -0,0 +1,196 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + */ + +namespace PrestaShop\PrestaShop\Core\Product\Search; + +use Context; + +class ProductSearchContext +{ + /** + * @var int the Shop id + */ + private $idShop; + + /** + * @var int the Language id + */ + private $idLang; + + /** + * @var int the Currency id + */ + private $idCurrency; + + /** + * @var int the Customer id + */ + private $idCustomer; + + /** + * @var int the Shop Group id + */ + private $idShopGroup; + + /** + * @var bool if the sharing stock is enable + */ + private $stockSharingBetweenShopGroupEnabled = false; + + public function __construct(Context $context = null) + { + if ($context) { + $shopGroup = $context->shop->getGroup(); + + $this->idShop = $context->shop->id; + $this->idShopGroup = $shopGroup->id; + $this->stockSharingBetweenShopGroupEnabled = (bool) $shopGroup->share_stock; + $this->idLang = $context->language->id; + $this->idCurrency = $context->currency->id; + $this->idCustomer = $context->customer->id; + } + } + + /** + * @param int $idShop + * + * @return self + */ + public function setIdShop($idShop) + { + $this->idShop = $idShop; + + return $this; + } + + /** + * @return int the Product Search Shop id + */ + public function getIdShop() + { + return $this->idShop; + } + + /** + * @param int $idLang + * + * @return self + */ + public function setIdLang($idLang) + { + $this->idLang = $idLang; + + return $this; + } + + /** + * @return int the Product Search Language id + */ + public function getIdLang() + { + return $this->idLang; + } + + /** + * @param int $idCurrency + * + * @return self + */ + public function setIdCurrency($idCurrency) + { + $this->idCurrency = $idCurrency; + + return $this; + } + + /** + * @return int the Product Search Currency id + */ + public function getIdCurrency() + { + return $this->idCurrency; + } + + /** + * @param int $idCustomer + * + * @return self + */ + public function setIdCustomer($idCustomer) + { + $this->idCustomer = $idCustomer; + + return $this; + } + + /** + * @return int the Product Search Customer id + */ + public function getIdCustomer() + { + return $this->idCustomer; + } + + /** + * @return int the Shop Group Iid + */ + public function getIdShopGroup(): int + { + return $this->idShopGroup; + } + + /** + * @param int $idShopGroup + * + * @return self + */ + public function setIdShopGroup(int $idShopGroup): self + { + $this->idShopGroup = $idShopGroup; + + return $this; + } + + /** + * @return bool if sharing stock is enable + */ + public function isStockSharingBetweenShopGroupEnabled(): bool + { + return $this->stockSharingBetweenShopGroupEnabled; + } + + /** + * @param bool $stockSharingBetweenShopGroupEnabled + * + * @return self + */ + public function setStockSharingBetweenShopGroupEnabled(bool $stockSharingBetweenShopGroupEnabled): self + { + $this->stockSharingBetweenShopGroupEnabled = $stockSharingBetweenShopGroupEnabled; + + return $this; + } +} diff --git a/src/Core/Product/Search/ProductSearchProviderInterface.php b/src/Core/Product/Search/ProductSearchProviderInterface.php new file mode 100644 index 00000000..fefc5853 --- /dev/null +++ b/src/Core/Product/Search/ProductSearchProviderInterface.php @@ -0,0 +1,44 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + */ + +namespace PrestaShop\PrestaShop\Core\Product\Search; + +/** + * Will define the query to execute in order to retrieve the list of products. + */ +interface ProductSearchProviderInterface +{ + /** + * @param ProductSearchContext $context + * @param ProductSearchQuery $query + * + * @return ProductSearchResult + */ + public function runQuery( + ProductSearchContext $context, + ProductSearchQuery $query + ); +} diff --git a/src/Core/Product/Search/ProductSearchQuery.php b/src/Core/Product/Search/ProductSearchQuery.php new file mode 100644 index 00000000..f9a25ec5 --- /dev/null +++ b/src/Core/Product/Search/ProductSearchQuery.php @@ -0,0 +1,294 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + */ + +namespace PrestaShop\PrestaShop\Core\Product\Search; + +/** + * Define the Product Query to execute according the the encoded facets. + */ +class ProductSearchQuery +{ + /** + * @var string + */ + private $queryType; + + /** + * @var int + */ + private $idCategory; + + /** + * @var int + */ + private $idManufacturer; + + /** + * @var int + */ + private $idSupplier; + + /** + * @var string + */ + private $searchString; + + /** + * @var string + */ + private $searchTag; + + /** + * @var array|string + */ + private $encodedFacets; + + /** + * A default that is multiple of 2, 3 and 4 should be OK for + * many layouts. + * + * @var int 12 is the best number ever + */ + private $resultsPerPage = 12; + + /** + * @var int + */ + private $page = 1; + + /** + * @var SortOrder + */ + private $sortOrder; + + /** + * ProductSearchQuery constructor. + */ + public function __construct() + { + $this->setSortOrder(new SortOrder('product', 'name', 'ASC')); + } + + /** + * @param string $queryType + * + * @return $this + */ + public function setQueryType($queryType) + { + $this->queryType = $queryType; + + return $this; + } + + /** + * @return string + */ + public function getQueryType() + { + return $this->queryType; + } + + /** + * @param int $idCategory + * + * @return $this + */ + public function setIdCategory($idCategory) + { + $this->idCategory = $idCategory; + + return $this; + } + + /** + * @return int + */ + public function getIdCategory() + { + return $this->idCategory; + } + + /** + * @param int $idManufacturer + * + * @return $this + */ + public function setIdManufacturer($idManufacturer) + { + $this->idManufacturer = $idManufacturer; + + return $this; + } + + /** + * @return int + */ + public function getIdManufacturer() + { + return $this->idManufacturer; + } + + /** + * @param int $idSupplier + * + * @return $this + */ + public function setIdSupplier($idSupplier) + { + $this->idSupplier = $idSupplier; + + return $this; + } + + /** + * @return int + */ + public function getIdSupplier() + { + return $this->idSupplier; + } + + /** + * @param int $resultsPerPage + * + * @return $this + */ + public function setResultsPerPage($resultsPerPage) + { + $this->resultsPerPage = (int) $resultsPerPage; + + return $this; + } + + /** + * @return int + */ + public function getResultsPerPage() + { + return $this->resultsPerPage; + } + + /** + * @param int $page + * + * @return $this + */ + public function setPage($page) + { + $this->page = (int) $page; + + return $this; + } + + /** + * @return int + */ + public function getPage() + { + return $this->page; + } + + /** + * @param SortOrder $sortOrder + * + * @return $this + */ + public function setSortOrder(SortOrder $sortOrder) + { + $this->sortOrder = $sortOrder; + + return $this; + } + + /** + * @return SortOrder + */ + public function getSortOrder() + { + return $this->sortOrder; + } + + /** + * @param string $searchString + * + * @return $this + */ + public function setSearchString($searchString) + { + $this->searchString = $searchString; + + return $this; + } + + /** + * @return string + */ + public function getSearchString() + { + return $this->searchString; + } + + /** + * @param string $searchTag + * + * @return $this + */ + public function setSearchTag($searchTag) + { + $this->searchTag = $searchTag; + + return $this; + } + + /** + * @return string + */ + public function getSearchTag() + { + return $this->searchTag; + } + + /** + * @param array|string $encodedFacets + * + * @return $this + */ + public function setEncodedFacets($encodedFacets) + { + $this->encodedFacets = $encodedFacets; + + return $this; + } + + /** + * @return array|string + */ + public function getEncodedFacets() + { + return $this->encodedFacets; + } +} diff --git a/src/Core/Product/Search/ProductSearchResult.php b/src/Core/Product/Search/ProductSearchResult.php new file mode 100644 index 00000000..64ed3e2e --- /dev/null +++ b/src/Core/Product/Search/ProductSearchResult.php @@ -0,0 +1,191 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + */ + +namespace PrestaShop\PrestaShop\Core\Product\Search; + +class ProductSearchResult +{ + /** + * @var array + */ + private $products = []; + /** + * @var int + */ + private $totalProductsCount; + /** + * @var FacetCollection + */ + private $facetCollection; + /** + * @var string + */ + private $encodedFacets; + /** + * @var SortOrder[] + */ + private $availableSortOrders = []; + /** + * @var SortOrder + */ + private $currentSortOrder; + + /** + * @param array $products + * + * @return $this + */ + public function setProducts(array $products) + { + $this->products = $products; + + return $this; + } + + /** + * @return array + */ + public function getProducts() + { + return $this->products; + } + + /** + * @param int $totalProductsCount + * + * @return $this + */ + public function setTotalProductsCount($totalProductsCount) + { + $this->totalProductsCount = $totalProductsCount; + + return $this; + } + + /** + * @return int + */ + public function getTotalProductsCount() + { + return $this->totalProductsCount; + } + + /** + * @param FacetCollection $facetCollection + * + * @return $this + */ + public function setFacetCollection(FacetCollection $facetCollection) + { + $this->facetCollection = $facetCollection; + + return $this; + } + + /** + * @return FacetCollection + */ + public function getFacetCollection() + { + return $this->facetCollection; + } + + /** + * @param string $encodedFacets + * + * @return $this + */ + public function setEncodedFacets($encodedFacets) + { + $this->encodedFacets = $encodedFacets; + + return $this; + } + + /** + * @return string + */ + public function getEncodedFacets() + { + return $this->encodedFacets; + } + + /** + * @param SortOrder $sortOrder + * + * @return $this + */ + public function addAvailableSortOrder(SortOrder $sortOrder) + { + $this->availableSortOrders[] = $sortOrder; + + return $this; + } + + /** + * @return array + */ + public function getAvailableSortOrders() + { + return $this->availableSortOrders; + } + + /** + * @param array $sortOrders + * + * @return $this + */ + public function setAvailableSortOrders(array $sortOrders) + { + $this->availableSortOrders = []; + + foreach ($sortOrders as $sortOrder) { + $this->addAvailableSortOrder($sortOrder); + } + + return $this; + } + + /** + * @param SortOrder $currentSortOrder + * + * @return $this + */ + public function setCurrentSortOrder(SortOrder $currentSortOrder) + { + $this->currentSortOrder = $currentSortOrder; + + return $this; + } + + /** + * @return mixed + */ + public function getCurrentSortOrder() + { + return $this->currentSortOrder; + } +} diff --git a/src/Core/Product/Search/SortOrder.php b/src/Core/Product/Search/SortOrder.php new file mode 100644 index 00000000..fd822e82 --- /dev/null +++ b/src/Core/Product/Search/SortOrder.php @@ -0,0 +1,270 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + */ + +namespace PrestaShop\PrestaShop\Core\Product\Search; + +use PrestaShop\PrestaShop\Core\Exception\CoreException; +use PrestaShop\PrestaShop\Core\Product\Search\Exception\InvalidSortOrderDirectionException; + +/** + * This class define in which order the list of products will be sorted. + */ +class SortOrder +{ + /** + * @var string the SortOrder entity + */ + private $entity; + /** + * @var string the SortOrder field + */ + private $field; + /** + * @var string the SortOrder direction + */ + private $direction; + /** + * @var string string The SortOrder label + */ + private $label; + + /** + * SortOrder constructor. + * + * @param string $entity the SortOrder entity + * @param string $field the SortOrder field + * @param string $direction the SortOrder direction + * + * @throws InvalidSortOrderDirectionException + */ + public function __construct($entity, $field, $direction = 'asc') + { + $this + ->setEntity($entity) + ->setField($field) + ->setDirection($direction); + } + + /** + * Will returns a new Sort Order with random direction. + * + * @return SortOrder + * + * @throws InvalidSortOrderDirectionException + */ + public static function random() + { + return new static('', '', 'random'); + } + + /** + * @return bool if true, the Sort Order direction is random + */ + public function isRandom() + { + return $this->getDirection() === 'random'; + } + + /** + * @return array the array representation of a Sort Order + */ + public function toArray() + { + return [ + 'entity' => $this->entity, + 'field' => $this->field, + 'direction' => $this->direction, + 'label' => $this->label, + 'urlParameter' => $this->toString(), + ]; + } + + /** + * @return string the string representation of a Sort Order + */ + public function toString() + { + return "{$this->entity}.{$this->field}.{$this->direction}"; + } + + /** + * Creates a new Sort Order from string of this kind: {entity}.{field}.{direction}. + * + * @param string $sortOrderConfiguration the Sort Order configuration string + * + * @return SortOrder + * + * @throws InvalidSortOrderDirectionException + */ + public static function newFromString($sortOrderConfiguration) + { + $sortParams = explode('.', $sortOrderConfiguration); + + if (count($sortParams) < 3) { + throw new CoreException('Invalid argument'); + } + + list($entity, $field, $direction) = $sortParams; + + return new static($entity, $field, $direction); + } + + /** + * @param string $label the Sort Order label + * + * @return $this + */ + public function setLabel($label) + { + $this->label = $label; + + return $this; + } + + /** + * @return string the Sort Order label + */ + public function getLabel() + { + return $this->label; + } + + /** + * @param string $entity the Sort Order entity + * + * @return $this + */ + public function setEntity($entity) + { + $this->entity = $entity; + + return $this; + } + + /** + * @return string the Sort Order entity + */ + public function getEntity() + { + return $this->entity; + } + + /** + * @param string $field the Sort Order field + * + * @return $this + */ + public function setField($field) + { + $this->field = $field; + + return $this; + } + + /** + * @return string the Sort Order field + */ + public function getField() + { + return $this->field; + } + + /** + * @param string $direction + * + * @return string + * + * @throws InvalidSortOrderDirectionException + */ + public function setDirection($direction) + { + $formattedDirection = strtolower($direction); + if (!in_array($formattedDirection, ['asc', 'desc', 'random'])) { + throw new InvalidSortOrderDirectionException($direction); + } + + $this->direction = $formattedDirection; + + return $this->direction; + } + + /** + * @return string the Sort Order direction + */ + public function getDirection() + { + return $this->direction; + } + + /** + * @return string Returns the order way using legacy prefix + */ + private function getLegacyPrefix() + { + if ($this->entity === 'product') { + if ($this->field === 'name') { + return 'pl.'; + } elseif ($this->field === 'position') { + return 'cp.'; + } elseif ($this->field === 'manufacturer_name') { + $this->setField('name'); + + return 'm.'; + } + + return 'p.'; + } + if ($this->entity === 'manufacturer') { + return 'm.'; + } + + return ''; + } + + /** + * @param bool $prefix if true, relies on legacy prefix + * + * @return string + */ + public function toLegacyOrderBy($prefix = false) + { + if ($prefix) { + return $this->getLegacyPrefix() . $this->field; + } elseif ($this->entity === 'manufacturer' && $this->field === 'name') { + return 'manufacturer_name'; + } else { + return $this->field; + } + } + + /** + * @return string the legacy order way + */ + public function toLegacyOrderWay() + { + return $this->getDirection(); + } +} diff --git a/src/Core/Product/Search/SortOrderFactory.php b/src/Core/Product/Search/SortOrderFactory.php new file mode 100644 index 00000000..26e412a3 --- /dev/null +++ b/src/Core/Product/Search/SortOrderFactory.php @@ -0,0 +1,61 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + */ + +namespace PrestaShop\PrestaShop\Core\Product\Search; + +use Symfony\Component\Translation\TranslatorInterface; + +/** + * This class is not a factory but a provider of default Sort Orders. + * + * @deprecated since 1.7.6 and to be removed in the next major: use SortOrdersCollection:getDefaults instead. + */ +class SortOrderFactory +{ + /** + * @var TranslatorInterface the translator + */ + private $translator; + + public function __construct(TranslatorInterface $translator) + { + @trigger_error( + 'This class is deprecated since 1.7.6, use SortOrdersCollection::getDefaults instead.', + E_USER_DEPRECATED + ); + $this->translator = $translator; + } + + /** + * @return array + * + * @throws \Exception + */ + public function getDefaultSortOrders() + { + return (new SortOrdersCollection($this->translator))->getDefaults(); + } +} diff --git a/src/Core/Product/Search/SortOrdersCollection.php b/src/Core/Product/Search/SortOrdersCollection.php new file mode 100644 index 00000000..2892ce4d --- /dev/null +++ b/src/Core/Product/Search/SortOrdersCollection.php @@ -0,0 +1,71 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + */ + +namespace PrestaShop\PrestaShop\Core\Product\Search; + +use Symfony\Component\Translation\TranslatorInterface; + +/** + * This class provide the list of default Sort Orders. + */ +final class SortOrdersCollection +{ + /** + * @var TranslatorInterface the translator + */ + private $translator; + + public function __construct(TranslatorInterface $translator) + { + $this->translator = $translator; + } + + /** + * @return array + * + * @throws \Exception + */ + public function getDefaults() + { + return [ + (new SortOrder('product', 'position', 'asc'))->setLabel( + $this->translator->trans('Relevance', [], 'Shop.Theme.Catalog') + ), + (new SortOrder('product', 'name', 'asc'))->setLabel( + $this->translator->trans('Name, A to Z', [], 'Shop.Theme.Catalog') + ), + (new SortOrder('product', 'name', 'desc'))->setLabel( + $this->translator->trans('Name, Z to A', [], 'Shop.Theme.Catalog') + ), + (new SortOrder('product', 'price', 'asc'))->setLabel( + $this->translator->trans('Price, low to high', [], 'Shop.Theme.Catalog') + ), + (new SortOrder('product', 'price', 'desc'))->setLabel( + $this->translator->trans('Price, high to low', [], 'Shop.Theme.Catalog') + ), + ]; + } +} diff --git a/src/Core/Product/Search/URLFragmentSerializer.php b/src/Core/Product/Search/URLFragmentSerializer.php new file mode 100644 index 00000000..ed55f7ca --- /dev/null +++ b/src/Core/Product/Search/URLFragmentSerializer.php @@ -0,0 +1,141 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + */ + +namespace PrestaShop\PrestaShop\Core\Product\Search; + +@trigger_error( + sprintf( + '%s is deprecated since version 1.7.8.0 and will be removed in the next major version.', + URLFragmentSerializer::class + ), + E_USER_DEPRECATED +); + +/** + * This class is a serializer for URL fragments. + * + * @deprecated since version 1.7.8 and will be removed in the next major version. + */ +class URLFragmentSerializer +{ + /** + * @param array $fragment + * + * @return string + */ + public function serialize(array $fragment) + { + $parts = []; + foreach ($fragment as $key => $values) { + array_unshift($values, $key); + $parts[] = $this->serializeListOfStrings('-', '-', $values); + } + + return $this->serializeListOfStrings('/', '/', $parts); + } + + /** + * @param string $string + * + * @return array + */ + public function unserialize($string) + { + $fragment = []; + $parts = $this->unserializeListOfStrings('/', '/', $string); + foreach ($parts as $part) { + $values = $this->unserializeListOfStrings('-', '-', $part); + $key = array_shift($values); + $fragment[$key] = $values; + } + + return $fragment; + } + + /** + * @param string $separator the string separator + * @param string $escape the string escape + * @param array $list + * + * @return string + */ + private function serializeListOfStrings($separator, $escape, array $list) + { + return implode($separator, array_map(function ($item) use ($separator, $escape) { + return str_replace($separator, $escape . $separator, $item); + }, $list)); + } + + /** + * @param string $separator the string separator + * @param string $escape the string escape + * @param string $string the UTF8 string + * + * @return array + */ + private function unserializeListOfStrings($separator, $escape, $string) + { + $list = []; + $currentString = ''; + $escaping = false; + + // get UTF-8 chars, inspired from http://stackoverflow.com/questions/9438158/split-utf8-string-into-array-of-chars + $arrayOfCharacters = []; + preg_match_all('/./u', $string, $arrayOfCharacters); + $characters = $arrayOfCharacters[0]; + + foreach ($characters as $character) { + if ($escaping) { + if ($character === $separator || $character === $escape) { + $currentString .= $character; + } else { + $list[] = $currentString; + $currentString = $character; + } + $escaping = false; + } else { + if ($character === $escape) { + $escaping = true; + } elseif ($character === $separator) { + $list[] = $currentString; + $currentString = ''; + } else { + $currentString .= $character; + } + } + } + + if ($escaping) { + $currentString .= $escape; + } + + if ('' !== $currentString) { + $list[] = $currentString; + } + + return $list; + } +}