@@ -36,6 +36,9 @@ |
||
| 36 | 36 | $this->mLingoBackend = new $wgexLingoBackend( $messages ); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | + /** |
|
| 40 | + * @return string |
|
| 41 | + */ |
|
| 39 | 42 | private static function uniqPrefix( Parser &$parser) { |
| 40 | 43 | if ( defined("Parser::MARKER_PREFIX" )) { |
| 41 | 44 | return Parser::MARKER_PREFIX; |
@@ -30,14 +30,14 @@ discard block |
||
| 30 | 30 | // The RegEx to split a chunk of text into words |
| 31 | 31 | public static $regex = null; |
| 32 | 32 | |
| 33 | - public function __construct( LingoMessageLog &$messages = null ) { |
|
| 33 | + public function __construct(LingoMessageLog&$messages = null) { |
|
| 34 | 34 | global $wgexLingoBackend; |
| 35 | 35 | |
| 36 | - $this->mLingoBackend = new $wgexLingoBackend( $messages ); |
|
| 36 | + $this->mLingoBackend = new $wgexLingoBackend($messages); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - private static function uniqPrefix( Parser &$parser) { |
|
| 40 | - if ( defined("Parser::MARKER_PREFIX" )) { |
|
| 39 | + private static function uniqPrefix(Parser&$parser) { |
|
| 40 | + if (defined("Parser::MARKER_PREFIX")) { |
|
| 41 | 41 | return Parser::MARKER_PREFIX; |
| 42 | 42 | } else { |
| 43 | 43 | return $parser->uniqPrefix(); |
@@ -50,19 +50,19 @@ discard block |
||
| 50 | 50 | * @param string $text |
| 51 | 51 | * @return Boolean |
| 52 | 52 | */ |
| 53 | - static function parse( Parser &$parser, &$text ) { |
|
| 54 | - wfProfileIn( __METHOD__ ); |
|
| 55 | - if ( !self::$parserSingleton ) { |
|
| 53 | + static function parse(Parser&$parser, &$text) { |
|
| 54 | + wfProfileIn(__METHOD__); |
|
| 55 | + if (!self::$parserSingleton) { |
|
| 56 | 56 | self::$parserSingleton = new LingoParser(); |
| 57 | 57 | |
| 58 | 58 | // The RegEx to split a chunk of text into words |
| 59 | 59 | // Words are: placeholders for stripped items, sequences of letters and numbers, single characters that are neither letter nor number |
| 60 | - self::$regex = '/' . preg_quote( self::uniqPrefix($parser), '/' ) . '.*?' . preg_quote( Parser::MARKER_SUFFIX, '/' ) . '|[\p{L}\p{N}]+|[^\p{L}\p{N}]/u'; |
|
| 60 | + self::$regex = '/'.preg_quote(self::uniqPrefix($parser), '/').'.*?'.preg_quote(Parser::MARKER_SUFFIX, '/').'|[\p{L}\p{N}]+|[^\p{L}\p{N}]/u'; |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - self::$parserSingleton->realParse( $parser, $text ); |
|
| 63 | + self::$parserSingleton->realParse($parser, $text); |
|
| 64 | 64 | |
| 65 | - wfProfileOut( __METHOD__ ); |
|
| 65 | + wfProfileOut(__METHOD__); |
|
| 66 | 66 | |
| 67 | 67 | return true; |
| 68 | 68 | } |
@@ -81,14 +81,14 @@ discard block |
||
| 81 | 81 | * @return Array an array mapping terms (keys) to descriptions (values) |
| 82 | 82 | */ |
| 83 | 83 | function getLingoArray() { |
| 84 | - wfProfileIn( __METHOD__ ); |
|
| 84 | + wfProfileIn(__METHOD__); |
|
| 85 | 85 | |
| 86 | 86 | // build glossary array only once per request |
| 87 | - if ( !$this->mLingoTree ) { |
|
| 87 | + if (!$this->mLingoTree) { |
|
| 88 | 88 | $this->buildLingo(); |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - wfProfileOut( __METHOD__ ); |
|
| 91 | + wfProfileOut(__METHOD__); |
|
| 92 | 92 | |
| 93 | 93 | return $this->mLingoTree->getTermList(); |
| 94 | 94 | } |
@@ -99,57 +99,57 @@ discard block |
||
| 99 | 99 | * @return LingoTree a LingoTree mapping terms (keys) to descriptions (values) |
| 100 | 100 | */ |
| 101 | 101 | function getLingoTree() { |
| 102 | - wfProfileIn( __METHOD__ ); |
|
| 102 | + wfProfileIn(__METHOD__); |
|
| 103 | 103 | |
| 104 | 104 | // build glossary array only once per request |
| 105 | - if ( !$this->mLingoTree ) { |
|
| 105 | + if (!$this->mLingoTree) { |
|
| 106 | 106 | |
| 107 | 107 | // use cache if enabled |
| 108 | - if ( $this->mLingoBackend->useCache() ) { |
|
| 108 | + if ($this->mLingoBackend->useCache()) { |
|
| 109 | 109 | |
| 110 | 110 | // Try cache first |
| 111 | 111 | global $wgexLingoCacheType; |
| 112 | - $cache = ($wgexLingoCacheType !== null)? wfGetCache( $wgexLingoCacheType ):wfGetMainCache(); |
|
| 113 | - $cachekey = wfMemcKey( 'ext', 'lingo', 'lingotree' ); |
|
| 114 | - $cachedLingoTree = $cache->get( $cachekey ); |
|
| 112 | + $cache = ($wgexLingoCacheType !== null) ? wfGetCache($wgexLingoCacheType) : wfGetMainCache(); |
|
| 113 | + $cachekey = wfMemcKey('ext', 'lingo', 'lingotree'); |
|
| 114 | + $cachedLingoTree = $cache->get($cachekey); |
|
| 115 | 115 | |
| 116 | 116 | // cache hit? |
| 117 | - if ( $cachedLingoTree !== false && $cachedLingoTree !== null ) { |
|
| 117 | + if ($cachedLingoTree !== false && $cachedLingoTree !== null) { |
|
| 118 | 118 | |
| 119 | - wfDebug( "Cache hit: Got lingo tree from cache.\n" ); |
|
| 119 | + wfDebug("Cache hit: Got lingo tree from cache.\n"); |
|
| 120 | 120 | $this->mLingoTree = &$cachedLingoTree; |
| 121 | 121 | |
| 122 | 122 | } else { |
| 123 | 123 | |
| 124 | - wfDebug( "Cache miss: Lingo tree not found in cache.\n" ); |
|
| 125 | - $this->mLingoTree =& $this->buildLingo(); |
|
| 126 | - $cache->set( $cachekey, $this->mLingoTree ); |
|
| 127 | - wfDebug( "Cached lingo tree.\n" ); |
|
| 124 | + wfDebug("Cache miss: Lingo tree not found in cache.\n"); |
|
| 125 | + $this->mLingoTree = & $this->buildLingo(); |
|
| 126 | + $cache->set($cachekey, $this->mLingoTree); |
|
| 127 | + wfDebug("Cached lingo tree.\n"); |
|
| 128 | 128 | } |
| 129 | 129 | } else { |
| 130 | - wfDebug( "Caching of lingo tree disabled.\n" ); |
|
| 131 | - $this->mLingoTree =& $this->buildLingo(); |
|
| 130 | + wfDebug("Caching of lingo tree disabled.\n"); |
|
| 131 | + $this->mLingoTree = & $this->buildLingo(); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - wfProfileOut( __METHOD__ ); |
|
| 136 | + wfProfileOut(__METHOD__); |
|
| 137 | 137 | |
| 138 | 138 | return $this->mLingoTree; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | protected function &buildLingo() { |
| 142 | - wfProfileIn( __METHOD__ ); |
|
| 142 | + wfProfileIn(__METHOD__); |
|
| 143 | 143 | |
| 144 | 144 | $lingoTree = new LingoTree(); |
| 145 | 145 | $backend = &$this->mLingoBackend; |
| 146 | 146 | |
| 147 | 147 | // assemble the result array |
| 148 | - while ( $elementData = $backend->next() ) { |
|
| 149 | - $lingoTree->addTerm( $elementData[LingoElement::ELEMENT_TERM], $elementData ); |
|
| 148 | + while ($elementData = $backend->next()) { |
|
| 149 | + $lingoTree->addTerm($elementData[LingoElement::ELEMENT_TERM], $elementData); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - wfProfileOut( __METHOD__ ); |
|
| 152 | + wfProfileOut(__METHOD__); |
|
| 153 | 153 | return $lingoTree; |
| 154 | 154 | } |
| 155 | 155 | |
@@ -162,101 +162,101 @@ discard block |
||
| 162 | 162 | * @param $text |
| 163 | 163 | * @return Boolean |
| 164 | 164 | */ |
| 165 | - protected function realParse( &$parser, &$text ) { |
|
| 165 | + protected function realParse(&$parser, &$text) { |
|
| 166 | 166 | global $wgRequest; |
| 167 | 167 | |
| 168 | - wfProfileIn( __METHOD__ ); |
|
| 168 | + wfProfileIn(__METHOD__); |
|
| 169 | 169 | |
| 170 | - $action = $wgRequest->getVal( 'action', 'view' ); |
|
| 170 | + $action = $wgRequest->getVal('action', 'view'); |
|
| 171 | 171 | |
| 172 | - if ( $text === null || |
|
| 172 | + if ($text === null || |
|
| 173 | 173 | $text === '' || |
| 174 | 174 | $action === 'edit' || |
| 175 | 175 | $action === 'ajax' || |
| 176 | - isset( $_POST['wpPreview'] ) |
|
| 176 | + isset($_POST['wpPreview']) |
|
| 177 | 177 | ) { |
| 178 | 178 | |
| 179 | - wfProfileOut( __METHOD__ ); |
|
| 179 | + wfProfileOut(__METHOD__); |
|
| 180 | 180 | return true; |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | // Get array of terms |
| 184 | 184 | $glossary = $this->getLingoTree(); |
| 185 | 185 | |
| 186 | - if ( $glossary == null ) { |
|
| 187 | - wfProfileOut( __METHOD__ ); |
|
| 186 | + if ($glossary == null) { |
|
| 187 | + wfProfileOut(__METHOD__); |
|
| 188 | 188 | return true; |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | // Parse HTML from page |
| 192 | - wfProfileIn( __METHOD__ . ' 1 loadHTML' ); |
|
| 192 | + wfProfileIn(__METHOD__.' 1 loadHTML'); |
|
| 193 | 193 | wfSuppressWarnings(); |
| 194 | 194 | |
| 195 | - $doc = new DOMDocument('1.0','utf-8'); |
|
| 196 | - $doc->loadHTML( '<html><head><meta http-equiv="content-type" content="charset=utf-8"/></head><body>' . $text . '</body></html>' ); |
|
| 195 | + $doc = new DOMDocument('1.0', 'utf-8'); |
|
| 196 | + $doc->loadHTML('<html><head><meta http-equiv="content-type" content="charset=utf-8"/></head><body>'.$text.'</body></html>'); |
|
| 197 | 197 | |
| 198 | 198 | wfRestoreWarnings(); |
| 199 | - wfProfileOut( __METHOD__ . ' 1 loadHTML' ); |
|
| 199 | + wfProfileOut(__METHOD__.' 1 loadHTML'); |
|
| 200 | 200 | |
| 201 | - wfProfileIn( __METHOD__ . ' 2 xpath' ); |
|
| 201 | + wfProfileIn(__METHOD__.' 2 xpath'); |
|
| 202 | 202 | // Find all text in HTML. |
| 203 | - $xpath = new DOMXpath( $doc ); |
|
| 203 | + $xpath = new DOMXpath($doc); |
|
| 204 | 204 | $elements = $xpath->query( |
| 205 | 205 | "//*[not(ancestor-or-self::*[@class='noglossary'] or ancestor-or-self::a)][text()!=' ']/text()" |
| 206 | 206 | ); |
| 207 | - wfProfileOut( __METHOD__ . ' 2 xpath' ); |
|
| 207 | + wfProfileOut(__METHOD__.' 2 xpath'); |
|
| 208 | 208 | |
| 209 | 209 | // Iterate all HTML text matches |
| 210 | 210 | $nb = $elements->length; |
| 211 | 211 | $changedDoc = false; |
| 212 | 212 | |
| 213 | - for ( $pos = 0; $pos < $nb; $pos++ ) { |
|
| 214 | - $el = $elements->item( $pos ); |
|
| 213 | + for ($pos = 0; $pos < $nb; $pos++) { |
|
| 214 | + $el = $elements->item($pos); |
|
| 215 | 215 | |
| 216 | - if ( strlen( $el->nodeValue ) < $glossary->getMinTermLength() ) { |
|
| 216 | + if (strlen($el->nodeValue) < $glossary->getMinTermLength()) { |
|
| 217 | 217 | continue; |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | - wfProfileIn( __METHOD__ . ' 3 lexer' ); |
|
| 220 | + wfProfileIn(__METHOD__.' 3 lexer'); |
|
| 221 | 221 | $matches = array(); |
| 222 | 222 | preg_match_all( |
| 223 | 223 | self::$regex, |
| 224 | 224 | $el->nodeValue, |
| 225 | 225 | $matches, |
| 226 | - PREG_OFFSET_CAPTURE | PREG_PATTERN_ORDER |
|
| 226 | + PREG_OFFSET_CAPTURE|PREG_PATTERN_ORDER |
|
| 227 | 227 | ); |
| 228 | - wfProfileOut( __METHOD__ . ' 3 lexer' ); |
|
| 228 | + wfProfileOut(__METHOD__.' 3 lexer'); |
|
| 229 | 229 | |
| 230 | - if ( count( $matches ) == 0 || count( $matches[0] ) == 0 ) { |
|
| 230 | + if (count($matches) == 0 || count($matches[0]) == 0) { |
|
| 231 | 231 | continue; |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | $lexemes = &$matches[0]; |
| 235 | - $countLexemes = count( $lexemes ); |
|
| 235 | + $countLexemes = count($lexemes); |
|
| 236 | 236 | $parent = &$el->parentNode; |
| 237 | 237 | $index = 0; |
| 238 | 238 | $changedElem = false; |
| 239 | 239 | |
| 240 | - while ( $index < $countLexemes ) { |
|
| 241 | - wfProfileIn( __METHOD__ . ' 4 findNextTerm' ); |
|
| 242 | - list( $skipped, $used, $definition ) = |
|
| 243 | - $glossary->findNextTerm( $lexemes, $index, $countLexemes ); |
|
| 244 | - wfProfileOut( __METHOD__ . ' 4 findNextTerm' ); |
|
| 240 | + while ($index < $countLexemes) { |
|
| 241 | + wfProfileIn(__METHOD__.' 4 findNextTerm'); |
|
| 242 | + list($skipped, $used, $definition) = |
|
| 243 | + $glossary->findNextTerm($lexemes, $index, $countLexemes); |
|
| 244 | + wfProfileOut(__METHOD__.' 4 findNextTerm'); |
|
| 245 | 245 | |
| 246 | - wfProfileIn( __METHOD__ . ' 5 insert' ); |
|
| 247 | - if ( $used > 0 ) { // found a term |
|
| 248 | - if ( $skipped > 0 ) { // skipped some text, insert it as is |
|
| 246 | + wfProfileIn(__METHOD__.' 5 insert'); |
|
| 247 | + if ($used > 0) { // found a term |
|
| 248 | + if ($skipped > 0) { // skipped some text, insert it as is |
|
| 249 | 249 | $parent->insertBefore( |
| 250 | 250 | $doc->createTextNode( |
| 251 | - substr( $el->nodeValue, |
|
| 251 | + substr($el->nodeValue, |
|
| 252 | 252 | $currLexIndex = $lexemes[$index][1], |
| 253 | - $lexemes[$index + $skipped][1] - $currLexIndex ) |
|
| 253 | + $lexemes[$index + $skipped][1] - $currLexIndex) |
|
| 254 | 254 | ), |
| 255 | 255 | $el |
| 256 | 256 | ); |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - $parent->insertBefore( $definition->getFullDefinition( $doc ), $el ); |
|
| 259 | + $parent->insertBefore($definition->getFullDefinition($doc), $el); |
|
| 260 | 260 | |
| 261 | 261 | $changedElem = true; |
| 262 | 262 | } else { // did not find term, just use the rest of the text |
@@ -264,76 +264,76 @@ discard block |
||
| 264 | 264 | // term in the whole element. Might as well not change the |
| 265 | 265 | // element at all. |
| 266 | 266 | // Only change element if found term before |
| 267 | - if ( $changedElem ) { |
|
| 267 | + if ($changedElem) { |
|
| 268 | 268 | $parent->insertBefore( |
| 269 | 269 | $doc->createTextNode( |
| 270 | - substr( $el->nodeValue, $lexemes[$index][1] ) |
|
| 270 | + substr($el->nodeValue, $lexemes[$index][1]) |
|
| 271 | 271 | ), |
| 272 | 272 | $el |
| 273 | 273 | ); |
| 274 | 274 | } else { |
| 275 | - wfProfileOut( __METHOD__ . ' 5 insert' ); |
|
| 275 | + wfProfileOut(__METHOD__.' 5 insert'); |
|
| 276 | 276 | // In principle superfluous, the loop would run out |
| 277 | 277 | // anyway. Might save a bit of time. |
| 278 | 278 | break; |
| 279 | 279 | } |
| 280 | 280 | } |
| 281 | - wfProfileOut( __METHOD__ . ' 5 insert' ); |
|
| 281 | + wfProfileOut(__METHOD__.' 5 insert'); |
|
| 282 | 282 | |
| 283 | 283 | $index += $used + $skipped; |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | - if ( $changedElem ) { |
|
| 287 | - $parent->removeChild( $el ); |
|
| 286 | + if ($changedElem) { |
|
| 287 | + $parent->removeChild($el); |
|
| 288 | 288 | $changedDoc = true; |
| 289 | 289 | } |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | - if ( $changedDoc ) { |
|
| 293 | - $this->loadModules( $parser ); |
|
| 292 | + if ($changedDoc) { |
|
| 293 | + $this->loadModules($parser); |
|
| 294 | 294 | |
| 295 | 295 | // U - Ungreedy, D - dollar matches only end of string, s - dot matches newlines |
| 296 | - $text = preg_replace( '%(^.*<body>)|(</body>.*$)%UDs', '', $doc->saveHTML() ); |
|
| 296 | + $text = preg_replace('%(^.*<body>)|(</body>.*$)%UDs', '', $doc->saveHTML()); |
|
| 297 | 297 | } |
| 298 | 298 | |
| 299 | - wfProfileOut( __METHOD__ ); |
|
| 299 | + wfProfileOut(__METHOD__); |
|
| 300 | 300 | |
| 301 | 301 | return true; |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | - protected function loadModules( &$parser ) { |
|
| 304 | + protected function loadModules(&$parser) { |
|
| 305 | 305 | global $wgOut, $wgScriptPath; |
| 306 | 306 | |
| 307 | 307 | $parserOutput = $parser->getOutput(); |
| 308 | 308 | |
| 309 | 309 | // load scripts |
| 310 | - if ( defined( 'MW_SUPPORTS_RESOURCE_MODULES' ) ) { |
|
| 311 | - $parserOutput->addModules( 'ext.Lingo.Scripts' ); |
|
| 310 | + if (defined('MW_SUPPORTS_RESOURCE_MODULES')) { |
|
| 311 | + $parserOutput->addModules('ext.Lingo.Scripts'); |
|
| 312 | 312 | |
| 313 | - if ( !$wgOut->isArticle() ) { |
|
| 314 | - $wgOut->addModules( 'ext.Lingo.Scripts' ); |
|
| 313 | + if (!$wgOut->isArticle()) { |
|
| 314 | + $wgOut->addModules('ext.Lingo.Scripts'); |
|
| 315 | 315 | } |
| 316 | 316 | } else { |
| 317 | 317 | global $wgStylePath; |
| 318 | - $parserOutput->addHeadItem( "<script src='$wgStylePath/common/jquery.min.js'></script>\n", 'ext.Lingo.jq' ); |
|
| 319 | - $parserOutput->addHeadItem( "<script src='$wgScriptPath/extensions/Lingo/libs/Lingo.js'></script>\n", 'ext.Lingo.Scripts' ); |
|
| 318 | + $parserOutput->addHeadItem("<script src='$wgStylePath/common/jquery.min.js'></script>\n", 'ext.Lingo.jq'); |
|
| 319 | + $parserOutput->addHeadItem("<script src='$wgScriptPath/extensions/Lingo/libs/Lingo.js'></script>\n", 'ext.Lingo.Scripts'); |
|
| 320 | 320 | |
| 321 | - if ( !$wgOut->isArticle() ) { |
|
| 322 | - $wgOut->addHeadItem( 'ext.Lingo.jq', "<script src='$wgStylePath/common/jquery.min.js'></script>\n" ); |
|
| 323 | - $wgOut->addHeadItem( 'ext.Lingo.Scripts', "<script src='$wgScriptPath/extensions/Lingo/libs/Lingo.js'></script>\n" ); |
|
| 321 | + if (!$wgOut->isArticle()) { |
|
| 322 | + $wgOut->addHeadItem('ext.Lingo.jq', "<script src='$wgStylePath/common/jquery.min.js'></script>\n"); |
|
| 323 | + $wgOut->addHeadItem('ext.Lingo.Scripts', "<script src='$wgScriptPath/extensions/Lingo/libs/Lingo.js'></script>\n"); |
|
| 324 | 324 | } |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | // load styles |
| 328 | - if ( method_exists( $parserOutput, 'addModuleStyles') ) { |
|
| 329 | - $parserOutput->addModuleStyles( 'ext.Lingo.Styles' ); |
|
| 330 | - if ( !$wgOut->isArticle() ) { |
|
| 331 | - $wgOut->addModuleStyles( 'ext.Lingo.Styles' ); |
|
| 328 | + if (method_exists($parserOutput, 'addModuleStyles')) { |
|
| 329 | + $parserOutput->addModuleStyles('ext.Lingo.Styles'); |
|
| 330 | + if (!$wgOut->isArticle()) { |
|
| 331 | + $wgOut->addModuleStyles('ext.Lingo.Styles'); |
|
| 332 | 332 | } |
| 333 | 333 | } else { |
| 334 | - $parserOutput->addHeadItem( "<link rel='stylesheet' href='$wgScriptPath/extensions/Lingo/styles/Lingo.css' />\n", 'ext.Lingo.Styles' ); |
|
| 335 | - if ( !$wgOut->isArticle() ) { |
|
| 336 | - $wgOut->addHeadItem( 'ext.Lingo.Styles', "<link rel='stylesheet' href='$wgScriptPath/extensions/Lingo/styles/Lingo.css' />\n" ); |
|
| 334 | + $parserOutput->addHeadItem("<link rel='stylesheet' href='$wgScriptPath/extensions/Lingo/styles/Lingo.css' />\n", 'ext.Lingo.Styles'); |
|
| 335 | + if (!$wgOut->isArticle()) { |
|
| 336 | + $wgOut->addHeadItem('ext.Lingo.Styles', "<link rel='stylesheet' href='$wgScriptPath/extensions/Lingo/styles/Lingo.css' />\n"); |
|
| 337 | 337 | } |
| 338 | 338 | } |
| 339 | 339 | } |
@@ -341,11 +341,11 @@ discard block |
||
| 341 | 341 | /** |
| 342 | 342 | * Purges the lingo tree from the cache. |
| 343 | 343 | */ |
| 344 | - public static function purgeCache () { |
|
| 344 | + public static function purgeCache() { |
|
| 345 | 345 | |
| 346 | 346 | global $wgexLingoCacheType; |
| 347 | - $cache = ($wgexLingoCacheType !== null)? wfGetCache( $wgexLingoCacheType ):wfGetMainCache(); |
|
| 348 | - $cache->delete( wfMemcKey( 'ext', 'lingo', 'lingotree' ) ); |
|
| 347 | + $cache = ($wgexLingoCacheType !== null) ? wfGetCache($wgexLingoCacheType) : wfGetMainCache(); |
|
| 348 | + $cache->delete(wfMemcKey('ext', 'lingo', 'lingotree')); |
|
| 349 | 349 | |
| 350 | 350 | } |
| 351 | 351 | } |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | /** |
| 62 | 62 | * Adds an element to the Lingo Tree |
| 63 | 63 | * |
| 64 | - * @param array $path An array containing the constituing lexemes of the term |
|
| 64 | + * @param string[] $path An array containing the constituing lexemes of the term |
|
| 65 | 65 | * @param String $term |
| 66 | 66 | * @param String $definition |
| 67 | 67 | * @return Array the tree node the element was stored in |
@@ -97,6 +97,10 @@ discard block |
||
| 97 | 97 | return $this->mList; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | + /** |
|
| 101 | + * @param integer $index |
|
| 102 | + * @param integer $countLexemes |
|
| 103 | + */ |
|
| 100 | 104 | function findNextTerm( &$lexemes, $index, $countLexemes ) { |
| 101 | 105 | wfProfileIn( __METHOD__ ); |
| 102 | 106 | |
@@ -39,22 +39,22 @@ discard block |
||
| 39 | 39 | * Adds a string to the Lingo Tree |
| 40 | 40 | * @param String $term |
| 41 | 41 | */ |
| 42 | - function addTerm( &$term, $definition ) { |
|
| 43 | - if ( !$term ) { |
|
| 42 | + function addTerm(&$term, $definition) { |
|
| 43 | + if (!$term) { |
|
| 44 | 44 | return; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - if ( isset( $this->mList[$term] ) ) { // term exists, store 2nd definition |
|
| 48 | - $this->mList[$term]->addDefinition( $definition ); |
|
| 47 | + if (isset($this->mList[$term])) { // term exists, store 2nd definition |
|
| 48 | + $this->mList[$term]->addDefinition($definition); |
|
| 49 | 49 | } else { |
| 50 | 50 | |
| 51 | 51 | $matches = array(); |
| 52 | - preg_match_all( LingoParser::$regex, $term, $matches ); |
|
| 52 | + preg_match_all(LingoParser::$regex, $term, $matches); |
|
| 53 | 53 | |
| 54 | - $elt = $this->addElement( $matches[0], $term, $definition ); |
|
| 54 | + $elt = $this->addElement($matches[0], $term, $definition); |
|
| 55 | 55 | $this->mList[$term] = &$elt[-1]; |
| 56 | 56 | |
| 57 | - $this->mMinLength = min( array($this->mMinLength, strlen( $term )) ); |
|
| 57 | + $this->mMinLength = min(array($this->mMinLength, strlen($term))); |
|
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | |
@@ -66,24 +66,24 @@ discard block |
||
| 66 | 66 | * @param String $definition |
| 67 | 67 | * @return Array the tree node the element was stored in |
| 68 | 68 | */ |
| 69 | - protected function &addElement( Array &$path, &$term, &$definition ) { |
|
| 69 | + protected function &addElement(Array &$path, &$term, &$definition) { |
|
| 70 | 70 | |
| 71 | 71 | $tree = &$this->mTree; |
| 72 | 72 | |
| 73 | 73 | // end of path, store description; end of recursion |
| 74 | - while ( ($step = array_shift( $path )) !== null ) { |
|
| 74 | + while (($step = array_shift($path)) !== null) { |
|
| 75 | 75 | |
| 76 | - if ( !isset( $tree[$step] ) ) { |
|
| 76 | + if (!isset($tree[$step])) { |
|
| 77 | 77 | $tree[$step] = array(); |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | $tree = &$tree[$step]; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - if ( isset( $tree[-1] ) ) { |
|
| 84 | - $tree[-1]->addDefinition( $definition ); |
|
| 83 | + if (isset($tree[-1])) { |
|
| 84 | + $tree[-1]->addDefinition($definition); |
|
| 85 | 85 | } else { |
| 86 | - $tree[-1] = new LingoElement( $term, $definition ); |
|
| 86 | + $tree[-1] = new LingoElement($term, $definition); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | return $tree; |
@@ -97,19 +97,19 @@ discard block |
||
| 97 | 97 | return $this->mList; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - function findNextTerm( &$lexemes, $index, $countLexemes ) { |
|
| 101 | - wfProfileIn( __METHOD__ ); |
|
| 100 | + function findNextTerm(&$lexemes, $index, $countLexemes) { |
|
| 101 | + wfProfileIn(__METHOD__); |
|
| 102 | 102 | |
| 103 | 103 | $start = $lastindex = $index; |
| 104 | 104 | $definition = null; |
| 105 | 105 | |
| 106 | 106 | // skip until the start of a term is found |
| 107 | - while ( $index < $countLexemes && !$definition ) { |
|
| 107 | + while ($index < $countLexemes && !$definition) { |
|
| 108 | 108 | $currLex = &$lexemes[$index][0]; |
| 109 | 109 | |
| 110 | 110 | // Did we find the start of a term? |
| 111 | - if ( array_key_exists( $currLex, $this->mTree ) ) { |
|
| 112 | - list( $lastindex, $definition ) = $this->findNextTermNoSkip( $this->mTree[$currLex], $lexemes, $index, $countLexemes ); |
|
| 111 | + if (array_key_exists($currLex, $this->mTree)) { |
|
| 112 | + list($lastindex, $definition) = $this->findNextTermNoSkip($this->mTree[$currLex], $lexemes, $index, $countLexemes); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | // this will increase the index even if we found something; |
@@ -117,23 +117,23 @@ discard block |
||
| 117 | 117 | $index++; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - wfProfileOut( __METHOD__ ); |
|
| 121 | - if ( $definition ) { |
|
| 120 | + wfProfileOut(__METHOD__); |
|
| 121 | + if ($definition) { |
|
| 122 | 122 | return array($index - $start - 1, $lastindex - $index + 2, $definition); |
| 123 | 123 | } else { |
| 124 | 124 | return array($index - $start, 0, null); |
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - function findNextTermNoSkip( Array &$tree, &$lexemes, $index, $countLexemes ) { |
|
| 129 | - wfProfileIn( __METHOD__ ); |
|
| 128 | + function findNextTermNoSkip(Array &$tree, &$lexemes, $index, $countLexemes) { |
|
| 129 | + wfProfileIn(__METHOD__); |
|
| 130 | 130 | |
| 131 | - if ( $index + 1 < $countLexemes && array_key_exists( $currLex = $lexemes[$index + 1][0], $tree ) ) { |
|
| 132 | - $ret = $this->findNextTermNoSkip( $tree[$currLex], $lexemes, $index + 1, $countLexemes ); |
|
| 131 | + if ($index + 1 < $countLexemes && array_key_exists($currLex = $lexemes[$index + 1][0], $tree)) { |
|
| 132 | + $ret = $this->findNextTermNoSkip($tree[$currLex], $lexemes, $index + 1, $countLexemes); |
|
| 133 | 133 | } else { |
| 134 | 134 | $ret = array($index, &$tree[-1]); |
| 135 | 135 | } |
| 136 | - wfProfileOut( __METHOD__ ); |
|
| 136 | + wfProfileOut(__METHOD__); |
|
| 137 | 137 | return $ret; |
| 138 | 138 | } |
| 139 | 139 | |
@@ -24,17 +24,17 @@ discard block |
||
| 24 | 24 | * @param String $text |
| 25 | 25 | * @return Boolean |
| 26 | 26 | */ |
| 27 | - static function parse( &$parser, &$text ) { |
|
| 27 | + static function parse(&$parser, &$text) { |
|
| 28 | 28 | |
| 29 | 29 | global $wgexLingoUseNamespaces; |
| 30 | 30 | |
| 31 | 31 | $title = $parser->getTitle(); |
| 32 | 32 | |
| 33 | 33 | // parse if |
| 34 | - if ( !isset( $parser->mDoubleUnderscores['noglossary'] ) && // __NOGLOSSARY__ not present and |
|
| 34 | + if (!isset($parser->mDoubleUnderscores['noglossary']) && // __NOGLOSSARY__ not present and |
|
| 35 | 35 | ( |
| 36 | 36 | !$title || // title not set or |
| 37 | - !isset( $wgexLingoUseNamespaces[ $title->getNamespace() ] ) || // namespace not explicitly forbidden (i.e. not in list of namespaces and set to false) or |
|
| 37 | + !isset($wgexLingoUseNamespaces[$title->getNamespace()]) || // namespace not explicitly forbidden (i.e. not in list of namespaces and set to false) or |
|
| 38 | 38 | $wgexLingoUseNamespaces[$title->getNamespace()] // namespace explicitly allowed |
| 39 | 39 | ) |
| 40 | 40 | ) { |
@@ -42,8 +42,8 @@ discard block |
||
| 42 | 42 | // unstrip strip items of the 'general' group |
| 43 | 43 | // this will be done again by parse when this hook returns, but it should not hurt to do this twice |
| 44 | 44 | // Only problem is with other hook handlers that might not expect strip items to be unstripped already |
| 45 | - $text = $parser->mStripState->unstripGeneral( $text ); |
|
| 46 | - LingoParser::parse( $parser, $text ); |
|
| 45 | + $text = $parser->mStripState->unstripGeneral($text); |
|
| 46 | + LingoParser::parse($parser, $text); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | return true; |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * Creates tag hook(s) |
| 54 | 54 | */ |
| 55 | 55 | public static function registerTags(Parser $parser) { |
| 56 | - $parser->setHook( 'noglossary', 'LingoHooks::noglossaryTagRenderer'); |
|
| 56 | + $parser->setHook('noglossary', 'LingoHooks::noglossaryTagRenderer'); |
|
| 57 | 57 | return true; |
| 58 | 58 | } |
| 59 | 59 | |
@@ -66,8 +66,8 @@ discard block |
||
| 66 | 66 | * @param PPFrame $frame |
| 67 | 67 | * @return string |
| 68 | 68 | */ |
| 69 | - public static function noglossaryTagRenderer( $input, array $args, Parser $parser, PPFrame $frame ) { |
|
| 70 | - $output = $parser->recursiveTagParse( $input, $frame ); |
|
| 69 | + public static function noglossaryTagRenderer($input, array $args, Parser $parser, PPFrame $frame) { |
|
| 70 | + $output = $parser->recursiveTagParse($input, $frame); |
|
| 71 | 71 | return '<span class="noglossary">'.$output.'</span>'; |
| 72 | 72 | } |
| 73 | 73 | |
@@ -78,12 +78,12 @@ discard block |
||
| 78 | 78 | * |
| 79 | 79 | */ |
| 80 | 80 | public static function initExtension() { |
| 81 | - MagicWord::$mDoubleUnderscoreIDs[ ] = 'noglossary'; |
|
| 81 | + MagicWord::$mDoubleUnderscoreIDs[] = 'noglossary'; |
|
| 82 | 82 | |
| 83 | - foreach ( $GLOBALS['wgExtensionCredits']['parserhook'] as $index => $description ) { |
|
| 83 | + foreach ($GLOBALS['wgExtensionCredits']['parserhook'] as $index => $description) { |
|
| 84 | 84 | if ($GLOBALS['wgExtensionCredits']['parserhook'][$index]['name'] === 'Lingo') { |
| 85 | 85 | $GLOBALS['wgExtensionCredits']['parserhook'][$index]['description'] = |
| 86 | - wfMessage( 'lingo-desc', $GLOBALS['wgexLingoPage'] ? $GLOBALS['wgexLingoPage'] : wfMessage( 'lingo-terminologypagename' )->inContentLanguage()->text() )->text(); |
|
| 86 | + wfMessage('lingo-desc', $GLOBALS['wgexLingoPage'] ? $GLOBALS['wgexLingoPage'] : wfMessage('lingo-terminologypagename')->inContentLanguage()->text())->text(); |
|
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | 89 | } |
@@ -17,9 +17,9 @@ |
||
| 17 | 17 | |
| 18 | 18 | protected $mMessageLog; |
| 19 | 19 | |
| 20 | - public function __construct( LingoMessageLog &$messages = null ) { |
|
| 20 | + public function __construct(LingoMessageLog&$messages = null) { |
|
| 21 | 21 | |
| 22 | - if ( !$messages ) { |
|
| 22 | + if (!$messages) { |
|
| 23 | 23 | $this->mMessageLog = new LingoMessageLog(); |
| 24 | 24 | } else { |
| 25 | 25 | $this->mMessageLog = $messages; |
@@ -17,18 +17,18 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | protected $mArticleLines = array(); |
| 19 | 19 | |
| 20 | - public function __construct( LingoMessageLog &$messages = null ) { |
|
| 20 | + public function __construct(LingoMessageLog&$messages = null) { |
|
| 21 | 21 | |
| 22 | 22 | global $wgexLingoPage, $wgRequest; |
| 23 | 23 | |
| 24 | - $page = $wgexLingoPage ? $wgexLingoPage : wfMessage( 'lingo-terminologypagename' )->inContentLanguage()->text(); |
|
| 24 | + $page = $wgexLingoPage ? $wgexLingoPage : wfMessage('lingo-terminologypagename')->inContentLanguage()->text(); |
|
| 25 | 25 | |
| 26 | - parent::__construct( $messages ); |
|
| 26 | + parent::__construct($messages); |
|
| 27 | 27 | |
| 28 | 28 | // Get Terminology page |
| 29 | - $title = Title::newFromText( $page ); |
|
| 30 | - if ( $title->getInterwiki() ) { |
|
| 31 | - $this->getMessageLog()->addError( wfMessage( 'lingo-terminologypagenotlocal' , $page )->inContentLanguage()->text() ); |
|
| 29 | + $title = Title::newFromText($page); |
|
| 30 | + if ($title->getInterwiki()) { |
|
| 31 | + $this->getMessageLog()->addError(wfMessage('lingo-terminologypagenotlocal', $page)->inContentLanguage()->text()); |
|
| 32 | 32 | return false; |
| 33 | 33 | } |
| 34 | 34 | |
@@ -36,15 +36,15 @@ discard block |
||
| 36 | 36 | // page itself. In this case the Revision is not up to date when we get |
| 37 | 37 | // here, i.e. $rev->getText() would return outdated Test. |
| 38 | 38 | // This hack takes the text directly out of the data from the web request. |
| 39 | - if ( $wgRequest->getVal( 'action', 'view' ) === 'submit' |
|
| 40 | - && Title::newFromText( $wgRequest->getVal( 'title' ) )->getArticleID() === $title->getArticleID() ) { |
|
| 39 | + if ($wgRequest->getVal('action', 'view') === 'submit' |
|
| 40 | + && Title::newFromText($wgRequest->getVal('title'))->getArticleID() === $title->getArticleID()) { |
|
| 41 | 41 | |
| 42 | - $content = $wgRequest->getVal( 'wpTextbox1' ); |
|
| 42 | + $content = $wgRequest->getVal('wpTextbox1'); |
|
| 43 | 43 | |
| 44 | 44 | } else { |
| 45 | - $rev = $this->getRevision( $title ); |
|
| 46 | - if ( !$rev ) { |
|
| 47 | - $this->getMessageLog()->addWarning( wfMessage( 'lingo-noterminologypage', $page )->inContentLanguage()->text() ); |
|
| 45 | + $rev = $this->getRevision($title); |
|
| 46 | + if (!$rev) { |
|
| 47 | + $this->getMessageLog()->addWarning(wfMessage('lingo-noterminologypage', $page)->inContentLanguage()->text()); |
|
| 48 | 48 | return false; |
| 49 | 49 | } |
| 50 | 50 | |
@@ -55,9 +55,9 @@ discard block |
||
| 55 | 55 | $parser = new Parser; |
| 56 | 56 | // expand templates and variables in the text, producing valid, static wikitext |
| 57 | 57 | // have to use a new anonymous user to avoid any leakage as Lingo is caching only one user-independant glossary |
| 58 | - $content = $parser->preprocess( $content, $title, new ParserOptions( new User() ) ); |
|
| 58 | + $content = $parser->preprocess($content, $title, new ParserOptions(new User())); |
|
| 59 | 59 | |
| 60 | - $this->mArticleLines = array_reverse(explode( "\n", $content )); |
|
| 60 | + $this->mArticleLines = array_reverse(explode("\n", $content)); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
@@ -70,40 +70,40 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | public function next() { |
| 72 | 72 | |
| 73 | - wfProfileIn( __METHOD__ ); |
|
| 73 | + wfProfileIn(__METHOD__); |
|
| 74 | 74 | |
| 75 | 75 | static $term = null; |
| 76 | 76 | static $definitions = array(); |
| 77 | 77 | static $ret = array(); |
| 78 | 78 | |
| 79 | 79 | // find next valid line (yes, the assignation is intended) |
| 80 | - while ( ( count( $ret ) == 0 ) && ( $entry = each( $this->mArticleLines ) ) ) { |
|
| 80 | + while ((count($ret) == 0) && ($entry = each($this->mArticleLines))) { |
|
| 81 | 81 | |
| 82 | - if ( empty( $entry[1] ) || ($entry[1][0] !== ';' && $entry[1][0] !== ':')) { |
|
| 82 | + if (empty($entry[1]) || ($entry[1][0] !== ';' && $entry[1][0] !== ':')) { |
|
| 83 | 83 | continue; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - $chunks = explode( ':', $entry[1], 2 ); |
|
| 86 | + $chunks = explode(':', $entry[1], 2); |
|
| 87 | 87 | |
| 88 | 88 | // found a new definition? |
| 89 | - if ( count ( $chunks ) == 2 ) { |
|
| 89 | + if (count($chunks) == 2) { |
|
| 90 | 90 | |
| 91 | 91 | // wipe the data if its a totaly new term definition |
| 92 | - if ( !empty( $term ) && count( $definitions ) > 0) { |
|
| 92 | + if (!empty($term) && count($definitions) > 0) { |
|
| 93 | 93 | $definitions = array(); |
| 94 | 94 | $term = null; |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - $definitions[] = trim( $chunks[1] ); |
|
| 97 | + $definitions[] = trim($chunks[1]); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | // found a new term? |
| 101 | - if (count( $chunks ) >= 1 && strlen( $chunks[0] ) >= 1 ) { |
|
| 102 | - $term = trim( substr( $chunks[0], 1 ) ); |
|
| 101 | + if (count($chunks) >= 1 && strlen($chunks[0]) >= 1) { |
|
| 102 | + $term = trim(substr($chunks[0], 1)); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - if ( $term !== null ) { |
|
| 106 | - foreach ( $definitions as $definition ) { |
|
| 105 | + if ($term !== null) { |
|
| 106 | + foreach ($definitions as $definition) { |
|
| 107 | 107 | $ret[] = array( |
| 108 | 108 | LingoElement::ELEMENT_TERM => $term, |
| 109 | 109 | LingoElement::ELEMENT_DEFINITION => $definition, |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - wfProfileOut( __METHOD__ ); |
|
| 117 | + wfProfileOut(__METHOD__); |
|
| 118 | 118 | |
| 119 | 119 | return array_pop($ret); |
| 120 | 120 | } |
@@ -125,21 +125,21 @@ discard block |
||
| 125 | 125 | * @param Title $title |
| 126 | 126 | * @return Revision |
| 127 | 127 | */ |
| 128 | - public function getRevision( $title ) |
|
| 128 | + public function getRevision($title) |
|
| 129 | 129 | { |
| 130 | 130 | global $wgexLingoEnableApprovedRevs; |
| 131 | 131 | |
| 132 | - if ( $wgexLingoEnableApprovedRevs ) { |
|
| 132 | + if ($wgexLingoEnableApprovedRevs) { |
|
| 133 | 133 | |
| 134 | - if ( defined( 'APPROVED_REVS_VERSION' ) ) { |
|
| 135 | - $rev_id = ApprovedRevs::getApprovedRevID( $title ); |
|
| 136 | - return Revision::newFromId( $rev_id ); |
|
| 134 | + if (defined('APPROVED_REVS_VERSION')) { |
|
| 135 | + $rev_id = ApprovedRevs::getApprovedRevID($title); |
|
| 136 | + return Revision::newFromId($rev_id); |
|
| 137 | 137 | } else { |
| 138 | - wfDebug( 'Support for ApprovedRevs is enabled in Lingo. But ApprovedRevs was not found.\n' ); |
|
| 138 | + wfDebug('Support for ApprovedRevs is enabled in Lingo. But ApprovedRevs was not found.\n'); |
|
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - return Revision::newFromTitle( $title ); |
|
| 142 | + return Revision::newFromTitle($title); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | /** |
@@ -148,12 +148,12 @@ discard block |
||
| 148 | 148 | * @param Page $wikipage |
| 149 | 149 | * @return Bool |
| 150 | 150 | */ |
| 151 | - public static function purgeCache( &$wikipage ) { |
|
| 151 | + public static function purgeCache(&$wikipage) { |
|
| 152 | 152 | |
| 153 | 153 | global $wgexLingoPage; |
| 154 | - $page = $wgexLingoPage ? $wgexLingoPage : wfMessage( 'lingo-terminologypagename' )->inContentLanguage()->text(); |
|
| 154 | + $page = $wgexLingoPage ? $wgexLingoPage : wfMessage('lingo-terminologypagename')->inContentLanguage()->text(); |
|
| 155 | 155 | |
| 156 | - if ( !is_null( $wikipage ) && ( $wikipage->getTitle()->getText() === $page ) ) { |
|
| 156 | + if (!is_null($wikipage) && ($wikipage->getTitle()->getText() === $page)) { |
|
| 157 | 157 | |
| 158 | 158 | LingoParser::purgeCache(); |
| 159 | 159 | } |
@@ -10,80 +10,80 @@ |
||
| 10 | 10 | |
| 11 | 11 | /** English (English) */ |
| 12 | 12 | $magicWords['en'] = array( |
| 13 | - 'noglossary' => array( 0, '__NOGLOSSARY__' ), |
|
| 13 | + 'noglossary' => array(0, '__NOGLOSSARY__'), |
|
| 14 | 14 | ); |
| 15 | 15 | |
| 16 | 16 | /** Arabic (العربية) */ |
| 17 | 17 | $magicWords['ar'] = array( |
| 18 | - 'noglossary' => array( 0, '__لا_قاموس__' ), |
|
| 18 | + 'noglossary' => array(0, '__لا_قاموس__'), |
|
| 19 | 19 | ); |
| 20 | 20 | |
| 21 | 21 | /** Egyptian Arabic (مصرى) */ |
| 22 | 22 | $magicWords['arz'] = array( |
| 23 | - 'noglossary' => array( 0, '__من_غير_قاموس__' ), |
|
| 23 | + 'noglossary' => array(0, '__من_غير_قاموس__'), |
|
| 24 | 24 | ); |
| 25 | 25 | |
| 26 | 26 | /** German (Deutsch) */ |
| 27 | 27 | $magicWords['de'] = array( |
| 28 | - 'noglossary' => array( 0, '__KEINGLOSSAR__', '__KEIN_GLOSSAR__' ), |
|
| 28 | + 'noglossary' => array(0, '__KEINGLOSSAR__', '__KEIN_GLOSSAR__'), |
|
| 29 | 29 | ); |
| 30 | 30 | |
| 31 | 31 | /** Zazaki (Zazaki) */ |
| 32 | 32 | $magicWords['diq'] = array( |
| 33 | - 'noglossary' => array( 0, 'QISEBENDÇINİYO' ), |
|
| 33 | + 'noglossary' => array(0, 'QISEBENDÇINİYO'), |
|
| 34 | 34 | ); |
| 35 | 35 | |
| 36 | 36 | /** Esperanto (Esperanto) */ |
| 37 | 37 | $magicWords['eo'] = array( |
| 38 | - 'noglossary' => array( 0, '__NEDIFINO__' ), |
|
| 38 | + 'noglossary' => array(0, '__NEDIFINO__'), |
|
| 39 | 39 | ); |
| 40 | 40 | |
| 41 | 41 | /** French (français) */ |
| 42 | 42 | $magicWords['fr'] = array( |
| 43 | - 'noglossary' => array( 0, '__SANSGLOSSAIRE__' ), |
|
| 43 | + 'noglossary' => array(0, '__SANSGLOSSAIRE__'), |
|
| 44 | 44 | ); |
| 45 | 45 | |
| 46 | 46 | /** Italian (italiano) */ |
| 47 | 47 | $magicWords['it'] = array( |
| 48 | - 'noglossary' => array( 0, '__NOGLOSSARIO__' ), |
|
| 48 | + 'noglossary' => array(0, '__NOGLOSSARIO__'), |
|
| 49 | 49 | ); |
| 50 | 50 | |
| 51 | 51 | /** Korean (한국어) */ |
| 52 | 52 | $magicWords['ko'] = array( |
| 53 | - 'noglossary' => array( 0, '__용어집없음__' ), |
|
| 53 | + 'noglossary' => array(0, '__용어집없음__'), |
|
| 54 | 54 | ); |
| 55 | 55 | |
| 56 | 56 | /** Macedonian (македонски) */ |
| 57 | 57 | $magicWords['mk'] = array( |
| 58 | - 'noglossary' => array( 0, '__БЕЗПОИМНИК__' ), |
|
| 58 | + 'noglossary' => array(0, '__БЕЗПОИМНИК__'), |
|
| 59 | 59 | ); |
| 60 | 60 | |
| 61 | 61 | /** Malayalam (മലയാളം) */ |
| 62 | 62 | $magicWords['ml'] = array( |
| 63 | - 'noglossary' => array( 0, '__ചുരുക്കംവേണ്ട__' ), |
|
| 63 | + 'noglossary' => array(0, '__ചുരുക്കംവേണ്ട__'), |
|
| 64 | 64 | ); |
| 65 | 65 | |
| 66 | 66 | /** Low Saxon (Netherlands) (Nedersaksies) */ |
| 67 | 67 | $magicWords['nds-nl'] = array( |
| 68 | - 'noglossary' => array( 0, '__GIEN_GLOSSARIUM__' ), |
|
| 68 | + 'noglossary' => array(0, '__GIEN_GLOSSARIUM__'), |
|
| 69 | 69 | ); |
| 70 | 70 | |
| 71 | 71 | /** Dutch (Nederlands) */ |
| 72 | 72 | $magicWords['nl'] = array( |
| 73 | - 'noglossary' => array( 0, '___GEENWOORDENLIJST__' ), |
|
| 73 | + 'noglossary' => array(0, '___GEENWOORDENLIJST__'), |
|
| 74 | 74 | ); |
| 75 | 75 | |
| 76 | 76 | /** Serbian (Latin script) (srpski (latinica)) */ |
| 77 | 77 | $magicWords['sr-el'] = array( |
| 78 | - 'noglossary' => array( 0, '__BEZREČNIKA__', '__BEZ_REČNIKA__' ), |
|
| 78 | + 'noglossary' => array(0, '__BEZREČNIKA__', '__BEZ_REČNIKA__'), |
|
| 79 | 79 | ); |
| 80 | 80 | |
| 81 | 81 | /** Turkish (Türkçe) */ |
| 82 | 82 | $magicWords['tr'] = array( |
| 83 | - 'noglossary' => array( 0, '__SÖZLÜKYOK__' ), |
|
| 83 | + 'noglossary' => array(0, '__SÖZLÜKYOK__'), |
|
| 84 | 84 | ); |
| 85 | 85 | |
| 86 | 86 | /** Simplified Chinese (中文(简体)) */ |
| 87 | 87 | $magicWords['zh-hans'] = array( |
| 88 | - 'noglossary' => array( 0, '__无词汇表__' ), |
|
| 88 | + 'noglossary' => array(0, '__无词汇表__'), |
|
| 89 | 89 | ); |
| 90 | 90 | \ No newline at end of file |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | const ELEMENT_LINK = 3; |
| 23 | 23 | const ELEMENT_STYLE = 4; |
| 24 | 24 | |
| 25 | - const ELEMENT_FIELDCOUNT = 5; // number of fields stored for each element; (last field's index) + 1 |
|
| 25 | + const ELEMENT_FIELDCOUNT = 5; // number of fields stored for each element; (last field's index) + 1 |
|
| 26 | 26 | |
| 27 | 27 | private $mFullDefinition = null; |
| 28 | 28 | private $mDefinitions = array(); |
@@ -31,94 +31,94 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | static private $mLinkTemplate = null; |
| 33 | 33 | |
| 34 | - public function __construct( &$term, &$definition = null ) { |
|
| 34 | + public function __construct(&$term, &$definition = null) { |
|
| 35 | 35 | |
| 36 | 36 | $this->mTerm = $term; |
| 37 | 37 | |
| 38 | - if ( $definition ) { |
|
| 39 | - $this->addDefinition( $definition ); |
|
| 38 | + if ($definition) { |
|
| 39 | + $this->addDefinition($definition); |
|
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - public function addDefinition( &$definition ) { |
|
| 44 | - $this->mDefinitions[] = array_pad( $definition, self::ELEMENT_FIELDCOUNT, null ); |
|
| 43 | + public function addDefinition(&$definition) { |
|
| 44 | + $this->mDefinitions[] = array_pad($definition, self::ELEMENT_FIELDCOUNT, null); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - public function getFullDefinition( DOMDocument &$doc ) { |
|
| 47 | + public function getFullDefinition(DOMDocument&$doc) { |
|
| 48 | 48 | |
| 49 | 49 | global $wgexLingoDisplayOnce; |
| 50 | 50 | |
| 51 | - wfProfileIn( __METHOD__ ); |
|
| 51 | + wfProfileIn(__METHOD__); |
|
| 52 | 52 | |
| 53 | 53 | // return textnode if |
| 54 | - if ( $wgexLingoDisplayOnce && $this->mHasBeenDisplayed ) { |
|
| 54 | + if ($wgexLingoDisplayOnce && $this->mHasBeenDisplayed) { |
|
| 55 | 55 | return $doc->createTextNode($this->mTerm); |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | // only create if not yet created |
| 59 | - if ( $this->mFullDefinition === null || $this->mFullDefinition->ownerDocument !== $doc ) { |
|
| 59 | + if ($this->mFullDefinition === null || $this->mFullDefinition->ownerDocument !== $doc) { |
|
| 60 | 60 | |
| 61 | 61 | // if there is only one link available, just insert the link |
| 62 | - if ( count( $this->mDefinitions ) === 1 |
|
| 63 | - && !is_string( $this->mDefinitions[0][self::ELEMENT_DEFINITION] ) |
|
| 64 | - && is_string( $this->mDefinitions[0][self::ELEMENT_LINK] ) ) { |
|
| 62 | + if (count($this->mDefinitions) === 1 |
|
| 63 | + && !is_string($this->mDefinitions[0][self::ELEMENT_DEFINITION]) |
|
| 64 | + && is_string($this->mDefinitions[0][self::ELEMENT_LINK])) { |
|
| 65 | 65 | |
| 66 | - $this->mFullDefinition = $this->getFullDefinitionAsLink( $doc ); |
|
| 66 | + $this->mFullDefinition = $this->getFullDefinitionAsLink($doc); |
|
| 67 | 67 | |
| 68 | 68 | } else { // else insert the complete tooltip |
| 69 | 69 | |
| 70 | - $this->mFullDefinition = $this->getFullDefinitionAsTooltip( $doc ); |
|
| 70 | + $this->mFullDefinition = $this->getFullDefinitionAsTooltip($doc); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | $this->mHasBeenDisplayed = true; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - wfProfileOut( __METHOD__ ); |
|
| 76 | + wfProfileOut(__METHOD__); |
|
| 77 | 77 | |
| 78 | - return $this->mFullDefinition->cloneNode( true ); |
|
| 78 | + return $this->mFullDefinition->cloneNode(true); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | public function getCurrentKey() { |
| 82 | - return key( $this->mDefinitions ); |
|
| 82 | + return key($this->mDefinitions); |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - public function getTerm( $key ) { |
|
| 85 | + public function getTerm($key) { |
|
| 86 | 86 | return $this->mDefinitions[$key][self::ELEMENT_TERM]; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - public function getSource( &$key ) { |
|
| 89 | + public function getSource(&$key) { |
|
| 90 | 90 | return $this->mDefinitions[$key][self::ELEMENT_SOURCE]; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - public function getDefinition( &$key ) { |
|
| 93 | + public function getDefinition(&$key) { |
|
| 94 | 94 | return $this->mDefinitions[$key][self::ELEMENT_DEFINITION]; |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - public function getLink( &$key ) { |
|
| 97 | + public function getLink(&$key) { |
|
| 98 | 98 | return $this->mDefinitions[$key][self::ELEMENT_LINK]; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - public function getStyle( &$key ) { |
|
| 101 | + public function getStyle(&$key) { |
|
| 102 | 102 | return $this->mDefinitions[$key][self::ELEMENT_STYLE]; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | public function next() { |
| 106 | - next( $this->mDefinitions ); |
|
| 106 | + next($this->mDefinitions); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - private function getLinkTemplate( DOMDocument &$doc ) { |
|
| 109 | + private function getLinkTemplate(DOMDocument&$doc) { |
|
| 110 | 110 | // create template if it does not yet exist |
| 111 | - if ( !self::$mLinkTemplate || ( self::$mLinkTemplate->ownerDocument !== $doc ) ) { |
|
| 111 | + if (!self::$mLinkTemplate || (self::$mLinkTemplate->ownerDocument !== $doc)) { |
|
| 112 | 112 | global $wgScriptPath; |
| 113 | 113 | |
| 114 | - $linkimage = $doc->createElement( 'img' ); |
|
| 115 | - $linkimage->setAttribute( 'src', $wgScriptPath . '/extensions/Lingo/styles/linkicon.png' ); |
|
| 114 | + $linkimage = $doc->createElement('img'); |
|
| 115 | + $linkimage->setAttribute('src', $wgScriptPath.'/extensions/Lingo/styles/linkicon.png'); |
|
| 116 | 116 | |
| 117 | - self::$mLinkTemplate = $doc->createElement( 'a' ); |
|
| 118 | - self::$mLinkTemplate->appendChild( $linkimage ); |
|
| 117 | + self::$mLinkTemplate = $doc->createElement('a'); |
|
| 118 | + self::$mLinkTemplate->appendChild($linkimage); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - return self::$mLinkTemplate->cloneNode( true ); |
|
| 121 | + return self::$mLinkTemplate->cloneNode(true); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | /** |
@@ -127,18 +127,18 @@ discard block |
||
| 127 | 127 | * @return DOMElement |
| 128 | 128 | * @throws MWException |
| 129 | 129 | */ |
| 130 | - protected function getFullDefinitionAsLink( DOMDocument &$doc ) { |
|
| 130 | + protected function getFullDefinitionAsLink(DOMDocument&$doc) { |
|
| 131 | 131 | |
| 132 | 132 | // create Title object for target page |
| 133 | - $target = Title::newFromText( $this->mDefinitions[ 0 ][ self::ELEMENT_LINK ] ); |
|
| 133 | + $target = Title::newFromText($this->mDefinitions[0][self::ELEMENT_LINK]); |
|
| 134 | 134 | |
| 135 | 135 | // create link element |
| 136 | - $link = $doc->createElement( 'a', $this->mDefinitions[ 0 ][ self::ELEMENT_TERM ] ); |
|
| 136 | + $link = $doc->createElement('a', $this->mDefinitions[0][self::ELEMENT_TERM]); |
|
| 137 | 137 | |
| 138 | 138 | // set the link target |
| 139 | - $link->setAttribute( 'href', $target->getLinkUrl() ); |
|
| 140 | - $link = $this->addClassAttributeToLink( $target, $link ); |
|
| 141 | - $link = $this->addTitleAttributeToLink( $target, $link ); |
|
| 139 | + $link->setAttribute('href', $target->getLinkUrl()); |
|
| 140 | + $link = $this->addClassAttributeToLink($target, $link); |
|
| 141 | + $link = $this->addTitleAttributeToLink($target, $link); |
|
| 142 | 142 | |
| 143 | 143 | return $link; |
| 144 | 144 | } |
@@ -149,42 +149,42 @@ discard block |
||
| 149 | 149 | * @return string |
| 150 | 150 | * @throws MWException |
| 151 | 151 | */ |
| 152 | - protected function getFullDefinitionAsTooltip( DOMDocument &$doc ) { |
|
| 152 | + protected function getFullDefinitionAsTooltip(DOMDocument&$doc) { |
|
| 153 | 153 | |
| 154 | 154 | // Wrap term and definition in <span> tags |
| 155 | - $span = $doc->createElement( 'span' ); |
|
| 156 | - $span->setAttribute( 'class', 'mw-lingo-tooltip ' . $this->mDefinitions[ 0 ][ self::ELEMENT_STYLE ] ); |
|
| 155 | + $span = $doc->createElement('span'); |
|
| 156 | + $span->setAttribute('class', 'mw-lingo-tooltip '.$this->mDefinitions[0][self::ELEMENT_STYLE]); |
|
| 157 | 157 | |
| 158 | 158 | // Wrap term in <span> tag, hidden |
| 159 | 159 | wfSuppressWarnings(); |
| 160 | - $spanTerm = $doc->createElement( 'span', htmlentities( $this->mTerm, ENT_COMPAT, 'UTF-8' ) ); |
|
| 160 | + $spanTerm = $doc->createElement('span', htmlentities($this->mTerm, ENT_COMPAT, 'UTF-8')); |
|
| 161 | 161 | |
| 162 | 162 | wfRestoreWarnings(); |
| 163 | - $spanTerm->setAttribute( 'class', 'mw-lingo-tooltip-abbr' ); |
|
| 163 | + $spanTerm->setAttribute('class', 'mw-lingo-tooltip-abbr'); |
|
| 164 | 164 | |
| 165 | 165 | // Wrap definition in a <span> tag |
| 166 | - $spanDefinition = $doc->createElement( 'span' ); |
|
| 167 | - $spanDefinition->setAttribute( 'class', 'mw-lingo-tooltip-tip ' . $this->mDefinitions[ 0 ][ self::ELEMENT_STYLE ] ); |
|
| 166 | + $spanDefinition = $doc->createElement('span'); |
|
| 167 | + $spanDefinition->setAttribute('class', 'mw-lingo-tooltip-tip '.$this->mDefinitions[0][self::ELEMENT_STYLE]); |
|
| 168 | 168 | |
| 169 | - foreach ( $this->mDefinitions as $definition ) { |
|
| 169 | + foreach ($this->mDefinitions as $definition) { |
|
| 170 | 170 | wfSuppressWarnings(); |
| 171 | - $element = $doc->createElement( 'span', htmlentities( $definition[ self::ELEMENT_DEFINITION ], ENT_COMPAT, 'UTF-8' ) ); |
|
| 172 | - $element->setAttribute( 'class', 'mw-lingo-tooltip-definition ' . $this->mDefinitions[ 0 ][ self::ELEMENT_STYLE ] ); |
|
| 171 | + $element = $doc->createElement('span', htmlentities($definition[self::ELEMENT_DEFINITION], ENT_COMPAT, 'UTF-8')); |
|
| 172 | + $element->setAttribute('class', 'mw-lingo-tooltip-definition '.$this->mDefinitions[0][self::ELEMENT_STYLE]); |
|
| 173 | 173 | wfRestoreWarnings(); |
| 174 | - if ( $definition[ self::ELEMENT_LINK ] ) { |
|
| 175 | - $linkedTitle = Title::newFromText( $definition[ self::ELEMENT_LINK ] ); |
|
| 176 | - if ( $linkedTitle ) { |
|
| 177 | - $link = $this->getLinkTemplate( $doc ); |
|
| 178 | - $link->setAttribute( 'href', $linkedTitle->getFullURL() ); |
|
| 179 | - $element->appendChild( $link ); |
|
| 174 | + if ($definition[self::ELEMENT_LINK]) { |
|
| 175 | + $linkedTitle = Title::newFromText($definition[self::ELEMENT_LINK]); |
|
| 176 | + if ($linkedTitle) { |
|
| 177 | + $link = $this->getLinkTemplate($doc); |
|
| 178 | + $link->setAttribute('href', $linkedTitle->getFullURL()); |
|
| 179 | + $element->appendChild($link); |
|
| 180 | 180 | } |
| 181 | 181 | } |
| 182 | - $spanDefinition->appendChild( $element ); |
|
| 182 | + $spanDefinition->appendChild($element); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | // insert term and definition |
| 186 | - $span->appendChild( $spanTerm ); |
|
| 187 | - $span->appendChild( $spanDefinition ); |
|
| 186 | + $span->appendChild($spanTerm); |
|
| 187 | + $span->appendChild($spanDefinition); |
|
| 188 | 188 | return $span; |
| 189 | 189 | } |
| 190 | 190 | |
@@ -192,15 +192,15 @@ discard block |
||
| 192 | 192 | * @param $target |
| 193 | 193 | * @param $link |
| 194 | 194 | */ |
| 195 | - protected function &addTitleAttributeToLink( $target, &$link ) { |
|
| 195 | + protected function &addTitleAttributeToLink($target, &$link) { |
|
| 196 | 196 | |
| 197 | - if ( $target->getPrefixedText() === '' ) { |
|
| 197 | + if ($target->getPrefixedText() === '') { |
|
| 198 | 198 | // A link like [[#Foo]]. This used to mean an empty title |
| 199 | 199 | // attribute, but that's silly. Just don't output a title. |
| 200 | - } elseif ( $target->isKnown() ) { |
|
| 201 | - $link->setAttribute( 'title', $target->getPrefixedText() ); |
|
| 200 | + } elseif ($target->isKnown()) { |
|
| 201 | + $link->setAttribute('title', $target->getPrefixedText()); |
|
| 202 | 202 | } else { |
| 203 | - $link->setAttribute( 'title', wfMessage( 'red-link-title', $target->getPrefixedText() )->text() ); |
|
| 203 | + $link->setAttribute('title', wfMessage('red-link-title', $target->getPrefixedText())->text()); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | return $link; |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | * @param $target |
| 211 | 211 | * @param $link |
| 212 | 212 | */ |
| 213 | - protected function &addClassAttributeToLink( $target, &$link ) { |
|
| 213 | + protected function &addClassAttributeToLink($target, &$link) { |
|
| 214 | 214 | |
| 215 | 215 | // TODO: should this be more elaborate? See Linker::linkAttribs |
| 216 | 216 | // Cleanest would probably be to use Linker::link and parse it |
@@ -218,19 +218,19 @@ discard block |
||
| 218 | 218 | // part here. |
| 219 | 219 | $classes = ''; |
| 220 | 220 | |
| 221 | - if ( !$target->isKnown() ) { |
|
| 221 | + if (!$target->isKnown()) { |
|
| 222 | 222 | $classes .= 'new '; |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | - if ( $target->isExternal() ) { |
|
| 225 | + if ($target->isExternal()) { |
|
| 226 | 226 | $classes .= 'extiw '; |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | // set style |
| 230 | - $classes .= $this->mDefinitions[ 0 ][ self::ELEMENT_STYLE ]; |
|
| 230 | + $classes .= $this->mDefinitions[0][self::ELEMENT_STYLE]; |
|
| 231 | 231 | |
| 232 | - if ( $classes !== '' ) { |
|
| 233 | - $link->setAttribute( 'class', $classes ); |
|
| 232 | + if ($classes !== '') { |
|
| 233 | + $link->setAttribute('class', $classes); |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | return $link; |
@@ -25,58 +25,58 @@ |
||
| 25 | 25 | const MESSAGE_WARNING = 2; |
| 26 | 26 | const MESSAGE_NOTICE = 3; |
| 27 | 27 | |
| 28 | - function addMessage( $message, $severity = self::MESSAGE_NOTICE ) { |
|
| 28 | + function addMessage($message, $severity = self::MESSAGE_NOTICE) { |
|
| 29 | 29 | $this->mMessages[] = array($message, $severity); |
| 30 | 30 | |
| 31 | 31 | // log errors and warnings in debug log |
| 32 | - if ( $severity == self::MESSAGE_WARNING || |
|
| 33 | - $severity == self::MESSAGE_ERROR ) { |
|
| 34 | - wfDebug( $message ); |
|
| 32 | + if ($severity == self::MESSAGE_WARNING || |
|
| 33 | + $severity == self::MESSAGE_ERROR) { |
|
| 34 | + wfDebug($message); |
|
| 35 | 35 | } |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - function addError( $message ) { |
|
| 38 | + function addError($message) { |
|
| 39 | 39 | $this->mMessages[] = array($message, self::MESSAGE_ERROR); |
| 40 | - wfDebug( "Error: $message\n" ); |
|
| 40 | + wfDebug("Error: $message\n"); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - function addWarning( $message ) { |
|
| 43 | + function addWarning($message) { |
|
| 44 | 44 | $this->mMessages[] = array($message, self::MESSAGE_WARNING); |
| 45 | - wfDebug( "Warning: $message\n" ); |
|
| 45 | + wfDebug("Warning: $message\n"); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - function addNotice( $message ) { |
|
| 48 | + function addNotice($message) { |
|
| 49 | 49 | $this->mMessages[] = array($message, self::MESSAGE_NOTICE); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - function getMessagesFormatted( $severity = self::MESSAGE_WARNING, $header = null ) { |
|
| 52 | + function getMessagesFormatted($severity = self::MESSAGE_WARNING, $header = null) { |
|
| 53 | 53 | global $wgTitle, $wgUser; |
| 54 | 54 | |
| 55 | 55 | $ret = ''; |
| 56 | 56 | |
| 57 | - foreach ( $this->mMessages as $message ) { |
|
| 58 | - if ( $message[1] <= $severity ) { |
|
| 59 | - $ret .= '* ' . $message[0] . "\n"; |
|
| 57 | + foreach ($this->mMessages as $message) { |
|
| 58 | + if ($message[1] <= $severity) { |
|
| 59 | + $ret .= '* '.$message[0]."\n"; |
|
| 60 | 60 | } |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - if ( $ret != '' ) { |
|
| 64 | - if ( !$this->mParser ) { |
|
| 63 | + if ($ret != '') { |
|
| 64 | + if (!$this->mParser) { |
|
| 65 | 65 | $parser = new Parser(); |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - if ( $header == null ) { |
|
| 68 | + if ($header == null) { |
|
| 69 | 69 | $header = ''; |
| 70 | - } elseif ( $header != '' ) { |
|
| 71 | - $header = Html::rawElement( 'div', array('class' => 'heading'), $header ); |
|
| 70 | + } elseif ($header != '') { |
|
| 71 | + $header = Html::rawElement('div', array('class' => 'heading'), $header); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - $ret = Html::rawElement( 'div', array('class' => 'messages'), |
|
| 75 | - $header . "\n" . |
|
| 74 | + $ret = Html::rawElement('div', array('class' => 'messages'), |
|
| 75 | + $header."\n". |
|
| 76 | 76 | $ret |
| 77 | 77 | ); |
| 78 | 78 | |
| 79 | - $ret = $parser->parse( $ret, $wgTitle, ParserOptions::newFromUser( $wgUser ) ); |
|
| 79 | + $ret = $parser->parse($ret, $wgTitle, ParserOptions::newFromUser($wgUser)); |
|
| 80 | 80 | } else { |
| 81 | 81 | $ret = null; |
| 82 | 82 | } |