@@ -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) |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | * |
| 45 | 45 | * {@link XoopsObject} |
| 46 | 46 | **/ |
| 47 | -if(!class_exists("Barticle")): |
|
| 47 | +if (!class_exists("Barticle")): |
|
| 48 | 48 | |
| 49 | 49 | class Barticle extends ArtObject |
| 50 | 50 | { |
@@ -100,7 +100,7 @@ discard block |
||
| 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)) $time = time(); |
|
| 104 | 104 | $time = planet_formatTimestamp($time, $format); |
| 105 | 105 | return $time; |
| 106 | 106 | } |
@@ -116,10 +116,10 @@ discard block |
||
| 116 | 116 | { |
| 117 | 117 | $content = $this->getVar("art_content"); |
| 118 | 118 | $summary = planet_html2text($content); |
| 119 | - if(empty($length)){ |
|
| 119 | + if (empty($length)) { |
|
| 120 | 120 | $length = $GLOBALS["xoopsModuleConfig"]["display_summary"]; |
| 121 | 121 | } |
| 122 | - if(!empty($length)){ |
|
| 122 | + if (!empty($length)) { |
|
| 123 | 123 | $summary = xoops_substr($summary, 0, $length); |
| 124 | 124 | } |
| 125 | 125 | return $summary; |
@@ -134,9 +134,9 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | function getRatingAverage($decimals = 1) |
| 136 | 136 | { |
| 137 | - $ave=3; |
|
| 138 | - if($this->getVar("art_rates")){ |
|
| 139 | - $ave = number_format($this->getVar("art_rating")/$this->getVar("art_rates"),$decimals); |
|
| 137 | + $ave = 3; |
|
| 138 | + if ($this->getVar("art_rates")) { |
|
| 139 | + $ave = number_format($this->getVar("art_rating")/$this->getVar("art_rates"), $decimals); |
|
| 140 | 140 | } |
| 141 | 141 | return $ave; |
| 142 | 142 | } |
@@ -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; |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | class IXR_Value { |
| 14 | 14 | var $data; |
| 15 | 15 | var $type; |
| 16 | - function IXR_Value ($data, $type = false) { |
|
| 16 | + function IXR_Value($data, $type = false) { |
|
| 17 | 17 | $this->data = $data; |
| 18 | 18 | if (!$type) { |
| 19 | 19 | $type = $this->calculateType(); |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | } |
| 27 | 27 | } |
| 28 | 28 | if ($type == 'array') { |
| 29 | - for ($i = 0, $j = count($this->data); $i < $j; $i++) { |
|
| 29 | + for ($i = 0, $j = count($this->data); $i<$j; $i++) { |
|
| 30 | 30 | $this->data[$i] = new IXR_Value($this->data[$i]); |
| 31 | 31 | } |
| 32 | 32 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | /* We have an array - is it an array or a struct ? */ |
| 61 | 61 | if ($this->isStruct($this->data)) { |
| 62 | 62 | return 'struct'; |
| 63 | - } else { |
|
| 63 | + }else { |
|
| 64 | 64 | return 'array'; |
| 65 | 65 | } |
| 66 | 66 | } |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | /* Nasty function to check if an array is a struct or not */ |
| 108 | 108 | $expected = 0; |
| 109 | 109 | foreach ($array as $key => $value) { |
| 110 | - if ((string)$key != (string)$expected) { |
|
| 110 | + if ((string) $key != (string) $expected) { |
|
| 111 | 111 | return true; |
| 112 | 112 | } |
| 113 | 113 | $expected++; |
@@ -119,22 +119,22 @@ discard block |
||
| 119 | 119 | |
| 120 | 120 | class IXR_Message { |
| 121 | 121 | var $message; |
| 122 | - var $messageType; // methodCall / methodResponse / fault |
|
| 122 | + var $messageType; // methodCall / methodResponse / fault |
|
| 123 | 123 | var $faultCode; |
| 124 | 124 | var $faultString; |
| 125 | 125 | var $methodName; |
| 126 | 126 | var $params; |
| 127 | 127 | // Current variable stacks |
| 128 | - var $_arraystructs = array(); // The stack used to keep track of the current array/struct |
|
| 128 | + var $_arraystructs = array(); // The stack used to keep track of the current array/struct |
|
| 129 | 129 | var $_arraystructstypes = array(); // Stack keeping track of if things are structs or array |
| 130 | - var $_currentStructName = array(); // A stack as well |
|
| 130 | + var $_currentStructName = array(); // A stack as well |
|
| 131 | 131 | var $_param; |
| 132 | 132 | var $_value; |
| 133 | 133 | var $_currentTag; |
| 134 | 134 | var $_currentTagContents; |
| 135 | 135 | // The XML parser |
| 136 | 136 | var $_parser; |
| 137 | - function IXR_Message ($message) { |
|
| 137 | + function IXR_Message($message) { |
|
| 138 | 138 | $this->message = $message; |
| 139 | 139 | } |
| 140 | 140 | function parse() { |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | } |
| 167 | 167 | function tag_open($parser, $tag, $attr) { |
| 168 | 168 | $this->currentTag = $tag; |
| 169 | - switch($tag) { |
|
| 169 | + switch ($tag) { |
|
| 170 | 170 | case 'methodCall': |
| 171 | 171 | case 'methodResponse': |
| 172 | 172 | case 'fault': |
@@ -188,20 +188,20 @@ discard block |
||
| 188 | 188 | } |
| 189 | 189 | function tag_close($parser, $tag) { |
| 190 | 190 | $valueFlag = false; |
| 191 | - switch($tag) { |
|
| 191 | + switch ($tag) { |
|
| 192 | 192 | case 'int': |
| 193 | 193 | case 'i4': |
| 194 | - $value = (int)trim($this->_currentTagContents); |
|
| 194 | + $value = (int) trim($this->_currentTagContents); |
|
| 195 | 195 | $this->_currentTagContents = ''; |
| 196 | 196 | $valueFlag = true; |
| 197 | 197 | break; |
| 198 | 198 | case 'double': |
| 199 | - $value = (double)trim($this->_currentTagContents); |
|
| 199 | + $value = (double) trim($this->_currentTagContents); |
|
| 200 | 200 | $this->_currentTagContents = ''; |
| 201 | 201 | $valueFlag = true; |
| 202 | 202 | break; |
| 203 | 203 | case 'string': |
| 204 | - $value = (string)trim($this->_currentTagContents); |
|
| 204 | + $value = (string) trim($this->_currentTagContents); |
|
| 205 | 205 | $this->_currentTagContents = ''; |
| 206 | 206 | $valueFlag = true; |
| 207 | 207 | break; |
@@ -214,18 +214,18 @@ discard block |
||
| 214 | 214 | case 'value': |
| 215 | 215 | // "If no type is indicated, the type is string." |
| 216 | 216 | if (trim($this->_currentTagContents) != '') { |
| 217 | - $value = (string)$this->_currentTagContents; |
|
| 217 | + $value = (string) $this->_currentTagContents; |
|
| 218 | 218 | $this->_currentTagContents = ''; |
| 219 | 219 | $valueFlag = true; |
| 220 | 220 | } |
| 221 | 221 | break; |
| 222 | 222 | case 'boolean': |
| 223 | - $value = (boolean)trim($this->_currentTagContents); |
|
| 223 | + $value = (boolean) trim($this->_currentTagContents); |
|
| 224 | 224 | $this->_currentTagContents = ''; |
| 225 | 225 | $valueFlag = true; |
| 226 | 226 | break; |
| 227 | 227 | case 'base64': |
| 228 | - $value = base64_decode( trim($this->_currentTagContents) ); |
|
| 228 | + $value = base64_decode(trim($this->_currentTagContents)); |
|
| 229 | 229 | $this->_currentTagContents = ''; |
| 230 | 230 | $valueFlag = true; |
| 231 | 231 | break; |
@@ -254,16 +254,16 @@ discard block |
||
| 254 | 254 | $value = trim($value); |
| 255 | 255 | } |
| 256 | 256 | */ |
| 257 | - if (count($this->_arraystructs) > 0) { |
|
| 257 | + if (count($this->_arraystructs)>0) { |
|
| 258 | 258 | // Add value to struct or array |
| 259 | 259 | if ($this->_arraystructstypes[count($this->_arraystructstypes)-1] == 'struct') { |
| 260 | 260 | // Add to struct |
| 261 | 261 | $this->_arraystructs[count($this->_arraystructs)-1][$this->_currentStructName[count($this->_currentStructName)-1]] = $value; |
| 262 | - } else { |
|
| 262 | + }else { |
|
| 263 | 263 | // Add to array |
| 264 | 264 | $this->_arraystructs[count($this->_arraystructs)-1][] = $value; |
| 265 | 265 | } |
| 266 | - } else { |
|
| 266 | + }else { |
|
| 267 | 267 | // Just add as a paramater |
| 268 | 268 | $this->params[] = $value; |
| 269 | 269 | } |
@@ -343,13 +343,13 @@ discard block |
||
| 343 | 343 | } |
| 344 | 344 | // Call the method |
| 345 | 345 | $result = $this->$method($args); |
| 346 | - } else { |
|
| 346 | + }else { |
|
| 347 | 347 | // It's a function - does it exist? |
| 348 | 348 | if (is_array($method)) { |
| 349 | 349 | if (!method_exists($method[0], $method[1])) { |
| 350 | 350 | return new IXR_Error(-32601, 'server error. requested object method "'.$method[1].'" does not exist.'); |
| 351 | 351 | } |
| 352 | - } else if (!function_exists($method)) { |
|
| 352 | + }else if (!function_exists($method)) { |
|
| 353 | 353 | return new IXR_Error(-32601, 'server error. requested function "'.$method.'" does not exist.'); |
| 354 | 354 | } |
| 355 | 355 | // Call the function |
@@ -416,7 +416,7 @@ discard block |
||
| 416 | 416 | $params = $call['params']; |
| 417 | 417 | if ($method == 'system.multicall') { |
| 418 | 418 | $result = new IXR_Error(-32600, 'Recursive calls to system.multicall are forbidden'); |
| 419 | - } else { |
|
| 419 | + }else { |
|
| 420 | 420 | $result = $this->call($method, $params); |
| 421 | 421 | } |
| 422 | 422 | if (is_a($result, 'IXR_Error')) { |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | 'faultCode' => $result->code, |
| 425 | 425 | 'faultString' => $result->message |
| 426 | 426 | ); |
| 427 | - } else { |
|
| 427 | + }else { |
|
| 428 | 428 | $return[] = array($result); |
| 429 | 429 | } |
| 430 | 430 | } |
@@ -486,7 +486,7 @@ discard block |
||
| 486 | 486 | if (!$this->path) { |
| 487 | 487 | $this->path = '/'; |
| 488 | 488 | } |
| 489 | - } else { |
|
| 489 | + }else { |
|
| 490 | 490 | $this->server = $server; |
| 491 | 491 | $this->path = $path; |
| 492 | 492 | $this->port = $port; |
@@ -615,7 +615,7 @@ discard block |
||
| 615 | 615 | // $time can be a PHP timestamp or an ISO one |
| 616 | 616 | if (is_numeric($time)) { |
| 617 | 617 | $this->parseTimestamp($time); |
| 618 | - } else { |
|
| 618 | + }else { |
|
| 619 | 619 | $this->parseIso($time); |
| 620 | 620 | } |
| 621 | 621 | } |
@@ -719,7 +719,7 @@ discard block |
||
| 719 | 719 | // Check the argument types |
| 720 | 720 | $ok = true; |
| 721 | 721 | $argsbackup = $args; |
| 722 | - for ($i = 0, $j = count($args); $i < $j; $i++) { |
|
| 722 | + for ($i = 0, $j = count($args); $i<$j; $i++) { |
|
| 723 | 723 | $arg = array_shift($args); |
| 724 | 724 | $type = array_shift($signature); |
| 725 | 725 | switch ($type) { |
@@ -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; |
@@ -333,10 +333,10 @@ discard block |
||
| 333 | 333 | $result = ""; |
| 334 | 334 | } elseif ($this->syndicateHtml) { |
| 335 | 335 | $result = "<![CDATA[".$this->rawFieldContent."]]>"; |
| 336 | - } else { |
|
| 336 | + }else { |
|
| 337 | 337 | if ($this->truncSize and is_int($this->truncSize)) { |
| 338 | - $result = FeedCreator::iTrunc(htmlspecialchars($this->rawFieldContent),$this->truncSize); |
|
| 339 | - } else { |
|
| 338 | + $result = FeedCreator::iTrunc(htmlspecialchars($this->rawFieldContent), $this->truncSize); |
|
| 339 | + }else { |
|
| 340 | 340 | $result = htmlspecialchars($this->rawFieldContent); |
| 341 | 341 | } |
| 342 | 342 | } |
@@ -448,7 +448,7 @@ discard block |
||
| 448 | 448 | * @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()). |
| 449 | 449 | * @param boolean displayContents optional send the content of the file or not. If true, the file will be sent in the body of the response. |
| 450 | 450 | */ |
| 451 | - function saveFeed($format="RSS0.91", $filename="", $displayContents=true) { |
|
| 451 | + function saveFeed($format = "RSS0.91", $filename = "", $displayContents = true) { |
|
| 452 | 452 | $this->_setFormat($format); |
| 453 | 453 | $this->_feed->saveFeed($filename, $displayContents); |
| 454 | 454 | } |
@@ -466,7 +466,7 @@ discard block |
||
| 466 | 466 | * @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()). |
| 467 | 467 | * @param timeout int optional the timeout in seconds before a cached version is refreshed (defaults to 3600 = 1 hour) |
| 468 | 468 | */ |
| 469 | - function useCached($format="RSS0.91", $filename="", $timeout=3600) { |
|
| 469 | + function useCached($format = "RSS0.91", $filename = "", $timeout = 3600) { |
|
| 470 | 470 | $this->_setFormat($format); |
| 471 | 471 | $this->_feed->useCached($filename, $timeout); |
| 472 | 472 | } |
@@ -564,25 +564,25 @@ discard block |
||
| 564 | 564 | return $string; |
| 565 | 565 | } |
| 566 | 566 | |
| 567 | - $pos = strrpos($string,"."); |
|
| 567 | + $pos = strrpos($string, "."); |
|
| 568 | 568 | if ($pos>=$length-4) { |
| 569 | - $string = substr($string,0,$length-4); |
|
| 570 | - $pos = strrpos($string,"."); |
|
| 569 | + $string = substr($string, 0, $length-4); |
|
| 570 | + $pos = strrpos($string, "."); |
|
| 571 | 571 | } |
| 572 | 572 | if ($pos>=$length*0.4) { |
| 573 | - return substr($string,0,$pos+1)." ..."; |
|
| 573 | + return substr($string, 0, $pos+1)." ..."; |
|
| 574 | 574 | } |
| 575 | 575 | |
| 576 | - $pos = strrpos($string," "); |
|
| 576 | + $pos = strrpos($string, " "); |
|
| 577 | 577 | if ($pos>=$length-4) { |
| 578 | - $string = substr($string,0,$length-4); |
|
| 579 | - $pos = strrpos($string," "); |
|
| 578 | + $string = substr($string, 0, $length-4); |
|
| 579 | + $pos = strrpos($string, " "); |
|
| 580 | 580 | } |
| 581 | 581 | if ($pos>=$length*0.4) { |
| 582 | - return substr($string,0,$pos)." ..."; |
|
| 582 | + return substr($string, 0, $pos)." ..."; |
|
| 583 | 583 | } |
| 584 | 584 | |
| 585 | - return substr($string,0,$length-4)." ..."; |
|
| 585 | + return substr($string, 0, $length-4)." ..."; |
|
| 586 | 586 | |
| 587 | 587 | } |
| 588 | 588 | |
@@ -604,11 +604,11 @@ discard block |
||
| 604 | 604 | * @param indentString string a string that will be inserted before every generated line |
| 605 | 605 | * @return string the XML tags corresponding to $additionalElements |
| 606 | 606 | */ |
| 607 | - function _createAdditionalElements($elements, $indentString="") { |
|
| 607 | + function _createAdditionalElements($elements, $indentString = "") { |
|
| 608 | 608 | $ae = ""; |
| 609 | 609 | if (is_array($elements)) { |
| 610 | - foreach($elements AS $key => $value) { |
|
| 611 | - $ae.= $indentString."<$key>$value</$key>\n"; |
|
| 610 | + foreach ($elements AS $key => $value) { |
|
| 611 | + $ae .= $indentString."<$key>$value</$key>\n"; |
|
| 612 | 612 | } |
| 613 | 613 | } |
| 614 | 614 | return $ae; |
@@ -648,7 +648,7 @@ discard block |
||
| 648 | 648 | */ |
| 649 | 649 | function _generateFilename() { |
| 650 | 650 | $fileInfo = pathinfo($_SERVER["PHP_SELF"]); |
| 651 | - return substr($fileInfo["basename"],0,-(strlen($fileInfo["extension"])+1)).".xml"; |
|
| 651 | + return substr($fileInfo["basename"], 0, -(strlen($fileInfo["extension"])+1)).".xml"; |
|
| 652 | 652 | } |
| 653 | 653 | |
| 654 | 654 | |
@@ -686,12 +686,12 @@ discard block |
||
| 686 | 686 | * @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()). |
| 687 | 687 | * @param timeout int optional the timeout in seconds before a cached version is refreshed (defaults to 3600 = 1 hour) |
| 688 | 688 | */ |
| 689 | - function useCached($filename="", $timeout=3600) { |
|
| 689 | + function useCached($filename = "", $timeout = 3600) { |
|
| 690 | 690 | $this->_timeout = $timeout; |
| 691 | - if ($filename=="") { |
|
| 691 | + if ($filename == "") { |
|
| 692 | 692 | $filename = $this->_generateFilename(); |
| 693 | 693 | } |
| 694 | - if (file_exists($filename) AND (time()-filemtime($filename) < $timeout)) { |
|
| 694 | + if (file_exists($filename) AND (time()-filemtime($filename)<$timeout)) { |
|
| 695 | 695 | $this->_redirect($filename); |
| 696 | 696 | } |
| 697 | 697 | } |
@@ -705,18 +705,18 @@ discard block |
||
| 705 | 705 | * @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()). |
| 706 | 706 | * @param redirect boolean optional send an HTTP redirect header or not. If true, the user will be automatically redirected to the created file. |
| 707 | 707 | */ |
| 708 | - function saveFeed($filename="", $displayContents=true) { |
|
| 709 | - if ($filename=="") { |
|
| 708 | + function saveFeed($filename = "", $displayContents = true) { |
|
| 709 | + if ($filename == "") { |
|
| 710 | 710 | $filename = $this->_generateFilename(); |
| 711 | 711 | } |
| 712 | 712 | $feedFile = fopen($filename, "w+"); |
| 713 | 713 | if ($feedFile) { |
| 714 | - fputs($feedFile,$this->createFeed()); |
|
| 714 | + fputs($feedFile, $this->createFeed()); |
|
| 715 | 715 | fclose($feedFile); |
| 716 | 716 | if ($displayContents) { |
| 717 | 717 | $this->_redirect($filename); |
| 718 | 718 | } |
| 719 | - } else { |
|
| 719 | + }else { |
|
| 720 | 720 | echo "<br /><b>Error creating feed file, please check write permissions.</b><br />"; |
| 721 | 721 | } |
| 722 | 722 | } |
@@ -736,29 +736,29 @@ discard block |
||
| 736 | 736 | * Accepts RFC 822, ISO 8601 date formats as well as unix time stamps. |
| 737 | 737 | * @param mixed $dateString optional the date this FeedDate will represent. If not specified, the current date and time is used. |
| 738 | 738 | */ |
| 739 | - function FeedDate($dateString="") { |
|
| 739 | + function FeedDate($dateString = "") { |
|
| 740 | 740 | $tzOffset = 0; |
| 741 | - if ($dateString=="") $dateString = date("r"); |
|
| 741 | + if ($dateString == "") $dateString = date("r"); |
|
| 742 | 742 | |
| 743 | 743 | //if (is_integer($dateString)) { |
| 744 | 744 | if (is_numeric($dateString)) { |
| 745 | 745 | $this->unix = $dateString; |
| 746 | 746 | return; |
| 747 | 747 | } |
| 748 | - 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)) { |
|
| 749 | - $months = Array("Jan"=>1,"Feb"=>2,"Mar"=>3,"Apr"=>4,"May"=>5,"Jun"=>6,"Jul"=>7,"Aug"=>8,"Sep"=>9,"Oct"=>10,"Nov"=>11,"Dec"=>12); |
|
| 750 | - $this->unix = mktime($matches[4],$matches[5],$matches[6],$months[$matches[2]],$matches[1],$matches[3]); |
|
| 751 | - if (substr($matches[7],0,1)=='+' OR substr($matches[7],0,1)=='-') { |
|
| 752 | - $tzOffset = (substr($matches[7],0,3) * 60 + substr($matches[7],-2)) * 60; |
|
| 753 | - } else { |
|
| 754 | - if (strlen($matches[7])==1) { |
|
| 748 | + 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)) { |
|
| 749 | + $months = Array("Jan"=>1, "Feb"=>2, "Mar"=>3, "Apr"=>4, "May"=>5, "Jun"=>6, "Jul"=>7, "Aug"=>8, "Sep"=>9, "Oct"=>10, "Nov"=>11, "Dec"=>12); |
|
| 750 | + $this->unix = mktime($matches[4], $matches[5], $matches[6], $months[$matches[2]], $matches[1], $matches[3]); |
|
| 751 | + if (substr($matches[7], 0, 1) == '+' OR substr($matches[7], 0, 1) == '-') { |
|
| 752 | + $tzOffset = (substr($matches[7], 0, 3)*60+substr($matches[7], -2))*60; |
|
| 753 | + }else { |
|
| 754 | + if (strlen($matches[7]) == 1) { |
|
| 755 | 755 | $oneHour = 3600; |
| 756 | 756 | $ord = ord($matches[7]); |
| 757 | - if ($ord < ord("M")) { |
|
| 758 | - $tzOffset = (ord("A") - $ord - 1) * $oneHour; |
|
| 759 | - } elseif ($ord >= ord("M") AND $matches[7]!="Z") { |
|
| 760 | - $tzOffset = ($ord - ord("M")) * $oneHour; |
|
| 761 | - } elseif ($matches[7]=="Z") { |
|
| 757 | + if ($ord<ord("M")) { |
|
| 758 | + $tzOffset = (ord("A")-$ord-1)*$oneHour; |
|
| 759 | + } elseif ($ord>=ord("M") AND $matches[7] != "Z") { |
|
| 760 | + $tzOffset = ($ord-ord("M"))*$oneHour; |
|
| 761 | + } elseif ($matches[7] == "Z") { |
|
| 762 | 762 | $tzOffset = 0; |
| 763 | 763 | } |
| 764 | 764 | } |
@@ -770,12 +770,12 @@ discard block |
||
| 770 | 770 | $this->unix += $tzOffset; |
| 771 | 771 | return; |
| 772 | 772 | } |
| 773 | - if (preg_match("~(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})(.*)~",$dateString,$matches)) { |
|
| 774 | - $this->unix = mktime($matches[4],$matches[5],$matches[6],$matches[2],$matches[3],$matches[1]); |
|
| 775 | - if (substr($matches[7],0,1)=='+' OR substr($matches[7],0,1)=='-') { |
|
| 776 | - $tzOffset = (substr($matches[7],0,3) * 60 + substr($matches[7],-2)) * 60; |
|
| 777 | - } else { |
|
| 778 | - if ($matches[7]=="Z") { |
|
| 773 | + if (preg_match("~(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})(.*)~", $dateString, $matches)) { |
|
| 774 | + $this->unix = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); |
|
| 775 | + if (substr($matches[7], 0, 1) == '+' OR substr($matches[7], 0, 1) == '-') { |
|
| 776 | + $tzOffset = (substr($matches[7], 0, 3)*60+substr($matches[7], -2))*60; |
|
| 777 | + }else { |
|
| 778 | + if ($matches[7] == "Z") { |
|
| 779 | 779 | $tzOffset = 0; |
| 780 | 780 | } |
| 781 | 781 | } |
@@ -793,7 +793,7 @@ discard block |
||
| 793 | 793 | function rfc822() { |
| 794 | 794 | //return gmdate("r",$this->unix); |
| 795 | 795 | $date = gmdate("D, d M Y H:i:s", $this->unix); |
| 796 | - if (TIME_ZONE!="") $date .= " ".str_replace(":","",TIME_ZONE); |
|
| 796 | + if (TIME_ZONE != "") $date .= " ".str_replace(":", "", TIME_ZONE); |
|
| 797 | 797 | return $date; |
| 798 | 798 | } |
| 799 | 799 | |
@@ -803,9 +803,9 @@ discard block |
||
| 803 | 803 | * @return a date in ISO 8601 format |
| 804 | 804 | */ |
| 805 | 805 | function iso8601() { |
| 806 | - $date = gmdate("Y-m-d\TH:i:sO",$this->unix); |
|
| 807 | - $date = substr($date,0,22) . ':' . substr($date,-2); |
|
| 808 | - if (TIME_ZONE!="") $date = str_replace("+00:00",TIME_ZONE,$date); |
|
| 806 | + $date = gmdate("Y-m-d\TH:i:sO", $this->unix); |
|
| 807 | + $date = substr($date, 0, 22).':'.substr($date, -2); |
|
| 808 | + if (TIME_ZONE != "") $date = str_replace("+00:00", TIME_ZONE, $date); |
|
| 809 | 809 | return $date; |
| 810 | 810 | } |
| 811 | 811 | |
@@ -836,63 +836,63 @@ discard block |
||
| 836 | 836 | */ |
| 837 | 837 | function createFeed() { |
| 838 | 838 | $feed = "<?xml version=\"1.0\" encoding=\"".$this->encoding."\"?>\n"; |
| 839 | - $feed.= $this->_createGeneratorComment(); |
|
| 840 | - if ($this->cssStyleSheet=="") { |
|
| 839 | + $feed .= $this->_createGeneratorComment(); |
|
| 840 | + if ($this->cssStyleSheet == "") { |
|
| 841 | 841 | $cssStyleSheet = "http://www.w3.org/2000/08/w3c-synd/style.css"; |
| 842 | 842 | } |
| 843 | - $feed.= $this->_createStylesheetReferences(); |
|
| 844 | - $feed.= "<rdf:RDF\n"; |
|
| 845 | - $feed.= " xmlns=\"http://purl.org/rss/1.0/\"\n"; |
|
| 846 | - $feed.= " xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n"; |
|
| 847 | - $feed.= " xmlns:slash=\"http://purl.org/rss/1.0/modules/slash/\"\n"; |
|
| 848 | - $feed.= " xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n"; |
|
| 849 | - $feed.= " <channel rdf:about=\"".$this->syndicationURL."\">\n"; |
|
| 850 | - $feed.= " <title>".htmlspecialchars($this->title)."</title>\n"; |
|
| 851 | - $feed.= " <description>".htmlspecialchars($this->description)."</description>\n"; |
|
| 852 | - $feed.= " <link>".$this->link."</link>\n"; |
|
| 853 | - if ($this->image!=null) { |
|
| 854 | - $feed.= " <image rdf:resource=\"".$this->image->url."\" />\n"; |
|
| 843 | + $feed .= $this->_createStylesheetReferences(); |
|
| 844 | + $feed .= "<rdf:RDF\n"; |
|
| 845 | + $feed .= " xmlns=\"http://purl.org/rss/1.0/\"\n"; |
|
| 846 | + $feed .= " xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n"; |
|
| 847 | + $feed .= " xmlns:slash=\"http://purl.org/rss/1.0/modules/slash/\"\n"; |
|
| 848 | + $feed .= " xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n"; |
|
| 849 | + $feed .= " <channel rdf:about=\"".$this->syndicationURL."\">\n"; |
|
| 850 | + $feed .= " <title>".htmlspecialchars($this->title)."</title>\n"; |
|
| 851 | + $feed .= " <description>".htmlspecialchars($this->description)."</description>\n"; |
|
| 852 | + $feed .= " <link>".$this->link."</link>\n"; |
|
| 853 | + if ($this->image != null) { |
|
| 854 | + $feed .= " <image rdf:resource=\"".$this->image->url."\" />\n"; |
|
| 855 | 855 | } |
| 856 | 856 | $now = new FeedDate(); |
| 857 | - $feed.= " <dc:date>".htmlspecialchars($now->iso8601())."</dc:date>\n"; |
|
| 858 | - $feed.= " <items>\n"; |
|
| 859 | - $feed.= " <rdf:Seq>\n"; |
|
| 860 | - for ($i=0;$i<count($this->items);$i++) { |
|
| 861 | - $feed.= " <rdf:li rdf:resource=\"".htmlspecialchars($this->items[$i]->link)."\"/>\n"; |
|
| 857 | + $feed .= " <dc:date>".htmlspecialchars($now->iso8601())."</dc:date>\n"; |
|
| 858 | + $feed .= " <items>\n"; |
|
| 859 | + $feed .= " <rdf:Seq>\n"; |
|
| 860 | + for ($i = 0; $i<count($this->items); $i++) { |
|
| 861 | + $feed .= " <rdf:li rdf:resource=\"".htmlspecialchars($this->items[$i]->link)."\"/>\n"; |
|
| 862 | 862 | } |
| 863 | - $feed.= " </rdf:Seq>\n"; |
|
| 864 | - $feed.= " </items>\n"; |
|
| 865 | - $feed.= " </channel>\n"; |
|
| 866 | - if ($this->image!=null) { |
|
| 867 | - $feed.= " <image rdf:about=\"".$this->image->url."\">\n"; |
|
| 868 | - $feed.= " <title>".$this->image->title."</title>\n"; |
|
| 869 | - $feed.= " <link>".$this->image->link."</link>\n"; |
|
| 870 | - $feed.= " <url>".$this->image->url."</url>\n"; |
|
| 871 | - $feed.= " </image>\n"; |
|
| 863 | + $feed .= " </rdf:Seq>\n"; |
|
| 864 | + $feed .= " </items>\n"; |
|
| 865 | + $feed .= " </channel>\n"; |
|
| 866 | + if ($this->image != null) { |
|
| 867 | + $feed .= " <image rdf:about=\"".$this->image->url."\">\n"; |
|
| 868 | + $feed .= " <title>".$this->image->title."</title>\n"; |
|
| 869 | + $feed .= " <link>".$this->image->link."</link>\n"; |
|
| 870 | + $feed .= " <url>".$this->image->url."</url>\n"; |
|
| 871 | + $feed .= " </image>\n"; |
|
| 872 | 872 | } |
| 873 | - $feed.= $this->_createAdditionalElements($this->additionalElements, " "); |
|
| 873 | + $feed .= $this->_createAdditionalElements($this->additionalElements, " "); |
|
| 874 | 874 | |
| 875 | - for ($i=0;$i<count($this->items);$i++) { |
|
| 876 | - $feed.= " <item rdf:about=\"".htmlspecialchars($this->items[$i]->link)."\">\n"; |
|
| 875 | + for ($i = 0; $i<count($this->items); $i++) { |
|
| 876 | + $feed .= " <item rdf:about=\"".htmlspecialchars($this->items[$i]->link)."\">\n"; |
|
| 877 | 877 | //$feed.= " <dc:type>Posting</dc:type>\n"; |
| 878 | - $feed.= " <dc:format>text/html</dc:format>\n"; |
|
| 879 | - if ($this->items[$i]->date!=null) { |
|
| 878 | + $feed .= " <dc:format>text/html</dc:format>\n"; |
|
| 879 | + if ($this->items[$i]->date != null) { |
|
| 880 | 880 | $itemDate = new FeedDate($this->items[$i]->date); |
| 881 | - $feed.= " <dc:date>".htmlspecialchars($itemDate->iso8601())."</dc:date>\n"; |
|
| 881 | + $feed .= " <dc:date>".htmlspecialchars($itemDate->iso8601())."</dc:date>\n"; |
|
| 882 | 882 | } |
| 883 | - if ($this->items[$i]->source!="") { |
|
| 884 | - $feed.= " <dc:source>".htmlspecialchars($this->items[$i]->source)."</dc:source>\n"; |
|
| 883 | + if ($this->items[$i]->source != "") { |
|
| 884 | + $feed .= " <dc:source>".htmlspecialchars($this->items[$i]->source)."</dc:source>\n"; |
|
| 885 | 885 | } |
| 886 | - if ($this->items[$i]->author!="") { |
|
| 887 | - $feed.= " <dc:creator>".htmlspecialchars($this->items[$i]->author)."</dc:creator>\n"; |
|
| 886 | + if ($this->items[$i]->author != "") { |
|
| 887 | + $feed .= " <dc:creator>".htmlspecialchars($this->items[$i]->author)."</dc:creator>\n"; |
|
| 888 | 888 | } |
| 889 | - $feed.= " <title>".htmlspecialchars(strip_tags(strtr($this->items[$i]->title,"\n\r"," ")))."</title>\n"; |
|
| 890 | - $feed.= " <link>".htmlspecialchars($this->items[$i]->link)."</link>\n"; |
|
| 891 | - $feed.= " <description>".htmlspecialchars($this->items[$i]->description)."</description>\n"; |
|
| 892 | - $feed.= $this->_createAdditionalElements($this->items[$i]->additionalElements, " "); |
|
| 893 | - $feed.= " </item>\n"; |
|
| 889 | + $feed .= " <title>".htmlspecialchars(strip_tags(strtr($this->items[$i]->title, "\n\r", " ")))."</title>\n"; |
|
| 890 | + $feed .= " <link>".htmlspecialchars($this->items[$i]->link)."</link>\n"; |
|
| 891 | + $feed .= " <description>".htmlspecialchars($this->items[$i]->description)."</description>\n"; |
|
| 892 | + $feed .= $this->_createAdditionalElements($this->items[$i]->additionalElements, " "); |
|
| 893 | + $feed .= " </item>\n"; |
|
| 894 | 894 | } |
| 895 | - $feed.= "</rdf:RDF>\n"; |
|
| 895 | + $feed .= "</rdf:RDF>\n"; |
|
| 896 | 896 | return $feed; |
| 897 | 897 | } |
| 898 | 898 | } |
@@ -934,78 +934,78 @@ discard block |
||
| 934 | 934 | */ |
| 935 | 935 | function createFeed() { |
| 936 | 936 | $feed = "<?xml version=\"1.0\" encoding=\"".$this->encoding."\"?>\n"; |
| 937 | - $feed.= $this->_createGeneratorComment(); |
|
| 938 | - $feed.= $this->_createStylesheetReferences(); |
|
| 939 | - $feed.= "<rss version=\"".$this->RSSVersion."\">\n"; |
|
| 940 | - $feed.= " <channel>\n"; |
|
| 941 | - $feed.= " <title>".FeedCreator::iTrunc(htmlspecialchars($this->title),100)."</title>\n"; |
|
| 937 | + $feed .= $this->_createGeneratorComment(); |
|
| 938 | + $feed .= $this->_createStylesheetReferences(); |
|
| 939 | + $feed .= "<rss version=\"".$this->RSSVersion."\">\n"; |
|
| 940 | + $feed .= " <channel>\n"; |
|
| 941 | + $feed .= " <title>".FeedCreator::iTrunc(htmlspecialchars($this->title), 100)."</title>\n"; |
|
| 942 | 942 | $this->descriptionTruncSize = 500; |
| 943 | - $feed.= " <description>".$this->getDescription()."</description>\n"; |
|
| 944 | - $feed.= " <link>".$this->link."</link>\n"; |
|
| 943 | + $feed .= " <description>".$this->getDescription()."</description>\n"; |
|
| 944 | + $feed .= " <link>".$this->link."</link>\n"; |
|
| 945 | 945 | $now = new FeedDate(); |
| 946 | - $feed.= " <lastBuildDate>".htmlspecialchars($now->rfc822())."</lastBuildDate>\n"; |
|
| 947 | - $feed.= " <generator>".FEEDCREATOR_VERSION."</generator>\n"; |
|
| 948 | - |
|
| 949 | - if ($this->image!=null) { |
|
| 950 | - $feed.= " <image>\n"; |
|
| 951 | - $feed.= " <url>".$this->image->url."</url>\n"; |
|
| 952 | - $feed.= " <title>".FeedCreator::iTrunc(htmlspecialchars($this->image->title),100)."</title>\n"; |
|
| 953 | - $feed.= " <link>".$this->image->link."</link>\n"; |
|
| 954 | - if ($this->image->width!="") { |
|
| 955 | - $feed.= " <width>".$this->image->width."</width>\n"; |
|
| 946 | + $feed .= " <lastBuildDate>".htmlspecialchars($now->rfc822())."</lastBuildDate>\n"; |
|
| 947 | + $feed .= " <generator>".FEEDCREATOR_VERSION."</generator>\n"; |
|
| 948 | + |
|
| 949 | + if ($this->image != null) { |
|
| 950 | + $feed .= " <image>\n"; |
|
| 951 | + $feed .= " <url>".$this->image->url."</url>\n"; |
|
| 952 | + $feed .= " <title>".FeedCreator::iTrunc(htmlspecialchars($this->image->title), 100)."</title>\n"; |
|
| 953 | + $feed .= " <link>".$this->image->link."</link>\n"; |
|
| 954 | + if ($this->image->width != "") { |
|
| 955 | + $feed .= " <width>".$this->image->width."</width>\n"; |
|
| 956 | 956 | } |
| 957 | - if ($this->image->height!="") { |
|
| 958 | - $feed.= " <height>".$this->image->height."</height>\n"; |
|
| 957 | + if ($this->image->height != "") { |
|
| 958 | + $feed .= " <height>".$this->image->height."</height>\n"; |
|
| 959 | 959 | } |
| 960 | - if ($this->image->description!="") { |
|
| 961 | - $feed.= " <description>".$this->image->getDescription()."</description>\n"; |
|
| 960 | + if ($this->image->description != "") { |
|
| 961 | + $feed .= " <description>".$this->image->getDescription()."</description>\n"; |
|
| 962 | 962 | } |
| 963 | - $feed.= " </image>\n"; |
|
| 963 | + $feed .= " </image>\n"; |
|
| 964 | 964 | } |
| 965 | - if ($this->language!="") { |
|
| 966 | - $feed.= " <language>".$this->language."</language>\n"; |
|
| 965 | + if ($this->language != "") { |
|
| 966 | + $feed .= " <language>".$this->language."</language>\n"; |
|
| 967 | 967 | } |
| 968 | - if ($this->copyright!="") { |
|
| 969 | - $feed.= " <copyright>".FeedCreator::iTrunc(htmlspecialchars($this->copyright),100)."</copyright>\n"; |
|
| 968 | + if ($this->copyright != "") { |
|
| 969 | + $feed .= " <copyright>".FeedCreator::iTrunc(htmlspecialchars($this->copyright), 100)."</copyright>\n"; |
|
| 970 | 970 | } |
| 971 | - if ($this->editor!="") { |
|
| 972 | - $feed.= " <managingEditor>".FeedCreator::iTrunc(htmlspecialchars($this->editor),100)."</managingEditor>\n"; |
|
| 971 | + if ($this->editor != "") { |
|
| 972 | + $feed .= " <managingEditor>".FeedCreator::iTrunc(htmlspecialchars($this->editor), 100)."</managingEditor>\n"; |
|
| 973 | 973 | } |
| 974 | - if ($this->webmaster!="") { |
|
| 975 | - $feed.= " <webMaster>".FeedCreator::iTrunc(htmlspecialchars($this->webmaster),100)."</webMaster>\n"; |
|
| 974 | + if ($this->webmaster != "") { |
|
| 975 | + $feed .= " <webMaster>".FeedCreator::iTrunc(htmlspecialchars($this->webmaster), 100)."</webMaster>\n"; |
|
| 976 | 976 | } |
| 977 | - if ($this->pubDate!="") { |
|
| 977 | + if ($this->pubDate != "") { |
|
| 978 | 978 | $pubDate = new FeedDate($this->pubDate); |
| 979 | - $feed.= " <pubDate>".htmlspecialchars($pubDate->rfc822())."</pubDate>\n"; |
|
| 979 | + $feed .= " <pubDate>".htmlspecialchars($pubDate->rfc822())."</pubDate>\n"; |
|
| 980 | 980 | } |
| 981 | - if ($this->category!="") { |
|
| 982 | - $feed.= " <category>".htmlspecialchars($this->category)."</category>\n"; |
|
| 981 | + if ($this->category != "") { |
|
| 982 | + $feed .= " <category>".htmlspecialchars($this->category)."</category>\n"; |
|
| 983 | 983 | } |
| 984 | - if ($this->docs!="") { |
|
| 985 | - $feed.= " <docs>".FeedCreator::iTrunc(htmlspecialchars($this->docs),500)."</docs>\n"; |
|
| 984 | + if ($this->docs != "") { |
|
| 985 | + $feed .= " <docs>".FeedCreator::iTrunc(htmlspecialchars($this->docs), 500)."</docs>\n"; |
|
| 986 | 986 | } |
| 987 | - if ($this->ttl!="") { |
|
| 988 | - $feed.= " <ttl>".htmlspecialchars($this->ttl)."</ttl>\n"; |
|
| 987 | + if ($this->ttl != "") { |
|
| 988 | + $feed .= " <ttl>".htmlspecialchars($this->ttl)."</ttl>\n"; |
|
| 989 | 989 | } |
| 990 | - if ($this->rating!="") { |
|
| 991 | - $feed.= " <rating>".FeedCreator::iTrunc(htmlspecialchars($this->rating),500)."</rating>\n"; |
|
| 990 | + if ($this->rating != "") { |
|
| 991 | + $feed .= " <rating>".FeedCreator::iTrunc(htmlspecialchars($this->rating), 500)."</rating>\n"; |
|
| 992 | 992 | } |
| 993 | - if ($this->skipHours!="") { |
|
| 994 | - $feed.= " <skipHours>".htmlspecialchars($this->skipHours)."</skipHours>\n"; |
|
| 993 | + if ($this->skipHours != "") { |
|
| 994 | + $feed .= " <skipHours>".htmlspecialchars($this->skipHours)."</skipHours>\n"; |
|
| 995 | 995 | } |
| 996 | - if ($this->skipDays!="") { |
|
| 997 | - $feed.= " <skipDays>".htmlspecialchars($this->skipDays)."</skipDays>\n"; |
|
| 996 | + if ($this->skipDays != "") { |
|
| 997 | + $feed .= " <skipDays>".htmlspecialchars($this->skipDays)."</skipDays>\n"; |
|
| 998 | 998 | } |
| 999 | - $feed.= $this->_createAdditionalElements($this->additionalElements, " "); |
|
| 999 | + $feed .= $this->_createAdditionalElements($this->additionalElements, " "); |
|
| 1000 | 1000 | |
| 1001 | - for ($i=0;$i<count($this->items);$i++) { |
|
| 1002 | - $feed.= " <item>\n"; |
|
| 1003 | - $feed.= " <title>".FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)),100)."</title>\n"; |
|
| 1004 | - $feed.= " <link>".htmlspecialchars($this->items[$i]->link)."</link>\n"; |
|
| 1005 | - $feed.= " <description>".$this->items[$i]->getDescription()."</description>\n"; |
|
| 1001 | + for ($i = 0; $i<count($this->items); $i++) { |
|
| 1002 | + $feed .= " <item>\n"; |
|
| 1003 | + $feed .= " <title>".FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)), 100)."</title>\n"; |
|
| 1004 | + $feed .= " <link>".htmlspecialchars($this->items[$i]->link)."</link>\n"; |
|
| 1005 | + $feed .= " <description>".$this->items[$i]->getDescription()."</description>\n"; |
|
| 1006 | 1006 | |
| 1007 | - if ($this->items[$i]->author!="") { |
|
| 1008 | - $feed.= " <author>".htmlspecialchars($this->items[$i]->author)."</author>\n"; |
|
| 1007 | + if ($this->items[$i]->author != "") { |
|
| 1008 | + $feed .= " <author>".htmlspecialchars($this->items[$i]->author)."</author>\n"; |
|
| 1009 | 1009 | } |
| 1010 | 1010 | /* |
| 1011 | 1011 | // on hold |
@@ -1013,24 +1013,24 @@ discard block |
||
| 1013 | 1013 | $feed.= " <source>".htmlspecialchars($this->items[$i]->source)."</source>\n"; |
| 1014 | 1014 | } |
| 1015 | 1015 | */ |
| 1016 | - if ($this->items[$i]->category!="") { |
|
| 1017 | - $feed.= " <category>".htmlspecialchars($this->items[$i]->category)."</category>\n"; |
|
| 1016 | + if ($this->items[$i]->category != "") { |
|
| 1017 | + $feed .= " <category>".htmlspecialchars($this->items[$i]->category)."</category>\n"; |
|
| 1018 | 1018 | } |
| 1019 | - if ($this->items[$i]->comments!="") { |
|
| 1020 | - $feed.= " <comments>".htmlspecialchars($this->items[$i]->comments)."</comments>\n"; |
|
| 1019 | + if ($this->items[$i]->comments != "") { |
|
| 1020 | + $feed .= " <comments>".htmlspecialchars($this->items[$i]->comments)."</comments>\n"; |
|
| 1021 | 1021 | } |
| 1022 | - if ($this->items[$i]->date!="") { |
|
| 1022 | + if ($this->items[$i]->date != "") { |
|
| 1023 | 1023 | $itemDate = new FeedDate($this->items[$i]->date); |
| 1024 | - $feed.= " <pubDate>".htmlspecialchars($itemDate->rfc822())."</pubDate>\n"; |
|
| 1024 | + $feed .= " <pubDate>".htmlspecialchars($itemDate->rfc822())."</pubDate>\n"; |
|
| 1025 | 1025 | } |
| 1026 | - if ($this->items[$i]->guid!="") { |
|
| 1027 | - $feed.= " <guid>".htmlspecialchars($this->items[$i]->guid)."</guid>\n"; |
|
| 1026 | + if ($this->items[$i]->guid != "") { |
|
| 1027 | + $feed .= " <guid>".htmlspecialchars($this->items[$i]->guid)."</guid>\n"; |
|
| 1028 | 1028 | } |
| 1029 | - $feed.= $this->_createAdditionalElements($this->items[$i]->additionalElements, " "); |
|
| 1030 | - $feed.= " </item>\n"; |
|
| 1029 | + $feed .= $this->_createAdditionalElements($this->items[$i]->additionalElements, " "); |
|
| 1030 | + $feed .= " </item>\n"; |
|
| 1031 | 1031 | } |
| 1032 | - $feed.= " </channel>\n"; |
|
| 1033 | - $feed.= "</rss>\n"; |
|
| 1032 | + $feed .= " </channel>\n"; |
|
| 1033 | + $feed .= "</rss>\n"; |
|
| 1034 | 1034 | return $feed; |
| 1035 | 1035 | } |
| 1036 | 1036 | } |
@@ -1069,35 +1069,35 @@ discard block |
||
| 1069 | 1069 | |
| 1070 | 1070 | function createFeed() { |
| 1071 | 1071 | $feed = "<?xml version=\"1.0\" encoding=\"".$this->encoding."\"?>\n"; |
| 1072 | - $feed.= $this->_createStylesheetReferences(); |
|
| 1073 | - $feed.= "<feed version=\"0.1\" xmlns=\"http://example.com/newformat#\">\n"; |
|
| 1074 | - $feed.= " <title>".FeedCreator::iTrunc(htmlspecialchars($this->title),100)."</title>\n"; |
|
| 1072 | + $feed .= $this->_createStylesheetReferences(); |
|
| 1073 | + $feed .= "<feed version=\"0.1\" xmlns=\"http://example.com/newformat#\">\n"; |
|
| 1074 | + $feed .= " <title>".FeedCreator::iTrunc(htmlspecialchars($this->title), 100)."</title>\n"; |
|
| 1075 | 1075 | $this->truncSize = 500; |
| 1076 | - $feed.= " <subtitle>".$this->getDescription()."</subtitle>\n"; |
|
| 1077 | - $feed.= " <link>".$this->link."</link>\n"; |
|
| 1078 | - for ($i=0;$i<count($this->items);$i++) { |
|
| 1079 | - $feed.= " <entry>\n"; |
|
| 1080 | - $feed.= " <title>".FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)),100)."</title>\n"; |
|
| 1081 | - $feed.= " <link>".htmlspecialchars($this->items[$i]->link)."</link>\n"; |
|
| 1076 | + $feed .= " <subtitle>".$this->getDescription()."</subtitle>\n"; |
|
| 1077 | + $feed .= " <link>".$this->link."</link>\n"; |
|
| 1078 | + for ($i = 0; $i<count($this->items); $i++) { |
|
| 1079 | + $feed .= " <entry>\n"; |
|
| 1080 | + $feed .= " <title>".FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)), 100)."</title>\n"; |
|
| 1081 | + $feed .= " <link>".htmlspecialchars($this->items[$i]->link)."</link>\n"; |
|
| 1082 | 1082 | $itemDate = new FeedDate($this->items[$i]->date); |
| 1083 | - $feed.= " <created>".htmlspecialchars($itemDate->iso8601())."</created>\n"; |
|
| 1084 | - $feed.= " <issued>".htmlspecialchars($itemDate->iso8601())."</issued>\n"; |
|
| 1085 | - $feed.= " <modified>".htmlspecialchars($itemDate->iso8601())."</modified>\n"; |
|
| 1086 | - $feed.= " <id>".htmlspecialchars($this->items[$i]->guid)."</id>\n"; |
|
| 1087 | - if ($this->items[$i]->author!="") { |
|
| 1088 | - $feed.= " <author>\n"; |
|
| 1089 | - $feed.= " <name>".htmlspecialchars($this->items[$i]->author)."</name>\n"; |
|
| 1090 | - if ($this->items[$i]->authorEmail!="") { |
|
| 1091 | - $feed.= " <email>".$this->items[$i]->authorEmail."</email>\n"; |
|
| 1083 | + $feed .= " <created>".htmlspecialchars($itemDate->iso8601())."</created>\n"; |
|
| 1084 | + $feed .= " <issued>".htmlspecialchars($itemDate->iso8601())."</issued>\n"; |
|
| 1085 | + $feed .= " <modified>".htmlspecialchars($itemDate->iso8601())."</modified>\n"; |
|
| 1086 | + $feed .= " <id>".htmlspecialchars($this->items[$i]->guid)."</id>\n"; |
|
| 1087 | + if ($this->items[$i]->author != "") { |
|
| 1088 | + $feed .= " <author>\n"; |
|
| 1089 | + $feed .= " <name>".htmlspecialchars($this->items[$i]->author)."</name>\n"; |
|
| 1090 | + if ($this->items[$i]->authorEmail != "") { |
|
| 1091 | + $feed .= " <email>".$this->items[$i]->authorEmail."</email>\n"; |
|
| 1092 | 1092 | } |
| 1093 | - $feed.=" </author>\n"; |
|
| 1093 | + $feed .= " </author>\n"; |
|
| 1094 | 1094 | } |
| 1095 | - $feed.= " <content type=\"text/html\" xml:lang=\"en-us\">\n"; |
|
| 1096 | - $feed.= " <div xmlns=\"http://www.w3.org/1999/xhtml\">".$this->items[$i]->getDescription()."</div>\n"; |
|
| 1097 | - $feed.= " </content>\n"; |
|
| 1098 | - $feed.= " </entry>\n"; |
|
| 1095 | + $feed .= " <content type=\"text/html\" xml:lang=\"en-us\">\n"; |
|
| 1096 | + $feed .= " <div xmlns=\"http://www.w3.org/1999/xhtml\">".$this->items[$i]->getDescription()."</div>\n"; |
|
| 1097 | + $feed .= " </content>\n"; |
|
| 1098 | + $feed .= " </entry>\n"; |
|
| 1099 | 1099 | } |
| 1100 | - $feed.= "</feed>\n"; |
|
| 1100 | + $feed .= "</feed>\n"; |
|
| 1101 | 1101 | return $feed; |
| 1102 | 1102 | } |
| 1103 | 1103 | } |
@@ -1128,53 +1128,53 @@ discard block |
||
| 1128 | 1128 | |
| 1129 | 1129 | function createFeed() { |
| 1130 | 1130 | $feed = "<?xml version=\"1.0\" encoding=\"".$this->encoding."\"?>\n"; |
| 1131 | - $feed.= $this->_createGeneratorComment(); |
|
| 1132 | - $feed.= $this->_createStylesheetReferences(); |
|
| 1133 | - $feed.= "<feed version=\"0.3\" xmlns=\"http://purl.org/atom/ns#\""; |
|
| 1134 | - if ($this->language!="") { |
|
| 1135 | - $feed.= " xml:lang=\"".$this->language."\""; |
|
| 1131 | + $feed .= $this->_createGeneratorComment(); |
|
| 1132 | + $feed .= $this->_createStylesheetReferences(); |
|
| 1133 | + $feed .= "<feed version=\"0.3\" xmlns=\"http://purl.org/atom/ns#\""; |
|
| 1134 | + if ($this->language != "") { |
|
| 1135 | + $feed .= " xml:lang=\"".$this->language."\""; |
|
| 1136 | 1136 | } |
| 1137 | - $feed.= ">\n"; |
|
| 1138 | - $feed.= " <title>".htmlspecialchars($this->title)."</title>\n"; |
|
| 1139 | - $feed.= " <tagline>".htmlspecialchars($this->description)."</tagline>\n"; |
|
| 1140 | - $feed.= " <link rel=\"alternate\" type=\"text/html\" href=\"".htmlspecialchars($this->link)."\"/>\n"; |
|
| 1141 | - $feed.= " <id>".htmlspecialchars($this->link)."</id>\n"; |
|
| 1137 | + $feed .= ">\n"; |
|
| 1138 | + $feed .= " <title>".htmlspecialchars($this->title)."</title>\n"; |
|
| 1139 | + $feed .= " <tagline>".htmlspecialchars($this->description)."</tagline>\n"; |
|
| 1140 | + $feed .= " <link rel=\"alternate\" type=\"text/html\" href=\"".htmlspecialchars($this->link)."\"/>\n"; |
|
| 1141 | + $feed .= " <id>".htmlspecialchars($this->link)."</id>\n"; |
|
| 1142 | 1142 | $now = new FeedDate(); |
| 1143 | - $feed.= " <modified>".htmlspecialchars($now->iso8601())."</modified>\n"; |
|
| 1144 | - if ($this->editor!="") { |
|
| 1145 | - $feed.= " <author>\n"; |
|
| 1146 | - $feed.= " <name>".$this->editor."</name>\n"; |
|
| 1147 | - if ($this->editorEmail!="") { |
|
| 1148 | - $feed.= " <email>".$this->editorEmail."</email>\n"; |
|
| 1143 | + $feed .= " <modified>".htmlspecialchars($now->iso8601())."</modified>\n"; |
|
| 1144 | + if ($this->editor != "") { |
|
| 1145 | + $feed .= " <author>\n"; |
|
| 1146 | + $feed .= " <name>".$this->editor."</name>\n"; |
|
| 1147 | + if ($this->editorEmail != "") { |
|
| 1148 | + $feed .= " <email>".$this->editorEmail."</email>\n"; |
|
| 1149 | 1149 | } |
| 1150 | - $feed.= " </author>\n"; |
|
| 1150 | + $feed .= " </author>\n"; |
|
| 1151 | 1151 | } |
| 1152 | - $feed.= " <generator>".FEEDCREATOR_VERSION."</generator>\n"; |
|
| 1153 | - $feed.= $this->_createAdditionalElements($this->additionalElements, " "); |
|
| 1154 | - for ($i=0;$i<count($this->items);$i++) { |
|
| 1155 | - $feed.= " <entry>\n"; |
|
| 1156 | - $feed.= " <title>".htmlspecialchars(strip_tags($this->items[$i]->title))."</title>\n"; |
|
| 1157 | - $feed.= " <link rel=\"alternate\" type=\"text/html\" href=\"".htmlspecialchars($this->items[$i]->link)."\"/>\n"; |
|
| 1158 | - if ($this->items[$i]->date=="") { |
|
| 1152 | + $feed .= " <generator>".FEEDCREATOR_VERSION."</generator>\n"; |
|
| 1153 | + $feed .= $this->_createAdditionalElements($this->additionalElements, " "); |
|
| 1154 | + for ($i = 0; $i<count($this->items); $i++) { |
|
| 1155 | + $feed .= " <entry>\n"; |
|
| 1156 | + $feed .= " <title>".htmlspecialchars(strip_tags($this->items[$i]->title))."</title>\n"; |
|
| 1157 | + $feed .= " <link rel=\"alternate\" type=\"text/html\" href=\"".htmlspecialchars($this->items[$i]->link)."\"/>\n"; |
|
| 1158 | + if ($this->items[$i]->date == "") { |
|
| 1159 | 1159 | $this->items[$i]->date = time(); |
| 1160 | 1160 | } |
| 1161 | 1161 | $itemDate = new FeedDate($this->items[$i]->date); |
| 1162 | - $feed.= " <created>".htmlspecialchars($itemDate->iso8601())."</created>\n"; |
|
| 1163 | - $feed.= " <issued>".htmlspecialchars($itemDate->iso8601())."</issued>\n"; |
|
| 1164 | - $feed.= " <modified>".htmlspecialchars($itemDate->iso8601())."</modified>\n"; |
|
| 1165 | - $feed.= " <id>".htmlspecialchars($this->items[$i]->link)."</id>\n"; |
|
| 1166 | - $feed.= $this->_createAdditionalElements($this->items[$i]->additionalElements, " "); |
|
| 1167 | - if ($this->items[$i]->author!="") { |
|
| 1168 | - $feed.= " <author>\n"; |
|
| 1169 | - $feed.= " <name>".htmlspecialchars($this->items[$i]->author)."</name>\n"; |
|
| 1170 | - $feed.= " </author>\n"; |
|
| 1162 | + $feed .= " <created>".htmlspecialchars($itemDate->iso8601())."</created>\n"; |
|
| 1163 | + $feed .= " <issued>".htmlspecialchars($itemDate->iso8601())."</issued>\n"; |
|
| 1164 | + $feed .= " <modified>".htmlspecialchars($itemDate->iso8601())."</modified>\n"; |
|
| 1165 | + $feed .= " <id>".htmlspecialchars($this->items[$i]->link)."</id>\n"; |
|
| 1166 | + $feed .= $this->_createAdditionalElements($this->items[$i]->additionalElements, " "); |
|
| 1167 | + if ($this->items[$i]->author != "") { |
|
| 1168 | + $feed .= " <author>\n"; |
|
| 1169 | + $feed .= " <name>".htmlspecialchars($this->items[$i]->author)."</name>\n"; |
|
| 1170 | + $feed .= " </author>\n"; |
|
| 1171 | 1171 | } |
| 1172 | - if ($this->items[$i]->description!="") { |
|
| 1173 | - $feed.= " <summary>".htmlspecialchars($this->items[$i]->description)."</summary>\n"; |
|
| 1172 | + if ($this->items[$i]->description != "") { |
|
| 1173 | + $feed .= " <summary>".htmlspecialchars($this->items[$i]->description)."</summary>\n"; |
|
| 1174 | 1174 | } |
| 1175 | - $feed.= " </entry>\n"; |
|
| 1175 | + $feed .= " </entry>\n"; |
|
| 1176 | 1176 | } |
| 1177 | - $feed.= "</feed>\n"; |
|
| 1177 | + $feed .= "</feed>\n"; |
|
| 1178 | 1178 | return $feed; |
| 1179 | 1179 | } |
| 1180 | 1180 | } |
@@ -1195,25 +1195,25 @@ discard block |
||
| 1195 | 1195 | } |
| 1196 | 1196 | |
| 1197 | 1197 | function qp_enc($input = "", $line_max = 76) { |
| 1198 | - $hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); |
|
| 1198 | + $hex = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'); |
|
| 1199 | 1199 | $lines = preg_split("/(?:\r\n|\r|\n)/", $input); |
| 1200 | 1200 | $eol = "\r\n"; |
| 1201 | 1201 | $escape = "="; |
| 1202 | 1202 | $output = ""; |
| 1203 | - while( list(, $line) = each($lines) ) { |
|
| 1203 | + while (list(, $line) = each($lines)) { |
|
| 1204 | 1204 | //$line = rtrim($line); // remove trailing white space -> no =20\r\n necessary |
| 1205 | 1205 | $linlen = strlen($line); |
| 1206 | 1206 | $newline = ""; |
| 1207 | - for($i = 0; $i < $linlen; $i++) { |
|
| 1207 | + for ($i = 0; $i<$linlen; $i++) { |
|
| 1208 | 1208 | $c = substr($line, $i, 1); |
| 1209 | 1209 | $dec = ord($c); |
| 1210 | - if ( ($dec == 32) && ($i == ($linlen - 1)) ) { // convert space at eol only |
|
| 1210 | + if (($dec == 32) && ($i == ($linlen-1))) { // convert space at eol only |
|
| 1211 | 1211 | $c = "=20"; |
| 1212 | - } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { // always encode "\t", which is *not* required |
|
| 1212 | + } elseif (($dec == 61) || ($dec<32) || ($dec>126)) { // always encode "\t", which is *not* required |
|
| 1213 | 1213 | $h2 = floor($dec/16); $h1 = floor($dec%16); |
| 1214 | 1214 | $c = $escape.$hex["$h2"].$hex["$h1"]; |
| 1215 | 1215 | } |
| 1216 | - if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted |
|
| 1216 | + if ((strlen($newline)+strlen($c))>=$line_max) { // CRLF is not counted |
|
| 1217 | 1217 | $output .= $newline.$escape.$eol; // soft line break; " =\r\n" is okay |
| 1218 | 1218 | $newline = ""; |
| 1219 | 1219 | } |
@@ -1230,26 +1230,26 @@ discard block |
||
| 1230 | 1230 | * @return string the feed's complete text |
| 1231 | 1231 | */ |
| 1232 | 1232 | function createFeed() { |
| 1233 | - for ($i=0;$i<count($this->items);$i++) { |
|
| 1234 | - if ($this->items[$i]->author!="") { |
|
| 1233 | + for ($i = 0; $i<count($this->items); $i++) { |
|
| 1234 | + if ($this->items[$i]->author != "") { |
|
| 1235 | 1235 | $from = $this->items[$i]->author; |
| 1236 | - } else { |
|
| 1236 | + }else { |
|
| 1237 | 1237 | $from = $this->title; |
| 1238 | 1238 | } |
| 1239 | 1239 | $itemDate = new FeedDate($this->items[$i]->date); |
| 1240 | - $feed.= "From ".strtr(MBOXCreator::qp_enc($from)," ","_")." ".date("D M d H:i:s Y",$itemDate->unix())."\n"; |
|
| 1241 | - $feed.= "Content-Type: text/plain;\n"; |
|
| 1242 | - $feed.= " charset=\"".$this->encoding."\"\n"; |
|
| 1243 | - $feed.= "Content-Transfer-Encoding: quoted-printable\n"; |
|
| 1244 | - $feed.= "Content-Type: text/plain\n"; |
|
| 1245 | - $feed.= "From: \"".MBOXCreator::qp_enc($from)."\"\n"; |
|
| 1246 | - $feed.= "Date: ".$itemDate->rfc822()."\n"; |
|
| 1247 | - $feed.= "Subject: ".MBOXCreator::qp_enc(FeedCreator::iTrunc($this->items[$i]->title,100))."\n"; |
|
| 1248 | - $feed.= "\n"; |
|
| 1240 | + $feed .= "From ".strtr(MBOXCreator::qp_enc($from), " ", "_")." ".date("D M d H:i:s Y", $itemDate->unix())."\n"; |
|
| 1241 | + $feed .= "Content-Type: text/plain;\n"; |
|
| 1242 | + $feed .= " charset=\"".$this->encoding."\"\n"; |
|
| 1243 | + $feed .= "Content-Transfer-Encoding: quoted-printable\n"; |
|
| 1244 | + $feed .= "Content-Type: text/plain\n"; |
|
| 1245 | + $feed .= "From: \"".MBOXCreator::qp_enc($from)."\"\n"; |
|
| 1246 | + $feed .= "Date: ".$itemDate->rfc822()."\n"; |
|
| 1247 | + $feed .= "Subject: ".MBOXCreator::qp_enc(FeedCreator::iTrunc($this->items[$i]->title, 100))."\n"; |
|
| 1248 | + $feed .= "\n"; |
|
| 1249 | 1249 | $body = chunk_split(MBOXCreator::qp_enc($this->items[$i]->description)); |
| 1250 | - $feed.= preg_replace("~\nFrom ([^\n]*)(\n?)~","\n>From $1$2\n",$body); |
|
| 1251 | - $feed.= "\n"; |
|
| 1252 | - $feed.= "\n"; |
|
| 1250 | + $feed .= preg_replace("~\nFrom ([^\n]*)(\n?)~", "\n>From $1$2\n", $body); |
|
| 1251 | + $feed .= "\n"; |
|
| 1252 | + $feed .= "\n"; |
|
| 1253 | 1253 | } |
| 1254 | 1254 | return $feed; |
| 1255 | 1255 | } |
@@ -1262,7 +1262,7 @@ discard block |
||
| 1262 | 1262 | */ |
| 1263 | 1263 | function _generateFilename() { |
| 1264 | 1264 | $fileInfo = pathinfo($_SERVER["PHP_SELF"]); |
| 1265 | - return substr($fileInfo["basename"],0,-(strlen($fileInfo["extension"])+1)).".mbox"; |
|
| 1265 | + return substr($fileInfo["basename"], 0, -(strlen($fileInfo["extension"])+1)).".mbox"; |
|
| 1266 | 1266 | } |
| 1267 | 1267 | } |
| 1268 | 1268 | |
@@ -1282,38 +1282,38 @@ discard block |
||
| 1282 | 1282 | |
| 1283 | 1283 | function createFeed() { |
| 1284 | 1284 | $feed = "<?xml version=\"1.0\" encoding=\"".$this->encoding."\"?>\n"; |
| 1285 | - $feed.= $this->_createGeneratorComment(); |
|
| 1286 | - $feed.= $this->_createStylesheetReferences(); |
|
| 1287 | - $feed.= "<opml xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n"; |
|
| 1288 | - $feed.= " <head>\n"; |
|
| 1289 | - $feed.= " <title>".htmlspecialchars($this->title)."</title>\n"; |
|
| 1290 | - if ($this->pubDate!="") { |
|
| 1285 | + $feed .= $this->_createGeneratorComment(); |
|
| 1286 | + $feed .= $this->_createStylesheetReferences(); |
|
| 1287 | + $feed .= "<opml xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n"; |
|
| 1288 | + $feed .= " <head>\n"; |
|
| 1289 | + $feed .= " <title>".htmlspecialchars($this->title)."</title>\n"; |
|
| 1290 | + if ($this->pubDate != "") { |
|
| 1291 | 1291 | $date = new FeedDate($this->pubDate); |
| 1292 | - $feed.= " <dateCreated>".$date->rfc822()."</dateCreated>\n"; |
|
| 1292 | + $feed .= " <dateCreated>".$date->rfc822()."</dateCreated>\n"; |
|
| 1293 | 1293 | } |
| 1294 | - if ($this->lastBuildDate!="") { |
|
| 1294 | + if ($this->lastBuildDate != "") { |
|
| 1295 | 1295 | $date = new FeedDate($this->lastBuildDate); |
| 1296 | - $feed.= " <dateModified>".$date->rfc822()."</dateModified>\n"; |
|
| 1296 | + $feed .= " <dateModified>".$date->rfc822()."</dateModified>\n"; |
|
| 1297 | 1297 | } |
| 1298 | - if ($this->editor!="") { |
|
| 1299 | - $feed.= " <ownerName>".$this->editor."</ownerName>\n"; |
|
| 1298 | + if ($this->editor != "") { |
|
| 1299 | + $feed .= " <ownerName>".$this->editor."</ownerName>\n"; |
|
| 1300 | 1300 | } |
| 1301 | - if ($this->editorEmail!="") { |
|
| 1302 | - $feed.= " <ownerEmail>".$this->editorEmail."</ownerEmail>\n"; |
|
| 1301 | + if ($this->editorEmail != "") { |
|
| 1302 | + $feed .= " <ownerEmail>".$this->editorEmail."</ownerEmail>\n"; |
|
| 1303 | 1303 | } |
| 1304 | - $feed.= " </head>\n"; |
|
| 1305 | - $feed.= " <body>\n"; |
|
| 1306 | - for ($i=0;$i<count($this->items);$i++) { |
|
| 1307 | - $feed.= " <outline type=\"rss\" "; |
|
| 1308 | - $title = htmlspecialchars(strip_tags(strtr($this->items[$i]->title,"\n\r"," "))); |
|
| 1309 | - $feed.= " title=\"".$title."\""; |
|
| 1310 | - $feed.= " text=\"".$title."\""; |
|
| 1304 | + $feed .= " </head>\n"; |
|
| 1305 | + $feed .= " <body>\n"; |
|
| 1306 | + for ($i = 0; $i<count($this->items); $i++) { |
|
| 1307 | + $feed .= " <outline type=\"rss\" "; |
|
| 1308 | + $title = htmlspecialchars(strip_tags(strtr($this->items[$i]->title, "\n\r", " "))); |
|
| 1309 | + $feed .= " title=\"".$title."\""; |
|
| 1310 | + $feed .= " text=\"".$title."\""; |
|
| 1311 | 1311 | //$feed.= " description=\"".htmlspecialchars($this->items[$i]->description)."\""; |
| 1312 | - $feed.= " url=\"".htmlspecialchars($this->items[$i]->link)."\""; |
|
| 1313 | - $feed.= "/>\n"; |
|
| 1312 | + $feed .= " url=\"".htmlspecialchars($this->items[$i]->link)."\""; |
|
| 1313 | + $feed .= "/>\n"; |
|
| 1314 | 1314 | } |
| 1315 | - $feed.= " </body>\n"; |
|
| 1316 | - $feed.= "</opml>\n"; |
|
| 1315 | + $feed .= " </body>\n"; |
|
| 1316 | + $feed .= "</opml>\n"; |
|
| 1317 | 1317 | return $feed; |
| 1318 | 1318 | } |
| 1319 | 1319 | } |
@@ -1343,7 +1343,7 @@ discard block |
||
| 1343 | 1343 | /** |
| 1344 | 1344 | * Contains HTML to be output at the end of the feed's html representation. |
| 1345 | 1345 | */ |
| 1346 | - var $footer ; |
|
| 1346 | + var $footer; |
|
| 1347 | 1347 | |
| 1348 | 1348 | /** |
| 1349 | 1349 | * Contains HTML to be output between entries. A separator is only used in |
@@ -1362,7 +1362,7 @@ discard block |
||
| 1362 | 1362 | */ |
| 1363 | 1363 | var $openInNewWindow = true; |
| 1364 | 1364 | |
| 1365 | - var $imageAlign ="right"; |
|
| 1365 | + var $imageAlign = "right"; |
|
| 1366 | 1366 | |
| 1367 | 1367 | /** |
| 1368 | 1368 | * In case of very simple output you may want to get rid of the style tags, |
@@ -1371,7 +1371,7 @@ discard block |
||
| 1371 | 1371 | * and when it is non-empty, ONLY the styleless output is printed, the rest is ignored |
| 1372 | 1372 | * in the function createFeed(). |
| 1373 | 1373 | */ |
| 1374 | - var $stylelessOutput =""; |
|
| 1374 | + var $stylelessOutput = ""; |
|
| 1375 | 1375 | |
| 1376 | 1376 | /** |
| 1377 | 1377 | * Writes the HTML. |
@@ -1379,12 +1379,12 @@ discard block |
||
| 1379 | 1379 | */ |
| 1380 | 1380 | function createFeed() { |
| 1381 | 1381 | // if there is styleless output, use the content of this variable and ignore the rest |
| 1382 | - if ($this->stylelessOutput!="") { |
|
| 1382 | + if ($this->stylelessOutput != "") { |
|
| 1383 | 1383 | return $this->stylelessOutput; |
| 1384 | 1384 | } |
| 1385 | 1385 | |
| 1386 | 1386 | //if no stylePrefix is set, generate it yourself depending on the script name |
| 1387 | - if ($this->stylePrefix=="") { |
|
| 1387 | + if ($this->stylePrefix == "") { |
|
| 1388 | 1388 | $this->stylePrefix = str_replace(".", "_", $this->_generateFilename())."_"; |
| 1389 | 1389 | } |
| 1390 | 1390 | |
@@ -1395,24 +1395,24 @@ discard block |
||
| 1395 | 1395 | |
| 1396 | 1396 | // use this array to put the lines in and implode later with "document.write" javascript |
| 1397 | 1397 | $feedArray = array(); |
| 1398 | - if ($this->image!=null) { |
|
| 1398 | + if ($this->image != null) { |
|
| 1399 | 1399 | $imageStr = "<a href='".$this->image->link."'".$targetInsert.">". |
| 1400 | 1400 | "<img src='".$this->image->url."' border='0' alt='". |
| 1401 | - FeedCreator::iTrunc(htmlspecialchars($this->image->title),100). |
|
| 1401 | + FeedCreator::iTrunc(htmlspecialchars($this->image->title), 100). |
|
| 1402 | 1402 | "' align='".$this->imageAlign."' "; |
| 1403 | 1403 | if ($this->image->width) { |
| 1404 | - $imageStr .=" width='".$this->image->width. "' "; |
|
| 1404 | + $imageStr .= " width='".$this->image->width."' "; |
|
| 1405 | 1405 | } |
| 1406 | 1406 | if ($this->image->height) { |
| 1407 | - $imageStr .=" height='".$this->image->height."' "; |
|
| 1407 | + $imageStr .= " height='".$this->image->height."' "; |
|
| 1408 | 1408 | } |
| 1409 | - $imageStr .="/></a>"; |
|
| 1409 | + $imageStr .= "/></a>"; |
|
| 1410 | 1410 | $feedArray[] = $imageStr; |
| 1411 | 1411 | } |
| 1412 | 1412 | |
| 1413 | 1413 | if ($this->title) { |
| 1414 | 1414 | $feedArray[] = "<div class='".$this->stylePrefix."title'><a href='".$this->link."' ".$targetInsert." class='".$this->stylePrefix."title'>". |
| 1415 | - FeedCreator::iTrunc(htmlspecialchars($this->title),100)."</a></div>"; |
|
| 1415 | + FeedCreator::iTrunc(htmlspecialchars($this->title), 100)."</a></div>"; |
|
| 1416 | 1416 | } |
| 1417 | 1417 | if ($this->getDescription()) { |
| 1418 | 1418 | $feedArray[] = "<div class='".$this->stylePrefix."description'>". |
@@ -1424,8 +1424,8 @@ discard block |
||
| 1424 | 1424 | $feedArray[] = "<div class='".$this->stylePrefix."header'>".$this->header."</div>"; |
| 1425 | 1425 | } |
| 1426 | 1426 | |
| 1427 | - for ($i=0;$i<count($this->items);$i++) { |
|
| 1428 | - if ($this->separator and $i > 0) { |
|
| 1427 | + for ($i = 0; $i<count($this->items); $i++) { |
|
| 1428 | + if ($this->separator and $i>0) { |
|
| 1429 | 1429 | $feedArray[] = "<div class='".$this->stylePrefix."separator'>".$this->separator."</div>"; |
| 1430 | 1430 | } |
| 1431 | 1431 | |
@@ -1433,12 +1433,12 @@ discard block |
||
| 1433 | 1433 | if ($this->items[$i]->link) { |
| 1434 | 1434 | $feedArray[] = |
| 1435 | 1435 | "<div class='".$this->stylePrefix."item_title'><a href='".$this->items[$i]->link."' class='".$this->stylePrefix. |
| 1436 | - "item_title'".$targetInsert.">".FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)),100). |
|
| 1436 | + "item_title'".$targetInsert.">".FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)), 100). |
|
| 1437 | 1437 | "</a></div>"; |
| 1438 | - } else { |
|
| 1438 | + }else { |
|
| 1439 | 1439 | $feedArray[] = |
| 1440 | 1440 | "<div class='".$this->stylePrefix."item_title'>". |
| 1441 | - FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)),100). |
|
| 1441 | + FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)), 100). |
|
| 1442 | 1442 | "</div>"; |
| 1443 | 1443 | } |
| 1444 | 1444 | } |
@@ -1453,7 +1453,7 @@ discard block |
||
| 1453 | 1453 | $feedArray[] = "<div class='".$this->stylePrefix."footer'>".$this->footer."</div>"; |
| 1454 | 1454 | } |
| 1455 | 1455 | |
| 1456 | - $feed= "".join($feedArray, "\r\n"); |
|
| 1456 | + $feed = "".join($feedArray, "\r\n"); |
|
| 1457 | 1457 | return $feed; |
| 1458 | 1458 | } |
| 1459 | 1459 | |
@@ -1466,7 +1466,7 @@ discard block |
||
| 1466 | 1466 | */ |
| 1467 | 1467 | function _generateFilename() { |
| 1468 | 1468 | $fileInfo = pathinfo($_SERVER["PHP_SELF"]); |
| 1469 | - return substr($fileInfo["basename"],0,-(strlen($fileInfo["extension"])+1)).".html"; |
|
| 1469 | + return substr($fileInfo["basename"], 0, -(strlen($fileInfo["extension"])+1)).".html"; |
|
| 1470 | 1470 | } |
| 1471 | 1471 | } |
| 1472 | 1472 | |
@@ -1487,7 +1487,7 @@ discard block |
||
| 1487 | 1487 | function createFeed() |
| 1488 | 1488 | { |
| 1489 | 1489 | $feed = parent::createFeed(); |
| 1490 | - $feedArray = explode("\n",$feed); |
|
| 1490 | + $feedArray = explode("\n", $feed); |
|
| 1491 | 1491 | |
| 1492 | 1492 | $jsFeed = ""; |
| 1493 | 1493 | foreach ($feedArray as $value) { |
@@ -1505,7 +1505,7 @@ discard block |
||
| 1505 | 1505 | */ |
| 1506 | 1506 | function _generateFilename() { |
| 1507 | 1507 | $fileInfo = pathinfo($_SERVER["PHP_SELF"]); |
| 1508 | - return substr($fileInfo["basename"],0,-(strlen($fileInfo["extension"])+1)).".js"; |
|
| 1508 | + return substr($fileInfo["basename"], 0, -(strlen($fileInfo["extension"])+1)).".js"; |
|
| 1509 | 1509 | } |
| 1510 | 1510 | |
| 1511 | 1511 | } |
@@ -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) ) { |
@@ -34,16 +34,16 @@ discard block |
||
| 34 | 34 | class MagpieRSS { |
| 35 | 35 | var $parser; |
| 36 | 36 | |
| 37 | - var $current_item = array(); // item currently being parsed |
|
| 38 | - var $items = array(); // collection of parsed items |
|
| 39 | - var $channel = array(); // hash of channel fields |
|
| 37 | + var $current_item = array(); // item currently being parsed |
|
| 38 | + var $items = array(); // collection of parsed items |
|
| 39 | + var $channel = array(); // hash of channel fields |
|
| 40 | 40 | var $textinput = array(); |
| 41 | 41 | var $image = array(); |
| 42 | 42 | var $feed_type; |
| 43 | 43 | var $feed_version; |
| 44 | - var $encoding = ''; // output encoding of parsed rss |
|
| 44 | + var $encoding = ''; // output encoding of parsed rss |
|
| 45 | 45 | |
| 46 | - var $_source_encoding = ''; // only set if we have to parse xml prolog |
|
| 46 | + var $_source_encoding = ''; // only set if we have to parse xml prolog |
|
| 47 | 47 | |
| 48 | 48 | var $ERROR = ""; |
| 49 | 49 | var $WARNING = ""; |
@@ -92,15 +92,15 @@ discard block |
||
| 92 | 92 | * source encoding. (caveat emptor) |
| 93 | 93 | * |
| 94 | 94 | */ |
| 95 | - function MagpieRSS ($source, $output_encoding='ISO-8859-1', |
|
| 96 | - $input_encoding=null, $detect_encoding=true) |
|
| 95 | + function MagpieRSS($source, $output_encoding = 'ISO-8859-1', |
|
| 96 | + $input_encoding = null, $detect_encoding = true) |
|
| 97 | 97 | { |
| 98 | 98 | # if PHP xml isn't compiled in, die |
| 99 | 99 | # |
| 100 | 100 | if (!function_exists('xml_parser_create')) { |
| 101 | - $this->error( "Failed to load PHP's XML Extension. " . |
|
| 101 | + $this->error("Failed to load PHP's XML Extension. ". |
|
| 102 | 102 | "http://www.php.net/manual/en/ref.xml.php", |
| 103 | - E_USER_ERROR ); |
|
| 103 | + E_USER_ERROR); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | list($parser, $source) = $this->create_parser($source, |
@@ -108,9 +108,9 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | |
| 110 | 110 | if (!is_resource($parser)) { |
| 111 | - $this->error( "Failed to create an instance of PHP's XML parser. " . |
|
| 111 | + $this->error("Failed to create an instance of PHP's XML parser. ". |
|
| 112 | 112 | "http://www.php.net/manual/en/ref.xml.php", |
| 113 | - E_USER_ERROR ); |
|
| 113 | + E_USER_ERROR); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | |
@@ -119,27 +119,27 @@ discard block |
||
| 119 | 119 | # pass in parser, and a reference to this object |
| 120 | 120 | # setup handlers |
| 121 | 121 | # |
| 122 | - xml_set_object( $this->parser, $this ); |
|
| 122 | + xml_set_object($this->parser, $this); |
|
| 123 | 123 | xml_set_element_handler($this->parser, |
| 124 | - 'feed_start_element', 'feed_end_element' ); |
|
| 124 | + 'feed_start_element', 'feed_end_element'); |
|
| 125 | 125 | |
| 126 | - xml_set_character_data_handler( $this->parser, 'feed_cdata' ); |
|
| 126 | + xml_set_character_data_handler($this->parser, 'feed_cdata'); |
|
| 127 | 127 | |
| 128 | - $status = @xml_parse( $this->parser, $source ); |
|
| 128 | + $status = @xml_parse($this->parser, $source); |
|
| 129 | 129 | |
| 130 | - if (! $status ) { |
|
| 131 | - $errorcode = xml_get_error_code( $this->parser ); |
|
| 132 | - if ( $errorcode != XML_ERROR_NONE ) { |
|
| 133 | - $xml_error = xml_error_string( $errorcode ); |
|
| 130 | + if (!$status) { |
|
| 131 | + $errorcode = xml_get_error_code($this->parser); |
|
| 132 | + if ($errorcode != XML_ERROR_NONE) { |
|
| 133 | + $xml_error = xml_error_string($errorcode); |
|
| 134 | 134 | $error_line = xml_get_current_line_number($this->parser); |
| 135 | 135 | $error_col = xml_get_current_column_number($this->parser); |
| 136 | 136 | $errormsg = "$xml_error at line $error_line, column $error_col"; |
| 137 | 137 | |
| 138 | - $this->error( $errormsg ); |
|
| 138 | + $this->error($errormsg); |
|
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - xml_parser_free( $this->parser ); |
|
| 142 | + xml_parser_free($this->parser); |
|
| 143 | 143 | |
| 144 | 144 | $this->normalize(); |
| 145 | 145 | |
@@ -151,26 +151,26 @@ discard block |
||
| 151 | 151 | |
| 152 | 152 | // check for a namespace, and split if found |
| 153 | 153 | $ns = false; |
| 154 | - if ( strpos( $element, ':' ) ) { |
|
| 155 | - list($ns, $el) = split( ':', $element, 2); |
|
| 154 | + if (strpos($element, ':')) { |
|
| 155 | + list($ns, $el) = split(':', $element, 2); |
|
| 156 | 156 | } |
| 157 | - if ( $ns and $ns != 'rdf' ) { |
|
| 157 | + if ($ns and $ns != 'rdf') { |
|
| 158 | 158 | $this->current_namespace = $ns; |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | # if feed type isn't set, then this is first element of feed |
| 162 | 162 | # identify feed from root element |
| 163 | 163 | # |
| 164 | - if (!isset($this->feed_type) ) { |
|
| 165 | - if ( $el == 'rdf' ) { |
|
| 164 | + if (!isset($this->feed_type)) { |
|
| 165 | + if ($el == 'rdf') { |
|
| 166 | 166 | $this->feed_type = RSS; |
| 167 | 167 | $this->feed_version = '1.0'; |
| 168 | 168 | } |
| 169 | - elseif ( $el == 'rss' ) { |
|
| 169 | + elseif ($el == 'rss') { |
|
| 170 | 170 | $this->feed_type = RSS; |
| 171 | 171 | $this->feed_version = $attrs['version']; |
| 172 | 172 | } |
| 173 | - elseif ( $el == 'feed' ) { |
|
| 173 | + elseif ($el == 'feed') { |
|
| 174 | 174 | $this->feed_type = ATOM; |
| 175 | 175 | $this->feed_version = $attrs['version']; |
| 176 | 176 | $this->inchannel = true; |
@@ -178,14 +178,14 @@ discard block |
||
| 178 | 178 | return; |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - if ( $el == 'channel' ) |
|
| 181 | + if ($el == 'channel') |
|
| 182 | 182 | { |
| 183 | 183 | $this->inchannel = true; |
| 184 | 184 | } |
| 185 | - elseif ($el == 'item' or $el == 'entry' ) |
|
| 185 | + elseif ($el == 'item' or $el == 'entry') |
|
| 186 | 186 | { |
| 187 | 187 | $this->initem = true; |
| 188 | - if ( isset($attrs['rdf:about']) ) { |
|
| 188 | + if (isset($attrs['rdf:about'])) { |
|
| 189 | 189 | $this->current_item['about'] = $attrs['rdf:about']; |
| 190 | 190 | } |
| 191 | 191 | } |
@@ -209,10 +209,10 @@ discard block |
||
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | # handle atom content constructs |
| 212 | - elseif ( $this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) ) |
|
| 212 | + elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS)) |
|
| 213 | 213 | { |
| 214 | 214 | // avoid clashing w/ RSS mod_content |
| 215 | - if ($el == 'content' ) { |
|
| 215 | + if ($el == 'content') { |
|
| 216 | 216 | $el = 'atom_content'; |
| 217 | 217 | } |
| 218 | 218 | |
@@ -222,31 +222,31 @@ discard block |
||
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | // if inside an Atom content construct (e.g. content or summary) field treat tags as text |
| 225 | - elseif ($this->feed_type == ATOM and $this->incontent ) |
|
| 225 | + elseif ($this->feed_type == ATOM and $this->incontent) |
|
| 226 | 226 | { |
| 227 | 227 | // if tags are inlined, then flatten |
| 228 | 228 | $attrs_str = join(' ', |
| 229 | 229 | array_map('map_attrs', |
| 230 | 230 | array_keys($attrs), |
| 231 | - array_values($attrs) ) ); |
|
| 231 | + array_values($attrs))); |
|
| 232 | 232 | |
| 233 | - $this->append_content( "<$element $attrs_str>" ); |
|
| 233 | + $this->append_content("<$element $attrs_str>"); |
|
| 234 | 234 | |
| 235 | - array_unshift( $this->stack, $el ); |
|
| 235 | + array_unshift($this->stack, $el); |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | // Atom support many links per containging element. |
| 239 | 239 | // Magpie treats link elements of type rel='alternate' |
| 240 | 240 | // as being equivalent to RSS's simple link element. |
| 241 | 241 | // |
| 242 | - elseif ($this->feed_type == ATOM and $el == 'link' ) |
|
| 242 | + elseif ($this->feed_type == ATOM and $el == 'link') |
|
| 243 | 243 | { |
| 244 | - if ( isset($attrs['rel']) and $attrs['rel'] == 'alternate' ) |
|
| 244 | + if (isset($attrs['rel']) and $attrs['rel'] == 'alternate') |
|
| 245 | 245 | { |
| 246 | 246 | $link_el = 'link'; |
| 247 | 247 | } |
| 248 | 248 | else { |
| 249 | - $link_el = 'link_' . $attrs['rel']; |
|
| 249 | + $link_el = 'link_'.$attrs['rel']; |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | $this->append($link_el, $attrs['href']); |
@@ -259,11 +259,11 @@ discard block |
||
| 259 | 259 | |
| 260 | 260 | |
| 261 | 261 | |
| 262 | - function feed_cdata ($p, $text) { |
|
| 262 | + function feed_cdata($p, $text) { |
|
| 263 | 263 | |
| 264 | 264 | if ($this->feed_type == ATOM and $this->incontent) |
| 265 | 265 | { |
| 266 | - $this->append_content( $text ); |
|
| 266 | + $this->append_content($text); |
|
| 267 | 267 | } |
| 268 | 268 | else { |
| 269 | 269 | $current_el = join('_', array_reverse($this->stack)); |
@@ -271,35 +271,35 @@ discard block |
||
| 271 | 271 | } |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | - function feed_end_element ($p, $el) { |
|
| 274 | + function feed_end_element($p, $el) { |
|
| 275 | 275 | $el = strtolower($el); |
| 276 | 276 | |
| 277 | - if ( $el == 'item' or $el == 'entry' ) |
|
| 277 | + if ($el == 'item' or $el == 'entry') |
|
| 278 | 278 | { |
| 279 | 279 | $this->items[] = $this->current_item; |
| 280 | 280 | $this->current_item = array(); |
| 281 | 281 | $this->initem = false; |
| 282 | 282 | } |
| 283 | - elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'textinput' ) |
|
| 283 | + elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'textinput') |
|
| 284 | 284 | { |
| 285 | 285 | $this->intextinput = false; |
| 286 | 286 | } |
| 287 | - elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'image' ) |
|
| 287 | + elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'image') |
|
| 288 | 288 | { |
| 289 | 289 | $this->inimage = false; |
| 290 | 290 | } |
| 291 | - elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) ) |
|
| 291 | + elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS)) |
|
| 292 | 292 | { |
| 293 | 293 | $this->incontent = false; |
| 294 | 294 | } |
| 295 | - elseif ($el == 'channel' or $el == 'feed' ) |
|
| 295 | + elseif ($el == 'channel' or $el == 'feed') |
|
| 296 | 296 | { |
| 297 | 297 | $this->inchannel = false; |
| 298 | 298 | } |
| 299 | - elseif ($this->feed_type == ATOM and $this->incontent ) { |
|
| 299 | + elseif ($this->feed_type == ATOM and $this->incontent) { |
|
| 300 | 300 | // balance tags properly |
| 301 | 301 | // note: i don't think this is actually neccessary |
| 302 | - if ( $this->stack[0] == $el ) |
|
| 302 | + if ($this->stack[0] == $el) |
|
| 303 | 303 | { |
| 304 | 304 | $this->append_content("</$el>"); |
| 305 | 305 | } |
@@ -307,18 +307,18 @@ discard block |
||
| 307 | 307 | $this->append_content("<$el />"); |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | - array_shift( $this->stack ); |
|
| 310 | + array_shift($this->stack); |
|
| 311 | 311 | } |
| 312 | 312 | else { |
| 313 | - array_shift( $this->stack ); |
|
| 313 | + array_shift($this->stack); |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | $this->current_namespace = false; |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | - function concat (&$str1, $str2="") { |
|
| 320 | - if (!isset($str1) ) { |
|
| 321 | - $str1=""; |
|
| 319 | + function concat(&$str1, $str2 = "") { |
|
| 320 | + if (!isset($str1)) { |
|
| 321 | + $str1 = ""; |
|
| 322 | 322 | } |
| 323 | 323 | $str1 .= $str2; |
| 324 | 324 | } |
@@ -326,11 +326,11 @@ discard block |
||
| 326 | 326 | |
| 327 | 327 | |
| 328 | 328 | function append_content($text) { |
| 329 | - if ( $this->initem ) { |
|
| 330 | - $this->concat( $this->current_item[ $this->incontent ], $text ); |
|
| 329 | + if ($this->initem) { |
|
| 330 | + $this->concat($this->current_item[$this->incontent], $text); |
|
| 331 | 331 | } |
| 332 | - elseif ( $this->inchannel ) { |
|
| 333 | - $this->concat( $this->channel[ $this->incontent ], $text ); |
|
| 332 | + elseif ($this->inchannel) { |
|
| 333 | + $this->concat($this->channel[$this->incontent], $text); |
|
| 334 | 334 | } |
| 335 | 335 | } |
| 336 | 336 | |
@@ -339,61 +339,61 @@ discard block |
||
| 339 | 339 | if (!$el) { |
| 340 | 340 | return; |
| 341 | 341 | } |
| 342 | - if ( $this->current_namespace ) |
|
| 342 | + if ($this->current_namespace) |
|
| 343 | 343 | { |
| 344 | - if ( $this->initem ) { |
|
| 344 | + if ($this->initem) { |
|
| 345 | 345 | $this->concat( |
| 346 | - $this->current_item[ $this->current_namespace ][ $el ], $text); |
|
| 346 | + $this->current_item[$this->current_namespace][$el], $text); |
|
| 347 | 347 | } |
| 348 | 348 | elseif ($this->inchannel) { |
| 349 | 349 | $this->concat( |
| 350 | - $this->channel[ $this->current_namespace][ $el ], $text ); |
|
| 350 | + $this->channel[$this->current_namespace][$el], $text ); |
|
| 351 | 351 | } |
| 352 | 352 | elseif ($this->intextinput) { |
| 353 | 353 | $this->concat( |
| 354 | - $this->textinput[ $this->current_namespace][ $el ], $text ); |
|
| 354 | + $this->textinput[$this->current_namespace][$el], $text ); |
|
| 355 | 355 | } |
| 356 | 356 | elseif ($this->inimage) { |
| 357 | 357 | $this->concat( |
| 358 | - $this->image[ $this->current_namespace ][ $el ], $text ); |
|
| 358 | + $this->image[$this->current_namespace][$el], $text ); |
|
| 359 | 359 | } |
| 360 | 360 | } |
| 361 | 361 | else { |
| 362 | - if ( $this->initem ) { |
|
| 362 | + if ($this->initem) { |
|
| 363 | 363 | $this->concat( |
| 364 | - $this->current_item[ $el ], $text); |
|
| 364 | + $this->current_item[$el], $text); |
|
| 365 | 365 | } |
| 366 | 366 | elseif ($this->intextinput) { |
| 367 | 367 | $this->concat( |
| 368 | - $this->textinput[ $el ], $text ); |
|
| 368 | + $this->textinput[$el], $text ); |
|
| 369 | 369 | } |
| 370 | 370 | elseif ($this->inimage) { |
| 371 | 371 | $this->concat( |
| 372 | - $this->image[ $el ], $text ); |
|
| 372 | + $this->image[$el], $text ); |
|
| 373 | 373 | } |
| 374 | 374 | elseif ($this->inchannel) { |
| 375 | 375 | $this->concat( |
| 376 | - $this->channel[ $el ], $text ); |
|
| 376 | + $this->channel[$el], $text ); |
|
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | } |
| 380 | 380 | } |
| 381 | 381 | |
| 382 | - function normalize () { |
|
| 382 | + function normalize() { |
|
| 383 | 383 | // if atom populate rss fields |
| 384 | - if ( $this->is_atom() ) { |
|
| 384 | + if ($this->is_atom()) { |
|
| 385 | 385 | $this->channel['description'] = $this->channel['tagline']; |
| 386 | - for ( $i = 0; $i < count($this->items); $i++) { |
|
| 386 | + for ($i = 0; $i<count($this->items); $i++) { |
|
| 387 | 387 | $item = $this->items[$i]; |
| 388 | - if ( isset($item['summary']) ) |
|
| 388 | + if (isset($item['summary'])) |
|
| 389 | 389 | $item['description'] = $item['summary']; |
| 390 | - if ( isset($item['atom_content'])) |
|
| 390 | + if (isset($item['atom_content'])) |
|
| 391 | 391 | $item['content']['encoded'] = $item['atom_content']; |
| 392 | 392 | |
| 393 | - $atom_date = (isset($item['issued']) ) ? $item['issued'] : @$item['modified']; |
|
| 394 | - if ( $atom_date ) { |
|
| 393 | + $atom_date = (isset($item['issued'])) ? $item['issued'] : @$item['modified']; |
|
| 394 | + if ($atom_date) { |
|
| 395 | 395 | $epoch = @parse_w3cdtf($atom_date); |
| 396 | - if ($epoch and $epoch > 0) { |
|
| 396 | + if ($epoch and $epoch>0) { |
|
| 397 | 397 | $item['date_timestamp'] = $epoch; |
| 398 | 398 | } |
| 399 | 399 | } |
@@ -401,24 +401,24 @@ discard block |
||
| 401 | 401 | $this->items[$i] = $item; |
| 402 | 402 | } |
| 403 | 403 | } |
| 404 | - elseif ( $this->is_rss() ) { |
|
| 404 | + elseif ($this->is_rss()) { |
|
| 405 | 405 | $this->channel['tagline'] = $this->channel['description']; |
| 406 | - for ( $i = 0; $i < count($this->items); $i++) { |
|
| 406 | + for ($i = 0; $i<count($this->items); $i++) { |
|
| 407 | 407 | $item = $this->items[$i]; |
| 408 | - if ( isset($item['description'])) |
|
| 408 | + if (isset($item['description'])) |
|
| 409 | 409 | $item['summary'] = $item['description']; |
| 410 | - if ( isset($item['content']['encoded'] ) ) |
|
| 410 | + if (isset($item['content']['encoded'])) |
|
| 411 | 411 | $item['atom_content'] = $item['content']['encoded']; |
| 412 | 412 | |
| 413 | - if ( $this->is_rss() == '1.0' and isset($item['dc']['date']) ) { |
|
| 413 | + if ($this->is_rss() == '1.0' and isset($item['dc']['date'])) { |
|
| 414 | 414 | $epoch = @parse_w3cdtf($item['dc']['date']); |
| 415 | - if ($epoch and $epoch > 0) { |
|
| 415 | + if ($epoch and $epoch>0) { |
|
| 416 | 416 | $item['date_timestamp'] = $epoch; |
| 417 | 417 | } |
| 418 | 418 | } |
| 419 | - elseif ( isset($item['pubdate']) ) { |
|
| 419 | + elseif (isset($item['pubdate'])) { |
|
| 420 | 420 | $epoch = @strtotime($item['pubdate']); |
| 421 | - if ($epoch > 0) { |
|
| 421 | + if ($epoch>0) { |
|
| 422 | 422 | $item['date_timestamp'] = $epoch; |
| 423 | 423 | } |
| 424 | 424 | } |
@@ -429,8 +429,8 @@ discard block |
||
| 429 | 429 | } |
| 430 | 430 | |
| 431 | 431 | |
| 432 | - function is_rss () { |
|
| 433 | - if ( $this->feed_type == RSS ) { |
|
| 432 | + function is_rss() { |
|
| 433 | + if ($this->feed_type == RSS) { |
|
| 434 | 434 | return $this->feed_version; |
| 435 | 435 | } |
| 436 | 436 | else { |
@@ -439,7 +439,7 @@ discard block |
||
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | function is_atom() { |
| 442 | - if ( $this->feed_type == ATOM ) { |
|
| 442 | + if ($this->feed_type == ATOM) { |
|
| 443 | 443 | return $this->feed_version; |
| 444 | 444 | } |
| 445 | 445 | else { |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | * |
| 453 | 453 | */ |
| 454 | 454 | function create_parser($source, $out_enc, $in_enc, $detect) { |
| 455 | - if ( substr(phpversion(),0,1) == 5) { |
|
| 455 | + if (substr(phpversion(), 0, 1) == 5) { |
|
| 456 | 456 | $parser = $this->php5_create_parser($in_enc, $detect); |
| 457 | 457 | } |
| 458 | 458 | else { |
@@ -477,7 +477,7 @@ discard block |
||
| 477 | 477 | */ |
| 478 | 478 | function php5_create_parser($in_enc, $detect) { |
| 479 | 479 | // by default php5 does a fine job of detecting input encodings |
| 480 | - if(!$detect && $in_enc) { |
|
| 480 | + if (!$detect && $in_enc) { |
|
| 481 | 481 | return xml_parser_create($in_enc); |
| 482 | 482 | } |
| 483 | 483 | else { |
@@ -501,7 +501,7 @@ discard block |
||
| 501 | 501 | * |
| 502 | 502 | */ |
| 503 | 503 | function php4_create_parser($source, $in_enc, $detect) { |
| 504 | - if ( !$detect ) { |
|
| 504 | + if (!$detect) { |
|
| 505 | 505 | return array(xml_parser_create($in_enc), $source); |
| 506 | 506 | } |
| 507 | 507 | |
@@ -553,7 +553,7 @@ discard block |
||
| 553 | 553 | |
| 554 | 554 | function known_encoding($enc) { |
| 555 | 555 | $enc = strtoupper($enc); |
| 556 | - if ( in_array($enc, $this->_KNOWN_ENCODINGS) ) { |
|
| 556 | + if (in_array($enc, $this->_KNOWN_ENCODINGS)) { |
|
| 557 | 557 | return $enc; |
| 558 | 558 | } |
| 559 | 559 | else { |
@@ -561,22 +561,22 @@ discard block |
||
| 561 | 561 | } |
| 562 | 562 | } |
| 563 | 563 | |
| 564 | - function error ($errormsg, $lvl=E_USER_WARNING) { |
|
| 564 | + function error($errormsg, $lvl = E_USER_WARNING) { |
|
| 565 | 565 | // append PHP's error message if track_errors enabled |
| 566 | - if ( !empty($php_errormsg) ) { |
|
| 566 | + if (!empty($php_errormsg)) { |
|
| 567 | 567 | $errormsg .= " ($php_errormsg)"; |
| 568 | 568 | } |
| 569 | - if ( MAGPIE_DEBUG ) { |
|
| 570 | - trigger_error( $errormsg, $lvl); |
|
| 569 | + if (MAGPIE_DEBUG) { |
|
| 570 | + trigger_error($errormsg, $lvl); |
|
| 571 | 571 | } |
| 572 | 572 | else { |
| 573 | - error_log( $errormsg, 0); |
|
| 573 | + error_log($errormsg, 0); |
|
| 574 | 574 | } |
| 575 | 575 | |
| 576 | - $notices = E_USER_NOTICE|E_NOTICE; |
|
| 577 | - if ( $lvl&$notices ) { |
|
| 576 | + $notices = E_USER_NOTICE | E_NOTICE; |
|
| 577 | + if ($lvl & $notices) { |
|
| 578 | 578 | $this->WARNING = $errormsg; |
| 579 | - } else { |
|
| 579 | + }else { |
|
| 580 | 580 | $this->ERROR = $errormsg; |
| 581 | 581 | } |
| 582 | 582 | } |
@@ -589,41 +589,41 @@ discard block |
||
| 589 | 589 | } |
| 590 | 590 | |
| 591 | 591 | |
| 592 | -function parse_w3cdtf ( $date_str ) { |
|
| 592 | +function parse_w3cdtf($date_str) { |
|
| 593 | 593 | |
| 594 | 594 | # regex to match wc3dtf |
| 595 | 595 | $pat = "/(\d{4})-(\d{2})-(\d{2})[T]?(\d{2})?[:]?(\d{2})?(:(\d{2}))?(?:([-+])(\d{2}):?(\d{2})|(Z))?/"; |
| 596 | 596 | |
| 597 | - if ( preg_match( $pat, $date_str, $match ) ) { |
|
| 598 | - list( $year, $month, $day, $hours, $minutes, $seconds) = |
|
| 599 | - array( $match[1], $match[2], $match[3], $match[4], $match[5], $match[6]); |
|
| 597 | + if (preg_match($pat, $date_str, $match)) { |
|
| 598 | + list($year, $month, $day, $hours, $minutes, $seconds) = |
|
| 599 | + array($match[1], $match[2], $match[3], $match[4], $match[5], $match[6]); |
|
| 600 | 600 | |
| 601 | 601 | # calc epoch for current date assuming GMT |
| 602 | - $epoch = gmmktime( intval($hours), intval($minutes), intval($seconds), intval($month), intval($day), intval($year)); |
|
| 602 | + $epoch = gmmktime(intval($hours), intval($minutes), intval($seconds), intval($month), intval($day), intval($year)); |
|
| 603 | 603 | |
| 604 | 604 | $offset = 0; |
| 605 | - if ( $match[10] == 'Z' ) { |
|
| 605 | + if ($match[10] == 'Z') { |
|
| 606 | 606 | # zulu time, aka GMT |
| 607 | 607 | } |
| 608 | 608 | else { |
| 609 | - list( $tz_mod, $tz_hour, $tz_min ) = |
|
| 610 | - array( $match[8], $match[9], $match[10]); |
|
| 609 | + list($tz_mod, $tz_hour, $tz_min) = |
|
| 610 | + array($match[8], $match[9], $match[10]); |
|
| 611 | 611 | |
| 612 | 612 | # zero out the variables |
| 613 | - if ( ! $tz_hour ) { $tz_hour = 0; } |
|
| 614 | - if ( ! $tz_min ) { $tz_min = 0; } |
|
| 613 | + if (!$tz_hour) { $tz_hour = 0; } |
|
| 614 | + if (!$tz_min) { $tz_min = 0; } |
|
| 615 | 615 | |
| 616 | 616 | $offset_secs = (($tz_hour*60)+$tz_min)*60; |
| 617 | 617 | |
| 618 | 618 | # is timezone ahead of GMT? then subtract offset |
| 619 | 619 | # |
| 620 | - if ( $tz_mod == '+' ) { |
|
| 621 | - $offset_secs = $offset_secs * -1; |
|
| 620 | + if ($tz_mod == '+') { |
|
| 621 | + $offset_secs = $offset_secs*-1; |
|
| 622 | 622 | } |
| 623 | 623 | |
| 624 | 624 | $offset = $offset_secs; |
| 625 | 625 | } |
| 626 | - $epoch = $epoch + $offset; |
|
| 626 | + $epoch = $epoch+$offset; |
|
| 627 | 627 | return $epoch; |
| 628 | 628 | } |
| 629 | 629 | else { |
@@ -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); |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | // Project: Article Project // |
| 26 | 26 | // ------------------------------------------------------------------------ // |
| 27 | 27 | |
| 28 | -if (!defined('XOOPS_ROOT_PATH')){ exit(); } |
|
| 28 | +if (!defined('XOOPS_ROOT_PATH')) { exit(); } |
|
| 29 | 29 | include_once dirname(dirname(__FILE__))."/include/vars.php"; |
| 30 | 30 | mod_loadFunctions("", $GLOBALS["moddirname"]); |
| 31 | 31 | |
@@ -66,8 +66,8 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | // your local timezone, set to "" to disable or for GMT |
| 68 | 68 | $server_TZ = abs(intval($GLOBALS['xoopsConfig']['server_TZ']*3600.0)); |
| 69 | -$prefix = ($GLOBALS['xoopsConfig']['server_TZ']<0)?"-":"+"; |
|
| 70 | -$TIME_ZONE = $prefix.date("H:i",$server_TZ); |
|
| 69 | +$prefix = ($GLOBALS['xoopsConfig']['server_TZ']<0) ? "-" : "+"; |
|
| 70 | +$TIME_ZONE = $prefix.date("H:i", $server_TZ); |
|
| 71 | 71 | define("TIME_ZONE", $TIME_ZONE); |
| 72 | 72 | // Version string. |
| 73 | 73 | define("FEEDCREATOR_VERSION", "ARTICLE @ XOOPS powered by FeedCreator"); |
@@ -81,31 +81,31 @@ discard block |
||
| 81 | 81 | * @return type description |
| 82 | 82 | * @link |
| 83 | 83 | */ |
| 84 | -if(!class_exists("Xmlfeed")){ |
|
| 84 | +if (!class_exists("Xmlfeed")) { |
|
| 85 | 85 | class Bxmlfeed extends UniversalFeedCreator |
| 86 | 86 | { |
| 87 | 87 | var $version; |
| 88 | - var $filename= ""; |
|
| 88 | + var $filename = ""; |
|
| 89 | 89 | |
| 90 | 90 | function Bxmlfeed($version) |
| 91 | 91 | { |
| 92 | - $this->filename= XOOPS_CACHE_PATH."/feed.xml"; |
|
| 92 | + $this->filename = XOOPS_CACHE_PATH."/feed.xml"; |
|
| 93 | 93 | $this->version = $version; |
| 94 | 94 | } |
| 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)) $val = $this->convert_encoding($val); |
|
| 99 | 99 | $this->$var = $val; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | function convert_encoding($val) |
| 103 | 103 | { |
| 104 | - if(is_array($val)){ |
|
| 105 | - foreach(array_keys($val) as $key){ |
|
| 104 | + if (is_array($val)) { |
|
| 105 | + foreach (array_keys($val) as $key) { |
|
| 106 | 106 | $val[$key] = $this->convert_encoding($val[$key]); |
| 107 | 107 | } |
| 108 | - }else{ |
|
| 108 | + }else { |
|
| 109 | 109 | $val = XoopsLocal::convert_encoding($val, $this->encoding, _CHARSET); |
| 110 | 110 | } |
| 111 | 111 | return $val; |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | function setImage(&$img) |
| 120 | 120 | { |
| 121 | 121 | $image = new FeedImage(); |
| 122 | - foreach($img as $key=>$val){ |
|
| 122 | + foreach ($img as $key=>$val) { |
|
| 123 | 123 | $image->$key = $this->convert_encoding($val); |
| 124 | 124 | } |
| 125 | 125 | $this->setVar("image", $image); |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | function _addItem(&$itm) |
| 129 | 129 | { |
| 130 | 130 | $item = new FeedItem(); |
| 131 | - foreach($itm as $key=>$val){ |
|
| 131 | + foreach ($itm as $key=>$val) { |
|
| 132 | 132 | $item->$key = $this->convert_encoding($val); |
| 133 | 133 | } |
| 134 | 134 | $this->addItem($item); |
@@ -136,8 +136,8 @@ discard block |
||
| 136 | 136 | |
| 137 | 137 | function addItems(&$items) |
| 138 | 138 | { |
| 139 | - if(!is_array($items) || count($items)==0) return; |
|
| 140 | - foreach($items as $item){ |
|
| 139 | + if (!is_array($items) || count($items) == 0) return; |
|
| 140 | + foreach ($items as $item) { |
|
| 141 | 141 | $this->_addItem($item); |
| 142 | 142 | } |
| 143 | 143 | } |
@@ -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()) |
@@ -62,9 +62,9 @@ discard block |
||
| 62 | 62 | * out. |
| 63 | 63 | * |
| 64 | 64 | */ |
| 65 | - function XmlParser ($content, $input_charset, $output_charset = _CHARSET, $tags = array()) |
|
| 65 | + function XmlParser($content, $input_charset, $output_charset = _CHARSET, $tags = array()) |
|
| 66 | 66 | { |
| 67 | - if(!in_array(strtoupper($input_charset), array("UTF-8", "US-ASCII", "ISO-8859-1"))) { |
|
| 67 | + if (!in_array(strtoupper($input_charset), array("UTF-8", "US-ASCII", "ISO-8859-1"))) { |
|
| 68 | 68 | $content = XoopsLocal::convert_encoding($content, "UTF-8", $input_charset); |
| 69 | 69 | $content = preg_replace('/(<\?xml.*encoding=[\'"])(.*?)([\'"].*\?>)/m', '$1UTF-8$3', $content); |
| 70 | 70 | $input_charset = "UTF-8"; |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | $this->charset_out = $output_charset; |
| 75 | 75 | |
| 76 | 76 | /* TODO: parse specified tags only */ |
| 77 | - $this->MagpieRSS( $content, $input_charset, $input_charset, false ); |
|
| 77 | + $this->MagpieRSS($content, $input_charset, $input_charset, false); |
|
| 78 | 78 | |
| 79 | 79 | //xoops_message($this); |
| 80 | 80 | unset($this->content); |
@@ -82,8 +82,8 @@ discard block |
||
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | function is_atom() { |
| 85 | - if ( $this->feed_type == ATOM ) { |
|
| 86 | - $this->feed_version = empty($this->feed_version)?"0.3":$this->feed_version; |
|
| 85 | + if ($this->feed_type == ATOM) { |
|
| 86 | + $this->feed_version = empty($this->feed_version) ? "0.3" : $this->feed_version; |
|
| 87 | 87 | return $this->feed_version; |
| 88 | 88 | } |
| 89 | 89 | else { |
@@ -91,94 +91,94 @@ discard block |
||
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - function normalize () { |
|
| 95 | - if ( $this->is_atom() ): |
|
| 96 | - if(empty($this->channel["tagline"])){ |
|
| 94 | + function normalize() { |
|
| 95 | + if ($this->is_atom()): |
|
| 96 | + if (empty($this->channel["tagline"])) { |
|
| 97 | 97 | /* ATOM */ |
| 98 | 98 | $this->channel["tagline"] = @$this->channel["subtitle"]; |
| 99 | 99 | unset($this->channel["subtitle"]); |
| 100 | 100 | } |
| 101 | - for ( $i = 0; $i < count($this->items); $i++) { |
|
| 101 | + for ($i = 0; $i<count($this->items); $i++) { |
|
| 102 | 102 | // ATOM time |
| 103 | - if($date = @$this->items[$i]['modified']) continue; |
|
| 104 | - if(empty($date)){ |
|
| 103 | + if ($date = @$this->items[$i]['modified']) continue; |
|
| 104 | + if (empty($date)) { |
|
| 105 | 105 | $date = @$this->items[$i]['updated']; |
| 106 | 106 | } |
| 107 | - if(empty($date)){ |
|
| 107 | + if (empty($date)) { |
|
| 108 | 108 | $date = @$this->items[$i]['issued']; |
| 109 | 109 | } |
| 110 | - if(empty($date)){ |
|
| 110 | + if (empty($date)) { |
|
| 111 | 111 | $date = @$this->items[$i]['created']; |
| 112 | 112 | } |
| 113 | - if(empty($date)){ |
|
| 113 | + if (empty($date)) { |
|
| 114 | 114 | $date = @$this->items[$i]['created']; |
| 115 | 115 | } |
| 116 | 116 | $this->items[$i]['modified'] = $date; |
| 117 | 117 | } |
| 118 | - elseif($this->is_rss() != '1.0'): |
|
| 119 | - for ( $i = 0; $i < count($this->items); $i++) { |
|
| 120 | - if($date = @$this->items[$i]['pubdate']) continue; |
|
| 118 | + elseif ($this->is_rss() != '1.0'): |
|
| 119 | + for ($i = 0; $i<count($this->items); $i++) { |
|
| 120 | + if ($date = @$this->items[$i]['pubdate']) continue; |
|
| 121 | 121 | $this->items[$i]['pubdate'] = @$this->items[$i]['dc']['date']; |
| 122 | 122 | } |
| 123 | 123 | endif; |
| 124 | 124 | parent::normalize(); |
| 125 | 125 | /* ATOM */ |
| 126 | - if(empty($this->channel["language"]) && !empty($this->channel["dc"]["language"]) ) { |
|
| 126 | + if (empty($this->channel["language"]) && !empty($this->channel["dc"]["language"])) { |
|
| 127 | 127 | $this->channel["language"] = $this->channel["dc"]["language"]; |
| 128 | 128 | unset($this->channel["dc"]["language"]); |
| 129 | 129 | } |
| 130 | - if(empty($this->channel["language"]) && preg_match('/<link.*hreflang=[\'"](.*?)[\'"].*?>/m', $this->content, $match) ) { |
|
| 130 | + if (empty($this->channel["language"]) && preg_match('/<link.*hreflang=[\'"](.*?)[\'"].*?>/m', $this->content, $match)) { |
|
| 131 | 131 | $this->channel["language"] = $match[1]; |
| 132 | 132 | } |
| 133 | - if(empty($this->channel["language"]) && preg_match('/<feed.*xml:lang=[\'"](.*?)[\'"].*?>/m', $this->content, $match) ) { |
|
| 133 | + if (empty($this->channel["language"]) && preg_match('/<feed.*xml:lang=[\'"](.*?)[\'"].*?>/m', $this->content, $match)) { |
|
| 134 | 134 | $this->channel["language"] = $match[1]; |
| 135 | 135 | } |
| 136 | 136 | /* remove to avoid redundant encoding conversion */ |
| 137 | - if(!empty($this->channel["tagline"])){ |
|
| 137 | + if (!empty($this->channel["tagline"])) { |
|
| 138 | 138 | unset($this->channel["tagline"]); |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - for ( $i = 0; $i < count($this->items); $i++) { |
|
| 142 | - if($date_timestamp = @$this->items[$i]['date_timestamp']) continue; |
|
| 143 | - if($date_timestamp = @$this->items[$i]['pubdate']){ |
|
| 141 | + for ($i = 0; $i<count($this->items); $i++) { |
|
| 142 | + if ($date_timestamp = @$this->items[$i]['date_timestamp']) continue; |
|
| 143 | + if ($date_timestamp = @$this->items[$i]['pubdate']) { |
|
| 144 | 144 | $this->items[$i]['date_timestamp'] = $date_timestamp; |
| 145 | - }elseif($date_timestamp = @$this->items[$i]['dc']['date']){ |
|
| 145 | + }elseif ($date_timestamp = @$this->items[$i]['dc']['date']) { |
|
| 146 | 146 | $this->items[$i]['date_timestamp'] = $date_timestamp; |
| 147 | - }else{ |
|
| 147 | + }else { |
|
| 148 | 148 | $this->items[$i]['date_timestamp'] = time(); |
| 149 | 149 | } |
| 150 | - if(!is_numeric($this->items[$i]['date_timestamp'])){ |
|
| 151 | - if($date = parse_w3cdtf($this->items[$i]['date_timestamp'])) { |
|
| 150 | + if (!is_numeric($this->items[$i]['date_timestamp'])) { |
|
| 151 | + if ($date = parse_w3cdtf($this->items[$i]['date_timestamp'])) { |
|
| 152 | 152 | $this->items[$i]['date_timestamp'] = $date; |
| 153 | - }elseif($date = strtotime($this->items[$i]['date_timestamp'])) { |
|
| 153 | + }elseif ($date = strtotime($this->items[$i]['date_timestamp'])) { |
|
| 154 | 154 | $this->items[$i]['date_timestamp'] = $date; |
| 155 | 155 | } |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | /* remove to avoid redundant encoding conversion */ |
| 159 | - if ( isset($this->items[$i]['summary']) ) |
|
| 159 | + if (isset($this->items[$i]['summary'])) |
|
| 160 | 160 | unset($this->items[$i]['summary']); |
| 161 | - if ( isset($this->items[$i]['atom_content'])) |
|
| 161 | + if (isset($this->items[$i]['atom_content'])) |
|
| 162 | 162 | unset($this->items[$i]['atom_content']); |
| 163 | 163 | } |
| 164 | 164 | return; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - function encoding_convert($tags = array()){ |
|
| 168 | - if(empty($tags) || in_array("channel", $tags)){ |
|
| 167 | + function encoding_convert($tags = array()) { |
|
| 168 | + if (empty($tags) || in_array("channel", $tags)) { |
|
| 169 | 169 | $this->channel = $this->_encoding($this->channel); |
| 170 | 170 | } |
| 171 | - if(empty($tags) || in_array("items", $tags)){ |
|
| 171 | + if (empty($tags) || in_array("items", $tags)) { |
|
| 172 | 172 | $this->items = $this->_encoding($this->items); |
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - function _encoding($val){ |
|
| 177 | - if(is_array($val)){ |
|
| 178 | - foreach(array_keys($val) as $key){ |
|
| 176 | + function _encoding($val) { |
|
| 177 | + if (is_array($val)) { |
|
| 178 | + foreach (array_keys($val) as $key) { |
|
| 179 | 179 | $val[$key] = $this->_encoding($val[$key]); |
| 180 | 180 | } |
| 181 | - }else{ |
|
| 181 | + }else { |
|
| 182 | 182 | $val = XoopsLocal::convert_encoding($val, $this->charset_out, $this->charset_in); |
| 183 | 183 | } |
| 184 | 184 | 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); |
@@ -30,12 +30,12 @@ discard block |
||
| 30 | 30 | The functions loaded on initializtion |
| 31 | 31 | */ |
| 32 | 32 | |
| 33 | -if (!defined('XOOPS_ROOT_PATH')){ exit(); } |
|
| 34 | -if (!defined('PLANET_INI')){ exit(); } |
|
| 33 | +if (!defined('XOOPS_ROOT_PATH')) { exit(); } |
|
| 34 | +if (!defined('PLANET_INI')) { exit(); } |
|
| 35 | 35 | |
| 36 | 36 | |
| 37 | -if(!defined("PLANET_FUNCTIONS_INI")): |
|
| 38 | -define("PLANET_FUNCTIONS_INI",1); |
|
| 37 | +if (!defined("PLANET_FUNCTIONS_INI")): |
|
| 38 | +define("PLANET_FUNCTIONS_INI", 1); |
|
| 39 | 39 | |
| 40 | 40 | function planet_constant($name) |
| 41 | 41 | { |
@@ -55,25 +55,25 @@ discard block |
||
| 55 | 55 | function planet_load_config() |
| 56 | 56 | { |
| 57 | 57 | static $moduleConfig; |
| 58 | - if(isset($moduleConfig)){ |
|
| 58 | + if (isset($moduleConfig)) { |
|
| 59 | 59 | return $moduleConfig; |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - if(is_object($GLOBALS["xoopsModule"]) && $GLOBALS["xoopsModule"]->getVar("dirname") == $GLOBALS["moddirname"]){ |
|
| 63 | - $moduleConfig =& $GLOBALS["xoopsModuleConfig"]; |
|
| 64 | - }else{ |
|
| 62 | + if (is_object($GLOBALS["xoopsModule"]) && $GLOBALS["xoopsModule"]->getVar("dirname") == $GLOBALS["moddirname"]) { |
|
| 63 | + $moduleConfig = & $GLOBALS["xoopsModuleConfig"]; |
|
| 64 | + }else { |
|
| 65 | 65 | $module_handler = &xoops_gethandler('module'); |
| 66 | 66 | $module = $module_handler->getByDirname($GLOBALS["moddirname"]); |
| 67 | 67 | |
| 68 | 68 | $config_handler = &xoops_gethandler('config'); |
| 69 | 69 | $criteria = new CriteriaCompo(new Criteria('conf_modid', $module->getVar('mid'))); |
| 70 | - $configs =& $config_handler->getConfigs($criteria); |
|
| 71 | - foreach(array_keys($configs) as $i){ |
|
| 70 | + $configs = & $config_handler->getConfigs($criteria); |
|
| 71 | + foreach (array_keys($configs) as $i) { |
|
| 72 | 72 | $moduleConfig[$configs[$i]->getVar('conf_name')] = $configs[$i]->getConfValueForOutput(); |
| 73 | 73 | } |
| 74 | 74 | unset($configs); |
| 75 | 75 | } |
| 76 | - if($customConfig = @include(XOOPS_ROOT_PATH."/modules/".$GLOBALS["moddirname"]."/include/plugin.php")){ |
|
| 76 | + if ($customConfig = @include(XOOPS_ROOT_PATH."/modules/".$GLOBALS["moddirname"]."/include/plugin.php")) { |
|
| 77 | 77 | $moduleConfig = array_merge($moduleConfig, $customConfig); |
| 78 | 78 | } |
| 79 | 79 | return $moduleConfig; |
@@ -81,13 +81,13 @@ discard block |
||
| 81 | 81 | |
| 82 | 82 | function planet_define_url_delimiter() |
| 83 | 83 | { |
| 84 | - if(defined("URL_DELIMITER")){ |
|
| 85 | - if(!in_array(URL_DELIMITER, array("?","/"))) die("Exit on security"); |
|
| 86 | - }else{ |
|
| 84 | + if (defined("URL_DELIMITER")) { |
|
| 85 | + if (!in_array(URL_DELIMITER, array("?", "/"))) die("Exit on security"); |
|
| 86 | + }else { |
|
| 87 | 87 | $moduleConfig = planet_load_config(); |
| 88 | - if(empty($moduleConfig["do_urw"])){ |
|
| 88 | + if (empty($moduleConfig["do_urw"])) { |
|
| 89 | 89 | define("URL_DELIMITER", "?"); |
| 90 | - }else{ |
|
| 90 | + }else { |
|
| 91 | 91 | define("URL_DELIMITER", "/"); |
| 92 | 92 | } |
| 93 | 93 | } |
@@ -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 | { |
@@ -25,15 +25,15 @@ discard block |
||
| 25 | 25 | // Project: Article Project // |
| 26 | 26 | // ------------------------------------------------------------------------ // |
| 27 | 27 | |
| 28 | -if (!defined('XOOPS_ROOT_PATH')){ exit(); } |
|
| 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); |
|
| 32 | -$url_arr = explode('/',strstr($current_path,'/modules/')); |
|
| 31 | +if (DIRECTORY_SEPARATOR != '/') $current_path = str_replace(strpos($current_path, '\\\\', 2) ? '\\\\' : DIRECTORY_SEPARATOR, '/', $current_path); |
|
| 32 | +$url_arr = explode('/', strstr($current_path, '/modules/')); |
|
| 33 | 33 | $GLOBALS["moddirname"] = $url_arr[2]; |
| 34 | 34 | |
| 35 | -if(!defined("planet_FUNCTIONS")): |
|
| 36 | -define("planet_FUNCTIONS",1); |
|
| 35 | +if (!defined("planet_FUNCTIONS")): |
|
| 36 | +define("planet_FUNCTIONS", 1); |
|
| 37 | 37 | |
| 38 | 38 | require XOOPS_ROOT_PATH."/modules/".$GLOBALS["moddirname"]."/include/vars.php"; |
| 39 | 39 | include_once(XOOPS_ROOT_PATH."/class/xoopslists.php"); |
@@ -44,9 +44,9 @@ discard block |
||
| 44 | 44 | * |
| 45 | 45 | * @var mixed $messages |
| 46 | 46 | */ |
| 47 | -function planet_message( $message ) |
|
| 47 | +function planet_message($message) |
|
| 48 | 48 | { |
| 49 | - return mod_message( $message ); |
|
| 49 | + return mod_message($message); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /** |
@@ -65,30 +65,30 @@ discard block |
||
| 65 | 65 | */ |
| 66 | 66 | function planet_parse_args(&$args_numeric, &$args, &$args_string) |
| 67 | 67 | { |
| 68 | - $args_abb=array("a"=>"article", "b"=>"blog", "c"=>"category", "l"=>"list", "o"=>"sort", "s"=>"start", "u"=>"uid"); |
|
| 68 | + $args_abb = array("a"=>"article", "b"=>"blog", "c"=>"category", "l"=>"list", "o"=>"sort", "s"=>"start", "u"=>"uid"); |
|
| 69 | 69 | $args = array(); |
| 70 | 70 | $args_numeric = array(); |
| 71 | 71 | $args_string = array(); |
| 72 | - if(preg_match("/[^\?]*\.php[\/|\?]([^\?]*)/i", $_SERVER['REQUEST_URI'], $matches)){ |
|
| 72 | + if (preg_match("/[^\?]*\.php[\/|\?]([^\?]*)/i", $_SERVER['REQUEST_URI'], $matches)) { |
|
| 73 | 73 | $vars = preg_split("/[\/|&]/", $matches[1]); |
| 74 | 74 | $vars = array_map("trim", $vars); |
| 75 | - if(count($vars)>0) { |
|
| 76 | - foreach($vars as $var){ |
|
| 77 | - if(is_numeric($var)){ |
|
| 75 | + if (count($vars)>0) { |
|
| 76 | + foreach ($vars as $var) { |
|
| 77 | + if (is_numeric($var)) { |
|
| 78 | 78 | $args_numeric[] = $var; |
| 79 | - }elseif(false === strpos($var, "=")){ |
|
| 80 | - if(is_numeric(substr($var, 1))){ |
|
| 79 | + }elseif (false === strpos($var, "=")) { |
|
| 80 | + if (is_numeric(substr($var, 1))) { |
|
| 81 | 81 | $args[$args_abb[strtolower($var{0})]] = intval(substr($var, 1)); |
| 82 | - }else{ |
|
| 82 | + }else { |
|
| 83 | 83 | $args_string[] = urldecode($var); |
| 84 | 84 | } |
| 85 | - }else{ |
|
| 85 | + }else { |
|
| 86 | 86 | parse_str($var, $args); |
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | - return (count($args)+count($args_numeric)+count($args_string) == 0)?null:true; |
|
| 91 | + return (count($args)+count($args_numeric)+count($args_string) == 0) ? null : true; |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | /** |
@@ -100,21 +100,21 @@ discard block |
||
| 100 | 100 | * |
| 101 | 101 | * @return bool true on success |
| 102 | 102 | */ |
| 103 | -function planet_parse_class($class_string, $pattern="", $replacement="") |
|
| 103 | +function planet_parse_class($class_string, $pattern = "", $replacement = "") |
|
| 104 | 104 | { |
| 105 | - if(empty($class_string)) return; |
|
| 105 | + if (empty($class_string)) return; |
|
| 106 | 106 | $patterns = array("/\[CLASS_PREFIX\]/"); |
| 107 | 107 | $replacements = array(ucfirst(strtolower($GLOBALS["moddirname"]))); |
| 108 | - if(!empty($pattern) && !is_array($pattern) && !is_array($replacement)){ |
|
| 108 | + if (!empty($pattern) && !is_array($pattern) && !is_array($replacement)) { |
|
| 109 | 109 | $pattern = array($pattern); |
| 110 | 110 | $replacement = array($replacement); |
| 111 | 111 | } |
| 112 | - if(is_array($pattern) && count($pattern)>0){ |
|
| 112 | + if (is_array($pattern) && count($pattern)>0) { |
|
| 113 | 113 | $ii = 0; |
| 114 | - foreach($pattern as $pat){ |
|
| 115 | - if(!in_array($pat, $patterns)){ |
|
| 114 | + foreach ($pattern as $pat) { |
|
| 115 | + if (!in_array($pat, $patterns)) { |
|
| 116 | 116 | $patterns[] = $pat; |
| 117 | - $replacements[] = isset($replacement[$ii])?$replacement[$ii]:""; |
|
| 117 | + $replacements[] = isset($replacement[$ii]) ? $replacement[$ii] : ""; |
|
| 118 | 118 | } |
| 119 | 119 | $ii++; |
| 120 | 120 | } |
@@ -133,21 +133,21 @@ discard block |
||
| 133 | 133 | * |
| 134 | 134 | * @return bool true on success |
| 135 | 135 | */ |
| 136 | -function planet_parse_function($function_string, $pattern="", $replacement="") |
|
| 136 | +function planet_parse_function($function_string, $pattern = "", $replacement = "") |
|
| 137 | 137 | { |
| 138 | - if(empty($function_string)) return; |
|
| 138 | + if (empty($function_string)) return; |
|
| 139 | 139 | $patterns = array("/\[DIRNAME\]/", "/\[VAR_PREFIX\]/"); |
| 140 | 140 | $replacements = array($GLOBALS["moddirname"], $GLOBALS["VAR_PREFIX"]); |
| 141 | - if(!empty($pattern) && !is_array($pattern) && !is_array($replacement)){ |
|
| 141 | + if (!empty($pattern) && !is_array($pattern) && !is_array($replacement)) { |
|
| 142 | 142 | $pattern = array($pattern); |
| 143 | 143 | $replacement = array($replacement); |
| 144 | 144 | } |
| 145 | - if(is_array($pattern) && count($pattern)>0){ |
|
| 145 | + if (is_array($pattern) && count($pattern)>0) { |
|
| 146 | 146 | $ii = 0; |
| 147 | - foreach($pattern as $pat){ |
|
| 148 | - if(!in_array($pat, $patterns)){ |
|
| 147 | + foreach ($pattern as $pat) { |
|
| 148 | + if (!in_array($pat, $patterns)) { |
|
| 149 | 149 | $patterns[] = $pat; |
| 150 | - $replacements[] = isset($replacement[$ii])?$replacement[$ii]:""; |
|
| 150 | + $replacements[] = isset($replacement[$ii]) ? $replacement[$ii] : ""; |
|
| 151 | 151 | } |
| 152 | 152 | $ii++; |
| 153 | 153 | } |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | */ |
| 163 | 163 | function planet_formatTimestamp($time, $format = "") |
| 164 | 164 | { |
| 165 | - if(empty($time)) return ""; |
|
| 165 | + if (empty($time)) return ""; |
|
| 166 | 166 | return formatTimestamp($time, $format); |
| 167 | 167 | } |
| 168 | 168 | |
@@ -170,9 +170,9 @@ discard block |
||
| 170 | 170 | * Function to a list of user names associated with their user IDs |
| 171 | 171 | * |
| 172 | 172 | */ |
| 173 | -function &planet_getUnameFromId( $userid, $usereal = 0, $linked = false ) |
|
| 173 | +function &planet_getUnameFromId($userid, $usereal = 0, $linked = false) |
|
| 174 | 174 | { |
| 175 | - if(!is_array($userid)) $userid = array($userid); |
|
| 175 | + if (!is_array($userid)) $userid = array($userid); |
|
| 176 | 176 | $users = mod_getUnameFromIds($userid, $usereal, $linked); |
| 177 | 177 | |
| 178 | 178 | return $users; |
@@ -188,12 +188,12 @@ discard block |
||
| 188 | 188 | */ |
| 189 | 189 | function &planet_parseLinks($text) |
| 190 | 190 | { |
| 191 | - $myts =& MyTextSanitizer::getInstance(); |
|
| 191 | + $myts = & MyTextSanitizer::getInstance(); |
|
| 192 | 192 | $link_array = preg_split("/(\r\n|\r|\n)( *)/", $text); |
| 193 | 193 | $links = array(); |
| 194 | - if(count($link_array)>0) foreach($link_array as $link){ |
|
| 195 | - @list($url, $title) = array_map("trim",preg_split("/ /", $link, 2)); |
|
| 196 | - if(empty($url)) continue; |
|
| 194 | + if (count($link_array)>0) foreach ($link_array as $link) { |
|
| 195 | + @list($url, $title) = array_map("trim", preg_split("/ /", $link, 2)); |
|
| 196 | + if (empty($url)) continue; |
|
| 197 | 197 | //if(empty($title)) $title = $url; |
| 198 | 198 | $links[] = array("url"=>$url, "title"=>$myts->htmlSpecialChars($title)); |
| 199 | 199 | } |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | return $GLOBALS["VAR_PREFIX"]."_".$pagename.".html"; |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | -function planet_adminmenu ($currentoption = -1) |
|
| 208 | +function planet_adminmenu($currentoption = -1) |
|
| 209 | 209 | { |
| 210 | 210 | loadModuleAdminMenu($currentoption, ""); |
| 211 | 211 | return; |
@@ -218,10 +218,10 @@ discard block |
||
| 218 | 218 | */ |
| 219 | 219 | function planet_com_trackback(&$article, &$comment) |
| 220 | 220 | { |
| 221 | - $blog_handler =& xoops_getmodulehandler("blog", $GLOBALS["moddirname"]); |
|
| 222 | - $blog_obj =& $blog_handler->get($article->getVar("blog_id")); |
|
| 223 | - if(!$pattern = $blog_obj->getVar("blog_trackback")) return false; |
|
| 224 | - @list($pat, $rep) = array_map("trim",preg_split("#[\s]+#", $pattern)); |
|
| 221 | + $blog_handler = & xoops_getmodulehandler("blog", $GLOBALS["moddirname"]); |
|
| 222 | + $blog_obj = & $blog_handler->get($article->getVar("blog_id")); |
|
| 223 | + if (!$pattern = $blog_obj->getVar("blog_trackback")) return false; |
|
| 224 | + @list($pat, $rep) = array_map("trim", preg_split("#[\s]+#", $pattern)); |
|
| 225 | 225 | $trackback_url = preg_replace("#".$pat."#", $rep, $article_obj->getVar("art_link")); |
| 226 | 226 | return planet_trackback($trackback_url, $article); |
| 227 | 227 | } |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | $title = xoops_utf8_encode($title); |
| 237 | 237 | $excerpt = xoops_utf8_encode($excerpt); |
| 238 | 238 | $blog_name = xoops_utf8_encode($blog_name); |
| 239 | - $charset="utf-8"; |
|
| 239 | + $charset = "utf-8"; |
|
| 240 | 240 | $title1 = urlencode($title); |
| 241 | 241 | $excerpt1 = urlencode($excerpt); |
| 242 | 242 | $name1 = urlencode($blog_name); |
@@ -244,34 +244,34 @@ discard block |
||
| 244 | 244 | $query_string = "title=$title1&url=$url&blog_name=$name1&excerpt=$excerpt1&charset=$charset"; |
| 245 | 245 | $trackback_url = parse_url($trackback_url); |
| 246 | 246 | |
| 247 | - $http_request = 'POST ' . $trackback_url['path'] . ($trackback_url['query'] ? '?'.$trackback_url['query'] : '') . " HTTP/1.0\r\n"; |
|
| 247 | + $http_request = 'POST '.$trackback_url['path'].($trackback_url['query'] ? '?'.$trackback_url['query'] : '')." HTTP/1.0\r\n"; |
|
| 248 | 248 | $http_request .= "Host: ".$trackback_url["host"]."\r\n"; |
| 249 | 249 | $http_request .= "Content-Type: application/x-www-form-urlencoded; charset=".$charset."\r\n"; |
| 250 | 250 | $http_request .= "Content-Length: ".strlen($query_string)."\r\n"; |
| 251 | - $http_request .= "User-Agent: XOOPS Blogs/" . XOOPS_VERSION; |
|
| 251 | + $http_request .= "User-Agent: XOOPS Blogs/".XOOPS_VERSION; |
|
| 252 | 252 | $http_request .= "\r\n\r\n"; |
| 253 | 253 | $http_request .= $query_string; |
| 254 | - if ( '' == $trackback_url['port'] ){ |
|
| 254 | + if ('' == $trackback_url['port']) { |
|
| 255 | 255 | $trackback_url['port'] = 80; |
| 256 | 256 | } |
| 257 | 257 | $fs = @fsockopen($trackback_url['host'], $trackback_url['port'], $errno, $errstr, 4); |
| 258 | 258 | @fputs($fs, $http_request); |
| 259 | - if($xoopsModuleConfig["do_debug"]) { |
|
| 259 | + if ($xoopsModuleConfig["do_debug"]) { |
|
| 260 | 260 | $debug_file = XOOPS_CACHE_PATH."/".$GLOBALS["moddirname"]."_trackback.log"; |
| 261 | 261 | $fr = "\n*****\nRequest:\n\n$http_request\n\nResponse:\n\n"; |
| 262 | 262 | $fr .= "CHARSET:$charset\n"; |
| 263 | 263 | $fr .= "NAME:$blog_name\n"; |
| 264 | 264 | $fr .= "TITLE:".$title."\n"; |
| 265 | 265 | $fr .= "EXCERPT:$excerpt\n\n"; |
| 266 | - while(!@feof($fs)) { |
|
| 266 | + while (!@feof($fs)) { |
|
| 267 | 267 | $fr .= @fgets($fs, 4096); |
| 268 | 268 | } |
| 269 | 269 | $fr .= "\n\n"; |
| 270 | 270 | |
| 271 | - if($fp = fopen($debug_file, "a")){ |
|
| 271 | + if ($fp = fopen($debug_file, "a")) { |
|
| 272 | 272 | fwrite($fp, $fr); |
| 273 | 273 | fclose($fp); |
| 274 | - }else{ |
|
| 274 | + }else { |
|
| 275 | 275 | } |
| 276 | 276 | } |
| 277 | 277 | @fclose($fs); |
@@ -282,8 +282,8 @@ discard block |
||
| 282 | 282 | * Function to ping servers |
| 283 | 283 | */ |
| 284 | 284 | function planet_ping($server, $id) { |
| 285 | - if(is_array($server)){ |
|
| 286 | - foreach($server as $serv){ |
|
| 285 | + if (is_array($server)) { |
|
| 286 | + foreach ($server as $serv) { |
|
| 287 | 287 | planet_ping($serv, $id); |
| 288 | 288 | } |
| 289 | 289 | } |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | $home = XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/"; |
| 302 | 302 | $rss2_url = XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/xml.php".URL_DELIMITER."rss2.0/".$id; |
| 303 | 303 | |
| 304 | - if ( !$client->query('weblogUpdates.extendedPing', $blogname, $home, $rss2_url ) ) // then try a normal ping |
|
| 304 | + if (!$client->query('weblogUpdates.extendedPing', $blogname, $home, $rss2_url)) // then try a normal ping |
|
| 305 | 305 | $client->query('weblogUpdates.ping', $blogname, $home); |
| 306 | 306 | } |
| 307 | 307 | |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | echo "<message>$error_message</message>\n"; |
| 320 | 320 | echo "</response>"; |
| 321 | 321 | die(); |
| 322 | - } else { |
|
| 322 | + }else { |
|
| 323 | 323 | echo '<?xml version="1.0" encoding="'.$charset.'"?'.">\n"; |
| 324 | 324 | echo "<response>\n"; |
| 325 | 325 | echo "<error>0</error>\n"; |
@@ -334,10 +334,10 @@ discard block |
||
| 334 | 334 | */ |
| 335 | 335 | function planet_setcookie($name, $string = '', $expire = 0) |
| 336 | 336 | { |
| 337 | - if(is_array($string)) { |
|
| 337 | + if (is_array($string)) { |
|
| 338 | 338 | $value = array(); |
| 339 | - foreach ($string as $key => $val){ |
|
| 340 | - $value[]=$key."|".$val; |
|
| 339 | + foreach ($string as $key => $val) { |
|
| 340 | + $value[] = $key."|".$val; |
|
| 341 | 341 | } |
| 342 | 342 | $string = implode(",", $value); |
| 343 | 343 | } |
@@ -347,12 +347,12 @@ discard block |
||
| 347 | 347 | function planet_getcookie($name, $isArray = false) |
| 348 | 348 | { |
| 349 | 349 | $value = isset($_COOKIE[$GLOBALS["VAR_PREFIX"].$name]) ? $_COOKIE[$GLOBALS["VAR_PREFIX"].$name] : null; |
| 350 | - if($isArray) { |
|
| 351 | - $_value = ($value)?explode(",", $value):array(); |
|
| 350 | + if ($isArray) { |
|
| 351 | + $_value = ($value) ? explode(",", $value) : array(); |
|
| 352 | 352 | $value = array(); |
| 353 | - if(count($_value)>0) foreach($_value as $string){ |
|
| 354 | - $key = substr($string, 0, strpos($string,"|")); |
|
| 355 | - $val = substr($string, (strpos($string,"|")+1)); |
|
| 353 | + if (count($_value)>0) foreach ($_value as $string) { |
|
| 354 | + $key = substr($string, 0, strpos($string, "|")); |
|
| 355 | + $val = substr($string, (strpos($string, "|")+1)); |
|
| 356 | 356 | $value[$key] = $val; |
| 357 | 357 | } |
| 358 | 358 | unset($_value); |
@@ -379,9 +379,9 @@ discard block |
||
| 379 | 379 | |
| 380 | 380 | function planet_remote_content($url) |
| 381 | 381 | { |
| 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; |
|
| 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; |
|
| 385 | 385 | return false; |
| 386 | 386 | } |
| 387 | 387 | |
@@ -390,20 +390,20 @@ discard block |
||
| 390 | 390 | require_once(XOOPS_ROOT_PATH."/class/snoopy.php"); |
| 391 | 391 | $snoopy = new Snoopy; |
| 392 | 392 | $data = ""; |
| 393 | - if (@$snoopy->fetch($url)){ |
|
| 394 | - $data = (is_array($snoopy->results))?implode("\n",$snoopy->results):$snoopy->results; |
|
| 393 | + if (@$snoopy->fetch($url)) { |
|
| 394 | + $data = (is_array($snoopy->results)) ? implode("\n", $snoopy->results) : $snoopy->results; |
|
| 395 | 395 | } |
| 396 | 396 | return $data; |
| 397 | 397 | } |
| 398 | 398 | |
| 399 | 399 | function planet_fetch_CURL($url) |
| 400 | 400 | { |
| 401 | - if (!function_exists('curl_init') ) return false; |
|
| 402 | - $ch = curl_init(); // initialize curl handle |
|
| 401 | + if (!function_exists('curl_init')) return false; |
|
| 402 | + $ch = curl_init(); // initialize curl handle |
|
| 403 | 403 | curl_setopt($ch, CURLOPT_URL, $url); // set url to post to |
| 404 | 404 | curl_setopt($ch, CURLOPT_FAILONERROR, 1); |
| 405 | - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects |
|
| 406 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable |
|
| 405 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // allow redirects |
|
| 406 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable |
|
| 407 | 407 | curl_setopt($ch, CURLOPT_TIMEOUT, 30); // times out after 31s |
| 408 | 408 | $data = curl_exec($ch); // run the whole process |
| 409 | 409 | curl_close($ch); |
@@ -412,25 +412,25 @@ discard block |
||
| 412 | 412 | |
| 413 | 413 | function planet_fetch_fopen($url) |
| 414 | 414 | { |
| 415 | - if(!$fp = @fopen ($url, 'r')) return false; |
|
| 415 | + if (!$fp = @fopen($url, 'r')) return false; |
|
| 416 | 416 | $data = ""; |
| 417 | 417 | while (!feof($fp)) { |
| 418 | - $data .= fgets ($fp, 1024); |
|
| 418 | + $data .= fgets($fp, 1024); |
|
| 419 | 419 | } |
| 420 | 420 | fclose($fp); |
| 421 | 421 | return $data; |
| 422 | 422 | } |
| 423 | 423 | |
| 424 | -function planet_strrpos($haystack, $needle, $offset = 0 ) |
|
| 424 | +function planet_strrpos($haystack, $needle, $offset = 0) |
|
| 425 | 425 | { |
| 426 | - if( substr(phpversion(),0,1) == 5 ){ |
|
| 426 | + if (substr(phpversion(), 0, 1) == 5) { |
|
| 427 | 427 | return strrpos($haystack, $needle, $offset); |
| 428 | 428 | } |
| 429 | 429 | $index = strpos(strrev($haystack), strrev($needle)); |
| 430 | - if($index === false) { |
|
| 430 | + if ($index === false) { |
|
| 431 | 431 | return false; |
| 432 | 432 | } |
| 433 | - $index = strlen($haystack) - strlen($needle) - $index; |
|
| 433 | + $index = strlen($haystack)-strlen($needle)-$index; |
|
| 434 | 434 | return $index; |
| 435 | 435 | } |
| 436 | 436 | endif; |
@@ -26,46 +26,46 @@ discard block |
||
| 26 | 26 | // ------------------------------------------------------------------------ // |
| 27 | 27 | include "header.php"; |
| 28 | 28 | |
| 29 | -if(preg_match("/\/notification_update\.php/i", $_SERVER['REQUEST_URI'], $matches)){ |
|
| 29 | +if (preg_match("/\/notification_update\.php/i", $_SERVER['REQUEST_URI'], $matches)) { |
|
| 30 | 30 | include XOOPS_ROOT_PATH.'/include/notification_update.php'; |
| 31 | 31 | exit(); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | -if($REQUEST_URI_parsed = planet_parse_args($args_num, $args, $args_str)){ |
|
| 34 | +if ($REQUEST_URI_parsed = planet_parse_args($args_num, $args, $args_str)) { |
|
| 35 | 35 | $args["start"] = @$args_num[0]; |
| 36 | 36 | $args["sort"] = @$args_str[0]; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /* Start */ |
| 40 | -$start = intval( empty($_GET["start"])?@$args["start"]:$_GET["start"] ); |
|
| 40 | +$start = intval(empty($_GET["start"]) ? @$args["start"] : $_GET["start"]); |
|
| 41 | 41 | /* Specified Category */ |
| 42 | -$category_id = intval( empty($_GET["category"])?@$args["category"]:$_GET["category"] ); |
|
| 42 | +$category_id = intval(empty($_GET["category"]) ? @$args["category"] : $_GET["category"]); |
|
| 43 | 43 | /* Specified Blog */ |
| 44 | -$blog_id = intval( empty($_GET["blog"])?@$args["blog"]:$_GET["blog"] ); |
|
| 44 | +$blog_id = intval(empty($_GET["blog"]) ? @$args["blog"] : $_GET["blog"]); |
|
| 45 | 45 | /* Specified Bookmar(Favorite) UID */ |
| 46 | -$uid = intval( empty($_GET["uid"])?@$args["uid"]:$_GET["uid"] ); |
|
| 46 | +$uid = intval(empty($_GET["uid"]) ? @$args["uid"] : $_GET["uid"]); |
|
| 47 | 47 | /* Sort by term */ |
| 48 | -$sort = empty($_GET["sort"])?@$args["sort"]:$_GET["sort"]; |
|
| 48 | +$sort = empty($_GET["sort"]) ? @$args["sort"] : $_GET["sort"]; |
|
| 49 | 49 | /* Display as list */ |
| 50 | -$list = intval( empty($_GET["list"])?@$args["list"]:$_GET["list"] ); |
|
| 50 | +$list = intval(empty($_GET["list"]) ? @$args["list"] : $_GET["list"]); |
|
| 51 | 51 | |
| 52 | 52 | // restore $_SERVER['REQUEST_URI'] |
| 53 | -if(!empty($REQUEST_URI_parsed)){ |
|
| 53 | +if (!empty($REQUEST_URI_parsed)) { |
|
| 54 | 54 | $args_REQUEST_URI = array(); |
| 55 | - $_args =array("start", "sort", "uid", "list"); |
|
| 56 | - foreach($_args as $arg){ |
|
| 57 | - if(!empty(${$arg})){ |
|
| 58 | - $args_REQUEST_URI[] = $arg ."=". ${$arg}; |
|
| 55 | + $_args = array("start", "sort", "uid", "list"); |
|
| 56 | + foreach ($_args as $arg) { |
|
| 57 | + if (!empty(${$arg})) { |
|
| 58 | + $args_REQUEST_URI[] = $arg."=".${$arg}; |
|
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | - if(!empty($blog_id)){ |
|
| 62 | - $args_REQUEST_URI[] = "blog=". $blog_id; |
|
| 61 | + if (!empty($blog_id)) { |
|
| 62 | + $args_REQUEST_URI[] = "blog=".$blog_id; |
|
| 63 | 63 | } |
| 64 | - if(!empty($category_id)){ |
|
| 65 | - $args_REQUEST_URI[] = "category=". $category_id; |
|
| 64 | + if (!empty($category_id)) { |
|
| 65 | + $args_REQUEST_URI[] = "category=".$category_id; |
|
| 66 | 66 | } |
| 67 | 67 | $_SERVER['REQUEST_URI'] = XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/index.php". |
| 68 | - (empty($args_REQUEST_URI)?"":"?".implode("&",$args_REQUEST_URI)); |
|
| 68 | + (empty($args_REQUEST_URI) ? "" : "?".implode("&", $args_REQUEST_URI)); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | $xoopsOption["template_main"] = planet_getTemplate("index"); |
@@ -76,20 +76,20 @@ discard block |
||
| 76 | 76 | '; |
| 77 | 77 | |
| 78 | 78 | $xoopsOption["xoops_module_header"] = $xoops_module_header; |
| 79 | -include_once( XOOPS_ROOT_PATH . "/header.php" ); |
|
| 79 | +include_once(XOOPS_ROOT_PATH."/header.php"); |
|
| 80 | 80 | include XOOPS_ROOT_PATH."/modules/".$xoopsModule->getVar("dirname")."/include/vars.php"; |
| 81 | 81 | |
| 82 | 82 | // Following part will not be executed after cache |
| 83 | -$category_handler =& xoops_getmodulehandler("category", $GLOBALS["moddirname"]); |
|
| 84 | -$blog_handler =& xoops_getmodulehandler("blog", $GLOBALS["moddirname"]); |
|
| 85 | -$article_handler =& xoops_getmodulehandler("article", $GLOBALS["moddirname"]); |
|
| 83 | +$category_handler = & xoops_getmodulehandler("category", $GLOBALS["moddirname"]); |
|
| 84 | +$blog_handler = & xoops_getmodulehandler("blog", $GLOBALS["moddirname"]); |
|
| 85 | +$article_handler = & xoops_getmodulehandler("article", $GLOBALS["moddirname"]); |
|
| 86 | 86 | |
| 87 | -$limit = empty($list)? $xoopsModuleConfig["articles_perpage"] : $xoopsModuleConfig["list_perpage"]; |
|
| 87 | +$limit = empty($list) ? $xoopsModuleConfig["articles_perpage"] : $xoopsModuleConfig["list_perpage"]; |
|
| 88 | 88 | $query_type = ""; |
| 89 | 89 | $criteria = new CriteriaCompo(); |
| 90 | 90 | $article_prefix = ""; |
| 91 | 91 | /* Specific category */ |
| 92 | -if($category_id >0){ |
|
| 92 | +if ($category_id>0) { |
|
| 93 | 93 | $category_obj = $category_handler->get($category_id); |
| 94 | 94 | $criteria->add(new Criteria("bc.cat_id", $category_id)); |
| 95 | 95 | $uid = 0; |
@@ -99,15 +99,15 @@ discard block |
||
| 99 | 99 | $article_prefix = "a."; |
| 100 | 100 | } |
| 101 | 101 | /* Specific blog */ |
| 102 | -if($blog_id>0){ |
|
| 103 | - $blog_obj =& $blog_handler->get($blog_id); |
|
| 104 | - if($blog_obj->getVar("blog_status") || |
|
| 105 | - (is_object($xoopsUser) && $xoopsUser->getVar("uid")== $blog_obj->getVar("blog_submitter")) |
|
| 106 | - ){ |
|
| 102 | +if ($blog_id>0) { |
|
| 103 | + $blog_obj = & $blog_handler->get($blog_id); |
|
| 104 | + if ($blog_obj->getVar("blog_status") || |
|
| 105 | + (is_object($xoopsUser) && $xoopsUser->getVar("uid") == $blog_obj->getVar("blog_submitter")) |
|
| 106 | + ) { |
|
| 107 | 107 | $criteria->add(new Criteria("blog_id", $blog_id)); |
| 108 | 108 | $category_id = 0; |
| 109 | 109 | $uid = 0; |
| 110 | - $bookmark_handler =& xoops_getmodulehandler("bookmark", $GLOBALS["moddirname"]); |
|
| 110 | + $bookmark_handler = & xoops_getmodulehandler("bookmark", $GLOBALS["moddirname"]); |
|
| 111 | 111 | $blog_data = array( |
| 112 | 112 | "id"=>$blog_id, |
| 113 | 113 | "title"=>$blog_obj->getVar("blog_title"), |
@@ -126,11 +126,11 @@ discard block |
||
| 126 | 126 | $article_prefix = ""; |
| 127 | 127 | } |
| 128 | 128 | /* User bookmarks(favorites) */ |
| 129 | -if($uid >0){ |
|
| 129 | +if ($uid>0) { |
|
| 130 | 130 | $criteria->add(new Criteria("bm.bm_uid", $uid)); |
| 131 | 131 | $category_id = 0; |
| 132 | 132 | $blog_id = 0; |
| 133 | - $bookmark_handler =& xoops_getmodulehandler("bookmark", $GLOBALS["moddirname"]); |
|
| 133 | + $bookmark_handler = & xoops_getmodulehandler("bookmark", $GLOBALS["moddirname"]); |
|
| 134 | 134 | $user_data = array( |
| 135 | 135 | "uid"=>$uid, |
| 136 | 136 | "name"=>XoopsUser::getUnameFromID($uid), |
@@ -142,8 +142,8 @@ discard block |
||
| 142 | 142 | |
| 143 | 143 | /* Sort */ |
| 144 | 144 | $order = "DESC"; |
| 145 | -$sort = empty($sort)?"time":$sort; |
|
| 146 | -switch($sort){ |
|
| 145 | +$sort = empty($sort) ? "time" : $sort; |
|
| 146 | +switch ($sort) { |
|
| 147 | 147 | case "views": |
| 148 | 148 | $sortby = $article_prefix."art_views"; |
| 149 | 149 | break; |
@@ -163,25 +163,25 @@ discard block |
||
| 163 | 163 | $criteria->setStart($start); |
| 164 | 164 | $criteria->setLimit($limit); |
| 165 | 165 | |
| 166 | -$tags = empty($list)?"":array($article_prefix."art_title", $article_prefix."blog_id", $article_prefix."art_time"); |
|
| 167 | -switch($query_type){ |
|
| 166 | +$tags = empty($list) ? "" : array($article_prefix."art_title", $article_prefix."blog_id", $article_prefix."art_time"); |
|
| 167 | +switch ($query_type) { |
|
| 168 | 168 | case "category": |
| 169 | - $articles_obj =& $article_handler->getByCategory($criteria, $tags); |
|
| 169 | + $articles_obj = & $article_handler->getByCategory($criteria, $tags); |
|
| 170 | 170 | $count_article = $article_handler->getCountByCategory($criteria); |
| 171 | 171 | break; |
| 172 | 172 | case "bookmark": |
| 173 | - $articles_obj =& $article_handler->getByBookmark($criteria, $tags); |
|
| 173 | + $articles_obj = & $article_handler->getByBookmark($criteria, $tags); |
|
| 174 | 174 | $count_article = $article_handler->getCountByBookmark($criteria); |
| 175 | 175 | break; |
| 176 | 176 | default: |
| 177 | - $articles_obj =& $article_handler->getAll($criteria, $tags); |
|
| 177 | + $articles_obj = & $article_handler->getAll($criteria, $tags); |
|
| 178 | 178 | $count_article = $article_handler->getCount($criteria); |
| 179 | 179 | break; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | -if(!empty($blog_data)){ |
|
| 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; |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | "time" => $articles_obj[$id]->getTime(), |
| 200 | 200 | "blog"=> array("id"=>$articles_obj[$id]->getVar("blog_id"), "title"=>$blogs[$articles_obj[$id]->getVar("blog_id")]) |
| 201 | 201 | ); |
| 202 | - if(empty($list)){ |
|
| 202 | + if (empty($list)) { |
|
| 203 | 203 | $_article = array_merge($_article, array( |
| 204 | 204 | "author" => $articles_obj[$id]->getVar("art_author"), |
| 205 | 205 | "views"=> $articles_obj[$id]->getVar("art_views"), |
@@ -208,9 +208,9 @@ discard block |
||
| 208 | 208 | "rates"=> $articles_obj[$id]->getVar("art_rates") |
| 209 | 209 | ) |
| 210 | 210 | ); |
| 211 | - if(!empty($xoopsModuleConfig["display_summary"])){ |
|
| 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 | } |
@@ -219,46 +219,46 @@ discard block |
||
| 219 | 219 | } |
| 220 | 220 | unset($articles_obj); |
| 221 | 221 | |
| 222 | -if ( $count_article > $limit) { |
|
| 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) $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; |
|
| 229 | 229 | $nav = new XoopsPageNav($count_article, $limit, $start, "start", implode("&", $start_link)); |
| 230 | 230 | $pagenav = $nav->renderNav(4); |
| 231 | -} else { |
|
| 231 | +}else { |
|
| 232 | 232 | $pagenav = ""; |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | -$xoopsTpl -> assign("xoops_module_header", $xoops_module_header ); |
|
| 236 | -$xoopsTpl -> assign("dirname", $GLOBALS["moddirname"] ); |
|
| 235 | +$xoopsTpl -> assign("xoops_module_header", $xoops_module_header); |
|
| 236 | +$xoopsTpl -> assign("dirname", $GLOBALS["moddirname"]); |
|
| 237 | 237 | |
| 238 | -if($category_id || $blog_id || $uid){ |
|
| 238 | +if ($category_id || $blog_id || $uid) { |
|
| 239 | 239 | $xoopsTpl -> assign("link_index", "<a href=\"".XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/index.php\" title=\"".planet_constant("MD_INDEX")."\" target=\"_self\">".planet_constant("MD_INDEX")."</a>"); |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | $link_switch = "<a href=\"".XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/index.php". |
| 243 | - (empty($category_id)?"":"/c".$category_id). |
|
| 244 | - (empty($uid)?"":"/u".$uid). |
|
| 245 | - (empty($blog_id)?"":"/b".$blog_id). |
|
| 246 | - (empty($list)?"/l1":""). |
|
| 247 | - "\" title=\"".(empty($list)?planet_constant("MD_LISTVIEW"):planet_constant("MD_FULLVIEW"))."\">".(empty($list)?planet_constant("MD_LISTVIEW"):planet_constant("MD_FULLVIEW"))."</a>"; |
|
| 243 | + (empty($category_id) ? "" : "/c".$category_id). |
|
| 244 | + (empty($uid) ? "" : "/u".$uid). |
|
| 245 | + (empty($blog_id) ? "" : "/b".$blog_id). |
|
| 246 | + (empty($list) ? "/l1" : ""). |
|
| 247 | + "\" title=\"".(empty($list) ? planet_constant("MD_LISTVIEW") : planet_constant("MD_FULLVIEW"))."\">".(empty($list) ? planet_constant("MD_LISTVIEW") : planet_constant("MD_FULLVIEW"))."</a>"; |
|
| 248 | 248 | $xoopsTpl -> assign("link_switch", $link_switch); |
| 249 | 249 | |
| 250 | 250 | $link_blogs = "<a href=\"".XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/view.blogs.php". |
| 251 | - (empty($category_id)?"":"/c".$category_id). |
|
| 252 | - (empty($uid)?"":"/u".$uid). |
|
| 251 | + (empty($category_id) ? "" : "/c".$category_id). |
|
| 252 | + (empty($uid) ? "" : "/u".$uid). |
|
| 253 | 253 | "\" title=\"".planet_constant("MD_BLOGS")."\">".planet_constant("MD_BLOGS"). |
| 254 | 254 | "</a>"; |
| 255 | 255 | $xoopsTpl -> assign("link_blogs", $link_blogs); |
| 256 | 256 | |
| 257 | -if(empty($uid) && is_object($xoopsUser)){ |
|
| 257 | +if (empty($uid) && is_object($xoopsUser)) { |
|
| 258 | 258 | $xoopsTpl -> assign("link_bookmark", "<a href=\"".XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/index.php".URL_DELIMITER."u".$xoopsUser->getVar("uid")."\" title=\"".planet_constant("MD_BOOKMARKS")."\" target=\"_self\">".planet_constant("MD_BOOKMARKS")."</a>"); |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | -if($xoopsModuleConfig["newblog_submit"]==1 || is_object($xoopsUser)){ |
|
| 261 | +if ($xoopsModuleConfig["newblog_submit"] == 1 || is_object($xoopsUser)) { |
|
| 262 | 262 | $xoopsTpl -> assign("link_submit", "<a href=\"".XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/action.blog.php\" title=\""._SUBMIT."\" target=\"_blank\">"._SUBMIT."</a>"); |
| 263 | 263 | } |
| 264 | 264 | |
@@ -270,21 +270,21 @@ discard block |
||
| 270 | 270 | $xoopsTpl -> assign("pagenav", $pagenav); |
| 271 | 271 | $xoopsTpl -> assign("is_list", !empty($list)); |
| 272 | 272 | |
| 273 | -$xoopsTpl -> assign("user_level", !is_object($xoopsUser)?0:($xoopsUser->isAdmin()?2:1)); |
|
| 274 | -if(empty($xoopsModuleConfig["anonymous_rate"]) && !is_object($xoopsUser)){ |
|
| 275 | -}elseif($blog_id>0){ |
|
| 273 | +$xoopsTpl -> assign("user_level", !is_object($xoopsUser) ? 0 : ($xoopsUser->isAdmin() ? 2 : 1)); |
|
| 274 | +if (empty($xoopsModuleConfig["anonymous_rate"]) && !is_object($xoopsUser)) { |
|
| 275 | +}elseif ($blog_id>0) { |
|
| 276 | 276 | $xoopsTpl -> assign("canrate", 1); |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | $sort_link = XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/index.php". |
| 280 | - (empty($category_id)?"":"/c".$category_id). |
|
| 281 | - (empty($uid)?"":"/u".$uid). |
|
| 282 | - (empty($blog_id)?"":"/b".$blog_id). |
|
| 283 | - (empty($list)?"":"/l1"); |
|
| 280 | + (empty($category_id) ? "" : "/c".$category_id). |
|
| 281 | + (empty($uid) ? "" : "/u".$uid). |
|
| 282 | + (empty($blog_id) ? "" : "/b".$blog_id). |
|
| 283 | + (empty($list) ? "" : "/l1"); |
|
| 284 | 284 | $valid_sorts = array("views"=>planet_constant("MD_VIEWS"), "rating"=>planet_constant("MD_RATING"), "time"=>planet_constant("MD_TIME"), "default"=>planet_constant("MD_DEFAULT")); |
| 285 | 285 | $sortlinks = array(); |
| 286 | -foreach($valid_sorts as $val=>$name){ |
|
| 287 | - if($val == $sort) continue; |
|
| 286 | +foreach ($valid_sorts as $val=>$name) { |
|
| 287 | + if ($val == $sort) continue; |
|
| 288 | 288 | $sortlinks[] = "<a href=\"".$sort_link."/".$val."\">".$name."</a>"; |
| 289 | 289 | } |
| 290 | 290 | $xoopsTpl -> assign("link_sort", implode(" | ", $sortlinks)); |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | $xoopsTpl->assign('do_pseudocron', $xoopsModuleConfig["do_pseudocron"]); |
| 294 | 294 | |
| 295 | 295 | // for notification |
| 296 | -if(!empty($blog_id)){ |
|
| 296 | +if (!empty($blog_id)) { |
|
| 297 | 297 | //$_SERVER['REQUEST_URI'] = XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/index.php"; |
| 298 | 298 | $_GET["blog"] = $blog_id; |
| 299 | 299 | } |