diff --git a/RelatedArticles.i18n.php b/RelatedArticles.i18n.php index 96ccafc4..7333c95d 100644 --- a/RelatedArticles.i18n.php +++ b/RelatedArticles.i18n.php @@ -9,21 +9,21 @@ $messages = array(); $messages['en'] = array( - 'ra-RelatedArticles' => 'Related articles', - 'ra-desc' => 'Extension for presentation of related articles on the sidebar', + 'ra-RelatedArticles' => 'Related articles', + 'ra-desc' => 'Extension for presentation of related articles on the sidebar', ); $messages['de'] = array( - 'ra-RelatedArticles' => 'Verwandte Artikel', - 'ra-desc' => 'Erweiterung für die Ausgabe von verwandten Artikeln auf der Sidebar', + 'ra-RelatedArticles' => 'Verwandte Artikel', + 'ra-desc' => 'Erweiterung für die Ausgabe von verwandten Artikeln auf der Sidebar', ); $messages['fr'] = array( - 'ra-RelatedArticles' => 'Articoli collegati', + 'ra-RelatedArticles' => 'Articoli collegati', ); $messages['it'] = array( - 'ra-RelatedArticles' => 'Autres articles', + 'ra-RelatedArticles' => 'Autres articles', ); -?> + diff --git a/RelatedArticles.php b/RelatedArticles.php index 54cd9635..eb45024e 100644 --- a/RelatedArticles.php +++ b/RelatedArticles.php @@ -1,33 +1,33 @@ 'RelatedArticles', 'url' => -'http://wikivoyage.org/tech/RelatedArticles-Extension', 'author' => 'Roland Unger/Hans Musil', -'descriptionmsg' => 'ra-desc' ); +$wgExtensionCredits['parserhook']['RelatedArticles'] = array( + 'name' => 'RelatedArticles', + 'url' => 'http://wikivoyage.org/tech/RelatedArticles-Extension', + 'author' => 'Roland Unger/Hans Musil', + 'descriptionmsg' => 'ra-desc' +); -$wgHooks['LanguageGetMagic'][] = 'wfRelatedArticlesParserFunction_Magic'; +$wgHooks['LanguageGetMagic'][] = 'wfRelatedArticlesParserFunction_Magic'; -class RelatedArticles -{ +class RelatedArticles { var $mRelArtSet = array(); - function RelatedArticles() - { + function RelatedArticles() { # wfDebug( "Call to RelatedArticles constructor\n"); $this->mRelArtSet = array(); } - function onParserClearState( &$parser) - { + function onParserClearState( &$parser ) { # wfDebug( "RelatedArticles::onParserClearState: " . $parser->mTitle->getPrefixedText() . "\n"); # wfDebug( "RelatedArticles::onParserClearState\n"); @@ -37,18 +37,16 @@ class RelatedArticles } # function onFuncRelated( &$parser, $relart) - function onFuncRelated() - { + function onFuncRelated() { $args = func_get_args(); - array_shift( $args); + array_shift( $args ); # $parser = array_shift( $args); - foreach( $args as $relart) - { + foreach ( $args as $relart ) { # wfDebug( "RelatedArticles::onFuncRelated: relart = $relart\n"); $this->mRelArtSet[] = $relart; - }; + } return ''; } @@ -56,14 +54,12 @@ class RelatedArticles # # After parsing is done, store the $mRelArtSet in $wgCustomData. # - function onParserBeforeTidy( &$parser, &$text) - { + function onParserBeforeTidy( &$parser, &$text ) { global $wgCustomData; - if( $this->mRelArtSet) - { - $wgCustomData->setParserData( $parser->mOutput, 'RelatedArticles', $this->mRelArtSet); - }; + if ( $this->mRelArtSet ) { + $wgCustomData->setParserData( $parser->mOutput, 'RelatedArticles', $this->mRelArtSet ); + } return true; } @@ -72,24 +68,22 @@ class RelatedArticles # Hooked in from hook SkinTemplateOutputPageBeforeExec. # Preprocess related articles links. # - function onSkinTemplateOutputPageBeforeExec( &$SkTmpl, &$QuickTmpl) - { + function onSkinTemplateOutputPageBeforeExec( &$SkTmpl, &$QuickTmpl ) { global $wgCustomData, $wgOut; # wfDebug( "RelatedArticles::onSkinTemplateOutputPageBeforeExec\n"); $RelatedArticles_urls = array(); - # - # Fill the RelatedArticles array. - # - $ra = $wgCustomData->getPageData( $wgOut, 'RelatedArticles'); - foreach( $ra as $l) - { + # + # Fill the RelatedArticles array. + # + $ra = $wgCustomData->getPageData( $wgOut, 'RelatedArticles' ); + foreach ( $ra as $l ) { // Tribute to Evan - $l = urldecode( $l); + $l = urldecode( $l ); $altText = ''; - if (preg_match('/\&\&/', $l)) { - $parts = array_map( 'trim', explode('&&', $l, 2) ); + if ( preg_match( '/\&\&/', $l ) ) { + $parts = array_map( 'trim', explode( '&&', $l, 2 ) ); $l = $parts[0]; $altText = $parts[1]; } @@ -98,9 +92,10 @@ class RelatedArticles $class = 'interwiki-relart'; $nt = Title::newFromText( $l ); - if( $nt) - { - if ($altText == '') $altText = $nt->getPrefixedText(); + if ( $nt ) { + if ( $altText == '' ) { + $altText = $nt->getPrefixedText(); + } $RelatedArticles_urls[] = array( 'href' => $nt->getLocalURL(), # 'href' => $nt->getFullURL(), @@ -108,11 +103,12 @@ class RelatedArticles # 'text' => $nt->getText(), 'class' => $class ); - }; + } # wfDebug( "l: $l\n"); - }; - $wgCustomData->setSkinData( $QuickTmpl, 'RelatedArticles', $RelatedArticles_urls); + } + ; + $wgCustomData->setSkinData( $QuickTmpl, 'RelatedArticles', $RelatedArticles_urls ); return true; } @@ -120,62 +116,56 @@ class RelatedArticles # # Write out HTML-code. # - function onSkinTemplateToolboxEnd( &$skTemplate) - { + function onSkinTemplateToolboxEnd( &$skTemplate ) { global $wgCustomData; # wfDebug( "RelatedArticles::onSkinTemplateToolboxEnd\n"); - $ra = $wgCustomData->getSkinData( $skTemplate, 'RelatedArticles'); - if( $ra ) - { ?> - - - -
-
msg('ra-RelatedArticles') ?>
-
- +
+
+
+
msg( 'ra-RelatedArticles' ) ?>
+
+