r73662 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r73661‎ | r73662 | r73663 >
Date:16:17, 24 September 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Misc improvements
Modified paths:
  • /trunk/extensions/SlimboxThumbs/SlimboxThumbs.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SlimboxThumbs/SlimboxThumbs.php
@@ -19,7 +19,7 @@
2020 die( 'Not an entry point.' );
2121 }
2222
23 -define( 'SlimboxThumbs_VERSION', '0.1' );
 23+define( 'SlimboxThumbs_VERSION', '0.2' );
2424
2525 // Register the extension credits.
2626 $wgExtensionCredits['other'][] = array(
@@ -50,7 +50,7 @@
5151 */
5252 if ( $slimboxThumbsFilesDir ) {
5353 $slimboxThumbsFilesDir = rtrim( trim( $slimboxThumbsFilesDir ), '/' ); // strip whitespace, then any trailing /
54 - // $wgHooks['BeforeParserrenderImageGallery'][] = 'efSBTTestForGallery'; // this seems to fail on some pages :(
 54+ $wgHooks['BeforeParserrenderImageGallery'][] = 'efSBTTestForGallery'; // this seems to fail on some pages :(
5555 $hasGallery = true; // temporary fix
5656 $wgHooks['BeforePageDisplay'][] = 'efSBTAddScripts';
5757 $wgHooks['BeforePageDisplay'][] = 'efSBTAddSlimboxCode';
@@ -58,19 +58,20 @@
5959
6060 function efSBTTestForGallery( $parser, $gallery ) {
6161 global $hasGallery;
62 - if ( $gallery instanceof ImageGallery )
63 - return $hasGallery = true;
64 - return false;
 62+ $hasGallery = $gallery instanceof ImageGallery;
 63+ return $hasGallery;
6564 }
6665
6766 function efSBTDebugVar( $varName, $var ) {
6867 return "\n\n<!--\n$varName: " . str_replace( '--', '__', print_r( $var, true ) ) . "\n-->\n\n";
6968 }
7069
71 -// this is a callback function that gets called by efBeforePageDisplay()
 70+// This is a callback function that gets called by efBeforePageDisplay().
7271 function efRewriteThumbImage( $matches ) {
7372 global $wgOut, $slimboxThumbsDebug;
 73+
7474 if ( $slimboxThumbsDebug ) { global $wgContLang; }
 75+
7576 $titleObj = Title::newFromText( rawurldecode( $matches[2] ) );
7677 $image = wfFindFile( $titleObj, false, false, true ); # # wfFindFile($titleObj,false,false,true) to bypass cache
7778 $output = $matches[1]
@@ -85,7 +86,7 @@
8687 return $output;
8788 }
8889
89 -// rewrite the gallery code
 90+// Rewrite the gallery code.
9091 function efRewriteGalleryImage( $matches ) {
9192 global $wgOut, $slimboxThumbsDebug, $slimboxDefaultWidth;
9293 $titleObj = Title::newFromText( rawurldecode( $matches[2] ) );
@@ -134,9 +135,11 @@
135136
136137 function efSBTAddSlimboxCode( $out, $skin ) {
137138 global $slimboxThumbsFilesDir, $wgContLang, $hasGallery;
138 -
 139+
139140 // We don't want to run regular expressions if there's no gallery here.
140 - if ( !$hasGallery ) return false;
 141+ if ( !$hasGallery ) {
 142+ return false;
 143+ }
141144
142145 # # ideally we'd do this with XPath, but we'd need valid XML for that, so we'll do it with some ugly regexes
143146 # # (could use a regex to pull out all div.thumb, maybe they're valid XML? ...probably not)
@@ -166,7 +169,7 @@
167170 /sx';
168171
169172 $allDone = preg_replace_callback( $pattern, 'efRewriteGalleryImage', $thumbnailsDone );
170 -
 173+
171174 $out->clearHTML();
172175 $out->addHTML( $allDone );
173176

Status & tagging log