r10812 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r10811‎ | r10812 | r10813 >
Date:23:43, 27 August 2005
Author:wegge
Status:old
Tags:
Comment:
Add filter for robot edits to Special:Watchlist
Modified paths:
  • /trunk/extensions/FootNote (added) (history)
  • /trunk/extensions/FootNote/Footnote.php (added) (history)
  • /trunk/extensions/FootNote/README (added) (history)
  • /trunk/extensions/Footnote.php (deleted) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/SpecialWatchlist.php (modified) (history)
  • /trunk/phase3/languages/Language.php (modified) (history)
  • /trunk/phase3/languages/LanguageDa.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SpecialWatchlist.php
@@ -18,7 +18,7 @@
1919 global $wgUser, $wgOut, $wgLang, $wgTitle, $wgMemc, $wgRequest, $wgContLang;
2020 global $wgUseWatchlistCache, $wgWLCacheTimeout, $wgDBname;
2121 global $wgRCShowWatchingUsers, $wgEnotifWatchlist, $wgShowUpdatedMarker;
22 - global $wgEnotifWatchlist;
 22+ global $wgEnotifWatchlist, $wgFilterRobotsWL;
2323 $fname = 'wfSpecialWatchlist';
2424
2525 $wgOut->setPagetitle( wfMsg( 'watchlist' ) );
@@ -36,6 +36,7 @@
3737 $defaults = array(
3838 /* float */ 'days' => 3.0, /* or 0.5, watch further below */
3939 /* bool */ 'hideOwn' => false,
 40+ /* bool */ 'hideBots' => false,
4041 );
4142
4243 extract($defaults);
@@ -43,6 +44,7 @@
4445 # Get query variables
4546 $days = $wgRequest->getVal( 'days' );
4647 $hideOwn = $wgRequest->getBool( 'hideOwn' );
 48+ $hideBots = $wgRequest->getBool( 'hideBots' );
4749
4850 # Watchlist editing
4951 $action = $wgRequest->getVal( 'action' );
@@ -118,6 +120,7 @@
119121
120122 wfAppendToArrayIfNotDefault( 'days', $days, $defaults, $nondefaults);
121123 wfAppendToArrayIfNotDefault( 'hideOwn', $hideOwn, $defaults, $nondefaults);
 124+ wfAppendToArrayIfNotDefault( 'hideBots', $hideBots, $defaults, $nondefaults);
