http://www.mediawiki.org/wiki/Special:Code/MediaWiki/89977
Revision: 89977
Author: foxtrott
Date: 2011-06-13 16:26:56 +0000 (Mon, 13 Jun 2011)
Log Message:
-----------
* followup r89895: make magic words localisation look common
* fix (extension credits not shown if Lingo is only extension (ha, as if))
* new setting $wgexLingoDisplayOnce
Modified Paths:
--------------
trunk/extensions/Lingo/Lingo.i18n.php
trunk/extensions/Lingo/Lingo.php
trunk/extensions/Lingo/LingoElement.php
trunk/extensions/Lingo/LingoHooks.php
Added Paths:
-----------
trunk/extensions/Lingo/Lingo.i18n.magic.php
Added: trunk/extensions/Lingo/Lingo.i18n.magic.php
===================================================================
--- trunk/extensions/Lingo/Lingo.i18n.magic.php (rev 0)
+++ trunk/extensions/Lingo/Lingo.i18n.magic.php 2011-06-13 16:26:56 UTC (rev
89977)
@@ -0,0 +1,15 @@
+<?php
+
+$magicWords = array();
+
+/** English (English) */
+$magicWords['en'] = array(
+ 'noglossary' => array( 0, '__NOGLOSSARY__' ),
+);
+
+/** German (Deutsch) */
+$magicWords['en'] = array(
+ 'noglossary' => array( 0, '__KEIN_GLOSSAR__', '__NOGLOSSARY__' ),
+);
+
+
Property changes on: trunk/extensions/Lingo/Lingo.i18n.magic.php
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: trunk/extensions/Lingo/Lingo.i18n.php
===================================================================
--- trunk/extensions/Lingo/Lingo.i18n.php 2011-06-13 16:23:23 UTC (rev
89976)
+++ trunk/extensions/Lingo/Lingo.i18n.php 2011-06-13 16:26:56 UTC (rev
89977)
@@ -13,14 +13,12 @@
'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) (Беларуская (тарашкевіца))
@@ -42,7 +40,6 @@
'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-13 16:23:23 UTC (rev 89976)
+++ trunk/extensions/Lingo/Lingo.php 2011-06-13 16:26:56 UTC (rev 89977)
@@ -28,12 +28,26 @@
// set default for Terminology page (null = take from i18n)
$wgexLingoPage = null;
+// set if glossary terms are to be marked up once or always
+$wgexLingoDisplayOnce = false;
+
+// set extension credits
+// (no description here, will be set later)
+$wgExtensionCredits['parserhook']['lingo'] = 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',
+ 'version' => LINGO_VERSION,
+);
+
// server-local path to this file
$dir = dirname( __FILE__ );
-// register message file
+// register message files
$wgExtensionMessagesFiles['Lingo'] = $dir . '/Lingo.i18n.php';
+$wgExtensionMessagesFiles['LingoMagic'] = $dir . '/Lingo.i18n.magic.php';
// register class files with the Autoloader
$wgAutoloadClasses['LingoHooks'] = $dir . '/LingoHooks.php';
@@ -47,8 +61,6 @@
// 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(
Modified: trunk/extensions/Lingo/LingoElement.php
===================================================================
--- trunk/extensions/Lingo/LingoElement.php 2011-06-13 16:23:23 UTC (rev
89976)
+++ trunk/extensions/Lingo/LingoElement.php 2011-06-13 16:26:56 UTC (rev
89977)
@@ -27,6 +27,8 @@
private $mFullDefinition = null;
private $mDefinitions = array();
private $mTerm = null;
+ private $mHasBeenDisplayed = false;
+
static private $mLinkTemplate = null;
public function __construct( &$term, &$definition = null ) {
@@ -43,6 +45,14 @@
}
public function getFullDefinition( DOMDocument &$doc ) {
+
+ global $wgexLingoDisplayOnce;
+
+ // return textnode if
+ if ( $wgexLingoDisplayOnce && $this->mHasBeenDisplayed ) {
+ return $doc->createTextNode($this->mTerm);
+ }
+
// only create if not yet created
if ( $this->mFullDefinition == null ||
$this->mFullDefinition->ownerDocument !== $doc ) {
@@ -84,6 +94,7 @@
$spanDefinitionOuter->appendChild( $spanDefinitionInner
);
$this->mFullDefinition = $span;
+ $this->mHasBeenDisplayed = true;
}
return $this->mFullDefinition->cloneNode( true );
Modified: trunk/extensions/Lingo/LingoHooks.php
===================================================================
--- trunk/extensions/Lingo/LingoHooks.php 2011-06-13 16:23:23 UTC (rev
89976)
+++ trunk/extensions/Lingo/LingoHooks.php 2011-06-13 16:26:56 UTC (rev
89977)
@@ -18,11 +18,6 @@
*/
class LingoHooks {
- static function setMagicWords( &$magicWords, $langCode ) {
- $magicWords['noglossary'] = array( 0, '__NOGLOSSARY__', '__' .
wfMsgGetKey( 'lingo-noglossary', true, $langCode ) . '__' );
- return true;
- }
-
static function parse( &$parser, &$text ) {
if ( !isset( $parser->mDoubleUnderscores['noglossary'] ) ) {
@@ -33,9 +28,9 @@
}
/**
- * Deferred setting of extension credits
+ * Deferred setting of description in extension credits
*
- * Setting of extension credits has to be deferred to the
+ * Setting of description in 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.
@@ -45,14 +40,8 @@
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,
- );
+ $wgExtensionCredits['parserhook']['lingo']['description'] =
+ wfMsg( 'lingo-desc', $wgexLingoPage ? $wgexLingoPage :
wfMsgForContent( 'lingo-terminologypagename' ) );
return true;
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs