Index: trunk/extensions/SemanticGlossary/SpecialSemanticGlossaryBrowser.php |
— | — | @@ -461,7 +461,7 @@ |
462 | 462 | /** |
463 | 463 | * Checks if the user wants to perform an action, has the necessary right |
464 | 464 | * and submitted a valid edit token. |
465 | | - * |
| 465 | + * |
466 | 466 | * @return Boolean |
467 | 467 | */ |
468 | 468 | private function isActionAllowed() { |
Index: trunk/extensions/SemanticGlossary/SemanticGlossaryBackend.php |
— | — | @@ -2,7 +2,7 @@ |
3 | 3 | |
4 | 4 | /** |
5 | 5 | * File holding the SemanticGlossaryBackend class |
6 | | - * |
| 6 | + * |
7 | 7 | * @author Stephan Gambke |
8 | 8 | * @file |
9 | 9 | * @ingroup SemanticGlossary |
Index: trunk/extensions/SemanticGlossary/SemanticGlossaryElement.php |
— | — | @@ -26,9 +26,13 @@ |
27 | 27 | |
28 | 28 | private $mFullDefinition = null; |
29 | 29 | private $mDefinitions = array(); |
| 30 | + private $mTerm = null; |
30 | 31 | static private $mLinkTemplate = null; |
31 | 32 | |
32 | | - public function __construct( &$definition = null ) { |
| 33 | + public function __construct( &$term, &$definition = null ) { |
| 34 | + |
| 35 | + $this->mTerm = $term; |
| 36 | + |
33 | 37 | if ( $definition ) { |
34 | 38 | $this->addDefinition( $definition ); |
35 | 39 | } |
— | — | @@ -41,8 +45,22 @@ |
42 | 46 | public function getFullDefinition( DOMDocument &$doc ) { |
43 | 47 | // only create if not yet created |
44 | 48 | if ( $this->mFullDefinition == null || $this->mFullDefinition->ownerDocument !== $doc ) { |
45 | | - $this->mFullDefinition = $doc->createElement( 'span' ); |
46 | 49 | |
| 50 | + // Wrap term and definition in <span> tags |
| 51 | + $span = $doc->createElement( 'span' ); |
| 52 | + $span->setAttribute( 'class', 'tooltip' ); |
| 53 | + |
| 54 | + // Wrap term in <span> tag, hidden |
| 55 | + $spanTerm = $doc->createElement( 'span', $this->mTerm ); |
| 56 | + $spanTerm->setAttribute( 'class', 'tooltip_abbr' ); |
| 57 | + |
| 58 | + // Wrap definition in two <span> tags |
| 59 | + $spanDefinitionOuter = $doc->createElement( 'span' ); |
| 60 | + $spanDefinitionOuter->setAttribute( 'class', 'tooltip_tipwrapper' ); |
| 61 | + |
| 62 | + $spanDefinitionInner = $doc->createElement( 'span' ); |
| 63 | + $spanDefinitionInner->setAttribute( 'class', 'tooltip_tip' ); |
| 64 | + |
47 | 65 | foreach ( $this->mDefinitions as $definition ) { |
48 | 66 | $element = $doc->createElement( 'span', htmlentities( $definition[self::SG_DEFINITION], ENT_COMPAT, 'UTF-8' ) . ' ' ); |
49 | 67 | if ( $definition[self::SG_LINK] ) { |
— | — | @@ -53,8 +71,16 @@ |
54 | 72 | $element->appendChild( $link ); |
55 | 73 | } |
56 | 74 | } |
57 | | - $this->mFullDefinition->appendChild( $element ); |
| 75 | + $spanDefinitionInner->appendChild( $element ); |
58 | 76 | } |
| 77 | + |
| 78 | + // insert term and definition |
| 79 | + $span->appendChild( $spanTerm ); |
| 80 | + $span->appendChild( $spanDefinitionOuter ); |
| 81 | + $spanDefinitionOuter->appendChild( $spanDefinitionInner ); |
| 82 | + |
| 83 | + $this->mFullDefinition = $span; |
| 84 | + |
59 | 85 | } |
60 | 86 | |
61 | 87 | return $this->mFullDefinition->cloneNode( true ); |
Index: trunk/extensions/SemanticGlossary/skins/SemanticGlossary.css |
— | — | @@ -4,7 +4,7 @@ |
5 | 5 | |
6 | 6 | .tooltip { |
7 | 7 | display: inline; |
8 | | - position: static; |
| 8 | + position: relative; |
9 | 9 | cursor: help; |
10 | 10 | } |
11 | 11 | |
— | — | @@ -12,28 +12,44 @@ |
13 | 13 | border-bottom: 1px dotted #bbf; |
14 | 14 | } |
15 | 15 | |
16 | | -.tooltip_tip { |
| 16 | +.tooltip_tipwrapper { |
17 | 17 | display: none; |
18 | 18 | |
19 | | - border: 1px solid gray; |
20 | | - background-color: white; |
21 | | - padding: 0.1em 0.2em 0.1em 0.1em; |
| 19 | + position: absolute; |
| 20 | + top: 0; |
| 21 | + left: 0; |
| 22 | + |
| 23 | + padding: 1.5em 0 0 2em; |
| 24 | + width: 20em; |
| 25 | + |
| 26 | + z-index: 2; |
| 27 | +} |
| 28 | + |
| 29 | +.tooltip_tip { |
| 30 | + display: block; |
| 31 | + |
| 32 | + position: relative; |
| 33 | + top: 0em; |
| 34 | + left: 0em; |
| 35 | + |
| 36 | + background-color: #F9F9F9; |
| 37 | + padding: 0.5em; |
22 | 38 | margin: 0; |
23 | 39 | line-height: 1.2em; |
24 | 40 | |
25 | | - position: absolute; |
26 | | - top: 1.1em; |
27 | | - left: 1em; |
| 41 | + border: 1px solid #aaa; |
| 42 | + |
| 43 | + -moz-border-radius: 5px; |
| 44 | + border-radius: 5px; |
| 45 | + |
| 46 | + -webkit-box-shadow: 3px 3px 3px #888; |
| 47 | + box-shadow: 3px 3px 3px #888; |
28 | 48 | } |
29 | 49 | |
30 | 50 | .tooltip_tip span { |
31 | 51 | display: block; |
32 | 52 | } |
33 | 53 | |
34 | | -.tooltip:hover { |
35 | | - position: relative; |
36 | | -} |
37 | | - |
38 | | -.tooltip:hover .tooltip_tip { |
| 54 | +.tooltip:hover .tooltip_tipwrapper { |
39 | 55 | display: block; |
40 | 56 | } |
Index: trunk/extensions/SemanticGlossary/SemanticGlossaryParser.php |
— | — | @@ -17,7 +17,7 @@ |
18 | 18 | * terms. |
19 | 19 | * |
20 | 20 | * Contains a static function to initiate the parsing. |
21 | | - * |
| 21 | + * |
22 | 22 | * @ingroup SemanticGlossary |
23 | 23 | */ |
24 | 24 | class SemanticGlossaryParser { |
— | — | @@ -32,21 +32,21 @@ |
33 | 33 | * @param $text |
34 | 34 | * @return Boolean |
35 | 35 | */ |
36 | | - static function parse ( &$parser, &$text ) { |
| 36 | + static function parse( &$parser, &$text ) { |
37 | 37 | wfProfileIn( __METHOD__ ); |
38 | 38 | |
39 | 39 | if ( !self::$parserSingleton ) { |
40 | 40 | self::$parserSingleton = new SemanticGlossaryParser(); |
41 | 41 | } |
42 | 42 | |
43 | | - self::$parserSingleton -> realParse( $parser, $text ); |
| 43 | + self::$parserSingleton->realParse( $parser, $text ); |
44 | 44 | |
45 | 45 | wfProfileOut( __METHOD__ ); |
46 | 46 | |
47 | 47 | return true; |
48 | 48 | } |
49 | 49 | |
50 | | - function getBackend () { |
| 50 | + function getBackend() { |
51 | 51 | return new SemanticGlossaryBackend(); |
52 | 52 | } |
53 | 53 | |
— | — | @@ -55,17 +55,17 @@ |
56 | 56 | * |
57 | 57 | * @return Array an array mapping terms (keys) to descriptions (values) |
58 | 58 | */ |
59 | | - function getGlossaryArray ( SemanticGlossaryMessageLog &$messages = null ) { |
| 59 | + function getGlossaryArray( SemanticGlossaryMessageLog &$messages = null ) { |
60 | 60 | wfProfileIn( __METHOD__ ); |
61 | 61 | |
62 | 62 | // build glossary array only once per request |
63 | | - if ( !$this -> mGlossaryArray ) { |
64 | | - $this -> buildGlossary( $messages ); |
| 63 | + if ( !$this->mGlossaryArray ) { |
| 64 | + $this->buildGlossary( $messages ); |
65 | 65 | } |
66 | 66 | |
67 | 67 | wfProfileOut( __METHOD__ ); |
68 | 68 | |
69 | | - return $this -> mGlossaryArray; |
| 69 | + return $this->mGlossaryArray; |
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
— | — | @@ -73,44 +73,44 @@ |
74 | 74 | * |
75 | 75 | * @return Array an array mapping terms (keys) to descriptions (values) |
76 | 76 | */ |
77 | | - function getGlossaryTree ( SemanticGlossaryMessageLog &$messages = null ) { |
| 77 | + function getGlossaryTree( SemanticGlossaryMessageLog &$messages = null ) { |
78 | 78 | wfProfileIn( __METHOD__ ); |
79 | 79 | |
80 | 80 | // build glossary array only once per request |
81 | | - if ( !$this -> mGlossaryTree ) { |
82 | | - $this -> buildGlossary( $messages ); |
| 81 | + if ( !$this->mGlossaryTree ) { |
| 82 | + $this->buildGlossary( $messages ); |
83 | 83 | } |
84 | 84 | |
85 | 85 | wfProfileOut( __METHOD__ ); |
86 | 86 | |
87 | | - return $this -> mGlossaryTree; |
| 87 | + return $this->mGlossaryTree; |
88 | 88 | } |
89 | 89 | |
90 | | - protected function buildGlossary ( SemanticGlossaryMessageLog &$messages = null ) { |
| 90 | + protected function buildGlossary( SemanticGlossaryMessageLog &$messages = null ) { |
91 | 91 | wfProfileIn( __METHOD__ ); |
92 | 92 | |
93 | | - $this -> mGlossaryTree = new SemanticGlossaryTree(); |
| 93 | + $this->mGlossaryTree = new SemanticGlossaryTree(); |
94 | 94 | |
95 | | - $backend = $this -> getBackEnd(); |
| 95 | + $backend = $this->getBackEnd(); |
96 | 96 | |
97 | 97 | // assemble the result array |
98 | | - $this -> mGlossaryArray = array( ); |
99 | | - while ( $backend -> next() ) { |
| 98 | + $this->mGlossaryArray = array(); |
| 99 | + while ( $backend->next() ) { |
100 | 100 | |
101 | 101 | $elementData = array( |
102 | | - SemanticGlossaryElement::SG_TERM => ($term = $backend -> getTerm()), |
103 | | - SemanticGlossaryElement::SG_DEFINITION => $backend -> getDefinition(), |
104 | | - SemanticGlossaryElement::SG_LINK => $backend -> getLink(), |
105 | | - SemanticGlossaryElement::SG_SOURCE => $backend -> getSource() |
| 102 | + SemanticGlossaryElement::SG_TERM => ( $term = $backend->getTerm() ), |
| 103 | + SemanticGlossaryElement::SG_DEFINITION => $backend->getDefinition(), |
| 104 | + SemanticGlossaryElement::SG_LINK => $backend->getLink(), |
| 105 | + SemanticGlossaryElement::SG_SOURCE => $backend->getSource() |
106 | 106 | ); |
107 | 107 | |
108 | | - if ( array_key_exists( $term, $this -> mGlossaryArray ) ) { |
109 | | - $this -> mGlossaryArray[ $term ] -> addDefinition( $elementData ); |
| 108 | + if ( array_key_exists( $term, $this->mGlossaryArray ) ) { |
| 109 | + $this->mGlossaryArray[$term]->addDefinition( $elementData ); |
110 | 110 | } else { |
111 | | - $this -> mGlossaryArray[ $term ] = new SemanticGlossaryElement( $elementData ); |
| 111 | + $this->mGlossaryArray[$term] = new SemanticGlossaryElement( $term, $elementData ); |
112 | 112 | } |
113 | 113 | |
114 | | - $this -> mGlossaryTree -> addTerm( $term, $elementData ); |
| 114 | + $this->mGlossaryTree->addTerm( $term, $elementData ); |
115 | 115 | } |
116 | 116 | |
117 | 117 | wfProfileOut( __METHOD__ ); |
— | — | @@ -125,18 +125,18 @@ |
126 | 126 | * @param $text |
127 | 127 | * @return Boolean |
128 | 128 | */ |
129 | | - protected function realParse ( &$parser, &$text ) { |
| 129 | + protected function realParse( &$parser, &$text ) { |
130 | 130 | global $wgRequest; |
131 | 131 | |
132 | 132 | wfProfileIn( __METHOD__ ); |
133 | 133 | |
134 | | - $action = $wgRequest -> getVal( 'action', 'view' ); |
| 134 | + $action = $wgRequest->getVal( 'action', 'view' ); |
135 | 135 | |
136 | 136 | if ( $text == null || |
137 | 137 | $text == '' || |
138 | 138 | $action == 'edit' || |
139 | 139 | $action == 'ajax' || |
140 | | - isset( $_POST[ 'wpPreview' ] ) |
| 140 | + isset( $_POST['wpPreview'] ) |
141 | 141 | ) { |
142 | 142 | |
143 | 143 | wfProfileOut( __METHOD__ ); |
— | — | @@ -144,7 +144,7 @@ |
145 | 145 | } |
146 | 146 | |
147 | 147 | // Get array of terms |
148 | | - $glossary = $this -> getGlossaryTree(); |
| 148 | + $glossary = $this->getGlossaryTree(); |
149 | 149 | |
150 | 150 | if ( $glossary == null ) { |
151 | 151 | wfProfileOut( __METHOD__ ); |
— | — | @@ -166,84 +166,63 @@ |
167 | 167 | wfProfileIn( __METHOD__ . ' 2 xpath' ); |
168 | 168 | // Find all text in HTML. |
169 | 169 | $xpath = new DOMXpath( $doc ); |
170 | | - $elements = $xpath -> query( |
| 170 | + $elements = $xpath->query( |
171 | 171 | "//*[not(ancestor-or-self::*[@class='noglossary'] or ancestor-or-self::a)][text()!=' ']/text()" |
172 | 172 | ); |
173 | 173 | wfProfileOut( __METHOD__ . ' 2 xpath' ); |
174 | 174 | |
175 | 175 | // Iterate all HTML text matches |
176 | | - $nb = $elements -> length; |
| 176 | + $nb = $elements->length; |
177 | 177 | $changedDoc = false; |
178 | 178 | |
179 | 179 | for ( $pos = 0; $pos < $nb; $pos++ ) { |
180 | | - $el = $elements -> item( $pos ); |
| 180 | + $el = $elements->item( $pos ); |
181 | 181 | |
182 | | - if ( strlen( $el -> nodeValue ) < $glossary -> getMinTermLength() ) { |
| 182 | + if ( strlen( $el->nodeValue ) < $glossary->getMinTermLength() ) { |
183 | 183 | continue; |
184 | 184 | } |
185 | 185 | |
186 | 186 | wfProfileIn( __METHOD__ . ' 3 lexer' ); |
187 | | - $matches = array( ); |
| 187 | + $matches = array(); |
188 | 188 | preg_match_all( |
189 | 189 | '/[[:alpha:]]+|[^[:alpha:]]/u', |
190 | | - $el -> nodeValue, |
| 190 | + $el->nodeValue, |
191 | 191 | $matches, |
192 | 192 | PREG_OFFSET_CAPTURE | PREG_PATTERN_ORDER |
193 | 193 | ); |
194 | 194 | wfProfileOut( __METHOD__ . ' 3 lexer' ); |
195 | 195 | |
196 | | - if ( count( $matches ) == 0 || count( $matches[ 0 ] ) == 0 ) { |
| 196 | + if ( count( $matches ) == 0 || count( $matches[0] ) == 0 ) { |
197 | 197 | continue; |
198 | 198 | } |
199 | 199 | |
200 | | - $lexemes = &$matches[ 0 ]; |
| 200 | + $lexemes = &$matches[0]; |
201 | 201 | $countLexemes = count( $lexemes ); |
202 | | - $parent = &$el -> parentNode; |
| 202 | + $parent = &$el->parentNode; |
203 | 203 | $index = 0; |
204 | 204 | $changedElem = false; |
205 | 205 | |
206 | 206 | while ( $index < $countLexemes ) { |
207 | 207 | wfProfileIn( __METHOD__ . ' 4 findNextTerm' ); |
208 | | - list( $skipped, $used, $definition ) = $glossary -> findNextTerm( $lexemes, $index, $countLexemes ); |
| 208 | + list( $skipped, $used, $definition ) = |
| 209 | + $glossary->findNextTerm( $lexemes, $index, $countLexemes ); |
209 | 210 | wfProfileOut( __METHOD__ . ' 4 findNextTerm' ); |
210 | 211 | |
211 | 212 | wfProfileIn( __METHOD__ . ' 5 insert' ); |
212 | 213 | if ( $used > 0 ) { // found a term |
213 | 214 | if ( $skipped > 0 ) { // skipped some text, insert it as is |
214 | | - $parent -> insertBefore( |
215 | | - $doc -> createTextNode( |
216 | | - substr( $el -> nodeValue, |
217 | | - $currLexIndex = $lexemes[ $index ][ 1 ], |
218 | | - $lexemes[ $index + $skipped ][ 1 ] - $currLexIndex ) |
| 215 | + $parent->insertBefore( |
| 216 | + $doc->createTextNode( |
| 217 | + substr( $el->nodeValue, |
| 218 | + $currLexIndex = $lexemes[$index][1], |
| 219 | + $lexemes[$index + $skipped][1] - $currLexIndex ) |
219 | 220 | ), |
220 | 221 | $el |
221 | 222 | ); |
222 | 223 | } |
223 | 224 | |
224 | | - $index += $skipped; |
| 225 | + $parent->insertBefore( $definition->getFullDefinition( $doc ), $el ); |
225 | 226 | |
226 | | - // Wrap abbreviation in <span> tags |
227 | | - $span = $doc -> createElement( 'span' ); |
228 | | - $span -> setAttribute( 'class', 'tooltip' ); |
229 | | - |
230 | | - // Wrap abbreviation in <span> tags, hidden |
231 | | - $lastLex = $lexemes[ $index + $used - 1 ]; |
232 | | - $spanTerm = $doc -> createElement( 'span', |
233 | | - substr( $el -> nodeValue, |
234 | | - $currLexIndex = $lexemes[ $index ][ 1 ], |
235 | | - $lastLex[ 1 ] - $currLexIndex + strlen( $lastLex[ 0 ] ) ) |
236 | | - ); |
237 | | - $spanTerm -> setAttribute( 'class', 'tooltip_abbr' ); |
238 | | - |
239 | | - // Wrap definition in <span> tags, hidden |
240 | | - $spanDefinition = $definition -> getFullDefinition( $doc ); |
241 | | - $spanDefinition -> setAttribute( 'class', 'tooltip_tip' ); |
242 | | - |
243 | | - // insert term and definition |
244 | | - $span -> appendChild( $spanTerm ); |
245 | | - $span -> appendChild( $spanDefinition ); |
246 | | - $parent -> insertBefore( $span, $el ); |
247 | | - |
248 | 227 | $changedElem = true; |
249 | 228 | } else { // did not find term, just use the rest of the text |
250 | 229 | // If we found no term now and no term before, there was no |
— | — | @@ -251,9 +230,9 @@ |
252 | 231 | // element at all. |
253 | 232 | // Only change element if found term before |
254 | 233 | if ( $changedElem ) { |
255 | | - $parent -> insertBefore( |
256 | | - $doc -> createTextNode( |
257 | | - substr( $el -> nodeValue, $lexemes[ $index ][ 1 ] ) |
| 234 | + $parent->insertBefore( |
| 235 | + $doc->createTextNode( |
| 236 | + substr( $el->nodeValue, $lexemes[$index][1] ) |
258 | 237 | ), |
259 | 238 | $el |
260 | 239 | ); |
— | — | @@ -263,30 +242,27 @@ |
264 | 243 | // anyway. Might save a bit of time. |
265 | 244 | break; |
266 | 245 | } |
267 | | - |
268 | | - $index += $skipped; |
269 | 246 | } |
270 | 247 | wfProfileOut( __METHOD__ . ' 5 insert' ); |
271 | 248 | |
272 | | - |
273 | | - $index += $used; |
| 249 | + $index += $used + $skipped; |
274 | 250 | } |
275 | 251 | |
276 | 252 | if ( $changedElem ) { |
277 | | - $parent -> removeChild( $el ); |
| 253 | + $parent->removeChild( $el ); |
278 | 254 | $changedDoc = true; |
279 | 255 | } |
280 | 256 | } |
281 | 257 | |
282 | 258 | if ( $changedDoc ) { |
283 | | - $body = $xpath -> query( '/html/body' ); |
| 259 | + $body = $xpath->query( '/html/body' ); |
284 | 260 | |
285 | 261 | $text = ''; |
286 | | - foreach ( $body -> item( 0 ) -> childNodes as $child ) { |
287 | | - $text .= $doc -> saveXML( $child ); |
| 262 | + foreach ( $body->item( 0 )->childNodes as $child ) { |
| 263 | + $text .= $doc->saveXML( $child ); |
288 | 264 | } |
289 | 265 | |
290 | | - $this -> loadModules( $parser ); |
| 266 | + $this->loadModules( $parser ); |
291 | 267 | } |
292 | 268 | |
293 | 269 | wfProfileOut( __METHOD__ ); |
— | — | @@ -294,20 +270,20 @@ |
295 | 271 | return true; |
296 | 272 | } |
297 | 273 | |
298 | | - protected function loadModules ( &$parser ) { |
| 274 | + protected function loadModules( &$parser ) { |
299 | 275 | global $wgOut, $wgScriptPath; |
300 | 276 | |
301 | 277 | if ( defined( 'MW_SUPPORTS_RESOURCE_MODULES' ) ) { |
302 | 278 | if ( !is_null( $parser ) ) { |
303 | | - $parser -> getOutput() -> addModules( 'ext.SemanticGlossary' ); |
| 279 | + $parser->getOutput()->addModules( 'ext.SemanticGlossary' ); |
304 | 280 | } else { |
305 | | - $wgOut -> addModules( 'ext.SemanticGlossary' ); |
| 281 | + $wgOut->addModules( 'ext.SemanticGlossary' ); |
306 | 282 | } |
307 | 283 | } else { |
308 | | - if ( !is_null( $parser ) && ( $wgOut -> isArticle() ) ) { |
309 | | - $parser -> getOutput() -> addHeadItem( '<link rel="stylesheet" href="' . $wgScriptPath . '/extensions/SemanticGlossary/skins/SemanticGlossary.css" />', 'ext.SemanticGlossary.css' ); |
| 284 | + if ( !is_null( $parser ) && ( $wgOut->isArticle() ) ) { |
| 285 | + $parser->getOutput()->addHeadItem( '<link rel="stylesheet" href="' . $wgScriptPath . '/extensions/SemanticGlossary/skins/SemanticGlossary.css" />', 'ext.SemanticGlossary.css' ); |
310 | 286 | } else { |
311 | | - $wgOut -> addHeadItem( 'ext.SemanticGlossary.css', '<link rel="stylesheet" href="' . $wgScriptPath . '/extensions/SemanticGlossary/skins/SemanticGlossary.css" />' ); |
| 287 | + $wgOut->addHeadItem( 'ext.SemanticGlossary.css', '<link rel="stylesheet" href="' . $wgScriptPath . '/extensions/SemanticGlossary/skins/SemanticGlossary.css" />' ); |
312 | 288 | } |
313 | 289 | } |
314 | 290 | } |
Index: trunk/extensions/SemanticGlossary/SemanticGlossary.php |
— | — | @@ -35,7 +35,7 @@ |
36 | 36 | $wgExtensionCredits[defined( 'SEMANTIC_EXTENSION_TYPE' ) ? 'semantic' : 'other'][] = array( |
37 | 37 | 'path' => __FILE__, |
38 | 38 | 'name' => 'Semantic Glossary', |
39 | | - 'author' => '[[mw:User:F.trott|Stephan Gambke]]', |
| 39 | + 'author' => '[http://www.mediawiki.org/wiki/User:F.trott|Stephan Gambke]', |
40 | 40 | 'url' => 'http://www.mediawiki.org/wiki/Extension:Semantic_Glossary', |
41 | 41 | 'descriptionmsg' => 'semanticglossary-desc', |
42 | 42 | 'version' => SG_VERSION, |
— | — | @@ -62,7 +62,7 @@ |
63 | 63 | $wgSpecialPageGroups['SemanticGlossaryBrowser'] = 'other'; |
64 | 64 | |
65 | 65 | // register hook handlers |
66 | | -//$wgHooks['ParserFirstCallInit'][] = 'SemanticGlossarySetup'; // Define a setup function |
| 66 | +// $wgHooks['ParserFirstCallInit'][] = 'SemanticGlossarySetup'; // Define a setup function |
67 | 67 | $wgHooks['ParserAfterTidy'][] = 'SemanticGlossaryParser::parse'; |
68 | 68 | |
69 | 69 | $wgHooks['smwInitProperties'][] = 'SemanticGlossaryRegisterProperties'; |
— | — | @@ -71,16 +71,16 @@ |
72 | 72 | // register resource modules with the Resource Loader |
73 | 73 | $wgResourceModules['ext.SemanticGlossary'] = array( |
74 | 74 | // JavaScript and CSS styles. To combine multiple file, just list them as an array. |
75 | | - //'scripts' => 'js/ext.myExtension.js', |
| 75 | + // 'scripts' => 'js/ext.myExtension.js', |
76 | 76 | 'styles' => 'css/SemanticGlossary.css', |
77 | 77 | |
78 | 78 | // When your module is loaded, these messages will be available to mediaWiki.msg() |
79 | | - //'messages' => array( 'myextension-hello-world', 'myextension-goodbye-world' ), |
| 79 | + // 'messages' => array( 'myextension-hello-world', 'myextension-goodbye-world' ), |
80 | 80 | |
81 | 81 | // If your scripts need code from other modules, list their identifiers as dependencies |
82 | 82 | // and ResourceLoader will make sure they're loaded before you. |
83 | 83 | // You don't need to manually list 'mediawiki' or 'jquery', which are always loaded. |
84 | | - //'dependencies' => array( 'jquery.ui.datepicker' ), |
| 84 | + // 'dependencies' => array( 'jquery.ui.datepicker' ), |
85 | 85 | |
86 | 86 | // ResourceLoader needs to know where your files are; specify your |
87 | 87 | // subdir relative to "extensions" or $wgExtensionAssetsPath |
— | — | @@ -100,10 +100,10 @@ |
101 | 101 | /** |
102 | 102 | * Handler for late setup of Semantic Glossary |
103 | 103 | */ |
104 | | -//function SemanticGlossarySetup () { |
| 104 | +// function SemanticGlossarySetup () { |
105 | 105 | // |
106 | 106 | // return true; |
107 | | -//} |
| 107 | +// } |
108 | 108 | |
109 | 109 | define( 'SG_PROP_GLT', 'Glossary-Term' ); |
110 | 110 | define( 'SG_PROP_GLD', 'Glossary-Definition' ); |
Index: trunk/extensions/SemanticGlossary/SemanticGlossaryTree.php |
— | — | @@ -2,7 +2,7 @@ |
3 | 3 | |
4 | 4 | /** |
5 | 5 | * File holding the SemanticGlossaryTree class |
6 | | - * |
| 6 | + * |
7 | 7 | * @author Stephan Gambke |
8 | 8 | * @file |
9 | 9 | * @ingroup SemanticGlossary |
— | — | @@ -40,7 +40,7 @@ |
41 | 41 | $matches; |
42 | 42 | preg_match_all( '/[[:alpha:]]+|[^[:alpha:]]/u', $term, $matches ); |
43 | 43 | |
44 | | - $this->addElement( $matches[0], $definition ); |
| 44 | + $this->addElement( $matches[0], $term, $definition ); |
45 | 45 | |
46 | 46 | if ( $this->mMinLength > -1 ) { |
47 | 47 | $this->mMinLength = min( array( $this->mMinLength, strlen( $term ) ) ); |
— | — | @@ -55,10 +55,10 @@ |
56 | 56 | * @param array $path |
57 | 57 | * @param <type> $index |
58 | 58 | */ |
59 | | - protected function addElement( Array &$path, &$definition ) { |
| 59 | + protected function addElement( Array &$path, &$term, &$definition ) { |
60 | 60 | // end of path, store description; end of recursion |
61 | 61 | if ( $path == null ) { |
62 | | - $this -> addDefinition( $definition ); |
| 62 | + $this -> addDefinition( $term, $definition ); |
63 | 63 | } else { |
64 | 64 | $step = array_shift( $path ); |
65 | 65 | |
— | — | @@ -66,7 +66,7 @@ |
67 | 67 | $this->mTree[$step] = new SemanticGlossaryTree(); |
68 | 68 | } |
69 | 69 | |
70 | | - $this->mTree[$step]->addElement( $path, $definition ); |
| 70 | + $this->mTree[$step]->addElement( $path, $term, $definition ); |
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
— | — | @@ -74,11 +74,11 @@ |
75 | 75 | * Adds a defintion to the treenodes list of definitions |
76 | 76 | * @param <type> $definition |
77 | 77 | */ |
78 | | - protected function addDefinition( &$definition ) { |
| 78 | + protected function addDefinition( &$term, &$definition ) { |
79 | 79 | if ( $this->mDefinition ) { |
80 | 80 | $this->mDefinition->addDefinition( $definition ); |
81 | 81 | } else { |
82 | | - $this->mDefinition = new SemanticGlossaryElement( $definition ); |
| 82 | + $this->mDefinition = new SemanticGlossaryElement( $term, $definition ); |
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
— | — | @@ -95,7 +95,7 @@ |
96 | 96 | // skip until ther start of a term is found |
97 | 97 | while ( $index < $countLexemes && !$definition ) { |
98 | 98 | $currLex = &$lexemes[$index][0]; |
99 | | - |
| 99 | + |
100 | 100 | // Did we find the start of a term? |
101 | 101 | if ( array_key_exists( $currLex, $this->mTree ) ) { |
102 | 102 | list( $lastindex, $definition ) = $this->mTree[$currLex]->findNextTermNoSkip( $lexemes, $index, $countLexemes ); |