These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | // |
||
3 | // ------------------------------------------------------------------------ // |
||
4 | // XOOPS - PHP Content Management System // |
||
5 | // Copyright (c) 2000-2016 XOOPS.org // |
||
6 | // <http://xoops.org/> // |
||
7 | // ------------------------------------------------------------------------- // |
||
8 | // This program is free software; you can redistribute it and/or modify // |
||
9 | // it under the terms of the GNU General Public License as published by // |
||
10 | // the Free Software Foundation; either version 2 of the License, or // |
||
11 | // (at your option) any later version. // |
||
12 | // // |
||
13 | // You may not change or alter any portion of this comment or credits // |
||
14 | // of supporting developers from this source code or any supporting // |
||
15 | // source code which is considered copyrighted (c) material of the // |
||
16 | // original comment or credit authors. // |
||
17 | // // |
||
18 | // This program is distributed in the hope that it will be useful, // |
||
19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // |
||
20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
||
21 | // GNU General Public License for more details. // |
||
22 | // // |
||
23 | // You should have received a copy of the GNU General Public License // |
||
24 | // along with this program; if not, write to the Free Software // |
||
25 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
||
26 | // ------------------------------------------------------------------------ // |
||
27 | /* |
||
28 | * Display a list of all the published articles by month |
||
29 | * |
||
30 | * This page is called from the module's main menu. |
||
31 | * It will shows a list of all the articles by month. We use the module's |
||
32 | * option named "restrictindex" to show or hide stories according |
||
33 | * to users permissions |
||
34 | * |
||
35 | * @package News |
||
36 | * @author Xoops Modules Dev Team |
||
37 | * @copyright (c) XOOPS Project (http://xoops.org) |
||
38 | * |
||
39 | * Parameters received by this page : |
||
40 | * @page_param int year Optional, the starting year |
||
41 | * @page_param int month Optional, the starting month |
||
42 | * |
||
43 | * @page_title "News Archives" - Year - Month - Module's name |
||
44 | * |
||
45 | * @template_name news_archive.html |
||
46 | * |
||
47 | * Template's variables : |
||
48 | * @template_var array years Contains all the years we have information for |
||
49 | * Structure : |
||
50 | * number int Year (2004 for example) |
||
51 | * months array moths in the year (months when we have some articles) |
||
52 | * Structure : |
||
53 | * string string Month's name |
||
54 | * number int Month's number (between 1 and 12) |
||
55 | * @template_var boolean show_articles true or false |
||
56 | * @template_var string lang_articles Fixed text "Articles" |
||
57 | * @template_var array currentmonth Label of each month (from january to december) |
||
58 | * @template_var int currentyear Starting year |
||
59 | * @template_var string lang_actions Fixed text "Actions" |
||
60 | * @template_var string lang_date Fixed text "Date" |
||
61 | * @template_var string lang_views Fixed text "Views" |
||
62 | * @template_var array stories Contains all the stories to display |
||
63 | * Structure : |
||
64 | * title string Contains a link to see the topic and a link (with the story's title) to read the full story |
||
65 | * counter int Number of views for this article |
||
66 | * date string Article's publish date |
||
67 | * print_link string A link to the story's printable version |
||
68 | * mail_link string A mailto link to mail the story to a friend |
||
69 | * @template_var string lang_printer Fixed text "Printer Friendly Page" |
||
70 | * @template_var string lang_sendstory Fixed text "Send this Story to a Friend" |
||
71 | * @template_var string lang_storytotal Text "There are xx article(s) in total" |
||
72 | */ |
||
73 | ###################################################################### |
||
74 | # Original version: |
||
75 | # [11-may-2001] Kenneth Lee - http://www.nexgear.com/ |
||
76 | ###################################################################### |
||
77 | |||
78 | include __DIR__ . '/../../mainfile.php'; |
||
79 | $GLOBALS['xoopsOption']['template_main'] = 'news_archive.tpl'; |
||
80 | include_once XOOPS_ROOT_PATH . '/header.php'; |
||
81 | include_once XOOPS_ROOT_PATH . '/modules/news/class/class.newsstory.php'; |
||
82 | include_once XOOPS_ROOT_PATH . '/language/' . $xoopsConfig['language'] . '/calendar.php'; |
||
83 | include_once XOOPS_ROOT_PATH . '/modules/news/include/functions.php'; |
||
84 | $lastyear = 0; |
||
85 | $lastmonth = 0; |
||
86 | |||
87 | $months_arr = array( |
||
88 | 1 => _CAL_JANUARY, |
||
89 | 2 => _CAL_FEBRUARY, |
||
90 | 3 => _CAL_MARCH, |
||
91 | 4 => _CAL_APRIL, |
||
92 | 5 => _CAL_MAY, |
||
93 | 6 => _CAL_JUNE, |
||
94 | 7 => _CAL_JULY, |
||
95 | 8 => _CAL_AUGUST, |
||
96 | 9 => _CAL_SEPTEMBER, |
||
97 | 10 => _CAL_OCTOBER, |
||
98 | 11 => _CAL_NOVEMBER, |
||
99 | 12 => _CAL_DECEMBER |
||
100 | ); |
||
101 | |||
102 | $fromyear = isset($_GET['year']) ? (int)$_GET['year'] : 0; |
||
103 | $frommonth = isset($_GET['month']) ? (int)$_GET['month'] : 0; |
||
104 | |||
105 | $pgtitle = ''; |
||
106 | if ($fromyear && $frommonth) { |
||
107 | $pgtitle = sprintf(' - %d - %d', $fromyear, $frommonth); |
||
108 | } |
||
109 | $infotips = news_getmoduleoption('infotips'); |
||
110 | $restricted = news_getmoduleoption('restrictindex'); |
||
111 | $dateformat = news_getmoduleoption('dateformat'); |
||
112 | if ($dateformat === '') { |
||
113 | $dateformat = 'm'; |
||
114 | } |
||
115 | $myts = MyTextSanitizer::getInstance(); |
||
116 | $xoopsTpl->assign('xoops_pagetitle', $myts->htmlSpecialChars(_NW_NEWSARCHIVES) . $pgtitle . ' - ' . $xoopsModule->name('s')); |
||
117 | |||
118 | $useroffset = ''; |
||
119 | if (is_object($xoopsUser)) { |
||
120 | $timezone = $xoopsUser->timezone(); |
||
121 | if (isset($timezone)) { |
||
122 | $useroffset = $xoopsUser->timezone(); |
||
123 | } else { |
||
124 | $useroffset = $xoopsConfig['default_TZ']; |
||
125 | } |
||
126 | } |
||
127 | $result = $xoopsDB->query('SELECT published FROM ' |
||
128 | . $xoopsDB->prefix('news_stories') |
||
129 | . ' WHERE (published>0 AND published<=' |
||
130 | . time() |
||
131 | . ') AND (expired = 0 OR expired <= ' |
||
132 | . time() |
||
133 | . ') ORDER BY published DESC'); |
||
134 | if (!$result) { |
||
135 | echo _ERRORS; |
||
136 | exit(); |
||
137 | } else { |
||
138 | $years = array(); |
||
139 | $months = array(); |
||
140 | $i = 0; |
||
141 | while (list($time) = $xoopsDB->fetchRow($result)) { |
||
142 | $time = formatTimestamp($time, 'mysql', $useroffset); |
||
143 | if (preg_match('/(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})/', $time, $datetime)) { |
||
144 | $this_year = (int)$datetime[1]; |
||
145 | $this_month = (int)$datetime[2]; |
||
146 | if (empty($lastyear)) { |
||
147 | $lastyear = $this_year; |
||
148 | } |
||
149 | View Code Duplication | if ($lastmonth == 0) { |
|
150 | $lastmonth = $this_month; |
||
151 | $months[$lastmonth]['string'] = $months_arr[$lastmonth]; |
||
152 | $months[$lastmonth]['number'] = $lastmonth; |
||
153 | } |
||
154 | if ($lastyear != $this_year) { |
||
155 | $years[$i]['number'] = $lastyear; |
||
156 | $years[$i]['months'] = $months; |
||
157 | $months = array(); |
||
158 | $lastmonth = 0; |
||
159 | $lastyear = $this_year; |
||
160 | ++$i; |
||
161 | } |
||
162 | View Code Duplication | if ($lastmonth != $this_month) { |
|
163 | $lastmonth = $this_month; |
||
164 | $months[$lastmonth]['string'] = $months_arr[$lastmonth]; |
||
165 | $months[$lastmonth]['number'] = $lastmonth; |
||
166 | } |
||
167 | } |
||
168 | } |
||
169 | $years[$i]['number'] = $this_year; |
||
170 | $years[$i]['months'] = $months; |
||
171 | $xoopsTpl->assign('years', $years); |
||
172 | } |
||
173 | |||
174 | if ($fromyear != 0 && $frommonth != 0) { |
||
175 | $xoopsTpl->assign('show_articles', true); |
||
176 | $xoopsTpl->assign('lang_articles', _NW_ARTICLES); |
||
177 | $xoopsTpl->assign('currentmonth', $months_arr[$frommonth]); |
||
178 | $xoopsTpl->assign('currentyear', $fromyear); |
||
179 | $xoopsTpl->assign('lang_actions', _NW_ACTIONS); |
||
180 | $xoopsTpl->assign('lang_date', _NW_DATE); |
||
181 | $xoopsTpl->assign('lang_views', _NW_VIEWS); |
||
182 | |||
183 | // must adjust the selected time to server timestamp |
||
184 | $timeoffset = $useroffset - $xoopsConfig['server_TZ']; |
||
185 | $monthstart = mktime(0 - $timeoffset, 0, 0, $frommonth, 1, $fromyear); |
||
186 | $monthend = mktime(23 - $timeoffset, 59, 59, $frommonth + 1, 0, $fromyear); |
||
187 | $monthend = ($monthend > time()) ? time() : $monthend; |
||
188 | |||
189 | $count = 0; |
||
190 | $news = new NewsStory(); |
||
191 | $storyarray = $news->getArchive($monthstart, $monthend, $restricted); |
||
192 | $count = count($storyarray); |
||
193 | if (is_array($storyarray) && $count > 0) { |
||
194 | foreach ($storyarray as $article) { |
||
195 | $story = array(); |
||
196 | $htmltitle = ''; |
||
197 | if ($infotips > 0) { |
||
198 | $story['infotips'] = news_make_infotips($article->hometext()); |
||
0 ignored issues
–
show
|
|||
199 | $htmltitle = ' title="' . $story['infotips'] . '"'; |
||
200 | } |
||
201 | $story['title'] = "<a href='" |
||
202 | . XOOPS_URL |
||
203 | . '/modules/news/index.php?storytopic=' |
||
204 | . $article->topicid() |
||
205 | . "'>" |
||
206 | . $article->topic_title() |
||
207 | . "</a>: <a href='" |
||
208 | . XOOPS_URL |
||
209 | . '/modules/news/article.php?storyid=' |
||
210 | . $article->storyid() |
||
211 | . "'" |
||
212 | . $htmltitle |
||
213 | . '>' |
||
214 | . $article->title() |
||
215 | . '</a>'; |
||
216 | $story['counter'] = $article->counter(); |
||
217 | $story['date'] = formatTimestamp($article->published(), $dateformat, $useroffset); |
||
218 | $story['print_link'] = XOOPS_URL . '/modules/news/print.php?storyid=' . $article->storyid(); |
||
219 | $story['mail_link'] = 'mailto:?subject=' |
||
220 | . sprintf(_NW_INTARTICLE, $xoopsConfig['sitename']) |
||
221 | . '&body=' |
||
222 | . sprintf(_NW_INTARTFOUND, $xoopsConfig['sitename']) |
||
223 | . ': ' |
||
224 | . XOOPS_URL |
||
225 | . '/modules/' |
||
226 | . $xoopsModule->dirname() |
||
227 | . '/article.php?storyid=' |
||
228 | . $article->storyid(); |
||
229 | $xoopsTpl->append('stories', $story); |
||
230 | } |
||
231 | } |
||
232 | $xoopsTpl->assign('lang_printer', _NW_PRINTERFRIENDLY); |
||
233 | $xoopsTpl->assign('lang_sendstory', _NW_SENDSTORY); |
||
234 | $xoopsTpl->assign('lang_storytotal', sprintf(_NW_THEREAREINTOTAL, $count)); |
||
235 | } else { |
||
236 | $xoopsTpl->assign('show_articles', false); |
||
237 | } |
||
238 | |||
239 | $xoopsTpl->assign('lang_newsarchives', _NW_NEWSARCHIVES); |
||
240 | |||
241 | /** |
||
242 | * Create the meta datas |
||
243 | */ |
||
244 | news_CreateMetaDatas(); |
||
245 | |||
246 | include_once XOOPS_ROOT_PATH . '/footer.php'; |
||
247 |
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.