r89860 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89859‎ | r89860 | r89861 >
Date:23:16, 10 June 2011
Author:foxtrott
Status:deferred
Tags:
Comment:
new magic word nolingo, move hook handlers into separate file, fix some messages
Modified paths:
  • /trunk/extensions/Lingo/Lingo.i18n.php (modified) (history)
  • /trunk/extensions/Lingo/Lingo.php (modified) (history)
  • /trunk/extensions/Lingo/LingoHooks.php (added) (history)

Diff [purge]

Index: trunk/extensions/Lingo/LingoHooks.php
@@ -0,0 +1,68 @@
 2+<?php
 3+
 4+/**
 5+ * File holding the LingoHooks class
 6+ *
 7+ * @author Stephan Gambke
 8+ * @file
 9+ * @ingroup Lingo
 10+ */
 11+if ( !defined( 'LINGO_VERSION' ) ) {
 12+ die( 'This file is part of the Lingo extension, it is not a valid entry point.' );
 13+}
 14+
 15+/**
 16+ * The LingoHooks class.
 17+ *
 18+ * @ingroup Lingo
 19+ */
 20+class LingoHooks {
 21+
 22+ static function setup( &$parser ) {
 23+ # Set a function hook associating the "noglossary" with fnLingoNoGlossary
 24+ MagicWord::getDoubleUnderscoreArray()->add( 'nolingo' );
 25+ return true;
 26+ }
 27+
 28+ static function setMagicWords( &$magicWords, $langCode ) {
 29+ # Add the magic word
 30+ $magicWords['nolingo'] = array( 0, '__nolingo__' );
 31+ return true;
 32+ }
 33+
 34+ static function parse( &$parser, &$text ) {
 35+
 36+ if ( !isset( $parser->mDoubleUnderscores['nolingo'] ) ) {
 37+ LingoParser::parse( $parser, $text );
 38+ }
 39+
 40+ return true;
 41+ }
 42+
 43+ /**
 44+ * Deferred setting of extension credits
 45+ *
 46+ * Setting of extension credits has to be deferred to the
 47+ * SpecialVersionExtensionTypes hook as it uses variable $wgexLingoPage (which
 48+ * might be set only after inclusion of the extension in LocalSettings) and
 49+ * function wfMsg not available before.
 50+ *
 51+ * @return Boolean Always true.
 52+ */
 53+ static function setCredits() {
 54+
 55+ global $wgExtensionCredits, $wgexLingoPage;
 56+ $wgExtensionCredits['parserhook'][] = array(
 57+ 'path' => __FILE__,
 58+ 'name' => 'Lingo',
 59+ 'author' => array( 'Barry Coughlan', '[http://www.mediawiki.org/wiki/User:F.trott Stephan Gambke]' ),
 60+ 'url' => 'http://www.mediawiki.org/wiki/Extension:Lingo',
 61+ 'descriptionmsg' => array( 'lingo-desc', $wgexLingoPage ? $wgexLingoPage : wfMsgForContent( 'lingo-terminologypagename' ) ),
 62+ 'version' => LINGO_VERSION,
 63+ );
 64+
 65+ return true;
 66+ }
 67+
 68+}
 69+
