@@ -29,9 +29,9 @@ discard block |
||
29 | 29 | include __DIR__ . '/header.php'; |
30 | 30 | |
31 | 31 | if (PlanetUtility::planetParseArguments($args_num, $args, $args_str)) { |
32 | - $args['year'] = @$args_num[0]; |
|
33 | - $args['month'] = @$args_num[1]; |
|
34 | - $args['day'] = @$args_num[2]; |
|
32 | + $args['year'] = @$args_num[0]; |
|
33 | + $args['month'] = @$args_num[1]; |
|
34 | + $args['day'] = @$args_num[2]; |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | $day = Request::getInt('day', @$args['day'], 'GET'); //(int)(empty($_GET['day']) ? @$args['day'] : $_GET['day']); |
@@ -52,31 +52,31 @@ discard block |
||
52 | 52 | |
53 | 53 | $year = empty($year) ? date('Y') : $year; |
54 | 54 | if ($month < 1) { |
55 | - $month = $day = 0; |
|
56 | - $page['time'] = sprintf(planet_constant('MD_TIME_Y'), $year); |
|
55 | + $month = $day = 0; |
|
56 | + $page['time'] = sprintf(planet_constant('MD_TIME_Y'), $year); |
|
57 | 57 | } elseif ($day < 1) { |
58 | - $day = 0; |
|
59 | - $page['time'] = sprintf(planet_constant('MD_TIME_YM'), $year, $month); |
|
58 | + $day = 0; |
|
59 | + $page['time'] = sprintf(planet_constant('MD_TIME_YM'), $year, $month); |
|
60 | 60 | } else { |
61 | - $page['time'] = sprintf(planet_constant('MD_TIME_YMD'), $year, $month, $day); |
|
61 | + $page['time'] = sprintf(planet_constant('MD_TIME_YMD'), $year, $month, $day); |
|
62 | 62 | } |
63 | 63 | $time = ['year' => $year, 'month' => $month, 'day' => $day]; |
64 | 64 | if ($xoopsUser) { |
65 | - $timeoffset = ($xoopsUser->getVar('timezone_offset') - $xoopsConfig['server_TZ']) * 3600; |
|
65 | + $timeoffset = ($xoopsUser->getVar('timezone_offset') - $xoopsConfig['server_TZ']) * 3600; |
|
66 | 66 | } else { |
67 | - $timeoffset = ($xoopsConfig['default_TZ'] - $xoopsConfig['server_TZ']) * 3600; |
|
67 | + $timeoffset = ($xoopsConfig['default_TZ'] - $xoopsConfig['server_TZ']) * 3600; |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | $criteria = new CriteriaCompo(); |
71 | 71 | if ($blog_id) { |
72 | - $criteria->add(new Criteria('blog_id', $blog_id)); |
|
72 | + $criteria->add(new Criteria('blog_id', $blog_id)); |
|
73 | 73 | } |
74 | 74 | $criteria->add(new Criteria("YEAR(FROM_UNIXTIME(art_time_publish - $timeoffset))", $year)); |
75 | 75 | if ($month) { |
76 | - $criteria->add(new Criteria("MONTH(FROM_UNIXTIME(art_time_publish - $timeoffset))", $month)); |
|
77 | - if ($day) { |
|
78 | - $criteria->add(new Criteria("DAY(FROM_UNIXTIME(art_time_publish - $timeoffset))", $day)); |
|
79 | - } |
|
76 | + $criteria->add(new Criteria("MONTH(FROM_UNIXTIME(art_time_publish - $timeoffset))", $month)); |
|
77 | + if ($day) { |
|
78 | + $criteria->add(new Criteria("DAY(FROM_UNIXTIME(art_time_publish - $timeoffset))", $day)); |
|
79 | + } |
|
80 | 80 | } |
81 | 81 | $criteria->setStart($start); |
82 | 82 | $criteria->setLimit($xoopsModuleConfig['articles_perpage']); |
@@ -87,115 +87,115 @@ discard block |
||
87 | 87 | $articles = []; |
88 | 88 | $blogs_id = []; |
89 | 89 | foreach ($articles_obj as $id => $article) { |
90 | - $articles[] = [ |
|
91 | - 'id' => $id, |
|
92 | - 'blog' => ['id' => $article->getVar('blog_id'), 'title' => ''], |
|
93 | - 'title' => $article->getVar('art_title'), |
|
94 | - 'time' => $article->getTime(), |
|
95 | - 'content' => $article->getVar('art_content') |
|
96 | - ]; |
|
97 | - $articles[] = $_article; |
|
98 | - $blogs_id[$article->getVar('blog_id')] = 1; |
|
99 | - unset($_article); |
|
90 | + $articles[] = [ |
|
91 | + 'id' => $id, |
|
92 | + 'blog' => ['id' => $article->getVar('blog_id'), 'title' => ''], |
|
93 | + 'title' => $article->getVar('art_title'), |
|
94 | + 'time' => $article->getTime(), |
|
95 | + 'content' => $article->getVar('art_content') |
|
96 | + ]; |
|
97 | + $articles[] = $_article; |
|
98 | + $blogs_id[$article->getVar('blog_id')] = 1; |
|
99 | + unset($_article); |
|
100 | 100 | } |
101 | 101 | $criteria_blog = new Criteria('blog_id', '(' . implode(',', array_keys($blog_array)) . ')', 'IN'); |
102 | 102 | $blogs = $blogHandler->getList($criteria_blog); |
103 | 103 | foreach (array_keys($articles) as $key) { |
104 | - $articles[$key]['blog']['title'] = $blogs[$articles[$key]['blog']['id']]; |
|
104 | + $articles[$key]['blog']['title'] = $blogs[$articles[$key]['blog']['id']]; |
|
105 | 105 | } |
106 | 106 | if ($blog_id > 0) { |
107 | - $page['blog'] = $blogs[$blog_id]; |
|
107 | + $page['blog'] = $blogs[$blog_id]; |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | if ($articles_count > $xoopsModuleConfig['articles_perpage']) { |
111 | - include XOOPS_ROOT_PATH . '/class/pagenav.php'; |
|
112 | - $nav = new XoopsPageNav($articles_count, $xoopsModuleConfig['articles_perpage'], $start, 'start', 'month=' . $month . '&day=' . $day . '&year=' . $year . '&blog=' . (int)$blog_id); |
|
113 | - $pagenav = $nav->renderNav(4); |
|
111 | + include XOOPS_ROOT_PATH . '/class/pagenav.php'; |
|
112 | + $nav = new XoopsPageNav($articles_count, $xoopsModuleConfig['articles_perpage'], $start, 'start', 'month=' . $month . '&day=' . $day . '&year=' . $year . '&blog=' . (int)$blog_id); |
|
113 | + $pagenav = $nav->renderNav(4); |
|
114 | 114 | } else { |
115 | - $pagenav = ''; |
|
115 | + $pagenav = ''; |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | $timenav = null; |
119 | 119 | $calendar = null; |
120 | 120 | $months = null; |
121 | 121 | if (empty($start)) { |
122 | - if ($blog_id) { |
|
123 | - $blog_criteria = ' AND blog_id=' . $blog_id; |
|
124 | - } else { |
|
125 | - $blog_criteria = ''; |
|
126 | - } |
|
127 | - // Get monthly list |
|
128 | - if (empty($month)) { |
|
129 | - $sql = "SELECT MONTH(FROM_UNIXTIME(art_time - $timeoffset)) AS mon, COUNT(DISTINCT art_id) AS count |
|
122 | + if ($blog_id) { |
|
123 | + $blog_criteria = ' AND blog_id=' . $blog_id; |
|
124 | + } else { |
|
125 | + $blog_criteria = ''; |
|
126 | + } |
|
127 | + // Get monthly list |
|
128 | + if (empty($month)) { |
|
129 | + $sql = "SELECT MONTH(FROM_UNIXTIME(art_time - $timeoffset)) AS mon, COUNT(DISTINCT art_id) AS count |
|
130 | 130 | FROM " . planet_DB_prefix('article') . " |
131 | 131 | WHERE YEAR(FROM_UNIXTIME(art_time - $timeoffset)) = $year |
132 | 132 | " . $blog_criteria . ' |
133 | 133 | GROUP BY mon |
134 | 134 | '; |
135 | - $result = $xoopsDB->query($sql); |
|
136 | - $months = []; |
|
137 | - while ($myrow = $xoopsDB->fetchArray($result)) { |
|
138 | - $months[] = [ |
|
139 | - 'title' => planet_constant('MD_MONTH_' . (int)$myrow['mon']) . ' (' . (int)$myrow['count'] . ')', |
|
140 | - 'url' => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . '' . $year . '/' . $myrow['mon'] . '/b' . $blog_id |
|
141 | - ]; |
|
142 | - } |
|
143 | - $timenav['prev'] = [ |
|
144 | - 'url' => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . '' . ($year - 1) . '/b' . $blog_id, |
|
145 | - 'title' => sprintf(planet_constant('MD_TIME_Y'), $year - 1) |
|
146 | - ]; |
|
147 | - if ($year < date('Y')) { |
|
148 | - $timenav['next'] = [ |
|
149 | - 'url' => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . '' . ($year + 1) . '/b' . $blog_id, |
|
150 | - 'title' => sprintf(planet_constant('MD_TIME_Y'), $year + 1) |
|
151 | - ]; |
|
152 | - } |
|
153 | - } // Get daily list |
|
154 | - elseif (empty($day)) { |
|
155 | - $sql = "SELECT DAY(FROM_UNIXTIME(art_time - $timeoffset)) AS day, COUNT(DISTINCT a.art_id) AS count |
|
135 | + $result = $xoopsDB->query($sql); |
|
136 | + $months = []; |
|
137 | + while ($myrow = $xoopsDB->fetchArray($result)) { |
|
138 | + $months[] = [ |
|
139 | + 'title' => planet_constant('MD_MONTH_' . (int)$myrow['mon']) . ' (' . (int)$myrow['count'] . ')', |
|
140 | + 'url' => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . '' . $year . '/' . $myrow['mon'] . '/b' . $blog_id |
|
141 | + ]; |
|
142 | + } |
|
143 | + $timenav['prev'] = [ |
|
144 | + 'url' => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . '' . ($year - 1) . '/b' . $blog_id, |
|
145 | + 'title' => sprintf(planet_constant('MD_TIME_Y'), $year - 1) |
|
146 | + ]; |
|
147 | + if ($year < date('Y')) { |
|
148 | + $timenav['next'] = [ |
|
149 | + 'url' => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . '' . ($year + 1) . '/b' . $blog_id, |
|
150 | + 'title' => sprintf(planet_constant('MD_TIME_Y'), $year + 1) |
|
151 | + ]; |
|
152 | + } |
|
153 | + } // Get daily list |
|
154 | + elseif (empty($day)) { |
|
155 | + $sql = "SELECT DAY(FROM_UNIXTIME(art_time - $timeoffset)) AS day, COUNT(DISTINCT a.art_id) AS count |
|
156 | 156 | FROM " . planet_DB_prefix('article') . " |
157 | 157 | WHERE YEAR(FROM_UNIXTIME(art_time - $timeoffset)) = $year |
158 | 158 | AND MONTH(FROM_UNIXTIME(art_time - $timeoffset)) = $month |
159 | 159 | " . $blog_criteria . ' |
160 | 160 | GROUP BY day |
161 | 161 | '; |
162 | - $result = $xoopsDB->query($sql); |
|
163 | - $days = []; |
|
164 | - while ($myrow = $xoopsDB->fetchArray($result)) { |
|
165 | - $days[$myrow['day']]['count'] = $myrow['count']; |
|
166 | - } |
|
167 | - for ($i = 1; $i <= 31; ++$i) { |
|
168 | - if (!isset($days[$i])) { |
|
169 | - continue; |
|
170 | - } |
|
171 | - $days[$i] = [ |
|
172 | - 'title' => $days[$i]['count'], |
|
173 | - 'url' => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . '' . $year . '/' . $month . '/' . $i . '/b' . $blog_id |
|
174 | - ]; |
|
175 | - } |
|
176 | - $calendar = planet_getCalendar($year, $month, $days); |
|
177 | - $month_next = $month + 1; |
|
178 | - $month_prev = $month - 1; |
|
179 | - $_year = $year; |
|
180 | - if (12 == $month) { |
|
181 | - $month_next = 1; |
|
182 | - $_year = $year + 1; |
|
183 | - } |
|
184 | - if (1 == $month) { |
|
185 | - $month_pre = 12; |
|
186 | - $_year = $year - 1; |
|
187 | - } |
|
188 | - $timenav['prev'] = [ |
|
189 | - 'url' => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . '' . $_year . '/' . $month_prev . '/b' . $blog_id, |
|
190 | - 'title' => planet_constant('MD_MONTH_' . $month_prev) |
|
191 | - ]; |
|
192 | - if ($year < date('Y') || $month < date('n')) { |
|
193 | - $timenav['next'] = [ |
|
194 | - 'url' => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . '' . $_year . '/' . $month_next . '/b' . $blog_id, |
|
195 | - 'title' => planet_constant('MD_MONTH_' . $month_next) |
|
196 | - ]; |
|
197 | - } |
|
198 | - } |
|
162 | + $result = $xoopsDB->query($sql); |
|
163 | + $days = []; |
|
164 | + while ($myrow = $xoopsDB->fetchArray($result)) { |
|
165 | + $days[$myrow['day']]['count'] = $myrow['count']; |
|
166 | + } |
|
167 | + for ($i = 1; $i <= 31; ++$i) { |
|
168 | + if (!isset($days[$i])) { |
|
169 | + continue; |
|
170 | + } |
|
171 | + $days[$i] = [ |
|
172 | + 'title' => $days[$i]['count'], |
|
173 | + 'url' => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . '' . $year . '/' . $month . '/' . $i . '/b' . $blog_id |
|
174 | + ]; |
|
175 | + } |
|
176 | + $calendar = planet_getCalendar($year, $month, $days); |
|
177 | + $month_next = $month + 1; |
|
178 | + $month_prev = $month - 1; |
|
179 | + $_year = $year; |
|
180 | + if (12 == $month) { |
|
181 | + $month_next = 1; |
|
182 | + $_year = $year + 1; |
|
183 | + } |
|
184 | + if (1 == $month) { |
|
185 | + $month_pre = 12; |
|
186 | + $_year = $year - 1; |
|
187 | + } |
|
188 | + $timenav['prev'] = [ |
|
189 | + 'url' => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . '' . $_year . '/' . $month_prev . '/b' . $blog_id, |
|
190 | + 'title' => planet_constant('MD_MONTH_' . $month_prev) |
|
191 | + ]; |
|
192 | + if ($year < date('Y') || $month < date('n')) { |
|
193 | + $timenav['next'] = [ |
|
194 | + 'url' => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . '' . $_year . '/' . $month_next . '/b' . $blog_id, |
|
195 | + 'title' => planet_constant('MD_MONTH_' . $month_next) |
|
196 | + ]; |
|
197 | + } |
|
198 | + } |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | $xoopsTpl->assign('dirname', $GLOBALS['moddirname']); |
@@ -222,66 +222,66 @@ discard block |
||
222 | 222 | */ |
223 | 223 | function planet_getCalendar($year = null, $month = null, $days = null) |
224 | 224 | { |
225 | - $year = empty($year) ? date('Y') : $year; |
|
226 | - $month = empty($month) ? date('n') : $month; |
|
227 | - $unixmonth = mktime(0, 0, 0, $month, 1, $year); |
|
225 | + $year = empty($year) ? date('Y') : $year; |
|
226 | + $month = empty($month) ? date('n') : $month; |
|
227 | + $unixmonth = mktime(0, 0, 0, $month, 1, $year); |
|
228 | 228 | |
229 | - ob_start(); |
|
230 | - echo '<table id="calendar">'; |
|
231 | - echo '<caption>'; |
|
232 | - printf(planet_constant('MD_TIME_YM'), $year, planet_constant('MD_MONTH_' . $month)); |
|
233 | - echo '</caption>'; |
|
229 | + ob_start(); |
|
230 | + echo '<table id="calendar">'; |
|
231 | + echo '<caption>'; |
|
232 | + printf(planet_constant('MD_TIME_YM'), $year, planet_constant('MD_MONTH_' . $month)); |
|
233 | + echo '</caption>'; |
|
234 | 234 | |
235 | - for ($i = 1; $i <= 7; ++$i) { |
|
236 | - echo "\n\t\t<th abbr=\"" . planet_constant('MD_WEEK_' . $i) . "\" scope=\"col\" title=\"" . planet_constant('MD_WEEK_' . $i) . "\">" . planet_constant('MD_WEEK_' . $i) . '</th>'; |
|
237 | - } |
|
235 | + for ($i = 1; $i <= 7; ++$i) { |
|
236 | + echo "\n\t\t<th abbr=\"" . planet_constant('MD_WEEK_' . $i) . "\" scope=\"col\" title=\"" . planet_constant('MD_WEEK_' . $i) . "\">" . planet_constant('MD_WEEK_' . $i) . '</th>'; |
|
237 | + } |
|
238 | 238 | |
239 | - echo '<tr>'; |
|
239 | + echo '<tr>'; |
|
240 | 240 | |
241 | - // See how much we should pad in the beginning |
|
242 | - $week_begins = 1; |
|
243 | - $pad = planet_calendar_week_mod(date('w', $unixmonth) - $week_begins); |
|
244 | - if (0 != $pad) { |
|
245 | - echo "\n\t\t" . '<td colspan="' . $pad . '"> </td>'; |
|
246 | - } |
|
241 | + // See how much we should pad in the beginning |
|
242 | + $week_begins = 1; |
|
243 | + $pad = planet_calendar_week_mod(date('w', $unixmonth) - $week_begins); |
|
244 | + if (0 != $pad) { |
|
245 | + echo "\n\t\t" . '<td colspan="' . $pad . '"> </td>'; |
|
246 | + } |
|
247 | 247 | |
248 | - $daysinmonth = (int)date('t', $unixmonth); |
|
249 | - for ($day = 1; $day <= $daysinmonth; ++$day) { |
|
250 | - if (isset($newrow) && $newrow) { |
|
251 | - echo "\n\t</tr>\n\t<tr>\n\t\t"; |
|
252 | - } |
|
253 | - $newrow = false; |
|
248 | + $daysinmonth = (int)date('t', $unixmonth); |
|
249 | + for ($day = 1; $day <= $daysinmonth; ++$day) { |
|
250 | + if (isset($newrow) && $newrow) { |
|
251 | + echo "\n\t</tr>\n\t<tr>\n\t\t"; |
|
252 | + } |
|
253 | + $newrow = false; |
|
254 | 254 | |
255 | - echo '<td>'; |
|
255 | + echo '<td>'; |
|
256 | 256 | |
257 | - if (!empty($days[$day]['url'])) { |
|
258 | - echo '<a href="' . $days[$day]['url'] . "\""; |
|
259 | - if (!empty($days[$day]['title'])) { |
|
260 | - echo "title=\"" . $days[$day]['title'] . "\""; |
|
261 | - } |
|
262 | - echo ">$day</a>"; |
|
263 | - } elseif (!empty($days[$day]['title'])) { |
|
264 | - echo "<acronym title=\"" . $days[$day]['title'] . "\">$day</acronym>"; |
|
265 | - } else { |
|
266 | - echo $day; |
|
267 | - } |
|
268 | - echo '</td>'; |
|
257 | + if (!empty($days[$day]['url'])) { |
|
258 | + echo '<a href="' . $days[$day]['url'] . "\""; |
|
259 | + if (!empty($days[$day]['title'])) { |
|
260 | + echo "title=\"" . $days[$day]['title'] . "\""; |
|
261 | + } |
|
262 | + echo ">$day</a>"; |
|
263 | + } elseif (!empty($days[$day]['title'])) { |
|
264 | + echo "<acronym title=\"" . $days[$day]['title'] . "\">$day</acronym>"; |
|
265 | + } else { |
|
266 | + echo $day; |
|
267 | + } |
|
268 | + echo '</td>'; |
|
269 | 269 | |
270 | - if (6 == planet_calendar_week_mod(date('w', mktime(0, 0, 0, $month, $day, $year)) - $week_begins)) { |
|
271 | - $newrow = true; |
|
272 | - } |
|
273 | - } |
|
270 | + if (6 == planet_calendar_week_mod(date('w', mktime(0, 0, 0, $month, $day, $year)) - $week_begins)) { |
|
271 | + $newrow = true; |
|
272 | + } |
|
273 | + } |
|
274 | 274 | |
275 | - $pad = 7 - planet_calendar_week_mod(date('w', mktime(0, 0, 0, $month, $day, $year)) - $week_begins); |
|
276 | - if (0 != $pad && 7 != $pad) { |
|
277 | - echo "\n\t\t" . '<td class="pad" colspan="' . $pad . '"> </td>'; |
|
278 | - } |
|
275 | + $pad = 7 - planet_calendar_week_mod(date('w', mktime(0, 0, 0, $month, $day, $year)) - $week_begins); |
|
276 | + if (0 != $pad && 7 != $pad) { |
|
277 | + echo "\n\t\t" . '<td class="pad" colspan="' . $pad . '"> </td>'; |
|
278 | + } |
|
279 | 279 | |
280 | - echo "\n\t</tr>\n\t</tbody>\n\t</table>"; |
|
281 | - $calendar = ob_get_contents(); |
|
282 | - ob_end_clean(); |
|
280 | + echo "\n\t</tr>\n\t</tbody>\n\t</table>"; |
|
281 | + $calendar = ob_get_contents(); |
|
282 | + ob_end_clean(); |
|
283 | 283 | |
284 | - return $calendar; |
|
284 | + return $calendar; |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | // Used in get_calendar |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | */ |
292 | 292 | function planet_calendar_week_mod($num) |
293 | 293 | { |
294 | - $base = 7; |
|
294 | + $base = 7; |
|
295 | 295 | |
296 | - return ($num - $base * floor($num / $base)); |
|
296 | + return ($num - $base * floor($num / $base)); |
|
297 | 297 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | // ------------------------------------------------------------------------ // |
27 | 27 | use Xmf\Request; |
28 | 28 | |
29 | -include __DIR__ . '/header.php'; |
|
29 | +include __DIR__.'/header.php'; |
|
30 | 30 | |
31 | 31 | if (PlanetUtility::planetParseArguments($args_num, $args, $args_str)) { |
32 | 32 | $args['year'] = @$args_num[0]; |
@@ -45,26 +45,26 @@ discard block |
||
45 | 45 | $articleHandler = xoops_getModuleHandler('article', $GLOBALS['moddirname']); |
46 | 46 | $blogHandler = xoops_getModuleHandler('blog', $GLOBALS['moddirname']); |
47 | 47 | |
48 | -$xoopsOption['xoops_pagetitle'] = $xoopsModule->getVar('name') . ' - ' . planet_constant('MD_ACHIVE'); |
|
48 | +$xoopsOption['xoops_pagetitle'] = $xoopsModule->getVar('name').' - '.planet_constant('MD_ACHIVE'); |
|
49 | 49 | $xoopsOption['template_main'] = PlanetUtility::planetGetTemplate('archive'); |
50 | -require_once XOOPS_ROOT_PATH . '/header.php'; |
|
51 | -include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/include/vars.php'; |
|
50 | +require_once XOOPS_ROOT_PATH.'/header.php'; |
|
51 | +include XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/include/vars.php'; |
|
52 | 52 | |
53 | 53 | $year = empty($year) ? date('Y') : $year; |
54 | -if ($month < 1) { |
|
54 | +if ($month<1) { |
|
55 | 55 | $month = $day = 0; |
56 | 56 | $page['time'] = sprintf(planet_constant('MD_TIME_Y'), $year); |
57 | -} elseif ($day < 1) { |
|
57 | +} elseif ($day<1) { |
|
58 | 58 | $day = 0; |
59 | 59 | $page['time'] = sprintf(planet_constant('MD_TIME_YM'), $year, $month); |
60 | -} else { |
|
60 | +}else { |
|
61 | 61 | $page['time'] = sprintf(planet_constant('MD_TIME_YMD'), $year, $month, $day); |
62 | 62 | } |
63 | 63 | $time = ['year' => $year, 'month' => $month, 'day' => $day]; |
64 | 64 | if ($xoopsUser) { |
65 | - $timeoffset = ($xoopsUser->getVar('timezone_offset') - $xoopsConfig['server_TZ']) * 3600; |
|
66 | -} else { |
|
67 | - $timeoffset = ($xoopsConfig['default_TZ'] - $xoopsConfig['server_TZ']) * 3600; |
|
65 | + $timeoffset = ($xoopsUser->getVar('timezone_offset')-$xoopsConfig['server_TZ'])*3600; |
|
66 | +}else { |
|
67 | + $timeoffset = ($xoopsConfig['default_TZ']-$xoopsConfig['server_TZ'])*3600; |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | $criteria = new CriteriaCompo(); |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $articles = []; |
88 | 88 | $blogs_id = []; |
89 | 89 | foreach ($articles_obj as $id => $article) { |
90 | - $articles[] = [ |
|
90 | + $articles[] = [ |
|
91 | 91 | 'id' => $id, |
92 | 92 | 'blog' => ['id' => $article->getVar('blog_id'), 'title' => ''], |
93 | 93 | 'title' => $article->getVar('art_title'), |
@@ -98,20 +98,20 @@ discard block |
||
98 | 98 | $blogs_id[$article->getVar('blog_id')] = 1; |
99 | 99 | unset($_article); |
100 | 100 | } |
101 | -$criteria_blog = new Criteria('blog_id', '(' . implode(',', array_keys($blog_array)) . ')', 'IN'); |
|
101 | +$criteria_blog = new Criteria('blog_id', '('.implode(',', array_keys($blog_array)).')', 'IN'); |
|
102 | 102 | $blogs = $blogHandler->getList($criteria_blog); |
103 | 103 | foreach (array_keys($articles) as $key) { |
104 | 104 | $articles[$key]['blog']['title'] = $blogs[$articles[$key]['blog']['id']]; |
105 | 105 | } |
106 | -if ($blog_id > 0) { |
|
106 | +if ($blog_id>0) { |
|
107 | 107 | $page['blog'] = $blogs[$blog_id]; |
108 | 108 | } |
109 | 109 | |
110 | -if ($articles_count > $xoopsModuleConfig['articles_perpage']) { |
|
111 | - include XOOPS_ROOT_PATH . '/class/pagenav.php'; |
|
112 | - $nav = new XoopsPageNav($articles_count, $xoopsModuleConfig['articles_perpage'], $start, 'start', 'month=' . $month . '&day=' . $day . '&year=' . $year . '&blog=' . (int)$blog_id); |
|
110 | +if ($articles_count>$xoopsModuleConfig['articles_perpage']) { |
|
111 | + include XOOPS_ROOT_PATH.'/class/pagenav.php'; |
|
112 | + $nav = new XoopsPageNav($articles_count, $xoopsModuleConfig['articles_perpage'], $start, 'start', 'month='.$month.'&day='.$day.'&year='.$year.'&blog='.(int) $blog_id); |
|
113 | 113 | $pagenav = $nav->renderNav(4); |
114 | -} else { |
|
114 | +}else { |
|
115 | 115 | $pagenav = ''; |
116 | 116 | } |
117 | 117 | |
@@ -120,43 +120,43 @@ discard block |
||
120 | 120 | $months = null; |
121 | 121 | if (empty($start)) { |
122 | 122 | if ($blog_id) { |
123 | - $blog_criteria = ' AND blog_id=' . $blog_id; |
|
124 | - } else { |
|
123 | + $blog_criteria = ' AND blog_id='.$blog_id; |
|
124 | + }else { |
|
125 | 125 | $blog_criteria = ''; |
126 | 126 | } |
127 | 127 | // Get monthly list |
128 | 128 | if (empty($month)) { |
129 | - $sql = "SELECT MONTH(FROM_UNIXTIME(art_time - $timeoffset)) AS mon, COUNT(DISTINCT art_id) AS count |
|
130 | - FROM " . planet_DB_prefix('article') . " |
|
129 | + $sql = "SELECT MONTH(FROM_UNIXTIME(art_time - $timeoffset)) AS mon, COUNT(DISTINCT art_id) AS count |
|
130 | + FROM ".planet_DB_prefix('article')." |
|
131 | 131 | WHERE YEAR(FROM_UNIXTIME(art_time - $timeoffset)) = $year |
132 | - " . $blog_criteria . ' |
|
132 | + ".$blog_criteria.' |
|
133 | 133 | GROUP BY mon |
134 | 134 | '; |
135 | 135 | $result = $xoopsDB->query($sql); |
136 | 136 | $months = []; |
137 | 137 | while ($myrow = $xoopsDB->fetchArray($result)) { |
138 | 138 | $months[] = [ |
139 | - 'title' => planet_constant('MD_MONTH_' . (int)$myrow['mon']) . ' (' . (int)$myrow['count'] . ')', |
|
140 | - 'url' => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . '' . $year . '/' . $myrow['mon'] . '/b' . $blog_id |
|
139 | + 'title' => planet_constant('MD_MONTH_'.(int) $myrow['mon']).' ('.(int) $myrow['count'].')', |
|
140 | + 'url' => XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/view.archive.php'.URL_DELIMITER.''.$year.'/'.$myrow['mon'].'/b'.$blog_id |
|
141 | 141 | ]; |
142 | 142 | } |
143 | 143 | $timenav['prev'] = [ |
144 | - 'url' => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . '' . ($year - 1) . '/b' . $blog_id, |
|
145 | - 'title' => sprintf(planet_constant('MD_TIME_Y'), $year - 1) |
|
144 | + 'url' => XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/view.archive.php'.URL_DELIMITER.''.($year-1).'/b'.$blog_id, |
|
145 | + 'title' => sprintf(planet_constant('MD_TIME_Y'), $year-1) |
|
146 | 146 | ]; |
147 | - if ($year < date('Y')) { |
|
147 | + if ($year<date('Y')) { |
|
148 | 148 | $timenav['next'] = [ |
149 | - 'url' => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . '' . ($year + 1) . '/b' . $blog_id, |
|
150 | - 'title' => sprintf(planet_constant('MD_TIME_Y'), $year + 1) |
|
149 | + 'url' => XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/view.archive.php'.URL_DELIMITER.''.($year+1).'/b'.$blog_id, |
|
150 | + 'title' => sprintf(planet_constant('MD_TIME_Y'), $year+1) |
|
151 | 151 | ]; |
152 | 152 | } |
153 | 153 | } // Get daily list |
154 | 154 | elseif (empty($day)) { |
155 | - $sql = "SELECT DAY(FROM_UNIXTIME(art_time - $timeoffset)) AS day, COUNT(DISTINCT a.art_id) AS count |
|
156 | - FROM " . planet_DB_prefix('article') . " |
|
155 | + $sql = "SELECT DAY(FROM_UNIXTIME(art_time - $timeoffset)) AS day, COUNT(DISTINCT a.art_id) AS count |
|
156 | + FROM ".planet_DB_prefix('article')." |
|
157 | 157 | WHERE YEAR(FROM_UNIXTIME(art_time - $timeoffset)) = $year |
158 | 158 | AND MONTH(FROM_UNIXTIME(art_time - $timeoffset)) = $month |
159 | - " . $blog_criteria . ' |
|
159 | + ".$blog_criteria.' |
|
160 | 160 | GROUP BY day |
161 | 161 | '; |
162 | 162 | $result = $xoopsDB->query($sql); |
@@ -164,35 +164,35 @@ discard block |
||
164 | 164 | while ($myrow = $xoopsDB->fetchArray($result)) { |
165 | 165 | $days[$myrow['day']]['count'] = $myrow['count']; |
166 | 166 | } |
167 | - for ($i = 1; $i <= 31; ++$i) { |
|
167 | + for ($i = 1; $i<=31; ++$i) { |
|
168 | 168 | if (!isset($days[$i])) { |
169 | 169 | continue; |
170 | 170 | } |
171 | 171 | $days[$i] = [ |
172 | 172 | 'title' => $days[$i]['count'], |
173 | - 'url' => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . '' . $year . '/' . $month . '/' . $i . '/b' . $blog_id |
|
173 | + 'url' => XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/view.archive.php'.URL_DELIMITER.''.$year.'/'.$month.'/'.$i.'/b'.$blog_id |
|
174 | 174 | ]; |
175 | 175 | } |
176 | 176 | $calendar = planet_getCalendar($year, $month, $days); |
177 | - $month_next = $month + 1; |
|
178 | - $month_prev = $month - 1; |
|
177 | + $month_next = $month+1; |
|
178 | + $month_prev = $month-1; |
|
179 | 179 | $_year = $year; |
180 | 180 | if (12 == $month) { |
181 | 181 | $month_next = 1; |
182 | - $_year = $year + 1; |
|
182 | + $_year = $year+1; |
|
183 | 183 | } |
184 | 184 | if (1 == $month) { |
185 | 185 | $month_pre = 12; |
186 | - $_year = $year - 1; |
|
186 | + $_year = $year-1; |
|
187 | 187 | } |
188 | 188 | $timenav['prev'] = [ |
189 | - 'url' => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . '' . $_year . '/' . $month_prev . '/b' . $blog_id, |
|
190 | - 'title' => planet_constant('MD_MONTH_' . $month_prev) |
|
189 | + 'url' => XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/view.archive.php'.URL_DELIMITER.''.$_year.'/'.$month_prev.'/b'.$blog_id, |
|
190 | + 'title' => planet_constant('MD_MONTH_'.$month_prev) |
|
191 | 191 | ]; |
192 | - if ($year < date('Y') || $month < date('n')) { |
|
192 | + if ($year<date('Y') || $month<date('n')) { |
|
193 | 193 | $timenav['next'] = [ |
194 | - 'url' => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.archive.php' . URL_DELIMITER . '' . $_year . '/' . $month_next . '/b' . $blog_id, |
|
195 | - 'title' => planet_constant('MD_MONTH_' . $month_next) |
|
194 | + 'url' => XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/view.archive.php'.URL_DELIMITER.''.$_year.'/'.$month_next.'/b'.$blog_id, |
|
195 | + 'title' => planet_constant('MD_MONTH_'.$month_next) |
|
196 | 196 | ]; |
197 | 197 | } |
198 | 198 | } |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | $xoopsTpl->assign('timenav', $timenav); |
213 | 213 | $xoopsTpl->assign('pagenav', $pagenav); |
214 | 214 | |
215 | -require_once __DIR__ . '/footer.php'; |
|
215 | +require_once __DIR__.'/footer.php'; |
|
216 | 216 | |
217 | 217 | /** |
218 | 218 | * @param null $year |
@@ -229,24 +229,24 @@ discard block |
||
229 | 229 | ob_start(); |
230 | 230 | echo '<table id="calendar">'; |
231 | 231 | echo '<caption>'; |
232 | - printf(planet_constant('MD_TIME_YM'), $year, planet_constant('MD_MONTH_' . $month)); |
|
232 | + printf(planet_constant('MD_TIME_YM'), $year, planet_constant('MD_MONTH_'.$month)); |
|
233 | 233 | echo '</caption>'; |
234 | 234 | |
235 | - for ($i = 1; $i <= 7; ++$i) { |
|
236 | - echo "\n\t\t<th abbr=\"" . planet_constant('MD_WEEK_' . $i) . "\" scope=\"col\" title=\"" . planet_constant('MD_WEEK_' . $i) . "\">" . planet_constant('MD_WEEK_' . $i) . '</th>'; |
|
235 | + for ($i = 1; $i<=7; ++$i) { |
|
236 | + echo "\n\t\t<th abbr=\"".planet_constant('MD_WEEK_'.$i)."\" scope=\"col\" title=\"".planet_constant('MD_WEEK_'.$i)."\">".planet_constant('MD_WEEK_'.$i).'</th>'; |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | echo '<tr>'; |
240 | 240 | |
241 | 241 | // See how much we should pad in the beginning |
242 | 242 | $week_begins = 1; |
243 | - $pad = planet_calendar_week_mod(date('w', $unixmonth) - $week_begins); |
|
243 | + $pad = planet_calendar_week_mod(date('w', $unixmonth)-$week_begins); |
|
244 | 244 | if (0 != $pad) { |
245 | - echo "\n\t\t" . '<td colspan="' . $pad . '"> </td>'; |
|
245 | + echo "\n\t\t".'<td colspan="'.$pad.'"> </td>'; |
|
246 | 246 | } |
247 | 247 | |
248 | - $daysinmonth = (int)date('t', $unixmonth); |
|
249 | - for ($day = 1; $day <= $daysinmonth; ++$day) { |
|
248 | + $daysinmonth = (int) date('t', $unixmonth); |
|
249 | + for ($day = 1; $day<=$daysinmonth; ++$day) { |
|
250 | 250 | if (isset($newrow) && $newrow) { |
251 | 251 | echo "\n\t</tr>\n\t<tr>\n\t\t"; |
252 | 252 | } |
@@ -255,26 +255,26 @@ discard block |
||
255 | 255 | echo '<td>'; |
256 | 256 | |
257 | 257 | if (!empty($days[$day]['url'])) { |
258 | - echo '<a href="' . $days[$day]['url'] . "\""; |
|
258 | + echo '<a href="'.$days[$day]['url']."\""; |
|
259 | 259 | if (!empty($days[$day]['title'])) { |
260 | - echo "title=\"" . $days[$day]['title'] . "\""; |
|
260 | + echo "title=\"".$days[$day]['title']."\""; |
|
261 | 261 | } |
262 | 262 | echo ">$day</a>"; |
263 | 263 | } elseif (!empty($days[$day]['title'])) { |
264 | - echo "<acronym title=\"" . $days[$day]['title'] . "\">$day</acronym>"; |
|
265 | - } else { |
|
264 | + echo "<acronym title=\"".$days[$day]['title']."\">$day</acronym>"; |
|
265 | + }else { |
|
266 | 266 | echo $day; |
267 | 267 | } |
268 | 268 | echo '</td>'; |
269 | 269 | |
270 | - if (6 == planet_calendar_week_mod(date('w', mktime(0, 0, 0, $month, $day, $year)) - $week_begins)) { |
|
270 | + if (6 == planet_calendar_week_mod(date('w', mktime(0, 0, 0, $month, $day, $year))-$week_begins)) { |
|
271 | 271 | $newrow = true; |
272 | 272 | } |
273 | 273 | } |
274 | 274 | |
275 | - $pad = 7 - planet_calendar_week_mod(date('w', mktime(0, 0, 0, $month, $day, $year)) - $week_begins); |
|
275 | + $pad = 7-planet_calendar_week_mod(date('w', mktime(0, 0, 0, $month, $day, $year))-$week_begins); |
|
276 | 276 | if (0 != $pad && 7 != $pad) { |
277 | - echo "\n\t\t" . '<td class="pad" colspan="' . $pad . '"> </td>'; |
|
277 | + echo "\n\t\t".'<td class="pad" colspan="'.$pad.'"> </td>'; |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | echo "\n\t</tr>\n\t</tbody>\n\t</table>"; |
@@ -293,5 +293,5 @@ discard block |
||
293 | 293 | { |
294 | 294 | $base = 7; |
295 | 295 | |
296 | - return ($num - $base * floor($num / $base)); |
|
296 | + return ($num-$base*floor($num/$base)); |
|
297 | 297 | } |
@@ -33,15 +33,15 @@ discard block |
||
33 | 33 | $blog_id = is_array($blog_id) ? array_map('intval', $blog_id) : (int)$blog_id; |
34 | 34 | |
35 | 35 | if (empty($xoopsModuleConfig['newblog_submit']) && (!is_object($xoopsUser) || !$xoopsUser->isAdmin())) { |
36 | - redirect_header('index.php', 2, _NOPERM); |
|
36 | + redirect_header('index.php', 2, _NOPERM); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | if ('save' === $op && !empty(Request::getString('fetch', '', 'POST'))) {//!empty($_POST['fetch'])) { |
40 | - $op = 'edit'; |
|
40 | + $op = 'edit'; |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | if ('save' === $op && !$GLOBALS['xoopsSecurity']->check()) { |
44 | - redirect_header('javascript:history.go(-1);', 1, planet_constant('MD_INVALID') . ': security check failed'); |
|
44 | + redirect_header('javascript:history.go(-1);', 1, planet_constant('MD_INVALID') . ': security check failed'); |
|
45 | 45 | } |
46 | 46 | include XOOPS_ROOT_PATH . '/header.php'; |
47 | 47 | include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/include/vars.php'; |
@@ -50,110 +50,110 @@ discard block |
||
50 | 50 | $categoryHandler = xoops_getModuleHandler('category', $GLOBALS['moddirname']); |
51 | 51 | |
52 | 52 | switch ($op) { |
53 | - /* save a single blog */ |
|
54 | - case 'save': |
|
55 | - |
|
56 | - if ($blog_id) { |
|
57 | - $blog_obj = $blogHandler->get($blog_id); |
|
58 | - if ($xoopsUser->isAdmin()) { |
|
59 | - $blog_obj->setVar('blog_status', Request::getInt('blog_status', 0, 'POST'));// @$_POST['blog_status']); |
|
60 | - } |
|
61 | - } else { |
|
62 | - if ($blog_exists = $blogHandler->getCount(new Criteria('blog_feed', $myts->addSlashes(trim(Request::getText('blog_feed', '', 'POST'))))) //$_POST['blog_feed'])))) |
|
63 | - ) { |
|
64 | - redirect_header('index.php', 2, planet_constant('MD_BLOGEXISTS')); |
|
65 | - } |
|
66 | - |
|
67 | - $blog_obj = $blogHandler->create(); |
|
68 | - $blog_obj->setVar('blog_submitter', is_object($xoopsUser) ? $xoopsUser->getVar('uid') : PlanetUtility::planetGetIP(true)); |
|
69 | - |
|
70 | - switch ($xoopsModuleConfig['newblog_submit']) { |
|
71 | - case 2: |
|
72 | - if (!is_object($xoopsUser)) { |
|
73 | - $status = 0; |
|
74 | - } else { |
|
75 | - $status = 1; |
|
76 | - } |
|
77 | - break; |
|
78 | - case 0: |
|
79 | - case 3: |
|
80 | - $status = 1; |
|
81 | - break; |
|
82 | - case 1: |
|
83 | - default: |
|
84 | - if (!is_object($xoopsUser) || !$xoopsUser->isAdmin()) { |
|
85 | - $status = 0; |
|
86 | - } else { |
|
87 | - $status = 1; |
|
88 | - } |
|
89 | - break; |
|
90 | - } |
|
91 | - |
|
92 | - $blog_obj->setVar('blog_status', $status); |
|
93 | - } |
|
94 | - |
|
95 | - $blog_obj->setVar('blog_title', Request::getString('blog_title', '', 'POST'));//$_POST['blog_title']); |
|
96 | - $blog_obj->setVar('blog_desc', Request::getString('blog_desc', '', 'POST'));//$_POST['blog_desc']); |
|
97 | - $blog_obj->setVar('blog_image', Request::getString('blog_image', '', 'POST'));//$_POST['blog_image']); |
|
98 | - $blog_obj->setVar('blog_feed', Request::getText('blog_feed', '', 'POST'));//$_POST['blog_feed']); |
|
99 | - $blog_obj->setVar('blog_link', Request::getString('blog_link', '', 'POST'));//$_POST['blog_link']); |
|
100 | - $blog_obj->setVar('blog_language', Request::getString('blog_language', '', 'POST'));//$_POST['blog_language']); |
|
101 | - $blog_obj->setVar('blog_charset', Request::getString('blog_charset', '', 'POST'));//$_POST['blog_charset']); |
|
102 | - $blog_obj->setVar('blog_trackback', Request::getString('blog_trackback', '', 'POST'));//$_POST['blog_trackback']); |
|
103 | - if ($blog_obj->isNew()) { |
|
104 | - $blog_obj->setVar('blog_submitter', is_object($xoopsUser) ? $xoopsUser->getVar('uid') : PlanetUtility::planetGetIP(true)); |
|
105 | - } |
|
106 | - |
|
107 | - if (!$blogHandler->insert($blog_obj)) { |
|
108 | - } elseif (0 !== count(Request::getArray('categories', [], 'POST'))) { |
|
109 | - $blog_id = $blog_obj->getVar('blog_id'); |
|
110 | - if (in_array(0, $_POST['categories'])) { |
|
111 | - $_POST['categories'] = []; |
|
112 | - } |
|
113 | - $blogHandler->setCategories($blog_id, Request::getString('andor', '', 'POST'));//$_POST['categories']); |
|
114 | - } |
|
115 | - $message = planet_constant('MD_DBUPDATED'); |
|
116 | - redirect_header('index.php' . URL_DELIMITER . 'b' . $blog_id, 2, $message); |
|
117 | - |
|
118 | - /* edit a single blog */ |
|
119 | - // no break |
|
120 | - case 'edit': |
|
121 | - default: |
|
122 | - if (!empty(Request::getString('fetch', '', 'POST'))) { |
|
123 | - $blog_obj = $blogHandler->fetch(Request::getText('blog_feed', '', 'POST')); |
|
124 | - $blog_obj->setVar('blog_id', $blog_id); |
|
125 | - } else { |
|
126 | - $blog_obj = $blogHandler->get($blog_id); |
|
127 | - } |
|
128 | - $categories = Request::getArray('categories', [], 'POST');//isset($_POST['categories']) ? $_POST['categories'] : array(); |
|
129 | - if (in_array('-1', $categories)) { |
|
130 | - $categories = []; |
|
131 | - } |
|
132 | - if (empty($categories) && $blog_id > 0) { |
|
133 | - $crit = new Criteria('bc.blog_id', $blog_id); |
|
134 | - $categories = array_keys($categoryHandler->getByBlog($crit)); |
|
135 | - } |
|
136 | - if (empty($categories)) { |
|
137 | - $categories = [0 => _NONE]; |
|
138 | - } |
|
139 | - |
|
140 | - echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _EDIT . '</legend>'; |
|
141 | - echo '<br>'; |
|
142 | - if (empty($blog_id) && $blog_obj->getVar('blog_feed')) { |
|
143 | - $criteria = new Criteria('blog_feed', $blog_obj->getVar('blog_feed')); |
|
144 | - $blogs_obj = $blogHandler->getList($criteria); |
|
145 | - if (count($blogs_obj) > 0) { |
|
146 | - echo "<div class=\"errorMsg\">" . planet_constant('MD_BLOGEXISTS'); |
|
147 | - foreach (array_keys($blogs_obj) as $bid) { |
|
148 | - echo "<br><a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . URL_DELIMITER . 'b' . $bid . "\" target=\"_blank\">" . $blogs_obj[$bid] . '</a>'; |
|
149 | - } |
|
150 | - echo '</div>'; |
|
151 | - unset($blogs_obj, $criteria); |
|
152 | - } |
|
153 | - } |
|
154 | - include XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/include/form.blog.php'; |
|
155 | - echo '</fieldset>'; |
|
156 | - break; |
|
53 | + /* save a single blog */ |
|
54 | + case 'save': |
|
55 | + |
|
56 | + if ($blog_id) { |
|
57 | + $blog_obj = $blogHandler->get($blog_id); |
|
58 | + if ($xoopsUser->isAdmin()) { |
|
59 | + $blog_obj->setVar('blog_status', Request::getInt('blog_status', 0, 'POST'));// @$_POST['blog_status']); |
|
60 | + } |
|
61 | + } else { |
|
62 | + if ($blog_exists = $blogHandler->getCount(new Criteria('blog_feed', $myts->addSlashes(trim(Request::getText('blog_feed', '', 'POST'))))) //$_POST['blog_feed'])))) |
|
63 | + ) { |
|
64 | + redirect_header('index.php', 2, planet_constant('MD_BLOGEXISTS')); |
|
65 | + } |
|
66 | + |
|
67 | + $blog_obj = $blogHandler->create(); |
|
68 | + $blog_obj->setVar('blog_submitter', is_object($xoopsUser) ? $xoopsUser->getVar('uid') : PlanetUtility::planetGetIP(true)); |
|
69 | + |
|
70 | + switch ($xoopsModuleConfig['newblog_submit']) { |
|
71 | + case 2: |
|
72 | + if (!is_object($xoopsUser)) { |
|
73 | + $status = 0; |
|
74 | + } else { |
|
75 | + $status = 1; |
|
76 | + } |
|
77 | + break; |
|
78 | + case 0: |
|
79 | + case 3: |
|
80 | + $status = 1; |
|
81 | + break; |
|
82 | + case 1: |
|
83 | + default: |
|
84 | + if (!is_object($xoopsUser) || !$xoopsUser->isAdmin()) { |
|
85 | + $status = 0; |
|
86 | + } else { |
|
87 | + $status = 1; |
|
88 | + } |
|
89 | + break; |
|
90 | + } |
|
91 | + |
|
92 | + $blog_obj->setVar('blog_status', $status); |
|
93 | + } |
|
94 | + |
|
95 | + $blog_obj->setVar('blog_title', Request::getString('blog_title', '', 'POST'));//$_POST['blog_title']); |
|
96 | + $blog_obj->setVar('blog_desc', Request::getString('blog_desc', '', 'POST'));//$_POST['blog_desc']); |
|
97 | + $blog_obj->setVar('blog_image', Request::getString('blog_image', '', 'POST'));//$_POST['blog_image']); |
|
98 | + $blog_obj->setVar('blog_feed', Request::getText('blog_feed', '', 'POST'));//$_POST['blog_feed']); |
|
99 | + $blog_obj->setVar('blog_link', Request::getString('blog_link', '', 'POST'));//$_POST['blog_link']); |
|
100 | + $blog_obj->setVar('blog_language', Request::getString('blog_language', '', 'POST'));//$_POST['blog_language']); |
|
101 | + $blog_obj->setVar('blog_charset', Request::getString('blog_charset', '', 'POST'));//$_POST['blog_charset']); |
|
102 | + $blog_obj->setVar('blog_trackback', Request::getString('blog_trackback', '', 'POST'));//$_POST['blog_trackback']); |
|
103 | + if ($blog_obj->isNew()) { |
|
104 | + $blog_obj->setVar('blog_submitter', is_object($xoopsUser) ? $xoopsUser->getVar('uid') : PlanetUtility::planetGetIP(true)); |
|
105 | + } |
|
106 | + |
|
107 | + if (!$blogHandler->insert($blog_obj)) { |
|
108 | + } elseif (0 !== count(Request::getArray('categories', [], 'POST'))) { |
|
109 | + $blog_id = $blog_obj->getVar('blog_id'); |
|
110 | + if (in_array(0, $_POST['categories'])) { |
|
111 | + $_POST['categories'] = []; |
|
112 | + } |
|
113 | + $blogHandler->setCategories($blog_id, Request::getString('andor', '', 'POST'));//$_POST['categories']); |
|
114 | + } |
|
115 | + $message = planet_constant('MD_DBUPDATED'); |
|
116 | + redirect_header('index.php' . URL_DELIMITER . 'b' . $blog_id, 2, $message); |
|
117 | + |
|
118 | + /* edit a single blog */ |
|
119 | + // no break |
|
120 | + case 'edit': |
|
121 | + default: |
|
122 | + if (!empty(Request::getString('fetch', '', 'POST'))) { |
|
123 | + $blog_obj = $blogHandler->fetch(Request::getText('blog_feed', '', 'POST')); |
|
124 | + $blog_obj->setVar('blog_id', $blog_id); |
|
125 | + } else { |
|
126 | + $blog_obj = $blogHandler->get($blog_id); |
|
127 | + } |
|
128 | + $categories = Request::getArray('categories', [], 'POST');//isset($_POST['categories']) ? $_POST['categories'] : array(); |
|
129 | + if (in_array('-1', $categories)) { |
|
130 | + $categories = []; |
|
131 | + } |
|
132 | + if (empty($categories) && $blog_id > 0) { |
|
133 | + $crit = new Criteria('bc.blog_id', $blog_id); |
|
134 | + $categories = array_keys($categoryHandler->getByBlog($crit)); |
|
135 | + } |
|
136 | + if (empty($categories)) { |
|
137 | + $categories = [0 => _NONE]; |
|
138 | + } |
|
139 | + |
|
140 | + echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _EDIT . '</legend>'; |
|
141 | + echo '<br>'; |
|
142 | + if (empty($blog_id) && $blog_obj->getVar('blog_feed')) { |
|
143 | + $criteria = new Criteria('blog_feed', $blog_obj->getVar('blog_feed')); |
|
144 | + $blogs_obj = $blogHandler->getList($criteria); |
|
145 | + if (count($blogs_obj) > 0) { |
|
146 | + echo "<div class=\"errorMsg\">" . planet_constant('MD_BLOGEXISTS'); |
|
147 | + foreach (array_keys($blogs_obj) as $bid) { |
|
148 | + echo "<br><a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . URL_DELIMITER . 'b' . $bid . "\" target=\"_blank\">" . $blogs_obj[$bid] . '</a>'; |
|
149 | + } |
|
150 | + echo '</div>'; |
|
151 | + unset($blogs_obj, $criteria); |
|
152 | + } |
|
153 | + } |
|
154 | + include XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/include/form.blog.php'; |
|
155 | + echo '</fieldset>'; |
|
156 | + break; |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | include XOOPS_ROOT_PATH . '/footer.php'; |
@@ -26,11 +26,11 @@ discard block |
||
26 | 26 | // ------------------------------------------------------------------------ // |
27 | 27 | use Xmf\Request; |
28 | 28 | |
29 | -include __DIR__ . '/header.php'; |
|
29 | +include __DIR__.'/header.php'; |
|
30 | 30 | |
31 | -$op = Request::getString('op', Request::getString('op', '', 'POST'), 'GET');//!empty($_POST['op']) ? $_POST['op'] : (!empty($_GET['op']) ? $_GET['op'] : ''); |
|
32 | -$blog_id = Request::getArray('blog', Request::getArray('blog', [], 'POST'), 'GET');//!empty($_POST['blog']) ? $_POST['blog'] : (!empty($_GET['blog']) ? $_GET['blog'] : 0); |
|
33 | -$blog_id = is_array($blog_id) ? array_map('intval', $blog_id) : (int)$blog_id; |
|
31 | +$op = Request::getString('op', Request::getString('op', '', 'POST'), 'GET'); //!empty($_POST['op']) ? $_POST['op'] : (!empty($_GET['op']) ? $_GET['op'] : ''); |
|
32 | +$blog_id = Request::getArray('blog', Request::getArray('blog', [], 'POST'), 'GET'); //!empty($_POST['blog']) ? $_POST['blog'] : (!empty($_GET['blog']) ? $_GET['blog'] : 0); |
|
33 | +$blog_id = is_array($blog_id) ? array_map('intval', $blog_id) : (int) $blog_id; |
|
34 | 34 | |
35 | 35 | if (empty($xoopsModuleConfig['newblog_submit']) && (!is_object($xoopsUser) || !$xoopsUser->isAdmin())) { |
36 | 36 | redirect_header('index.php', 2, _NOPERM); |
@@ -41,10 +41,10 @@ discard block |
||
41 | 41 | } |
42 | 42 | |
43 | 43 | if ('save' === $op && !$GLOBALS['xoopsSecurity']->check()) { |
44 | - redirect_header('javascript:history.go(-1);', 1, planet_constant('MD_INVALID') . ': security check failed'); |
|
44 | + redirect_header('javascript:history.go(-1);', 1, planet_constant('MD_INVALID').': security check failed'); |
|
45 | 45 | } |
46 | -include XOOPS_ROOT_PATH . '/header.php'; |
|
47 | -include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/include/vars.php'; |
|
46 | +include XOOPS_ROOT_PATH.'/header.php'; |
|
47 | +include XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/include/vars.php'; |
|
48 | 48 | |
49 | 49 | $blogHandler = xoops_getModuleHandler('blog', $GLOBALS['moddirname']); |
50 | 50 | $categoryHandler = xoops_getModuleHandler('category', $GLOBALS['moddirname']); |
@@ -56,9 +56,9 @@ discard block |
||
56 | 56 | if ($blog_id) { |
57 | 57 | $blog_obj = $blogHandler->get($blog_id); |
58 | 58 | if ($xoopsUser->isAdmin()) { |
59 | - $blog_obj->setVar('blog_status', Request::getInt('blog_status', 0, 'POST'));// @$_POST['blog_status']); |
|
59 | + $blog_obj->setVar('blog_status', Request::getInt('blog_status', 0, 'POST')); // @$_POST['blog_status']); |
|
60 | 60 | } |
61 | - } else { |
|
61 | + }else { |
|
62 | 62 | if ($blog_exists = $blogHandler->getCount(new Criteria('blog_feed', $myts->addSlashes(trim(Request::getText('blog_feed', '', 'POST'))))) //$_POST['blog_feed'])))) |
63 | 63 | ) { |
64 | 64 | redirect_header('index.php', 2, planet_constant('MD_BLOGEXISTS')); |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | case 2: |
72 | 72 | if (!is_object($xoopsUser)) { |
73 | 73 | $status = 0; |
74 | - } else { |
|
74 | + }else { |
|
75 | 75 | $status = 1; |
76 | 76 | } |
77 | 77 | break; |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | default: |
84 | 84 | if (!is_object($xoopsUser) || !$xoopsUser->isAdmin()) { |
85 | 85 | $status = 0; |
86 | - } else { |
|
86 | + }else { |
|
87 | 87 | $status = 1; |
88 | 88 | } |
89 | 89 | break; |
@@ -92,14 +92,14 @@ discard block |
||
92 | 92 | $blog_obj->setVar('blog_status', $status); |
93 | 93 | } |
94 | 94 | |
95 | - $blog_obj->setVar('blog_title', Request::getString('blog_title', '', 'POST'));//$_POST['blog_title']); |
|
96 | - $blog_obj->setVar('blog_desc', Request::getString('blog_desc', '', 'POST'));//$_POST['blog_desc']); |
|
97 | - $blog_obj->setVar('blog_image', Request::getString('blog_image', '', 'POST'));//$_POST['blog_image']); |
|
98 | - $blog_obj->setVar('blog_feed', Request::getText('blog_feed', '', 'POST'));//$_POST['blog_feed']); |
|
99 | - $blog_obj->setVar('blog_link', Request::getString('blog_link', '', 'POST'));//$_POST['blog_link']); |
|
100 | - $blog_obj->setVar('blog_language', Request::getString('blog_language', '', 'POST'));//$_POST['blog_language']); |
|
101 | - $blog_obj->setVar('blog_charset', Request::getString('blog_charset', '', 'POST'));//$_POST['blog_charset']); |
|
102 | - $blog_obj->setVar('blog_trackback', Request::getString('blog_trackback', '', 'POST'));//$_POST['blog_trackback']); |
|
95 | + $blog_obj->setVar('blog_title', Request::getString('blog_title', '', 'POST')); //$_POST['blog_title']); |
|
96 | + $blog_obj->setVar('blog_desc', Request::getString('blog_desc', '', 'POST')); //$_POST['blog_desc']); |
|
97 | + $blog_obj->setVar('blog_image', Request::getString('blog_image', '', 'POST')); //$_POST['blog_image']); |
|
98 | + $blog_obj->setVar('blog_feed', Request::getText('blog_feed', '', 'POST')); //$_POST['blog_feed']); |
|
99 | + $blog_obj->setVar('blog_link', Request::getString('blog_link', '', 'POST')); //$_POST['blog_link']); |
|
100 | + $blog_obj->setVar('blog_language', Request::getString('blog_language', '', 'POST')); //$_POST['blog_language']); |
|
101 | + $blog_obj->setVar('blog_charset', Request::getString('blog_charset', '', 'POST')); //$_POST['blog_charset']); |
|
102 | + $blog_obj->setVar('blog_trackback', Request::getString('blog_trackback', '', 'POST')); //$_POST['blog_trackback']); |
|
103 | 103 | if ($blog_obj->isNew()) { |
104 | 104 | $blog_obj->setVar('blog_submitter', is_object($xoopsUser) ? $xoopsUser->getVar('uid') : PlanetUtility::planetGetIP(true)); |
105 | 105 | } |
@@ -110,10 +110,10 @@ discard block |
||
110 | 110 | if (in_array(0, $_POST['categories'])) { |
111 | 111 | $_POST['categories'] = []; |
112 | 112 | } |
113 | - $blogHandler->setCategories($blog_id, Request::getString('andor', '', 'POST'));//$_POST['categories']); |
|
113 | + $blogHandler->setCategories($blog_id, Request::getString('andor', '', 'POST')); //$_POST['categories']); |
|
114 | 114 | } |
115 | 115 | $message = planet_constant('MD_DBUPDATED'); |
116 | - redirect_header('index.php' . URL_DELIMITER . 'b' . $blog_id, 2, $message); |
|
116 | + redirect_header('index.php'.URL_DELIMITER.'b'.$blog_id, 2, $message); |
|
117 | 117 | |
118 | 118 | /* edit a single blog */ |
119 | 119 | // no break |
@@ -122,14 +122,14 @@ discard block |
||
122 | 122 | if (!empty(Request::getString('fetch', '', 'POST'))) { |
123 | 123 | $blog_obj = $blogHandler->fetch(Request::getText('blog_feed', '', 'POST')); |
124 | 124 | $blog_obj->setVar('blog_id', $blog_id); |
125 | - } else { |
|
125 | + }else { |
|
126 | 126 | $blog_obj = $blogHandler->get($blog_id); |
127 | 127 | } |
128 | - $categories = Request::getArray('categories', [], 'POST');//isset($_POST['categories']) ? $_POST['categories'] : array(); |
|
128 | + $categories = Request::getArray('categories', [], 'POST'); //isset($_POST['categories']) ? $_POST['categories'] : array(); |
|
129 | 129 | if (in_array('-1', $categories)) { |
130 | 130 | $categories = []; |
131 | 131 | } |
132 | - if (empty($categories) && $blog_id > 0) { |
|
132 | + if (empty($categories) && $blog_id>0) { |
|
133 | 133 | $crit = new Criteria('bc.blog_id', $blog_id); |
134 | 134 | $categories = array_keys($categoryHandler->getByBlog($crit)); |
135 | 135 | } |
@@ -137,23 +137,23 @@ discard block |
||
137 | 137 | $categories = [0 => _NONE]; |
138 | 138 | } |
139 | 139 | |
140 | - echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _EDIT . '</legend>'; |
|
140 | + echo "<fieldset><legend style='font-weight: bold; color: #900;'>"._EDIT.'</legend>'; |
|
141 | 141 | echo '<br>'; |
142 | 142 | if (empty($blog_id) && $blog_obj->getVar('blog_feed')) { |
143 | 143 | $criteria = new Criteria('blog_feed', $blog_obj->getVar('blog_feed')); |
144 | 144 | $blogs_obj = $blogHandler->getList($criteria); |
145 | - if (count($blogs_obj) > 0) { |
|
146 | - echo "<div class=\"errorMsg\">" . planet_constant('MD_BLOGEXISTS'); |
|
145 | + if (count($blogs_obj)>0) { |
|
146 | + echo "<div class=\"errorMsg\">".planet_constant('MD_BLOGEXISTS'); |
|
147 | 147 | foreach (array_keys($blogs_obj) as $bid) { |
148 | - echo "<br><a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . URL_DELIMITER . 'b' . $bid . "\" target=\"_blank\">" . $blogs_obj[$bid] . '</a>'; |
|
148 | + echo "<br><a href=\"".XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/index.php'.URL_DELIMITER.'b'.$bid."\" target=\"_blank\">".$blogs_obj[$bid].'</a>'; |
|
149 | 149 | } |
150 | 150 | echo '</div>'; |
151 | 151 | unset($blogs_obj, $criteria); |
152 | 152 | } |
153 | 153 | } |
154 | - include XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/include/form.blog.php'; |
|
154 | + include XOOPS_ROOT_PATH.'/modules/'.$GLOBALS['moddirname'].'/include/form.blog.php'; |
|
155 | 155 | echo '</fieldset>'; |
156 | 156 | break; |
157 | 157 | } |
158 | 158 | |
159 | -include XOOPS_ROOT_PATH . '/footer.php'; |
|
159 | +include XOOPS_ROOT_PATH.'/footer.php'; |
@@ -38,159 +38,159 @@ |
||
38 | 38 | $charset = trim(Request::getString('charset', '', 'POST'));//trim($_POST['charset']); |
39 | 39 | |
40 | 40 | if (empty($xoopsModuleConfig['trackback_option'])) { |
41 | - PlanetUtility::planetRespondToTrackback(1, 'Trackback is closed'); |
|
41 | + PlanetUtility::planetRespondToTrackback(1, 'Trackback is closed'); |
|
42 | 42 | } |
43 | 43 | if (!strlen($title . $url . $blog_name)) { |
44 | - PlanetUtility::planetRespondToTrackback(1, planet_constant('MD_INVALID')); |
|
44 | + PlanetUtility::planetRespondToTrackback(1, planet_constant('MD_INVALID')); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | if (!empty($article_id) && !empty($url)) { |
48 | - $trackbackHandler = xoops_getModuleHandler('trackback', $GLOBALS['moddirname']); |
|
49 | - $criteria = new CriteriaCompo(new Criteria('art_id', $article_id)); |
|
50 | - $criteria->add(new Criteria('tb_url', $url)); |
|
51 | - if ($trackbackHandler->getCount($criteria) > 0) { |
|
52 | - PlanetUtility::planetRespondToTrackback(1, 'We already have a ping from that URI for this article.'); |
|
53 | - } |
|
48 | + $trackbackHandler = xoops_getModuleHandler('trackback', $GLOBALS['moddirname']); |
|
49 | + $criteria = new CriteriaCompo(new Criteria('art_id', $article_id)); |
|
50 | + $criteria->add(new Criteria('tb_url', $url)); |
|
51 | + if ($trackbackHandler->getCount($criteria) > 0) { |
|
52 | + PlanetUtility::planetRespondToTrackback(1, 'We already have a ping from that URI for this article.'); |
|
53 | + } |
|
54 | 54 | |
55 | - $charset = empty($charset) ? 'utf-8' : $charset; |
|
56 | - $title = XoopsLocal::convert_encoding($title, _CHARSET, $charset); |
|
57 | - $excerpt = XoopsLocal::convert_encoding($excerpt, _CHARSET, $charset); |
|
58 | - $blog_name = XoopsLocal::convert_encoding($blog_name, _CHARSET, $charset); |
|
59 | - $tb_status = (int)$xoopsModuleConfig['trackback_option']; |
|
55 | + $charset = empty($charset) ? 'utf-8' : $charset; |
|
56 | + $title = XoopsLocal::convert_encoding($title, _CHARSET, $charset); |
|
57 | + $excerpt = XoopsLocal::convert_encoding($excerpt, _CHARSET, $charset); |
|
58 | + $blog_name = XoopsLocal::convert_encoding($blog_name, _CHARSET, $charset); |
|
59 | + $tb_status = (int)$xoopsModuleConfig['trackback_option']; |
|
60 | 60 | |
61 | - $com_pid = 0; |
|
62 | - $com_itemid = $article_id; |
|
63 | - $com_rootid = 0; |
|
64 | - $com_title = $title; |
|
65 | - $com_text = $excerpt; |
|
66 | - $com_text .= "\n\n[TRACKBACK]" . _POSTEDBY . ': '; |
|
67 | - if (!empty($url)) { |
|
68 | - $com_text .= '[url=' . $url . ']' . $blog_name . '[/url]'; |
|
69 | - } else { |
|
70 | - $com_text .= $blog_name; |
|
71 | - } |
|
72 | - $com_modid = $xoopsModule->getVar('mid'); |
|
61 | + $com_pid = 0; |
|
62 | + $com_itemid = $article_id; |
|
63 | + $com_rootid = 0; |
|
64 | + $com_title = $title; |
|
65 | + $com_text = $excerpt; |
|
66 | + $com_text .= "\n\n[TRACKBACK]" . _POSTEDBY . ': '; |
|
67 | + if (!empty($url)) { |
|
68 | + $com_text .= '[url=' . $url . ']' . $blog_name . '[/url]'; |
|
69 | + } else { |
|
70 | + $com_text .= $blog_name; |
|
71 | + } |
|
72 | + $com_modid = $xoopsModule->getVar('mid'); |
|
73 | 73 | |
74 | - $commentHandler = xoops_getHandler('comment'); |
|
75 | - $comment = $commentHandler->create(); |
|
76 | - $comment->setVar('com_created', time()); |
|
77 | - $comment->setVar('com_pid', $com_pid); |
|
78 | - $comment->setVar('com_itemid', $com_itemid); |
|
79 | - $comment->setVar('com_rootid', $com_rootid); |
|
80 | - $comment->setVar('com_ip', xoops_getenv('REMOTE_ADDR')); |
|
81 | - switch ($tb_status) { |
|
82 | - case 2: |
|
83 | - $comment->setVar('com_status', 2); |
|
84 | - $call_approvefunc = true; |
|
85 | - $call_updatefunc = true; |
|
86 | - $notify_event = 'comment'; |
|
87 | - break; |
|
88 | - case 1: |
|
89 | - default: |
|
90 | - $comment->setVar('com_status', 1); |
|
91 | - $notify_event = 'comment_submit'; |
|
92 | - break; |
|
93 | - } |
|
94 | - $comment->setVar('com_uid', 0); |
|
95 | - $com_title = xoops_trim($com_title); |
|
96 | - $com_title = empty($com_title) ? _NOTITLE : $com_title; |
|
97 | - $comment->setVar('com_title', $com_title); |
|
98 | - $comment->setVar('com_text', $com_text); |
|
99 | - $comment->setVar('dohtml', 0); |
|
100 | - $comment->setVar('dosmiley', 0); |
|
101 | - $comment->setVar('doxcode', 1); |
|
102 | - $comment->setVar('doimage', 0); |
|
103 | - $comment->setVar('dobr', 1); |
|
104 | - $comment->setVar('com_icon', ''); |
|
105 | - $comment->setVar('com_modified', time()); |
|
106 | - $comment->setVar('com_modid', $com_modid); |
|
107 | - if (false != $commentHandler->insert($comment)) { |
|
108 | - $newcid = $comment->getVar('com_id'); |
|
74 | + $commentHandler = xoops_getHandler('comment'); |
|
75 | + $comment = $commentHandler->create(); |
|
76 | + $comment->setVar('com_created', time()); |
|
77 | + $comment->setVar('com_pid', $com_pid); |
|
78 | + $comment->setVar('com_itemid', $com_itemid); |
|
79 | + $comment->setVar('com_rootid', $com_rootid); |
|
80 | + $comment->setVar('com_ip', xoops_getenv('REMOTE_ADDR')); |
|
81 | + switch ($tb_status) { |
|
82 | + case 2: |
|
83 | + $comment->setVar('com_status', 2); |
|
84 | + $call_approvefunc = true; |
|
85 | + $call_updatefunc = true; |
|
86 | + $notify_event = 'comment'; |
|
87 | + break; |
|
88 | + case 1: |
|
89 | + default: |
|
90 | + $comment->setVar('com_status', 1); |
|
91 | + $notify_event = 'comment_submit'; |
|
92 | + break; |
|
93 | + } |
|
94 | + $comment->setVar('com_uid', 0); |
|
95 | + $com_title = xoops_trim($com_title); |
|
96 | + $com_title = empty($com_title) ? _NOTITLE : $com_title; |
|
97 | + $comment->setVar('com_title', $com_title); |
|
98 | + $comment->setVar('com_text', $com_text); |
|
99 | + $comment->setVar('dohtml', 0); |
|
100 | + $comment->setVar('dosmiley', 0); |
|
101 | + $comment->setVar('doxcode', 1); |
|
102 | + $comment->setVar('doimage', 0); |
|
103 | + $comment->setVar('dobr', 1); |
|
104 | + $comment->setVar('com_icon', ''); |
|
105 | + $comment->setVar('com_modified', time()); |
|
106 | + $comment->setVar('com_modid', $com_modid); |
|
107 | + if (false != $commentHandler->insert($comment)) { |
|
108 | + $newcid = $comment->getVar('com_id'); |
|
109 | 109 | |
110 | - // set own id as root id |
|
111 | - $com_rootid = $newcid; |
|
112 | - if (!$commentHandler->updateByField($comment, 'com_rootid', $com_rootid)) { |
|
113 | - $commentHandler->delete($comment); |
|
114 | - PlanetUtility::planetRespondToTrackback(1, xoops_error()); |
|
115 | - } |
|
110 | + // set own id as root id |
|
111 | + $com_rootid = $newcid; |
|
112 | + if (!$commentHandler->updateByField($comment, 'com_rootid', $com_rootid)) { |
|
113 | + $commentHandler->delete($comment); |
|
114 | + PlanetUtility::planetRespondToTrackback(1, xoops_error()); |
|
115 | + } |
|
116 | 116 | |
117 | - // call custom approve function if any |
|
118 | - if (false != $call_approvefunc && isset($comment_config['callback']['approve']) |
|
119 | - && '' != trim($comment_config['callback']['approve'])) { |
|
120 | - $skip = false; |
|
121 | - if (!function_exists($comment_config['callback']['approve'])) { |
|
122 | - if (isset($comment_config['callbackFile'])) { |
|
123 | - $callbackfile = trim($comment_config['callbackFile']); |
|
124 | - if ('' != $callbackfile |
|
125 | - && file_exists(XOOPS_ROOT_PATH . '/modules/' . $moddir . '/' . $callbackfile)) { |
|
126 | - require_once XOOPS_ROOT_PATH . '/modules/' . $moddir . '/' . $callbackfile; |
|
127 | - } |
|
128 | - if (!function_exists($comment_config['callback']['approve'])) { |
|
129 | - $skip = true; |
|
130 | - } |
|
131 | - } else { |
|
132 | - $skip = true; |
|
133 | - } |
|
134 | - } |
|
135 | - if (!$skip) { |
|
136 | - $comment_config['callback']['approve']($comment); |
|
137 | - } |
|
138 | - } |
|
117 | + // call custom approve function if any |
|
118 | + if (false != $call_approvefunc && isset($comment_config['callback']['approve']) |
|
119 | + && '' != trim($comment_config['callback']['approve'])) { |
|
120 | + $skip = false; |
|
121 | + if (!function_exists($comment_config['callback']['approve'])) { |
|
122 | + if (isset($comment_config['callbackFile'])) { |
|
123 | + $callbackfile = trim($comment_config['callbackFile']); |
|
124 | + if ('' != $callbackfile |
|
125 | + && file_exists(XOOPS_ROOT_PATH . '/modules/' . $moddir . '/' . $callbackfile)) { |
|
126 | + require_once XOOPS_ROOT_PATH . '/modules/' . $moddir . '/' . $callbackfile; |
|
127 | + } |
|
128 | + if (!function_exists($comment_config['callback']['approve'])) { |
|
129 | + $skip = true; |
|
130 | + } |
|
131 | + } else { |
|
132 | + $skip = true; |
|
133 | + } |
|
134 | + } |
|
135 | + if (!$skip) { |
|
136 | + $comment_config['callback']['approve']($comment); |
|
137 | + } |
|
138 | + } |
|
139 | 139 | |
140 | - // call custom update function if any |
|
141 | - if (false != $call_updatefunc && isset($comment_config['callback']['update']) |
|
142 | - && '' != trim($comment_config['callback']['update'])) { |
|
143 | - $skip = false; |
|
144 | - if (!function_exists($comment_config['callback']['update'])) { |
|
145 | - if (isset($comment_config['callbackFile'])) { |
|
146 | - $callbackfile = trim($comment_config['callbackFile']); |
|
147 | - if ('' != $callbackfile |
|
148 | - && file_exists(XOOPS_ROOT_PATH . '/modules/' . $moddir . '/' . $callbackfile)) { |
|
149 | - require_once XOOPS_ROOT_PATH . '/modules/' . $moddir . '/' . $callbackfile; |
|
150 | - } |
|
151 | - if (!function_exists($comment_config['callback']['update'])) { |
|
152 | - $skip = true; |
|
153 | - } |
|
154 | - } else { |
|
155 | - $skip = true; |
|
156 | - } |
|
157 | - } |
|
158 | - if (!$skip) { |
|
159 | - $criteria = new CriteriaCompo(new Criteria('com_modid', $com_modid)); |
|
160 | - $criteria->add(new Criteria('com_itemid', $com_itemid)); |
|
161 | - $criteria->add(new Criteria('com_status', XOOPS_COMMENT_ACTIVE)); |
|
162 | - $comment_count = $commentHandler->getCount($criteria); |
|
163 | - $func = $comment_config['callback']['update']; |
|
164 | - call_user_func_array($func, [$com_itemid, $comment_count, $comment->getVar('com_id')]); |
|
165 | - } |
|
166 | - } |
|
140 | + // call custom update function if any |
|
141 | + if (false != $call_updatefunc && isset($comment_config['callback']['update']) |
|
142 | + && '' != trim($comment_config['callback']['update'])) { |
|
143 | + $skip = false; |
|
144 | + if (!function_exists($comment_config['callback']['update'])) { |
|
145 | + if (isset($comment_config['callbackFile'])) { |
|
146 | + $callbackfile = trim($comment_config['callbackFile']); |
|
147 | + if ('' != $callbackfile |
|
148 | + && file_exists(XOOPS_ROOT_PATH . '/modules/' . $moddir . '/' . $callbackfile)) { |
|
149 | + require_once XOOPS_ROOT_PATH . '/modules/' . $moddir . '/' . $callbackfile; |
|
150 | + } |
|
151 | + if (!function_exists($comment_config['callback']['update'])) { |
|
152 | + $skip = true; |
|
153 | + } |
|
154 | + } else { |
|
155 | + $skip = true; |
|
156 | + } |
|
157 | + } |
|
158 | + if (!$skip) { |
|
159 | + $criteria = new CriteriaCompo(new Criteria('com_modid', $com_modid)); |
|
160 | + $criteria->add(new Criteria('com_itemid', $com_itemid)); |
|
161 | + $criteria->add(new Criteria('com_status', XOOPS_COMMENT_ACTIVE)); |
|
162 | + $comment_count = $commentHandler->getCount($criteria); |
|
163 | + $func = $comment_config['callback']['update']; |
|
164 | + call_user_func_array($func, [$com_itemid, $comment_count, $comment->getVar('com_id')]); |
|
165 | + } |
|
166 | + } |
|
167 | 167 | |
168 | - // RMV-NOTIFY |
|
169 | - // trigger notification event if necessary |
|
170 | - if ($notify_event) { |
|
171 | - $not_modid = $com_modid; |
|
172 | - // require_once XOOPS_ROOT_PATH . '/include/notification_functions.php'; |
|
173 | - $not_catinfo = notificationCommentCategoryInfo($not_modid); |
|
174 | - $not_category = $not_catinfo['name']; |
|
175 | - $not_itemid = $com_itemid; |
|
176 | - $not_event = $notify_event; |
|
177 | - // Build an ABSOLUTE URL to view the comment. Make sure we |
|
178 | - // point to a viewable page (i.e. not the system administration |
|
179 | - // module). |
|
180 | - $comment_tags = []; |
|
181 | - $not_module = $xoopsModule; |
|
182 | - if (!isset($comment_url)) { |
|
183 | - $com_config = $not_module->getInfo('comments'); |
|
184 | - $comment_url = $com_config['pageName'] . '?'; |
|
185 | - $comment_url .= $com_config['itemName']; |
|
186 | - } |
|
187 | - $comment_tags['X_COMMENT_URL'] = XOOPS_URL . '/modules/' . $not_module->getVar('dirname') . '/' . $comment_url . '=' . $com_itemid . '&com_id=' . $newcid . '&com_rootid=' . $com_rootid . '&com_mode=' . $com_mode . '&com_order=' . $com_order . '#comment' . $newcid; |
|
188 | - $notificationHandler = xoops_getHandler('notification'); |
|
189 | - $notificationHandler->triggerEvent($not_category, $not_itemid, $not_event, $comment_tags, false, $not_modid); |
|
190 | - } |
|
168 | + // RMV-NOTIFY |
|
169 | + // trigger notification event if necessary |
|
170 | + if ($notify_event) { |
|
171 | + $not_modid = $com_modid; |
|
172 | + // require_once XOOPS_ROOT_PATH . '/include/notification_functions.php'; |
|
173 | + $not_catinfo = notificationCommentCategoryInfo($not_modid); |
|
174 | + $not_category = $not_catinfo['name']; |
|
175 | + $not_itemid = $com_itemid; |
|
176 | + $not_event = $notify_event; |
|
177 | + // Build an ABSOLUTE URL to view the comment. Make sure we |
|
178 | + // point to a viewable page (i.e. not the system administration |
|
179 | + // module). |
|
180 | + $comment_tags = []; |
|
181 | + $not_module = $xoopsModule; |
|
182 | + if (!isset($comment_url)) { |
|
183 | + $com_config = $not_module->getInfo('comments'); |
|
184 | + $comment_url = $com_config['pageName'] . '?'; |
|
185 | + $comment_url .= $com_config['itemName']; |
|
186 | + } |
|
187 | + $comment_tags['X_COMMENT_URL'] = XOOPS_URL . '/modules/' . $not_module->getVar('dirname') . '/' . $comment_url . '=' . $com_itemid . '&com_id=' . $newcid . '&com_rootid=' . $com_rootid . '&com_mode=' . $com_mode . '&com_order=' . $com_order . '#comment' . $newcid; |
|
188 | + $notificationHandler = xoops_getHandler('notification'); |
|
189 | + $notificationHandler->triggerEvent($not_category, $not_itemid, $not_event, $comment_tags, false, $not_modid); |
|
190 | + } |
|
191 | 191 | |
192 | - PlanetUtility::planetRespondToTrackback(0); |
|
193 | - } else { |
|
194 | - PlanetUtility::planetRespondToTrackback(1, xoops_error($comment->getHtmlErrors())); |
|
195 | - } |
|
192 | + PlanetUtility::planetRespondToTrackback(0); |
|
193 | + } else { |
|
194 | + PlanetUtility::planetRespondToTrackback(1, xoops_error($comment->getHtmlErrors())); |
|
195 | + } |
|
196 | 196 | } |
@@ -26,21 +26,21 @@ discard block |
||
26 | 26 | // ------------------------------------------------------------------------ // |
27 | 27 | use Xmf\Request; |
28 | 28 | |
29 | -include __DIR__ . '/header.php'; |
|
29 | +include __DIR__.'/header.php'; |
|
30 | 30 | |
31 | 31 | // trackback is done by a POST |
32 | 32 | $art_id = explode('/', Request::getString('REQUEST_URI', '', 'SERVER')); |
33 | -$article_id = (int)$art_id[count($art_id) - 1]; |
|
34 | -$url = Request::getString('url', '', 'POST');//$_POST['url']; |
|
35 | -$title = Request::getString('title', '', 'POST');//$_POST['title']; |
|
36 | -$excerpt = Request::getString('excerpt', '', 'POST');//$_POST['excerpt']; |
|
37 | -$blog_name = Request::getString('blog_name', '', 'POST');//$_POST['blog_name']; |
|
38 | -$charset = trim(Request::getString('charset', '', 'POST'));//trim($_POST['charset']); |
|
33 | +$article_id = (int) $art_id[count($art_id)-1]; |
|
34 | +$url = Request::getString('url', '', 'POST'); //$_POST['url']; |
|
35 | +$title = Request::getString('title', '', 'POST'); //$_POST['title']; |
|
36 | +$excerpt = Request::getString('excerpt', '', 'POST'); //$_POST['excerpt']; |
|
37 | +$blog_name = Request::getString('blog_name', '', 'POST'); //$_POST['blog_name']; |
|
38 | +$charset = trim(Request::getString('charset', '', 'POST')); //trim($_POST['charset']); |
|
39 | 39 | |
40 | 40 | if (empty($xoopsModuleConfig['trackback_option'])) { |
41 | 41 | PlanetUtility::planetRespondToTrackback(1, 'Trackback is closed'); |
42 | 42 | } |
43 | -if (!strlen($title . $url . $blog_name)) { |
|
43 | +if (!strlen($title.$url.$blog_name)) { |
|
44 | 44 | PlanetUtility::planetRespondToTrackback(1, planet_constant('MD_INVALID')); |
45 | 45 | } |
46 | 46 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | $trackbackHandler = xoops_getModuleHandler('trackback', $GLOBALS['moddirname']); |
49 | 49 | $criteria = new CriteriaCompo(new Criteria('art_id', $article_id)); |
50 | 50 | $criteria->add(new Criteria('tb_url', $url)); |
51 | - if ($trackbackHandler->getCount($criteria) > 0) { |
|
51 | + if ($trackbackHandler->getCount($criteria)>0) { |
|
52 | 52 | PlanetUtility::planetRespondToTrackback(1, 'We already have a ping from that URI for this article.'); |
53 | 53 | } |
54 | 54 | |
@@ -56,17 +56,17 @@ discard block |
||
56 | 56 | $title = XoopsLocal::convert_encoding($title, _CHARSET, $charset); |
57 | 57 | $excerpt = XoopsLocal::convert_encoding($excerpt, _CHARSET, $charset); |
58 | 58 | $blog_name = XoopsLocal::convert_encoding($blog_name, _CHARSET, $charset); |
59 | - $tb_status = (int)$xoopsModuleConfig['trackback_option']; |
|
59 | + $tb_status = (int) $xoopsModuleConfig['trackback_option']; |
|
60 | 60 | |
61 | 61 | $com_pid = 0; |
62 | 62 | $com_itemid = $article_id; |
63 | 63 | $com_rootid = 0; |
64 | 64 | $com_title = $title; |
65 | 65 | $com_text = $excerpt; |
66 | - $com_text .= "\n\n[TRACKBACK]" . _POSTEDBY . ': '; |
|
66 | + $com_text .= "\n\n[TRACKBACK]"._POSTEDBY.': '; |
|
67 | 67 | if (!empty($url)) { |
68 | - $com_text .= '[url=' . $url . ']' . $blog_name . '[/url]'; |
|
69 | - } else { |
|
68 | + $com_text .= '[url='.$url.']'.$blog_name.'[/url]'; |
|
69 | + }else { |
|
70 | 70 | $com_text .= $blog_name; |
71 | 71 | } |
72 | 72 | $com_modid = $xoopsModule->getVar('mid'); |
@@ -122,13 +122,13 @@ discard block |
||
122 | 122 | if (isset($comment_config['callbackFile'])) { |
123 | 123 | $callbackfile = trim($comment_config['callbackFile']); |
124 | 124 | if ('' != $callbackfile |
125 | - && file_exists(XOOPS_ROOT_PATH . '/modules/' . $moddir . '/' . $callbackfile)) { |
|
126 | - require_once XOOPS_ROOT_PATH . '/modules/' . $moddir . '/' . $callbackfile; |
|
125 | + && file_exists(XOOPS_ROOT_PATH.'/modules/'.$moddir.'/'.$callbackfile)) { |
|
126 | + require_once XOOPS_ROOT_PATH.'/modules/'.$moddir.'/'.$callbackfile; |
|
127 | 127 | } |
128 | 128 | if (!function_exists($comment_config['callback']['approve'])) { |
129 | 129 | $skip = true; |
130 | 130 | } |
131 | - } else { |
|
131 | + }else { |
|
132 | 132 | $skip = true; |
133 | 133 | } |
134 | 134 | } |
@@ -145,13 +145,13 @@ discard block |
||
145 | 145 | if (isset($comment_config['callbackFile'])) { |
146 | 146 | $callbackfile = trim($comment_config['callbackFile']); |
147 | 147 | if ('' != $callbackfile |
148 | - && file_exists(XOOPS_ROOT_PATH . '/modules/' . $moddir . '/' . $callbackfile)) { |
|
149 | - require_once XOOPS_ROOT_PATH . '/modules/' . $moddir . '/' . $callbackfile; |
|
148 | + && file_exists(XOOPS_ROOT_PATH.'/modules/'.$moddir.'/'.$callbackfile)) { |
|
149 | + require_once XOOPS_ROOT_PATH.'/modules/'.$moddir.'/'.$callbackfile; |
|
150 | 150 | } |
151 | 151 | if (!function_exists($comment_config['callback']['update'])) { |
152 | 152 | $skip = true; |
153 | 153 | } |
154 | - } else { |
|
154 | + }else { |
|
155 | 155 | $skip = true; |
156 | 156 | } |
157 | 157 | } |
@@ -181,16 +181,16 @@ discard block |
||
181 | 181 | $not_module = $xoopsModule; |
182 | 182 | if (!isset($comment_url)) { |
183 | 183 | $com_config = $not_module->getInfo('comments'); |
184 | - $comment_url = $com_config['pageName'] . '?'; |
|
184 | + $comment_url = $com_config['pageName'].'?'; |
|
185 | 185 | $comment_url .= $com_config['itemName']; |
186 | 186 | } |
187 | - $comment_tags['X_COMMENT_URL'] = XOOPS_URL . '/modules/' . $not_module->getVar('dirname') . '/' . $comment_url . '=' . $com_itemid . '&com_id=' . $newcid . '&com_rootid=' . $com_rootid . '&com_mode=' . $com_mode . '&com_order=' . $com_order . '#comment' . $newcid; |
|
187 | + $comment_tags['X_COMMENT_URL'] = XOOPS_URL.'/modules/'.$not_module->getVar('dirname').'/'.$comment_url.'='.$com_itemid.'&com_id='.$newcid.'&com_rootid='.$com_rootid.'&com_mode='.$com_mode.'&com_order='.$com_order.'#comment'.$newcid; |
|
188 | 188 | $notificationHandler = xoops_getHandler('notification'); |
189 | 189 | $notificationHandler->triggerEvent($not_category, $not_itemid, $not_event, $comment_tags, false, $not_modid); |
190 | 190 | } |
191 | 191 | |
192 | 192 | PlanetUtility::planetRespondToTrackback(0); |
193 | - } else { |
|
193 | + }else { |
|
194 | 194 | PlanetUtility::planetRespondToTrackback(1, xoops_error($comment->getHtmlErrors())); |
195 | 195 | } |
196 | 196 | } |
@@ -29,13 +29,13 @@ discard block |
||
29 | 29 | include __DIR__ . '/header.php'; |
30 | 30 | |
31 | 31 | if (preg_match("/\/notification_update\.php/i", Request::getUrl('REQUEST_URI', '', 'SERVER'), $matches)) { |
32 | - include XOOPS_ROOT_PATH . '/include/notification_update.php'; |
|
33 | - exit(); |
|
32 | + include XOOPS_ROOT_PATH . '/include/notification_update.php'; |
|
33 | + exit(); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | if ($REQUEST_URI_parsed = PlanetUtility::planetParseArguments($args_num, $args, $args_str)) { |
37 | - $args['start'] = @$args_num[0]; |
|
38 | - $args['sort'] = @$args_str[0]; |
|
37 | + $args['start'] = @$args_num[0]; |
|
38 | + $args['sort'] = @$args_str[0]; |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /* Start */ |
@@ -82,28 +82,28 @@ discard block |
||
82 | 82 | $blog_prefix = ''; |
83 | 83 | /* Specific category */ |
84 | 84 | if ($category_id > 0) { |
85 | - $category_obj = $categoryHandler->get($category_id); |
|
86 | - $criteria->add(new Criteria('bc.cat_id', $category_id)); |
|
87 | - $uid = 0; |
|
88 | - $blog_id = 0; |
|
89 | - $category_data = ['id' => $category_id, 'title' => $category_obj->getVar('cat_title')]; |
|
90 | - $query_type = 'category'; |
|
91 | - $blog_prefix = 'b.'; |
|
85 | + $category_obj = $categoryHandler->get($category_id); |
|
86 | + $criteria->add(new Criteria('bc.cat_id', $category_id)); |
|
87 | + $uid = 0; |
|
88 | + $blog_id = 0; |
|
89 | + $category_data = ['id' => $category_id, 'title' => $category_obj->getVar('cat_title')]; |
|
90 | + $query_type = 'category'; |
|
91 | + $blog_prefix = 'b.'; |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /* User bookmarks(favorites) */ |
95 | 95 | if ($uid > 0) { |
96 | - $criteria->add(new Criteria('bm.bm_uid', $uid)); |
|
97 | - $category_id = 0; |
|
98 | - $blog_id = 0; |
|
99 | - $bookmarkHandler = xoops_getModuleHandler('bookmark', $GLOBALS['moddirname']); |
|
100 | - $user_data = [ |
|
101 | - 'uid' => $uid, |
|
102 | - 'name' => XoopsUser::getUnameFromId($uid), |
|
103 | - 'marks' => $bookmarkHandler->getCount(new Criteria('bm_uid', $uid)) |
|
104 | - ]; |
|
105 | - $query_type = 'bookmark'; |
|
106 | - $blog_prefix = 'b.'; |
|
96 | + $criteria->add(new Criteria('bm.bm_uid', $uid)); |
|
97 | + $category_id = 0; |
|
98 | + $blog_id = 0; |
|
99 | + $bookmarkHandler = xoops_getModuleHandler('bookmark', $GLOBALS['moddirname']); |
|
100 | + $user_data = [ |
|
101 | + 'uid' => $uid, |
|
102 | + 'name' => XoopsUser::getUnameFromId($uid), |
|
103 | + 'marks' => $bookmarkHandler->getCount(new Criteria('bm_uid', $uid)) |
|
104 | + ]; |
|
105 | + $query_type = 'bookmark'; |
|
106 | + $blog_prefix = 'b.'; |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | $criteria->add(new Criteria($blog_prefix . 'blog_status', 0, '>')); |
@@ -112,20 +112,20 @@ discard block |
||
112 | 112 | $order = 'DESC'; |
113 | 113 | $sort = empty($sort) ? 'default' : $sort; |
114 | 114 | switch ($sort) { |
115 | - case 'marks': |
|
116 | - $sortby = $blog_prefix . 'blog_marks'; |
|
117 | - break; |
|
118 | - case 'rating': |
|
119 | - $sortby = $blog_prefix . 'blog_rating'; |
|
120 | - break; |
|
121 | - case 'time': |
|
122 | - $sortby = $blog_prefix . 'blog_time'; |
|
123 | - break; |
|
124 | - case 'default': |
|
125 | - default: |
|
126 | - $sort = 'default'; |
|
127 | - $sortby = $blog_prefix . 'blog_id'; |
|
128 | - break; |
|
115 | + case 'marks': |
|
116 | + $sortby = $blog_prefix . 'blog_marks'; |
|
117 | + break; |
|
118 | + case 'rating': |
|
119 | + $sortby = $blog_prefix . 'blog_rating'; |
|
120 | + break; |
|
121 | + case 'time': |
|
122 | + $sortby = $blog_prefix . 'blog_time'; |
|
123 | + break; |
|
124 | + case 'default': |
|
125 | + default: |
|
126 | + $sort = 'default'; |
|
127 | + $sortby = $blog_prefix . 'blog_id'; |
|
128 | + break; |
|
129 | 129 | } |
130 | 130 | $criteria->setSort($sortby); |
131 | 131 | $criteria->setOrder($order); |
@@ -134,93 +134,93 @@ discard block |
||
134 | 134 | |
135 | 135 | $tags = empty($list) ? '' : [$blog_prefix . 'blog_title', $blog_prefix . 'blog_time']; |
136 | 136 | switch ($query_type) { |
137 | - case 'category': |
|
138 | - $blogs_obj = $blogHandler->getByCategory($criteria, $tags); |
|
139 | - $count_blog = $blogHandler->getCountByCategory($criteria); |
|
140 | - break; |
|
141 | - case 'bookmark': |
|
142 | - $blogs_obj = $blogHandler->getByBookmark($criteria, $tags); |
|
143 | - $count_blog = $blogHandler->getCountByBookmark($criteria); |
|
144 | - break; |
|
145 | - default: |
|
146 | - $blogs_obj = $blogHandler->getAll($criteria, $tags); |
|
147 | - $count_blog = $blogHandler->getCount($criteria); |
|
148 | - break; |
|
137 | + case 'category': |
|
138 | + $blogs_obj = $blogHandler->getByCategory($criteria, $tags); |
|
139 | + $count_blog = $blogHandler->getCountByCategory($criteria); |
|
140 | + break; |
|
141 | + case 'bookmark': |
|
142 | + $blogs_obj = $blogHandler->getByBookmark($criteria, $tags); |
|
143 | + $count_blog = $blogHandler->getCountByBookmark($criteria); |
|
144 | + break; |
|
145 | + default: |
|
146 | + $blogs_obj = $blogHandler->getAll($criteria, $tags); |
|
147 | + $count_blog = $blogHandler->getCount($criteria); |
|
148 | + break; |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | /* Objects to array */ |
152 | 152 | $blogs = []; |
153 | 153 | foreach (array_keys($blogs_obj) as $id) { |
154 | - $_blog = [ |
|
155 | - 'id' => $id, |
|
156 | - 'title' => $blogs_obj[$id]->getVar('blog_title'), |
|
157 | - 'time' => $blogs_obj[$id]->getTime() |
|
158 | - ]; |
|
159 | - if (empty($list)) { |
|
160 | - $_blog = array_merge($_blog, [ |
|
161 | - 'image' => $blogs_obj[$id]->getImage(), |
|
162 | - 'feed' => $blogs_obj[$id]->getVar('blog_feed'), |
|
163 | - 'link' => $blogs_obj[$id]->getVar('blog_link'), |
|
164 | - 'desc' => $blogs_obj[$id]->getVar('blog_desc'), |
|
165 | - 'star' => $blogs_obj[$id]->getStar(), |
|
166 | - 'rates' => $blogs_obj[$id]->getVar('blog_rates'), |
|
167 | - 'marks' => $blogs_obj[$id]->getVar('blog_marks') |
|
168 | - ]); |
|
169 | - } |
|
170 | - $blogs[] = $_blog; |
|
171 | - unset($_blog); |
|
154 | + $_blog = [ |
|
155 | + 'id' => $id, |
|
156 | + 'title' => $blogs_obj[$id]->getVar('blog_title'), |
|
157 | + 'time' => $blogs_obj[$id]->getTime() |
|
158 | + ]; |
|
159 | + if (empty($list)) { |
|
160 | + $_blog = array_merge($_blog, [ |
|
161 | + 'image' => $blogs_obj[$id]->getImage(), |
|
162 | + 'feed' => $blogs_obj[$id]->getVar('blog_feed'), |
|
163 | + 'link' => $blogs_obj[$id]->getVar('blog_link'), |
|
164 | + 'desc' => $blogs_obj[$id]->getVar('blog_desc'), |
|
165 | + 'star' => $blogs_obj[$id]->getStar(), |
|
166 | + 'rates' => $blogs_obj[$id]->getVar('blog_rates'), |
|
167 | + 'marks' => $blogs_obj[$id]->getVar('blog_marks') |
|
168 | + ]); |
|
169 | + } |
|
170 | + $blogs[] = $_blog; |
|
171 | + unset($_blog); |
|
172 | 172 | } |
173 | 173 | unset($blogs_obj); |
174 | 174 | |
175 | 175 | if ($count_blog > $limit) { |
176 | - include XOOPS_ROOT_PATH . '/class/pagenav.php'; |
|
177 | - $start_link = []; |
|
178 | - if ($sort) { |
|
179 | - $start_link[] = 'sort=' . $sort; |
|
180 | - } |
|
181 | - if ($category_id) { |
|
182 | - $start_link[] = 'category=' . $category_id; |
|
183 | - } |
|
184 | - if ($list) { |
|
185 | - $start_link[] = 'list=' . $list; |
|
186 | - } |
|
187 | - $nav = new XoopsPageNav($count_blog, $limit, $start, 'start', implode('&', $start_link)); |
|
188 | - $pagenav = $nav->renderNav(4); |
|
176 | + include XOOPS_ROOT_PATH . '/class/pagenav.php'; |
|
177 | + $start_link = []; |
|
178 | + if ($sort) { |
|
179 | + $start_link[] = 'sort=' . $sort; |
|
180 | + } |
|
181 | + if ($category_id) { |
|
182 | + $start_link[] = 'category=' . $category_id; |
|
183 | + } |
|
184 | + if ($list) { |
|
185 | + $start_link[] = 'list=' . $list; |
|
186 | + } |
|
187 | + $nav = new XoopsPageNav($count_blog, $limit, $start, 'start', implode('&', $start_link)); |
|
188 | + $pagenav = $nav->renderNav(4); |
|
189 | 189 | } else { |
190 | - $pagenav = ''; |
|
190 | + $pagenav = ''; |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | $xoopsTpl->assign('xoops_pagetitle', $xoopsOption['xoops_pagetitle']); |
194 | 194 | $xoopsTpl->assign('link_home', "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . "/index.php\" title=\"" . planet_constant('MD_HOME') . "\" target=\"_self\">" . planet_constant('MD_HOME') . '</a>'); |
195 | 195 | |
196 | 196 | if ($category_id || $uid) { |
197 | - $xoopsTpl->assign('link_index', "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . "/view.blogs.php\" title=\"" . planet_constant('MD_INDEX') . "\" target=\"_self\">" . planet_constant('MD_INDEX') . '</a>'); |
|
197 | + $xoopsTpl->assign('link_index', "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . "/view.blogs.php\" title=\"" . planet_constant('MD_INDEX') . "\" target=\"_self\">" . planet_constant('MD_INDEX') . '</a>'); |
|
198 | 198 | |
199 | - $link_articles = "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . (empty($category_id) ? '' : '/c' . $category_id) . (empty($uid) ? '' : '/u' . $uid) . "\" title=\"" . planet_constant('MD_ARTICLES') . "\">" . planet_constant('MD_ARTICLES') . '</a>'; |
|
200 | - $xoopsTpl->assign('link_articles', $link_articles); |
|
199 | + $link_articles = "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . (empty($category_id) ? '' : '/c' . $category_id) . (empty($uid) ? '' : '/u' . $uid) . "\" title=\"" . planet_constant('MD_ARTICLES') . "\">" . planet_constant('MD_ARTICLES') . '</a>'; |
|
200 | + $xoopsTpl->assign('link_articles', $link_articles); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | $link_switch = "<a href=\"" |
204 | - . XOOPS_URL |
|
205 | - . '/modules/' |
|
206 | - . $GLOBALS['moddirname'] |
|
207 | - . '/view.blogs.php' |
|
208 | - . (empty($category_id) ? '' : '/c' . $category_id) |
|
209 | - . (empty($uid) ? '' : '/u' . $uid) |
|
210 | - . (empty($list) ? '/l1' : '') |
|
211 | - . "\" title=\"" |
|
212 | - . (empty($list) ? planet_constant('MD_LISTVIEW') : planet_constant('MD_FULLVIEW')) |
|
213 | - . "\">" |
|
214 | - . (empty($list) ? planet_constant('MD_LISTVIEW') : planet_constant('MD_FULLVIEW')) |
|
215 | - . '</a>'; |
|
204 | + . XOOPS_URL |
|
205 | + . '/modules/' |
|
206 | + . $GLOBALS['moddirname'] |
|
207 | + . '/view.blogs.php' |
|
208 | + . (empty($category_id) ? '' : '/c' . $category_id) |
|
209 | + . (empty($uid) ? '' : '/u' . $uid) |
|
210 | + . (empty($list) ? '/l1' : '') |
|
211 | + . "\" title=\"" |
|
212 | + . (empty($list) ? planet_constant('MD_LISTVIEW') : planet_constant('MD_FULLVIEW')) |
|
213 | + . "\">" |
|
214 | + . (empty($list) ? planet_constant('MD_LISTVIEW') : planet_constant('MD_FULLVIEW')) |
|
215 | + . '</a>'; |
|
216 | 216 | $xoopsTpl->assign('link_switch', $link_switch); |
217 | 217 | |
218 | 218 | if (empty($uid) && is_object($xoopsUser)) { |
219 | - $xoopsTpl->assign('link_bookmark', "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.blogs.php' . URL_DELIMITER . 'u' . $xoopsUser->getVar('uid') . "\" title=\"" . planet_constant('MD_BOOKMARKS') . "\" target=\"_self\">" . planet_constant('MD_BOOKMARKS') . '</a>'); |
|
219 | + $xoopsTpl->assign('link_bookmark', "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.blogs.php' . URL_DELIMITER . 'u' . $xoopsUser->getVar('uid') . "\" title=\"" . planet_constant('MD_BOOKMARKS') . "\" target=\"_self\">" . planet_constant('MD_BOOKMARKS') . '</a>'); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | if (1 == $xoopsModuleConfig['newblog_submit'] || is_object($xoopsUser)) { |
223 | - $xoopsTpl->assign('link_submit', "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . "/action.blog.php\" title=\"" . _SUBMIT . "\" target=\"_blank\">" . _SUBMIT . '</a>'); |
|
223 | + $xoopsTpl->assign('link_submit', "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . "/action.blog.php\" title=\"" . _SUBMIT . "\" target=\"_blank\">" . _SUBMIT . '</a>'); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | $xoopsTpl->assign('pagetitle', $xoopsModule->getVar('name') . '::' . planet_constant('MD_BLOGS')); |
@@ -234,35 +234,35 @@ discard block |
||
234 | 234 | $xoopsTpl->assign('user_level', !is_object($xoopsUser) ? 0 : ($xoopsUser->isAdmin() ? 2 : 1)); |
235 | 235 | if (empty($xoopsModuleConfig['anonymous_rate']) && !is_object($xoopsUser)) { |
236 | 236 | } elseif (!$list) { |
237 | - $xoopsTpl->assign('canrate', 1); |
|
237 | + $xoopsTpl->assign('canrate', 1); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | $sort_link = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.blogs.php' . URL_DELIMITER; |
241 | 241 | $vars = []; |
242 | 242 | if (!empty($category_id)) { |
243 | - $vars[] = 'c' . $category_id; |
|
243 | + $vars[] = 'c' . $category_id; |
|
244 | 244 | } |
245 | 245 | if (!empty($uid)) { |
246 | - $vars[] = 'u' . $uid; |
|
246 | + $vars[] = 'u' . $uid; |
|
247 | 247 | } |
248 | 248 | if (!empty($list)) { |
249 | - $vars[] = 'li'; |
|
249 | + $vars[] = 'li'; |
|
250 | 250 | } |
251 | 251 | if (!empty($vars)) { |
252 | - $sort_link .= implode('/', $vars) . '/'; |
|
252 | + $sort_link .= implode('/', $vars) . '/'; |
|
253 | 253 | } |
254 | 254 | $sortlinks = []; |
255 | 255 | $valid_sorts = [ |
256 | - 'marks' => planet_constant('MD_BOOKMARKS'), |
|
257 | - 'rating' => planet_constant('MD_RATING'), |
|
258 | - 'time' => planet_constant('MD_TIME'), |
|
259 | - 'default' => planet_constant('MD_DEFAULT') |
|
256 | + 'marks' => planet_constant('MD_BOOKMARKS'), |
|
257 | + 'rating' => planet_constant('MD_RATING'), |
|
258 | + 'time' => planet_constant('MD_TIME'), |
|
259 | + 'default' => planet_constant('MD_DEFAULT') |
|
260 | 260 | ]; |
261 | 261 | foreach ($valid_sorts as $val => $name) { |
262 | - if ($val == $sort) { |
|
263 | - continue; |
|
264 | - } |
|
265 | - $sortlinks[] = "<a href=\"" . $sort_link . $val . "\">" . $name . '</a>'; |
|
262 | + if ($val == $sort) { |
|
263 | + continue; |
|
264 | + } |
|
265 | + $sortlinks[] = "<a href=\"" . $sort_link . $val . "\">" . $name . '</a>'; |
|
266 | 266 | } |
267 | 267 | $xoopsTpl->assign('link_sort', implode(' | ', $sortlinks)); |
268 | 268 |
@@ -26,10 +26,10 @@ discard block |
||
26 | 26 | // ------------------------------------------------------------------------ // |
27 | 27 | use Xmf\Request; |
28 | 28 | |
29 | -include __DIR__ . '/header.php'; |
|
29 | +include __DIR__.'/header.php'; |
|
30 | 30 | |
31 | 31 | if (preg_match("/\/notification_update\.php/i", Request::getUrl('REQUEST_URI', '', 'SERVER'), $matches)) { |
32 | - include XOOPS_ROOT_PATH . '/include/notification_update.php'; |
|
32 | + include XOOPS_ROOT_PATH.'/include/notification_update.php'; |
|
33 | 33 | exit(); |
34 | 34 | } |
35 | 35 | |
@@ -66,10 +66,10 @@ discard block |
||
66 | 66 | } |
67 | 67 | */ |
68 | 68 | |
69 | -$xoopsOption['xoops_pagetitle'] = $xoopsModule->getVar('name') . ' - ' . planet_constant('MD_BLOGS'); |
|
69 | +$xoopsOption['xoops_pagetitle'] = $xoopsModule->getVar('name').' - '.planet_constant('MD_BLOGS'); |
|
70 | 70 | $xoopsOption['template_main'] = PlanetUtility::planetGetTemplate('blogs'); |
71 | -require_once XOOPS_ROOT_PATH . '/header.php'; |
|
72 | -include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/include/vars.php'; |
|
71 | +require_once XOOPS_ROOT_PATH.'/header.php'; |
|
72 | +include XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/include/vars.php'; |
|
73 | 73 | |
74 | 74 | // Following part will not be executed after cache |
75 | 75 | $categoryHandler = xoops_getModuleHandler('category', $GLOBALS['moddirname']); |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | $criteria = new CriteriaCompo(); |
82 | 82 | $blog_prefix = ''; |
83 | 83 | /* Specific category */ |
84 | -if ($category_id > 0) { |
|
84 | +if ($category_id>0) { |
|
85 | 85 | $category_obj = $categoryHandler->get($category_id); |
86 | 86 | $criteria->add(new Criteria('bc.cat_id', $category_id)); |
87 | 87 | $uid = 0; |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | } |
93 | 93 | |
94 | 94 | /* User bookmarks(favorites) */ |
95 | -if ($uid > 0) { |
|
95 | +if ($uid>0) { |
|
96 | 96 | $criteria->add(new Criteria('bm.bm_uid', $uid)); |
97 | 97 | $category_id = 0; |
98 | 98 | $blog_id = 0; |
@@ -106,25 +106,25 @@ discard block |
||
106 | 106 | $blog_prefix = 'b.'; |
107 | 107 | } |
108 | 108 | |
109 | -$criteria->add(new Criteria($blog_prefix . 'blog_status', 0, '>')); |
|
109 | +$criteria->add(new Criteria($blog_prefix.'blog_status', 0, '>')); |
|
110 | 110 | |
111 | 111 | /* Sort */ |
112 | 112 | $order = 'DESC'; |
113 | 113 | $sort = empty($sort) ? 'default' : $sort; |
114 | 114 | switch ($sort) { |
115 | 115 | case 'marks': |
116 | - $sortby = $blog_prefix . 'blog_marks'; |
|
116 | + $sortby = $blog_prefix.'blog_marks'; |
|
117 | 117 | break; |
118 | 118 | case 'rating': |
119 | - $sortby = $blog_prefix . 'blog_rating'; |
|
119 | + $sortby = $blog_prefix.'blog_rating'; |
|
120 | 120 | break; |
121 | 121 | case 'time': |
122 | - $sortby = $blog_prefix . 'blog_time'; |
|
122 | + $sortby = $blog_prefix.'blog_time'; |
|
123 | 123 | break; |
124 | 124 | case 'default': |
125 | 125 | default: |
126 | 126 | $sort = 'default'; |
127 | - $sortby = $blog_prefix . 'blog_id'; |
|
127 | + $sortby = $blog_prefix.'blog_id'; |
|
128 | 128 | break; |
129 | 129 | } |
130 | 130 | $criteria->setSort($sortby); |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | $criteria->setStart($start); |
133 | 133 | $criteria->setLimit($limit); |
134 | 134 | |
135 | -$tags = empty($list) ? '' : [$blog_prefix . 'blog_title', $blog_prefix . 'blog_time']; |
|
135 | +$tags = empty($list) ? '' : [$blog_prefix.'blog_title', $blog_prefix.'blog_time']; |
|
136 | 136 | switch ($query_type) { |
137 | 137 | case 'category': |
138 | 138 | $blogs_obj = $blogHandler->getByCategory($criteria, $tags); |
@@ -172,31 +172,31 @@ discard block |
||
172 | 172 | } |
173 | 173 | unset($blogs_obj); |
174 | 174 | |
175 | -if ($count_blog > $limit) { |
|
176 | - include XOOPS_ROOT_PATH . '/class/pagenav.php'; |
|
175 | +if ($count_blog>$limit) { |
|
176 | + include XOOPS_ROOT_PATH.'/class/pagenav.php'; |
|
177 | 177 | $start_link = []; |
178 | 178 | if ($sort) { |
179 | - $start_link[] = 'sort=' . $sort; |
|
179 | + $start_link[] = 'sort='.$sort; |
|
180 | 180 | } |
181 | 181 | if ($category_id) { |
182 | - $start_link[] = 'category=' . $category_id; |
|
182 | + $start_link[] = 'category='.$category_id; |
|
183 | 183 | } |
184 | 184 | if ($list) { |
185 | - $start_link[] = 'list=' . $list; |
|
185 | + $start_link[] = 'list='.$list; |
|
186 | 186 | } |
187 | 187 | $nav = new XoopsPageNav($count_blog, $limit, $start, 'start', implode('&', $start_link)); |
188 | 188 | $pagenav = $nav->renderNav(4); |
189 | -} else { |
|
189 | +}else { |
|
190 | 190 | $pagenav = ''; |
191 | 191 | } |
192 | 192 | |
193 | 193 | $xoopsTpl->assign('xoops_pagetitle', $xoopsOption['xoops_pagetitle']); |
194 | -$xoopsTpl->assign('link_home', "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . "/index.php\" title=\"" . planet_constant('MD_HOME') . "\" target=\"_self\">" . planet_constant('MD_HOME') . '</a>'); |
|
194 | +$xoopsTpl->assign('link_home', "<a href=\"".XOOPS_URL.'/modules/'.$GLOBALS['moddirname']."/index.php\" title=\"".planet_constant('MD_HOME')."\" target=\"_self\">".planet_constant('MD_HOME').'</a>'); |
|
195 | 195 | |
196 | 196 | if ($category_id || $uid) { |
197 | - $xoopsTpl->assign('link_index', "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . "/view.blogs.php\" title=\"" . planet_constant('MD_INDEX') . "\" target=\"_self\">" . planet_constant('MD_INDEX') . '</a>'); |
|
197 | + $xoopsTpl->assign('link_index', "<a href=\"".XOOPS_URL.'/modules/'.$GLOBALS['moddirname']."/view.blogs.php\" title=\"".planet_constant('MD_INDEX')."\" target=\"_self\">".planet_constant('MD_INDEX').'</a>'); |
|
198 | 198 | |
199 | - $link_articles = "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . (empty($category_id) ? '' : '/c' . $category_id) . (empty($uid) ? '' : '/u' . $uid) . "\" title=\"" . planet_constant('MD_ARTICLES') . "\">" . planet_constant('MD_ARTICLES') . '</a>'; |
|
199 | + $link_articles = "<a href=\"".XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/index.php'.(empty($category_id) ? '' : '/c'.$category_id).(empty($uid) ? '' : '/u'.$uid)."\" title=\"".planet_constant('MD_ARTICLES')."\">".planet_constant('MD_ARTICLES').'</a>'; |
|
200 | 200 | $xoopsTpl->assign('link_articles', $link_articles); |
201 | 201 | } |
202 | 202 | |
@@ -205,8 +205,8 @@ discard block |
||
205 | 205 | . '/modules/' |
206 | 206 | . $GLOBALS['moddirname'] |
207 | 207 | . '/view.blogs.php' |
208 | - . (empty($category_id) ? '' : '/c' . $category_id) |
|
209 | - . (empty($uid) ? '' : '/u' . $uid) |
|
208 | + . (empty($category_id) ? '' : '/c'.$category_id) |
|
209 | + . (empty($uid) ? '' : '/u'.$uid) |
|
210 | 210 | . (empty($list) ? '/l1' : '') |
211 | 211 | . "\" title=\"" |
212 | 212 | . (empty($list) ? planet_constant('MD_LISTVIEW') : planet_constant('MD_FULLVIEW')) |
@@ -216,14 +216,14 @@ discard block |
||
216 | 216 | $xoopsTpl->assign('link_switch', $link_switch); |
217 | 217 | |
218 | 218 | if (empty($uid) && is_object($xoopsUser)) { |
219 | - $xoopsTpl->assign('link_bookmark', "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.blogs.php' . URL_DELIMITER . 'u' . $xoopsUser->getVar('uid') . "\" title=\"" . planet_constant('MD_BOOKMARKS') . "\" target=\"_self\">" . planet_constant('MD_BOOKMARKS') . '</a>'); |
|
219 | + $xoopsTpl->assign('link_bookmark', "<a href=\"".XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/view.blogs.php'.URL_DELIMITER.'u'.$xoopsUser->getVar('uid')."\" title=\"".planet_constant('MD_BOOKMARKS')."\" target=\"_self\">".planet_constant('MD_BOOKMARKS').'</a>'); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | if (1 == $xoopsModuleConfig['newblog_submit'] || is_object($xoopsUser)) { |
223 | - $xoopsTpl->assign('link_submit', "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . "/action.blog.php\" title=\"" . _SUBMIT . "\" target=\"_blank\">" . _SUBMIT . '</a>'); |
|
223 | + $xoopsTpl->assign('link_submit', "<a href=\"".XOOPS_URL.'/modules/'.$GLOBALS['moddirname']."/action.blog.php\" title=\""._SUBMIT."\" target=\"_blank\">"._SUBMIT.'</a>'); |
|
224 | 224 | } |
225 | 225 | |
226 | -$xoopsTpl->assign('pagetitle', $xoopsModule->getVar('name') . '::' . planet_constant('MD_BLOGS')); |
|
226 | +$xoopsTpl->assign('pagetitle', $xoopsModule->getVar('name').'::'.planet_constant('MD_BLOGS')); |
|
227 | 227 | $xoopsTpl->assign('category', @$category_data); |
228 | 228 | $xoopsTpl->assign('user', @$user_data); |
229 | 229 | $xoopsTpl->assign('blogs', $blogs); |
@@ -237,19 +237,19 @@ discard block |
||
237 | 237 | $xoopsTpl->assign('canrate', 1); |
238 | 238 | } |
239 | 239 | |
240 | -$sort_link = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.blogs.php' . URL_DELIMITER; |
|
240 | +$sort_link = XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/view.blogs.php'.URL_DELIMITER; |
|
241 | 241 | $vars = []; |
242 | 242 | if (!empty($category_id)) { |
243 | - $vars[] = 'c' . $category_id; |
|
243 | + $vars[] = 'c'.$category_id; |
|
244 | 244 | } |
245 | 245 | if (!empty($uid)) { |
246 | - $vars[] = 'u' . $uid; |
|
246 | + $vars[] = 'u'.$uid; |
|
247 | 247 | } |
248 | 248 | if (!empty($list)) { |
249 | 249 | $vars[] = 'li'; |
250 | 250 | } |
251 | 251 | if (!empty($vars)) { |
252 | - $sort_link .= implode('/', $vars) . '/'; |
|
252 | + $sort_link .= implode('/', $vars).'/'; |
|
253 | 253 | } |
254 | 254 | $sortlinks = []; |
255 | 255 | $valid_sorts = [ |
@@ -262,8 +262,8 @@ discard block |
||
262 | 262 | if ($val == $sort) { |
263 | 263 | continue; |
264 | 264 | } |
265 | - $sortlinks[] = "<a href=\"" . $sort_link . $val . "\">" . $name . '</a>'; |
|
265 | + $sortlinks[] = "<a href=\"".$sort_link.$val."\">".$name.'</a>'; |
|
266 | 266 | } |
267 | 267 | $xoopsTpl->assign('link_sort', implode(' | ', $sortlinks)); |
268 | 268 | |
269 | -require_once __DIR__ . '/footer.php'; |
|
269 | +require_once __DIR__.'/footer.php'; |
@@ -27,13 +27,13 @@ discard block |
||
27 | 27 | include __DIR__ . '/header.php'; |
28 | 28 | |
29 | 29 | if (preg_match("/\/notification_update\.php/i", $_SERVER['REQUEST_URI'], $matches)) { |
30 | - include XOOPS_ROOT_PATH . '/include/notification_update.php'; |
|
31 | - exit(); |
|
30 | + include XOOPS_ROOT_PATH . '/include/notification_update.php'; |
|
31 | + exit(); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | if ($REQUEST_URI_parsed = PlanetUtility::planetParseArguments($args_num, $args, $args_str)) { |
35 | - $args['start'] = @$args_num[0]; |
|
36 | - $args['sort'] = @$args_str[0]; |
|
35 | + $args['start'] = @$args_num[0]; |
|
36 | + $args['sort'] = @$args_str[0]; |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /* Start */ |
@@ -51,20 +51,20 @@ discard block |
||
51 | 51 | |
52 | 52 | // restore $_SERVER['REQUEST_URI'] |
53 | 53 | if (!empty($REQUEST_URI_parsed)) { |
54 | - $args_REQUEST_URI = []; |
|
55 | - $_args = ['start', 'sort', 'uid', 'list']; |
|
56 | - foreach ($_args as $arg) { |
|
57 | - if (!empty(${$arg})) { |
|
58 | - $args_REQUEST_URI[] = $arg . '=' . ${$arg}; |
|
59 | - } |
|
60 | - } |
|
61 | - if (!empty($blog_id)) { |
|
62 | - $args_REQUEST_URI[] = 'blog=' . $blog_id; |
|
63 | - } |
|
64 | - if (!empty($category_id)) { |
|
65 | - $args_REQUEST_URI[] = 'category=' . $category_id; |
|
66 | - } |
|
67 | - $_SERVER['REQUEST_URI'] = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . (empty($args_REQUEST_URI) ? '' : '?' . implode('&', $args_REQUEST_URI)); |
|
54 | + $args_REQUEST_URI = []; |
|
55 | + $_args = ['start', 'sort', 'uid', 'list']; |
|
56 | + foreach ($_args as $arg) { |
|
57 | + if (!empty(${$arg})) { |
|
58 | + $args_REQUEST_URI[] = $arg . '=' . ${$arg}; |
|
59 | + } |
|
60 | + } |
|
61 | + if (!empty($blog_id)) { |
|
62 | + $args_REQUEST_URI[] = 'blog=' . $blog_id; |
|
63 | + } |
|
64 | + if (!empty($category_id)) { |
|
65 | + $args_REQUEST_URI[] = 'category=' . $category_id; |
|
66 | + } |
|
67 | + $_SERVER['REQUEST_URI'] = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . (empty($args_REQUEST_URI) ? '' : '?' . implode('&', $args_REQUEST_URI)); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | $GLOBALS['xoopsOption']['template_main'] = PlanetUtility::planetGetTemplate('index'); |
@@ -89,73 +89,73 @@ discard block |
||
89 | 89 | $article_prefix = ''; |
90 | 90 | /* Specific category */ |
91 | 91 | if ($category_id > 0) { |
92 | - $category_obj = $categoryHandler->get($category_id); |
|
93 | - $criteria->add(new Criteria('bc.cat_id', $category_id)); |
|
94 | - $uid = 0; |
|
95 | - $blog_id = 0; |
|
96 | - $category_data = ['id' => $category_id, 'title' => $category_obj->getVar('cat_title')]; |
|
97 | - $query_type = 'category'; |
|
98 | - $article_prefix = 'a.'; |
|
92 | + $category_obj = $categoryHandler->get($category_id); |
|
93 | + $criteria->add(new Criteria('bc.cat_id', $category_id)); |
|
94 | + $uid = 0; |
|
95 | + $blog_id = 0; |
|
96 | + $category_data = ['id' => $category_id, 'title' => $category_obj->getVar('cat_title')]; |
|
97 | + $query_type = 'category'; |
|
98 | + $article_prefix = 'a.'; |
|
99 | 99 | } |
100 | 100 | /* Specific blog */ |
101 | 101 | if ($blog_id > 0) { |
102 | - $blog_obj = $blogHandler->get($blog_id); |
|
103 | - if ($blog_obj->getVar('blog_status') |
|
104 | - || (is_object($xoopsUser) |
|
105 | - && $xoopsUser->getVar('uid') == $blog_obj->getVar('blog_submitter'))) { |
|
106 | - $criteria->add(new Criteria('blog_id', $blog_id)); |
|
107 | - $category_id = 0; |
|
108 | - $uid = 0; |
|
109 | - $bookmarkHandler = xoops_getModuleHandler('bookmark', $GLOBALS['moddirname']); |
|
110 | - $blog_data = [ |
|
111 | - 'id' => $blog_id, |
|
112 | - 'title' => $blog_obj->getVar('blog_title'), |
|
113 | - 'image' => $blog_obj->getImage(), |
|
114 | - 'title' => $blog_obj->getVar('blog_title'), |
|
115 | - 'feed' => $blog_obj->getVar('blog_feed'), |
|
116 | - 'link' => $blog_obj->getVar('blog_link'), |
|
117 | - 'desc' => $blog_obj->getVar('blog_desc'), |
|
118 | - 'time' => $blog_obj->getTime(), |
|
119 | - 'star' => $blog_obj->getStar(), |
|
120 | - 'rates' => $blog_obj->getVar('blog_rates'), |
|
121 | - 'marks' => $blog_obj->getVar('blog_marks') |
|
122 | - ]; |
|
123 | - } |
|
124 | - $query_type = 'blog'; |
|
125 | - $article_prefix = ''; |
|
102 | + $blog_obj = $blogHandler->get($blog_id); |
|
103 | + if ($blog_obj->getVar('blog_status') |
|
104 | + || (is_object($xoopsUser) |
|
105 | + && $xoopsUser->getVar('uid') == $blog_obj->getVar('blog_submitter'))) { |
|
106 | + $criteria->add(new Criteria('blog_id', $blog_id)); |
|
107 | + $category_id = 0; |
|
108 | + $uid = 0; |
|
109 | + $bookmarkHandler = xoops_getModuleHandler('bookmark', $GLOBALS['moddirname']); |
|
110 | + $blog_data = [ |
|
111 | + 'id' => $blog_id, |
|
112 | + 'title' => $blog_obj->getVar('blog_title'), |
|
113 | + 'image' => $blog_obj->getImage(), |
|
114 | + 'title' => $blog_obj->getVar('blog_title'), |
|
115 | + 'feed' => $blog_obj->getVar('blog_feed'), |
|
116 | + 'link' => $blog_obj->getVar('blog_link'), |
|
117 | + 'desc' => $blog_obj->getVar('blog_desc'), |
|
118 | + 'time' => $blog_obj->getTime(), |
|
119 | + 'star' => $blog_obj->getStar(), |
|
120 | + 'rates' => $blog_obj->getVar('blog_rates'), |
|
121 | + 'marks' => $blog_obj->getVar('blog_marks') |
|
122 | + ]; |
|
123 | + } |
|
124 | + $query_type = 'blog'; |
|
125 | + $article_prefix = ''; |
|
126 | 126 | } |
127 | 127 | /* User bookmarks(favorites) */ |
128 | 128 | if ($uid > 0) { |
129 | - $criteria->add(new Criteria('bm.bm_uid', $uid)); |
|
130 | - $category_id = 0; |
|
131 | - $blog_id = 0; |
|
132 | - $bookmarkHandler = xoops_getModuleHandler('bookmark', $GLOBALS['moddirname']); |
|
133 | - $user_data = [ |
|
134 | - 'uid' => $uid, |
|
135 | - 'name' => XoopsUser::getUnameFromId($uid), |
|
136 | - 'marks' => $bookmarkHandler->getCount(new Criteria('bm_uid', $uid)) |
|
137 | - ]; |
|
138 | - $query_type = 'bookmark'; |
|
139 | - $article_prefix = 'a.'; |
|
129 | + $criteria->add(new Criteria('bm.bm_uid', $uid)); |
|
130 | + $category_id = 0; |
|
131 | + $blog_id = 0; |
|
132 | + $bookmarkHandler = xoops_getModuleHandler('bookmark', $GLOBALS['moddirname']); |
|
133 | + $user_data = [ |
|
134 | + 'uid' => $uid, |
|
135 | + 'name' => XoopsUser::getUnameFromId($uid), |
|
136 | + 'marks' => $bookmarkHandler->getCount(new Criteria('bm_uid', $uid)) |
|
137 | + ]; |
|
138 | + $query_type = 'bookmark'; |
|
139 | + $article_prefix = 'a.'; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /* Sort */ |
143 | 143 | $order = 'DESC'; |
144 | 144 | $sort = empty($sort) ? 'time' : $sort; |
145 | 145 | switch ($sort) { |
146 | - case 'views': |
|
147 | - $sortby = $article_prefix . 'art_views'; |
|
148 | - break; |
|
149 | - case 'rating': |
|
150 | - $sortby = $article_prefix . 'art_rating'; |
|
151 | - break; |
|
152 | - case 'time': |
|
153 | - $sortby = $article_prefix . 'art_time'; |
|
154 | - break; |
|
155 | - case 'default': |
|
156 | - default: |
|
157 | - $sortby = ''; |
|
158 | - break; |
|
146 | + case 'views': |
|
147 | + $sortby = $article_prefix . 'art_views'; |
|
148 | + break; |
|
149 | + case 'rating': |
|
150 | + $sortby = $article_prefix . 'art_rating'; |
|
151 | + break; |
|
152 | + case 'time': |
|
153 | + $sortby = $article_prefix . 'art_time'; |
|
154 | + break; |
|
155 | + case 'default': |
|
156 | + default: |
|
157 | + $sortby = ''; |
|
158 | + break; |
|
159 | 159 | } |
160 | 160 | $criteria->setSort($sortby); |
161 | 161 | $criteria->setOrder($order); |
@@ -163,120 +163,120 @@ discard block |
||
163 | 163 | $criteria->setLimit($limit); |
164 | 164 | |
165 | 165 | $tags = empty($list) ? '' : [ |
166 | - $article_prefix . 'art_title', |
|
167 | - $article_prefix . 'blog_id', |
|
168 | - $article_prefix . 'art_time' |
|
166 | + $article_prefix . 'art_title', |
|
167 | + $article_prefix . 'blog_id', |
|
168 | + $article_prefix . 'art_time' |
|
169 | 169 | ]; |
170 | 170 | switch ($query_type) { |
171 | - case 'category': |
|
172 | - $articles_obj = $articleHandler->getByCategory($criteria, $tags); |
|
173 | - $count_article = $articleHandler->getCountByCategory($criteria); |
|
174 | - break; |
|
175 | - case 'bookmark': |
|
176 | - $articles_obj = $articleHandler->getByBookmark($criteria, $tags); |
|
177 | - $count_article = $articleHandler->getCountByBookmark($criteria); |
|
178 | - break; |
|
179 | - default: |
|
180 | - $articles_obj = $articleHandler->getAll($criteria, $tags); |
|
181 | - $count_article = $articleHandler->getCount($criteria); |
|
182 | - break; |
|
171 | + case 'category': |
|
172 | + $articles_obj = $articleHandler->getByCategory($criteria, $tags); |
|
173 | + $count_article = $articleHandler->getCountByCategory($criteria); |
|
174 | + break; |
|
175 | + case 'bookmark': |
|
176 | + $articles_obj = $articleHandler->getByBookmark($criteria, $tags); |
|
177 | + $count_article = $articleHandler->getCountByBookmark($criteria); |
|
178 | + break; |
|
179 | + default: |
|
180 | + $articles_obj = $articleHandler->getAll($criteria, $tags); |
|
181 | + $count_article = $articleHandler->getCount($criteria); |
|
182 | + break; |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | if (!empty($blog_data)) { |
186 | - $blogs[$blog_data['id']] = $blog_data['title']; |
|
186 | + $blogs[$blog_data['id']] = $blog_data['title']; |
|
187 | 187 | } else { |
188 | - $blog_array = []; |
|
189 | - foreach (array_keys($articles_obj) as $id) { |
|
190 | - $blog_array[$articles_obj[$id]->getVar('blog_id')] = 1; |
|
191 | - } |
|
192 | - $criteria_blog = new Criteria('blog_id', '(' . implode(',', array_keys($blog_array)) . ')', 'IN'); |
|
193 | - $blogs = $blogHandler->getList($criteria_blog); |
|
188 | + $blog_array = []; |
|
189 | + foreach (array_keys($articles_obj) as $id) { |
|
190 | + $blog_array[$articles_obj[$id]->getVar('blog_id')] = 1; |
|
191 | + } |
|
192 | + $criteria_blog = new Criteria('blog_id', '(' . implode(',', array_keys($blog_array)) . ')', 'IN'); |
|
193 | + $blogs = $blogHandler->getList($criteria_blog); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | /* Objects to array */ |
197 | 197 | $articles = []; |
198 | 198 | foreach (array_keys($articles_obj) as $id) { |
199 | - $_article = [ |
|
200 | - 'id' => $id, |
|
201 | - 'title' => $articles_obj[$id]->getVar('art_title'), |
|
202 | - 'time' => $articles_obj[$id]->getTime(), |
|
203 | - 'blog' => [ |
|
204 | - 'id' => $articles_obj[$id]->getVar('blog_id'), |
|
205 | - 'title' => $blogs[$articles_obj[$id]->getVar('blog_id')] |
|
206 | - ] |
|
207 | - ]; |
|
208 | - if (empty($list)) { |
|
209 | - $_article = array_merge($_article, [ |
|
210 | - 'author' => $articles_obj[$id]->getVar('art_author'), |
|
211 | - 'views' => $articles_obj[$id]->getVar('art_views'), |
|
212 | - 'comments' => $articles_obj[$id]->getVar('art_comments'), |
|
213 | - 'star' => $articles_obj[$id]->getStar(), |
|
214 | - 'rates' => $articles_obj[$id]->getVar('art_rates') |
|
215 | - ]); |
|
216 | - if (!empty($xoopsModuleConfig['display_summary'])) { |
|
217 | - $_article['content'] = $articles_obj[$id]->getSummary(); |
|
218 | - } else { |
|
219 | - $_article['content'] = $articles_obj[$id]->getVar('art_content'); |
|
220 | - } |
|
221 | - } |
|
222 | - $articles[] = $_article; |
|
223 | - unset($_article); |
|
199 | + $_article = [ |
|
200 | + 'id' => $id, |
|
201 | + 'title' => $articles_obj[$id]->getVar('art_title'), |
|
202 | + 'time' => $articles_obj[$id]->getTime(), |
|
203 | + 'blog' => [ |
|
204 | + 'id' => $articles_obj[$id]->getVar('blog_id'), |
|
205 | + 'title' => $blogs[$articles_obj[$id]->getVar('blog_id')] |
|
206 | + ] |
|
207 | + ]; |
|
208 | + if (empty($list)) { |
|
209 | + $_article = array_merge($_article, [ |
|
210 | + 'author' => $articles_obj[$id]->getVar('art_author'), |
|
211 | + 'views' => $articles_obj[$id]->getVar('art_views'), |
|
212 | + 'comments' => $articles_obj[$id]->getVar('art_comments'), |
|
213 | + 'star' => $articles_obj[$id]->getStar(), |
|
214 | + 'rates' => $articles_obj[$id]->getVar('art_rates') |
|
215 | + ]); |
|
216 | + if (!empty($xoopsModuleConfig['display_summary'])) { |
|
217 | + $_article['content'] = $articles_obj[$id]->getSummary(); |
|
218 | + } else { |
|
219 | + $_article['content'] = $articles_obj[$id]->getVar('art_content'); |
|
220 | + } |
|
221 | + } |
|
222 | + $articles[] = $_article; |
|
223 | + unset($_article); |
|
224 | 224 | } |
225 | 225 | unset($articles_obj); |
226 | 226 | |
227 | 227 | if ($count_article > $limit) { |
228 | - include XOOPS_ROOT_PATH . '/class/pagenav.php'; |
|
229 | - $start_link = []; |
|
230 | - if ($sort) { |
|
231 | - $start_link[] = 'sort=' . $sort; |
|
232 | - } |
|
233 | - if ($category_id) { |
|
234 | - $start_link[] = 'category=' . $category_id; |
|
235 | - } |
|
236 | - if ($blog_id) { |
|
237 | - $start_link[] = 'blog=' . $blog_id; |
|
238 | - } |
|
239 | - if ($list) { |
|
240 | - $start_link[] = 'list=' . $list; |
|
241 | - } |
|
242 | - $nav = new XoopsPageNav($count_article, $limit, $start, 'start', implode('&', $start_link)); |
|
243 | - $pagenav = $nav->renderNav(4); |
|
228 | + include XOOPS_ROOT_PATH . '/class/pagenav.php'; |
|
229 | + $start_link = []; |
|
230 | + if ($sort) { |
|
231 | + $start_link[] = 'sort=' . $sort; |
|
232 | + } |
|
233 | + if ($category_id) { |
|
234 | + $start_link[] = 'category=' . $category_id; |
|
235 | + } |
|
236 | + if ($blog_id) { |
|
237 | + $start_link[] = 'blog=' . $blog_id; |
|
238 | + } |
|
239 | + if ($list) { |
|
240 | + $start_link[] = 'list=' . $list; |
|
241 | + } |
|
242 | + $nav = new XoopsPageNav($count_article, $limit, $start, 'start', implode('&', $start_link)); |
|
243 | + $pagenav = $nav->renderNav(4); |
|
244 | 244 | } else { |
245 | - $pagenav = ''; |
|
245 | + $pagenav = ''; |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | $xoopsTpl->assign('xoops_module_header', $xoops_module_header); |
249 | 249 | $xoopsTpl->assign('dirname', $GLOBALS['moddirname']); |
250 | 250 | |
251 | 251 | if ($category_id || $blog_id || $uid) { |
252 | - $xoopsTpl->assign('link_index', "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . "/index.php\" title=\"" . planet_constant('MD_INDEX') . "\" target=\"_self\">" . planet_constant('MD_INDEX') . '</a>'); |
|
252 | + $xoopsTpl->assign('link_index', "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . "/index.php\" title=\"" . planet_constant('MD_INDEX') . "\" target=\"_self\">" . planet_constant('MD_INDEX') . '</a>'); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | $link_switch = "<a href=\"" |
256 | - . XOOPS_URL |
|
257 | - . '/modules/' |
|
258 | - . $GLOBALS['moddirname'] |
|
259 | - . '/index.php' |
|
260 | - . (empty($category_id) ? '' : '/c' . $category_id) |
|
261 | - . (empty($uid) ? '' : '/u' . $uid) |
|
262 | - . (empty($blog_id) ? '' : '/b' . $blog_id) |
|
263 | - . (empty($list) ? '/l1' : '') |
|
264 | - . "\" title=\"" |
|
265 | - . (empty($list) ? planet_constant('MD_LISTVIEW') : planet_constant('MD_FULLVIEW')) |
|
266 | - . "\">" |
|
267 | - . (empty($list) ? planet_constant('MD_LISTVIEW') : planet_constant('MD_FULLVIEW')) |
|
268 | - . '</a>'; |
|
256 | + . XOOPS_URL |
|
257 | + . '/modules/' |
|
258 | + . $GLOBALS['moddirname'] |
|
259 | + . '/index.php' |
|
260 | + . (empty($category_id) ? '' : '/c' . $category_id) |
|
261 | + . (empty($uid) ? '' : '/u' . $uid) |
|
262 | + . (empty($blog_id) ? '' : '/b' . $blog_id) |
|
263 | + . (empty($list) ? '/l1' : '') |
|
264 | + . "\" title=\"" |
|
265 | + . (empty($list) ? planet_constant('MD_LISTVIEW') : planet_constant('MD_FULLVIEW')) |
|
266 | + . "\">" |
|
267 | + . (empty($list) ? planet_constant('MD_LISTVIEW') : planet_constant('MD_FULLVIEW')) |
|
268 | + . '</a>'; |
|
269 | 269 | $xoopsTpl->assign('link_switch', $link_switch); |
270 | 270 | |
271 | 271 | $link_blogs = "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.blogs.php' . (empty($category_id) ? '' : '/c' . $category_id) . (empty($uid) ? '' : '/u' . $uid) . "\" title=\"" . planet_constant('MD_BLOGS') . "\">" . planet_constant('MD_BLOGS') . '</a>'; |
272 | 272 | $xoopsTpl->assign('link_blogs', $link_blogs); |
273 | 273 | |
274 | 274 | if (empty($uid) && is_object($xoopsUser)) { |
275 | - $xoopsTpl->assign('link_bookmark', "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . URL_DELIMITER . 'u' . $xoopsUser->getVar('uid') . "\" title=\"" . planet_constant('MD_BOOKMARKS') . "\" target=\"_self\">" . planet_constant('MD_BOOKMARKS') . '</a>'); |
|
275 | + $xoopsTpl->assign('link_bookmark', "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . URL_DELIMITER . 'u' . $xoopsUser->getVar('uid') . "\" title=\"" . planet_constant('MD_BOOKMARKS') . "\" target=\"_self\">" . planet_constant('MD_BOOKMARKS') . '</a>'); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | if (1 == $xoopsModuleConfig['newblog_submit'] || is_object($xoopsUser)) { |
279 | - $xoopsTpl->assign('link_submit', "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . "/action.blog.php\" title=\"" . _SUBMIT . "\" target=\"_blank\">" . _SUBMIT . '</a>'); |
|
279 | + $xoopsTpl->assign('link_submit', "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . "/action.blog.php\" title=\"" . _SUBMIT . "\" target=\"_blank\">" . _SUBMIT . '</a>'); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | $xoopsTpl->assign('pagetitle', $xoopsModule->getVar('name') . '::' . planet_constant('MD_ARTICLES')); |
@@ -290,22 +290,22 @@ discard block |
||
290 | 290 | $xoopsTpl->assign('user_level', !is_object($xoopsUser) ? 0 : ($xoopsUser->isAdmin() ? 2 : 1)); |
291 | 291 | if (empty($xoopsModuleConfig['anonymous_rate']) && !is_object($xoopsUser)) { |
292 | 292 | } elseif ($blog_id > 0) { |
293 | - $xoopsTpl->assign('canrate', 1); |
|
293 | + $xoopsTpl->assign('canrate', 1); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | $sort_link = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . (empty($category_id) ? '' : '/c' . $category_id) . (empty($uid) ? '' : '/u' . $uid) . (empty($blog_id) ? '' : '/b' . $blog_id) . (empty($list) ? '' : '/l1'); |
297 | 297 | $valid_sorts = [ |
298 | - 'views' => planet_constant('MD_VIEWS'), |
|
299 | - 'rating' => planet_constant('MD_RATING'), |
|
300 | - 'time' => planet_constant('MD_TIME'), |
|
301 | - 'default' => planet_constant('MD_DEFAULT') |
|
298 | + 'views' => planet_constant('MD_VIEWS'), |
|
299 | + 'rating' => planet_constant('MD_RATING'), |
|
300 | + 'time' => planet_constant('MD_TIME'), |
|
301 | + 'default' => planet_constant('MD_DEFAULT') |
|
302 | 302 | ]; |
303 | 303 | $sortlinks = []; |
304 | 304 | foreach ($valid_sorts as $val => $name) { |
305 | - if ($val == $sort) { |
|
306 | - continue; |
|
307 | - } |
|
308 | - $sortlinks[] = "<a href=\"" . $sort_link . '/' . $val . "\">" . $name . '</a>'; |
|
305 | + if ($val == $sort) { |
|
306 | + continue; |
|
307 | + } |
|
308 | + $sortlinks[] = "<a href=\"" . $sort_link . '/' . $val . "\">" . $name . '</a>'; |
|
309 | 309 | } |
310 | 310 | $xoopsTpl->assign('link_sort', implode(' | ', $sortlinks)); |
311 | 311 | $xoopsTpl->assign('version', $xoopsModule->getVar('version')); |
@@ -314,8 +314,8 @@ discard block |
||
314 | 314 | |
315 | 315 | // for notification |
316 | 316 | if (!empty($blog_id)) { |
317 | - //$_SERVER['REQUEST_URI'] = XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/index.php"; |
|
318 | - $_GET['blog'] = $blog_id; |
|
317 | + //$_SERVER['REQUEST_URI'] = XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/index.php"; |
|
318 | + $_GET['blog'] = $blog_id; |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | require_once __DIR__ . '/footer.php'; |
@@ -24,10 +24,10 @@ discard block |
||
24 | 24 | // URL: https://xoops.org // |
25 | 25 | // Project: Article Project // |
26 | 26 | // ------------------------------------------------------------------------ // |
27 | -include __DIR__ . '/header.php'; |
|
27 | +include __DIR__.'/header.php'; |
|
28 | 28 | |
29 | 29 | if (preg_match("/\/notification_update\.php/i", $_SERVER['REQUEST_URI'], $matches)) { |
30 | - include XOOPS_ROOT_PATH . '/include/notification_update.php'; |
|
30 | + include XOOPS_ROOT_PATH.'/include/notification_update.php'; |
|
31 | 31 | exit(); |
32 | 32 | } |
33 | 33 | |
@@ -37,17 +37,17 @@ discard block |
||
37 | 37 | } |
38 | 38 | |
39 | 39 | /* Start */ |
40 | -$start = (int)(empty($_GET['start']) ? @$args['start'] : $_GET['start']); |
|
40 | +$start = (int) (empty($_GET['start']) ? @$args['start'] : $_GET['start']); |
|
41 | 41 | /* Specified Category */ |
42 | -$category_id = (int)(empty($_GET['category']) ? @$args['category'] : $_GET['category']); |
|
42 | +$category_id = (int) (empty($_GET['category']) ? @$args['category'] : $_GET['category']); |
|
43 | 43 | /* Specified Blog */ |
44 | -$blog_id = (int)(empty($_GET['blog']) ? @$args['blog'] : $_GET['blog']); |
|
44 | +$blog_id = (int) (empty($_GET['blog']) ? @$args['blog'] : $_GET['blog']); |
|
45 | 45 | /* Specified Bookmar(Favorite) UID */ |
46 | -$uid = (int)(empty($_GET['uid']) ? @$args['uid'] : $_GET['uid']); |
|
46 | +$uid = (int) (empty($_GET['uid']) ? @$args['uid'] : $_GET['uid']); |
|
47 | 47 | /* Sort by term */ |
48 | 48 | $sort = empty($_GET['sort']) ? @$args['sort'] : $_GET['sort']; |
49 | 49 | /* Display as list */ |
50 | -$list = (int)(empty($_GET['list']) ? @$args['list'] : $_GET['list']); |
|
50 | +$list = (int) (empty($_GET['list']) ? @$args['list'] : $_GET['list']); |
|
51 | 51 | |
52 | 52 | // restore $_SERVER['REQUEST_URI'] |
53 | 53 | if (!empty($REQUEST_URI_parsed)) { |
@@ -55,28 +55,28 @@ discard block |
||
55 | 55 | $_args = ['start', 'sort', 'uid', 'list']; |
56 | 56 | foreach ($_args as $arg) { |
57 | 57 | if (!empty(${$arg})) { |
58 | - $args_REQUEST_URI[] = $arg . '=' . ${$arg}; |
|
58 | + $args_REQUEST_URI[] = $arg.'='.${$arg}; |
|
59 | 59 | } |
60 | 60 | } |
61 | 61 | if (!empty($blog_id)) { |
62 | - $args_REQUEST_URI[] = 'blog=' . $blog_id; |
|
62 | + $args_REQUEST_URI[] = 'blog='.$blog_id; |
|
63 | 63 | } |
64 | 64 | if (!empty($category_id)) { |
65 | - $args_REQUEST_URI[] = 'category=' . $category_id; |
|
65 | + $args_REQUEST_URI[] = 'category='.$category_id; |
|
66 | 66 | } |
67 | - $_SERVER['REQUEST_URI'] = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . (empty($args_REQUEST_URI) ? '' : '?' . implode('&', $args_REQUEST_URI)); |
|
67 | + $_SERVER['REQUEST_URI'] = XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/index.php'.(empty($args_REQUEST_URI) ? '' : '?'.implode('&', $args_REQUEST_URI)); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | $GLOBALS['xoopsOption']['template_main'] = PlanetUtility::planetGetTemplate('index'); |
71 | 71 | $xoops_module_header = ' |
72 | - <link rel="alternate" type="application/rss+xml" title="' . $xoopsModule->getVar('name') . ' rss" href="' . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/xml.php".URL_DELIMITER."rss/c' . $category_id . '/b' . $blog_id . '/u' . $uid . '"> |
|
73 | - <link rel="alternate" type="application/rss+xml" title="' . $xoopsModule->getVar('name') . ' rdf" href="' . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/xml.php".URL_DELIMITER."rdf/c' . $category_id . '/b' . $blog_id . '/u' . $uid . '"> |
|
74 | - <link rel="alternate" type="application/atom+xml" title="' . $xoopsModule->getVar('name') . ' atom" href="' . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/xml.php".URL_DELIMITER."atom/c' . $category_id . '/b' . $blog_id . '/u' . $uid . '"> |
|
72 | + <link rel="alternate" type="application/rss+xml" title="' . $xoopsModule->getVar('name').' rss" href="'.XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/xml.php".URL_DELIMITER."rss/c'.$category_id.'/b'.$blog_id.'/u'.$uid.'"> |
|
73 | + <link rel="alternate" type="application/rss+xml" title="' . $xoopsModule->getVar('name').' rdf" href="'.XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/xml.php".URL_DELIMITER."rdf/c'.$category_id.'/b'.$blog_id.'/u'.$uid.'"> |
|
74 | + <link rel="alternate" type="application/atom+xml" title="' . $xoopsModule->getVar('name').' atom" href="'.XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/xml.php".URL_DELIMITER."atom/c'.$category_id.'/b'.$blog_id.'/u'.$uid.'"> |
|
75 | 75 | '; |
76 | 76 | |
77 | 77 | $xoopsOption['xoops_module_header'] = $xoops_module_header; |
78 | -require_once XOOPS_ROOT_PATH . '/header.php'; |
|
79 | -include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/include/vars.php'; |
|
78 | +require_once XOOPS_ROOT_PATH.'/header.php'; |
|
79 | +include XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/include/vars.php'; |
|
80 | 80 | |
81 | 81 | // Following part will not be executed after cache |
82 | 82 | $categoryHandler = xoops_getModuleHandler('category', $GLOBALS['moddirname']); |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | $criteria = new CriteriaCompo(); |
89 | 89 | $article_prefix = ''; |
90 | 90 | /* Specific category */ |
91 | -if ($category_id > 0) { |
|
91 | +if ($category_id>0) { |
|
92 | 92 | $category_obj = $categoryHandler->get($category_id); |
93 | 93 | $criteria->add(new Criteria('bc.cat_id', $category_id)); |
94 | 94 | $uid = 0; |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | $article_prefix = 'a.'; |
99 | 99 | } |
100 | 100 | /* Specific blog */ |
101 | -if ($blog_id > 0) { |
|
101 | +if ($blog_id>0) { |
|
102 | 102 | $blog_obj = $blogHandler->get($blog_id); |
103 | 103 | if ($blog_obj->getVar('blog_status') |
104 | 104 | || (is_object($xoopsUser) |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | $article_prefix = ''; |
126 | 126 | } |
127 | 127 | /* User bookmarks(favorites) */ |
128 | -if ($uid > 0) { |
|
128 | +if ($uid>0) { |
|
129 | 129 | $criteria->add(new Criteria('bm.bm_uid', $uid)); |
130 | 130 | $category_id = 0; |
131 | 131 | $blog_id = 0; |
@@ -144,13 +144,13 @@ discard block |
||
144 | 144 | $sort = empty($sort) ? 'time' : $sort; |
145 | 145 | switch ($sort) { |
146 | 146 | case 'views': |
147 | - $sortby = $article_prefix . 'art_views'; |
|
147 | + $sortby = $article_prefix.'art_views'; |
|
148 | 148 | break; |
149 | 149 | case 'rating': |
150 | - $sortby = $article_prefix . 'art_rating'; |
|
150 | + $sortby = $article_prefix.'art_rating'; |
|
151 | 151 | break; |
152 | 152 | case 'time': |
153 | - $sortby = $article_prefix . 'art_time'; |
|
153 | + $sortby = $article_prefix.'art_time'; |
|
154 | 154 | break; |
155 | 155 | case 'default': |
156 | 156 | default: |
@@ -163,9 +163,9 @@ discard block |
||
163 | 163 | $criteria->setLimit($limit); |
164 | 164 | |
165 | 165 | $tags = empty($list) ? '' : [ |
166 | - $article_prefix . 'art_title', |
|
167 | - $article_prefix . 'blog_id', |
|
168 | - $article_prefix . 'art_time' |
|
166 | + $article_prefix.'art_title', |
|
167 | + $article_prefix.'blog_id', |
|
168 | + $article_prefix.'art_time' |
|
169 | 169 | ]; |
170 | 170 | switch ($query_type) { |
171 | 171 | case 'category': |
@@ -184,12 +184,12 @@ discard block |
||
184 | 184 | |
185 | 185 | if (!empty($blog_data)) { |
186 | 186 | $blogs[$blog_data['id']] = $blog_data['title']; |
187 | -} else { |
|
187 | +}else { |
|
188 | 188 | $blog_array = []; |
189 | 189 | foreach (array_keys($articles_obj) as $id) { |
190 | 190 | $blog_array[$articles_obj[$id]->getVar('blog_id')] = 1; |
191 | 191 | } |
192 | - $criteria_blog = new Criteria('blog_id', '(' . implode(',', array_keys($blog_array)) . ')', 'IN'); |
|
192 | + $criteria_blog = new Criteria('blog_id', '('.implode(',', array_keys($blog_array)).')', 'IN'); |
|
193 | 193 | $blogs = $blogHandler->getList($criteria_blog); |
194 | 194 | } |
195 | 195 | |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | ]); |
216 | 216 | if (!empty($xoopsModuleConfig['display_summary'])) { |
217 | 217 | $_article['content'] = $articles_obj[$id]->getSummary(); |
218 | - } else { |
|
218 | + }else { |
|
219 | 219 | $_article['content'] = $articles_obj[$id]->getVar('art_content'); |
220 | 220 | } |
221 | 221 | } |
@@ -224,24 +224,24 @@ discard block |
||
224 | 224 | } |
225 | 225 | unset($articles_obj); |
226 | 226 | |
227 | -if ($count_article > $limit) { |
|
228 | - include XOOPS_ROOT_PATH . '/class/pagenav.php'; |
|
227 | +if ($count_article>$limit) { |
|
228 | + include XOOPS_ROOT_PATH.'/class/pagenav.php'; |
|
229 | 229 | $start_link = []; |
230 | 230 | if ($sort) { |
231 | - $start_link[] = 'sort=' . $sort; |
|
231 | + $start_link[] = 'sort='.$sort; |
|
232 | 232 | } |
233 | 233 | if ($category_id) { |
234 | - $start_link[] = 'category=' . $category_id; |
|
234 | + $start_link[] = 'category='.$category_id; |
|
235 | 235 | } |
236 | 236 | if ($blog_id) { |
237 | - $start_link[] = 'blog=' . $blog_id; |
|
237 | + $start_link[] = 'blog='.$blog_id; |
|
238 | 238 | } |
239 | 239 | if ($list) { |
240 | - $start_link[] = 'list=' . $list; |
|
240 | + $start_link[] = 'list='.$list; |
|
241 | 241 | } |
242 | 242 | $nav = new XoopsPageNav($count_article, $limit, $start, 'start', implode('&', $start_link)); |
243 | 243 | $pagenav = $nav->renderNav(4); |
244 | -} else { |
|
244 | +}else { |
|
245 | 245 | $pagenav = ''; |
246 | 246 | } |
247 | 247 | |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | $xoopsTpl->assign('dirname', $GLOBALS['moddirname']); |
250 | 250 | |
251 | 251 | if ($category_id || $blog_id || $uid) { |
252 | - $xoopsTpl->assign('link_index', "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . "/index.php\" title=\"" . planet_constant('MD_INDEX') . "\" target=\"_self\">" . planet_constant('MD_INDEX') . '</a>'); |
|
252 | + $xoopsTpl->assign('link_index', "<a href=\"".XOOPS_URL.'/modules/'.$GLOBALS['moddirname']."/index.php\" title=\"".planet_constant('MD_INDEX')."\" target=\"_self\">".planet_constant('MD_INDEX').'</a>'); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | $link_switch = "<a href=\"" |
@@ -257,9 +257,9 @@ discard block |
||
257 | 257 | . '/modules/' |
258 | 258 | . $GLOBALS['moddirname'] |
259 | 259 | . '/index.php' |
260 | - . (empty($category_id) ? '' : '/c' . $category_id) |
|
261 | - . (empty($uid) ? '' : '/u' . $uid) |
|
262 | - . (empty($blog_id) ? '' : '/b' . $blog_id) |
|
260 | + . (empty($category_id) ? '' : '/c'.$category_id) |
|
261 | + . (empty($uid) ? '' : '/u'.$uid) |
|
262 | + . (empty($blog_id) ? '' : '/b'.$blog_id) |
|
263 | 263 | . (empty($list) ? '/l1' : '') |
264 | 264 | . "\" title=\"" |
265 | 265 | . (empty($list) ? planet_constant('MD_LISTVIEW') : planet_constant('MD_FULLVIEW')) |
@@ -268,18 +268,18 @@ discard block |
||
268 | 268 | . '</a>'; |
269 | 269 | $xoopsTpl->assign('link_switch', $link_switch); |
270 | 270 | |
271 | -$link_blogs = "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.blogs.php' . (empty($category_id) ? '' : '/c' . $category_id) . (empty($uid) ? '' : '/u' . $uid) . "\" title=\"" . planet_constant('MD_BLOGS') . "\">" . planet_constant('MD_BLOGS') . '</a>'; |
|
271 | +$link_blogs = "<a href=\"".XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/view.blogs.php'.(empty($category_id) ? '' : '/c'.$category_id).(empty($uid) ? '' : '/u'.$uid)."\" title=\"".planet_constant('MD_BLOGS')."\">".planet_constant('MD_BLOGS').'</a>'; |
|
272 | 272 | $xoopsTpl->assign('link_blogs', $link_blogs); |
273 | 273 | |
274 | 274 | if (empty($uid) && is_object($xoopsUser)) { |
275 | - $xoopsTpl->assign('link_bookmark', "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . URL_DELIMITER . 'u' . $xoopsUser->getVar('uid') . "\" title=\"" . planet_constant('MD_BOOKMARKS') . "\" target=\"_self\">" . planet_constant('MD_BOOKMARKS') . '</a>'); |
|
275 | + $xoopsTpl->assign('link_bookmark', "<a href=\"".XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/index.php'.URL_DELIMITER.'u'.$xoopsUser->getVar('uid')."\" title=\"".planet_constant('MD_BOOKMARKS')."\" target=\"_self\">".planet_constant('MD_BOOKMARKS').'</a>'); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | if (1 == $xoopsModuleConfig['newblog_submit'] || is_object($xoopsUser)) { |
279 | - $xoopsTpl->assign('link_submit', "<a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . "/action.blog.php\" title=\"" . _SUBMIT . "\" target=\"_blank\">" . _SUBMIT . '</a>'); |
|
279 | + $xoopsTpl->assign('link_submit', "<a href=\"".XOOPS_URL.'/modules/'.$GLOBALS['moddirname']."/action.blog.php\" title=\""._SUBMIT."\" target=\"_blank\">"._SUBMIT.'</a>'); |
|
280 | 280 | } |
281 | 281 | |
282 | -$xoopsTpl->assign('pagetitle', $xoopsModule->getVar('name') . '::' . planet_constant('MD_ARTICLES')); |
|
282 | +$xoopsTpl->assign('pagetitle', $xoopsModule->getVar('name').'::'.planet_constant('MD_ARTICLES')); |
|
283 | 283 | $xoopsTpl->assign('category', @$category_data); |
284 | 284 | $xoopsTpl->assign('blog', @$blog_data); |
285 | 285 | $xoopsTpl->assign('user', @$user_data); |
@@ -289,23 +289,23 @@ discard block |
||
289 | 289 | |
290 | 290 | $xoopsTpl->assign('user_level', !is_object($xoopsUser) ? 0 : ($xoopsUser->isAdmin() ? 2 : 1)); |
291 | 291 | if (empty($xoopsModuleConfig['anonymous_rate']) && !is_object($xoopsUser)) { |
292 | -} elseif ($blog_id > 0) { |
|
292 | +} elseif ($blog_id>0) { |
|
293 | 293 | $xoopsTpl->assign('canrate', 1); |
294 | 294 | } |
295 | 295 | |
296 | -$sort_link = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . (empty($category_id) ? '' : '/c' . $category_id) . (empty($uid) ? '' : '/u' . $uid) . (empty($blog_id) ? '' : '/b' . $blog_id) . (empty($list) ? '' : '/l1'); |
|
296 | +$sort_link = XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/index.php'.(empty($category_id) ? '' : '/c'.$category_id).(empty($uid) ? '' : '/u'.$uid).(empty($blog_id) ? '' : '/b'.$blog_id).(empty($list) ? '' : '/l1'); |
|
297 | 297 | $valid_sorts = [ |
298 | 298 | 'views' => planet_constant('MD_VIEWS'), |
299 | 299 | 'rating' => planet_constant('MD_RATING'), |
300 | 300 | 'time' => planet_constant('MD_TIME'), |
301 | 301 | 'default' => planet_constant('MD_DEFAULT') |
302 | 302 | ]; |
303 | -$sortlinks = []; |
|
303 | +$sortlinks = []; |
|
304 | 304 | foreach ($valid_sorts as $val => $name) { |
305 | 305 | if ($val == $sort) { |
306 | 306 | continue; |
307 | 307 | } |
308 | - $sortlinks[] = "<a href=\"" . $sort_link . '/' . $val . "\">" . $name . '</a>'; |
|
308 | + $sortlinks[] = "<a href=\"".$sort_link.'/'.$val."\">".$name.'</a>'; |
|
309 | 309 | } |
310 | 310 | $xoopsTpl->assign('link_sort', implode(' | ', $sortlinks)); |
311 | 311 | $xoopsTpl->assign('version', $xoopsModule->getVar('version')); |
@@ -318,4 +318,4 @@ discard block |
||
318 | 318 | $_GET['blog'] = $blog_id; |
319 | 319 | } |
320 | 320 | |
321 | -require_once __DIR__ . '/footer.php'; |
|
321 | +require_once __DIR__.'/footer.php'; |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | $configHandler = xoops_getHandler('config'); |
33 | 33 | $xoopsConfigSearch = $configHandler->getConfigsByCat(XOOPS_CONF_SEARCH); |
34 | 34 | if (empty($xoopsConfigSearch['enable_search'])) { |
35 | - redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php', 2, planet_constant('MD_NOACCESS')); |
|
35 | + redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php', 2, planet_constant('MD_NOACCESS')); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | $xoopsConfig['module_cache'][$xoopsModule->getVar('mid')] = 0; |
@@ -50,93 +50,93 @@ discard block |
||
50 | 50 | $blog = Request::getInt('blog', Request::getInt('blog', 0, 'GET'), 'POST');//(int)(isset($_POST['blog']) ? $_POST['blog'] : (isset($_GET['blog']) ? $_GET['blog'] : null)); |
51 | 51 | $uid = Request::getInt('uid', Request::getInt('uid', 0, 'GET'), 'POST');//(int)(isset($_POST['uid']) ? $_POST['uid'] : (isset($_GET['uid']) ? $_GET['uid'] : null)); |
52 | 52 | $searchin = Request::getArray( |
53 | - 'searchin', |
|
54 | - 0 !== count(Request::getArray('searchin', [], 'GET')) ? explode('|', Request::getArray('searchin', [], 'GET')) : [], |
|
55 | - 'POST' |
|
53 | + 'searchin', |
|
54 | + 0 !== count(Request::getArray('searchin', [], 'GET')) ? explode('|', Request::getArray('searchin', [], 'GET')) : [], |
|
55 | + 'POST' |
|
56 | 56 | ); //isset($_POST['searchin']) ? $_POST['searchin'] : (isset($_GET['searchin']) ? explode('|', $_GET['searchin']) : array()); |
57 | 57 | $sortby = Request::getString('sortby', Request::getString('sortby', null, 'GET'), 'POST');//isset($_POST['sortby']) ? $_POST['sortby'] : (isset($_GET['sortby']) ? $_GET['sortby'] : null); |
58 | 58 | $term = Request::getString('term', Request::getString('term', '', 'GET'), 'POST');//isset($_POST['term']) ? $_POST['term'] : (isset($_GET['term']) ? $_GET['term'] : ''); |
59 | 59 | |
60 | 60 | $andor = in_array(strtoupper($andor), ['OR', 'AND', 'EXACT']) ? strtoupper($andor) : 'OR'; |
61 | 61 | $sortby = in_array(strtolower($sortby), [ |
62 | - 'a.art_id desc', |
|
63 | - 'a.art_time desc', |
|
64 | - 'a.art_title', |
|
65 | - 'a.blog_id', |
|
66 | - 'b.blog_id', |
|
67 | - 'b.blog_feed', |
|
68 | - 'b.blog_title', |
|
69 | - 'b.blog_time' |
|
62 | + 'a.art_id desc', |
|
63 | + 'a.art_time desc', |
|
64 | + 'a.art_title', |
|
65 | + 'a.blog_id', |
|
66 | + 'b.blog_id', |
|
67 | + 'b.blog_feed', |
|
68 | + 'b.blog_title', |
|
69 | + 'b.blog_time' |
|
70 | 70 | ]) ? strtolower($sortby) : ''; |
71 | 71 | |
72 | 72 | if (!(empty(Request::getString('submit', '', 'POST')) && empty(Request::getString('term', '', 'GET')))) { |
73 | - $next_search['category'] = $category; |
|
74 | - $next_search['blog'] = $blog; |
|
75 | - $next_search['uid'] = $uid; |
|
76 | - $next_search['andor'] = $andor; |
|
73 | + $next_search['category'] = $category; |
|
74 | + $next_search['blog'] = $blog; |
|
75 | + $next_search['uid'] = $uid; |
|
76 | + $next_search['andor'] = $andor; |
|
77 | 77 | |
78 | - $next_search['term'] = $term; |
|
79 | - $query = trim($term); |
|
78 | + $next_search['term'] = $term; |
|
79 | + $query = trim($term); |
|
80 | 80 | |
81 | - if ('EXACT' !== $andor) { |
|
82 | - $ignored_queries = []; // holds kewords that are shorter than allowed minmum length |
|
83 | - $temp_queries = preg_split("/[\s,]+/", $query); |
|
84 | - foreach ($temp_queries as $q) { |
|
85 | - $q = trim($q); |
|
86 | - if (strlen($q) >= $xoopsConfigSearch['keyword_min']) { |
|
87 | - $queries[] = $myts->addSlashes($q); |
|
88 | - } else { |
|
89 | - $ignored_queries[] = $myts->addSlashes($q); |
|
90 | - } |
|
91 | - } |
|
92 | - if (0 == count($queries)) { |
|
93 | - redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/search.php', 2, sprintf(_SR_KEYTOOSHORT, $xoopsConfigSearch['keyword_min'])); |
|
94 | - } |
|
95 | - } else { |
|
96 | - if (strlen($query) < $xoopsConfigSearch['keyword_min']) { |
|
97 | - redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/search.php', 2, sprintf(_SR_KEYTOOSHORT, $xoopsConfigSearch['keyword_min'])); |
|
98 | - } |
|
99 | - $queries = [$myts->addSlashes($query)]; |
|
100 | - } |
|
81 | + if ('EXACT' !== $andor) { |
|
82 | + $ignored_queries = []; // holds kewords that are shorter than allowed minmum length |
|
83 | + $temp_queries = preg_split("/[\s,]+/", $query); |
|
84 | + foreach ($temp_queries as $q) { |
|
85 | + $q = trim($q); |
|
86 | + if (strlen($q) >= $xoopsConfigSearch['keyword_min']) { |
|
87 | + $queries[] = $myts->addSlashes($q); |
|
88 | + } else { |
|
89 | + $ignored_queries[] = $myts->addSlashes($q); |
|
90 | + } |
|
91 | + } |
|
92 | + if (0 == count($queries)) { |
|
93 | + redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/search.php', 2, sprintf(_SR_KEYTOOSHORT, $xoopsConfigSearch['keyword_min'])); |
|
94 | + } |
|
95 | + } else { |
|
96 | + if (strlen($query) < $xoopsConfigSearch['keyword_min']) { |
|
97 | + redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/search.php', 2, sprintf(_SR_KEYTOOSHORT, $xoopsConfigSearch['keyword_min'])); |
|
98 | + } |
|
99 | + $queries = [$myts->addSlashes($query)]; |
|
100 | + } |
|
101 | 101 | |
102 | - $next_search['sortby'] = $sortby; |
|
103 | - $next_search['searchin'] = implode('|', $searchin); |
|
102 | + $next_search['sortby'] = $sortby; |
|
103 | + $next_search['searchin'] = implode('|', $searchin); |
|
104 | 104 | |
105 | - /* To be added: year-month |
|
105 | + /* To be added: year-month |
|
106 | 106 | * see view.archive.php |
107 | 107 | */ |
108 | - if (!empty($time)) { |
|
109 | - $extra = ''; |
|
110 | - } else { |
|
111 | - $extra = ''; |
|
112 | - } |
|
108 | + if (!empty($time)) { |
|
109 | + $extra = ''; |
|
110 | + } else { |
|
111 | + $extra = ''; |
|
112 | + } |
|
113 | 113 | |
114 | - $results = planet_search($queries, $andor, $limit, $start, $uid, $category, $blog, $sortby, $searchin, $extra); |
|
114 | + $results = planet_search($queries, $andor, $limit, $start, $uid, $category, $blog, $sortby, $searchin, $extra); |
|
115 | 115 | |
116 | - /* |
|
116 | + /* |
|
117 | 117 | if ( count($results) < 1 ) { |
118 | 118 | redirect_header("javascript:history.go(-1);", 2, _SR_NOMATCH); |
119 | 119 | } else |
120 | 120 | */ |
121 | - { |
|
122 | - $xoopsTpl->assign('results', $results); |
|
121 | + { |
|
122 | + $xoopsTpl->assign('results', $results); |
|
123 | 123 | |
124 | - if (count($next_search) > 0) { |
|
125 | - $items = []; |
|
126 | - foreach ($next_search as $para => $val) { |
|
127 | - if (!empty($val)) { |
|
128 | - $items[] = "$para=$val"; |
|
129 | - } |
|
130 | - } |
|
131 | - if (count($items) > 0) { |
|
132 | - $paras = implode('&', $items); |
|
133 | - } |
|
134 | - unset($next_search); |
|
135 | - unset($items); |
|
136 | - } |
|
137 | - $search_url = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/search.php?' . $paras; |
|
124 | + if (count($next_search) > 0) { |
|
125 | + $items = []; |
|
126 | + foreach ($next_search as $para => $val) { |
|
127 | + if (!empty($val)) { |
|
128 | + $items[] = "$para=$val"; |
|
129 | + } |
|
130 | + } |
|
131 | + if (count($items) > 0) { |
|
132 | + $paras = implode('&', $items); |
|
133 | + } |
|
134 | + unset($next_search); |
|
135 | + unset($items); |
|
136 | + } |
|
137 | + $search_url = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/search.php?' . $paras; |
|
138 | 138 | |
139 | - /* |
|
139 | + /* |
|
140 | 140 | $next_results =& planet_search($queries, $andor, 1, $start + $limit, $uid, $category, $sortby, $searchin, $extra); |
141 | 141 | $next_count = count($next_results); |
142 | 142 | $has_next = false; |
@@ -145,41 +145,41 @@ discard block |
||
145 | 145 | } |
146 | 146 | if (false != $has_next) |
147 | 147 | */ |
148 | - if (count($results)) { |
|
149 | - $next = $start + $limit; |
|
150 | - $queries = implode(',', $queries); |
|
151 | - $search_url_next = $search_url . "&start=$next"; |
|
152 | - $search_next = "<a href=\"" . htmlspecialchars($search_url_next) . "\">" . _SR_NEXT . '</a>'; |
|
153 | - $xoopsTpl->assign('search_next', $search_next); |
|
154 | - } |
|
155 | - if ($start > 0) { |
|
156 | - $prev = $start - $limit; |
|
157 | - $search_url_prev = $search_url . "&start=$prev"; |
|
158 | - $search_prev = "<a href=\"" . htmlspecialchars($search_url_prev) . "\">" . _SR_PREVIOUS . '</a>'; |
|
159 | - $xoopsTpl->assign('search_prev', $search_prev); |
|
160 | - } |
|
161 | - } |
|
148 | + if (count($results)) { |
|
149 | + $next = $start + $limit; |
|
150 | + $queries = implode(',', $queries); |
|
151 | + $search_url_next = $search_url . "&start=$next"; |
|
152 | + $search_next = "<a href=\"" . htmlspecialchars($search_url_next) . "\">" . _SR_NEXT . '</a>'; |
|
153 | + $xoopsTpl->assign('search_next', $search_next); |
|
154 | + } |
|
155 | + if ($start > 0) { |
|
156 | + $prev = $start - $limit; |
|
157 | + $search_url_prev = $search_url . "&start=$prev"; |
|
158 | + $search_prev = "<a href=\"" . htmlspecialchars($search_url_prev) . "\">" . _SR_PREVIOUS . '</a>'; |
|
159 | + $xoopsTpl->assign('search_prev', $search_prev); |
|
160 | + } |
|
161 | + } |
|
162 | 162 | |
163 | - unset($results); |
|
164 | - $search_info = _SR_KEYWORDS . ': ' . $myts->htmlSpecialChars($term); |
|
165 | - $xoopsTpl->assign('search_info', $search_info); |
|
163 | + unset($results); |
|
164 | + $search_info = _SR_KEYWORDS . ': ' . $myts->htmlSpecialChars($term); |
|
165 | + $xoopsTpl->assign('search_info', $search_info); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /* type */ |
169 | 169 | $type_select = "<select name=\"andor\">"; |
170 | 170 | $type_select .= "<option value=\"OR\""; |
171 | 171 | if ('OR' === $andor) { |
172 | - $type_select .= " selected=\"selected\""; |
|
172 | + $type_select .= " selected=\"selected\""; |
|
173 | 173 | } |
174 | 174 | $type_select .= '>' . _SR_ANY . '</option>'; |
175 | 175 | $type_select .= "<option value=\"AND\""; |
176 | 176 | if ('AND' === $andor) { |
177 | - $type_select .= " selected=\"selected\""; |
|
177 | + $type_select .= " selected=\"selected\""; |
|
178 | 178 | } |
179 | 179 | $type_select .= '>' . _SR_ALL . '</option>'; |
180 | 180 | $type_select .= "<option value=\"EXACT\""; |
181 | 181 | if ('exact' === $andor) { |
182 | - $type_select .= " selected=\"selected\""; |
|
182 | + $type_select .= " selected=\"selected\""; |
|
183 | 183 | } |
184 | 184 | $type_select .= '>' . _SR_EXACT . '</option>'; |
185 | 185 | $type_select .= '</select>'; |
@@ -188,32 +188,32 @@ discard block |
||
188 | 188 | $searchin_select = ''; |
189 | 189 | $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"title\""; |
190 | 190 | if (in_array('title', $searchin)) { |
191 | - $searchin_select .= ' checked'; |
|
191 | + $searchin_select .= ' checked'; |
|
192 | 192 | } |
193 | 193 | $searchin_select .= '>' . planet_constant('MD_TITLE') . ' '; |
194 | 194 | $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"text\""; |
195 | 195 | if (in_array('text', $searchin)) { |
196 | - $searchin_select .= ' checked'; |
|
196 | + $searchin_select .= ' checked'; |
|
197 | 197 | } |
198 | 198 | $searchin_select .= '>' . planet_constant('MD_BODY') . ' || '; |
199 | 199 | $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"blog\""; |
200 | 200 | if (in_array('blog', $searchin)) { |
201 | - $searchin_select .= ' checked'; |
|
201 | + $searchin_select .= ' checked'; |
|
202 | 202 | } |
203 | 203 | $searchin_select .= '>' . planet_constant('MD_BLOG') . ' '; |
204 | 204 | $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"feed\""; |
205 | 205 | if (in_array('feed', $searchin)) { |
206 | - $searchin_select .= ' checked'; |
|
206 | + $searchin_select .= ' checked'; |
|
207 | 207 | } |
208 | 208 | $searchin_select .= '>' . planet_constant('MD_FEED') . ' '; |
209 | 209 | $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"desc\""; |
210 | 210 | if (in_array('desc', $searchin)) { |
211 | - $searchin_select .= ' checked'; |
|
211 | + $searchin_select .= ' checked'; |
|
212 | 212 | } |
213 | 213 | $searchin_select .= '>' . planet_constant('MD_DESC') . ' '; |
214 | 214 | $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"all\""; |
215 | 215 | if (empty($searchin)) { |
216 | - $searchin_select .= ' checked'; |
|
216 | + $searchin_select .= ' checked'; |
|
217 | 217 | } |
218 | 218 | $searchin_select .= '>' . _ALL . ' '; |
219 | 219 | |
@@ -221,28 +221,28 @@ discard block |
||
221 | 221 | $sortby_select = "<select name=\"sortby\">"; |
222 | 222 | $sortby_select .= "<option value=\"\""; |
223 | 223 | if (empty($sortby)) { |
224 | - $sortby_select .= " selected=\"selected\""; |
|
224 | + $sortby_select .= " selected=\"selected\""; |
|
225 | 225 | } |
226 | 226 | $sortby_select .= '>' . _NONE . '</option>'; |
227 | 227 | $sortby_select .= "<option value=\"a.art_time\""; |
228 | 228 | if ('a.art_time' === $sortby) { |
229 | - $sortby_select .= " selected=\"selected\""; |
|
229 | + $sortby_select .= " selected=\"selected\""; |
|
230 | 230 | } |
231 | 231 | $sortby_select .= '>' . planet_constant('MD_TIME') . '</option>'; |
232 | 232 | $sortby_select .= "<option value=\"a.art_title\""; |
233 | 233 | if ('a.art_title' === $sortby) { |
234 | - $sortby_select .= " selected=\"selected\""; |
|
234 | + $sortby_select .= " selected=\"selected\""; |
|
235 | 235 | } |
236 | 236 | $sortby_select .= '>' . planet_constant('MD_TITLE') . '</option>'; |
237 | 237 | $sortby_select .= "<option value=\"\"> ---- </option>"; |
238 | 238 | $sortby_select .= "<option value=\"a.blog_title\""; |
239 | 239 | if ('a.blog_title' === $sortby) { |
240 | - $sortby_select .= " selected=\"selected\""; |
|
240 | + $sortby_select .= " selected=\"selected\""; |
|
241 | 241 | } |
242 | 242 | $sortby_select .= '>' . planet_constant('MD_BLOG') . '</option>'; |
243 | 243 | $sortby_select .= "<option value=\"a.blog_time\""; |
244 | 244 | if ('b.blog_time' === $sortby) { |
245 | - $sortby_select .= " selected=\"selected\""; |
|
245 | + $sortby_select .= " selected=\"selected\""; |
|
246 | 246 | } |
247 | 247 | $sortby_select .= '>' . planet_constant('MD_UPDATE') . '</option>'; |
248 | 248 | $sortby_select .= '</select>'; |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | $xoopsTpl->assign('uid', $uid); |
260 | 260 | |
261 | 261 | if ($xoopsConfigSearch['keyword_min'] > 0) { |
262 | - $xoopsTpl->assign('search_rule', sprintf(_SR_KEYIGNORE, $xoopsConfigSearch['keyword_min'])); |
|
262 | + $xoopsTpl->assign('search_rule', sprintf(_SR_KEYIGNORE, $xoopsConfigSearch['keyword_min'])); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | include XOOPS_ROOT_PATH . '/footer.php'; |
@@ -27,35 +27,35 @@ discard block |
||
27 | 27 | use Xmf\Request; |
28 | 28 | |
29 | 29 | $xoopsOption['pagetype'] = 'search'; |
30 | -include __DIR__ . '/header.php'; |
|
30 | +include __DIR__.'/header.php'; |
|
31 | 31 | $xoopsModule->loadLanguage('main'); |
32 | 32 | $configHandler = xoops_getHandler('config'); |
33 | 33 | $xoopsConfigSearch = $configHandler->getConfigsByCat(XOOPS_CONF_SEARCH); |
34 | 34 | if (empty($xoopsConfigSearch['enable_search'])) { |
35 | - redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php', 2, planet_constant('MD_NOACCESS')); |
|
35 | + redirect_header(XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/index.php', 2, planet_constant('MD_NOACCESS')); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | $xoopsConfig['module_cache'][$xoopsModule->getVar('mid')] = 0; |
39 | 39 | $xoopsOption['template_main'] = PlanetUtility::planetGetTemplate('search'); |
40 | -include XOOPS_ROOT_PATH . '/header.php'; |
|
41 | -include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/include/vars.php'; |
|
40 | +include XOOPS_ROOT_PATH.'/header.php'; |
|
41 | +include XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/include/vars.php'; |
|
42 | 42 | |
43 | -require_once XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/include/search.inc.php'; |
|
43 | +require_once XOOPS_ROOT_PATH.'/modules/'.$GLOBALS['moddirname'].'/include/search.inc.php'; |
|
44 | 44 | $limit = $xoopsModuleConfig['articles_perpage']; |
45 | 45 | |
46 | 46 | $queries = []; |
47 | -$andor = Request::getString('andor', Request::getString('andor', '', 'GET'), 'POST');//isset($_POST['andor']) ? $_POST['andor'] : (isset($_GET['andor']) ? $_GET['andor'] : ''); |
|
48 | -$start = Request::getInt('start', 0, 'GET');//isset($_GET['start']) ? $_GET['start'] : 0; |
|
47 | +$andor = Request::getString('andor', Request::getString('andor', '', 'GET'), 'POST'); //isset($_POST['andor']) ? $_POST['andor'] : (isset($_GET['andor']) ? $_GET['andor'] : ''); |
|
48 | +$start = Request::getInt('start', 0, 'GET'); //isset($_GET['start']) ? $_GET['start'] : 0; |
|
49 | 49 | $category = Request::getInt('category', Request::getInt('category', 0, 'GET'), 'POST'); //(int)(isset($_POST['category']) ? $_POST['category'] : (isset($_GET['category']) ? $_GET['category'] : null)); |
50 | -$blog = Request::getInt('blog', Request::getInt('blog', 0, 'GET'), 'POST');//(int)(isset($_POST['blog']) ? $_POST['blog'] : (isset($_GET['blog']) ? $_GET['blog'] : null)); |
|
51 | -$uid = Request::getInt('uid', Request::getInt('uid', 0, 'GET'), 'POST');//(int)(isset($_POST['uid']) ? $_POST['uid'] : (isset($_GET['uid']) ? $_GET['uid'] : null)); |
|
50 | +$blog = Request::getInt('blog', Request::getInt('blog', 0, 'GET'), 'POST'); //(int)(isset($_POST['blog']) ? $_POST['blog'] : (isset($_GET['blog']) ? $_GET['blog'] : null)); |
|
51 | +$uid = Request::getInt('uid', Request::getInt('uid', 0, 'GET'), 'POST'); //(int)(isset($_POST['uid']) ? $_POST['uid'] : (isset($_GET['uid']) ? $_GET['uid'] : null)); |
|
52 | 52 | $searchin = Request::getArray( |
53 | 53 | 'searchin', |
54 | 54 | 0 !== count(Request::getArray('searchin', [], 'GET')) ? explode('|', Request::getArray('searchin', [], 'GET')) : [], |
55 | 55 | 'POST' |
56 | 56 | ); //isset($_POST['searchin']) ? $_POST['searchin'] : (isset($_GET['searchin']) ? explode('|', $_GET['searchin']) : array()); |
57 | -$sortby = Request::getString('sortby', Request::getString('sortby', null, 'GET'), 'POST');//isset($_POST['sortby']) ? $_POST['sortby'] : (isset($_GET['sortby']) ? $_GET['sortby'] : null); |
|
58 | -$term = Request::getString('term', Request::getString('term', '', 'GET'), 'POST');//isset($_POST['term']) ? $_POST['term'] : (isset($_GET['term']) ? $_GET['term'] : ''); |
|
57 | +$sortby = Request::getString('sortby', Request::getString('sortby', null, 'GET'), 'POST'); //isset($_POST['sortby']) ? $_POST['sortby'] : (isset($_GET['sortby']) ? $_GET['sortby'] : null); |
|
58 | +$term = Request::getString('term', Request::getString('term', '', 'GET'), 'POST'); //isset($_POST['term']) ? $_POST['term'] : (isset($_GET['term']) ? $_GET['term'] : ''); |
|
59 | 59 | |
60 | 60 | $andor = in_array(strtoupper($andor), ['OR', 'AND', 'EXACT']) ? strtoupper($andor) : 'OR'; |
61 | 61 | $sortby = in_array(strtolower($sortby), [ |
@@ -83,18 +83,18 @@ discard block |
||
83 | 83 | $temp_queries = preg_split("/[\s,]+/", $query); |
84 | 84 | foreach ($temp_queries as $q) { |
85 | 85 | $q = trim($q); |
86 | - if (strlen($q) >= $xoopsConfigSearch['keyword_min']) { |
|
86 | + if (strlen($q)>=$xoopsConfigSearch['keyword_min']) { |
|
87 | 87 | $queries[] = $myts->addSlashes($q); |
88 | - } else { |
|
88 | + }else { |
|
89 | 89 | $ignored_queries[] = $myts->addSlashes($q); |
90 | 90 | } |
91 | 91 | } |
92 | 92 | if (0 == count($queries)) { |
93 | - redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/search.php', 2, sprintf(_SR_KEYTOOSHORT, $xoopsConfigSearch['keyword_min'])); |
|
93 | + redirect_header(XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/search.php', 2, sprintf(_SR_KEYTOOSHORT, $xoopsConfigSearch['keyword_min'])); |
|
94 | 94 | } |
95 | - } else { |
|
96 | - if (strlen($query) < $xoopsConfigSearch['keyword_min']) { |
|
97 | - redirect_header(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/search.php', 2, sprintf(_SR_KEYTOOSHORT, $xoopsConfigSearch['keyword_min'])); |
|
95 | + }else { |
|
96 | + if (strlen($query)<$xoopsConfigSearch['keyword_min']) { |
|
97 | + redirect_header(XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/search.php', 2, sprintf(_SR_KEYTOOSHORT, $xoopsConfigSearch['keyword_min'])); |
|
98 | 98 | } |
99 | 99 | $queries = [$myts->addSlashes($query)]; |
100 | 100 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | */ |
108 | 108 | if (!empty($time)) { |
109 | 109 | $extra = ''; |
110 | - } else { |
|
110 | + }else { |
|
111 | 111 | $extra = ''; |
112 | 112 | } |
113 | 113 | |
@@ -121,20 +121,20 @@ discard block |
||
121 | 121 | { |
122 | 122 | $xoopsTpl->assign('results', $results); |
123 | 123 | |
124 | - if (count($next_search) > 0) { |
|
124 | + if (count($next_search)>0) { |
|
125 | 125 | $items = []; |
126 | 126 | foreach ($next_search as $para => $val) { |
127 | 127 | if (!empty($val)) { |
128 | 128 | $items[] = "$para=$val"; |
129 | 129 | } |
130 | 130 | } |
131 | - if (count($items) > 0) { |
|
131 | + if (count($items)>0) { |
|
132 | 132 | $paras = implode('&', $items); |
133 | 133 | } |
134 | 134 | unset($next_search); |
135 | 135 | unset($items); |
136 | 136 | } |
137 | - $search_url = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/search.php?' . $paras; |
|
137 | + $search_url = XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/search.php?'.$paras; |
|
138 | 138 | |
139 | 139 | /* |
140 | 140 | $next_results =& planet_search($queries, $andor, 1, $start + $limit, $uid, $category, $sortby, $searchin, $extra); |
@@ -146,22 +146,22 @@ discard block |
||
146 | 146 | if (false != $has_next) |
147 | 147 | */ |
148 | 148 | if (count($results)) { |
149 | - $next = $start + $limit; |
|
149 | + $next = $start+$limit; |
|
150 | 150 | $queries = implode(',', $queries); |
151 | - $search_url_next = $search_url . "&start=$next"; |
|
152 | - $search_next = "<a href=\"" . htmlspecialchars($search_url_next) . "\">" . _SR_NEXT . '</a>'; |
|
151 | + $search_url_next = $search_url."&start=$next"; |
|
152 | + $search_next = "<a href=\"".htmlspecialchars($search_url_next)."\">"._SR_NEXT.'</a>'; |
|
153 | 153 | $xoopsTpl->assign('search_next', $search_next); |
154 | 154 | } |
155 | - if ($start > 0) { |
|
156 | - $prev = $start - $limit; |
|
157 | - $search_url_prev = $search_url . "&start=$prev"; |
|
158 | - $search_prev = "<a href=\"" . htmlspecialchars($search_url_prev) . "\">" . _SR_PREVIOUS . '</a>'; |
|
155 | + if ($start>0) { |
|
156 | + $prev = $start-$limit; |
|
157 | + $search_url_prev = $search_url."&start=$prev"; |
|
158 | + $search_prev = "<a href=\"".htmlspecialchars($search_url_prev)."\">"._SR_PREVIOUS.'</a>'; |
|
159 | 159 | $xoopsTpl->assign('search_prev', $search_prev); |
160 | 160 | } |
161 | 161 | } |
162 | 162 | |
163 | 163 | unset($results); |
164 | - $search_info = _SR_KEYWORDS . ': ' . $myts->htmlSpecialChars($term); |
|
164 | + $search_info = _SR_KEYWORDS.': '.$myts->htmlSpecialChars($term); |
|
165 | 165 | $xoopsTpl->assign('search_info', $search_info); |
166 | 166 | } |
167 | 167 | |
@@ -171,17 +171,17 @@ discard block |
||
171 | 171 | if ('OR' === $andor) { |
172 | 172 | $type_select .= " selected=\"selected\""; |
173 | 173 | } |
174 | -$type_select .= '>' . _SR_ANY . '</option>'; |
|
174 | +$type_select .= '>'._SR_ANY.'</option>'; |
|
175 | 175 | $type_select .= "<option value=\"AND\""; |
176 | 176 | if ('AND' === $andor) { |
177 | 177 | $type_select .= " selected=\"selected\""; |
178 | 178 | } |
179 | -$type_select .= '>' . _SR_ALL . '</option>'; |
|
179 | +$type_select .= '>'._SR_ALL.'</option>'; |
|
180 | 180 | $type_select .= "<option value=\"EXACT\""; |
181 | 181 | if ('exact' === $andor) { |
182 | 182 | $type_select .= " selected=\"selected\""; |
183 | 183 | } |
184 | -$type_select .= '>' . _SR_EXACT . '</option>'; |
|
184 | +$type_select .= '>'._SR_EXACT.'</option>'; |
|
185 | 185 | $type_select .= '</select>'; |
186 | 186 | |
187 | 187 | /* scope */ |
@@ -190,32 +190,32 @@ discard block |
||
190 | 190 | if (in_array('title', $searchin)) { |
191 | 191 | $searchin_select .= ' checked'; |
192 | 192 | } |
193 | -$searchin_select .= '>' . planet_constant('MD_TITLE') . ' '; |
|
193 | +$searchin_select .= '>'.planet_constant('MD_TITLE').' '; |
|
194 | 194 | $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"text\""; |
195 | 195 | if (in_array('text', $searchin)) { |
196 | 196 | $searchin_select .= ' checked'; |
197 | 197 | } |
198 | -$searchin_select .= '>' . planet_constant('MD_BODY') . ' || '; |
|
198 | +$searchin_select .= '>'.planet_constant('MD_BODY').' || '; |
|
199 | 199 | $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"blog\""; |
200 | 200 | if (in_array('blog', $searchin)) { |
201 | 201 | $searchin_select .= ' checked'; |
202 | 202 | } |
203 | -$searchin_select .= '>' . planet_constant('MD_BLOG') . ' '; |
|
203 | +$searchin_select .= '>'.planet_constant('MD_BLOG').' '; |
|
204 | 204 | $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"feed\""; |
205 | 205 | if (in_array('feed', $searchin)) { |
206 | 206 | $searchin_select .= ' checked'; |
207 | 207 | } |
208 | -$searchin_select .= '>' . planet_constant('MD_FEED') . ' '; |
|
208 | +$searchin_select .= '>'.planet_constant('MD_FEED').' '; |
|
209 | 209 | $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"desc\""; |
210 | 210 | if (in_array('desc', $searchin)) { |
211 | 211 | $searchin_select .= ' checked'; |
212 | 212 | } |
213 | -$searchin_select .= '>' . planet_constant('MD_DESC') . ' '; |
|
213 | +$searchin_select .= '>'.planet_constant('MD_DESC').' '; |
|
214 | 214 | $searchin_select .= "<input type=\"checkbox\" name=\"searchin[]\" value=\"all\""; |
215 | 215 | if (empty($searchin)) { |
216 | 216 | $searchin_select .= ' checked'; |
217 | 217 | } |
218 | -$searchin_select .= '>' . _ALL . ' '; |
|
218 | +$searchin_select .= '>'._ALL.' '; |
|
219 | 219 | |
220 | 220 | /* sortby */ |
221 | 221 | $sortby_select = "<select name=\"sortby\">"; |
@@ -223,28 +223,28 @@ discard block |
||
223 | 223 | if (empty($sortby)) { |
224 | 224 | $sortby_select .= " selected=\"selected\""; |
225 | 225 | } |
226 | -$sortby_select .= '>' . _NONE . '</option>'; |
|
226 | +$sortby_select .= '>'._NONE.'</option>'; |
|
227 | 227 | $sortby_select .= "<option value=\"a.art_time\""; |
228 | 228 | if ('a.art_time' === $sortby) { |
229 | 229 | $sortby_select .= " selected=\"selected\""; |
230 | 230 | } |
231 | -$sortby_select .= '>' . planet_constant('MD_TIME') . '</option>'; |
|
231 | +$sortby_select .= '>'.planet_constant('MD_TIME').'</option>'; |
|
232 | 232 | $sortby_select .= "<option value=\"a.art_title\""; |
233 | 233 | if ('a.art_title' === $sortby) { |
234 | 234 | $sortby_select .= " selected=\"selected\""; |
235 | 235 | } |
236 | -$sortby_select .= '>' . planet_constant('MD_TITLE') . '</option>'; |
|
236 | +$sortby_select .= '>'.planet_constant('MD_TITLE').'</option>'; |
|
237 | 237 | $sortby_select .= "<option value=\"\"> ---- </option>"; |
238 | 238 | $sortby_select .= "<option value=\"a.blog_title\""; |
239 | 239 | if ('a.blog_title' === $sortby) { |
240 | 240 | $sortby_select .= " selected=\"selected\""; |
241 | 241 | } |
242 | -$sortby_select .= '>' . planet_constant('MD_BLOG') . '</option>'; |
|
242 | +$sortby_select .= '>'.planet_constant('MD_BLOG').'</option>'; |
|
243 | 243 | $sortby_select .= "<option value=\"a.blog_time\""; |
244 | 244 | if ('b.blog_time' === $sortby) { |
245 | 245 | $sortby_select .= " selected=\"selected\""; |
246 | 246 | } |
247 | -$sortby_select .= '>' . planet_constant('MD_UPDATE') . '</option>'; |
|
247 | +$sortby_select .= '>'.planet_constant('MD_UPDATE').'</option>'; |
|
248 | 248 | $sortby_select .= '</select>'; |
249 | 249 | |
250 | 250 | $xoopsTpl->assign('type_select', $type_select); |
@@ -258,8 +258,8 @@ discard block |
||
258 | 258 | $xoopsTpl->assign('blog', $blog); |
259 | 259 | $xoopsTpl->assign('uid', $uid); |
260 | 260 | |
261 | -if ($xoopsConfigSearch['keyword_min'] > 0) { |
|
261 | +if ($xoopsConfigSearch['keyword_min']>0) { |
|
262 | 262 | $xoopsTpl->assign('search_rule', sprintf(_SR_KEYIGNORE, $xoopsConfigSearch['keyword_min'])); |
263 | 263 | } |
264 | 264 | |
265 | -include XOOPS_ROOT_PATH . '/footer.php'; |
|
265 | +include XOOPS_ROOT_PATH.'/footer.php'; |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | |
30 | 30 | if (false !== ($moduleHelper = Xmf\Module\Helper::getHelper($moduleDirName))) { |
31 | 31 | } else { |
32 | - $moduleHelper = Xmf\Module\Helper::getHelper('system'); |
|
32 | + $moduleHelper = Xmf\Module\Helper::getHelper('system'); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | $pathIcon32 = \Xmf\Module\Admin::menuIconPath(''); |
@@ -38,33 +38,33 @@ discard block |
||
38 | 38 | $moduleHelper->loadLanguage('modinfo'); |
39 | 39 | |
40 | 40 | $adminmenu[] = [ |
41 | - 'title' => _AM_MODULEADMIN_HOME, |
|
42 | - 'link' => 'admin/index.php', |
|
43 | - 'icon' => $pathIcon32 . '/home.png', |
|
41 | + 'title' => _AM_MODULEADMIN_HOME, |
|
42 | + 'link' => 'admin/index.php', |
|
43 | + 'icon' => $pathIcon32 . '/home.png', |
|
44 | 44 | ]; |
45 | 45 | |
46 | 46 | $adminmenu[] = [ |
47 | - 'title' => planet_constant('MI_ADMENU_INDEX'), |
|
48 | - 'link' => 'admin/main.php', |
|
49 | - 'icon' => $pathIcon32 . '/manage.png', |
|
47 | + 'title' => planet_constant('MI_ADMENU_INDEX'), |
|
48 | + 'link' => 'admin/main.php', |
|
49 | + 'icon' => $pathIcon32 . '/manage.png', |
|
50 | 50 | ]; |
51 | 51 | |
52 | 52 | $adminmenu[] = [ |
53 | - 'title' => planet_constant('MI_ADMENU_CATEGORY'), |
|
54 | - 'link' => 'admin/admin.category.php', |
|
55 | - 'icon' => $pathIcon32 . '/category.png', |
|
53 | + 'title' => planet_constant('MI_ADMENU_CATEGORY'), |
|
54 | + 'link' => 'admin/admin.category.php', |
|
55 | + 'icon' => $pathIcon32 . '/category.png', |
|
56 | 56 | ]; |
57 | 57 | |
58 | 58 | $adminmenu[] = [ |
59 | - 'title' => planet_constant('MI_ADMENU_BLOG'), |
|
60 | - 'link' => 'admin/admin.blog.php', |
|
61 | - 'icon' => $pathIcon32 . '/translations.png', |
|
59 | + 'title' => planet_constant('MI_ADMENU_BLOG'), |
|
60 | + 'link' => 'admin/admin.blog.php', |
|
61 | + 'icon' => $pathIcon32 . '/translations.png', |
|
62 | 62 | ]; |
63 | 63 | |
64 | 64 | $adminmenu[] = [ |
65 | - 'title' => planet_constant('MI_ADMENU_ARTICLE'), |
|
66 | - 'link' => 'admin/admin.article.php', |
|
67 | - 'icon' => $pathIcon32 . '/content.png', |
|
65 | + 'title' => planet_constant('MI_ADMENU_ARTICLE'), |
|
66 | + 'link' => 'admin/admin.article.php', |
|
67 | + 'icon' => $pathIcon32 . '/content.png', |
|
68 | 68 | ]; |
69 | 69 | |
70 | 70 | //$adminmenu[] = [ |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | //]; |
75 | 75 | |
76 | 76 | $adminmenu[] = [ |
77 | - 'title' => _AM_MODULEADMIN_ABOUT, |
|
78 | - 'link' => 'admin/about.php', |
|
79 | - 'icon' => $pathIcon32 . '/about.png', |
|
77 | + 'title' => _AM_MODULEADMIN_ABOUT, |
|
78 | + 'link' => 'admin/about.php', |
|
79 | + 'icon' => $pathIcon32 . '/about.png', |
|
80 | 80 | ]; |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | $moduleDirName = basename(dirname(__DIR__)); |
29 | 29 | |
30 | 30 | if (false !== ($moduleHelper = Xmf\Module\Helper::getHelper($moduleDirName))) { |
31 | -} else { |
|
31 | +}else { |
|
32 | 32 | $moduleHelper = Xmf\Module\Helper::getHelper('system'); |
33 | 33 | } |
34 | 34 | |
@@ -40,31 +40,31 @@ discard block |
||
40 | 40 | $adminmenu[] = [ |
41 | 41 | 'title' => _AM_MODULEADMIN_HOME, |
42 | 42 | 'link' => 'admin/index.php', |
43 | - 'icon' => $pathIcon32 . '/home.png', |
|
43 | + 'icon' => $pathIcon32.'/home.png', |
|
44 | 44 | ]; |
45 | 45 | |
46 | 46 | $adminmenu[] = [ |
47 | 47 | 'title' => planet_constant('MI_ADMENU_INDEX'), |
48 | 48 | 'link' => 'admin/main.php', |
49 | - 'icon' => $pathIcon32 . '/manage.png', |
|
49 | + 'icon' => $pathIcon32.'/manage.png', |
|
50 | 50 | ]; |
51 | 51 | |
52 | 52 | $adminmenu[] = [ |
53 | 53 | 'title' => planet_constant('MI_ADMENU_CATEGORY'), |
54 | 54 | 'link' => 'admin/admin.category.php', |
55 | - 'icon' => $pathIcon32 . '/category.png', |
|
55 | + 'icon' => $pathIcon32.'/category.png', |
|
56 | 56 | ]; |
57 | 57 | |
58 | 58 | $adminmenu[] = [ |
59 | 59 | 'title' => planet_constant('MI_ADMENU_BLOG'), |
60 | 60 | 'link' => 'admin/admin.blog.php', |
61 | - 'icon' => $pathIcon32 . '/translations.png', |
|
61 | + 'icon' => $pathIcon32.'/translations.png', |
|
62 | 62 | ]; |
63 | 63 | |
64 | 64 | $adminmenu[] = [ |
65 | 65 | 'title' => planet_constant('MI_ADMENU_ARTICLE'), |
66 | 66 | 'link' => 'admin/admin.article.php', |
67 | - 'icon' => $pathIcon32 . '/content.png', |
|
67 | + 'icon' => $pathIcon32.'/content.png', |
|
68 | 68 | ]; |
69 | 69 | |
70 | 70 | //$adminmenu[] = [ |
@@ -76,5 +76,5 @@ discard block |
||
76 | 76 | $adminmenu[] = [ |
77 | 77 | 'title' => _AM_MODULEADMIN_ABOUT, |
78 | 78 | 'link' => 'admin/about.php', |
79 | - 'icon' => $pathIcon32 . '/about.png', |
|
79 | + 'icon' => $pathIcon32.'/about.png', |
|
80 | 80 | ]; |
@@ -52,353 +52,353 @@ |
||
52 | 52 | $categoryHandler = xoops_getModuleHandler('category', $GLOBALS['moddirname']); |
53 | 53 | |
54 | 54 | if ('save' === $op && !empty(Request::getString('fetch', '', 'POST'))) { |
55 | - $op = 'edit'; |
|
55 | + $op = 'edit'; |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | switch ($op) { |
59 | - /* save a single blog */ |
|
60 | - case 'save': |
|
61 | - |
|
62 | - if ($blog_id) { |
|
63 | - $blog_obj = $blogHandler->get($blog_id); |
|
64 | - } else { |
|
65 | - if ($blog_exists = $blogHandler->getCount(new Criteria('blog_feed', Request::getString('blog_feed', '', 'POST')))) { |
|
66 | - redirect_header('admin.blog.php', 2, planet_constant('AM_BLOGEXISTS')); |
|
67 | - } |
|
68 | - $blog_obj = $blogHandler->create(); |
|
69 | - $blog_obj->setVar('blog_submitter', $xoopsUser->getVar('uid')); |
|
70 | - } |
|
71 | - |
|
72 | - $blog_obj->setVar('blog_title', Request::getString('blog_title', '', 'POST')); //$_POST['blog_title']); |
|
73 | - $blog_obj->setVar('blog_desc', Request::getString('blog_desc', '', 'POST')); //$_POST['blog_desc']); |
|
74 | - $blog_obj->setVar('blog_image', Request::getString('blog_image', '', 'POST')); //$_POST['blog_image']); |
|
75 | - $blog_obj->setVar('blog_feed', Request::getString('blog_feed', '', 'POST')); //$_POST['blog_feed']); |
|
76 | - $blog_obj->setVar('blog_link', Request::getString('blog_link', '', 'POST')); //$_POST['blog_link']); |
|
77 | - $blog_obj->setVar('blog_language', Request::getString('blog_language', '', 'POST')); //$_POST['blog_language']); |
|
78 | - $blog_obj->setVar('blog_charset', Request::getString('blog_charset', '', 'POST')); //$_POST['blog_charset']); |
|
79 | - $blog_obj->setVar('blog_trackback', Request::getString('blog_trackback', '', 'POST')); //$_POST['blog_trackback']); |
|
80 | - $blog_obj->setVar('blog_status', Request::getInt('blog_status', 0, 'POST')); //$_POST['blog_status']); |
|
81 | - |
|
82 | - if (!$blogHandler->insert($blog_obj)) { |
|
83 | - } elseif (!empty(Request::getArray('categories', [], 'POST'))) { |
|
84 | - $blog_id = $blog_obj->getVar('blog_id'); |
|
85 | - if (in_array(0, Request::getArray('categories', [], 'POST'))) { |
|
86 | - $_POST['categories'] = []; |
|
87 | - } |
|
88 | - $blogHandler->setCategories($blog_id, Request::getArray('categories', [], 'POST')); |
|
89 | - } |
|
90 | - $message = planet_constant('AM_DBUPDATED'); |
|
91 | - redirect_header('admin.blog.php', 2, $message); |
|
92 | - |
|
93 | - /* fetch and add a list of blogs to a category */ |
|
94 | - // no break |
|
95 | - case 'add': |
|
96 | - $links = PlanetUtility::planetParseLinks(Request::getArray('links', [], 'POST')); |
|
97 | - $blogs = []; |
|
98 | - foreach ($links as $link) { |
|
99 | - if ($blog_exist = $blogHandler->getCount(new Criteria('blog_feed', $link['url']))) { |
|
100 | - continue; |
|
101 | - } |
|
102 | - $blog_obj = $blogHandler->fetch($link['url']); |
|
103 | - if (!empty($link['title'])) { |
|
104 | - $blog_obj->setVar('blog_title', $link['title']); |
|
105 | - } |
|
106 | - $blogHandler->insert($blog_obj); |
|
107 | - $blogs[] = $blog_obj->getVar('blog_id'); |
|
108 | - unset($blog_obj); |
|
109 | - } |
|
110 | - if (!empty(Request::getArray('categories', [], 'POST'))) { |
|
111 | - $categoryHandler = xoops_getModuleHandler('category', $GLOBALS['moddirname']); |
|
112 | - foreach (Request::getArray('categories', [], 'POST') as $cat_id) { |
|
113 | - $categoryHandler->addBlogs($cat_id, $blogs); |
|
114 | - } |
|
115 | - } |
|
116 | - $message = planet_constant('AM_DBUPDATED'); |
|
117 | - redirect_header('admin.blog.php', 2, $message); |
|
118 | - |
|
119 | - /* update a list of blogs */ |
|
120 | - // no break |
|
121 | - case 'update': |
|
122 | - foreach ($blog_id as $bid) { |
|
123 | - $blog_obj = $blogHandler->fetch($bid); |
|
124 | - if (!$blogHandler->insert($blog_obj)) { |
|
125 | - } |
|
126 | - unset($blog_obj); |
|
127 | - } |
|
128 | - $message = planet_constant('AM_DBUPDATED'); |
|
129 | - redirect_header('admin.blog.php?category=' . $category_id . '&start=' . $start, 2, $message); |
|
130 | - |
|
131 | - /* add a list of blogs to a category */ |
|
132 | - // no break |
|
133 | - case 'register': |
|
134 | - if (!empty(Request::getArray('category_dest', [], 'POST'))) { |
|
135 | - if (!is_array($blog_id)) { |
|
136 | - $blog_id = [$blog_id]; |
|
137 | - } |
|
138 | - $categoryHandler = xoops_getModuleHandler('category', $GLOBALS['moddirname']); |
|
139 | - $categoryHandler->addBlogs(Request::getArray('category_dest', [], 'POST'), $blog_id); |
|
140 | - } |
|
141 | - $message = planet_constant('AM_DBUPDATED'); |
|
142 | - redirect_header('admin.blog.php?category=' . Request::getArray('category_dest', [], 'POST') . '&start=' . $start, 2, $message); |
|
143 | - |
|
144 | - /* remove a list of blogs from a category */ |
|
145 | - // no break |
|
146 | - case 'remove': |
|
147 | - if (!is_array($blog_id)) { |
|
148 | - $blog_id = [$blog_id]; |
|
149 | - } |
|
150 | - if (!empty($category_id)) { |
|
151 | - $categoryHandler = xoops_getModuleHandler('category', $GLOBALS['moddirname']); |
|
152 | - $categoryHandler->removeBlogs($category_id, $blog_id); |
|
153 | - } |
|
154 | - $message = planet_constant('AM_DBUPDATED'); |
|
155 | - redirect_header('admin.blog.php?category=' . $category_id . '&start=' . $start, 2, $message); |
|
156 | - |
|
157 | - /* delete a single blog or a list blogs */ |
|
158 | - // no break |
|
159 | - case 'del': |
|
160 | - if (!is_array($blog_id)) { |
|
161 | - $blog_id = [$blog_id]; |
|
162 | - } |
|
163 | - foreach ($blog_id as $bid) { |
|
164 | - $blog_obj = $blogHandler->get($bid); |
|
165 | - if (!$blogHandler->delete($blog_obj, true)) { |
|
166 | - } |
|
167 | - unset($blog_obj); |
|
168 | - } |
|
169 | - $message = planet_constant('AM_DBUPDATED'); |
|
170 | - redirect_header('admin.blog.php?category=' . $category_id . '&start=' . $start, 2, $message); |
|
171 | - |
|
172 | - /* empty a single blog or a list blogs */ |
|
173 | - // no break |
|
174 | - case 'empty': |
|
175 | - if (!is_array($blog_id)) { |
|
176 | - $blog_id = [$blog_id]; |
|
177 | - } |
|
178 | - foreach ($blog_id as $bid) { |
|
179 | - $blog_obj = $blogHandler->get($bid); |
|
180 | - if (!$blogHandler->do_empty($blog_obj)) { |
|
181 | - } |
|
182 | - } |
|
183 | - $message = planet_constant('AM_DBUPDATED'); |
|
184 | - redirect_header('admin.blog.php?category=' . $category_id . '&start=' . $start, 2, $message); |
|
185 | - |
|
186 | - /* approve a single blog or a list blogs */ |
|
187 | - // no break |
|
188 | - case 'approve': |
|
189 | - if (!is_array($blog_id)) { |
|
190 | - $blog_id = [$blog_id]; |
|
191 | - } |
|
192 | - $criteria = new Criteria('blog_id', '(' . implode(',', $blog_id) . ')', 'IN'); |
|
193 | - $blogHandler->updateAll('blog_status', 1, $criteria, true); |
|
194 | - $message = planet_constant('AM_DBUPDATED'); |
|
195 | - redirect_header('admin.blog.php?category=' . $category_id . '&start=' . $start, 2, $message); |
|
196 | - |
|
197 | - /* mark a single blog or a list blogs as featured */ |
|
198 | - // no break |
|
199 | - case 'feature': |
|
200 | - if (!is_array($blog_id)) { |
|
201 | - $blog_id = [$blog_id]; |
|
202 | - } |
|
203 | - $criteria = new Criteria('blog_id', '(' . implode(',', $blog_id) . ')', 'IN'); |
|
204 | - $blogHandler->updateAll('blog_status', 2, $criteria, true); |
|
205 | - $message = planet_constant('AM_DBUPDATED'); |
|
206 | - redirect_header('admin.blog.php?category=' . $category_id . '&start=' . $start, 2, $message); |
|
207 | - |
|
208 | - /* edit a single blog */ |
|
209 | - // no break |
|
210 | - case 'edit': |
|
211 | - if (!empty(Request::getString('fetch', '', 'POST'))) { |
|
212 | - $blog_obj = $blogHandler->fetch(Request::getString('blog_feed', '', 'POST')); |
|
213 | - $blog_obj->setVar('blog_id', $blog_id); |
|
214 | - } else { |
|
215 | - $blog_obj = $blogHandler->get($blog_id); |
|
216 | - } |
|
217 | - $categories = Request::getArray('categories', [], 'POST'); |
|
218 | - if (empty($categories) && $blog_id > 0) { |
|
219 | - $crit = new Criteria('bc.blog_id', $blog_id); |
|
220 | - $categories = array_keys($categoryHandler->getByBlog($crit)); |
|
221 | - } |
|
222 | - if (empty($categories)) { |
|
223 | - $categories = [0 => _NONE]; |
|
224 | - } |
|
225 | - |
|
226 | - echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _EDIT . '</legend>'; |
|
227 | - echo '<br>'; |
|
228 | - if (empty($blog_id) && $blog_obj->getVar('blog_feed')) { |
|
229 | - $criteria = new Criteria('blog_feed', $blog_obj->getVar('blog_feed')); |
|
230 | - $blogs_obj = $blogHandler->getList($criteria); |
|
231 | - if (count($blogs_obj) > 0) { |
|
232 | - echo "<div class=\"errorMsg\">" . planet_constant('AM_BLOGEXISTS'); |
|
233 | - foreach (array_keys($blogs_obj) as $bid) { |
|
234 | - echo "<br><a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . URL_DELIMITER . 'b' . $bid . "\" target=\"_blank\">" . $blogs_obj[$bid] . '</a>'; |
|
235 | - } |
|
236 | - echo '</div>'; |
|
237 | - } |
|
238 | - unset($blogs_obj, $criteria); |
|
239 | - } |
|
240 | - include XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/include/form.blog.php'; |
|
241 | - echo '</fieldset>'; |
|
242 | - break; |
|
243 | - |
|
244 | - default: |
|
245 | - |
|
246 | - $crit = new Criteria('1', 1); |
|
247 | - $crit->setSort('cat_order'); |
|
248 | - $crit->setOrder('ASC'); |
|
249 | - $categories = $categoryHandler->getList($crit); |
|
250 | - |
|
251 | - // Display category option form |
|
252 | - $opform = new XoopsSimpleForm('', 'opform', 'admin.blog.php', 'get'); |
|
253 | - $op_select = new XoopsFormSelect('', 'category', $category_id); |
|
254 | - $op_select->setExtra('onchange="document.forms.opform.submit()"'); |
|
255 | - $options = [ |
|
256 | - '0' => _ALL, |
|
257 | - '-1' => planet_constant('MD_ACTIVE'), |
|
258 | - '-2' => planet_constant('MD_FEATURED'), |
|
259 | - '-3' => planet_constant('MD_PENDING') |
|
260 | - ]; |
|
261 | - foreach (array_keys($categories) as $key) { |
|
262 | - $options[$key] = $categories[$key]; |
|
263 | - } |
|
264 | - $op_select->addOptionArray($options); |
|
265 | - $opform->addElement($op_select); |
|
266 | - $opform->display(); |
|
267 | - |
|
268 | - if ($category_id > 0) { |
|
269 | - $criteria = new CriteriaCompo(new Criteria('b.blog_status', 0, '>')); |
|
270 | - $criteria->add(new Criteria('bc.cat_id', $category_id)); |
|
271 | - $blog_count = $blogHandler->getCountByCategory($criteria); |
|
272 | - $criteria->setStart($start); |
|
273 | - $criteria->setLimit($xoopsModuleConfig['list_perpage']); |
|
274 | - $blog_objs = $blogHandler->getByCategory($criteria); |
|
275 | - } else { |
|
276 | - /* All active blogs */ |
|
277 | - if (0 == $category_id) { |
|
278 | - $criteria = new Criteria('1', 1); |
|
279 | - $criteria->setStart($start); |
|
280 | - $criteria->setLimit($xoopsModuleConfig['list_perpage']); |
|
281 | - /* Active blogs */ |
|
282 | - } elseif ($category_id == -1) { |
|
283 | - $criteria = new Criteria('blog_status', 1); |
|
284 | - $criteria->setStart($start); |
|
285 | - $criteria->setLimit($xoopsModuleConfig['list_perpage']); |
|
286 | - /* Featured blogs */ |
|
287 | - } elseif ($category_id == -2) { |
|
288 | - $criteria = new Criteria('blog_status', 2); |
|
289 | - $criteria->setStart($start); |
|
290 | - $criteria->setLimit($xoopsModuleConfig['list_perpage']); |
|
291 | - /* Pending blogs */ |
|
292 | - } else { |
|
293 | - $criteria = new Criteria('blog_status', 0); |
|
294 | - $criteria->setStart($start); |
|
295 | - $criteria->setLimit($xoopsModuleConfig['list_perpage']); |
|
296 | - } |
|
297 | - $blog_count = $blogHandler->getCount($criteria); |
|
298 | - $blog_objs = $blogHandler->getAll($criteria); |
|
299 | - } |
|
300 | - |
|
301 | - echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . planet_constant('AM_LIST') . '</legend>'; |
|
302 | - echo "<br style=\"clear:both\">"; |
|
303 | - |
|
304 | - echo "<form name='list' id='list' method='post' action='" . xoops_getenv('PHP_SELF') . "'>"; |
|
305 | - echo "<table border='0' cellpadding='4' cellspacing='1' width='100%' class='outer'>"; |
|
306 | - echo "<tr align='center'>"; |
|
307 | - echo "<th class='bg3' width='5%'><input name='blog_check' id='blog_check' value='1' type='checkbox' onclick=\"xoopsCheckAll('list', 'blog_check');\"></td>"; |
|
308 | - echo "<th class='bg3'>" . planet_constant('AM_TITLE') . '</td>'; |
|
309 | - echo "<th class='bg3' width='5%'>" . planet_constant('AM_STATUS') . '</td>'; |
|
310 | - echo "<th class='bg3' width='40%'>" . planet_constant('AM_FEED') . '</td>'; |
|
311 | - // echo "<th class='bg3' width='5%'>" . _EDIT . "</td>"; |
|
312 | - // echo "<th class='bg3' width='5%'>" . _DELETE . "</td>"; |
|
313 | - echo "<th class='bg3' width='10%'>" . planet_constant('AM_ACTIONS') . '</td>'; |
|
314 | - echo '</tr>'; |
|
315 | - |
|
316 | - $status = [ |
|
317 | - '0' => planet_constant('MD_PENDING'), |
|
318 | - '1' => planet_constant('MD_ACTIVE'), |
|
319 | - '2' => planet_constant('MD_FEATURED') |
|
320 | - ]; |
|
321 | - foreach (array_keys($blog_objs) as $bid) { |
|
322 | - echo "<tr class='odd' align='left'>"; |
|
323 | - echo "<td align='center'><input name='blog[]' value='" . $bid . "' type='checkbox'></td>"; |
|
324 | - echo "<td><a href='" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . URL_DELIMITER . 'b' . $bid . "'>" . $blog_objs[$bid]->getVar('blog_title') . '</a></td>'; |
|
325 | - echo "<td align='center'>" . $status[$blog_objs[$bid]->getVar('blog_status')] . '</td>'; |
|
326 | - echo '<td>' . $blog_objs[$bid]->getVar('blog_feed') . '</td>'; |
|
327 | - echo "<td align='center'><a href='admin.blog.php?op=edit&blog=" . $bid . "' title='" . _EDIT . "'><img src='" . $pathIcon16 . "/edit.png '" . "alt='" . _EDIT . " title='" . _EDIT . " </a> |
|
59 | + /* save a single blog */ |
|
60 | + case 'save': |
|
61 | + |
|
62 | + if ($blog_id) { |
|
63 | + $blog_obj = $blogHandler->get($blog_id); |
|
64 | + } else { |
|
65 | + if ($blog_exists = $blogHandler->getCount(new Criteria('blog_feed', Request::getString('blog_feed', '', 'POST')))) { |
|
66 | + redirect_header('admin.blog.php', 2, planet_constant('AM_BLOGEXISTS')); |
|
67 | + } |
|
68 | + $blog_obj = $blogHandler->create(); |
|
69 | + $blog_obj->setVar('blog_submitter', $xoopsUser->getVar('uid')); |
|
70 | + } |
|
71 | + |
|
72 | + $blog_obj->setVar('blog_title', Request::getString('blog_title', '', 'POST')); //$_POST['blog_title']); |
|
73 | + $blog_obj->setVar('blog_desc', Request::getString('blog_desc', '', 'POST')); //$_POST['blog_desc']); |
|
74 | + $blog_obj->setVar('blog_image', Request::getString('blog_image', '', 'POST')); //$_POST['blog_image']); |
|
75 | + $blog_obj->setVar('blog_feed', Request::getString('blog_feed', '', 'POST')); //$_POST['blog_feed']); |
|
76 | + $blog_obj->setVar('blog_link', Request::getString('blog_link', '', 'POST')); //$_POST['blog_link']); |
|
77 | + $blog_obj->setVar('blog_language', Request::getString('blog_language', '', 'POST')); //$_POST['blog_language']); |
|
78 | + $blog_obj->setVar('blog_charset', Request::getString('blog_charset', '', 'POST')); //$_POST['blog_charset']); |
|
79 | + $blog_obj->setVar('blog_trackback', Request::getString('blog_trackback', '', 'POST')); //$_POST['blog_trackback']); |
|
80 | + $blog_obj->setVar('blog_status', Request::getInt('blog_status', 0, 'POST')); //$_POST['blog_status']); |
|
81 | + |
|
82 | + if (!$blogHandler->insert($blog_obj)) { |
|
83 | + } elseif (!empty(Request::getArray('categories', [], 'POST'))) { |
|
84 | + $blog_id = $blog_obj->getVar('blog_id'); |
|
85 | + if (in_array(0, Request::getArray('categories', [], 'POST'))) { |
|
86 | + $_POST['categories'] = []; |
|
87 | + } |
|
88 | + $blogHandler->setCategories($blog_id, Request::getArray('categories', [], 'POST')); |
|
89 | + } |
|
90 | + $message = planet_constant('AM_DBUPDATED'); |
|
91 | + redirect_header('admin.blog.php', 2, $message); |
|
92 | + |
|
93 | + /* fetch and add a list of blogs to a category */ |
|
94 | + // no break |
|
95 | + case 'add': |
|
96 | + $links = PlanetUtility::planetParseLinks(Request::getArray('links', [], 'POST')); |
|
97 | + $blogs = []; |
|
98 | + foreach ($links as $link) { |
|
99 | + if ($blog_exist = $blogHandler->getCount(new Criteria('blog_feed', $link['url']))) { |
|
100 | + continue; |
|
101 | + } |
|
102 | + $blog_obj = $blogHandler->fetch($link['url']); |
|
103 | + if (!empty($link['title'])) { |
|
104 | + $blog_obj->setVar('blog_title', $link['title']); |
|
105 | + } |
|
106 | + $blogHandler->insert($blog_obj); |
|
107 | + $blogs[] = $blog_obj->getVar('blog_id'); |
|
108 | + unset($blog_obj); |
|
109 | + } |
|
110 | + if (!empty(Request::getArray('categories', [], 'POST'))) { |
|
111 | + $categoryHandler = xoops_getModuleHandler('category', $GLOBALS['moddirname']); |
|
112 | + foreach (Request::getArray('categories', [], 'POST') as $cat_id) { |
|
113 | + $categoryHandler->addBlogs($cat_id, $blogs); |
|
114 | + } |
|
115 | + } |
|
116 | + $message = planet_constant('AM_DBUPDATED'); |
|
117 | + redirect_header('admin.blog.php', 2, $message); |
|
118 | + |
|
119 | + /* update a list of blogs */ |
|
120 | + // no break |
|
121 | + case 'update': |
|
122 | + foreach ($blog_id as $bid) { |
|
123 | + $blog_obj = $blogHandler->fetch($bid); |
|
124 | + if (!$blogHandler->insert($blog_obj)) { |
|
125 | + } |
|
126 | + unset($blog_obj); |
|
127 | + } |
|
128 | + $message = planet_constant('AM_DBUPDATED'); |
|
129 | + redirect_header('admin.blog.php?category=' . $category_id . '&start=' . $start, 2, $message); |
|
130 | + |
|
131 | + /* add a list of blogs to a category */ |
|
132 | + // no break |
|
133 | + case 'register': |
|
134 | + if (!empty(Request::getArray('category_dest', [], 'POST'))) { |
|
135 | + if (!is_array($blog_id)) { |
|
136 | + $blog_id = [$blog_id]; |
|
137 | + } |
|
138 | + $categoryHandler = xoops_getModuleHandler('category', $GLOBALS['moddirname']); |
|
139 | + $categoryHandler->addBlogs(Request::getArray('category_dest', [], 'POST'), $blog_id); |
|
140 | + } |
|
141 | + $message = planet_constant('AM_DBUPDATED'); |
|
142 | + redirect_header('admin.blog.php?category=' . Request::getArray('category_dest', [], 'POST') . '&start=' . $start, 2, $message); |
|
143 | + |
|
144 | + /* remove a list of blogs from a category */ |
|
145 | + // no break |
|
146 | + case 'remove': |
|
147 | + if (!is_array($blog_id)) { |
|
148 | + $blog_id = [$blog_id]; |
|
149 | + } |
|
150 | + if (!empty($category_id)) { |
|
151 | + $categoryHandler = xoops_getModuleHandler('category', $GLOBALS['moddirname']); |
|
152 | + $categoryHandler->removeBlogs($category_id, $blog_id); |
|
153 | + } |
|
154 | + $message = planet_constant('AM_DBUPDATED'); |
|
155 | + redirect_header('admin.blog.php?category=' . $category_id . '&start=' . $start, 2, $message); |
|
156 | + |
|
157 | + /* delete a single blog or a list blogs */ |
|
158 | + // no break |
|
159 | + case 'del': |
|
160 | + if (!is_array($blog_id)) { |
|
161 | + $blog_id = [$blog_id]; |
|
162 | + } |
|
163 | + foreach ($blog_id as $bid) { |
|
164 | + $blog_obj = $blogHandler->get($bid); |
|
165 | + if (!$blogHandler->delete($blog_obj, true)) { |
|
166 | + } |
|
167 | + unset($blog_obj); |
|
168 | + } |
|
169 | + $message = planet_constant('AM_DBUPDATED'); |
|
170 | + redirect_header('admin.blog.php?category=' . $category_id . '&start=' . $start, 2, $message); |
|
171 | + |
|
172 | + /* empty a single blog or a list blogs */ |
|
173 | + // no break |
|
174 | + case 'empty': |
|
175 | + if (!is_array($blog_id)) { |
|
176 | + $blog_id = [$blog_id]; |
|
177 | + } |
|
178 | + foreach ($blog_id as $bid) { |
|
179 | + $blog_obj = $blogHandler->get($bid); |
|
180 | + if (!$blogHandler->do_empty($blog_obj)) { |
|
181 | + } |
|
182 | + } |
|
183 | + $message = planet_constant('AM_DBUPDATED'); |
|
184 | + redirect_header('admin.blog.php?category=' . $category_id . '&start=' . $start, 2, $message); |
|
185 | + |
|
186 | + /* approve a single blog or a list blogs */ |
|
187 | + // no break |
|
188 | + case 'approve': |
|
189 | + if (!is_array($blog_id)) { |
|
190 | + $blog_id = [$blog_id]; |
|
191 | + } |
|
192 | + $criteria = new Criteria('blog_id', '(' . implode(',', $blog_id) . ')', 'IN'); |
|
193 | + $blogHandler->updateAll('blog_status', 1, $criteria, true); |
|
194 | + $message = planet_constant('AM_DBUPDATED'); |
|
195 | + redirect_header('admin.blog.php?category=' . $category_id . '&start=' . $start, 2, $message); |
|
196 | + |
|
197 | + /* mark a single blog or a list blogs as featured */ |
|
198 | + // no break |
|
199 | + case 'feature': |
|
200 | + if (!is_array($blog_id)) { |
|
201 | + $blog_id = [$blog_id]; |
|
202 | + } |
|
203 | + $criteria = new Criteria('blog_id', '(' . implode(',', $blog_id) . ')', 'IN'); |
|
204 | + $blogHandler->updateAll('blog_status', 2, $criteria, true); |
|
205 | + $message = planet_constant('AM_DBUPDATED'); |
|
206 | + redirect_header('admin.blog.php?category=' . $category_id . '&start=' . $start, 2, $message); |
|
207 | + |
|
208 | + /* edit a single blog */ |
|
209 | + // no break |
|
210 | + case 'edit': |
|
211 | + if (!empty(Request::getString('fetch', '', 'POST'))) { |
|
212 | + $blog_obj = $blogHandler->fetch(Request::getString('blog_feed', '', 'POST')); |
|
213 | + $blog_obj->setVar('blog_id', $blog_id); |
|
214 | + } else { |
|
215 | + $blog_obj = $blogHandler->get($blog_id); |
|
216 | + } |
|
217 | + $categories = Request::getArray('categories', [], 'POST'); |
|
218 | + if (empty($categories) && $blog_id > 0) { |
|
219 | + $crit = new Criteria('bc.blog_id', $blog_id); |
|
220 | + $categories = array_keys($categoryHandler->getByBlog($crit)); |
|
221 | + } |
|
222 | + if (empty($categories)) { |
|
223 | + $categories = [0 => _NONE]; |
|
224 | + } |
|
225 | + |
|
226 | + echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _EDIT . '</legend>'; |
|
227 | + echo '<br>'; |
|
228 | + if (empty($blog_id) && $blog_obj->getVar('blog_feed')) { |
|
229 | + $criteria = new Criteria('blog_feed', $blog_obj->getVar('blog_feed')); |
|
230 | + $blogs_obj = $blogHandler->getList($criteria); |
|
231 | + if (count($blogs_obj) > 0) { |
|
232 | + echo "<div class=\"errorMsg\">" . planet_constant('AM_BLOGEXISTS'); |
|
233 | + foreach (array_keys($blogs_obj) as $bid) { |
|
234 | + echo "<br><a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . URL_DELIMITER . 'b' . $bid . "\" target=\"_blank\">" . $blogs_obj[$bid] . '</a>'; |
|
235 | + } |
|
236 | + echo '</div>'; |
|
237 | + } |
|
238 | + unset($blogs_obj, $criteria); |
|
239 | + } |
|
240 | + include XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/include/form.blog.php'; |
|
241 | + echo '</fieldset>'; |
|
242 | + break; |
|
243 | + |
|
244 | + default: |
|
245 | + |
|
246 | + $crit = new Criteria('1', 1); |
|
247 | + $crit->setSort('cat_order'); |
|
248 | + $crit->setOrder('ASC'); |
|
249 | + $categories = $categoryHandler->getList($crit); |
|
250 | + |
|
251 | + // Display category option form |
|
252 | + $opform = new XoopsSimpleForm('', 'opform', 'admin.blog.php', 'get'); |
|
253 | + $op_select = new XoopsFormSelect('', 'category', $category_id); |
|
254 | + $op_select->setExtra('onchange="document.forms.opform.submit()"'); |
|
255 | + $options = [ |
|
256 | + '0' => _ALL, |
|
257 | + '-1' => planet_constant('MD_ACTIVE'), |
|
258 | + '-2' => planet_constant('MD_FEATURED'), |
|
259 | + '-3' => planet_constant('MD_PENDING') |
|
260 | + ]; |
|
261 | + foreach (array_keys($categories) as $key) { |
|
262 | + $options[$key] = $categories[$key]; |
|
263 | + } |
|
264 | + $op_select->addOptionArray($options); |
|
265 | + $opform->addElement($op_select); |
|
266 | + $opform->display(); |
|
267 | + |
|
268 | + if ($category_id > 0) { |
|
269 | + $criteria = new CriteriaCompo(new Criteria('b.blog_status', 0, '>')); |
|
270 | + $criteria->add(new Criteria('bc.cat_id', $category_id)); |
|
271 | + $blog_count = $blogHandler->getCountByCategory($criteria); |
|
272 | + $criteria->setStart($start); |
|
273 | + $criteria->setLimit($xoopsModuleConfig['list_perpage']); |
|
274 | + $blog_objs = $blogHandler->getByCategory($criteria); |
|
275 | + } else { |
|
276 | + /* All active blogs */ |
|
277 | + if (0 == $category_id) { |
|
278 | + $criteria = new Criteria('1', 1); |
|
279 | + $criteria->setStart($start); |
|
280 | + $criteria->setLimit($xoopsModuleConfig['list_perpage']); |
|
281 | + /* Active blogs */ |
|
282 | + } elseif ($category_id == -1) { |
|
283 | + $criteria = new Criteria('blog_status', 1); |
|
284 | + $criteria->setStart($start); |
|
285 | + $criteria->setLimit($xoopsModuleConfig['list_perpage']); |
|
286 | + /* Featured blogs */ |
|
287 | + } elseif ($category_id == -2) { |
|
288 | + $criteria = new Criteria('blog_status', 2); |
|
289 | + $criteria->setStart($start); |
|
290 | + $criteria->setLimit($xoopsModuleConfig['list_perpage']); |
|
291 | + /* Pending blogs */ |
|
292 | + } else { |
|
293 | + $criteria = new Criteria('blog_status', 0); |
|
294 | + $criteria->setStart($start); |
|
295 | + $criteria->setLimit($xoopsModuleConfig['list_perpage']); |
|
296 | + } |
|
297 | + $blog_count = $blogHandler->getCount($criteria); |
|
298 | + $blog_objs = $blogHandler->getAll($criteria); |
|
299 | + } |
|
300 | + |
|
301 | + echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . planet_constant('AM_LIST') . '</legend>'; |
|
302 | + echo "<br style=\"clear:both\">"; |
|
303 | + |
|
304 | + echo "<form name='list' id='list' method='post' action='" . xoops_getenv('PHP_SELF') . "'>"; |
|
305 | + echo "<table border='0' cellpadding='4' cellspacing='1' width='100%' class='outer'>"; |
|
306 | + echo "<tr align='center'>"; |
|
307 | + echo "<th class='bg3' width='5%'><input name='blog_check' id='blog_check' value='1' type='checkbox' onclick=\"xoopsCheckAll('list', 'blog_check');\"></td>"; |
|
308 | + echo "<th class='bg3'>" . planet_constant('AM_TITLE') . '</td>'; |
|
309 | + echo "<th class='bg3' width='5%'>" . planet_constant('AM_STATUS') . '</td>'; |
|
310 | + echo "<th class='bg3' width='40%'>" . planet_constant('AM_FEED') . '</td>'; |
|
311 | + // echo "<th class='bg3' width='5%'>" . _EDIT . "</td>"; |
|
312 | + // echo "<th class='bg3' width='5%'>" . _DELETE . "</td>"; |
|
313 | + echo "<th class='bg3' width='10%'>" . planet_constant('AM_ACTIONS') . '</td>'; |
|
314 | + echo '</tr>'; |
|
315 | + |
|
316 | + $status = [ |
|
317 | + '0' => planet_constant('MD_PENDING'), |
|
318 | + '1' => planet_constant('MD_ACTIVE'), |
|
319 | + '2' => planet_constant('MD_FEATURED') |
|
320 | + ]; |
|
321 | + foreach (array_keys($blog_objs) as $bid) { |
|
322 | + echo "<tr class='odd' align='left'>"; |
|
323 | + echo "<td align='center'><input name='blog[]' value='" . $bid . "' type='checkbox'></td>"; |
|
324 | + echo "<td><a href='" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . URL_DELIMITER . 'b' . $bid . "'>" . $blog_objs[$bid]->getVar('blog_title') . '</a></td>'; |
|
325 | + echo "<td align='center'>" . $status[$blog_objs[$bid]->getVar('blog_status')] . '</td>'; |
|
326 | + echo '<td>' . $blog_objs[$bid]->getVar('blog_feed') . '</td>'; |
|
327 | + echo "<td align='center'><a href='admin.blog.php?op=edit&blog=" . $bid . "' title='" . _EDIT . "'><img src='" . $pathIcon16 . "/edit.png '" . "alt='" . _EDIT . " title='" . _EDIT . " </a> |
|
328 | 328 | <a href='admin.blog.php?op=del&blog=" . $bid . "' title='" . _DELETE . "'><img src='" . $pathIcon16 . "/delete.png '" . " alt='" . _EDIT . " title='" . _DELETE . " </a> |
329 | 329 | <a href='admin.blog.php?op=empty&blog=" . $bid . "' title='" . planet_constant('MD_EMPTY_BLOG') . "'><img src='" . $pathIcon16 . "/empty.png '" . " alt='" . _EDIT . " title='" . planet_constant('MD_EMPTY_BLOG') . '</a></td>'; |
330 | 330 | |
331 | - echo '</tr>'; |
|
332 | - } |
|
333 | - echo "<tr class='even' align='center'>"; |
|
334 | - echo "<td colspan='7'>"; |
|
335 | - echo "<select name='op' onChange='if (this.options[this.selectedIndex].value==\"register\") {setVisible(\"catdiv\");} else {setHidden(\"catdiv\");}'>"; |
|
336 | - echo "<option value=''>" . _SELECT . '</option>'; |
|
337 | - echo "<option value='del'>" . _DELETE . '</option>'; |
|
338 | - echo "<option value='empty'>" . planet_constant('MD_EMPTY_BLOG') . '</option>'; |
|
339 | - echo "<option value='register'>" . planet_constant('AM_REGISTER') . '</option>'; |
|
340 | - if ($category_id > 0) { |
|
341 | - echo "<option value='remove'>" . planet_constant('AM_REMOVE') . '</option>'; |
|
342 | - } |
|
343 | - echo "<option value='approve'>" . planet_constant('AM_APPROVE') . '</option>'; |
|
344 | - echo "<option value='feature'>" . planet_constant('AM_FEATURE') . '</option>'; |
|
345 | - echo "<option value='update'>" . planet_constant('AM_UPDATE') . '</option>'; |
|
346 | - |
|
347 | - echo "<option value='pending'>" . planet_constant('AM_PENDING') . '</option>'; |
|
348 | - echo "<option value='active'>" . planet_constant('AM_ACTIVE') . '</option>'; |
|
349 | - |
|
350 | - echo '</select>'; |
|
351 | - echo "<div id='catdiv' style='visibility:hidden;display:inline;'>"; |
|
352 | - echo "<select name='category_dest'>"; |
|
353 | - echo "<option value=''>" . _SELECT . '</option>'; |
|
354 | - foreach ($categories as $cid => $name) { |
|
355 | - echo "<option value='" . $cid . "'>" . $name . '</option>'; |
|
356 | - } |
|
357 | - echo '</select>'; |
|
358 | - echo '</div>'; |
|
359 | - echo "<input name='start' value='" . $start . "' type='hidden'>"; |
|
360 | - echo "<input name='category' value='" . $category_id . "' type='hidden'>"; |
|
361 | - echo "<input name='submit' value='" . _SUBMIT . "' type='submit'>"; |
|
362 | - echo "<input name='' value='" . _CANCEL . "' type='reset'>"; |
|
363 | - echo '</td>'; |
|
364 | - echo '</tr>'; |
|
365 | - if ($blog_count > $xoopsModuleConfig['list_perpage']) { |
|
366 | - include XOOPS_ROOT_PATH . '/class/pagenav.php'; |
|
367 | - $nav = new XoopsPageNav($blog_count, $xoopsModuleConfig['list_perpage'], $start, 'start', 'category=' . $category_id); |
|
368 | - $pagenav = $nav->renderNav(4); |
|
369 | - echo "<tr align='right'><td colspan='6'>" . $pagenav . '</td></tr>'; |
|
370 | - } |
|
371 | - echo '</table></form>'; |
|
372 | - echo "</fieldset><br style='clear:both;'>"; |
|
373 | - |
|
374 | - if (empty($start) && empty($category_id)) { |
|
375 | - $form = new XoopsThemeForm(_ADD, 'edit', xoops_getenv('PHP_SELF'), 'post', true); |
|
376 | - $form->addElement(new XoopsFormText(planet_constant('AM_FEED'), 'blog_feed', 50, 255), true); |
|
377 | - $form->addElement(new XoopsFormHidden('op', 'edit')); |
|
378 | - $button_tray = new XoopsFormElementTray('', ''); |
|
379 | - $butt_save = new XoopsFormButton('', 'fetch', _SUBMIT, 'submit'); |
|
380 | - $button_tray->addElement($butt_save); |
|
381 | - $butt_cancel = new XoopsFormButton('', '', _CANCEL, 'reset'); |
|
382 | - $button_tray->addElement($butt_cancel); |
|
383 | - $form->addElement($button_tray); |
|
384 | - |
|
385 | - $form_add = new XoopsThemeForm(_ADD, 'add', xoops_getenv('PHP_SELF'), 'post', true); |
|
386 | - $form_add->addElement(new XoopsFormTextArea(planet_constant('AM_FEED'), 'links')); |
|
387 | - $form_add->addElement(new XoopsFormHidden('op', 'add')); |
|
388 | - $button_tray = new XoopsFormElementTray('', ''); |
|
389 | - $butt_save = new XoopsFormButton('', 'submit', _SUBMIT, 'submit'); |
|
390 | - $button_tray->addElement($butt_save); |
|
391 | - $butt_cancel = new XoopsFormButton('', '', _CANCEL, 'reset'); |
|
392 | - $button_tray->addElement($butt_cancel); |
|
393 | - $form_add->addElement($button_tray); |
|
394 | - |
|
395 | - echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _ADD . '</legend>'; |
|
396 | - echo '<br>'; |
|
397 | - $form->display(); |
|
398 | - $form_add->display(); |
|
399 | - echo '</fieldset>'; |
|
400 | - } |
|
401 | - break; |
|
331 | + echo '</tr>'; |
|
332 | + } |
|
333 | + echo "<tr class='even' align='center'>"; |
|
334 | + echo "<td colspan='7'>"; |
|
335 | + echo "<select name='op' onChange='if (this.options[this.selectedIndex].value==\"register\") {setVisible(\"catdiv\");} else {setHidden(\"catdiv\");}'>"; |
|
336 | + echo "<option value=''>" . _SELECT . '</option>'; |
|
337 | + echo "<option value='del'>" . _DELETE . '</option>'; |
|
338 | + echo "<option value='empty'>" . planet_constant('MD_EMPTY_BLOG') . '</option>'; |
|
339 | + echo "<option value='register'>" . planet_constant('AM_REGISTER') . '</option>'; |
|
340 | + if ($category_id > 0) { |
|
341 | + echo "<option value='remove'>" . planet_constant('AM_REMOVE') . '</option>'; |
|
342 | + } |
|
343 | + echo "<option value='approve'>" . planet_constant('AM_APPROVE') . '</option>'; |
|
344 | + echo "<option value='feature'>" . planet_constant('AM_FEATURE') . '</option>'; |
|
345 | + echo "<option value='update'>" . planet_constant('AM_UPDATE') . '</option>'; |
|
346 | + |
|
347 | + echo "<option value='pending'>" . planet_constant('AM_PENDING') . '</option>'; |
|
348 | + echo "<option value='active'>" . planet_constant('AM_ACTIVE') . '</option>'; |
|
349 | + |
|
350 | + echo '</select>'; |
|
351 | + echo "<div id='catdiv' style='visibility:hidden;display:inline;'>"; |
|
352 | + echo "<select name='category_dest'>"; |
|
353 | + echo "<option value=''>" . _SELECT . '</option>'; |
|
354 | + foreach ($categories as $cid => $name) { |
|
355 | + echo "<option value='" . $cid . "'>" . $name . '</option>'; |
|
356 | + } |
|
357 | + echo '</select>'; |
|
358 | + echo '</div>'; |
|
359 | + echo "<input name='start' value='" . $start . "' type='hidden'>"; |
|
360 | + echo "<input name='category' value='" . $category_id . "' type='hidden'>"; |
|
361 | + echo "<input name='submit' value='" . _SUBMIT . "' type='submit'>"; |
|
362 | + echo "<input name='' value='" . _CANCEL . "' type='reset'>"; |
|
363 | + echo '</td>'; |
|
364 | + echo '</tr>'; |
|
365 | + if ($blog_count > $xoopsModuleConfig['list_perpage']) { |
|
366 | + include XOOPS_ROOT_PATH . '/class/pagenav.php'; |
|
367 | + $nav = new XoopsPageNav($blog_count, $xoopsModuleConfig['list_perpage'], $start, 'start', 'category=' . $category_id); |
|
368 | + $pagenav = $nav->renderNav(4); |
|
369 | + echo "<tr align='right'><td colspan='6'>" . $pagenav . '</td></tr>'; |
|
370 | + } |
|
371 | + echo '</table></form>'; |
|
372 | + echo "</fieldset><br style='clear:both;'>"; |
|
373 | + |
|
374 | + if (empty($start) && empty($category_id)) { |
|
375 | + $form = new XoopsThemeForm(_ADD, 'edit', xoops_getenv('PHP_SELF'), 'post', true); |
|
376 | + $form->addElement(new XoopsFormText(planet_constant('AM_FEED'), 'blog_feed', 50, 255), true); |
|
377 | + $form->addElement(new XoopsFormHidden('op', 'edit')); |
|
378 | + $button_tray = new XoopsFormElementTray('', ''); |
|
379 | + $butt_save = new XoopsFormButton('', 'fetch', _SUBMIT, 'submit'); |
|
380 | + $button_tray->addElement($butt_save); |
|
381 | + $butt_cancel = new XoopsFormButton('', '', _CANCEL, 'reset'); |
|
382 | + $button_tray->addElement($butt_cancel); |
|
383 | + $form->addElement($button_tray); |
|
384 | + |
|
385 | + $form_add = new XoopsThemeForm(_ADD, 'add', xoops_getenv('PHP_SELF'), 'post', true); |
|
386 | + $form_add->addElement(new XoopsFormTextArea(planet_constant('AM_FEED'), 'links')); |
|
387 | + $form_add->addElement(new XoopsFormHidden('op', 'add')); |
|
388 | + $button_tray = new XoopsFormElementTray('', ''); |
|
389 | + $butt_save = new XoopsFormButton('', 'submit', _SUBMIT, 'submit'); |
|
390 | + $button_tray->addElement($butt_save); |
|
391 | + $butt_cancel = new XoopsFormButton('', '', _CANCEL, 'reset'); |
|
392 | + $button_tray->addElement($butt_cancel); |
|
393 | + $form_add->addElement($button_tray); |
|
394 | + |
|
395 | + echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _ADD . '</legend>'; |
|
396 | + echo '<br>'; |
|
397 | + $form->display(); |
|
398 | + $form_add->display(); |
|
399 | + echo '</fieldset>'; |
|
400 | + } |
|
401 | + break; |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | xoops_cp_footer(); |
@@ -57,348 +57,348 @@ |
||
57 | 57 | |
58 | 58 | switch ($op) { |
59 | 59 | /* save a single blog */ |
60 | - case 'save': |
|
61 | - |
|
62 | - if ($blog_id) { |
|
63 | - $blog_obj = $blogHandler->get($blog_id); |
|
64 | - } else { |
|
65 | - if ($blog_exists = $blogHandler->getCount(new Criteria('blog_feed', Request::getString('blog_feed', '', 'POST')))) { |
|
66 | - redirect_header('admin.blog.php', 2, planet_constant('AM_BLOGEXISTS')); |
|
67 | - } |
|
68 | - $blog_obj = $blogHandler->create(); |
|
69 | - $blog_obj->setVar('blog_submitter', $xoopsUser->getVar('uid')); |
|
70 | - } |
|
71 | - |
|
72 | - $blog_obj->setVar('blog_title', Request::getString('blog_title', '', 'POST')); //$_POST['blog_title']); |
|
73 | - $blog_obj->setVar('blog_desc', Request::getString('blog_desc', '', 'POST')); //$_POST['blog_desc']); |
|
74 | - $blog_obj->setVar('blog_image', Request::getString('blog_image', '', 'POST')); //$_POST['blog_image']); |
|
75 | - $blog_obj->setVar('blog_feed', Request::getString('blog_feed', '', 'POST')); //$_POST['blog_feed']); |
|
76 | - $blog_obj->setVar('blog_link', Request::getString('blog_link', '', 'POST')); //$_POST['blog_link']); |
|
77 | - $blog_obj->setVar('blog_language', Request::getString('blog_language', '', 'POST')); //$_POST['blog_language']); |
|
78 | - $blog_obj->setVar('blog_charset', Request::getString('blog_charset', '', 'POST')); //$_POST['blog_charset']); |
|
79 | - $blog_obj->setVar('blog_trackback', Request::getString('blog_trackback', '', 'POST')); //$_POST['blog_trackback']); |
|
80 | - $blog_obj->setVar('blog_status', Request::getInt('blog_status', 0, 'POST')); //$_POST['blog_status']); |
|
81 | - |
|
82 | - if (!$blogHandler->insert($blog_obj)) { |
|
83 | - } elseif (!empty(Request::getArray('categories', [], 'POST'))) { |
|
84 | - $blog_id = $blog_obj->getVar('blog_id'); |
|
85 | - if (in_array(0, Request::getArray('categories', [], 'POST'))) { |
|
86 | - $_POST['categories'] = []; |
|
87 | - } |
|
88 | - $blogHandler->setCategories($blog_id, Request::getArray('categories', [], 'POST')); |
|
89 | - } |
|
90 | - $message = planet_constant('AM_DBUPDATED'); |
|
91 | - redirect_header('admin.blog.php', 2, $message); |
|
92 | - |
|
93 | - /* fetch and add a list of blogs to a category */ |
|
94 | - // no break |
|
95 | - case 'add': |
|
96 | - $links = PlanetUtility::planetParseLinks(Request::getArray('links', [], 'POST')); |
|
97 | - $blogs = []; |
|
98 | - foreach ($links as $link) { |
|
99 | - if ($blog_exist = $blogHandler->getCount(new Criteria('blog_feed', $link['url']))) { |
|
100 | - continue; |
|
101 | - } |
|
102 | - $blog_obj = $blogHandler->fetch($link['url']); |
|
103 | - if (!empty($link['title'])) { |
|
104 | - $blog_obj->setVar('blog_title', $link['title']); |
|
105 | - } |
|
106 | - $blogHandler->insert($blog_obj); |
|
107 | - $blogs[] = $blog_obj->getVar('blog_id'); |
|
108 | - unset($blog_obj); |
|
109 | - } |
|
110 | - if (!empty(Request::getArray('categories', [], 'POST'))) { |
|
111 | - $categoryHandler = xoops_getModuleHandler('category', $GLOBALS['moddirname']); |
|
112 | - foreach (Request::getArray('categories', [], 'POST') as $cat_id) { |
|
113 | - $categoryHandler->addBlogs($cat_id, $blogs); |
|
114 | - } |
|
115 | - } |
|
116 | - $message = planet_constant('AM_DBUPDATED'); |
|
117 | - redirect_header('admin.blog.php', 2, $message); |
|
118 | - |
|
119 | - /* update a list of blogs */ |
|
120 | - // no break |
|
121 | - case 'update': |
|
122 | - foreach ($blog_id as $bid) { |
|
123 | - $blog_obj = $blogHandler->fetch($bid); |
|
124 | - if (!$blogHandler->insert($blog_obj)) { |
|
125 | - } |
|
126 | - unset($blog_obj); |
|
127 | - } |
|
128 | - $message = planet_constant('AM_DBUPDATED'); |
|
129 | - redirect_header('admin.blog.php?category=' . $category_id . '&start=' . $start, 2, $message); |
|
130 | - |
|
131 | - /* add a list of blogs to a category */ |
|
132 | - // no break |
|
133 | - case 'register': |
|
134 | - if (!empty(Request::getArray('category_dest', [], 'POST'))) { |
|
135 | - if (!is_array($blog_id)) { |
|
136 | - $blog_id = [$blog_id]; |
|
137 | - } |
|
138 | - $categoryHandler = xoops_getModuleHandler('category', $GLOBALS['moddirname']); |
|
139 | - $categoryHandler->addBlogs(Request::getArray('category_dest', [], 'POST'), $blog_id); |
|
140 | - } |
|
141 | - $message = planet_constant('AM_DBUPDATED'); |
|
142 | - redirect_header('admin.blog.php?category=' . Request::getArray('category_dest', [], 'POST') . '&start=' . $start, 2, $message); |
|
143 | - |
|
144 | - /* remove a list of blogs from a category */ |
|
145 | - // no break |
|
146 | - case 'remove': |
|
147 | - if (!is_array($blog_id)) { |
|
148 | - $blog_id = [$blog_id]; |
|
149 | - } |
|
150 | - if (!empty($category_id)) { |
|
151 | - $categoryHandler = xoops_getModuleHandler('category', $GLOBALS['moddirname']); |
|
152 | - $categoryHandler->removeBlogs($category_id, $blog_id); |
|
153 | - } |
|
154 | - $message = planet_constant('AM_DBUPDATED'); |
|
155 | - redirect_header('admin.blog.php?category=' . $category_id . '&start=' . $start, 2, $message); |
|
156 | - |
|
157 | - /* delete a single blog or a list blogs */ |
|
158 | - // no break |
|
159 | - case 'del': |
|
160 | - if (!is_array($blog_id)) { |
|
161 | - $blog_id = [$blog_id]; |
|
162 | - } |
|
163 | - foreach ($blog_id as $bid) { |
|
164 | - $blog_obj = $blogHandler->get($bid); |
|
165 | - if (!$blogHandler->delete($blog_obj, true)) { |
|
166 | - } |
|
167 | - unset($blog_obj); |
|
168 | - } |
|
169 | - $message = planet_constant('AM_DBUPDATED'); |
|
170 | - redirect_header('admin.blog.php?category=' . $category_id . '&start=' . $start, 2, $message); |
|
171 | - |
|
172 | - /* empty a single blog or a list blogs */ |
|
173 | - // no break |
|
174 | - case 'empty': |
|
175 | - if (!is_array($blog_id)) { |
|
176 | - $blog_id = [$blog_id]; |
|
177 | - } |
|
178 | - foreach ($blog_id as $bid) { |
|
179 | - $blog_obj = $blogHandler->get($bid); |
|
180 | - if (!$blogHandler->do_empty($blog_obj)) { |
|
181 | - } |
|
182 | - } |
|
183 | - $message = planet_constant('AM_DBUPDATED'); |
|
184 | - redirect_header('admin.blog.php?category=' . $category_id . '&start=' . $start, 2, $message); |
|
185 | - |
|
186 | - /* approve a single blog or a list blogs */ |
|
187 | - // no break |
|
188 | - case 'approve': |
|
189 | - if (!is_array($blog_id)) { |
|
190 | - $blog_id = [$blog_id]; |
|
191 | - } |
|
192 | - $criteria = new Criteria('blog_id', '(' . implode(',', $blog_id) . ')', 'IN'); |
|
193 | - $blogHandler->updateAll('blog_status', 1, $criteria, true); |
|
194 | - $message = planet_constant('AM_DBUPDATED'); |
|
195 | - redirect_header('admin.blog.php?category=' . $category_id . '&start=' . $start, 2, $message); |
|
196 | - |
|
197 | - /* mark a single blog or a list blogs as featured */ |
|
198 | - // no break |
|
199 | - case 'feature': |
|
200 | - if (!is_array($blog_id)) { |
|
201 | - $blog_id = [$blog_id]; |
|
202 | - } |
|
203 | - $criteria = new Criteria('blog_id', '(' . implode(',', $blog_id) . ')', 'IN'); |
|
204 | - $blogHandler->updateAll('blog_status', 2, $criteria, true); |
|
205 | - $message = planet_constant('AM_DBUPDATED'); |
|
206 | - redirect_header('admin.blog.php?category=' . $category_id . '&start=' . $start, 2, $message); |
|
207 | - |
|
208 | - /* edit a single blog */ |
|
209 | - // no break |
|
210 | - case 'edit': |
|
211 | - if (!empty(Request::getString('fetch', '', 'POST'))) { |
|
212 | - $blog_obj = $blogHandler->fetch(Request::getString('blog_feed', '', 'POST')); |
|
213 | - $blog_obj->setVar('blog_id', $blog_id); |
|
214 | - } else { |
|
215 | - $blog_obj = $blogHandler->get($blog_id); |
|
216 | - } |
|
217 | - $categories = Request::getArray('categories', [], 'POST'); |
|
218 | - if (empty($categories) && $blog_id > 0) { |
|
219 | - $crit = new Criteria('bc.blog_id', $blog_id); |
|
220 | - $categories = array_keys($categoryHandler->getByBlog($crit)); |
|
221 | - } |
|
222 | - if (empty($categories)) { |
|
223 | - $categories = [0 => _NONE]; |
|
224 | - } |
|
225 | - |
|
226 | - echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _EDIT . '</legend>'; |
|
227 | - echo '<br>'; |
|
228 | - if (empty($blog_id) && $blog_obj->getVar('blog_feed')) { |
|
229 | - $criteria = new Criteria('blog_feed', $blog_obj->getVar('blog_feed')); |
|
230 | - $blogs_obj = $blogHandler->getList($criteria); |
|
231 | - if (count($blogs_obj) > 0) { |
|
232 | - echo "<div class=\"errorMsg\">" . planet_constant('AM_BLOGEXISTS'); |
|
233 | - foreach (array_keys($blogs_obj) as $bid) { |
|
234 | - echo "<br><a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . URL_DELIMITER . 'b' . $bid . "\" target=\"_blank\">" . $blogs_obj[$bid] . '</a>'; |
|
235 | - } |
|
236 | - echo '</div>'; |
|
237 | - } |
|
238 | - unset($blogs_obj, $criteria); |
|
239 | - } |
|
240 | - include XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/include/form.blog.php'; |
|
241 | - echo '</fieldset>'; |
|
242 | - break; |
|
243 | - |
|
244 | - default: |
|
245 | - |
|
246 | - $crit = new Criteria('1', 1); |
|
247 | - $crit->setSort('cat_order'); |
|
248 | - $crit->setOrder('ASC'); |
|
249 | - $categories = $categoryHandler->getList($crit); |
|
250 | - |
|
251 | - // Display category option form |
|
252 | - $opform = new XoopsSimpleForm('', 'opform', 'admin.blog.php', 'get'); |
|
253 | - $op_select = new XoopsFormSelect('', 'category', $category_id); |
|
254 | - $op_select->setExtra('onchange="document.forms.opform.submit()"'); |
|
255 | - $options = [ |
|
256 | - '0' => _ALL, |
|
257 | - '-1' => planet_constant('MD_ACTIVE'), |
|
258 | - '-2' => planet_constant('MD_FEATURED'), |
|
259 | - '-3' => planet_constant('MD_PENDING') |
|
260 | - ]; |
|
261 | - foreach (array_keys($categories) as $key) { |
|
262 | - $options[$key] = $categories[$key]; |
|
263 | - } |
|
264 | - $op_select->addOptionArray($options); |
|
265 | - $opform->addElement($op_select); |
|
266 | - $opform->display(); |
|
267 | - |
|
268 | - if ($category_id > 0) { |
|
269 | - $criteria = new CriteriaCompo(new Criteria('b.blog_status', 0, '>')); |
|
270 | - $criteria->add(new Criteria('bc.cat_id', $category_id)); |
|
271 | - $blog_count = $blogHandler->getCountByCategory($criteria); |
|
272 | - $criteria->setStart($start); |
|
273 | - $criteria->setLimit($xoopsModuleConfig['list_perpage']); |
|
274 | - $blog_objs = $blogHandler->getByCategory($criteria); |
|
275 | - } else { |
|
276 | - /* All active blogs */ |
|
277 | - if (0 == $category_id) { |
|
278 | - $criteria = new Criteria('1', 1); |
|
279 | - $criteria->setStart($start); |
|
280 | - $criteria->setLimit($xoopsModuleConfig['list_perpage']); |
|
281 | - /* Active blogs */ |
|
282 | - } elseif ($category_id == -1) { |
|
283 | - $criteria = new Criteria('blog_status', 1); |
|
284 | - $criteria->setStart($start); |
|
285 | - $criteria->setLimit($xoopsModuleConfig['list_perpage']); |
|
286 | - /* Featured blogs */ |
|
287 | - } elseif ($category_id == -2) { |
|
288 | - $criteria = new Criteria('blog_status', 2); |
|
289 | - $criteria->setStart($start); |
|
290 | - $criteria->setLimit($xoopsModuleConfig['list_perpage']); |
|
291 | - /* Pending blogs */ |
|
292 | - } else { |
|
293 | - $criteria = new Criteria('blog_status', 0); |
|
294 | - $criteria->setStart($start); |
|
295 | - $criteria->setLimit($xoopsModuleConfig['list_perpage']); |
|
296 | - } |
|
297 | - $blog_count = $blogHandler->getCount($criteria); |
|
298 | - $blog_objs = $blogHandler->getAll($criteria); |
|
299 | - } |
|
300 | - |
|
301 | - echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . planet_constant('AM_LIST') . '</legend>'; |
|
302 | - echo "<br style=\"clear:both\">"; |
|
303 | - |
|
304 | - echo "<form name='list' id='list' method='post' action='" . xoops_getenv('PHP_SELF') . "'>"; |
|
305 | - echo "<table border='0' cellpadding='4' cellspacing='1' width='100%' class='outer'>"; |
|
306 | - echo "<tr align='center'>"; |
|
307 | - echo "<th class='bg3' width='5%'><input name='blog_check' id='blog_check' value='1' type='checkbox' onclick=\"xoopsCheckAll('list', 'blog_check');\"></td>"; |
|
308 | - echo "<th class='bg3'>" . planet_constant('AM_TITLE') . '</td>'; |
|
309 | - echo "<th class='bg3' width='5%'>" . planet_constant('AM_STATUS') . '</td>'; |
|
310 | - echo "<th class='bg3' width='40%'>" . planet_constant('AM_FEED') . '</td>'; |
|
311 | - // echo "<th class='bg3' width='5%'>" . _EDIT . "</td>"; |
|
312 | - // echo "<th class='bg3' width='5%'>" . _DELETE . "</td>"; |
|
313 | - echo "<th class='bg3' width='10%'>" . planet_constant('AM_ACTIONS') . '</td>'; |
|
314 | - echo '</tr>'; |
|
315 | - |
|
316 | - $status = [ |
|
317 | - '0' => planet_constant('MD_PENDING'), |
|
318 | - '1' => planet_constant('MD_ACTIVE'), |
|
319 | - '2' => planet_constant('MD_FEATURED') |
|
320 | - ]; |
|
321 | - foreach (array_keys($blog_objs) as $bid) { |
|
322 | - echo "<tr class='odd' align='left'>"; |
|
323 | - echo "<td align='center'><input name='blog[]' value='" . $bid . "' type='checkbox'></td>"; |
|
324 | - echo "<td><a href='" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . URL_DELIMITER . 'b' . $bid . "'>" . $blog_objs[$bid]->getVar('blog_title') . '</a></td>'; |
|
325 | - echo "<td align='center'>" . $status[$blog_objs[$bid]->getVar('blog_status')] . '</td>'; |
|
326 | - echo '<td>' . $blog_objs[$bid]->getVar('blog_feed') . '</td>'; |
|
327 | - echo "<td align='center'><a href='admin.blog.php?op=edit&blog=" . $bid . "' title='" . _EDIT . "'><img src='" . $pathIcon16 . "/edit.png '" . "alt='" . _EDIT . " title='" . _EDIT . " </a> |
|
60 | + case 'save': |
|
61 | + |
|
62 | + if ($blog_id) { |
|
63 | + $blog_obj = $blogHandler->get($blog_id); |
|
64 | + } else { |
|
65 | + if ($blog_exists = $blogHandler->getCount(new Criteria('blog_feed', Request::getString('blog_feed', '', 'POST')))) { |
|
66 | + redirect_header('admin.blog.php', 2, planet_constant('AM_BLOGEXISTS')); |
|
67 | + } |
|
68 | + $blog_obj = $blogHandler->create(); |
|
69 | + $blog_obj->setVar('blog_submitter', $xoopsUser->getVar('uid')); |
|
70 | + } |
|
71 | + |
|
72 | + $blog_obj->setVar('blog_title', Request::getString('blog_title', '', 'POST')); //$_POST['blog_title']); |
|
73 | + $blog_obj->setVar('blog_desc', Request::getString('blog_desc', '', 'POST')); //$_POST['blog_desc']); |
|
74 | + $blog_obj->setVar('blog_image', Request::getString('blog_image', '', 'POST')); //$_POST['blog_image']); |
|
75 | + $blog_obj->setVar('blog_feed', Request::getString('blog_feed', '', 'POST')); //$_POST['blog_feed']); |
|
76 | + $blog_obj->setVar('blog_link', Request::getString('blog_link', '', 'POST')); //$_POST['blog_link']); |
|
77 | + $blog_obj->setVar('blog_language', Request::getString('blog_language', '', 'POST')); //$_POST['blog_language']); |
|
78 | + $blog_obj->setVar('blog_charset', Request::getString('blog_charset', '', 'POST')); //$_POST['blog_charset']); |
|
79 | + $blog_obj->setVar('blog_trackback', Request::getString('blog_trackback', '', 'POST')); //$_POST['blog_trackback']); |
|
80 | + $blog_obj->setVar('blog_status', Request::getInt('blog_status', 0, 'POST')); //$_POST['blog_status']); |
|
81 | + |
|
82 | + if (!$blogHandler->insert($blog_obj)) { |
|
83 | + } elseif (!empty(Request::getArray('categories', [], 'POST'))) { |
|
84 | + $blog_id = $blog_obj->getVar('blog_id'); |
|
85 | + if (in_array(0, Request::getArray('categories', [], 'POST'))) { |
|
86 | + $_POST['categories'] = []; |
|
87 | + } |
|
88 | + $blogHandler->setCategories($blog_id, Request::getArray('categories', [], 'POST')); |
|
89 | + } |
|
90 | + $message = planet_constant('AM_DBUPDATED'); |
|
91 | + redirect_header('admin.blog.php', 2, $message); |
|
92 | + |
|
93 | + /* fetch and add a list of blogs to a category */ |
|
94 | + // no break |
|
95 | + case 'add': |
|
96 | + $links = PlanetUtility::planetParseLinks(Request::getArray('links', [], 'POST')); |
|
97 | + $blogs = []; |
|
98 | + foreach ($links as $link) { |
|
99 | + if ($blog_exist = $blogHandler->getCount(new Criteria('blog_feed', $link['url']))) { |
|
100 | + continue; |
|
101 | + } |
|
102 | + $blog_obj = $blogHandler->fetch($link['url']); |
|
103 | + if (!empty($link['title'])) { |
|
104 | + $blog_obj->setVar('blog_title', $link['title']); |
|
105 | + } |
|
106 | + $blogHandler->insert($blog_obj); |
|
107 | + $blogs[] = $blog_obj->getVar('blog_id'); |
|
108 | + unset($blog_obj); |
|
109 | + } |
|
110 | + if (!empty(Request::getArray('categories', [], 'POST'))) { |
|
111 | + $categoryHandler = xoops_getModuleHandler('category', $GLOBALS['moddirname']); |
|
112 | + foreach (Request::getArray('categories', [], 'POST') as $cat_id) { |
|
113 | + $categoryHandler->addBlogs($cat_id, $blogs); |
|
114 | + } |
|
115 | + } |
|
116 | + $message = planet_constant('AM_DBUPDATED'); |
|
117 | + redirect_header('admin.blog.php', 2, $message); |
|
118 | + |
|
119 | + /* update a list of blogs */ |
|
120 | + // no break |
|
121 | + case 'update': |
|
122 | + foreach ($blog_id as $bid) { |
|
123 | + $blog_obj = $blogHandler->fetch($bid); |
|
124 | + if (!$blogHandler->insert($blog_obj)) { |
|
125 | + } |
|
126 | + unset($blog_obj); |
|
127 | + } |
|
128 | + $message = planet_constant('AM_DBUPDATED'); |
|
129 | + redirect_header('admin.blog.php?category=' . $category_id . '&start=' . $start, 2, $message); |
|
130 | + |
|
131 | + /* add a list of blogs to a category */ |
|
132 | + // no break |
|
133 | + case 'register': |
|
134 | + if (!empty(Request::getArray('category_dest', [], 'POST'))) { |
|
135 | + if (!is_array($blog_id)) { |
|
136 | + $blog_id = [$blog_id]; |
|
137 | + } |
|
138 | + $categoryHandler = xoops_getModuleHandler('category', $GLOBALS['moddirname']); |
|
139 | + $categoryHandler->addBlogs(Request::getArray('category_dest', [], 'POST'), $blog_id); |
|
140 | + } |
|
141 | + $message = planet_constant('AM_DBUPDATED'); |
|
142 | + redirect_header('admin.blog.php?category=' . Request::getArray('category_dest', [], 'POST') . '&start=' . $start, 2, $message); |
|
143 | + |
|
144 | + /* remove a list of blogs from a category */ |
|
145 | + // no break |
|
146 | + case 'remove': |
|
147 | + if (!is_array($blog_id)) { |
|
148 | + $blog_id = [$blog_id]; |
|
149 | + } |
|
150 | + if (!empty($category_id)) { |
|
151 | + $categoryHandler = xoops_getModuleHandler('category', $GLOBALS['moddirname']); |
|
152 | + $categoryHandler->removeBlogs($category_id, $blog_id); |
|
153 | + } |
|
154 | + $message = planet_constant('AM_DBUPDATED'); |
|
155 | + redirect_header('admin.blog.php?category=' . $category_id . '&start=' . $start, 2, $message); |
|
156 | + |
|
157 | + /* delete a single blog or a list blogs */ |
|
158 | + // no break |
|
159 | + case 'del': |
|
160 | + if (!is_array($blog_id)) { |
|
161 | + $blog_id = [$blog_id]; |
|
162 | + } |
|
163 | + foreach ($blog_id as $bid) { |
|
164 | + $blog_obj = $blogHandler->get($bid); |
|
165 | + if (!$blogHandler->delete($blog_obj, true)) { |
|
166 | + } |
|
167 | + unset($blog_obj); |
|
168 | + } |
|
169 | + $message = planet_constant('AM_DBUPDATED'); |
|
170 | + redirect_header('admin.blog.php?category=' . $category_id . '&start=' . $start, 2, $message); |
|
171 | + |
|
172 | + /* empty a single blog or a list blogs */ |
|
173 | + // no break |
|
174 | + case 'empty': |
|
175 | + if (!is_array($blog_id)) { |
|
176 | + $blog_id = [$blog_id]; |
|
177 | + } |
|
178 | + foreach ($blog_id as $bid) { |
|
179 | + $blog_obj = $blogHandler->get($bid); |
|
180 | + if (!$blogHandler->do_empty($blog_obj)) { |
|
181 | + } |
|
182 | + } |
|
183 | + $message = planet_constant('AM_DBUPDATED'); |
|
184 | + redirect_header('admin.blog.php?category=' . $category_id . '&start=' . $start, 2, $message); |
|
185 | + |
|
186 | + /* approve a single blog or a list blogs */ |
|
187 | + // no break |
|
188 | + case 'approve': |
|
189 | + if (!is_array($blog_id)) { |
|
190 | + $blog_id = [$blog_id]; |
|
191 | + } |
|
192 | + $criteria = new Criteria('blog_id', '(' . implode(',', $blog_id) . ')', 'IN'); |
|
193 | + $blogHandler->updateAll('blog_status', 1, $criteria, true); |
|
194 | + $message = planet_constant('AM_DBUPDATED'); |
|
195 | + redirect_header('admin.blog.php?category=' . $category_id . '&start=' . $start, 2, $message); |
|
196 | + |
|
197 | + /* mark a single blog or a list blogs as featured */ |
|
198 | + // no break |
|
199 | + case 'feature': |
|
200 | + if (!is_array($blog_id)) { |
|
201 | + $blog_id = [$blog_id]; |
|
202 | + } |
|
203 | + $criteria = new Criteria('blog_id', '(' . implode(',', $blog_id) . ')', 'IN'); |
|
204 | + $blogHandler->updateAll('blog_status', 2, $criteria, true); |
|
205 | + $message = planet_constant('AM_DBUPDATED'); |
|
206 | + redirect_header('admin.blog.php?category=' . $category_id . '&start=' . $start, 2, $message); |
|
207 | + |
|
208 | + /* edit a single blog */ |
|
209 | + // no break |
|
210 | + case 'edit': |
|
211 | + if (!empty(Request::getString('fetch', '', 'POST'))) { |
|
212 | + $blog_obj = $blogHandler->fetch(Request::getString('blog_feed', '', 'POST')); |
|
213 | + $blog_obj->setVar('blog_id', $blog_id); |
|
214 | + } else { |
|
215 | + $blog_obj = $blogHandler->get($blog_id); |
|
216 | + } |
|
217 | + $categories = Request::getArray('categories', [], 'POST'); |
|
218 | + if (empty($categories) && $blog_id > 0) { |
|
219 | + $crit = new Criteria('bc.blog_id', $blog_id); |
|
220 | + $categories = array_keys($categoryHandler->getByBlog($crit)); |
|
221 | + } |
|
222 | + if (empty($categories)) { |
|
223 | + $categories = [0 => _NONE]; |
|
224 | + } |
|
225 | + |
|
226 | + echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _EDIT . '</legend>'; |
|
227 | + echo '<br>'; |
|
228 | + if (empty($blog_id) && $blog_obj->getVar('blog_feed')) { |
|
229 | + $criteria = new Criteria('blog_feed', $blog_obj->getVar('blog_feed')); |
|
230 | + $blogs_obj = $blogHandler->getList($criteria); |
|
231 | + if (count($blogs_obj) > 0) { |
|
232 | + echo "<div class=\"errorMsg\">" . planet_constant('AM_BLOGEXISTS'); |
|
233 | + foreach (array_keys($blogs_obj) as $bid) { |
|
234 | + echo "<br><a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . URL_DELIMITER . 'b' . $bid . "\" target=\"_blank\">" . $blogs_obj[$bid] . '</a>'; |
|
235 | + } |
|
236 | + echo '</div>'; |
|
237 | + } |
|
238 | + unset($blogs_obj, $criteria); |
|
239 | + } |
|
240 | + include XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/include/form.blog.php'; |
|
241 | + echo '</fieldset>'; |
|
242 | + break; |
|
243 | + |
|
244 | + default: |
|
245 | + |
|
246 | + $crit = new Criteria('1', 1); |
|
247 | + $crit->setSort('cat_order'); |
|
248 | + $crit->setOrder('ASC'); |
|
249 | + $categories = $categoryHandler->getList($crit); |
|
250 | + |
|
251 | + // Display category option form |
|
252 | + $opform = new XoopsSimpleForm('', 'opform', 'admin.blog.php', 'get'); |
|
253 | + $op_select = new XoopsFormSelect('', 'category', $category_id); |
|
254 | + $op_select->setExtra('onchange="document.forms.opform.submit()"'); |
|
255 | + $options = [ |
|
256 | + '0' => _ALL, |
|
257 | + '-1' => planet_constant('MD_ACTIVE'), |
|
258 | + '-2' => planet_constant('MD_FEATURED'), |
|
259 | + '-3' => planet_constant('MD_PENDING') |
|
260 | + ]; |
|
261 | + foreach (array_keys($categories) as $key) { |
|
262 | + $options[$key] = $categories[$key]; |
|
263 | + } |
|
264 | + $op_select->addOptionArray($options); |
|
265 | + $opform->addElement($op_select); |
|
266 | + $opform->display(); |
|
267 | + |
|
268 | + if ($category_id > 0) { |
|
269 | + $criteria = new CriteriaCompo(new Criteria('b.blog_status', 0, '>')); |
|
270 | + $criteria->add(new Criteria('bc.cat_id', $category_id)); |
|
271 | + $blog_count = $blogHandler->getCountByCategory($criteria); |
|
272 | + $criteria->setStart($start); |
|
273 | + $criteria->setLimit($xoopsModuleConfig['list_perpage']); |
|
274 | + $blog_objs = $blogHandler->getByCategory($criteria); |
|
275 | + } else { |
|
276 | + /* All active blogs */ |
|
277 | + if (0 == $category_id) { |
|
278 | + $criteria = new Criteria('1', 1); |
|
279 | + $criteria->setStart($start); |
|
280 | + $criteria->setLimit($xoopsModuleConfig['list_perpage']); |
|
281 | + /* Active blogs */ |
|
282 | + } elseif ($category_id == -1) { |
|
283 | + $criteria = new Criteria('blog_status', 1); |
|
284 | + $criteria->setStart($start); |
|
285 | + $criteria->setLimit($xoopsModuleConfig['list_perpage']); |
|
286 | + /* Featured blogs */ |
|
287 | + } elseif ($category_id == -2) { |
|
288 | + $criteria = new Criteria('blog_status', 2); |
|
289 | + $criteria->setStart($start); |
|
290 | + $criteria->setLimit($xoopsModuleConfig['list_perpage']); |
|
291 | + /* Pending blogs */ |
|
292 | + } else { |
|
293 | + $criteria = new Criteria('blog_status', 0); |
|
294 | + $criteria->setStart($start); |
|
295 | + $criteria->setLimit($xoopsModuleConfig['list_perpage']); |
|
296 | + } |
|
297 | + $blog_count = $blogHandler->getCount($criteria); |
|
298 | + $blog_objs = $blogHandler->getAll($criteria); |
|
299 | + } |
|
300 | + |
|
301 | + echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . planet_constant('AM_LIST') . '</legend>'; |
|
302 | + echo "<br style=\"clear:both\">"; |
|
303 | + |
|
304 | + echo "<form name='list' id='list' method='post' action='" . xoops_getenv('PHP_SELF') . "'>"; |
|
305 | + echo "<table border='0' cellpadding='4' cellspacing='1' width='100%' class='outer'>"; |
|
306 | + echo "<tr align='center'>"; |
|
307 | + echo "<th class='bg3' width='5%'><input name='blog_check' id='blog_check' value='1' type='checkbox' onclick=\"xoopsCheckAll('list', 'blog_check');\"></td>"; |
|
308 | + echo "<th class='bg3'>" . planet_constant('AM_TITLE') . '</td>'; |
|
309 | + echo "<th class='bg3' width='5%'>" . planet_constant('AM_STATUS') . '</td>'; |
|
310 | + echo "<th class='bg3' width='40%'>" . planet_constant('AM_FEED') . '</td>'; |
|
311 | + // echo "<th class='bg3' width='5%'>" . _EDIT . "</td>"; |
|
312 | + // echo "<th class='bg3' width='5%'>" . _DELETE . "</td>"; |
|
313 | + echo "<th class='bg3' width='10%'>" . planet_constant('AM_ACTIONS') . '</td>'; |
|
314 | + echo '</tr>'; |
|
315 | + |
|
316 | + $status = [ |
|
317 | + '0' => planet_constant('MD_PENDING'), |
|
318 | + '1' => planet_constant('MD_ACTIVE'), |
|
319 | + '2' => planet_constant('MD_FEATURED') |
|
320 | + ]; |
|
321 | + foreach (array_keys($blog_objs) as $bid) { |
|
322 | + echo "<tr class='odd' align='left'>"; |
|
323 | + echo "<td align='center'><input name='blog[]' value='" . $bid . "' type='checkbox'></td>"; |
|
324 | + echo "<td><a href='" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . URL_DELIMITER . 'b' . $bid . "'>" . $blog_objs[$bid]->getVar('blog_title') . '</a></td>'; |
|
325 | + echo "<td align='center'>" . $status[$blog_objs[$bid]->getVar('blog_status')] . '</td>'; |
|
326 | + echo '<td>' . $blog_objs[$bid]->getVar('blog_feed') . '</td>'; |
|
327 | + echo "<td align='center'><a href='admin.blog.php?op=edit&blog=" . $bid . "' title='" . _EDIT . "'><img src='" . $pathIcon16 . "/edit.png '" . "alt='" . _EDIT . " title='" . _EDIT . " </a> |
|
328 | 328 | <a href='admin.blog.php?op=del&blog=" . $bid . "' title='" . _DELETE . "'><img src='" . $pathIcon16 . "/delete.png '" . " alt='" . _EDIT . " title='" . _DELETE . " </a> |
329 | 329 | <a href='admin.blog.php?op=empty&blog=" . $bid . "' title='" . planet_constant('MD_EMPTY_BLOG') . "'><img src='" . $pathIcon16 . "/empty.png '" . " alt='" . _EDIT . " title='" . planet_constant('MD_EMPTY_BLOG') . '</a></td>'; |
330 | 330 | |
331 | - echo '</tr>'; |
|
332 | - } |
|
333 | - echo "<tr class='even' align='center'>"; |
|
334 | - echo "<td colspan='7'>"; |
|
335 | - echo "<select name='op' onChange='if (this.options[this.selectedIndex].value==\"register\") {setVisible(\"catdiv\");} else {setHidden(\"catdiv\");}'>"; |
|
336 | - echo "<option value=''>" . _SELECT . '</option>'; |
|
337 | - echo "<option value='del'>" . _DELETE . '</option>'; |
|
338 | - echo "<option value='empty'>" . planet_constant('MD_EMPTY_BLOG') . '</option>'; |
|
339 | - echo "<option value='register'>" . planet_constant('AM_REGISTER') . '</option>'; |
|
340 | - if ($category_id > 0) { |
|
341 | - echo "<option value='remove'>" . planet_constant('AM_REMOVE') . '</option>'; |
|
342 | - } |
|
343 | - echo "<option value='approve'>" . planet_constant('AM_APPROVE') . '</option>'; |
|
344 | - echo "<option value='feature'>" . planet_constant('AM_FEATURE') . '</option>'; |
|
345 | - echo "<option value='update'>" . planet_constant('AM_UPDATE') . '</option>'; |
|
346 | - |
|
347 | - echo "<option value='pending'>" . planet_constant('AM_PENDING') . '</option>'; |
|
348 | - echo "<option value='active'>" . planet_constant('AM_ACTIVE') . '</option>'; |
|
349 | - |
|
350 | - echo '</select>'; |
|
351 | - echo "<div id='catdiv' style='visibility:hidden;display:inline;'>"; |
|
352 | - echo "<select name='category_dest'>"; |
|
353 | - echo "<option value=''>" . _SELECT . '</option>'; |
|
354 | - foreach ($categories as $cid => $name) { |
|
355 | - echo "<option value='" . $cid . "'>" . $name . '</option>'; |
|
356 | - } |
|
357 | - echo '</select>'; |
|
358 | - echo '</div>'; |
|
359 | - echo "<input name='start' value='" . $start . "' type='hidden'>"; |
|
360 | - echo "<input name='category' value='" . $category_id . "' type='hidden'>"; |
|
361 | - echo "<input name='submit' value='" . _SUBMIT . "' type='submit'>"; |
|
362 | - echo "<input name='' value='" . _CANCEL . "' type='reset'>"; |
|
363 | - echo '</td>'; |
|
364 | - echo '</tr>'; |
|
365 | - if ($blog_count > $xoopsModuleConfig['list_perpage']) { |
|
366 | - include XOOPS_ROOT_PATH . '/class/pagenav.php'; |
|
367 | - $nav = new XoopsPageNav($blog_count, $xoopsModuleConfig['list_perpage'], $start, 'start', 'category=' . $category_id); |
|
368 | - $pagenav = $nav->renderNav(4); |
|
369 | - echo "<tr align='right'><td colspan='6'>" . $pagenav . '</td></tr>'; |
|
370 | - } |
|
371 | - echo '</table></form>'; |
|
372 | - echo "</fieldset><br style='clear:both;'>"; |
|
373 | - |
|
374 | - if (empty($start) && empty($category_id)) { |
|
375 | - $form = new XoopsThemeForm(_ADD, 'edit', xoops_getenv('PHP_SELF'), 'post', true); |
|
376 | - $form->addElement(new XoopsFormText(planet_constant('AM_FEED'), 'blog_feed', 50, 255), true); |
|
377 | - $form->addElement(new XoopsFormHidden('op', 'edit')); |
|
378 | - $button_tray = new XoopsFormElementTray('', ''); |
|
379 | - $butt_save = new XoopsFormButton('', 'fetch', _SUBMIT, 'submit'); |
|
380 | - $button_tray->addElement($butt_save); |
|
381 | - $butt_cancel = new XoopsFormButton('', '', _CANCEL, 'reset'); |
|
382 | - $button_tray->addElement($butt_cancel); |
|
383 | - $form->addElement($button_tray); |
|
384 | - |
|
385 | - $form_add = new XoopsThemeForm(_ADD, 'add', xoops_getenv('PHP_SELF'), 'post', true); |
|
386 | - $form_add->addElement(new XoopsFormTextArea(planet_constant('AM_FEED'), 'links')); |
|
387 | - $form_add->addElement(new XoopsFormHidden('op', 'add')); |
|
388 | - $button_tray = new XoopsFormElementTray('', ''); |
|
389 | - $butt_save = new XoopsFormButton('', 'submit', _SUBMIT, 'submit'); |
|
390 | - $button_tray->addElement($butt_save); |
|
391 | - $butt_cancel = new XoopsFormButton('', '', _CANCEL, 'reset'); |
|
392 | - $button_tray->addElement($butt_cancel); |
|
393 | - $form_add->addElement($button_tray); |
|
394 | - |
|
395 | - echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _ADD . '</legend>'; |
|
396 | - echo '<br>'; |
|
397 | - $form->display(); |
|
398 | - $form_add->display(); |
|
399 | - echo '</fieldset>'; |
|
400 | - } |
|
401 | - break; |
|
331 | + echo '</tr>'; |
|
332 | + } |
|
333 | + echo "<tr class='even' align='center'>"; |
|
334 | + echo "<td colspan='7'>"; |
|
335 | + echo "<select name='op' onChange='if (this.options[this.selectedIndex].value==\"register\") {setVisible(\"catdiv\");} else {setHidden(\"catdiv\");}'>"; |
|
336 | + echo "<option value=''>" . _SELECT . '</option>'; |
|
337 | + echo "<option value='del'>" . _DELETE . '</option>'; |
|
338 | + echo "<option value='empty'>" . planet_constant('MD_EMPTY_BLOG') . '</option>'; |
|
339 | + echo "<option value='register'>" . planet_constant('AM_REGISTER') . '</option>'; |
|
340 | + if ($category_id > 0) { |
|
341 | + echo "<option value='remove'>" . planet_constant('AM_REMOVE') . '</option>'; |
|
342 | + } |
|
343 | + echo "<option value='approve'>" . planet_constant('AM_APPROVE') . '</option>'; |
|
344 | + echo "<option value='feature'>" . planet_constant('AM_FEATURE') . '</option>'; |
|
345 | + echo "<option value='update'>" . planet_constant('AM_UPDATE') . '</option>'; |
|
346 | + |
|
347 | + echo "<option value='pending'>" . planet_constant('AM_PENDING') . '</option>'; |
|
348 | + echo "<option value='active'>" . planet_constant('AM_ACTIVE') . '</option>'; |
|
349 | + |
|
350 | + echo '</select>'; |
|
351 | + echo "<div id='catdiv' style='visibility:hidden;display:inline;'>"; |
|
352 | + echo "<select name='category_dest'>"; |
|
353 | + echo "<option value=''>" . _SELECT . '</option>'; |
|
354 | + foreach ($categories as $cid => $name) { |
|
355 | + echo "<option value='" . $cid . "'>" . $name . '</option>'; |
|
356 | + } |
|
357 | + echo '</select>'; |
|
358 | + echo '</div>'; |
|
359 | + echo "<input name='start' value='" . $start . "' type='hidden'>"; |
|
360 | + echo "<input name='category' value='" . $category_id . "' type='hidden'>"; |
|
361 | + echo "<input name='submit' value='" . _SUBMIT . "' type='submit'>"; |
|
362 | + echo "<input name='' value='" . _CANCEL . "' type='reset'>"; |
|
363 | + echo '</td>'; |
|
364 | + echo '</tr>'; |
|
365 | + if ($blog_count > $xoopsModuleConfig['list_perpage']) { |
|
366 | + include XOOPS_ROOT_PATH . '/class/pagenav.php'; |
|
367 | + $nav = new XoopsPageNav($blog_count, $xoopsModuleConfig['list_perpage'], $start, 'start', 'category=' . $category_id); |
|
368 | + $pagenav = $nav->renderNav(4); |
|
369 | + echo "<tr align='right'><td colspan='6'>" . $pagenav . '</td></tr>'; |
|
370 | + } |
|
371 | + echo '</table></form>'; |
|
372 | + echo "</fieldset><br style='clear:both;'>"; |
|
373 | + |
|
374 | + if (empty($start) && empty($category_id)) { |
|
375 | + $form = new XoopsThemeForm(_ADD, 'edit', xoops_getenv('PHP_SELF'), 'post', true); |
|
376 | + $form->addElement(new XoopsFormText(planet_constant('AM_FEED'), 'blog_feed', 50, 255), true); |
|
377 | + $form->addElement(new XoopsFormHidden('op', 'edit')); |
|
378 | + $button_tray = new XoopsFormElementTray('', ''); |
|
379 | + $butt_save = new XoopsFormButton('', 'fetch', _SUBMIT, 'submit'); |
|
380 | + $button_tray->addElement($butt_save); |
|
381 | + $butt_cancel = new XoopsFormButton('', '', _CANCEL, 'reset'); |
|
382 | + $button_tray->addElement($butt_cancel); |
|
383 | + $form->addElement($button_tray); |
|
384 | + |
|
385 | + $form_add = new XoopsThemeForm(_ADD, 'add', xoops_getenv('PHP_SELF'), 'post', true); |
|
386 | + $form_add->addElement(new XoopsFormTextArea(planet_constant('AM_FEED'), 'links')); |
|
387 | + $form_add->addElement(new XoopsFormHidden('op', 'add')); |
|
388 | + $button_tray = new XoopsFormElementTray('', ''); |
|
389 | + $butt_save = new XoopsFormButton('', 'submit', _SUBMIT, 'submit'); |
|
390 | + $button_tray->addElement($butt_save); |
|
391 | + $butt_cancel = new XoopsFormButton('', '', _CANCEL, 'reset'); |
|
392 | + $button_tray->addElement($butt_cancel); |
|
393 | + $form_add->addElement($button_tray); |
|
394 | + |
|
395 | + echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _ADD . '</legend>'; |
|
396 | + echo '<br>'; |
|
397 | + $form->display(); |
|
398 | + $form_add->display(); |
|
399 | + echo '</fieldset>'; |
|
400 | + } |
|
401 | + break; |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | xoops_cp_footer(); |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | // ------------------------------------------------------------------------ // |
27 | 27 | use Xmf\Request; |
28 | 28 | |
29 | -require_once __DIR__ . '/admin_header.php'; |
|
30 | -require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
|
29 | +require_once __DIR__.'/admin_header.php'; |
|
30 | +require_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php'; |
|
31 | 31 | |
32 | 32 | xoops_cp_header(); |
33 | 33 | $adminObject = \Xmf\Module\Admin::getInstance(); |
@@ -39,14 +39,14 @@ discard block |
||
39 | 39 | * This is a tricky fix for incomplete solution of module cone |
40 | 40 | * it is expected to have a better solution in article 1.0 |
41 | 41 | */ |
42 | -require XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/include/vars.php'; |
|
42 | +require XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/include/vars.php'; |
|
43 | 43 | //planet_adminmenu(2); |
44 | 44 | |
45 | -$op = Request::getString('op', Request::getString('op', '', 'POST'), 'GET');//!empty($_POST['op']) ? $_POST['op'] : (!empty($_GET['op']) ? $_GET['op'] : ''); |
|
46 | -$blog_id = Request::getArray('blog', Request::getArray('blog', [], 'POST'), 'GET');//!empty($_POST['blog']) ? $_POST['blog'] : (!empty($_GET['blog']) ? $_GET['blog'] : 0); |
|
47 | -$blog_id = is_array($blog_id) ? array_map('intval', $blog_id) : (int)$blog_id; |
|
48 | -$category_id = Request::getInt('category', Request::getInt('category', 0, 'POST'), 'GET');//(int)(!empty($_POST['category']) ? $_POST['category'] : (!empty($_GET['category']) ? $_GET['category'] : 0)); |
|
49 | -$start = Request::getInt('start', Request::getInt('start', 0, 'POST'), 'GET');//(int)(!empty($_POST['start']) ? $_POST['start'] : (!empty($_GET['start']) ? $_GET['start'] : 0)); |
|
45 | +$op = Request::getString('op', Request::getString('op', '', 'POST'), 'GET'); //!empty($_POST['op']) ? $_POST['op'] : (!empty($_GET['op']) ? $_GET['op'] : ''); |
|
46 | +$blog_id = Request::getArray('blog', Request::getArray('blog', [], 'POST'), 'GET'); //!empty($_POST['blog']) ? $_POST['blog'] : (!empty($_GET['blog']) ? $_GET['blog'] : 0); |
|
47 | +$blog_id = is_array($blog_id) ? array_map('intval', $blog_id) : (int) $blog_id; |
|
48 | +$category_id = Request::getInt('category', Request::getInt('category', 0, 'POST'), 'GET'); //(int)(!empty($_POST['category']) ? $_POST['category'] : (!empty($_GET['category']) ? $_GET['category'] : 0)); |
|
49 | +$start = Request::getInt('start', Request::getInt('start', 0, 'POST'), 'GET'); //(int)(!empty($_POST['start']) ? $_POST['start'] : (!empty($_GET['start']) ? $_GET['start'] : 0)); |
|
50 | 50 | |
51 | 51 | $blogHandler = xoops_getModuleHandler('blog', $GLOBALS['moddirname']); |
52 | 52 | $categoryHandler = xoops_getModuleHandler('category', $GLOBALS['moddirname']); |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | |
62 | 62 | if ($blog_id) { |
63 | 63 | $blog_obj = $blogHandler->get($blog_id); |
64 | - } else { |
|
64 | + }else { |
|
65 | 65 | if ($blog_exists = $blogHandler->getCount(new Criteria('blog_feed', Request::getString('blog_feed', '', 'POST')))) { |
66 | 66 | redirect_header('admin.blog.php', 2, planet_constant('AM_BLOGEXISTS')); |
67 | 67 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | unset($blog_obj); |
127 | 127 | } |
128 | 128 | $message = planet_constant('AM_DBUPDATED'); |
129 | - redirect_header('admin.blog.php?category=' . $category_id . '&start=' . $start, 2, $message); |
|
129 | + redirect_header('admin.blog.php?category='.$category_id.'&start='.$start, 2, $message); |
|
130 | 130 | |
131 | 131 | /* add a list of blogs to a category */ |
132 | 132 | // no break |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | $categoryHandler->addBlogs(Request::getArray('category_dest', [], 'POST'), $blog_id); |
140 | 140 | } |
141 | 141 | $message = planet_constant('AM_DBUPDATED'); |
142 | - redirect_header('admin.blog.php?category=' . Request::getArray('category_dest', [], 'POST') . '&start=' . $start, 2, $message); |
|
142 | + redirect_header('admin.blog.php?category='.Request::getArray('category_dest', [], 'POST').'&start='.$start, 2, $message); |
|
143 | 143 | |
144 | 144 | /* remove a list of blogs from a category */ |
145 | 145 | // no break |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | $categoryHandler->removeBlogs($category_id, $blog_id); |
153 | 153 | } |
154 | 154 | $message = planet_constant('AM_DBUPDATED'); |
155 | - redirect_header('admin.blog.php?category=' . $category_id . '&start=' . $start, 2, $message); |
|
155 | + redirect_header('admin.blog.php?category='.$category_id.'&start='.$start, 2, $message); |
|
156 | 156 | |
157 | 157 | /* delete a single blog or a list blogs */ |
158 | 158 | // no break |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | unset($blog_obj); |
168 | 168 | } |
169 | 169 | $message = planet_constant('AM_DBUPDATED'); |
170 | - redirect_header('admin.blog.php?category=' . $category_id . '&start=' . $start, 2, $message); |
|
170 | + redirect_header('admin.blog.php?category='.$category_id.'&start='.$start, 2, $message); |
|
171 | 171 | |
172 | 172 | /* empty a single blog or a list blogs */ |
173 | 173 | // no break |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | } |
182 | 182 | } |
183 | 183 | $message = planet_constant('AM_DBUPDATED'); |
184 | - redirect_header('admin.blog.php?category=' . $category_id . '&start=' . $start, 2, $message); |
|
184 | + redirect_header('admin.blog.php?category='.$category_id.'&start='.$start, 2, $message); |
|
185 | 185 | |
186 | 186 | /* approve a single blog or a list blogs */ |
187 | 187 | // no break |
@@ -189,10 +189,10 @@ discard block |
||
189 | 189 | if (!is_array($blog_id)) { |
190 | 190 | $blog_id = [$blog_id]; |
191 | 191 | } |
192 | - $criteria = new Criteria('blog_id', '(' . implode(',', $blog_id) . ')', 'IN'); |
|
192 | + $criteria = new Criteria('blog_id', '('.implode(',', $blog_id).')', 'IN'); |
|
193 | 193 | $blogHandler->updateAll('blog_status', 1, $criteria, true); |
194 | 194 | $message = planet_constant('AM_DBUPDATED'); |
195 | - redirect_header('admin.blog.php?category=' . $category_id . '&start=' . $start, 2, $message); |
|
195 | + redirect_header('admin.blog.php?category='.$category_id.'&start='.$start, 2, $message); |
|
196 | 196 | |
197 | 197 | /* mark a single blog or a list blogs as featured */ |
198 | 198 | // no break |
@@ -200,10 +200,10 @@ discard block |
||
200 | 200 | if (!is_array($blog_id)) { |
201 | 201 | $blog_id = [$blog_id]; |
202 | 202 | } |
203 | - $criteria = new Criteria('blog_id', '(' . implode(',', $blog_id) . ')', 'IN'); |
|
203 | + $criteria = new Criteria('blog_id', '('.implode(',', $blog_id).')', 'IN'); |
|
204 | 204 | $blogHandler->updateAll('blog_status', 2, $criteria, true); |
205 | 205 | $message = planet_constant('AM_DBUPDATED'); |
206 | - redirect_header('admin.blog.php?category=' . $category_id . '&start=' . $start, 2, $message); |
|
206 | + redirect_header('admin.blog.php?category='.$category_id.'&start='.$start, 2, $message); |
|
207 | 207 | |
208 | 208 | /* edit a single blog */ |
209 | 209 | // no break |
@@ -211,11 +211,11 @@ discard block |
||
211 | 211 | if (!empty(Request::getString('fetch', '', 'POST'))) { |
212 | 212 | $blog_obj = $blogHandler->fetch(Request::getString('blog_feed', '', 'POST')); |
213 | 213 | $blog_obj->setVar('blog_id', $blog_id); |
214 | - } else { |
|
214 | + }else { |
|
215 | 215 | $blog_obj = $blogHandler->get($blog_id); |
216 | 216 | } |
217 | 217 | $categories = Request::getArray('categories', [], 'POST'); |
218 | - if (empty($categories) && $blog_id > 0) { |
|
218 | + if (empty($categories) && $blog_id>0) { |
|
219 | 219 | $crit = new Criteria('bc.blog_id', $blog_id); |
220 | 220 | $categories = array_keys($categoryHandler->getByBlog($crit)); |
221 | 221 | } |
@@ -223,21 +223,21 @@ discard block |
||
223 | 223 | $categories = [0 => _NONE]; |
224 | 224 | } |
225 | 225 | |
226 | - echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _EDIT . '</legend>'; |
|
226 | + echo "<fieldset><legend style='font-weight: bold; color: #900;'>"._EDIT.'</legend>'; |
|
227 | 227 | echo '<br>'; |
228 | 228 | if (empty($blog_id) && $blog_obj->getVar('blog_feed')) { |
229 | 229 | $criteria = new Criteria('blog_feed', $blog_obj->getVar('blog_feed')); |
230 | 230 | $blogs_obj = $blogHandler->getList($criteria); |
231 | - if (count($blogs_obj) > 0) { |
|
232 | - echo "<div class=\"errorMsg\">" . planet_constant('AM_BLOGEXISTS'); |
|
231 | + if (count($blogs_obj)>0) { |
|
232 | + echo "<div class=\"errorMsg\">".planet_constant('AM_BLOGEXISTS'); |
|
233 | 233 | foreach (array_keys($blogs_obj) as $bid) { |
234 | - echo "<br><a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . URL_DELIMITER . 'b' . $bid . "\" target=\"_blank\">" . $blogs_obj[$bid] . '</a>'; |
|
234 | + echo "<br><a href=\"".XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/index.php'.URL_DELIMITER.'b'.$bid."\" target=\"_blank\">".$blogs_obj[$bid].'</a>'; |
|
235 | 235 | } |
236 | 236 | echo '</div>'; |
237 | 237 | } |
238 | 238 | unset($blogs_obj, $criteria); |
239 | 239 | } |
240 | - include XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/include/form.blog.php'; |
|
240 | + include XOOPS_ROOT_PATH.'/modules/'.$GLOBALS['moddirname'].'/include/form.blog.php'; |
|
241 | 241 | echo '</fieldset>'; |
242 | 242 | break; |
243 | 243 | |
@@ -265,14 +265,14 @@ discard block |
||
265 | 265 | $opform->addElement($op_select); |
266 | 266 | $opform->display(); |
267 | 267 | |
268 | - if ($category_id > 0) { |
|
268 | + if ($category_id>0) { |
|
269 | 269 | $criteria = new CriteriaCompo(new Criteria('b.blog_status', 0, '>')); |
270 | 270 | $criteria->add(new Criteria('bc.cat_id', $category_id)); |
271 | 271 | $blog_count = $blogHandler->getCountByCategory($criteria); |
272 | 272 | $criteria->setStart($start); |
273 | 273 | $criteria->setLimit($xoopsModuleConfig['list_perpage']); |
274 | 274 | $blog_objs = $blogHandler->getByCategory($criteria); |
275 | - } else { |
|
275 | + }else { |
|
276 | 276 | /* All active blogs */ |
277 | 277 | if (0 == $category_id) { |
278 | 278 | $criteria = new Criteria('1', 1); |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | $criteria->setStart($start); |
290 | 290 | $criteria->setLimit($xoopsModuleConfig['list_perpage']); |
291 | 291 | /* Pending blogs */ |
292 | - } else { |
|
292 | + }else { |
|
293 | 293 | $criteria = new Criteria('blog_status', 0); |
294 | 294 | $criteria->setStart($start); |
295 | 295 | $criteria->setLimit($xoopsModuleConfig['list_perpage']); |
@@ -298,19 +298,19 @@ discard block |
||
298 | 298 | $blog_objs = $blogHandler->getAll($criteria); |
299 | 299 | } |
300 | 300 | |
301 | - echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . planet_constant('AM_LIST') . '</legend>'; |
|
301 | + echo "<fieldset><legend style='font-weight: bold; color: #900;'>".planet_constant('AM_LIST').'</legend>'; |
|
302 | 302 | echo "<br style=\"clear:both\">"; |
303 | 303 | |
304 | - echo "<form name='list' id='list' method='post' action='" . xoops_getenv('PHP_SELF') . "'>"; |
|
304 | + echo "<form name='list' id='list' method='post' action='".xoops_getenv('PHP_SELF')."'>"; |
|
305 | 305 | echo "<table border='0' cellpadding='4' cellspacing='1' width='100%' class='outer'>"; |
306 | 306 | echo "<tr align='center'>"; |
307 | 307 | echo "<th class='bg3' width='5%'><input name='blog_check' id='blog_check' value='1' type='checkbox' onclick=\"xoopsCheckAll('list', 'blog_check');\"></td>"; |
308 | - echo "<th class='bg3'>" . planet_constant('AM_TITLE') . '</td>'; |
|
309 | - echo "<th class='bg3' width='5%'>" . planet_constant('AM_STATUS') . '</td>'; |
|
310 | - echo "<th class='bg3' width='40%'>" . planet_constant('AM_FEED') . '</td>'; |
|
308 | + echo "<th class='bg3'>".planet_constant('AM_TITLE').'</td>'; |
|
309 | + echo "<th class='bg3' width='5%'>".planet_constant('AM_STATUS').'</td>'; |
|
310 | + echo "<th class='bg3' width='40%'>".planet_constant('AM_FEED').'</td>'; |
|
311 | 311 | // echo "<th class='bg3' width='5%'>" . _EDIT . "</td>"; |
312 | 312 | // echo "<th class='bg3' width='5%'>" . _DELETE . "</td>"; |
313 | - echo "<th class='bg3' width='10%'>" . planet_constant('AM_ACTIONS') . '</td>'; |
|
313 | + echo "<th class='bg3' width='10%'>".planet_constant('AM_ACTIONS').'</td>'; |
|
314 | 314 | echo '</tr>'; |
315 | 315 | |
316 | 316 | $status = [ |
@@ -320,53 +320,53 @@ discard block |
||
320 | 320 | ]; |
321 | 321 | foreach (array_keys($blog_objs) as $bid) { |
322 | 322 | echo "<tr class='odd' align='left'>"; |
323 | - echo "<td align='center'><input name='blog[]' value='" . $bid . "' type='checkbox'></td>"; |
|
324 | - echo "<td><a href='" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . URL_DELIMITER . 'b' . $bid . "'>" . $blog_objs[$bid]->getVar('blog_title') . '</a></td>'; |
|
325 | - echo "<td align='center'>" . $status[$blog_objs[$bid]->getVar('blog_status')] . '</td>'; |
|
326 | - echo '<td>' . $blog_objs[$bid]->getVar('blog_feed') . '</td>'; |
|
327 | - echo "<td align='center'><a href='admin.blog.php?op=edit&blog=" . $bid . "' title='" . _EDIT . "'><img src='" . $pathIcon16 . "/edit.png '" . "alt='" . _EDIT . " title='" . _EDIT . " </a> |
|
328 | - <a href='admin.blog.php?op=del&blog=" . $bid . "' title='" . _DELETE . "'><img src='" . $pathIcon16 . "/delete.png '" . " alt='" . _EDIT . " title='" . _DELETE . " </a> |
|
329 | - <a href='admin.blog.php?op=empty&blog=" . $bid . "' title='" . planet_constant('MD_EMPTY_BLOG') . "'><img src='" . $pathIcon16 . "/empty.png '" . " alt='" . _EDIT . " title='" . planet_constant('MD_EMPTY_BLOG') . '</a></td>'; |
|
323 | + echo "<td align='center'><input name='blog[]' value='".$bid."' type='checkbox'></td>"; |
|
324 | + echo "<td><a href='".XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/index.php'.URL_DELIMITER.'b'.$bid."'>".$blog_objs[$bid]->getVar('blog_title').'</a></td>'; |
|
325 | + echo "<td align='center'>".$status[$blog_objs[$bid]->getVar('blog_status')].'</td>'; |
|
326 | + echo '<td>'.$blog_objs[$bid]->getVar('blog_feed').'</td>'; |
|
327 | + echo "<td align='center'><a href='admin.blog.php?op=edit&blog=".$bid."' title='"._EDIT."'><img src='".$pathIcon16."/edit.png '"."alt='"._EDIT." title='"._EDIT." </a> |
|
328 | + <a href='admin.blog.php?op=del&blog=" . $bid."' title='"._DELETE."'><img src='".$pathIcon16."/delete.png '"." alt='"._EDIT." title='"._DELETE." </a> |
|
329 | + <a href='admin.blog.php?op=empty&blog=" . $bid."' title='".planet_constant('MD_EMPTY_BLOG')."'><img src='".$pathIcon16."/empty.png '"." alt='"._EDIT." title='".planet_constant('MD_EMPTY_BLOG').'</a></td>'; |
|
330 | 330 | |
331 | 331 | echo '</tr>'; |
332 | 332 | } |
333 | 333 | echo "<tr class='even' align='center'>"; |
334 | 334 | echo "<td colspan='7'>"; |
335 | 335 | echo "<select name='op' onChange='if (this.options[this.selectedIndex].value==\"register\") {setVisible(\"catdiv\");} else {setHidden(\"catdiv\");}'>"; |
336 | - echo "<option value=''>" . _SELECT . '</option>'; |
|
337 | - echo "<option value='del'>" . _DELETE . '</option>'; |
|
338 | - echo "<option value='empty'>" . planet_constant('MD_EMPTY_BLOG') . '</option>'; |
|
339 | - echo "<option value='register'>" . planet_constant('AM_REGISTER') . '</option>'; |
|
340 | - if ($category_id > 0) { |
|
341 | - echo "<option value='remove'>" . planet_constant('AM_REMOVE') . '</option>'; |
|
336 | + echo "<option value=''>"._SELECT.'</option>'; |
|
337 | + echo "<option value='del'>"._DELETE.'</option>'; |
|
338 | + echo "<option value='empty'>".planet_constant('MD_EMPTY_BLOG').'</option>'; |
|
339 | + echo "<option value='register'>".planet_constant('AM_REGISTER').'</option>'; |
|
340 | + if ($category_id>0) { |
|
341 | + echo "<option value='remove'>".planet_constant('AM_REMOVE').'</option>'; |
|
342 | 342 | } |
343 | - echo "<option value='approve'>" . planet_constant('AM_APPROVE') . '</option>'; |
|
344 | - echo "<option value='feature'>" . planet_constant('AM_FEATURE') . '</option>'; |
|
345 | - echo "<option value='update'>" . planet_constant('AM_UPDATE') . '</option>'; |
|
343 | + echo "<option value='approve'>".planet_constant('AM_APPROVE').'</option>'; |
|
344 | + echo "<option value='feature'>".planet_constant('AM_FEATURE').'</option>'; |
|
345 | + echo "<option value='update'>".planet_constant('AM_UPDATE').'</option>'; |
|
346 | 346 | |
347 | - echo "<option value='pending'>" . planet_constant('AM_PENDING') . '</option>'; |
|
348 | - echo "<option value='active'>" . planet_constant('AM_ACTIVE') . '</option>'; |
|
347 | + echo "<option value='pending'>".planet_constant('AM_PENDING').'</option>'; |
|
348 | + echo "<option value='active'>".planet_constant('AM_ACTIVE').'</option>'; |
|
349 | 349 | |
350 | 350 | echo '</select>'; |
351 | 351 | echo "<div id='catdiv' style='visibility:hidden;display:inline;'>"; |
352 | 352 | echo "<select name='category_dest'>"; |
353 | - echo "<option value=''>" . _SELECT . '</option>'; |
|
353 | + echo "<option value=''>"._SELECT.'</option>'; |
|
354 | 354 | foreach ($categories as $cid => $name) { |
355 | - echo "<option value='" . $cid . "'>" . $name . '</option>'; |
|
355 | + echo "<option value='".$cid."'>".$name.'</option>'; |
|
356 | 356 | } |
357 | 357 | echo '</select>'; |
358 | 358 | echo '</div>'; |
359 | - echo "<input name='start' value='" . $start . "' type='hidden'>"; |
|
360 | - echo "<input name='category' value='" . $category_id . "' type='hidden'>"; |
|
361 | - echo "<input name='submit' value='" . _SUBMIT . "' type='submit'>"; |
|
362 | - echo "<input name='' value='" . _CANCEL . "' type='reset'>"; |
|
359 | + echo "<input name='start' value='".$start."' type='hidden'>"; |
|
360 | + echo "<input name='category' value='".$category_id."' type='hidden'>"; |
|
361 | + echo "<input name='submit' value='"._SUBMIT."' type='submit'>"; |
|
362 | + echo "<input name='' value='"._CANCEL."' type='reset'>"; |
|
363 | 363 | echo '</td>'; |
364 | 364 | echo '</tr>'; |
365 | - if ($blog_count > $xoopsModuleConfig['list_perpage']) { |
|
366 | - include XOOPS_ROOT_PATH . '/class/pagenav.php'; |
|
367 | - $nav = new XoopsPageNav($blog_count, $xoopsModuleConfig['list_perpage'], $start, 'start', 'category=' . $category_id); |
|
365 | + if ($blog_count>$xoopsModuleConfig['list_perpage']) { |
|
366 | + include XOOPS_ROOT_PATH.'/class/pagenav.php'; |
|
367 | + $nav = new XoopsPageNav($blog_count, $xoopsModuleConfig['list_perpage'], $start, 'start', 'category='.$category_id); |
|
368 | 368 | $pagenav = $nav->renderNav(4); |
369 | - echo "<tr align='right'><td colspan='6'>" . $pagenav . '</td></tr>'; |
|
369 | + echo "<tr align='right'><td colspan='6'>".$pagenav.'</td></tr>'; |
|
370 | 370 | } |
371 | 371 | echo '</table></form>'; |
372 | 372 | echo "</fieldset><br style='clear:both;'>"; |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | $button_tray->addElement($butt_cancel); |
393 | 393 | $form_add->addElement($button_tray); |
394 | 394 | |
395 | - echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _ADD . '</legend>'; |
|
395 | + echo "<fieldset><legend style='font-weight: bold; color: #900;'>"._ADD.'</legend>'; |
|
396 | 396 | echo '<br>'; |
397 | 397 | $form->display(); |
398 | 398 | $form_add->display(); |
@@ -30,521 +30,521 @@ |
||
30 | 30 | |
31 | 31 | $current_path = __FILE__; |
32 | 32 | if (DIRECTORY_SEPARATOR !== '/') { |
33 | - $current_path = str_replace(strpos($current_path, '\\\\', 2) ? '\\\\' : DIRECTORY_SEPARATOR, '/', $current_path); |
|
33 | + $current_path = str_replace(strpos($current_path, '\\\\', 2) ? '\\\\' : DIRECTORY_SEPARATOR, '/', $current_path); |
|
34 | 34 | } |
35 | 35 | $url_arr = explode('/', strstr($current_path, '/modules/')); |
36 | 36 | $GLOBALS['moddirname'] = $url_arr[2]; |
37 | 37 | |
38 | 38 | if (!defined('planet_FUNCTIONS')): |
39 | - define('planet_FUNCTIONS', 1); |
|
40 | - |
|
41 | - require XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/include/vars.php'; |
|
42 | - require_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; |
|
43 | - require_once XOOPS_ROOT_PATH . '/Frameworks/art/functions.php'; |
|
44 | - |
|
45 | - /** |
|
46 | - * Function to display messages |
|
47 | - * |
|
48 | - * @var mixed $messages |
|
49 | - * @return bool |
|
50 | - */ |
|
51 | - function planetDisplayMessage($message) |
|
52 | - { |
|
53 | - return mod_message($message); |
|
54 | - } |
|
55 | - |
|
56 | - /** |
|
57 | - * Function to parse arguments for a page according to $_SERVER['REQUEST_URI'] |
|
58 | - * |
|
59 | - * @var array $args_numeric array of numeric variable values |
|
60 | - * @var array $args array of indexed variables: name and value |
|
61 | - * @var array $args_string array of string variable values |
|
62 | - * |
|
63 | - * @return bool true on args parsed |
|
64 | - */ |
|
65 | - |
|
66 | - /* known issues: |
|
39 | + define('planet_FUNCTIONS', 1); |
|
40 | + |
|
41 | + require XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/include/vars.php'; |
|
42 | + require_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; |
|
43 | + require_once XOOPS_ROOT_PATH . '/Frameworks/art/functions.php'; |
|
44 | + |
|
45 | + /** |
|
46 | + * Function to display messages |
|
47 | + * |
|
48 | + * @var mixed $messages |
|
49 | + * @return bool |
|
50 | + */ |
|
51 | + function planetDisplayMessage($message) |
|
52 | + { |
|
53 | + return mod_message($message); |
|
54 | + } |
|
55 | + |
|
56 | + /** |
|
57 | + * Function to parse arguments for a page according to $_SERVER['REQUEST_URI'] |
|
58 | + * |
|
59 | + * @var array $args_numeric array of numeric variable values |
|
60 | + * @var array $args array of indexed variables: name and value |
|
61 | + * @var array $args_string array of string variable values |
|
62 | + * |
|
63 | + * @return bool true on args parsed |
|
64 | + */ |
|
65 | + |
|
66 | + /* known issues: |
|
67 | 67 | * - "/" in a string |
68 | 68 | * - "&" in a string |
69 | 69 | */ |
70 | - function planetParseArguments(&$args_numeric, &$args, &$args_string) |
|
71 | - { |
|
72 | - $args_abb = [ |
|
73 | - 'a' => 'article', |
|
74 | - 'b' => 'blog', |
|
75 | - 'c' => 'category', |
|
76 | - 'l' => 'list', |
|
77 | - 'o' => 'sort', |
|
78 | - 's' => 'start', |
|
79 | - 'u' => 'uid' |
|
80 | - ]; |
|
81 | - $args = []; |
|
82 | - $args_numeric = []; |
|
83 | - $args_string = []; |
|
84 | - if (preg_match("/[^\?]*\.php[\/|\?]([^\?]*)/i", Request::getUrl('REQUEST_URI', '', 'SERVER'), $matches)) { |
|
85 | - $vars = preg_split("/[\/|&]/", $matches[1]); |
|
86 | - $vars = array_map('trim', $vars); |
|
87 | - if (count($vars) > 0) { |
|
88 | - foreach ($vars as $var) { |
|
89 | - if (is_numeric($var)) { |
|
90 | - $args_numeric[] = $var; |
|
91 | - } elseif (false === strpos($var, '=')) { |
|
92 | - if (is_numeric(substr($var, 1))) { |
|
93 | - $args[$args_abb[strtolower($var{0})]] = (int)substr($var, 1); |
|
94 | - } else { |
|
95 | - $args_string[] = urldecode($var); |
|
96 | - } |
|
97 | - } else { |
|
98 | - parse_str($var, $args); |
|
99 | - } |
|
100 | - } |
|
101 | - } |
|
102 | - } |
|
103 | - |
|
104 | - return (0 == count($args) + count($args_numeric) + count($args_string)) ? null : true; |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * Function to parse class prefix |
|
109 | - * |
|
110 | - * @var string $class_string string to be parsed |
|
111 | - * @var mixed $pattern |
|
112 | - * @var mixed $replacement |
|
113 | - * |
|
114 | - * @return bool true on success |
|
115 | - */ |
|
116 | - function planetParseClass($class_string, $pattern = '', $replacement = '') |
|
117 | - { |
|
118 | - if (empty($class_string)) { |
|
119 | - return; |
|
120 | - } |
|
121 | - $patterns = ["/\[CLASS_PREFIX\]/"]; |
|
122 | - $replacements = [ucfirst(strtolower($GLOBALS['moddirname']))]; |
|
123 | - if (!empty($pattern) && !is_array($pattern) && !is_array($replacement)) { |
|
124 | - $pattern = [$pattern]; |
|
125 | - $replacement = [$replacement]; |
|
126 | - } |
|
127 | - if (is_array($pattern) && count($pattern) > 0) { |
|
128 | - $ii = 0; |
|
129 | - foreach ($pattern as $pat) { |
|
130 | - if (!in_array($pat, $patterns)) { |
|
131 | - $patterns[] = $pat; |
|
132 | - $replacements[] = isset($replacement[$ii]) ? $replacement[$ii] : ''; |
|
133 | - } |
|
134 | - ++$ii; |
|
135 | - } |
|
136 | - } |
|
137 | - $class_string = preg_replace($patterns, $replacements, $class_string); |
|
138 | - eval($class_string); |
|
139 | - |
|
140 | - return true; |
|
141 | - } |
|
142 | - |
|
143 | - /** |
|
144 | - * Function to parse function prefix |
|
145 | - * |
|
146 | - * @var string $function_string string to be parsed |
|
147 | - * @var mixed $pattern |
|
148 | - * @var mixed $replacement |
|
149 | - * |
|
150 | - * @return bool true on success |
|
151 | - */ |
|
152 | - function planetParseFunction($function_string, $pattern = '', $replacement = '') |
|
153 | - { |
|
154 | - if (empty($function_string)) { |
|
155 | - return; |
|
156 | - } |
|
157 | - $patterns = ["/\[DIRNAME\]/", "/\[VAR_PREFIX\]/"]; |
|
158 | - $replacements = [$GLOBALS['moddirname'], $GLOBALS['VAR_PREFIX']]; |
|
159 | - if (!empty($pattern) && !is_array($pattern) && !is_array($replacement)) { |
|
160 | - $pattern = [$pattern]; |
|
161 | - $replacement = [$replacement]; |
|
162 | - } |
|
163 | - if (is_array($pattern) && count($pattern) > 0) { |
|
164 | - $ii = 0; |
|
165 | - foreach ($pattern as $pat) { |
|
166 | - if (!in_array($pat, $patterns)) { |
|
167 | - $patterns[] = $pat; |
|
168 | - $replacements[] = isset($replacement[$ii]) ? $replacement[$ii] : ''; |
|
169 | - } |
|
170 | - ++$ii; |
|
171 | - } |
|
172 | - } |
|
173 | - $function_string = preg_replace($patterns, $replacements, $function_string); |
|
174 | - eval($function_string); |
|
175 | - |
|
176 | - return true; |
|
177 | - } |
|
178 | - |
|
179 | - /** |
|
180 | - * Function to convert UNIX time to formatted time string |
|
181 | - * @param $time |
|
182 | - * @param string $format |
|
183 | - * @return string |
|
184 | - */ |
|
185 | - function planet_formatTimestamp($time, $format = '') |
|
186 | - { |
|
187 | - if (empty($time)) { |
|
188 | - return ''; |
|
189 | - } |
|
190 | - |
|
191 | - return formatTimestamp($time, $format); |
|
192 | - } |
|
193 | - |
|
194 | - /** |
|
195 | - * Function to a list of user names associated with their user IDs |
|
196 | - * @param int $userid |
|
197 | - * @param int $usereal |
|
198 | - * @param bool $linked |
|
199 | - * @return array |
|
200 | - */ |
|
201 | - function &planetGetUnameFromId($userid, $usereal = 0, $linked = false) |
|
202 | - { |
|
203 | - if (!is_array($userid)) { |
|
204 | - $userid = [$userid]; |
|
205 | - } |
|
206 | - $users =& mod_getUnameFromIds($userid, $usereal, $linked); |
|
207 | - |
|
208 | - return $users; |
|
209 | - } |
|
210 | - |
|
211 | - /** |
|
212 | - * Function to parse links, links are delimited by link break, URL and title of a link are delimited by space |
|
213 | - * |
|
214 | - * @var string $text raw content |
|
215 | - * |
|
216 | - * @return array associative array of link url and title |
|
217 | - */ |
|
218 | - function &planetParseLinks($text) |
|
219 | - { |
|
220 | - $myts = MyTextSanitizer::getInstance(); |
|
221 | - $link_array = preg_split("/(\r\n|\r|\n)( *)/", $text); |
|
222 | - $links = []; |
|
223 | - if (count($link_array) > 0) { |
|
224 | - foreach ($link_array as $link) { |
|
225 | - @list($url, $title) = array_map('trim', preg_split('/ /', $link, 2)); |
|
226 | - if (empty($url)) { |
|
227 | - continue; |
|
228 | - } |
|
229 | - //if(empty($title)) $title = $url; |
|
230 | - $links[] = ['url' => $url, 'title' => $myts->htmlSpecialChars($title)]; |
|
231 | - } |
|
232 | - } |
|
233 | - |
|
234 | - return $links; |
|
235 | - } |
|
236 | - |
|
237 | - /** |
|
238 | - * @param $pagename |
|
239 | - * @return string |
|
240 | - */ |
|
241 | - function planetGetTemplate($pagename) |
|
242 | - { |
|
243 | - return $GLOBALS['VAR_PREFIX'] . '_' . $pagename . '.tpl'; |
|
244 | - } |
|
245 | - |
|
246 | - /** |
|
247 | - * @param int $currentoption |
|
248 | - */ |
|
249 | - function planet_adminmenu($currentoption = -1) |
|
250 | - { |
|
251 | - loadModuleAdminMenu($currentoption, ''); |
|
252 | - |
|
253 | - return; |
|
254 | - } |
|
255 | - |
|
256 | - /** |
|
257 | - * Function to send a trackback |
|
258 | - * |
|
259 | - * @param $article |
|
260 | - * @param $comment |
|
261 | - * @return bool |
|
262 | - */ |
|
263 | - function planet_com_trackback(&$article, &$comment) |
|
264 | - { |
|
265 | - $blogHandler = xoops_getModuleHandler('blog', $GLOBALS['moddirname']); |
|
266 | - $blog_obj = $blogHandler->get($article->getVar('blog_id')); |
|
267 | - if (!$pattern = $blog_obj->getVar('blog_trackback')) { |
|
268 | - return false; |
|
269 | - } |
|
270 | - @list($pat, $rep) = array_map('trim', preg_split("#[\s]+#", $pattern)); |
|
271 | - $trackback_url = preg_replace('#' . $pat . '#', $rep, $article_obj->getVar('art_link')); |
|
272 | - |
|
273 | - return planetTrackback($trackback_url, $article); |
|
274 | - } |
|
275 | - |
|
276 | - /** |
|
277 | - * @param $trackback_url |
|
278 | - * @param $article |
|
279 | - * @return bool |
|
280 | - */ |
|
281 | - function planetTrackback($trackback_url, $article) |
|
282 | - { |
|
283 | - global $myts, $xoopsConfig, $xoopsModule, $xoopsModuleConfig; |
|
284 | - |
|
285 | - $title = $article->getVar('art_title'); |
|
286 | - $excerpt = $article->getVar('art_content'); |
|
287 | - $blog_name = $xoopsConfig['sitename'] . '-' . $xoopsModule->getVar('name'); |
|
288 | - $title = xoops_utf8_encode($title); |
|
289 | - $excerpt = xoops_utf8_encode($excerpt); |
|
290 | - $blog_name = xoops_utf8_encode($blog_name); |
|
291 | - $charset = 'utf-8'; |
|
292 | - $title1 = urlencode($title); |
|
293 | - $excerpt1 = urlencode($excerpt); |
|
294 | - $name1 = urlencode($blog_name); |
|
295 | - $url = urlencode(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php' . URL_DELIMITER . '' . $article->getVar('art_id')); |
|
296 | - $query_string = "title=$title1&url=$url&blog_name=$name1&excerpt=$excerpt1&charset=$charset"; |
|
297 | - $trackback_url = parse_url($trackback_url); |
|
298 | - |
|
299 | - $http_request = 'POST ' . $trackback_url['path'] . ($trackback_url['query'] ? '?' . $trackback_url['query'] : '') . " HTTP/1.0\r\n"; |
|
300 | - $http_request .= 'Host: ' . $trackback_url['host'] . "\r\n"; |
|
301 | - $http_request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . $charset . "\r\n"; |
|
302 | - $http_request .= 'Content-Length: ' . strlen($query_string) . "\r\n"; |
|
303 | - $http_request .= 'User-Agent: XOOPS Blogs/' . XOOPS_VERSION; |
|
304 | - $http_request .= "\r\n\r\n"; |
|
305 | - $http_request .= $query_string; |
|
306 | - if ('' == $trackback_url['port']) { |
|
307 | - $trackback_url['port'] = 80; |
|
308 | - } |
|
309 | - $fs = @fsockopen($trackback_url['host'], $trackback_url['port'], $errno, $errstr, 4); |
|
310 | - @fwrite($fs, $http_request); |
|
311 | - if ($xoopsModuleConfig['do_debug']) { |
|
312 | - $debug_file = XOOPS_CACHE_PATH . '/' . $GLOBALS['moddirname'] . '_trackback.log'; |
|
313 | - $fr = "\n*****\nRequest:\n\n$http_request\n\nResponse:\n\n"; |
|
314 | - $fr .= "CHARSET:$charset\n"; |
|
315 | - $fr .= "NAME:$blog_name\n"; |
|
316 | - $fr .= 'TITLE:' . $title . "\n"; |
|
317 | - $fr .= "EXCERPT:$excerpt\n\n"; |
|
318 | - while (!@feof($fs)) { |
|
319 | - $fr .= @fgets($fs, 4096); |
|
320 | - } |
|
321 | - $fr .= "\n\n"; |
|
322 | - |
|
323 | - if ($fp = fopen($debug_file, 'a')) { |
|
324 | - fwrite($fp, $fr); |
|
325 | - fclose($fp); |
|
326 | - } else { |
|
327 | - } |
|
328 | - } |
|
329 | - @fclose($fs); |
|
330 | - |
|
331 | - return true; |
|
332 | - } |
|
333 | - |
|
334 | - /** |
|
335 | - * Function to ping servers |
|
336 | - * @param $server |
|
337 | - * @param $id |
|
338 | - */ |
|
339 | - function planetGetPing($server, $id) |
|
340 | - { |
|
341 | - if (is_array($server)) { |
|
342 | - foreach ($server as $serv) { |
|
343 | - planetGetPing($serv, $id); |
|
344 | - } |
|
345 | - } |
|
346 | - require_once XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/class-IXR.php'; |
|
347 | - |
|
348 | - // using a timeout of 3 seconds should be enough to cover slow servers |
|
349 | - $client = new IXR_Client($server, false); |
|
350 | - $client->timeout = 3; |
|
351 | - $client->useragent .= ' -- XOOPS Article/' . XOOPS_VERSION; |
|
352 | - |
|
353 | - // when set to true, this outputs debug messages by itself |
|
354 | - $client->debug = false; |
|
355 | - |
|
356 | - $blogname = xoops_utf8_encode($GLOBALS['xoopsModule']->getVar('name')); |
|
357 | - $home = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/'; |
|
358 | - $rss2_url = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/xml.php' . URL_DELIMITER . 'rss2.0/' . $id; |
|
359 | - |
|
360 | - if (!$client->query('weblogUpdates.extendedPing', $blogname, $home, $rss2_url)) { // then try a normal ping |
|
361 | - $client->query('weblogUpdates.ping', $blogname, $home); |
|
362 | - } |
|
363 | - } |
|
364 | - |
|
365 | - /** |
|
366 | - * Function to respond to a trackback |
|
367 | - * @param int $error |
|
368 | - * @param string $error_message |
|
369 | - */ |
|
370 | - function planetRespondToTrackback($error = 0, $error_message = '') |
|
371 | - { |
|
372 | - $charset = 'utf-8'; |
|
373 | - $error_message = xoops_utf8_encode($error_message); |
|
374 | - header('Content-Type: text/xml; charset="' . $charset . '"'); |
|
375 | - if ($error) { |
|
376 | - echo '<?xml version="1.0" encoding="' . $charset . '"?' . ">\n"; |
|
377 | - echo "<response>\n"; |
|
378 | - echo "<error>1</error>\n"; |
|
379 | - echo "<message>$error_message</message>\n"; |
|
380 | - echo '</response>'; |
|
381 | - die(); |
|
382 | - } else { |
|
383 | - echo '<?xml version="1.0" encoding="' . $charset . '"?' . ">\n"; |
|
384 | - echo "<response>\n"; |
|
385 | - echo "<error>0</error>\n"; |
|
386 | - echo '</response>'; |
|
387 | - } |
|
388 | - } |
|
389 | - |
|
390 | - /** |
|
391 | - * Function to set a cookie with module-specified name |
|
392 | - * |
|
393 | - * using customized serialization method |
|
394 | - * @param $name |
|
395 | - * @param string $string |
|
396 | - * @param int $expire |
|
397 | - */ |
|
398 | - function planetSetCookie($name, $string = '', $expire = 0) |
|
399 | - { |
|
400 | - if (is_array($string)) { |
|
401 | - $value = []; |
|
402 | - foreach ($string as $key => $val) { |
|
403 | - $value[] = $key . '|' . $val; |
|
404 | - } |
|
405 | - $string = implode(',', $value); |
|
406 | - } |
|
407 | - setcookie($GLOBALS['VAR_PREFIX'] . $name, $string, (int)$expire, '/'); |
|
408 | - } |
|
409 | - |
|
410 | - /** |
|
411 | - * @param $name |
|
412 | - * @param bool $isArray |
|
413 | - * @return array|null |
|
414 | - */ |
|
415 | - function planetGetCookie($name, $isArray = false) |
|
416 | - { |
|
417 | - $value = isset($_COOKIE[$GLOBALS['VAR_PREFIX'] . $name]) ? $_COOKIE[$GLOBALS['VAR_PREFIX'] . $name] : null; |
|
418 | - if ($isArray) { |
|
419 | - $_value = $value ? explode(',', $value) : []; |
|
420 | - $value = []; |
|
421 | - if (count($_value) > 0) { |
|
422 | - foreach ($_value as $string) { |
|
423 | - $key = substr($string, 0, strpos($string, '|')); |
|
424 | - $val = substr($string, strpos($string, '|') + 1); |
|
425 | - $value[$key] = $val; |
|
426 | - } |
|
427 | - } |
|
428 | - unset($_value); |
|
429 | - } |
|
430 | - |
|
431 | - return $value; |
|
432 | - } |
|
433 | - |
|
434 | - /** |
|
435 | - * Function to filter text |
|
436 | - * |
|
437 | - * @param $document |
|
438 | - * @return string filtered text |
|
439 | - */ |
|
440 | - function &planetHtml2text(&$document) |
|
441 | - { |
|
442 | - $document = strip_tags($document); |
|
443 | - |
|
444 | - return $document; |
|
445 | - } |
|
446 | - |
|
447 | - // Adapted from PMA_getIp() [phpmyadmin project] |
|
448 | - /** |
|
449 | - * @param bool $asString |
|
450 | - * @return mixed |
|
451 | - */ |
|
452 | - function planetGetIP($asString = false) |
|
453 | - { |
|
454 | - return mod_getIP($asString); |
|
455 | - } |
|
456 | - |
|
457 | - /** |
|
458 | - * @param $url |
|
459 | - * @return bool|mixed|string |
|
460 | - */ |
|
461 | - function planetGetRemoteContent($url) |
|
462 | - { |
|
463 | - if ($data = planet_fetch_snoopy($url)) { |
|
464 | - return $data; |
|
465 | - } |
|
466 | - if ($data = planet_fetch_CURL($url)) { |
|
467 | - return $data; |
|
468 | - } |
|
469 | - if ($data = planet_fetch_fopen($url)) { |
|
470 | - return $data; |
|
471 | - } |
|
472 | - |
|
473 | - return false; |
|
474 | - } |
|
475 | - |
|
476 | - /** |
|
477 | - * @param $url |
|
478 | - * @return string |
|
479 | - */ |
|
480 | - function planet_fetch_snoopy($url) |
|
481 | - { |
|
482 | - require_once XOOPS_ROOT_PATH . '/class/snoopy.php'; |
|
483 | - $snoopy = new Snoopy; |
|
484 | - $data = ''; |
|
485 | - if (@$snoopy->fetch($url)) { |
|
486 | - $data = is_array($snoopy->results) ? implode("\n", $snoopy->results) : $snoopy->results; |
|
487 | - } |
|
488 | - |
|
489 | - return $data; |
|
490 | - } |
|
491 | - |
|
492 | - /** |
|
493 | - * @param $url |
|
494 | - * @return bool|mixed |
|
495 | - */ |
|
496 | - function planet_fetch_CURL($url) |
|
497 | - { |
|
498 | - if (!function_exists('curl_init')) { |
|
499 | - return false; |
|
500 | - } |
|
501 | - $ch = curl_init(); // initialize curl handle |
|
502 | - curl_setopt($ch, CURLOPT_URL, $url); // set url to post to |
|
503 | - curl_setopt($ch, CURLOPT_FAILONERROR, 1); |
|
504 | - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects |
|
505 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable |
|
506 | - curl_setopt($ch, CURLOPT_TIMEOUT, 30); // times out after 31s |
|
507 | - $data = curl_exec($ch); // run the whole process |
|
508 | - curl_close($ch); |
|
509 | - |
|
510 | - return $data; |
|
511 | - } |
|
512 | - |
|
513 | - /** |
|
514 | - * @param $url |
|
515 | - * @return bool|string |
|
516 | - */ |
|
517 | - function planet_fetch_fopen($url) |
|
518 | - { |
|
519 | - if (!$fp = @fopen($url, 'r')) { |
|
520 | - return false; |
|
521 | - } |
|
522 | - $data = ''; |
|
523 | - while (!feof($fp)) { |
|
524 | - $data .= fgets($fp, 1024); |
|
525 | - } |
|
526 | - fclose($fp); |
|
527 | - |
|
528 | - return $data; |
|
529 | - } |
|
530 | - |
|
531 | - /** |
|
532 | - * @param $haystack |
|
533 | - * @param $needle |
|
534 | - * @param int $offset |
|
535 | - * @return bool|int |
|
536 | - */ |
|
537 | - function planetStrrPos($haystack, $needle, $offset = 0) |
|
538 | - { |
|
539 | - if (5 == substr(PHP_VERSION, 0, 1)) { |
|
540 | - return strrpos($haystack, $needle, $offset); |
|
541 | - } |
|
542 | - $index = strpos(strrev($haystack), strrev($needle)); |
|
543 | - if (false === $index) { |
|
544 | - return false; |
|
545 | - } |
|
546 | - $index = strlen($haystack) - strlen($needle) - $index; |
|
547 | - |
|
548 | - return $index; |
|
549 | - } |
|
70 | + function planetParseArguments(&$args_numeric, &$args, &$args_string) |
|
71 | + { |
|
72 | + $args_abb = [ |
|
73 | + 'a' => 'article', |
|
74 | + 'b' => 'blog', |
|
75 | + 'c' => 'category', |
|
76 | + 'l' => 'list', |
|
77 | + 'o' => 'sort', |
|
78 | + 's' => 'start', |
|
79 | + 'u' => 'uid' |
|
80 | + ]; |
|
81 | + $args = []; |
|
82 | + $args_numeric = []; |
|
83 | + $args_string = []; |
|
84 | + if (preg_match("/[^\?]*\.php[\/|\?]([^\?]*)/i", Request::getUrl('REQUEST_URI', '', 'SERVER'), $matches)) { |
|
85 | + $vars = preg_split("/[\/|&]/", $matches[1]); |
|
86 | + $vars = array_map('trim', $vars); |
|
87 | + if (count($vars) > 0) { |
|
88 | + foreach ($vars as $var) { |
|
89 | + if (is_numeric($var)) { |
|
90 | + $args_numeric[] = $var; |
|
91 | + } elseif (false === strpos($var, '=')) { |
|
92 | + if (is_numeric(substr($var, 1))) { |
|
93 | + $args[$args_abb[strtolower($var{0})]] = (int)substr($var, 1); |
|
94 | + } else { |
|
95 | + $args_string[] = urldecode($var); |
|
96 | + } |
|
97 | + } else { |
|
98 | + parse_str($var, $args); |
|
99 | + } |
|
100 | + } |
|
101 | + } |
|
102 | + } |
|
103 | + |
|
104 | + return (0 == count($args) + count($args_numeric) + count($args_string)) ? null : true; |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * Function to parse class prefix |
|
109 | + * |
|
110 | + * @var string $class_string string to be parsed |
|
111 | + * @var mixed $pattern |
|
112 | + * @var mixed $replacement |
|
113 | + * |
|
114 | + * @return bool true on success |
|
115 | + */ |
|
116 | + function planetParseClass($class_string, $pattern = '', $replacement = '') |
|
117 | + { |
|
118 | + if (empty($class_string)) { |
|
119 | + return; |
|
120 | + } |
|
121 | + $patterns = ["/\[CLASS_PREFIX\]/"]; |
|
122 | + $replacements = [ucfirst(strtolower($GLOBALS['moddirname']))]; |
|
123 | + if (!empty($pattern) && !is_array($pattern) && !is_array($replacement)) { |
|
124 | + $pattern = [$pattern]; |
|
125 | + $replacement = [$replacement]; |
|
126 | + } |
|
127 | + if (is_array($pattern) && count($pattern) > 0) { |
|
128 | + $ii = 0; |
|
129 | + foreach ($pattern as $pat) { |
|
130 | + if (!in_array($pat, $patterns)) { |
|
131 | + $patterns[] = $pat; |
|
132 | + $replacements[] = isset($replacement[$ii]) ? $replacement[$ii] : ''; |
|
133 | + } |
|
134 | + ++$ii; |
|
135 | + } |
|
136 | + } |
|
137 | + $class_string = preg_replace($patterns, $replacements, $class_string); |
|
138 | + eval($class_string); |
|
139 | + |
|
140 | + return true; |
|
141 | + } |
|
142 | + |
|
143 | + /** |
|
144 | + * Function to parse function prefix |
|
145 | + * |
|
146 | + * @var string $function_string string to be parsed |
|
147 | + * @var mixed $pattern |
|
148 | + * @var mixed $replacement |
|
149 | + * |
|
150 | + * @return bool true on success |
|
151 | + */ |
|
152 | + function planetParseFunction($function_string, $pattern = '', $replacement = '') |
|
153 | + { |
|
154 | + if (empty($function_string)) { |
|
155 | + return; |
|
156 | + } |
|
157 | + $patterns = ["/\[DIRNAME\]/", "/\[VAR_PREFIX\]/"]; |
|
158 | + $replacements = [$GLOBALS['moddirname'], $GLOBALS['VAR_PREFIX']]; |
|
159 | + if (!empty($pattern) && !is_array($pattern) && !is_array($replacement)) { |
|
160 | + $pattern = [$pattern]; |
|
161 | + $replacement = [$replacement]; |
|
162 | + } |
|
163 | + if (is_array($pattern) && count($pattern) > 0) { |
|
164 | + $ii = 0; |
|
165 | + foreach ($pattern as $pat) { |
|
166 | + if (!in_array($pat, $patterns)) { |
|
167 | + $patterns[] = $pat; |
|
168 | + $replacements[] = isset($replacement[$ii]) ? $replacement[$ii] : ''; |
|
169 | + } |
|
170 | + ++$ii; |
|
171 | + } |
|
172 | + } |
|
173 | + $function_string = preg_replace($patterns, $replacements, $function_string); |
|
174 | + eval($function_string); |
|
175 | + |
|
176 | + return true; |
|
177 | + } |
|
178 | + |
|
179 | + /** |
|
180 | + * Function to convert UNIX time to formatted time string |
|
181 | + * @param $time |
|
182 | + * @param string $format |
|
183 | + * @return string |
|
184 | + */ |
|
185 | + function planet_formatTimestamp($time, $format = '') |
|
186 | + { |
|
187 | + if (empty($time)) { |
|
188 | + return ''; |
|
189 | + } |
|
190 | + |
|
191 | + return formatTimestamp($time, $format); |
|
192 | + } |
|
193 | + |
|
194 | + /** |
|
195 | + * Function to a list of user names associated with their user IDs |
|
196 | + * @param int $userid |
|
197 | + * @param int $usereal |
|
198 | + * @param bool $linked |
|
199 | + * @return array |
|
200 | + */ |
|
201 | + function &planetGetUnameFromId($userid, $usereal = 0, $linked = false) |
|
202 | + { |
|
203 | + if (!is_array($userid)) { |
|
204 | + $userid = [$userid]; |
|
205 | + } |
|
206 | + $users =& mod_getUnameFromIds($userid, $usereal, $linked); |
|
207 | + |
|
208 | + return $users; |
|
209 | + } |
|
210 | + |
|
211 | + /** |
|
212 | + * Function to parse links, links are delimited by link break, URL and title of a link are delimited by space |
|
213 | + * |
|
214 | + * @var string $text raw content |
|
215 | + * |
|
216 | + * @return array associative array of link url and title |
|
217 | + */ |
|
218 | + function &planetParseLinks($text) |
|
219 | + { |
|
220 | + $myts = MyTextSanitizer::getInstance(); |
|
221 | + $link_array = preg_split("/(\r\n|\r|\n)( *)/", $text); |
|
222 | + $links = []; |
|
223 | + if (count($link_array) > 0) { |
|
224 | + foreach ($link_array as $link) { |
|
225 | + @list($url, $title) = array_map('trim', preg_split('/ /', $link, 2)); |
|
226 | + if (empty($url)) { |
|
227 | + continue; |
|
228 | + } |
|
229 | + //if(empty($title)) $title = $url; |
|
230 | + $links[] = ['url' => $url, 'title' => $myts->htmlSpecialChars($title)]; |
|
231 | + } |
|
232 | + } |
|
233 | + |
|
234 | + return $links; |
|
235 | + } |
|
236 | + |
|
237 | + /** |
|
238 | + * @param $pagename |
|
239 | + * @return string |
|
240 | + */ |
|
241 | + function planetGetTemplate($pagename) |
|
242 | + { |
|
243 | + return $GLOBALS['VAR_PREFIX'] . '_' . $pagename . '.tpl'; |
|
244 | + } |
|
245 | + |
|
246 | + /** |
|
247 | + * @param int $currentoption |
|
248 | + */ |
|
249 | + function planet_adminmenu($currentoption = -1) |
|
250 | + { |
|
251 | + loadModuleAdminMenu($currentoption, ''); |
|
252 | + |
|
253 | + return; |
|
254 | + } |
|
255 | + |
|
256 | + /** |
|
257 | + * Function to send a trackback |
|
258 | + * |
|
259 | + * @param $article |
|
260 | + * @param $comment |
|
261 | + * @return bool |
|
262 | + */ |
|
263 | + function planet_com_trackback(&$article, &$comment) |
|
264 | + { |
|
265 | + $blogHandler = xoops_getModuleHandler('blog', $GLOBALS['moddirname']); |
|
266 | + $blog_obj = $blogHandler->get($article->getVar('blog_id')); |
|
267 | + if (!$pattern = $blog_obj->getVar('blog_trackback')) { |
|
268 | + return false; |
|
269 | + } |
|
270 | + @list($pat, $rep) = array_map('trim', preg_split("#[\s]+#", $pattern)); |
|
271 | + $trackback_url = preg_replace('#' . $pat . '#', $rep, $article_obj->getVar('art_link')); |
|
272 | + |
|
273 | + return planetTrackback($trackback_url, $article); |
|
274 | + } |
|
275 | + |
|
276 | + /** |
|
277 | + * @param $trackback_url |
|
278 | + * @param $article |
|
279 | + * @return bool |
|
280 | + */ |
|
281 | + function planetTrackback($trackback_url, $article) |
|
282 | + { |
|
283 | + global $myts, $xoopsConfig, $xoopsModule, $xoopsModuleConfig; |
|
284 | + |
|
285 | + $title = $article->getVar('art_title'); |
|
286 | + $excerpt = $article->getVar('art_content'); |
|
287 | + $blog_name = $xoopsConfig['sitename'] . '-' . $xoopsModule->getVar('name'); |
|
288 | + $title = xoops_utf8_encode($title); |
|
289 | + $excerpt = xoops_utf8_encode($excerpt); |
|
290 | + $blog_name = xoops_utf8_encode($blog_name); |
|
291 | + $charset = 'utf-8'; |
|
292 | + $title1 = urlencode($title); |
|
293 | + $excerpt1 = urlencode($excerpt); |
|
294 | + $name1 = urlencode($blog_name); |
|
295 | + $url = urlencode(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php' . URL_DELIMITER . '' . $article->getVar('art_id')); |
|
296 | + $query_string = "title=$title1&url=$url&blog_name=$name1&excerpt=$excerpt1&charset=$charset"; |
|
297 | + $trackback_url = parse_url($trackback_url); |
|
298 | + |
|
299 | + $http_request = 'POST ' . $trackback_url['path'] . ($trackback_url['query'] ? '?' . $trackback_url['query'] : '') . " HTTP/1.0\r\n"; |
|
300 | + $http_request .= 'Host: ' . $trackback_url['host'] . "\r\n"; |
|
301 | + $http_request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . $charset . "\r\n"; |
|
302 | + $http_request .= 'Content-Length: ' . strlen($query_string) . "\r\n"; |
|
303 | + $http_request .= 'User-Agent: XOOPS Blogs/' . XOOPS_VERSION; |
|
304 | + $http_request .= "\r\n\r\n"; |
|
305 | + $http_request .= $query_string; |
|
306 | + if ('' == $trackback_url['port']) { |
|
307 | + $trackback_url['port'] = 80; |
|
308 | + } |
|
309 | + $fs = @fsockopen($trackback_url['host'], $trackback_url['port'], $errno, $errstr, 4); |
|
310 | + @fwrite($fs, $http_request); |
|
311 | + if ($xoopsModuleConfig['do_debug']) { |
|
312 | + $debug_file = XOOPS_CACHE_PATH . '/' . $GLOBALS['moddirname'] . '_trackback.log'; |
|
313 | + $fr = "\n*****\nRequest:\n\n$http_request\n\nResponse:\n\n"; |
|
314 | + $fr .= "CHARSET:$charset\n"; |
|
315 | + $fr .= "NAME:$blog_name\n"; |
|
316 | + $fr .= 'TITLE:' . $title . "\n"; |
|
317 | + $fr .= "EXCERPT:$excerpt\n\n"; |
|
318 | + while (!@feof($fs)) { |
|
319 | + $fr .= @fgets($fs, 4096); |
|
320 | + } |
|
321 | + $fr .= "\n\n"; |
|
322 | + |
|
323 | + if ($fp = fopen($debug_file, 'a')) { |
|
324 | + fwrite($fp, $fr); |
|
325 | + fclose($fp); |
|
326 | + } else { |
|
327 | + } |
|
328 | + } |
|
329 | + @fclose($fs); |
|
330 | + |
|
331 | + return true; |
|
332 | + } |
|
333 | + |
|
334 | + /** |
|
335 | + * Function to ping servers |
|
336 | + * @param $server |
|
337 | + * @param $id |
|
338 | + */ |
|
339 | + function planetGetPing($server, $id) |
|
340 | + { |
|
341 | + if (is_array($server)) { |
|
342 | + foreach ($server as $serv) { |
|
343 | + planetGetPing($serv, $id); |
|
344 | + } |
|
345 | + } |
|
346 | + require_once XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/class-IXR.php'; |
|
347 | + |
|
348 | + // using a timeout of 3 seconds should be enough to cover slow servers |
|
349 | + $client = new IXR_Client($server, false); |
|
350 | + $client->timeout = 3; |
|
351 | + $client->useragent .= ' -- XOOPS Article/' . XOOPS_VERSION; |
|
352 | + |
|
353 | + // when set to true, this outputs debug messages by itself |
|
354 | + $client->debug = false; |
|
355 | + |
|
356 | + $blogname = xoops_utf8_encode($GLOBALS['xoopsModule']->getVar('name')); |
|
357 | + $home = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/'; |
|
358 | + $rss2_url = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/xml.php' . URL_DELIMITER . 'rss2.0/' . $id; |
|
359 | + |
|
360 | + if (!$client->query('weblogUpdates.extendedPing', $blogname, $home, $rss2_url)) { // then try a normal ping |
|
361 | + $client->query('weblogUpdates.ping', $blogname, $home); |
|
362 | + } |
|
363 | + } |
|
364 | + |
|
365 | + /** |
|
366 | + * Function to respond to a trackback |
|
367 | + * @param int $error |
|
368 | + * @param string $error_message |
|
369 | + */ |
|
370 | + function planetRespondToTrackback($error = 0, $error_message = '') |
|
371 | + { |
|
372 | + $charset = 'utf-8'; |
|
373 | + $error_message = xoops_utf8_encode($error_message); |
|
374 | + header('Content-Type: text/xml; charset="' . $charset . '"'); |
|
375 | + if ($error) { |
|
376 | + echo '<?xml version="1.0" encoding="' . $charset . '"?' . ">\n"; |
|
377 | + echo "<response>\n"; |
|
378 | + echo "<error>1</error>\n"; |
|
379 | + echo "<message>$error_message</message>\n"; |
|
380 | + echo '</response>'; |
|
381 | + die(); |
|
382 | + } else { |
|
383 | + echo '<?xml version="1.0" encoding="' . $charset . '"?' . ">\n"; |
|
384 | + echo "<response>\n"; |
|
385 | + echo "<error>0</error>\n"; |
|
386 | + echo '</response>'; |
|
387 | + } |
|
388 | + } |
|
389 | + |
|
390 | + /** |
|
391 | + * Function to set a cookie with module-specified name |
|
392 | + * |
|
393 | + * using customized serialization method |
|
394 | + * @param $name |
|
395 | + * @param string $string |
|
396 | + * @param int $expire |
|
397 | + */ |
|
398 | + function planetSetCookie($name, $string = '', $expire = 0) |
|
399 | + { |
|
400 | + if (is_array($string)) { |
|
401 | + $value = []; |
|
402 | + foreach ($string as $key => $val) { |
|
403 | + $value[] = $key . '|' . $val; |
|
404 | + } |
|
405 | + $string = implode(',', $value); |
|
406 | + } |
|
407 | + setcookie($GLOBALS['VAR_PREFIX'] . $name, $string, (int)$expire, '/'); |
|
408 | + } |
|
409 | + |
|
410 | + /** |
|
411 | + * @param $name |
|
412 | + * @param bool $isArray |
|
413 | + * @return array|null |
|
414 | + */ |
|
415 | + function planetGetCookie($name, $isArray = false) |
|
416 | + { |
|
417 | + $value = isset($_COOKIE[$GLOBALS['VAR_PREFIX'] . $name]) ? $_COOKIE[$GLOBALS['VAR_PREFIX'] . $name] : null; |
|
418 | + if ($isArray) { |
|
419 | + $_value = $value ? explode(',', $value) : []; |
|
420 | + $value = []; |
|
421 | + if (count($_value) > 0) { |
|
422 | + foreach ($_value as $string) { |
|
423 | + $key = substr($string, 0, strpos($string, '|')); |
|
424 | + $val = substr($string, strpos($string, '|') + 1); |
|
425 | + $value[$key] = $val; |
|
426 | + } |
|
427 | + } |
|
428 | + unset($_value); |
|
429 | + } |
|
430 | + |
|
431 | + return $value; |
|
432 | + } |
|
433 | + |
|
434 | + /** |
|
435 | + * Function to filter text |
|
436 | + * |
|
437 | + * @param $document |
|
438 | + * @return string filtered text |
|
439 | + */ |
|
440 | + function &planetHtml2text(&$document) |
|
441 | + { |
|
442 | + $document = strip_tags($document); |
|
443 | + |
|
444 | + return $document; |
|
445 | + } |
|
446 | + |
|
447 | + // Adapted from PMA_getIp() [phpmyadmin project] |
|
448 | + /** |
|
449 | + * @param bool $asString |
|
450 | + * @return mixed |
|
451 | + */ |
|
452 | + function planetGetIP($asString = false) |
|
453 | + { |
|
454 | + return mod_getIP($asString); |
|
455 | + } |
|
456 | + |
|
457 | + /** |
|
458 | + * @param $url |
|
459 | + * @return bool|mixed|string |
|
460 | + */ |
|
461 | + function planetGetRemoteContent($url) |
|
462 | + { |
|
463 | + if ($data = planet_fetch_snoopy($url)) { |
|
464 | + return $data; |
|
465 | + } |
|
466 | + if ($data = planet_fetch_CURL($url)) { |
|
467 | + return $data; |
|
468 | + } |
|
469 | + if ($data = planet_fetch_fopen($url)) { |
|
470 | + return $data; |
|
471 | + } |
|
472 | + |
|
473 | + return false; |
|
474 | + } |
|
475 | + |
|
476 | + /** |
|
477 | + * @param $url |
|
478 | + * @return string |
|
479 | + */ |
|
480 | + function planet_fetch_snoopy($url) |
|
481 | + { |
|
482 | + require_once XOOPS_ROOT_PATH . '/class/snoopy.php'; |
|
483 | + $snoopy = new Snoopy; |
|
484 | + $data = ''; |
|
485 | + if (@$snoopy->fetch($url)) { |
|
486 | + $data = is_array($snoopy->results) ? implode("\n", $snoopy->results) : $snoopy->results; |
|
487 | + } |
|
488 | + |
|
489 | + return $data; |
|
490 | + } |
|
491 | + |
|
492 | + /** |
|
493 | + * @param $url |
|
494 | + * @return bool|mixed |
|
495 | + */ |
|
496 | + function planet_fetch_CURL($url) |
|
497 | + { |
|
498 | + if (!function_exists('curl_init')) { |
|
499 | + return false; |
|
500 | + } |
|
501 | + $ch = curl_init(); // initialize curl handle |
|
502 | + curl_setopt($ch, CURLOPT_URL, $url); // set url to post to |
|
503 | + curl_setopt($ch, CURLOPT_FAILONERROR, 1); |
|
504 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects |
|
505 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable |
|
506 | + curl_setopt($ch, CURLOPT_TIMEOUT, 30); // times out after 31s |
|
507 | + $data = curl_exec($ch); // run the whole process |
|
508 | + curl_close($ch); |
|
509 | + |
|
510 | + return $data; |
|
511 | + } |
|
512 | + |
|
513 | + /** |
|
514 | + * @param $url |
|
515 | + * @return bool|string |
|
516 | + */ |
|
517 | + function planet_fetch_fopen($url) |
|
518 | + { |
|
519 | + if (!$fp = @fopen($url, 'r')) { |
|
520 | + return false; |
|
521 | + } |
|
522 | + $data = ''; |
|
523 | + while (!feof($fp)) { |
|
524 | + $data .= fgets($fp, 1024); |
|
525 | + } |
|
526 | + fclose($fp); |
|
527 | + |
|
528 | + return $data; |
|
529 | + } |
|
530 | + |
|
531 | + /** |
|
532 | + * @param $haystack |
|
533 | + * @param $needle |
|
534 | + * @param int $offset |
|
535 | + * @return bool|int |
|
536 | + */ |
|
537 | + function planetStrrPos($haystack, $needle, $offset = 0) |
|
538 | + { |
|
539 | + if (5 == substr(PHP_VERSION, 0, 1)) { |
|
540 | + return strrpos($haystack, $needle, $offset); |
|
541 | + } |
|
542 | + $index = strpos(strrev($haystack), strrev($needle)); |
|
543 | + if (false === $index) { |
|
544 | + return false; |
|
545 | + } |
|
546 | + $index = strlen($haystack) - strlen($needle) - $index; |
|
547 | + |
|
548 | + return $index; |
|
549 | + } |
|
550 | 550 | endif; |
@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | if (!defined('planet_FUNCTIONS')): |
39 | 39 | define('planet_FUNCTIONS', 1); |
40 | 40 | |
41 | - require XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/include/vars.php'; |
|
42 | - require_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; |
|
43 | - require_once XOOPS_ROOT_PATH . '/Frameworks/art/functions.php'; |
|
41 | + require XOOPS_ROOT_PATH.'/modules/'.$GLOBALS['moddirname'].'/include/vars.php'; |
|
42 | + require_once XOOPS_ROOT_PATH.'/class/xoopslists.php'; |
|
43 | + require_once XOOPS_ROOT_PATH.'/Frameworks/art/functions.php'; |
|
44 | 44 | |
45 | 45 | /** |
46 | 46 | * Function to display messages |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | function planetParseArguments(&$args_numeric, &$args, &$args_string) |
71 | 71 | { |
72 | - $args_abb = [ |
|
72 | + $args_abb = [ |
|
73 | 73 | 'a' => 'article', |
74 | 74 | 'b' => 'blog', |
75 | 75 | 'c' => 'category', |
@@ -84,24 +84,24 @@ discard block |
||
84 | 84 | if (preg_match("/[^\?]*\.php[\/|\?]([^\?]*)/i", Request::getUrl('REQUEST_URI', '', 'SERVER'), $matches)) { |
85 | 85 | $vars = preg_split("/[\/|&]/", $matches[1]); |
86 | 86 | $vars = array_map('trim', $vars); |
87 | - if (count($vars) > 0) { |
|
87 | + if (count($vars)>0) { |
|
88 | 88 | foreach ($vars as $var) { |
89 | 89 | if (is_numeric($var)) { |
90 | 90 | $args_numeric[] = $var; |
91 | 91 | } elseif (false === strpos($var, '=')) { |
92 | 92 | if (is_numeric(substr($var, 1))) { |
93 | - $args[$args_abb[strtolower($var{0})]] = (int)substr($var, 1); |
|
94 | - } else { |
|
93 | + $args[$args_abb[strtolower($var{0})]] = (int) substr($var, 1); |
|
94 | + }else { |
|
95 | 95 | $args_string[] = urldecode($var); |
96 | 96 | } |
97 | - } else { |
|
97 | + }else { |
|
98 | 98 | parse_str($var, $args); |
99 | 99 | } |
100 | 100 | } |
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
104 | - return (0 == count($args) + count($args_numeric) + count($args_string)) ? null : true; |
|
104 | + return (0 == count($args)+count($args_numeric)+count($args_string)) ? null : true; |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | $pattern = [$pattern]; |
125 | 125 | $replacement = [$replacement]; |
126 | 126 | } |
127 | - if (is_array($pattern) && count($pattern) > 0) { |
|
127 | + if (is_array($pattern) && count($pattern)>0) { |
|
128 | 128 | $ii = 0; |
129 | 129 | foreach ($pattern as $pat) { |
130 | 130 | if (!in_array($pat, $patterns)) { |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | $pattern = [$pattern]; |
161 | 161 | $replacement = [$replacement]; |
162 | 162 | } |
163 | - if (is_array($pattern) && count($pattern) > 0) { |
|
163 | + if (is_array($pattern) && count($pattern)>0) { |
|
164 | 164 | $ii = 0; |
165 | 165 | foreach ($pattern as $pat) { |
166 | 166 | if (!in_array($pat, $patterns)) { |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | if (!is_array($userid)) { |
204 | 204 | $userid = [$userid]; |
205 | 205 | } |
206 | - $users =& mod_getUnameFromIds($userid, $usereal, $linked); |
|
206 | + $users = & mod_getUnameFromIds($userid, $usereal, $linked); |
|
207 | 207 | |
208 | 208 | return $users; |
209 | 209 | } |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | $myts = MyTextSanitizer::getInstance(); |
221 | 221 | $link_array = preg_split("/(\r\n|\r|\n)( *)/", $text); |
222 | 222 | $links = []; |
223 | - if (count($link_array) > 0) { |
|
223 | + if (count($link_array)>0) { |
|
224 | 224 | foreach ($link_array as $link) { |
225 | 225 | @list($url, $title) = array_map('trim', preg_split('/ /', $link, 2)); |
226 | 226 | if (empty($url)) { |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | */ |
241 | 241 | function planetGetTemplate($pagename) |
242 | 242 | { |
243 | - return $GLOBALS['VAR_PREFIX'] . '_' . $pagename . '.tpl'; |
|
243 | + return $GLOBALS['VAR_PREFIX'].'_'.$pagename.'.tpl'; |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | /** |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | return false; |
269 | 269 | } |
270 | 270 | @list($pat, $rep) = array_map('trim', preg_split("#[\s]+#", $pattern)); |
271 | - $trackback_url = preg_replace('#' . $pat . '#', $rep, $article_obj->getVar('art_link')); |
|
271 | + $trackback_url = preg_replace('#'.$pat.'#', $rep, $article_obj->getVar('art_link')); |
|
272 | 272 | |
273 | 273 | return planetTrackback($trackback_url, $article); |
274 | 274 | } |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | |
285 | 285 | $title = $article->getVar('art_title'); |
286 | 286 | $excerpt = $article->getVar('art_content'); |
287 | - $blog_name = $xoopsConfig['sitename'] . '-' . $xoopsModule->getVar('name'); |
|
287 | + $blog_name = $xoopsConfig['sitename'].'-'.$xoopsModule->getVar('name'); |
|
288 | 288 | $title = xoops_utf8_encode($title); |
289 | 289 | $excerpt = xoops_utf8_encode($excerpt); |
290 | 290 | $blog_name = xoops_utf8_encode($blog_name); |
@@ -292,15 +292,15 @@ discard block |
||
292 | 292 | $title1 = urlencode($title); |
293 | 293 | $excerpt1 = urlencode($excerpt); |
294 | 294 | $name1 = urlencode($blog_name); |
295 | - $url = urlencode(XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php' . URL_DELIMITER . '' . $article->getVar('art_id')); |
|
295 | + $url = urlencode(XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/view.article.php'.URL_DELIMITER.''.$article->getVar('art_id')); |
|
296 | 296 | $query_string = "title=$title1&url=$url&blog_name=$name1&excerpt=$excerpt1&charset=$charset"; |
297 | 297 | $trackback_url = parse_url($trackback_url); |
298 | 298 | |
299 | - $http_request = 'POST ' . $trackback_url['path'] . ($trackback_url['query'] ? '?' . $trackback_url['query'] : '') . " HTTP/1.0\r\n"; |
|
300 | - $http_request .= 'Host: ' . $trackback_url['host'] . "\r\n"; |
|
301 | - $http_request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . $charset . "\r\n"; |
|
302 | - $http_request .= 'Content-Length: ' . strlen($query_string) . "\r\n"; |
|
303 | - $http_request .= 'User-Agent: XOOPS Blogs/' . XOOPS_VERSION; |
|
299 | + $http_request = 'POST '.$trackback_url['path'].($trackback_url['query'] ? '?'.$trackback_url['query'] : '')." HTTP/1.0\r\n"; |
|
300 | + $http_request .= 'Host: '.$trackback_url['host']."\r\n"; |
|
301 | + $http_request .= 'Content-Type: application/x-www-form-urlencoded; charset='.$charset."\r\n"; |
|
302 | + $http_request .= 'Content-Length: '.strlen($query_string)."\r\n"; |
|
303 | + $http_request .= 'User-Agent: XOOPS Blogs/'.XOOPS_VERSION; |
|
304 | 304 | $http_request .= "\r\n\r\n"; |
305 | 305 | $http_request .= $query_string; |
306 | 306 | if ('' == $trackback_url['port']) { |
@@ -309,11 +309,11 @@ discard block |
||
309 | 309 | $fs = @fsockopen($trackback_url['host'], $trackback_url['port'], $errno, $errstr, 4); |
310 | 310 | @fwrite($fs, $http_request); |
311 | 311 | if ($xoopsModuleConfig['do_debug']) { |
312 | - $debug_file = XOOPS_CACHE_PATH . '/' . $GLOBALS['moddirname'] . '_trackback.log'; |
|
312 | + $debug_file = XOOPS_CACHE_PATH.'/'.$GLOBALS['moddirname'].'_trackback.log'; |
|
313 | 313 | $fr = "\n*****\nRequest:\n\n$http_request\n\nResponse:\n\n"; |
314 | 314 | $fr .= "CHARSET:$charset\n"; |
315 | 315 | $fr .= "NAME:$blog_name\n"; |
316 | - $fr .= 'TITLE:' . $title . "\n"; |
|
316 | + $fr .= 'TITLE:'.$title."\n"; |
|
317 | 317 | $fr .= "EXCERPT:$excerpt\n\n"; |
318 | 318 | while (!@feof($fs)) { |
319 | 319 | $fr .= @fgets($fs, 4096); |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | if ($fp = fopen($debug_file, 'a')) { |
324 | 324 | fwrite($fp, $fr); |
325 | 325 | fclose($fp); |
326 | - } else { |
|
326 | + }else { |
|
327 | 327 | } |
328 | 328 | } |
329 | 329 | @fclose($fs); |
@@ -343,19 +343,19 @@ discard block |
||
343 | 343 | planetGetPing($serv, $id); |
344 | 344 | } |
345 | 345 | } |
346 | - require_once XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/class-IXR.php'; |
|
346 | + require_once XOOPS_ROOT_PATH.'/modules/'.$GLOBALS['moddirname'].'/class-IXR.php'; |
|
347 | 347 | |
348 | 348 | // using a timeout of 3 seconds should be enough to cover slow servers |
349 | 349 | $client = new IXR_Client($server, false); |
350 | 350 | $client->timeout = 3; |
351 | - $client->useragent .= ' -- XOOPS Article/' . XOOPS_VERSION; |
|
351 | + $client->useragent .= ' -- XOOPS Article/'.XOOPS_VERSION; |
|
352 | 352 | |
353 | 353 | // when set to true, this outputs debug messages by itself |
354 | 354 | $client->debug = false; |
355 | 355 | |
356 | 356 | $blogname = xoops_utf8_encode($GLOBALS['xoopsModule']->getVar('name')); |
357 | - $home = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/'; |
|
358 | - $rss2_url = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/xml.php' . URL_DELIMITER . 'rss2.0/' . $id; |
|
357 | + $home = XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/'; |
|
358 | + $rss2_url = XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/xml.php'.URL_DELIMITER.'rss2.0/'.$id; |
|
359 | 359 | |
360 | 360 | if (!$client->query('weblogUpdates.extendedPing', $blogname, $home, $rss2_url)) { // then try a normal ping |
361 | 361 | $client->query('weblogUpdates.ping', $blogname, $home); |
@@ -371,16 +371,16 @@ discard block |
||
371 | 371 | { |
372 | 372 | $charset = 'utf-8'; |
373 | 373 | $error_message = xoops_utf8_encode($error_message); |
374 | - header('Content-Type: text/xml; charset="' . $charset . '"'); |
|
374 | + header('Content-Type: text/xml; charset="'.$charset.'"'); |
|
375 | 375 | if ($error) { |
376 | - echo '<?xml version="1.0" encoding="' . $charset . '"?' . ">\n"; |
|
376 | + echo '<?xml version="1.0" encoding="'.$charset.'"?'.">\n"; |
|
377 | 377 | echo "<response>\n"; |
378 | 378 | echo "<error>1</error>\n"; |
379 | 379 | echo "<message>$error_message</message>\n"; |
380 | 380 | echo '</response>'; |
381 | 381 | die(); |
382 | - } else { |
|
383 | - echo '<?xml version="1.0" encoding="' . $charset . '"?' . ">\n"; |
|
382 | + }else { |
|
383 | + echo '<?xml version="1.0" encoding="'.$charset.'"?'.">\n"; |
|
384 | 384 | echo "<response>\n"; |
385 | 385 | echo "<error>0</error>\n"; |
386 | 386 | echo '</response>'; |
@@ -400,11 +400,11 @@ discard block |
||
400 | 400 | if (is_array($string)) { |
401 | 401 | $value = []; |
402 | 402 | foreach ($string as $key => $val) { |
403 | - $value[] = $key . '|' . $val; |
|
403 | + $value[] = $key.'|'.$val; |
|
404 | 404 | } |
405 | 405 | $string = implode(',', $value); |
406 | 406 | } |
407 | - setcookie($GLOBALS['VAR_PREFIX'] . $name, $string, (int)$expire, '/'); |
|
407 | + setcookie($GLOBALS['VAR_PREFIX'].$name, $string, (int) $expire, '/'); |
|
408 | 408 | } |
409 | 409 | |
410 | 410 | /** |
@@ -414,14 +414,14 @@ discard block |
||
414 | 414 | */ |
415 | 415 | function planetGetCookie($name, $isArray = false) |
416 | 416 | { |
417 | - $value = isset($_COOKIE[$GLOBALS['VAR_PREFIX'] . $name]) ? $_COOKIE[$GLOBALS['VAR_PREFIX'] . $name] : null; |
|
417 | + $value = isset($_COOKIE[$GLOBALS['VAR_PREFIX'].$name]) ? $_COOKIE[$GLOBALS['VAR_PREFIX'].$name] : null; |
|
418 | 418 | if ($isArray) { |
419 | 419 | $_value = $value ? explode(',', $value) : []; |
420 | 420 | $value = []; |
421 | - if (count($_value) > 0) { |
|
421 | + if (count($_value)>0) { |
|
422 | 422 | foreach ($_value as $string) { |
423 | 423 | $key = substr($string, 0, strpos($string, '|')); |
424 | - $val = substr($string, strpos($string, '|') + 1); |
|
424 | + $val = substr($string, strpos($string, '|')+1); |
|
425 | 425 | $value[$key] = $val; |
426 | 426 | } |
427 | 427 | } |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | */ |
480 | 480 | function planet_fetch_snoopy($url) |
481 | 481 | { |
482 | - require_once XOOPS_ROOT_PATH . '/class/snoopy.php'; |
|
482 | + require_once XOOPS_ROOT_PATH.'/class/snoopy.php'; |
|
483 | 483 | $snoopy = new Snoopy; |
484 | 484 | $data = ''; |
485 | 485 | if (@$snoopy->fetch($url)) { |
@@ -498,10 +498,10 @@ discard block |
||
498 | 498 | if (!function_exists('curl_init')) { |
499 | 499 | return false; |
500 | 500 | } |
501 | - $ch = curl_init(); // initialize curl handle |
|
501 | + $ch = curl_init(); // initialize curl handle |
|
502 | 502 | curl_setopt($ch, CURLOPT_URL, $url); // set url to post to |
503 | 503 | curl_setopt($ch, CURLOPT_FAILONERROR, 1); |
504 | - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects |
|
504 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // allow redirects |
|
505 | 505 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable |
506 | 506 | curl_setopt($ch, CURLOPT_TIMEOUT, 30); // times out after 31s |
507 | 507 | $data = curl_exec($ch); // run the whole process |
@@ -543,7 +543,7 @@ discard block |
||
543 | 543 | if (false === $index) { |
544 | 544 | return false; |
545 | 545 | } |
546 | - $index = strlen($haystack) - strlen($needle) - $index; |
|
546 | + $index = strlen($haystack)-strlen($needle)-$index; |
|
547 | 547 | |
548 | 548 | return $index; |
549 | 549 | } |