Files
lulandia.pl/override/modules/af_seopages/controllers/front/seopage.php
2025-08-07 21:16:42 +02:00

70 lines
2.7 KiB
PHP

<?php
/**
* Page Cache Ultimate, Page Cache standard and Speed pack are powered by Jpresta (jpresta . com)
*
* @author Jpresta
* @copyright Jpresta
* @license See the license of this module in file LICENSE.txt, thank you.
*/
if (!defined('_PS_VERSION_')) {
exit;
}
/**
* Implements getJprestaModelObjectClassName() and getJprestaModelObjectId() to enable the HTML cache provided by the
* module Page Cache Ultimate created by jpresta.com
*/
class Af_SeopagesSeopageModuleFrontControllerOverride extends Af_SeopagesSeopageModuleFrontController
{
/**
* @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()
{
// A fake class to enable the cache
return 'AfSeoPage';
}
/**
* @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()
{
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) {
if (file_exists(_PS_MODULE_DIR_ . '/af_seopages/classes/SiteMap.php')) {
require_once _PS_MODULE_DIR_ . '/af_seopages/classes/SiteMap.php';
$afsp = Module::getInstanceByName('af_seopages');
if ($afsp) {
$sitemap = new SiteMap($afsp);
$links = $sitemap->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);
}
}