Property changes on: trunk/extensions/Lingo/LingoHooks.php
___________________________________________________________________
Added: svn:eol-style
170 + native
Index: trunk/extensions/Lingo/Lingo.i18n.php
@@ -37,7 +37,7 @@
3838 * @author Kghbln
3939 */
4040 $messages['de'] = array(
41 - 'lingo-desc' => 'Ermöglicht Informationstexte die eingeblendet werden, sobald man mit der Maus über einen auf der Seite [[$1]] hinterlegten Begriff führt',
 41+ 'lingo-desc' => 'Ermöglicht Informationstexte, die eingeblendet werden, sobald man die Maus über einen auf der Seite [[$1]] hinterlegten Begriff führt',
4242 'lingo-terminologypagename' => 'Glossar',
4343 'lingo-noterminologypage' => 'Seite „$1“ ist nicht vorhanden.',
4444 'lingo-terminologypagenotlocal' => 'Seite „$1“ befindet sich nicht auf diesem Wiki.',
@@ -47,7 +47,7 @@
4848 * @author Sherbrooke
4949 */
5050 $messages['fr'] = array(
51 - 'lingo-desc' => 'Dans les pages, affiche une info-bulle si le mot est défini dans la page de [[Terminology|Terminologie]].',
 51+ 'lingo-desc' => 'Dans les pages, affiche une info-bulle si le mot est défini dans la page de [[$1]].',
5252 );
5353
5454 /** Galician (Galego)
@@ -64,7 +64,7 @@
6565 * @author Bjankuloski06
6666 */
6767 $messages['mk'] = array(
68 - 'lingo-desc' => 'Овозможува описи при лебдење над алатките на страниците (од зборови со утврдени значења на страницата [[Terminology|Терминологија]])',
 68+ 'lingo-desc' => 'Овозможува описи при лебдење над алатките на страниците (од зборови со утврдени значења на страницата [[$1]])',
6969 'lingo-terminologypagename' => 'Терминологија',
7070 'lingo-noterminologypage' => 'Страницата „$1“ не постои.',
7171 'lingo-terminologypagenotlocal' => 'Страницата „$1“ не е локална страница.',
@@ -84,7 +84,7 @@
8585 * @author Hamilton Abreu
8686 */
8787 $messages['pt'] = array(
88 - '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]].',
 88+ '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]].',
8989 'lingo-terminologypagename' => 'Terminology',
9090 'lingo-noterminologypage' => "A página '$1' não existe.",
9191 'lingo-terminologypagenotlocal' => "A página '$1' não é uma página local.",
@@ -94,6 +94,6 @@
9595 * @author Александр Сигачёв
9696 */
9797 $messages['ru'] = array(
98 - 'lingo-desc' => 'Показывает всплывающую подсказку при наведении на слово, присутствующее на странице [[Terminology]]',
 98+ 'lingo-desc' => 'Показывает всплывающую подсказку при наведении на слово, присутствующее на странице [[$1]]',
9999 );
100100
Index: trunk/extensions/Lingo/Lingo.php
@@ -19,9 +19,10 @@
2020
2121 define( 'LINGO_VERSION', '0.2 alpha' );
2222
 23+
2324 // set defaults for settings
2425
25 -// set LingoBasicBackend as the backend to access the glossary
 26+// set the backend to access the glossary
2627 $wgexLingoBackend = 'LingoBasicBackend';
2728
2829 // set default for Terminology page (null = take from i18n)
@@ -32,23 +33,25 @@
3334 $dir = dirname( __FILE__ );
3435
3536 // register message file
36 -$wgExtensionMessagesFiles[ 'Lingo' ] = $dir . '/Lingo.i18n.php';
37 -// $wgExtensionMessagesFiles['LingoAlias'] = $dir . '/Lingo.alias.php';
 37+$wgExtensionMessagesFiles['Lingo'] = $dir . '/Lingo.i18n.php';
 38+
3839 // register class files with the Autoloader
39 -// $wgAutoloadClasses['LingoSettings'] = $dir . '/LingoSettings.php';
40 -$wgAutoloadClasses[ 'LingoParser' ] = $dir . '/LingoParser.php';
41 -$wgAutoloadClasses[ 'LingoTree' ] = $dir . '/LingoTree.php';
42 -$wgAutoloadClasses[ 'LingoElement' ] = $dir . '/LingoElement.php';
43 -$wgAutoloadClasses[ 'LingoBackend' ] = $dir . '/LingoBackend.php';
44 -$wgAutoloadClasses[ 'LingoBasicBackend' ] = $dir . '/LingoBasicBackend.php';
45 -$wgAutoloadClasses[ 'LingoMessageLog' ] = $dir . '/LingoMessageLog.php';
46 -// $wgAutoloadClasses['SpecialLingoBrowser'] = $dir . '/SpecialLingoBrowser.php';
 40+$wgAutoloadClasses['LingoHooks'] = $dir . '/LingoHooks.php';
 41+$wgAutoloadClasses['LingoParser'] = $dir . '/LingoParser.php';
 42+$wgAutoloadClasses['LingoTree'] = $dir . '/LingoTree.php';
 43+$wgAutoloadClasses['LingoElement'] = $dir . '/LingoElement.php';
 44+$wgAutoloadClasses['LingoBackend'] = $dir . '/LingoBackend.php';
 45+$wgAutoloadClasses['LingoBasicBackend'] = $dir . '/LingoBasicBackend.php';
 46+$wgAutoloadClasses['LingoMessageLog'] = $dir . '/LingoMessageLog.php';
4747
48 -$wgHooks[ 'SpecialVersionExtensionTypes' ][ ] = 'fnLingoSetCredits';
49 -$wgHooks[ 'ParserAfterTidy' ][ ] = 'LingoParser::parse';
 48+// register hook handlers
 49+$wgHooks['SpecialVersionExtensionTypes'][] = 'LingoHooks::setCredits'; // set credits
 50+$wgHooks['ParserAfterTidy'][] = 'LingoHooks::parse'; // parse page
 51+$wgHooks['ParserFirstCallInit'][] = 'LingoHooks::setup'; // do late setup
 52+$wgHooks['LanguageGetMagic'][] = 'LingoHooks::setMagicWords'; // set magic words
5053
5154 // register resource modules with the Resource Loader
52 -$wgResourceModules[ 'ext.Lingo.Styles' ] = array(
 55+$wgResourceModules['ext.Lingo.Styles'] = array(
5356 'localBasePath' => $dir,
5457 'remoteExtPath' => 'Lingo',
5558 // 'scripts' => 'libs/ext.myExtension.js',
@@ -57,7 +60,7 @@
5861 // 'dependencies' => array( 'jquery.ui.datepicker' ),
5962 );
6063
61 -$wgResourceModules[ 'ext.Lingo.Scripts' ] = array(
 64+$wgResourceModules['ext.Lingo.Scripts'] = array(
6265 'localBasePath' => $dir,
6366 'remoteExtPath' => 'Lingo',
6467 'scripts' => 'libs/Lingo.js',
@@ -66,29 +69,5 @@
6770 // 'dependencies' => array( 'jquery.ui.datepicker' ),
6871 );
6972
70 -unset ($dir);
 73+unset( $dir );
7174
72 -/**
73 - * Deferred setting of extension credits
74 - *
75 - * Setting of extension credits has to be deferred to the
76 - * SpecialVersionExtensionTypes hook as it uses variable $wgexLingoPage (which
77 - * might be set only after inclusion of the extension in LocalSettings) and
78 - * function wfMsg not available before.
79 - *
80 - * @return Boolean Always true.
81 - */
82 -function fnLingoSetCredits() {
83 -
84 - global $wgExtensionCredits, $wgexLingoPage;
85 - $wgExtensionCredits[ 'parserhook' ][ ] = array(
86 - 'path' => __FILE__,
87 - 'name' => 'Lingo',
88 - 'author' => array( 'Barry Coughlan', '[http://www.mediawiki.org/wiki/User:F.trott Stephan Gambke]' ),
89 - 'url' => 'http://www.mediawiki.org/wiki/Extension:Lingo',
90 - 'descriptionmsg' => array('lingo-desc', $wgexLingoPage ? $wgexLingoPage : wfMsgForContent( 'lingo-terminologypagename' )),
91 - 'version' => LINGO_VERSION,
92 - );
93 -
94 - return true;
95 -}

Follow-up revisions

RevisionCommit summaryAuthorDate
r89895* followup r89860: magic word renamed and internationalized...foxtrott21:38, 11 June 2011

Status & tagging log