r22493 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r22492‎ | r22493 | r22494 >
Date:01:44, 28 May 2007
Author:tstarling
Status:old
Tags:
Comment:
Pre-emptively migrated extensions to the filerepo-work file creation method, with backwards compatibility. Fixed the indenting in SmoothGallery.
Modified paths:
  • /trunk/extensions/FileSearch/FileSearchIndexer.php (modified) (history)
  • /trunk/extensions/Filepath/SpecialFilepath_body.php (modified) (history)
  • /trunk/extensions/ImageMap/ImageMap_body.php (modified) (history)
  • /trunk/extensions/Logo/Logo.php (modified) (history)
  • /trunk/extensions/News/NewsRenderer.php (modified) (history)
  • /trunk/extensions/PicturePopup/PicturePopup_body.php (modified) (history)
  • /trunk/extensions/Player/PlayerClass.php (modified) (history)
  • /trunk/extensions/ProofreadPage/ProofreadPage.php (modified) (history)
  • /trunk/extensions/SmoothGallery/SmoothGallery.php (modified) (history)
  • /trunk/extensions/SpecialFileList/SpecialFilelist.php (modified) (history)
  • /trunk/extensions/UserImages/UserImages.class.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ImageMap/ImageMap_body.php
@@ -83,7 +83,10 @@
8484 $thumbWidth = $imageNode->getAttribute('width');
8585 $thumbHeight = $imageNode->getAttribute('height');
8686
87 - $imageObj = new Image( $imageTitle );
 87+ $imageObj = function_exists( 'wfFindFile' ) ? wfFindFile( $imageTitle ) : new Image( $imageTitle );
 88+ if ( !$imageObj || !$imageObj->exists() ) {
 89+ return self::error( 'imagemap_invalid_image' );
 90+ }
8891 # Add the linear dimensions to avoid inaccuracy in the scale
8992 # factor when one is much larger than the other
9093 # (sx+sy)/(x+y) = s
Index: trunk/extensions/SmoothGallery/SmoothGallery.php
@@ -27,7 +27,7 @@
2828 #
2929
3030 if( !defined( 'MEDIAWIKI' ) )
31 - die( -1 );
 31+ die( -1 );
