Split enhanced and old changelist in two classes that inherit from the main
authorAntoine Musso <hashar@users.mediawiki.org>
Tue, 6 Sep 2005 18:43:45 +0000 (18:43 +0000)
committerAntoine Musso <hashar@users.mediawiki.org>
Tue, 6 Sep 2005 18:43:45 +0000 (18:43 +0000)
class. Need to setup more methods :)

includes/ChangesList.php
includes/SpecialRecentchanges.php
includes/SpecialRecentchangeslinked.php
includes/SpecialWatchlist.php

index 89a6ec1..41f972d 100644 (file)
@@ -25,7 +25,6 @@ class ChangesList {
                                : $nothing;
                $f .= $patrolled ? '<span class="unpatrolled">!</span>' : $nothing;
                return $f;
-
        }
 
        /**
@@ -247,24 +246,17 @@ class ChangesList {
 
                return '<div>'.$blockOut.'</div>' ;
        }
+}
 
-       /**
-        * Called in a loop over all displayed RC entries
-        * Either returns the line, or caches it for later use
-        */
-       function recentChangesLine( &$rc, $watched = false ) {
-               global $wgUser;
-               if ( $wgUser->getOption( 'usenewrc' ) )
-                       $line = $this->recentChangesLineNew ( $rc, $watched ) ;
-               else
-                       $line = $this->recentChangesLineOld ( $rc, $watched ) ;
-               return $line ;
-       }
 
+/**
+ * Generate a list of changes using the good old system (no javascript)
+ */
+class OldChangesList extends ChangesList {
        /**
         * Format a line using the old system (aka without any javascript).
         */
-       function recentChangesLineOld( &$rc, $watched = false ) {
+       function recentChangesLine( &$rc, $watched = false ) {
                global $wgTitle, $wgLang, $wgContLang, $wgUser, $wgUseRCPatrol,
                        $wgOnlySysopsCanPatrol, $wgSysopUserBans;
 
@@ -407,10 +399,17 @@ class ChangesList {
                return $s;
        }
 
+
+}
+
+/**
+ * Generate a list of changes using an Enhanced system (use javascript).
+ */
+class EnhancedChangesList extends ChangesList {
        /**
         * Format a line for enhanced recentchange (aka with javascript and block of lines).
         */
-       function recentChangesLineNew( &$baseRC, $watched = false ) {
+       function recentChangesLine( &$baseRC, $watched = false ) {
                global $wgTitle, $wgLang, $wgContLang, $wgUser,
                        $wgUseRCPatrol, $wgOnlySysopsCanPatrol, $wgSysopUserBans;
 
@@ -548,4 +547,5 @@ class ChangesList {
        }
 
 }
+
 ?>
index 9074681..72d2a4b 100644 (file)
@@ -189,13 +189,19 @@ function wfSpecialRecentchanges( $par, $specialPage ) {
 
                        // Add end of the texts
                        $wgOut->addHTML( '<div class="rcoptions">' . rcOptionsPanel( $defaults, $nondefaults ) . "\n" );
-                       $wgOut->addHTML( rcNamespaceForm( $namespace, $invert, $nondefaults) . '</div>');
+                       $wgOut->addHTML( rcNamespaceForm( $namespace, $invert, $nondefaults) . '</div>'."\n");
                }
 
                // And now for the content
                $sk = $wgUser->getSkin();
                $wgOut->setSyndicated( true );
-               $list =& new ChangesList( $sk );
+
+               if ( $wgUser->getOption('usenewrc') ) {
+                       $list =& new EnhancedChangesList( $sk );
+               } else {
+                       $list =& new OldChangesList( $sk );
+               }
+
                $s = $list->beginRecentChangesList();
                $counter = 1;
                foreach( $rows as $obj ){
@@ -460,7 +466,7 @@ function rcNamespaceForm ( $namespace, $invert, $nondefaults ) {
        $t = Title::makeTitle( NS_SPECIAL, 'Recentchanges' );
 
        $namespaceselect = HTMLnamespaceselector($namespace, '');
-       $submitbutton = '<input type="submit" value="' . wfMsgHtml( 'allpagessubmit' ) . '" />';
+       $submitbutton = '<input type="submit" value="' . wfMsgHtml( 'allpagessubmit' ) . "\" />\n";
        $invertbox = "<input type='checkbox' name='invert' value='1' id='nsinvert'" . ( $invert ? ' checked="checked"' : '' ) . ' />';
 
        $out = "<div class='namespacesettings'><form method='get' action='{$wgScript}'>\n";
@@ -474,8 +480,7 @@ function rcNamespaceForm ( $namespace, $invert, $nondefaults ) {
        $out .= "
 <div id='nsselect' class='recentchanges'>
        <label for='namespace'>" . wfMsgHtml('namespace') . "</label>
-       $namespaceselect $submitbutton $invertbox <label for='nsinvert'>" . wfMsgHtml('invert') . "</label>
-</div>";
+       {$namespaceselect}{$submitbutton}{$invertbox} <label for='nsinvert'>" . wfMsgHtml('invert') . "</label>\n</div>";
        $out .= '</form></div>';
        return $out;
 }
@@ -489,7 +494,7 @@ function rcFormatDiff( $row ) {
        wfProfileIn( $fname );
 
        require_once( 'DifferenceEngine.php' );
-       $comment = "<p>" . htmlspecialchars( $row->rc_comment ) . "</p>\n";
+       $comment = '<p>' . htmlspecialchars( $row->rc_comment ) . "</p>\n";
 
        if( $row->rc_namespace >= 0 ) {
                global $wgContLang;
index 08ca2dc..e35c5a4 100644 (file)
@@ -112,7 +112,11 @@ ORDER BY rev_timestamp DESC
 
        $wgOut->addHTML( $note."\n" );
 
-       $list =& new ChangesList( $sk );
+       if ( $wgUser->getOption('usenewrc') ) {
+               $list =& new EnhancedChangesList( $sk );
+       } else {
+               $list =& new OldChangesList( $sk );
+       }
        $s = $list->beginRecentChangesList();
        $count = $dbr->numRows( $res );
        
index f534905..7702727 100644 (file)
@@ -294,7 +294,13 @@ function wfSpecialWatchlist( $par ) {
        /* End bottom header */
 
        $sk = $wgUser->getSkin();
-       $list =& new ChangesList( $sk );
+
+       if ( $wgUser->getOption('usenewrc') ) {
+               $list =& new EnhancedChangesList( $sk );
+       } else {
+               $list =& new OldChangesList( $sk );
+       }
+
        $s = $list->beginRecentChangesList();
        $counter = 1;
        while ( $obj = $dbr->fetchObject( $res ) ) {