http://www.mediawiki.org/wiki/Special:Code/MediaWiki/89703
Revision: 89703
Author: foxtrott
Date: 2011-06-07 22:15:08 +0000 (Tue, 07 Jun 2011)
Log Message:
-----------
small fixes (creating new MessageLog if not provided, adding LingoTree getter,
disabling use of RL, comments)
Modified Paths:
--------------
trunk/extensions/Lingo/Lingo.i18n.php
trunk/extensions/Lingo/Lingo.php
trunk/extensions/Lingo/LingoBackend.php
trunk/extensions/Lingo/LingoBasicBackend.php
trunk/extensions/Lingo/LingoParser.php
trunk/extensions/Lingo/LingoTree.php
Modified: trunk/extensions/Lingo/Lingo.i18n.php
===================================================================
--- trunk/extensions/Lingo/Lingo.i18n.php 2011-06-07 21:59:06 UTC (rev
89702)
+++ trunk/extensions/Lingo/Lingo.i18n.php 2011-06-07 22:15:08 UTC (rev
89703)
@@ -3,7 +3,7 @@
* Internationalisation file for extension Lingo.
*
* @file
- * @ingroup Extensions
+ * @ingroup Lingo
*/
$messages = array();
@@ -12,3 +12,7 @@
'lingo-desc' => 'Provides hover-over tool tips on pages from words
defined on the [[Terminology]] page'
);
+$messages['qqq'] = array(
+ 'lingo-desc' => '{{desc}}'
+);
+
Modified: trunk/extensions/Lingo/Lingo.php
===================================================================
--- trunk/extensions/Lingo/Lingo.php 2011-06-07 21:59:06 UTC (rev 89702)
+++ trunk/extensions/Lingo/Lingo.php 2011-06-07 22:15:08 UTC (rev 89703)
@@ -53,9 +53,8 @@
// register resource modules with the Resource Loader
$wgResourceModules['ext.Lingo'] = array(
// JavaScript and CSS styles. To combine multiple file, just list them
as an array.
- // 'scripts' => 'js/ext.myExtension.js',
- 'styles' => 'css/Lingo.css',
-
+ // 'scripts' => 'libs/ext.myExtension.js',
+ 'styles' => 'skins/Lingo.css',
// When your module is loaded, these messages will be available to
mediaWiki.msg()
// 'messages' => array( 'myextension-hello-world',
'myextension-goodbye-world' ),
Modified: trunk/extensions/Lingo/LingoBackend.php
===================================================================
--- trunk/extensions/Lingo/LingoBackend.php 2011-06-07 21:59:06 UTC (rev
89702)
+++ trunk/extensions/Lingo/LingoBackend.php 2011-06-07 22:15:08 UTC (rev
89703)
@@ -22,7 +22,11 @@
public function __construct( LingoMessageLog &$messages = null ) {
- $this->mMessageLog = $messages;
+ if ( !$messages ) {
+ $this->mMessageLog = new LingoMessageLog();
+ } else {
+ $this->mMessageLog = $messages;
+ }
}
public function getMessageLog() {
Modified: trunk/extensions/Lingo/LingoBasicBackend.php
===================================================================
--- trunk/extensions/Lingo/LingoBasicBackend.php 2011-06-07 21:59:06 UTC
(rev 89702)
+++ trunk/extensions/Lingo/LingoBasicBackend.php 2011-06-07 22:15:08 UTC
(rev 89703)
@@ -20,7 +20,7 @@
protected $mArticleLines = array();
- public function __construct( LingoMessageLog &$messages ) {
+ public function __construct( LingoMessageLog &$messages = null ) {
parent::__construct( $messages );
@@ -28,7 +28,7 @@
$rev = Revision::newFromTitle( Title::makeTitle( null,
'Terminology' ) );
if ( !$rev ) {
- $messages->addWarning( '[[Terminology]] does not
exist.' );
+ $this->getMessageLog()->addWarning( '[[Terminology]]
does not exist.' );
return false;
}
Modified: trunk/extensions/Lingo/LingoParser.php
===================================================================
--- trunk/extensions/Lingo/LingoParser.php 2011-06-07 21:59:06 UTC (rev
89702)
+++ trunk/extensions/Lingo/LingoParser.php 2011-06-07 22:15:08 UTC (rev
89703)
@@ -52,7 +52,15 @@
}
/**
- * Returns the list of terms applicable in the current context
+ *
+ * @return LingoBackend the backend used by the parser
+ */
+ public function getBackend() {
+ return $this->mLingoBackend;
+ }
+
+ /**
+ * Returns the list of terms in the glossary
*
* @return Array an array mapping terms (keys) to descriptions (values)
*/
@@ -70,7 +78,7 @@
}
/**
- * Returns the list of terms applicable in the current context
+ * Returns the list of terms in the glossary as a LingoTree
*
* @return LingoTree a LingoTree mapping terms (keys) to descriptions
(values)
*/
@@ -259,19 +267,22 @@
protected function loadModules( &$parser ) {
global $wgOut, $wgScriptPath;
- if ( defined( 'MW_SUPPORTS_RESOURCE_MODULES' ) ) {
- if ( !is_null( $parser ) ) {
- $parser->getOutput()->addModules( 'ext.Lingo' );
- } else {
- $wgOut->addModules( 'ext.Lingo' );
- }
+ // FIXME: Modules loaded by the ResourceLoader only work on
JS-enabled
+ // 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 ) ) {
+// $parser->getOutput()->addModules( 'ext.Lingo' );
+// } else {
+// $wgOut->addModules( 'ext.Lingo' );
+// }
+// } else {
+ if ( !is_null( $parser ) && ( $wgOut->isArticle() ) ) {
+ $parser->getOutput()->addHeadItem( '<link
rel="stylesheet" href="' . $wgScriptPath . '/extensions/Lingo/skins/Lingo.css"
/>', 'ext.Lingo.css' );
} else {
- if ( !is_null( $parser ) && ( $wgOut->isArticle() ) ) {
- $parser->getOutput()->addHeadItem( '<link
rel="stylesheet" href="' . $wgScriptPath . '/extensions/Lingo/skins/Lingo.css"
/>', 'ext.Lingo.css' );
- } else {
- $wgOut->addHeadItem( 'ext.Lingo.css', '<link
rel="stylesheet" href="' . $wgScriptPath . '/extensions/Lingo/skins/Lingo.css"
/>' );
- }
+ $wgOut->addHeadItem( 'ext.Lingo.css', '<link
rel="stylesheet" href="' . $wgScriptPath . '/extensions/Lingo/skins/Lingo.css"
/>' );
}
+// }
}
}
Modified: trunk/extensions/Lingo/LingoTree.php
===================================================================
--- trunk/extensions/Lingo/LingoTree.php 2011-06-07 21:59:06 UTC (rev
89702)
+++ trunk/extensions/Lingo/LingoTree.php 2011-06-07 22:15:08 UTC (rev
89703)
@@ -17,10 +17,19 @@
*
* Vocabulary:
* Term - The term as a normal string
- * Definition - Its definition object
+ * Definition - Its definition (any object)
* Element - An element (leaf) in the glossary tree
* Path - The path in the tree to the leaf representing a term
*
+ * The glossary is organized as a tree (nested arrays) where the path to the
+ * definition of a term is the lexemes of the term followed by -1 as the end
+ * marker.
+ *
+ * Example:
+ * The path to the definition of the term "foo bar baz" would be
+ * 'foo'.' '.'bar'.' '.'baz'.'-1'. It could thus be accessed as
+ * $mTree['foo'][' ']['bar'][' ']['baz'][-1]
+ *
* @ingroup Lingo
*/
class LingoTree {
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs