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

@ -4,30 +4,30 @@ if ( !defined( 'MEDIAWIKI' ) ) {
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';
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,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");
@ -82,14 +77,13 @@ class RelatedArticles
#
# Fill the RelatedArticles array.
#
$ra = $wgCustomData->getPageData( $wgOut, 'RelatedArticles');
foreach( $ra as $l)
{
$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,49 +116,44 @@ 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 )
{ ?>
$ra = $wgCustomData->getSkinData( $skTemplate, 'RelatedArticles' );
if ( $ra ) {
?>
</ul>
</div>
</div>
<div id="p-lang" class="portal">
<h5><?php $skTemplate->msg('ra-RelatedArticles') ?></h5>
<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;
}
};
}
function wfSetupRelatedArticles()
{
function wfSetupRelatedArticles() {
global $wgParser, $wgHooks;
global $wgRelatedArticles;
$wgRelatedArticles = new RelatedArticles;
$wgParser->setFunctionHook( 'related', array( &$wgRelatedArticles, 'onFuncRelated' ));
$wgParser->setFunctionHook( 'related', array( &$wgRelatedArticles, 'onFuncRelated' ) );
$wgHooks['SkinTemplateToolboxEnd'][] =
array( &$wgRelatedArticles, 'onSkinTemplateToolboxEnd' );
@ -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;
}
?>