3232
3333 $wgExtensionFunctions[] = "wfSmoothGallery";
3434
@@ -43,9 +43,9 @@
4444 $wgSmoothGalleryExtensionPath = $wgScriptPath . '/extensions/SmoothGallery';
4545
4646 function wfSmoothGallery() {
47 - global $wgParser;
 47+ global $wgParser;
4848
49 - $wgParser->setHook( 'sgallery', 'renderSmoothGallery' );
 49+ $wgParser->setHook( 'sgallery', 'renderSmoothGallery' );
5050 }
5151
5252 function smoothGalleryImagesByCat( $title ) {
@@ -75,120 +75,120 @@
7676 }
7777
7878 function renderSmoothGallery( $input, $argv, &$parser ) {
79 - global $wgContLang, $wgUser, $wgTitle;
80 - global $wgSmoothGalleryDelimiter;
 79+ global $wgContLang, $wgUser, $wgTitle;
 80+ global $wgSmoothGalleryDelimiter;
8181
82 - $skin = $wgUser->getSkin();
 82+ $skin = $wgUser->getSkin();
8383
84 - //Sanity check
85 - if ( $input == "" ) {
 84+ //Sanity check
 85+ if ( $input == "" ) {
8686 loadSmoothGalleryI18n();
8787 $output = wfMsg("smoothgallery-error");
88 - $output .= wfMsg("smoothgallery-not-found");
89 - return $output;
90 - }
 88+ $output .= wfMsg("smoothgallery-not-found");
 89+ return $output;
 90+ }
9191
92 - //Give this gallery a random name so that we can have more than one gallery
93 - //on a page.
94 - $name = "myGallery" . mt_rand();
 92+ //Give this gallery a random name so that we can have more than one gallery
 93+ //on a page.
 94+ $name = "myGallery" . mt_rand();
9595
96 - //Parse arguments, set defaults, and do sanity checks
97 - if ( isset( $argv["height"] ) && is_numeric( $argv["height"] ) ) {
98 - if ( isset( $argv["special"] ) ) {
99 - //Creating a link instead, the special page is going to call this
100 - //function again, so "px" will be appended.
101 - $height = $argv["height"];
102 - } else {
103 - $height = $argv["height"] . "px";
104 - }
105 - } else {
106 - $height = "300px";
107 - }
 96+ //Parse arguments, set defaults, and do sanity checks
 97+ if ( isset( $argv["height"] ) && is_numeric( $argv["height"] ) ) {
 98+ if ( isset( $argv["special"] ) ) {
 99+ //Creating a link instead, the special page is going to call this
 100+ //function again, so "px" will be appended.
 101+ $height = $argv["height"];
 102+ } else {
 103+ $height = $argv["height"] . "px";
 104+ }
 105+ } else {
 106+ $height = "300px";
 107+ }
108108
109 - if ( isset( $argv["width"] ) && is_numeric( $argv["width"] ) ) {
110 - if ( isset( $argv["special"] ) ) {
111 - //Creating a link instead, the special page is going to call this
112 - //function again, so "px" will be appended.
113 - $width = $argv["width"];
114 - } else {
115 - $width = $argv["width"] . "px";
116 - }
117 - } else {
118 - $width = "400px";
119 - }
 109+ if ( isset( $argv["width"] ) && is_numeric( $argv["width"] ) ) {
 110+ if ( isset( $argv["special"] ) ) {
 111+ //Creating a link instead, the special page is going to call this
 112+ //function again, so "px" will be appended.
 113+ $width = $argv["width"];
 114+ } else {
 115+ $width = $argv["width"] . "px";
 116+ }
 117+ } else {
 118+ $width = "400px";
 119+ }
120120
121 - if ( isset( $argv["showcarousel"] ) && $argv["showcarousel"] == "false" ) {
122 - $carousel = false;
123 - } else {
124 - $carousel = true;
125 - }
 121+ if ( isset( $argv["showcarousel"] ) && $argv["showcarousel"] == "false" ) {
 122+ $carousel = false;
 123+ } else {
 124+ $carousel = true;
 125+ }
126126
127 - if ( isset( $argv["timed"] ) && $argv["timed"] == "true" ) {
128 - $timed = true;
129 - } else {
130 - $timed = false;
131 - }
 127+ if ( isset( $argv["timed"] ) && $argv["timed"] == "true" ) {
 128+ $timed = true;
 129+ } else {
 130+ $timed = false;
 131+ }
132132
133 - if ( isset( $argv["delay"] ) && is_numeric($argv["delay"]) ) {
134 - $delay = $argv["delay"];
135 - } else {
136 - $delay = "9000";
137 - }
 133+ if ( isset( $argv["delay"] ) && is_numeric($argv["delay"]) ) {
 134+ $delay = $argv["delay"];
 135+ } else {
 136+ $delay = "9000";
 137+ }
138138
139 - if ( isset( $argv["showarrows"] ) && $argv["showarrows"] == "false" ) {
140 - $showarrows = false;
141 - } else {
142 - $showarrows = true;
143 - }
 139+ if ( isset( $argv["showarrows"] ) && $argv["showarrows"] == "false" ) {
 140+ $showarrows = false;
 141+ } else {
 142+ $showarrows = true;
 143+ }
144144
145 - if ( isset( $argv["showinfopane"] ) && $argv["showinfopane"] == "false" ) {
146 - $showinfopane = false;
147 - } else {
148 - $showinfopane = true;
149 - }
 145+ if ( isset( $argv["showinfopane"] ) && $argv["showinfopane"] == "false" ) {
 146+ $showinfopane = false;
 147+ } else {
 148+ $showinfopane = true;
 149+ }
150150
151 - if ( isset( $argv["special"] ) ) {
152 - //The user wants a link to a special page instead. Let's provide a link with
153 - //the relevant info
 151+ if ( isset( $argv["special"] ) ) {
 152+ //The user wants a link to a special page instead. Let's provide a link with
 153+ //the relevant info
154154
155 - //sanity check
156 - $name = htmlspecialchars( $argv["special"] );
 155+ //sanity check
 156+ $name = htmlspecialchars( $argv["special"] );
157157
158 - //This is a dirty, dirty hack that should be replaced. It works, and
159 - //it is safe, but there *MUST* be a better way to do this...
160 - $input = str_replace( $wgSmoothGalleryDelimiter, '|', $input );
 158+ //This is a dirty, dirty hack that should be replaced. It works, and
 159+ //it is safe, but there *MUST* be a better way to do this...
 160+ $input = str_replace( $wgSmoothGalleryDelimiter, '|', $input );
161161
162 - //Get a local link from the special page
163 - $sp = Title::newFromText( "Special:SmoothGallery" );
164 - $output = $sp->getLocalURL( "height=" . $height . "&width=" . $width . "&showcarousel=" . $carousel . "&timed=" .
165 - $timed . "&delay=" . $delay . "&showarrows=" . $showarrows . "&showinfopane=" . $showinfopane . "&input=" . htmlspecialchars( $input ) );
 162+ //Get a local link from the special page
 163+ $sp = Title::newFromText( "Special:SmoothGallery" );
 164+ $output = $sp->getLocalURL( "height=" . $height . "&width=" . $width . "&showcarousel=" . $carousel . "&timed=" .
 165+ $timed . "&delay=" . $delay . "&showarrows=" . $showarrows . "&showinfopane=" . $showinfopane . "&input=" . htmlspecialchars( $input ) );
166166
167 - //Provide the link
168 - return '<a href="' . $output . '">' . $name . '</a>';
169 - }
 167+ //Provide the link
 168+ return '<a href="' . $output . '">' . $name . '</a>';
 169+ }
170170
171171 $parser->mOutput->mSmoothGalleryTag = true; # flag for use by smoothGalleryParserOutput
172172
173 - //Open the outer div of the gallery
174 - $output = '<div id="' . $name . '" class="myGallery" style="width: ' . $width . ';height: ' . $height . '; display:none;">';
 173+ //Open the outer div of the gallery
 174+ $output = '<div id="' . $name . '" class="myGallery" style="width: ' . $width . ';height: ' . $height . '; display:none;">';
175175
176 - //We need a parser to pass to the render function, this
177 - //seems kinda dirty, but it works on MediaWiki 1.6-1.9...
178 - $local_parser = clone $parser;
179 - $local_parser_options = new ParserOptions();
180 - $local_parser->mOptions = $local_parser_options;
181 - $local_parser->Title( $wgTitle );
182 - $local_parser->mArgStack = array();
 176+ //We need a parser to pass to the render function, this
 177+ //seems kinda dirty, but it works on MediaWiki 1.6-1.9...
 178+ $local_parser = clone $parser;
 179+ $local_parser_options = new ParserOptions();
 180+ $local_parser->mOptions = $local_parser_options;
 181+ $local_parser->Title( $wgTitle );
 182+ $local_parser->mArgStack = array();
183183
184 - //Expand templates in the input
185 - $local_parser->replaceVariables( $input );
 184+ //Expand templates in the input
 185+ $local_parser->replaceVariables( $input );
186186
187 - //The image array is a delimited list of images (strings)
 187+ //The image array is a delimited list of images (strings)
188188 $img_arr = preg_split( "/$wgSmoothGalleryDelimiter/", $input, -1, PREG_SPLIT_NO_EMPTY );
189 - $img_count = count( $img_arr );
 189+ $img_count = count( $img_arr );
190190
191 - $title_arr = array();
192 - foreach ( $img_arr as $img ) {
 191+ $title_arr = array();
 192+ foreach ( $img_arr as $img ) {
193193 $title = Title::newFromText( $img, NS_IMAGE );
194194
195195 if ( is_null($title) ) {
@@ -196,7 +196,7 @@
197197 }
198198
199199 $ns = $title->getNamespace();
200 -
 200+
201201 if ( $ns == NS_IMAGE ) $title_arr[] = $title;
202202 else if ( $ns == NS_CATEGORY ) {
203203 //list images in category
@@ -205,175 +205,169 @@
206206 $title_arr = array_merge( $title_arr, $cat_images );
207207 }
208208 }
209 - }
 209+ }
