76 lines
2.5 KiB
PHP
76 lines
2.5 KiB
PHP
<?php
|
|
/**
|
|
* 2024 Anvanto
|
|
*
|
|
* NOTICE OF LICENSE
|
|
*
|
|
* This source file is subject to the Academic Free License (AFL 3.0)
|
|
*
|
|
* @author Anvanto <anvantoco@gmail.com>
|
|
* @copyright 2024 Anvanto
|
|
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
|
*/
|
|
|
|
if (!defined('_PS_VERSION_')) {
|
|
exit;
|
|
}
|
|
|
|
include_once _PS_MODULE_DIR_.'anblog/loader.php';
|
|
|
|
class anblogrssModuleFrontController extends ModuleFrontController
|
|
{
|
|
public function initContent()
|
|
{
|
|
// Get data
|
|
$authors = array();
|
|
$config = AnblogConfig::getInstance();
|
|
$enbrss = Configuration::get(anblog::PREFIX . 'indexation', 0);
|
|
if ($enbrss != 1) {
|
|
exit;
|
|
}
|
|
$config->setVar('blockanblogs_height', Configuration::get('BANBLOGS_HEIGHT'));
|
|
$config->setVar('blockanblogs_width', Configuration::get('BANBLOGS_WIDTH'));
|
|
$config->setVar('blockanblogs_limit', Configuration::get('BANBLOGS_NBR'));
|
|
$limit = Configuration::get(anblog::PREFIX . 'rss_limit_item', 4);
|
|
$helper = AnblogHelper::getInstance();
|
|
$blogs = AnblogBlog::getListBlogs(
|
|
null,
|
|
Context::getContext()->language->id,
|
|
0,
|
|
$limit,
|
|
'id_anblog_blog',
|
|
'DESC',
|
|
array(),
|
|
true
|
|
);
|
|
foreach ($blogs as $key => $blog) {
|
|
$blog = AnblogHelper::buildBlog($helper, $blog, 'anblog_listing_leading_img', $config);
|
|
if ($blog['id_employee']) {
|
|
if (!isset($authors[$blog['id_employee']])) {
|
|
// validate module
|
|
$authors[$blog['id_employee']] = new Employee($blog['id_employee']);
|
|
}
|
|
|
|
$blog['author'] = $authors[$blog['id_employee']]->firstname.' '.$authors[$blog['id_employee']]->lastname;
|
|
$blog['author_link'] = $helper->getBlogAuthorLink($authors[$blog['id_employee']]->id);
|
|
} else {
|
|
$blog['author'] = '';
|
|
$blog['author_link'] = '';
|
|
}
|
|
|
|
$blogs[$key] = $blog;
|
|
}
|
|
|
|
$this->context->smarty->assign('anblogrss', [
|
|
'PS_SHOP_NAME' => Configuration::get('PS_SHOP_NAME'),
|
|
'link' => _PS_BASE_URL_.__PS_BASE_URI__,
|
|
'webMaster' => Configuration::get('PS_SHOP_EMAIL'),
|
|
'language' => Context::getContext()->language->iso_code,
|
|
'posts' => $blogs
|
|
]);
|
|
|
|
header('Content-Type:text/xml; charset=utf-8');
|
|
echo $this->module->display($this->module->name, 'rss.tpl');
|
|
die;
|
|
}
|
|
} |