Index: trunk/extensions/intersection/DynamicPageList.php |
— | — | @@ -51,6 +51,7 @@ |
52 | 52 | $dir = dirname( __FILE__ ) . '/'; |
53 | 53 | $wgExtensionMessagesFiles['DynamicPageList'] = $dir . 'DynamicPageList.i18n.php'; |
54 | 54 | |
| 55 | +// Parser tests |
55 | 56 | $wgParserTestFiles[] = $dir . 'DynamicPageList.tests.txt'; |
56 | 57 | |
57 | 58 | # Configuration variables |
— | — | @@ -78,85 +79,85 @@ |
79 | 80 | global $wgDLPmaxCategories, $wgDLPMaxResultCount; |
80 | 81 | global $wgDLPAllowUnlimitedResults, $wgDLPAllowUnlimitedCategories; |
81 | 82 | |
82 | | - $bCountSet = false; |
| 83 | + $countSet = false; |
83 | 84 | |
84 | | - $sStartList = '<ul>'; |
85 | | - $sEndList = '</ul>'; |
86 | | - $sStartItem = '<li>'; |
87 | | - $sEndItem = '</li>'; |
88 | | - $bInlineMode = false; |
| 85 | + $startList = '<ul>'; |
| 86 | + $endList = '</ul>'; |
| 87 | + $startItem = '<li>'; |
| 88 | + $endItem = '</li>'; |
| 89 | + $inlineMode = false; |
89 | 90 | |
90 | | - $bUseGallery = false; |
91 | | - $bGalleryFileSize = false; |
92 | | - $bGalleryFileName = true; |
93 | | - $iGalleryImageHeight = 0; |
94 | | - $iGalleryImageWidth = 0; |
95 | | - $iGalleryNumbRows = 0; |
96 | | - $sGalleryCaption = ''; |
| 91 | + $useGallery = false; |
| 92 | + $galleryFileSize = false; |
| 93 | + $galleryFileName = true; |
| 94 | + $galleryImageHeight = 0; |
| 95 | + $galleryImageWidth = 0; |
| 96 | + $galleryNumbRows = 0; |
| 97 | + $galleryCaption = ''; |
97 | 98 | $gallery = null; |
98 | 99 | |
99 | | - $sOrderMethod = 'categoryadd'; |
100 | | - $sOrder = 'descending'; |
101 | | - $sRedirects = 'exclude'; |
102 | | - $sStable = $sQuality = 'include'; |
103 | | - $bFlaggedRevs = false; |
| 100 | + $orderMethod = 'categoryadd'; |
| 101 | + $order = 'descending'; |
| 102 | + $redirects = 'exclude'; |
| 103 | + $stable = $quality = 'include'; |
| 104 | + $flaggedRevs = false; |
104 | 105 | |
105 | 106 | $bNamespace = false; |
106 | | - $iNamespace = 0; |
| 107 | + $namespaceIndex = 0; |
107 | 108 | |
108 | | - $iOffset = 0; |
| 109 | + $offset = 0; |
109 | 110 | |
110 | | - $bGoogleHack = false; |
| 111 | + $googleHack = false; |
111 | 112 | |
112 | | - $bSuppressErrors = false; |
113 | | - $bShowNamespace = true; |
114 | | - $bAddFirstCategoryDate = false; |
115 | | - $sDateFormat = ''; |
116 | | - $bStripYear = false; |
| 113 | + $suppressErrors = false; |
| 114 | + $showNamespace = true; |
| 115 | + $addFirstCategoryDate = false; |
| 116 | + $dateFormat = ''; |
| 117 | + $stripYear = false; |
117 | 118 | |
118 | | - $aLinkOptions = array(); |
119 | | - $aCategories = array(); |
120 | | - $aExcludeCategories = array(); |
| 119 | + $linkOptions = array(); |
| 120 | + $categories = array(); |
| 121 | + $excludeCategories = array(); |
121 | 122 | |
122 | | - $aParams = explode( "\n", $input ); |
| 123 | + $parameters = explode( "\n", $input ); |
123 | 124 | |
124 | 125 | $parser = new Parser; |
125 | 126 | $poptions = new ParserOptions; |
126 | 127 | |
127 | | - foreach ( $aParams as $sParam ) { |
128 | | - $aParam = explode( '=', $sParam, 2 ); |
| 128 | + foreach ( $parameters as $parameter ) { |
| 129 | + $aParam = explode( '=', $parameter, 2 ); |
129 | 130 | if( count( $aParam ) < 2 ) { |
130 | 131 | continue; |
131 | 132 | } |
132 | | - $sType = trim( $aParam[0] ); |
133 | | - $sArg = trim( $aParam[1] ); |
134 | | - switch ( $sType ) { |
| 133 | + $type = trim( $aParam[0] ); |
| 134 | + $arg = trim( $aParam[1] ); |
| 135 | + switch ( $type ) { |
135 | 136 | case 'category': |
136 | 137 | $title = Title::newFromText( |
137 | | - $parser->transformMsg( $sArg, $poptions ) |
| 138 | + $parser->transformMsg( $arg, $poptions ) |
138 | 139 | ); |
139 | 140 | if( is_null( $title ) ) { |
140 | 141 | continue; |
141 | 142 | } |
142 | | - $aCategories[] = $title; |
| 143 | + $categories[] = $title; |
143 | 144 | break; |
144 | 145 | case 'notcategory': |
145 | 146 | $title = Title::newFromText( |
146 | | - $parser->transformMsg( $sArg, $poptions ) |
| 147 | + $parser->transformMsg( $arg, $poptions ) |
147 | 148 | ); |
148 | 149 | if( is_null( $title ) ) { |
149 | 150 | continue; |
150 | 151 | } |
151 | | - $aExcludeCategories[] = $title; |
| 152 | + $excludeCategories[] = $title; |
152 | 153 | break; |
153 | 154 | case 'namespace': |
154 | | - $ns = $wgContLang->getNsIndex( $sArg ); |
| 155 | + $ns = $wgContLang->getNsIndex( $arg ); |
155 | 156 | if ( $ns != null ) { |
156 | | - $iNamespace = $ns; |
| 157 | + $namespaceIndex = $ns; |
157 | 158 | $bNamespace = true; |
158 | 159 | } else { |
159 | | - $iNamespace = intval( $sArg ); |
160 | | - if ( $iNamespace >= 0 ) { |
| 160 | + $namespaceIndex = intval( $arg ); |
| 161 | + if ( $namespaceIndex >= 0 ) { |
161 | 162 | $bNamespace = true; |
162 | 163 | } else { |
163 | 164 | $bNamespace = false; |
— | — | @@ -164,259 +165,259 @@ |
165 | 166 | } |
166 | 167 | break; |
167 | 168 | case 'count': |
168 | | - // ensure that $iCount is a number; |
169 | | - $iCount = intval( $sArg ); |
170 | | - $bCountSet = true; |
| 169 | + // ensure that $count is a number; |
| 170 | + $count = intval( $arg ); |
| 171 | + $countSet = true; |
171 | 172 | break; |
172 | 173 | case 'offset': |
173 | | - $iOffset = intval( $sArg ); |
| 174 | + $offset = intval( $arg ); |
174 | 175 | break; |
175 | 176 | case 'imagewidth': |
176 | | - $iGalleryImageWidth = intval( $sArg ); |
| 177 | + $galleryImageWidth = intval( $arg ); |
177 | 178 | break; |
178 | 179 | case 'imageheight': |
179 | | - $iGalleryImageHeight = intval( $sArg ); |
| 180 | + $galleryImageHeight = intval( $arg ); |
180 | 181 | break; |
181 | 182 | case 'imagesperrow': |
182 | | - $iGalleryNumbRows = intval( $sArg ); |
| 183 | + $galleryNumbRows = intval( $arg ); |
183 | 184 | break; |
184 | 185 | case 'mode': |
185 | | - switch ( $sArg ) { |
| 186 | + switch ( $arg ) { |
186 | 187 | case 'gallery': |
187 | | - $bUseGallery = true; |
| 188 | + $useGallery = true; |
188 | 189 | $gallery = new ImageGallery; |
189 | | - $sStartList = ''; |
190 | | - $sEndList = ''; |
191 | | - $sStartItem = ''; |
192 | | - $sEndItem = ''; |
| 190 | + $startList = ''; |
| 191 | + $endList = ''; |
| 192 | + $startItem = ''; |
| 193 | + $endItem = ''; |
193 | 194 | break; |
194 | 195 | case 'none': |
195 | | - $sStartList = ''; |
196 | | - $sEndList = ''; |
197 | | - $sStartItem = ''; |
198 | | - $sEndItem = '<br />'; |
199 | | - $bInlineMode = false; |
| 196 | + $startList = ''; |
| 197 | + $endList = ''; |
| 198 | + $startItem = ''; |
| 199 | + $endItem = '<br />'; |
| 200 | + $inlineMode = false; |
200 | 201 | break; |
201 | 202 | case 'ordered': |
202 | | - $sStartList = '<ol>'; |
203 | | - $sEndList = '</ol>'; |
204 | | - $sStartItem = '<li>'; |
205 | | - $sEndItem = '</li>'; |
206 | | - $bInlineMode = false; |
| 203 | + $startList = '<ol>'; |
| 204 | + $endList = '</ol>'; |
| 205 | + $startItem = '<li>'; |
| 206 | + $endItem = '</li>'; |
| 207 | + $inlineMode = false; |
207 | 208 | break; |
208 | 209 | case 'inline': |
209 | 210 | // aka comma seperated list |
210 | | - $sStartList = ''; |
211 | | - $sEndList = ''; |
212 | | - $sStartItem = ''; |
213 | | - $sEndItem = ''; |
214 | | - $bInlineMode = true; |
| 211 | + $startList = ''; |
| 212 | + $endList = ''; |
| 213 | + $startItem = ''; |
| 214 | + $endItem = ''; |
| 215 | + $inlineMode = true; |
215 | 216 | break; |
216 | 217 | case 'unordered': |
217 | 218 | default: |
218 | | - $sStartList = '<ul>'; |
219 | | - $sEndList = '</ul>'; |
220 | | - $sStartItem = '<li>'; |
221 | | - $sEndItem = '</li>'; |
222 | | - $bInlineMode = false; |
| 219 | + $startList = '<ul>'; |
| 220 | + $endList = '</ul>'; |
| 221 | + $startItem = '<li>'; |
| 222 | + $endItem = '</li>'; |
| 223 | + $inlineMode = false; |
223 | 224 | break; |
224 | 225 | } |
225 | 226 | break; |
226 | 227 | case 'gallerycaption': |
227 | 228 | // Should perhaps actually parse caption instead |
228 | 229 | // as links and what not in caption might be useful. |
229 | | - $sGalleryCaption = $parser->transformMsg( $sArg, $poptions ); |
| 230 | + $galleryCaption = $parser->transformMsg( $arg, $poptions ); |
230 | 231 | break; |
231 | 232 | case 'galleryshowfilesize': |
232 | | - switch ( $sArg ) { |
| 233 | + switch ( $arg ) { |
233 | 234 | case 'no': |
234 | 235 | case 'false': |
235 | | - $bGalleryFileSize = false; |
| 236 | + $galleryFileSize = false; |
236 | 237 | break; |
237 | 238 | case 'true': |
238 | 239 | default: |
239 | | - $bGalleryFileSize = true; |
| 240 | + $galleryFileSize = true; |
240 | 241 | } |
241 | 242 | break; |
242 | 243 | case 'galleryshowfilename': |
243 | | - switch ( $sArg ) { |
| 244 | + switch ( $arg ) { |
244 | 245 | case 'no': |
245 | 246 | case 'false': |
246 | | - $bGalleryFileName = false; |
| 247 | + $galleryFileName = false; |
247 | 248 | break; |
248 | 249 | case 'true': |
249 | 250 | default: |
250 | | - $bGalleryFileName = true; |
| 251 | + $galleryFileName = true; |
251 | 252 | break; |
252 | 253 | } |
253 | 254 | break; |
254 | 255 | case 'order': |
255 | | - switch ( $sArg ) { |
| 256 | + switch ( $arg ) { |
256 | 257 | case 'ascending': |
257 | | - $sOrder = 'ascending'; |
| 258 | + $order = 'ascending'; |
258 | 259 | break; |
259 | 260 | case 'descending': |
260 | 261 | default: |
261 | | - $sOrder = 'descending'; |
| 262 | + $order = 'descending'; |
262 | 263 | break; |
263 | 264 | } |
264 | 265 | break; |
265 | 266 | case 'ordermethod': |
266 | | - switch ( $sArg ) { |
| 267 | + switch ( $arg ) { |
267 | 268 | case 'lastedit': |
268 | | - $sOrderMethod = 'lastedit'; |
| 269 | + $orderMethod = 'lastedit'; |
269 | 270 | break; |
270 | 271 | case 'length': |
271 | | - $sOrderMethod = 'length'; |
| 272 | + $orderMethod = 'length'; |
272 | 273 | break; |
273 | 274 | case 'created': |
274 | | - $sOrderMethod = 'created'; |
| 275 | + $orderMethod = 'created'; |
275 | 276 | break; |
276 | 277 | case 'sortkey': |
277 | 278 | case 'categorysortkey': |
278 | | - $sOrderMethod = 'categorysortkey'; |
| 279 | + $orderMethod = 'categorysortkey'; |
279 | 280 | break; |
280 | 281 | case 'popularity': |
281 | 282 | if ( !$wgDisableCounters ) { |
282 | | - $sOrderMethod = 'popularity'; |
| 283 | + $orderMethod = 'popularity'; |
283 | 284 | } else { |
284 | | - $sOrderMethod = 'categoyadd'; // default if hitcounter disabled. |
| 285 | + $orderMethod = 'categoyadd'; // default if hitcounter disabled. |
285 | 286 | } |
286 | 287 | break; |
287 | 288 | case 'categoryadd': |
288 | 289 | default: |
289 | | - $sOrderMethod = 'categoryadd'; |
| 290 | + $orderMethod = 'categoryadd'; |
290 | 291 | break; |
291 | 292 | } |
292 | 293 | break; |
293 | 294 | case 'redirects': |
294 | | - switch ( $sArg ) { |
| 295 | + switch ( $arg ) { |
295 | 296 | case 'include': |
296 | | - $sRedirects = 'include'; |
| 297 | + $redirects = 'include'; |
297 | 298 | break; |
298 | 299 | case 'only': |
299 | | - $sRedirects = 'only'; |
| 300 | + $redirects = 'only'; |
300 | 301 | break; |
301 | 302 | case 'exclude': |
302 | 303 | default: |
303 | | - $sRedirects = 'exclude'; |
| 304 | + $redirects = 'exclude'; |
304 | 305 | break; |
305 | 306 | } |
306 | 307 | break; |
307 | 308 | case 'stablepages': |
308 | | - switch ( $sArg ) { |
| 309 | + switch ( $arg ) { |
309 | 310 | case 'include': |
310 | | - $sStable = 'include'; |
| 311 | + $stable = 'include'; |
311 | 312 | break; |
312 | 313 | case 'only': |
313 | | - $bFlaggedRevs = true; |
314 | | - $sStable = 'only'; |
| 314 | + $flaggedRevs = true; |
| 315 | + $stable = 'only'; |
315 | 316 | break; |
316 | 317 | case 'exclude': |
317 | 318 | default: |
318 | | - $bFlaggedRevs = true; |
319 | | - $sStable = 'exclude'; |
| 319 | + $flaggedRevs = true; |
| 320 | + $stable = 'exclude'; |
320 | 321 | break; |
321 | 322 | } |
322 | 323 | break; |
323 | 324 | case 'qualitypages': |
324 | | - switch ( $sArg ) { |
| 325 | + switch ( $arg ) { |
325 | 326 | case 'include': |
326 | | - $sQuality = 'include'; |
| 327 | + $quality = 'include'; |
327 | 328 | break; |
328 | 329 | case 'only': |
329 | | - $bFlaggedRevs = true; |
330 | | - $sQuality = 'only'; |
| 330 | + $flaggedRevs = true; |
| 331 | + $quality = 'only'; |
331 | 332 | break; |
332 | 333 | case 'exclude': |
333 | 334 | default: |
334 | | - $bFlaggedRevs = true; |
335 | | - $sQuality = 'exclude'; |
| 335 | + $flaggedRevs = true; |
| 336 | + $quality = 'exclude'; |
336 | 337 | break; |
337 | 338 | } |
338 | 339 | break; |
339 | 340 | case 'suppresserrors': |
340 | | - if ( $sArg == 'true' ) { |
341 | | - $bSuppressErrors = true; |
| 341 | + if ( $arg == 'true' ) { |
| 342 | + $suppressErrors = true; |
342 | 343 | } else { |
343 | | - $bSuppressErrors = false; |
| 344 | + $suppressErrors = false; |
344 | 345 | } |
345 | 346 | break; |
346 | 347 | case 'addfirstcategorydate': |
347 | | - if ( $sArg == 'true' ) { |
348 | | - $bAddFirstCategoryDate = true; |
349 | | - } elseif ( preg_match( '/^(?:[ymd]{2,3}|ISO 8601)$/', $sArg ) ) { |
| 348 | + if ( $arg == 'true' ) { |
| 349 | + $addFirstCategoryDate = true; |
| 350 | + } elseif ( preg_match( '/^(?:[ymd]{2,3}|ISO 8601)$/', $arg ) ) { |
350 | 351 | // if it more or less is valid dateformat. |
351 | | - $bAddFirstCategoryDate = true; |
352 | | - $sDateFormat = $sArg; |
353 | | - if ( strlen( $sDateFormat ) == 2 ) { |
354 | | - $sDateFormat = $sDateFormat . 'y'; # DateFormatter does not support no year. work arround |
355 | | - $bStripYear = true; |
| 352 | + $addFirstCategoryDate = true; |
| 353 | + $dateFormat = $arg; |
| 354 | + if ( strlen( $dateFormat ) == 2 ) { |
| 355 | + $dateFormat = $dateFormat . 'y'; # DateFormatter does not support no year. work around |
| 356 | + $stripYear = true; |
356 | 357 | } |
357 | 358 | } else { |
358 | | - $bAddFirstCategoryDate = false; |
| 359 | + $addFirstCategoryDate = false; |
359 | 360 | } |
360 | 361 | break; |
361 | 362 | case 'shownamespace': |
362 | | - if ( 'false' == $sArg ) { |
363 | | - $bShowNamespace = false; |
| 363 | + if ( 'false' == $arg ) { |
| 364 | + $showNamespace = false; |
364 | 365 | } else { |
365 | | - $bShowNamespace = true; |
| 366 | + $showNamespace = true; |
366 | 367 | } |
367 | 368 | break; |
368 | 369 | case 'googlehack': |
369 | | - if ( 'false' == $sArg ) { |
370 | | - $bGoogleHack = false; |
| 370 | + if ( 'false' == $arg ) { |
| 371 | + $googleHack = false; |
371 | 372 | } else { |
372 | | - $bGoogleHack = true; |
| 373 | + $googleHack = true; |
373 | 374 | } |
374 | 375 | break; |
375 | 376 | case 'nofollow': # bug 6658 |
376 | | - if ( 'false' != $sArg ) { |
377 | | - $aLinkOptions['rel'] = 'nofollow'; |
| 377 | + if ( 'false' != $arg ) { |
| 378 | + $linkOptions['rel'] = 'nofollow'; |
378 | 379 | } |
379 | 380 | break; |
380 | 381 | } // end main switch() |
381 | 382 | } // end foreach() |
382 | 383 | |
383 | | - $iCatCount = count( $aCategories ); |
384 | | - $iExcludeCatCount = count( $aExcludeCategories ); |
385 | | - $iTotalCatCount = $iCatCount + $iExcludeCatCount; |
| 384 | + $catCount = count( $categories ); |
| 385 | + $excludeCatCount = count( $excludeCategories ); |
| 386 | + $totalCatCount = $catCount + $excludeCatCount; |
386 | 387 | |
387 | | - if ( $iCatCount < 1 && false == $bNamespace ) { |
388 | | - if ( $bSuppressErrors == false ) { |
| 388 | + if ( $catCount < 1 && false == $bNamespace ) { |
| 389 | + if ( $suppressErrors == false ) { |
389 | 390 | return htmlspecialchars( wfMsg( 'intersection_noincludecats' ) ); // "!!no included categories!!"; |
390 | 391 | } else { |
391 | 392 | return ''; |
392 | 393 | } |
393 | 394 | } |
394 | 395 | |
395 | | - if ( $iTotalCatCount > $wgDLPmaxCategories && !$wgDLPAllowUnlimitedCategories ) { |
396 | | - if ( $bSuppressErrors == false ) { |
| 396 | + if ( $totalCatCount > $wgDLPmaxCategories && !$wgDLPAllowUnlimitedCategories ) { |
| 397 | + if ( $suppressErrors == false ) { |
397 | 398 | return htmlspecialchars( wfMsg( 'intersection_toomanycats' ) ); // "!!too many categories!!"; |
398 | 399 | } else { |
399 | 400 | return ''; |
400 | 401 | } |
401 | 402 | } |
402 | 403 | |
403 | | - if ( $bCountSet ) { |
404 | | - if ( $iCount < 1 ) { |
405 | | - $iCount = 1; |
| 404 | + if ( $countSet ) { |
| 405 | + if ( $count < 1 ) { |
| 406 | + $count = 1; |
406 | 407 | } |
407 | | - if ( $iCount > $wgDLPMaxResultCount ) { |
408 | | - $iCount = $wgDLPMaxResultCount; |
| 408 | + if ( $count > $wgDLPMaxResultCount ) { |
| 409 | + $count = $wgDLPMaxResultCount; |
409 | 410 | } |
410 | 411 | } elseif ( !$wgDLPAllowUnlimitedResults ) { |
411 | | - $iCount = $wgDLPMaxResultCount; |
412 | | - $bCountSet = true; |
| 412 | + $count = $wgDLPMaxResultCount; |
| 413 | + $countSet = true; |
413 | 414 | } |
414 | 415 | |
415 | 416 | // disallow showing date if the query doesn't have an inclusion category parameter |
416 | | - if ( $iCatCount < 1 ) { |
417 | | - $bAddFirstCategoryDate = false; |
| 417 | + if ( $catCount < 1 ) { |
| 418 | + $addFirstCategoryDate = false; |
418 | 419 | // don't sort by fields relating to categories if there are no categories. |
419 | | - if ( $sOrderMethod == 'categoryadd' || $sOrderMethod == 'categorysortkey' ) { |
420 | | - $sOrderMethod = 'created'; |
| 420 | + if ( $orderMethod == 'categoryadd' || $orderMethod == 'categorysortkey' ) { |
| 421 | + $orderMethod = 'created'; |
421 | 422 | } |
422 | 423 | } |
423 | 424 | |
— | — | @@ -428,25 +429,25 @@ |
429 | 430 | $join = array(); |
430 | 431 | $options = array(); |
431 | 432 | |
432 | | - if ( $bGoogleHack ) { |
| 433 | + if ( $googleHack ) { |
433 | 434 | $fields[] = 'page_id'; |
434 | 435 | } |
435 | 436 | |
436 | | - if ( $bAddFirstCategoryDate ) { |
| 437 | + if ( $addFirstCategoryDate ) { |
437 | 438 | $fields[] = 'c1.cl_timestamp'; |
438 | 439 | } |
439 | 440 | |
440 | 441 | if ( $bNamespace == true ) { |
441 | | - $where['page_namespace'] = $iNamespace; |
| 442 | + $where['page_namespace'] = $namespaceIndex; |
442 | 443 | } |
443 | 444 | |
444 | 445 | // Bug 14943 - Allow filtering based on FlaggedRevs stability. |
445 | 446 | // Check if the extension actually exists before changing the query... |
446 | | - if ( function_exists( 'efLoadFlaggedRevs' ) && $bFlaggedRevs ) { |
| 447 | + if ( function_exists( 'efLoadFlaggedRevs' ) && $flaggedRevs ) { |
447 | 448 | $tables[] = 'flaggedpages'; |
448 | 449 | $join['flaggedpages'] = array( 'LEFT JOIN', 'page_id = fp_page_id' ); |
449 | 450 | |
450 | | - switch( $sStable ) { |
| 451 | + switch( $stable ) { |
451 | 452 | case 'only': |
452 | 453 | $where[] = 'fp_stable IS NOT NULL'; |
453 | 454 | break; |
— | — | @@ -455,7 +456,7 @@ |
456 | 457 | break; |
457 | 458 | } |
458 | 459 | |
459 | | - switch( $sQuality ) { |
| 460 | + switch( $quality ) { |
460 | 461 | case 'only': |
461 | 462 | $where[] = 'fp_quality >= 1'; |
462 | 463 | break; |
— | — | @@ -465,7 +466,7 @@ |
466 | 467 | } |
467 | 468 | } |
468 | 469 | |
469 | | - switch ( $sRedirects ) { |
| 470 | + switch ( $redirects ) { |
470 | 471 | case 'only': |
471 | 472 | $where['page_is_redirect'] = 1; |
472 | 473 | break; |
— | — | @@ -474,70 +475,70 @@ |
475 | 476 | break; |
476 | 477 | } |
477 | 478 | |
478 | | - $iCurrentTableNumber = 1; |
| 479 | + $currentTableNumber = 1; |
479 | 480 | $categorylinks = $dbr->tableName( 'categorylinks' ); |
480 | 481 | |
481 | | - for ( $i = 0; $i < $iCatCount; $i++ ) { |
482 | | - $join["$categorylinks AS c$iCurrentTableNumber"] = array( |
| 482 | + for ( $i = 0; $i < $catCount; $i++ ) { |
| 483 | + $join["$categorylinks AS c$currentTableNumber"] = array( |
483 | 484 | 'INNER JOIN', |
484 | 485 | array( |
485 | | - "page_id = c{$iCurrentTableNumber}.cl_from", |
486 | | - "c{$iCurrentTableNumber}.cl_to={$dbr->addQuotes($aCategories[$i]->getDBKey())}" |
| 486 | + "page_id = c{$currentTableNumber}.cl_from", |
| 487 | + "c{$currentTableNumber}.cl_to={$dbr->addQuotes( $categories[$i]->getDBKey() )}" |
487 | 488 | ) |
488 | 489 | ); |
489 | | - $tables[] = "$categorylinks AS c$iCurrentTableNumber"; |
| 490 | + $tables[] = "$categorylinks AS c$currentTableNumber"; |
490 | 491 | |
491 | | - $iCurrentTableNumber++; |
| 492 | + $currentTableNumber++; |
492 | 493 | } |
493 | 494 | |
494 | | - for ( $i = 0; $i < $iExcludeCatCount; $i++ ) { |
495 | | - $join["$categorylinks AS c$iCurrentTableNumber"] = array( |
| 495 | + for ( $i = 0; $i < $excludeCatCount; $i++ ) { |
| 496 | + $join["$categorylinks AS c$currentTableNumber"] = array( |
496 | 497 | 'LEFT OUTER JOIN', |
497 | 498 | array( |
498 | | - "page_id = c{$iCurrentTableNumber}.cl_from", |
499 | | - "c{$iCurrentTableNumber}.cl_to={$dbr->addQuotes($aExcludeCategories[$i]->getDBKey())}" |
| 499 | + "page_id = c{$currentTableNumber}.cl_from", |
| 500 | + "c{$currentTableNumber}.cl_to={$dbr->addQuotes( $excludeCategories[$i]->getDBKey() )}" |
500 | 501 | ) |
501 | 502 | ); |
502 | | - $tables[] = "$categorylinks AS c$iCurrentTableNumber"; |
503 | | - $where["c{$iCurrentTableNumber}.cl_to"] = null; |
504 | | - $iCurrentTableNumber++; |
| 503 | + $tables[] = "$categorylinks AS c$currentTableNumber"; |
| 504 | + $where["c{$currentTableNumber}.cl_to"] = null; |
| 505 | + $currentTableNumber++; |
505 | 506 | } |
506 | 507 | |
507 | | - if ( 'descending' == $sOrder ) { |
508 | | - $sSqlOrder = 'DESC'; |
| 508 | + if ( 'descending' == $order ) { |
| 509 | + $sqlOrder = 'DESC'; |
509 | 510 | } else { |
510 | | - $sSqlOrder = 'ASC'; |
| 511 | + $sqlOrder = 'ASC'; |
511 | 512 | } |
512 | 513 | |
513 | | - switch ( $sOrderMethod ) { |
| 514 | + switch ( $orderMethod ) { |
514 | 515 | case 'lastedit': |
515 | | - $sSqlSort = 'page_touched'; |
| 516 | + $sqlSort = 'page_touched'; |
516 | 517 | break; |
517 | 518 | case 'length': |
518 | | - $sSqlSort = 'page_len'; |
| 519 | + $sqlSort = 'page_len'; |
519 | 520 | break; |
520 | 521 | case 'created': |
521 | | - $sSqlSort = 'page_id'; # Since they're never reused and increasing |
| 522 | + $sqlSort = 'page_id'; # Since they're never reused and increasing |
522 | 523 | break; |
523 | 524 | case 'categorysortkey': |
524 | | - $sSqlSort = "c1.cl_type $sSqlOrder, c1.cl_sortkey"; |
| 525 | + $sqlSort = "c1.cl_type $sqlOrder, c1.cl_sortkey"; |
525 | 526 | break; |
526 | 527 | case 'popularity': |
527 | | - $sSqlSort = 'page_counter'; |
| 528 | + $sqlSort = 'page_counter'; |
528 | 529 | break; |
529 | 530 | case 'categoryadd': |
530 | 531 | default: |
531 | | - $sSqlSort = 'c1.cl_timestamp'; |
| 532 | + $sqlSort = 'c1.cl_timestamp'; |
532 | 533 | break; |
533 | 534 | } |
534 | 535 | |
535 | | - $options['ORDER BY'] = "$sSqlSort $sSqlOrder"; |
| 536 | + $options['ORDER BY'] = "$sqlSort $sqlOrder"; |
536 | 537 | |
537 | | - if ( $bCountSet ) { |
538 | | - $options['LIMIT'] = $iCount; |
| 538 | + if ( $countSet ) { |
| 539 | + $options['LIMIT'] = $count; |
539 | 540 | } |
540 | | - if ( $iOffset > 0 ) { |
541 | | - $options['OFFSET'] = $iOffset; |
| 541 | + if ( $offset > 0 ) { |
| 542 | + $options['OFFSET'] = $offset; |
542 | 543 | } |
543 | 544 | |
544 | 545 | // process the query |
— | — | @@ -545,7 +546,7 @@ |
546 | 547 | $sk = $wgUser->getSkin(); |
547 | 548 | |
548 | 549 | if ( $dbr->numRows( $res ) == 0 ) { |
549 | | - if ( $bSuppressErrors == false ) { |
| 550 | + if ( $suppressErrors == false ) { |
550 | 551 | return htmlspecialchars( wfMsg( 'intersection_noresults' ) ); |
551 | 552 | } else { |
552 | 553 | return ''; |
— | — | @@ -553,11 +554,11 @@ |
554 | 555 | } |
555 | 556 | |
556 | 557 | // start unordered list |
557 | | - $output = $sStartList . "\n"; |
| 558 | + $output = $startList . "\n"; |
558 | 559 | |
559 | 560 | $categoryDate = ''; |
560 | 561 | $df = null; |
561 | | - if ( $sDateFormat != '' && $bAddFirstCategoryDate ) { |
| 562 | + if ( $dateFormat != '' && $addFirstCategoryDate ) { |
562 | 563 | $df = DateFormatter::getInstance(); |
563 | 564 | } |
564 | 565 | |
— | — | @@ -567,22 +568,22 @@ |
568 | 569 | $articleList = array(); |
569 | 570 | foreach ( $res as $row ) { |
570 | 571 | $title = Title::makeTitle( $row->page_namespace, $row->page_title ); |
571 | | - if ( true == $bAddFirstCategoryDate ) { |
572 | | - if ( $sDateFormat != '' ) { |
| 572 | + if ( true == $addFirstCategoryDate ) { |
| 573 | + if ( $dateFormat != '' ) { |
573 | 574 | # this is a tad ugly |
574 | 575 | # use DateFormatter, and support disgarding year. |
575 | 576 | $categoryDate = wfTimestamp( TS_ISO_8601, $row->cl_timestamp ); |
576 | | - if ( $bStripYear ) { |
| 577 | + if ( $stripYear ) { |
577 | 578 | $categoryDate = $wgContLang->getMonthName( substr( $categoryDate, 5, 2 ) ) |
578 | 579 | . ' ' . substr ( $categoryDate, 8, 2 ); |
579 | 580 | } else { |
580 | 581 | $categoryDate = substr( $categoryDate, 0, 10 ); |
581 | 582 | } |
582 | | - $categoryDate = $df->reformat( $sDateFormat, $categoryDate, array( 'match-whole' ) ); |
| 583 | + $categoryDate = $df->reformat( $dateFormat, $categoryDate, array( 'match-whole' ) ); |
583 | 584 | } else { |
584 | 585 | $categoryDate = $wgLang->date( wfTimestamp( TS_MW, $row->cl_timestamp ) ); |
585 | 586 | } |
586 | | - if ( !$bUseGallery ) { |
| 587 | + if ( !$useGallery ) { |
587 | 588 | $categoryDate .= wfMsg( 'colon-separator' ); |
588 | 589 | } else { |
589 | 590 | $categoryDate .= ' '; |
— | — | @@ -591,17 +592,17 @@ |
592 | 593 | |
593 | 594 | $query = array(); |
594 | 595 | |
595 | | - if ( $bGoogleHack == true ) { |
| 596 | + if ( $googleHack == true ) { |
596 | 597 | $query['dpl_id'] = intval( $row->page_id ); |
597 | 598 | } |
598 | 599 | |
599 | | - if ( $bShowNamespace == true ) { |
| 600 | + if ( $showNamespace == true ) { |
600 | 601 | $titleText = $title->getPrefixedText(); |
601 | 602 | } else { |
602 | 603 | $titleText = $title->getText(); |
603 | 604 | } |
604 | 605 | |
605 | | - if ( $bUseGallery ) { |
| 606 | + if ( $useGallery ) { |
606 | 607 | # Note, $categoryDate is treated as raw html |
607 | 608 | # this is safe since the only html present |
608 | 609 | # would come from the dateformatter <span>. |
— | — | @@ -611,7 +612,7 @@ |
612 | 613 | $sk->link( |
613 | 614 | $title, |
614 | 615 | htmlspecialchars( $titleText ), |
615 | | - $aLinkOptions, |
| 616 | + $linkOptions, |
616 | 617 | $query, |
617 | 618 | array( 'forcearticlepath', 'known' ) |
618 | 619 | ); |
— | — | @@ -619,32 +620,33 @@ |
620 | 621 | } |
621 | 622 | |
622 | 623 | // end unordered list |
623 | | - if ( $bUseGallery ) { |
| 624 | + if ( $useGallery ) { |
624 | 625 | $gallery->setHideBadImages(); |
625 | | - $gallery->setShowFilename( $bGalleryFileName ); |
626 | | - $gallery->setShowBytes( $bGalleryFileSize ); |
627 | | - if ( $iGalleryImageHeight > 0 ) { |
628 | | - $gallery->setHeights( $iGalleryImageHeight ); |
| 626 | + $gallery->setShowFilename( $galleryFileName ); |
| 627 | + $gallery->setShowBytes( $galleryFileSize ); |
| 628 | + if ( $galleryImageHeight > 0 ) { |
| 629 | + $gallery->setHeights( $galleryImageHeight ); |
629 | 630 | } |
630 | | - if ( $iGalleryImageWidth > 0 ) { |
631 | | - $gallery->setWidths( $iGalleryImageWidth ); |
| 631 | + if ( $galleryImageWidth > 0 ) { |
| 632 | + $gallery->setWidths( $galleryImageWidth ); |
632 | 633 | } |
633 | | - if ( $iGalleryNumbRows > 0 ) { |
634 | | - $gallery->setPerRow( $iGalleryNumbRows ); |
| 634 | + if ( $galleryNumbRows > 0 ) { |
| 635 | + $gallery->setPerRow( $galleryNumbRows ); |
635 | 636 | } |
636 | | - if ( $sGalleryCaption != '' ) { |
637 | | - $gallery->setCaption( $sGalleryCaption ); # gallery class escapes string |
| 637 | + if ( $galleryCaption != '' ) { |
| 638 | + $gallery->setCaption( $galleryCaption ); # gallery class escapes string |
638 | 639 | } |
639 | 640 | $output = $gallery->toHtml(); |
640 | 641 | } else { |
641 | | - $output .= $sStartItem; |
642 | | - if ( $bInlineMode ) { |
| 642 | + $output .= $startItem; |
| 643 | + if ( $inlineMode ) { |
643 | 644 | $output .= $wgContLang->commaList( $articleList ); |
644 | 645 | } else { |
645 | | - $output .= implode( "$sEndItem \n $sStartItem", $articleList ); |
| 646 | + $output .= implode( "$endItem \n $startItem", $articleList ); |
646 | 647 | } |
647 | | - $output .= $sEndItem; |
648 | | - $output .= $sEndList . "\n"; |
| 648 | + $output .= $endItem; |
| 649 | + $output .= $endList . "\n"; |
649 | 650 | } |
| 651 | + |
650 | 652 | return $output; |
651 | 653 | } |