MediaWiki r10812 - Code Review

Jump to: navigation, search
Repository:MediaWiki
Revision:r10811‎ | r10812 (on ViewVC)‎ | r10813 >
Date:23:43, 27 August 2005
Author:wegge
Status:old
Tags:
Comment:
Add filter for robot edits to Special:Watchlist
Modified paths:

Diff [purge]

Index: trunk/phase3/includes/SpecialWatchlist.php
===================================================================
--- trunk/phase3/includes/SpecialWatchlist.php	(revision 10811)
+++ trunk/phase3/includes/SpecialWatchlist.php	(revision 10812)
@@ -18,7 +18,7 @@
 	global $wgUser, $wgOut, $wgLang, $wgTitle, $wgMemc, $wgRequest, $wgContLang;
 	global $wgUseWatchlistCache, $wgWLCacheTimeout, $wgDBname;
 	global $wgRCShowWatchingUsers, $wgEnotifWatchlist, $wgShowUpdatedMarker;
-	global $wgEnotifWatchlist;
+	global $wgEnotifWatchlist, $wgFilterRobotsWL;
 	$fname = 'wfSpecialWatchlist';
 
 	$wgOut->setPagetitle( wfMsg( 'watchlist' ) );
@@ -36,6 +36,7 @@
 	$defaults = array(
 	/* float */ 'days' => 3.0, /* or 0.5, watch further below */
 	/* bool  */ 'hideOwn' => false,
+	/* bool  */ 'hideBots' => false,
 	);
 
 	extract($defaults);
@@ -43,6 +44,7 @@
 	# Get query variables
 	$days = $wgRequest->getVal( 'days' );
 	$hideOwn = $wgRequest->getBool( 'hideOwn' );
+	$hideBots = $wgRequest->getBool( 'hideBots' );
 
 	# Watchlist editing
 	$action = $wgRequest->getVal( 'action' );
@@ -118,6 +120,7 @@
 
 	wfAppendToArrayIfNotDefault( 'days', $days, $defaults, $nondefaults);
 	wfAppendToArrayIfNotDefault( 'hideOwn', $hideOwn, $defaults, $nondefaults);
