r98371 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98370‎ | r98371 | r98372 >
Date:21:25, 28 September 2011
Author:dasch
Status:ok (Comments)
Tags:
Comment:
changes made on advice from r98321 thanks to IAlex and Krinkle
Modified paths:
  • /trunk/extensions/RelationLinks/RelationLinks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/RelationLinks/RelationLinks.php
@@ -17,7 +17,7 @@
1818 'author' => '[http://www.dasch-tour.de DaSch]',
1919 'description' => 'Adds link rel to header, that can used for navigation and for SEO',
2020 'descriptionmsg' => 'relationlinks-desc',
21 - 'version' => '0.2.1',
 21+ 'version' => '0.3.0',
2222 'url' => 'http://www.mediawiki.org/wiki/Extension:RelationLinks',
2323 );
2424 $dir = dirname( __FILE__ ) . '/';
@@ -25,14 +25,48 @@
2626 // Internationalization
2727 $wgExtensionMessagesFiles['RelationLinks'] = $dir . 'RelationLinks.i18n.php';
2828
29 -$wgHooks['ParserBeforeTidy'][] = 'addRelationLinks';
 29+$wgHooks['BeforePageDisplay'][] = 'addRelationLinks';
3030
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+ ) );
3872 return true;
3973 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r98321New Extension CreditTabdasch16:01, 28 September 2011

Comments

#Comment by Krinkle (talk | contribs)   21:28, 28 September 2011
-	global $wgArticlePath, $wgTitle;
+	global $wgArticlePath;

That one isn't needed any more now. Awesome!

#Comment by DaSch (talk | contribs)   21:54, 28 September 2011

thanks :) will change this with another commit ;)

Status & tagging log