1 | <?php |
||
2 | /** |
||
3 | * TDMDownload |
||
4 | * |
||
5 | * You may not change or alter any portion of this comment or credits |
||
6 | * of supporting developers from this source code or any supporting source code |
||
7 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||
8 | * This program is distributed in the hope that it will be useful, |
||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
11 | * |
||
12 | * @copyright Gregory Mage (Aka Mage) |
||
13 | * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
||
14 | * @author Gregory Mage (Aka Mage) |
||
15 | */ |
||
16 | |||
17 | use XoopsModules\Tdmdownloads; |
||
18 | |||
19 | require_once __DIR__ . '/header.php'; |
||
20 | require_once XOOPS_ROOT_PATH . '/class/template.php'; |
||
21 | |||
22 | global $xoopsModuleConfig; |
||
23 | /** @var \XoopsModules\Tdmdownloads\Helper $helper */ |
||
24 | $helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); |
||
25 | |||
26 | $items_count = $helper->getConfig('perpagerss'); |
||
27 | $cid = \Xmf\Request::getInt('cid', 0, 'GET'); |
||
28 | if (function_exists('mb_http_output')) { |
||
29 | mb_http_output('pass'); |
||
30 | } |
||
31 | //header ('Content-Type:text/xml; charset=UTF-8'); |
||
32 | $xoopsModuleConfig['utf8'] = false; |
||
33 | |||
34 | $moduleDirName = basename(__DIR__); |
||
35 | |||
36 | //$xoopsTpl = new \XoopsTpl(); |
||
37 | $xoopsTpl->caching = 2; //1 = Cache global, 2 = Cache individuel (par template) |
||
38 | $xoopsTpl->xoops_setCacheTime($helper->getConfig('timecacherss') * 60); // Temps de cache en secondes |
||
39 | $categories = $utility->getItemIds('tdmdownloads_view', $moduleDirName); |
||
40 | $criteria = new \CriteriaCompo(); |
||
41 | $criteria->add(new \Criteria('status', 0, '!=')); |
||
42 | $criteria->add(new \Criteria('cid', '(' . implode(',', $categories) . ')', 'IN')); |
||
43 | if (0 !== $cid) { |
||
44 | $criteria->add(new \Criteria('cid', $cid)); |
||
45 | $cat = $categoryHandler->get($cid); |
||
46 | $title = $xoopsConfig['sitename'] . ' - ' . $xoopsModule->getVar('name') . ' - ' . $cat->getVar('cat_title'); |
||
47 | } else { |
||
48 | $title = $xoopsConfig['sitename'] . ' - ' . $xoopsModule->getVar('name'); |
||
49 | } |
||
50 | $criteria->setLimit($helper->getConfig('perpagerss')); |
||
51 | $criteria->setSort('date'); |
||
52 | $criteria->setOrder('DESC'); |
||
53 | $downloads_arr = $downloadsHandler->getAll($criteria); |
||
54 | |||
55 | if (!$xoopsTpl->is_cached('db:tdmdownloads_rss.tpl', $cid)) { |
||
56 | $xoopsTpl->assign('channel_title', htmlspecialchars($title, ENT_QUOTES)); |
||
57 | $xoopsTpl->assign('channel_link', XOOPS_URL . '/'); |
||
58 | $xoopsTpl->assign('channel_desc', htmlspecialchars($xoopsConfig['slogan'], ENT_QUOTES)); |
||
59 | $xoopsTpl->assign('channel_lastbuild', formatTimestamp(time(), 'rss')); |
||
60 | $xoopsTpl->assign('channel_webmaster', $xoopsConfig['adminmail']); |
||
61 | $xoopsTpl->assign('channel_editor', $xoopsConfig['adminmail']); |
||
62 | $xoopsTpl->assign('channel_category', 'Event'); |
||
63 | $xoopsTpl->assign('channel_generator', 'XOOPS - ' . htmlspecialchars($xoopsModule->getVar('name'), ENT_QUOTES)); |
||
64 | $xoopsTpl->assign('channel_language', _LANGCODE); |
||
65 | if (_LANGCODE === 'fr') { |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
66 | $xoopsTpl->assign('docs', 'http://www.scriptol.fr/rss/RSS-2.0.html'); |
||
67 | } else { |
||
68 | $xoopsTpl->assign('docs', 'http://cyber.law.harvard.edu/rss/rss.html'); |
||
69 | } |
||
70 | |||
71 | $xoopsTpl->assign('image_url', XOOPS_URL . $helper->getConfig('logorss')); |
||
72 | $dimention = getimagesize(XOOPS_ROOT_PATH . $helper->getConfig('logorss')); |
||
73 | if (empty($dimention[0])) { |
||
74 | $width = 88; |
||
75 | } else { |
||
76 | $width = ($dimention[0] > 144) ? 144 : $dimention[0]; |
||
77 | } |
||
78 | if (empty($dimention[1])) { |
||
79 | $height = 31; |
||
80 | } else { |
||
81 | $height = ($dimention[1] > 400) ? 400 : $dimention[1]; |
||
82 | } |
||
83 | $xoopsTpl->assign('image_width', $width); |
||
84 | $xoopsTpl->assign('image_height', $height); |
||
85 | foreach (array_keys($downloads_arr) as $i) { |
||
86 | $description = $downloads_arr[$i]->getVar('description'); |
||
87 | //permet d'afficher uniquement la description courte |
||
88 | if (false === mb_strpos($description, '[pagebreak]')) { |
||
89 | $description_short = $description; |
||
90 | } else { |
||
91 | $description_short = mb_substr($description, 0, mb_strpos($description, '[pagebreak]')); |
||
92 | } |
||
93 | $xoopsTpl->append('items', [ |
||
94 | 'title' => htmlspecialchars($downloads_arr[$i]->getVar('title'), ENT_QUOTES), |
||
95 | 'link' => XOOPS_URL . '/modules/' . $moduleDirName . '/singlefile.php?cid=' . $downloads_arr[$i]->getVar('cid') . '&lid=' . $downloads_arr[$i]->getVar('lid'), |
||
96 | 'guid' => XOOPS_URL . '/modules/' . $moduleDirName . '/singlefile.php?cid=' . $downloads_arr[$i]->getVar('cid') . '&lid=' . $downloads_arr[$i]->getVar('lid'), |
||
97 | 'pubdate' => formatTimestamp($downloads_arr[$i]->getVar('date'), 'rss'), |
||
98 | 'description' => htmlspecialchars($description_short, ENT_QUOTES), |
||
99 | ]); |
||
100 | } |
||
101 | } |
||
102 | header('Content-Type:text/xml; charset=' . _CHARSET); |
||
103 | $xoopsTpl->display('db:tdmdownloads_rss.tpl', $cid); |
||
104 |