122125
123126 if ( $days <= 0 ) {
124127 $docutoff = '';
@@ -202,7 +205,13 @@
203206 # Up estimate of watched items by 15% to compensate for talk pages...
204207
205208 $andHideOwn = $hideOwn ? "AND (rc_user <> $uid)" : '';
206 -
 209+ if( $wgFilterRobotsWL ) {
 210+ $andHideBotsOptional = $hideBots ? "AND (rc_bot = 0)" : '';
 211+ } else {
 212+ $andHideBotsOptional = "AND AND rc_this_oldid=page_latest";
 213+ }
 214+
 215+
207216 # Show watchlist header
208217 $header = '';
209218 if( $wgUser->getOption( 'enotifwatchlistpages' ) && $wgEnotifWatchlist) {
@@ -243,6 +252,7 @@
244253 AND rc_cur_id=page_id
245254 AND rc_this_oldid=page_latest
246255 $andHideOwn
 256+ $andHideBotsOptional
247257 ORDER BY rc_timestamp DESC";
248258
249259 $res = $dbr->query( $sql, $fname );
@@ -265,8 +275,15 @@
266276 $wgContLang->specialPage( 'Watchlist' ),
267277 (0 == $hideOwn) ? wfMsgHtml( 'wlhide' ) : wfMsgHtml( 'wlshow' ),
268278 wfArrayToCGI( array('hideOwn' => 1-$hideOwn ), $nondefaults ) );
 279+ $wgOut->addHTML( wfMsgHtml( "wlhideshowown", $s ) );
269280
270 - $wgOut->addHTML( wfMsgHtml( "wlhideshowown", $s ) );
 281+ if( $wgFilterRobotsWL ) {
 282+ $s = $sk->makeKnownLink(
 283+ $wgContLang->specialPage( 'Watchlist' ),
 284+ (0 == $hideBots) ? wfMsgHtml( 'wlhide' ) : wfMsgHtml( 'wlshow' ),
 285+ wfArrayToCGI( array('hideBots' => 1-$hideBots ), $nondefaults ) );
 286+ $wgOut->addHTML( wfMsgHtml( "wlhideshowbots", " $s" ) );
 287+ }
271288
272289 if ( $numRows == 0 ) {
273290 $wgOut->addWikitext( "<br />" . wfMsg( 'watchnochange' ), false );
Index: trunk/phase3/includes/DefaultSettings.php
@@ -1616,4 +1616,10 @@
16171617 */
16181618 $wgUseTrackbacks = false;
16191619
 1620+/**
 1621+ * Enable filtering of robots in Special:Watchlist
 1622+ */
 1623+
 1624+$wgFilterRobotsWL = false;
 1625+
16201626 ?>
Index: trunk/phase3/languages/Language.php
@@ -1238,6 +1238,7 @@
12391239 'wlshowlast' => 'Show last $1 hours $2 days $3',
12401240 'wlsaved' => 'This is a saved version of your watchlist.',
12411241 'wlhideshowown' => '$1 my edits.',
 1242+'wlhideshowown' => '$1 robot edits.',
12421243 'wlshow' => 'Show',
12431244 'wlhide' => 'Hide',
12441245
Index: trunk/phase3/languages/LanguageDa.php
@@ -1035,6 +1035,7 @@
10361036 'wlshow' => 'Vis',
10371037 'wlhide' => 'Skjul',
10381038 'wlhideshowown' => '$1 mine redigeringer.',
 1039+'wlhideshowown' => '$1 robotredigeringer.',
10391040 'enotif_mailer' => '{{SITENAME}} informationsmail',
10401041 'enotif_reset' => 'Marker alle sider som besøgt',
10411042 'enotif_newpagetext'=> 'Dette er en ny side.',
Index: trunk/extensions/Footnote.php
@@ -1,94 +0,0 @@
2 -<?php
3 -# Copyright (C) 2005 Anders Wegge Jakobsen <awegge@gmail.com>
4 -# http://www.mediawiki.org/
5 -#
6 -# This program is free software; you can redistribute it and/or modify
7 -# it under the terms of the GNU General Public License as published by
8 -# the Free Software Foundation; either version 2 of the License, or
9 -# (at your option) any later version.
10 -#
11 -# This program is distributed in the hope that it will be useful,
12 -# but WITHOUT ANY WARRANTY; without even the implied warranty of
13 -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 -# GNU General Public License for more details.
15 -#
16 -# You should have received a copy of the GNU General Public License along
17 -# with this program; if not, write to the Free Software Foundation, Inc.,
18 -# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 -# http://www.gnu.org/copyleft/gpl.html
20 -
21 -/**
22 -
23 -* Extension to add footnotes to the wiki pages.
24 -*
25 -* Use with:
26 -*
27 -* <footnote>This text is placed at the end of the page.</footnote>
28 -*
29 -* @author Anders Wegge Jakobsen <awegge@gmail.com>
30 -* @package MediaWiki
31 -* @subpackage Extensions
32 - */
33 -
34 -if( !defined( 'MEDIAWIKI' ) ) {
35 - die();
36 -}
37 -
38 -
39 -$wgExtensionFunctions[] = "wfFootnote";
40 -
41 -function wfFootnote() {
42 - global $wgParser ;
43 - $wgParser->setHook( "footnote" , 'parse_footnote' ) ;
44 -}
45 -
46 -$footnotes = array() ;
47 -$footnotecount = 1 ;
48 -$recursion_guard = 0;
49 -
50 -function footnote_hooker( $parser , $text ) {
51 - global $footnotes , $footnotecount, $recursion_guard ;
52 -
53 - if( $recursion_guard != 0 ) return;
54 - if( count( $footnotes ) == 0 ) return ;
55 -
56 - $ret = "" ;
57 - foreach( $footnotes AS $num => $entry ) {
58 - $x = " <a name='footnote{$num}'></a>\n";
59 - $x = $x . "<li>$entry <a href='#footnoteback{$num}'>&uarr;</a></li>\n" ;
60 - $ret .= $x ;
61 - }
62 - $ret = "<hr/><ol>" . $ret . "</ol>" ;
63 -
64 - $text .= $ret ;
65 -}
66 -
67 -function parse_footnote( $text ) {
68 - $ret = "" ;
69 -
70 - global $footnotes , $footnotecount, $recursion_guard ;
71 -
72 - global $wgTitle , $wgOut, $p;
73 -
74 - if( !isset( $p )) {
75 - $p = new Parser ;
76 - }
77 -
78 - $recursion_guard = 1;
79 - $ret = $p->parse( $text , $wgTitle , $wgOut->mParserOptions, false ) ;
80 - $ret = $ret->getText();
81 - $recursion_guard = 0;
82 -
83 - $footnotes[$footnotecount] = $ret;
84 -
85 - $ret = "<a href='#footnote{$footnotecount}' name='footnoteback{$footnotecount}'><sup>$footnotecount</sup></a>" ;
86 -
87 - $footnotecount++ ;
88 - if( $footnotecount == 2 ) {
89 - global $wgHooks;
90 - $wgHooks['ParserBeforeTidy'][] = 'footnote_hooker' ;
91 - }
92 -
93 - return $ret ;
94 -}
95 -?>
Index: trunk/extensions/FootNote/Footnote.php
@@ -0,0 +1,101 @@
 2+<?php
 3+# Copyright (C) 2005 Anders Wegge Jakobsen <awegge@gmail.com>
 4+# http://www.mediawiki.org/
 5+#
 6+# This program is free software; you can redistribute it and/or modify
 7+# it under the terms of the GNU General Public License as published by
 8+# the Free Software Foundation; either version 2 of the License, or
 9+# (at your option) any later version.
 10+#
 11+# This program is distributed in the hope that it will be useful,
 12+# but WITHOUT ANY WARRANTY; without even the implied warranty of
 13+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 14+# GNU General Public License for more details.
 15+#
 16+# You should have received a copy of the GNU General Public License along
 17+# with this program; if not, write to the Free Software Foundation, Inc.,
 18+# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 19+# http://www.gnu.org/copyleft/gpl.html
 20+
 21+/**
 22+
 23+* Extension to add footnotes to the wiki pages.
 24+*
 25+* Use with:
 26+*
 27+* <footnote>This text is placed at the end of the page.</footnote>
 28+*
 29+* @author Anders Wegge Jakobsen <awegge@gmail.com>
 30+* @package MediaWiki
 31+* @subpackage Extensions
 32+ */
 33+
 34+if( !defined( 'MEDIAWIKI' ) ) {
 35+ die();
 36+}
 37+
 38+
 39+$wgExtensionFunctions[] = "wfFootnote";
 40+
 41+function wfFootnote() {
 42+ global $wgParser, $wgHooks ;
 43+ $wgParser->setHook( "footnote" , 'parse_footnote' ) ;
 44+ $wgHooks['ParserBeforeTidy'][] = 'insert_endnotes' ;
 45+}
 46+
 47+$footnoteNotes = array() ;
 48+$footnoteCount = 1 ;
 49+$footnoteRecursionGuard = false;
 50+
 51+function insert_endnotes( $parser , $text ) {
 52+ global $footnoteNotes , $footnoteCount, $footnoteRecursionGuard ;
 53+
 54+ wfDebug("insert_endnotes:\n<<<$text>>>\n");
 55+
 56+ if( $footnoteRecursionGuard ) return;
 57+ if( count( $footnoteNotes ) == 0 ) return ;
 58+
 59+ $ret = "" ;
 60+ foreach( $footnoteNotes AS $num => $entry ) {
 61+ $x = " <a name='footnote{$num}'></a>\n";
 62+ $x = $x . "<li>$entry <a href='#footnoteback{$num}'>&uarr;</a></li>\n" ;
 63+ $ret .= $x ;
 64+ }
 65+ $ret = "<hr /><ol>" . $ret . "</ol>" ;
 66+
 67+ $text .= $ret ;
 68+
 69+ /* Clear global array after rendering */
 70+ $footnoteNotes = array();
 71+ $footnoteCount = 1 ;
 72+}
 73+
 74+function parse_footnote( $text ) {
 75+ $ret = "" ;
 76+
 77+ global $footnoteNotes , $footnoteCount, $footnoteRecursionGuard ;
 78+
 79+ global $wgTitle , $wgOut, $footnoteParserObj;
 80+
 81+ if( !isset( $footnoteParserObj )) {
 82+ $footnoteParserObj = new Parser ;
 83+ }
 84+
 85+ $footnoteRecursionGuard = true;
 86+ $ret = $footnoteParserObj->parse( $text , $wgTitle , $wgOut->mParserOptions, false ) ;
 87+ $ret = $ret->getText();
 88+ $footnoteRecursionGuard = false;
 89+
 90+ $footnoteNotes[$footnoteCount] = $ret;
 91+
 92+ $ret = "<a href='#footnote{$footnoteCount}' name='footnoteback{$footnoteCount}'><sup>$footnoteCount</sup></a>" ;
 93+
 94+ $footnoteCount++ ;
 95+ if( $footnoteCount == 2 ) {
 96+ global $wgHooks;
 97+ $wgHooks['ParserBeforeTidy'][] = 'insert_endnotes' ;
 98+ }
 99+
 100+ return $ret ;
 101+}
 102+?>
Property changes on: trunk/extensions/FootNote/Footnote.php
___________________________________________________________________
Added: svn:keywords
1103 + Author Date Id Revision
Added: svn:eol-style
2104 + native
Index: trunk/extensions/FootNote/README
@@ -0,0 +1,6 @@
 2+== Known problems ==
 3+
 4+* Footnotes inside galleries does not get parsed
 5+* A footnote in a template does not expand the template parameters
 6+* The numbering of footnotes when doing page inclusions is wrong.
 7+
Property changes on: trunk/extensions/FootNote/README
___________________________________________________________________
Added: svn:keywords
18 + Author Date Id Revision
Added: svn:eol-style
29 + native

Status & tagging log