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