udpate
This commit is contained in:
101
override/modules/prestablog/controllers/front/blog.php
Normal file
101
override/modules/prestablog/controllers/front/blog.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
class PrestaBlogBlogModuleFrontControllerOverride extends PrestaBlogBlogModuleFrontController
|
||||
{
|
||||
// Needed by creativeelements
|
||||
private $news = array();
|
||||
|
||||
/**
|
||||
* @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 'NewsClass';
|
||||
}
|
||||
|
||||
/**
|
||||
* @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()
|
||||
{
|
||||
$id_post = (int)Tools::getValue('id');
|
||||
if ($id_post && ($postObj = new NewsClass($id_post)) && Validate::isLoadedObject($postObj)) {
|
||||
return $id_post;
|
||||
}
|
||||
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) {
|
||||
$urls = [];
|
||||
|
||||
// Articles
|
||||
$urlsInfos = NewsClass::getListe(
|
||||
(int) $id_lang,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
null,
|
||||
'n.`date`',
|
||||
'desc',
|
||||
date(
|
||||
'Y-m-d H:i:s',
|
||||
strtotime('-' . (int) Configuration::get('prestablog_sitemap_older') . ' months')
|
||||
),
|
||||
null,
|
||||
null,
|
||||
1,
|
||||
(int) Configuration::get('prestablog_news_title_length'),
|
||||
(int) Configuration::get('prestablog_news_intro_length')
|
||||
);
|
||||
foreach ($urlsInfos as $child) {
|
||||
$urls[] = PrestaBlog::prestablogUrl(
|
||||
[
|
||||
'id' => (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);
|
||||
}
|
||||
}
|
||||
19
override/modules/prestablog/controllers/front/index.php
Normal file
19
override/modules/prestablog/controllers/front/index.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* This file protect the directory
|
||||
* 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.
|
||||
*/
|
||||
|
||||
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;
|
||||
Reference in New Issue
Block a user