210210
211 - //Initialize a string for images we can't find, so that we
212 - //can report them later
213 - $missing_img = "";
 211+ //Initialize a string for images we can't find, so that we
 212+ //can report them later
 213+ $missing_img = "";
214214
215 - $plain_gallery = new ImageGallery();
 215+ $plain_gallery = new ImageGallery();
216216
217 - foreach ( $title_arr as $title ) {
218 - //Get the image object from the database
219 - $img_obj = new Image( $title );
 217+ foreach ( $title_arr as $title ) {
 218+ //Get the image object from the database
 219+ $img_obj = function_exists( 'wfFindFile' ) ? wfFindFile( $title ) : new Image( $title );
220220
221 - //Image wasn't found. No point in going any further.
222 - if ( is_null($img_obj) ) {
223 - $img_count = $img_count - 1;
224 - continue;
225 - }
 221+ if ( !$img_obj || !$img_obj->exists() ) {
 222+ //The user asked for an image that doesn't exist, let's
 223+ //add this to the list of missing objects and not output
 224+ //any html
 225+ $img_count = $img_count - 1;
 226+ $missing_img .= " " . htmlspecialchars( $title->getDBkey() );
226227
227 - if ( !$img_obj->exists() ) {
228 - //The user asked for an image that doesn't exist, let's
229 - //add this to the list of missing objects and not output
230 - //any html
231 - $img_count = $img_count - 1;
232 - $missing_img .= " " . htmlspecialchars( $img_obj->getName() );
 228+ continue;
 229+ }
233230
234 - continue;
235 - }
236 -
237 - //check media type. Only images are supported
 231+ //check media type. Only images are supported
238232 $mtype = $img_obj->getMediaType();
239 - if ( $mtype != MEDIATYPE_DRAWING && $mtype != MEDIATYPE_BITMAP ) {
240 - $img_count = $img_count - 1;
241 - continue;
242 - }
 233+ if ( $mtype != MEDIATYPE_DRAWING && $mtype != MEDIATYPE_BITMAP ) {
 234+ $img_count = $img_count - 1;
 235+ continue;
 236+ }
243237
244 - //Create a thumbnail the same size as our gallery so that
245 - //full images fit correctly
246 - $full_thumb_obj = $img_obj->getThumbnail( $width, $height );
 238+ //Create a thumbnail the same size as our gallery so that
 239+ //full images fit correctly
 240+ $full_thumb_obj = $img_obj->getThumbnail( $width, $height );
247241 if ( !is_null($full_thumb_obj) ) {
248 - $full_thumb = $full_thumb_obj->getUrl();
 242+ $full_thumb = $full_thumb_obj->getUrl();
249243 } else {
250 - $img_count = $img_count - 1;
251 - continue;
 244+ $img_count = $img_count - 1;
 245+ continue;
252246 }
253247
254 - if ( $full_thumb == "" ) {
255 - //The thumbnail we requested was larger than the image;
256 - //we need to just provide the image
257 - $full_thumb = $img_obj->getUrl();
258 - }
 248+ if ( $full_thumb == "" ) {
 249+ //The thumbnail we requested was larger than the image;
 250+ //we need to just provide the image
 251+ $full_thumb = $img_obj->getUrl();
 252+ }
259253
260 - if ( $carousel ) {
261 - //We are going to show a carousel to the user; we need
262 - //to make icon thumbnails
263 - //$thumb_obj = $img_obj->getThumbnail( 120, 120 ); //would be nice to reuse images already loaded...
264 - $thumb_obj = $img_obj->getThumbnail( 100, 75 );
265 - if ( $thumb_obj ) {
266 - $icon_thumb = $thumb_obj->getUrl();
267 - }
268 - else {
269 - //The thumbnail we requested was larger than the image;
270 - //we need to just provide the image
271 - $icon_thumb = $img_obj->getUrl();
272 - }
273 - }
 254+ if ( $carousel ) {
 255+ //We are going to show a carousel to the user; we need
 256+ //to make icon thumbnails
 257+ //$thumb_obj = $img_obj->getThumbnail( 120, 120 ); //would be nice to reuse images already loaded...
 258+ $thumb_obj = $img_obj->getThumbnail( 100, 75 );
 259+ if ( $thumb_obj ) {
 260+ $icon_thumb = $thumb_obj->getUrl();
 261+ }
 262+ else {
 263+ //The thumbnail we requested was larger than the image;
 264+ //we need to just provide the image
 265+ $icon_thumb = $img_obj->getUrl();
 266+ }
 267+ }
274268
275 - $fulldesc = '';
 269+ $fulldesc = '';
276270
277 - if ( $showinfopane ) {
278 - //Load the image page from the database with the provided title from
279 - //the image object
280 - $db = wfGetDB( DB_SLAVE );
281 - $img_rev = Revision::loadFromTitle( $db, $title );
 271+ if ( $showinfopane ) {
 272+ //Load the image page from the database with the provided title from
 273+ //the image object
 274+ $db = wfGetDB( DB_SLAVE );
 275+ $img_rev = Revision::loadFromTitle( $db, $title );
282276
283 - //Get the text from the image page's description
284 - $fulldesc = $img_rev->getText();
 277+ //Get the text from the image page's description
 278+ $fulldesc = $img_rev->getText();
285279
286 - if ( $local_parser ) { //convert wikitext to HTML
287 - $pout = $local_parser->parse( $fulldesc, $title, $local_parser_options, true );
288 - $fulldesc = strip_tags( $pout->getText() );
289 - }
290 - else { //fall back to HTML-escaping
291 - $fulldesc = htmlspecialchars( $fulldesc );
292 - }
293 - }
 280+ if ( $local_parser ) { //convert wikitext to HTML
 281+ $pout = $local_parser->parse( $fulldesc, $title, $local_parser_options, true );
 282+ $fulldesc = strip_tags( $pout->getText() );
 283+ }
 284+ else { //fall back to HTML-escaping
 285+ $fulldesc = htmlspecialchars( $fulldesc );
 286+ }
 287+ }
294288
295 - //Add the html for the image
296 - $output .= '<div class="imageElement">';
297 - $output .= '<h3>' . $skin->makeKnownLinkObj($img_obj->getTitle(), $img_obj->getName()) . '</h3>';
298 - $output .= '<p>' . $fulldesc . '</p>';
299 - $output .= '<a href="' . $title->getFullURL() . '" title="open image" class="open"></a>';
300 - $output .= '<a href="' . $img_obj->getViewURL() . '" title="open image" class="open"></a>';
301 - $output .= '<img src="' . $full_thumb . '" class="full" />';
 289+ //Add the html for the image
 290+ $output .= '<div class="imageElement">';
 291+ $output .= '<h3>' . $skin->makeKnownLinkObj($img_obj->getTitle(), $img_obj->getName()) . '</h3>';
 292+ $output .= '<p>' . $fulldesc . '</p>';
 293+ $output .= '<a href="' . $title->getFullURL() . '" title="open image" class="open"></a>';
 294+ $output .= '<a href="' . $img_obj->getViewURL() . '" title="open image" class="open"></a>';
 295+ $output .= '<img src="' . $full_thumb . '" class="full" />';
302296
303 - if ( $carousel ) {
304 - $output .= '<img src="' . $icon_thumb . '" class="thumbnail" />';
305 - }
 297+ if ( $carousel ) {
 298+ $output .= '<img src="' . $icon_thumb . '" class="thumbnail" />';
 299+ }
306300
307 - $output .= '</div>';
 301+ $output .= '</div>';
308302
309 - $plain_gallery->add( $img_obj ); //TODO: use text
310 - }
 303+ $plain_gallery->add( $img_obj->getTitle() ); //TODO: use text
 304+ }
