Merge changes Ic13414f0,I26085bfc
[lhc/web/wiklou.git] / includes / FeedUtils.php
index 57d8c0b..22cb52b 100644 (file)
@@ -59,7 +59,7 @@ class FeedUtils {
                        return false;
                }
 
-               if( !isset( $wgFeedClasses[$type] ) ) {
+               if ( !isset( $wgFeedClasses[$type] ) ) {
                        $wgOut->addWikiMsg( 'feed-invalid' );
                        return false;
                }
@@ -77,14 +77,14 @@ class FeedUtils {
                $titleObj = Title::makeTitle( $row->rc_namespace, $row->rc_title );
                $timestamp = wfTimestamp( TS_MW, $row->rc_timestamp );
                $actiontext = '';
-               if( $row->rc_type == RC_LOG ) {
+               if ( $row->rc_type == RC_LOG ) {
                        $rcRow = (array)$row; // newFromRow() only accepts arrays for RC rows
                        $actiontext = LogFormatter::newFromRow( $rcRow )->getActionText();
                }
                return self::formatDiffRow( $titleObj,
                        $row->rc_last_oldid, $row->rc_this_oldid,
                        $timestamp,
-                       ($row->rc_deleted & Revision::DELETED_COMMENT)
+                       $row->rc_deleted & Revision::DELETED_COMMENT
                                ? wfMessage( 'rev-deleted-comment' )->escaped()
                                : $row->rc_comment,
                        $actiontext
@@ -121,13 +121,13 @@ class FeedUtils {
 
                // Can't diff special pages, unreadable pages or pages with no new revision
                // to compare against: just return the text.
-               if( $title->getNamespace() < 0 || $accErrors || !$newid ) {
+               if ( $title->getNamespace() < 0 || $accErrors || !$newid ) {
                        wfProfileOut( __METHOD__ );
                        return $completeText;
                }
 
-               if( $oldid ) {
-                       wfProfileIn( __METHOD__."-dodiff" );
+               if ( $oldid ) {
+                       wfProfileIn( __METHOD__ . "-dodiff" );
 
                        #$diffText = $de->getDiff( wfMessage( 'revisionasof',
                        #       $wgLang->timeanddate( $timestamp ),
@@ -168,10 +168,10 @@ class FeedUtils {
                                $diffText = UtfNormal::cleanUp( $diffText );
                                $diffText = self::applyDiffStyle( $diffText );
                        }
-                       wfProfileOut( __METHOD__."-dodiff" );
+                       wfProfileOut( __METHOD__ . "-dodiff" );
                } else {
                        $rev = Revision::newFromId( $newid );
-                       if( $wgFeedDiffCutoff <= 0 || is_null( $rev ) ) {
+                       if ( $wgFeedDiffCutoff <= 0 || is_null( $rev ) ) {
                                $newContent = ContentHandler::getForTitle( $title )->makeEmptyContent();
                        } else {
                                $newContent = $rev->getContent();
@@ -220,9 +220,10 @@ class FeedUtils {
         * @return string
         */
        protected static function getDiffLink( Title $title, $newid, $oldid = null ) {
-               $queryParameters = ($oldid == null)
-                       ? "diff={$newid}"
-                       : "diff={$newid}&oldid={$oldid}";
+               $queryParameters = array( 'diff' => $newid );
+               if ( $oldid != null ) {
+                       $queryParameters['oldid'] = $oldid;
+               }
                $diffUrl = $title->getFullURL( $queryParameters );
 
                $diffLink = Html::element( 'a', array( 'href' => $diffUrl ),
@@ -250,7 +251,7 @@ class FeedUtils {
                        'diffchange'       => 'font-weight: bold; text-decoration: none;',
                );
 
-               foreach( $styles as $class => $style ) {
+               foreach ( $styles as $class => $style ) {
                        $text = preg_replace( "/(<[^>]+)class=(['\"])$class\\2([^>]*>)/",
                                "\\1style=\"$style\"\\3", $text );
                }