r65228 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65227‎ | r65228 | r65229 >
Date:14:05, 18 April 2010
Author:siebrand
Status:deferred
Tags:
Comment:
* stylize RPED and small updates
* add RPED to Translate
Modified paths:
  • /trunk/extensions/RPED/RPED.alias.php (modified) (history)
  • /trunk/extensions/RPED/RPED.hooks.php (modified) (history)
  • /trunk/extensions/RPED/RPED.i18n.php (modified) (history)
  • /trunk/extensions/RPED/RPED.php (modified) (history)
  • /trunk/extensions/RPED/rpedtable.sql (modified) (history)
  • /trunk/extensions/Translate/groups/mediawiki-defines.txt (modified) (history)

Diff [purge]

Index: trunk/extensions/RPED/RPED.php
@@ -18,27 +18,26 @@
1919 /* Alert the user that this is not a valid entry point to MediaWiki if they try to access the
2020 special pages file directly.*/
2121
22 -if (!defined('MEDIAWIKI')) {
 22+if ( !defined( 'MEDIAWIKI' ) ) {
2323 echo <<<EOT
2424 To install the RPED extension, put the following line in LocalSettings.php:
2525 require( "extensions/RPED/RPED.php" );
2626 EOT;
27 - exit( 1 );
 27+ exit( 1 );
2828 }
2929
3030 $wgExtensionCredits['specialpage'][] = array(
3131 'name' => 'Remote Page Existence Detection',
3232 'author' => 'Tisane',
3333 'url' => 'http://www.mediawiki.org/wiki/Extension:RemotePageExistenceDetection',
34 - 'description' => 'Remote Page Existence Detection',
3534 'descriptionmsg' => 'rped-desc',
36 - 'version' => '1.0.0',
 35+ 'version' => '1.0.1',
3736 );
3837
39 -$dir = dirname(__FILE__) . '/';
40 -$wgAutoloadClasses['RPEDHooks'] = $dir.'RPED.hooks.php';
 38+$dir = dirname( __FILE__ ) . '/';
 39+$wgAutoloadClasses['RPEDHooks'] = $dir . 'RPED.hooks.php';
4140 $wgExtensionMessagesFiles['RPED'] = $dir . 'RPED.i18n.php';
4241 $wgExtensionAliasesFiles['RPED'] = $dir . 'RPED.alias.php';
4342
4443 $wgHooks['LoadExtensionSchemaUpdates'][] = 'RPEDHooks::RPEDCreateTable';
45 -$wgHooks['LinkBegin'][] = 'RPEDHooks::wikipediaLink';
\ No newline at end of file
 44+$wgHooks['LinkBegin'][] = 'RPEDHooks::wikipediaLink';
Index: trunk/extensions/RPED/rpedtable.sql
@@ -9,4 +9,4 @@
1010 CREATE INDEX rped_page_id ON rped_page (rped_page_id);
1111 CREATE INDEX rped_page_title ON rped_page (rped_page_title);
1212
13 -COMMIT;
\ No newline at end of file
 13+COMMIT;
Index: trunk/extensions/RPED/RPED.hooks.php
@@ -1,82 +1,102 @@
22 <?php
3 -if (!defined('MEDIAWIKI')) {
4 - echo <<<EOT
5 -To install the RPED extension, put the following line in LocalSettings.php:
6 -require_once( "\$IP/extensions/RPED/RPED.php" );
7 -EOT;
8 - exit( 1 );
 3+if ( !defined( 'MEDIAWIKI' ) ) {
 4+ echo <<<EOT
 5+ To install the RPED extension, put the following line in LocalSettings.php:
 6+ require_once( "\$IP/extensions/RPED/RPED.php" );
 7+ EOT;
 8+ exit( 1 );
99 }
1010
1111 class RPEDHooks {
12 -
13 - public static function RPEDCreateTable() {
14 - global $wgExtNewTables;
15 - $wgExtNewTables[] = array(
16 - 'blanked_pages',
17 - dirname( __FILE__ ) . '/rpedtable.sql' );
18 - return true;
19 - }
20 -
21 - public static function wikipediaLink( $skin, $target, &$text
22 - , &$customAttribs, &$query, &$options, &$ret ) {
23 - global $wgLocalStyle,$wgRemoteStyle,$wgPureWikiDeletionInEffect
24 - ,$wgTitle,$wgRequest;
25 - if ($wgTitle->getNamespace ()==-1){
26 - return true;
27 - }
28 - if (isset($query['action']) && $query['action']=='history'){
29 - return true;
30 - }
31 - if ($wgRequest->getText( 'action' )=='history'){
32 - return true;
33 - }
34 - $itIsBlank=false;
35 - // Return immediately if we know it's existent on the local wiki
36 - if ( in_array( 'known', $options ) ) {
37 - if (!isset($query['action']) && !isset($query['curid'])){
38 - $customAttribs['style']=$wgLocalStyle;
39 - }
40 - if (!isset($wgPureWikiDeletionInEffect) || $wgPureWikiDeletionInEffect!=true){
41 - return true;
42 - }
43 - $dbr = wfGetDB( DB_SLAVE );
44 - /*$myRevision=Revision::loadFromTitle($dbr,$target);
45 - if ($myRevision->getRawText()!=''){*/
46 - $id=$target->getArticleID();
47 - $result=$dbr->selectRow('blanked_page','blank_page_id'
48 - ,array("blank_page_id" => $id));
49 - if (!$result){
50 - return true;
51 - }
52 - $itIsBlank=true;
53 - }
54 -
55 - // If it doesn't exist on the local wiki, then see if it exists on the
56 - // remote wiki (Wikipedia)
57 - if ( in_array( 'broken', $options ) || $itIsBlank==true) {
58 - $title=$target->getPrefixedText ();
59 - for ($thiscount=0; $thiscount<strlen($title); $thiscount++){
60 - if (substr($title,$thiscount,1)==' '){
61 - $title=substr_replace($title,'_',$thiscount,1);
62 - }
63 - }
64 - $dbr = wfGetDB( DB_SLAVE );
65 - $result=$dbr->selectRow('rped_page','rped_page_id'
66 - ,array("rped_page_title" => $title));
67 -
68 - if (!$result){
69 - return true;
70 - } else {
71 - $title=htmlentities($title);
72 - $url='http://en.wikipedia.org/wiki/'.$title;
73 -
74 - // The page that we'll link to
75 - $text='<a href="'.$url.'">'.$text.'</a>';
76 - if ($wgRemoteStyle!=''){
77 - $customAttribs['style']=$wgRemoteStyle;
78 - }
79 - }
 12+ public static function RPEDCreateTable() {
 13+ global $wgExtNewTables;
 14+
 15+ $wgExtNewTables[] = array(
 16+ 'blanked_pages',
 17+ dirname( __FILE__ ) . '/rpedtable.sql'
 18+ );
 19+ return true;
8020 }
81 - return true;
82 - }
83 -}
\ No newline at end of file
 21+
 22+ public static function wikipediaLink( $skin, $target, &$text,
 23+ &$customAttribs, &$query, &$options, &$ret
 24+ ) {
 25+ global $wgLocalStyle, $wgRemoteStyle, $wgPureWikiDeletionInEffect, $wgTitle, $wgRequest;
 26+
 27+ if ( $wgTitle->getNamespace () == -1 ) {
 28+ return true;
 29+ }
 30+
 31+ if ( isset( $query['action'] ) && $query['action'] == 'history' ) {
 32+ return true;
 33+ }
 34+
 35+ if ( $wgRequest->getText( 'action' ) == 'history' ) {
 36+ return true;
 37+ }
 38+
 39+ $itIsBlank = false;
 40+
 41+ // Return immediately if we know it's existent on the local wiki
 42+ if ( in_array( 'known', $options ) ) {
 43+ if ( !isset( $query['action'] ) && !isset( $query['curid'] ) ) {
 44+ $customAttribs['style'] = $wgLocalStyle;
 45+ }
 46+
 47+ if ( !isset( $wgPureWikiDeletionInEffect ) || $wgPureWikiDeletionInEffect != true ) {
 48+ return true;
 49+ }
 50+
 51+ $dbr = wfGetDB( DB_SLAVE );
 52+
 53+ /*$myRevision=Revision::loadFromTitle($dbr,$target);
 54+ if ($myRevision->getRawText()!=''){*/
 55+ $id = $target->getArticleID();
 56+ $result = $dbr->selectRow(
 57+ 'blanked_page',
 58+ 'blank_page_id',
 59+ array( "blank_page_id" => $id )
 60+ );
 61+
 62+ if ( !$result ) {
 63+ return true;
 64+ }
 65+
 66+ $itIsBlank = true;
 67+ }
 68+
 69+ // If it doesn't exist on the local wiki, then see if it exists on the
 70+ // remote wiki (Wikipedia)
 71+ if ( in_array( 'broken', $options ) || $itIsBlank == true ) {
 72+ $title = $target->getPrefixedText ();
 73+
 74+ for ( $thiscount = 0; $thiscount < strlen( $title ); $thiscount++ ) {
 75+ if ( substr( $title, $thiscount, 1 ) == ' ' ) {
 76+ $title = substr_replace( $title, '_', $thiscount, 1 );
 77+ }
 78+ }
 79+ $dbr = wfGetDB( DB_SLAVE );
 80+ $result = $dbr->selectRow(
 81+ 'rped_page',
 82+ 'rped_page_id',
 83+ array( "rped_page_title" => $title )
 84+ );
 85+
 86+ if ( !$result ) {
 87+ return true;
 88+ } else {
 89+ $title = htmlentities( $title );
 90+ // FIXME: make language configurable, or the same as content language.
 91+ $url = 'http://en.wikipedia.org/wiki/' . $title;
 92+
 93+ // The page that we'll link to
 94+ $text = '<a href="' . $url . '">' . $text . '</a>';
 95+
 96+ if ( $wgRemoteStyle != '' ) {
 97+ $customAttribs['style'] = $wgRemoteStyle;
 98+ }
 99+ }
 100+ }
 101+ return true;
 102+ }
 103+}
Index: trunk/extensions/RPED/RPED.alias.php
@@ -1,7 +1,13 @@
22 <?php
 3+/**
 4+ * Aliases for special pages of RPED extension.
 5+ */
 6+
37 $aliases = array();
4 -
5 -/** English */
 8+
 9+/** English
 10+ * @author Tisane
 11+ */
612 $aliases['en'] = array(
7 - 'RPED' => array( 'RPED' ),
8 -);
\ No newline at end of file
 13+ 'RPED' => array( 'RPED' ),
 14+);
Index: trunk/extensions/RPED/RPED.i18n.php
@@ -1,8 +1,15 @@
22 <?php
 3+/**
 4+ * Internationalisation file for the RPED extension
 5+ * @addtogroup Extensions
 6+ */
 7+
38 $messages = array();
4 -
5 -$messages['en'] = array(
6 - 'rped' => 'Remote Page Existence Detection',
7 - 'rped-desc' => 'Links wikilinks to Wikipedia if the page is nonexistent on '
8 - .'the local wiki but exists on Wikipedia',
 9+
 10+/* English
 11+ * @author Tisane
 12+ */
 13+$messages['en'] = array(
 14+ 'rped' => 'Remote page existence detection',
 15+ 'rped-desc' => 'Links wikilinks to Wikipedia if the page is does not exist on the local wiki but exists on Wikipedia',
916 );
Index: trunk/extensions/Translate/groups/mediawiki-defines.txt
@@ -901,6 +901,9 @@
902902 Right Functions
903903 optional = rightfunctions-rest1, rightfunctions-rest2, rightfunctions-rest3, rightfunctions-sep
904904
 905+RPED
 906+aliasfile = RPED/RPED.alias.php
 907+
905908 RT
906909
907910 Search Box

Follow-up revisions

RevisionCommit summaryAuthorDate
r65368Follow-up r65228: stylize.php breaks <<<EOT ... EOT sytaxraymond10:07, 21 April 2010

Status & tagging log