http://www.mediawiki.org/wiki/Special:Code/MediaWiki/89860

Revision: 89860
Author:   foxtrott
Date:     2011-06-10 23:16:44 +0000 (Fri, 10 Jun 2011)
Log Message:
-----------
new magic word nolingo, move hook handlers into separate file, fix some messages

Modified Paths:
--------------
    trunk/extensions/Lingo/Lingo.i18n.php
    trunk/extensions/Lingo/Lingo.php

Added Paths:
-----------
    trunk/extensions/Lingo/LingoHooks.php

Modified: trunk/extensions/Lingo/Lingo.i18n.php
===================================================================
--- trunk/extensions/Lingo/Lingo.i18n.php       2011-06-10 23:14:51 UTC (rev 
89859)
+++ trunk/extensions/Lingo/Lingo.i18n.php       2011-06-10 23:16:44 UTC (rev 
89860)
@@ -37,7 +37,7 @@
  * @author Kghbln
  */
 $messages['de'] = array(
-       'lingo-desc' => 'Ermöglicht Informationstexte die eingeblendet werden, 
sobald man mit der Maus über einen auf der Seite [[$1]] hinterlegten Begriff 
führt',
+       'lingo-desc' => 'Ermöglicht Informationstexte, die eingeblendet werden, 
sobald man die Maus über einen auf der Seite [[$1]] hinterlegten Begriff führt',
        'lingo-terminologypagename' => 'Glossar',
        'lingo-noterminologypage' => 'Seite „$1“ ist nicht vorhanden.',
        'lingo-terminologypagenotlocal' => 'Seite „$1“ befindet sich nicht auf 
diesem Wiki.',
@@ -47,7 +47,7 @@
  * @author Sherbrooke
  */
 $messages['fr'] = array(
-       'lingo-desc' => 'Dans les pages, affiche une info-bulle si le mot est 
défini dans la page de [[Terminology|Terminologie]].',
+       'lingo-desc' => 'Dans les pages, affiche une info-bulle si le mot est 
défini dans la page de [[$1]].',
 );
 
 /** Galician (Galego)
@@ -64,7 +64,7 @@
  * @author Bjankuloski06
  */
 $messages['mk'] = array(
-       'lingo-desc' => 'Овозможува описи при лебдење над алатките на 
страниците (од зборови со утврдени значења на страницата 
[[Terminology|Терминологија]])',
+       'lingo-desc' => 'Овозможува описи при лебдење над алатките на 
страниците (од зборови со утврдени значења на страницата [[$1]])',
        'lingo-terminologypagename' => 'Терминологија',
        'lingo-noterminologypage' => 'Страницата „$1“ не постои.',
        'lingo-terminologypagenotlocal' => 'Страницата „$1“ не е локална 
страница.',
@@ -84,7 +84,7 @@
  * @author Hamilton Abreu
  */
 $messages['pt'] = array(
-       'lingo-desc' => 'Permite que a passagem do ponteiro do rato sobre 
palavras nas páginas, resulte no aparecimento de uma legenda. As palavras são 
definidas na página [[Terminology]].',
+       'lingo-desc' => 'Permite que a passagem do ponteiro do rato sobre 
palavras nas páginas, resulte no aparecimento de uma legenda. As palavras são 
definidas na página [[$1]].',
        'lingo-terminologypagename' => 'Terminology',
        'lingo-noterminologypage' => "A página '$1' não existe.",
        'lingo-terminologypagenotlocal' => "A página '$1' não é uma página 
local.",
@@ -94,6 +94,6 @@
  * @author Александр Сигачёв
  */
 $messages['ru'] = array(
-       'lingo-desc' => 'Показывает всплывающую подсказку при наведении на 
слово, присутствующее на странице [[Terminology]]',
+       'lingo-desc' => 'Показывает всплывающую подсказку при наведении на 
слово, присутствующее на странице [[$1]]',
 );
 

Modified: trunk/extensions/Lingo/Lingo.php
===================================================================
--- trunk/extensions/Lingo/Lingo.php    2011-06-10 23:14:51 UTC (rev 89859)
+++ trunk/extensions/Lingo/Lingo.php    2011-06-10 23:16:44 UTC (rev 89860)
@@ -19,9 +19,10 @@
 
 define( 'LINGO_VERSION', '0.2 alpha' );
 
+
 // set defaults for settings
 
-// set LingoBasicBackend as the backend to access the glossary
+// set the backend to access the glossary
 $wgexLingoBackend = 'LingoBasicBackend';
 
 // set default for Terminology page (null = take from i18n)
@@ -32,23 +33,25 @@
 $dir = dirname( __FILE__ );
 
 // register message file
-$wgExtensionMessagesFiles[ 'Lingo' ] = $dir . '/Lingo.i18n.php';
-// $wgExtensionMessagesFiles['LingoAlias'] = $dir . '/Lingo.alias.php';
+$wgExtensionMessagesFiles['Lingo'] = $dir . '/Lingo.i18n.php';
+
 // register class files with the Autoloader
-// $wgAutoloadClasses['LingoSettings'] = $dir . '/LingoSettings.php';
-$wgAutoloadClasses[ 'LingoParser' ] = $dir . '/LingoParser.php';
-$wgAutoloadClasses[ 'LingoTree' ] = $dir . '/LingoTree.php';
-$wgAutoloadClasses[ 'LingoElement' ] = $dir . '/LingoElement.php';
-$wgAutoloadClasses[ 'LingoBackend' ] = $dir . '/LingoBackend.php';
-$wgAutoloadClasses[ 'LingoBasicBackend' ] = $dir . '/LingoBasicBackend.php';
-$wgAutoloadClasses[ 'LingoMessageLog' ] = $dir . '/LingoMessageLog.php';
-// $wgAutoloadClasses['SpecialLingoBrowser'] = $dir . 
'/SpecialLingoBrowser.php';
+$wgAutoloadClasses['LingoHooks'] = $dir . '/LingoHooks.php';
+$wgAutoloadClasses['LingoParser'] = $dir . '/LingoParser.php';
+$wgAutoloadClasses['LingoTree'] = $dir . '/LingoTree.php';
+$wgAutoloadClasses['LingoElement'] = $dir . '/LingoElement.php';
+$wgAutoloadClasses['LingoBackend'] = $dir . '/LingoBackend.php';
+$wgAutoloadClasses['LingoBasicBackend'] = $dir . '/LingoBasicBackend.php';
+$wgAutoloadClasses['LingoMessageLog'] = $dir . '/LingoMessageLog.php';
 
-$wgHooks[ 'SpecialVersionExtensionTypes' ][ ] = 'fnLingoSetCredits';
-$wgHooks[ 'ParserAfterTidy' ][ ] = 'LingoParser::parse';
+// register hook handlers
+$wgHooks['SpecialVersionExtensionTypes'][] = 'LingoHooks::setCredits'; // set 
credits
+$wgHooks['ParserAfterTidy'][] = 'LingoHooks::parse'; // parse page
+$wgHooks['ParserFirstCallInit'][] = 'LingoHooks::setup'; // do late setup
+$wgHooks['LanguageGetMagic'][] = 'LingoHooks::setMagicWords'; // set magic 
words
 
 // register resource modules with the Resource Loader
-$wgResourceModules[ 'ext.Lingo.Styles' ] = array(
+$wgResourceModules['ext.Lingo.Styles'] = array(
        'localBasePath' => $dir,
        'remoteExtPath' => 'Lingo',
        // 'scripts' => 'libs/ext.myExtension.js',
@@ -57,7 +60,7 @@
        // 'dependencies' => array( 'jquery.ui.datepicker' ),
 );
 
-$wgResourceModules[ 'ext.Lingo.Scripts' ] = array(
+$wgResourceModules['ext.Lingo.Scripts'] = array(
        'localBasePath' => $dir,
        'remoteExtPath' => 'Lingo',
        'scripts' => 'libs/Lingo.js',
@@ -66,29 +69,5 @@
        // 'dependencies' => array( 'jquery.ui.datepicker' ),
 );
 
-unset ($dir);
+unset( $dir );
 
-/**
- * Deferred setting of extension credits
- * 
- * Setting of extension credits has to be deferred to the
- * SpecialVersionExtensionTypes hook as it uses variable $wgexLingoPage (which
- * might be set only after inclusion of the extension in LocalSettings) and
- * function wfMsg not available before.
- * 
- * @return Boolean Always true.
- */
-function fnLingoSetCredits() {
-       
-       global $wgExtensionCredits, $wgexLingoPage;
-       $wgExtensionCredits[ 'parserhook' ][ ] = array(
-               'path' => __FILE__,
-               'name' => 'Lingo',
-               'author' => array( 'Barry Coughlan', 
'[http://www.mediawiki.org/wiki/User:F.trott Stephan Gambke]' ),
-               'url' => 'http://www.mediawiki.org/wiki/Extension:Lingo',
-               'descriptionmsg' => array('lingo-desc', $wgexLingoPage ? 
$wgexLingoPage : wfMsgForContent( 'lingo-terminologypagename' )),
-               'version' => LINGO_VERSION,
-       );
-
-       return true;
-}

Added: trunk/extensions/Lingo/LingoHooks.php
===================================================================
--- trunk/extensions/Lingo/LingoHooks.php                               (rev 0)
+++ trunk/extensions/Lingo/LingoHooks.php       2011-06-10 23:16:44 UTC (rev 
89860)
@@ -0,0 +1,68 @@
+<?php
+
+/**
+ * File holding the LingoHooks class
+ *
+ * @author Stephan Gambke
+ * @file
+ * @ingroup Lingo
+ */
+if ( !defined( 'LINGO_VERSION' ) ) {
+       die( 'This file is part of the Lingo extension, it is not a valid entry 
point.' );
+}
+
+/**
+ * The LingoHooks class.
+ *
+ * @ingroup Lingo
+ */
+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__' );
+               return true;
+       }
+
+       static function parse( &$parser, &$text ) {
+
+               if ( !isset( $parser->mDoubleUnderscores['nolingo'] ) ) {
+                       LingoParser::parse( $parser, $text );
+               }
+
+               return true;
+       }
+
+       /**
+        * Deferred setting of extension credits
+        *
+        * Setting of extension credits has to be deferred to the
+        * SpecialVersionExtensionTypes hook as it uses variable $wgexLingoPage 
(which
+        * might be set only after inclusion of the extension in LocalSettings) 
and
+        * function wfMsg not available before.
+        *
+        * @return Boolean Always true.
+        */
+       static function setCredits() {
+
+               global $wgExtensionCredits, $wgexLingoPage;
+               $wgExtensionCredits['parserhook'][] = array(
+                       'path' => __FILE__,
+                       'name' => 'Lingo',
+                       'author' => array( 'Barry Coughlan', 
'[http://www.mediawiki.org/wiki/User:F.trott Stephan Gambke]' ),
+                       'url' => 
'http://www.mediawiki.org/wiki/Extension:Lingo',
+                       'descriptionmsg' => array( 'lingo-desc', $wgexLingoPage 
? $wgexLingoPage : wfMsgForContent( 'lingo-terminologypagename' ) ),
+                       'version' => LINGO_VERSION,
+               );
+
+               return true;
+       }
+
+}
+


Property changes on: trunk/extensions/Lingo/LingoHooks.php
___________________________________________________________________
Added: svn:eol-style
   + native


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to