From e00b2f8d2ed1e609067d8affa43f1bdffa6034da Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Tue, 6 Sep 2005 18:43:45 +0000 Subject: [PATCH] Split enhanced and old changelist in two classes that inherit from the main class. Need to setup more methods :) --- includes/ChangesList.php | 30 ++++++++++++------------- includes/SpecialRecentchanges.php | 17 +++++++++----- includes/SpecialRecentchangeslinked.php | 6 ++++- includes/SpecialWatchlist.php | 8 ++++++- 4 files changed, 38 insertions(+), 23 deletions(-) diff --git a/includes/ChangesList.php b/includes/ChangesList.php index 89a6ec128a..41f972dfe5 100644 --- a/includes/ChangesList.php +++ b/includes/ChangesList.php @@ -25,7 +25,6 @@ class ChangesList { : $nothing; $f .= $patrolled ? '!' : $nothing; return $f; - } /** @@ -247,24 +246,17 @@ class ChangesList { return '
'.$blockOut.'
' ; } +} - /** - * 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 { } } + ?> diff --git a/includes/SpecialRecentchanges.php b/includes/SpecialRecentchanges.php index 90746810bc..72d2a4b53a 100644 --- a/includes/SpecialRecentchanges.php +++ b/includes/SpecialRecentchanges.php @@ -189,13 +189,19 @@ function wfSpecialRecentchanges( $par, $specialPage ) { // Add end of the texts $wgOut->addHTML( '
' . rcOptionsPanel( $defaults, $nondefaults ) . "\n" ); - $wgOut->addHTML( rcNamespaceForm( $namespace, $invert, $nondefaults) . '
'); + $wgOut->addHTML( rcNamespaceForm( $namespace, $invert, $nondefaults) . ''."\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 = ''; + $submitbutton = '\n"; $invertbox = "'; $out = "
\n"; @@ -474,8 +480,7 @@ function rcNamespaceForm ( $namespace, $invert, $nondefaults ) { $out .= "
- $namespaceselect $submitbutton $invertbox -
"; + {$namespaceselect}{$submitbutton}{$invertbox} \n
"; $out .= ''; return $out; } @@ -489,7 +494,7 @@ function rcFormatDiff( $row ) { wfProfileIn( $fname ); require_once( 'DifferenceEngine.php' ); - $comment = "

" . htmlspecialchars( $row->rc_comment ) . "

\n"; + $comment = '

' . htmlspecialchars( $row->rc_comment ) . "

\n"; if( $row->rc_namespace >= 0 ) { global $wgContLang; diff --git a/includes/SpecialRecentchangeslinked.php b/includes/SpecialRecentchangeslinked.php index 08ca2dc383..e35c5a4616 100644 --- a/includes/SpecialRecentchangeslinked.php +++ b/includes/SpecialRecentchangeslinked.php @@ -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 ); diff --git a/includes/SpecialWatchlist.php b/includes/SpecialWatchlist.php index f534905e56..770272752b 100644 --- a/includes/SpecialWatchlist.php +++ b/includes/SpecialWatchlist.php @@ -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 ) ) { -- 2.20.1