1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
You may not change or alter any portion of this comment or credits |
4
|
|
|
of supporting developers from this source code or any supporting source code |
5
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
6
|
|
|
|
7
|
|
|
This program is distributed in the hope that it will be useful, |
8
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
9
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* oledrion |
14
|
|
|
* |
15
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
16
|
|
|
* @license {@link http://www.fsf.org/copyleft/gpl.html GNU public license} |
17
|
|
|
* @author Hervé Thouzard (http://www.herve-thouzard.com/) |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Flux RSS pour suivre les derniers produits |
22
|
|
|
*/ |
23
|
|
|
|
24
|
|
|
use XoopsModules\Oledrion; |
25
|
|
|
|
26
|
|
|
require_once __DIR__ . '/header.php'; |
27
|
|
|
require_once XOOPS_ROOT_PATH . '/class/template.php'; |
28
|
|
|
|
29
|
|
|
if (0 == Oledrion\Utility::getModuleOption('use_rss')) { |
30
|
|
|
exit; |
31
|
|
|
} |
32
|
|
|
// Paramètre, soit rien auquel cas on prend tous les produits récents soit cat_cid |
33
|
|
|
$cat_cid = \Xmf\Request::getInt('cat_cid', 0, 'GET'); |
34
|
|
|
if (function_exists('mb_http_output')) { |
35
|
|
|
mb_http_output('pass'); |
36
|
|
|
} |
37
|
|
|
$charset = 'utf-8'; |
38
|
|
|
header('Content-Type:text/xml; charset=' . $charset); |
39
|
|
|
$tpl = new \XoopsTpl(); |
40
|
|
|
|
41
|
|
|
$tpl->caching = 2; // 1 = Cache global, 2 = Cache individuel (par template) |
42
|
|
|
$tpl->xoops_setCacheTime(OLEDRION_RSS_CACHE); // Temps de cache en secondes |
|
|
|
|
43
|
|
|
|
44
|
|
|
if (!$tpl->is_cached('db:oledrion_rss.tpl', $cat_cid)) { |
45
|
|
|
$categoryTitle = ''; |
46
|
|
|
if (!empty($cat_cid)) { |
47
|
|
|
$category = null; |
48
|
|
|
$category = $categoryHandler->get($cat_cid); |
49
|
|
|
if (is_object($category)) { |
50
|
|
|
$categoryTitle = $category->getVar('cat_title'); |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
$sitename = htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES); |
54
|
|
|
$email = checkEmail($xoopsConfig['adminmail'], true); |
55
|
|
|
$slogan = htmlspecialchars($xoopsConfig['slogan'], ENT_QUOTES); |
56
|
|
|
$limit = Oledrion\Utility::getModuleOption('perpage'); |
57
|
|
|
|
58
|
|
|
$tpl->assign('charset', $charset); |
59
|
|
|
$tpl->assign('channel_title', xoops_utf8_encode($sitename)); |
60
|
|
|
$tpl->assign('channel_link', XOOPS_URL . '/'); |
61
|
|
|
$tpl->assign('channel_desc', xoops_utf8_encode($slogan)); |
62
|
|
|
$tpl->assign('channel_lastbuild', formatTimestamp(time(), 'rss')); |
63
|
|
|
$tpl->assign('channel_webmaster', xoops_utf8_encode($email)); |
64
|
|
|
$tpl->assign('channel_editor', xoops_utf8_encode($email)); |
65
|
|
|
$tpl->assign('channel_category', xoops_utf8_encode($categoryTitle)); |
66
|
|
|
$temp = Oledrion\Utility::getModuleName(); |
67
|
|
|
$tpl->assign('channel_generator', xoops_utf8_encode($temp)); |
68
|
|
|
$tpl->assign('channel_language', _LANGCODE); |
69
|
|
|
$tpl->assign('image_url', XOOPS_URL . '/images/logo.png'); |
70
|
|
|
$dimention = getimagesize(XOOPS_ROOT_PATH . '/images/logo.png'); |
71
|
|
|
if (empty($dimention[0])) { |
72
|
|
|
$width = 88; |
73
|
|
|
} else { |
74
|
|
|
$width = ($dimention[0] > 144) ? 144 : $dimention[0]; |
75
|
|
|
} |
76
|
|
|
if (empty($dimention[1])) { |
77
|
|
|
$height = 31; |
78
|
|
|
} else { |
79
|
|
|
$height = ($dimention[1] > 400) ? 400 : $dimention[1]; |
80
|
|
|
} |
81
|
|
|
$tpl->assign('image_width', $width); |
82
|
|
|
$tpl->assign('image_height', $height); |
83
|
|
|
|
84
|
|
|
$products = $productsHandler->getRecentProducts(new Oledrion\Parameters([ |
85
|
|
|
'start' => 0, |
86
|
|
|
'limit' => $limit, |
87
|
|
|
'category' => $cat_cid, |
88
|
|
|
])); |
89
|
|
|
foreach ($products as $item) { |
90
|
|
|
$title = htmlspecialchars($item->getVar('product_title'), ENT_QUOTES); |
91
|
|
|
$description = htmlspecialchars(strip_tags($item->getVar('product_summary')), ENT_QUOTES); |
92
|
|
|
$link = $item->getLink(); |
93
|
|
|
$tpl->append('items', [ |
94
|
|
|
'title' => xoops_utf8_encode($title), |
95
|
|
|
'link' => $link, |
96
|
|
|
'guid' => $link, |
97
|
|
|
'pubdate' => formatTimestamp($item->getVar('product_submitted'), 'rss'), |
98
|
|
|
'description' => xoops_utf8_encode($description), |
99
|
|
|
]); |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
$tpl->display('db:oledrion_rss.tpl', $cat_cid); |
103
|
|
|
|
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.