Index: trunk/extensions/RPED/RPED.php |
— | — | @@ -27,7 +27,6 @@ |
28 | 28 | } |
29 | 29 | |
30 | 30 | $wgExtensionCredits['other'][] = array( |
31 | | - 'path' => __FILE__, |
32 | 31 | 'name' => 'Remote Page Existence Detection', |
33 | 32 | 'author' => 'Tisane', |
34 | 33 | 'url' => 'http://www.mediawiki.org/wiki/Extension:RemotePageExistenceDetection', |
— | — | @@ -38,6 +37,9 @@ |
39 | 38 | $dir = dirname( __FILE__ ) . '/'; |
40 | 39 | $wgAutoloadClasses['RPEDHooks'] = $dir . 'RPED.hooks.php'; |
41 | 40 | $wgExtensionMessagesFiles['RPED'] = $dir . 'RPED.i18n.php'; |
| 41 | +$wgAutoloadClasses['ApiRPED'] = $dir.'ApiRPED.php'; |
| 42 | +$wgAPIModules['rped'] = 'ApiRPED'; |
| 43 | +$wgGroupPermissions['RPED']['rped'] = true; |
42 | 44 | |
43 | 45 | $wgHooks['LoadExtensionSchemaUpdates'][] = 'RPEDHooks::RPEDCreateTable'; |
44 | 46 | $wgHooks['LinkBegin'][] = 'RPEDHooks::wikipediaLink'; |
Index: trunk/extensions/RPED/RPED.hooks.php |
— | — | @@ -22,7 +22,7 @@ |
23 | 23 | &$customAttribs, &$query, &$options, &$ret |
24 | 24 | ) { |
25 | 25 | global $wgLocalStyle, $wgRemoteStyle, $wgPureWikiDeletionInEffect, $wgTitle, $wgRequest; |
26 | | - |
| 26 | + wfLoadExtensionMessages('RPED'); |
27 | 27 | if ( $wgTitle->getNamespace () == -1 ) { |
28 | 28 | return true; |
29 | 29 | } |
— | — | @@ -86,8 +86,7 @@ |
87 | 87 | return true; |
88 | 88 | } else { |
89 | 89 | $title = htmlentities( $title ); |
90 | | - // FIXME: make language configurable, or the same as content language. |
91 | | - $url = 'http://en.wikipedia.org/wiki/' . $title; |
| 90 | + $url = wfMsgExt( 'rped-wikipedia-url','parsemag') . $title; |
92 | 91 | |
93 | 92 | // The page that we'll link to |
94 | 93 | $text = '<a href="' . $url . '">' . $text . '</a>'; |
Index: trunk/extensions/RPED/ApiRPED.php |
— | — | @@ -0,0 +1,105 @@ |
| 2 | +<?php |
| 3 | +if (!defined('MEDIAWIKI')) { |
| 4 | + die(); |
| 5 | +} |
| 6 | + |
| 7 | +class ApiRPED extends ApiBase { |
| 8 | + public function __construct($main, $action) { |
| 9 | + parent :: __construct($main, $action); |
| 10 | + } |
| 11 | + public function execute() { |
| 12 | + global $wgUser; |
| 13 | + /*if (!$this->userCanExecute( $wgUser )) { |
| 14 | + $this->displayRestrictionError(); |
| 15 | + return; |
| 16 | + }*/ |
| 17 | + |
| 18 | + if (!$wgUser->isAllowed( 'rped' ) ){ |
| 19 | + $this->displayRestrictionError(); |
| 20 | + return; |
| 21 | + } |
| 22 | + |
| 23 | + |
| 24 | + #$dbw->insert('rped_pages',array('rped_page_title' => $subValue)); |
| 25 | + $params = $this->extractRequestParams(false); |
| 26 | + /*foreach ($params as $key => $value) { |
| 27 | + $dbw->insert('rped_page',array('rped_page_title' => $key)); |
| 28 | + $dbw->insert('rped_page',array('rped_page_title' => $value)); |
| 29 | + }*/ |
| 30 | + foreach ($params as $key => $value) { |
| 31 | + if ($key!=null && $value!=null){ |
| 32 | + ApiRPED::paramProcess($key,$value); |
| 33 | + } |
| 34 | + |
| 35 | + } |
| 36 | + return; |
| 37 | + } |
| 38 | + |
| 39 | + public function paramProcess($key,$value){ |
| 40 | + $dbr = wfGetDB( DB_SLAVE ); |
| 41 | + $dbw = wfGetDB( DB_MASTER ); |
| 42 | + $myInputNum=0; |
| 43 | + for ($count=0; $count<strlen($value); $count++){ |
| 44 | + if (substr($value,$count,1)=='|'){ |
| 45 | + $myInputNum++; |
| 46 | + } else { |
| 47 | + if (!isset($myInput[$myInputNum])){ |
| 48 | + $myInput[$myInputNum]=''; |
| 49 | + } |
| 50 | + if (substr($value,$count,1)==' '){ |
| 51 | + $myInput[$myInputNum].='_'; |
| 52 | + } else { |
| 53 | + $myInput[$myInputNum].=substr($value,$count,1); |
| 54 | + } |
| 55 | + } |
| 56 | + } |
| 57 | + if (isset($myInput)){ |
| 58 | + foreach ($myInput as $subValue){ |
| 59 | + |
| 60 | + if (isset($subValue) && !($subValue===null)){ |
| 61 | + $existCheck=null; |
| 62 | + $existCheck=$dbr->selectrow('rped_page','rped_page_title',array |
| 63 | + ('rped_page_title' => $subValue)); |
| 64 | + #$dbw->insert('rped_page',array('rped_page_title' => "key: ".$key)); |
| 65 | + #$dbw->insert('rped_page',array('rped_page_title' => "subValue: ".$subValue)); |
| 66 | + #if($key=='insert' && !isset($existCheck) && $existCheck!=null){ |
| 67 | + if($key=='insert' && (!isset($existCheck) || $existCheck==null)){ |
| 68 | + $dbw->insert('rped_page',array('rped_page_title' => $subValue)); |
| 69 | + } |
| 70 | + if ($key=='delete' && isset($existCheck) && $existCheck!=null){ |
| 71 | + $dbw->delete('rped_page',array('rped_page_title' => $subValue)); |
| 72 | + } |
| 73 | + } |
| 74 | + } |
| 75 | + } |
| 76 | + } |
| 77 | + |
| 78 | + public function getAllowedParams(){ |
| 79 | + return array( |
| 80 | + 'insert' => null, |
| 81 | + 'delete' => null |
| 82 | + ); |
| 83 | + } |
| 84 | + |
| 85 | + public function getParamDescription(){ |
| 86 | + return array ( |
| 87 | + 'insert' => 'page name to insert', |
| 88 | + 'delete' => 'page name to delete' |
| 89 | + ); |
| 90 | + } |
| 91 | + |
| 92 | + public function getDescription(){ |
| 93 | + return array ( |
| 94 | + 'This module is used to insert data into, and delete date from, ', |
| 95 | + 'the RPED page name table.' |
| 96 | + ); |
| 97 | + } |
| 98 | + |
| 99 | + public function getVersion() { |
| 100 | + return __CLASS__ . ': $Id$'; |
| 101 | + } |
| 102 | + |
| 103 | + public function displayRestrictionError(){ |
| 104 | + echo("Access denied."); |
| 105 | + } |
| 106 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/RPED/ApiRPED.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 107 | + native |
Index: trunk/extensions/RPED/RPED.i18n.php |
— | — | @@ -12,6 +12,7 @@ |
13 | 13 | $messages['en'] = array( |
14 | 14 | 'rped' => 'Remote page existence detection', |
15 | 15 | 'rped-desc' => 'Links wikilinks to Wikipedia if the page does not exist on the local wiki but exists on Wikipedia', |
| 16 | + 'rped-wikipedia-url' => 'http://en.wikipedia.org/wiki/', |
16 | 17 | ); |
17 | 18 | |
18 | 19 | /** Belarusian (Taraškievica orthography) (Беларуская (тарашкевіца)) |
— | — | @@ -21,6 +22,7 @@ |
22 | 23 | $messages['be-tarask'] = array( |
23 | 24 | 'rped' => 'Выяўленьне існаваньня вонкавай старонкі', |
24 | 25 | 'rped-desc' => 'Устаўляе вікі-спасылкі на Вікіпэдыю, калі старонка не існуе ў лякальнай вікі, але існуе ў Вікіпэдыі', |
| 26 | + 'rped-wikipedia-url' => 'http://be.wikipedia.org/', |
25 | 27 | ); |
26 | 28 | |
27 | 29 | /** German (Deutsch) |
— | — | @@ -29,6 +31,7 @@ |
30 | 32 | $messages['de'] = array( |
31 | 33 | 'rped' => 'Ermittlung websitefremder Webseiten', |
32 | 34 | 'rped-desc' => 'Leitet Wikilinks zur Wikipedia, sofern die betreffende Seite nicht im lokalen Wiki, aber in der Wikipedia vorhanden ist', |
| 35 | + 'rped-wikipedia-url' => 'http://de.wikipedia.org/', |
33 | 36 | ); |
34 | 37 | |
35 | 38 | /** Lower Sorbian (Dolnoserbski) |
— | — | @@ -37,6 +40,7 @@ |
38 | 41 | $messages['dsb'] = array( |
39 | 42 | 'rped' => 'Namakanje eksistence zdalonego boka', |
40 | 43 | 'rped-desc' => 'Wótkazujo wikiwótkaze do Wikipedije, jolic bok njeeksistěrujo w lokalnem wikiju, ale eksistěrujo we Wikipediji', |
| 44 | + 'rped-wikipedia-url' => 'http://dsb.wikipedia.org/', |
41 | 45 | ); |
42 | 46 | |
43 | 47 | /** Spanish (Español) |
— | — | @@ -45,6 +49,7 @@ |
46 | 50 | $messages['es'] = array( |
47 | 51 | 'rped' => 'Detección de existencia de página remota', |
48 | 52 | 'rped-desc' => 'Enlaza los wikienlaces a Wikipedia si la página no existe en la wiki local pero existe en Wikipedia', |
| 53 | + 'rped-wikipedia-url' => 'http://es.wikipedia.org/', |
49 | 54 | ); |
50 | 55 | |
51 | 56 | /** French (Français) |
— | — | @@ -53,6 +58,7 @@ |
54 | 59 | $messages['fr'] = array( |
55 | 60 | 'rped' => "Détection d'existence des pages à distance", |
56 | 61 | 'rped-desc' => "Lie les wikiliens vers Wikipédia si la page n'existe pas sur le wiki local mais existe sur Wikipédia", |
| 62 | + 'rped-wikipedia-url' => 'http://fr.wikipedia.org/', |
57 | 63 | ); |
58 | 64 | |
59 | 65 | /** Galician (Galego) |
— | — | @@ -61,6 +67,7 @@ |
62 | 68 | $messages['gl'] = array( |
63 | 69 | 'rped' => 'Detección remota da existencia de páxinas', |
64 | 70 | 'rped-desc' => 'Crea ligazóns cara á Wikipedia se a páxina non existe no wiki local pero si na Wikipedia', |
| 71 | + 'rped-wikipedia-url' => 'http://gl.wikipedia.org/', |
65 | 72 | ); |
66 | 73 | |
67 | 74 | /** Swiss German (Alemannisch) |
— | — | @@ -69,6 +76,7 @@ |
70 | 77 | $messages['gsw'] = array( |
71 | 78 | 'rped' => 'Erkännig vu främde Netzsyte', |
72 | 79 | 'rped-desc' => 'Leitet Wikilinks uf d Wikipedia, wänn die Syte nit im lokale Wiki git, derfir aber in dr Wikipedia', |
| 80 | + 'rped-wikipedia-url' => 'http://gsw.wikipedia.org/', |
73 | 81 | ); |
74 | 82 | |
75 | 83 | /** Upper Sorbian (Hornjoserbsce) |
— | — | @@ -77,6 +85,7 @@ |
78 | 86 | $messages['hsb'] = array( |
79 | 87 | 'rped' => 'Wotkryće eksistency zdaleneje strony', |
80 | 88 | 'rped-desc' => 'Wotkazuje wikiwotkazy do Wikipedije, jeli strona njeeksistuje w lokalnym wikiju, ale eksistuje we Wikipediji', |
| 89 | + 'rped-wikipedia-url' => 'http://hsb.wikipedia.org/', |
81 | 90 | ); |
82 | 91 | |
83 | 92 | /** Hungarian (Magyar) |
— | — | @@ -85,6 +94,7 @@ |
86 | 95 | $messages['hu'] = array( |
87 | 96 | 'rped' => 'Ellenőrzi, hogy egy távoli lap létezik-e', |
88 | 97 | 'rped-desc' => 'A wikilinkeket a Wikipédiára irányítja, ha a lap nem létezik a helyi wikiben, de a Wikipédián igen', |
| 98 | + 'rped-wikipedia-url' => 'http://hu.wikipedia.org/', |
89 | 99 | ); |
90 | 100 | |
91 | 101 | /** Interlingua (Interlingua) |
— | — | @@ -93,6 +103,7 @@ |
94 | 104 | $messages['ia'] = array( |
95 | 105 | 'rped' => 'Detection del existentia de paginas remote', |
96 | 106 | 'rped-desc' => 'Face wiki-ligamines a Wikipedia si le pagina non existe in le wiki local ma existe in Wikipedia', |
| 107 | + 'rped-wikipedia-url' => 'http://ia.wikipedia.org/', |
97 | 108 | ); |
98 | 109 | |
99 | 110 | /** Macedonian (Македонски) |
— | — | @@ -101,6 +112,7 @@ |
102 | 113 | $messages['mk'] = array( |
103 | 114 | 'rped' => 'Пронаоѓач на постоечка надворешна страница', |
104 | 115 | 'rped-desc' => 'Поврзува викиврски со Википедија ако страницата не постои на локалното вики, но постои на Википедија', |
| 116 | + 'rped-wikipedia-url' => 'http://mk.wikipedia.org/', |
105 | 117 | ); |
106 | 118 | |
107 | 119 | /** Dutch (Nederlands) |
— | — | @@ -109,6 +121,7 @@ |
110 | 122 | $messages['nl'] = array( |
111 | 123 | 'rped' => "Detectie van pagina's in andere wiki's", |
112 | 124 | 'rped-desc' => 'Verwijst naar Wikipedia als de pagina niet bestaat in de lokale wiki maar wel in Wikipedia', |
| 125 | + 'rped-wikipedia-url' => 'http://nl.wikipedia.org/', |
113 | 126 | ); |
114 | 127 | |
115 | 128 | /** Norwegian (bokmål) (Norsk (bokmål)) |
— | — | @@ -117,22 +130,16 @@ |
118 | 131 | $messages['no'] = array( |
119 | 132 | 'rped' => 'Eksistensdeteksjon av eksterne sider', |
120 | 133 | 'rped-desc' => 'Lenker wikilenker til Wikipedia om siden ikke finnes på den lokale wikien men finnes på Wikipedia', |
| 134 | + 'rped-wikipedia-url' => 'http://no.wikipedia.org/', |
121 | 135 | ); |
122 | 136 | |
123 | | -/** Occitan (Occitan) |
124 | | - * @author Cedric31 |
125 | | - */ |
126 | | -$messages['oc'] = array( |
127 | | - 'rped' => "Deteccion d'existéncia de las paginas a distància", |
128 | | - 'rped-desc' => 'Liga los wikiligams cap a Wikipèdia se la pagina existís pas sul wiki local mas existís sus Wikipèdia', |
129 | | -); |
130 | | - |
131 | 137 | /** Piedmontese (Piemontèis) |
132 | 138 | * @author Borichèt |
133 | 139 | */ |
134 | 140 | $messages['pms'] = array( |
135 | 141 | 'rped' => "Determinassion d'esistensa dle pàgine a distansa", |
136 | 142 | 'rped-desc' => "A colega j'anliure wiki a Wikipedia se la pàgina a esist pa an sla wiki local ma a esist dzora a Wikipedia", |
| 143 | + 'rped-wikipedia-url' => 'http://pms.wikipedia.org/', |
137 | 144 | ); |
138 | 145 | |
139 | 146 | /** Portuguese (Português) |
— | — | @@ -141,6 +148,7 @@ |
142 | 149 | $messages['pt'] = array( |
143 | 150 | 'rped' => 'Detecção da existência de páginas remotas', |
144 | 151 | 'rped-desc' => 'Liga um link à Wikipédia, se a página de destino não existe na wiki local mas existe na Wikipédia', |
| 152 | + 'rped-wikipedia-url' => 'http://pt.wikipedia.org/', |
145 | 153 | ); |
146 | 154 | |
147 | 155 | /** Russian (Русский) |
— | — | @@ -149,5 +157,6 @@ |
150 | 158 | $messages['ru'] = array( |
151 | 159 | 'rped' => 'Обнаружение существования внешней страницы', |
152 | 160 | 'rped-desc' => 'Ставит вики-ссылки на Википедию, если страницы не существует в локальной вики, но она присутствует в Википедии', |
| 161 | + 'rped-wikipedia-url' => 'http://ru.wikipedia.org/', |
153 | 162 | ); |
154 | 163 | |