|
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
|
|
|
* My Module module for xoops |
|
14
|
|
|
* |
|
15
|
|
|
* @copyright 2020 XOOPS Project (https://xooops.org) |
|
16
|
|
|
* @license GPL 2.0 or later |
|
17
|
|
|
* @package mymodule |
|
18
|
|
|
* @since 1.0 |
|
19
|
|
|
* @min_xoops 2.5.9 |
|
20
|
|
|
* @author TDM XOOPS - Email:<[email protected]> - Website:<http://xoops.org> |
|
21
|
|
|
*/ |
|
22
|
|
|
|
|
23
|
|
|
use Xmf\Request; |
|
24
|
|
|
|
|
25
|
|
|
require __DIR__ . '/header.php'; |
|
26
|
|
|
|
|
27
|
|
|
$cid = Request::getInt('cid', 0, 'GET'); |
|
28
|
|
|
include_once XOOPS_ROOT_PATH.'/class/template.php'; |
|
29
|
|
|
if (function_exists('mb_http_output')) { |
|
30
|
|
|
mb_http_output('pass'); |
|
31
|
|
|
} |
|
32
|
|
|
//header ('Content-Type:text/xml; charset=UTF-8'); |
|
33
|
|
|
$xoopsModuleConfig['utf8'] = false; |
|
34
|
|
|
|
|
35
|
|
|
$tpl = new \XoopsTpl(); |
|
36
|
|
|
$tpl->xoops_setCaching(2); //1 = Cache global, 2 = Cache individual (for template) |
|
37
|
|
|
$tpl->xoops_setCacheTime($helper->getConfig('timecacherss')*60); // Time of the cache on seconds |
|
38
|
|
|
$categories = mymoduleMyGetItemIds('mymodule_view', 'mymodule'); |
|
|
|
|
|
|
39
|
|
|
$criteria = new \CriteriaCompo(); |
|
40
|
|
|
|
|
41
|
|
|
$criteria->add(new \Criteria('cat_status', 0, '!=')); |
|
42
|
|
|
$criteria->add(new \Criteria('cid', '(' . implode(',', $categories) . ')','IN')); |
|
43
|
|
|
if ($cid != 0){ |
|
44
|
|
|
$criteria->add(new \Criteria('cid', $cid)); |
|
45
|
|
|
$articles = $articlesHandler->get($cid); |
|
46
|
|
|
$title = $xoopsConfig['sitename'] . ' - ' . $xoopsModule->getVar('name') . ' - ' . $articles->getVar('art_submitter'); |
|
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
|
|
|
$articlesArr = $articlesHandler->getAll($criteria); |
|
54
|
|
|
unset($criteria); |
|
55
|
|
|
|
|
56
|
|
|
if (!$tpl->is_cached('db:mymodule_rss.tpl', $cid)) { |
|
57
|
|
|
$tpl->assign('channel_title', htmlspecialchars($title, ENT_QUOTES)); |
|
58
|
|
|
$tpl->assign('channel_link', XOOPS_URL.'/'); |
|
59
|
|
|
$tpl->assign('channel_desc', htmlspecialchars($xoopsConfig['slogan'], ENT_QUOTES)); |
|
60
|
|
|
$tpl->assign('channel_lastbuild', formatTimestamp(time(), 'rss')); |
|
61
|
|
|
$tpl->assign('channel_webmaster', $xoopsConfig['adminmail']); |
|
62
|
|
|
$tpl->assign('channel_editor', $xoopsConfig['adminmail']); |
|
63
|
|
|
$tpl->assign('channel_category', 'Event'); |
|
64
|
|
|
$tpl->assign('channel_generator', 'XOOPS - ' . htmlspecialchars($xoopsModule->getVar('art_submitter'), ENT_QUOTES)); |
|
65
|
|
|
$tpl->assign('channel_language', _LANGCODE); |
|
66
|
|
|
if ( _LANGCODE == 'fr' ) { |
|
|
|
|
|
|
67
|
|
|
$tpl->assign('docs', 'http://www.scriptol.fr/rss/RSS-2.0.html'); |
|
68
|
|
|
} else { |
|
69
|
|
|
$tpl->assign('docs', 'http://cyber.law.harvard.edu/rss/rss.html'); |
|
70
|
|
|
} |
|
71
|
|
|
$tpl->assign('image_url', XOOPS_URL . $xoopsModuleConfig['logorss']); |
|
72
|
|
|
$dimention = getimagesize(XOOPS_ROOT_PATH . $xoopsModuleConfig['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
|
|
|
$tpl->assign('image_width', $width); |
|
84
|
|
|
$tpl->assign('image_height', $height); |
|
85
|
|
|
foreach (array_keys($articlesArr) as $i) { |
|
86
|
|
|
$description = $articlesArr[$i]->getVar('description'); |
|
87
|
|
|
//permet d'afficher uniquement la description courte |
|
88
|
|
|
if (strpos($description,'[pagebreak]')==false){ |
|
|
|
|
|
|
89
|
|
|
$description_short = $description; |
|
90
|
|
|
} else { |
|
91
|
|
|
$description_short = substr($description,0,strpos($description,'[pagebreak]')); |
|
92
|
|
|
} |
|
93
|
|
|
$tpl->append('items', array('title' => htmlspecialchars($articlesArr[$i]->getVar('art_submitter'), ENT_QUOTES), |
|
94
|
|
|
'link' => XOOPS_URL . '/modules/mymodule/single.php?cid=' . $articlesArr[$i]->getVar('cid') . '&art_id=' . $articlesArr[$i]->getVar('art_id'), |
|
95
|
|
|
'guid' => XOOPS_URL . '/modules/mymodule/single.php?cid=' . $articlesArr[$i]->getVar('cid') . '&art_id=' . $articlesArr[$i]->getVar('art_id'), |
|
96
|
|
|
'pubdate' => formatTimestamp($articlesArr[$i]->getVar('date'), 'rss'), |
|
97
|
|
|
'description' => htmlspecialchars($description_short, ENT_QUOTES))); |
|
98
|
|
|
} |
|
99
|
|
|
} |
|
100
|
|
|
header('Content-Type:text/xml; charset=' . _CHARSET); |
|
101
|
|
|
$tpl->display('db:mymodule_rss.tpl', $cid); |