r47802 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r47801‎ | r47802 | r47803 >
Date:15:52, 25 February 2009
Author:ashley
Status:deferred
Tags:
Comment:
FindSpam:
*doxygen comments
*add version number into extension credits
*delay message loading in body file
*mark function visibility
*remove unused $wgTitle global
*remove php4-ism
*DB_READ => DB_SLAVE
*change wiki.phtml links to index.php ones
*add 'right-findspam' message for Special:ListGroupRights
Modified paths:
  • /trunk/extensions/FindSpam/FindSpam.i18n.php (modified) (history)
  • /trunk/extensions/FindSpam/FindSpam.php (modified) (history)
  • /trunk/extensions/FindSpam/FindSpam_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FindSpam/FindSpam_body.php
@@ -5,17 +5,25 @@
66 exit( 1 );
77 }
88
9 -wfLoadExtensionMessages( 'FindSpam' );
10 -
119 class FindSpamPage extends SpecialPage {
1210
13 - function FindSpamPage() {
14 - SpecialPage::SpecialPage( 'FindSpam', 'findspam' );
 11+ /**
 12+ * Constructor
 13+ */
 14+ public function __construct() {
 15+ parent::__construct( 'FindSpam'/*class*/, 'findspam'/*restriction*/ );
1516 }
1617
17 - function execute( $par ) {
18 - global $wgRequest, $wgOut, $wgTitle, $wgLocalDatabases, $wgUser;
 18+ /**
 19+ * Show the special page
 20+ *
 21+ * @param $par Mixed: parameter passed to the page
 22+ */
 23+ public function execute( $par ) {
 24+ global $wgRequest, $wgOut, $wgLocalDatabases, $wgUser;
1925 global $wgConf, $wgCanonicalNamespaceNames, $wgLang;
 26+
 27+ wfLoadExtensionMessages( 'FindSpam' );
2028 $this->setHeaders();
2129
2230 # Check permissions
@@ -35,13 +43,13 @@
3644 $wgOut->addHTML( $form );
3745
3846 if ( $ip ) {
39 - $dbr =& wfGetDB( DB_READ );
40 - $s = '';
 47+ $dbr = wfGetDB( DB_SLAVE );
 48+ $s = '';
4149
4250 foreach ( $wgLocalDatabases as $db ) {
4351 $sql = "SELECT rc_namespace,rc_title,rc_timestamp,rc_user_text,rc_last_oldid FROM $db.recentchanges WHERE rc_ip='" . $dbr->strencode( $ip ) .
4452 "' AND rc_this_oldid=0";
45 - $res = $dbr->query( $sql, "findspam.php" );
 53+ $res = $dbr->query( $sql, __METHOD__ );
4654 list( $site, $lang ) = $wgConf->siteFromDB( $db );
4755 if ( $lang == 'meta' ) {
4856 $baseUrl = "http://meta.wikimedia.org";
@@ -63,10 +71,10 @@
6472 $user = urlencode( $row->rc_user_text );
6573 #$rollbackText = wfMsg( 'rollback' );
6674 $diffText = wfMsg( 'diff' );
67 - #$rollbackUrl = "$baseUrl/w/wiki.phtml?title=$encTitle&action=rollback&from=$user";
68 - $diffUrl = "$baseUrl/w/wiki.phtml?title=$encTitle&diff=0&oldid=0";
 75+ #$rollbackUrl = "$baseUrl/w/index.php?title=$encTitle&action=rollback&from=$user";
 76+ $diffUrl = "$baseUrl/w/index.php?title=$encTitle&diff=0&oldid=0";
6977 if ( $row->rc_last_oldid ) {
70 - $lastLink = "[$baseUrl/w/wiki.phtml?title=$encTitle&oldid={$row->rc_last_oldid}&action=edit last]";
 78+ $lastLink = "[$baseUrl/w/index.php?title=$encTitle&oldid={$row->rc_last_oldid}&action=edit last]";
7179 }
7280
7381 $date = $wgLang->timeanddate( $row->rc_timestamp );
@@ -76,9 +84,9 @@
7785 }
7886 }
7987 if ( $s == '' ) {
80 - $s = wfMsg('findspam-notextfound');
 88+ $s = wfMsg( 'findspam-notextfound' );
8189 }
82 - $wgOut->addWikiText( $s."<br />" );
 90+ $wgOut->addWikiText( $s.'<br />' );
8391 }
8492 }
85 -}
 93+}
\ No newline at end of file
Index: trunk/extensions/FindSpam/FindSpam.i18n.php
@@ -1,18 +1,24 @@
22 <?php
33 /**
4 - * Internationalisation file for extension FindSpam.
 4+ * Internationalisation file for FindSpam extension.
55 *
6 - * @addtogroup Extensions
7 -*/
 6+ * @file
 7+ * @ingroup Extensions
 8+ */
89
910 $messages = array();
1011
 12+/** English
 13+ * @author Tim Starling
 14+ */
1115 $messages['en'] = array(
12 - 'findspam' => 'Find spam',
13 - 'findspam-desc' => 'Adds a [[Special:FindSpam|special page]] that allows to find recently added spam',
14 - 'findspam-ip' => 'IP address:',
15 - 'findspam-ok' => 'OK',
 16+ 'findspam' => 'Find spam',
 17+ 'findspam-desc' => 'Adds a [[Special:FindSpam|special page]] that allows to find recently added spam',
 18+ 'findspam-ip' => 'IP address:',
 19+ 'findspam-ok' => 'OK',
1620 'findspam-notextfound' => 'No contributions found',
 21+ // For Special:ListGroupRights
 22+ 'right-findspam' => 'Search for recently added spam',
1723 );
1824
1925 /** Message documentation (Message documentation)
@@ -228,7 +234,7 @@
229235 );
230236
231237 /** Finnish (Suomi)
232 - * @author Jack Phoenix
 238+ * @author Jack Phoenix <jack@countervandalism.net>
233239 * @author Nike
234240 * @author Tarmo
235241 */
@@ -238,6 +244,7 @@
239245 'findspam-ip' => 'IP-osoite',
240246 'findspam-ok' => 'OK',
241247 'findspam-notextfound' => 'Muokkauksia ei löytynyt',
 248+ 'right-findspam' => 'Etsiä äskettäin lisättyä spämmiä',
242249 );
243250
244251 /** French (Français)
Index: trunk/extensions/FindSpam/FindSpam.php
@@ -1,30 +1,36 @@
22 <?php
3 -
 3+/**
 4+ * FindSpam extension - a special page for finding recently added spam
 5+ *
 6+ * @file
 7+ * @ingroup Extensions
 8+ * @version 1.0
 9+ * @author Tim Starling
 10+ * @link http://www.mediawiki.org/wiki/Extension:Find_Spam Documentation
 11+ */
