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 | require_once __DIR__ . '/header.php'; |
||||
17 | require_once XOOPS_ROOT_PATH . '/class/template.php'; |
||||
18 | |||||
19 | global $xoopsModuleConfig; |
||||
20 | /** @var \XoopsModules\Tdmdownloads\Helper $helper */ |
||||
21 | $helper = \XoopsModules\Tdmdownloads\Helper::getInstance(); |
||||
22 | |||||
23 | $itemsCount = $helper->getConfig('perpagerss'); |
||||
24 | $cid = \Xmf\Request::getInt('cid', 0, 'GET'); |
||||
25 | if (function_exists('mb_http_output')) { |
||||
26 | mb_http_output('pass'); |
||||
27 | } |
||||
28 | //header ('Content-Type:text/xml; charset=UTF-8'); |
||||
29 | $xoopsModuleConfig['utf8'] = false; |
||||
30 | |||||
31 | $moduleDirName = basename(__DIR__); |
||||
32 | |||||
33 | //$xoopsTpl = new \XoopsTpl(); |
||||
34 | $xoopsTpl->caching = 2; //1 = Cache global, 2 = Cache individuel (par template) |
||||
35 | $xoopsTpl->xoops_setCacheTime($helper->getConfig('timecacherss') * 60); // Temps de cache en secondes |
||||
36 | $categories = $utility->getItemIds('tdmdownloads_view', $moduleDirName); |
||||
37 | $criteria = new \CriteriaCompo(); |
||||
38 | $criteria->add(new \Criteria('status', 0, '!=')); |
||||
39 | $criteria->add(new \Criteria('cid', '(' . implode(',', $categories) . ')', 'IN')); |
||||
40 | if (0 !== $cid) { |
||||
41 | $criteria->add(new \Criteria('cid', $cid)); |
||||
42 | $cat = $categoryHandler->get($cid); |
||||
43 | $title = $xoopsConfig['sitename'] . ' - ' . $xoopsModule->getVar('name') . ' - ' . $cat->getVar('cat_title'); |
||||
44 | } else { |
||||
45 | $title = $xoopsConfig['sitename'] . ' - ' . $xoopsModule->getVar('name'); |
||||
46 | } |
||||
47 | $criteria->setLimit($helper->getConfig('perpagerss')); |
||||
48 | $criteria->setSort('date'); |
||||
49 | $criteria->setOrder('DESC'); |
||||
50 | $downloadsArray = $downloadsHandler->getAll($criteria); |
||||
51 | |||||
52 | if (!$xoopsTpl->is_cached('db:tdmdownloads_rss.tpl', $cid)) { |
||||
53 | $xoopsTpl->assign('channel_title', htmlspecialchars($title, ENT_QUOTES)); |
||||
54 | $xoopsTpl->assign('channel_link', XOOPS_URL . '/'); |
||||
55 | $xoopsTpl->assign('channel_desc', htmlspecialchars($xoopsConfig['slogan'], ENT_QUOTES)); |
||||
56 | $xoopsTpl->assign('channel_lastbuild', formatTimestamp(time(), 'rss')); |
||||
57 | $xoopsTpl->assign('channel_webmaster', $xoopsConfig['adminmail']); |
||||
58 | $xoopsTpl->assign('channel_editor', $xoopsConfig['adminmail']); |
||||
59 | $xoopsTpl->assign('channel_category', 'Event'); |
||||
60 | $xoopsTpl->assign('channel_generator', 'XOOPS - ' . htmlspecialchars($xoopsModule->getVar('name'), ENT_QUOTES)); |
||||
61 | $xoopsTpl->assign('channel_language', _LANGCODE); |
||||
62 | if (_LANGCODE === 'fr') { |
||||
0 ignored issues
–
show
introduced
by
![]() |
|||||
63 | $xoopsTpl->assign('docs', 'http://www.scriptol.fr/rss/RSS-2.0.html'); |
||||
64 | } else { |
||||
65 | $xoopsTpl->assign('docs', 'http://cyber.law.harvard.edu/rss/rss.html'); |
||||
66 | } |
||||
67 | |||||
68 | $xoopsTpl->assign('image_url', XOOPS_URL . $helper->getConfig('logorss')); |
||||
69 | $dimention = getimagesize(XOOPS_ROOT_PATH . $helper->getConfig('logorss')); |
||||
70 | if (empty($dimention[0])) { |
||||
71 | $width = 88; |
||||
72 | } else { |
||||
73 | $width = ($dimention[0] > 144) ? 144 : $dimention[0]; |
||||
74 | } |
||||
75 | if (empty($dimention[1])) { |
||||
76 | $height = 31; |
||||
77 | } else { |
||||
78 | $height = ($dimention[1] > 400) ? 400 : $dimention[1]; |
||||
79 | } |
||||
80 | $xoopsTpl->assign('image_width', $width); |
||||
81 | $xoopsTpl->assign('image_height', $height); |
||||
82 | foreach (array_keys($downloadsArray) as $i) { |
||||
83 | /** @var \XoopsModules\Tdmdownloads\Downloads[] $downloadsArray */ |
||||
84 | $description = $downloadsArray[$i]->getVar('description'); |
||||
85 | //permet d'afficher uniquement la description courte |
||||
86 | if (false === mb_strpos($description, '[pagebreak]')) { |
||||
0 ignored issues
–
show
It seems like
$description can also be of type array and array ; however, parameter $haystack of mb_strpos() does only seem to accept string , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
87 | $descriptionShort = $description; |
||||
88 | } else { |
||||
89 | $descriptionShort = mb_substr($description, 0, mb_strpos($description, '[pagebreak]')); |
||||
0 ignored issues
–
show
It seems like
$description can also be of type array and array ; however, parameter $str of mb_substr() does only seem to accept string , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
90 | } |
||||
91 | $xoopsTpl->append('items', [ |
||||
92 | 'title' => htmlspecialchars($downloadsArray[$i]->getVar('title'), ENT_QUOTES), |
||||
0 ignored issues
–
show
It seems like
$downloadsArray[$i]->getVar('title') can also be of type array and array ; however, parameter $string of htmlspecialchars() does only seem to accept string , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
93 | 'link' => XOOPS_URL . '/modules/' . $moduleDirName . '/singlefile.php?cid=' . $downloadsArray[$i]->getVar('cid') . '&lid=' . $downloadsArray[$i]->getVar('lid'), |
||||
94 | 'guid' => XOOPS_URL . '/modules/' . $moduleDirName . '/singlefile.php?cid=' . $downloadsArray[$i]->getVar('cid') . '&lid=' . $downloadsArray[$i]->getVar('lid'), |
||||
95 | 'pubdate' => formatTimestamp($downloadsArray[$i]->getVar('date'), 'rss'), |
||||
96 | 'description' => htmlspecialchars($descriptionShort, ENT_QUOTES), |
||||
97 | ]); |
||||
98 | } |
||||
99 | } |
||||
100 | header('Content-Type:text/xml; charset=' . _CHARSET); |
||||
101 | $xoopsTpl->display('db:tdmdownloads_rss.tpl', $cid); |
||||
102 |