]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blobdiff - includes/Feed.php
MediaWiki 1.14.0
[autoinstallsdev/mediawiki.git] / includes / Feed.php
index ed4343c31bfbc5d330c98706546a1aa19d028f90..fe6d8febd63e04fea5ef729d4dedf642483d9b63 100644 (file)
@@ -41,6 +41,7 @@ class FeedItem {
 
        /**#@+
         * @todo document
+        * @param $Url URL uniquely designating the item.
         */
        function __construct( $Title, $Description, $Url, $Date = '', $Author = '', $Comments = '' ) {
                $this->Title = $Title;
@@ -51,25 +52,45 @@ class FeedItem {
                $this->Comments = $Comments;
        }
 
-       /**
-        * @static
-        */
-       function xmlEncode( $string ) {
+       public function xmlEncode( $string ) {
                $string = str_replace( "\r\n", "\n", $string );
                $string = preg_replace( '/[\x00-\x08\x0b\x0c\x0e-\x1f]/', '', $string );
                return htmlspecialchars( $string );
        }
 
-       function getTitle() { return $this->xmlEncode( $this->Title ); }
-       function getUrl() { return $this->xmlEncode( $this->Url ); }
-       function getDescription() { return $this->xmlEncode( $this->Description ); }
-       function getLanguage() {
+       public function getTitle() {
+               return $this->xmlEncode( $this->Title );
+       }
+
+       public function getUrl() {
+               return $this->xmlEncode( $this->Url );
+       }
+
+       public function getDescription() {
+               return $this->xmlEncode( $this->Description );
+       }
+
+       public function getLanguage() {
                global $wgContLanguageCode;
                return $wgContLanguageCode;
        }
-       function getDate() { return $this->Date; }
-       function getAuthor() { return $this->xmlEncode( $this->Author ); }
-       function getComments() { return $this->xmlEncode( $this->Comments ); }
+
+       public function getDate() {
+               return $this->Date;
+       }
+       public function getAuthor() {
+               return $this->xmlEncode( $this->Author );
+       }
+       public function getComments() {
+               return $this->xmlEncode( $this->Comments );
+       }
+       
+       /**
+        * Quickie hack... strip out wikilinks to more legible form from the comment.
+        */
+       public static function stripComment( $text ) {
+               return preg_replace( '/\[\[([^]]*\|)?([^]]+)\]\]/', '\2', $text );
+       }
        /**#@-*/
 }
 
@@ -145,12 +166,13 @@ class ChannelFeed extends FeedItem {
         * @private
         */
        function outXmlHeader() {
-               global $wgServer, $wgStylePath, $wgStyleVersion;
+               global $wgStylePath, $wgStyleVersion;
 
                $this->httpHeaders();
-               echo '<?xml version="1.0" encoding="utf-8"?>' . "\n";
+               echo '<?xml version="1.0"?>' . "\n";
                echo '<?xml-stylesheet type="text/css" href="' .
-                       htmlspecialchars( "$wgServer$wgStylePath/common/feed.css?$wgStyleVersion" ) . '"?' . ">\n";
+                       htmlspecialchars( wfExpandUrl( "$wgStylePath/common/feed.css?$wgStyleVersion" ) ) .
+                       '"?' . ">\n";
        }
 }
 
@@ -298,5 +320,3 @@ class AtomFeed extends ChannelFeed {
        </feed><?php
        }
 }
-
-?>