+	wfAppendToArrayIfNotDefault( 'hideBots', $hideBots, $defaults, $nondefaults);
 
 	if ( $days <= 0 ) {
 		$docutoff = '';
@@ -202,7 +205,13 @@
 	# Up estimate of watched items by 15% to compensate for talk pages...
 
 	$andHideOwn = $hideOwn ? "AND (rc_user <> $uid)" : '';
-
+	if( $wgFilterRobotsWL ) {
+		$andHideBotsOptional = $hideBots ? "AND (rc_bot = 0)" : '';
+	} else {
+		$andHideBotsOptional = "AND AND  rc_this_oldid=page_latest";
+	}
+		
+	
 	# Show watchlist header
 	$header = '';
 	if( $wgUser->getOption( 'enotifwatchlistpages' ) && $wgEnotifWatchlist) {
@@ -243,6 +252,7 @@
           AND rc_cur_id=page_id
           AND rc_this_oldid=page_latest
           $andHideOwn
+          $andHideBotsOptional
           ORDER BY rc_timestamp DESC";
 
 	$res = $dbr->query( $sql, $fname );
@@ -265,8 +275,15 @@
 		$wgContLang->specialPage( 'Watchlist' ),
 		(0 == $hideOwn) ? wfMsgHtml( 'wlhide' ) : wfMsgHtml( 'wlshow' ),
 		wfArrayToCGI( array('hideOwn' => 1-$hideOwn ), $nondefaults ) );
+	$wgOut->addHTML( wfMsgHtml( "wlhideshowown", $s ) );
 
-	$wgOut->addHTML( wfMsgHtml( "wlhideshowown", $s ) );
+	if( $wgFilterRobotsWL ) {
+		$s = $sk->makeKnownLink(
+      $wgContLang->specialPage( 'Watchlist' ),
+		  (0 == $hideBots) ? wfMsgHtml( 'wlhide' ) : wfMsgHtml( 'wlshow' ),
+		  wfArrayToCGI( array('hideBots' => 1-$hideBots ), $nondefaults ) );
+	  $wgOut->addHTML( wfMsgHtml( "wlhideshowbots", "  $s" ) );
+	}
 	
 	if ( $numRows == 0 ) {
 		$wgOut->addWikitext( "<br />" . wfMsg( 'watchnochange' ), false );
Index: trunk/phase3/includes/DefaultSettings.php
===================================================================
--- trunk/phase3/includes/DefaultSettings.php	(revision 10811)
+++ trunk/phase3/includes/DefaultSettings.php	(revision 10812)
@@ -1616,4 +1616,10 @@
  */
 $wgUseTrackbacks = false;
 
+/**
+ * Enable filtering of robots in Special:Watchlist
+ */
+
+$wgFilterRobotsWL = false;
+
 ?>
Index: trunk/phase3/languages/Language.php
===================================================================
--- trunk/phase3/languages/Language.php	(revision 10811)
+++ trunk/phase3/languages/Language.php	(revision 10812)
@@ -1238,6 +1238,7 @@
 'wlshowlast' 		=> 'Show last $1 hours $2 days $3',
 'wlsaved'		=> 'This is a saved version of your watchlist.',
 'wlhideshowown'   	=> '$1 my edits.',
+'wlhideshowown'   	=> '$1 robot edits.',
 'wlshow'		=> 'Show',
 'wlhide'		=> 'Hide',
 
Index: trunk/phase3/languages/LanguageDa.php
===================================================================
--- trunk/phase3/languages/LanguageDa.php	(revision 10811)
+++ trunk/phase3/languages/LanguageDa.php	(revision 10812)
@@ -1035,6 +1035,7 @@
 'wlshow'		=> 'Vis',
 'wlhide'		=> 'Skjul',
 'wlhideshowown'		=> '$1 mine redigeringer.',
+'wlhideshowown'		=> '$1 robotredigeringer.',
 'enotif_mailer' 		=> '{{SITENAME}} informationsmail',
 'enotif_reset'			=> 'Marker alle sider som besøgt',
 'enotif_newpagetext'=> 'Dette er en ny side.',
Index: trunk/extensions/Footnote.php
===================================================================
--- trunk/extensions/Footnote.php	(revision 10811)
+++ trunk/extensions/Footnote.php	(revision 10812)
@@ -1,94 +0,0 @@
-<?php
-# Copyright (C) 2005 Anders Wegge Jakobsen <awegge@gmail.com>
-# http://www.mediawiki.org/
-# 
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or 
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-# http://www.gnu.org/copyleft/gpl.html
-
-/**
- 
-* Extension to add footnotes to the wiki pages. 
-*
-* Use with:
-*
-* <footnote>This text is placed at the end of the page.</footnote>
-*
-* @author Anders Wegge Jakobsen <awegge@gmail.com>
-* @package MediaWiki
-* @subpackage Extensions
- */
-
-if( !defined( 'MEDIAWIKI' ) ) {
-	die();
-}
-
-
-$wgExtensionFunctions[] = "wfFootnote";
-
-function wfFootnote() {
-	global $wgParser ;
-	$wgParser->setHook( "footnote" , 'parse_footnote' ) ;
-}
-
-$footnotes = array() ;
-$footnotecount = 1 ;
-$recursion_guard = 0;
-
-function footnote_hooker( $parser , $text ) {
-	global $footnotes , $footnotecount, $recursion_guard ;
-	
-	if( $recursion_guard != 0 ) return;
-	if( count( $footnotes ) == 0 ) return ;
-
-	$ret = "" ;
-	foreach( $footnotes AS $num => $entry ) {
-		$x = " <a name='footnote{$num}'></a>\n";
-		$x = $x . "<li>$entry <a href='#footnoteback{$num}'>&uarr;</a></li>\n" ;
-		$ret .= $x ;
-	}
-	$ret = "<hr/><ol>" . $ret . "</ol>" ;
-	
-	$text .= $ret ;
-}
-
-function parse_footnote( $text ) {
-	$ret = "" ;
-
-	global $footnotes , $footnotecount, $recursion_guard ;
-
-	global $wgTitle , $wgOut, $p;
-
-	if( !isset( $p )) {
-		$p = new Parser ;
-	}
-
-	$recursion_guard = 1;
-	$ret = $p->parse( $text , $wgTitle , $wgOut->mParserOptions, false ) ;
-	$ret = $ret->getText();
-	$recursion_guard = 0;
-
-	$footnotes[$footnotecount] = $ret;
-
-	$ret = "<a href='#footnote{$footnotecount}' name='footnoteback{$footnotecount}'><sup>$footnotecount</sup></a>" ;
-	
-	$footnotecount++ ;
-	if( $footnotecount == 2 ) {
-		global $wgHooks;
-		$wgHooks['ParserBeforeTidy'][] = 'footnote_hooker' ;
-	}
-
-	return $ret ;
-}
-?>
Index: trunk/extensions/FootNote/Footnote.php
===================================================================
--- trunk/extensions/FootNote/Footnote.php	(revision 0)
+++ trunk/extensions/FootNote/Footnote.php	(revision 10812)
@@ -0,0 +1,101 @@
+<?php
+# Copyright (C) 2005 Anders Wegge Jakobsen <awegge@gmail.com>
+# http://www.mediawiki.org/
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or 
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# http://www.gnu.org/copyleft/gpl.html
+
+/**
+ 
+* Extension to add footnotes to the wiki pages. 
+*
+* Use with:
+*
+* <footnote>This text is placed at the end of the page.</footnote>
+*
+* @author Anders Wegge Jakobsen <awegge@gmail.com>
+* @package MediaWiki
+* @subpackage Extensions
+ */
+
+if( !defined( 'MEDIAWIKI' ) ) {
+	die();
+}
+
+
+$wgExtensionFunctions[] = "wfFootnote";
+
+function wfFootnote() {
+  global $wgParser, $wgHooks ;
+	$wgParser->setHook( "footnote" , 'parse_footnote' ) ;
+	$wgHooks['ParserBeforeTidy'][] = 'insert_endnotes' ;
+}
+
+$footnoteNotes = array() ;
+$footnoteCount = 1 ;
+$footnoteRecursionGuard = false;
+
+function insert_endnotes( $parser , $text ) {
+	global $footnoteNotes , $footnoteCount, $footnoteRecursionGuard ;
+	
+	wfDebug("insert_endnotes:\n<<<$text>>>\n");
+
+	if( $footnoteRecursionGuard ) return;
+	if( count( $footnoteNotes ) == 0 ) return ;
+	
+	$ret = "" ;
+	foreach( $footnoteNotes AS $num => $entry ) {
+		$x = " <a name='footnote{$num}'></a>\n";
+		$x = $x . "<li>$entry <a href='#footnoteback{$num}'>&uarr;</a></li>\n" ;
+		$ret .= $x ;
+	}
+	$ret = "<hr /><ol>" . $ret . "</ol>" ;
+	
+	$text .= $ret ;
+
+	/* Clear global array after rendering */
+	$footnoteNotes = array();
+	$footnoteCount = 1 ;
+}
+
+function parse_footnote( $text ) {
+	$ret = "" ;
+
+	global $footnoteNotes , $footnoteCount, $footnoteRecursionGuard ;
+
+	global $wgTitle , $wgOut, $footnoteParserObj;
+
+	if( !isset( $footnoteParserObj )) {
+		$footnoteParserObj = new Parser ;
+	}
+
+	$footnoteRecursionGuard = true;
+	$ret = $footnoteParserObj->parse( $text , $wgTitle , $wgOut->mParserOptions, false ) ;
+	$ret = $ret->getText();
+	$footnoteRecursionGuard = false;
+
+	$footnoteNotes[$footnoteCount] = $ret;
+
+	$ret = "<a href='#footnote{$footnoteCount}' name='footnoteback{$footnoteCount}'><sup>$footnoteCount</sup></a>" ;
+	
+	$footnoteCount++ ;
+	if( $footnoteCount == 2 ) {
+		global $wgHooks;
+		$wgHooks['ParserBeforeTidy'][] = 'insert_endnotes' ;
+	}
+
+	return $ret ;
+}
+?>

Property changes on: trunk/extensions/FootNote/Footnote.php
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Index: trunk/extensions/FootNote/README
===================================================================
--- trunk/extensions/FootNote/README	(revision 0)
+++ trunk/extensions/FootNote/README	(revision 10812)
@@ -0,0 +1,6 @@
+== Known problems ==
+
+* Footnotes inside galleries does not get parsed
+* A footnote in a template does not expand the template parameters
+* The numbering of footnotes when doing page inclusions is wrong.
+

Property changes on: trunk/extensions/FootNote/README
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Status & tagging log

  • 01:58, 13 October 2010 ^demon (Talk | contribs) changed the status of r10812 [removed: new added: old]
Personal tools
Namespaces
Variants
Views
Actions
Site
Support
Download
Development
Communication
Toolbox