412 if ( !defined( 'MEDIAWIKI' ) ) {
513 die( "Not a valid entry point\n" );
614 }
715
8 -# This is a simple example of a special page module
9 -# Given a string in UTF-8, it converts it to HTML entities suitable for
10 -# an ISO 8859-1 web page.
 16+// Extension credits that will show up on Special:Version
 17+$wgExtensionCredits['specialpage'][] = array(
 18+ 'name' => 'FindSpam',
 19+ 'version' => '1.0',
 20+ 'author' => 'Tim Starling',
 21+ 'description' => 'Adds a special page that allows to find recently added spam.',
 22+ 'descriptionmsg' => 'findspam-desc',
 23+ 'url' => 'http://www.mediawiki.org/wiki/Extension:Find_Spam',
 24+);
1125
12 -global $wgAvailableRights, $wgGroupPermissions;
 26+// New user right
1327 $wgAvailableRights[] = 'findspam';
1428 $wgGroupPermissions['sysop']['findspam'] = true;
1529
16 -$wgSpecialPages['FindSpam'] = 'FindSpamPage';
17 -$wgSpecialPageGroups['FindSpam'] = 'spam';
18 -
 30+// Set up the new special page
1931 $dir = dirname(__FILE__) . '/';
2032 $wgAutoloadClasses['FindSpamPage'] = $dir . 'FindSpam_body.php';
2133 $wgExtensionMessagesFiles['FindSpam'] = $dir . 'FindSpam.i18n.php';
2234 $wgExtensionAliasesFiles['FindSpam'] = $dir . 'FindSpam.alias.php';
23 -
24 -$wgExtensionCredits['specialpage'][] = array(
25 - 'name' => 'FindSpam',
26 - 'url'=>'http://www.mediawiki.org/wiki/Extension:Find_Spam',
27 - 'author' => 'Tim Starling',
28 - 'description' => 'Adds a special page that allows to find recently added spam.',
29 - 'descriptionmsg' => 'findspam-desc',
30 -);
31 -
 35+$wgSpecialPages['FindSpam'] = 'FindSpamPage';
 36+// Special page group for MW 1.13+
 37+$wgSpecialPageGroups['FindSpam'] = 'spam';
\ No newline at end of file

Status & tagging log