[MediaWiki-commits] [Gerrit] Ability to turn off the recognition of glossary terms in cer... - change (mediawiki...Lingo)

2013-09-07 Thread Euvl (Code Review)
Euvl has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/83228


Change subject: Ability to turn off the recognition of glossary terms in 
certain places(Lingo). Phase 2: visual interface for turning off in (involves 
JS)
..

Ability to turn off the recognition of glossary terms in certain places(Lingo). 
Phase 2: visual interface for turning off in (involves JS)

Change-Id: I85bcc25f6c31874041014ce1893aa5e2068640be
---
M LingoElement.php
M libs/Lingo.js
M skins/Lingo.css
A skins/removeicon.png
4 files changed, 64 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Lingo 
refs/changes/28/83228/1

diff --git a/LingoElement.php b/LingoElement.php
index a153470..67c041d 100644
--- a/LingoElement.php
+++ b/LingoElement.php
@@ -138,10 +138,14 @@
$spanDefinitionInner-appendChild( 
$element );
}
 
+   $spanDefinitionInner-appendChild( 
$this-getDeleteButton( $doc, $this-mTerm ) );
+
// insert term and definition
$span-appendChild( $spanTerm );
$span-appendChild( $spanDefinitionOuter );
+
$spanDefinitionOuter-appendChild( 
$spanDefinitionInner );
+
 
$this-mFullDefinition = $span;
}
@@ -193,4 +197,13 @@
return self::$mLinkTemplate-cloneNode( true );
}
 
+   private function getDeleteButton( DOMDocument $doc, $term ) {
+
+   $link = $doc-createElement( 'span',  );
+   $link-setAttribute( 'class', 'deleteButton' );
+   $link-setAttribute( 'id', $term );
+
+   return $link;
+   }
+
 }
diff --git a/libs/Lingo.js b/libs/Lingo.js
index 6dae13e..d7a5f47 100644
--- a/libs/Lingo.js
+++ b/libs/Lingo.js
@@ -215,7 +215,50 @@
}
 
$( this ).parent().fadeOut( 200 );
-   } );
+   } )
 
+   .find( '.deleteButton' )
+   .click( function ( event ) {
+   event.stopImmediatePropagation();
+
+   $.getJSON( mw.util.wikiScript( 'api' ), {
+   format: 'json',
+   action: 'query',
+   titles: mw.config.get( 'wgPageName' ),
+   prop: 'revisions',
+   rvprop: 'content'
+   } ).done( function ( data ) {
+
+   var editToken = mw.user.tokens.get( 'editToken' 
);
+   var term = event.target.id;
+   var text = 
data.query.pages[1].revisions[0][*];
+   var new_text = text.replace(term, 
noglossary + term + /noglossary);
+
+   $.ajax( {
+   url: mw.util.wikiScript( 'api' ),
+   data: {
+   format: 'json',
+   action: 'edit',
+   title: mw.config.get( 
'wgPageName' ),
+   summary: 
data.query.pages[1].title,
+   text: new_text + ' + ' + 
Date.now(),
+   token: editToken
+   },
+   dataType: 'json',
+   type: 'POST',
+   success: function( data ) {
+
+   if ( data  data.edit  
data.edit.result == 'Success' ) {
+   
window.location.reload();
+   } else {
+   alert( 'Error: API 
returned error code ' + data.error.code );
+   }
+   },
+   error: function( xhr ) {
+   alert( 'Error: Request failed.' 
);
+   }
+   } );
+   } );
+   } );
} );
 }( jQuery, mediaWiki ) );
diff --git a/skins/Lingo.css b/skins/Lingo.css
index e8631e1..bb6c8a8 100644
--- a/skins/Lingo.css
+++ b/skins/Lingo.css
@@ -62,3 +62,10 @@
 .tooltip:hover .tooltip_tipwrapper {
 display: block;
 }
+
+.deleteButton {
+cursor: pointer;
+background: url(removeicon.png) no-repeat center;
+width: 16px;
+height: 16px;
+}
diff --git 

[MediaWiki-commits] [Gerrit] Ability to turn off the recognition of glossary terms in cer... - change (mediawiki...Lingo)

2013-09-07 Thread Euvl (Code Review)
Euvl has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/83229


