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

@ -26,4 +26,4 @@ $messages['it'] = array(
'ra-RelatedArticles' => 'Autres articles',
);
?>

View file

@ -10,24 +10,24 @@ $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';
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 );
# $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)
{
if ( $this->mRelArtSet ) {
$wgCustomData->setParserData( $parser->mOutput, 'RelatedArticles', $this->mRelArtSet );
};
}
return true;
}
@ -72,8 +68,7 @@ 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");
@ -83,8 +78,7 @@ class RelatedArticles
# Fill the RelatedArticles array.
#
$ra = $wgCustomData->getPageData( $wgOut, 'RelatedArticles' );
foreach( $ra as $l)
{
foreach ( $ra as $l ) {
// Tribute to Evan
$l = urldecode( $l );
$altText = '';
@ -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,10 +103,11 @@ class RelatedArticles
# 'text' => $nt->getText(),
'class' => $class
);
};
}
# wfDebug( "l: $l\n");
};
}
;
$wgCustomData->setSkinData( $QuickTmpl, 'RelatedArticles', $RelatedArticles_urls );
return true;
@ -120,15 +116,14 @@ 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 )
{ ?>
if ( $ra ) {
?>
</ul>
</div>
</div>
@ -138,32 +133,28 @@ class RelatedArticles
<ul>
<?php
foreach( $ra as $ralink)
{ ?>
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 }
<?php
}
};
}
return true;
}
};
}
function wfSetupRelatedArticles()
{
function wfSetupRelatedArticles() {
global $wgParser, $wgHooks;
global $wgRelatedArticles;
$wgRelatedArticles = new RelatedArticles;
$wgParser->setFunctionHook( 'related', array( &$wgRelatedArticles, 'onFuncRelated' ) );
$wgHooks['SkinTemplateToolboxEnd'][] =
array( &$wgRelatedArticles, 'onSkinTemplateToolboxEnd' );
$wgHooks['SkinTemplateOutputPageBeforeExec'][] =
@ -174,8 +165,7 @@ function wfSetupRelatedArticles()
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;
}
?>