311305
312 - //Make sure we have something to output
313 - if ( $img_count <= 0 ) {
314 - //The user requested images, but none of the ones requested
315 - //actually exist, let's inform the user
 306+ //Make sure we have something to output
 307+ if ( $img_count <= 0 ) {
 308+ //The user requested images, but none of the ones requested
 309+ //actually exist, let's inform the user
316310 loadSmoothGalleryI18n();
317311
318312 $output = wfMsg("smoothgallery-error");
319313
320 - //Sanity check
321 - if ( $missing_img != "" ) {
322 - $output .= wfMsg("smoothgallery-no-images", $missing_img);
323 - } else {
324 - $output .= wfMsg("smoothgallery-unexpected-error");
325 - }
 314+ //Sanity check
 315+ if ( $missing_img != "" ) {
 316+ $output .= wfMsg("smoothgallery-no-images", $missing_img);
 317+ } else {
 318+ $output .= wfMsg("smoothgallery-unexpected-error");
 319+ }
326320
327 - return $output;
328 - }
 321+ return $output;
 322+ }
329323
330 - //Close the outer div of the gallery
331 - $output .= '</div>';
 324+ //Close the outer div of the gallery
 325+ $output .= '</div>';
332326
333 - //Wrapper div for plain old gallery, to be shown per default, if JS is off.
334 - $output .= '<div id="' . $name . '-plain">';
 327+ //Wrapper div for plain old gallery, to be shown per default, if JS is off.
 328+ $output .= '<div id="' . $name . '-plain">';
