Reformat code. Remove ?>

Change-Id: Ief2c9620b65aee4d72a1669f965dda4218444d13
This commit is contained in:
Reedy 2012-10-12 15:51:29 +01:00
parent 2c93d90d86
commit bb5e4ff182
2 changed files with 73 additions and 84 deletions

View file

@ -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',
);
?>

View file

@ -1,33 +1,33 @@
<?php
if ( !defined( 'MEDIAWIKI' ) ) {
die( 'This file is a MediaWiki extension, it is not a valid entry point' );
die( 'This file is a MediaWiki extension, it is not a valid entry point' );
}
require_once( dirname(__FILE__) . "/../CustomData/CustomData.php" );
require_once( dirname( __FILE__ ) . "/../CustomData/CustomData.php" );
$dir = dirname(__FILE__) . '/';
$dir = dirname( __FILE__ ) . '/';
$wgExtensionMessagesFiles['RelatedArticles'] = $dir . 'RelatedArticles.i18n.php';
$wgExtensionFunctions[] = 'wfSetupRelatedArticles';
$wgExtensionCredits['parserhook']['RelatedArticles'] = array( 'name' => '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 )
{ ?>
</ul>
</div>
</div>
<div id="p-lang" class="portal">
<h5><?php $skTemplate->msg('ra-RelatedArticles') ?></h5>
<div class="body">
<ul>
$ra = $wgCustomData->getSkinData( $skTemplate, 'RelatedArticles' );
if ( $ra ) {
?>
</ul>
</div>
</div>
<div id="p-lang" class="portal">
<h5><?php $skTemplate->msg( 'ra-RelatedArticles' ) ?></h5>
<div class="body">
<ul>
<?php
foreach( $ra as $ralink)
{ ?>
<li class="<?php echo htmlspecialchars($ralink['class'])?>"><?php
?><a href="<?php echo htmlspecialchars($ralink['href']) ?>"><?php echo $ralink['text'] ?></a></li>
<?php }
foreach ( $ra as $ralink ) {
?>
<li class="<?php echo htmlspecialchars( $ralink['class'] )?>"><?php
?><a href="<?php echo htmlspecialchars( $ralink['href'] ) ?>"><?php echo $ralink['text'] ?></a></li>
<?php
}
};
}
return true;
return true;
}
};
}
function wfSetupRelatedArticles()
{
function wfSetupRelatedArticles() {
global $wgParser, $wgHooks;
global $wgRelatedArticles;
$wgRelatedArticles = new RelatedArticles;
$wgParser->setFunctionHook( 'related', array( &$wgRelatedArticles, 'onFuncRelated' ));
$wgRelatedArticles = new RelatedArticles;
$wgParser->setFunctionHook( 'related', array( &$wgRelatedArticles, 'onFuncRelated' ) );
$wgHooks['SkinTemplateToolboxEnd'][] =
array( &$wgRelatedArticles, 'onSkinTemplateToolboxEnd' );
array( &$wgRelatedArticles, 'onSkinTemplateToolboxEnd' );
$wgHooks['SkinTemplateOutputPageBeforeExec'][] =
array( &$wgRelatedArticles, 'onSkinTemplateOutputPageBeforeExec' );
array( &$wgRelatedArticles, 'onSkinTemplateOutputPageBeforeExec' );
$wgHooks['ParserClearState'][] = array( &$wgRelatedArticles, 'onParserClearState' );
$wgHooks['ParserBeforeTidy'][] = array( &$wgRelatedArticles, 'onParserBeforeTidy' );
return true;
}
function wfRelatedArticlesParserFunction_Magic( &$magicWords, $langCode )
{
function wfRelatedArticlesParserFunction_Magic( &$magicWords, $langCode ) {
# wfDebug( "Call to wfRelatedArticlesParserFunction_Magic\n");
$magicWords['related'] = array( 0, 'related' );
@ -183,4 +173,3 @@ function wfRelatedArticlesParserFunction_Magic( &$magicWords, $langCode )
return true;
}
?>