@@ -109,7 +109,6 @@ |
||
| 109 | 109 | /** |
| 110 | 110 | * get summary of the article |
| 111 | 111 | * |
| 112 | - * @param bool $actionOnEmpty flag for truncating content if summary is empty |
|
| 113 | 112 | * @return string |
| 114 | 113 | */ |
| 115 | 114 | function &getSummary($length = 0) |
@@ -100,7 +100,9 @@ |
||
| 100 | 100 | function getTime($format = "c") |
| 101 | 101 | { |
| 102 | 102 | $time = $this->getVar("art_time"); |
| 103 | - if(empty($time)) $time = time(); |
|
| 103 | + if(empty($time)) { |
|
| 104 | + $time = time(); |
|
| 105 | + } |
|
| 104 | 106 | $time = planet_formatTimestamp($time, $format); |
| 105 | 107 | return $time; |
| 106 | 108 | } |
@@ -650,6 +650,10 @@ discard block |
||
| 650 | 650 | |
| 651 | 651 | class IXR_Base64 { |
| 652 | 652 | var $data; |
| 653 | + |
|
| 654 | + /** |
|
| 655 | + * @param string $data |
|
| 656 | + */ |
|
| 653 | 657 | function IXR_Base64($data) { |
| 654 | 658 | $this->data = $data; |
| 655 | 659 | } |
@@ -694,6 +698,13 @@ discard block |
||
| 694 | 698 | 'Returns a documentation string for the specified method' |
| 695 | 699 | ); |
| 696 | 700 | } |
| 701 | + |
|
| 702 | + /** |
|
| 703 | + * @param string $method |
|
| 704 | + * @param string $callback |
|
| 705 | + * @param string[] $args |
|
| 706 | + * @param string $help |
|
| 707 | + */ |
|
| 697 | 708 | function addCallback($method, $callback, $args, $help) { |
| 698 | 709 | $this->callbacks[$method] = $callback; |
| 699 | 710 | $this->signatures[$method] = $args; |
@@ -359,6 +359,9 @@ discard block |
||
| 359 | 359 | class UniversalFeedCreator extends FeedCreator { |
| 360 | 360 | var $_feed; |
| 361 | 361 | |
| 362 | + /** |
|
| 363 | + * @param string $format |
|
| 364 | + */ |
|
| 362 | 365 | function _setFormat($format) { |
| 363 | 366 | switch (strtoupper($format)) { |
| 364 | 367 | |
@@ -540,6 +543,7 @@ discard block |
||
| 540 | 543 | * Adds an FeedItem to the feed. |
| 541 | 544 | * |
| 542 | 545 | * @param object FeedItem $item The FeedItem to add to the feed. |
| 546 | + * @param FeedItem $item |
|
| 543 | 547 | * @access public |
| 544 | 548 | */ |
| 545 | 549 | function addItem($item) { |
@@ -557,6 +561,7 @@ discard block |
||
| 557 | 561 | * @static |
| 558 | 562 | * @param string string A string to be truncated. |
| 559 | 563 | * @param int length the maximum length the string should be truncated to |
| 564 | + * @param integer $length |
|
| 560 | 565 | * @return string the truncated string |
| 561 | 566 | */ |
| 562 | 567 | function iTrunc($string, $length) { |
@@ -655,6 +660,7 @@ discard block |
||
| 655 | 660 | /** |
| 656 | 661 | * @since 1.4 |
| 657 | 662 | * @access private |
| 663 | + * @param string $filename |
|
| 658 | 664 | */ |
| 659 | 665 | function _redirect($filename) { |
| 660 | 666 | // attention, heavily-commented-out-area |
@@ -788,7 +794,7 @@ discard block |
||
| 788 | 794 | /** |
| 789 | 795 | * Gets the date stored in this FeedDate as an RFC 822 date. |
| 790 | 796 | * |
| 791 | - * @return a date in RFC 822 format |
|
| 797 | + * @return string date in RFC 822 format |
|
| 792 | 798 | */ |
| 793 | 799 | function rfc822() { |
| 794 | 800 | //return gmdate("r",$this->unix); |
@@ -800,7 +806,7 @@ discard block |
||
| 800 | 806 | /** |
| 801 | 807 | * Gets the date stored in this FeedDate as an ISO 8601 date. |
| 802 | 808 | * |
| 803 | - * @return a date in ISO 8601 format |
|
| 809 | + * @return string date in ISO 8601 format |
|
| 804 | 810 | */ |
| 805 | 811 | function iso8601() { |
| 806 | 812 | $date = gmdate("Y-m-d\TH:i:sO",$this->unix); |
@@ -922,6 +928,7 @@ discard block |
||
| 922 | 928 | /** |
| 923 | 929 | * Sets this RSS feed's version number. |
| 924 | 930 | * @access private |
| 931 | + * @param string $version |
|
| 925 | 932 | */ |
| 926 | 933 | function _setRSSVersion($version) { |
| 927 | 934 | $this->RSSVersion = $version; |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | // - no truncation (truncating risks producing invalid html) |
| 332 | 332 | if (!$this->rawFieldContent) { |
| 333 | 333 | $result = ""; |
| 334 | - } elseif ($this->syndicateHtml) { |
|
| 334 | + } elseif ($this->syndicateHtml) { |
|
| 335 | 335 | $result = "<![CDATA[".$this->rawFieldContent."]]>"; |
| 336 | 336 | } else { |
| 337 | 337 | if ($this->truncSize and is_int($this->truncSize)) { |
@@ -616,8 +616,12 @@ discard block |
||
| 616 | 616 | |
| 617 | 617 | function _createStylesheetReferences() { |
| 618 | 618 | $xml = ""; |
| 619 | - if ($this->cssStyleSheet) $xml .= "<?xml-stylesheet href=\"".$this->cssStyleSheet."\" type=\"text/css\"?>\n"; |
|
| 620 | - if ($this->xslStyleSheet) $xml .= "<?xml-stylesheet href=\"".$this->xslStyleSheet."\" type=\"text/xsl\"?>\n"; |
|
| 619 | + if ($this->cssStyleSheet) { |
|
| 620 | + $xml .= "<?xml-stylesheet href=\"".$this->cssStyleSheet."\" type=\"text/css\"?>\n"; |
|
| 621 | + } |
|
| 622 | + if ($this->xslStyleSheet) { |
|
| 623 | + $xml .= "<?xml-stylesheet href=\"".$this->xslStyleSheet."\" type=\"text/xsl\"?>\n"; |
|
| 624 | + } |
|
| 621 | 625 | return $xml; |
| 622 | 626 | } |
| 623 | 627 | |
@@ -738,7 +742,9 @@ discard block |
||
| 738 | 742 | */ |
| 739 | 743 | function FeedDate($dateString="") { |
| 740 | 744 | $tzOffset = 0; |
| 741 | - if ($dateString=="") $dateString = date("r"); |
|
| 745 | + if ($dateString=="") { |
|
| 746 | + $dateString = date("r"); |
|
| 747 | + } |
|
| 742 | 748 | |
| 743 | 749 | //if (is_integer($dateString)) { |
| 744 | 750 | if (is_numeric($dateString)) { |
@@ -793,7 +799,9 @@ discard block |
||
| 793 | 799 | function rfc822() { |
| 794 | 800 | //return gmdate("r",$this->unix); |
| 795 | 801 | $date = gmdate("D, d M Y H:i:s", $this->unix); |
| 796 | - if (TIME_ZONE!="") $date .= " ".str_replace(":","",TIME_ZONE); |
|
| 802 | + if (TIME_ZONE!="") { |
|
| 803 | + $date .= " ".str_replace(":","",TIME_ZONE); |
|
| 804 | + } |
|
| 797 | 805 | return $date; |
| 798 | 806 | } |
| 799 | 807 | |
@@ -805,7 +813,9 @@ discard block |
||
| 805 | 813 | function iso8601() { |
| 806 | 814 | $date = gmdate("Y-m-d\TH:i:sO",$this->unix); |
| 807 | 815 | $date = substr($date,0,22) . ':' . substr($date,-2); |
| 808 | - if (TIME_ZONE!="") $date = str_replace("+00:00",TIME_ZONE,$date); |
|
| 816 | + if (TIME_ZONE!="") { |
|
| 817 | + $date = str_replace("+00:00",TIME_ZONE,$date); |
|
| 818 | + } |
|
| 809 | 819 | return $date; |
| 810 | 820 | } |
| 811 | 821 | |
@@ -450,6 +450,10 @@ discard block |
||
| 450 | 450 | /** |
| 451 | 451 | * return XML parser, and possibly re-encoded source |
| 452 | 452 | * |
| 453 | + * @param string $source |
|
| 454 | + * @param string $out_enc |
|
| 455 | + * @param string|null $in_enc |
|
| 456 | + * @param boolean $detect |
|
| 453 | 457 | */ |
| 454 | 458 | function create_parser($source, $out_enc, $in_enc, $detect) { |
| 455 | 459 | if ( substr(phpversion(),0,1) == 5) { |
@@ -561,6 +565,9 @@ discard block |
||
| 561 | 565 | } |
| 562 | 566 | } |
| 563 | 567 | |
| 568 | + /** |
|
| 569 | + * @param integer $lvl |
|
| 570 | + */ |
|
| 564 | 571 | function error ($errormsg, $lvl=E_USER_WARNING) { |
| 565 | 572 | // append PHP's error message if track_errors enabled |
| 566 | 573 | if ( !empty($php_errormsg) ) { |
@@ -165,12 +165,10 @@ discard block |
||
| 165 | 165 | if ( $el == 'rdf' ) { |
| 166 | 166 | $this->feed_type = RSS; |
| 167 | 167 | $this->feed_version = '1.0'; |
| 168 | - } |
|
| 169 | - elseif ( $el == 'rss' ) { |
|
| 168 | + } elseif ( $el == 'rss' ) { |
|
| 170 | 169 | $this->feed_type = RSS; |
| 171 | 170 | $this->feed_version = $attrs['version']; |
| 172 | - } |
|
| 173 | - elseif ( $el == 'feed' ) { |
|
| 171 | + } elseif ( $el == 'feed' ) { |
|
| 174 | 172 | $this->feed_type = ATOM; |
| 175 | 173 | $this->feed_version = $attrs['version']; |
| 176 | 174 | $this->inchannel = true; |
@@ -181,8 +179,7 @@ discard block |
||
| 181 | 179 | if ( $el == 'channel' ) |
| 182 | 180 | { |
| 183 | 181 | $this->inchannel = true; |
| 184 | - } |
|
| 185 | - elseif ($el == 'item' or $el == 'entry' ) |
|
| 182 | + } elseif ($el == 'item' or $el == 'entry' ) |
|
| 186 | 183 | { |
| 187 | 184 | $this->initem = true; |
| 188 | 185 | if ( isset($attrs['rdf:about']) ) { |
@@ -198,9 +195,7 @@ discard block |
||
| 198 | 195 | $el == 'textinput' ) |
| 199 | 196 | { |
| 200 | 197 | $this->intextinput = true; |
| 201 | - } |
|
| 202 | - |
|
| 203 | - elseif ( |
|
| 198 | + } elseif ( |
|
| 204 | 199 | $this->feed_type == RSS and |
| 205 | 200 | $this->current_namespace == '' and |
| 206 | 201 | $el == 'image' ) |
@@ -244,8 +239,7 @@ discard block |
||
| 244 | 239 | if ( isset($attrs['rel']) and $attrs['rel'] == 'alternate' ) |
| 245 | 240 | { |
| 246 | 241 | $link_el = 'link'; |
| 247 | - } |
|
| 248 | - else { |
|
| 242 | + } else { |
|
| 249 | 243 | $link_el = 'link_' . $attrs['rel']; |
| 250 | 244 | } |
| 251 | 245 | |
@@ -264,8 +258,7 @@ discard block |
||
| 264 | 258 | if ($this->feed_type == ATOM and $this->incontent) |
| 265 | 259 | { |
| 266 | 260 | $this->append_content( $text ); |
| 267 | - } |
|
| 268 | - else { |
|
| 261 | + } else { |
|
| 269 | 262 | $current_el = join('_', array_reverse($this->stack)); |
| 270 | 263 | $this->append($current_el, $text); |
| 271 | 264 | } |
@@ -279,37 +272,30 @@ discard block |
||
| 279 | 272 | $this->items[] = $this->current_item; |
| 280 | 273 | $this->current_item = array(); |
| 281 | 274 | $this->initem = false; |
| 282 | - } |
|
| 283 | - elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'textinput' ) |
|
| 275 | + } elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'textinput' ) |
|
| 284 | 276 | { |
| 285 | 277 | $this->intextinput = false; |
| 286 | - } |
|
| 287 | - elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'image' ) |
|
| 278 | + } elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'image' ) |
|
| 288 | 279 | { |
| 289 | 280 | $this->inimage = false; |
| 290 | - } |
|
| 291 | - elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) ) |
|
| 281 | + } elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) ) |
|
| 292 | 282 | { |
| 293 | 283 | $this->incontent = false; |
| 294 | - } |
|
| 295 | - elseif ($el == 'channel' or $el == 'feed' ) |
|
| 284 | + } elseif ($el == 'channel' or $el == 'feed' ) |
|
| 296 | 285 | { |
| 297 | 286 | $this->inchannel = false; |
| 298 | - } |
|
| 299 | - elseif ($this->feed_type == ATOM and $this->incontent ) { |
|
| 287 | + } elseif ($this->feed_type == ATOM and $this->incontent ) { |
|
| 300 | 288 | // balance tags properly |
| 301 | 289 | // note: i don't think this is actually neccessary |
| 302 | 290 | if ( $this->stack[0] == $el ) |
| 303 | 291 | { |
| 304 | 292 | $this->append_content("</$el>"); |
| 305 | - } |
|
| 306 | - else { |
|
| 293 | + } else { |
|
| 307 | 294 | $this->append_content("<$el />"); |
| 308 | 295 | } |
| 309 | 296 | |
| 310 | 297 | array_shift( $this->stack ); |
| 311 | - } |
|
| 312 | - else { |
|
| 298 | + } else { |
|
| 313 | 299 | array_shift( $this->stack ); |
| 314 | 300 | } |
| 315 | 301 | |
@@ -328,8 +314,7 @@ discard block |
||
| 328 | 314 | function append_content($text) { |
| 329 | 315 | if ( $this->initem ) { |
| 330 | 316 | $this->concat( $this->current_item[ $this->incontent ], $text ); |
| 331 | - } |
|
| 332 | - elseif ( $this->inchannel ) { |
|
| 317 | + } elseif ( $this->inchannel ) { |
|
| 333 | 318 | $this->concat( $this->channel[ $this->incontent ], $text ); |
| 334 | 319 | } |
| 335 | 320 | } |
@@ -344,34 +329,27 @@ discard block |
||
| 344 | 329 | if ( $this->initem ) { |
| 345 | 330 | $this->concat( |
| 346 | 331 | $this->current_item[ $this->current_namespace ][ $el ], $text); |
| 347 | - } |
|
| 348 | - elseif ($this->inchannel) { |
|
| 332 | + } elseif ($this->inchannel) { |
|
| 349 | 333 | $this->concat( |
| 350 | 334 | $this->channel[ $this->current_namespace][ $el ], $text ); |
| 351 | - } |
|
| 352 | - elseif ($this->intextinput) { |
|
| 335 | + } elseif ($this->intextinput) { |
|
| 353 | 336 | $this->concat( |
| 354 | 337 | $this->textinput[ $this->current_namespace][ $el ], $text ); |
| 355 | - } |
|
| 356 | - elseif ($this->inimage) { |
|
| 338 | + } elseif ($this->inimage) { |
|
| 357 | 339 | $this->concat( |
| 358 | 340 | $this->image[ $this->current_namespace ][ $el ], $text ); |
| 359 | 341 | } |
| 360 | - } |
|
| 361 | - else { |
|
| 342 | + } else { |
|
| 362 | 343 | if ( $this->initem ) { |
| 363 | 344 | $this->concat( |
| 364 | 345 | $this->current_item[ $el ], $text); |
| 365 | - } |
|
| 366 | - elseif ($this->intextinput) { |
|
| 346 | + } elseif ($this->intextinput) { |
|
| 367 | 347 | $this->concat( |
| 368 | 348 | $this->textinput[ $el ], $text ); |
| 369 | - } |
|
| 370 | - elseif ($this->inimage) { |
|
| 349 | + } elseif ($this->inimage) { |
|
| 371 | 350 | $this->concat( |
| 372 | 351 | $this->image[ $el ], $text ); |
| 373 | - } |
|
| 374 | - elseif ($this->inchannel) { |
|
| 352 | + } elseif ($this->inchannel) { |
|
| 375 | 353 | $this->concat( |
| 376 | 354 | $this->channel[ $el ], $text ); |
| 377 | 355 | } |
@@ -385,10 +363,12 @@ discard block |
||
| 385 | 363 | $this->channel['description'] = $this->channel['tagline']; |
| 386 | 364 | for ( $i = 0; $i < count($this->items); $i++) { |
| 387 | 365 | $item = $this->items[$i]; |
| 388 | - if ( isset($item['summary']) ) |
|
| 389 | - $item['description'] = $item['summary']; |
|
| 390 | - if ( isset($item['atom_content'])) |
|
| 391 | - $item['content']['encoded'] = $item['atom_content']; |
|
| 366 | + if ( isset($item['summary']) ) { |
|
| 367 | + $item['description'] = $item['summary']; |
|
| 368 | + } |
|
| 369 | + if ( isset($item['atom_content'])) { |
|
| 370 | + $item['content']['encoded'] = $item['atom_content']; |
|
| 371 | + } |
|
| 392 | 372 | |
| 393 | 373 | $atom_date = (isset($item['issued']) ) ? $item['issued'] : @$item['modified']; |
| 394 | 374 | if ( $atom_date ) { |
@@ -400,23 +380,23 @@ discard block |
||
| 400 | 380 | |
| 401 | 381 | $this->items[$i] = $item; |
| 402 | 382 | } |
| 403 | - } |
|
| 404 | - elseif ( $this->is_rss() ) { |
|
| 383 | + } elseif ( $this->is_rss() ) { |
|
| 405 | 384 | $this->channel['tagline'] = $this->channel['description']; |
| 406 | 385 | for ( $i = 0; $i < count($this->items); $i++) { |
| 407 | 386 | $item = $this->items[$i]; |
| 408 | - if ( isset($item['description'])) |
|
| 409 | - $item['summary'] = $item['description']; |
|
| 410 | - if ( isset($item['content']['encoded'] ) ) |
|
| 411 | - $item['atom_content'] = $item['content']['encoded']; |
|
| 387 | + if ( isset($item['description'])) { |
|
| 388 | + $item['summary'] = $item['description']; |
|
| 389 | + } |
|
| 390 | + if ( isset($item['content']['encoded'] ) ) { |
|
| 391 | + $item['atom_content'] = $item['content']['encoded']; |
|
| 392 | + } |
|
| 412 | 393 | |
| 413 | 394 | if ( $this->is_rss() == '1.0' and isset($item['dc']['date']) ) { |
| 414 | 395 | $epoch = @parse_w3cdtf($item['dc']['date']); |
| 415 | 396 | if ($epoch and $epoch > 0) { |
| 416 | 397 | $item['date_timestamp'] = $epoch; |
| 417 | 398 | } |
| 418 | - } |
|
| 419 | - elseif ( isset($item['pubdate']) ) { |
|
| 399 | + } elseif ( isset($item['pubdate']) ) { |
|
| 420 | 400 | $epoch = @strtotime($item['pubdate']); |
| 421 | 401 | if ($epoch > 0) { |
| 422 | 402 | $item['date_timestamp'] = $epoch; |
@@ -432,8 +412,7 @@ discard block |
||
| 432 | 412 | function is_rss () { |
| 433 | 413 | if ( $this->feed_type == RSS ) { |
| 434 | 414 | return $this->feed_version; |
| 435 | - } |
|
| 436 | - else { |
|
| 415 | + } else { |
|
| 437 | 416 | return false; |
| 438 | 417 | } |
| 439 | 418 | } |
@@ -441,8 +420,7 @@ discard block |
||
| 441 | 420 | function is_atom() { |
| 442 | 421 | if ( $this->feed_type == ATOM ) { |
| 443 | 422 | return $this->feed_version; |
| 444 | - } |
|
| 445 | - else { |
|
| 423 | + } else { |
|
| 446 | 424 | return false; |
| 447 | 425 | } |
| 448 | 426 | } |
@@ -454,8 +432,7 @@ discard block |
||
| 454 | 432 | function create_parser($source, $out_enc, $in_enc, $detect) { |
| 455 | 433 | if ( substr(phpversion(),0,1) == 5) { |
| 456 | 434 | $parser = $this->php5_create_parser($in_enc, $detect); |
| 457 | - } |
|
| 458 | - else { |
|
| 435 | + } else { |
|
| 459 | 436 | list($parser, $source) = $this->php4_create_parser($source, $in_enc, $detect); |
| 460 | 437 | } |
| 461 | 438 | if ($out_enc) { |
@@ -479,8 +456,7 @@ discard block |
||
| 479 | 456 | // by default php5 does a fine job of detecting input encodings |
| 480 | 457 | if(!$detect && $in_enc) { |
| 481 | 458 | return xml_parser_create($in_enc); |
| 482 | - } |
|
| 483 | - else { |
|
| 459 | + } else { |
|
| 484 | 460 | return xml_parser_create(''); |
| 485 | 461 | } |
| 486 | 462 | } |
@@ -509,8 +485,7 @@ discard block |
||
| 509 | 485 | if (preg_match('/<?xml.*encoding=[\'"](.*?)[\'"].*?>/m', $source, $m)) { |
| 510 | 486 | $in_enc = strtoupper($m[1]); |
| 511 | 487 | $this->source_encoding = $in_enc; |
| 512 | - } |
|
| 513 | - else { |
|
| 488 | + } else { |
|
| 514 | 489 | $in_enc = 'UTF-8'; |
| 515 | 490 | } |
| 516 | 491 | } |
@@ -555,8 +530,7 @@ discard block |
||
| 555 | 530 | $enc = strtoupper($enc); |
| 556 | 531 | if ( in_array($enc, $this->_KNOWN_ENCODINGS) ) { |
| 557 | 532 | return $enc; |
| 558 | - } |
|
| 559 | - else { |
|
| 533 | + } else { |
|
| 560 | 534 | return false; |
| 561 | 535 | } |
| 562 | 536 | } |
@@ -568,8 +542,7 @@ discard block |
||
| 568 | 542 | } |
| 569 | 543 | if ( MAGPIE_DEBUG ) { |
| 570 | 544 | trigger_error( $errormsg, $lvl); |
| 571 | - } |
|
| 572 | - else { |
|
| 545 | + } else { |
|
| 573 | 546 | error_log( $errormsg, 0); |
| 574 | 547 | } |
| 575 | 548 | |
@@ -604,8 +577,7 @@ discard block |
||
| 604 | 577 | $offset = 0; |
| 605 | 578 | if ( $match[10] == 'Z' ) { |
| 606 | 579 | # zulu time, aka GMT |
| 607 | - } |
|
| 608 | - else { |
|
| 580 | + } else { |
|
| 609 | 581 | list( $tz_mod, $tz_hour, $tz_min ) = |
| 610 | 582 | array( $match[8], $match[9], $match[10]); |
| 611 | 583 | |
@@ -625,8 +597,7 @@ discard block |
||
| 625 | 597 | } |
| 626 | 598 | $epoch = $epoch + $offset; |
| 627 | 599 | return $epoch; |
| 628 | - } |
|
| 629 | - else { |
|
| 600 | + } else { |
|
| 630 | 601 | return -1; |
| 631 | 602 | } |
| 632 | 603 | } |
@@ -93,6 +93,10 @@ |
||
| 93 | 93 | $this->version = $version; |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | + /** |
|
| 97 | + * @param string $var |
|
| 98 | + * @param FeedImage $val |
|
| 99 | + */ |
|
| 96 | 100 | function setVar($var, $val, $encoding = false) |
| 97 | 101 | { |
| 98 | 102 | if(!empty($encoding)) $val = $this->convert_encoding($val); |
@@ -95,7 +95,9 @@ discard block |
||
| 95 | 95 | |
| 96 | 96 | function setVar($var, $val, $encoding = false) |
| 97 | 97 | { |
| 98 | - if(!empty($encoding)) $val = $this->convert_encoding($val); |
|
| 98 | + if(!empty($encoding)) { |
|
| 99 | + $val = $this->convert_encoding($val); |
|
| 100 | + } |
|
| 99 | 101 | $this->$var = $val; |
| 100 | 102 | } |
| 101 | 103 | |
@@ -105,7 +107,7 @@ discard block |
||
| 105 | 107 | foreach(array_keys($val) as $key){ |
| 106 | 108 | $val[$key] = $this->convert_encoding($val[$key]); |
| 107 | 109 | } |
| 108 | - }else{ |
|
| 110 | + } else{ |
|
| 109 | 111 | $val = XoopsLocal::convert_encoding($val, $this->encoding, _CHARSET); |
| 110 | 112 | } |
| 111 | 113 | return $val; |
@@ -136,7 +138,9 @@ discard block |
||
| 136 | 138 | |
| 137 | 139 | function addItems(&$items) |
| 138 | 140 | { |
| 139 | - if(!is_array($items) || count($items)==0) return; |
|
| 141 | + if(!is_array($items) || count($items)==0) { |
|
| 142 | + return; |
|
| 143 | + } |
|
| 140 | 144 | foreach($items as $item){ |
| 141 | 145 | $this->_addItem($item); |
| 142 | 146 | } |
@@ -53,13 +53,6 @@ |
||
| 53 | 53 | * @param string $content string containing the RSS to be parsed |
| 54 | 54 | * |
| 55 | 55 | * |
| 56 | - * @param string $output_encoding output the parsed RSS in this character |
|
| 57 | - * set defaults to ISO-8859-1 as this is PHP's |
|
| 58 | - * default. |
|
| 59 | - * |
|
| 60 | - * @param string $input_encoding the character set of the incoming RSS source. |
|
| 61 | - * Leave blank and Magpie will try to figure it |
|
| 62 | - * out. |
|
| 63 | 56 | * |
| 64 | 57 | */ |
| 65 | 58 | function XmlParser ($content, $input_charset, $output_charset = _CHARSET, $tags = array()) |
@@ -85,8 +85,7 @@ discard block |
||
| 85 | 85 | if ( $this->feed_type == ATOM ) { |
| 86 | 86 | $this->feed_version = empty($this->feed_version)?"0.3":$this->feed_version; |
| 87 | 87 | return $this->feed_version; |
| 88 | - } |
|
| 89 | - else { |
|
| 88 | + } else { |
|
| 90 | 89 | return false; |
| 91 | 90 | } |
| 92 | 91 | } |
@@ -100,7 +99,9 @@ discard block |
||
| 100 | 99 | } |
| 101 | 100 | for ( $i = 0; $i < count($this->items); $i++) { |
| 102 | 101 | // ATOM time |
| 103 | - if($date = @$this->items[$i]['modified']) continue; |
|
| 102 | + if($date = @$this->items[$i]['modified']) { |
|
| 103 | + continue; |
|
| 104 | + } |
|
| 104 | 105 | if(empty($date)){ |
| 105 | 106 | $date = @$this->items[$i]['updated']; |
| 106 | 107 | } |
@@ -114,10 +115,11 @@ discard block |
||
| 114 | 115 | $date = @$this->items[$i]['created']; |
| 115 | 116 | } |
| 116 | 117 | $this->items[$i]['modified'] = $date; |
| 117 | - } |
|
| 118 | - elseif($this->is_rss() != '1.0'): |
|
| 118 | + } elseif($this->is_rss() != '1.0'): |
|
| 119 | 119 | for ( $i = 0; $i < count($this->items); $i++) { |
| 120 | - if($date = @$this->items[$i]['pubdate']) continue; |
|
| 120 | + if($date = @$this->items[$i]['pubdate']) { |
|
| 121 | + continue; |
|
| 122 | + } |
|
| 121 | 123 | $this->items[$i]['pubdate'] = @$this->items[$i]['dc']['date']; |
| 122 | 124 | } |
| 123 | 125 | endif; |
@@ -139,27 +141,31 @@ discard block |
||
| 139 | 141 | } |
| 140 | 142 | |
| 141 | 143 | for ( $i = 0; $i < count($this->items); $i++) { |
| 142 | - if($date_timestamp = @$this->items[$i]['date_timestamp']) continue; |
|
| 144 | + if($date_timestamp = @$this->items[$i]['date_timestamp']) { |
|
| 145 | + continue; |
|
| 146 | + } |
|
| 143 | 147 | if($date_timestamp = @$this->items[$i]['pubdate']){ |
| 144 | 148 | $this->items[$i]['date_timestamp'] = $date_timestamp; |
| 145 | - }elseif($date_timestamp = @$this->items[$i]['dc']['date']){ |
|
| 149 | + } elseif($date_timestamp = @$this->items[$i]['dc']['date']){ |
|
| 146 | 150 | $this->items[$i]['date_timestamp'] = $date_timestamp; |
| 147 | - }else{ |
|
| 151 | + } else{ |
|
| 148 | 152 | $this->items[$i]['date_timestamp'] = time(); |
| 149 | 153 | } |
| 150 | 154 | if(!is_numeric($this->items[$i]['date_timestamp'])){ |
| 151 | 155 | if($date = parse_w3cdtf($this->items[$i]['date_timestamp'])) { |
| 152 | 156 | $this->items[$i]['date_timestamp'] = $date; |
| 153 | - }elseif($date = strtotime($this->items[$i]['date_timestamp'])) { |
|
| 157 | + } elseif($date = strtotime($this->items[$i]['date_timestamp'])) { |
|
| 154 | 158 | $this->items[$i]['date_timestamp'] = $date; |
| 155 | 159 | } |
| 156 | 160 | } |
| 157 | 161 | |
| 158 | 162 | /* remove to avoid redundant encoding conversion */ |
| 159 | - if ( isset($this->items[$i]['summary']) ) |
|
| 160 | - unset($this->items[$i]['summary']); |
|
| 161 | - if ( isset($this->items[$i]['atom_content'])) |
|
| 162 | - unset($this->items[$i]['atom_content']); |
|
| 163 | + if ( isset($this->items[$i]['summary']) ) { |
|
| 164 | + unset($this->items[$i]['summary']); |
|
| 165 | + } |
|
| 166 | + if ( isset($this->items[$i]['atom_content'])) { |
|
| 167 | + unset($this->items[$i]['atom_content']); |
|
| 168 | + } |
|
| 163 | 169 | } |
| 164 | 170 | return; |
| 165 | 171 | } |
@@ -178,7 +184,7 @@ discard block |
||
| 178 | 184 | foreach(array_keys($val) as $key){ |
| 179 | 185 | $val[$key] = $this->_encoding($val[$key]); |
| 180 | 186 | } |
| 181 | - }else{ |
|
| 187 | + } else{ |
|
| 182 | 188 | $val = XoopsLocal::convert_encoding($val, $this->charset_out, $this->charset_in); |
| 183 | 189 | } |
| 184 | 190 | return $val; |
@@ -37,11 +37,17 @@ |
||
| 37 | 37 | if(!defined("PLANET_FUNCTIONS_INI")): |
| 38 | 38 | define("PLANET_FUNCTIONS_INI",1); |
| 39 | 39 | |
| 40 | +/** |
|
| 41 | + * @param string $name |
|
| 42 | + */ |
|
| 40 | 43 | function planet_constant($name) |
| 41 | 44 | { |
| 42 | 45 | return mod_constant($name); |
| 43 | 46 | } |
| 44 | 47 | |
| 48 | +/** |
|
| 49 | + * @param string $name |
|
| 50 | + */ |
|
| 45 | 51 | function planet_DB_prefix($name, $isRel = false) |
| 46 | 52 | { |
| 47 | 53 | return mod_DB_prefix($name, $isRel); |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | if(is_object($GLOBALS["xoopsModule"]) && $GLOBALS["xoopsModule"]->getVar("dirname") == $GLOBALS["moddirname"]){ |
| 63 | 63 | $moduleConfig =& $GLOBALS["xoopsModuleConfig"]; |
| 64 | - }else{ |
|
| 64 | + } else{ |
|
| 65 | 65 | $module_handler = &xoops_gethandler('module'); |
| 66 | 66 | $module = $module_handler->getByDirname($GLOBALS["moddirname"]); |
| 67 | 67 | |
@@ -82,12 +82,14 @@ discard block |
||
| 82 | 82 | function planet_define_url_delimiter() |
| 83 | 83 | { |
| 84 | 84 | if(defined("URL_DELIMITER")){ |
| 85 | - if(!in_array(URL_DELIMITER, array("?","/"))) die("Exit on security"); |
|
| 86 | - }else{ |
|
| 85 | + if(!in_array(URL_DELIMITER, array("?","/"))) { |
|
| 86 | + die("Exit on security"); |
|
| 87 | + } |
|
| 88 | + } else{ |
|
| 87 | 89 | $moduleConfig = planet_load_config(); |
| 88 | 90 | if(empty($moduleConfig["do_urw"])){ |
| 89 | 91 | define("URL_DELIMITER", "?"); |
| 90 | - }else{ |
|
| 92 | + } else{ |
|
| 91 | 93 | define("URL_DELIMITER", "/"); |
| 92 | 94 | } |
| 93 | 95 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | * @var mixed $pattern |
| 99 | 99 | * @var mixed $replacement |
| 100 | 100 | * |
| 101 | - * @return bool true on success |
|
| 101 | + * @return null|boolean true on success |
|
| 102 | 102 | */ |
| 103 | 103 | function planet_parse_class($class_string, $pattern="", $replacement="") |
| 104 | 104 | { |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | * @var mixed $pattern |
| 132 | 132 | * @var mixed $replacement |
| 133 | 133 | * |
| 134 | - * @return bool true on success |
|
| 134 | + * @return null|boolean true on success |
|
| 135 | 135 | */ |
| 136 | 136 | function planet_parse_function($function_string, $pattern="", $replacement="") |
| 137 | 137 | { |
@@ -28,7 +28,9 @@ discard block |
||
| 28 | 28 | if (!defined('XOOPS_ROOT_PATH')){ exit(); } |
| 29 | 29 | |
| 30 | 30 | $current_path = __FILE__; |
| 31 | -if ( DIRECTORY_SEPARATOR != '/' ) $current_path = str_replace( strpos( $current_path, '\\\\', 2 ) ? '\\\\' : DIRECTORY_SEPARATOR, '/', $current_path); |
|
| 31 | +if ( DIRECTORY_SEPARATOR != '/' ) { |
|
| 32 | + $current_path = str_replace( strpos( $current_path, '\\\\', 2 ) ? '\\\\' : DIRECTORY_SEPARATOR, '/', $current_path); |
|
| 33 | +} |
|
| 32 | 34 | $url_arr = explode('/',strstr($current_path,'/modules/')); |
| 33 | 35 | $GLOBALS["moddirname"] = $url_arr[2]; |
| 34 | 36 | |
@@ -76,13 +78,13 @@ discard block |
||
| 76 | 78 | foreach($vars as $var){ |
| 77 | 79 | if(is_numeric($var)){ |
| 78 | 80 | $args_numeric[] = $var; |
| 79 | - }elseif(false === strpos($var, "=")){ |
|
| 81 | + } elseif(false === strpos($var, "=")){ |
|
| 80 | 82 | if(is_numeric(substr($var, 1))){ |
| 81 | 83 | $args[$args_abb[strtolower($var{0})]] = intval(substr($var, 1)); |
| 82 | - }else{ |
|
| 84 | + } else{ |
|
| 83 | 85 | $args_string[] = urldecode($var); |
| 84 | 86 | } |
| 85 | - }else{ |
|
| 87 | + } else{ |
|
| 86 | 88 | parse_str($var, $args); |
| 87 | 89 | } |
| 88 | 90 | } |
@@ -102,7 +104,9 @@ discard block |
||
| 102 | 104 | */ |
| 103 | 105 | function planet_parse_class($class_string, $pattern="", $replacement="") |
| 104 | 106 | { |
| 105 | - if(empty($class_string)) return; |
|
| 107 | + if(empty($class_string)) { |
|
| 108 | + return; |
|
| 109 | + } |
|
| 106 | 110 | $patterns = array("/\[CLASS_PREFIX\]/"); |
| 107 | 111 | $replacements = array(ucfirst(strtolower($GLOBALS["moddirname"]))); |
| 108 | 112 | if(!empty($pattern) && !is_array($pattern) && !is_array($replacement)){ |
@@ -135,7 +139,9 @@ discard block |
||
| 135 | 139 | */ |
| 136 | 140 | function planet_parse_function($function_string, $pattern="", $replacement="") |
| 137 | 141 | { |
| 138 | - if(empty($function_string)) return; |
|
| 142 | + if(empty($function_string)) { |
|
| 143 | + return; |
|
| 144 | + } |
|
| 139 | 145 | $patterns = array("/\[DIRNAME\]/", "/\[VAR_PREFIX\]/"); |
| 140 | 146 | $replacements = array($GLOBALS["moddirname"], $GLOBALS["VAR_PREFIX"]); |
| 141 | 147 | if(!empty($pattern) && !is_array($pattern) && !is_array($replacement)){ |
@@ -162,7 +168,9 @@ discard block |
||
| 162 | 168 | */ |
| 163 | 169 | function planet_formatTimestamp($time, $format = "") |
| 164 | 170 | { |
| 165 | - if(empty($time)) return ""; |
|
| 171 | + if(empty($time)) { |
|
| 172 | + return ""; |
|
| 173 | + } |
|
| 166 | 174 | return formatTimestamp($time, $format); |
| 167 | 175 | } |
| 168 | 176 | |
@@ -172,7 +180,9 @@ discard block |
||
| 172 | 180 | */ |
| 173 | 181 | function &planet_getUnameFromId( $userid, $usereal = 0, $linked = false ) |
| 174 | 182 | { |
| 175 | - if(!is_array($userid)) $userid = array($userid); |
|
| 183 | + if(!is_array($userid)) { |
|
| 184 | + $userid = array($userid); |
|
| 185 | + } |
|
| 176 | 186 | $users = mod_getUnameFromIds($userid, $usereal, $linked); |
| 177 | 187 | |
| 178 | 188 | return $users; |
@@ -191,9 +201,13 @@ discard block |
||
| 191 | 201 | $myts =& MyTextSanitizer::getInstance(); |
| 192 | 202 | $link_array = preg_split("/(\r\n|\r|\n)( *)/", $text); |
| 193 | 203 | $links = array(); |
| 194 | - if(count($link_array)>0) foreach($link_array as $link){ |
|
| 204 | + if(count($link_array)>0) { |
|
| 205 | + foreach($link_array as $link){ |
|
| 195 | 206 | @list($url, $title) = array_map("trim",preg_split("/ /", $link, 2)); |
| 196 | - if(empty($url)) continue; |
|
| 207 | + } |
|
| 208 | + if(empty($url)) { |
|
| 209 | + continue; |
|
| 210 | + } |
|
| 197 | 211 | //if(empty($title)) $title = $url; |
| 198 | 212 | $links[] = array("url"=>$url, "title"=>$myts->htmlSpecialChars($title)); |
| 199 | 213 | } |
@@ -220,7 +234,9 @@ discard block |
||
| 220 | 234 | { |
| 221 | 235 | $blog_handler =& xoops_getmodulehandler("blog", $GLOBALS["moddirname"]); |
| 222 | 236 | $blog_obj =& $blog_handler->get($article->getVar("blog_id")); |
| 223 | - if(!$pattern = $blog_obj->getVar("blog_trackback")) return false; |
|
| 237 | + if(!$pattern = $blog_obj->getVar("blog_trackback")) { |
|
| 238 | + return false; |
|
| 239 | + } |
|
| 224 | 240 | @list($pat, $rep) = array_map("trim",preg_split("#[\s]+#", $pattern)); |
| 225 | 241 | $trackback_url = preg_replace("#".$pat."#", $rep, $article_obj->getVar("art_link")); |
| 226 | 242 | return planet_trackback($trackback_url, $article); |
@@ -271,7 +287,7 @@ discard block |
||
| 271 | 287 | if($fp = fopen($debug_file, "a")){ |
| 272 | 288 | fwrite($fp, $fr); |
| 273 | 289 | fclose($fp); |
| 274 | - }else{ |
|
| 290 | + } else{ |
|
| 275 | 291 | } |
| 276 | 292 | } |
| 277 | 293 | @fclose($fs); |
@@ -301,9 +317,11 @@ discard block |
||
| 301 | 317 | $home = XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/"; |
| 302 | 318 | $rss2_url = XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/xml.php".URL_DELIMITER."rss2.0/".$id; |
| 303 | 319 | |
| 304 | - if ( !$client->query('weblogUpdates.extendedPing', $blogname, $home, $rss2_url ) ) // then try a normal ping |
|
| 320 | + if ( !$client->query('weblogUpdates.extendedPing', $blogname, $home, $rss2_url ) ) { |
|
| 321 | + // then try a normal ping |
|
| 305 | 322 | $client->query('weblogUpdates.ping', $blogname, $home); |
| 306 | -} |
|
| 323 | + } |
|
| 324 | + } |
|
| 307 | 325 | |
| 308 | 326 | /** |
| 309 | 327 | * Function to respond to a trackback |
@@ -350,8 +368,10 @@ discard block |
||
| 350 | 368 | if($isArray) { |
| 351 | 369 | $_value = ($value)?explode(",", $value):array(); |
| 352 | 370 | $value = array(); |
| 353 | - if(count($_value)>0) foreach($_value as $string){ |
|
| 371 | + if(count($_value)>0) { |
|
| 372 | + foreach($_value as $string){ |
|
| 354 | 373 | $key = substr($string, 0, strpos($string,"|")); |
| 374 | + } |
|
| 355 | 375 | $val = substr($string, (strpos($string,"|")+1)); |
| 356 | 376 | $value[$key] = $val; |
| 357 | 377 | } |
@@ -379,9 +399,15 @@ discard block |
||
| 379 | 399 | |
| 380 | 400 | function planet_remote_content($url) |
| 381 | 401 | { |
| 382 | - if($data = planet_fetch_snoopy($url)) return $data; |
|
| 383 | - if($data = planet_fetch_CURL($url)) return $data; |
|
| 384 | - if($data = planet_fetch_fopen($url)) return $data; |
|
| 402 | + if($data = planet_fetch_snoopy($url)) { |
|
| 403 | + return $data; |
|
| 404 | + } |
|
| 405 | + if($data = planet_fetch_CURL($url)) { |
|
| 406 | + return $data; |
|
| 407 | + } |
|
| 408 | + if($data = planet_fetch_fopen($url)) { |
|
| 409 | + return $data; |
|
| 410 | + } |
|
| 385 | 411 | return false; |
| 386 | 412 | } |
| 387 | 413 | |
@@ -398,7 +424,9 @@ discard block |
||
| 398 | 424 | |
| 399 | 425 | function planet_fetch_CURL($url) |
| 400 | 426 | { |
| 401 | - if (!function_exists('curl_init') ) return false; |
|
| 427 | + if (!function_exists('curl_init') ) { |
|
| 428 | + return false; |
|
| 429 | + } |
|
| 402 | 430 | $ch = curl_init(); // initialize curl handle |
| 403 | 431 | curl_setopt($ch, CURLOPT_URL, $url); // set url to post to |
| 404 | 432 | curl_setopt($ch, CURLOPT_FAILONERROR, 1); |
@@ -412,7 +440,9 @@ discard block |
||
| 412 | 440 | |
| 413 | 441 | function planet_fetch_fopen($url) |
| 414 | 442 | { |
| 415 | - if(!$fp = @fopen ($url, 'r')) return false; |
|
| 443 | + if(!$fp = @fopen ($url, 'r')) { |
|
| 444 | + return false; |
|
| 445 | + } |
|
| 416 | 446 | $data = ""; |
| 417 | 447 | while (!feof($fp)) { |
| 418 | 448 | $data .= fgets ($fp, 1024); |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | |
| 182 | 182 | if(!empty($blog_data)){ |
| 183 | 183 | $blogs[$blog_data["id"]] = $blog_data["title"]; |
| 184 | -}else{ |
|
| 184 | +} else{ |
|
| 185 | 185 | $blog_array = array(); |
| 186 | 186 | foreach (array_keys($articles_obj) as $id) { |
| 187 | 187 | $blog_array[$articles_obj[$id]->getVar("blog_id")] = 1; |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | ); |
| 211 | 211 | if(!empty($xoopsModuleConfig["display_summary"])){ |
| 212 | 212 | $_article["content"] = $articles_obj[$id]->getSummary(); |
| 213 | - }else{ |
|
| 213 | + } else{ |
|
| 214 | 214 | $_article["content"] = $articles_obj[$id]->getVar("art_content"); |
| 215 | 215 | } |
| 216 | 216 | } |
@@ -222,10 +222,18 @@ discard block |
||
| 222 | 222 | if ( $count_article > $limit) { |
| 223 | 223 | include(XOOPS_ROOT_PATH."/class/pagenav.php"); |
| 224 | 224 | $start_link = array(); |
| 225 | - if($sort) $start_link[] = "sort=".$sort; |
|
| 226 | - if($category_id) $start_link[] = "category=".$category_id; |
|
| 227 | - if($blog_id) $start_link[] = "blog=".$blog_id; |
|
| 228 | - if($list) $start_link[] = "list=".$list; |
|
| 225 | + if($sort) { |
|
| 226 | + $start_link[] = "sort=".$sort; |
|
| 227 | + } |
|
| 228 | + if($category_id) { |
|
| 229 | + $start_link[] = "category=".$category_id; |
|
| 230 | + } |
|
| 231 | + if($blog_id) { |
|
| 232 | + $start_link[] = "blog=".$blog_id; |
|
| 233 | + } |
|
| 234 | + if($list) { |
|
| 235 | + $start_link[] = "list=".$list; |
|
| 236 | + } |
|
| 229 | 237 | $nav = new XoopsPageNav($count_article, $limit, $start, "start", implode("&", $start_link)); |
| 230 | 238 | $pagenav = $nav->renderNav(4); |
| 231 | 239 | } else { |
@@ -272,7 +280,7 @@ discard block |
||
| 272 | 280 | |
| 273 | 281 | $xoopsTpl -> assign("user_level", !is_object($xoopsUser)?0:($xoopsUser->isAdmin()?2:1)); |
| 274 | 282 | if(empty($xoopsModuleConfig["anonymous_rate"]) && !is_object($xoopsUser)){ |
| 275 | -}elseif($blog_id>0){ |
|
| 283 | +} elseif($blog_id>0){ |
|
| 276 | 284 | $xoopsTpl -> assign("canrate", 1); |
| 277 | 285 | } |
| 278 | 286 | |
@@ -284,7 +292,9 @@ discard block |
||
| 284 | 292 | $valid_sorts = array("views"=>planet_constant("MD_VIEWS"), "rating"=>planet_constant("MD_RATING"), "time"=>planet_constant("MD_TIME"), "default"=>planet_constant("MD_DEFAULT")); |
| 285 | 293 | $sortlinks = array(); |
| 286 | 294 | foreach($valid_sorts as $val=>$name){ |
| 287 | - if($val == $sort) continue; |
|
| 295 | + if($val == $sort) { |
|
| 296 | + continue; |
|
| 297 | + } |
|
| 288 | 298 | $sortlinks[] = "<a href=\"".$sort_link."/".$val."\">".$name."</a>"; |
| 289 | 299 | } |
| 290 | 300 | $xoopsTpl -> assign("link_sort", implode(" | ", $sortlinks)); |