335329
336 - $output .= $plain_gallery->toHTML();
 330+ $output .= $plain_gallery->toHTML();
337331
338 - //Close the wrappe div for the plain old gallery
339 - $output .= '</div>';
 332+ //Close the wrappe div for the plain old gallery
 333+ $output .= '</div>';
340334
341 - //Output the javascript needed for the gallery with any
342 - //options the user requested
343 - $output .= '<script type="text/javascript">';
 335+ //Output the javascript needed for the gallery with any
 336+ //options the user requested
 337+ $output .= '<script type="text/javascript">';
344338
345 - $output .= 'document.getElementById("' . $name . '-plain").style.display = "none";'; //hide plain gallery
346 - $output .= 'document.getElementById("' . $name . '").style.display = "block";'; //show smooth gallery
 339+ $output .= 'document.getElementById("' . $name . '-plain").style.display = "none";'; //hide plain gallery
 340+ $output .= 'document.getElementById("' . $name . '").style.display = "block";'; //show smooth gallery
347341
348 - $output .= 'function startGallery_' . $name . '() {';
349 - $output .= "var myGallery = new gallery($('" . $name . "'), {";
 342+ $output .= 'function startGallery_' . $name . '() {';
 343+ $output .= "var myGallery = new gallery($('" . $name . "'), {";
350344
351 - $output .= 'thumbWidth: 100, thumbHeight: 75'; //would be nice if we could change this to 120x120 to re-use thumbnails...
 345+ $output .= 'thumbWidth: 100, thumbHeight: 75'; //would be nice if we could change this to 120x120 to re-use thumbnails...
352346
353 - //Add user provided options
354 - if ( $timed ) {
355 - $output .= ', timed: true';
356 - $output .= ', delay: ' . $delay;
357 - }
 347+ //Add user provided options
 348+ if ( $timed ) {
 349+ $output .= ', timed: true';
 350+ $output .= ', delay: ' . $delay;
 351+ }
358352
359 - if ( !$carousel ) {
360 - $output .= ', showCarousel: false';
361 - }
 353+ if ( !$carousel ) {
 354+ $output .= ', showCarousel: false';
 355+ }
362356
363 - if ( !$showarrows ) {
364 - $output .= ', showArrows: false';
365 - }
 357+ if ( !$showarrows ) {
 358+ $output .= ', showArrows: false';
 359+ }
366360
367 - if ( !$showinfopane ) {
368 - $output .= ', showInfopane: false';
369 - }
 361+ if ( !$showinfopane ) {
 362+ $output .= ', showInfopane: false';
 363+ }
370364
371 - $output .= '});';
372 - $output .= '}';
373 - $output .= 'addOnloadHook(startGallery_' . $name . ');';
374 - $output .= '</script>';
 365+ $output .= '});';
 366+ $output .= '}';
 367+ $output .= 'addOnloadHook(startGallery_' . $name . ');';
 368+ $output .= '</script>';
375369
376 - //Finished, let's send it out
377 - return $output;
 370+ //Finished, let's send it out
 371+ return $output;
378372 }
379373
380374 /**
@@ -381,34 +375,34 @@
382376 * Does nothing if $parserOutput->mSmoothGalleryTag is not set
383377 */
384378 function smoothGalleryParserOutput( &$outputPage, &$parserOutput ) {
385 - if ( !empty( $parserOutput->mSmoothGalleryTag ) ) {
386 - SmoothGallery::setHeaders( $outputPage );
387 - }
388 - return true;
 379+ if ( !empty( $parserOutput->mSmoothGalleryTag ) ) {
 380+ SmoothGallery::setHeaders( $outputPage );
 381+ }
 382+ return true;
389383 }
390384
391385 /**
392386 * Load the SmoothGallery internationalization file
393387 */
394388 function loadSmoothGalleryI18n() {
395 - global $wgContLang, $wgMessageCache;
 389+ global $wgContLang, $wgMessageCache;
396390
397 - static $initialized = false;
 391+ static $initialized = false;
398392
399 - if ( $initialized ) return true;
 393+ if ( $initialized ) return true;
400394
401 - $messages = array();
 395+ $messages = array();
402396
403 - $f = dirname( __FILE__ ) . '/SmoothGallery.i18n.php';
404 - include( $f );
 397+ $f = dirname( __FILE__ ) . '/SmoothGallery.i18n.php';
 398+ include( $f );
405399
406 - $f = dirname( __FILE__ ) . '/SmoothGallery.i18n.' . $wgContLang->getCode() . '.php';
407 - if ( file_exists( $f ) ) include( $f );
 400+ $f = dirname( __FILE__ ) . '/SmoothGallery.i18n.' . $wgContLang->getCode() . '.php';
 401+ if ( file_exists( $f ) ) include( $f );
408402
409 - $initialized = true;
410 - $wgMessageCache->addMessages( $messages );
 403+ $initialized = true;
 404+ $wgMessageCache->addMessages( $messages );
411405
412 - return true;
 406+ return true;
413407 }
414408
415409
@@ -416,10 +410,10 @@
417411 * Add extension information to Special:Version
418412 */
419413 $wgExtensionCredits['other'][] = array(
420 - 'name' => 'SmoothGallery parser extension',
421 - 'version' => '1.0i',
422 - 'author' => 'Ryan Lane',
423 - 'description' => 'Allows users to create galleries with images that have been uploaded. Allows most options of SmoothGallery',
424 - 'url' => 'http://www.mediawiki.org/wiki/Extension:SmoothGallery'
425 - );
 414+ 'name' => 'SmoothGallery parser extension',
 415+ 'version' => '1.0i',
 416+ 'author' => 'Ryan Lane',
 417+ 'description' => 'Allows users to create galleries with images that have been uploaded. Allows most options of SmoothGallery',
 418+ 'url' => 'http://www.mediawiki.org/wiki/Extension:SmoothGallery'
 419+);
426420 ?>
Index: trunk/extensions/SpecialFileList/SpecialFilelist.php
@@ -178,10 +178,9 @@
179179 $ut = $s->img_user_text;
180180
181181 $nt = Title::newFromText( $name, NS_IMAGE );
182 - $img = new Image( $nt );
183182 $ul = $this->sk->makeLinkObj( Title::makeTitle( NS_USER, $ut ), $ut );
184183
185 - $gallery->add( $img, "$ul<br />\n<i>".$wgLang->timeanddate( $s->img_timestamp, true )."</i><br />\n" );
 184+ $gallery->add( $nt, "$ul<br />\n<i>".$wgLang->timeanddate( $s->img_timestamp, true )."</i><br />\n" );
