http://www.mediawiki.org/wiki/Special:Code/MediaWiki/89895
Revision: 89895 Author: foxtrott Date: 2011-06-11 21:38:48 +0000 (Sat, 11 Jun 2011) Log Message: ----------- * followup r89860: magic word renamed and internationalized * fixes (magic word registration, loading css and js, return ParserOutput as error message) Modified Paths: -------------- trunk/extensions/Lingo/Lingo.i18n.php trunk/extensions/Lingo/Lingo.php trunk/extensions/Lingo/LingoHooks.php trunk/extensions/Lingo/LingoMessageLog.php trunk/extensions/Lingo/LingoParser.php Modified: trunk/extensions/Lingo/Lingo.i18n.php =================================================================== --- trunk/extensions/Lingo/Lingo.i18n.php 2011-06-11 21:10:26 UTC (rev 89894) +++ trunk/extensions/Lingo/Lingo.i18n.php 2011-06-11 21:38:48 UTC (rev 89895) @@ -13,13 +13,14 @@ 'lingo-terminologypagename' => 'Terminology', 'lingo-noterminologypage' => "Page '$1' does not exist.", 'lingo-terminologypagenotlocal' => "Page '$1' is not a local page.", - + 'lingo-noglossary' => 'NOGLOSSARY', ); /** Message documentation (Message documentation) */ $messages['qqq'] = array( 'lingo-desc' => '{{desc}}', 'lingo-terminologypagename' => 'Name of the page where the terms and definitions of the glossary are stored', + 'lingo-noglossary' => 'The magic word which will suppress the application of the glossary for a page.', ); /** Belarusian (Taraškievica orthography) (Беларуская (тарашкевіца)) @@ -41,6 +42,7 @@ 'lingo-terminologypagename' => 'Glossar', 'lingo-noterminologypage' => 'Seite „$1“ ist nicht vorhanden.', 'lingo-terminologypagenotlocal' => 'Seite „$1“ befindet sich nicht auf diesem Wiki.', + 'lingo-noglossary' => 'KEIN_GLOSSAR', ); /** French (Français) Modified: trunk/extensions/Lingo/Lingo.php =================================================================== --- trunk/extensions/Lingo/Lingo.php 2011-06-11 21:10:26 UTC (rev 89894) +++ trunk/extensions/Lingo/Lingo.php 2011-06-11 21:38:48 UTC (rev 89895) @@ -47,7 +47,7 @@ // register hook handlers $wgHooks['SpecialVersionExtensionTypes'][] = 'LingoHooks::setCredits'; // set credits $wgHooks['ParserAfterTidy'][] = 'LingoHooks::parse'; // parse page -$wgHooks['ParserFirstCallInit'][] = 'LingoHooks::setup'; // do late setup +//$wgHooks['ParserFirstCallInit'][] = 'LingoHooks::setup'; // do late setup $wgHooks['LanguageGetMagic'][] = 'LingoHooks::setMagicWords'; // set magic words // register resource modules with the Resource Loader @@ -69,5 +69,7 @@ // 'dependencies' => array( 'jquery.ui.datepicker' ), ); +MagicWord::$mDoubleUnderscoreIDs[] = 'noglossary'; + unset( $dir ); Modified: trunk/extensions/Lingo/LingoHooks.php =================================================================== --- trunk/extensions/Lingo/LingoHooks.php 2011-06-11 21:10:26 UTC (rev 89894) +++ trunk/extensions/Lingo/LingoHooks.php 2011-06-11 21:38:48 UTC (rev 89895) @@ -18,21 +18,14 @@ */ class LingoHooks { - static function setup( &$parser ) { - # Set a function hook associating the "noglossary" with fnLingoNoGlossary - MagicWord::getDoubleUnderscoreArray()->add( 'nolingo' ); - return true; - } - static function setMagicWords( &$magicWords, $langCode ) { - # Add the magic word - $magicWords['nolingo'] = array( 0, '__nolingo__' ); + $magicWords['noglossary'] = array( 0, '__NOGLOSSARY__', '__' . wfMsgGetKey( 'lingo-noglossary', true, $langCode ) . '__' ); return true; } static function parse( &$parser, &$text ) { - if ( !isset( $parser->mDoubleUnderscores['nolingo'] ) ) { + if ( !isset( $parser->mDoubleUnderscores['noglossary'] ) ) { LingoParser::parse( $parser, $text ); } Modified: trunk/extensions/Lingo/LingoMessageLog.php =================================================================== --- trunk/extensions/Lingo/LingoMessageLog.php 2011-06-11 21:10:26 UTC (rev 89894) +++ trunk/extensions/Lingo/LingoMessageLog.php 2011-06-11 21:38:48 UTC (rev 89895) @@ -75,9 +75,13 @@ } $ret = Html::rawElement( 'div', array('class' => 'messages'), - $header . - $parser->parse( $ret, $wgTitle, ParserOptions::newFromUser( $wgUser ) )->getText() + $header . "\n" . + $ret ); + + $ret = $parser->parse( $ret, $wgTitle, ParserOptions::newFromUser( $wgUser ) ); + } else { + $ret = null; } return $ret; Modified: trunk/extensions/Lingo/LingoParser.php =================================================================== --- trunk/extensions/Lingo/LingoParser.php 2011-06-11 21:10:26 UTC (rev 89894) +++ trunk/extensions/Lingo/LingoParser.php 2011-06-11 21:38:48 UTC (rev 89895) @@ -265,19 +265,20 @@ } protected function loadModules( &$parser ) { - global $wgOut, $wgScriptPath; + global $wgOut, $wgScriptPath, $wgParser; // load scripts if ( defined( 'MW_SUPPORTS_RESOURCE_MODULES' ) ) { - if ( !is_null( $parser ) && ( $wgOut->isArticle() ) ) { - $parser->getOutput()->addModules( 'ext.Lingo.Scripts' ); - } else { + $parser->getOutput()->addModules( 'ext.Lingo.Scripts' ); + if ( !$wgOut->isArticle() ) { $wgOut->addModules( 'ext.Lingo.Scripts' ); } } else { - if ( !is_null( $parser ) && ( $wgOut->isArticle() ) ) { - $parser->getOutput()->addHeadItem( "<script src='$wgScriptPath/extensions/Lingo/libs/Lingo.js'></script>\n", 'ext.Lingo.Scripts' ); - } else { + global $wgStylePath; + $parser->getOutput()->addHeadItem( "<script src='$wgStylePath/common/jquery.min.js'></script>\n", 'ext.Lingo.jq' ); + $parser->getOutput()->addHeadItem( "<script src='$wgScriptPath/extensions/Lingo/libs/Lingo.js'></script>\n", 'ext.Lingo.Scripts' ); + if ( !$wgOut->isArticle() ) { + $wgOut->addHeadItem( 'ext.Lingo.jq', "<script src='$wgStylePath/common/jquery.min.js'></script>\n" ); $wgOut->addHeadItem( 'ext.Lingo.Scripts', "<script src='$wgScriptPath/extensions/Lingo/libs/Lingo.js'></script>\n" ); } } @@ -287,15 +288,13 @@ // browsers. This doesn't make any sense for CSS-only modules that don't // need any JS. -> Use ResourceLoader if and when Bug 29308 gets fixed. // if ( defined( 'MW_SUPPORTS_RESOURCE_MODULES' ) ) { -// if ( !is_null( $parser ) && ( $wgOut->isArticle() ) ) { -// $parser->getOutput()->addModules( 'ext.Lingo.Styles' ); -// } else { +// $parser->getOutput()->addModules( 'ext.Lingo.Styles' ); +// if ( !$wgOut->isArticle() ) { // $wgOut->addModules( 'ext.Lingo.Styles' ); // } // } else { - if ( !is_null( $parser ) && ( $wgOut->isArticle() ) ) { - $parser->getOutput()->addHeadItem( "<link rel='stylesheet' href='$wgScriptPath/extensions/Lingo/skins/Lingo.css' />\n", 'ext.Lingo.Styles' ); - } else { + $parser->getOutput()->addHeadItem( "<link rel='stylesheet' href='$wgScriptPath/extensions/Lingo/skins/Lingo.css' />\n", 'ext.Lingo.Styles' ); + if ( !$wgOut->isArticle() ) { $wgOut->addHeadItem( 'ext.Lingo.Styles', "<link rel='stylesheet' href='$wgScriptPath/extensions/Lingo/skins/Lingo.css' />\n" ); } // } _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs