Index: trunk/extensions/Lingo/LingoBasicBackend.php |
— | — | @@ -43,8 +43,7 @@ |
44 | 44 | |
45 | 45 | $content = $rev->getText(); |
46 | 46 | |
47 | | - $term = array(); |
48 | | - $this->mArticleLines = explode( "\n", $content ); |
| 47 | + $this->mArticleLines = array_reverse(explode( "\n", $content )); |
49 | 48 | } |
50 | 49 | |
51 | 50 | /** |
— | — | @@ -58,26 +57,37 @@ |
59 | 58 | public function next() { |
60 | 59 | |
61 | 60 | $ret = null; |
| 61 | + static $term = null; |
| 62 | + static $definition = null; |
62 | 63 | |
63 | 64 | // find next valid line (yes, the assignation is intended) |
64 | 65 | while ( ( $ret == null ) && ( $entry = each( $this->mArticleLines ) ) ) { |
65 | 66 | |
66 | | - if ( empty( $entry[1] ) || $entry[1][0] !== ';' ) { |
| 67 | + if ( empty( $entry[1] ) || ($entry[1][0] !== ';' && $entry[1][0] !== ':')) { |
67 | 68 | continue; |
68 | 69 | } |
69 | 70 | |
70 | | - $terms = explode( ':', $entry[1], 2 ); |
| 71 | + $chunks = explode( ':', $entry[1], 2 ); |
71 | 72 | |
72 | | - if ( count( $terms ) < 2 ) { |
73 | | - continue; // Invalid syntax |
| 73 | + // found a new term? |
| 74 | + if ( $chunks[0] ) { |
| 75 | + $term = trim( substr( $chunks[0], 1 ) ); |
74 | 76 | } |
| 77 | + |
| 78 | + // found a new definition? |
| 79 | + if ( count ( $chunks ) == 2 ) { |
| 80 | + $definition = trim( $chunks[1] ); |
| 81 | + } |
75 | 82 | |
76 | | - $ret = array( |
77 | | - LingoElement::ELEMENT_TERM => trim( substr( $terms[0], 1 ) ), |
78 | | - LingoElement::ELEMENT_DEFINITION => trim( $terms[1] ), |
79 | | - LingoElement::ELEMENT_LINK => null, |
80 | | - LingoElement::ELEMENT_SOURCE => null |
81 | | - ); |
| 83 | + if ( $term !== null ) { |
| 84 | + $ret = array( |
| 85 | + LingoElement::ELEMENT_TERM => $term, |
| 86 | + LingoElement::ELEMENT_DEFINITION => $definition, |
| 87 | + LingoElement::ELEMENT_LINK => null, |
| 88 | + LingoElement::ELEMENT_SOURCE => null |
| 89 | + ); |
| 90 | + } |
| 91 | + |
82 | 92 | } |
83 | 93 | |
84 | 94 | return $ret; |