186185
187186 $timestamp = wfTimestamp( TS_MW, $s->img_timestamp );
188187 if( empty( $firstTimestamp ) ) {
Index: trunk/extensions/UserImages/UserImages.class.php
@@ -80,10 +80,8 @@
8181 $gallery->setCaption( $this->getCaption() );
8282 $gallery->useSkin( $this->parser->getOptions()->getSkin() );
8383 foreach( $images as $image ) {
84 - $object = new Image( Title::makeTitleSafe( NS_IMAGE, $image->img_name ) );
85 - $object->loadFromFile();
86 - $object->loadFromRow( $image );
87 - $gallery->add( $object );
 84+ $title = Title::makeTitleSafe( NS_IMAGE, $image->img_name );
 85+ $gallery->add( $title );
8886 }
8987 return $gallery->toHtml();
9088 } else {
Index: trunk/extensions/FileSearch/FileSearchIndexer.php
@@ -46,7 +46,12 @@
4747 public static function index( $id, $namespace, $title, $text ) {
4848 if( $namespace == NS_IMAGE ) {
4949 wfDebugLog( 'filesearch', "Update called for `{$title}`" );
50 - $image = new Image( Title::makeTitle( NS_IMAGE, $title ) );
 50+ $titleObj = Title::makeTitle( NS_IMAGE, $title );
 51+ $image = function_exists( 'wfFindFile' ) ? wfFindFile( $titleObj ) : new Image( $titleObj );
 52+ if ( !$image || !$image->exists() ) {
 53+ wfDebugLog( 'filesearch', "Image does not exist: $title" );
 54+ return;
 55+ }
5156 $extractor = self::getExtractor( ( $mime = $image->getMimeType() ) );
5257 if( $extractor instanceof Extractor ) {
5358 wfDebugLog( 'filesearch', 'Using extractor ' . get_class( $extractor ) );
@@ -94,4 +99,4 @@
95100
96101 }
97102
98 -?>
\ No newline at end of file
 103+?>
Index: trunk/extensions/Player/PlayerClass.php
@@ -49,9 +49,10 @@
5050 static function newFromTitle( $title, $options, $sizeDefault = 'imagesize' ) {
5151 loadPlayerI18n();
5252
53 - if (!$title->exists()) throw new PlayerException(wfMsg("player-not-found"), 404);
54 -
55 - $image = new Image( $title );
 53+ $image = function_exists( 'wfFindFile' ) ? wfFindFile( $title ) : new Image( $title );
 54+ if ( !$image || !$image->exists() ) {
 55+ throw new PlayerException(wfMsg("player-not-found"), 404);
 56+ }
5657
5758 return new Player( $image, $options, $sizeDefault );
5859 }
Index: trunk/extensions/Logo/Logo.php
@@ -23,8 +23,8 @@
2424 if( is_object( $title ) ) {
2525 if( $title->getNamespace() != NS_IMAGE )
2626 $title = Title::makeTitle( NS_IMAGE, $title->getText() );
27 - $logo = new Image( $title );
28 - if( $logo->exists() )
 27+ $logo = function_exists( 'wfFindFile' ) ? wfFindFile( $title ) : new Image( $title );
 28+ if( $logo && $logo->exists() )
2929 $wgLogo = $wgLogoAutoScale ? $logo->createThumb( 135 ) : $logo->getUrl();
3030 }
3131 }
@@ -35,4 +35,4 @@
3636 die( 1 );
3737 }
3838
39 -?>
\ No newline at end of file
 39+?>
Index: trunk/extensions/ProofreadPage/ProofreadPage.php
@@ -108,8 +108,8 @@
109109 return true;
110110 }
111111
112 - $image = new Image( $imageTitle );
113 - if ( $image->exists() ) {
 112+ $image = function_exists( 'wfFindFile' ) ? wfFindFile( $imageTitle ) : new Image( $imageTitle );
 113+ if ( $image && $image->exists() ) {
114114 $width = intval( $image->getWidth() );
115115 $height = intval( $image->getHeight() );
116116 if($m[2]) {
Index: trunk/extensions/PicturePopup/PicturePopup_body.php
@@ -64,8 +64,8 @@
6565 }
6666
6767 function ajaxNoCache( $sizeSel ) {
68 - $image = new Image( $this->mTitle );
69 - if ( !$image->exists() ) {
 68+ $image = function_exists( 'wfFindFile' ) ? wfFindFile( $this->mTitle ) : new Image( $this->mTitle );
 69+ if ( !$image || !$image->exists() ) {
7070 return self::jsonError( 'picturepopup_no_image' );
7171 }
7272 $licenseData = $this->getImageLicenseMetadata( $this->mTitle );
Index: trunk/extensions/Filepath/SpecialFilepath_body.php
@@ -28,8 +28,8 @@
2929 $cform = new FilepathForm( $title );
3030 $cform->execute();
3131 } else {
32 - $file = new Image( $title );
33 - if ( $file->exists() ) {
 32+ $file = function_exists( 'wfFindFile' ) ? wfFindFile( $title ) : new Image( $title );
 33+ if ( $file && $file->exists() ) {
3434 $wgOut->redirect( $file->getURL() );
3535 } else {
3636 $wgOut->setStatusCode( 404 );
Index: trunk/extensions/News/NewsRenderer.php
@@ -612,7 +612,12 @@
613613 }
614614
615615 $ticon = $icon ? Title::newFromText($icon, NS_IMAGE) : NULL;
616 - $image = $ticon ? new Image( $ticon ) : NULL;
 616+ if ( $ticon ) {
 617+ $image = function_exists( 'wfFindFile' ) ? wfFindFile( $ticon ) : new Image( $ticon );
 618+ } else {
 619+ $image = false;
 620+ }
 621+
617622 $thumb = $image ? $image->getThumbnail(80, 16) : NULL;
618623 if ($image && !$thumb) $thumb = $image;
619624 $iconurl = $thumb ? $thumb->getUrl() : NULL;
@@ -848,4 +853,4 @@
849854 $this->view( false );
850855 }
851856 }
852 -?>
\ No newline at end of file
 857+?>