Index: trunk/extensions/FindSpam/FindSpam_body.php |
— | — | @@ -5,17 +5,25 @@ |
6 | 6 | exit( 1 ); |
7 | 7 | } |
8 | 8 | |
9 | | -wfLoadExtensionMessages( 'FindSpam' ); |
10 | | - |
11 | 9 | class FindSpamPage extends SpecialPage { |
12 | 10 | |
13 | | - function FindSpamPage() { |
14 | | - SpecialPage::SpecialPage( 'FindSpam', 'findspam' ); |
| 11 | + /** |
| 12 | + * Constructor |
| 13 | + */ |
| 14 | + public function __construct() { |
| 15 | + parent::__construct( 'FindSpam'/*class*/, 'findspam'/*restriction*/ ); |
15 | 16 | } |
16 | 17 | |
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; |
19 | 25 | global $wgConf, $wgCanonicalNamespaceNames, $wgLang; |
| 26 | + |
| 27 | + wfLoadExtensionMessages( 'FindSpam' ); |
20 | 28 | $this->setHeaders(); |
21 | 29 | |
22 | 30 | # Check permissions |
— | — | @@ -35,13 +43,13 @@ |
36 | 44 | $wgOut->addHTML( $form ); |
37 | 45 | |
38 | 46 | if ( $ip ) { |
39 | | - $dbr =& wfGetDB( DB_READ ); |
40 | | - $s = ''; |
| 47 | + $dbr = wfGetDB( DB_SLAVE ); |
| 48 | + $s = ''; |
41 | 49 | |
42 | 50 | foreach ( $wgLocalDatabases as $db ) { |
43 | 51 | $sql = "SELECT rc_namespace,rc_title,rc_timestamp,rc_user_text,rc_last_oldid FROM $db.recentchanges WHERE rc_ip='" . $dbr->strencode( $ip ) . |
44 | 52 | "' AND rc_this_oldid=0"; |
45 | | - $res = $dbr->query( $sql, "findspam.php" ); |
| 53 | + $res = $dbr->query( $sql, __METHOD__ ); |
46 | 54 | list( $site, $lang ) = $wgConf->siteFromDB( $db ); |
47 | 55 | if ( $lang == 'meta' ) { |
48 | 56 | $baseUrl = "http://meta.wikimedia.org"; |
— | — | @@ -63,10 +71,10 @@ |
64 | 72 | $user = urlencode( $row->rc_user_text ); |
65 | 73 | #$rollbackText = wfMsg( 'rollback' ); |
66 | 74 | $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"; |
69 | 77 | 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]"; |
71 | 79 | } |
72 | 80 | |
73 | 81 | $date = $wgLang->timeanddate( $row->rc_timestamp ); |
— | — | @@ -76,9 +84,9 @@ |
77 | 85 | } |
78 | 86 | } |
79 | 87 | if ( $s == '' ) { |
80 | | - $s = wfMsg('findspam-notextfound'); |
| 88 | + $s = wfMsg( 'findspam-notextfound' ); |
81 | 89 | } |
82 | | - $wgOut->addWikiText( $s."<br />" ); |
| 90 | + $wgOut->addWikiText( $s.'<br />' ); |
83 | 91 | } |
84 | 92 | } |
85 | | -} |
| 93 | +} |
\ No newline at end of file |
Index: trunk/extensions/FindSpam/FindSpam.i18n.php |
— | — | @@ -1,18 +1,24 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | | - * Internationalisation file for extension FindSpam. |
| 4 | + * Internationalisation file for FindSpam extension. |
5 | 5 | * |
6 | | - * @addtogroup Extensions |
7 | | -*/ |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + */ |
8 | 9 | |
9 | 10 | $messages = array(); |
10 | 11 | |
| 12 | +/** English |
| 13 | + * @author Tim Starling |
| 14 | + */ |
11 | 15 | $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', |
16 | 20 | 'findspam-notextfound' => 'No contributions found', |
| 21 | + // For Special:ListGroupRights |
| 22 | + 'right-findspam' => 'Search for recently added spam', |
17 | 23 | ); |
18 | 24 | |
19 | 25 | /** Message documentation (Message documentation) |
— | — | @@ -228,7 +234,7 @@ |
229 | 235 | ); |
230 | 236 | |
231 | 237 | /** Finnish (Suomi) |
232 | | - * @author Jack Phoenix |
| 238 | + * @author Jack Phoenix <jack@countervandalism.net> |
233 | 239 | * @author Nike |
234 | 240 | * @author Tarmo |
235 | 241 | */ |
— | — | @@ -238,6 +244,7 @@ |
239 | 245 | 'findspam-ip' => 'IP-osoite', |
240 | 246 | 'findspam-ok' => 'OK', |
241 | 247 | 'findspam-notextfound' => 'Muokkauksia ei löytynyt', |
| 248 | + 'right-findspam' => 'Etsiä äskettäin lisättyä spämmiä', |
242 | 249 | ); |
243 | 250 | |
244 | 251 | /** French (Français) |
Index: trunk/extensions/FindSpam/FindSpam.php |
— | — | @@ -1,30 +1,36 @@ |
2 | 2 | <?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 | + */ |
4 | 12 | if ( !defined( 'MEDIAWIKI' ) ) { |
5 | 13 | die( "Not a valid entry point\n" ); |
6 | 14 | } |
7 | 15 | |
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 | +); |
11 | 25 | |
12 | | -global $wgAvailableRights, $wgGroupPermissions; |
| 26 | +// New user right |
13 | 27 | $wgAvailableRights[] = 'findspam'; |
14 | 28 | $wgGroupPermissions['sysop']['findspam'] = true; |
15 | 29 | |
16 | | -$wgSpecialPages['FindSpam'] = 'FindSpamPage'; |
17 | | -$wgSpecialPageGroups['FindSpam'] = 'spam'; |
18 | | - |
| 30 | +// Set up the new special page |
19 | 31 | $dir = dirname(__FILE__) . '/'; |
20 | 32 | $wgAutoloadClasses['FindSpamPage'] = $dir . 'FindSpam_body.php'; |
21 | 33 | $wgExtensionMessagesFiles['FindSpam'] = $dir . 'FindSpam.i18n.php'; |
22 | 34 | $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 |