These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||
14 | * @license {@link http://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later} |
||
15 | * @package |
||
16 | * @since |
||
17 | * @author XOOPS Development Team |
||
18 | */ |
||
19 | |||
20 | /* |
||
21 | * Display a list of all the published articles by month |
||
22 | * |
||
23 | * This page is called from the module's main menu. |
||
24 | * It will shows a list of all the articles by month. We use the module's |
||
25 | * option named "restrictindex" to show or hide stories according |
||
26 | * to users permissions |
||
27 | * |
||
28 | * @package News |
||
29 | * @author Xoops Modules Dev Team |
||
30 | * @copyright (c) XOOPS Project (https://xoops.org) |
||
31 | * |
||
32 | * Parameters received by this page : |
||
33 | * @page_param int year Optional, the starting year |
||
34 | * @page_param int month Optional, the starting month |
||
35 | * |
||
36 | * @page_title "News Archives" - Year - Month - Module's name |
||
37 | * |
||
38 | * @template_name news_archive.html |
||
39 | * |
||
40 | * Template's variables : |
||
41 | * @template_var array years Contains all the years we have information for |
||
42 | * Structure : |
||
43 | * number int Year (2004 for example) |
||
44 | * months array moths in the year (months when we have some articles) |
||
45 | * Structure : |
||
46 | * string string Month's name |
||
47 | * number int Month's number (between 1 and 12) |
||
48 | * @template_var boolean show_articles true or false |
||
49 | * @template_var string lang_articles Fixed text "Articles" |
||
50 | * @template_var array currentmonth Label of each month (from january to december) |
||
51 | * @template_var int currentyear Starting year |
||
52 | * @template_var string lang_actions Fixed text "Actions" |
||
53 | * @template_var string lang_date Fixed text "Date" |
||
54 | * @template_var string lang_views Fixed text "Views" |
||
55 | * @template_var array stories Contains all the stories to display |
||
56 | * Structure : |
||
57 | * title string Contains a link to see the topic and a link (with the story's title) to read the full story |
||
58 | * counter int Number of views for this article |
||
59 | * date string Article's publish date |
||
60 | * print_link string A link to the story's printable version |
||
61 | * mail_link string A mailto link to mail the story to a friend |
||
62 | * @template_var string lang_printer Fixed text "Printer Friendly Page" |
||
63 | * @template_var string lang_sendstory Fixed text "Send this Story to a Friend" |
||
64 | * @template_var string lang_storytotal Text "There are xx article(s) in total" |
||
65 | */ |
||
66 | ###################################################################### |
||
67 | # Original version: |
||
68 | # [11-may-2001] Kenneth Lee - http://www.nexgear.com/ |
||
69 | ###################################################################### |
||
70 | |||
71 | include __DIR__ . '/../../mainfile.php'; |
||
72 | $GLOBALS['xoopsOption']['template_main'] = 'news_archive.tpl'; |
||
73 | require_once XOOPS_ROOT_PATH . '/header.php'; |
||
74 | require_once XOOPS_ROOT_PATH . '/modules/news/class/class.newsstory.php'; |
||
75 | require_once XOOPS_ROOT_PATH . '/language/' . $xoopsConfig['language'] . '/calendar.php'; |
||
76 | require_once XOOPS_ROOT_PATH . '/modules/news/class/utility.php'; |
||
77 | $lastyear = 0; |
||
78 | $lastmonth = 0; |
||
79 | |||
80 | $months_arr = [ |
||
81 | 1 => _CAL_JANUARY, |
||
82 | 2 => _CAL_FEBRUARY, |
||
83 | 3 => _CAL_MARCH, |
||
84 | 4 => _CAL_APRIL, |
||
85 | 5 => _CAL_MAY, |
||
86 | 6 => _CAL_JUNE, |
||
87 | 7 => _CAL_JULY, |
||
88 | 8 => _CAL_AUGUST, |
||
89 | 9 => _CAL_SEPTEMBER, |
||
90 | 10 => _CAL_OCTOBER, |
||
91 | 11 => _CAL_NOVEMBER, |
||
92 | 12 => _CAL_DECEMBER |
||
93 | ]; |
||
94 | |||
95 | $fromyear = isset($_GET['year']) ? (int)$_GET['year'] : 0; |
||
96 | $frommonth = isset($_GET['month']) ? (int)$_GET['month'] : 0; |
||
97 | |||
98 | $pgtitle = ''; |
||
99 | if ($fromyear && $frommonth) { |
||
100 | $pgtitle = sprintf(' - %d - %d', $fromyear, $frommonth); |
||
101 | } |
||
102 | $infotips = NewsUtility::getModuleOption('infotips'); |
||
103 | $restricted = NewsUtility::getModuleOption('restrictindex'); |
||
104 | $dateformat = NewsUtility::getModuleOption('dateformat'); |
||
105 | if ('' === $dateformat) { |
||
106 | $dateformat = 'm'; |
||
107 | } |
||
108 | $myts = MyTextSanitizer::getInstance(); |
||
109 | $xoopsTpl->assign('xoops_pagetitle', $myts->htmlSpecialChars(_NW_NEWSARCHIVES) . $pgtitle . ' - ' . $xoopsModule->name('s')); |
||
110 | |||
111 | $useroffset = ''; |
||
112 | if (is_object($xoopsUser)) { |
||
113 | $timezone = $xoopsUser->timezone(); |
||
114 | if (isset($timezone)) { |
||
115 | $useroffset = $xoopsUser->timezone(); |
||
116 | } else { |
||
117 | $useroffset = $xoopsConfig['default_TZ']; |
||
118 | } |
||
119 | } |
||
120 | $result = $xoopsDB->query('SELECT published FROM ' . $xoopsDB->prefix('news_stories') . ' WHERE (published>0 AND published<=' . time() . ') AND (expired = 0 OR expired <= ' . time() . ') ORDER BY published DESC'); |
||
121 | if (!$result) { |
||
122 | echo _ERRORS; |
||
123 | exit(); |
||
124 | } else { |
||
125 | $years = []; |
||
126 | $months = []; |
||
127 | $i = 0; |
||
128 | while (list($time) = $xoopsDB->fetchRow($result)) { |
||
129 | $time = formatTimestamp($time, 'mysql', $useroffset); |
||
130 | if (preg_match('/(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})/', $time, $datetime)) { |
||
131 | $this_year = (int)$datetime[1]; |
||
132 | $this_month = (int)$datetime[2]; |
||
133 | if (empty($lastyear)) { |
||
134 | $lastyear = $this_year; |
||
135 | } |
||
136 | View Code Duplication | if (0 == $lastmonth) { |
|
137 | $lastmonth = $this_month; |
||
138 | $months[$lastmonth]['string'] = $months_arr[$lastmonth]; |
||
139 | $months[$lastmonth]['number'] = $lastmonth; |
||
140 | } |
||
141 | if ($lastyear != $this_year) { |
||
142 | $years[$i]['number'] = $lastyear; |
||
143 | $years[$i]['months'] = $months; |
||
144 | $months = []; |
||
145 | $lastmonth = 0; |
||
146 | $lastyear = $this_year; |
||
147 | ++$i; |
||
148 | } |
||
149 | View Code Duplication | if ($lastmonth != $this_month) { |
|
150 | $lastmonth = $this_month; |
||
151 | $months[$lastmonth]['string'] = $months_arr[$lastmonth]; |
||
152 | $months[$lastmonth]['number'] = $lastmonth; |
||
153 | } |
||
154 | } |
||
155 | } |
||
156 | $years[$i]['number'] = $this_year; |
||
157 | $years[$i]['months'] = $months; |
||
158 | $xoopsTpl->assign('years', $years); |
||
159 | } |
||
160 | |||
161 | if (0 != $fromyear && 0 != $frommonth) { |
||
162 | $xoopsTpl->assign('show_articles', true); |
||
163 | $xoopsTpl->assign('lang_articles', _NW_ARTICLES); |
||
164 | $xoopsTpl->assign('currentmonth', $months_arr[$frommonth]); |
||
165 | $xoopsTpl->assign('currentyear', $fromyear); |
||
166 | $xoopsTpl->assign('lang_actions', _NW_ACTIONS); |
||
167 | $xoopsTpl->assign('lang_date', _NW_DATE); |
||
168 | $xoopsTpl->assign('lang_views', _NW_VIEWS); |
||
169 | |||
170 | // must adjust the selected time to server timestamp |
||
171 | $timeoffset = $useroffset - $xoopsConfig['server_TZ']; |
||
172 | $monthstart = mktime(0 - $timeoffset, 0, 0, $frommonth, 1, $fromyear); |
||
173 | $monthend = mktime(23 - $timeoffset, 59, 59, $frommonth + 1, 0, $fromyear); |
||
174 | $monthend = ($monthend > time()) ? time() : $monthend; |
||
175 | |||
176 | $count = 0; |
||
177 | $news = new NewsStory(); |
||
178 | $storyarray = $news->getArchive($monthstart, $monthend, $restricted); |
||
179 | $count = count($storyarray); |
||
180 | if (is_array($storyarray) && $count > 0) { |
||
181 | foreach ($storyarray as $article) { |
||
182 | $story = []; |
||
183 | $htmltitle = ''; |
||
184 | if ($infotips > 0) { |
||
185 | $story['infotips'] = NewsUtility::makeInfotips($article->hometext()); |
||
0 ignored issues
–
show
|
|||
186 | $htmltitle = ' title="' . $story['infotips'] . '"'; |
||
187 | } |
||
188 | $story['title'] = "<a href='" |
||
189 | . XOOPS_URL |
||
190 | . '/modules/news/index.php?storytopic=' |
||
191 | . $article->topicid() |
||
192 | . "'>" |
||
193 | . $article->topic_title() |
||
194 | . "</a>: <a href='" |
||
195 | . XOOPS_URL |
||
196 | . '/modules/news/article.php?storyid=' |
||
197 | . $article->storyid() |
||
198 | . "'" |
||
199 | . $htmltitle |
||
200 | . '>' |
||
201 | . $article->title() |
||
202 | . '</a>'; |
||
203 | $story['counter'] = $article->counter(); |
||
204 | $story['date'] = formatTimestamp($article->published(), $dateformat, $useroffset); |
||
205 | $story['print_link'] = XOOPS_URL . '/modules/news/print.php?storyid=' . $article->storyid(); |
||
206 | $story['mail_link'] = 'mailto:?subject=' . sprintf(_NW_INTARTICLE, $xoopsConfig['sitename']) . '&body=' . sprintf(_NW_INTARTFOUND, $xoopsConfig['sitename']) . ': ' . XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/article.php?storyid=' . $article->storyid(); |
||
207 | $xoopsTpl->append('stories', $story); |
||
208 | } |
||
209 | } |
||
210 | $xoopsTpl->assign('lang_printer', _NW_PRINTERFRIENDLY); |
||
211 | $xoopsTpl->assign('lang_sendstory', _NW_SENDSTORY); |
||
212 | $xoopsTpl->assign('lang_storytotal', sprintf(_NW_THEREAREINTOTAL, $count)); |
||
213 | } else { |
||
214 | $xoopsTpl->assign('show_articles', false); |
||
215 | } |
||
216 | |||
217 | $xoopsTpl->assign('lang_newsarchives', _NW_NEWSARCHIVES); |
||
218 | |||
219 | /** |
||
220 | * Create the meta datas |
||
221 | */ |
||
222 | NewsUtility::createMetaDatas(); |
||
223 | |||
224 | require_once XOOPS_ROOT_PATH . '/footer.php'; |
||
225 |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.