Index: trunk/extensions/RPED/RPED.php |
— | — | @@ -18,27 +18,26 @@ |
19 | 19 | /* Alert the user that this is not a valid entry point to MediaWiki if they try to access the |
20 | 20 | special pages file directly.*/ |
21 | 21 | |
22 | | -if (!defined('MEDIAWIKI')) { |
| 22 | +if ( !defined( 'MEDIAWIKI' ) ) { |
23 | 23 | echo <<<EOT |
24 | 24 | To install the RPED extension, put the following line in LocalSettings.php: |
25 | 25 | require( "extensions/RPED/RPED.php" ); |
26 | 26 | EOT; |
27 | | - exit( 1 ); |
| 27 | + exit( 1 ); |
28 | 28 | } |
29 | 29 | |
30 | 30 | $wgExtensionCredits['specialpage'][] = array( |
31 | 31 | 'name' => 'Remote Page Existence Detection', |
32 | 32 | 'author' => 'Tisane', |
33 | 33 | 'url' => 'http://www.mediawiki.org/wiki/Extension:RemotePageExistenceDetection', |
34 | | - 'description' => 'Remote Page Existence Detection', |
35 | 34 | 'descriptionmsg' => 'rped-desc', |
36 | | - 'version' => '1.0.0', |
| 35 | + 'version' => '1.0.1', |
37 | 36 | ); |
38 | 37 | |
39 | | -$dir = dirname(__FILE__) . '/'; |
40 | | -$wgAutoloadClasses['RPEDHooks'] = $dir.'RPED.hooks.php'; |
| 38 | +$dir = dirname( __FILE__ ) . '/'; |
| 39 | +$wgAutoloadClasses['RPEDHooks'] = $dir . 'RPED.hooks.php'; |
41 | 40 | $wgExtensionMessagesFiles['RPED'] = $dir . 'RPED.i18n.php'; |
42 | 41 | $wgExtensionAliasesFiles['RPED'] = $dir . 'RPED.alias.php'; |
43 | 42 | |
44 | 43 | $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 @@ |
10 | 10 | CREATE INDEX rped_page_id ON rped_page (rped_page_id); |
11 | 11 | CREATE INDEX rped_page_title ON rped_page (rped_page_title); |
12 | 12 | |
13 | | -COMMIT; |
\ No newline at end of file |
| 13 | +COMMIT; |
Index: trunk/extensions/RPED/RPED.hooks.php |
— | — | @@ -1,82 +1,102 @@ |
2 | 2 | <?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 ); |
9 | 9 | } |
10 | 10 | |
11 | 11 | 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; |
80 | 20 | } |
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 @@ |
2 | 2 | <?php |
| 3 | +/** |
| 4 | + * Aliases for special pages of RPED extension. |
| 5 | + */ |
| 6 | + |
3 | 7 | $aliases = array(); |
4 | | - |
5 | | -/** English */ |
| 8 | + |
| 9 | +/** English |
| 10 | + * @author Tisane |
| 11 | + */ |
6 | 12 | $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 @@ |
2 | 2 | <?php |
| 3 | +/** |
| 4 | + * Internationalisation file for the RPED extension |
| 5 | + * @addtogroup Extensions |
| 6 | + */ |
| 7 | + |
3 | 8 | $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', |
9 | 16 | ); |
Index: trunk/extensions/Translate/groups/mediawiki-defines.txt |
— | — | @@ -901,6 +901,9 @@ |
902 | 902 | Right Functions |
903 | 903 | optional = rightfunctions-rest1, rightfunctions-rest2, rightfunctions-rest3, rightfunctions-sep |
904 | 904 | |
| 905 | +RPED |
| 906 | +aliasfile = RPED/RPED.alias.php |
| 907 | + |
905 | 908 | RT |
906 | 909 | |
907 | 910 | Search Box |