r50418 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50417‎ | r50418 | r50419 >
Date:08:59, 10 May 2009
Author:siebrand
Status:deferred
Tags:
Comment:
* stylize.php, update indentation, remove trailing whitespace
* added a fixme for parser tag init
* updated line breaks in README
* update svn props
Modified paths:
  • /trunk/extensions/SmoothGallery/README (modified) (history)
  • /trunk/extensions/SmoothGallery/SmoothGallery.i18n.php (modified) (history)
  • /trunk/extensions/SmoothGallery/SmoothGallery.php (modified) (history)
  • /trunk/extensions/SmoothGallery/SmoothGalleryClass.php (modified) (history)
  • /trunk/extensions/SmoothGallery/SmoothGalleryParser.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SmoothGallery/SmoothGalleryClass.php
@@ -21,24 +21,24 @@
2222
2323 function checkForErrors() {
2424 foreach ( $this->galleriesArray["galleries"] as $galleryArray ) {
25 - //We are being harsh for gallery sets.
26 - //If even one gallery is missing all images, we
27 - //are going to return an error to the user.
 25+ // We are being harsh for gallery sets.
 26+ // If even one gallery is missing all images, we
 27+ // are going to return an error to the user.
2828 if ( !isset( $galleryArray["images"] ) ) {
2929 wfLoadExtensionMessages( 'SmoothGallery' );
3030 $error = wfMsg( "smoothgallery-error" );
31 -
 31+
3232 if ( isset( $galleryArray["missing_images"] ) && isset( $galleryArray["invalid_images"] ) ) {
33 - $error .= wfMsg( "smoothgallery-no-images", implode( ", " , $galleryArray["missing_images"] , count($galleryArray["missing_images"]) , count($galleryArray["missing_images"]) + count($galleryArray["invalid_images"]) ) ); // FIXME: 3rd (last) parameter should have the number of good images added.
34 - $error .= wfMsg( "smoothgallery-invalid-images", implode( ", " , $galleryArray["invalid_images"] , count($galleryArray["invalid_images"]) ) );
 33+ $error .= wfMsg( "smoothgallery-no-images", implode( ", " , $galleryArray["missing_images"] , count( $galleryArray["missing_images"] ) , count( $galleryArray["missing_images"] ) + count( $galleryArray["invalid_images"] ) ) ); // FIXME: 3rd (last) parameter should have the number of good images added.
 34+ $error .= wfMsg( "smoothgallery-invalid-images", implode( ", " , $galleryArray["invalid_images"] , count( $galleryArray["invalid_images"] ) ) );
3535 } else if ( isset( $galleryArray["invalid_images"] ) ) {
36 - $error .= wfMsg( "smoothgallery-invalid-images", implode( ", " , $galleryArray["invalid_images"] , count($galleryArray["invalid_images"]) ) );
 36+ $error .= wfMsg( "smoothgallery-invalid-images", implode( ", " , $galleryArray["invalid_images"] , count( $galleryArray["invalid_images"] ) ) );
3737 } else if ( isset( $galleryArray["missing_images"] ) ) {
38 - $error .= wfMsg( "smoothgallery-no-images", implode( ", " , $galleryArray["missing_images"] , count($galleryArray["missing_images"]) , count($galleryArray["missing_images"]) ) ); // FIXME: 3rd (last) parameter should have the number of good images added.
 38+ $error .= wfMsg( "smoothgallery-no-images", implode( ", " , $galleryArray["missing_images"] , count( $galleryArray["missing_images"] ) , count( $galleryArray["missing_images"] ) ) ); // FIXME: 3rd (last) parameter should have the number of good images added.
3939 } else {
4040 $error .= wfMsg( "smoothgallery-not-found" );
4141 }
42 -
 42+
4343 if ( $this->errors == '' ) {
4444 $this->errors = $error;
4545 } else {
@@ -46,7 +46,6 @@
4747 }
4848 }
4949 }
50 -
5150 }
5251
5352 function setArguments( $argumentArray ) {
@@ -68,20 +67,20 @@
6968 function toHTML () {
7069 $output = '';
7170 $fallbackOutput = '';
72 -
 71+
7372 if ( $this->set ) {
74 - //Open the div, and initialize any needed variables
 73+ // Open the div, and initialize any needed variables
7574 $output = '<div id="' . $this->galleriesArray["gallery_set_name"] . '" style="width: ' . $this->argumentArray["width"] . ';height: ' . $this->argumentArray["height"] . '; display: none;" >';
76 -
77 - //iterate through galleries, call renderGallery on each, and
78 - //collect the fallback output
 75+
 76+ // iterate through galleries, call renderGallery on each, and
 77+ // collect the fallback output
7978 $i = 1;
8079 foreach ( $this->galleriesArray["galleries"] as $galleryArray ) {
8180 $output .= $this->renderGallery( $galleryArray );
8281 $fallbackOutput .= $this->renderFallback( $galleryArray );
8382 $i++;
8483 }
85 -
 84+
8685 $output .= '</div>';
8786 $output .= '<div id="' . $this->galleriesArray["gallery_set_name"] . '-fallback">' . $fallbackOutput . '</div>';
8887 $output .= $this->renderJavascript( $this->galleriesArray["gallery_set_name"] );
@@ -90,30 +89,30 @@
9190 $output .= $this->renderFallback( $this->galleriesArray["galleries"][0] );
9291 $output .= $this->renderJavascript( $this->galleriesArray["galleries"][0]["gallery_name"] );
9392 }
94 -
 93+
9594 # flags for use by smoothGalleryParserOutput
9695 $this->parser->mOutput->mSmoothGalleryTag = true;
9796 if ( $this->set ) {
9897 $this->parser->mOutput->mSmoothGallerySetTag = true;
9998 }
100 -
101 - //Finished, let's send it out
 99+
 100+ // Finished, let's send it out
102101 return $output;
103102 }
104 -
 103+
105104 function renderGallery ( $galleryArray ) {
106105 global $wgSmoothGalleryDelimiter;
107106 global $wgSmoothGalleryThumbHeight, $wgSmoothGalleryThumbWidth;
108 -
109 - //Open the outer div of the gallery
 107+
 108+ // Open the outer div of the gallery
110109 if ( $this->set ) {
111110 $output = '<div id="' . $galleryArray["gallery_name"] . '" class="galleryElement">';
112111 $output .= '<h2>' . $galleryArray["gallery_name"] . '<h2>';
113112 } else {
114113 $output = '<div id="' . $galleryArray["gallery_name"] . '" style="width: ' . $this->argumentArray["width"] . ';height: ' . $this->argumentArray["height"] . '; display:none;">';
115114 }
116 -
117 - //TODO iterate over the images and output each
 115+
 116+ // TODO iterate over the images and output each
118117 foreach ( $galleryArray["images"] as $imageArray ) {
119118 if ( isset( $imageArray["external"] ) && $imageArray["external"] ) {
120119 $thumbsizes = 'height="' . $wgSmoothGalleryThumbHeight . '" width="' . $wgSmoothGalleryThumbWidth . '" ';
@@ -122,35 +121,34 @@
123122 $thumbsizes = '';
124123 $fullsizes = '';
125124 }
126 - //Add the html for the image
 125+ // Add the html for the image
127126 $output .= '<div class="imageElement">';
128127 $output .= '<h3>' . $imageArray["heading"] . '</h3>';
129128 $output .= '<p>' . $imageArray["description"] . '</p>';
130129 $output .= '<a href="' . $imageArray["full_url"] . '" title="open image" class="open"></a>';
131130 $output .= '<a href="' . $imageArray["view_url"] . '" title="open image" class="open"></a>';
132131 $output .= '<img src="' . $imageArray["full_thumb_url"] . '" class="full" alt="' . $imageArray["description"] . '" ' . $fullsizes . '/>';
133 -
 132+
134133 if ( $this->argumentArray["carousel"] ) {
135134 $output .= '<img src="' . $imageArray["icon_thumb_url"] . '" class="thumbnail" alt="' . $imageArray["description"] . '" ' . $thumbsizes . '/>';
136135 }
137 -
 136+
138137 $output .= '</div>';
139138 }
140 -
141 -
142 - //Close the outer div of the gallery
 139+
 140+ // Close the outer div of the gallery
143141 $output .= '</div>';
144 -
 142+
145143 return $output;
146144 }
147 -
 145+
148146 function renderFallback ( $galleryArray ) {
149147 $output = '';
150 -
 148+
151149 if ( !isset( $galleryArray["images"] ) ) {
152150 return $output;
153151 }
154 -
 152+
155153 if ( $this->argumentArray["fallback"] == "image" ) {
156154 if ( !isset( $galleryArray["images"][0] ) ) {
157155 return '';
@@ -167,7 +165,7 @@
168166 $output .= '<div id="' . $galleryArray['gallery_name'] . '-fallback" class="MediaWikiSGalleryWarning" style="width: ' . $this->argumentArray["width"] . ';height: ' . $this->argumentArray["height"] . ';" alt="' . $galleryArray["images"][0]["description"] . '">';
169167
170168 wfLoadExtensionMessages( 'SmoothGallery' );
171 - $output .= wfMsg("smoothgallery-javascript-disabled");
 169+ $output .= wfMsg( "smoothgallery-javascript-disabled" );
172170
173171 $output .= '<div class="MediaWikiSGallerySingleImage">';
174172 $output .= '<img src="' . $galleryArray["images"][0]["full_thumb_url"] . '" class="full" alt="' . $galleryArray["images"][0]["description"] . '" />';
@@ -175,32 +173,32 @@
176174 } else {
177175 $output .= $this->renderPlainGallery ( $galleryArray );
178176 }
179 -
 177+
180178 return $output;
181179 }
182 -
 180+
183181 function renderPlainGallery ( $galleryArray ) {
184182 global $wgVersion;
185 -
 183+
186184 if ( !isset( $galleryArray["images"] ) ) {
187185 return '';
188186 }
189 -
190 - //Wrapper div for plain old gallery, to be shown per default, if JS is off.
 187+
 188+ // Wrapper div for plain old gallery, to be shown per default, if JS is off.
191189 $output = '<div id="' . $galleryArray["gallery_name"] . '-fallback">';
192 -
 190+
193191 $plain_gallery = new ImageGallery();
194192
195 - $i = 0;
 193+ $i = 0;
196194 foreach ( $galleryArray["images"] as $image ) {
197195 if ( isset( $image["external"] ) && $image["external"] ) {
198196 continue;
199197 }
200198
201199 if ( version_compare( $wgVersion, "1.11", '<' ) ) {
202 - $plain_gallery->add( $image["image_object"], $image["description"] ); //TODO: use text
 200+ $plain_gallery->add( $image["image_object"], $image["description"] ); // TODO: use text
203201 } else {
204 - $plain_gallery->add( $image["image_object"]->getTitle(), $image["description"] ); //TODO: use text
 202+ $plain_gallery->add( $image["image_object"]->getTitle(), $image["description"] ); // TODO: use text
205203 }
206204 $i++;
207205 }
@@ -212,124 +210,124 @@
213211 }
214212
215213 $output .= $plain_gallery->toHTML();
216 -
217 - //Close the wrapper div for the plain old gallery
 214+
 215+ // Close the wrapper div for the plain old gallery
218216 $output .= '</div>';
219 -
 217+
220218 return $output;
221219 }
222 -
 220+
223221 function renderJavascript ( $name ) {
224 - //Output the javascript needed for the gallery with any
225 - //options the user requested
 222+ // Output the javascript needed for the gallery with any
 223+ // options the user requested
226224 $output = '<script type="text/javascript">';
227 -
228 - $output .= 'document.getElementById("' . $name . '-fallback").style.display = "none";'; //hide plain gallery
229 - $output .= 'document.getElementById("' . $name . '").style.display = "block";'; //show smooth gallery
230 -
 225+
 226+ $output .= 'document.getElementById("' . $name . '-fallback").style.display = "none";'; // hide plain gallery
 227+ $output .= 'document.getElementById("' . $name . '").style.display = "block";'; // show smooth gallery
 228+
231229 $output .= 'function startGallery_' . $name . '() {';
232230 if ( $this->set ) {
233231 $output .= "var MediaWikiSGallerySet = new gallerySet($('" . $name . "'), {";
234232 } else {
235233 $output .= "var MediaWikiSGallery = new gallery($('" . $name . "'), {";
236234 }
237 -
238 - $output .= 'thumbWidth: 100, thumbHeight: 75'; //would be nice if we could change this to 120x120 to re-use thumbnails...
239 -
240 - //Add user provided options
 235+
 236+ $output .= 'thumbWidth: 100, thumbHeight: 75'; // would be nice if we could change this to 120x120 to re-use thumbnails...
 237+
 238+ // Add user provided options
241239 if ( $this->argumentArray["timed"] ) {
242240 $output .= ', timed: true';
243241 $output .= ', delay: ' . $this->argumentArray["delay"];
244242 }
245 -
 243+
246244 if ( !$this->argumentArray["carousel"] ) {
247245 $output .= ', showCarousel: false';
248246 }
249 -
 247+
250248 if ( !$this->argumentArray["showarrows"] ) {
251249 $output .= ', showArrows: false';
252250 }
253 -
 251+
254252 if ( !$this->argumentArray["showinfopane"] ) {
255253 $output .= ', showInfopane: false';
256254 }
257 -
 255+
258256 if ( !$this->argumentArray["slideinfozoneslide"] ) {
259257 $output .= ', slideInfoZoneSlide: false';
260258 }
261 -
 259+
262260 if ( $this->argumentArray["slideinfozoneopacity"] ) {
263261 $output .= ', slideInfoZoneOpacity: ' . $this->argumentArray["slideinfozoneopacity"];
264262 }
265 -
266 - #$output .= ', useHistoryManager: true';
267 - #$output .= ', preloader: true';
268 - #$output .= ', preloaderImage: true';
269 - #$output .= ', preloaderErrorImage: true';
270 - #$output .= ', carouselPreloader: true';
271 - #$output .= ", textPreloadingCarousel: '" . wfMsg("smoothgallery-loading") . "'";
272 -
 263+
 264+ # $output .= ', useHistoryManager: true';
 265+ # $output .= ', preloader: true';
 266+ # $output .= ', preloaderImage: true';
 267+ # $output .= ', preloaderErrorImage: true';
 268+ # $output .= ', carouselPreloader: true';
 269+ # $output .= ", textPreloadingCarousel: '" . wfMsg("smoothgallery-loading") . "'";
 270+
273271 $output .= '});';
274 - #$output .= 'HistoryManager.start();';
 272+ # $output .= 'HistoryManager.start();';
275273 $output .= '}';
276274 $output .= "window.addEvent('domready', startGallery_$name);";
277 - #$output .= 'addOnloadHook(startGallery_' . $name . ');';
 275+ # $output .= 'addOnloadHook(startGallery_' . $name . ');';
278276 $output .= '</script>';
279 -
 277+
280278 return $output;
281279 }
282 -
283 - static function setGalleryHeaders( &$outputPage ) {
284 - global $wgSmoothGalleryExtensionPath;
285280
286 - $extensionpath = $wgSmoothGalleryExtensionPath;
 281+ static function setGalleryHeaders( &$outputPage ) {
 282+ global $wgSmoothGalleryExtensionPath;
287283
288 - //Add mootools (required by SmoothGallery)
289 - //You can use the compressed js if you want, but I
290 - //generally don't trust them unless I wrote them myself
291 - $outputPage->addScript( '<script src="' . $extensionpath . '/scripts/mootools.uncompressed.js" type="text/javascript"></script>' );
 284+ $extensionpath = $wgSmoothGalleryExtensionPath;
292285
293 - //Add SmoothGallery javascript
294 - $outputPage->addScript( '<script src="' . $extensionpath . '/scripts/jd.gallery.js" type="text/javascript"></script>' );
295 - $outputPage->addScript( '<script src="' . $extensionpath . '/scripts/HistoryManager.js" type="text/javascript"></script>' );
 286+ // Add mootools (required by SmoothGallery)
 287+ // You can use the compressed js if you want, but I
 288+ // generally don't trust them unless I wrote them myself
 289+ $outputPage->addScript( '<script src="' . $extensionpath . '/scripts/mootools.uncompressed.js" type="text/javascript"></script>' );
296290
297 - //Add SmoothGallery css
298 - $outputPage->addLink(
299 - array(
300 - 'rel' => 'stylesheet',
301 - 'type' => 'text/css',
302 - 'href' => $extensionpath . '/css/jd.gallery.css'
303 - )
304 - );
 291+ // Add SmoothGallery javascript
 292+ $outputPage->addScript( '<script src="' . $extensionpath . '/scripts/jd.gallery.js" type="text/javascript"></script>' );
 293+ $outputPage->addScript( '<script src="' . $extensionpath . '/scripts/HistoryManager.js" type="text/javascript"></script>' );
305294
306 - #$outputPage->addScript( '<link rel="stylesheet" href="' . $extensionpath . '/css/jd.gallery.css" type="text/css" media="screen" charset="utf-8" />' );
 295+ // Add SmoothGallery css
 296+ $outputPage->addLink(
 297+ array(
 298+ 'rel' => 'stylesheet',
 299+ 'type' => 'text/css',
 300+ 'href' => $extensionpath . '/css/jd.gallery.css'
 301+ )
 302+ );
307303
308 - $outputPage->addScript( '<style type="text/css">.jdGallery .slideInfoZone { overflow:auto ! important; }</style>' );
 304+ # $outputPage->addScript( '<link rel="stylesheet" href="' . $extensionpath . '/css/jd.gallery.css" type="text/css" media="screen" charset="utf-8" />' );
309305
310 - return true;
311 - }
 306+ $outputPage->addScript( '<style type="text/css">.jdGallery .slideInfoZone { overflow:auto ! important; }</style>' );
312307
313 - static function setGallerySetHeaders( &$outputPage ) {
314 - global $wgSmoothGalleryExtensionPath;
 308+ return true;
 309+ }
315310
316 - $extensionpath = $wgSmoothGalleryExtensionPath;
317 - $outputPage->addScript( '<script src="' . $extensionpath . '/scripts/jd.gallery.set.js" type="text/javascript"></script>' );
 311+ static function setGallerySetHeaders( &$outputPage ) {
 312+ global $wgSmoothGalleryExtensionPath;
318313
 314+ $extensionpath = $wgSmoothGalleryExtensionPath;
 315+ $outputPage->addScript( '<script src="' . $extensionpath . '/scripts/jd.gallery.set.js" type="text/javascript"></script>' );
 316+
319317 return true;
320318 }
321319
322320 static function debug( $debugText, $debugArr = null ) {
323 - global $wgSmoothGalleryDebug;
 321+ global $wgSmoothGalleryDebug;
324322
325 - if ( isset( $debugArr ) ) {
326 - if ( $wgSmoothGalleryDebug > 0 ) {
327 - $text = $debugText . " " . implode( "::", $debugArr );
328 - wfDebugLog( 'sgallery', $text, false );
329 - }
330 - } else {
331 - if ( $wgSmoothGalleryDebug > 0 ) {
332 - wfDebugLog( 'sgallery', $debugText, false );
333 - }
334 - }
 323+ if ( isset( $debugArr ) ) {
 324+ if ( $wgSmoothGalleryDebug > 0 ) {
 325+ $text = $debugText . " " . implode( "::", $debugArr );
 326+ wfDebugLog( 'sgallery', $text, false );
 327+ }
 328+ } else {
 329+ if ( $wgSmoothGalleryDebug > 0 ) {
 330+ wfDebugLog( 'sgallery', $debugText, false );
 331+ }
 332+ }
335333 }
336334 }
Index: trunk/extensions/SmoothGallery/SmoothGalleryParser.php
@@ -6,7 +6,7 @@
77 var $argumentArray;
88 var $galleriesArray;
99
10 - function SmoothGalleryParser( $input, $argv, &$parser, $calledAsSet=false ) {
 10+ function SmoothGalleryParser( $input, $argv, &$parser, $calledAsSet = false ) {
1111 $this->set = $calledAsSet;
1212 $this->parseArguments( $argv );
1313 $this->parseGalleries( $input, $parser );
@@ -21,43 +21,43 @@
2222 }
2323
2424 function parseArguments( $argv ) {
25 - //Parse arguments, set defaults, and do sanity checks
 25+ // Parse arguments, set defaults, and do sanity checks
2626 if ( isset( $argv["height"] ) && is_numeric( $argv["height"] ) ) {
2727 $this->argumentArray["height"] = $argv["height"] . "px";
2828 } else {
2929 $this->argumentArray["height"] = "300px";
3030 }
31 -
 31+
3232 if ( isset( $argv["width"] ) && is_numeric( $argv["width"] ) ) {
3333 $this->argumentArray["width"] = $argv["width"] . "px";
3434 } else {
3535 $this->argumentArray["width"] = "400px";
3636 }
37 -
 37+
3838 if ( isset( $argv["showcarousel"] ) && $argv["showcarousel"] == "false" ) {
3939 $this->argumentArray["carousel"] = false;
4040 } else {
4141 $this->argumentArray["carousel"] = true;
4242 }
43 -
 43+
4444 if ( isset( $argv["timed"] ) && $argv["timed"] == "true" ) {
4545 $this->argumentArray["timed"] = true;
4646 } else {
4747 $this->argumentArray["timed"] = false;
4848 }
49 -
50 - if ( isset( $argv["delay"] ) && is_numeric($argv["delay"]) ) {
 49+
 50+ if ( isset( $argv["delay"] ) && is_numeric( $argv["delay"] ) ) {
5151 $this->argumentArray["delay"] = $argv["delay"];
5252 } else {
5353 $this->argumentArray["delay"] = "9000";
5454 }
55 -
 55+
5656 if ( isset( $argv["showarrows"] ) && $argv["showarrows"] == "false" ) {
5757 $this->argumentArray["showarrows"] = false;
5858 } else {
5959 $this->argumentArray["showarrows"] = true;
6060 }
61 -
 61+
6262 if ( isset( $argv["showinfopane"] ) && $argv["showinfopane"] == "false" ) {
6363 $this->argumentArray["showinfopane"] = false;
6464 } else {
@@ -70,7 +70,7 @@
7171 $this->argumentArray["slideinfozoneslide"] = true;
7272 }
7373
74 - if ( isset( $argv["slideinfozoneopacity"] ) && is_numeric($argv["slideinfozoneopacity"]) ) {
 74+ if ( isset( $argv["slideinfozoneopacity"] ) && is_numeric( $argv["slideinfozoneopacity"] ) ) {
7575 $this->argumentArray["slideinfozoneopacity"] = $argv["slideinfozoneopacity"];
7676 } else {
7777 $this->argumentArray["slideinfozoneopacity"] = "0.7";
@@ -81,64 +81,64 @@
8282 } else {
8383 $this->argumentArray["fallback"] = "gallery";
8484 }
85 -
 85+
8686 if ( isset( $argv["nolink"] ) && $argv["nolink"] == "true" ) {
8787 $this->argumentArray["nolink"] = true;
8888 } else {
8989 $this->argumentArray["nolink"] = false;
9090 }
9191 }
92 -
 92+
9393 function parseGalleries( $input, $parser ) {
9494 $this->galleriesArray = Array();
95 -
 95+
9696 if ( $this->set ) {
97 - //This isn't currently working right, I need to enter
98 - //a bug report with smooth gallery, so we'll leave
99 - //the name alone for now.
100 - #$this->galleriesArray["gallery_set_name"] = "MediaWikiSGallerySet" . mt_rand();
 97+ // This isn't currently working right, I need to enter
 98+ // a bug report with smooth gallery, so we'll leave
 99+ // the name alone for now.
 100+ # $this->galleriesArray["gallery_set_name"] = "MediaWikiSGallerySet" . mt_rand();
101101 $this->galleriesArray["gallery_set_name"] = "MediaWikiSGallerySet";
102 -
103 - //parse set into separate galleries
 102+
 103+ // parse set into separate galleries
104104 preg_match_all( "/<sgallery([\w]+)?[^>]*>(.*)<\/sgallery>/smU", $input, $galleries, PREG_SET_ORDER );
105 -
106 - //iterate through galleries, call renderGallery on each, and
107 - //collect the fallback output
 105+
 106+ // iterate through galleries, call renderGallery on each, and
 107+ // collect the fallback output
108108 $i = 0;
109109 foreach ( $galleries as $galleryInput ) {
110 - //TOFIX:
111 - //This couldn't possibly be right... If these are different
112 - //galleries in a gallery set, shouldn't they have unique names?
 110+ // TOFIX:
 111+ // This couldn't possibly be right... If these are different
 112+ // galleries in a gallery set, shouldn't they have unique names?
113113 $name = "MediaWikiSGallery" . $i;
114 -
 114+
115115 $this->galleriesArray["galleries"][$i] = $this->parseGallery( $galleryInput[2], $parser );
116116 $this->galleriesArray["galleries"][$i]["gallery_name"] = $name;
117 -
 117+
118118 $i++;
119119 }
120120 } else {
121121 $name = "MediaWikiSGallery" . mt_rand();
122 -
123 - $this->galleriesArray["galleries"][0] = $this->parseGallery( $input, $parser);
 122+
 123+ $this->galleriesArray["galleries"][0] = $this->parseGallery( $input, $parser );
124124 $this->galleriesArray["galleries"][0]["gallery_name"] = $name;
125125 }
126 -
 126+
127127 return $this->galleriesArray;
128128 }
129 -
 129+
130130 function parseGallery( $input, $parser ) {
131131 global $wgTitle;
132132 global $wgSmoothGalleryDelimiter;
133133 global $wgSmoothGalleryAllowExternal;
134 -
 134+
135135 $galleryArray = Array();
136 -
137 - //Expand templates in the input
 136+
 137+ // Expand templates in the input
138138 $input = $parser->recursiveTagParse( $input );
139 -
140 - //The image array is a delimited list of images (strings)
 139+
 140+ // The image array is a delimited list of images (strings)
141141 $line_arr = preg_split( "/$wgSmoothGalleryDelimiter/", $input, -1, PREG_SPLIT_NO_EMPTY );
142 -
 142+
143143 foreach ( $line_arr as $line ) {
144144 $img_arr = explode( "|", $line, 2 );
145145 $img = $img_arr[0];
@@ -153,7 +153,7 @@
154154 ( strlen( $img ) >= 7 && substr( $img, 0, 8 ) == "https://" ) )
155155 ) {
156156 $imageArray["title"] = null;
157 - //TODO: internationalize
 157+ // TODO: internationalize
158158 $imageArray["heading"] = "External Image";
159159 $imageArray["description"] = $img_desc;
160160 $imageArray["full_url"] = $img;
@@ -167,16 +167,16 @@
168168
169169 continue;
170170 }
171 -
 171+
172172 $title = Title::newFromText( $img, NS_IMAGE );
173 -
174 - if ( is_null($title) ) {
 173+
 174+ if ( is_null( $title ) ) {
175175 $galleryArray["missing_images"][] = $title;
176176 continue;
177177 }
178 -
 178+
179179 $ns = $title->getNamespace();
180 -
 180+
181181 if ( $ns == NS_IMAGE ) {
182182 if ( $img_desc != '' ) {
183183 $galleryArray = $this->parseImage( $title, $parser, $galleryArray, true );
@@ -187,7 +187,7 @@
188188 $galleryArray = $this->parseImage( $title, $parser, $galleryArray );
189189 }
190190 } else if ( $ns == NS_CATEGORY ) {
191 - //list images in category
 191+ // list images in category
192192 $cat_images = $this->smoothGalleryImagesByCat( $title );
193193 if ( $cat_images ) {
194194 foreach ( $cat_images as $title ) {
@@ -196,134 +196,134 @@
197197 }
198198 }
199199 }
200 -
 200+
201201 return $galleryArray;
202202 }
203 -
204 - function parseImage( $title, $parser, $galleryArray, $getDescription=false ) {
 203+
 204+ function parseImage( $title, $parser, $galleryArray, $getDescription = false ) {
205205 global $wgUser;
206206 global $wgSmoothGalleryThumbHeight, $wgSmoothGalleryThumbWidth;
207 -
 207+
208208 $imageArray = Array();
209 -
210 - //Get the image object from the database
 209+
 210+ // Get the image object from the database
211211 $img_obj = wfFindFile( $title );
212 -
 212+
213213 if ( !$img_obj ) {
214 - //The user asked for an image that doesn't exist, let's
215 - //add this to the list of missing objects
 214+ // The user asked for an image that doesn't exist, let's
 215+ // add this to the list of missing objects
216216 $galleryArray["missing_images"][] = htmlspecialchars( $title->getDBkey() );
217 -
 217+
218218 return $galleryArray;
219219 }
220 -
221 - //check media type. Only images are supported
 220+
 221+ // check media type. Only images are supported
222222 $mtype = $img_obj->getMediaType();
223223 if ( $mtype != MEDIATYPE_DRAWING && $mtype != MEDIATYPE_BITMAP ) {
224224 $galleryArray["invalid_images"][] = htmlspecialchars( $title->getDBkey() );
225 -
 225+
226226 return $galleryArray;
227227 }
228 -
229 - //Create a thumbnail the same size as our gallery so that
230 - //full images fit correctly
 228+
 229+ // Create a thumbnail the same size as our gallery so that
 230+ // full images fit correctly
231231 $full_thumb_obj = $img_obj->getThumbnail( $this->argumentArray["width"], $this->argumentArray["height"] );
232 - if ( !is_null($full_thumb_obj) ) {
 232+ if ( !is_null( $full_thumb_obj ) ) {
233233 $full_thumb = $full_thumb_obj->getUrl();
234234 } else {
235235 $galleryArray["missing_images"][] = htmlspecialchars( $title->getDBkey() );
236 -
 236+
237237 return $galleryArray;
238238 }
239 -
 239+
240240 if ( $full_thumb == '' ) {
241 - //The thumbnail we requested was larger than the image;
242 - //we need to just provide the image
 241+ // The thumbnail we requested was larger than the image;
 242+ // we need to just provide the image
243243 $full_thumb = $img_obj->getUrl();
244244 }
245245
246246 $icon_thumb = '';
247247 if ( $this->argumentArray["carousel"] ) {
248 - //We are going to show a carousel to the user; we need
249 - //to make icon thumbnails
250 - //$thumb_obj = $img_obj->getThumbnail( 120, 120 ); //would be nice to reuse images already loaded...
 248+ // We are going to show a carousel to the user; we need
 249+ // to make icon thumbnails
 250+ // $thumb_obj = $img_obj->getThumbnail( 120, 120 ); //would be nice to reuse images already loaded...
251251 $thumb_obj = $img_obj->getThumbnail( $wgSmoothGalleryThumbWidth, $wgSmoothGalleryThumbHeight );
252252 if ( $thumb_obj ) {
253253 $icon_thumb = $thumb_obj->getUrl();
254254 }
255255 else {
256 - //The thumbnail we requested was larger than the image;
257 - //we need to just provide the image
 256+ // The thumbnail we requested was larger than the image;
 257+ // we need to just provide the image
258258 $icon_thumb = $img_obj->getUrl();
259259 }
260260 }
261 -
 261+
262262 $fulldesc = '';
263 -
 263+
264264 if ( $this->argumentArray["showinfopane"] ) {
265265 if ( $getDescription ) {
266 - //Load the image page from the database with the provided title from
267 - //the image object
 266+ // Load the image page from the database with the provided title from
 267+ // the image object
268268 $db = wfGetDB( DB_SLAVE );
269269 $img_rev = Revision::loadFromTitle( $db, $title );
270 -
271 - //Get the text from the image page's description
 270+
 271+ // Get the text from the image page's description
272272 $fulldesc = $img_rev->getText();
273273 }
274274
275 - //convert wikitext to HTML
276 - //TODO: find out why this doesn't work with special pages
 275+ // convert wikitext to HTML
 276+ // TODO: find out why this doesn't work with special pages
277277 if ( $parser ) {
278278 $pout = $parser->recursiveTagParse( $fulldesc, $title, $parser->mOptions, true );
279279 $fulldesc = strip_tags( $pout );
280 - #$fulldesc = strip_tags( $pout->getText() );
281 - } else { //fall back to HTML-escaping
 280+ # $fulldesc = strip_tags( $pout->getText() );
 281+ } else { // fall back to HTML-escaping
282282 $fulldesc = htmlspecialchars( $fulldesc );
283283 }
284284 }
285 -
 285+
286286 $skin = $wgUser->getSkin();
287 -
288 - //Everything is checked, and converted; add to the array and return
 287+
 288+ // Everything is checked, and converted; add to the array and return
289289 $imageArray["title"] = $title;
290 -
 290+
291291 # We need the following for the image's div
292 - $imageArray["heading"] = $skin->makeKnownLinkObj($img_obj->getTitle(), $img_obj->getName());
 292+ $imageArray["heading"] = $skin->makeKnownLinkObj( $img_obj->getTitle(), $img_obj->getName() );
293293 $imageArray["description"] = $fulldesc;
294294 $imageArray["full_url"] = $title->getFullURL();
295295 $imageArray["view_url"] = $img_obj->getViewURL();
296296 $imageArray["full_thumb_url"] = $full_thumb;
297297 $imageArray["icon_thumb_url"] = $icon_thumb;
298 -
 298+
299299 # We need the image object for plain galleries
300300 $imageArray["image_object"] = $img_obj;
301 -
 301+
302302 $galleryArray["images"][] = $imageArray;
303 -
 303+
304304 return $galleryArray;
305305 }
306306
307307 function smoothGalleryImagesByCat( $title ) {
308308 $name = $title->getDBkey();
309 -
 309+
310310 $dbr = wfGetDB( DB_SLAVE );
311 -
 311+
312312 list( $page, $categorylinks ) = $dbr->tableNamesN( 'page', 'categorylinks' );
313313 $sql = "SELECT page_namespace, page_title FROM $page " .
314314 "JOIN $categorylinks ON cl_from = page_id " .
315315 "WHERE cl_to = " . $dbr->addQuotes( $name ) . " " .
316316 "AND page_namespace = " . NS_IMAGE . " " .
317317 "ORDER BY cl_sortkey";
318 -
 318+
319319 $images = array();
320320 $res = $dbr->query( $sql, 'smoothGalleryImagesByCat' );
321321 while ( $row = $dbr->fetchObject( $res ) ) {
322322 $img = Title::makeTitle( $row->page_namespace, $row->page_title );
323 -
 323+
324324 $images[] = $img;
325325 }
326 - $dbr->freeResult($res);
327 -
 326+ $dbr->freeResult( $res );
 327+
328328 return $images;
329329 }
330330
Index: trunk/extensions/SmoothGallery/README
@@ -1,5 +1,11 @@
2 -This is an extension that integrates JonDesign's SmoothGallery, which is a set of Javascript and CSS that lets you make picture galleries. A number of features are available from SmoothGallery, and this extension aims to be an easy to use, and full featured integration with MediaWiki. JonDesign's SmoothGallery is released under the GPL.
 2+This is an extension that integrates JonDesign's SmoothGallery, which is a set
 3+of Javascript and CSS that lets you make picture galleries. A number of
 4+features are available from SmoothGallery, and this extension aims to be an
 5+easy to use, and full featured integration with MediaWiki. JonDesign's
 6+SmoothGallery is released under the GPL.
37
4 -For more information on the SmoothGallery javascript gallery, see: http://smoothgallery.jondesign.net/what
 8+For more information on the SmoothGallery javascript gallery,
 9+see: http://smoothgallery.jondesign.net/what
510
6 -For more information on the SmoothGallery extension, see: http://www.mediawiki.org/wiki/Extension:SmoothGallery
 11+For more information on the SmoothGallery extension,
 12+see: http://www.mediawiki.org/wiki/Extension:SmoothGallery
Property changes on: trunk/extensions/SmoothGallery/README
___________________________________________________________________
Added: svn:eol-style
713 + native
Index: trunk/extensions/SmoothGallery/SmoothGallery.i18n.php
@@ -395,14 +395,14 @@
396396 */
397397 $messages['km'] = array(
398398 'smoothgallery' => 'វិចិត្រសាលរាបស្មើ',
399 - 'smoothgallery-desc' => 'អនុញ្ញាត​ឱ្យ​បង្កើត​វិចិត្រសាល​ជាមួយ​រូបភាព​ដែល​បាន​ផ្ទុកឡើង​។
 399+ 'smoothgallery-desc' => 'អនុញ្ញាត​ឱ្យ​បង្កើត​វិចិត្រសាល​ជាមួយ​រូបភាព​ដែល​បាន​ផ្ទុកឡើង​។
400400
401401 អនុញ្ញាត​ជម្រើស​ភាគច្រើន​នៃ​វិចិត្រសាលរាបស្មើ​',
402402 'smoothgallery-title' => 'វិចិត្រសាលរាបស្មើ',
403403 'smoothgallery-smoothgallerytitle' => 'វិចិត្រសាលរាបស្មើ​៖ $1',
404404 'smoothgallery-error' => 'កំហុស​វិចិត្រសាលរាបស្មើ​​៖',
405405 'smoothgallery-gallery-not-found' => 'មិនមានវិចិត្រសាលដែលត្រូវបានស្នើ​។',
406 - 'smoothgallery-not-found' => 'មិនមាន​រូបភាព​ត្រូវ​បាន​បន្ថែម​ទៅ​ក្នុង​វិចិត្រសាល​ទេ​។
 406+ 'smoothgallery-not-found' => 'មិនមាន​រូបភាព​ត្រូវ​បាន​បន្ថែម​ទៅ​ក្នុង​វិចិត្រសាល​ទេ​។
407407
408408 សូម​បន្ថែម​រូបភាព​យ៉ាងហោច​មួយ​។',
409409 'smoothgallery-javascript-disabled' => 'តម្រូវឱ្យមាន Javascript ដើម្បី​មើលបានល្អ​វិចិត្រសាលនេះ​។',
@@ -451,7 +451,7 @@
452452 */
453453 $messages['mr'] = array(
454454 'smoothgallery' => 'मुलायमप्रेक्षा',
455 - 'smoothgallery-desc' => 'उपयोगकर्त्यांना चढवलेल्या चित्रणांपासून दीर्घा(प्रेक्षा)बनवण्याकरिता अनुमति देते.
 455+ 'smoothgallery-desc' => 'उपयोगकर्त्यांना चढवलेल्या चित्रणांपासून दीर्घा(प्रेक्षा)बनवण्याकरिता अनुमति देते.
456456 मुलायमदिर्घा(प्रेक्षा) बनविण्याकरिता सर्वाधिक पर्याय उपलब्ध करून देते.',
457457 'smoothgallery-title' => 'मुलायमप्रेक्षा',
458458 'smoothgallery-smoothgallerytitle' => 'मुलायमप्रेक्षा $1',
@@ -495,13 +495,13 @@
496496 */
497497 $messages['nn'] = array(
498498 'smoothgallery' => 'Jamnt galleri',
499 - 'smoothgallery-desc' => 'Lèt brukarar oppretta galleri med bilete som er blitt lasta opp.
 499+ 'smoothgallery-desc' => 'Lèt brukarar oppretta galleri med bilete som er blitt lasta opp.
500500 Inneheld dei fleste av SmoothGallery sine valalternativ.',
501501 'smoothgallery-title' => 'Jamnt galleri',
502502 'smoothgallery-smoothgallerytitle' => 'Jamnt galleri: $1',
503503 'smoothgallery-error' => '<b>Feil med jamnt galleri:</b>',
504504 'smoothgallery-gallery-not-found' => 'Det etterspurde galleriet finst ikkje.',
505 - 'smoothgallery-not-found' => 'Ingen bilete blei lagt til i galleriet.
 505+ 'smoothgallery-not-found' => 'Ingen bilete blei lagt til i galleriet.
506506 Legg til minst eitt bilete.',
507507 'smoothgallery-no-images' => 'Ingen bilete blei funne i dette galleriet.
508508 Forsikra deg om at {{PLURAL:$3|biletet|bileta}} finst.
@@ -555,7 +555,7 @@
556556 */
557557 $messages['pl'] = array(
558558 'smoothgallery' => 'Płynna galeria',
559 - 'smoothgallery-desc' => 'Pozwala użytkownikom na tworzenie galerii przesłanych zdjęć.
 559+ 'smoothgallery-desc' => 'Pozwala użytkownikom na tworzenie galerii przesłanych zdjęć.
560560 Udostępnia większości opcji SmoothGallery',
561561 'smoothgallery-title' => 'Płynna galeria',
562562 'smoothgallery-smoothgallerytitle' => 'Płynna galeria: $1',
Index: trunk/extensions/SmoothGallery/SmoothGallery.php
@@ -26,20 +26,20 @@
2727 # sgallery Parser Function changes contributed by David Claughton <dave@eclecticdave.com>
2828 # infopane sliding and opacity patch provided by David Claughton <dave@eclecticdave.com>
2929
30 -if( !defined( 'MEDIAWIKI' ) )
 30+if ( !defined( 'MEDIAWIKI' ) )
3131 die( -1 );
3232
3333 /**
3434 * Add extension information to Special:Version
3535 */
3636 $wgExtensionCredits['other'][] = array(
37 - 'path' => __FILE__,
38 - 'name' => 'SmoothGallery parser extension',
39 - 'version' => '1.1d',
40 - 'author' => 'Ryan Lane',
41 - 'description' => 'Allows users to create galleries with images that have been uploaded. Allows most options of SmoothGallery',
 37+ 'path' => __FILE__,
 38+ 'name' => 'SmoothGallery parser extension',
 39+ 'version' => '1.1d',
 40+ 'author' => 'Ryan Lane',
 41+ 'description' => 'Allows users to create galleries with images that have been uploaded. Allows most options of SmoothGallery',
4242 'descriptionmsg' => 'smoothgallery-desc',
43 - 'url' => 'http://www.mediawiki.org/wiki/Extension:SmoothGallery',
 43+ 'url' => 'http://www.mediawiki.org/wiki/Extension:SmoothGallery',
4444 );
4545
4646 $wgExtensionFunctions[] = "efSmoothGallery";
@@ -47,12 +47,12 @@
4848 $wgHooks['OutputPageParserOutput'][] = 'smoothGalleryParserOutput';
4949 $wgHooks['LanguageGetMagic'][] = 'smoothGalleryLanguageGetMagic';
5050
51 -$dir = dirname(__FILE__) . '/';
 51+$dir = dirname( __FILE__ ) . '/';
5252 $wgExtensionMessagesFiles['SmoothGallery'] = $dir . 'SmoothGallery.i18n.php';
5353 $wgAutoloadClasses['SmoothGallery'] = $dir . 'SmoothGalleryClass.php';
5454 $wgAutoloadClasses['SmoothGalleryParser'] = $dir . 'SmoothGalleryParser.php';
5555
56 -//sane defaults. always initialize to avoid register_globals vulnerabilities
 56+// sane defaults. always initialize to avoid register_globals vulnerabilities
5757 $wgSmoothGalleryDelimiter = "\n";
5858 $wgSmoothGalleryExtensionPath = $wgScriptPath . '/extensions/SmoothGallery';
5959 $wgSmoothGalleryAllowExternal = false;
@@ -68,9 +68,10 @@
6969 $wgParser->setFunctionHook( 'sgallery', 'initSmoothGalleryPF' );
7070 }
7171
 72+// FIXME: split off to a hook file and use $wgHooks['ParserFirstCallInit'] to init tags
7273 function initSmoothGalleryPF( &$parser ) {
7374 global $wgSmoothGalleryDelimiter;
74 -
 75+
7576 $numargs = func_num_args();
7677 if ( $numargs < 2 ) {
7778 $input = "#SmoothGallery: no arguments specified";
@@ -96,23 +97,23 @@
9798 $sKey = trim( $aParam[0] );
9899 $sVal = trim( $aParam[1] );
99100
100 - if ( $sKey != '' ){
 101+ if ( $sKey != '' ) {
101102 $argv[$sKey] = $sVal;
102103 }
103104 }
104105
105106 $output = initSmoothGallery( $input, $argv, $parser );
106 - return array( $output, 'noparse' => true, 'isHTML' => true);
 107+ return array( $output, 'noparse' => true, 'isHTML' => true );
107108 }
108109
109 -function initSmoothGallery( $input, $argv, &$parser, $calledAsSet=false ) {
 110+function initSmoothGallery( $input, $argv, &$parser, $calledAsSet = false ) {
110111 $sgParser = new SmoothGalleryParser( $input, $argv, $parser, $calledAsSet );
111112 $sgGallery = new SmoothGallery();
112113
113114 $sgGallery->setParser( $parser );
114115 $sgGallery->setSet( $calledAsSet );
115116 $sgGallery->setArguments( $sgParser->getArguments() );
116 - $sgGallery->setGalleries( $sgParser->getGalleries() );
 117+ $sgGallery->setGalleries( $sgParser->getGalleries() );
117118
118119 $sgGallery->checkForErrors();
119120 if ( $sgGallery->hasErrors() ) {
@@ -147,6 +148,6 @@
148149 * we are not using this feature
149150 */
150151 function smoothGalleryLanguageGetMagic( &$magicWords, $langCode ) {
151 - $magicWords['sgallery'] = array(0, 'sgallery');
 152+ $magicWords['sgallery'] = array( 0, 'sgallery' );
152153 return true;
153154 }

Status & tagging log