jenkins-bot has submitted this change and it was merged.

Change subject: Support for multiple definitions per term. Used Coding 
conventions
......................................................................


Support for multiple definitions per term. Used Coding conventions

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

Approvals:
  Foxtrott: Verified; Looks good to me, approved
  jenkins-bot: Verified



diff --git a/LingoBasicBackend.php b/LingoBasicBackend.php
index 0149918..6c1fba3 100644
--- a/LingoBasicBackend.php
+++ b/LingoBasicBackend.php
@@ -53,6 +53,7 @@
                        }
 
                        $content = $rev->getText();
+
                }
 
                $this->mArticleLines = array_reverse(explode( "\n", $content ));
@@ -69,13 +70,13 @@
        public function next() {
 
                wfProfileIn( __METHOD__ );
-               
-               $ret = null;
-               $term = null;
-               static $definition = null;
+
+               static $term = null;
+               static $definitions = array();
+               static $ret = array();
 
                // find next valid line (yes, the assignation is intended)
-               while ( ( $ret == null ) && ( $entry = each( 
$this->mArticleLines ) ) ) {
+               while ( ( count( $ret ) == 0 ) && ( $entry = each( 
$this->mArticleLines ) ) ) {
 
                        if ( empty( $entry[1] ) || ($entry[1][0] !== ';' && 
$entry[1][0] !== ':')) {
                                continue;
@@ -83,30 +84,38 @@
 
                        $chunks = explode( ':', $entry[1], 2 );
 
+                       // found a new definition?
+                       if ( count ( $chunks ) == 2 ) {
+
+                               // wipe the data if its a totaly new term 
definition
+                               if ( !empty( $term ) && count( $definitions ) > 
0) {
+                                       $definitions = array();
+                                       $term = null;
+                               }
+
+                               $definitions[] = trim( $chunks[1] );
+                       }
+
                        // found a new term?
-                       if ( count( $chunks ) >= 1 && strlen( $chunks[0] ) >= 1 
) {
+                       if (count( $chunks ) >= 1 && strlen( $chunks[0] ) >= 1 
) {
                                $term = trim( substr( $chunks[0], 1 ) );
                        }
 
-                       // found a new definition?
-                       if ( count ( $chunks ) == 2 ) {
-                               $definition = trim( $chunks[1] );
-                       }
-
                        if ( $term !== null ) {
-                               $ret = array(
-                                       LingoElement::ELEMENT_TERM => $term,
-                                       LingoElement::ELEMENT_DEFINITION => 
$definition,
-                                       LingoElement::ELEMENT_LINK => null,
-                                       LingoElement::ELEMENT_SOURCE => null
-                               );
+                               foreach ( $definitions as $definition ) {
+                                       $ret[] = array(
+                                               LingoElement::ELEMENT_TERM => 
$term,
+                                               
LingoElement::ELEMENT_DEFINITION => $definition,
+                                               LingoElement::ELEMENT_LINK => 
null,
+                                               LingoElement::ELEMENT_SOURCE => 
null
+                                       );
+                               }
                        }
-
                }
 
                wfProfileOut( __METHOD__ );
                
-               return $ret;
+               return array_pop($ret);;
        }
 
        /**
diff --git a/LingoElement.php b/LingoElement.php
index 0a2733f..a153470 100644
--- a/LingoElement.php
+++ b/LingoElement.php
@@ -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' );
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I4e1d0651b3d66bada92db9c3a1c76cdd6de1529c
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/Lingo
Gerrit-Branch: master
Gerrit-Owner: Euvl <[email protected]>
Gerrit-Reviewer: Euvl <[email protected]>
Gerrit-Reviewer: Foxtrott <[email protected]>
Gerrit-Reviewer: Yury Katkov <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to