Index: trunk/extensions/SemanticGlossary/SemanticGlossarySettings.php |
— | — | @@ -1,26 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -/** |
5 | | - * File holding the default settings for the Semantic Glossary extension |
6 | | - * |
7 | | - * @author Stephan Gambke |
8 | | - * |
9 | | - * @file |
10 | | - * @ingroup SemanticGlossary |
11 | | - */ |
12 | | -if ( !defined( 'SG_VERSION' ) ) { |
13 | | - die( 'This file is part of the Semantic Glossary extension, it is not a valid entry point.' ); |
14 | | -} |
15 | | - |
16 | | -/** |
17 | | - * Class to encapsulate Semantic Glossary settings |
18 | | - * @ingroup SemanticGlossary |
19 | | - */ |
20 | | -class SemanticGlossarySettings { |
21 | | - |
22 | | - /** |
23 | | - * @var Contains the characters that may not be part of a term. |
24 | | - */ |
25 | | - public $punctuationCharacters = '\.(),;:?!'; |
26 | | -} |
27 | | - |
Index: trunk/extensions/SemanticGlossary/SpecialSemanticGlossaryBrowser.php |
— | — | @@ -73,8 +73,7 @@ |
74 | 74 | foreach ( $glossaryarray as $term => $glossaryElement ) { |
75 | 75 | // One term may have several definitions. Include them all. |
76 | 76 | while ( ( $key = $glossaryElement->getCurrentKey() ) !== null ) { |
77 | | - $sourceArray = $glossaryElement->getSource( $key ); |
78 | | - $source = $sourceArray[2] . ':' . $sourceArray[1] . ':' . $sourceArray[0]; |
| 77 | + $source = $glossaryElement->getSource( $key ); |
79 | 78 | $definition = $glossaryElement->getDefinition( $key ); |
80 | 79 | $link = $glossaryElement->getLink( $key ); |
81 | 80 | |
Index: trunk/extensions/SemanticGlossary/SemanticGlossaryBackend.php |
— | — | @@ -0,0 +1,102 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * File holding the SemanticGlossaryBackend class |
| 6 | + * |
| 7 | + * @author Stephan Gambke |
| 8 | + * @file |
| 9 | + * @ingroup SemanticGlossary |
| 10 | + */ |
| 11 | +if ( !defined( 'SG_VERSION' ) ) { |
| 12 | + die( 'This file is part of the SemanticGlossary extension, it is not a valid entry point.' ); |
| 13 | +} |
| 14 | + |
| 15 | +/** |
| 16 | + * The SemanticGlossaryBackend class. |
| 17 | + * |
| 18 | + * @ingroup SemanticGlossary |
| 19 | + */ |
| 20 | +class SemanticGlossaryBackend { |
| 21 | + |
| 22 | + protected $mQueryResult; |
| 23 | + protected $mResultLine; |
| 24 | + protected $mMessageLog; |
| 25 | + protected $mTerm; |
| 26 | + protected $mDefinition; |
| 27 | + protected $mLink; |
| 28 | + protected $mSource; |
| 29 | + |
| 30 | + public function __construct ( SemanticGlossaryMessageLog &$messages = null ) { |
| 31 | + |
| 32 | + $this -> mMessageLog = $messages; |
| 33 | + |
| 34 | + $store = smwfGetStore(); // default store |
| 35 | + // Create query |
| 36 | + $desc = new SMWSomeProperty( new SMWDIProperty( '___glt' ), new SMWThingDescription() ); |
| 37 | + $desc -> addPrintRequest( new SMWPrintRequest( SMWPrintRequest::PRINT_PROP, null, SMWPropertyValue::makeProperty( '___glt' ) ) ); |
| 38 | + $desc -> addPrintRequest( new SMWPrintRequest( SMWPrintRequest::PRINT_PROP, null, SMWPropertyValue::makeProperty( '___gld' ) ) ); |
| 39 | + $desc -> addPrintRequest( new SMWPrintRequest( SMWPrintRequest::PRINT_PROP, null, SMWPropertyValue::makeProperty( '___gll' ) ) ); |
| 40 | + |
| 41 | + $query = new SMWQuery( $desc, false, false ); |
| 42 | + $query -> sort = true; |
| 43 | + $query -> sortkeys[ '___glt' ] = 'ASC'; |
| 44 | + |
| 45 | + // get the query result |
| 46 | + $this -> mQueryResult = $store -> getQueryResult( $query ); |
| 47 | + } |
| 48 | + |
| 49 | + public function next () { |
| 50 | + |
| 51 | + // find next line |
| 52 | + while ( $resultline = $this -> mQueryResult -> getNext() ) { |
| 53 | + $this -> mTerm = $resultline[ 0 ] -> getNextText( SMW_OUTPUT_HTML ); |
| 54 | + $this -> mDefinition = $resultline[ 1 ] -> getNextText( SMW_OUTPUT_HTML ); |
| 55 | + $this -> mLink = $resultline[ 2 ] -> getNextText( SMW_OUTPUT_HTML ); |
| 56 | + $this -> mSource = $resultline[ 0 ] -> getResultSubject() -> getTitle() -> getPrefixedText(); |
| 57 | + |
| 58 | + $nextTerm = $resultline[ 0 ] -> getNextText( SMW_OUTPUT_HTML ); |
| 59 | + $nextDefinition = $resultline[ 1 ] -> getNextText( SMW_OUTPUT_HTML ); |
| 60 | + $nextLink = $resultline[ 2 ] -> getNextText( SMW_OUTPUT_HTML ); |
| 61 | + |
| 62 | + |
| 63 | + // FIXME: SMW has a bug that right after storing data this data |
| 64 | + // might be available twice. The workaround here is to compare the |
| 65 | + // first and second result and if they are identical assume that |
| 66 | + // it is because of the bug. (2nd condition in the if below) |
| 67 | + // skip if more then one term or more than one definition present |
| 68 | + if ( ( $nextTerm || $nextDefinition || $nextLink ) && |
| 69 | + !( $nextTerm == $this -> mTerm && $nextDefinition == $this -> mDefinition && $nextLink == $this -> mLink ) ) { |
| 70 | + |
| 71 | + if ( $this -> mMessageLog ) { |
| 72 | + $this -> mMessageLog -> addMessage( |
| 73 | + wfMsg( 'semanticglossary-termdefinedtwice', array( $subject -> getTitle() -> getPrefixedText() ) ), |
| 74 | + SemanticGlossaryMessageLog::SG_WARNING ); |
| 75 | + } |
| 76 | + |
| 77 | + continue; |
| 78 | + } |
| 79 | + |
| 80 | + return true; |
| 81 | + } |
| 82 | + |
| 83 | + return $resultline != null; |
| 84 | + } |
| 85 | + |
| 86 | + function &getTerm () { |
| 87 | + return $this -> mTerm; |
| 88 | + } |
| 89 | + |
| 90 | + function &getDefinition () { |
| 91 | + return $this -> mDefinition; |
| 92 | + } |
| 93 | + |
| 94 | + function &getLink () { |
| 95 | + return $this -> mLink; |
| 96 | + } |
| 97 | + |
| 98 | + function &getSource () { |
| 99 | + return $this -> mSource; |
| 100 | + } |
| 101 | + |
| 102 | +} |
| 103 | + |
Property changes on: trunk/extensions/SemanticGlossary/SemanticGlossaryBackend.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 104 | + native |
Index: trunk/extensions/SemanticGlossary/SemanticGlossaryParser.php |
— | — | @@ -32,36 +32,40 @@ |
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 () { |
| 51 | + return new SemanticGlossaryBackend(); |
| 52 | + } |
| 53 | + |
50 | 54 | /** |
51 | 55 | * Returns the list of terms applicable in the current context |
52 | 56 | * |
53 | 57 | * @return Array an array mapping terms (keys) to descriptions (values) |
54 | 58 | */ |
55 | | - function getGlossaryArray( SemanticGlossaryMessageLog &$messages = null ) { |
| 59 | + function getGlossaryArray ( SemanticGlossaryMessageLog &$messages = null ) { |
56 | 60 | wfProfileIn( __METHOD__ ); |
57 | 61 | |
58 | 62 | // build glossary array only once per request |
59 | | - if ( !$this->mGlossaryArray ) { |
60 | | - $this->buildGlossary( $messages ); |
| 63 | + if ( !$this -> mGlossaryArray ) { |
| 64 | + $this -> buildGlossary( $messages ); |
61 | 65 | } |
62 | 66 | |
63 | 67 | wfProfileOut( __METHOD__ ); |
64 | 68 | |
65 | | - return $this->mGlossaryArray; |
| 69 | + return $this -> mGlossaryArray; |
66 | 70 | } |
67 | 71 | |
68 | 72 | /** |
— | — | @@ -69,90 +73,44 @@ |
70 | 74 | * |
71 | 75 | * @return Array an array mapping terms (keys) to descriptions (values) |
72 | 76 | */ |
73 | | - function getGlossaryTree( SemanticGlossaryMessageLog &$messages = null ) { |
| 77 | + function getGlossaryTree ( SemanticGlossaryMessageLog &$messages = null ) { |
74 | 78 | wfProfileIn( __METHOD__ ); |
75 | 79 | |
76 | 80 | // build glossary array only once per request |
77 | | - if ( !$this->mGlossaryTree ) { |
78 | | - $this->buildGlossary( $messages ); |
| 81 | + if ( !$this -> mGlossaryTree ) { |
| 82 | + $this -> buildGlossary( $messages ); |
79 | 83 | } |
80 | 84 | |
81 | 85 | wfProfileOut( __METHOD__ ); |
82 | 86 | |
83 | | - return $this->mGlossaryTree; |
| 87 | + return $this -> mGlossaryTree; |
84 | 88 | } |
85 | 89 | |
86 | | - protected function buildGlossary( SemanticGlossaryMessageLog &$messages = null ) { |
| 90 | + protected function buildGlossary ( SemanticGlossaryMessageLog &$messages = null ) { |
87 | 91 | wfProfileIn( __METHOD__ ); |
88 | 92 | |
89 | | - $this->mGlossaryTree = new SemanticGlossaryTree(); |
| 93 | + $this -> mGlossaryTree = new SemanticGlossaryTree(); |
90 | 94 | |
91 | | - $store = smwfGetStore(); // default store |
92 | | - // Create query |
93 | | - $desc = new SMWSomeProperty( new SMWDIProperty( '___glt' ), new SMWThingDescription() ); |
94 | | - $desc->addPrintRequest( new SMWPrintRequest( SMWPrintRequest::PRINT_PROP, null, SMWPropertyValue::makeProperty( '___glt' ) ) ); |
95 | | - $desc->addPrintRequest( new SMWPrintRequest( SMWPrintRequest::PRINT_PROP, null, SMWPropertyValue::makeProperty( '___gld' ) ) ); |
96 | | - $desc->addPrintRequest( new SMWPrintRequest( SMWPrintRequest::PRINT_PROP, null, SMWPropertyValue::makeProperty( '___gll' ) ) ); |
| 95 | + $backend = $this -> getBackEnd(); |
97 | 96 | |
98 | | - $query = new SMWQuery( $desc, true, false ); |
99 | | - $query->querymode = SMWQuery::MODE_INSTANCES; |
100 | | - |
101 | | - global $smwgQDefaultLimit; |
102 | | - $query->setLimit( $smwgQDefaultLimit ); |
103 | | - $query->sortkeys[SG_PROP_GLT] = 'ASC'; |
104 | | - |
105 | | - // get the query result |
106 | | - $queryresult = $store->getQueryResult( $query ); |
107 | | - |
108 | 97 | // assemble the result array |
109 | | - $this->mGlossaryArray = array(); |
110 | | - while ( ( $resultline = $queryresult->getNext() ) ) { |
111 | | - $term = $resultline[0]->getNextText( SMW_OUTPUT_HTML ); |
112 | | - $definition = $resultline[1]-> getNextText( SMW_OUTPUT_HTML ); |
113 | | - $link = $resultline[2]->getNextText( SMW_OUTPUT_HTML ); |
114 | | - $subject = $resultline[0]->getResultSubject(); |
| 98 | + $this -> mGlossaryArray = array( ); |
| 99 | + while ( $backend -> next() ) { |
115 | 100 | |
116 | | - // FIXME: SMW has a bug that right after storing data this data |
117 | | - // might be available twice. The workaround here is to compare the |
118 | | - // first and second result and if they are identical assume that |
119 | | - // it is because of the bug. (2nd condition in the if below) |
120 | | - |
121 | | - $nextTerm = $resultline[0]->getNextText( SMW_OUTPUT_HTML ); |
122 | | - $nextDefinition = $resultline[1]->getNextText( SMW_OUTPUT_HTML ); |
123 | | - |
124 | | - // skip if more then one term or more than one definition present |
125 | | - if ( ( $nextTerm || $nextDefinition ) && |
126 | | - !( $nextTerm == $term && $nextDefinition == $definition ) ) { |
127 | | - |
128 | | - if ( $messages ) { |
129 | | - $messages->addMessage( |
130 | | - wfMsg( 'semanticglossary-termdefinedtwice', array( $subject->getTitle()->getPrefixedText() ) ), |
131 | | - SemanticGlossaryMessageLog::SG_WARNING ); |
132 | | - } |
133 | | - |
134 | | - continue; |
135 | | - } |
136 | | - |
137 | | - $source = array( |
138 | | - $subject->getDBkey(), |
139 | | - $subject->getNamespace(), |
140 | | - $subject->getInterwiki() |
141 | | - ); |
142 | | - |
143 | 101 | $elementData = array( |
144 | | - SemanticGlossaryElement::SG_TERM => $term, |
145 | | - SemanticGlossaryElement::SG_DEFINITION => $definition, |
146 | | - SemanticGlossaryElement::SG_LINK => $link, |
147 | | - SemanticGlossaryElement::SG_SOURCE => $source |
| 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() |
148 | 106 | ); |
149 | 107 | |
150 | | - if ( array_key_exists( $term, $this->mGlossaryArray ) ) { |
151 | | - $this->mGlossaryArray[$term]->addDefinition( $elementData ); |
| 108 | + if ( array_key_exists( $term, $this -> mGlossaryArray ) ) { |
| 109 | + $this -> mGlossaryArray[ $term ] -> addDefinition( $elementData ); |
152 | 110 | } else { |
153 | | - $this->mGlossaryArray[$term] = new SemanticGlossaryElement( $elementData ); |
| 111 | + $this -> mGlossaryArray[ $term ] = new SemanticGlossaryElement( $elementData ); |
154 | 112 | } |
155 | 113 | |
156 | | - $this->mGlossaryTree->addTerm( $term, $elementData ); |
| 114 | + $this -> mGlossaryTree -> addTerm( $term, $elementData ); |
157 | 115 | } |
158 | 116 | |
159 | 117 | wfProfileOut( __METHOD__ ); |
— | — | @@ -167,18 +125,18 @@ |
168 | 126 | * @param $text |
169 | 127 | * @return Boolean |
170 | 128 | */ |
171 | | - protected function realParse( &$parser, &$text ) { |
172 | | - global $wgRequest, $sggSettings; |
| 129 | + protected function realParse ( &$parser, &$text ) { |
| 130 | + global $wgRequest; |
173 | 131 | |
174 | 132 | wfProfileIn( __METHOD__ ); |
175 | 133 | |
176 | | - $action = $wgRequest->getVal( 'action', 'view' ); |
| 134 | + $action = $wgRequest -> getVal( 'action', 'view' ); |
177 | 135 | |
178 | 136 | if ( $text == null || |
179 | 137 | $text == '' || |
180 | 138 | $action == 'edit' || |
181 | 139 | $action == 'ajax' || |
182 | | - isset( $_POST['wpPreview'] ) |
| 140 | + isset( $_POST[ 'wpPreview' ] ) |
183 | 141 | ) { |
184 | 142 | |
185 | 143 | wfProfileOut( __METHOD__ ); |
— | — | @@ -186,7 +144,7 @@ |
187 | 145 | } |
188 | 146 | |
189 | 147 | // Get array of terms |
190 | | - $glossary = $this->getGlossaryTree(); |
| 148 | + $glossary = $this -> getGlossaryTree(); |
191 | 149 | |
192 | 150 | if ( $glossary == null ) { |
193 | 151 | wfProfileOut( __METHOD__ ); |
— | — | @@ -199,7 +157,7 @@ |
200 | 158 | wfSuppressWarnings(); |
201 | 159 | |
202 | 160 | $doc = DOMDocument::loadHTML( |
203 | | - '<html><meta http-equiv="content-type" content="charset=utf-8"/>' . $text . '</html>' |
| 161 | + '<html><meta http-equiv="content-type" content="charset=utf-8"/>' . $text . '</html>' |
204 | 162 | ); |
205 | 163 | |
206 | 164 | wfRestoreWarnings(); |
— | — | @@ -208,55 +166,55 @@ |
209 | 167 | wfProfileIn( __METHOD__ . ' 2 xpath' ); |
210 | 168 | // Find all text in HTML. |
211 | 169 | $xpath = new DOMXpath( $doc ); |
212 | | - $elements = $xpath->query( |
213 | | - "//*[not(ancestor-or-self::*[@class='noglossary'] or ancestor-or-self::a)][text()!=' ']/text()" |
| 170 | + $elements = $xpath -> query( |
| 171 | + "//*[not(ancestor-or-self::*[@class='noglossary'] or ancestor-or-self::a)][text()!=' ']/text()" |
214 | 172 | ); |
215 | 173 | wfProfileOut( __METHOD__ . ' 2 xpath' ); |
216 | 174 | |
217 | 175 | // Iterate all HTML text matches |
218 | | - $nb = $elements->length; |
| 176 | + $nb = $elements -> length; |
219 | 177 | $changedDoc = false; |
220 | 178 | |
221 | 179 | for ( $pos = 0; $pos < $nb; $pos++ ) { |
222 | | - $el = $elements->item( $pos ); |
| 180 | + $el = $elements -> item( $pos ); |
223 | 181 | |
224 | | - if ( strlen( $el->nodeValue ) < $glossary->getMinTermLength() ) { |
| 182 | + if ( strlen( $el -> nodeValue ) < $glossary -> getMinTermLength() ) { |
225 | 183 | continue; |
226 | 184 | } |
227 | 185 | |
228 | 186 | wfProfileIn( __METHOD__ . ' 3 lexer' ); |
229 | | - $matches = array(); |
| 187 | + $matches = array( ); |
230 | 188 | preg_match_all( |
231 | 189 | '/[[:alpha:]]+|[^[:alpha:]]/u', |
232 | | - $el->nodeValue, |
| 190 | + $el -> nodeValue, |
233 | 191 | $matches, |
234 | 192 | PREG_OFFSET_CAPTURE | PREG_PATTERN_ORDER |
235 | 193 | ); |
236 | 194 | wfProfileOut( __METHOD__ . ' 3 lexer' ); |
237 | 195 | |
238 | | - if ( count( $matches ) == 0 || count( $matches[0] ) == 0 ) { |
| 196 | + if ( count( $matches ) == 0 || count( $matches[ 0 ] ) == 0 ) { |
239 | 197 | continue; |
240 | 198 | } |
241 | 199 | |
242 | | - $lexemes = &$matches[0]; |
| 200 | + $lexemes = &$matches[ 0 ]; |
243 | 201 | $countLexemes = count( $lexemes ); |
244 | | - $parent = &$el->parentNode; |
| 202 | + $parent = &$el -> parentNode; |
245 | 203 | $index = 0; |
246 | 204 | $changedElem = false; |
247 | 205 | |
248 | 206 | while ( $index < $countLexemes ) { |
249 | 207 | wfProfileIn( __METHOD__ . ' 4 findNextTerm' ); |
250 | | - list( $skipped, $used, $definition ) = $glossary->findNextTerm( $lexemes, $index, $countLexemes ); |
| 208 | + list( $skipped, $used, $definition ) = $glossary -> findNextTerm( $lexemes, $index, $countLexemes ); |
251 | 209 | wfProfileOut( __METHOD__ . ' 4 findNextTerm' ); |
252 | 210 | |
253 | 211 | wfProfileIn( __METHOD__ . ' 5 insert' ); |
254 | 212 | if ( $used > 0 ) { // found a term |
255 | 213 | if ( $skipped > 0 ) { // skipped some text, insert it as is |
256 | | - $parent->insertBefore( |
257 | | - $doc->createTextNode( |
258 | | - substr( $el->nodeValue, |
259 | | - $currLexIndex = $lexemes[$index][1], |
260 | | - $lexemes[$index + $skipped][1] - $currLexIndex ) |
| 214 | + $parent -> insertBefore( |
| 215 | + $doc -> createTextNode( |
| 216 | + substr( $el -> nodeValue, |
| 217 | + $currLexIndex = $lexemes[ $index ][ 1 ], |
| 218 | + $lexemes[ $index + $skipped ][ 1 ] - $currLexIndex ) |
261 | 219 | ), |
262 | 220 | $el |
263 | 221 | ); |
— | — | @@ -269,22 +227,22 @@ |
270 | 228 | $span -> setAttribute( 'class', 'tooltip' ); |
271 | 229 | |
272 | 230 | // Wrap abbreviation in <span> tags, hidden |
273 | | - $lastLex = $lexemes[$index + $used - 1]; |
274 | | - $spanTerm = $doc->createElement( 'span', |
275 | | - substr( $el->nodeValue, |
276 | | - $currLexIndex = $lexemes[$index][1], |
277 | | - $lastLex[1] - $currLexIndex + strlen( $lastLex[0] ) ) |
| 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 ] ) ) |
278 | 236 | ); |
279 | | - $spanTerm->setAttribute( 'class', 'tooltip_abbr' ); |
| 237 | + $spanTerm -> setAttribute( 'class', 'tooltip_abbr' ); |
280 | 238 | |
281 | 239 | // Wrap definition in <span> tags, hidden |
282 | | - $spanDefinition = $definition->getFullDefinition( $doc ); |
283 | | - $spanDefinition->setAttribute( 'class', 'tooltip_tip' ); |
| 240 | + $spanDefinition = $definition -> getFullDefinition( $doc ); |
| 241 | + $spanDefinition -> setAttribute( 'class', 'tooltip_tip' ); |
284 | 242 | |
285 | 243 | // insert term and definition |
286 | | - $span->appendChild( $spanTerm ); |
287 | | - $span->appendChild( $spanDefinition ); |
288 | | - $parent->insertBefore( $span, $el ); |
| 244 | + $span -> appendChild( $spanTerm ); |
| 245 | + $span -> appendChild( $spanDefinition ); |
| 246 | + $parent -> insertBefore( $span, $el ); |
289 | 247 | |
290 | 248 | $changedElem = true; |
291 | 249 | } else { // did not find term, just use the rest of the text |
— | — | @@ -293,9 +251,9 @@ |
294 | 252 | // element at all. |
295 | 253 | // Only change element if found term before |
296 | 254 | if ( $changedElem ) { |
297 | | - $parent->insertBefore( |
298 | | - $doc->createTextNode( |
299 | | - substr( $el->nodeValue, $lexemes[$index][1] ) |
| 255 | + $parent -> insertBefore( |
| 256 | + $doc -> createTextNode( |
| 257 | + substr( $el -> nodeValue, $lexemes[ $index ][ 1 ] ) |
300 | 258 | ), |
301 | 259 | $el |
302 | 260 | ); |
— | — | @@ -315,21 +273,20 @@ |
316 | 274 | } |
317 | 275 | |
318 | 276 | if ( $changedElem ) { |
319 | | - $parent->removeChild( $el ); |
| 277 | + $parent -> removeChild( $el ); |
320 | 278 | $changedDoc = true; |
321 | 279 | } |
322 | | - |
323 | 280 | } |
324 | 281 | |
325 | 282 | if ( $changedDoc ) { |
326 | | - $body = $xpath->query( '/html/body' ); |
| 283 | + $body = $xpath -> query( '/html/body' ); |
327 | 284 | |
328 | 285 | $text = ''; |
329 | | - foreach ( $body->item( 0 )->childNodes as $child ) { |
330 | | - $text .= $doc->saveXML( $child ); |
| 286 | + foreach ( $body -> item( 0 ) -> childNodes as $child ) { |
| 287 | + $text .= $doc -> saveXML( $child ); |
331 | 288 | } |
332 | 289 | |
333 | | - $this->loadModules( $parser ); |
| 290 | + $this -> loadModules( $parser ); |
334 | 291 | } |
335 | 292 | |
336 | 293 | wfProfileOut( __METHOD__ ); |
— | — | @@ -337,20 +294,20 @@ |
338 | 295 | return true; |
339 | 296 | } |
340 | 297 | |
341 | | - protected function loadModules( &$parser ) { |
| 298 | + protected function loadModules ( &$parser ) { |
342 | 299 | global $wgOut, $wgScriptPath; |
343 | 300 | |
344 | 301 | if ( defined( 'MW_SUPPORTS_RESOURCE_MODULES' ) ) { |
345 | 302 | if ( !is_null( $parser ) ) { |
346 | | - $parser->getOutput()->addModules( 'ext.SemanticGlossary' ); |
| 303 | + $parser -> getOutput() -> addModules( 'ext.SemanticGlossary' ); |
347 | 304 | } else { |
348 | | - $wgOut->addModules( 'ext.SemanticGlossary' ); |
| 305 | + $wgOut -> addModules( 'ext.SemanticGlossary' ); |
349 | 306 | } |
350 | 307 | } else { |
351 | | - if ( !is_null( $parser ) && ( $wgOut->isArticle() ) ) { |
352 | | - $parser->getOutput()->addHeadItem( '<link rel="stylesheet" href="' . $wgScriptPath . '/extensions/SemanticGlossary/skins/SemanticGlossary.css" />', 'ext.SemanticGlossary.css' ); |
| 308 | + if ( !is_null( $parser ) && ( $wgOut -> isArticle() ) ) { |
| 309 | + $parser -> getOutput() -> addHeadItem( '<link rel="stylesheet" href="' . $wgScriptPath . '/extensions/SemanticGlossary/skins/SemanticGlossary.css" />', 'ext.SemanticGlossary.css' ); |
353 | 310 | } else { |
354 | | - $wgOut->addHeadItem( 'ext.SemanticGlossary.css', '<link rel="stylesheet" href="' . $wgScriptPath . '/extensions/SemanticGlossary/skins/SemanticGlossary.css" />' ); |
| 311 | + $wgOut -> addHeadItem( 'ext.SemanticGlossary.css', '<link rel="stylesheet" href="' . $wgScriptPath . '/extensions/SemanticGlossary/skins/SemanticGlossary.css" />' ); |
355 | 312 | } |
356 | 313 | } |
357 | 314 | } |
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' => '[http://www.mediawiki.org/wiki/User:F.trott Stephan Gambke]', |
| 39 | + 'author' => '[[mw: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, |
— | — | @@ -53,6 +53,7 @@ |
54 | 54 | $wgAutoloadClasses['SemanticGlossaryParser'] = $dir . '/SemanticGlossaryParser.php'; |
55 | 55 | $wgAutoloadClasses['SemanticGlossaryTree'] = $dir . '/SemanticGlossaryTree.php'; |
56 | 56 | $wgAutoloadClasses['SemanticGlossaryElement'] = $dir . '/SemanticGlossaryElement.php'; |
| 57 | +$wgAutoloadClasses['SemanticGlossaryBackend'] = $dir . '/SemanticGlossaryBackend.php'; |
57 | 58 | $wgAutoloadClasses['SemanticGlossaryMessageLog'] = $dir . '/SemanticGlossaryMessageLog.php'; |
58 | 59 | $wgAutoloadClasses['SpecialSemanticGlossaryBrowser'] = $dir . '/SpecialSemanticGlossaryBrowser.php'; |
59 | 60 | |
— | — | @@ -96,9 +97,6 @@ |
97 | 98 | // Create new permission 'editglossary' and assign it to usergroup 'user' by default |
98 | 99 | $wgGroupPermissions['user']['editglossary'] = true; |
99 | 100 | |
100 | | -// create and initialize settings object |
101 | | -$sggSettings = new SemanticGlossarySettings(); |
102 | | - |
103 | 101 | /** |
104 | 102 | * Handler for late setup of Semantic Glossary |
105 | 103 | */ |