Index: trunk/extensions/Interlanguage/Interlanguage.php |
— | — | @@ -49,6 +49,7 @@ |
50 | 50 | $wgInterlanguageExtension = new InterlanguageExtension(); |
51 | 51 | $wgHooks['EditPage::showEditForm:fields'][] = array( $wgInterlanguageExtension, 'pageLinks' ); |
52 | 52 | $wgHooks['ArticleSaveComplete'][] = $wgInterlanguageExtension; |
| 53 | + $wgHooks['SkinTemplateLanguageBoxEnd'][] = $wgInterlanguageExtension; |
53 | 54 | $parser->setFunctionHook( 'interlanguage', array( $wgInterlanguageExtension, 'interlanguage' ), SFH_NO_HASH ); |
54 | 55 | } |
55 | 56 | return true; |
Index: trunk/extensions/Interlanguage/InterlanguageCentralExtensionPurgeJob.php |
— | — | @@ -1,10 +1,10 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | | - * MediaWiki InterlanguageCentral extension v1.2 |
| 4 | + * MediaWiki InterlanguageCentral extension |
5 | 5 | * InterlanguageCentralExtensionPurgeJob class |
6 | 6 | * |
7 | 7 | * Copyright © 2010-2011 Nikola Smolenski <smolensk@eunet.rs> |
8 | | - * @version 1.1 |
| 8 | + * @version 1.2 |
9 | 9 | * |
10 | 10 | * This program is free software; you can redistribute it and/or modify |
11 | 11 | * it under the terms of the GNU General Public License as published by |
Index: trunk/extensions/Interlanguage/InterlanguageCentralExtension.php |
— | — | @@ -1,10 +1,10 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | | - * MediaWiki InterlanguageCentral extension v1.2 |
| 4 | + * MediaWiki InterlanguageCentral extension |
5 | 5 | * InterlanguageCentralExtension class |
6 | 6 | * |
7 | 7 | * Copyright © 2010-2011 Nikola Smolenski <smolensk@eunet.rs> |
8 | | - * @version 1.1 |
| 8 | + * @version 1.2 |
9 | 9 | * |
10 | 10 | * This program is free software; you can redistribute it and/or modify |
11 | 11 | * it under the terms of the GNU General Public License as published by |
Index: trunk/extensions/Interlanguage/InterlanguageCentral.php |
— | — | @@ -3,7 +3,7 @@ |
4 | 4 | * MediaWiki InterlanguageCentral extension v1.2 |
5 | 5 | * |
6 | 6 | * Copyright © 2010-2011 Nikola Smolenski <smolensk@eunet.rs> |
7 | | - * @version 1.1 |
| 7 | + * @version 1.2 |
8 | 8 | * |
9 | 9 | * This program is free software; you can redistribute it and/or modify |
10 | 10 | * it under the terms of the GNU General Public License as published by |
Index: trunk/extensions/Interlanguage/InterlanguageExtension.php |
— | — | @@ -185,26 +185,9 @@ |
186 | 186 | * @param $editPage - standard EditPage object. |
187 | 187 | */ |
188 | 188 | function pageLinks( $editPage ) { |
189 | | - global $wgInterlanguageExtensionInterwiki; |
| 189 | + $pagelinktexts = $this->getPageLinkTexts( $editPage->mArticle->mTitle->mArticleID ); |
190 | 190 | |
191 | | - $articleid = $editPage->mArticle->mTitle->mArticleID; |
192 | | - |
193 | | - if( isset( $this->pageLinks[$articleid] ) && count( $this->pageLinks[$articleid] ) ) { |
194 | | - $pagelinks = $this->pageLinks[$articleid]; |
195 | | - } else { |
196 | | - $pagelinks = $this->loadPageLinks( $articleid ); |
197 | | - } |
198 | | - |
199 | | - if( count( $pagelinks ) ) { |
200 | | - $linker = new Linker(); $pagelinktexts = array(); |
201 | | - foreach( $pagelinks as $page => $dummy ) { |
202 | | - $title = Title::newFromText( $wgInterlanguageExtensionInterwiki . strtr($this->translateNamespace( $page ), '_', ' ') ); |
203 | | - $link = $linker->link( $title ); |
204 | | - if( strlen( $link ) ) { |
205 | | - $pagelinktexts[] = $link; |
206 | | - } |
207 | | - } |
208 | | - |
| 191 | + if( count( $pagelinktexts ) ) { |
209 | 192 | $ple = wfMsg( 'interlanguage-pagelinksexplanation' ); |
210 | 193 | |
211 | 194 | $res = <<<THEEND |
— | — | @@ -283,6 +266,60 @@ |
284 | 267 | } |
285 | 268 | |
286 | 269 | /** |
| 270 | + * Displays a list of links to pages on the central wiki at the end of the language box. |
| 271 | + * |
| 272 | + * @param $editPage - standard EditPage object. |
| 273 | + */ |
| 274 | + function onSkinTemplateLanguageBoxEnd( $tpl ) { |
| 275 | + $pagelinktexts = $this->getPageLinkTexts( $tpl->skin->mTitle->mArticleID, wfMsg( 'editsection' ) ); |
| 276 | + |
| 277 | + if( count( $pagelinktexts ) ) { |
| 278 | + $res = ""; |
| 279 | + foreach($pagelinktexts as $link) { |
| 280 | + $res .= "<li class=\"interwiki-interlanguage\">[$link]</li>\n"; |
| 281 | + } |
| 282 | + |
| 283 | + echo $res; |
| 284 | + } |
| 285 | + |
| 286 | + return true; |
| 287 | + } |
| 288 | + |
| 289 | + /** |
| 290 | + * Returns an array of link texts of pages on the central wiki which are linked to from a page |
| 291 | + * on this wiki by {{interlanguage:}} magic. |
| 292 | + * |
| 293 | + * @param $articleid - ID of the article whose links should be returned. |
| 294 | + * @param $text = false - The HTML contents of the <a> element. If set, it will be |
| 295 | + * passed to Linker::link(), if unset the link title will be used. |
| 296 | + * @returns The array. If there are no pages linked, an empty array is returned. |
| 297 | + */ |
| 298 | + function getPageLinkTexts( $articleid, $text = false ) { |
| 299 | + global $wgInterlanguageExtensionInterwiki; |
| 300 | + |
| 301 | + if( isset( $this->pageLinks[$articleid] ) && count( $this->pageLinks[$articleid] ) ) { |
| 302 | + $pagelinks = $this->pageLinks[$articleid]; |
| 303 | + } else { |
| 304 | + $pagelinks = $this->loadPageLinks( $articleid ); |
| 305 | + } |
| 306 | + |
| 307 | + $pagelinktexts = array(); |
| 308 | + if( count( $pagelinks ) ) { |
| 309 | + $linker = new Linker(); |
| 310 | + foreach( $pagelinks as $page => $dummy ) { |
| 311 | + $title = Title::newFromText( $wgInterlanguageExtensionInterwiki . strtr( $this->translateNamespace( $page ), '_', ' ') ); |
| 312 | + $link = $linker->link( $title, $text? $text: $page ); |
| 313 | + if( strlen( $link ) ) { |
| 314 | + $pagelinktexts[] = $link; |
| 315 | + } |
| 316 | + } |
| 317 | + } |
| 318 | + |
| 319 | + return $pagelinktexts; |
| 320 | + |
| 321 | + } |
| 322 | + |
| 323 | + /** |
287 | 324 | * Returns an array of names of pages on the central wiki which are linked to from a page |
288 | 325 | * on this wiki by {{interlanguage:}} magic. Pagenames are array keys. |
289 | 326 | * |