Revision: 43695
Author:   aaron
Date:     2008-11-19 00:11:14 +0000 (Wed, 19 Nov 2008)

Log Message:
-----------
Add FeedItem::stripComment() and remove duplication

Modified Paths:
--------------
    trunk/phase3/includes/Feed.php
    trunk/phase3/includes/PageHistory.php
    trunk/phase3/includes/specials/SpecialContributions.php
    trunk/phase3/includes/specials/SpecialNewpages.php

Modified: trunk/phase3/includes/Feed.php
===================================================================
--- trunk/phase3/includes/Feed.php      2008-11-19 00:06:51 UTC (rev 43694)
+++ trunk/phase3/includes/Feed.php      2008-11-19 00:11:14 UTC (rev 43695)
@@ -52,22 +52,45 @@
                $this->Comments = $Comments;
        }
 
-       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 
);
+       }
        /[EMAIL PROTECTED]/
 }
 

Modified: trunk/phase3/includes/PageHistory.php
===================================================================
--- trunk/phase3/includes/PageHistory.php       2008-11-19 00:06:51 UTC (rev 
43694)
+++ trunk/phase3/includes/PageHistory.php       2008-11-19 00:11:14 UTC (rev 
43695)
@@ -573,7 +573,7 @@
                        $rev->getUserText(),
                        $wgContLang->timeanddate( $rev->getTimestamp() ) );
                } else {
-                       $title = $rev->getUserText() . ": " . 
$this->stripComment( $rev->getComment() );
+                       $title = $rev->getUserText() . ": " . 
FeedItem::stripComment( $rev->getComment() );
                }
 
                return new FeedItem(
@@ -584,13 +584,6 @@
                        $rev->getUserText(),
                        $this->mTitle->getTalkPage()->getFullUrl() );
        }
-
-       /**
-        * Quickie hack... strip out wikilinks to more legible form from the 
comment.
-        */
-       function stripComment( $text ) {
-               return preg_replace( '/\[\[([^]]*\|)?([^]]+)\]\]/', '\2', $text 
);
-       }
 }
 
 

Modified: trunk/phase3/includes/specials/SpecialContributions.php
===================================================================
--- trunk/phase3/includes/specials/SpecialContributions.php     2008-11-19 
00:06:51 UTC (rev 43694)
+++ trunk/phase3/includes/specials/SpecialContributions.php     2008-11-19 
00:11:14 UTC (rev 43695)
@@ -347,13 +347,6 @@
                }
        }
 
-       /**
-        * Quickie hack... strip out wikilinks to more legible form from the 
comment.
-        */
-       protected function stripComment( $text ) {
-               return preg_replace( '/\[\[([^]]*\|)?([^]]+)\]\]/', '\2', $text 
);
-       }
-
        protected function feedItemAuthor( $revision ) {
                return $revision->getUserText();
        }
@@ -361,7 +354,7 @@
        protected function feedItemDesc( $revision ) {
                if( $revision ) {
                        return '<p>' . htmlspecialchars( 
$revision->getUserText() ) . ': ' .
-                               htmlspecialchars( $this->stripComment( 
$revision->getComment() ) ) . 
+                               htmlspecialchars( FeedItem::stripComment( 
$revision->getComment() ) ) . 
                                "</p>\n<hr />\n<div>" .
                                nl2br( htmlspecialchars( $revision->getText() ) 
) . "</div>";
                }

Modified: trunk/phase3/includes/specials/SpecialNewpages.php
===================================================================
--- trunk/phase3/includes/specials/SpecialNewpages.php  2008-11-19 00:06:51 UTC 
(rev 43694)
+++ trunk/phase3/includes/specials/SpecialNewpages.php  2008-11-19 00:11:14 UTC 
(rev 43695)
@@ -322,13 +322,6 @@
                }
        }
 
-       /**
-        * Quickie hack... strip out wikilinks to more legible form from the 
comment.
-        */
-       protected function stripComment( $text ) {
-               return preg_replace( '/\[\[([^]]*\|)?([^]]+)\]\]/', '\2', $text 
);
-       }
-
        protected function feedItemAuthor( $row ) {
                return isset( $row->rc_user_text ) ? $row->rc_user_text : '';
        }
@@ -337,7 +330,7 @@
                $revision = Revision::newFromId( $row->rev_id );
                if( $revision ) {
                        return '<p>' . htmlspecialchars( 
$revision->getUserText() ) . ': ' .
-                               htmlspecialchars( $this->stripComment( 
$revision->getComment() ) ) . 
+                               htmlspecialchars( FeedItem::stripComment( 
$revision->getComment() ) ) . 
                                "</p>\n<hr />\n<div>" .
                                nl2br( htmlspecialchars( $revision->getText() ) 
) . "</div>";
                }



_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to