Index: trunk/extensions/Lingo/LingoHooks.php |
— | — | @@ -18,11 +18,6 @@ |
19 | 19 | */ |
20 | 20 | class LingoHooks { |
21 | 21 | |
22 | | - static function setMagicWords( &$magicWords, $langCode ) { |
23 | | - $magicWords['noglossary'] = array( 0, '__NOGLOSSARY__', '__' . wfMsgGetKey( 'lingo-noglossary', true, $langCode ) . '__' ); |
24 | | - return true; |
25 | | - } |
26 | | - |
27 | 22 | static function parse( &$parser, &$text ) { |
28 | 23 | |
29 | 24 | if ( !isset( $parser->mDoubleUnderscores['noglossary'] ) ) { |
— | — | @@ -33,9 +28,9 @@ |
34 | 29 | } |
35 | 30 | |
36 | 31 | /** |
37 | | - * Deferred setting of extension credits |
| 32 | + * Deferred setting of description in extension credits |
38 | 33 | * |
39 | | - * Setting of extension credits has to be deferred to the |
| 34 | + * Setting of description in extension credits has to be deferred to the |
40 | 35 | * SpecialVersionExtensionTypes hook as it uses variable $wgexLingoPage (which |
41 | 36 | * might be set only after inclusion of the extension in LocalSettings) and |
42 | 37 | * function wfMsg not available before. |
— | — | @@ -45,14 +40,8 @@ |
46 | 41 | static function setCredits() { |
47 | 42 | |
48 | 43 | global $wgExtensionCredits, $wgexLingoPage; |
49 | | - $wgExtensionCredits['parserhook'][] = array( |
50 | | - 'path' => __FILE__, |
51 | | - 'name' => 'Lingo', |
52 | | - 'author' => array( 'Barry Coughlan', '[http://www.mediawiki.org/wiki/User:F.trott Stephan Gambke]' ), |
53 | | - 'url' => 'http://www.mediawiki.org/wiki/Extension:Lingo', |
54 | | - 'descriptionmsg' => array( 'lingo-desc', $wgexLingoPage ? $wgexLingoPage : wfMsgForContent( 'lingo-terminologypagename' ) ), |
55 | | - 'version' => LINGO_VERSION, |
56 | | - ); |
| 44 | + $wgExtensionCredits['parserhook']['lingo']['description'] = |
| 45 | + wfMsg( 'lingo-desc', $wgexLingoPage ? $wgexLingoPage : wfMsgForContent( 'lingo-terminologypagename' ) ); |
57 | 46 | |
58 | 47 | return true; |
59 | 48 | } |
Index: trunk/extensions/Lingo/LingoElement.php |
— | — | @@ -27,6 +27,8 @@ |
28 | 28 | private $mFullDefinition = null; |
29 | 29 | private $mDefinitions = array(); |
30 | 30 | private $mTerm = null; |
| 31 | + private $mHasBeenDisplayed = false; |
| 32 | + |
31 | 33 | static private $mLinkTemplate = null; |
32 | 34 | |
33 | 35 | public function __construct( &$term, &$definition = null ) { |
— | — | @@ -43,6 +45,14 @@ |
44 | 46 | } |
45 | 47 | |
46 | 48 | public function getFullDefinition( DOMDocument &$doc ) { |
| 49 | + |
| 50 | + global $wgexLingoDisplayOnce; |
| 51 | + |
| 52 | + // return textnode if |
| 53 | + if ( $wgexLingoDisplayOnce && $this->mHasBeenDisplayed ) { |
| 54 | + return $doc->createTextNode($this->mTerm); |
| 55 | + } |
| 56 | + |
47 | 57 | // only create if not yet created |
48 | 58 | if ( $this->mFullDefinition == null || $this->mFullDefinition->ownerDocument !== $doc ) { |
49 | 59 | |
— | — | @@ -84,6 +94,7 @@ |
85 | 95 | $spanDefinitionOuter->appendChild( $spanDefinitionInner ); |
86 | 96 | |
87 | 97 | $this->mFullDefinition = $span; |
| 98 | + $this->mHasBeenDisplayed = true; |
88 | 99 | } |
89 | 100 | |
90 | 101 | return $this->mFullDefinition->cloneNode( true ); |
Index: trunk/extensions/Lingo/Lingo.i18n.magic.php |
— | — | @@ -0,0 +1,15 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +$magicWords = array(); |
| 5 | + |
| 6 | +/** English (English) */ |
| 7 | +$magicWords['en'] = array( |
| 8 | + 'noglossary' => array( 0, '__NOGLOSSARY__' ), |
| 9 | +); |
| 10 | + |
| 11 | +/** German (Deutsch) */ |
| 12 | +$magicWords['en'] = array( |
| 13 | + 'noglossary' => array( 0, '__KEIN_GLOSSAR__', '__NOGLOSSARY__' ), |
| 14 | +); |
| 15 | + |
| 16 | + |
Property changes on: trunk/extensions/Lingo/Lingo.i18n.magic.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 17 | + native |
Index: trunk/extensions/Lingo/Lingo.i18n.php |
— | — | @@ -13,14 +13,12 @@ |
14 | 14 | 'lingo-terminologypagename' => 'Terminology', |
15 | 15 | 'lingo-noterminologypage' => "Page '$1' does not exist.", |
16 | 16 | 'lingo-terminologypagenotlocal' => "Page '$1' is not a local page.", |
17 | | - 'lingo-noglossary' => 'NOGLOSSARY', |
18 | 17 | ); |
19 | 18 | |
20 | 19 | /** Message documentation (Message documentation) */ |
21 | 20 | $messages['qqq'] = array( |
22 | 21 | 'lingo-desc' => '{{desc}}', |
23 | 22 | 'lingo-terminologypagename' => 'Name of the page where the terms and definitions of the glossary are stored', |
24 | | - 'lingo-noglossary' => 'The magic word which will suppress the application of the glossary for a page.', |
25 | 23 | ); |
26 | 24 | |
27 | 25 | /** Belarusian (Taraškievica orthography) (Беларуская (тарашкевіца)) |
— | — | @@ -42,7 +40,6 @@ |
43 | 41 | 'lingo-terminologypagename' => 'Glossar', |
44 | 42 | 'lingo-noterminologypage' => 'Seite „$1“ ist nicht vorhanden.', |
45 | 43 | 'lingo-terminologypagenotlocal' => 'Seite „$1“ befindet sich nicht auf diesem Wiki.', |
46 | | - 'lingo-noglossary' => 'KEIN_GLOSSAR', |
47 | 44 | ); |
48 | 45 | |
49 | 46 | /** French (Français) |
Index: trunk/extensions/Lingo/Lingo.php |
— | — | @@ -28,12 +28,26 @@ |
29 | 29 | // set default for Terminology page (null = take from i18n) |
30 | 30 | $wgexLingoPage = null; |
31 | 31 | |
| 32 | +// set if glossary terms are to be marked up once or always |
| 33 | +$wgexLingoDisplayOnce = false; |
32 | 34 | |
| 35 | + |
| 36 | +// set extension credits |
| 37 | +// (no description here, will be set later) |
| 38 | +$wgExtensionCredits['parserhook']['lingo'] = array( |
| 39 | + 'path' => __FILE__, |
| 40 | + 'name' => 'Lingo', |
| 41 | + 'author' => array('Barry Coughlan', '[http://www.mediawiki.org/wiki/User:F.trott Stephan Gambke]'), |
| 42 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:Lingo', |
| 43 | + 'version' => LINGO_VERSION, |
| 44 | +); |
| 45 | + |
33 | 46 | // server-local path to this file |
34 | 47 | $dir = dirname( __FILE__ ); |
35 | 48 | |
36 | | -// register message file |
| 49 | +// register message files |
37 | 50 | $wgExtensionMessagesFiles['Lingo'] = $dir . '/Lingo.i18n.php'; |
| 51 | +$wgExtensionMessagesFiles['LingoMagic'] = $dir . '/Lingo.i18n.magic.php'; |
38 | 52 | |
39 | 53 | // register class files with the Autoloader |
40 | 54 | $wgAutoloadClasses['LingoHooks'] = $dir . '/LingoHooks.php'; |
— | — | @@ -47,8 +61,6 @@ |
48 | 62 | // register hook handlers |
49 | 63 | $wgHooks['SpecialVersionExtensionTypes'][] = 'LingoHooks::setCredits'; // set credits |
50 | 64 | $wgHooks['ParserAfterTidy'][] = 'LingoHooks::parse'; // parse page |
51 | | -//$wgHooks['ParserFirstCallInit'][] = 'LingoHooks::setup'; // do late setup |
52 | | -$wgHooks['LanguageGetMagic'][] = 'LingoHooks::setMagicWords'; // set magic words |
53 | 65 | |
54 | 66 | // register resource modules with the Resource Loader |
55 | 67 | $wgResourceModules['ext.Lingo.Styles'] = array( |