@@ -30,7 +30,7 @@ |
||
30 | 30 | */ |
31 | 31 | |
32 | 32 | // defined('XOOPS_ROOT_PATH') || exit('Restricted access.'); |
33 | -require_once __DIR__ . '/../include/vars.php'; |
|
33 | +require_once __DIR__.'/../include/vars.php'; |
|
34 | 34 | //mod_loadFunctions('', $GLOBALS['moddirname']); |
35 | 35 | |
36 | 36 | /** |
@@ -33,468 +33,468 @@ discard block |
||
33 | 33 | */ |
34 | 34 | class MagpieRSS |
35 | 35 | { |
36 | - public $parser; |
|
37 | - |
|
38 | - public $current_item = []; // item currently being parsed |
|
39 | - public $items = []; // collection of parsed items |
|
40 | - public $channel = []; // hash of channel fields |
|
41 | - public $textinput = []; |
|
42 | - public $image = []; |
|
43 | - public $feed_type; |
|
44 | - public $feed_version; |
|
45 | - public $encoding = ''; // output encoding of parsed rss |
|
46 | - |
|
47 | - public $_source_encoding = ''; // only set if we have to parse xml prolog |
|
48 | - |
|
49 | - public $ERROR = ''; |
|
50 | - public $WARNING = ''; |
|
51 | - |
|
52 | - // define some constants |
|
53 | - |
|
54 | - public $_CONTENT_CONSTRUCTS = ['content', 'summary', 'info', 'title', 'tagline', 'copyright']; |
|
55 | - public $_KNOWN_ENCODINGS = ['UTF-8', 'US-ASCII', 'ISO-8859-1']; |
|
56 | - |
|
57 | - // parser variables, useless if you're not a parser, treat as private |
|
58 | - public $stack = []; // parser stack |
|
59 | - public $inchannel = false; |
|
60 | - public $initem = false; |
|
61 | - public $incontent = false; // if in Atom <content mode="xml"> field |
|
62 | - public $intextinput = false; |
|
63 | - public $inimage = false; |
|
64 | - public $current_field = ''; |
|
65 | - public $current_namespace = false; |
|
66 | - |
|
67 | - /** |
|
68 | - * Set up XML parser, parse source, and return populated RSS object.. |
|
69 | - * |
|
70 | - * @param string $source string containing the RSS to be parsed |
|
71 | - * |
|
72 | - * NOTE: Probably a good idea to leave the encoding options alone unless |
|
73 | - * you know what you're doing as PHP's character set support is |
|
74 | - * a little weird. |
|
75 | - * |
|
76 | - * NOTE: A lot of this is unnecessary but harmless with PHP5 |
|
77 | - * |
|
78 | - * |
|
79 | - * @param string $output_encoding output the parsed RSS in this character |
|
80 | - * set defaults to ISO-8859-1 as this is PHP's |
|
81 | - * default. |
|
82 | - * |
|
83 | - * NOTE: might be changed to UTF-8 in future |
|
84 | - * versions. |
|
85 | - * |
|
86 | - * @param string $input_encoding the character set of the incoming RSS source. |
|
87 | - * Leave blank and Magpie will try to figure it |
|
88 | - * out. |
|
89 | - * |
|
90 | - * |
|
91 | - * @param bool $detect_encoding if false Magpie won't attempt to detect |
|
92 | - * source encoding. (caveat emptor) |
|
93 | - * |
|
94 | - */ |
|
95 | - public function __construct( |
|
96 | - $source, |
|
97 | - $output_encoding = 'ISO-8859-1', |
|
98 | - $input_encoding = null, |
|
99 | - $detect_encoding = true |
|
100 | - ) { |
|
101 | - # if PHP xml isn't compiled in, die |
|
102 | - # |
|
103 | - if (!function_exists('xml_parser_create')) { |
|
104 | - $this->error("Failed to load PHP's XML Extension. " . 'http://www.php.net/manual/en/ref.xml.php', E_USER_ERROR); |
|
105 | - } |
|
106 | - |
|
107 | - list($parser, $source) = $this->create_parser($source, $output_encoding, $input_encoding, $detect_encoding); |
|
108 | - |
|
109 | - if (!is_resource($parser)) { |
|
110 | - $this->error("Failed to create an instance of PHP's XML parser. " . 'http://www.php.net/manual/en/ref.xml.php', E_USER_ERROR); |
|
111 | - } |
|
112 | - |
|
113 | - $this->parser = $parser; |
|
114 | - |
|
115 | - # pass in parser, and a reference to this object |
|
116 | - # setup handlers |
|
117 | - # |
|
118 | - xml_set_object($this->parser, $this); |
|
119 | - xml_set_elementHandler($this->parser, 'feed_start_element', 'feed_end_element'); |
|
120 | - |
|
121 | - xml_set_character_dataHandler($this->parser, 'feed_cdata'); |
|
122 | - |
|
123 | - $status = @xml_parse($this->parser, $source); |
|
124 | - |
|
125 | - if (!$status) { |
|
126 | - $errorcode = xml_get_error_code($this->parser); |
|
127 | - if ($errorcode != XML_ERROR_NONE) { |
|
128 | - $xml_error = xml_error_string($errorcode); |
|
129 | - $error_line = xml_get_current_line_number($this->parser); |
|
130 | - $error_col = xml_get_current_column_number($this->parser); |
|
131 | - $errormsg = "$xml_error at line $error_line, column $error_col"; |
|
132 | - |
|
133 | - $this->error($errormsg); |
|
134 | - } |
|
135 | - } |
|
136 | - |
|
137 | - xml_parser_free($this->parser); |
|
138 | - |
|
139 | - $this->normalize(); |
|
140 | - } |
|
141 | - |
|
142 | - /** |
|
143 | - * @param $p |
|
144 | - * @param $element |
|
145 | - * @param $attrs |
|
146 | - */ |
|
147 | - public function feed_start_element($p, $element, &$attrs) |
|
148 | - { |
|
149 | - $el = $element = strtolower($element); |
|
150 | - $attrs = array_change_key_case($attrs, CASE_LOWER); |
|
151 | - |
|
152 | - // check for a namespace, and split if found |
|
153 | - $ns = false; |
|
154 | - if (strpos($element, ':')) { |
|
155 | - list($ns, $el) = explode(':', $element, 2); |
|
156 | - } |
|
157 | - if ($ns && $ns !== 'rdf') { |
|
158 | - $this->current_namespace = $ns; |
|
159 | - } |
|
160 | - |
|
161 | - # if feed type isn't set, then this is first element of feed |
|
162 | - # identify feed from root element |
|
163 | - # |
|
164 | - if (!isset($this->feed_type)) { |
|
165 | - if ($el === 'rdf') { |
|
166 | - $this->feed_type = RSS; |
|
167 | - $this->feed_version = '1.0'; |
|
168 | - } elseif ($el === 'rss') { |
|
169 | - $this->feed_type = RSS; |
|
170 | - $this->feed_version = $attrs['version']; |
|
171 | - } elseif ($el === 'feed') { |
|
172 | - $this->feed_type = ATOM; |
|
173 | - $this->feed_version = $attrs['version']; |
|
174 | - $this->inchannel = true; |
|
175 | - } |
|
176 | - |
|
177 | - return; |
|
178 | - } |
|
179 | - |
|
180 | - if ($el === 'channel') { |
|
181 | - $this->inchannel = true; |
|
182 | - } elseif ($el === 'item' || $el === 'entry') { |
|
183 | - $this->initem = true; |
|
184 | - if (isset($attrs['rdf:about'])) { |
|
185 | - $this->current_item['about'] = $attrs['rdf:about']; |
|
186 | - } |
|
187 | - } |
|
188 | - |
|
189 | - // if we're in the default namespace of an RSS feed, |
|
190 | - // record textinput or image fields |
|
191 | - elseif ($this->feed_type == RSS && $this->current_namespace === '' && $el === 'textinput') { |
|
192 | - $this->intextinput = true; |
|
193 | - } elseif ($this->feed_type == RSS && $this->current_namespace === '' && $el === 'image') { |
|
194 | - $this->inimage = true; |
|
195 | - } # handle atom content constructs |
|
196 | - elseif ($this->feed_type == ATOM && in_array($el, $this->_CONTENT_CONSTRUCTS)) { |
|
197 | - // avoid clashing w/ RSS mod_content |
|
198 | - if ($el === 'content') { |
|
199 | - $el = 'atom_content'; |
|
200 | - } |
|
201 | - |
|
202 | - $this->incontent = $el; |
|
203 | - } // if inside an Atom content construct (e.g. content or summary) field treat tags as text |
|
204 | - elseif ($this->feed_type == ATOM && $this->incontent) { |
|
205 | - // if tags are inlined, then flatten |
|
206 | - $attrs_str = implode(' ', array_map('map_attrs', array_keys($attrs), array_values($attrs))); |
|
207 | - |
|
208 | - $this->append_content("<$element $attrs_str>"); |
|
209 | - |
|
210 | - array_unshift($this->stack, $el); |
|
211 | - } |
|
212 | - |
|
213 | - // Atom support many links per containging element. |
|
214 | - // Magpie treats link elements of type rel='alternate' |
|
215 | - // as being equivalent to RSS's simple link element. |
|
216 | - // |
|
217 | - elseif ($this->feed_type == ATOM && $el === 'link') { |
|
218 | - if (isset($attrs['rel']) && $attrs['rel'] === 'alternate') { |
|
219 | - $link_el = 'link'; |
|
220 | - } else { |
|
221 | - $link_el = 'link_' . $attrs['rel']; |
|
222 | - } |
|
223 | - |
|
224 | - $this->append($link_el, $attrs['href']); |
|
225 | - } // set stack[0] to current element |
|
226 | - else { |
|
227 | - array_unshift($this->stack, $el); |
|
228 | - } |
|
229 | - } |
|
230 | - |
|
231 | - /** |
|
232 | - * @param $p |
|
233 | - * @param $text |
|
234 | - */ |
|
235 | - public function feed_cdata($p, $text) |
|
236 | - { |
|
237 | - if ($this->feed_type == ATOM && $this->incontent) { |
|
238 | - $this->append_content($text); |
|
239 | - } else { |
|
240 | - $current_el = implode('_', array_reverse($this->stack)); |
|
241 | - $this->append($current_el, $text); |
|
242 | - } |
|
243 | - } |
|
244 | - |
|
245 | - /** |
|
246 | - * @param $p |
|
247 | - * @param $el |
|
248 | - */ |
|
249 | - public function feed_end_element($p, $el) |
|
250 | - { |
|
251 | - $el = strtolower($el); |
|
252 | - |
|
253 | - if ($el === 'item' || $el === 'entry') { |
|
254 | - $this->items[] = $this->current_item; |
|
255 | - $this->current_item = []; |
|
256 | - $this->initem = false; |
|
257 | - } elseif ($this->feed_type == RSS && $this->current_namespace === '' && $el === 'textinput') { |
|
258 | - $this->intextinput = false; |
|
259 | - } elseif ($this->feed_type == RSS && $this->current_namespace === '' && $el === 'image') { |
|
260 | - $this->inimage = false; |
|
261 | - } elseif ($this->feed_type == ATOM && in_array($el, $this->_CONTENT_CONSTRUCTS)) { |
|
262 | - $this->incontent = false; |
|
263 | - } elseif ($el === 'channel' || $el === 'feed') { |
|
264 | - $this->inchannel = false; |
|
265 | - } elseif ($this->feed_type == ATOM && $this->incontent) { |
|
266 | - // balance tags properly |
|
267 | - // note: i don't think this is actually neccessary |
|
268 | - if ($this->stack[0] == $el) { |
|
269 | - $this->append_content("</$el>"); |
|
270 | - } else { |
|
271 | - $this->append_content("<$el>"); |
|
272 | - } |
|
273 | - |
|
274 | - array_shift($this->stack); |
|
275 | - } else { |
|
276 | - array_shift($this->stack); |
|
277 | - } |
|
278 | - |
|
279 | - $this->current_namespace = false; |
|
280 | - } |
|
281 | - |
|
282 | - /** |
|
283 | - * @param $str1 |
|
284 | - * @param string $str2 |
|
285 | - */ |
|
286 | - public function concat(&$str1, $str2 = '') |
|
287 | - { |
|
288 | - if (!isset($str1)) { |
|
289 | - $str1 = ''; |
|
290 | - } |
|
291 | - $str1 .= $str2; |
|
292 | - } |
|
293 | - |
|
294 | - /** |
|
295 | - * @param $text |
|
296 | - */ |
|
297 | - public function append_content($text) |
|
298 | - { |
|
299 | - if ($this->initem) { |
|
300 | - $this->concat($this->current_item[$this->incontent], $text); |
|
301 | - } elseif ($this->inchannel) { |
|
302 | - $this->concat($this->channel[$this->incontent], $text); |
|
303 | - } |
|
304 | - } |
|
305 | - |
|
306 | - // smart append - field and namespace aware |
|
307 | - |
|
308 | - /** |
|
309 | - * @param $el |
|
310 | - * @param $text |
|
311 | - */ |
|
312 | - public function append($el, $text) |
|
313 | - { |
|
314 | - if (!$el) { |
|
315 | - return; |
|
316 | - } |
|
317 | - if ($this->current_namespace) { |
|
318 | - if ($this->initem) { |
|
319 | - $this->concat($this->current_item[$this->current_namespace][$el], $text); |
|
320 | - } elseif ($this->inchannel) { |
|
321 | - $this->concat($this->channel[$this->current_namespace][$el], $text); |
|
322 | - } elseif ($this->intextinput) { |
|
323 | - $this->concat($this->textinput[$this->current_namespace][$el], $text); |
|
324 | - } elseif ($this->inimage) { |
|
325 | - $this->concat($this->image[$this->current_namespace][$el], $text); |
|
326 | - } |
|
327 | - } else { |
|
328 | - if ($this->initem) { |
|
329 | - $this->concat($this->current_item[$el], $text); |
|
330 | - } elseif ($this->intextinput) { |
|
331 | - $this->concat($this->textinput[$el], $text); |
|
332 | - } elseif ($this->inimage) { |
|
333 | - $this->concat($this->image[$el], $text); |
|
334 | - } elseif ($this->inchannel) { |
|
335 | - $this->concat($this->channel[$el], $text); |
|
336 | - } |
|
337 | - } |
|
338 | - } |
|
339 | - |
|
340 | - public function normalize() |
|
341 | - { |
|
342 | - // if atom populate rss fields |
|
343 | - if ($this->is_atom()) { |
|
344 | - $this->channel['description'] = $this->channel['tagline']; |
|
345 | - for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
|
346 | - $item = $this->items[$i]; |
|
347 | - if (isset($item['summary'])) { |
|
348 | - $item['description'] = $item['summary']; |
|
349 | - } |
|
350 | - if (isset($item['atom_content'])) { |
|
351 | - $item['content']['encoded'] = $item['atom_content']; |
|
352 | - } |
|
353 | - |
|
354 | - $atom_date = isset($item['issued']) ? $item['issued'] : @$item['modified']; |
|
355 | - if ($atom_date) { |
|
356 | - $epoch = @parse_w3cdtf($atom_date); |
|
357 | - if ($epoch && $epoch > 0) { |
|
358 | - $item['date_timestamp'] = $epoch; |
|
359 | - } |
|
360 | - } |
|
361 | - |
|
362 | - $this->items[$i] = $item; |
|
363 | - } |
|
364 | - } elseif ($this->is_rss()) { |
|
365 | - $this->channel['tagline'] = $this->channel['description']; |
|
366 | - for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
|
367 | - $item = $this->items[$i]; |
|
368 | - if (isset($item['description'])) { |
|
369 | - $item['summary'] = $item['description']; |
|
370 | - } |
|
371 | - if (isset($item['content']['encoded'])) { |
|
372 | - $item['atom_content'] = $item['content']['encoded']; |
|
373 | - } |
|
374 | - |
|
375 | - if ($this->is_rss() === '1.0' && isset($item['dc']['date'])) { |
|
376 | - $epoch = @parse_w3cdtf($item['dc']['date']); |
|
377 | - if ($epoch && $epoch > 0) { |
|
378 | - $item['date_timestamp'] = $epoch; |
|
379 | - } |
|
380 | - } elseif (isset($item['pubdate'])) { |
|
381 | - $epoch = @strtotime($item['pubdate']); |
|
382 | - if ($epoch > 0) { |
|
383 | - $item['date_timestamp'] = $epoch; |
|
384 | - } |
|
385 | - } |
|
386 | - |
|
387 | - $this->items[$i] = $item; |
|
388 | - } |
|
389 | - } |
|
390 | - } |
|
391 | - |
|
392 | - /** |
|
393 | - * @return bool |
|
394 | - */ |
|
395 | - public function is_rss() |
|
396 | - { |
|
397 | - if ($this->feed_type == RSS) { |
|
398 | - return $this->feed_version; |
|
399 | - } else { |
|
400 | - return false; |
|
401 | - } |
|
402 | - } |
|
403 | - |
|
404 | - /** |
|
405 | - * @return bool |
|
406 | - */ |
|
407 | - public function is_atom() |
|
408 | - { |
|
409 | - if ($this->feed_type == ATOM) { |
|
410 | - return $this->feed_version; |
|
411 | - } else { |
|
412 | - return false; |
|
413 | - } |
|
414 | - } |
|
415 | - |
|
416 | - /** |
|
417 | - * return XML parser, and possibly re-encoded source |
|
418 | - * @param $source |
|
419 | - * @param $out_enc |
|
420 | - * @param $in_enc |
|
421 | - * @param $detect |
|
422 | - * @return array |
|
423 | - */ |
|
424 | - public function create_parser($source, $out_enc, $in_enc, $detect) |
|
425 | - { |
|
426 | - if (substr(PHP_VERSION, 0, 1) == 5) { |
|
427 | - $parser = $this->php5_create_parser($in_enc, $detect); |
|
428 | - } else { |
|
429 | - list($parser, $source) = $this->php4_create_parser($source, $in_enc, $detect); |
|
430 | - } |
|
431 | - if ($out_enc) { |
|
432 | - $this->encoding = $out_enc; |
|
433 | - xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, $out_enc); |
|
434 | - } |
|
435 | - |
|
436 | - return [$parser, $source]; |
|
437 | - } |
|
438 | - |
|
439 | - /** |
|
440 | - * Instantiate an XML parser under PHP5 |
|
441 | - * |
|
442 | - * PHP5 will do a fine job of detecting input encoding |
|
443 | - * if passed an empty string as the encoding. |
|
444 | - * |
|
445 | - * All hail libxml2! |
|
446 | - * @param $in_enc |
|
447 | - * @param $detect |
|
448 | - * @return resource |
|
449 | - */ |
|
450 | - public function php5_create_parser($in_enc, $detect) |
|
451 | - { |
|
452 | - // by default php5 does a fine job of detecting input encodings |
|
453 | - if (!$detect && $in_enc) { |
|
454 | - return xml_parser_create($in_enc); |
|
455 | - } else { |
|
456 | - return xml_parser_create(''); |
|
457 | - } |
|
458 | - } |
|
459 | - |
|
460 | - /** |
|
461 | - * Instaniate an XML parser under PHP4 |
|
462 | - * |
|
463 | - * Unfortunately PHP4's support for character encodings |
|
464 | - * and especially XML and character encodings sucks. As |
|
465 | - * long as the documents you parse only contain characters |
|
466 | - * from the ISO-8859-1 character set (a superset of ASCII, |
|
467 | - * and a subset of UTF-8) you're fine. However once you |
|
468 | - * step out of that comfy little world things get mad, bad, |
|
469 | - * and dangerous to know. |
|
470 | - * |
|
471 | - * The following code is based on SJM's work with FoF |
|
472 | - * @see http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss |
|
473 | - * @param $source |
|
474 | - * @param $in_enc |
|
475 | - * @param $detect |
|
476 | - * @return array |
|
477 | - */ |
|
478 | - public function php4_create_parser($source, $in_enc, $detect) |
|
479 | - { |
|
480 | - if (!$detect) { |
|
481 | - return [xml_parser_create($in_enc), $source]; |
|
482 | - } |
|
483 | - |
|
484 | - if (!$in_enc) { |
|
485 | - if (preg_match('/<?xml.*encoding=[\'"](.*?)[\'"].*?>/m', $source, $m)) { |
|
486 | - $in_enc = strtoupper($m[1]); |
|
487 | - $this->source_encoding = $in_enc; |
|
488 | - } else { |
|
489 | - $in_enc = 'UTF-8'; |
|
490 | - } |
|
491 | - } |
|
492 | - |
|
493 | - if ($this->known_encoding($in_enc)) { |
|
494 | - return [xml_parser_create($in_enc), $source]; |
|
495 | - } |
|
496 | - |
|
497 | - /* |
|
36 | + public $parser; |
|
37 | + |
|
38 | + public $current_item = []; // item currently being parsed |
|
39 | + public $items = []; // collection of parsed items |
|
40 | + public $channel = []; // hash of channel fields |
|
41 | + public $textinput = []; |
|
42 | + public $image = []; |
|
43 | + public $feed_type; |
|
44 | + public $feed_version; |
|
45 | + public $encoding = ''; // output encoding of parsed rss |
|
46 | + |
|
47 | + public $_source_encoding = ''; // only set if we have to parse xml prolog |
|
48 | + |
|
49 | + public $ERROR = ''; |
|
50 | + public $WARNING = ''; |
|
51 | + |
|
52 | + // define some constants |
|
53 | + |
|
54 | + public $_CONTENT_CONSTRUCTS = ['content', 'summary', 'info', 'title', 'tagline', 'copyright']; |
|
55 | + public $_KNOWN_ENCODINGS = ['UTF-8', 'US-ASCII', 'ISO-8859-1']; |
|
56 | + |
|
57 | + // parser variables, useless if you're not a parser, treat as private |
|
58 | + public $stack = []; // parser stack |
|
59 | + public $inchannel = false; |
|
60 | + public $initem = false; |
|
61 | + public $incontent = false; // if in Atom <content mode="xml"> field |
|
62 | + public $intextinput = false; |
|
63 | + public $inimage = false; |
|
64 | + public $current_field = ''; |
|
65 | + public $current_namespace = false; |
|
66 | + |
|
67 | + /** |
|
68 | + * Set up XML parser, parse source, and return populated RSS object.. |
|
69 | + * |
|
70 | + * @param string $source string containing the RSS to be parsed |
|
71 | + * |
|
72 | + * NOTE: Probably a good idea to leave the encoding options alone unless |
|
73 | + * you know what you're doing as PHP's character set support is |
|
74 | + * a little weird. |
|
75 | + * |
|
76 | + * NOTE: A lot of this is unnecessary but harmless with PHP5 |
|
77 | + * |
|
78 | + * |
|
79 | + * @param string $output_encoding output the parsed RSS in this character |
|
80 | + * set defaults to ISO-8859-1 as this is PHP's |
|
81 | + * default. |
|
82 | + * |
|
83 | + * NOTE: might be changed to UTF-8 in future |
|
84 | + * versions. |
|
85 | + * |
|
86 | + * @param string $input_encoding the character set of the incoming RSS source. |
|
87 | + * Leave blank and Magpie will try to figure it |
|
88 | + * out. |
|
89 | + * |
|
90 | + * |
|
91 | + * @param bool $detect_encoding if false Magpie won't attempt to detect |
|
92 | + * source encoding. (caveat emptor) |
|
93 | + * |
|
94 | + */ |
|
95 | + public function __construct( |
|
96 | + $source, |
|
97 | + $output_encoding = 'ISO-8859-1', |
|
98 | + $input_encoding = null, |
|
99 | + $detect_encoding = true |
|
100 | + ) { |
|
101 | + # if PHP xml isn't compiled in, die |
|
102 | + # |
|
103 | + if (!function_exists('xml_parser_create')) { |
|
104 | + $this->error("Failed to load PHP's XML Extension. " . 'http://www.php.net/manual/en/ref.xml.php', E_USER_ERROR); |
|
105 | + } |
|
106 | + |
|
107 | + list($parser, $source) = $this->create_parser($source, $output_encoding, $input_encoding, $detect_encoding); |
|
108 | + |
|
109 | + if (!is_resource($parser)) { |
|
110 | + $this->error("Failed to create an instance of PHP's XML parser. " . 'http://www.php.net/manual/en/ref.xml.php', E_USER_ERROR); |
|
111 | + } |
|
112 | + |
|
113 | + $this->parser = $parser; |
|
114 | + |
|
115 | + # pass in parser, and a reference to this object |
|
116 | + # setup handlers |
|
117 | + # |
|
118 | + xml_set_object($this->parser, $this); |
|
119 | + xml_set_elementHandler($this->parser, 'feed_start_element', 'feed_end_element'); |
|
120 | + |
|
121 | + xml_set_character_dataHandler($this->parser, 'feed_cdata'); |
|
122 | + |
|
123 | + $status = @xml_parse($this->parser, $source); |
|
124 | + |
|
125 | + if (!$status) { |
|
126 | + $errorcode = xml_get_error_code($this->parser); |
|
127 | + if ($errorcode != XML_ERROR_NONE) { |
|
128 | + $xml_error = xml_error_string($errorcode); |
|
129 | + $error_line = xml_get_current_line_number($this->parser); |
|
130 | + $error_col = xml_get_current_column_number($this->parser); |
|
131 | + $errormsg = "$xml_error at line $error_line, column $error_col"; |
|
132 | + |
|
133 | + $this->error($errormsg); |
|
134 | + } |
|
135 | + } |
|
136 | + |
|
137 | + xml_parser_free($this->parser); |
|
138 | + |
|
139 | + $this->normalize(); |
|
140 | + } |
|
141 | + |
|
142 | + /** |
|
143 | + * @param $p |
|
144 | + * @param $element |
|
145 | + * @param $attrs |
|
146 | + */ |
|
147 | + public function feed_start_element($p, $element, &$attrs) |
|
148 | + { |
|
149 | + $el = $element = strtolower($element); |
|
150 | + $attrs = array_change_key_case($attrs, CASE_LOWER); |
|
151 | + |
|
152 | + // check for a namespace, and split if found |
|
153 | + $ns = false; |
|
154 | + if (strpos($element, ':')) { |
|
155 | + list($ns, $el) = explode(':', $element, 2); |
|
156 | + } |
|
157 | + if ($ns && $ns !== 'rdf') { |
|
158 | + $this->current_namespace = $ns; |
|
159 | + } |
|
160 | + |
|
161 | + # if feed type isn't set, then this is first element of feed |
|
162 | + # identify feed from root element |
|
163 | + # |
|
164 | + if (!isset($this->feed_type)) { |
|
165 | + if ($el === 'rdf') { |
|
166 | + $this->feed_type = RSS; |
|
167 | + $this->feed_version = '1.0'; |
|
168 | + } elseif ($el === 'rss') { |
|
169 | + $this->feed_type = RSS; |
|
170 | + $this->feed_version = $attrs['version']; |
|
171 | + } elseif ($el === 'feed') { |
|
172 | + $this->feed_type = ATOM; |
|
173 | + $this->feed_version = $attrs['version']; |
|
174 | + $this->inchannel = true; |
|
175 | + } |
|
176 | + |
|
177 | + return; |
|
178 | + } |
|
179 | + |
|
180 | + if ($el === 'channel') { |
|
181 | + $this->inchannel = true; |
|
182 | + } elseif ($el === 'item' || $el === 'entry') { |
|
183 | + $this->initem = true; |
|
184 | + if (isset($attrs['rdf:about'])) { |
|
185 | + $this->current_item['about'] = $attrs['rdf:about']; |
|
186 | + } |
|
187 | + } |
|
188 | + |
|
189 | + // if we're in the default namespace of an RSS feed, |
|
190 | + // record textinput or image fields |
|
191 | + elseif ($this->feed_type == RSS && $this->current_namespace === '' && $el === 'textinput') { |
|
192 | + $this->intextinput = true; |
|
193 | + } elseif ($this->feed_type == RSS && $this->current_namespace === '' && $el === 'image') { |
|
194 | + $this->inimage = true; |
|
195 | + } # handle atom content constructs |
|
196 | + elseif ($this->feed_type == ATOM && in_array($el, $this->_CONTENT_CONSTRUCTS)) { |
|
197 | + // avoid clashing w/ RSS mod_content |
|
198 | + if ($el === 'content') { |
|
199 | + $el = 'atom_content'; |
|
200 | + } |
|
201 | + |
|
202 | + $this->incontent = $el; |
|
203 | + } // if inside an Atom content construct (e.g. content or summary) field treat tags as text |
|
204 | + elseif ($this->feed_type == ATOM && $this->incontent) { |
|
205 | + // if tags are inlined, then flatten |
|
206 | + $attrs_str = implode(' ', array_map('map_attrs', array_keys($attrs), array_values($attrs))); |
|
207 | + |
|
208 | + $this->append_content("<$element $attrs_str>"); |
|
209 | + |
|
210 | + array_unshift($this->stack, $el); |
|
211 | + } |
|
212 | + |
|
213 | + // Atom support many links per containging element. |
|
214 | + // Magpie treats link elements of type rel='alternate' |
|
215 | + // as being equivalent to RSS's simple link element. |
|
216 | + // |
|
217 | + elseif ($this->feed_type == ATOM && $el === 'link') { |
|
218 | + if (isset($attrs['rel']) && $attrs['rel'] === 'alternate') { |
|
219 | + $link_el = 'link'; |
|
220 | + } else { |
|
221 | + $link_el = 'link_' . $attrs['rel']; |
|
222 | + } |
|
223 | + |
|
224 | + $this->append($link_el, $attrs['href']); |
|
225 | + } // set stack[0] to current element |
|
226 | + else { |
|
227 | + array_unshift($this->stack, $el); |
|
228 | + } |
|
229 | + } |
|
230 | + |
|
231 | + /** |
|
232 | + * @param $p |
|
233 | + * @param $text |
|
234 | + */ |
|
235 | + public function feed_cdata($p, $text) |
|
236 | + { |
|
237 | + if ($this->feed_type == ATOM && $this->incontent) { |
|
238 | + $this->append_content($text); |
|
239 | + } else { |
|
240 | + $current_el = implode('_', array_reverse($this->stack)); |
|
241 | + $this->append($current_el, $text); |
|
242 | + } |
|
243 | + } |
|
244 | + |
|
245 | + /** |
|
246 | + * @param $p |
|
247 | + * @param $el |
|
248 | + */ |
|
249 | + public function feed_end_element($p, $el) |
|
250 | + { |
|
251 | + $el = strtolower($el); |
|
252 | + |
|
253 | + if ($el === 'item' || $el === 'entry') { |
|
254 | + $this->items[] = $this->current_item; |
|
255 | + $this->current_item = []; |
|
256 | + $this->initem = false; |
|
257 | + } elseif ($this->feed_type == RSS && $this->current_namespace === '' && $el === 'textinput') { |
|
258 | + $this->intextinput = false; |
|
259 | + } elseif ($this->feed_type == RSS && $this->current_namespace === '' && $el === 'image') { |
|
260 | + $this->inimage = false; |
|
261 | + } elseif ($this->feed_type == ATOM && in_array($el, $this->_CONTENT_CONSTRUCTS)) { |
|
262 | + $this->incontent = false; |
|
263 | + } elseif ($el === 'channel' || $el === 'feed') { |
|
264 | + $this->inchannel = false; |
|
265 | + } elseif ($this->feed_type == ATOM && $this->incontent) { |
|
266 | + // balance tags properly |
|
267 | + // note: i don't think this is actually neccessary |
|
268 | + if ($this->stack[0] == $el) { |
|
269 | + $this->append_content("</$el>"); |
|
270 | + } else { |
|
271 | + $this->append_content("<$el>"); |
|
272 | + } |
|
273 | + |
|
274 | + array_shift($this->stack); |
|
275 | + } else { |
|
276 | + array_shift($this->stack); |
|
277 | + } |
|
278 | + |
|
279 | + $this->current_namespace = false; |
|
280 | + } |
|
281 | + |
|
282 | + /** |
|
283 | + * @param $str1 |
|
284 | + * @param string $str2 |
|
285 | + */ |
|
286 | + public function concat(&$str1, $str2 = '') |
|
287 | + { |
|
288 | + if (!isset($str1)) { |
|
289 | + $str1 = ''; |
|
290 | + } |
|
291 | + $str1 .= $str2; |
|
292 | + } |
|
293 | + |
|
294 | + /** |
|
295 | + * @param $text |
|
296 | + */ |
|
297 | + public function append_content($text) |
|
298 | + { |
|
299 | + if ($this->initem) { |
|
300 | + $this->concat($this->current_item[$this->incontent], $text); |
|
301 | + } elseif ($this->inchannel) { |
|
302 | + $this->concat($this->channel[$this->incontent], $text); |
|
303 | + } |
|
304 | + } |
|
305 | + |
|
306 | + // smart append - field and namespace aware |
|
307 | + |
|
308 | + /** |
|
309 | + * @param $el |
|
310 | + * @param $text |
|
311 | + */ |
|
312 | + public function append($el, $text) |
|
313 | + { |
|
314 | + if (!$el) { |
|
315 | + return; |
|
316 | + } |
|
317 | + if ($this->current_namespace) { |
|
318 | + if ($this->initem) { |
|
319 | + $this->concat($this->current_item[$this->current_namespace][$el], $text); |
|
320 | + } elseif ($this->inchannel) { |
|
321 | + $this->concat($this->channel[$this->current_namespace][$el], $text); |
|
322 | + } elseif ($this->intextinput) { |
|
323 | + $this->concat($this->textinput[$this->current_namespace][$el], $text); |
|
324 | + } elseif ($this->inimage) { |
|
325 | + $this->concat($this->image[$this->current_namespace][$el], $text); |
|
326 | + } |
|
327 | + } else { |
|
328 | + if ($this->initem) { |
|
329 | + $this->concat($this->current_item[$el], $text); |
|
330 | + } elseif ($this->intextinput) { |
|
331 | + $this->concat($this->textinput[$el], $text); |
|
332 | + } elseif ($this->inimage) { |
|
333 | + $this->concat($this->image[$el], $text); |
|
334 | + } elseif ($this->inchannel) { |
|
335 | + $this->concat($this->channel[$el], $text); |
|
336 | + } |
|
337 | + } |
|
338 | + } |
|
339 | + |
|
340 | + public function normalize() |
|
341 | + { |
|
342 | + // if atom populate rss fields |
|
343 | + if ($this->is_atom()) { |
|
344 | + $this->channel['description'] = $this->channel['tagline']; |
|
345 | + for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
|
346 | + $item = $this->items[$i]; |
|
347 | + if (isset($item['summary'])) { |
|
348 | + $item['description'] = $item['summary']; |
|
349 | + } |
|
350 | + if (isset($item['atom_content'])) { |
|
351 | + $item['content']['encoded'] = $item['atom_content']; |
|
352 | + } |
|
353 | + |
|
354 | + $atom_date = isset($item['issued']) ? $item['issued'] : @$item['modified']; |
|
355 | + if ($atom_date) { |
|
356 | + $epoch = @parse_w3cdtf($atom_date); |
|
357 | + if ($epoch && $epoch > 0) { |
|
358 | + $item['date_timestamp'] = $epoch; |
|
359 | + } |
|
360 | + } |
|
361 | + |
|
362 | + $this->items[$i] = $item; |
|
363 | + } |
|
364 | + } elseif ($this->is_rss()) { |
|
365 | + $this->channel['tagline'] = $this->channel['description']; |
|
366 | + for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
|
367 | + $item = $this->items[$i]; |
|
368 | + if (isset($item['description'])) { |
|
369 | + $item['summary'] = $item['description']; |
|
370 | + } |
|
371 | + if (isset($item['content']['encoded'])) { |
|
372 | + $item['atom_content'] = $item['content']['encoded']; |
|
373 | + } |
|
374 | + |
|
375 | + if ($this->is_rss() === '1.0' && isset($item['dc']['date'])) { |
|
376 | + $epoch = @parse_w3cdtf($item['dc']['date']); |
|
377 | + if ($epoch && $epoch > 0) { |
|
378 | + $item['date_timestamp'] = $epoch; |
|
379 | + } |
|
380 | + } elseif (isset($item['pubdate'])) { |
|
381 | + $epoch = @strtotime($item['pubdate']); |
|
382 | + if ($epoch > 0) { |
|
383 | + $item['date_timestamp'] = $epoch; |
|
384 | + } |
|
385 | + } |
|
386 | + |
|
387 | + $this->items[$i] = $item; |
|
388 | + } |
|
389 | + } |
|
390 | + } |
|
391 | + |
|
392 | + /** |
|
393 | + * @return bool |
|
394 | + */ |
|
395 | + public function is_rss() |
|
396 | + { |
|
397 | + if ($this->feed_type == RSS) { |
|
398 | + return $this->feed_version; |
|
399 | + } else { |
|
400 | + return false; |
|
401 | + } |
|
402 | + } |
|
403 | + |
|
404 | + /** |
|
405 | + * @return bool |
|
406 | + */ |
|
407 | + public function is_atom() |
|
408 | + { |
|
409 | + if ($this->feed_type == ATOM) { |
|
410 | + return $this->feed_version; |
|
411 | + } else { |
|
412 | + return false; |
|
413 | + } |
|
414 | + } |
|
415 | + |
|
416 | + /** |
|
417 | + * return XML parser, and possibly re-encoded source |
|
418 | + * @param $source |
|
419 | + * @param $out_enc |
|
420 | + * @param $in_enc |
|
421 | + * @param $detect |
|
422 | + * @return array |
|
423 | + */ |
|
424 | + public function create_parser($source, $out_enc, $in_enc, $detect) |
|
425 | + { |
|
426 | + if (substr(PHP_VERSION, 0, 1) == 5) { |
|
427 | + $parser = $this->php5_create_parser($in_enc, $detect); |
|
428 | + } else { |
|
429 | + list($parser, $source) = $this->php4_create_parser($source, $in_enc, $detect); |
|
430 | + } |
|
431 | + if ($out_enc) { |
|
432 | + $this->encoding = $out_enc; |
|
433 | + xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, $out_enc); |
|
434 | + } |
|
435 | + |
|
436 | + return [$parser, $source]; |
|
437 | + } |
|
438 | + |
|
439 | + /** |
|
440 | + * Instantiate an XML parser under PHP5 |
|
441 | + * |
|
442 | + * PHP5 will do a fine job of detecting input encoding |
|
443 | + * if passed an empty string as the encoding. |
|
444 | + * |
|
445 | + * All hail libxml2! |
|
446 | + * @param $in_enc |
|
447 | + * @param $detect |
|
448 | + * @return resource |
|
449 | + */ |
|
450 | + public function php5_create_parser($in_enc, $detect) |
|
451 | + { |
|
452 | + // by default php5 does a fine job of detecting input encodings |
|
453 | + if (!$detect && $in_enc) { |
|
454 | + return xml_parser_create($in_enc); |
|
455 | + } else { |
|
456 | + return xml_parser_create(''); |
|
457 | + } |
|
458 | + } |
|
459 | + |
|
460 | + /** |
|
461 | + * Instaniate an XML parser under PHP4 |
|
462 | + * |
|
463 | + * Unfortunately PHP4's support for character encodings |
|
464 | + * and especially XML and character encodings sucks. As |
|
465 | + * long as the documents you parse only contain characters |
|
466 | + * from the ISO-8859-1 character set (a superset of ASCII, |
|
467 | + * and a subset of UTF-8) you're fine. However once you |
|
468 | + * step out of that comfy little world things get mad, bad, |
|
469 | + * and dangerous to know. |
|
470 | + * |
|
471 | + * The following code is based on SJM's work with FoF |
|
472 | + * @see http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss |
|
473 | + * @param $source |
|
474 | + * @param $in_enc |
|
475 | + * @param $detect |
|
476 | + * @return array |
|
477 | + */ |
|
478 | + public function php4_create_parser($source, $in_enc, $detect) |
|
479 | + { |
|
480 | + if (!$detect) { |
|
481 | + return [xml_parser_create($in_enc), $source]; |
|
482 | + } |
|
483 | + |
|
484 | + if (!$in_enc) { |
|
485 | + if (preg_match('/<?xml.*encoding=[\'"](.*?)[\'"].*?>/m', $source, $m)) { |
|
486 | + $in_enc = strtoupper($m[1]); |
|
487 | + $this->source_encoding = $in_enc; |
|
488 | + } else { |
|
489 | + $in_enc = 'UTF-8'; |
|
490 | + } |
|
491 | + } |
|
492 | + |
|
493 | + if ($this->known_encoding($in_enc)) { |
|
494 | + return [xml_parser_create($in_enc), $source]; |
|
495 | + } |
|
496 | + |
|
497 | + /* |
|
498 | 498 | // the dectected encoding is not one of the simple encodings PHP knows |
499 | 499 | |
500 | 500 | // attempt to use the iconv extension to |
@@ -523,46 +523,46 @@ discard block |
||
523 | 523 | E_USER_NOTICE); |
524 | 524 | */ |
525 | 525 | |
526 | - return [xml_parser_create(), $source]; |
|
527 | - } |
|
528 | - |
|
529 | - /** |
|
530 | - * @param $enc |
|
531 | - * @return bool|string |
|
532 | - */ |
|
533 | - public function known_encoding($enc) |
|
534 | - { |
|
535 | - $enc = strtoupper($enc); |
|
536 | - if (in_array($enc, $this->_KNOWN_ENCODINGS)) { |
|
537 | - return $enc; |
|
538 | - } else { |
|
539 | - return false; |
|
540 | - } |
|
541 | - } |
|
542 | - |
|
543 | - /** |
|
544 | - * @param $errormsg |
|
545 | - * @param int $lvl |
|
546 | - */ |
|
547 | - public function error($errormsg, $lvl = E_USER_WARNING) |
|
548 | - { |
|
549 | - // append PHP's error message if track_errors enabled |
|
550 | - if (!empty($php_errormsg)) { |
|
551 | - $errormsg .= " ($php_errormsg)"; |
|
552 | - } |
|
553 | - if (MAGPIE_DEBUG) { |
|
554 | - trigger_error($errormsg, $lvl); |
|
555 | - } else { |
|
556 | - error_log($errormsg, 0); |
|
557 | - } |
|
558 | - |
|
559 | - $notices = E_USER_NOTICE | E_NOTICE; |
|
560 | - if ($lvl & $notices) { |
|
561 | - $this->WARNING = $errormsg; |
|
562 | - } else { |
|
563 | - $this->ERROR = $errormsg; |
|
564 | - } |
|
565 | - } |
|
526 | + return [xml_parser_create(), $source]; |
|
527 | + } |
|
528 | + |
|
529 | + /** |
|
530 | + * @param $enc |
|
531 | + * @return bool|string |
|
532 | + */ |
|
533 | + public function known_encoding($enc) |
|
534 | + { |
|
535 | + $enc = strtoupper($enc); |
|
536 | + if (in_array($enc, $this->_KNOWN_ENCODINGS)) { |
|
537 | + return $enc; |
|
538 | + } else { |
|
539 | + return false; |
|
540 | + } |
|
541 | + } |
|
542 | + |
|
543 | + /** |
|
544 | + * @param $errormsg |
|
545 | + * @param int $lvl |
|
546 | + */ |
|
547 | + public function error($errormsg, $lvl = E_USER_WARNING) |
|
548 | + { |
|
549 | + // append PHP's error message if track_errors enabled |
|
550 | + if (!empty($php_errormsg)) { |
|
551 | + $errormsg .= " ($php_errormsg)"; |
|
552 | + } |
|
553 | + if (MAGPIE_DEBUG) { |
|
554 | + trigger_error($errormsg, $lvl); |
|
555 | + } else { |
|
556 | + error_log($errormsg, 0); |
|
557 | + } |
|
558 | + |
|
559 | + $notices = E_USER_NOTICE | E_NOTICE; |
|
560 | + if ($lvl & $notices) { |
|
561 | + $this->WARNING = $errormsg; |
|
562 | + } else { |
|
563 | + $this->ERROR = $errormsg; |
|
564 | + } |
|
565 | + } |
|
566 | 566 | } // end class RSS |
567 | 567 | |
568 | 568 | /** |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | */ |
573 | 573 | function map_attrs($k, $v) |
574 | 574 | { |
575 | - return "$k=\"$v\""; |
|
575 | + return "$k=\"$v\""; |
|
576 | 576 | } |
577 | 577 | |
578 | 578 | /** |
@@ -581,50 +581,50 @@ discard block |
||
581 | 581 | */ |
582 | 582 | function parse_w3cdtf($date_str) |
583 | 583 | { |
584 | - # regex to match wc3dtf |
|
585 | - $pat = "/(\d{4})-(\d{2})-(\d{2})[T]?(\d{2})?[:]?(\d{2})?(:(\d{2}))?(?:([-+])(\d{2}):?(\d{2})|(Z))?/"; |
|
586 | - |
|
587 | - if (preg_match($pat, $date_str, $match)) { |
|
588 | - list($year, $month, $day, $hours, $minutes, $seconds) = [ |
|
589 | - $match[1], |
|
590 | - $match[2], |
|
591 | - $match[3], |
|
592 | - $match[4], |
|
593 | - $match[5], |
|
594 | - $match[6] |
|
595 | - ]; |
|
596 | - |
|
597 | - # calc epoch for current date assuming GMT |
|
598 | - $epoch = gmmktime((int)$hours, (int)$minutes, (int)$seconds, (int)$month, (int)$day, (int)$year); |
|
599 | - |
|
600 | - $offset = 0; |
|
601 | - if ($match[10] === 'Z') { |
|
602 | - # zulu time, aka GMT |
|
603 | - } else { |
|
604 | - list($tz_mod, $tz_hour, $tz_min) = [$match[8], $match[9], $match[10]]; |
|
605 | - |
|
606 | - # zero out the variables |
|
607 | - if (!$tz_hour) { |
|
608 | - $tz_hour = 0; |
|
609 | - } |
|
610 | - if (!$tz_min) { |
|
611 | - $tz_min = 0; |
|
612 | - } |
|
613 | - |
|
614 | - $offset_secs = (($tz_hour * 60) + $tz_min) * 60; |
|
615 | - |
|
616 | - # is timezone ahead of GMT? then subtract offset |
|
617 | - # |
|
618 | - if ($tz_mod == '+') { |
|
619 | - $offset_secs = $offset_secs * -1; |
|
620 | - } |
|
621 | - |
|
622 | - $offset = $offset_secs; |
|
623 | - } |
|
624 | - $epoch = $epoch + $offset; |
|
625 | - |
|
626 | - return $epoch; |
|
627 | - } else { |
|
628 | - return -1; |
|
629 | - } |
|
584 | + # regex to match wc3dtf |
|
585 | + $pat = "/(\d{4})-(\d{2})-(\d{2})[T]?(\d{2})?[:]?(\d{2})?(:(\d{2}))?(?:([-+])(\d{2}):?(\d{2})|(Z))?/"; |
|
586 | + |
|
587 | + if (preg_match($pat, $date_str, $match)) { |
|
588 | + list($year, $month, $day, $hours, $minutes, $seconds) = [ |
|
589 | + $match[1], |
|
590 | + $match[2], |
|
591 | + $match[3], |
|
592 | + $match[4], |
|
593 | + $match[5], |
|
594 | + $match[6] |
|
595 | + ]; |
|
596 | + |
|
597 | + # calc epoch for current date assuming GMT |
|
598 | + $epoch = gmmktime((int)$hours, (int)$minutes, (int)$seconds, (int)$month, (int)$day, (int)$year); |
|
599 | + |
|
600 | + $offset = 0; |
|
601 | + if ($match[10] === 'Z') { |
|
602 | + # zulu time, aka GMT |
|
603 | + } else { |
|
604 | + list($tz_mod, $tz_hour, $tz_min) = [$match[8], $match[9], $match[10]]; |
|
605 | + |
|
606 | + # zero out the variables |
|
607 | + if (!$tz_hour) { |
|
608 | + $tz_hour = 0; |
|
609 | + } |
|
610 | + if (!$tz_min) { |
|
611 | + $tz_min = 0; |
|
612 | + } |
|
613 | + |
|
614 | + $offset_secs = (($tz_hour * 60) + $tz_min) * 60; |
|
615 | + |
|
616 | + # is timezone ahead of GMT? then subtract offset |
|
617 | + # |
|
618 | + if ($tz_mod == '+') { |
|
619 | + $offset_secs = $offset_secs * -1; |
|
620 | + } |
|
621 | + |
|
622 | + $offset = $offset_secs; |
|
623 | + } |
|
624 | + $epoch = $epoch + $offset; |
|
625 | + |
|
626 | + return $epoch; |
|
627 | + } else { |
|
628 | + return -1; |
|
629 | + } |
|
630 | 630 | } |
@@ -35,16 +35,16 @@ discard block |
||
35 | 35 | { |
36 | 36 | public $parser; |
37 | 37 | |
38 | - public $current_item = []; // item currently being parsed |
|
39 | - public $items = []; // collection of parsed items |
|
40 | - public $channel = []; // hash of channel fields |
|
38 | + public $current_item = []; // item currently being parsed |
|
39 | + public $items = []; // collection of parsed items |
|
40 | + public $channel = []; // hash of channel fields |
|
41 | 41 | public $textinput = []; |
42 | 42 | public $image = []; |
43 | 43 | public $feed_type; |
44 | 44 | public $feed_version; |
45 | - public $encoding = ''; // output encoding of parsed rss |
|
45 | + public $encoding = ''; // output encoding of parsed rss |
|
46 | 46 | |
47 | - public $_source_encoding = ''; // only set if we have to parse xml prolog |
|
47 | + public $_source_encoding = ''; // only set if we have to parse xml prolog |
|
48 | 48 | |
49 | 49 | public $ERROR = ''; |
50 | 50 | public $WARNING = ''; |
@@ -101,13 +101,13 @@ discard block |
||
101 | 101 | # if PHP xml isn't compiled in, die |
102 | 102 | # |
103 | 103 | if (!function_exists('xml_parser_create')) { |
104 | - $this->error("Failed to load PHP's XML Extension. " . 'http://www.php.net/manual/en/ref.xml.php', E_USER_ERROR); |
|
104 | + $this->error("Failed to load PHP's XML Extension. ".'http://www.php.net/manual/en/ref.xml.php', E_USER_ERROR); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | list($parser, $source) = $this->create_parser($source, $output_encoding, $input_encoding, $detect_encoding); |
108 | 108 | |
109 | 109 | if (!is_resource($parser)) { |
110 | - $this->error("Failed to create an instance of PHP's XML parser. " . 'http://www.php.net/manual/en/ref.xml.php', E_USER_ERROR); |
|
110 | + $this->error("Failed to create an instance of PHP's XML parser. ".'http://www.php.net/manual/en/ref.xml.php', E_USER_ERROR); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | $this->parser = $parser; |
@@ -217,8 +217,8 @@ discard block |
||
217 | 217 | elseif ($this->feed_type == ATOM && $el === 'link') { |
218 | 218 | if (isset($attrs['rel']) && $attrs['rel'] === 'alternate') { |
219 | 219 | $link_el = 'link'; |
220 | - } else { |
|
221 | - $link_el = 'link_' . $attrs['rel']; |
|
220 | + }else { |
|
221 | + $link_el = 'link_'.$attrs['rel']; |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | $this->append($link_el, $attrs['href']); |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | { |
237 | 237 | if ($this->feed_type == ATOM && $this->incontent) { |
238 | 238 | $this->append_content($text); |
239 | - } else { |
|
239 | + }else { |
|
240 | 240 | $current_el = implode('_', array_reverse($this->stack)); |
241 | 241 | $this->append($current_el, $text); |
242 | 242 | } |
@@ -267,12 +267,12 @@ discard block |
||
267 | 267 | // note: i don't think this is actually neccessary |
268 | 268 | if ($this->stack[0] == $el) { |
269 | 269 | $this->append_content("</$el>"); |
270 | - } else { |
|
270 | + }else { |
|
271 | 271 | $this->append_content("<$el>"); |
272 | 272 | } |
273 | 273 | |
274 | 274 | array_shift($this->stack); |
275 | - } else { |
|
275 | + }else { |
|
276 | 276 | array_shift($this->stack); |
277 | 277 | } |
278 | 278 | |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | } elseif ($this->inimage) { |
325 | 325 | $this->concat($this->image[$this->current_namespace][$el], $text); |
326 | 326 | } |
327 | - } else { |
|
327 | + }else { |
|
328 | 328 | if ($this->initem) { |
329 | 329 | $this->concat($this->current_item[$el], $text); |
330 | 330 | } elseif ($this->intextinput) { |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | // if atom populate rss fields |
343 | 343 | if ($this->is_atom()) { |
344 | 344 | $this->channel['description'] = $this->channel['tagline']; |
345 | - for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
|
345 | + for ($i = 0, $iMax = count($this->items); $i<$iMax; ++$i) { |
|
346 | 346 | $item = $this->items[$i]; |
347 | 347 | if (isset($item['summary'])) { |
348 | 348 | $item['description'] = $item['summary']; |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | $atom_date = isset($item['issued']) ? $item['issued'] : @$item['modified']; |
355 | 355 | if ($atom_date) { |
356 | 356 | $epoch = @parse_w3cdtf($atom_date); |
357 | - if ($epoch && $epoch > 0) { |
|
357 | + if ($epoch && $epoch>0) { |
|
358 | 358 | $item['date_timestamp'] = $epoch; |
359 | 359 | } |
360 | 360 | } |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | } |
364 | 364 | } elseif ($this->is_rss()) { |
365 | 365 | $this->channel['tagline'] = $this->channel['description']; |
366 | - for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
|
366 | + for ($i = 0, $iMax = count($this->items); $i<$iMax; ++$i) { |
|
367 | 367 | $item = $this->items[$i]; |
368 | 368 | if (isset($item['description'])) { |
369 | 369 | $item['summary'] = $item['description']; |
@@ -374,12 +374,12 @@ discard block |
||
374 | 374 | |
375 | 375 | if ($this->is_rss() === '1.0' && isset($item['dc']['date'])) { |
376 | 376 | $epoch = @parse_w3cdtf($item['dc']['date']); |
377 | - if ($epoch && $epoch > 0) { |
|
377 | + if ($epoch && $epoch>0) { |
|
378 | 378 | $item['date_timestamp'] = $epoch; |
379 | 379 | } |
380 | 380 | } elseif (isset($item['pubdate'])) { |
381 | 381 | $epoch = @strtotime($item['pubdate']); |
382 | - if ($epoch > 0) { |
|
382 | + if ($epoch>0) { |
|
383 | 383 | $item['date_timestamp'] = $epoch; |
384 | 384 | } |
385 | 385 | } |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | { |
397 | 397 | if ($this->feed_type == RSS) { |
398 | 398 | return $this->feed_version; |
399 | - } else { |
|
399 | + }else { |
|
400 | 400 | return false; |
401 | 401 | } |
402 | 402 | } |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | { |
409 | 409 | if ($this->feed_type == ATOM) { |
410 | 410 | return $this->feed_version; |
411 | - } else { |
|
411 | + }else { |
|
412 | 412 | return false; |
413 | 413 | } |
414 | 414 | } |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | { |
426 | 426 | if (substr(PHP_VERSION, 0, 1) == 5) { |
427 | 427 | $parser = $this->php5_create_parser($in_enc, $detect); |
428 | - } else { |
|
428 | + }else { |
|
429 | 429 | list($parser, $source) = $this->php4_create_parser($source, $in_enc, $detect); |
430 | 430 | } |
431 | 431 | if ($out_enc) { |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | // by default php5 does a fine job of detecting input encodings |
453 | 453 | if (!$detect && $in_enc) { |
454 | 454 | return xml_parser_create($in_enc); |
455 | - } else { |
|
455 | + }else { |
|
456 | 456 | return xml_parser_create(''); |
457 | 457 | } |
458 | 458 | } |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | if (preg_match('/<?xml.*encoding=[\'"](.*?)[\'"].*?>/m', $source, $m)) { |
486 | 486 | $in_enc = strtoupper($m[1]); |
487 | 487 | $this->source_encoding = $in_enc; |
488 | - } else { |
|
488 | + }else { |
|
489 | 489 | $in_enc = 'UTF-8'; |
490 | 490 | } |
491 | 491 | } |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | $enc = strtoupper($enc); |
536 | 536 | if (in_array($enc, $this->_KNOWN_ENCODINGS)) { |
537 | 537 | return $enc; |
538 | - } else { |
|
538 | + }else { |
|
539 | 539 | return false; |
540 | 540 | } |
541 | 541 | } |
@@ -552,14 +552,14 @@ discard block |
||
552 | 552 | } |
553 | 553 | if (MAGPIE_DEBUG) { |
554 | 554 | trigger_error($errormsg, $lvl); |
555 | - } else { |
|
555 | + }else { |
|
556 | 556 | error_log($errormsg, 0); |
557 | 557 | } |
558 | 558 | |
559 | 559 | $notices = E_USER_NOTICE | E_NOTICE; |
560 | 560 | if ($lvl & $notices) { |
561 | 561 | $this->WARNING = $errormsg; |
562 | - } else { |
|
562 | + }else { |
|
563 | 563 | $this->ERROR = $errormsg; |
564 | 564 | } |
565 | 565 | } |
@@ -595,12 +595,12 @@ discard block |
||
595 | 595 | ]; |
596 | 596 | |
597 | 597 | # calc epoch for current date assuming GMT |
598 | - $epoch = gmmktime((int)$hours, (int)$minutes, (int)$seconds, (int)$month, (int)$day, (int)$year); |
|
598 | + $epoch = gmmktime((int) $hours, (int) $minutes, (int) $seconds, (int) $month, (int) $day, (int) $year); |
|
599 | 599 | |
600 | 600 | $offset = 0; |
601 | 601 | if ($match[10] === 'Z') { |
602 | 602 | # zulu time, aka GMT |
603 | - } else { |
|
603 | + }else { |
|
604 | 604 | list($tz_mod, $tz_hour, $tz_min) = [$match[8], $match[9], $match[10]]; |
605 | 605 | |
606 | 606 | # zero out the variables |
@@ -611,20 +611,20 @@ discard block |
||
611 | 611 | $tz_min = 0; |
612 | 612 | } |
613 | 613 | |
614 | - $offset_secs = (($tz_hour * 60) + $tz_min) * 60; |
|
614 | + $offset_secs = (($tz_hour*60)+$tz_min)*60; |
|
615 | 615 | |
616 | 616 | # is timezone ahead of GMT? then subtract offset |
617 | 617 | # |
618 | 618 | if ($tz_mod == '+') { |
619 | - $offset_secs = $offset_secs * -1; |
|
619 | + $offset_secs = $offset_secs*-1; |
|
620 | 620 | } |
621 | 621 | |
622 | 622 | $offset = $offset_secs; |
623 | 623 | } |
624 | - $epoch = $epoch + $offset; |
|
624 | + $epoch = $epoch+$offset; |
|
625 | 625 | |
626 | 626 | return $epoch; |
627 | - } else { |
|
627 | + }else { |
|
628 | 628 | return -1; |
629 | 629 | } |
630 | 630 | } |
@@ -43,171 +43,171 @@ |
||
43 | 43 | **/ |
44 | 44 | class xmlparser extends MagpieRSS |
45 | 45 | { |
46 | - public $content; |
|
47 | - public $charset_in; |
|
48 | - public $charset_out; |
|
46 | + public $content; |
|
47 | + public $charset_in; |
|
48 | + public $charset_out; |
|
49 | 49 | |
50 | - /** |
|
51 | - * Set up XML parser, parse source, and return populated RSS object.. |
|
52 | - * |
|
53 | - * @param string $content string containing the RSS to be parsed |
|
54 | - * |
|
55 | - * |
|
56 | - * @param string $input_charset |
|
57 | - * @param null|string $output_charset |
|
58 | - * @param array $tags |
|
59 | - * @internal param string $output_encoding output the parsed RSS in this character |
|
60 | - * set defaults to ISO-8859-1 as this is PHP's |
|
61 | - * default. |
|
62 | - * |
|
63 | - * @internal param string $input_encoding the character set of the incoming RSS source. |
|
64 | - * Leave blank and Magpie will try to figure it |
|
65 | - * out. |
|
66 | - */ |
|
67 | - public function __construct($content, $input_charset, $output_charset = _CHARSET, $tags = []) |
|
68 | - { |
|
69 | - if (!in_array(strtoupper($input_charset), ['UTF-8', 'US-ASCII', 'ISO-8859-1'])) { |
|
70 | - $content = XoopsLocal::convert_encoding($content, 'UTF-8', $input_charset); |
|
71 | - $content = preg_replace('/(<\?xml.*encoding=[\'"])(.*?)([\'"].*\?>)/m', '$1UTF-8$3', $content); |
|
72 | - $input_charset = 'UTF-8'; |
|
73 | - } |
|
74 | - $this->content = $content; |
|
75 | - $this->charset_in = $input_charset; |
|
76 | - $this->charset_out = $output_charset; |
|
50 | + /** |
|
51 | + * Set up XML parser, parse source, and return populated RSS object.. |
|
52 | + * |
|
53 | + * @param string $content string containing the RSS to be parsed |
|
54 | + * |
|
55 | + * |
|
56 | + * @param string $input_charset |
|
57 | + * @param null|string $output_charset |
|
58 | + * @param array $tags |
|
59 | + * @internal param string $output_encoding output the parsed RSS in this character |
|
60 | + * set defaults to ISO-8859-1 as this is PHP's |
|
61 | + * default. |
|
62 | + * |
|
63 | + * @internal param string $input_encoding the character set of the incoming RSS source. |
|
64 | + * Leave blank and Magpie will try to figure it |
|
65 | + * out. |
|
66 | + */ |
|
67 | + public function __construct($content, $input_charset, $output_charset = _CHARSET, $tags = []) |
|
68 | + { |
|
69 | + if (!in_array(strtoupper($input_charset), ['UTF-8', 'US-ASCII', 'ISO-8859-1'])) { |
|
70 | + $content = XoopsLocal::convert_encoding($content, 'UTF-8', $input_charset); |
|
71 | + $content = preg_replace('/(<\?xml.*encoding=[\'"])(.*?)([\'"].*\?>)/m', '$1UTF-8$3', $content); |
|
72 | + $input_charset = 'UTF-8'; |
|
73 | + } |
|
74 | + $this->content = $content; |
|
75 | + $this->charset_in = $input_charset; |
|
76 | + $this->charset_out = $output_charset; |
|
77 | 77 | |
78 | - /* TODO: parse specified tags only */ |
|
79 | - parent::__construct($content, $input_charset, $input_charset, false); |
|
78 | + /* TODO: parse specified tags only */ |
|
79 | + parent::__construct($content, $input_charset, $input_charset, false); |
|
80 | 80 | |
81 | - //xoops_message($this); |
|
82 | - unset($this->content); |
|
83 | - $this->encoding_convert($tags); |
|
84 | - } |
|
81 | + //xoops_message($this); |
|
82 | + unset($this->content); |
|
83 | + $this->encoding_convert($tags); |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * @return bool|string |
|
88 | - */ |
|
89 | - public function is_atom() |
|
90 | - { |
|
91 | - if ($this->feed_type == ATOM) { |
|
92 | - $this->feed_version = empty($this->feed_version) ? '0.3' : $this->feed_version; |
|
86 | + /** |
|
87 | + * @return bool|string |
|
88 | + */ |
|
89 | + public function is_atom() |
|
90 | + { |
|
91 | + if ($this->feed_type == ATOM) { |
|
92 | + $this->feed_version = empty($this->feed_version) ? '0.3' : $this->feed_version; |
|
93 | 93 | |
94 | - return $this->feed_version; |
|
95 | - } else { |
|
96 | - return false; |
|
97 | - } |
|
98 | - } |
|
94 | + return $this->feed_version; |
|
95 | + } else { |
|
96 | + return false; |
|
97 | + } |
|
98 | + } |
|
99 | 99 | |
100 | - public function normalize() |
|
101 | - { |
|
102 | - if ($this->is_atom()): |
|
103 | - if (empty($this->channel['tagline'])) { |
|
104 | - /* ATOM */ |
|
105 | - $this->channel['tagline'] = @$this->channel['subtitle']; |
|
106 | - unset($this->channel['subtitle']); |
|
107 | - } |
|
108 | - for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
|
109 | - // ATOM time |
|
110 | - if ($date = @$this->items[$i]['modified']) { |
|
111 | - continue; |
|
112 | - } |
|
113 | - if (empty($date)) { |
|
114 | - $date = @$this->items[$i]['updated']; |
|
115 | - } |
|
116 | - if (empty($date)) { |
|
117 | - $date = @$this->items[$i]['issued']; |
|
118 | - } |
|
119 | - if (empty($date)) { |
|
120 | - $date = @$this->items[$i]['created']; |
|
121 | - } |
|
122 | - if (empty($date)) { |
|
123 | - $date = @$this->items[$i]['created']; |
|
124 | - } |
|
125 | - $this->items[$i]['modified'] = $date; |
|
126 | - } elseif ($this->is_rss() !== '1.0'): |
|
127 | - for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
|
128 | - if ($date = @$this->items[$i]['pubdate']) { |
|
129 | - continue; |
|
130 | - } |
|
131 | - $this->items[$i]['pubdate'] = @$this->items[$i]['dc']['date']; |
|
132 | - } |
|
133 | - endif; |
|
134 | - parent::normalize(); |
|
135 | - /* ATOM */ |
|
136 | - if (empty($this->channel['language']) && !empty($this->channel['dc']['language'])) { |
|
137 | - $this->channel['language'] = $this->channel['dc']['language']; |
|
138 | - unset($this->channel['dc']['language']); |
|
139 | - } |
|
140 | - if (empty($this->channel['language']) |
|
141 | - && preg_match('/<link.*hreflang=[\'"](.*?)[\'"].*?>/m', $this->content, $match)) { |
|
142 | - $this->channel['language'] = $match[1]; |
|
143 | - } |
|
144 | - if (empty($this->channel['language']) |
|
145 | - && preg_match('/<feed.*xml:lang=[\'"](.*?)[\'"].*?>/m', $this->content, $match)) { |
|
146 | - $this->channel['language'] = $match[1]; |
|
147 | - } |
|
148 | - /* remove to avoid redundant encoding conversion */ |
|
149 | - if (!empty($this->channel['tagline'])) { |
|
150 | - unset($this->channel['tagline']); |
|
151 | - } |
|
100 | + public function normalize() |
|
101 | + { |
|
102 | + if ($this->is_atom()): |
|
103 | + if (empty($this->channel['tagline'])) { |
|
104 | + /* ATOM */ |
|
105 | + $this->channel['tagline'] = @$this->channel['subtitle']; |
|
106 | + unset($this->channel['subtitle']); |
|
107 | + } |
|
108 | + for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
|
109 | + // ATOM time |
|
110 | + if ($date = @$this->items[$i]['modified']) { |
|
111 | + continue; |
|
112 | + } |
|
113 | + if (empty($date)) { |
|
114 | + $date = @$this->items[$i]['updated']; |
|
115 | + } |
|
116 | + if (empty($date)) { |
|
117 | + $date = @$this->items[$i]['issued']; |
|
118 | + } |
|
119 | + if (empty($date)) { |
|
120 | + $date = @$this->items[$i]['created']; |
|
121 | + } |
|
122 | + if (empty($date)) { |
|
123 | + $date = @$this->items[$i]['created']; |
|
124 | + } |
|
125 | + $this->items[$i]['modified'] = $date; |
|
126 | + } elseif ($this->is_rss() !== '1.0'): |
|
127 | + for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
|
128 | + if ($date = @$this->items[$i]['pubdate']) { |
|
129 | + continue; |
|
130 | + } |
|
131 | + $this->items[$i]['pubdate'] = @$this->items[$i]['dc']['date']; |
|
132 | + } |
|
133 | + endif; |
|
134 | + parent::normalize(); |
|
135 | + /* ATOM */ |
|
136 | + if (empty($this->channel['language']) && !empty($this->channel['dc']['language'])) { |
|
137 | + $this->channel['language'] = $this->channel['dc']['language']; |
|
138 | + unset($this->channel['dc']['language']); |
|
139 | + } |
|
140 | + if (empty($this->channel['language']) |
|
141 | + && preg_match('/<link.*hreflang=[\'"](.*?)[\'"].*?>/m', $this->content, $match)) { |
|
142 | + $this->channel['language'] = $match[1]; |
|
143 | + } |
|
144 | + if (empty($this->channel['language']) |
|
145 | + && preg_match('/<feed.*xml:lang=[\'"](.*?)[\'"].*?>/m', $this->content, $match)) { |
|
146 | + $this->channel['language'] = $match[1]; |
|
147 | + } |
|
148 | + /* remove to avoid redundant encoding conversion */ |
|
149 | + if (!empty($this->channel['tagline'])) { |
|
150 | + unset($this->channel['tagline']); |
|
151 | + } |
|
152 | 152 | |
153 | - for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
|
154 | - if ($date_timestamp = @$this->items[$i]['date_timestamp']) { |
|
155 | - continue; |
|
156 | - } |
|
157 | - if ($date_timestamp = @$this->items[$i]['pubdate']) { |
|
158 | - $this->items[$i]['date_timestamp'] = $date_timestamp; |
|
159 | - } elseif ($date_timestamp = @$this->items[$i]['dc']['date']) { |
|
160 | - $this->items[$i]['date_timestamp'] = $date_timestamp; |
|
161 | - } else { |
|
162 | - $this->items[$i]['date_timestamp'] = time(); |
|
163 | - } |
|
164 | - if (!is_numeric($this->items[$i]['date_timestamp'])) { |
|
165 | - if ($date = parse_w3cdtf($this->items[$i]['date_timestamp'])) { |
|
166 | - $this->items[$i]['date_timestamp'] = $date; |
|
167 | - } elseif ($date = strtotime($this->items[$i]['date_timestamp'])) { |
|
168 | - $this->items[$i]['date_timestamp'] = $date; |
|
169 | - } |
|
170 | - } |
|
153 | + for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
|
154 | + if ($date_timestamp = @$this->items[$i]['date_timestamp']) { |
|
155 | + continue; |
|
156 | + } |
|
157 | + if ($date_timestamp = @$this->items[$i]['pubdate']) { |
|
158 | + $this->items[$i]['date_timestamp'] = $date_timestamp; |
|
159 | + } elseif ($date_timestamp = @$this->items[$i]['dc']['date']) { |
|
160 | + $this->items[$i]['date_timestamp'] = $date_timestamp; |
|
161 | + } else { |
|
162 | + $this->items[$i]['date_timestamp'] = time(); |
|
163 | + } |
|
164 | + if (!is_numeric($this->items[$i]['date_timestamp'])) { |
|
165 | + if ($date = parse_w3cdtf($this->items[$i]['date_timestamp'])) { |
|
166 | + $this->items[$i]['date_timestamp'] = $date; |
|
167 | + } elseif ($date = strtotime($this->items[$i]['date_timestamp'])) { |
|
168 | + $this->items[$i]['date_timestamp'] = $date; |
|
169 | + } |
|
170 | + } |
|
171 | 171 | |
172 | - /* remove to avoid redundant encoding conversion */ |
|
173 | - if (isset($this->items[$i]['summary'])) { |
|
174 | - unset($this->items[$i]['summary']); |
|
175 | - } |
|
176 | - if (isset($this->items[$i]['atom_content'])) { |
|
177 | - unset($this->items[$i]['atom_content']); |
|
178 | - } |
|
179 | - } |
|
172 | + /* remove to avoid redundant encoding conversion */ |
|
173 | + if (isset($this->items[$i]['summary'])) { |
|
174 | + unset($this->items[$i]['summary']); |
|
175 | + } |
|
176 | + if (isset($this->items[$i]['atom_content'])) { |
|
177 | + unset($this->items[$i]['atom_content']); |
|
178 | + } |
|
179 | + } |
|
180 | 180 | |
181 | - return; |
|
182 | - } |
|
181 | + return; |
|
182 | + } |
|
183 | 183 | |
184 | - /** |
|
185 | - * @param array $tags |
|
186 | - */ |
|
187 | - public function encoding_convert($tags = []) |
|
188 | - { |
|
189 | - if (empty($tags) || in_array('channel', $tags)) { |
|
190 | - $this->channel = $this->_encoding($this->channel); |
|
191 | - } |
|
192 | - if (empty($tags) || in_array('items', $tags)) { |
|
193 | - $this->items = $this->_encoding($this->items); |
|
194 | - } |
|
195 | - } |
|
184 | + /** |
|
185 | + * @param array $tags |
|
186 | + */ |
|
187 | + public function encoding_convert($tags = []) |
|
188 | + { |
|
189 | + if (empty($tags) || in_array('channel', $tags)) { |
|
190 | + $this->channel = $this->_encoding($this->channel); |
|
191 | + } |
|
192 | + if (empty($tags) || in_array('items', $tags)) { |
|
193 | + $this->items = $this->_encoding($this->items); |
|
194 | + } |
|
195 | + } |
|
196 | 196 | |
197 | - /** |
|
198 | - * @param $val |
|
199 | - * @return array|mixed|string |
|
200 | - */ |
|
201 | - public function _encoding($val) |
|
202 | - { |
|
203 | - if (is_array($val)) { |
|
204 | - foreach (array_keys($val) as $key) { |
|
205 | - $val[$key] = $this->_encoding($val[$key]); |
|
206 | - } |
|
207 | - } else { |
|
208 | - $val = XoopsLocal::convert_encoding($val, $this->charset_out, $this->charset_in); |
|
209 | - } |
|
197 | + /** |
|
198 | + * @param $val |
|
199 | + * @return array|mixed|string |
|
200 | + */ |
|
201 | + public function _encoding($val) |
|
202 | + { |
|
203 | + if (is_array($val)) { |
|
204 | + foreach (array_keys($val) as $key) { |
|
205 | + $val[$key] = $this->_encoding($val[$key]); |
|
206 | + } |
|
207 | + } else { |
|
208 | + $val = XoopsLocal::convert_encoding($val, $this->charset_out, $this->charset_in); |
|
209 | + } |
|
210 | 210 | |
211 | - return $val; |
|
212 | - } |
|
211 | + return $val; |
|
212 | + } |
|
213 | 213 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | */ |
31 | 31 | global $msg; |
32 | 32 | |
33 | -require_once XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/class/magpie.inc.php'; |
|
33 | +require_once XOOPS_ROOT_PATH.'/modules/'.$GLOBALS['moddirname'].'/class/magpie.inc.php'; |
|
34 | 34 | |
35 | 35 | /** |
36 | 36 | * XmlParser |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | $this->feed_version = empty($this->feed_version) ? '0.3' : $this->feed_version; |
93 | 93 | |
94 | 94 | return $this->feed_version; |
95 | - } else { |
|
95 | + }else { |
|
96 | 96 | return false; |
97 | 97 | } |
98 | 98 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | $this->channel['tagline'] = @$this->channel['subtitle']; |
106 | 106 | unset($this->channel['subtitle']); |
107 | 107 | } |
108 | - for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
|
108 | + for ($i = 0, $iMax = count($this->items); $i<$iMax; ++$i) { |
|
109 | 109 | // ATOM time |
110 | 110 | if ($date = @$this->items[$i]['modified']) { |
111 | 111 | continue; |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | } |
125 | 125 | $this->items[$i]['modified'] = $date; |
126 | 126 | } elseif ($this->is_rss() !== '1.0'): |
127 | - for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
|
127 | + for ($i = 0, $iMax = count($this->items); $i<$iMax; ++$i) { |
|
128 | 128 | if ($date = @$this->items[$i]['pubdate']) { |
129 | 129 | continue; |
130 | 130 | } |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | unset($this->channel['tagline']); |
151 | 151 | } |
152 | 152 | |
153 | - for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
|
153 | + for ($i = 0, $iMax = count($this->items); $i<$iMax; ++$i) { |
|
154 | 154 | if ($date_timestamp = @$this->items[$i]['date_timestamp']) { |
155 | 155 | continue; |
156 | 156 | } |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | $this->items[$i]['date_timestamp'] = $date_timestamp; |
159 | 159 | } elseif ($date_timestamp = @$this->items[$i]['dc']['date']) { |
160 | 160 | $this->items[$i]['date_timestamp'] = $date_timestamp; |
161 | - } else { |
|
161 | + }else { |
|
162 | 162 | $this->items[$i]['date_timestamp'] = time(); |
163 | 163 | } |
164 | 164 | if (!is_numeric($this->items[$i]['date_timestamp'])) { |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | foreach (array_keys($val) as $key) { |
205 | 205 | $val[$key] = $this->_encoding($val[$key]); |
206 | 206 | } |
207 | - } else { |
|
207 | + }else { |
|
208 | 208 | $val = XoopsLocal::convert_encoding($val, $this->charset_out, $this->charset_in); |
209 | 209 | } |
210 | 210 |
@@ -197,52 +197,52 @@ discard block |
||
197 | 197 | */ |
198 | 198 | class FeedItem extends HtmlDescribable |
199 | 199 | { |
200 | - /** |
|
201 | - * Mandatory attributes of an item. |
|
202 | - */ |
|
203 | - public $title; |
|
204 | - public $description; |
|
205 | - public $link; |
|
206 | - |
|
207 | - /** |
|
208 | - * Optional attributes of an item. |
|
209 | - */ |
|
210 | - public $author; |
|
211 | - public $authorEmail; |
|
212 | - public $image; |
|
213 | - public $category; |
|
214 | - public $comments; |
|
215 | - public $guid; |
|
216 | - public $source; |
|
217 | - public $creator; |
|
218 | - |
|
219 | - /** |
|
220 | - * Publishing date of an item. May be in one of the following formats: |
|
221 | - * |
|
222 | - * RFC 822: |
|
223 | - * "Mon, 20 Jan 03 18:05:41 +0400" |
|
224 | - * "20 Jan 03 18:05:41 +0000" |
|
225 | - * |
|
226 | - * ISO 8601: |
|
227 | - * "2003-01-20T18:05:41+04:00" |
|
228 | - * |
|
229 | - * Unix: |
|
230 | - * 1043082341 |
|
231 | - */ |
|
232 | - public $date; |
|
233 | - |
|
234 | - /** |
|
235 | - * Any additional elements to include as an assiciated array. All $key => $value pairs |
|
236 | - * will be included unencoded in the feed item in the form |
|
237 | - * <$key>$value</$key> |
|
238 | - * Again: No encoding will be used! This means you can invalidate or enhance the feed |
|
239 | - * if $value contains markup. This may be abused to embed tags not implemented by |
|
240 | - * the FeedCreator class used. |
|
241 | - */ |
|
242 | - public $additionalElements = []; |
|
243 | - |
|
244 | - // on hold |
|
245 | - // var $source; |
|
200 | + /** |
|
201 | + * Mandatory attributes of an item. |
|
202 | + */ |
|
203 | + public $title; |
|
204 | + public $description; |
|
205 | + public $link; |
|
206 | + |
|
207 | + /** |
|
208 | + * Optional attributes of an item. |
|
209 | + */ |
|
210 | + public $author; |
|
211 | + public $authorEmail; |
|
212 | + public $image; |
|
213 | + public $category; |
|
214 | + public $comments; |
|
215 | + public $guid; |
|
216 | + public $source; |
|
217 | + public $creator; |
|
218 | + |
|
219 | + /** |
|
220 | + * Publishing date of an item. May be in one of the following formats: |
|
221 | + * |
|
222 | + * RFC 822: |
|
223 | + * "Mon, 20 Jan 03 18:05:41 +0400" |
|
224 | + * "20 Jan 03 18:05:41 +0000" |
|
225 | + * |
|
226 | + * ISO 8601: |
|
227 | + * "2003-01-20T18:05:41+04:00" |
|
228 | + * |
|
229 | + * Unix: |
|
230 | + * 1043082341 |
|
231 | + */ |
|
232 | + public $date; |
|
233 | + |
|
234 | + /** |
|
235 | + * Any additional elements to include as an assiciated array. All $key => $value pairs |
|
236 | + * will be included unencoded in the feed item in the form |
|
237 | + * <$key>$value</$key> |
|
238 | + * Again: No encoding will be used! This means you can invalidate or enhance the feed |
|
239 | + * if $value contains markup. This may be abused to embed tags not implemented by |
|
240 | + * the FeedCreator class used. |
|
241 | + */ |
|
242 | + public $additionalElements = []; |
|
243 | + |
|
244 | + // on hold |
|
245 | + // var $source; |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | /** |
@@ -252,19 +252,19 @@ discard block |
||
252 | 252 | */ |
253 | 253 | class FeedImage extends HtmlDescribable |
254 | 254 | { |
255 | - /** |
|
256 | - * Mandatory attributes of an image. |
|
257 | - */ |
|
258 | - public $title; |
|
259 | - public $url; |
|
260 | - public $link; |
|
261 | - |
|
262 | - /** |
|
263 | - * Optional attributes of an image. |
|
264 | - */ |
|
265 | - public $width; |
|
266 | - public $height; |
|
267 | - public $description; |
|
255 | + /** |
|
256 | + * Mandatory attributes of an image. |
|
257 | + */ |
|
258 | + public $title; |
|
259 | + public $url; |
|
260 | + public $link; |
|
261 | + |
|
262 | + /** |
|
263 | + * Optional attributes of an image. |
|
264 | + */ |
|
265 | + public $width; |
|
266 | + public $height; |
|
267 | + public $description; |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | /** |
@@ -273,29 +273,29 @@ discard block |
||
273 | 273 | */ |
274 | 274 | class HtmlDescribable |
275 | 275 | { |
276 | - /** |
|
277 | - * Indicates whether the description field should be rendered in HTML. |
|
278 | - */ |
|
279 | - public $descriptionHtmlSyndicated; |
|
280 | - |
|
281 | - /** |
|
282 | - * Indicates whether and to how many characters a description should be truncated. |
|
283 | - */ |
|
284 | - public $descriptionTruncSize; |
|
285 | - |
|
286 | - /** |
|
287 | - * Returns a formatted description field, depending on descriptionHtmlSyndicated and |
|
288 | - * $descriptionTruncSize properties |
|
289 | - * @return string the formatted description |
|
290 | - */ |
|
291 | - public function getDescription() |
|
292 | - { |
|
293 | - $descriptionField = new FeedHtmlField($this->description); |
|
294 | - $descriptionField->syndicateHtml = $this->descriptionHtmlSyndicated; |
|
295 | - $descriptionField->truncSize = $this->descriptionTruncSize; |
|
296 | - |
|
297 | - return $descriptionField->output(); |
|
298 | - } |
|
276 | + /** |
|
277 | + * Indicates whether the description field should be rendered in HTML. |
|
278 | + */ |
|
279 | + public $descriptionHtmlSyndicated; |
|
280 | + |
|
281 | + /** |
|
282 | + * Indicates whether and to how many characters a description should be truncated. |
|
283 | + */ |
|
284 | + public $descriptionTruncSize; |
|
285 | + |
|
286 | + /** |
|
287 | + * Returns a formatted description field, depending on descriptionHtmlSyndicated and |
|
288 | + * $descriptionTruncSize properties |
|
289 | + * @return string the formatted description |
|
290 | + */ |
|
291 | + public function getDescription() |
|
292 | + { |
|
293 | + $descriptionField = new FeedHtmlField($this->description); |
|
294 | + $descriptionField->syndicateHtml = $this->descriptionHtmlSyndicated; |
|
295 | + $descriptionField->truncSize = $this->descriptionTruncSize; |
|
296 | + |
|
297 | + return $descriptionField->output(); |
|
298 | + } |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | /** |
@@ -306,53 +306,53 @@ discard block |
||
306 | 306 | */ |
307 | 307 | class FeedHtmlField |
308 | 308 | { |
309 | - /** |
|
310 | - * Mandatory attributes of a FeedHtmlField. |
|
311 | - */ |
|
312 | - public $rawFieldContent; |
|
313 | - |
|
314 | - /** |
|
315 | - * Optional attributes of a FeedHtmlField. |
|
316 | - * |
|
317 | - */ |
|
318 | - public $truncSize; |
|
319 | - public $syndicateHtml; |
|
320 | - |
|
321 | - /** |
|
322 | - * Creates a new instance of FeedHtmlField. |
|
323 | - * @param $parFieldContent |
|
324 | - * @internal param $string : if given, sets the rawFieldContent property |
|
325 | - */ |
|
326 | - public function __construct($parFieldContent) |
|
327 | - { |
|
328 | - if ($parFieldContent) { |
|
329 | - $this->rawFieldContent = $parFieldContent; |
|
330 | - } |
|
331 | - } |
|
332 | - |
|
333 | - /** |
|
334 | - * Creates the right output, depending on $truncSize, $syndicateHtml properties. |
|
335 | - * @return string the formatted field |
|
336 | - */ |
|
337 | - public function output() |
|
338 | - { |
|
339 | - // when field available and syndicated in html we assume |
|
340 | - // - valid html in $rawFieldContent and we enclose in CDATA tags |
|
341 | - // - no truncation (truncating risks producing invalid html) |
|
342 | - if (!$this->rawFieldContent) { |
|
343 | - $result = ''; |
|
344 | - } elseif ($this->syndicateHtml) { |
|
345 | - $result = '<![CDATA[' . $this->rawFieldContent . ']]>'; |
|
346 | - } else { |
|
347 | - if ($this->truncSize && is_int($this->truncSize)) { |
|
348 | - $result = FeedCreator::iTrunc(htmlspecialchars($this->rawFieldContent), $this->truncSize); |
|
349 | - } else { |
|
350 | - $result = htmlspecialchars($this->rawFieldContent); |
|
351 | - } |
|
352 | - } |
|
353 | - |
|
354 | - return $result; |
|
355 | - } |
|
309 | + /** |
|
310 | + * Mandatory attributes of a FeedHtmlField. |
|
311 | + */ |
|
312 | + public $rawFieldContent; |
|
313 | + |
|
314 | + /** |
|
315 | + * Optional attributes of a FeedHtmlField. |
|
316 | + * |
|
317 | + */ |
|
318 | + public $truncSize; |
|
319 | + public $syndicateHtml; |
|
320 | + |
|
321 | + /** |
|
322 | + * Creates a new instance of FeedHtmlField. |
|
323 | + * @param $parFieldContent |
|
324 | + * @internal param $string : if given, sets the rawFieldContent property |
|
325 | + */ |
|
326 | + public function __construct($parFieldContent) |
|
327 | + { |
|
328 | + if ($parFieldContent) { |
|
329 | + $this->rawFieldContent = $parFieldContent; |
|
330 | + } |
|
331 | + } |
|
332 | + |
|
333 | + /** |
|
334 | + * Creates the right output, depending on $truncSize, $syndicateHtml properties. |
|
335 | + * @return string the formatted field |
|
336 | + */ |
|
337 | + public function output() |
|
338 | + { |
|
339 | + // when field available and syndicated in html we assume |
|
340 | + // - valid html in $rawFieldContent and we enclose in CDATA tags |
|
341 | + // - no truncation (truncating risks producing invalid html) |
|
342 | + if (!$this->rawFieldContent) { |
|
343 | + $result = ''; |
|
344 | + } elseif ($this->syndicateHtml) { |
|
345 | + $result = '<![CDATA[' . $this->rawFieldContent . ']]>'; |
|
346 | + } else { |
|
347 | + if ($this->truncSize && is_int($this->truncSize)) { |
|
348 | + $result = FeedCreator::iTrunc(htmlspecialchars($this->rawFieldContent), $this->truncSize); |
|
349 | + } else { |
|
350 | + $result = htmlspecialchars($this->rawFieldContent); |
|
351 | + } |
|
352 | + } |
|
353 | + |
|
354 | + return $result; |
|
355 | + } |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | /** |
@@ -366,129 +366,129 @@ discard block |
||
366 | 366 | */ |
367 | 367 | class UniversalFeedCreator extends FeedCreator |
368 | 368 | { |
369 | - public $_feed; |
|
370 | - |
|
371 | - /** |
|
372 | - * @param $format |
|
373 | - */ |
|
374 | - public function _setFormat($format) |
|
375 | - { |
|
376 | - switch (strtoupper($format)) { |
|
377 | - |
|
378 | - case '2.0': |
|
379 | - // fall through |
|
380 | - case 'RSS2.0': |
|
381 | - $this->_feed = new RSSCreator20(); |
|
382 | - break; |
|
383 | - |
|
384 | - case '1.0': |
|
385 | - // fall through |
|
386 | - case 'RSS1.0': |
|
387 | - $this->_feed = new RSSCreator10(); |
|
388 | - break; |
|
389 | - |
|
390 | - case '0.91': |
|
391 | - // fall through |
|
392 | - case 'RSS0.91': |
|
393 | - $this->_feed = new RSSCreator091(); |
|
394 | - break; |
|
395 | - |
|
396 | - case 'PIE0.1': |
|
397 | - $this->_feed = new PIECreator01(); |
|
398 | - break; |
|
399 | - |
|
400 | - case 'MBOX': |
|
401 | - $this->_feed = new MBOXCreator(); |
|
402 | - break; |
|
403 | - |
|
404 | - case 'OPML': |
|
405 | - $this->_feed = new OPMLCreator(); |
|
406 | - break; |
|
407 | - |
|
408 | - case 'ATOM': |
|
409 | - // fall through: always the latest ATOM version |
|
410 | - |
|
411 | - case 'ATOM0.3': |
|
412 | - $this->_feed = new AtomCreator03(); |
|
413 | - break; |
|
414 | - |
|
415 | - case 'HTML': |
|
416 | - $this->_feed = new HTMLCreator(); |
|
417 | - break; |
|
418 | - |
|
419 | - case 'JS': |
|
420 | - // fall through |
|
421 | - case 'JAVASCRIPT': |
|
422 | - $this->_feed = new JSCreator(); |
|
423 | - break; |
|
424 | - |
|
425 | - default: |
|
426 | - $this->_feed = new RSSCreator091(); |
|
427 | - break; |
|
428 | - } |
|
429 | - |
|
430 | - $vars = get_object_vars($this); |
|
431 | - foreach ($vars as $key => $value) { |
|
432 | - // prevent overwriting of properties "contentType", "encoding"; do not copy "_feed" itself |
|
433 | - //if (!in_array($key, array("_feed", "contentType", "encoding"))) { |
|
434 | - $this->_feed->{$key} = $this->{$key}; |
|
435 | - //} |
|
436 | - } |
|
437 | - } |
|
438 | - |
|
439 | - /** |
|
440 | - * Creates a syndication feed based on the items previously added. |
|
441 | - * |
|
442 | - * @see FeedCreator::addItem() |
|
443 | - * @param string format format the feed should comply to. Valid values are: |
|
444 | - * "PIE0.1", "mbox", "RSS0.91", "RSS1.0", "RSS2.0", "OPML", "ATOM0.3", "HTML", "JS" |
|
445 | - * @return string the contents of the feed. |
|
446 | - */ |
|
447 | - public function createFeed($format = 'RSS0.91') |
|
448 | - { |
|
449 | - $this->_setFormat($format); |
|
450 | - |
|
451 | - return $this->_feed->createFeed(); |
|
452 | - } |
|
453 | - |
|
454 | - /** |
|
455 | - * Saves this feed as a file on the local disk. After the file is saved, an HTTP redirect |
|
456 | - * header may be sent to redirect the use to the newly created file. |
|
457 | - * @since 1.4 |
|
458 | - * |
|
459 | - * @param string $format |
|
460 | - * @param string $filename |
|
461 | - * @param bool $displayContents displayContents optional send the content of the file or not. If true, the file will be sent in the body of the response. |
|
462 | - * @internal param format $string format the feed should comply to. Valid values are: |
|
463 | - * "PIE0.1" (deprecated), "mbox", "RSS0.91", "RSS1.0", "RSS2.0", "OPML", "ATOM", "ATOM0.3", "HTML", "JS" |
|
464 | - * @internal param filename $string optional the filename where a recent version of the feed is saved. If not specified, the filename is $_SERVER["PHP_SELF"] with the extension changed to .xml (see _generateFilename()). |
|
465 | - */ |
|
466 | - public function saveFeed($format = 'RSS0.91', $filename = '', $displayContents = true) |
|
467 | - { |
|
468 | - $this->_setFormat($format); |
|
469 | - $this->_feed->saveFeed($filename, $displayContents); |
|
470 | - } |
|
471 | - |
|
472 | - /** |
|
473 | - * Turns on caching and checks if there is a recent version of this feed in the cache. |
|
474 | - * If there is, an HTTP redirect header is sent. |
|
475 | - * To effectively use caching, you should create the FeedCreator object and call this method |
|
476 | - * before anything else, especially before you do the time consuming task to build the feed |
|
477 | - * (web fetching, for example). |
|
478 | - * |
|
479 | - * @param string $format |
|
480 | - * @param string $filename |
|
481 | - * @param int $timeout |
|
482 | - * @internal param format $string format the feed should comply to. Valid values are: |
|
483 | - * "PIE0.1" (deprecated), "mbox", "RSS0.91", "RSS1.0", "RSS2.0", "OPML", "ATOM0.3". |
|
484 | - * @internal param string $filename optional the filename where a recent version of the feed is saved. If not specified, the filename is $_SERVER["PHP_SELF"] with the extension changed to .xml (see _generateFilename()). |
|
485 | - * @internal param int $timeout optional the timeout in seconds before a cached version is refreshed (defaults to 3600 = 1 hour) |
|
486 | - */ |
|
487 | - public function useCached($format = 'RSS0.91', $filename = '', $timeout = 3600) |
|
488 | - { |
|
489 | - $this->_setFormat($format); |
|
490 | - $this->_feed->useCached($filename, $timeout); |
|
491 | - } |
|
369 | + public $_feed; |
|
370 | + |
|
371 | + /** |
|
372 | + * @param $format |
|
373 | + */ |
|
374 | + public function _setFormat($format) |
|
375 | + { |
|
376 | + switch (strtoupper($format)) { |
|
377 | + |
|
378 | + case '2.0': |
|
379 | + // fall through |
|
380 | + case 'RSS2.0': |
|
381 | + $this->_feed = new RSSCreator20(); |
|
382 | + break; |
|
383 | + |
|
384 | + case '1.0': |
|
385 | + // fall through |
|
386 | + case 'RSS1.0': |
|
387 | + $this->_feed = new RSSCreator10(); |
|
388 | + break; |
|
389 | + |
|
390 | + case '0.91': |
|
391 | + // fall through |
|
392 | + case 'RSS0.91': |
|
393 | + $this->_feed = new RSSCreator091(); |
|
394 | + break; |
|
395 | + |
|
396 | + case 'PIE0.1': |
|
397 | + $this->_feed = new PIECreator01(); |
|
398 | + break; |
|
399 | + |
|
400 | + case 'MBOX': |
|
401 | + $this->_feed = new MBOXCreator(); |
|
402 | + break; |
|
403 | + |
|
404 | + case 'OPML': |
|
405 | + $this->_feed = new OPMLCreator(); |
|
406 | + break; |
|
407 | + |
|
408 | + case 'ATOM': |
|
409 | + // fall through: always the latest ATOM version |
|
410 | + |
|
411 | + case 'ATOM0.3': |
|
412 | + $this->_feed = new AtomCreator03(); |
|
413 | + break; |
|
414 | + |
|
415 | + case 'HTML': |
|
416 | + $this->_feed = new HTMLCreator(); |
|
417 | + break; |
|
418 | + |
|
419 | + case 'JS': |
|
420 | + // fall through |
|
421 | + case 'JAVASCRIPT': |
|
422 | + $this->_feed = new JSCreator(); |
|
423 | + break; |
|
424 | + |
|
425 | + default: |
|
426 | + $this->_feed = new RSSCreator091(); |
|
427 | + break; |
|
428 | + } |
|
429 | + |
|
430 | + $vars = get_object_vars($this); |
|
431 | + foreach ($vars as $key => $value) { |
|
432 | + // prevent overwriting of properties "contentType", "encoding"; do not copy "_feed" itself |
|
433 | + //if (!in_array($key, array("_feed", "contentType", "encoding"))) { |
|
434 | + $this->_feed->{$key} = $this->{$key}; |
|
435 | + //} |
|
436 | + } |
|
437 | + } |
|
438 | + |
|
439 | + /** |
|
440 | + * Creates a syndication feed based on the items previously added. |
|
441 | + * |
|
442 | + * @see FeedCreator::addItem() |
|
443 | + * @param string format format the feed should comply to. Valid values are: |
|
444 | + * "PIE0.1", "mbox", "RSS0.91", "RSS1.0", "RSS2.0", "OPML", "ATOM0.3", "HTML", "JS" |
|
445 | + * @return string the contents of the feed. |
|
446 | + */ |
|
447 | + public function createFeed($format = 'RSS0.91') |
|
448 | + { |
|
449 | + $this->_setFormat($format); |
|
450 | + |
|
451 | + return $this->_feed->createFeed(); |
|
452 | + } |
|
453 | + |
|
454 | + /** |
|
455 | + * Saves this feed as a file on the local disk. After the file is saved, an HTTP redirect |
|
456 | + * header may be sent to redirect the use to the newly created file. |
|
457 | + * @since 1.4 |
|
458 | + * |
|
459 | + * @param string $format |
|
460 | + * @param string $filename |
|
461 | + * @param bool $displayContents displayContents optional send the content of the file or not. If true, the file will be sent in the body of the response. |
|
462 | + * @internal param format $string format the feed should comply to. Valid values are: |
|
463 | + * "PIE0.1" (deprecated), "mbox", "RSS0.91", "RSS1.0", "RSS2.0", "OPML", "ATOM", "ATOM0.3", "HTML", "JS" |
|
464 | + * @internal param filename $string optional the filename where a recent version of the feed is saved. If not specified, the filename is $_SERVER["PHP_SELF"] with the extension changed to .xml (see _generateFilename()). |
|
465 | + */ |
|
466 | + public function saveFeed($format = 'RSS0.91', $filename = '', $displayContents = true) |
|
467 | + { |
|
468 | + $this->_setFormat($format); |
|
469 | + $this->_feed->saveFeed($filename, $displayContents); |
|
470 | + } |
|
471 | + |
|
472 | + /** |
|
473 | + * Turns on caching and checks if there is a recent version of this feed in the cache. |
|
474 | + * If there is, an HTTP redirect header is sent. |
|
475 | + * To effectively use caching, you should create the FeedCreator object and call this method |
|
476 | + * before anything else, especially before you do the time consuming task to build the feed |
|
477 | + * (web fetching, for example). |
|
478 | + * |
|
479 | + * @param string $format |
|
480 | + * @param string $filename |
|
481 | + * @param int $timeout |
|
482 | + * @internal param format $string format the feed should comply to. Valid values are: |
|
483 | + * "PIE0.1" (deprecated), "mbox", "RSS0.91", "RSS1.0", "RSS2.0", "OPML", "ATOM0.3". |
|
484 | + * @internal param string $filename optional the filename where a recent version of the feed is saved. If not specified, the filename is $_SERVER["PHP_SELF"] with the extension changed to .xml (see _generateFilename()). |
|
485 | + * @internal param int $timeout optional the timeout in seconds before a cached version is refreshed (defaults to 3600 = 1 hour) |
|
486 | + */ |
|
487 | + public function useCached($format = 'RSS0.91', $filename = '', $timeout = 3600) |
|
488 | + { |
|
489 | + $this->_setFormat($format); |
|
490 | + $this->_feed->useCached($filename, $timeout); |
|
491 | + } |
|
492 | 492 | } |
493 | 493 | |
494 | 494 | /** |
@@ -501,271 +501,271 @@ discard block |
||
501 | 501 | */ |
502 | 502 | class FeedCreator extends HtmlDescribable |
503 | 503 | { |
504 | - /** |
|
505 | - * Mandatory attributes of a feed. |
|
506 | - */ |
|
507 | - public $title; |
|
508 | - public $description; |
|
509 | - public $link; |
|
510 | - |
|
511 | - /** |
|
512 | - * Optional attributes of a feed. |
|
513 | - */ |
|
514 | - public $syndicationURL; |
|
515 | - public $image; |
|
516 | - public $language; |
|
517 | - public $copyright; |
|
518 | - public $pubDate; |
|
519 | - public $lastBuildDate; |
|
520 | - public $editor; |
|
521 | - public $editorEmail; |
|
522 | - public $webmaster; |
|
523 | - public $category; |
|
524 | - public $docs; |
|
525 | - public $ttl; |
|
526 | - public $rating; |
|
527 | - public $skipHours; |
|
528 | - public $skipDays; |
|
529 | - |
|
530 | - /** |
|
531 | - * The url of the external xsl stylesheet used to format the naked rss feed. |
|
532 | - * Ignored in the output when empty. |
|
533 | - */ |
|
534 | - public $xslStyleSheet = ''; |
|
535 | - |
|
536 | - public $cssStyleSheet = ''; |
|
537 | - |
|
538 | - /** |
|
539 | - * @access private |
|
540 | - */ |
|
541 | - public $items = []; |
|
542 | - |
|
543 | - /** |
|
544 | - * This feed's MIME content type. |
|
545 | - * @since 1.4 |
|
546 | - * @access private |
|
547 | - */ |
|
548 | - public $contentType = 'application/xml'; |
|
549 | - |
|
550 | - /** |
|
551 | - * This feed's character encoding. |
|
552 | - * @since 1.6.1 |
|
553 | - **/ |
|
554 | - public $encoding = 'ISO-8859-1'; |
|
555 | - |
|
556 | - /** |
|
557 | - * Any additional elements to include as an assiciated array. All $key => $value pairs |
|
558 | - * will be included unencoded in the feed in the form |
|
559 | - * <$key>$value</$key> |
|
560 | - * Again: No encoding will be used! This means you can invalidate or enhance the feed |
|
561 | - * if $value contains markup. This may be abused to embed tags not implemented by |
|
562 | - * the FeedCreator class used. |
|
563 | - */ |
|
564 | - public $additionalElements = []; |
|
565 | - |
|
566 | - /** |
|
567 | - * Adds an FeedItem to the feed. |
|
568 | - * |
|
569 | - * @param $item |
|
570 | - * @internal param FeedItem $object $item The FeedItem to add to the feed. |
|
571 | - * @access public |
|
572 | - */ |
|
573 | - public function addItem($item) |
|
574 | - { |
|
575 | - $this->items[] = $item; |
|
576 | - } |
|
577 | - |
|
578 | - /** |
|
579 | - * Truncates a string to a certain length at the most sensible point. |
|
580 | - * First, if there's a '.' character near the end of the string, the string is truncated after this character. |
|
581 | - * If there is no '.', the string is truncated after the last ' ' character. |
|
582 | - * If the string is truncated, " ..." is appended. |
|
583 | - * If the string is already shorter than $length, it is returned unchanged. |
|
584 | - * |
|
585 | - * @static |
|
586 | - * @param string string A string to be truncated. |
|
587 | - * @param int length the maximum length the string should be truncated to |
|
588 | - * @return string the truncated string |
|
589 | - */ |
|
590 | - public function iTrunc($string, $length) |
|
591 | - { |
|
592 | - if (strlen($string) <= $length) { |
|
593 | - return $string; |
|
594 | - } |
|
595 | - |
|
596 | - $pos = strrpos($string, '.'); |
|
597 | - if ($pos >= $length - 4) { |
|
598 | - $string = substr($string, 0, $length - 4); |
|
599 | - $pos = strrpos($string, '.'); |
|
600 | - } |
|
601 | - if ($pos >= $length * 0.4) { |
|
602 | - return substr($string, 0, $pos + 1) . ' ...'; |
|
603 | - } |
|
604 | - |
|
605 | - $pos = strrpos($string, ' '); |
|
606 | - if ($pos >= $length - 4) { |
|
607 | - $string = substr($string, 0, $length - 4); |
|
608 | - $pos = strrpos($string, ' '); |
|
609 | - } |
|
610 | - if ($pos >= $length * 0.4) { |
|
611 | - return substr($string, 0, $pos) . ' ...'; |
|
612 | - } |
|
613 | - |
|
614 | - return substr($string, 0, $length - 4) . ' ...'; |
|
615 | - } |
|
616 | - |
|
617 | - /** |
|
618 | - * Creates a comment indicating the generator of this feed. |
|
619 | - * The format of this comment seems to be recognized by |
|
620 | - * Syndic8.com. |
|
621 | - */ |
|
622 | - public function _createGeneratorComment() |
|
623 | - { |
|
624 | - return "<!-- generator=\"" . FEEDCREATOR_VERSION . "\" -->\n"; |
|
625 | - } |
|
626 | - |
|
627 | - /** |
|
628 | - * Creates a string containing all additional elements specified in |
|
629 | - * $additionalElements. |
|
630 | - * @param array $elements |
|
631 | - * @param string $indentString |
|
632 | - * @return string the XML tags corresponding to $additionalElements |
|
633 | - * @internal param array $elements an associative array containing key => value pairs |
|
634 | - * @internal param string $indentString a string that will be inserted before every generated line |
|
635 | - */ |
|
636 | - public function _createAdditionalElements($elements, $indentString = '') |
|
637 | - { |
|
638 | - $ae = ''; |
|
639 | - if (is_array($elements)) { |
|
640 | - foreach ($elements as $key => $value) { |
|
641 | - $ae .= $indentString . "<$key>$value</$key>\n"; |
|
642 | - } |
|
643 | - } |
|
644 | - |
|
645 | - return $ae; |
|
646 | - } |
|
647 | - |
|
648 | - /** |
|
649 | - * @return string |
|
650 | - */ |
|
651 | - public function _createStylesheetReferences() |
|
652 | - { |
|
653 | - $xml = ''; |
|
654 | - if ($this->cssStyleSheet) { |
|
655 | - $xml .= "<?xml-stylesheet href=\"" . $this->cssStyleSheet . "\" type=\"text/css\"?>\n"; |
|
656 | - } |
|
657 | - if ($this->xslStyleSheet) { |
|
658 | - $xml .= "<?xml-stylesheet href=\"" . $this->xslStyleSheet . "\" type=\"text/xsl\"?>\n"; |
|
659 | - } |
|
660 | - |
|
661 | - return $xml; |
|
662 | - } |
|
663 | - |
|
664 | - /** |
|
665 | - * Builds the feed's text. |
|
666 | - * @abstract |
|
667 | - * @return string the feed's complete text |
|
668 | - */ |
|
669 | - public function createFeed() |
|
670 | - { |
|
671 | - } |
|
672 | - |
|
673 | - /** |
|
674 | - * Generate a filename for the feed cache file. The result will be $_SERVER["PHP_SELF"] with the extension changed to .xml. |
|
675 | - * For example: |
|
676 | - * |
|
677 | - * echo $_SERVER["PHP_SELF"]."\n"; |
|
678 | - * echo FeedCreator::_generateFilename(); |
|
679 | - * |
|
680 | - * would produce: |
|
681 | - * |
|
682 | - * /rss/latestnews.php |
|
683 | - * latestnews.xml |
|
684 | - * |
|
685 | - * @return string the feed cache filename |
|
686 | - * @since 1.4 |
|
687 | - * @access private |
|
688 | - */ |
|
689 | - public function _generateFilename() |
|
690 | - { |
|
691 | - $fileInfo = pathinfo($_SERVER['PHP_SELF']); |
|
692 | - |
|
693 | - return substr($fileInfo['basename'], 0, -(strlen($fileInfo['extension']) + 1)) . '.xml'; |
|
694 | - } |
|
695 | - |
|
696 | - /** |
|
697 | - * @since 1.4 |
|
698 | - * @access private |
|
699 | - * @param $filename |
|
700 | - */ |
|
701 | - public function _redirect($filename) |
|
702 | - { |
|
703 | - // attention, heavily-commented-out-area |
|
704 | - |
|
705 | - // maybe use this in addition to file time checking |
|
706 | - //Header("Expires: ".date("r",time()+$this->_timeout)); |
|
707 | - |
|
708 | - /* no caching at all, doesn't seem to work as good: |
|
504 | + /** |
|
505 | + * Mandatory attributes of a feed. |
|
506 | + */ |
|
507 | + public $title; |
|
508 | + public $description; |
|
509 | + public $link; |
|
510 | + |
|
511 | + /** |
|
512 | + * Optional attributes of a feed. |
|
513 | + */ |
|
514 | + public $syndicationURL; |
|
515 | + public $image; |
|
516 | + public $language; |
|
517 | + public $copyright; |
|
518 | + public $pubDate; |
|
519 | + public $lastBuildDate; |
|
520 | + public $editor; |
|
521 | + public $editorEmail; |
|
522 | + public $webmaster; |
|
523 | + public $category; |
|
524 | + public $docs; |
|
525 | + public $ttl; |
|
526 | + public $rating; |
|
527 | + public $skipHours; |
|
528 | + public $skipDays; |
|
529 | + |
|
530 | + /** |
|
531 | + * The url of the external xsl stylesheet used to format the naked rss feed. |
|
532 | + * Ignored in the output when empty. |
|
533 | + */ |
|
534 | + public $xslStyleSheet = ''; |
|
535 | + |
|
536 | + public $cssStyleSheet = ''; |
|
537 | + |
|
538 | + /** |
|
539 | + * @access private |
|
540 | + */ |
|
541 | + public $items = []; |
|
542 | + |
|
543 | + /** |
|
544 | + * This feed's MIME content type. |
|
545 | + * @since 1.4 |
|
546 | + * @access private |
|
547 | + */ |
|
548 | + public $contentType = 'application/xml'; |
|
549 | + |
|
550 | + /** |
|
551 | + * This feed's character encoding. |
|
552 | + * @since 1.6.1 |
|
553 | + **/ |
|
554 | + public $encoding = 'ISO-8859-1'; |
|
555 | + |
|
556 | + /** |
|
557 | + * Any additional elements to include as an assiciated array. All $key => $value pairs |
|
558 | + * will be included unencoded in the feed in the form |
|
559 | + * <$key>$value</$key> |
|
560 | + * Again: No encoding will be used! This means you can invalidate or enhance the feed |
|
561 | + * if $value contains markup. This may be abused to embed tags not implemented by |
|
562 | + * the FeedCreator class used. |
|
563 | + */ |
|
564 | + public $additionalElements = []; |
|
565 | + |
|
566 | + /** |
|
567 | + * Adds an FeedItem to the feed. |
|
568 | + * |
|
569 | + * @param $item |
|
570 | + * @internal param FeedItem $object $item The FeedItem to add to the feed. |
|
571 | + * @access public |
|
572 | + */ |
|
573 | + public function addItem($item) |
|
574 | + { |
|
575 | + $this->items[] = $item; |
|
576 | + } |
|
577 | + |
|
578 | + /** |
|
579 | + * Truncates a string to a certain length at the most sensible point. |
|
580 | + * First, if there's a '.' character near the end of the string, the string is truncated after this character. |
|
581 | + * If there is no '.', the string is truncated after the last ' ' character. |
|
582 | + * If the string is truncated, " ..." is appended. |
|
583 | + * If the string is already shorter than $length, it is returned unchanged. |
|
584 | + * |
|
585 | + * @static |
|
586 | + * @param string string A string to be truncated. |
|
587 | + * @param int length the maximum length the string should be truncated to |
|
588 | + * @return string the truncated string |
|
589 | + */ |
|
590 | + public function iTrunc($string, $length) |
|
591 | + { |
|
592 | + if (strlen($string) <= $length) { |
|
593 | + return $string; |
|
594 | + } |
|
595 | + |
|
596 | + $pos = strrpos($string, '.'); |
|
597 | + if ($pos >= $length - 4) { |
|
598 | + $string = substr($string, 0, $length - 4); |
|
599 | + $pos = strrpos($string, '.'); |
|
600 | + } |
|
601 | + if ($pos >= $length * 0.4) { |
|
602 | + return substr($string, 0, $pos + 1) . ' ...'; |
|
603 | + } |
|
604 | + |
|
605 | + $pos = strrpos($string, ' '); |
|
606 | + if ($pos >= $length - 4) { |
|
607 | + $string = substr($string, 0, $length - 4); |
|
608 | + $pos = strrpos($string, ' '); |
|
609 | + } |
|
610 | + if ($pos >= $length * 0.4) { |
|
611 | + return substr($string, 0, $pos) . ' ...'; |
|
612 | + } |
|
613 | + |
|
614 | + return substr($string, 0, $length - 4) . ' ...'; |
|
615 | + } |
|
616 | + |
|
617 | + /** |
|
618 | + * Creates a comment indicating the generator of this feed. |
|
619 | + * The format of this comment seems to be recognized by |
|
620 | + * Syndic8.com. |
|
621 | + */ |
|
622 | + public function _createGeneratorComment() |
|
623 | + { |
|
624 | + return "<!-- generator=\"" . FEEDCREATOR_VERSION . "\" -->\n"; |
|
625 | + } |
|
626 | + |
|
627 | + /** |
|
628 | + * Creates a string containing all additional elements specified in |
|
629 | + * $additionalElements. |
|
630 | + * @param array $elements |
|
631 | + * @param string $indentString |
|
632 | + * @return string the XML tags corresponding to $additionalElements |
|
633 | + * @internal param array $elements an associative array containing key => value pairs |
|
634 | + * @internal param string $indentString a string that will be inserted before every generated line |
|
635 | + */ |
|
636 | + public function _createAdditionalElements($elements, $indentString = '') |
|
637 | + { |
|
638 | + $ae = ''; |
|
639 | + if (is_array($elements)) { |
|
640 | + foreach ($elements as $key => $value) { |
|
641 | + $ae .= $indentString . "<$key>$value</$key>\n"; |
|
642 | + } |
|
643 | + } |
|
644 | + |
|
645 | + return $ae; |
|
646 | + } |
|
647 | + |
|
648 | + /** |
|
649 | + * @return string |
|
650 | + */ |
|
651 | + public function _createStylesheetReferences() |
|
652 | + { |
|
653 | + $xml = ''; |
|
654 | + if ($this->cssStyleSheet) { |
|
655 | + $xml .= "<?xml-stylesheet href=\"" . $this->cssStyleSheet . "\" type=\"text/css\"?>\n"; |
|
656 | + } |
|
657 | + if ($this->xslStyleSheet) { |
|
658 | + $xml .= "<?xml-stylesheet href=\"" . $this->xslStyleSheet . "\" type=\"text/xsl\"?>\n"; |
|
659 | + } |
|
660 | + |
|
661 | + return $xml; |
|
662 | + } |
|
663 | + |
|
664 | + /** |
|
665 | + * Builds the feed's text. |
|
666 | + * @abstract |
|
667 | + * @return string the feed's complete text |
|
668 | + */ |
|
669 | + public function createFeed() |
|
670 | + { |
|
671 | + } |
|
672 | + |
|
673 | + /** |
|
674 | + * Generate a filename for the feed cache file. The result will be $_SERVER["PHP_SELF"] with the extension changed to .xml. |
|
675 | + * For example: |
|
676 | + * |
|
677 | + * echo $_SERVER["PHP_SELF"]."\n"; |
|
678 | + * echo FeedCreator::_generateFilename(); |
|
679 | + * |
|
680 | + * would produce: |
|
681 | + * |
|
682 | + * /rss/latestnews.php |
|
683 | + * latestnews.xml |
|
684 | + * |
|
685 | + * @return string the feed cache filename |
|
686 | + * @since 1.4 |
|
687 | + * @access private |
|
688 | + */ |
|
689 | + public function _generateFilename() |
|
690 | + { |
|
691 | + $fileInfo = pathinfo($_SERVER['PHP_SELF']); |
|
692 | + |
|
693 | + return substr($fileInfo['basename'], 0, -(strlen($fileInfo['extension']) + 1)) . '.xml'; |
|
694 | + } |
|
695 | + |
|
696 | + /** |
|
697 | + * @since 1.4 |
|
698 | + * @access private |
|
699 | + * @param $filename |
|
700 | + */ |
|
701 | + public function _redirect($filename) |
|
702 | + { |
|
703 | + // attention, heavily-commented-out-area |
|
704 | + |
|
705 | + // maybe use this in addition to file time checking |
|
706 | + //Header("Expires: ".date("r",time()+$this->_timeout)); |
|
707 | + |
|
708 | + /* no caching at all, doesn't seem to work as good: |
|
709 | 709 | Header("Cache-Control: no-cache"); |
710 | 710 | Header("Pragma: no-cache"); |
711 | 711 | */ |
712 | 712 | |
713 | - // HTTP redirect, some feed readers' simple HTTP implementations don't follow it |
|
714 | - //Header("Location: ".$filename); |
|
715 | - |
|
716 | - header('Content-Type: ' . $this->contentType . '; charset=' . $this->encoding . '; filename=' . basename($filename)); |
|
717 | - header('Content-Disposition: inline; filename=' . basename($filename)); |
|
718 | - readfile($filename, 'r'); |
|
719 | - die(); |
|
720 | - } |
|
721 | - |
|
722 | - /** |
|
723 | - * Turns on caching and checks if there is a recent version of this feed in the cache. |
|
724 | - * If there is, an HTTP redirect header is sent. |
|
725 | - * To effectively use caching, you should create the FeedCreator object and call this method |
|
726 | - * before anything else, especially before you do the time consuming task to build the feed |
|
727 | - * (web fetching, for example). |
|
728 | - * @since 1.4 |
|
729 | - * @param filename string optional the filename where a recent version of the feed is saved. If not specified, the filename is $_SERVER["PHP_SELF"] with the extension changed to .xml (see _generateFilename()). |
|
730 | - * @param int $timeout |
|
731 | - * @internal param int $timeout optional the timeout in seconds before a cached version is refreshed (defaults to 3600 = 1 hour) |
|
732 | - */ |
|
733 | - public function useCached($filename = '', $timeout = 3600) |
|
734 | - { |
|
735 | - $this->_timeout = $timeout; |
|
736 | - if ($filename == '') { |
|
737 | - $filename = $this->_generateFilename(); |
|
738 | - } |
|
739 | - if (file_exists($filename) && (time() - filemtime($filename) < $timeout)) { |
|
740 | - $this->_redirect($filename); |
|
741 | - } |
|
742 | - } |
|
743 | - |
|
744 | - /** |
|
745 | - * Saves this feed as a file on the local disk. After the file is saved, a redirect |
|
746 | - * header may be sent to redirect the user to the newly created file. |
|
747 | - * @since 1.4 |
|
748 | - * |
|
749 | - * @param filename string optional the filename where a recent version of the feed is saved. If not specified, the filename is $_SERVER["PHP_SELF"] with the extension changed to .xml (see _generateFilename()). |
|
750 | - * @param bool $displayContents |
|
751 | - * @internal param bool $redirect optional send an HTTP redirect header or not. If true, the user will be automatically redirected to the created file. |
|
752 | - */ |
|
753 | - public function saveFeed($filename = '', $displayContents = true) |
|
754 | - { |
|
755 | - if ($filename == '') { |
|
756 | - $filename = $this->_generateFilename(); |
|
757 | - } |
|
758 | - $feedFile = fopen($filename, 'w+'); |
|
759 | - if ($feedFile) { |
|
760 | - fwrite($feedFile, $this->createFeed()); |
|
761 | - fclose($feedFile); |
|
762 | - if ($displayContents) { |
|
763 | - $this->_redirect($filename); |
|
764 | - } |
|
765 | - } else { |
|
766 | - echo '<br><b>Error creating feed file, please check write permissions.</b><br>'; |
|
767 | - } |
|
768 | - } |
|
713 | + // HTTP redirect, some feed readers' simple HTTP implementations don't follow it |
|
714 | + //Header("Location: ".$filename); |
|
715 | + |
|
716 | + header('Content-Type: ' . $this->contentType . '; charset=' . $this->encoding . '; filename=' . basename($filename)); |
|
717 | + header('Content-Disposition: inline; filename=' . basename($filename)); |
|
718 | + readfile($filename, 'r'); |
|
719 | + die(); |
|
720 | + } |
|
721 | + |
|
722 | + /** |
|
723 | + * Turns on caching and checks if there is a recent version of this feed in the cache. |
|
724 | + * If there is, an HTTP redirect header is sent. |
|
725 | + * To effectively use caching, you should create the FeedCreator object and call this method |
|
726 | + * before anything else, especially before you do the time consuming task to build the feed |
|
727 | + * (web fetching, for example). |
|
728 | + * @since 1.4 |
|
729 | + * @param filename string optional the filename where a recent version of the feed is saved. If not specified, the filename is $_SERVER["PHP_SELF"] with the extension changed to .xml (see _generateFilename()). |
|
730 | + * @param int $timeout |
|
731 | + * @internal param int $timeout optional the timeout in seconds before a cached version is refreshed (defaults to 3600 = 1 hour) |
|
732 | + */ |
|
733 | + public function useCached($filename = '', $timeout = 3600) |
|
734 | + { |
|
735 | + $this->_timeout = $timeout; |
|
736 | + if ($filename == '') { |
|
737 | + $filename = $this->_generateFilename(); |
|
738 | + } |
|
739 | + if (file_exists($filename) && (time() - filemtime($filename) < $timeout)) { |
|
740 | + $this->_redirect($filename); |
|
741 | + } |
|
742 | + } |
|
743 | + |
|
744 | + /** |
|
745 | + * Saves this feed as a file on the local disk. After the file is saved, a redirect |
|
746 | + * header may be sent to redirect the user to the newly created file. |
|
747 | + * @since 1.4 |
|
748 | + * |
|
749 | + * @param filename string optional the filename where a recent version of the feed is saved. If not specified, the filename is $_SERVER["PHP_SELF"] with the extension changed to .xml (see _generateFilename()). |
|
750 | + * @param bool $displayContents |
|
751 | + * @internal param bool $redirect optional send an HTTP redirect header or not. If true, the user will be automatically redirected to the created file. |
|
752 | + */ |
|
753 | + public function saveFeed($filename = '', $displayContents = true) |
|
754 | + { |
|
755 | + if ($filename == '') { |
|
756 | + $filename = $this->_generateFilename(); |
|
757 | + } |
|
758 | + $feedFile = fopen($filename, 'w+'); |
|
759 | + if ($feedFile) { |
|
760 | + fwrite($feedFile, $this->createFeed()); |
|
761 | + fclose($feedFile); |
|
762 | + if ($displayContents) { |
|
763 | + $this->_redirect($filename); |
|
764 | + } |
|
765 | + } else { |
|
766 | + echo '<br><b>Error creating feed file, please check write permissions.</b><br>'; |
|
767 | + } |
|
768 | + } |
|
769 | 769 | } |
770 | 770 | |
771 | 771 | /** |
@@ -774,123 +774,123 @@ discard block |
||
774 | 774 | */ |
775 | 775 | class FeedDate |
776 | 776 | { |
777 | - public $unix; |
|
778 | - |
|
779 | - /** |
|
780 | - * Creates a new instance of FeedDate representing a given date. |
|
781 | - * Accepts RFC 822, ISO 8601 date formats as well as unix time stamps. |
|
782 | - * @param mixed $dateString optional the date this FeedDate will represent. If not specified, the current date and time is used. |
|
783 | - */ |
|
784 | - public function __construct($dateString = '') |
|
785 | - { |
|
786 | - $tzOffset = 0; |
|
787 | - if ($dateString == '') { |
|
788 | - $dateString = date('r'); |
|
789 | - } |
|
790 | - |
|
791 | - //if (is_integer($dateString)) { |
|
792 | - if (is_numeric($dateString)) { |
|
793 | - $this->unix = $dateString; |
|
794 | - |
|
795 | - return; |
|
796 | - } |
|
797 | - if (preg_match("~(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun),\\s+)?(\\d{1,2})\\s+([a-zA-Z]{3})\\s+(\\d{4})\\s+(\\d{2}):(\\d{2}):(\\d{2})\\s+(.*)~", $dateString, $matches)) { |
|
798 | - $months = [ |
|
799 | - 'Jan' => 1, |
|
800 | - 'Feb' => 2, |
|
801 | - 'Mar' => 3, |
|
802 | - 'Apr' => 4, |
|
803 | - 'May' => 5, |
|
804 | - 'Jun' => 6, |
|
805 | - 'Jul' => 7, |
|
806 | - 'Aug' => 8, |
|
807 | - 'Sep' => 9, |
|
808 | - 'Oct' => 10, |
|
809 | - 'Nov' => 11, |
|
810 | - 'Dec' => 12 |
|
811 | - ]; |
|
812 | - $this->unix = mktime($matches[4], $matches[5], $matches[6], $months[$matches[2]], $matches[1], $matches[3]); |
|
813 | - if (substr($matches[7], 0, 1) == '+' || substr($matches[7], 0, 1) == '-') { |
|
814 | - $tzOffset = (substr($matches[7], 0, 3) * 60 + substr($matches[7], -2)) * 60; |
|
815 | - } else { |
|
816 | - if (strlen($matches[7]) == 1) { |
|
817 | - $oneHour = 3600; |
|
818 | - $ord = ord($matches[7]); |
|
819 | - if ($ord < ord('M')) { |
|
820 | - $tzOffset = (ord('A') - $ord - 1) * $oneHour; |
|
821 | - } elseif ($ord >= ord('M') && $matches[7] !== 'Z') { |
|
822 | - $tzOffset = ($ord - ord('M')) * $oneHour; |
|
823 | - } elseif ($matches[7] === 'Z') { |
|
824 | - $tzOffset = 0; |
|
825 | - } |
|
826 | - } |
|
827 | - switch ($matches[7]) { |
|
828 | - case 'UT': |
|
829 | - case 'GMT': |
|
830 | - $tzOffset = 0; |
|
831 | - } |
|
832 | - } |
|
833 | - $this->unix += $tzOffset; |
|
834 | - |
|
835 | - return; |
|
836 | - } |
|
837 | - if (preg_match("~(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})(.*)~", $dateString, $matches)) { |
|
838 | - $this->unix = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); |
|
839 | - if (substr($matches[7], 0, 1) == '+' || substr($matches[7], 0, 1) == '-') { |
|
840 | - $tzOffset = (substr($matches[7], 0, 3) * 60 + substr($matches[7], -2)) * 60; |
|
841 | - } else { |
|
842 | - if ($matches[7] === 'Z') { |
|
843 | - $tzOffset = 0; |
|
844 | - } |
|
845 | - } |
|
846 | - $this->unix += $tzOffset; |
|
847 | - |
|
848 | - return; |
|
849 | - } |
|
850 | - $this->unix = 0; |
|
851 | - } |
|
852 | - |
|
853 | - /** |
|
854 | - * Gets the date stored in this FeedDate as an RFC 822 date. |
|
855 | - * |
|
856 | - * @return a date in RFC 822 format |
|
857 | - */ |
|
858 | - public function rfc822() |
|
859 | - { |
|
860 | - //return gmdate("r",$this->unix); |
|
861 | - $date = gmdate('D, d M Y H:i:s', $this->unix); |
|
862 | - if (TIME_ZONE != '') { |
|
863 | - $date .= ' ' . str_replace(':', '', TIME_ZONE); |
|
864 | - } |
|
865 | - |
|
866 | - return $date; |
|
867 | - } |
|
868 | - |
|
869 | - /** |
|
870 | - * Gets the date stored in this FeedDate as an ISO 8601 date. |
|
871 | - * |
|
872 | - * @return a date in ISO 8601 format |
|
873 | - */ |
|
874 | - public function iso8601() |
|
875 | - { |
|
876 | - $date = gmdate("Y-m-d\TH:i:sO", $this->unix); |
|
877 | - $date = substr($date, 0, 22) . ':' . substr($date, -2); |
|
878 | - if (TIME_ZONE != '') { |
|
879 | - $date = str_replace('+00:00', TIME_ZONE, $date); |
|
880 | - } |
|
881 | - |
|
882 | - return $date; |
|
883 | - } |
|
884 | - |
|
885 | - /** |
|
886 | - * Gets the date stored in this FeedDate as unix time stamp. |
|
887 | - * |
|
888 | - * @return a date as a unix time stamp |
|
889 | - */ |
|
890 | - public function unix() |
|
891 | - { |
|
892 | - return $this->unix; |
|
893 | - } |
|
777 | + public $unix; |
|
778 | + |
|
779 | + /** |
|
780 | + * Creates a new instance of FeedDate representing a given date. |
|
781 | + * Accepts RFC 822, ISO 8601 date formats as well as unix time stamps. |
|
782 | + * @param mixed $dateString optional the date this FeedDate will represent. If not specified, the current date and time is used. |
|
783 | + */ |
|
784 | + public function __construct($dateString = '') |
|
785 | + { |
|
786 | + $tzOffset = 0; |
|
787 | + if ($dateString == '') { |
|
788 | + $dateString = date('r'); |
|
789 | + } |
|
790 | + |
|
791 | + //if (is_integer($dateString)) { |
|
792 | + if (is_numeric($dateString)) { |
|
793 | + $this->unix = $dateString; |
|
794 | + |
|
795 | + return; |
|
796 | + } |
|
797 | + if (preg_match("~(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun),\\s+)?(\\d{1,2})\\s+([a-zA-Z]{3})\\s+(\\d{4})\\s+(\\d{2}):(\\d{2}):(\\d{2})\\s+(.*)~", $dateString, $matches)) { |
|
798 | + $months = [ |
|
799 | + 'Jan' => 1, |
|
800 | + 'Feb' => 2, |
|
801 | + 'Mar' => 3, |
|
802 | + 'Apr' => 4, |
|
803 | + 'May' => 5, |
|
804 | + 'Jun' => 6, |
|
805 | + 'Jul' => 7, |
|
806 | + 'Aug' => 8, |
|
807 | + 'Sep' => 9, |
|
808 | + 'Oct' => 10, |
|
809 | + 'Nov' => 11, |
|
810 | + 'Dec' => 12 |
|
811 | + ]; |
|
812 | + $this->unix = mktime($matches[4], $matches[5], $matches[6], $months[$matches[2]], $matches[1], $matches[3]); |
|
813 | + if (substr($matches[7], 0, 1) == '+' || substr($matches[7], 0, 1) == '-') { |
|
814 | + $tzOffset = (substr($matches[7], 0, 3) * 60 + substr($matches[7], -2)) * 60; |
|
815 | + } else { |
|
816 | + if (strlen($matches[7]) == 1) { |
|
817 | + $oneHour = 3600; |
|
818 | + $ord = ord($matches[7]); |
|
819 | + if ($ord < ord('M')) { |
|
820 | + $tzOffset = (ord('A') - $ord - 1) * $oneHour; |
|
821 | + } elseif ($ord >= ord('M') && $matches[7] !== 'Z') { |
|
822 | + $tzOffset = ($ord - ord('M')) * $oneHour; |
|
823 | + } elseif ($matches[7] === 'Z') { |
|
824 | + $tzOffset = 0; |
|
825 | + } |
|
826 | + } |
|
827 | + switch ($matches[7]) { |
|
828 | + case 'UT': |
|
829 | + case 'GMT': |
|
830 | + $tzOffset = 0; |
|
831 | + } |
|
832 | + } |
|
833 | + $this->unix += $tzOffset; |
|
834 | + |
|
835 | + return; |
|
836 | + } |
|
837 | + if (preg_match("~(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})(.*)~", $dateString, $matches)) { |
|
838 | + $this->unix = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); |
|
839 | + if (substr($matches[7], 0, 1) == '+' || substr($matches[7], 0, 1) == '-') { |
|
840 | + $tzOffset = (substr($matches[7], 0, 3) * 60 + substr($matches[7], -2)) * 60; |
|
841 | + } else { |
|
842 | + if ($matches[7] === 'Z') { |
|
843 | + $tzOffset = 0; |
|
844 | + } |
|
845 | + } |
|
846 | + $this->unix += $tzOffset; |
|
847 | + |
|
848 | + return; |
|
849 | + } |
|
850 | + $this->unix = 0; |
|
851 | + } |
|
852 | + |
|
853 | + /** |
|
854 | + * Gets the date stored in this FeedDate as an RFC 822 date. |
|
855 | + * |
|
856 | + * @return a date in RFC 822 format |
|
857 | + */ |
|
858 | + public function rfc822() |
|
859 | + { |
|
860 | + //return gmdate("r",$this->unix); |
|
861 | + $date = gmdate('D, d M Y H:i:s', $this->unix); |
|
862 | + if (TIME_ZONE != '') { |
|
863 | + $date .= ' ' . str_replace(':', '', TIME_ZONE); |
|
864 | + } |
|
865 | + |
|
866 | + return $date; |
|
867 | + } |
|
868 | + |
|
869 | + /** |
|
870 | + * Gets the date stored in this FeedDate as an ISO 8601 date. |
|
871 | + * |
|
872 | + * @return a date in ISO 8601 format |
|
873 | + */ |
|
874 | + public function iso8601() |
|
875 | + { |
|
876 | + $date = gmdate("Y-m-d\TH:i:sO", $this->unix); |
|
877 | + $date = substr($date, 0, 22) . ':' . substr($date, -2); |
|
878 | + if (TIME_ZONE != '') { |
|
879 | + $date = str_replace('+00:00', TIME_ZONE, $date); |
|
880 | + } |
|
881 | + |
|
882 | + return $date; |
|
883 | + } |
|
884 | + |
|
885 | + /** |
|
886 | + * Gets the date stored in this FeedDate as unix time stamp. |
|
887 | + * |
|
888 | + * @return a date as a unix time stamp |
|
889 | + */ |
|
890 | + public function unix() |
|
891 | + { |
|
892 | + return $this->unix; |
|
893 | + } |
|
894 | 894 | } |
895 | 895 | |
896 | 896 | /** |
@@ -902,74 +902,74 @@ discard block |
||
902 | 902 | */ |
903 | 903 | class RSSCreator10 extends FeedCreator |
904 | 904 | { |
905 | - /** |
|
906 | - * Builds the RSS feed's text. The feed will be compliant to RDF Site Summary (RSS) 1.0. |
|
907 | - * The feed will contain all items previously added in the same order. |
|
908 | - * @return string the feed's complete text |
|
909 | - */ |
|
910 | - public function createFeed() |
|
911 | - { |
|
912 | - $feed = "<?xml version=\"1.0\" encoding=\"" . $this->encoding . "\"?>\n"; |
|
913 | - $feed .= $this->_createGeneratorComment(); |
|
914 | - if ($this->cssStyleSheet == '') { |
|
915 | - $cssStyleSheet = 'http://www.w3.org/2000/08/w3c-synd/style.css'; |
|
916 | - } |
|
917 | - $feed .= $this->_createStylesheetReferences(); |
|
918 | - $feed .= "<rdf:RDF\n"; |
|
919 | - $feed .= " xmlns=\"http://purl.org/rss/1.0/\"\n"; |
|
920 | - $feed .= " xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n"; |
|
921 | - $feed .= " xmlns:slash=\"http://purl.org/rss/1.0/modules/slash/\"\n"; |
|
922 | - $feed .= " xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n"; |
|
923 | - $feed .= " <channel rdf:about=\"" . $this->syndicationURL . "\">\n"; |
|
924 | - $feed .= ' <title>' . htmlspecialchars($this->title) . "</title>\n"; |
|
925 | - $feed .= ' <description>' . htmlspecialchars($this->description) . "</description>\n"; |
|
926 | - $feed .= ' <link>' . $this->link . "</link>\n"; |
|
927 | - if ($this->image != null) { |
|
928 | - $feed .= " <image rdf:resource=\"" . $this->image->url . "\">\n"; |
|
929 | - } |
|
930 | - $now = new FeedDate(); |
|
931 | - $feed .= ' <dc:date>' . htmlspecialchars($now->iso8601()) . "</dc:date>\n"; |
|
932 | - $feed .= " <items>\n"; |
|
933 | - $feed .= " <rdf:Seq>\n"; |
|
934 | - for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
|
935 | - $feed .= " <rdf:li rdf:resource=\"" . htmlspecialchars($this->items[$i]->link) . "\">\n"; |
|
936 | - } |
|
937 | - $feed .= " </rdf:Seq>\n"; |
|
938 | - $feed .= " </items>\n"; |
|
939 | - $feed .= " </channel>\n"; |
|
940 | - if ($this->image != null) { |
|
941 | - $feed .= " <image rdf:about=\"" . $this->image->url . "\">\n"; |
|
942 | - $feed .= ' <title>' . $this->image->title . "</title>\n"; |
|
943 | - $feed .= ' <link>' . $this->image->link . "</link>\n"; |
|
944 | - $feed .= ' <url>' . $this->image->url . "</url>\n"; |
|
945 | - $feed .= " </image>\n"; |
|
946 | - } |
|
947 | - $feed .= $this->_createAdditionalElements($this->additionalElements, ' '); |
|
948 | - |
|
949 | - for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
|
950 | - $feed .= " <item rdf:about=\"" . htmlspecialchars($this->items[$i]->link) . "\">\n"; |
|
951 | - //$feed.= " <dc:type>Posting</dc:type>\n"; |
|
952 | - $feed .= " <dc:format>text/html</dc:format>\n"; |
|
953 | - if ($this->items[$i]->date != null) { |
|
954 | - $itemDate = new FeedDate($this->items[$i]->date); |
|
955 | - $feed .= ' <dc:date>' . htmlspecialchars($itemDate->iso8601()) . "</dc:date>\n"; |
|
956 | - } |
|
957 | - if ($this->items[$i]->source != '') { |
|
958 | - $feed .= ' <dc:source>' . htmlspecialchars($this->items[$i]->source) . "</dc:source>\n"; |
|
959 | - } |
|
960 | - if ($this->items[$i]->author != '') { |
|
961 | - $feed .= ' <dc:creator>' . htmlspecialchars($this->items[$i]->author) . "</dc:creator>\n"; |
|
962 | - } |
|
963 | - $feed .= ' <title>' . htmlspecialchars(strip_tags(strtr($this->items[$i]->title, "\n\r", ' '))) . "</title>\n"; |
|
964 | - $feed .= ' <link>' . htmlspecialchars($this->items[$i]->link) . "</link>\n"; |
|
965 | - $feed .= ' <description>' . htmlspecialchars($this->items[$i]->description) . "</description>\n"; |
|
966 | - $feed .= $this->_createAdditionalElements($this->items[$i]->additionalElements, ' '); |
|
967 | - $feed .= " </item>\n"; |
|
968 | - } |
|
969 | - $feed .= "</rdf:RDF>\n"; |
|
970 | - |
|
971 | - return $feed; |
|
972 | - } |
|
905 | + /** |
|
906 | + * Builds the RSS feed's text. The feed will be compliant to RDF Site Summary (RSS) 1.0. |
|
907 | + * The feed will contain all items previously added in the same order. |
|
908 | + * @return string the feed's complete text |
|
909 | + */ |
|
910 | + public function createFeed() |
|
911 | + { |
|
912 | + $feed = "<?xml version=\"1.0\" encoding=\"" . $this->encoding . "\"?>\n"; |
|
913 | + $feed .= $this->_createGeneratorComment(); |
|
914 | + if ($this->cssStyleSheet == '') { |
|
915 | + $cssStyleSheet = 'http://www.w3.org/2000/08/w3c-synd/style.css'; |
|
916 | + } |
|
917 | + $feed .= $this->_createStylesheetReferences(); |
|
918 | + $feed .= "<rdf:RDF\n"; |
|
919 | + $feed .= " xmlns=\"http://purl.org/rss/1.0/\"\n"; |
|
920 | + $feed .= " xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n"; |
|
921 | + $feed .= " xmlns:slash=\"http://purl.org/rss/1.0/modules/slash/\"\n"; |
|
922 | + $feed .= " xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n"; |
|
923 | + $feed .= " <channel rdf:about=\"" . $this->syndicationURL . "\">\n"; |
|
924 | + $feed .= ' <title>' . htmlspecialchars($this->title) . "</title>\n"; |
|
925 | + $feed .= ' <description>' . htmlspecialchars($this->description) . "</description>\n"; |
|
926 | + $feed .= ' <link>' . $this->link . "</link>\n"; |
|
927 | + if ($this->image != null) { |
|
928 | + $feed .= " <image rdf:resource=\"" . $this->image->url . "\">\n"; |
|
929 | + } |
|
930 | + $now = new FeedDate(); |
|
931 | + $feed .= ' <dc:date>' . htmlspecialchars($now->iso8601()) . "</dc:date>\n"; |
|
932 | + $feed .= " <items>\n"; |
|
933 | + $feed .= " <rdf:Seq>\n"; |
|
934 | + for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
|
935 | + $feed .= " <rdf:li rdf:resource=\"" . htmlspecialchars($this->items[$i]->link) . "\">\n"; |
|
936 | + } |
|
937 | + $feed .= " </rdf:Seq>\n"; |
|
938 | + $feed .= " </items>\n"; |
|
939 | + $feed .= " </channel>\n"; |
|
940 | + if ($this->image != null) { |
|
941 | + $feed .= " <image rdf:about=\"" . $this->image->url . "\">\n"; |
|
942 | + $feed .= ' <title>' . $this->image->title . "</title>\n"; |
|
943 | + $feed .= ' <link>' . $this->image->link . "</link>\n"; |
|
944 | + $feed .= ' <url>' . $this->image->url . "</url>\n"; |
|
945 | + $feed .= " </image>\n"; |
|
946 | + } |
|
947 | + $feed .= $this->_createAdditionalElements($this->additionalElements, ' '); |
|
948 | + |
|
949 | + for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
|
950 | + $feed .= " <item rdf:about=\"" . htmlspecialchars($this->items[$i]->link) . "\">\n"; |
|
951 | + //$feed.= " <dc:type>Posting</dc:type>\n"; |
|
952 | + $feed .= " <dc:format>text/html</dc:format>\n"; |
|
953 | + if ($this->items[$i]->date != null) { |
|
954 | + $itemDate = new FeedDate($this->items[$i]->date); |
|
955 | + $feed .= ' <dc:date>' . htmlspecialchars($itemDate->iso8601()) . "</dc:date>\n"; |
|
956 | + } |
|
957 | + if ($this->items[$i]->source != '') { |
|
958 | + $feed .= ' <dc:source>' . htmlspecialchars($this->items[$i]->source) . "</dc:source>\n"; |
|
959 | + } |
|
960 | + if ($this->items[$i]->author != '') { |
|
961 | + $feed .= ' <dc:creator>' . htmlspecialchars($this->items[$i]->author) . "</dc:creator>\n"; |
|
962 | + } |
|
963 | + $feed .= ' <title>' . htmlspecialchars(strip_tags(strtr($this->items[$i]->title, "\n\r", ' '))) . "</title>\n"; |
|
964 | + $feed .= ' <link>' . htmlspecialchars($this->items[$i]->link) . "</link>\n"; |
|
965 | + $feed .= ' <description>' . htmlspecialchars($this->items[$i]->description) . "</description>\n"; |
|
966 | + $feed .= $this->_createAdditionalElements($this->items[$i]->additionalElements, ' '); |
|
967 | + $feed .= " </item>\n"; |
|
968 | + } |
|
969 | + $feed .= "</rdf:RDF>\n"; |
|
970 | + |
|
971 | + return $feed; |
|
972 | + } |
|
973 | 973 | } |
974 | 974 | |
975 | 975 | /** |
@@ -981,139 +981,139 @@ discard block |
||
981 | 981 | */ |
982 | 982 | class RSSCreator091 extends FeedCreator |
983 | 983 | { |
984 | - /** |
|
985 | - * Stores this RSS feed's version number. |
|
986 | - * @access private |
|
987 | - */ |
|
988 | - public $RSSVersion; |
|
989 | - |
|
990 | - /** |
|
991 | - * RSSCreator091 constructor. |
|
992 | - */ |
|
993 | - public function __construct() |
|
994 | - { |
|
995 | - $this->_setRSSVersion('0.91'); |
|
996 | - $this->contentType = 'application/rss+xml'; |
|
997 | - } |
|
998 | - |
|
999 | - /** |
|
1000 | - * Sets this RSS feed's version number. |
|
1001 | - * @access private |
|
1002 | - * @param $version |
|
1003 | - */ |
|
1004 | - public function _setRSSVersion($version) |
|
1005 | - { |
|
1006 | - $this->RSSVersion = $version; |
|
1007 | - } |
|
1008 | - |
|
1009 | - /** |
|
1010 | - * Builds the RSS feed's text. The feed will be compliant to RDF Site Summary (RSS) 1.0. |
|
1011 | - * The feed will contain all items previously added in the same order. |
|
1012 | - * @return string the feed's complete text |
|
1013 | - */ |
|
1014 | - public function createFeed() |
|
1015 | - { |
|
1016 | - $feed = "<?xml version=\"1.0\" encoding=\"" . $this->encoding . "\"?>\n"; |
|
1017 | - $feed .= $this->_createGeneratorComment(); |
|
1018 | - $feed .= $this->_createStylesheetReferences(); |
|
1019 | - $feed .= "<rss version=\"" . $this->RSSVersion . "\">\n"; |
|
1020 | - $feed .= " <channel>\n"; |
|
1021 | - $feed .= ' <title>' . FeedCreator::iTrunc(htmlspecialchars($this->title), 100) . "</title>\n"; |
|
1022 | - $this->descriptionTruncSize = 500; |
|
1023 | - $feed .= ' <description>' . $this->getDescription() . "</description>\n"; |
|
1024 | - $feed .= ' <link>' . $this->link . "</link>\n"; |
|
1025 | - $now = new FeedDate(); |
|
1026 | - $feed .= ' <lastBuildDate>' . htmlspecialchars($now->rfc822()) . "</lastBuildDate>\n"; |
|
1027 | - $feed .= ' <generator>' . FEEDCREATOR_VERSION . "</generator>\n"; |
|
1028 | - |
|
1029 | - if ($this->image != null) { |
|
1030 | - $feed .= " <image>\n"; |
|
1031 | - $feed .= ' <url>' . $this->image->url . "</url>\n"; |
|
1032 | - $feed .= ' <title>' . FeedCreator::iTrunc(htmlspecialchars($this->image->title), 100) . "</title>\n"; |
|
1033 | - $feed .= ' <link>' . $this->image->link . "</link>\n"; |
|
1034 | - if ($this->image->width != '') { |
|
1035 | - $feed .= ' <width>' . $this->image->width . "</width>\n"; |
|
1036 | - } |
|
1037 | - if ($this->image->height != '') { |
|
1038 | - $feed .= ' <height>' . $this->image->height . "</height>\n"; |
|
1039 | - } |
|
1040 | - if ($this->image->description != '') { |
|
1041 | - $feed .= ' <description>' . $this->image->getDescription() . "</description>\n"; |
|
1042 | - } |
|
1043 | - $feed .= " </image>\n"; |
|
1044 | - } |
|
1045 | - if ($this->language != '') { |
|
1046 | - $feed .= ' <language>' . $this->language . "</language>\n"; |
|
1047 | - } |
|
1048 | - if ($this->copyright != '') { |
|
1049 | - $feed .= ' <copyright>' . FeedCreator::iTrunc(htmlspecialchars($this->copyright), 100) . "</copyright>\n"; |
|
1050 | - } |
|
1051 | - if ($this->editor != '') { |
|
1052 | - $feed .= ' <managingEditor>' . FeedCreator::iTrunc(htmlspecialchars($this->editor), 100) . "</managingEditor>\n"; |
|
1053 | - } |
|
1054 | - if ($this->webmaster != '') { |
|
1055 | - $feed .= ' <webMaster>' . FeedCreator::iTrunc(htmlspecialchars($this->webmaster), 100) . "</webMaster>\n"; |
|
1056 | - } |
|
1057 | - if ($this->pubDate != '') { |
|
1058 | - $pubDate = new FeedDate($this->pubDate); |
|
1059 | - $feed .= ' <pubDate>' . htmlspecialchars($pubDate->rfc822()) . "</pubDate>\n"; |
|
1060 | - } |
|
1061 | - if ($this->category != '') { |
|
1062 | - $feed .= ' <category>' . htmlspecialchars($this->category) . "</category>\n"; |
|
1063 | - } |
|
1064 | - if ($this->docs != '') { |
|
1065 | - $feed .= ' <docs>' . FeedCreator::iTrunc(htmlspecialchars($this->docs), 500) . "</docs>\n"; |
|
1066 | - } |
|
1067 | - if ($this->ttl != '') { |
|
1068 | - $feed .= ' <ttl>' . htmlspecialchars($this->ttl) . "</ttl>\n"; |
|
1069 | - } |
|
1070 | - if ($this->rating != '') { |
|
1071 | - $feed .= ' <rating>' . FeedCreator::iTrunc(htmlspecialchars($this->rating), 500) . "</rating>\n"; |
|
1072 | - } |
|
1073 | - if ($this->skipHours != '') { |
|
1074 | - $feed .= ' <skipHours>' . htmlspecialchars($this->skipHours) . "</skipHours>\n"; |
|
1075 | - } |
|
1076 | - if ($this->skipDays != '') { |
|
1077 | - $feed .= ' <skipDays>' . htmlspecialchars($this->skipDays) . "</skipDays>\n"; |
|
1078 | - } |
|
1079 | - $feed .= $this->_createAdditionalElements($this->additionalElements, ' '); |
|
1080 | - |
|
1081 | - for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
|
1082 | - $feed .= " <item>\n"; |
|
1083 | - $feed .= ' <title>' . FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)), 100) . "</title>\n"; |
|
1084 | - $feed .= ' <link>' . htmlspecialchars($this->items[$i]->link) . "</link>\n"; |
|
1085 | - $feed .= ' <description>' . $this->items[$i]->getDescription() . "</description>\n"; |
|
1086 | - |
|
1087 | - if ($this->items[$i]->author != '') { |
|
1088 | - $feed .= ' <author>' . htmlspecialchars($this->items[$i]->author) . "</author>\n"; |
|
1089 | - } |
|
1090 | - /* |
|
984 | + /** |
|
985 | + * Stores this RSS feed's version number. |
|
986 | + * @access private |
|
987 | + */ |
|
988 | + public $RSSVersion; |
|
989 | + |
|
990 | + /** |
|
991 | + * RSSCreator091 constructor. |
|
992 | + */ |
|
993 | + public function __construct() |
|
994 | + { |
|
995 | + $this->_setRSSVersion('0.91'); |
|
996 | + $this->contentType = 'application/rss+xml'; |
|
997 | + } |
|
998 | + |
|
999 | + /** |
|
1000 | + * Sets this RSS feed's version number. |
|
1001 | + * @access private |
|
1002 | + * @param $version |
|
1003 | + */ |
|
1004 | + public function _setRSSVersion($version) |
|
1005 | + { |
|
1006 | + $this->RSSVersion = $version; |
|
1007 | + } |
|
1008 | + |
|
1009 | + /** |
|
1010 | + * Builds the RSS feed's text. The feed will be compliant to RDF Site Summary (RSS) 1.0. |
|
1011 | + * The feed will contain all items previously added in the same order. |
|
1012 | + * @return string the feed's complete text |
|
1013 | + */ |
|
1014 | + public function createFeed() |
|
1015 | + { |
|
1016 | + $feed = "<?xml version=\"1.0\" encoding=\"" . $this->encoding . "\"?>\n"; |
|
1017 | + $feed .= $this->_createGeneratorComment(); |
|
1018 | + $feed .= $this->_createStylesheetReferences(); |
|
1019 | + $feed .= "<rss version=\"" . $this->RSSVersion . "\">\n"; |
|
1020 | + $feed .= " <channel>\n"; |
|
1021 | + $feed .= ' <title>' . FeedCreator::iTrunc(htmlspecialchars($this->title), 100) . "</title>\n"; |
|
1022 | + $this->descriptionTruncSize = 500; |
|
1023 | + $feed .= ' <description>' . $this->getDescription() . "</description>\n"; |
|
1024 | + $feed .= ' <link>' . $this->link . "</link>\n"; |
|
1025 | + $now = new FeedDate(); |
|
1026 | + $feed .= ' <lastBuildDate>' . htmlspecialchars($now->rfc822()) . "</lastBuildDate>\n"; |
|
1027 | + $feed .= ' <generator>' . FEEDCREATOR_VERSION . "</generator>\n"; |
|
1028 | + |
|
1029 | + if ($this->image != null) { |
|
1030 | + $feed .= " <image>\n"; |
|
1031 | + $feed .= ' <url>' . $this->image->url . "</url>\n"; |
|
1032 | + $feed .= ' <title>' . FeedCreator::iTrunc(htmlspecialchars($this->image->title), 100) . "</title>\n"; |
|
1033 | + $feed .= ' <link>' . $this->image->link . "</link>\n"; |
|
1034 | + if ($this->image->width != '') { |
|
1035 | + $feed .= ' <width>' . $this->image->width . "</width>\n"; |
|
1036 | + } |
|
1037 | + if ($this->image->height != '') { |
|
1038 | + $feed .= ' <height>' . $this->image->height . "</height>\n"; |
|
1039 | + } |
|
1040 | + if ($this->image->description != '') { |
|
1041 | + $feed .= ' <description>' . $this->image->getDescription() . "</description>\n"; |
|
1042 | + } |
|
1043 | + $feed .= " </image>\n"; |
|
1044 | + } |
|
1045 | + if ($this->language != '') { |
|
1046 | + $feed .= ' <language>' . $this->language . "</language>\n"; |
|
1047 | + } |
|
1048 | + if ($this->copyright != '') { |
|
1049 | + $feed .= ' <copyright>' . FeedCreator::iTrunc(htmlspecialchars($this->copyright), 100) . "</copyright>\n"; |
|
1050 | + } |
|
1051 | + if ($this->editor != '') { |
|
1052 | + $feed .= ' <managingEditor>' . FeedCreator::iTrunc(htmlspecialchars($this->editor), 100) . "</managingEditor>\n"; |
|
1053 | + } |
|
1054 | + if ($this->webmaster != '') { |
|
1055 | + $feed .= ' <webMaster>' . FeedCreator::iTrunc(htmlspecialchars($this->webmaster), 100) . "</webMaster>\n"; |
|
1056 | + } |
|
1057 | + if ($this->pubDate != '') { |
|
1058 | + $pubDate = new FeedDate($this->pubDate); |
|
1059 | + $feed .= ' <pubDate>' . htmlspecialchars($pubDate->rfc822()) . "</pubDate>\n"; |
|
1060 | + } |
|
1061 | + if ($this->category != '') { |
|
1062 | + $feed .= ' <category>' . htmlspecialchars($this->category) . "</category>\n"; |
|
1063 | + } |
|
1064 | + if ($this->docs != '') { |
|
1065 | + $feed .= ' <docs>' . FeedCreator::iTrunc(htmlspecialchars($this->docs), 500) . "</docs>\n"; |
|
1066 | + } |
|
1067 | + if ($this->ttl != '') { |
|
1068 | + $feed .= ' <ttl>' . htmlspecialchars($this->ttl) . "</ttl>\n"; |
|
1069 | + } |
|
1070 | + if ($this->rating != '') { |
|
1071 | + $feed .= ' <rating>' . FeedCreator::iTrunc(htmlspecialchars($this->rating), 500) . "</rating>\n"; |
|
1072 | + } |
|
1073 | + if ($this->skipHours != '') { |
|
1074 | + $feed .= ' <skipHours>' . htmlspecialchars($this->skipHours) . "</skipHours>\n"; |
|
1075 | + } |
|
1076 | + if ($this->skipDays != '') { |
|
1077 | + $feed .= ' <skipDays>' . htmlspecialchars($this->skipDays) . "</skipDays>\n"; |
|
1078 | + } |
|
1079 | + $feed .= $this->_createAdditionalElements($this->additionalElements, ' '); |
|
1080 | + |
|
1081 | + for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
|
1082 | + $feed .= " <item>\n"; |
|
1083 | + $feed .= ' <title>' . FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)), 100) . "</title>\n"; |
|
1084 | + $feed .= ' <link>' . htmlspecialchars($this->items[$i]->link) . "</link>\n"; |
|
1085 | + $feed .= ' <description>' . $this->items[$i]->getDescription() . "</description>\n"; |
|
1086 | + |
|
1087 | + if ($this->items[$i]->author != '') { |
|
1088 | + $feed .= ' <author>' . htmlspecialchars($this->items[$i]->author) . "</author>\n"; |
|
1089 | + } |
|
1090 | + /* |
|
1091 | 1091 | // on hold |
1092 | 1092 | if ($this->items[$i]->source!="") { |
1093 | 1093 | $feed.= " <source>".htmlspecialchars($this->items[$i]->source)."</source>\n"; |
1094 | 1094 | } |
1095 | 1095 | */ |
1096 | - if ($this->items[$i]->category != '') { |
|
1097 | - $feed .= ' <category>' . htmlspecialchars($this->items[$i]->category) . "</category>\n"; |
|
1098 | - } |
|
1099 | - if ($this->items[$i]->comments != '') { |
|
1100 | - $feed .= ' <comments>' . htmlspecialchars($this->items[$i]->comments) . "</comments>\n"; |
|
1101 | - } |
|
1102 | - if ($this->items[$i]->date != '') { |
|
1103 | - $itemDate = new FeedDate($this->items[$i]->date); |
|
1104 | - $feed .= ' <pubDate>' . htmlspecialchars($itemDate->rfc822()) . "</pubDate>\n"; |
|
1105 | - } |
|
1106 | - if ($this->items[$i]->guid != '') { |
|
1107 | - $feed .= ' <guid>' . htmlspecialchars($this->items[$i]->guid) . "</guid>\n"; |
|
1108 | - } |
|
1109 | - $feed .= $this->_createAdditionalElements($this->items[$i]->additionalElements, ' '); |
|
1110 | - $feed .= " </item>\n"; |
|
1111 | - } |
|
1112 | - $feed .= " </channel>\n"; |
|
1113 | - $feed .= "</rss>\n"; |
|
1114 | - |
|
1115 | - return $feed; |
|
1116 | - } |
|
1096 | + if ($this->items[$i]->category != '') { |
|
1097 | + $feed .= ' <category>' . htmlspecialchars($this->items[$i]->category) . "</category>\n"; |
|
1098 | + } |
|
1099 | + if ($this->items[$i]->comments != '') { |
|
1100 | + $feed .= ' <comments>' . htmlspecialchars($this->items[$i]->comments) . "</comments>\n"; |
|
1101 | + } |
|
1102 | + if ($this->items[$i]->date != '') { |
|
1103 | + $itemDate = new FeedDate($this->items[$i]->date); |
|
1104 | + $feed .= ' <pubDate>' . htmlspecialchars($itemDate->rfc822()) . "</pubDate>\n"; |
|
1105 | + } |
|
1106 | + if ($this->items[$i]->guid != '') { |
|
1107 | + $feed .= ' <guid>' . htmlspecialchars($this->items[$i]->guid) . "</guid>\n"; |
|
1108 | + } |
|
1109 | + $feed .= $this->_createAdditionalElements($this->items[$i]->additionalElements, ' '); |
|
1110 | + $feed .= " </item>\n"; |
|
1111 | + } |
|
1112 | + $feed .= " </channel>\n"; |
|
1113 | + $feed .= "</rss>\n"; |
|
1114 | + |
|
1115 | + return $feed; |
|
1116 | + } |
|
1117 | 1117 | } |
1118 | 1118 | |
1119 | 1119 | /** |
@@ -1125,13 +1125,13 @@ discard block |
||
1125 | 1125 | */ |
1126 | 1126 | class RSSCreator20 extends RSSCreator091 |
1127 | 1127 | { |
1128 | - /** |
|
1129 | - * RSSCreator20 constructor. |
|
1130 | - */ |
|
1131 | - public function __construct() |
|
1132 | - { |
|
1133 | - parent::_setRSSVersion('2.0'); |
|
1134 | - } |
|
1128 | + /** |
|
1129 | + * RSSCreator20 constructor. |
|
1130 | + */ |
|
1131 | + public function __construct() |
|
1132 | + { |
|
1133 | + parent::_setRSSVersion('2.0'); |
|
1134 | + } |
|
1135 | 1135 | } |
1136 | 1136 | |
1137 | 1137 | /** |
@@ -1144,52 +1144,52 @@ discard block |
||
1144 | 1144 | */ |
1145 | 1145 | class PIECreator01 extends FeedCreator |
1146 | 1146 | { |
1147 | - /** |
|
1148 | - * PIECreator01 constructor. |
|
1149 | - */ |
|
1150 | - public function __construct() |
|
1151 | - { |
|
1152 | - $this->encoding = 'utf-8'; |
|
1153 | - } |
|
1154 | - |
|
1155 | - /** |
|
1156 | - * @return string |
|
1157 | - */ |
|
1158 | - public function createFeed() |
|
1159 | - { |
|
1160 | - $feed = "<?xml version=\"1.0\" encoding=\"" . $this->encoding . "\"?>\n"; |
|
1161 | - $feed .= $this->_createStylesheetReferences(); |
|
1162 | - $feed .= "<feed version=\"0.1\" xmlns=\"http://example.com/newformat#\">\n"; |
|
1163 | - $feed .= ' <title>' . FeedCreator::iTrunc(htmlspecialchars($this->title), 100) . "</title>\n"; |
|
1164 | - $this->truncSize = 500; |
|
1165 | - $feed .= ' <subtitle>' . $this->getDescription() . "</subtitle>\n"; |
|
1166 | - $feed .= ' <link>' . $this->link . "</link>\n"; |
|
1167 | - for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
|
1168 | - $feed .= " <entry>\n"; |
|
1169 | - $feed .= ' <title>' . FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)), 100) . "</title>\n"; |
|
1170 | - $feed .= ' <link>' . htmlspecialchars($this->items[$i]->link) . "</link>\n"; |
|
1171 | - $itemDate = new FeedDate($this->items[$i]->date); |
|
1172 | - $feed .= ' <created>' . htmlspecialchars($itemDate->iso8601()) . "</created>\n"; |
|
1173 | - $feed .= ' <issued>' . htmlspecialchars($itemDate->iso8601()) . "</issued>\n"; |
|
1174 | - $feed .= ' <modified>' . htmlspecialchars($itemDate->iso8601()) . "</modified>\n"; |
|
1175 | - $feed .= ' <id>' . htmlspecialchars($this->items[$i]->guid) . "</id>\n"; |
|
1176 | - if ($this->items[$i]->author != '') { |
|
1177 | - $feed .= " <author>\n"; |
|
1178 | - $feed .= ' <name>' . htmlspecialchars($this->items[$i]->author) . "</name>\n"; |
|
1179 | - if ($this->items[$i]->authorEmail != '') { |
|
1180 | - $feed .= ' <email>' . $this->items[$i]->authorEmail . "</email>\n"; |
|
1181 | - } |
|
1182 | - $feed .= " </author>\n"; |
|
1183 | - } |
|
1184 | - $feed .= " <content type=\"text/html\" xml:lang=\"en-us\">\n"; |
|
1185 | - $feed .= " <div xmlns=\"http://www.w3.org/1999/xhtml\">" . $this->items[$i]->getDescription() . "</div>\n"; |
|
1186 | - $feed .= " </content>\n"; |
|
1187 | - $feed .= " </entry>\n"; |
|
1188 | - } |
|
1189 | - $feed .= "</feed>\n"; |
|
1190 | - |
|
1191 | - return $feed; |
|
1192 | - } |
|
1147 | + /** |
|
1148 | + * PIECreator01 constructor. |
|
1149 | + */ |
|
1150 | + public function __construct() |
|
1151 | + { |
|
1152 | + $this->encoding = 'utf-8'; |
|
1153 | + } |
|
1154 | + |
|
1155 | + /** |
|
1156 | + * @return string |
|
1157 | + */ |
|
1158 | + public function createFeed() |
|
1159 | + { |
|
1160 | + $feed = "<?xml version=\"1.0\" encoding=\"" . $this->encoding . "\"?>\n"; |
|
1161 | + $feed .= $this->_createStylesheetReferences(); |
|
1162 | + $feed .= "<feed version=\"0.1\" xmlns=\"http://example.com/newformat#\">\n"; |
|
1163 | + $feed .= ' <title>' . FeedCreator::iTrunc(htmlspecialchars($this->title), 100) . "</title>\n"; |
|
1164 | + $this->truncSize = 500; |
|
1165 | + $feed .= ' <subtitle>' . $this->getDescription() . "</subtitle>\n"; |
|
1166 | + $feed .= ' <link>' . $this->link . "</link>\n"; |
|
1167 | + for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
|
1168 | + $feed .= " <entry>\n"; |
|
1169 | + $feed .= ' <title>' . FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)), 100) . "</title>\n"; |
|
1170 | + $feed .= ' <link>' . htmlspecialchars($this->items[$i]->link) . "</link>\n"; |
|
1171 | + $itemDate = new FeedDate($this->items[$i]->date); |
|
1172 | + $feed .= ' <created>' . htmlspecialchars($itemDate->iso8601()) . "</created>\n"; |
|
1173 | + $feed .= ' <issued>' . htmlspecialchars($itemDate->iso8601()) . "</issued>\n"; |
|
1174 | + $feed .= ' <modified>' . htmlspecialchars($itemDate->iso8601()) . "</modified>\n"; |
|
1175 | + $feed .= ' <id>' . htmlspecialchars($this->items[$i]->guid) . "</id>\n"; |
|
1176 | + if ($this->items[$i]->author != '') { |
|
1177 | + $feed .= " <author>\n"; |
|
1178 | + $feed .= ' <name>' . htmlspecialchars($this->items[$i]->author) . "</name>\n"; |
|
1179 | + if ($this->items[$i]->authorEmail != '') { |
|
1180 | + $feed .= ' <email>' . $this->items[$i]->authorEmail . "</email>\n"; |
|
1181 | + } |
|
1182 | + $feed .= " </author>\n"; |
|
1183 | + } |
|
1184 | + $feed .= " <content type=\"text/html\" xml:lang=\"en-us\">\n"; |
|
1185 | + $feed .= " <div xmlns=\"http://www.w3.org/1999/xhtml\">" . $this->items[$i]->getDescription() . "</div>\n"; |
|
1186 | + $feed .= " </content>\n"; |
|
1187 | + $feed .= " </entry>\n"; |
|
1188 | + } |
|
1189 | + $feed .= "</feed>\n"; |
|
1190 | + |
|
1191 | + return $feed; |
|
1192 | + } |
|
1193 | 1193 | } |
1194 | 1194 | |
1195 | 1195 | /** |
@@ -1210,71 +1210,71 @@ discard block |
||
1210 | 1210 | */ |
1211 | 1211 | class AtomCreator03 extends FeedCreator |
1212 | 1212 | { |
1213 | - /** |
|
1214 | - * AtomCreator03 constructor. |
|
1215 | - */ |
|
1216 | - public function __construct() |
|
1217 | - { |
|
1218 | - $this->contentType = 'application/atom+xml'; |
|
1219 | - $this->encoding = 'utf-8'; |
|
1220 | - } |
|
1221 | - |
|
1222 | - /** |
|
1223 | - * @return string |
|
1224 | - */ |
|
1225 | - public function createFeed() |
|
1226 | - { |
|
1227 | - $feed = "<?xml version=\"1.0\" encoding=\"" . $this->encoding . "\"?>\n"; |
|
1228 | - $feed .= $this->_createGeneratorComment(); |
|
1229 | - $feed .= $this->_createStylesheetReferences(); |
|
1230 | - $feed .= "<feed version=\"0.3\" xmlns=\"http://purl.org/atom/ns#\""; |
|
1231 | - if ($this->language != '') { |
|
1232 | - $feed .= " xml:lang=\"" . $this->language . "\""; |
|
1233 | - } |
|
1234 | - $feed .= ">\n"; |
|
1235 | - $feed .= ' <title>' . htmlspecialchars($this->title) . "</title>\n"; |
|
1236 | - $feed .= ' <tagline>' . htmlspecialchars($this->description) . "</tagline>\n"; |
|
1237 | - $feed .= " <link rel=\"alternate\" type=\"text/html\" href=\"" . htmlspecialchars($this->link) . "\">\n"; |
|
1238 | - $feed .= ' <id>' . htmlspecialchars($this->link) . "</id>\n"; |
|
1239 | - $now = new FeedDate(); |
|
1240 | - $feed .= ' <modified>' . htmlspecialchars($now->iso8601()) . "</modified>\n"; |
|
1241 | - if ($this->editor != '') { |
|
1242 | - $feed .= " <author>\n"; |
|
1243 | - $feed .= ' <name>' . $this->editor . "</name>\n"; |
|
1244 | - if ($this->editorEmail != '') { |
|
1245 | - $feed .= ' <email>' . $this->editorEmail . "</email>\n"; |
|
1246 | - } |
|
1247 | - $feed .= " </author>\n"; |
|
1248 | - } |
|
1249 | - $feed .= ' <generator>' . FEEDCREATOR_VERSION . "</generator>\n"; |
|
1250 | - $feed .= $this->_createAdditionalElements($this->additionalElements, ' '); |
|
1251 | - for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
|
1252 | - $feed .= " <entry>\n"; |
|
1253 | - $feed .= ' <title>' . htmlspecialchars(strip_tags($this->items[$i]->title)) . "</title>\n"; |
|
1254 | - $feed .= " <link rel=\"alternate\" type=\"text/html\" href=\"" . htmlspecialchars($this->items[$i]->link) . "\">\n"; |
|
1255 | - if ($this->items[$i]->date == '') { |
|
1256 | - $this->items[$i]->date = time(); |
|
1257 | - } |
|
1258 | - $itemDate = new FeedDate($this->items[$i]->date); |
|
1259 | - $feed .= ' <created>' . htmlspecialchars($itemDate->iso8601()) . "</created>\n"; |
|
1260 | - $feed .= ' <issued>' . htmlspecialchars($itemDate->iso8601()) . "</issued>\n"; |
|
1261 | - $feed .= ' <modified>' . htmlspecialchars($itemDate->iso8601()) . "</modified>\n"; |
|
1262 | - $feed .= ' <id>' . htmlspecialchars($this->items[$i]->link) . "</id>\n"; |
|
1263 | - $feed .= $this->_createAdditionalElements($this->items[$i]->additionalElements, ' '); |
|
1264 | - if ($this->items[$i]->author != '') { |
|
1265 | - $feed .= " <author>\n"; |
|
1266 | - $feed .= ' <name>' . htmlspecialchars($this->items[$i]->author) . "</name>\n"; |
|
1267 | - $feed .= " </author>\n"; |
|
1268 | - } |
|
1269 | - if ($this->items[$i]->description != '') { |
|
1270 | - $feed .= ' <summary>' . htmlspecialchars($this->items[$i]->description) . "</summary>\n"; |
|
1271 | - } |
|
1272 | - $feed .= " </entry>\n"; |
|
1273 | - } |
|
1274 | - $feed .= "</feed>\n"; |
|
1275 | - |
|
1276 | - return $feed; |
|
1277 | - } |
|
1213 | + /** |
|
1214 | + * AtomCreator03 constructor. |
|
1215 | + */ |
|
1216 | + public function __construct() |
|
1217 | + { |
|
1218 | + $this->contentType = 'application/atom+xml'; |
|
1219 | + $this->encoding = 'utf-8'; |
|
1220 | + } |
|
1221 | + |
|
1222 | + /** |
|
1223 | + * @return string |
|
1224 | + */ |
|
1225 | + public function createFeed() |
|
1226 | + { |
|
1227 | + $feed = "<?xml version=\"1.0\" encoding=\"" . $this->encoding . "\"?>\n"; |
|
1228 | + $feed .= $this->_createGeneratorComment(); |
|
1229 | + $feed .= $this->_createStylesheetReferences(); |
|
1230 | + $feed .= "<feed version=\"0.3\" xmlns=\"http://purl.org/atom/ns#\""; |
|
1231 | + if ($this->language != '') { |
|
1232 | + $feed .= " xml:lang=\"" . $this->language . "\""; |
|
1233 | + } |
|
1234 | + $feed .= ">\n"; |
|
1235 | + $feed .= ' <title>' . htmlspecialchars($this->title) . "</title>\n"; |
|
1236 | + $feed .= ' <tagline>' . htmlspecialchars($this->description) . "</tagline>\n"; |
|
1237 | + $feed .= " <link rel=\"alternate\" type=\"text/html\" href=\"" . htmlspecialchars($this->link) . "\">\n"; |
|
1238 | + $feed .= ' <id>' . htmlspecialchars($this->link) . "</id>\n"; |
|
1239 | + $now = new FeedDate(); |
|
1240 | + $feed .= ' <modified>' . htmlspecialchars($now->iso8601()) . "</modified>\n"; |
|
1241 | + if ($this->editor != '') { |
|
1242 | + $feed .= " <author>\n"; |
|
1243 | + $feed .= ' <name>' . $this->editor . "</name>\n"; |
|
1244 | + if ($this->editorEmail != '') { |
|
1245 | + $feed .= ' <email>' . $this->editorEmail . "</email>\n"; |
|
1246 | + } |
|
1247 | + $feed .= " </author>\n"; |
|
1248 | + } |
|
1249 | + $feed .= ' <generator>' . FEEDCREATOR_VERSION . "</generator>\n"; |
|
1250 | + $feed .= $this->_createAdditionalElements($this->additionalElements, ' '); |
|
1251 | + for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
|
1252 | + $feed .= " <entry>\n"; |
|
1253 | + $feed .= ' <title>' . htmlspecialchars(strip_tags($this->items[$i]->title)) . "</title>\n"; |
|
1254 | + $feed .= " <link rel=\"alternate\" type=\"text/html\" href=\"" . htmlspecialchars($this->items[$i]->link) . "\">\n"; |
|
1255 | + if ($this->items[$i]->date == '') { |
|
1256 | + $this->items[$i]->date = time(); |
|
1257 | + } |
|
1258 | + $itemDate = new FeedDate($this->items[$i]->date); |
|
1259 | + $feed .= ' <created>' . htmlspecialchars($itemDate->iso8601()) . "</created>\n"; |
|
1260 | + $feed .= ' <issued>' . htmlspecialchars($itemDate->iso8601()) . "</issued>\n"; |
|
1261 | + $feed .= ' <modified>' . htmlspecialchars($itemDate->iso8601()) . "</modified>\n"; |
|
1262 | + $feed .= ' <id>' . htmlspecialchars($this->items[$i]->link) . "</id>\n"; |
|
1263 | + $feed .= $this->_createAdditionalElements($this->items[$i]->additionalElements, ' '); |
|
1264 | + if ($this->items[$i]->author != '') { |
|
1265 | + $feed .= " <author>\n"; |
|
1266 | + $feed .= ' <name>' . htmlspecialchars($this->items[$i]->author) . "</name>\n"; |
|
1267 | + $feed .= " </author>\n"; |
|
1268 | + } |
|
1269 | + if ($this->items[$i]->description != '') { |
|
1270 | + $feed .= ' <summary>' . htmlspecialchars($this->items[$i]->description) . "</summary>\n"; |
|
1271 | + } |
|
1272 | + $feed .= " </entry>\n"; |
|
1273 | + } |
|
1274 | + $feed .= "</feed>\n"; |
|
1275 | + |
|
1276 | + return $feed; |
|
1277 | + } |
|
1278 | 1278 | } |
1279 | 1279 | |
1280 | 1280 | /** |
@@ -1286,97 +1286,97 @@ discard block |
||
1286 | 1286 | */ |
1287 | 1287 | class MBOXCreator extends FeedCreator |
1288 | 1288 | { |
1289 | - /** |
|
1290 | - * MBOXCreator constructor. |
|
1291 | - */ |
|
1292 | - public function __construct() |
|
1293 | - { |
|
1294 | - $this->contentType = 'text/plain'; |
|
1295 | - $this->encoding = 'ISO-8859-15'; |
|
1296 | - } |
|
1297 | - |
|
1298 | - /** |
|
1299 | - * @param string $input |
|
1300 | - * @param int $line_max |
|
1301 | - * @return string |
|
1302 | - */ |
|
1303 | - public function qp_enc($input = '', $line_max = 76) |
|
1304 | - { |
|
1305 | - $hex = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F']; |
|
1306 | - $lines = preg_split("/(?:\r\n|\r|\n)/", $input); |
|
1307 | - $eol = "\r\n"; |
|
1308 | - $escape = '='; |
|
1309 | - $output = ''; |
|
1310 | - // while (list(, $line) = each($lines)) { |
|
1311 | - foreach ($lines as $key => $line) { |
|
1312 | - //$line = rtrim($line); // remove trailing white space -> no =20\r\n necessary |
|
1313 | - $linlen = strlen($line); |
|
1314 | - $newline = ''; |
|
1315 | - for ($i = 0; $i < $linlen; ++$i) { |
|
1316 | - $c = substr($line, $i, 1); |
|
1317 | - $dec = ord($c); |
|
1318 | - if (($dec == 32) && ($i == ($linlen - 1))) { // convert space at eol only |
|
1319 | - $c = '=20'; |
|
1320 | - } elseif (($dec == 61) || ($dec < 32) || ($dec > 126)) { // always encode "\t", which is *not* required |
|
1321 | - $h2 = floor($dec / 16); |
|
1322 | - $h1 = floor($dec % 16); |
|
1323 | - $c = $escape . $hex["$h2"] . $hex["$h1"]; |
|
1324 | - } |
|
1325 | - if ((strlen($newline) + strlen($c)) >= $line_max) { // CRLF is not counted |
|
1326 | - $output .= $newline . $escape . $eol; // soft line break; " =\r\n" is okay |
|
1327 | - $newline = ''; |
|
1328 | - } |
|
1329 | - $newline .= $c; |
|
1330 | - } // end of for |
|
1331 | - $output .= $newline . $eol; |
|
1332 | - } |
|
1333 | - |
|
1334 | - return trim($output); |
|
1335 | - } |
|
1336 | - |
|
1337 | - /** |
|
1338 | - * Builds the MBOX contents. |
|
1339 | - * @return string the feed's complete text |
|
1340 | - */ |
|
1341 | - public function createFeed() |
|
1342 | - { |
|
1343 | - for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
|
1344 | - if ($this->items[$i]->author != '') { |
|
1345 | - $from = $this->items[$i]->author; |
|
1346 | - } else { |
|
1347 | - $from = $this->title; |
|
1348 | - } |
|
1349 | - $itemDate = new FeedDate($this->items[$i]->date); |
|
1350 | - $feed .= 'From ' . strtr(MBOXCreator::qp_enc($from), ' ', '_') . ' ' . date('D M d H:i:s Y', $itemDate->unix()) . "\n"; |
|
1351 | - $feed .= "Content-Type: text/plain;\n"; |
|
1352 | - $feed .= " charset=\"" . $this->encoding . "\"\n"; |
|
1353 | - $feed .= "Content-Transfer-Encoding: quoted-printable\n"; |
|
1354 | - $feed .= "Content-Type: text/plain\n"; |
|
1355 | - $feed .= "From: \"" . MBOXCreator::qp_enc($from) . "\"\n"; |
|
1356 | - $feed .= 'Date: ' . $itemDate->rfc822() . "\n"; |
|
1357 | - $feed .= 'Subject: ' . MBOXCreator::qp_enc(FeedCreator::iTrunc($this->items[$i]->title, 100)) . "\n"; |
|
1358 | - $feed .= "\n"; |
|
1359 | - $body = chunk_split(MBOXCreator::qp_enc($this->items[$i]->description)); |
|
1360 | - $feed .= preg_replace("~\nFrom ([^\n]*)(\n?)~", "\n>From $1$2\n", $body); |
|
1361 | - $feed .= "\n"; |
|
1362 | - $feed .= "\n"; |
|
1363 | - } |
|
1364 | - |
|
1365 | - return $feed; |
|
1366 | - } |
|
1367 | - |
|
1368 | - /** |
|
1369 | - * Generate a filename for the feed cache file. Overridden from FeedCreator to prevent XML data types. |
|
1370 | - * @return string the feed cache filename |
|
1371 | - * @since 1.4 |
|
1372 | - * @access private |
|
1373 | - */ |
|
1374 | - public function _generateFilename() |
|
1375 | - { |
|
1376 | - $fileInfo = pathinfo($_SERVER['PHP_SELF']); |
|
1377 | - |
|
1378 | - return substr($fileInfo['basename'], 0, -(strlen($fileInfo['extension']) + 1)) . '.mbox'; |
|
1379 | - } |
|
1289 | + /** |
|
1290 | + * MBOXCreator constructor. |
|
1291 | + */ |
|
1292 | + public function __construct() |
|
1293 | + { |
|
1294 | + $this->contentType = 'text/plain'; |
|
1295 | + $this->encoding = 'ISO-8859-15'; |
|
1296 | + } |
|
1297 | + |
|
1298 | + /** |
|
1299 | + * @param string $input |
|
1300 | + * @param int $line_max |
|
1301 | + * @return string |
|
1302 | + */ |
|
1303 | + public function qp_enc($input = '', $line_max = 76) |
|
1304 | + { |
|
1305 | + $hex = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F']; |
|
1306 | + $lines = preg_split("/(?:\r\n|\r|\n)/", $input); |
|
1307 | + $eol = "\r\n"; |
|
1308 | + $escape = '='; |
|
1309 | + $output = ''; |
|
1310 | + // while (list(, $line) = each($lines)) { |
|
1311 | + foreach ($lines as $key => $line) { |
|
1312 | + //$line = rtrim($line); // remove trailing white space -> no =20\r\n necessary |
|
1313 | + $linlen = strlen($line); |
|
1314 | + $newline = ''; |
|
1315 | + for ($i = 0; $i < $linlen; ++$i) { |
|
1316 | + $c = substr($line, $i, 1); |
|
1317 | + $dec = ord($c); |
|
1318 | + if (($dec == 32) && ($i == ($linlen - 1))) { // convert space at eol only |
|
1319 | + $c = '=20'; |
|
1320 | + } elseif (($dec == 61) || ($dec < 32) || ($dec > 126)) { // always encode "\t", which is *not* required |
|
1321 | + $h2 = floor($dec / 16); |
|
1322 | + $h1 = floor($dec % 16); |
|
1323 | + $c = $escape . $hex["$h2"] . $hex["$h1"]; |
|
1324 | + } |
|
1325 | + if ((strlen($newline) + strlen($c)) >= $line_max) { // CRLF is not counted |
|
1326 | + $output .= $newline . $escape . $eol; // soft line break; " =\r\n" is okay |
|
1327 | + $newline = ''; |
|
1328 | + } |
|
1329 | + $newline .= $c; |
|
1330 | + } // end of for |
|
1331 | + $output .= $newline . $eol; |
|
1332 | + } |
|
1333 | + |
|
1334 | + return trim($output); |
|
1335 | + } |
|
1336 | + |
|
1337 | + /** |
|
1338 | + * Builds the MBOX contents. |
|
1339 | + * @return string the feed's complete text |
|
1340 | + */ |
|
1341 | + public function createFeed() |
|
1342 | + { |
|
1343 | + for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
|
1344 | + if ($this->items[$i]->author != '') { |
|
1345 | + $from = $this->items[$i]->author; |
|
1346 | + } else { |
|
1347 | + $from = $this->title; |
|
1348 | + } |
|
1349 | + $itemDate = new FeedDate($this->items[$i]->date); |
|
1350 | + $feed .= 'From ' . strtr(MBOXCreator::qp_enc($from), ' ', '_') . ' ' . date('D M d H:i:s Y', $itemDate->unix()) . "\n"; |
|
1351 | + $feed .= "Content-Type: text/plain;\n"; |
|
1352 | + $feed .= " charset=\"" . $this->encoding . "\"\n"; |
|
1353 | + $feed .= "Content-Transfer-Encoding: quoted-printable\n"; |
|
1354 | + $feed .= "Content-Type: text/plain\n"; |
|
1355 | + $feed .= "From: \"" . MBOXCreator::qp_enc($from) . "\"\n"; |
|
1356 | + $feed .= 'Date: ' . $itemDate->rfc822() . "\n"; |
|
1357 | + $feed .= 'Subject: ' . MBOXCreator::qp_enc(FeedCreator::iTrunc($this->items[$i]->title, 100)) . "\n"; |
|
1358 | + $feed .= "\n"; |
|
1359 | + $body = chunk_split(MBOXCreator::qp_enc($this->items[$i]->description)); |
|
1360 | + $feed .= preg_replace("~\nFrom ([^\n]*)(\n?)~", "\n>From $1$2\n", $body); |
|
1361 | + $feed .= "\n"; |
|
1362 | + $feed .= "\n"; |
|
1363 | + } |
|
1364 | + |
|
1365 | + return $feed; |
|
1366 | + } |
|
1367 | + |
|
1368 | + /** |
|
1369 | + * Generate a filename for the feed cache file. Overridden from FeedCreator to prevent XML data types. |
|
1370 | + * @return string the feed cache filename |
|
1371 | + * @since 1.4 |
|
1372 | + * @access private |
|
1373 | + */ |
|
1374 | + public function _generateFilename() |
|
1375 | + { |
|
1376 | + $fileInfo = pathinfo($_SERVER['PHP_SELF']); |
|
1377 | + |
|
1378 | + return substr($fileInfo['basename'], 0, -(strlen($fileInfo['extension']) + 1)) . '.mbox'; |
|
1379 | + } |
|
1380 | 1380 | } |
1381 | 1381 | |
1382 | 1382 | /** |
@@ -1388,55 +1388,55 @@ discard block |
||
1388 | 1388 | */ |
1389 | 1389 | class OPMLCreator extends FeedCreator |
1390 | 1390 | { |
1391 | - /** |
|
1392 | - * OPMLCreator constructor. |
|
1393 | - */ |
|
1394 | - public function __construct() |
|
1395 | - { |
|
1396 | - $this->encoding = 'utf-8'; |
|
1397 | - } |
|
1398 | - |
|
1399 | - /** |
|
1400 | - * @return string |
|
1401 | - */ |
|
1402 | - public function createFeed() |
|
1403 | - { |
|
1404 | - $feed = "<?xml version=\"1.0\" encoding=\"" . $this->encoding . "\"?>\n"; |
|
1405 | - $feed .= $this->_createGeneratorComment(); |
|
1406 | - $feed .= $this->_createStylesheetReferences(); |
|
1407 | - $feed .= "<opml xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n"; |
|
1408 | - $feed .= " <head>\n"; |
|
1409 | - $feed .= ' <title>' . htmlspecialchars($this->title) . "</title>\n"; |
|
1410 | - if ($this->pubDate != '') { |
|
1411 | - $date = new FeedDate($this->pubDate); |
|
1412 | - $feed .= ' <dateCreated>' . $date->rfc822() . "</dateCreated>\n"; |
|
1413 | - } |
|
1414 | - if ($this->lastBuildDate != '') { |
|
1415 | - $date = new FeedDate($this->lastBuildDate); |
|
1416 | - $feed .= ' <dateModified>' . $date->rfc822() . "</dateModified>\n"; |
|
1417 | - } |
|
1418 | - if ($this->editor != '') { |
|
1419 | - $feed .= ' <ownerName>' . $this->editor . "</ownerName>\n"; |
|
1420 | - } |
|
1421 | - if ($this->editorEmail != '') { |
|
1422 | - $feed .= ' <ownerEmail>' . $this->editorEmail . "</ownerEmail>\n"; |
|
1423 | - } |
|
1424 | - $feed .= " </head>\n"; |
|
1425 | - $feed .= " <body>\n"; |
|
1426 | - for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
|
1427 | - $feed .= " <outline type=\"rss\" "; |
|
1428 | - $title = htmlspecialchars(strip_tags(strtr($this->items[$i]->title, "\n\r", ' '))); |
|
1429 | - $feed .= " title=\"" . $title . "\""; |
|
1430 | - $feed .= " text=\"" . $title . "\""; |
|
1431 | - //$feed.= " description=\"".htmlspecialchars($this->items[$i]->description)."\""; |
|
1432 | - $feed .= " url=\"" . htmlspecialchars($this->items[$i]->link) . "\""; |
|
1433 | - $feed .= ">\n"; |
|
1434 | - } |
|
1435 | - $feed .= " </body>\n"; |
|
1436 | - $feed .= "</opml>\n"; |
|
1437 | - |
|
1438 | - return $feed; |
|
1439 | - } |
|
1391 | + /** |
|
1392 | + * OPMLCreator constructor. |
|
1393 | + */ |
|
1394 | + public function __construct() |
|
1395 | + { |
|
1396 | + $this->encoding = 'utf-8'; |
|
1397 | + } |
|
1398 | + |
|
1399 | + /** |
|
1400 | + * @return string |
|
1401 | + */ |
|
1402 | + public function createFeed() |
|
1403 | + { |
|
1404 | + $feed = "<?xml version=\"1.0\" encoding=\"" . $this->encoding . "\"?>\n"; |
|
1405 | + $feed .= $this->_createGeneratorComment(); |
|
1406 | + $feed .= $this->_createStylesheetReferences(); |
|
1407 | + $feed .= "<opml xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n"; |
|
1408 | + $feed .= " <head>\n"; |
|
1409 | + $feed .= ' <title>' . htmlspecialchars($this->title) . "</title>\n"; |
|
1410 | + if ($this->pubDate != '') { |
|
1411 | + $date = new FeedDate($this->pubDate); |
|
1412 | + $feed .= ' <dateCreated>' . $date->rfc822() . "</dateCreated>\n"; |
|
1413 | + } |
|
1414 | + if ($this->lastBuildDate != '') { |
|
1415 | + $date = new FeedDate($this->lastBuildDate); |
|
1416 | + $feed .= ' <dateModified>' . $date->rfc822() . "</dateModified>\n"; |
|
1417 | + } |
|
1418 | + if ($this->editor != '') { |
|
1419 | + $feed .= ' <ownerName>' . $this->editor . "</ownerName>\n"; |
|
1420 | + } |
|
1421 | + if ($this->editorEmail != '') { |
|
1422 | + $feed .= ' <ownerEmail>' . $this->editorEmail . "</ownerEmail>\n"; |
|
1423 | + } |
|
1424 | + $feed .= " </head>\n"; |
|
1425 | + $feed .= " <body>\n"; |
|
1426 | + for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
|
1427 | + $feed .= " <outline type=\"rss\" "; |
|
1428 | + $title = htmlspecialchars(strip_tags(strtr($this->items[$i]->title, "\n\r", ' '))); |
|
1429 | + $feed .= " title=\"" . $title . "\""; |
|
1430 | + $feed .= " text=\"" . $title . "\""; |
|
1431 | + //$feed.= " description=\"".htmlspecialchars($this->items[$i]->description)."\""; |
|
1432 | + $feed .= " url=\"" . htmlspecialchars($this->items[$i]->link) . "\""; |
|
1433 | + $feed .= ">\n"; |
|
1434 | + } |
|
1435 | + $feed .= " </body>\n"; |
|
1436 | + $feed .= "</opml>\n"; |
|
1437 | + |
|
1438 | + return $feed; |
|
1439 | + } |
|
1440 | 1440 | } |
1441 | 1441 | |
1442 | 1442 | /** |
@@ -1452,138 +1452,138 @@ discard block |
||
1452 | 1452 | */ |
1453 | 1453 | class HTMLCreator extends FeedCreator |
1454 | 1454 | { |
1455 | - // public $contentType = 'text/html'; |
|
1456 | - |
|
1457 | - /** |
|
1458 | - * Contains HTML to be output at the start of the feed's html representation. |
|
1459 | - */ |
|
1460 | - public $header; |
|
1461 | - |
|
1462 | - /** |
|
1463 | - * Contains HTML to be output at the end of the feed's html representation. |
|
1464 | - */ |
|
1465 | - public $footer; |
|
1466 | - |
|
1467 | - /** |
|
1468 | - * Contains HTML to be output between entries. A separator is only used in |
|
1469 | - * case of multiple entries. |
|
1470 | - */ |
|
1471 | - public $separator; |
|
1472 | - |
|
1473 | - /** |
|
1474 | - * Used to prefix the stylenames to make sure they are unique |
|
1475 | - * and do not clash with stylenames on the users' page. |
|
1476 | - */ |
|
1477 | - public $stylePrefix; |
|
1478 | - |
|
1479 | - /** |
|
1480 | - * Determines whether the links open in a new window or not. |
|
1481 | - */ |
|
1482 | - public $openInNewWindow = true; |
|
1483 | - |
|
1484 | - public $imageAlign = 'right'; |
|
1485 | - |
|
1486 | - /** |
|
1487 | - * In case of very simple output you may want to get rid of the style tags, |
|
1488 | - * hence this variable. There's no equivalent on item level, but of course you can |
|
1489 | - * add strings to it while iterating over the items ($this->stylelessOutput .= ...) |
|
1490 | - * and when it is non-empty, ONLY the styleless output is printed, the rest is ignored |
|
1491 | - * in the function createFeed(). |
|
1492 | - */ |
|
1493 | - public $stylelessOutput = ''; |
|
1494 | - |
|
1495 | - /** |
|
1496 | - * HTMLCreator constructor. |
|
1497 | - */ |
|
1498 | - public function __construct() |
|
1499 | - { |
|
1500 | - $this->contentType = 'text/html'; |
|
1501 | - } |
|
1502 | - |
|
1503 | - /** |
|
1504 | - * Writes the HTML. |
|
1505 | - * @return string the scripts's complete text |
|
1506 | - */ |
|
1507 | - public function createFeed() |
|
1508 | - { |
|
1509 | - // if there is styleless output, use the content of this variable and ignore the rest |
|
1510 | - if ($this->stylelessOutput != '') { |
|
1511 | - return $this->stylelessOutput; |
|
1512 | - } |
|
1513 | - |
|
1514 | - //if no stylePrefix is set, generate it yourself depending on the script name |
|
1515 | - if ($this->stylePrefix == '') { |
|
1516 | - $this->stylePrefix = str_replace('.', '_', $this->_generateFilename()) . '_'; |
|
1517 | - } |
|
1518 | - |
|
1519 | - //set an openInNewWindow_token_to be inserted or not |
|
1520 | - if ($this->openInNewWindow) { |
|
1521 | - $targetInsert = " target='_blank'"; |
|
1522 | - } |
|
1523 | - |
|
1524 | - // use this array to put the lines in and implode later with "document.write" javascript |
|
1525 | - $feedArray = []; |
|
1526 | - if ($this->image != null) { |
|
1527 | - $imageStr = "<a href='" . $this->image->link . "'" . $targetInsert . '>' . "<img src='" . $this->image->url . "' border='0' alt='" . FeedCreator::iTrunc(htmlspecialchars($this->image->title), 100) . "' align='" . $this->imageAlign . "' "; |
|
1528 | - if ($this->image->width) { |
|
1529 | - $imageStr .= " width='" . $this->image->width . "' "; |
|
1530 | - } |
|
1531 | - if ($this->image->height) { |
|
1532 | - $imageStr .= " height='" . $this->image->height . "' "; |
|
1533 | - } |
|
1534 | - $imageStr .= '></a>'; |
|
1535 | - $feedArray[] = $imageStr; |
|
1536 | - } |
|
1537 | - |
|
1538 | - if ($this->title) { |
|
1539 | - $feedArray[] = "<div class='" . $this->stylePrefix . "title'><a href='" . $this->link . "' " . $targetInsert . " class='" . $this->stylePrefix . "title'>" . FeedCreator::iTrunc(htmlspecialchars($this->title), 100) . '</a></div>'; |
|
1540 | - } |
|
1541 | - if ($this->getDescription()) { |
|
1542 | - $feedArray[] = "<div class='" . $this->stylePrefix . "description'>" . str_replace(']]>', '', str_replace('<![CDATA[', '', $this->getDescription())) . '</div>'; |
|
1543 | - } |
|
1544 | - |
|
1545 | - if ($this->header) { |
|
1546 | - $feedArray[] = "<div class='" . $this->stylePrefix . "header'>" . $this->header . '</div>'; |
|
1547 | - } |
|
1548 | - |
|
1549 | - for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
|
1550 | - if ($this->separator && $i > 0) { |
|
1551 | - $feedArray[] = "<div class='" . $this->stylePrefix . "separator'>" . $this->separator . '</div>'; |
|
1552 | - } |
|
1553 | - |
|
1554 | - if ($this->items[$i]->title) { |
|
1555 | - if ($this->items[$i]->link) { |
|
1556 | - $feedArray[] = "<div class='" . $this->stylePrefix . "item_title'><a href='" . $this->items[$i]->link . "' class='" . $this->stylePrefix . "item_title'" . $targetInsert . '>' . FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)), 100) . '</a></div>'; |
|
1557 | - } else { |
|
1558 | - $feedArray[] = "<div class='" . $this->stylePrefix . "item_title'>" . FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)), 100) . '</div>'; |
|
1559 | - } |
|
1560 | - } |
|
1561 | - if ($this->items[$i]->getDescription()) { |
|
1562 | - $feedArray[] = "<div class='" . $this->stylePrefix . "item_description'>" . str_replace(']]>', '', str_replace('<![CDATA[', '', $this->items[$i]->getDescription())) . '</div>'; |
|
1563 | - } |
|
1564 | - } |
|
1565 | - if ($this->footer) { |
|
1566 | - $feedArray[] = "<div class='" . $this->stylePrefix . "footer'>" . $this->footer . '</div>'; |
|
1567 | - } |
|
1568 | - |
|
1569 | - $feed = '' . implode($feedArray, "\r\n"); |
|
1570 | - |
|
1571 | - return $feed; |
|
1572 | - } |
|
1573 | - |
|
1574 | - /** |
|
1575 | - * Overrrides parent to produce .html extensions |
|
1576 | - * |
|
1577 | - * @return string the feed cache filename |
|
1578 | - * @since 1.4 |
|
1579 | - * @access private |
|
1580 | - */ |
|
1581 | - public function _generateFilename() |
|
1582 | - { |
|
1583 | - $fileInfo = pathinfo($_SERVER['PHP_SELF']); |
|
1584 | - |
|
1585 | - return substr($fileInfo['basename'], 0, -(strlen($fileInfo['extension']) + 1)) . '.html'; |
|
1586 | - } |
|
1455 | + // public $contentType = 'text/html'; |
|
1456 | + |
|
1457 | + /** |
|
1458 | + * Contains HTML to be output at the start of the feed's html representation. |
|
1459 | + */ |
|
1460 | + public $header; |
|
1461 | + |
|
1462 | + /** |
|
1463 | + * Contains HTML to be output at the end of the feed's html representation. |
|
1464 | + */ |
|
1465 | + public $footer; |
|
1466 | + |
|
1467 | + /** |
|
1468 | + * Contains HTML to be output between entries. A separator is only used in |
|
1469 | + * case of multiple entries. |
|
1470 | + */ |
|
1471 | + public $separator; |
|
1472 | + |
|
1473 | + /** |
|
1474 | + * Used to prefix the stylenames to make sure they are unique |
|
1475 | + * and do not clash with stylenames on the users' page. |
|
1476 | + */ |
|
1477 | + public $stylePrefix; |
|
1478 | + |
|
1479 | + /** |
|
1480 | + * Determines whether the links open in a new window or not. |
|
1481 | + */ |
|
1482 | + public $openInNewWindow = true; |
|
1483 | + |
|
1484 | + public $imageAlign = 'right'; |
|
1485 | + |
|
1486 | + /** |
|
1487 | + * In case of very simple output you may want to get rid of the style tags, |
|
1488 | + * hence this variable. There's no equivalent on item level, but of course you can |
|
1489 | + * add strings to it while iterating over the items ($this->stylelessOutput .= ...) |
|
1490 | + * and when it is non-empty, ONLY the styleless output is printed, the rest is ignored |
|
1491 | + * in the function createFeed(). |
|
1492 | + */ |
|
1493 | + public $stylelessOutput = ''; |
|
1494 | + |
|
1495 | + /** |
|
1496 | + * HTMLCreator constructor. |
|
1497 | + */ |
|
1498 | + public function __construct() |
|
1499 | + { |
|
1500 | + $this->contentType = 'text/html'; |
|
1501 | + } |
|
1502 | + |
|
1503 | + /** |
|
1504 | + * Writes the HTML. |
|
1505 | + * @return string the scripts's complete text |
|
1506 | + */ |
|
1507 | + public function createFeed() |
|
1508 | + { |
|
1509 | + // if there is styleless output, use the content of this variable and ignore the rest |
|
1510 | + if ($this->stylelessOutput != '') { |
|
1511 | + return $this->stylelessOutput; |
|
1512 | + } |
|
1513 | + |
|
1514 | + //if no stylePrefix is set, generate it yourself depending on the script name |
|
1515 | + if ($this->stylePrefix == '') { |
|
1516 | + $this->stylePrefix = str_replace('.', '_', $this->_generateFilename()) . '_'; |
|
1517 | + } |
|
1518 | + |
|
1519 | + //set an openInNewWindow_token_to be inserted or not |
|
1520 | + if ($this->openInNewWindow) { |
|
1521 | + $targetInsert = " target='_blank'"; |
|
1522 | + } |
|
1523 | + |
|
1524 | + // use this array to put the lines in and implode later with "document.write" javascript |
|
1525 | + $feedArray = []; |
|
1526 | + if ($this->image != null) { |
|
1527 | + $imageStr = "<a href='" . $this->image->link . "'" . $targetInsert . '>' . "<img src='" . $this->image->url . "' border='0' alt='" . FeedCreator::iTrunc(htmlspecialchars($this->image->title), 100) . "' align='" . $this->imageAlign . "' "; |
|
1528 | + if ($this->image->width) { |
|
1529 | + $imageStr .= " width='" . $this->image->width . "' "; |
|
1530 | + } |
|
1531 | + if ($this->image->height) { |
|
1532 | + $imageStr .= " height='" . $this->image->height . "' "; |
|
1533 | + } |
|
1534 | + $imageStr .= '></a>'; |
|
1535 | + $feedArray[] = $imageStr; |
|
1536 | + } |
|
1537 | + |
|
1538 | + if ($this->title) { |
|
1539 | + $feedArray[] = "<div class='" . $this->stylePrefix . "title'><a href='" . $this->link . "' " . $targetInsert . " class='" . $this->stylePrefix . "title'>" . FeedCreator::iTrunc(htmlspecialchars($this->title), 100) . '</a></div>'; |
|
1540 | + } |
|
1541 | + if ($this->getDescription()) { |
|
1542 | + $feedArray[] = "<div class='" . $this->stylePrefix . "description'>" . str_replace(']]>', '', str_replace('<![CDATA[', '', $this->getDescription())) . '</div>'; |
|
1543 | + } |
|
1544 | + |
|
1545 | + if ($this->header) { |
|
1546 | + $feedArray[] = "<div class='" . $this->stylePrefix . "header'>" . $this->header . '</div>'; |
|
1547 | + } |
|
1548 | + |
|
1549 | + for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
|
1550 | + if ($this->separator && $i > 0) { |
|
1551 | + $feedArray[] = "<div class='" . $this->stylePrefix . "separator'>" . $this->separator . '</div>'; |
|
1552 | + } |
|
1553 | + |
|
1554 | + if ($this->items[$i]->title) { |
|
1555 | + if ($this->items[$i]->link) { |
|
1556 | + $feedArray[] = "<div class='" . $this->stylePrefix . "item_title'><a href='" . $this->items[$i]->link . "' class='" . $this->stylePrefix . "item_title'" . $targetInsert . '>' . FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)), 100) . '</a></div>'; |
|
1557 | + } else { |
|
1558 | + $feedArray[] = "<div class='" . $this->stylePrefix . "item_title'>" . FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)), 100) . '</div>'; |
|
1559 | + } |
|
1560 | + } |
|
1561 | + if ($this->items[$i]->getDescription()) { |
|
1562 | + $feedArray[] = "<div class='" . $this->stylePrefix . "item_description'>" . str_replace(']]>', '', str_replace('<![CDATA[', '', $this->items[$i]->getDescription())) . '</div>'; |
|
1563 | + } |
|
1564 | + } |
|
1565 | + if ($this->footer) { |
|
1566 | + $feedArray[] = "<div class='" . $this->stylePrefix . "footer'>" . $this->footer . '</div>'; |
|
1567 | + } |
|
1568 | + |
|
1569 | + $feed = '' . implode($feedArray, "\r\n"); |
|
1570 | + |
|
1571 | + return $feed; |
|
1572 | + } |
|
1573 | + |
|
1574 | + /** |
|
1575 | + * Overrrides parent to produce .html extensions |
|
1576 | + * |
|
1577 | + * @return string the feed cache filename |
|
1578 | + * @since 1.4 |
|
1579 | + * @access private |
|
1580 | + */ |
|
1581 | + public function _generateFilename() |
|
1582 | + { |
|
1583 | + $fileInfo = pathinfo($_SERVER['PHP_SELF']); |
|
1584 | + |
|
1585 | + return substr($fileInfo['basename'], 0, -(strlen($fileInfo['extension']) + 1)) . '.html'; |
|
1586 | + } |
|
1587 | 1587 | } |
1588 | 1588 | |
1589 | 1589 | /** |
@@ -1595,44 +1595,44 @@ discard block |
||
1595 | 1595 | class JSCreator extends HTMLCreator |
1596 | 1596 | { |
1597 | 1597 | |
1598 | - /** |
|
1599 | - * JSCreator constructor. |
|
1600 | - */ |
|
1601 | - public function __construct() |
|
1602 | - { |
|
1603 | - $this->contentType = 'text/javascript'; |
|
1604 | - } |
|
1605 | - |
|
1606 | - /** |
|
1607 | - * writes the javascript |
|
1608 | - * @return string the scripts's complete text |
|
1609 | - */ |
|
1610 | - public function createFeed() |
|
1611 | - { |
|
1612 | - $feed = parent::createFeed(); |
|
1613 | - $feedArray = explode("\n", $feed); |
|
1614 | - |
|
1615 | - $jsFeed = ''; |
|
1616 | - foreach ($feedArray as $value) { |
|
1617 | - $jsFeed .= "document.write('" . trim(addslashes($value)) . "');\n"; |
|
1618 | - } |
|
1619 | - |
|
1620 | - return $jsFeed; |
|
1621 | - } |
|
1622 | - |
|
1623 | - /** |
|
1624 | - * Overrrides parent to produce .js extensions |
|
1625 | - * |
|
1626 | - * @return string the feed cache filename |
|
1627 | - * @since 1.4 |
|
1628 | - * @access private |
|
1629 | - */ |
|
1630 | - public function _generateFilename() |
|
1631 | - { |
|
1632 | - $fileInfo = pathinfo($_SERVER['PHP_SELF']); |
|
1633 | - |
|
1634 | - return substr($fileInfo['basename'], 0, -(strlen($fileInfo['extension']) + 1)) . '.js'; |
|
1635 | - } |
|
1598 | + /** |
|
1599 | + * JSCreator constructor. |
|
1600 | + */ |
|
1601 | + public function __construct() |
|
1602 | + { |
|
1603 | + $this->contentType = 'text/javascript'; |
|
1604 | + } |
|
1605 | + |
|
1606 | + /** |
|
1607 | + * writes the javascript |
|
1608 | + * @return string the scripts's complete text |
|
1609 | + */ |
|
1610 | + public function createFeed() |
|
1611 | + { |
|
1612 | + $feed = parent::createFeed(); |
|
1613 | + $feedArray = explode("\n", $feed); |
|
1614 | + |
|
1615 | + $jsFeed = ''; |
|
1616 | + foreach ($feedArray as $value) { |
|
1617 | + $jsFeed .= "document.write('" . trim(addslashes($value)) . "');\n"; |
|
1618 | + } |
|
1619 | + |
|
1620 | + return $jsFeed; |
|
1621 | + } |
|
1622 | + |
|
1623 | + /** |
|
1624 | + * Overrrides parent to produce .js extensions |
|
1625 | + * |
|
1626 | + * @return string the feed cache filename |
|
1627 | + * @since 1.4 |
|
1628 | + * @access private |
|
1629 | + */ |
|
1630 | + public function _generateFilename() |
|
1631 | + { |
|
1632 | + $fileInfo = pathinfo($_SERVER['PHP_SELF']); |
|
1633 | + |
|
1634 | + return substr($fileInfo['basename'], 0, -(strlen($fileInfo['extension']) + 1)) . '.js'; |
|
1635 | + } |
|
1636 | 1636 | } |
1637 | 1637 | |
1638 | 1638 | /*** TEST SCRIPT ********************************************************* |
@@ -342,11 +342,11 @@ discard block |
||
342 | 342 | if (!$this->rawFieldContent) { |
343 | 343 | $result = ''; |
344 | 344 | } elseif ($this->syndicateHtml) { |
345 | - $result = '<![CDATA[' . $this->rawFieldContent . ']]>'; |
|
346 | - } else { |
|
345 | + $result = '<![CDATA['.$this->rawFieldContent.']]>'; |
|
346 | + }else { |
|
347 | 347 | if ($this->truncSize && is_int($this->truncSize)) { |
348 | 348 | $result = FeedCreator::iTrunc(htmlspecialchars($this->rawFieldContent), $this->truncSize); |
349 | - } else { |
|
349 | + }else { |
|
350 | 350 | $result = htmlspecialchars($this->rawFieldContent); |
351 | 351 | } |
352 | 352 | } |
@@ -589,29 +589,29 @@ discard block |
||
589 | 589 | */ |
590 | 590 | public function iTrunc($string, $length) |
591 | 591 | { |
592 | - if (strlen($string) <= $length) { |
|
592 | + if (strlen($string)<=$length) { |
|
593 | 593 | return $string; |
594 | 594 | } |
595 | 595 | |
596 | 596 | $pos = strrpos($string, '.'); |
597 | - if ($pos >= $length - 4) { |
|
598 | - $string = substr($string, 0, $length - 4); |
|
597 | + if ($pos>=$length-4) { |
|
598 | + $string = substr($string, 0, $length-4); |
|
599 | 599 | $pos = strrpos($string, '.'); |
600 | 600 | } |
601 | - if ($pos >= $length * 0.4) { |
|
602 | - return substr($string, 0, $pos + 1) . ' ...'; |
|
601 | + if ($pos>=$length*0.4) { |
|
602 | + return substr($string, 0, $pos+1).' ...'; |
|
603 | 603 | } |
604 | 604 | |
605 | 605 | $pos = strrpos($string, ' '); |
606 | - if ($pos >= $length - 4) { |
|
607 | - $string = substr($string, 0, $length - 4); |
|
606 | + if ($pos>=$length-4) { |
|
607 | + $string = substr($string, 0, $length-4); |
|
608 | 608 | $pos = strrpos($string, ' '); |
609 | 609 | } |
610 | - if ($pos >= $length * 0.4) { |
|
611 | - return substr($string, 0, $pos) . ' ...'; |
|
610 | + if ($pos>=$length*0.4) { |
|
611 | + return substr($string, 0, $pos).' ...'; |
|
612 | 612 | } |
613 | 613 | |
614 | - return substr($string, 0, $length - 4) . ' ...'; |
|
614 | + return substr($string, 0, $length-4).' ...'; |
|
615 | 615 | } |
616 | 616 | |
617 | 617 | /** |
@@ -621,7 +621,7 @@ discard block |
||
621 | 621 | */ |
622 | 622 | public function _createGeneratorComment() |
623 | 623 | { |
624 | - return "<!-- generator=\"" . FEEDCREATOR_VERSION . "\" -->\n"; |
|
624 | + return "<!-- generator=\"".FEEDCREATOR_VERSION."\" -->\n"; |
|
625 | 625 | } |
626 | 626 | |
627 | 627 | /** |
@@ -638,7 +638,7 @@ discard block |
||
638 | 638 | $ae = ''; |
639 | 639 | if (is_array($elements)) { |
640 | 640 | foreach ($elements as $key => $value) { |
641 | - $ae .= $indentString . "<$key>$value</$key>\n"; |
|
641 | + $ae .= $indentString."<$key>$value</$key>\n"; |
|
642 | 642 | } |
643 | 643 | } |
644 | 644 | |
@@ -652,10 +652,10 @@ discard block |
||
652 | 652 | { |
653 | 653 | $xml = ''; |
654 | 654 | if ($this->cssStyleSheet) { |
655 | - $xml .= "<?xml-stylesheet href=\"" . $this->cssStyleSheet . "\" type=\"text/css\"?>\n"; |
|
655 | + $xml .= "<?xml-stylesheet href=\"".$this->cssStyleSheet."\" type=\"text/css\"?>\n"; |
|
656 | 656 | } |
657 | 657 | if ($this->xslStyleSheet) { |
658 | - $xml .= "<?xml-stylesheet href=\"" . $this->xslStyleSheet . "\" type=\"text/xsl\"?>\n"; |
|
658 | + $xml .= "<?xml-stylesheet href=\"".$this->xslStyleSheet."\" type=\"text/xsl\"?>\n"; |
|
659 | 659 | } |
660 | 660 | |
661 | 661 | return $xml; |
@@ -690,7 +690,7 @@ discard block |
||
690 | 690 | { |
691 | 691 | $fileInfo = pathinfo($_SERVER['PHP_SELF']); |
692 | 692 | |
693 | - return substr($fileInfo['basename'], 0, -(strlen($fileInfo['extension']) + 1)) . '.xml'; |
|
693 | + return substr($fileInfo['basename'], 0, -(strlen($fileInfo['extension'])+1)).'.xml'; |
|
694 | 694 | } |
695 | 695 | |
696 | 696 | /** |
@@ -713,8 +713,8 @@ discard block |
||
713 | 713 | // HTTP redirect, some feed readers' simple HTTP implementations don't follow it |
714 | 714 | //Header("Location: ".$filename); |
715 | 715 | |
716 | - header('Content-Type: ' . $this->contentType . '; charset=' . $this->encoding . '; filename=' . basename($filename)); |
|
717 | - header('Content-Disposition: inline; filename=' . basename($filename)); |
|
716 | + header('Content-Type: '.$this->contentType.'; charset='.$this->encoding.'; filename='.basename($filename)); |
|
717 | + header('Content-Disposition: inline; filename='.basename($filename)); |
|
718 | 718 | readfile($filename, 'r'); |
719 | 719 | die(); |
720 | 720 | } |
@@ -736,7 +736,7 @@ discard block |
||
736 | 736 | if ($filename == '') { |
737 | 737 | $filename = $this->_generateFilename(); |
738 | 738 | } |
739 | - if (file_exists($filename) && (time() - filemtime($filename) < $timeout)) { |
|
739 | + if (file_exists($filename) && (time()-filemtime($filename)<$timeout)) { |
|
740 | 740 | $this->_redirect($filename); |
741 | 741 | } |
742 | 742 | } |
@@ -762,7 +762,7 @@ discard block |
||
762 | 762 | if ($displayContents) { |
763 | 763 | $this->_redirect($filename); |
764 | 764 | } |
765 | - } else { |
|
765 | + }else { |
|
766 | 766 | echo '<br><b>Error creating feed file, please check write permissions.</b><br>'; |
767 | 767 | } |
768 | 768 | } |
@@ -795,7 +795,7 @@ discard block |
||
795 | 795 | return; |
796 | 796 | } |
797 | 797 | if (preg_match("~(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun),\\s+)?(\\d{1,2})\\s+([a-zA-Z]{3})\\s+(\\d{4})\\s+(\\d{2}):(\\d{2}):(\\d{2})\\s+(.*)~", $dateString, $matches)) { |
798 | - $months = [ |
|
798 | + $months = [ |
|
799 | 799 | 'Jan' => 1, |
800 | 800 | 'Feb' => 2, |
801 | 801 | 'Mar' => 3, |
@@ -811,15 +811,15 @@ discard block |
||
811 | 811 | ]; |
812 | 812 | $this->unix = mktime($matches[4], $matches[5], $matches[6], $months[$matches[2]], $matches[1], $matches[3]); |
813 | 813 | if (substr($matches[7], 0, 1) == '+' || substr($matches[7], 0, 1) == '-') { |
814 | - $tzOffset = (substr($matches[7], 0, 3) * 60 + substr($matches[7], -2)) * 60; |
|
815 | - } else { |
|
814 | + $tzOffset = (substr($matches[7], 0, 3)*60+substr($matches[7], -2))*60; |
|
815 | + }else { |
|
816 | 816 | if (strlen($matches[7]) == 1) { |
817 | 817 | $oneHour = 3600; |
818 | 818 | $ord = ord($matches[7]); |
819 | - if ($ord < ord('M')) { |
|
820 | - $tzOffset = (ord('A') - $ord - 1) * $oneHour; |
|
821 | - } elseif ($ord >= ord('M') && $matches[7] !== 'Z') { |
|
822 | - $tzOffset = ($ord - ord('M')) * $oneHour; |
|
819 | + if ($ord<ord('M')) { |
|
820 | + $tzOffset = (ord('A')-$ord-1)*$oneHour; |
|
821 | + } elseif ($ord>=ord('M') && $matches[7] !== 'Z') { |
|
822 | + $tzOffset = ($ord-ord('M'))*$oneHour; |
|
823 | 823 | } elseif ($matches[7] === 'Z') { |
824 | 824 | $tzOffset = 0; |
825 | 825 | } |
@@ -837,8 +837,8 @@ discard block |
||
837 | 837 | if (preg_match("~(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})(.*)~", $dateString, $matches)) { |
838 | 838 | $this->unix = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); |
839 | 839 | if (substr($matches[7], 0, 1) == '+' || substr($matches[7], 0, 1) == '-') { |
840 | - $tzOffset = (substr($matches[7], 0, 3) * 60 + substr($matches[7], -2)) * 60; |
|
841 | - } else { |
|
840 | + $tzOffset = (substr($matches[7], 0, 3)*60+substr($matches[7], -2))*60; |
|
841 | + }else { |
|
842 | 842 | if ($matches[7] === 'Z') { |
843 | 843 | $tzOffset = 0; |
844 | 844 | } |
@@ -860,7 +860,7 @@ discard block |
||
860 | 860 | //return gmdate("r",$this->unix); |
861 | 861 | $date = gmdate('D, d M Y H:i:s', $this->unix); |
862 | 862 | if (TIME_ZONE != '') { |
863 | - $date .= ' ' . str_replace(':', '', TIME_ZONE); |
|
863 | + $date .= ' '.str_replace(':', '', TIME_ZONE); |
|
864 | 864 | } |
865 | 865 | |
866 | 866 | return $date; |
@@ -874,7 +874,7 @@ discard block |
||
874 | 874 | public function iso8601() |
875 | 875 | { |
876 | 876 | $date = gmdate("Y-m-d\TH:i:sO", $this->unix); |
877 | - $date = substr($date, 0, 22) . ':' . substr($date, -2); |
|
877 | + $date = substr($date, 0, 22).':'.substr($date, -2); |
|
878 | 878 | if (TIME_ZONE != '') { |
879 | 879 | $date = str_replace('+00:00', TIME_ZONE, $date); |
880 | 880 | } |
@@ -909,7 +909,7 @@ discard block |
||
909 | 909 | */ |
910 | 910 | public function createFeed() |
911 | 911 | { |
912 | - $feed = "<?xml version=\"1.0\" encoding=\"" . $this->encoding . "\"?>\n"; |
|
912 | + $feed = "<?xml version=\"1.0\" encoding=\"".$this->encoding."\"?>\n"; |
|
913 | 913 | $feed .= $this->_createGeneratorComment(); |
914 | 914 | if ($this->cssStyleSheet == '') { |
915 | 915 | $cssStyleSheet = 'http://www.w3.org/2000/08/w3c-synd/style.css'; |
@@ -920,49 +920,49 @@ discard block |
||
920 | 920 | $feed .= " xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n"; |
921 | 921 | $feed .= " xmlns:slash=\"http://purl.org/rss/1.0/modules/slash/\"\n"; |
922 | 922 | $feed .= " xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n"; |
923 | - $feed .= " <channel rdf:about=\"" . $this->syndicationURL . "\">\n"; |
|
924 | - $feed .= ' <title>' . htmlspecialchars($this->title) . "</title>\n"; |
|
925 | - $feed .= ' <description>' . htmlspecialchars($this->description) . "</description>\n"; |
|
926 | - $feed .= ' <link>' . $this->link . "</link>\n"; |
|
923 | + $feed .= " <channel rdf:about=\"".$this->syndicationURL."\">\n"; |
|
924 | + $feed .= ' <title>'.htmlspecialchars($this->title)."</title>\n"; |
|
925 | + $feed .= ' <description>'.htmlspecialchars($this->description)."</description>\n"; |
|
926 | + $feed .= ' <link>'.$this->link."</link>\n"; |
|
927 | 927 | if ($this->image != null) { |
928 | - $feed .= " <image rdf:resource=\"" . $this->image->url . "\">\n"; |
|
928 | + $feed .= " <image rdf:resource=\"".$this->image->url."\">\n"; |
|
929 | 929 | } |
930 | - $now = new FeedDate(); |
|
931 | - $feed .= ' <dc:date>' . htmlspecialchars($now->iso8601()) . "</dc:date>\n"; |
|
930 | + $now = new FeedDate(); |
|
931 | + $feed .= ' <dc:date>'.htmlspecialchars($now->iso8601())."</dc:date>\n"; |
|
932 | 932 | $feed .= " <items>\n"; |
933 | 933 | $feed .= " <rdf:Seq>\n"; |
934 | - for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
|
935 | - $feed .= " <rdf:li rdf:resource=\"" . htmlspecialchars($this->items[$i]->link) . "\">\n"; |
|
934 | + for ($i = 0, $iMax = count($this->items); $i<$iMax; ++$i) { |
|
935 | + $feed .= " <rdf:li rdf:resource=\"".htmlspecialchars($this->items[$i]->link)."\">\n"; |
|
936 | 936 | } |
937 | 937 | $feed .= " </rdf:Seq>\n"; |
938 | 938 | $feed .= " </items>\n"; |
939 | 939 | $feed .= " </channel>\n"; |
940 | 940 | if ($this->image != null) { |
941 | - $feed .= " <image rdf:about=\"" . $this->image->url . "\">\n"; |
|
942 | - $feed .= ' <title>' . $this->image->title . "</title>\n"; |
|
943 | - $feed .= ' <link>' . $this->image->link . "</link>\n"; |
|
944 | - $feed .= ' <url>' . $this->image->url . "</url>\n"; |
|
941 | + $feed .= " <image rdf:about=\"".$this->image->url."\">\n"; |
|
942 | + $feed .= ' <title>'.$this->image->title."</title>\n"; |
|
943 | + $feed .= ' <link>'.$this->image->link."</link>\n"; |
|
944 | + $feed .= ' <url>'.$this->image->url."</url>\n"; |
|
945 | 945 | $feed .= " </image>\n"; |
946 | 946 | } |
947 | 947 | $feed .= $this->_createAdditionalElements($this->additionalElements, ' '); |
948 | 948 | |
949 | - for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
|
950 | - $feed .= " <item rdf:about=\"" . htmlspecialchars($this->items[$i]->link) . "\">\n"; |
|
949 | + for ($i = 0, $iMax = count($this->items); $i<$iMax; ++$i) { |
|
950 | + $feed .= " <item rdf:about=\"".htmlspecialchars($this->items[$i]->link)."\">\n"; |
|
951 | 951 | //$feed.= " <dc:type>Posting</dc:type>\n"; |
952 | 952 | $feed .= " <dc:format>text/html</dc:format>\n"; |
953 | 953 | if ($this->items[$i]->date != null) { |
954 | 954 | $itemDate = new FeedDate($this->items[$i]->date); |
955 | - $feed .= ' <dc:date>' . htmlspecialchars($itemDate->iso8601()) . "</dc:date>\n"; |
|
955 | + $feed .= ' <dc:date>'.htmlspecialchars($itemDate->iso8601())."</dc:date>\n"; |
|
956 | 956 | } |
957 | 957 | if ($this->items[$i]->source != '') { |
958 | - $feed .= ' <dc:source>' . htmlspecialchars($this->items[$i]->source) . "</dc:source>\n"; |
|
958 | + $feed .= ' <dc:source>'.htmlspecialchars($this->items[$i]->source)."</dc:source>\n"; |
|
959 | 959 | } |
960 | 960 | if ($this->items[$i]->author != '') { |
961 | - $feed .= ' <dc:creator>' . htmlspecialchars($this->items[$i]->author) . "</dc:creator>\n"; |
|
961 | + $feed .= ' <dc:creator>'.htmlspecialchars($this->items[$i]->author)."</dc:creator>\n"; |
|
962 | 962 | } |
963 | - $feed .= ' <title>' . htmlspecialchars(strip_tags(strtr($this->items[$i]->title, "\n\r", ' '))) . "</title>\n"; |
|
964 | - $feed .= ' <link>' . htmlspecialchars($this->items[$i]->link) . "</link>\n"; |
|
965 | - $feed .= ' <description>' . htmlspecialchars($this->items[$i]->description) . "</description>\n"; |
|
963 | + $feed .= ' <title>'.htmlspecialchars(strip_tags(strtr($this->items[$i]->title, "\n\r", ' ')))."</title>\n"; |
|
964 | + $feed .= ' <link>'.htmlspecialchars($this->items[$i]->link)."</link>\n"; |
|
965 | + $feed .= ' <description>'.htmlspecialchars($this->items[$i]->description)."</description>\n"; |
|
966 | 966 | $feed .= $this->_createAdditionalElements($this->items[$i]->additionalElements, ' '); |
967 | 967 | $feed .= " </item>\n"; |
968 | 968 | } |
@@ -1013,79 +1013,79 @@ discard block |
||
1013 | 1013 | */ |
1014 | 1014 | public function createFeed() |
1015 | 1015 | { |
1016 | - $feed = "<?xml version=\"1.0\" encoding=\"" . $this->encoding . "\"?>\n"; |
|
1016 | + $feed = "<?xml version=\"1.0\" encoding=\"".$this->encoding."\"?>\n"; |
|
1017 | 1017 | $feed .= $this->_createGeneratorComment(); |
1018 | 1018 | $feed .= $this->_createStylesheetReferences(); |
1019 | - $feed .= "<rss version=\"" . $this->RSSVersion . "\">\n"; |
|
1019 | + $feed .= "<rss version=\"".$this->RSSVersion."\">\n"; |
|
1020 | 1020 | $feed .= " <channel>\n"; |
1021 | - $feed .= ' <title>' . FeedCreator::iTrunc(htmlspecialchars($this->title), 100) . "</title>\n"; |
|
1021 | + $feed .= ' <title>'.FeedCreator::iTrunc(htmlspecialchars($this->title), 100)."</title>\n"; |
|
1022 | 1022 | $this->descriptionTruncSize = 500; |
1023 | - $feed .= ' <description>' . $this->getDescription() . "</description>\n"; |
|
1024 | - $feed .= ' <link>' . $this->link . "</link>\n"; |
|
1023 | + $feed .= ' <description>'.$this->getDescription()."</description>\n"; |
|
1024 | + $feed .= ' <link>'.$this->link."</link>\n"; |
|
1025 | 1025 | $now = new FeedDate(); |
1026 | - $feed .= ' <lastBuildDate>' . htmlspecialchars($now->rfc822()) . "</lastBuildDate>\n"; |
|
1027 | - $feed .= ' <generator>' . FEEDCREATOR_VERSION . "</generator>\n"; |
|
1026 | + $feed .= ' <lastBuildDate>'.htmlspecialchars($now->rfc822())."</lastBuildDate>\n"; |
|
1027 | + $feed .= ' <generator>'.FEEDCREATOR_VERSION."</generator>\n"; |
|
1028 | 1028 | |
1029 | 1029 | if ($this->image != null) { |
1030 | 1030 | $feed .= " <image>\n"; |
1031 | - $feed .= ' <url>' . $this->image->url . "</url>\n"; |
|
1032 | - $feed .= ' <title>' . FeedCreator::iTrunc(htmlspecialchars($this->image->title), 100) . "</title>\n"; |
|
1033 | - $feed .= ' <link>' . $this->image->link . "</link>\n"; |
|
1031 | + $feed .= ' <url>'.$this->image->url."</url>\n"; |
|
1032 | + $feed .= ' <title>'.FeedCreator::iTrunc(htmlspecialchars($this->image->title), 100)."</title>\n"; |
|
1033 | + $feed .= ' <link>'.$this->image->link."</link>\n"; |
|
1034 | 1034 | if ($this->image->width != '') { |
1035 | - $feed .= ' <width>' . $this->image->width . "</width>\n"; |
|
1035 | + $feed .= ' <width>'.$this->image->width."</width>\n"; |
|
1036 | 1036 | } |
1037 | 1037 | if ($this->image->height != '') { |
1038 | - $feed .= ' <height>' . $this->image->height . "</height>\n"; |
|
1038 | + $feed .= ' <height>'.$this->image->height."</height>\n"; |
|
1039 | 1039 | } |
1040 | 1040 | if ($this->image->description != '') { |
1041 | - $feed .= ' <description>' . $this->image->getDescription() . "</description>\n"; |
|
1041 | + $feed .= ' <description>'.$this->image->getDescription()."</description>\n"; |
|
1042 | 1042 | } |
1043 | 1043 | $feed .= " </image>\n"; |
1044 | 1044 | } |
1045 | 1045 | if ($this->language != '') { |
1046 | - $feed .= ' <language>' . $this->language . "</language>\n"; |
|
1046 | + $feed .= ' <language>'.$this->language."</language>\n"; |
|
1047 | 1047 | } |
1048 | 1048 | if ($this->copyright != '') { |
1049 | - $feed .= ' <copyright>' . FeedCreator::iTrunc(htmlspecialchars($this->copyright), 100) . "</copyright>\n"; |
|
1049 | + $feed .= ' <copyright>'.FeedCreator::iTrunc(htmlspecialchars($this->copyright), 100)."</copyright>\n"; |
|
1050 | 1050 | } |
1051 | 1051 | if ($this->editor != '') { |
1052 | - $feed .= ' <managingEditor>' . FeedCreator::iTrunc(htmlspecialchars($this->editor), 100) . "</managingEditor>\n"; |
|
1052 | + $feed .= ' <managingEditor>'.FeedCreator::iTrunc(htmlspecialchars($this->editor), 100)."</managingEditor>\n"; |
|
1053 | 1053 | } |
1054 | 1054 | if ($this->webmaster != '') { |
1055 | - $feed .= ' <webMaster>' . FeedCreator::iTrunc(htmlspecialchars($this->webmaster), 100) . "</webMaster>\n"; |
|
1055 | + $feed .= ' <webMaster>'.FeedCreator::iTrunc(htmlspecialchars($this->webmaster), 100)."</webMaster>\n"; |
|
1056 | 1056 | } |
1057 | 1057 | if ($this->pubDate != '') { |
1058 | 1058 | $pubDate = new FeedDate($this->pubDate); |
1059 | - $feed .= ' <pubDate>' . htmlspecialchars($pubDate->rfc822()) . "</pubDate>\n"; |
|
1059 | + $feed .= ' <pubDate>'.htmlspecialchars($pubDate->rfc822())."</pubDate>\n"; |
|
1060 | 1060 | } |
1061 | 1061 | if ($this->category != '') { |
1062 | - $feed .= ' <category>' . htmlspecialchars($this->category) . "</category>\n"; |
|
1062 | + $feed .= ' <category>'.htmlspecialchars($this->category)."</category>\n"; |
|
1063 | 1063 | } |
1064 | 1064 | if ($this->docs != '') { |
1065 | - $feed .= ' <docs>' . FeedCreator::iTrunc(htmlspecialchars($this->docs), 500) . "</docs>\n"; |
|
1065 | + $feed .= ' <docs>'.FeedCreator::iTrunc(htmlspecialchars($this->docs), 500)."</docs>\n"; |
|
1066 | 1066 | } |
1067 | 1067 | if ($this->ttl != '') { |
1068 | - $feed .= ' <ttl>' . htmlspecialchars($this->ttl) . "</ttl>\n"; |
|
1068 | + $feed .= ' <ttl>'.htmlspecialchars($this->ttl)."</ttl>\n"; |
|
1069 | 1069 | } |
1070 | 1070 | if ($this->rating != '') { |
1071 | - $feed .= ' <rating>' . FeedCreator::iTrunc(htmlspecialchars($this->rating), 500) . "</rating>\n"; |
|
1071 | + $feed .= ' <rating>'.FeedCreator::iTrunc(htmlspecialchars($this->rating), 500)."</rating>\n"; |
|
1072 | 1072 | } |
1073 | 1073 | if ($this->skipHours != '') { |
1074 | - $feed .= ' <skipHours>' . htmlspecialchars($this->skipHours) . "</skipHours>\n"; |
|
1074 | + $feed .= ' <skipHours>'.htmlspecialchars($this->skipHours)."</skipHours>\n"; |
|
1075 | 1075 | } |
1076 | 1076 | if ($this->skipDays != '') { |
1077 | - $feed .= ' <skipDays>' . htmlspecialchars($this->skipDays) . "</skipDays>\n"; |
|
1077 | + $feed .= ' <skipDays>'.htmlspecialchars($this->skipDays)."</skipDays>\n"; |
|
1078 | 1078 | } |
1079 | 1079 | $feed .= $this->_createAdditionalElements($this->additionalElements, ' '); |
1080 | 1080 | |
1081 | - for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
|
1081 | + for ($i = 0, $iMax = count($this->items); $i<$iMax; ++$i) { |
|
1082 | 1082 | $feed .= " <item>\n"; |
1083 | - $feed .= ' <title>' . FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)), 100) . "</title>\n"; |
|
1084 | - $feed .= ' <link>' . htmlspecialchars($this->items[$i]->link) . "</link>\n"; |
|
1085 | - $feed .= ' <description>' . $this->items[$i]->getDescription() . "</description>\n"; |
|
1083 | + $feed .= ' <title>'.FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)), 100)."</title>\n"; |
|
1084 | + $feed .= ' <link>'.htmlspecialchars($this->items[$i]->link)."</link>\n"; |
|
1085 | + $feed .= ' <description>'.$this->items[$i]->getDescription()."</description>\n"; |
|
1086 | 1086 | |
1087 | 1087 | if ($this->items[$i]->author != '') { |
1088 | - $feed .= ' <author>' . htmlspecialchars($this->items[$i]->author) . "</author>\n"; |
|
1088 | + $feed .= ' <author>'.htmlspecialchars($this->items[$i]->author)."</author>\n"; |
|
1089 | 1089 | } |
1090 | 1090 | /* |
1091 | 1091 | // on hold |
@@ -1094,17 +1094,17 @@ discard block |
||
1094 | 1094 | } |
1095 | 1095 | */ |
1096 | 1096 | if ($this->items[$i]->category != '') { |
1097 | - $feed .= ' <category>' . htmlspecialchars($this->items[$i]->category) . "</category>\n"; |
|
1097 | + $feed .= ' <category>'.htmlspecialchars($this->items[$i]->category)."</category>\n"; |
|
1098 | 1098 | } |
1099 | 1099 | if ($this->items[$i]->comments != '') { |
1100 | - $feed .= ' <comments>' . htmlspecialchars($this->items[$i]->comments) . "</comments>\n"; |
|
1100 | + $feed .= ' <comments>'.htmlspecialchars($this->items[$i]->comments)."</comments>\n"; |
|
1101 | 1101 | } |
1102 | 1102 | if ($this->items[$i]->date != '') { |
1103 | 1103 | $itemDate = new FeedDate($this->items[$i]->date); |
1104 | - $feed .= ' <pubDate>' . htmlspecialchars($itemDate->rfc822()) . "</pubDate>\n"; |
|
1104 | + $feed .= ' <pubDate>'.htmlspecialchars($itemDate->rfc822())."</pubDate>\n"; |
|
1105 | 1105 | } |
1106 | 1106 | if ($this->items[$i]->guid != '') { |
1107 | - $feed .= ' <guid>' . htmlspecialchars($this->items[$i]->guid) . "</guid>\n"; |
|
1107 | + $feed .= ' <guid>'.htmlspecialchars($this->items[$i]->guid)."</guid>\n"; |
|
1108 | 1108 | } |
1109 | 1109 | $feed .= $this->_createAdditionalElements($this->items[$i]->additionalElements, ' '); |
1110 | 1110 | $feed .= " </item>\n"; |
@@ -1157,32 +1157,32 @@ discard block |
||
1157 | 1157 | */ |
1158 | 1158 | public function createFeed() |
1159 | 1159 | { |
1160 | - $feed = "<?xml version=\"1.0\" encoding=\"" . $this->encoding . "\"?>\n"; |
|
1160 | + $feed = "<?xml version=\"1.0\" encoding=\"".$this->encoding."\"?>\n"; |
|
1161 | 1161 | $feed .= $this->_createStylesheetReferences(); |
1162 | 1162 | $feed .= "<feed version=\"0.1\" xmlns=\"http://example.com/newformat#\">\n"; |
1163 | - $feed .= ' <title>' . FeedCreator::iTrunc(htmlspecialchars($this->title), 100) . "</title>\n"; |
|
1163 | + $feed .= ' <title>'.FeedCreator::iTrunc(htmlspecialchars($this->title), 100)."</title>\n"; |
|
1164 | 1164 | $this->truncSize = 500; |
1165 | - $feed .= ' <subtitle>' . $this->getDescription() . "</subtitle>\n"; |
|
1166 | - $feed .= ' <link>' . $this->link . "</link>\n"; |
|
1167 | - for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
|
1165 | + $feed .= ' <subtitle>'.$this->getDescription()."</subtitle>\n"; |
|
1166 | + $feed .= ' <link>'.$this->link."</link>\n"; |
|
1167 | + for ($i = 0, $iMax = count($this->items); $i<$iMax; ++$i) { |
|
1168 | 1168 | $feed .= " <entry>\n"; |
1169 | - $feed .= ' <title>' . FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)), 100) . "</title>\n"; |
|
1170 | - $feed .= ' <link>' . htmlspecialchars($this->items[$i]->link) . "</link>\n"; |
|
1169 | + $feed .= ' <title>'.FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)), 100)."</title>\n"; |
|
1170 | + $feed .= ' <link>'.htmlspecialchars($this->items[$i]->link)."</link>\n"; |
|
1171 | 1171 | $itemDate = new FeedDate($this->items[$i]->date); |
1172 | - $feed .= ' <created>' . htmlspecialchars($itemDate->iso8601()) . "</created>\n"; |
|
1173 | - $feed .= ' <issued>' . htmlspecialchars($itemDate->iso8601()) . "</issued>\n"; |
|
1174 | - $feed .= ' <modified>' . htmlspecialchars($itemDate->iso8601()) . "</modified>\n"; |
|
1175 | - $feed .= ' <id>' . htmlspecialchars($this->items[$i]->guid) . "</id>\n"; |
|
1172 | + $feed .= ' <created>'.htmlspecialchars($itemDate->iso8601())."</created>\n"; |
|
1173 | + $feed .= ' <issued>'.htmlspecialchars($itemDate->iso8601())."</issued>\n"; |
|
1174 | + $feed .= ' <modified>'.htmlspecialchars($itemDate->iso8601())."</modified>\n"; |
|
1175 | + $feed .= ' <id>'.htmlspecialchars($this->items[$i]->guid)."</id>\n"; |
|
1176 | 1176 | if ($this->items[$i]->author != '') { |
1177 | 1177 | $feed .= " <author>\n"; |
1178 | - $feed .= ' <name>' . htmlspecialchars($this->items[$i]->author) . "</name>\n"; |
|
1178 | + $feed .= ' <name>'.htmlspecialchars($this->items[$i]->author)."</name>\n"; |
|
1179 | 1179 | if ($this->items[$i]->authorEmail != '') { |
1180 | - $feed .= ' <email>' . $this->items[$i]->authorEmail . "</email>\n"; |
|
1180 | + $feed .= ' <email>'.$this->items[$i]->authorEmail."</email>\n"; |
|
1181 | 1181 | } |
1182 | 1182 | $feed .= " </author>\n"; |
1183 | 1183 | } |
1184 | 1184 | $feed .= " <content type=\"text/html\" xml:lang=\"en-us\">\n"; |
1185 | - $feed .= " <div xmlns=\"http://www.w3.org/1999/xhtml\">" . $this->items[$i]->getDescription() . "</div>\n"; |
|
1185 | + $feed .= " <div xmlns=\"http://www.w3.org/1999/xhtml\">".$this->items[$i]->getDescription()."</div>\n"; |
|
1186 | 1186 | $feed .= " </content>\n"; |
1187 | 1187 | $feed .= " </entry>\n"; |
1188 | 1188 | } |
@@ -1224,50 +1224,50 @@ discard block |
||
1224 | 1224 | */ |
1225 | 1225 | public function createFeed() |
1226 | 1226 | { |
1227 | - $feed = "<?xml version=\"1.0\" encoding=\"" . $this->encoding . "\"?>\n"; |
|
1227 | + $feed = "<?xml version=\"1.0\" encoding=\"".$this->encoding."\"?>\n"; |
|
1228 | 1228 | $feed .= $this->_createGeneratorComment(); |
1229 | 1229 | $feed .= $this->_createStylesheetReferences(); |
1230 | 1230 | $feed .= "<feed version=\"0.3\" xmlns=\"http://purl.org/atom/ns#\""; |
1231 | 1231 | if ($this->language != '') { |
1232 | - $feed .= " xml:lang=\"" . $this->language . "\""; |
|
1232 | + $feed .= " xml:lang=\"".$this->language."\""; |
|
1233 | 1233 | } |
1234 | 1234 | $feed .= ">\n"; |
1235 | - $feed .= ' <title>' . htmlspecialchars($this->title) . "</title>\n"; |
|
1236 | - $feed .= ' <tagline>' . htmlspecialchars($this->description) . "</tagline>\n"; |
|
1237 | - $feed .= " <link rel=\"alternate\" type=\"text/html\" href=\"" . htmlspecialchars($this->link) . "\">\n"; |
|
1238 | - $feed .= ' <id>' . htmlspecialchars($this->link) . "</id>\n"; |
|
1239 | - $now = new FeedDate(); |
|
1240 | - $feed .= ' <modified>' . htmlspecialchars($now->iso8601()) . "</modified>\n"; |
|
1235 | + $feed .= ' <title>'.htmlspecialchars($this->title)."</title>\n"; |
|
1236 | + $feed .= ' <tagline>'.htmlspecialchars($this->description)."</tagline>\n"; |
|
1237 | + $feed .= " <link rel=\"alternate\" type=\"text/html\" href=\"".htmlspecialchars($this->link)."\">\n"; |
|
1238 | + $feed .= ' <id>'.htmlspecialchars($this->link)."</id>\n"; |
|
1239 | + $now = new FeedDate(); |
|
1240 | + $feed .= ' <modified>'.htmlspecialchars($now->iso8601())."</modified>\n"; |
|
1241 | 1241 | if ($this->editor != '') { |
1242 | 1242 | $feed .= " <author>\n"; |
1243 | - $feed .= ' <name>' . $this->editor . "</name>\n"; |
|
1243 | + $feed .= ' <name>'.$this->editor."</name>\n"; |
|
1244 | 1244 | if ($this->editorEmail != '') { |
1245 | - $feed .= ' <email>' . $this->editorEmail . "</email>\n"; |
|
1245 | + $feed .= ' <email>'.$this->editorEmail."</email>\n"; |
|
1246 | 1246 | } |
1247 | 1247 | $feed .= " </author>\n"; |
1248 | 1248 | } |
1249 | - $feed .= ' <generator>' . FEEDCREATOR_VERSION . "</generator>\n"; |
|
1249 | + $feed .= ' <generator>'.FEEDCREATOR_VERSION."</generator>\n"; |
|
1250 | 1250 | $feed .= $this->_createAdditionalElements($this->additionalElements, ' '); |
1251 | - for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
|
1251 | + for ($i = 0, $iMax = count($this->items); $i<$iMax; ++$i) { |
|
1252 | 1252 | $feed .= " <entry>\n"; |
1253 | - $feed .= ' <title>' . htmlspecialchars(strip_tags($this->items[$i]->title)) . "</title>\n"; |
|
1254 | - $feed .= " <link rel=\"alternate\" type=\"text/html\" href=\"" . htmlspecialchars($this->items[$i]->link) . "\">\n"; |
|
1253 | + $feed .= ' <title>'.htmlspecialchars(strip_tags($this->items[$i]->title))."</title>\n"; |
|
1254 | + $feed .= " <link rel=\"alternate\" type=\"text/html\" href=\"".htmlspecialchars($this->items[$i]->link)."\">\n"; |
|
1255 | 1255 | if ($this->items[$i]->date == '') { |
1256 | 1256 | $this->items[$i]->date = time(); |
1257 | 1257 | } |
1258 | 1258 | $itemDate = new FeedDate($this->items[$i]->date); |
1259 | - $feed .= ' <created>' . htmlspecialchars($itemDate->iso8601()) . "</created>\n"; |
|
1260 | - $feed .= ' <issued>' . htmlspecialchars($itemDate->iso8601()) . "</issued>\n"; |
|
1261 | - $feed .= ' <modified>' . htmlspecialchars($itemDate->iso8601()) . "</modified>\n"; |
|
1262 | - $feed .= ' <id>' . htmlspecialchars($this->items[$i]->link) . "</id>\n"; |
|
1259 | + $feed .= ' <created>'.htmlspecialchars($itemDate->iso8601())."</created>\n"; |
|
1260 | + $feed .= ' <issued>'.htmlspecialchars($itemDate->iso8601())."</issued>\n"; |
|
1261 | + $feed .= ' <modified>'.htmlspecialchars($itemDate->iso8601())."</modified>\n"; |
|
1262 | + $feed .= ' <id>'.htmlspecialchars($this->items[$i]->link)."</id>\n"; |
|
1263 | 1263 | $feed .= $this->_createAdditionalElements($this->items[$i]->additionalElements, ' '); |
1264 | 1264 | if ($this->items[$i]->author != '') { |
1265 | 1265 | $feed .= " <author>\n"; |
1266 | - $feed .= ' <name>' . htmlspecialchars($this->items[$i]->author) . "</name>\n"; |
|
1266 | + $feed .= ' <name>'.htmlspecialchars($this->items[$i]->author)."</name>\n"; |
|
1267 | 1267 | $feed .= " </author>\n"; |
1268 | 1268 | } |
1269 | 1269 | if ($this->items[$i]->description != '') { |
1270 | - $feed .= ' <summary>' . htmlspecialchars($this->items[$i]->description) . "</summary>\n"; |
|
1270 | + $feed .= ' <summary>'.htmlspecialchars($this->items[$i]->description)."</summary>\n"; |
|
1271 | 1271 | } |
1272 | 1272 | $feed .= " </entry>\n"; |
1273 | 1273 | } |
@@ -1312,23 +1312,23 @@ discard block |
||
1312 | 1312 | //$line = rtrim($line); // remove trailing white space -> no =20\r\n necessary |
1313 | 1313 | $linlen = strlen($line); |
1314 | 1314 | $newline = ''; |
1315 | - for ($i = 0; $i < $linlen; ++$i) { |
|
1315 | + for ($i = 0; $i<$linlen; ++$i) { |
|
1316 | 1316 | $c = substr($line, $i, 1); |
1317 | 1317 | $dec = ord($c); |
1318 | - if (($dec == 32) && ($i == ($linlen - 1))) { // convert space at eol only |
|
1318 | + if (($dec == 32) && ($i == ($linlen-1))) { // convert space at eol only |
|
1319 | 1319 | $c = '=20'; |
1320 | - } elseif (($dec == 61) || ($dec < 32) || ($dec > 126)) { // always encode "\t", which is *not* required |
|
1321 | - $h2 = floor($dec / 16); |
|
1322 | - $h1 = floor($dec % 16); |
|
1323 | - $c = $escape . $hex["$h2"] . $hex["$h1"]; |
|
1320 | + } elseif (($dec == 61) || ($dec<32) || ($dec>126)) { // always encode "\t", which is *not* required |
|
1321 | + $h2 = floor($dec/16); |
|
1322 | + $h1 = floor($dec%16); |
|
1323 | + $c = $escape.$hex["$h2"].$hex["$h1"]; |
|
1324 | 1324 | } |
1325 | - if ((strlen($newline) + strlen($c)) >= $line_max) { // CRLF is not counted |
|
1326 | - $output .= $newline . $escape . $eol; // soft line break; " =\r\n" is okay |
|
1325 | + if ((strlen($newline)+strlen($c))>=$line_max) { // CRLF is not counted |
|
1326 | + $output .= $newline.$escape.$eol; // soft line break; " =\r\n" is okay |
|
1327 | 1327 | $newline = ''; |
1328 | 1328 | } |
1329 | 1329 | $newline .= $c; |
1330 | 1330 | } // end of for |
1331 | - $output .= $newline . $eol; |
|
1331 | + $output .= $newline.$eol; |
|
1332 | 1332 | } |
1333 | 1333 | |
1334 | 1334 | return trim($output); |
@@ -1340,23 +1340,23 @@ discard block |
||
1340 | 1340 | */ |
1341 | 1341 | public function createFeed() |
1342 | 1342 | { |
1343 | - for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
|
1343 | + for ($i = 0, $iMax = count($this->items); $i<$iMax; ++$i) { |
|
1344 | 1344 | if ($this->items[$i]->author != '') { |
1345 | 1345 | $from = $this->items[$i]->author; |
1346 | - } else { |
|
1346 | + }else { |
|
1347 | 1347 | $from = $this->title; |
1348 | 1348 | } |
1349 | 1349 | $itemDate = new FeedDate($this->items[$i]->date); |
1350 | - $feed .= 'From ' . strtr(MBOXCreator::qp_enc($from), ' ', '_') . ' ' . date('D M d H:i:s Y', $itemDate->unix()) . "\n"; |
|
1350 | + $feed .= 'From '.strtr(MBOXCreator::qp_enc($from), ' ', '_').' '.date('D M d H:i:s Y', $itemDate->unix())."\n"; |
|
1351 | 1351 | $feed .= "Content-Type: text/plain;\n"; |
1352 | - $feed .= " charset=\"" . $this->encoding . "\"\n"; |
|
1352 | + $feed .= " charset=\"".$this->encoding."\"\n"; |
|
1353 | 1353 | $feed .= "Content-Transfer-Encoding: quoted-printable\n"; |
1354 | 1354 | $feed .= "Content-Type: text/plain\n"; |
1355 | - $feed .= "From: \"" . MBOXCreator::qp_enc($from) . "\"\n"; |
|
1356 | - $feed .= 'Date: ' . $itemDate->rfc822() . "\n"; |
|
1357 | - $feed .= 'Subject: ' . MBOXCreator::qp_enc(FeedCreator::iTrunc($this->items[$i]->title, 100)) . "\n"; |
|
1355 | + $feed .= "From: \"".MBOXCreator::qp_enc($from)."\"\n"; |
|
1356 | + $feed .= 'Date: '.$itemDate->rfc822()."\n"; |
|
1357 | + $feed .= 'Subject: '.MBOXCreator::qp_enc(FeedCreator::iTrunc($this->items[$i]->title, 100))."\n"; |
|
1358 | 1358 | $feed .= "\n"; |
1359 | - $body = chunk_split(MBOXCreator::qp_enc($this->items[$i]->description)); |
|
1359 | + $body = chunk_split(MBOXCreator::qp_enc($this->items[$i]->description)); |
|
1360 | 1360 | $feed .= preg_replace("~\nFrom ([^\n]*)(\n?)~", "\n>From $1$2\n", $body); |
1361 | 1361 | $feed .= "\n"; |
1362 | 1362 | $feed .= "\n"; |
@@ -1375,7 +1375,7 @@ discard block |
||
1375 | 1375 | { |
1376 | 1376 | $fileInfo = pathinfo($_SERVER['PHP_SELF']); |
1377 | 1377 | |
1378 | - return substr($fileInfo['basename'], 0, -(strlen($fileInfo['extension']) + 1)) . '.mbox'; |
|
1378 | + return substr($fileInfo['basename'], 0, -(strlen($fileInfo['extension'])+1)).'.mbox'; |
|
1379 | 1379 | } |
1380 | 1380 | } |
1381 | 1381 | |
@@ -1401,35 +1401,35 @@ discard block |
||
1401 | 1401 | */ |
1402 | 1402 | public function createFeed() |
1403 | 1403 | { |
1404 | - $feed = "<?xml version=\"1.0\" encoding=\"" . $this->encoding . "\"?>\n"; |
|
1404 | + $feed = "<?xml version=\"1.0\" encoding=\"".$this->encoding."\"?>\n"; |
|
1405 | 1405 | $feed .= $this->_createGeneratorComment(); |
1406 | 1406 | $feed .= $this->_createStylesheetReferences(); |
1407 | 1407 | $feed .= "<opml xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n"; |
1408 | 1408 | $feed .= " <head>\n"; |
1409 | - $feed .= ' <title>' . htmlspecialchars($this->title) . "</title>\n"; |
|
1409 | + $feed .= ' <title>'.htmlspecialchars($this->title)."</title>\n"; |
|
1410 | 1410 | if ($this->pubDate != '') { |
1411 | 1411 | $date = new FeedDate($this->pubDate); |
1412 | - $feed .= ' <dateCreated>' . $date->rfc822() . "</dateCreated>\n"; |
|
1412 | + $feed .= ' <dateCreated>'.$date->rfc822()."</dateCreated>\n"; |
|
1413 | 1413 | } |
1414 | 1414 | if ($this->lastBuildDate != '') { |
1415 | 1415 | $date = new FeedDate($this->lastBuildDate); |
1416 | - $feed .= ' <dateModified>' . $date->rfc822() . "</dateModified>\n"; |
|
1416 | + $feed .= ' <dateModified>'.$date->rfc822()."</dateModified>\n"; |
|
1417 | 1417 | } |
1418 | 1418 | if ($this->editor != '') { |
1419 | - $feed .= ' <ownerName>' . $this->editor . "</ownerName>\n"; |
|
1419 | + $feed .= ' <ownerName>'.$this->editor."</ownerName>\n"; |
|
1420 | 1420 | } |
1421 | 1421 | if ($this->editorEmail != '') { |
1422 | - $feed .= ' <ownerEmail>' . $this->editorEmail . "</ownerEmail>\n"; |
|
1422 | + $feed .= ' <ownerEmail>'.$this->editorEmail."</ownerEmail>\n"; |
|
1423 | 1423 | } |
1424 | 1424 | $feed .= " </head>\n"; |
1425 | 1425 | $feed .= " <body>\n"; |
1426 | - for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
|
1426 | + for ($i = 0, $iMax = count($this->items); $i<$iMax; ++$i) { |
|
1427 | 1427 | $feed .= " <outline type=\"rss\" "; |
1428 | 1428 | $title = htmlspecialchars(strip_tags(strtr($this->items[$i]->title, "\n\r", ' '))); |
1429 | - $feed .= " title=\"" . $title . "\""; |
|
1430 | - $feed .= " text=\"" . $title . "\""; |
|
1429 | + $feed .= " title=\"".$title."\""; |
|
1430 | + $feed .= " text=\"".$title."\""; |
|
1431 | 1431 | //$feed.= " description=\"".htmlspecialchars($this->items[$i]->description)."\""; |
1432 | - $feed .= " url=\"" . htmlspecialchars($this->items[$i]->link) . "\""; |
|
1432 | + $feed .= " url=\"".htmlspecialchars($this->items[$i]->link)."\""; |
|
1433 | 1433 | $feed .= ">\n"; |
1434 | 1434 | } |
1435 | 1435 | $feed .= " </body>\n"; |
@@ -1513,7 +1513,7 @@ discard block |
||
1513 | 1513 | |
1514 | 1514 | //if no stylePrefix is set, generate it yourself depending on the script name |
1515 | 1515 | if ($this->stylePrefix == '') { |
1516 | - $this->stylePrefix = str_replace('.', '_', $this->_generateFilename()) . '_'; |
|
1516 | + $this->stylePrefix = str_replace('.', '_', $this->_generateFilename()).'_'; |
|
1517 | 1517 | } |
1518 | 1518 | |
1519 | 1519 | //set an openInNewWindow_token_to be inserted or not |
@@ -1524,49 +1524,49 @@ discard block |
||
1524 | 1524 | // use this array to put the lines in and implode later with "document.write" javascript |
1525 | 1525 | $feedArray = []; |
1526 | 1526 | if ($this->image != null) { |
1527 | - $imageStr = "<a href='" . $this->image->link . "'" . $targetInsert . '>' . "<img src='" . $this->image->url . "' border='0' alt='" . FeedCreator::iTrunc(htmlspecialchars($this->image->title), 100) . "' align='" . $this->imageAlign . "' "; |
|
1527 | + $imageStr = "<a href='".$this->image->link."'".$targetInsert.'>'."<img src='".$this->image->url."' border='0' alt='".FeedCreator::iTrunc(htmlspecialchars($this->image->title), 100)."' align='".$this->imageAlign."' "; |
|
1528 | 1528 | if ($this->image->width) { |
1529 | - $imageStr .= " width='" . $this->image->width . "' "; |
|
1529 | + $imageStr .= " width='".$this->image->width."' "; |
|
1530 | 1530 | } |
1531 | 1531 | if ($this->image->height) { |
1532 | - $imageStr .= " height='" . $this->image->height . "' "; |
|
1532 | + $imageStr .= " height='".$this->image->height."' "; |
|
1533 | 1533 | } |
1534 | - $imageStr .= '></a>'; |
|
1534 | + $imageStr .= '></a>'; |
|
1535 | 1535 | $feedArray[] = $imageStr; |
1536 | 1536 | } |
1537 | 1537 | |
1538 | 1538 | if ($this->title) { |
1539 | - $feedArray[] = "<div class='" . $this->stylePrefix . "title'><a href='" . $this->link . "' " . $targetInsert . " class='" . $this->stylePrefix . "title'>" . FeedCreator::iTrunc(htmlspecialchars($this->title), 100) . '</a></div>'; |
|
1539 | + $feedArray[] = "<div class='".$this->stylePrefix."title'><a href='".$this->link."' ".$targetInsert." class='".$this->stylePrefix."title'>".FeedCreator::iTrunc(htmlspecialchars($this->title), 100).'</a></div>'; |
|
1540 | 1540 | } |
1541 | 1541 | if ($this->getDescription()) { |
1542 | - $feedArray[] = "<div class='" . $this->stylePrefix . "description'>" . str_replace(']]>', '', str_replace('<![CDATA[', '', $this->getDescription())) . '</div>'; |
|
1542 | + $feedArray[] = "<div class='".$this->stylePrefix."description'>".str_replace(']]>', '', str_replace('<![CDATA[', '', $this->getDescription())).'</div>'; |
|
1543 | 1543 | } |
1544 | 1544 | |
1545 | 1545 | if ($this->header) { |
1546 | - $feedArray[] = "<div class='" . $this->stylePrefix . "header'>" . $this->header . '</div>'; |
|
1546 | + $feedArray[] = "<div class='".$this->stylePrefix."header'>".$this->header.'</div>'; |
|
1547 | 1547 | } |
1548 | 1548 | |
1549 | - for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) { |
|
1550 | - if ($this->separator && $i > 0) { |
|
1551 | - $feedArray[] = "<div class='" . $this->stylePrefix . "separator'>" . $this->separator . '</div>'; |
|
1549 | + for ($i = 0, $iMax = count($this->items); $i<$iMax; ++$i) { |
|
1550 | + if ($this->separator && $i>0) { |
|
1551 | + $feedArray[] = "<div class='".$this->stylePrefix."separator'>".$this->separator.'</div>'; |
|
1552 | 1552 | } |
1553 | 1553 | |
1554 | 1554 | if ($this->items[$i]->title) { |
1555 | 1555 | if ($this->items[$i]->link) { |
1556 | - $feedArray[] = "<div class='" . $this->stylePrefix . "item_title'><a href='" . $this->items[$i]->link . "' class='" . $this->stylePrefix . "item_title'" . $targetInsert . '>' . FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)), 100) . '</a></div>'; |
|
1557 | - } else { |
|
1558 | - $feedArray[] = "<div class='" . $this->stylePrefix . "item_title'>" . FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)), 100) . '</div>'; |
|
1556 | + $feedArray[] = "<div class='".$this->stylePrefix."item_title'><a href='".$this->items[$i]->link."' class='".$this->stylePrefix."item_title'".$targetInsert.'>'.FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)), 100).'</a></div>'; |
|
1557 | + }else { |
|
1558 | + $feedArray[] = "<div class='".$this->stylePrefix."item_title'>".FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)), 100).'</div>'; |
|
1559 | 1559 | } |
1560 | 1560 | } |
1561 | 1561 | if ($this->items[$i]->getDescription()) { |
1562 | - $feedArray[] = "<div class='" . $this->stylePrefix . "item_description'>" . str_replace(']]>', '', str_replace('<![CDATA[', '', $this->items[$i]->getDescription())) . '</div>'; |
|
1562 | + $feedArray[] = "<div class='".$this->stylePrefix."item_description'>".str_replace(']]>', '', str_replace('<![CDATA[', '', $this->items[$i]->getDescription())).'</div>'; |
|
1563 | 1563 | } |
1564 | 1564 | } |
1565 | 1565 | if ($this->footer) { |
1566 | - $feedArray[] = "<div class='" . $this->stylePrefix . "footer'>" . $this->footer . '</div>'; |
|
1566 | + $feedArray[] = "<div class='".$this->stylePrefix."footer'>".$this->footer.'</div>'; |
|
1567 | 1567 | } |
1568 | 1568 | |
1569 | - $feed = '' . implode($feedArray, "\r\n"); |
|
1569 | + $feed = ''.implode($feedArray, "\r\n"); |
|
1570 | 1570 | |
1571 | 1571 | return $feed; |
1572 | 1572 | } |
@@ -1582,7 +1582,7 @@ discard block |
||
1582 | 1582 | { |
1583 | 1583 | $fileInfo = pathinfo($_SERVER['PHP_SELF']); |
1584 | 1584 | |
1585 | - return substr($fileInfo['basename'], 0, -(strlen($fileInfo['extension']) + 1)) . '.html'; |
|
1585 | + return substr($fileInfo['basename'], 0, -(strlen($fileInfo['extension'])+1)).'.html'; |
|
1586 | 1586 | } |
1587 | 1587 | } |
1588 | 1588 | |
@@ -1614,7 +1614,7 @@ discard block |
||
1614 | 1614 | |
1615 | 1615 | $jsFeed = ''; |
1616 | 1616 | foreach ($feedArray as $value) { |
1617 | - $jsFeed .= "document.write('" . trim(addslashes($value)) . "');\n"; |
|
1617 | + $jsFeed .= "document.write('".trim(addslashes($value))."');\n"; |
|
1618 | 1618 | } |
1619 | 1619 | |
1620 | 1620 | return $jsFeed; |
@@ -1631,7 +1631,7 @@ discard block |
||
1631 | 1631 | { |
1632 | 1632 | $fileInfo = pathinfo($_SERVER['PHP_SELF']); |
1633 | 1633 | |
1634 | - return substr($fileInfo['basename'], 0, -(strlen($fileInfo['extension']) + 1)) . '.js'; |
|
1634 | + return substr($fileInfo['basename'], 0, -(strlen($fileInfo['extension'])+1)).'.js'; |
|
1635 | 1635 | } |
1636 | 1636 | } |
1637 | 1637 |
@@ -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 ($category_id == 0) { |
|
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 ($category_id == 0) { |
|
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 ($category_id == 0) { |
|
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 ($category_id == 0) { |
|
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 ($category_id == 0) { |
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(); |
@@ -29,7 +29,7 @@ |
||
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 |
@@ -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 | |
@@ -42,24 +42,24 @@ discard block |
||
42 | 42 | $i = 0; |
43 | 43 | $adminmenu[$i]['title'] = _AM_MODULEADMIN_HOME; |
44 | 44 | $adminmenu[$i]['link'] = 'admin/index.php'; |
45 | -$adminmenu[$i]['icon'] = $pathIcon32 . '/home.png'; |
|
45 | +$adminmenu[$i]['icon'] = $pathIcon32.'/home.png'; |
|
46 | 46 | ++$i; |
47 | 47 | $adminmenu[$i]['title'] = planet_constant('MI_ADMENU_INDEX'); |
48 | 48 | $adminmenu[$i]['link'] = 'admin/main.php'; |
49 | -$adminmenu[$i]['icon'] = $pathIcon32 . '/manage.png'; |
|
49 | +$adminmenu[$i]['icon'] = $pathIcon32.'/manage.png'; |
|
50 | 50 | |
51 | 51 | ++$i; |
52 | 52 | $adminmenu[$i]['title'] = planet_constant('MI_ADMENU_CATEGORY'); |
53 | 53 | $adminmenu[$i]['link'] = 'admin/admin.category.php'; |
54 | -$adminmenu[$i]['icon'] = $pathIcon32 . '/category.png'; |
|
54 | +$adminmenu[$i]['icon'] = $pathIcon32.'/category.png'; |
|
55 | 55 | ++$i; |
56 | 56 | $adminmenu[$i]['title'] = planet_constant('MI_ADMENU_BLOG'); |
57 | 57 | $adminmenu[$i]['link'] = 'admin/admin.blog.php'; |
58 | -$adminmenu[$i]['icon'] = $pathIcon32 . '/translations.png'; |
|
58 | +$adminmenu[$i]['icon'] = $pathIcon32.'/translations.png'; |
|
59 | 59 | ++$i; |
60 | 60 | $adminmenu[$i]['title'] = planet_constant('MI_ADMENU_ARTICLE'); |
61 | 61 | $adminmenu[$i]['link'] = 'admin/admin.article.php'; |
62 | -$adminmenu[$i]['icon'] = $pathIcon32 . '/content.png'; |
|
62 | +$adminmenu[$i]['icon'] = $pathIcon32.'/content.png'; |
|
63 | 63 | //++$i; |
64 | 64 | //$adminmenu[$i]['title'] = planet_constant("MI_ADMENU_BLOCK"); |
65 | 65 | //$adminmenu[$i]['link'] = "admin/admin.block.php"; |
@@ -67,4 +67,4 @@ discard block |
||
67 | 67 | ++$i; |
68 | 68 | $adminmenu[$i]['title'] = _AM_MODULEADMIN_ABOUT; |
69 | 69 | $adminmenu[$i]['link'] = 'admin/about.php'; |
70 | -$adminmenu[$i]['icon'] = $pathIcon32 . '/about.png'; |
|
70 | +$adminmenu[$i]['icon'] = $pathIcon32.'/about.png'; |
@@ -41,136 +41,136 @@ |
||
41 | 41 | $blogHandler = xoops_getModuleHandler('blog', $GLOBALS['moddirname']); |
42 | 42 | |
43 | 43 | switch ($op) { |
44 | - case 'save': |
|
45 | - if ($cat_id) { |
|
46 | - $category_obj = $categoryHandler->get($cat_id); |
|
47 | - } else { |
|
48 | - $category_obj = $categoryHandler->create(); |
|
49 | - } |
|
50 | - |
|
51 | - $category_obj->setVar('cat_title', $_POST['cat_title']); |
|
52 | - $category_obj->setVar('cat_order', $_POST['cat_order']); |
|
53 | - |
|
54 | - if (!$categoryHandler->insert($category_obj)) { |
|
55 | - $message = planet_constant('AM_ERROR'); |
|
56 | - } else { |
|
57 | - $message = planet_constant('AM_DBUPDATED'); |
|
58 | - } |
|
59 | - redirect_header('admin.category.php', 2, $message); |
|
60 | - |
|
61 | - // no break |
|
62 | - case 'del': |
|
63 | - if (!is_array($cat_id)) { |
|
64 | - $cat_id = [$cat_id]; |
|
65 | - } |
|
66 | - foreach ($cat_id as $cid) { |
|
67 | - $category_obj = $categoryHandler->get($cid); |
|
68 | - if (!$categoryHandler->delete($category_obj)) { |
|
69 | - } |
|
70 | - } |
|
71 | - $message = planet_constant('AM_DBUPDATED'); |
|
72 | - redirect_header('admin.category.php', 2, $message); |
|
73 | - |
|
74 | - // no break |
|
75 | - case 'order': |
|
76 | - $count = count($_POST['cat_order']); |
|
77 | - for ($i = 0; $i < $count; ++$i) { |
|
78 | - $category_obj = $categoryHandler->get($_POST['cat'][$i]); |
|
79 | - $category_obj->setVar('cat_order', $_POST['cat_order'][$i]); |
|
80 | - $categoryHandler->insert($category_obj, true); |
|
81 | - unset($category_obj); |
|
82 | - } |
|
83 | - $message = planet_constant('AM_DBUPDATED'); |
|
84 | - redirect_header('admin.category.php', 2, $message); |
|
85 | - |
|
86 | - // no break |
|
87 | - case 'edit': |
|
88 | - $category_obj = $categoryHandler->get($cat_id); |
|
89 | - $form = new XoopsThemeForm(_EDIT, 'edit', xoops_getenv('PHP_SELF'), 'post', true); |
|
90 | - $form->addElement(new XoopsFormText(planet_constant('AM_TITLE'), 'cat_title', 50, 80, $category_obj->getVar('cat_title', 'E')), true); |
|
91 | - $form->addElement(new XoopsFormText(planet_constant('AM_ORDER'), 'cat_order', 5, 10, $category_obj->getVar('cat_order')), false); |
|
92 | - $form->addElement(new XoopsFormHidden('category', $cat_id)); |
|
93 | - $form->addElement(new XoopsFormHidden('op', 'save')); |
|
94 | - |
|
95 | - $button_tray = new XoopsFormElementTray('', ''); |
|
96 | - $butt_save = new XoopsFormButton('', 'submit', _SUBMIT, 'submit'); |
|
97 | - $button_tray->addElement($butt_save); |
|
98 | - $butt_cancel = new XoopsFormButton('', '', _CANCEL, 'reset'); |
|
99 | - $button_tray->addElement($butt_cancel); |
|
100 | - $form->addElement($button_tray); |
|
101 | - |
|
102 | - echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _EDIT . '</legend>'; |
|
103 | - echo '<br>'; |
|
104 | - $form->display(); |
|
105 | - echo '</fieldset>'; |
|
106 | - break; |
|
107 | - |
|
108 | - default: |
|
109 | - $crit = new Criteria('1', 1); |
|
110 | - $crit->setSort('cat_order'); |
|
111 | - $crit->setOrder('ASC'); |
|
112 | - $categories = $categoryHandler->getList($crit); |
|
113 | - $blog_counts = $blogHandler->getCountsByCategory(); |
|
114 | - foreach (array_keys($categories) as $cid) { |
|
115 | - if (!empty($blog_counts[$cid])) { |
|
116 | - $categories[$cid] .= ' (' . (int)$blog_counts[$cid] . ')'; |
|
117 | - } |
|
118 | - } |
|
119 | - |
|
120 | - echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . planet_constant('AM_LIST') . '</legend>'; |
|
121 | - echo "<br style=\"clear:both;\">"; |
|
122 | - |
|
123 | - echo "<form name='list' method='post'>"; |
|
124 | - echo "<table border='0' cellpadding='4' cellspacing='1' width='100%' class='outer'>"; |
|
125 | - echo "<tr align='center'>"; |
|
126 | - echo "<th class='bg3' width='5%'>" . planet_constant('AM_ORDER') . '</td>'; |
|
127 | - echo "<th align='left' class='bg3' width='80%'>" . planet_constant('AM_TITLE') . '</td>'; |
|
128 | - echo "<th class='bg3' width='5%'>" . planet_constant('AM_BLOGCOUNT') . '</td>'; |
|
129 | - echo "<th class='bg3' width='5%'>" . planet_constant('AM_ACTIONS') . '</td>'; |
|
130 | - // echo "<td class='bg3' width='5%'>" . _DELETE . "</td>"; |
|
131 | - |
|
132 | - echo '</tr>'; |
|
133 | - |
|
134 | - $ii = 0; |
|
135 | - foreach (array_keys($categories) as $cid) { |
|
136 | - echo "<tr class='odd' align='left'>"; |
|
137 | - echo "<td><input type='hidden' name='cat[]' value='" . $cid . "'>"; |
|
138 | - echo "<input type='text' name='cat_order[]' value='" . ($ii * 10) . "'></td>"; |
|
139 | - echo '<td>' . $categories[$cid] . '</td>'; |
|
140 | - echo "<td align='center'>" . @$blog_counts[$cid] . '</td>'; |
|
141 | - |
|
142 | - echo "<td align='center'><a href='admin.category.php?op=edit &category='" . $cid . "' title='" . _EDIT . "'><img src='" . $pathIcon16 . "/edit.png '" . "alt='" . _EDIT . "' title='" . _EDIT . "' </a> |
|
44 | + case 'save': |
|
45 | + if ($cat_id) { |
|
46 | + $category_obj = $categoryHandler->get($cat_id); |
|
47 | + } else { |
|
48 | + $category_obj = $categoryHandler->create(); |
|
49 | + } |
|
50 | + |
|
51 | + $category_obj->setVar('cat_title', $_POST['cat_title']); |
|
52 | + $category_obj->setVar('cat_order', $_POST['cat_order']); |
|
53 | + |
|
54 | + if (!$categoryHandler->insert($category_obj)) { |
|
55 | + $message = planet_constant('AM_ERROR'); |
|
56 | + } else { |
|
57 | + $message = planet_constant('AM_DBUPDATED'); |
|
58 | + } |
|
59 | + redirect_header('admin.category.php', 2, $message); |
|
60 | + |
|
61 | + // no break |
|
62 | + case 'del': |
|
63 | + if (!is_array($cat_id)) { |
|
64 | + $cat_id = [$cat_id]; |
|
65 | + } |
|
66 | + foreach ($cat_id as $cid) { |
|
67 | + $category_obj = $categoryHandler->get($cid); |
|
68 | + if (!$categoryHandler->delete($category_obj)) { |
|
69 | + } |
|
70 | + } |
|
71 | + $message = planet_constant('AM_DBUPDATED'); |
|
72 | + redirect_header('admin.category.php', 2, $message); |
|
73 | + |
|
74 | + // no break |
|
75 | + case 'order': |
|
76 | + $count = count($_POST['cat_order']); |
|
77 | + for ($i = 0; $i < $count; ++$i) { |
|
78 | + $category_obj = $categoryHandler->get($_POST['cat'][$i]); |
|
79 | + $category_obj->setVar('cat_order', $_POST['cat_order'][$i]); |
|
80 | + $categoryHandler->insert($category_obj, true); |
|
81 | + unset($category_obj); |
|
82 | + } |
|
83 | + $message = planet_constant('AM_DBUPDATED'); |
|
84 | + redirect_header('admin.category.php', 2, $message); |
|
85 | + |
|
86 | + // no break |
|
87 | + case 'edit': |
|
88 | + $category_obj = $categoryHandler->get($cat_id); |
|
89 | + $form = new XoopsThemeForm(_EDIT, 'edit', xoops_getenv('PHP_SELF'), 'post', true); |
|
90 | + $form->addElement(new XoopsFormText(planet_constant('AM_TITLE'), 'cat_title', 50, 80, $category_obj->getVar('cat_title', 'E')), true); |
|
91 | + $form->addElement(new XoopsFormText(planet_constant('AM_ORDER'), 'cat_order', 5, 10, $category_obj->getVar('cat_order')), false); |
|
92 | + $form->addElement(new XoopsFormHidden('category', $cat_id)); |
|
93 | + $form->addElement(new XoopsFormHidden('op', 'save')); |
|
94 | + |
|
95 | + $button_tray = new XoopsFormElementTray('', ''); |
|
96 | + $butt_save = new XoopsFormButton('', 'submit', _SUBMIT, 'submit'); |
|
97 | + $button_tray->addElement($butt_save); |
|
98 | + $butt_cancel = new XoopsFormButton('', '', _CANCEL, 'reset'); |
|
99 | + $button_tray->addElement($butt_cancel); |
|
100 | + $form->addElement($button_tray); |
|
101 | + |
|
102 | + echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _EDIT . '</legend>'; |
|
103 | + echo '<br>'; |
|
104 | + $form->display(); |
|
105 | + echo '</fieldset>'; |
|
106 | + break; |
|
107 | + |
|
108 | + default: |
|
109 | + $crit = new Criteria('1', 1); |
|
110 | + $crit->setSort('cat_order'); |
|
111 | + $crit->setOrder('ASC'); |
|
112 | + $categories = $categoryHandler->getList($crit); |
|
113 | + $blog_counts = $blogHandler->getCountsByCategory(); |
|
114 | + foreach (array_keys($categories) as $cid) { |
|
115 | + if (!empty($blog_counts[$cid])) { |
|
116 | + $categories[$cid] .= ' (' . (int)$blog_counts[$cid] . ')'; |
|
117 | + } |
|
118 | + } |
|
119 | + |
|
120 | + echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . planet_constant('AM_LIST') . '</legend>'; |
|
121 | + echo "<br style=\"clear:both;\">"; |
|
122 | + |
|
123 | + echo "<form name='list' method='post'>"; |
|
124 | + echo "<table border='0' cellpadding='4' cellspacing='1' width='100%' class='outer'>"; |
|
125 | + echo "<tr align='center'>"; |
|
126 | + echo "<th class='bg3' width='5%'>" . planet_constant('AM_ORDER') . '</td>'; |
|
127 | + echo "<th align='left' class='bg3' width='80%'>" . planet_constant('AM_TITLE') . '</td>'; |
|
128 | + echo "<th class='bg3' width='5%'>" . planet_constant('AM_BLOGCOUNT') . '</td>'; |
|
129 | + echo "<th class='bg3' width='5%'>" . planet_constant('AM_ACTIONS') . '</td>'; |
|
130 | + // echo "<td class='bg3' width='5%'>" . _DELETE . "</td>"; |
|
131 | + |
|
132 | + echo '</tr>'; |
|
133 | + |
|
134 | + $ii = 0; |
|
135 | + foreach (array_keys($categories) as $cid) { |
|
136 | + echo "<tr class='odd' align='left'>"; |
|
137 | + echo "<td><input type='hidden' name='cat[]' value='" . $cid . "'>"; |
|
138 | + echo "<input type='text' name='cat_order[]' value='" . ($ii * 10) . "'></td>"; |
|
139 | + echo '<td>' . $categories[$cid] . '</td>'; |
|
140 | + echo "<td align='center'>" . @$blog_counts[$cid] . '</td>'; |
|
141 | + |
|
142 | + echo "<td align='center'><a href='admin.category.php?op=edit &category='" . $cid . "' title='" . _EDIT . "'><img src='" . $pathIcon16 . "/edit.png '" . "alt='" . _EDIT . "' title='" . _EDIT . "' </a> |
|
143 | 143 | <a href='admin.category.php?op=del &category='" . $cid . "' title='" . _DELETE . "'><img src='" . $pathIcon16 . "/delete.png '" . " alt='" . _EDIT . "' title='" . _DELETE . "' </a></td>"; |
144 | - echo '</tr>'; |
|
145 | - ++$ii; |
|
146 | - } |
|
147 | - echo "<tr class='even' align='center'>"; |
|
148 | - echo "<td colspan='5'>"; |
|
149 | - echo "<input name='submit' value='" . _SUBMIT . "' type='submit'>"; |
|
150 | - echo "<input name='' value='" . _CANCEL . "' type='reset'>"; |
|
151 | - echo "<input name='op' value='order' type='hidden'>"; |
|
152 | - echo '</td>'; |
|
153 | - echo '</tr>'; |
|
154 | - echo '</table></form>'; |
|
155 | - echo "</fieldset><br style='clear:both;'>"; |
|
156 | - |
|
157 | - $form = new XoopsThemeForm(_ADD, 'mod', xoops_getenv('PHP_SELF'), 'post', true); |
|
158 | - $form->addElement(new XoopsFormText(planet_constant('AM_TITLE'), 'cat_title', 50, 80), true); |
|
159 | - $form->addElement(new XoopsFormText(planet_constant('AM_ORDER'), 'cat_order', 5, 10), false); |
|
160 | - $form->addElement(new XoopsFormHidden('op', 'save')); |
|
161 | - |
|
162 | - $button_tray = new XoopsFormElementTray('', ''); |
|
163 | - $butt_save = new XoopsFormButton('', 'submit', _SUBMIT, 'submit'); |
|
164 | - $button_tray->addElement($butt_save); |
|
165 | - $butt_cancel = new XoopsFormButton('', '', _CANCEL, 'reset'); |
|
166 | - $button_tray->addElement($butt_cancel); |
|
167 | - $form->addElement($button_tray); |
|
168 | - |
|
169 | - echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _ADD . '</legend>'; |
|
170 | - echo '<br>'; |
|
171 | - $form->display(); |
|
172 | - echo '</fieldset>'; |
|
173 | - break; |
|
144 | + echo '</tr>'; |
|
145 | + ++$ii; |
|
146 | + } |
|
147 | + echo "<tr class='even' align='center'>"; |
|
148 | + echo "<td colspan='5'>"; |
|
149 | + echo "<input name='submit' value='" . _SUBMIT . "' type='submit'>"; |
|
150 | + echo "<input name='' value='" . _CANCEL . "' type='reset'>"; |
|
151 | + echo "<input name='op' value='order' type='hidden'>"; |
|
152 | + echo '</td>'; |
|
153 | + echo '</tr>'; |
|
154 | + echo '</table></form>'; |
|
155 | + echo "</fieldset><br style='clear:both;'>"; |
|
156 | + |
|
157 | + $form = new XoopsThemeForm(_ADD, 'mod', xoops_getenv('PHP_SELF'), 'post', true); |
|
158 | + $form->addElement(new XoopsFormText(planet_constant('AM_TITLE'), 'cat_title', 50, 80), true); |
|
159 | + $form->addElement(new XoopsFormText(planet_constant('AM_ORDER'), 'cat_order', 5, 10), false); |
|
160 | + $form->addElement(new XoopsFormHidden('op', 'save')); |
|
161 | + |
|
162 | + $button_tray = new XoopsFormElementTray('', ''); |
|
163 | + $butt_save = new XoopsFormButton('', 'submit', _SUBMIT, 'submit'); |
|
164 | + $button_tray->addElement($butt_save); |
|
165 | + $butt_cancel = new XoopsFormButton('', '', _CANCEL, 'reset'); |
|
166 | + $button_tray->addElement($butt_cancel); |
|
167 | + $form->addElement($button_tray); |
|
168 | + |
|
169 | + echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _ADD . '</legend>'; |
|
170 | + echo '<br>'; |
|
171 | + $form->display(); |
|
172 | + echo '</fieldset>'; |
|
173 | + break; |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | xoops_cp_footer(); |
@@ -24,18 +24,18 @@ discard block |
||
24 | 24 | // URL: https://xoops.org // |
25 | 25 | // Project: Article Project // |
26 | 26 | // ------------------------------------------------------------------------ // |
27 | -require_once __DIR__ . '/admin_header.php'; |
|
28 | -require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
|
27 | +require_once __DIR__.'/admin_header.php'; |
|
28 | +require_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php'; |
|
29 | 29 | |
30 | 30 | xoops_cp_header(); |
31 | 31 | $adminObject = \Xmf\Module\Admin::getInstance(); |
32 | 32 | $adminObject->displayNavigation(basename(__FILE__)); |
33 | -require XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/include/vars.php'; |
|
33 | +require XOOPS_ROOT_PATH.'/modules/'.$xoopsModule->getVar('dirname').'/include/vars.php'; |
|
34 | 34 | //planet_adminmenu(1); |
35 | 35 | |
36 | 36 | $op = !empty($_POST['op']) ? $_POST['op'] : (!empty($_GET['op']) ? $_GET['op'] : ''); |
37 | 37 | $cat_id = !empty($_POST['category']) ? $_POST['category'] : (!empty($_GET['category']) ? $_GET['category'] : 0); |
38 | -$cat_id = is_array($cat_id) ? array_map('intval', $cat_id) : (int)$cat_id; |
|
38 | +$cat_id = is_array($cat_id) ? array_map('intval', $cat_id) : (int) $cat_id; |
|
39 | 39 | |
40 | 40 | $categoryHandler = xoops_getModuleHandler('category', $GLOBALS['moddirname']); |
41 | 41 | $blogHandler = xoops_getModuleHandler('blog', $GLOBALS['moddirname']); |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | case 'save': |
45 | 45 | if ($cat_id) { |
46 | 46 | $category_obj = $categoryHandler->get($cat_id); |
47 | - } else { |
|
47 | + }else { |
|
48 | 48 | $category_obj = $categoryHandler->create(); |
49 | 49 | } |
50 | 50 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | |
54 | 54 | if (!$categoryHandler->insert($category_obj)) { |
55 | 55 | $message = planet_constant('AM_ERROR'); |
56 | - } else { |
|
56 | + }else { |
|
57 | 57 | $message = planet_constant('AM_DBUPDATED'); |
58 | 58 | } |
59 | 59 | redirect_header('admin.category.php', 2, $message); |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | // no break |
75 | 75 | case 'order': |
76 | 76 | $count = count($_POST['cat_order']); |
77 | - for ($i = 0; $i < $count; ++$i) { |
|
77 | + for ($i = 0; $i<$count; ++$i) { |
|
78 | 78 | $category_obj = $categoryHandler->get($_POST['cat'][$i]); |
79 | 79 | $category_obj->setVar('cat_order', $_POST['cat_order'][$i]); |
80 | 80 | $categoryHandler->insert($category_obj, true); |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | $button_tray->addElement($butt_cancel); |
100 | 100 | $form->addElement($button_tray); |
101 | 101 | |
102 | - echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _EDIT . '</legend>'; |
|
102 | + echo "<fieldset><legend style='font-weight: bold; color: #900;'>"._EDIT.'</legend>'; |
|
103 | 103 | echo '<br>'; |
104 | 104 | $form->display(); |
105 | 105 | echo '</fieldset>'; |
@@ -113,20 +113,20 @@ discard block |
||
113 | 113 | $blog_counts = $blogHandler->getCountsByCategory(); |
114 | 114 | foreach (array_keys($categories) as $cid) { |
115 | 115 | if (!empty($blog_counts[$cid])) { |
116 | - $categories[$cid] .= ' (' . (int)$blog_counts[$cid] . ')'; |
|
116 | + $categories[$cid] .= ' ('.(int) $blog_counts[$cid].')'; |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
120 | - echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . planet_constant('AM_LIST') . '</legend>'; |
|
120 | + echo "<fieldset><legend style='font-weight: bold; color: #900;'>".planet_constant('AM_LIST').'</legend>'; |
|
121 | 121 | echo "<br style=\"clear:both;\">"; |
122 | 122 | |
123 | 123 | echo "<form name='list' method='post'>"; |
124 | 124 | echo "<table border='0' cellpadding='4' cellspacing='1' width='100%' class='outer'>"; |
125 | 125 | echo "<tr align='center'>"; |
126 | - echo "<th class='bg3' width='5%'>" . planet_constant('AM_ORDER') . '</td>'; |
|
127 | - echo "<th align='left' class='bg3' width='80%'>" . planet_constant('AM_TITLE') . '</td>'; |
|
128 | - echo "<th class='bg3' width='5%'>" . planet_constant('AM_BLOGCOUNT') . '</td>'; |
|
129 | - echo "<th class='bg3' width='5%'>" . planet_constant('AM_ACTIONS') . '</td>'; |
|
126 | + echo "<th class='bg3' width='5%'>".planet_constant('AM_ORDER').'</td>'; |
|
127 | + echo "<th align='left' class='bg3' width='80%'>".planet_constant('AM_TITLE').'</td>'; |
|
128 | + echo "<th class='bg3' width='5%'>".planet_constant('AM_BLOGCOUNT').'</td>'; |
|
129 | + echo "<th class='bg3' width='5%'>".planet_constant('AM_ACTIONS').'</td>'; |
|
130 | 130 | // echo "<td class='bg3' width='5%'>" . _DELETE . "</td>"; |
131 | 131 | |
132 | 132 | echo '</tr>'; |
@@ -134,20 +134,20 @@ discard block |
||
134 | 134 | $ii = 0; |
135 | 135 | foreach (array_keys($categories) as $cid) { |
136 | 136 | echo "<tr class='odd' align='left'>"; |
137 | - echo "<td><input type='hidden' name='cat[]' value='" . $cid . "'>"; |
|
138 | - echo "<input type='text' name='cat_order[]' value='" . ($ii * 10) . "'></td>"; |
|
139 | - echo '<td>' . $categories[$cid] . '</td>'; |
|
140 | - echo "<td align='center'>" . @$blog_counts[$cid] . '</td>'; |
|
137 | + echo "<td><input type='hidden' name='cat[]' value='".$cid."'>"; |
|
138 | + echo "<input type='text' name='cat_order[]' value='".($ii*10)."'></td>"; |
|
139 | + echo '<td>'.$categories[$cid].'</td>'; |
|
140 | + echo "<td align='center'>".@$blog_counts[$cid].'</td>'; |
|
141 | 141 | |
142 | - echo "<td align='center'><a href='admin.category.php?op=edit &category='" . $cid . "' title='" . _EDIT . "'><img src='" . $pathIcon16 . "/edit.png '" . "alt='" . _EDIT . "' title='" . _EDIT . "' </a> |
|
143 | - <a href='admin.category.php?op=del &category='" . $cid . "' title='" . _DELETE . "'><img src='" . $pathIcon16 . "/delete.png '" . " alt='" . _EDIT . "' title='" . _DELETE . "' </a></td>"; |
|
142 | + echo "<td align='center'><a href='admin.category.php?op=edit &category='".$cid."' title='"._EDIT."'><img src='".$pathIcon16."/edit.png '"."alt='"._EDIT."' title='"._EDIT."' </a> |
|
143 | + <a href='admin.category.php?op=del &category='" . $cid."' title='"._DELETE."'><img src='".$pathIcon16."/delete.png '"." alt='"._EDIT."' title='"._DELETE."' </a></td>"; |
|
144 | 144 | echo '</tr>'; |
145 | 145 | ++$ii; |
146 | 146 | } |
147 | 147 | echo "<tr class='even' align='center'>"; |
148 | 148 | echo "<td colspan='5'>"; |
149 | - echo "<input name='submit' value='" . _SUBMIT . "' type='submit'>"; |
|
150 | - echo "<input name='' value='" . _CANCEL . "' type='reset'>"; |
|
149 | + echo "<input name='submit' value='"._SUBMIT."' type='submit'>"; |
|
150 | + echo "<input name='' value='"._CANCEL."' type='reset'>"; |
|
151 | 151 | echo "<input name='op' value='order' type='hidden'>"; |
152 | 152 | echo '</td>'; |
153 | 153 | echo '</tr>'; |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | $button_tray->addElement($butt_cancel); |
167 | 167 | $form->addElement($button_tray); |
168 | 168 | |
169 | - echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _ADD . '</legend>'; |
|
169 | + echo "<fieldset><legend style='font-weight: bold; color: #900;'>"._ADD.'</legend>'; |
|
170 | 170 | echo '<br>'; |
171 | 171 | $form->display(); |
172 | 172 | echo '</fieldset>'; |
@@ -31,44 +31,44 @@ discard block |
||
31 | 31 | error_reporting(0); |
32 | 32 | |
33 | 33 | if (empty(Request::getString('print_data', '', 'POST'))) { |
34 | - //$_POST['print_data'])) |
|
34 | + //$_POST['print_data'])) |
|
35 | 35 | |
36 | - if (PlanetUtility::planetParseArguments($args_num, $args, $args_str)) { |
|
37 | - $args['article'] = @$args_num[0]; |
|
38 | - } |
|
36 | + if (PlanetUtility::planetParseArguments($args_num, $args, $args_str)) { |
|
37 | + $args['article'] = @$args_num[0]; |
|
38 | + } |
|
39 | 39 | |
40 | - $article_id = Request::getInt('article', @$args['article'], 'POST');//(int)(empty($_GET['article']) ? @$args['article'] : $_GET['article']); |
|
40 | + $article_id = Request::getInt('article', @$args['article'], 'POST');//(int)(empty($_GET['article']) ? @$args['article'] : $_GET['article']); |
|
41 | 41 | |
42 | - $articleHandler = xoops_getModuleHandler('article', $GLOBALS['moddirname']); |
|
43 | - $article_obj = $articleHandler->get($article_id); |
|
42 | + $articleHandler = xoops_getModuleHandler('article', $GLOBALS['moddirname']); |
|
43 | + $article_obj = $articleHandler->get($article_id); |
|
44 | 44 | |
45 | - $article_data = []; |
|
45 | + $article_data = []; |
|
46 | 46 | |
47 | - // title |
|
48 | - $article_data['title'] = $article_obj->getVar('art_title'); |
|
47 | + // title |
|
48 | + $article_data['title'] = $article_obj->getVar('art_title'); |
|
49 | 49 | |
50 | - $article_data['author'] = $article_obj->getVar('art_author'); |
|
50 | + $article_data['author'] = $article_obj->getVar('art_author'); |
|
51 | 51 | |
52 | - // source |
|
53 | - $article_data['source'] = $article_obj->getVar('art_link'); |
|
52 | + // source |
|
53 | + $article_data['source'] = $article_obj->getVar('art_link'); |
|
54 | 54 | |
55 | - // publish time |
|
56 | - $article_data['time'] = $article_obj->getTime('l'); |
|
55 | + // publish time |
|
56 | + $article_data['time'] = $article_obj->getTime('l'); |
|
57 | 57 | |
58 | - // summary |
|
59 | - $article_data['summary'] =& $article_obj->getSummary(); |
|
58 | + // summary |
|
59 | + $article_data['summary'] =& $article_obj->getSummary(); |
|
60 | 60 | |
61 | - // text of page |
|
62 | - $article_data['text'] = $article_obj->getVar('art_content'); |
|
61 | + // text of page |
|
62 | + $article_data['text'] = $article_obj->getVar('art_content'); |
|
63 | 63 | |
64 | - $print_data['title'] = $article_data['title']; |
|
65 | - $print_data['author'] = $article_data['author']; |
|
66 | - $print_data['date'] = $article_data['time']; |
|
67 | - $print_data['summary'] = empty($article_data['summary']) ? '' : planet_constant('MD_SUMMARY') . ': ' . $article_data['summary']; |
|
68 | - $print_data['content'] = $article_data['text']; |
|
69 | - $print_data['url'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/view.article.php' . URL_DELIMITER . 'c' . $category_id . '/' . $article_id . '/p' . $page; |
|
64 | + $print_data['title'] = $article_data['title']; |
|
65 | + $print_data['author'] = $article_data['author']; |
|
66 | + $print_data['date'] = $article_data['time']; |
|
67 | + $print_data['summary'] = empty($article_data['summary']) ? '' : planet_constant('MD_SUMMARY') . ': ' . $article_data['summary']; |
|
68 | + $print_data['content'] = $article_data['text']; |
|
69 | + $print_data['url'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/view.article.php' . URL_DELIMITER . 'c' . $category_id . '/' . $article_id . '/p' . $page; |
|
70 | 70 | } else { |
71 | - $print_data = unserialize(base64_decode(Request::getString('print_data', '', 'POST')));//$_POST['print_data'])); |
|
71 | + $print_data = unserialize(base64_decode(Request::getString('print_data', '', 'POST')));//$_POST['print_data'])); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | $print_data['image'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/' . $xoopsModule->getInfo('image'); |
@@ -99,36 +99,36 @@ discard block |
||
99 | 99 | </style>\n"; |
100 | 100 | echo "</head>\n"; |
101 | 101 | echo "<body style='background-color:#ffffff; color:#000000; font-family: Arial' onload='window.print()'>\n" |
102 | - . "<div style='float:center; width: 750px; border: 1px solid #000; padding: 20px;'>\n" |
|
103 | - . "<div style='text-align: center; display: block; margin: 0 0 6px 0; padding: 5px;'>\n" |
|
104 | - . "<img src='" |
|
105 | - . $print_data['image'] |
|
106 | - . "' border='0' alt='" |
|
107 | - . $print_data['module'] |
|
108 | - . "'>\n" |
|
109 | - . '<h2>' |
|
110 | - . $print_data['title'] |
|
111 | - . "</h2>\n" |
|
112 | - . "</div>\n" |
|
113 | - . "<div style='margin-top: 12px; margin-bottom: 12px; border-top: 2px solid #ccc;'></div>\n"; |
|
102 | + . "<div style='float:center; width: 750px; border: 1px solid #000; padding: 20px;'>\n" |
|
103 | + . "<div style='text-align: center; display: block; margin: 0 0 6px 0; padding: 5px;'>\n" |
|
104 | + . "<img src='" |
|
105 | + . $print_data['image'] |
|
106 | + . "' border='0' alt='" |
|
107 | + . $print_data['module'] |
|
108 | + . "'>\n" |
|
109 | + . '<h2>' |
|
110 | + . $print_data['title'] |
|
111 | + . "</h2>\n" |
|
112 | + . "</div>\n" |
|
113 | + . "<div style='margin-top: 12px; margin-bottom: 12px; border-top: 2px solid #ccc;'></div>\n"; |
|
114 | 114 | echo(empty($print_data['author']) ? '' : '<div>' . planet_constant('MD_AUTHOR') . ': ' . $print_data['author'] . "</div>\n") |
115 | - . '<div>' |
|
116 | - . planet_constant('MD_DATE') |
|
117 | - . ': ' |
|
118 | - . $print_data['date'] |
|
119 | - . "</div>\n" |
|
120 | - . (empty($article_data['summary']) ? '' : "<div style='margin-top: 12px; margin-bottom: 12px; border-top: 1px solid #ccc;'></div>\n" . '<div>' . $print_data['summary'] . "</div>\n") |
|
121 | - . "<div style='margin-top: 12px; margin-bottom: 12px; border-top: 1px solid #ccc;'></div>\n" |
|
122 | - . '<div>' |
|
123 | - . $print_data['content'] |
|
124 | - . "</div>\n" |
|
125 | - . "<div style='margin-top: 12px; margin-bottom: 12px; border-top: 2px solid #ccc;'></div>\n" |
|
126 | - . '<div>' |
|
127 | - . $print_data['module'] |
|
128 | - . "</div>\n" |
|
129 | - . '<div>URL: ' |
|
130 | - . $print_data['url'] |
|
131 | - . "</div>\n" |
|
132 | - . "</div>\n" |
|
133 | - . "</body>\n</html>\n"; |
|
115 | + . '<div>' |
|
116 | + . planet_constant('MD_DATE') |
|
117 | + . ': ' |
|
118 | + . $print_data['date'] |
|
119 | + . "</div>\n" |
|
120 | + . (empty($article_data['summary']) ? '' : "<div style='margin-top: 12px; margin-bottom: 12px; border-top: 1px solid #ccc;'></div>\n" . '<div>' . $print_data['summary'] . "</div>\n") |
|
121 | + . "<div style='margin-top: 12px; margin-bottom: 12px; border-top: 1px solid #ccc;'></div>\n" |
|
122 | + . '<div>' |
|
123 | + . $print_data['content'] |
|
124 | + . "</div>\n" |
|
125 | + . "<div style='margin-top: 12px; margin-bottom: 12px; border-top: 2px solid #ccc;'></div>\n" |
|
126 | + . '<div>' |
|
127 | + . $print_data['module'] |
|
128 | + . "</div>\n" |
|
129 | + . '<div>URL: ' |
|
130 | + . $print_data['url'] |
|
131 | + . "</div>\n" |
|
132 | + . "</div>\n" |
|
133 | + . "</body>\n</html>\n"; |
|
134 | 134 | exit(); |
@@ -30,8 +30,8 @@ discard block |
||
30 | 30 | include __DIR__ . '/header.php'; |
31 | 31 | |
32 | 32 | if (PlanetUtility::planetParseArguments($args_num, $args, $args_str)) { |
33 | - $args['article'] = @$args_num[0]; |
|
34 | - $args['type'] = @$args_str[0]; |
|
33 | + $args['article'] = @$args_num[0]; |
|
34 | + $args['type'] = @$args_str[0]; |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /* Specified Article */ |
@@ -48,14 +48,14 @@ discard block |
||
48 | 48 | |
49 | 49 | $valid_format = ['RSS0.91', 'RSS1.0', 'RSS2.0', 'PIE0.1', 'MBOX', 'OPML', 'ATOM', 'ATOM0.3', 'HTML', 'JS']; |
50 | 50 | if ($type === 'RDF') { |
51 | - $type = 'RSS1.0'; |
|
51 | + $type = 'RSS1.0'; |
|
52 | 52 | } |
53 | 53 | if ($type === 'RSS') { |
54 | - $type = 'RSS0.91'; |
|
54 | + $type = 'RSS0.91'; |
|
55 | 55 | } |
56 | 56 | if (empty($type) || !in_array($type, $valid_format)) { |
57 | - PlanetUtility::planetRespondToTrackback(1, planet_constant('MD_INVALID')); |
|
58 | - exit(); |
|
57 | + PlanetUtility::planetRespondToTrackback(1, planet_constant('MD_INVALID')); |
|
58 | + exit(); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | $categoryHandler = xoops_getModuleHandler('category', $GLOBALS['moddirname']); |
@@ -64,30 +64,30 @@ discard block |
||
64 | 64 | $bookmarkHandler = xoops_getModuleHandler('bookmark', $GLOBALS['moddirname']); |
65 | 65 | |
66 | 66 | if (!empty($article_id)) { |
67 | - $article_obj = $articleHandler->get($article_id); |
|
68 | - if (!$article_obj->getVar('art_id')) { |
|
69 | - PlanetUtility::planetRespondToTrackback(1, planet_constant('MD_EXPIRED')); |
|
70 | - exit(); |
|
71 | - } |
|
72 | - $source = 'article'; |
|
67 | + $article_obj = $articleHandler->get($article_id); |
|
68 | + if (!$article_obj->getVar('art_id')) { |
|
69 | + PlanetUtility::planetRespondToTrackback(1, planet_constant('MD_EXPIRED')); |
|
70 | + exit(); |
|
71 | + } |
|
72 | + $source = 'article'; |
|
73 | 73 | } elseif (!empty($blog_id)) { |
74 | - $blog_obj = $blogHandler->get($blog_id); |
|
75 | - if (!$blog_obj->getVar('blog_id')) { |
|
76 | - PlanetUtility::planetRespondToTrackback(1, planet_constant('MD_INVALID')); |
|
77 | - exit(); |
|
78 | - } |
|
79 | - $source = 'blog'; |
|
74 | + $blog_obj = $blogHandler->get($blog_id); |
|
75 | + if (!$blog_obj->getVar('blog_id')) { |
|
76 | + PlanetUtility::planetRespondToTrackback(1, planet_constant('MD_INVALID')); |
|
77 | + exit(); |
|
78 | + } |
|
79 | + $source = 'blog'; |
|
80 | 80 | } elseif (!empty($category_id)) { |
81 | - $source = 'category'; |
|
82 | - $category_obj = $categoryHandler->get($category_id); |
|
83 | - if (!$category_obj->getVar('cat_id')) { |
|
84 | - PlanetUtility::planetRespondToTrackback(1, planet_constant('MD_INVALID')); |
|
85 | - exit(); |
|
86 | - } |
|
81 | + $source = 'category'; |
|
82 | + $category_obj = $categoryHandler->get($category_id); |
|
83 | + if (!$category_obj->getVar('cat_id')) { |
|
84 | + PlanetUtility::planetRespondToTrackback(1, planet_constant('MD_INVALID')); |
|
85 | + exit(); |
|
86 | + } |
|
87 | 87 | } elseif (!empty($uid)) { |
88 | - $source = 'bookmark'; |
|
88 | + $source = 'bookmark'; |
|
89 | 89 | } else { |
90 | - $source = ''; |
|
90 | + $source = ''; |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | $xml_charset = 'UTF-8'; |
@@ -97,102 +97,102 @@ discard block |
||
97 | 97 | $tpl->xoops_setCacheTime(3600); |
98 | 98 | $xoopsCachedTemplateId = md5($xoopsModule->getVar('mid') . ',' . $article_id . ',' . $category_id . ',' . $blog_id . ',' . $uid . ',' . $type); |
99 | 99 | if (!$tpl->is_cached('db:system_dummy.tpl', $xoopsCachedTemplateId)) { |
100 | - $criteria = new CriteriaCompo(); |
|
101 | - $criteria->setLimit($xoopsModuleConfig['articles_perpage']); |
|
102 | - $articles_obj = []; |
|
103 | - switch ($source) { |
|
104 | - case 'article': |
|
105 | - $pagetitle = planet_constant('MD_ARTICLE'); |
|
106 | - $rssdesc = planet_constant('MD_XMLDESC_ARTICLE'); |
|
107 | - |
|
108 | - $articles_obj[$article_id] = $article_obj; |
|
109 | - |
|
110 | - $xml_link = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php' . URL_DELIMITER . '' . $article_obj->getVar('art_id'); |
|
111 | - break; |
|
112 | - |
|
113 | - case 'category': |
|
114 | - $pagetitle = planet_constant('MD_CATEGORY'); |
|
115 | - $rssdesc = sprintf(planet_constant('MD_XMLDESC_CATEGORY'), $category_obj->getVar('cat_title')); |
|
116 | - |
|
117 | - $criteria->add(new Criteria('bc.cat_id', $category_id)); |
|
118 | - $articles_obj = $articleHandler->getByCategory($criteria); |
|
119 | - |
|
120 | - $xml_link = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . URL_DELIMITER . 'c' . $category_id; |
|
121 | - break; |
|
122 | - |
|
123 | - case 'blog': |
|
124 | - $pagetitle = planet_constant('MD_BLOG'); |
|
125 | - $rssdesc = sprintf(planet_constant('MD_XMLDESC_BLOG'), $blog_obj->getVar('blog_title')); |
|
126 | - |
|
127 | - $criteria->add(new Criteria('blog_id', $blog_id)); |
|
128 | - $articles_obj = $articleHandler->getAll($criteria); |
|
129 | - |
|
130 | - $xml_link = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . URL_DELIMITER . 'b' . $blog_id; |
|
131 | - break; |
|
132 | - |
|
133 | - case 'bookmark': |
|
134 | - $author_name = XoopsUser::getUnameFromId($uid); |
|
135 | - $pagetitle = planet_constant('MD_BOOKMARKS'); |
|
136 | - $rssdesc = sprintf(planet_constant('MD_XMLDESC_BOOKMARK'), $author_name); |
|
137 | - |
|
138 | - $criteria->add(new Criteria('bm.bm_uid', $uid)); |
|
139 | - $articles_obj = $articleHandler->getByBookmark($criteria); |
|
140 | - |
|
141 | - $xml_link = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . URL_DELIMITER . 'u' . $uid; |
|
142 | - |
|
143 | - break; |
|
144 | - |
|
145 | - default: |
|
146 | - $pagetitle = planet_constant('MD_INDEX'); |
|
147 | - $rssdesc = planet_constant('MD_XMLDESC_INDEX'); |
|
148 | - |
|
149 | - $articles_obj = $articleHandler->getAll($criteria); |
|
150 | - |
|
151 | - $xml_link = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php'; |
|
152 | - break; |
|
153 | - } |
|
154 | - $items = []; |
|
155 | - foreach (array_keys($articles_obj) as $id) { |
|
156 | - $content = $articles_obj[$id]->getVar('art_content'); |
|
157 | - $content .= '<br>' . planet_constant('MD_SOURCE') . ': ' . $articles_obj[$id]->getVar('art_link') . ' ' . $articles_obj[$id]->getVar('art_author'); |
|
158 | - $items[] = [ |
|
159 | - 'title' => $articles_obj[$id]->getVar('art_title'), |
|
160 | - 'link' => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php' . URL_DELIMITER . '' . $articles_obj[$id]->getVar('art_id'), |
|
161 | - 'description' => $content, |
|
162 | - 'descriptionHtmlSyndicated' => true, |
|
163 | - 'date' => $articles_obj[$id]->getTime('rss'), |
|
164 | - 'source' => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/', |
|
165 | - 'author' => $articles_obj[$id]->getVar('art_author') |
|
166 | - ]; |
|
167 | - } |
|
168 | - unset($articles_obj, $criteria); |
|
169 | - |
|
170 | - $xmlHandler = xoops_getModuleHandler('xml', $GLOBALS['moddirname']); |
|
171 | - $xml = $xmlHandler->create($type); |
|
172 | - $xml->setVar('encoding', $xml_charset); |
|
173 | - $xml->setVar('title', $xoopsConfig['sitename'] . ' :: ' . $pagetitle, 'UTF-8', $xml_charset, true); |
|
174 | - $xml->setVar('description', $rssdesc, true); |
|
175 | - $xml->setVar('descriptionHtmlSyndicated', true); |
|
176 | - $xml->setVar('link', $xml_link); |
|
177 | - $xml->setVar('syndicationURL', XOOPS_URL . '/' . xoops_getenv('PHP_SELF'), 'post', true); |
|
178 | - $xml->setVar('webmaster', checkEmail($xoopsConfig['adminmail'], true)); |
|
179 | - $xml->setVar('editor', checkEmail($xoopsConfig['adminmail'], true)); |
|
180 | - $xml->setVar('category', $xoopsModule->getVar('name'), true); |
|
181 | - $xml->setVar('generator', $xoopsModule->getInfo('version')); |
|
182 | - $xml->setVar('language', _LANGCODE); |
|
183 | - |
|
184 | - $dimention = @getimagesize(XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/' . $xoopsModule->getInfo('image')); |
|
185 | - $image = [ |
|
186 | - 'width' => $dimention[0], |
|
187 | - 'height' => $dimention[1], |
|
188 | - 'title' => $xoopsConfig['sitename'] . ' :: ' . $pagetitle, |
|
189 | - 'url' => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/' . $xoopsModule->getInfo('image'), |
|
190 | - 'link' => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/', |
|
191 | - 'description' => $rssdesc |
|
192 | - ]; |
|
193 | - $xml->setImage($image); |
|
194 | - |
|
195 | - /* |
|
100 | + $criteria = new CriteriaCompo(); |
|
101 | + $criteria->setLimit($xoopsModuleConfig['articles_perpage']); |
|
102 | + $articles_obj = []; |
|
103 | + switch ($source) { |
|
104 | + case 'article': |
|
105 | + $pagetitle = planet_constant('MD_ARTICLE'); |
|
106 | + $rssdesc = planet_constant('MD_XMLDESC_ARTICLE'); |
|
107 | + |
|
108 | + $articles_obj[$article_id] = $article_obj; |
|
109 | + |
|
110 | + $xml_link = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php' . URL_DELIMITER . '' . $article_obj->getVar('art_id'); |
|
111 | + break; |
|
112 | + |
|
113 | + case 'category': |
|
114 | + $pagetitle = planet_constant('MD_CATEGORY'); |
|
115 | + $rssdesc = sprintf(planet_constant('MD_XMLDESC_CATEGORY'), $category_obj->getVar('cat_title')); |
|
116 | + |
|
117 | + $criteria->add(new Criteria('bc.cat_id', $category_id)); |
|
118 | + $articles_obj = $articleHandler->getByCategory($criteria); |
|
119 | + |
|
120 | + $xml_link = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . URL_DELIMITER . 'c' . $category_id; |
|
121 | + break; |
|
122 | + |
|
123 | + case 'blog': |
|
124 | + $pagetitle = planet_constant('MD_BLOG'); |
|
125 | + $rssdesc = sprintf(planet_constant('MD_XMLDESC_BLOG'), $blog_obj->getVar('blog_title')); |
|
126 | + |
|
127 | + $criteria->add(new Criteria('blog_id', $blog_id)); |
|
128 | + $articles_obj = $articleHandler->getAll($criteria); |
|
129 | + |
|
130 | + $xml_link = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . URL_DELIMITER . 'b' . $blog_id; |
|
131 | + break; |
|
132 | + |
|
133 | + case 'bookmark': |
|
134 | + $author_name = XoopsUser::getUnameFromId($uid); |
|
135 | + $pagetitle = planet_constant('MD_BOOKMARKS'); |
|
136 | + $rssdesc = sprintf(planet_constant('MD_XMLDESC_BOOKMARK'), $author_name); |
|
137 | + |
|
138 | + $criteria->add(new Criteria('bm.bm_uid', $uid)); |
|
139 | + $articles_obj = $articleHandler->getByBookmark($criteria); |
|
140 | + |
|
141 | + $xml_link = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . URL_DELIMITER . 'u' . $uid; |
|
142 | + |
|
143 | + break; |
|
144 | + |
|
145 | + default: |
|
146 | + $pagetitle = planet_constant('MD_INDEX'); |
|
147 | + $rssdesc = planet_constant('MD_XMLDESC_INDEX'); |
|
148 | + |
|
149 | + $articles_obj = $articleHandler->getAll($criteria); |
|
150 | + |
|
151 | + $xml_link = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php'; |
|
152 | + break; |
|
153 | + } |
|
154 | + $items = []; |
|
155 | + foreach (array_keys($articles_obj) as $id) { |
|
156 | + $content = $articles_obj[$id]->getVar('art_content'); |
|
157 | + $content .= '<br>' . planet_constant('MD_SOURCE') . ': ' . $articles_obj[$id]->getVar('art_link') . ' ' . $articles_obj[$id]->getVar('art_author'); |
|
158 | + $items[] = [ |
|
159 | + 'title' => $articles_obj[$id]->getVar('art_title'), |
|
160 | + 'link' => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php' . URL_DELIMITER . '' . $articles_obj[$id]->getVar('art_id'), |
|
161 | + 'description' => $content, |
|
162 | + 'descriptionHtmlSyndicated' => true, |
|
163 | + 'date' => $articles_obj[$id]->getTime('rss'), |
|
164 | + 'source' => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/', |
|
165 | + 'author' => $articles_obj[$id]->getVar('art_author') |
|
166 | + ]; |
|
167 | + } |
|
168 | + unset($articles_obj, $criteria); |
|
169 | + |
|
170 | + $xmlHandler = xoops_getModuleHandler('xml', $GLOBALS['moddirname']); |
|
171 | + $xml = $xmlHandler->create($type); |
|
172 | + $xml->setVar('encoding', $xml_charset); |
|
173 | + $xml->setVar('title', $xoopsConfig['sitename'] . ' :: ' . $pagetitle, 'UTF-8', $xml_charset, true); |
|
174 | + $xml->setVar('description', $rssdesc, true); |
|
175 | + $xml->setVar('descriptionHtmlSyndicated', true); |
|
176 | + $xml->setVar('link', $xml_link); |
|
177 | + $xml->setVar('syndicationURL', XOOPS_URL . '/' . xoops_getenv('PHP_SELF'), 'post', true); |
|
178 | + $xml->setVar('webmaster', checkEmail($xoopsConfig['adminmail'], true)); |
|
179 | + $xml->setVar('editor', checkEmail($xoopsConfig['adminmail'], true)); |
|
180 | + $xml->setVar('category', $xoopsModule->getVar('name'), true); |
|
181 | + $xml->setVar('generator', $xoopsModule->getInfo('version')); |
|
182 | + $xml->setVar('language', _LANGCODE); |
|
183 | + |
|
184 | + $dimention = @getimagesize(XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/' . $xoopsModule->getInfo('image')); |
|
185 | + $image = [ |
|
186 | + 'width' => $dimention[0], |
|
187 | + 'height' => $dimention[1], |
|
188 | + 'title' => $xoopsConfig['sitename'] . ' :: ' . $pagetitle, |
|
189 | + 'url' => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/' . $xoopsModule->getInfo('image'), |
|
190 | + 'link' => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/', |
|
191 | + 'description' => $rssdesc |
|
192 | + ]; |
|
193 | + $xml->setImage($image); |
|
194 | + |
|
195 | + /* |
|
196 | 196 | $item = array( |
197 | 197 | "title" => $datatitle, |
198 | 198 | "link" => $dataurl, |
@@ -203,11 +203,11 @@ discard block |
||
203 | 203 | "author" => $dataauthor |
204 | 204 | ); |
205 | 205 | */ |
206 | - $xml->addItems($items); |
|
206 | + $xml->addItems($items); |
|
207 | 207 | |
208 | - $dummy_content = $xmlHandler->display($xml, XOOPS_CACHE_PATH . '/' . $GLOBALS['moddirname'] . '.xml.tmp'); |
|
208 | + $dummy_content = $xmlHandler->display($xml, XOOPS_CACHE_PATH . '/' . $GLOBALS['moddirname'] . '.xml.tmp'); |
|
209 | 209 | |
210 | - $tpl->assign_by_ref('dummy_content', $dummy_content); |
|
210 | + $tpl->assign_by_ref('dummy_content', $dummy_content); |
|
211 | 211 | } |
212 | 212 | //$content = ob_get_contents(); |
213 | 213 | ob_end_clean(); |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | use Xmf\Request; |
28 | 28 | |
29 | 29 | ob_start(); |
30 | -include __DIR__ . '/header.php'; |
|
30 | +include __DIR__.'/header.php'; |
|
31 | 31 | |
32 | 32 | if (PlanetUtility::planetParseArguments($args_num, $args, $args_str)) { |
33 | 33 | $args['article'] = @$args_num[0]; |
@@ -86,16 +86,16 @@ discard block |
||
86 | 86 | } |
87 | 87 | } elseif (!empty($uid)) { |
88 | 88 | $source = 'bookmark'; |
89 | -} else { |
|
89 | +}else { |
|
90 | 90 | $source = ''; |
91 | 91 | } |
92 | 92 | |
93 | 93 | $xml_charset = 'UTF-8'; |
94 | -require_once XOOPS_ROOT_PATH . '/class/template.php'; |
|
94 | +require_once XOOPS_ROOT_PATH.'/class/template.php'; |
|
95 | 95 | $tpl = new XoopsTpl(); |
96 | 96 | $tpl->xoops_setCaching(2); |
97 | 97 | $tpl->xoops_setCacheTime(3600); |
98 | -$xoopsCachedTemplateId = md5($xoopsModule->getVar('mid') . ',' . $article_id . ',' . $category_id . ',' . $blog_id . ',' . $uid . ',' . $type); |
|
98 | +$xoopsCachedTemplateId = md5($xoopsModule->getVar('mid').','.$article_id.','.$category_id.','.$blog_id.','.$uid.','.$type); |
|
99 | 99 | if (!$tpl->is_cached('db:system_dummy.tpl', $xoopsCachedTemplateId)) { |
100 | 100 | $criteria = new CriteriaCompo(); |
101 | 101 | $criteria->setLimit($xoopsModuleConfig['articles_perpage']); |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | |
108 | 108 | $articles_obj[$article_id] = $article_obj; |
109 | 109 | |
110 | - $xml_link = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php' . URL_DELIMITER . '' . $article_obj->getVar('art_id'); |
|
110 | + $xml_link = XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/view.article.php'.URL_DELIMITER.''.$article_obj->getVar('art_id'); |
|
111 | 111 | break; |
112 | 112 | |
113 | 113 | case 'category': |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | $criteria->add(new Criteria('bc.cat_id', $category_id)); |
118 | 118 | $articles_obj = $articleHandler->getByCategory($criteria); |
119 | 119 | |
120 | - $xml_link = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . URL_DELIMITER . 'c' . $category_id; |
|
120 | + $xml_link = XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/index.php'.URL_DELIMITER.'c'.$category_id; |
|
121 | 121 | break; |
122 | 122 | |
123 | 123 | case 'blog': |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | $criteria->add(new Criteria('blog_id', $blog_id)); |
128 | 128 | $articles_obj = $articleHandler->getAll($criteria); |
129 | 129 | |
130 | - $xml_link = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . URL_DELIMITER . 'b' . $blog_id; |
|
130 | + $xml_link = XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/index.php'.URL_DELIMITER.'b'.$blog_id; |
|
131 | 131 | break; |
132 | 132 | |
133 | 133 | case 'bookmark': |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | $criteria->add(new Criteria('bm.bm_uid', $uid)); |
139 | 139 | $articles_obj = $articleHandler->getByBookmark($criteria); |
140 | 140 | |
141 | - $xml_link = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . URL_DELIMITER . 'u' . $uid; |
|
141 | + $xml_link = XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/index.php'.URL_DELIMITER.'u'.$uid; |
|
142 | 142 | |
143 | 143 | break; |
144 | 144 | |
@@ -148,20 +148,20 @@ discard block |
||
148 | 148 | |
149 | 149 | $articles_obj = $articleHandler->getAll($criteria); |
150 | 150 | |
151 | - $xml_link = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php'; |
|
151 | + $xml_link = XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/index.php'; |
|
152 | 152 | break; |
153 | 153 | } |
154 | 154 | $items = []; |
155 | 155 | foreach (array_keys($articles_obj) as $id) { |
156 | 156 | $content = $articles_obj[$id]->getVar('art_content'); |
157 | - $content .= '<br>' . planet_constant('MD_SOURCE') . ': ' . $articles_obj[$id]->getVar('art_link') . ' ' . $articles_obj[$id]->getVar('art_author'); |
|
157 | + $content .= '<br>'.planet_constant('MD_SOURCE').': '.$articles_obj[$id]->getVar('art_link').' '.$articles_obj[$id]->getVar('art_author'); |
|
158 | 158 | $items[] = [ |
159 | 159 | 'title' => $articles_obj[$id]->getVar('art_title'), |
160 | - 'link' => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php' . URL_DELIMITER . '' . $articles_obj[$id]->getVar('art_id'), |
|
160 | + 'link' => XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/view.article.php'.URL_DELIMITER.''.$articles_obj[$id]->getVar('art_id'), |
|
161 | 161 | 'description' => $content, |
162 | 162 | 'descriptionHtmlSyndicated' => true, |
163 | 163 | 'date' => $articles_obj[$id]->getTime('rss'), |
164 | - 'source' => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/', |
|
164 | + 'source' => XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/', |
|
165 | 165 | 'author' => $articles_obj[$id]->getVar('art_author') |
166 | 166 | ]; |
167 | 167 | } |
@@ -170,24 +170,24 @@ discard block |
||
170 | 170 | $xmlHandler = xoops_getModuleHandler('xml', $GLOBALS['moddirname']); |
171 | 171 | $xml = $xmlHandler->create($type); |
172 | 172 | $xml->setVar('encoding', $xml_charset); |
173 | - $xml->setVar('title', $xoopsConfig['sitename'] . ' :: ' . $pagetitle, 'UTF-8', $xml_charset, true); |
|
173 | + $xml->setVar('title', $xoopsConfig['sitename'].' :: '.$pagetitle, 'UTF-8', $xml_charset, true); |
|
174 | 174 | $xml->setVar('description', $rssdesc, true); |
175 | 175 | $xml->setVar('descriptionHtmlSyndicated', true); |
176 | 176 | $xml->setVar('link', $xml_link); |
177 | - $xml->setVar('syndicationURL', XOOPS_URL . '/' . xoops_getenv('PHP_SELF'), 'post', true); |
|
177 | + $xml->setVar('syndicationURL', XOOPS_URL.'/'.xoops_getenv('PHP_SELF'), 'post', true); |
|
178 | 178 | $xml->setVar('webmaster', checkEmail($xoopsConfig['adminmail'], true)); |
179 | 179 | $xml->setVar('editor', checkEmail($xoopsConfig['adminmail'], true)); |
180 | 180 | $xml->setVar('category', $xoopsModule->getVar('name'), true); |
181 | 181 | $xml->setVar('generator', $xoopsModule->getInfo('version')); |
182 | 182 | $xml->setVar('language', _LANGCODE); |
183 | 183 | |
184 | - $dimention = @getimagesize(XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/' . $xoopsModule->getInfo('image')); |
|
184 | + $dimention = @getimagesize(XOOPS_ROOT_PATH.'/modules/'.$GLOBALS['moddirname'].'/'.$xoopsModule->getInfo('image')); |
|
185 | 185 | $image = [ |
186 | 186 | 'width' => $dimention[0], |
187 | 187 | 'height' => $dimention[1], |
188 | - 'title' => $xoopsConfig['sitename'] . ' :: ' . $pagetitle, |
|
189 | - 'url' => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/' . $xoopsModule->getInfo('image'), |
|
190 | - 'link' => XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/', |
|
188 | + 'title' => $xoopsConfig['sitename'].' :: '.$pagetitle, |
|
189 | + 'url' => XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/'.$xoopsModule->getInfo('image'), |
|
190 | + 'link' => XOOPS_URL.'/modules/'.$GLOBALS['moddirname'].'/', |
|
191 | 191 | 'description' => $rssdesc |
192 | 192 | ]; |
193 | 193 | $xml->setImage($image); |
@@ -205,11 +205,11 @@ discard block |
||
205 | 205 | */ |
206 | 206 | $xml->addItems($items); |
207 | 207 | |
208 | - $dummy_content = $xmlHandler->display($xml, XOOPS_CACHE_PATH . '/' . $GLOBALS['moddirname'] . '.xml.tmp'); |
|
208 | + $dummy_content = $xmlHandler->display($xml, XOOPS_CACHE_PATH.'/'.$GLOBALS['moddirname'].'.xml.tmp'); |
|
209 | 209 | |
210 | 210 | $tpl->assign_by_ref('dummy_content', $dummy_content); |
211 | 211 | } |
212 | 212 | //$content = ob_get_contents(); |
213 | 213 | ob_end_clean(); |
214 | -header('Content-Type:text/xml; charset=' . $xml_charset); |
|
214 | +header('Content-Type:text/xml; charset='.$xml_charset); |
|
215 | 215 | $tpl->display('db:system_dummy.tpl', $xoopsCachedTemplateId); |