Change subject: Ability to turn off the recognition of glossary terms in 
certain places(Lingo). Phase 2: visual interface for turning off in (involves 
JS)
..

Ability to turn off the recognition of glossary terms in certain places(Lingo). 
Phase 2: visual interface for turning off in (involves JS)

Change-Id: Iaa25829b00b6eab5eedd2dc978a32959b5ebc10c
---
M libs/Lingo.js
1 file changed, 2 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Lingo 
refs/changes/29/83229/1

diff --git a/libs/Lingo.js b/libs/Lingo.js
index d7a5f47..fc1588a 100644
--- a/libs/Lingo.js
+++ b/libs/Lingo.js
@@ -232,7 +232,7 @@
var editToken = mw.user.tokens.get( 'editToken' 
);
var term = event.target.id;
var text = 
data.query.pages[1].revisions[0][*];
-   var new_text = text.replace(term, 
noglossary + term + /noglossary);
+   var new_text = text.replace(term, noglossary 
 + term +  /noglossary);
 
$.ajax( {
url: mw.util.wikiScript( 'api' ),
@@ -241,13 +241,12 @@
action: 'edit',
title: mw.config.get( 
'wgPageName' ),
summary: 
data.query.pages[1].title,
-   text: new_text + ' + ' + 
Date.now(),
+   text: new_text,
token: editToken
},
dataType: 'json',
type: 'POST',
success: function( data ) {
-
if ( data  data.edit  
data.edit.result == 'Success' ) {

window.location.reload();
} else {

-- 
To view, visit https://gerrit.wikimedia.org/r/83229
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaa25829b00b6eab5eedd2dc978a32959b5ebc10c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Lingo
Gerrit-Branch: master
Gerrit-Owner: Euvl eu.vlase...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Making templates work with semantic glossary and lingo - change (mediawiki...Lingo)

2013-09-05 Thread Euvl (Code Review)
Euvl has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/82870


Change subject: Making templates work with semantic glossary and lingo
..

Making templates work with semantic glossary and lingo

Change-Id: I95d8e5badeded7686768c57d7561c94320e72520
---
M LingoElement.php
1 file changed, 19 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Lingo 
refs/changes/70/82870/1

diff --git a/LingoElement.php b/LingoElement.php
index a153470..db1b12a 100644
--- a/LingoElement.php
+++ b/LingoElement.php
@@ -125,7 +125,9 @@
 
foreach ( $this-mDefinitions as $definition ) {
wfSuppressWarnings();
-   $element = $doc-createElement( 'span', 
htmlentities( $definition[self::ELEMENT_DEFINITION], ENT_COMPAT, 'UTF-8' ) );
+   //$element = $doc-createElement( 
'span', htmlentities( $definition[self::ELEMENT_DEFINITION], ENT_COMPAT, 
'UTF-8' ) );
+   $element = $doc-createElement( 'span' 
);
+   $this-appendHTML( $element, 
$this-getParsedDefinition( $definition ) );
wfRestoreWarnings();
if ( $definition[self::ELEMENT_LINK] ) {
$linkedTitle = 
Title::newFromText( $definition[self::ELEMENT_LINK] );
@@ -193,4 +195,20 @@
return self::$mLinkTemplate-cloneNode( true );
}
 
+   private function getParsedDefinition( $definition ) {
+   global $wgTitle;
+   $parser = new Parser();
+   $result = $parser-parse( 
$definition[self::ELEMENT_DEFINITION], $wgTitle, new ParserOptions() );
+   return  $result-getText();//htmlentities( $result-getText() , 
ENT_COMPAT, 'UTF-8' );
+   }
+
+   private function appendHTML( DOMNode $parent, $source ) {
+   $tmpDoc = new DOMDocument();
+   $tmpDoc-loadHTML( $source );
+   foreach ( $tmpDoc-getElementsByTagName( body )-item( 0 
)-childNodes as $node ) {
+   $importedNode = $parent-ownerDocument-importNode( 
$node, true );
+   $parent-appendChild( $importedNode );
+   }
+   }
+
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/82870
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I95d8e5badeded7686768c57d7561c94320e72520
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Lingo
Gerrit-Branch: master
Gerrit-Owner: Euvl eu.vlase...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Added lingo support for ApprovedRevs. To enable feature use - change (mediawiki...Lingo)

2013-07-13 Thread Euvl (Code Review)
Euvl has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/73577


Change subject: Added lingo support for ApprovedRevs. To enable feature use
..

Added lingo support for ApprovedRevs. To enable feature use

Change-Id: I45bf91f4f5e76c78bf72164b0148e79418d7157d
---
M Lingo.php
A LingoApprovedRevs.php
M LingoBasicBackend.php
3 files changed, 48 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Lingo 
refs/changes/77/73577/1

diff --git a/Lingo.php b/Lingo.php
index 4e29ab4..e5f3641 100644
--- a/Lingo.php
+++ b/Lingo.php
@@ -43,6 +43,9 @@
 // set default cache type (null = use main cache)
 $wgexLingoCacheType = null;
 
+//use approved revs extension
+$wgLingoEnableApprovedRevs = false;
+
 // set extension credits
 // (no description here, will be set later)
 $wgExtensionCredits['parserhook']['lingo'] = array(
@@ -68,6 +71,7 @@
 $wgAutoloadClasses['LingoBackend'] = $dir . '/LingoBackend.php';
 $wgAutoloadClasses['LingoBasicBackend'] = $dir . '/LingoBasicBackend.php';
 $wgAutoloadClasses['LingoMessageLog'] = $dir . '/LingoMessageLog.php';
+$wgAutoloadClasses['LingoApprovedRevs'] = $dir . '/LingoApprovedRevs.php';
 
 // register hook handlers
 $wgHooks['SpecialVersionExtensionTypes'][] = 'LingoHooks::setCredits'; // set 
credits
diff --git a/LingoApprovedRevs.php b/LingoApprovedRevs.php
new file mode 100644
index 000..b85f89d
--- /dev/null
+++ b/LingoApprovedRevs.php
@@ -0,0 +1,36 @@
+?php
+/**
+ * Class for connection ApprovedRevs with Lingo
+ */
+if ( !defined( 'APPROVED_REVS_VERSION' ) ) {
+   die( 'Support for ApprovedRevs is enabled in Lingo. But 
ApprovedRevs was not found.' );
+}
+
+/*
+ * Returns revision of Terminology page approved by ApprovedRevs
+ */
+class LingoApprovedRevs
+{
+   public function __construct() { }
+
+   public static function getApprovedTerms( $title )
+   {
+   $article_id = $title-getArticleID();
+
+   $dbr = wfGetDB( DB_SLAVE );
+   $res = $dbr-select(
+   'approved_revs',
+   '*',
+   array( 'page_id' = $article_id ),
+   __METHOD__
+   );
+
+   foreach ( $res as $row ) {
+   $id = $row-rev_id;
+   $rev = Revision::newFromId( $id );
+   return $rev;
+   }
+
+   return null;
+   }
+}
diff --git a/LingoBasicBackend.php b/LingoBasicBackend.php
index 6c1fba3..ac1cd21 100644
--- a/LingoBasicBackend.php
+++ b/LingoBasicBackend.php
@@ -22,7 +22,7 @@
 
public function __construct( LingoMessageLog $messages = null ) {
 
-   global $wgexLingoPage, $wgRequest;
+   global $wgexLingoPage, $wgRequest, $wgLingoEnableApprovedRevs;
 
$page = $wgexLingoPage ? $wgexLingoPage : wfMsgForContent( 
'lingo-terminologypagename' );
 
@@ -35,6 +35,7 @@
return false;
}
 
+   //$lingoApprovedRevs-getApprovedTerms($title);
// FIXME: This is a hack special-casing the submitting of the 
terminology
// page itself. In this case the Revision is not up to date 
when we get
// here, i.e. $rev-getText() would return outdated Test.
@@ -46,7 +47,12 @@
 
} else {
 
-   $rev = Revision::newFromTitle( $title );
+   if ( $wgLingoEnableApprovedRevs ) {
+   $rev = LingoApprovedRevs::getApprovedTerms( 
$title );
+   } else {
+   $rev = Revision::newFromTitle( $title );
+   }
+
if ( !$rev ) {
$this-getMessageLog()-addWarning( 
wfMsgForContent( 'lingo-noterminologypage', $page ) );
return false;

-- 
To view, visit https://gerrit.wikimedia.org/r/73577
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I45bf91f4f5e76c78bf72164b0148e79418d7157d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Lingo
Gerrit-Branch: master
Gerrit-Owner: Euvl eu.vlase...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] added support for synonyms in Semantic Glossary, added .idea... - change (mediawiki...SemanticGlossary)

2013-07-04 Thread Euvl (Code Review)
Euvl has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/71969


Change subject: added support for synonyms in Semantic Glossary, added .idea to 
gitignore
..

added support for synonyms in Semantic Glossary, added .idea to gitignore

Change-Id: I5073db166165cc2a5aa2ba66113fc176313efd2d
---
M .gitignore
M SemanticGlossaryBackend.php
M SemanticGlossaryCacheHandling.php
3 files changed, 27 insertions(+), 19 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SemanticGlossary 
refs/changes/69/71969/1

diff --git a/.gitignore b/.gitignore
index 98b092a..da5d6dd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+.idea
 .svn
 *~
 *.kate-swp
diff --git a/SemanticGlossaryBackend.php b/SemanticGlossaryBackend.php
index df29c08..bf92648 100644
--- a/SemanticGlossaryBackend.php
+++ b/SemanticGlossaryBackend.php
@@ -89,12 +89,12 @@
public function next() {
 
wfProfileIn( __METHOD__ );
-   $ret = null;
+   static $ret = array();
 
// find next line
$page = current( $this-mQueryResults );
 
-   if ( $page ) {
+   if ( $page  count( $ret ) == 0 ) {
 
next( $this-mQueryResults );
 
@@ -117,13 +117,6 @@
$definitions = 
$this-mStore-getPropertyValues( $page, $this-mDiDefinition );
$links = $this-mStore-getPropertyValues( 
$page, $this-mDiLink );
 
-   if ( empty( $terms ) ) {
-   $term = null;
-   } else {
-   $this-mDvTerm-setDataItem( $terms[0] 
);
-   $term = 
$this-mDvTerm-getShortWikiText();
-   }
-
if ( empty( $definitions ) ) {
$definition = null;
} else {
@@ -138,18 +131,32 @@
$link = 
$this-mDvLink-getShortWikiText();
}
 
-   $ret = array(
-   LingoElement::ELEMENT_TERM = $term,
-   LingoElement::ELEMENT_DEFINITION = 
$definition,
-   LingoElement::ELEMENT_LINK = $link,
-   LingoElement::ELEMENT_SOURCE = $page
-   );
-   $cache-set( $cachekey, $ret );
-   wfDebug( Cached glossary entry $cachekey.\n );
+   $tmp_terms = array();
+
+   if ( !empty( $terms ) ) {
+   foreach ( $terms as $term ) {
+   $this-mDvTerm-setDataItem( 
$term );
+   $tmp_terms[] = 
$this-mDvTerm-getShortWikiText();
+   }
+   }
+
+   foreach ( $tmp_terms as $tmp_term ) {
+   $tmp_ret = array(
+   
LingoElement::ELEMENT_TERM = $tmp_term,
+   
LingoElement::ELEMENT_DEFINITION = $definition,
+   
LingoElement::ELEMENT_LINK = $link,
+   
LingoElement::ELEMENT_SOURCE = $page
+   );
+
+   $cache-set( $cachekey, 
$tmp_ret );
+   wfDebug( Cached glossary entry 
$cachekey.\n );
+   $ret[] = $tmp_ret;
+   }
}
}
+
wfProfileOut( __METHOD__ );
-   return $ret;
+   return array_pop($ret);
}
 
/**
diff --git a/SemanticGlossaryCacheHandling.php 
b/SemanticGlossaryCacheHandling.php
index 7e14b2f..96b16df 100644
--- a/SemanticGlossaryCacheHandling.php
+++ b/SemanticGlossaryCacheHandling.php
@@ -36,7 +36,7 @@
// first handle subobjects recursively
if ( array_key_exists( '_SOBJ', $properties ) ) {
foreach ( $data-getPropertyValues( 
$properties['_SOBJ'] ) as $so ) {
-   self::purgeCacheForData( $store, 
$so-getSemanticData(), false );
+   self::purgeCacheForData( $store, 
$store-getSemanticData($so), false );
}
}
 

-- 
To view, visit https://gerrit.wikimedia.org/r/71969
To unsubscribe, 

[MediaWiki-commits] [Gerrit] Support for multiple definitions per term - change (mediawiki...Lingo)

2013-06-27 Thread Euvl (Code Review)
Euvl has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/70802


Change subject: Support for multiple definitions per term
..

Support for multiple definitions per term

Change-Id: I4e1d0651b3d66bada92db9c3a1c76cdd6de1529c
---
M LingoBasicBackend.php
M LingoElement.php
2 files changed, 27 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Lingo 
refs/changes/02/70802/1

diff --git a/LingoBasicBackend.php b/LingoBasicBackend.php
index 09072dc..cab7084 100644
--- a/LingoBasicBackend.php
+++ b/LingoBasicBackend.php
@@ -53,6 +53,7 @@
}
 
$content = $rev-getText();
+
}
 
$this-mArticleLines = array_reverse(explode( \n, $content ));
@@ -71,8 +72,8 @@
wfProfileIn( __METHOD__ );

$ret = null;
-   $term = null;
-   static $definition = null;
+   static $term = null;
+   static $definitions = null;
 
// find next valid line (yes, the assignation is intended)
while ( ( $ret == null )  ( $entry = each( 
$this-mArticleLines ) ) ) {
@@ -83,25 +84,31 @@
 
$chunks = explode( ':', $entry[1], 2 );
 
-   // found a new term?
-   if ( count( $chunks ) = 1  strlen( $chunks[0] ) = 1 
) {
-   $term = trim( substr( $chunks[0], 1 ) );
-   }
+// found a new definition?
+if ( count ( $chunks ) == 2 ) {
+// if definitions and term are already set, and now goes 
definition again,
+// it means that we work with a totally new term and have to 
remove previous data
+// from static variables
+if ($definitions  $term) {
+$definitions = [];
+$term = null;
+}
+$definitions[] = trim( $chunks[1] );
+}
 
-   // found a new definition?
-   if ( count ( $chunks ) == 2 ) {
-   $definition = trim( $chunks[1] );
+   // found a new term?
+   if (count( $chunks ) = 1  strlen( $chunks[0] ) = 1 
) {
+   $term = trim( substr( $chunks[0], 1 ) );
}
 
if ( $term !== null ) {
$ret = array(
LingoElement::ELEMENT_TERM = $term,
-   LingoElement::ELEMENT_DEFINITION = 
$definition,
+   LingoElement::ELEMENT_DEFINITIONS = 
$definitions,
LingoElement::ELEMENT_LINK = null,
LingoElement::ELEMENT_SOURCE = null
);
}
-
}
 
wfProfileOut( __METHOD__ );
diff --git a/LingoElement.php b/LingoElement.php
index 0a2733f..e1d1b36 100644
--- a/LingoElement.php
+++ b/LingoElement.php
@@ -20,7 +20,7 @@
  */
 class LingoElement {
const ELEMENT_TERM = 0;
-   const ELEMENT_DEFINITION = 1;
+   const ELEMENT_DEFINITIONS = 1;
const ELEMENT_SOURCE = 2;
const ELEMENT_LINK = 3;
 
@@ -60,7 +60,7 @@
 
// if there is only one link available, just insert the 
link
if ( count( $this-mDefinitions ) === 1
-!is_string( 
$this-mDefinitions[0][self::ELEMENT_DEFINITION] )
+!is_string( 
$this-mDefinitions[0][self::ELEMENT_DEFINITIONS] )
 is_string( 
$this-mDefinitions[0][self::ELEMENT_LINK] ) ) {
 
// create Title object for target page
@@ -112,6 +112,7 @@
// Wrap term in span tag, hidden
wfSuppressWarnings();
$spanTerm = $doc-createElement( 'span', 
htmlentities( $this-mTerm, ENT_COMPAT, 'UTF-8' ) );
+
wfRestoreWarnings();
$spanTerm-setAttribute( 'class', 
'tooltip_abbr' );
 
@@ -124,7 +125,11 @@
 
foreach ( $this-mDefinitions as $definition ) {
wfSuppressWarnings();
-   $element = $doc-createElement( 'span', 
htmlentities( $definition[self::ELEMENT_DEFINITION], ENT_COMPAT, 'UTF-8' ) );
+$definitions = null;
+foreach ($definition[self::ELEMENT_DEFINITIONS] as $def) {
+$definitions .= $def . ', ';
+}
+   $element = 

[MediaWiki-commits] [Gerrit] improvements for 8e9bd87ede91cc5e07bcf79480bb31b34522ff67 co... - change (mediawiki...Lingo)

2013-06-27 Thread Euvl (Code Review)
Euvl has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/70807


Change subject: improvements for 8e9bd87ede91cc5e07bcf79480bb31b34522ff67 commit
..

improvements for 8e9bd87ede91cc5e07bcf79480bb31b34522ff67 commit

Change-Id: I1b73c35d91e8a7f7a7412e75d219bf71d985326a
---
M Lingo.php
M LingoBasicBackend.php
M LingoElement.php
M LingoHooks.php
4 files changed, 38 insertions(+), 38 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Lingo 
refs/changes/07/70807/1

diff --git a/Lingo.php b/Lingo.php
index 605a8aa..4e29ab4 100644
--- a/Lingo.php
+++ b/Lingo.php
@@ -81,7 +81,7 @@
 
 $wgHooks['ArticlePurge'][] = 'LingoBasicBackend::purgeCache';
 $wgHooks['ArticleSave'][] = 'LingoBasicBackend::purgeCache';
-$wgHooks['ParserFirstCallInit'][] = 'LingoBasicBackend::registerTags';
+$wgHooks['ParserFirstCallInit'][] = 'LingoHooks::registerTags';
 
 // register resource modules with the Resource Loader
 $wgResourceModules['ext.Lingo.Styles'] = array(
diff --git a/LingoBasicBackend.php b/LingoBasicBackend.php
index cab7084..6635464 100644
--- a/LingoBasicBackend.php
+++ b/LingoBasicBackend.php
@@ -84,17 +84,17 @@
 
$chunks = explode( ':', $entry[1], 2 );
 
-// found a new definition?
-if ( count ( $chunks ) == 2 ) {
-// if definitions and term are already set, and now goes 
definition again,
-// it means that we work with a totally new term and have to 
remove previous data
-// from static variables
-if ($definitions  $term) {
-$definitions = [];
-$term = null;
-}
-$definitions[] = trim( $chunks[1] );
-}
+   // found a new definition?
+   if ( count ( $chunks ) == 2 ) {
+   // if definitions and term are already set, and 
now goes definition again,
+   // it means that we work with a totally new 
term and have to remove previous data
+   // from static variables
+   if ($definitions  $term) {
+   $definitions = [];
+   $term = null;
+   }
+   $definitions[] = trim( $chunks[1] );
+   }
 
// found a new term?
if (count( $chunks ) = 1  strlen( $chunks[0] ) = 1 
) {
@@ -146,26 +146,5 @@
public function useCache() {
return true;
}
-
-/**
- * Creates tag hook(s)
- */
-public static function registerTags(Parser $parser) {
-$parser-setHook( 'noglossary',  
'LingoBasicBackend::noglossaryTagRenderer');
-return true;
-}
-
-/**
- * Sets hook on 'noglossary' tag
- * @static
- * @param $input
- * @param array $args
- * @param Parser $parser
- * @param PPFrame $frame
- * @return string
- */
-public static function noglossaryTagRenderer( $input, array $args, Parser 
$parser, PPFrame $frame ) {
-return 'span class=noglossary'.$input.'/span';
-}
 }
 
diff --git a/LingoElement.php b/LingoElement.php
index e1d1b36..30d1cc9 100644
--- a/LingoElement.php
+++ b/LingoElement.php
@@ -125,11 +125,11 @@
 
foreach ( $this-mDefinitions as $definition ) {
wfSuppressWarnings();
-$definitions = null;
-foreach ($definition[self::ELEMENT_DEFINITIONS] as $def) {
-$definitions .= $def . ', ';
-}
-   $element = $doc-createElement( 'span', 
htmlentities(trim($definitions, ', '), ENT_COMPAT, 'UTF-8' ) );
+   $definitions = null;
+   foreach ( 
$definition[self::ELEMENT_DEFINITIONS] as $def ) {
+   $definitions .= $def . ', ';
+   }
+   $element = $doc-createElement( 'span', 
htmlentities( trim($definitions, ', ' ), ENT_COMPAT, 'UTF-8' ) );
wfRestoreWarnings();
if ( $definition[self::ELEMENT_LINK] ) {
$linkedTitle = 
Title::newFromText( $definition[self::ELEMENT_LINK] );
diff --git a/LingoHooks.php b/LingoHooks.php
index 464c5a5..413d005 100644
--- a/LingoHooks.php
+++ b/LingoHooks.php
@@ -66,5 +66,26 @@
return true;
}
 
+   /**
+* Creates tag hook(s)
+*/
+   public static function registerTags(Parser $parser) {
+   $parser-setHook( 

[MediaWiki-commits] [Gerrit] Ability to turn off the recognition of glossary terms in cer... - change (mediawiki...Lingo)

2013-06-26 Thread Euvl (Code Review)
Euvl has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/70742


Change subject: Ability to turn off the recognition of glossary terms in 
certain places.
..

Ability to turn off the recognition of glossary terms in certain places.

Change-Id: Id941519dffe71a35554a24ee851fb1518c7e9e46
---
M Lingo.php
M LingoBasicBackend.php
M LingoTree.php
3 files changed, 23 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Lingo 
refs/changes/42/70742/1

diff --git a/Lingo.php b/Lingo.php
index fcfc725..605a8aa 100644
--- a/Lingo.php
+++ b/Lingo.php
@@ -81,6 +81,7 @@
 
 $wgHooks['ArticlePurge'][] = 'LingoBasicBackend::purgeCache';
 $wgHooks['ArticleSave'][] = 'LingoBasicBackend::purgeCache';
+$wgHooks['ParserFirstCallInit'][] = 'LingoBasicBackend::registerTags';
 
 // register resource modules with the Resource Loader
 $wgResourceModules['ext.Lingo.Styles'] = array(
diff --git a/LingoBasicBackend.php b/LingoBasicBackend.php
index 0149918..09072dc 100644
--- a/LingoBasicBackend.php
+++ b/LingoBasicBackend.php
@@ -139,5 +139,26 @@
public function useCache() {
return true;
}
+
+/**
+ * Creates tag hook(s)
+ */
+public static function registerTags(Parser $parser) {
+$parser-setHook( 'noglossary',  
'LingoBasicBackend::noglossaryTagRenderer');
+return true;
+}
+
+/**
+ * Sets hook on 'noglossary' tag
+ * @static
+ * @param $input
+ * @param array $args
+ * @param Parser $parser
+ * @param PPFrame $frame
+ * @return string
+ */
+public static function noglossaryTagRenderer( $input, array $args, Parser 
$parser, PPFrame $frame ) {
+return 'span class=noglossary'.$input.'/span';
+}
 }
 
diff --git a/LingoTree.php b/LingoTree.php
index 60f2881..11f659a 100644
--- a/LingoTree.php
+++ b/LingoTree.php
@@ -106,7 +106,7 @@
$start = $lastindex = $index;
$definition = null;
 
-   // skip until ther start of a term is found
+   // skip until the start of a term is found
while ( $index  $countLexemes  !$definition ) {
$currLex = $lexemes[$index][0];
 

-- 
To view, visit https://gerrit.wikimedia.org/r/70742
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id941519dffe71a35554a24ee851fb1518c7e9e46
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Lingo
Gerrit-Branch: master
Gerrit-Owner: Euvl eu.vlase...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] added .idea to gitignore - change (mediawiki...Lingo)

2013-06-11 Thread Euvl (Code Review)
Euvl has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/68000


Change subject: added .idea to gitignore
..

added .idea to gitignore

Change-Id: I2f6da9b40e2689c3baf238ac0d630197ea554e1a
---
M .gitignore
1 file changed, 1 insertion(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Lingo 
refs/changes/00/68000/1

diff --git a/.gitignore b/.gitignore
index 98b092a..aea1a8d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,4 @@
 *~
 *.kate-swp
 .*.swp
+.idea
\ No newline at end of file

-- 
To view, visit https://gerrit.wikimedia.org/r/68000
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2f6da9b40e2689c3baf238ac0d630197ea554e1a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Lingo
Gerrit-Branch: master
Gerrit-Owner: Euvl eu.vlase...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits