fix code style violations in RecentChange.php
[lhc/web/wiklou.git] / includes / FeedUtils.php
index 242f65c..82c6e4a 100644 (file)
@@ -87,7 +87,7 @@ class FeedUtils {
                        ($row->rc_deleted & Revision::DELETED_COMMENT)
                                ? wfMessage('rev-deleted-comment')->escaped()
                                : $row->rc_comment,
-                       $actiontext 
+                       $actiontext
                );
        }
 
@@ -172,16 +172,36 @@ class FeedUtils {
                } else {
                        $rev = Revision::newFromId( $newid );
                        if( $wgFeedDiffCutoff <= 0 || is_null( $rev ) ) {
-                               $newtext = '';
+                               $newContent = ContentHandler::getForTitle( $title )->makeEmptyContent();
                        } else {
-                               $newtext = $rev->getText();
+                               $newContent = $rev->getContent();
                        }
-                       if ( $wgFeedDiffCutoff <= 0 || strlen( $newtext ) > $wgFeedDiffCutoff ) {
+
+                       if ( $newContent instanceof TextContent ) {
+                               // only textual content has a "source view".
+                               $text = $newContent->getNativeData();
+
+                               if ( $wgFeedDiffCutoff <= 0 || strlen( $text ) > $wgFeedDiffCutoff ) {
+                                       $html = null;
+                               } else {
+                                       $html = nl2br( htmlspecialchars( $text ) );
+                               }
+                       } else {
+                               //XXX: we could get an HTML representation of the content via getParserOutput, but that may
+                               //     contain JS magic and generally may not be suitable for inclusion in a feed.
+                               //     Perhaps Content should have a getDescriptiveHtml method and/or a getSourceText method.
+                               //Compare also ApiFeedContributions::feedItemDesc
+                               $html = null;
+                       }
+
+                       if ( $html === null ) {
+
                                // Omit large new page diffs, bug 29110
+                               // Also use diff link for non-textual content
                                $diffText = self::getDiffLink( $title, $newid );
                        } else {
                                $diffText = '<p><b>' . wfMessage( 'newpage' )->text() . '</b></p>' .
-                                       '<div>' . nl2br( htmlspecialchars( $newtext ) ) . '</div>';
+                                       '<div>' . $html . '</div>';
                        }
                }
                $completeText .= $diffText;