Index: trunk/extensions/RelationLinks/RelationLinks.php |
— | — | @@ -17,7 +17,7 @@ |
18 | 18 | 'author' => '[http://www.dasch-tour.de DaSch]', |
19 | 19 | 'description' => 'Adds link rel to header, that can used for navigation and for SEO', |
20 | 20 | 'descriptionmsg' => 'relationlinks-desc', |
21 | | - 'version' => '0.2.1', |
| 21 | + 'version' => '0.3.0', |
22 | 22 | 'url' => 'http://www.mediawiki.org/wiki/Extension:RelationLinks', |
23 | 23 | ); |
24 | 24 | $dir = dirname( __FILE__ ) . '/'; |
— | — | @@ -25,14 +25,48 @@ |
26 | 26 | // Internationalization |
27 | 27 | $wgExtensionMessagesFiles['RelationLinks'] = $dir . 'RelationLinks.i18n.php'; |
28 | 28 | |
29 | | -$wgHooks['ParserBeforeTidy'][] = 'addRelationLinks'; |
| 29 | +$wgHooks['BeforePageDisplay'][] = 'addRelationLinks'; |
30 | 30 | |
31 | | -function addRelationLinks( &$parser, &$text ) { |
32 | | - global $wgArticlePath, $wgTitle; |
33 | | - $parser->mOutput->addHeadItem('<link rel="start" type="text/html" title="'. wfMsg('Mainpage') .'" href="'. str_replace( '$1', wfMsg('Mainpage'), $wgArticlePath ) .'" />'); |
34 | | - $parser->mOutput->addHeadItem('<link rel="up" type="text/html" title="'. $wgTitle->getBaseText() .'" href="'. str_replace( '$1', $wgTitle->getBaseText(), $wgArticlePath ) .'" />'); |
35 | | - $parser->mOutput->addHeadItem('<link rel="help" type="text/html" title="'. wfMsg('Helppage') .'" href="'. str_replace( '$1', wfMsg('Helppage'), $wgArticlePath ) .'" />'); |
36 | | - $parser->mOutput->addHeadItem('<link rel="index" type="text/html" title="'. wfMsg('Allpages') .'" href="'. str_replace( '$1', 'Special:AllPages', $wgArticlePath ) . '" />'); |
37 | | - $parser->mOutput->addHeadItem('<link rel="search" type="text/html" title="'. wfMsg('Search') .'" href="'. str_replace( '$1', 'Special:Search', $wgArticlePath ) . '" />'); |
| 31 | +function addRelationLinks( &$out, &$sk ) { |
| 32 | + global $wgArticlePath; |
| 33 | + $rlMainpage = Title::newFromText(wfMsg('Mainpage')); |
| 34 | + $out->addLink( array( |
| 35 | + 'rel' => 'start', |
| 36 | + 'type' => 'text/html', |
| 37 | + 'title' => wfMsg('Mainpage'), |
| 38 | + 'href' => $rlMainpage->getLocalURL(), |
| 39 | + ) ); |
| 40 | + $rlHelppage = Title::newFromText(wfMsg('Helppage')); |
| 41 | + $out->addLink( array( |
| 42 | + 'rel' => 'help', |
| 43 | + 'type' => 'text/html', |
| 44 | + 'title' => wfMsg('Helppage'), |
| 45 | + 'href' => $rlHelppage->getLocalURL(), |
| 46 | + ) ); |
| 47 | + $rlAllpages = Title::newFromText(wfMsg('Allpages')); |
| 48 | + $out->addLink( array( |
| 49 | + 'rel' => 'index', |
| 50 | + 'type' => 'text/html', |
| 51 | + 'title' => wfMsg('Allpages'), |
| 52 | + 'href' => $rlAllpages->getLocalURL(), |
| 53 | + ) ); |
| 54 | + $rlSearch = Title::newFromText(wfMsg('Search')); |
| 55 | + $out->addLink( array( |
| 56 | + 'rel' => 'search', |
| 57 | + 'type' => 'text/html', |
| 58 | + 'title' => wfMsg('Search'), |
| 59 | + 'href' => $rlSearch->getLocalURL(), |
| 60 | + ) ); |
| 61 | + $rlNamespace = $out->getTitle()->getNsText(); |
| 62 | + if ( strlen($rlNamespace) > 1 ) { |
| 63 | + $rlNamespace = $rlNamespace . ':'; |
| 64 | + } |
| 65 | + $rlSupPage = Title::newFromText($rlNamespace.$out->getTitle()->getBaseText()); |
| 66 | + $out->addLink( array( |
| 67 | + 'rel' => 'up', |
| 68 | + 'type' => 'text/html', |
| 69 | + 'title' => $rlNamespace . $out->getTitle()->getBaseText(), |
| 70 | + 'href' => $rlSupPage->getLocalURL(), |
| 71 | + ) ); |
38 | 72 | return true; |
39 | 73 | } |