Index: trunk/extensions/ImageMap/ImageMap_body.php |
— | — | @@ -83,7 +83,10 @@ |
84 | 84 | $thumbWidth = $imageNode->getAttribute('width'); |
85 | 85 | $thumbHeight = $imageNode->getAttribute('height'); |
86 | 86 | |
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 | + } |
88 | 91 | # Add the linear dimensions to avoid inaccuracy in the scale |
89 | 92 | # factor when one is much larger than the other |
90 | 93 | # (sx+sy)/(x+y) = s |
Index: trunk/extensions/SmoothGallery/SmoothGallery.php |
— | — | @@ -27,7 +27,7 @@ |
28 | 28 | # |
29 | 29 | |
30 | 30 | if( !defined( 'MEDIAWIKI' ) ) |
31 | | - die( -1 ); |
| 31 | + die( -1 ); |
32 | 32 | |
33 | 33 | $wgExtensionFunctions[] = "wfSmoothGallery"; |
34 | 34 | |
— | — | @@ -43,9 +43,9 @@ |
44 | 44 | $wgSmoothGalleryExtensionPath = $wgScriptPath . '/extensions/SmoothGallery'; |
45 | 45 | |
46 | 46 | function wfSmoothGallery() { |
47 | | - global $wgParser; |
| 47 | + global $wgParser; |
48 | 48 | |
49 | | - $wgParser->setHook( 'sgallery', 'renderSmoothGallery' ); |
| 49 | + $wgParser->setHook( 'sgallery', 'renderSmoothGallery' ); |
50 | 50 | } |
51 | 51 | |
52 | 52 | function smoothGalleryImagesByCat( $title ) { |
— | — | @@ -75,120 +75,120 @@ |
76 | 76 | } |
77 | 77 | |
78 | 78 | function renderSmoothGallery( $input, $argv, &$parser ) { |
79 | | - global $wgContLang, $wgUser, $wgTitle; |
80 | | - global $wgSmoothGalleryDelimiter; |
| 79 | + global $wgContLang, $wgUser, $wgTitle; |
| 80 | + global $wgSmoothGalleryDelimiter; |
81 | 81 | |
82 | | - $skin = $wgUser->getSkin(); |
| 82 | + $skin = $wgUser->getSkin(); |
83 | 83 | |
84 | | - //Sanity check |
85 | | - if ( $input == "" ) { |
| 84 | + //Sanity check |
| 85 | + if ( $input == "" ) { |
86 | 86 | loadSmoothGalleryI18n(); |
87 | 87 | $output = wfMsg("smoothgallery-error"); |
88 | | - $output .= wfMsg("smoothgallery-not-found"); |
89 | | - return $output; |
90 | | - } |
| 88 | + $output .= wfMsg("smoothgallery-not-found"); |
| 89 | + return $output; |
| 90 | + } |
91 | 91 | |
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(); |
95 | 95 | |
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 | + } |
108 | 108 | |
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 | + } |
120 | 120 | |
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 | + } |
126 | 126 | |
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 | + } |
132 | 132 | |
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 | + } |
138 | 138 | |
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 | + } |
144 | 144 | |
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 | + } |
150 | 150 | |
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 |
154 | 154 | |
155 | | - //sanity check |
156 | | - $name = htmlspecialchars( $argv["special"] ); |
| 155 | + //sanity check |
| 156 | + $name = htmlspecialchars( $argv["special"] ); |
157 | 157 | |
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 ); |
161 | 161 | |
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 ) ); |
166 | 166 | |
167 | | - //Provide the link |
168 | | - return '<a href="' . $output . '">' . $name . '</a>'; |
169 | | - } |
| 167 | + //Provide the link |
| 168 | + return '<a href="' . $output . '">' . $name . '</a>'; |
| 169 | + } |
170 | 170 | |
171 | 171 | $parser->mOutput->mSmoothGalleryTag = true; # flag for use by smoothGalleryParserOutput |
172 | 172 | |
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;">'; |
175 | 175 | |
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(); |
183 | 183 | |
184 | | - //Expand templates in the input |
185 | | - $local_parser->replaceVariables( $input ); |
| 184 | + //Expand templates in the input |
| 185 | + $local_parser->replaceVariables( $input ); |
186 | 186 | |
187 | | - //The image array is a delimited list of images (strings) |
| 187 | + //The image array is a delimited list of images (strings) |
188 | 188 | $img_arr = preg_split( "/$wgSmoothGalleryDelimiter/", $input, -1, PREG_SPLIT_NO_EMPTY ); |
189 | | - $img_count = count( $img_arr ); |
| 189 | + $img_count = count( $img_arr ); |
190 | 190 | |
191 | | - $title_arr = array(); |
192 | | - foreach ( $img_arr as $img ) { |
| 191 | + $title_arr = array(); |
| 192 | + foreach ( $img_arr as $img ) { |
193 | 193 | $title = Title::newFromText( $img, NS_IMAGE ); |
194 | 194 | |
195 | 195 | if ( is_null($title) ) { |
— | — | @@ -196,7 +196,7 @@ |
197 | 197 | } |
198 | 198 | |
199 | 199 | $ns = $title->getNamespace(); |
200 | | - |
| 200 | + |
201 | 201 | if ( $ns == NS_IMAGE ) $title_arr[] = $title; |
202 | 202 | else if ( $ns == NS_CATEGORY ) { |
203 | 203 | //list images in category |
— | — | @@ -205,175 +205,169 @@ |
206 | 206 | $title_arr = array_merge( $title_arr, $cat_images ); |
207 | 207 | } |
208 | 208 | } |
209 | | - } |
| 209 | + } |
210 | 210 | |
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 = ""; |
214 | 214 | |
215 | | - $plain_gallery = new ImageGallery(); |
| 215 | + $plain_gallery = new ImageGallery(); |
216 | 216 | |
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 ); |
220 | 220 | |
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() ); |
226 | 227 | |
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 | + } |
233 | 230 | |
234 | | - continue; |
235 | | - } |
236 | | - |
237 | | - //check media type. Only images are supported |
| 231 | + //check media type. Only images are supported |
238 | 232 | $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 | + } |
243 | 237 | |
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 ); |
247 | 241 | if ( !is_null($full_thumb_obj) ) { |
248 | | - $full_thumb = $full_thumb_obj->getUrl(); |
| 242 | + $full_thumb = $full_thumb_obj->getUrl(); |
249 | 243 | } else { |
250 | | - $img_count = $img_count - 1; |
251 | | - continue; |
| 244 | + $img_count = $img_count - 1; |
| 245 | + continue; |
252 | 246 | } |
253 | 247 | |
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 | + } |
259 | 253 | |
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 | + } |
274 | 268 | |
275 | | - $fulldesc = ''; |
| 269 | + $fulldesc = ''; |
276 | 270 | |
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 ); |
282 | 276 | |
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(); |
285 | 279 | |
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 | + } |
294 | 288 | |
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" />'; |
302 | 296 | |
303 | | - if ( $carousel ) { |
304 | | - $output .= '<img src="' . $icon_thumb . '" class="thumbnail" />'; |
305 | | - } |
| 297 | + if ( $carousel ) { |
| 298 | + $output .= '<img src="' . $icon_thumb . '" class="thumbnail" />'; |
| 299 | + } |
306 | 300 | |
307 | | - $output .= '</div>'; |
| 301 | + $output .= '</div>'; |
308 | 302 | |
309 | | - $plain_gallery->add( $img_obj ); //TODO: use text |
310 | | - } |
| 303 | + $plain_gallery->add( $img_obj->getTitle() ); //TODO: use text |
| 304 | + } |
311 | 305 | |
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 |
316 | 310 | loadSmoothGalleryI18n(); |
317 | 311 | |
318 | 312 | $output = wfMsg("smoothgallery-error"); |
319 | 313 | |
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 | + } |
326 | 320 | |
327 | | - return $output; |
328 | | - } |
| 321 | + return $output; |
| 322 | + } |
329 | 323 | |
330 | | - //Close the outer div of the gallery |
331 | | - $output .= '</div>'; |
| 324 | + //Close the outer div of the gallery |
| 325 | + $output .= '</div>'; |
332 | 326 | |
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">'; |
335 | 329 | |
336 | | - $output .= $plain_gallery->toHTML(); |
| 330 | + $output .= $plain_gallery->toHTML(); |
337 | 331 | |
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>'; |
340 | 334 | |
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">'; |
344 | 338 | |
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 |
347 | 341 | |
348 | | - $output .= 'function startGallery_' . $name . '() {'; |
349 | | - $output .= "var myGallery = new gallery($('" . $name . "'), {"; |
| 342 | + $output .= 'function startGallery_' . $name . '() {'; |
| 343 | + $output .= "var myGallery = new gallery($('" . $name . "'), {"; |
350 | 344 | |
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... |
352 | 346 | |
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 | + } |
358 | 352 | |
359 | | - if ( !$carousel ) { |
360 | | - $output .= ', showCarousel: false'; |
361 | | - } |
| 353 | + if ( !$carousel ) { |
| 354 | + $output .= ', showCarousel: false'; |
| 355 | + } |
362 | 356 | |
363 | | - if ( !$showarrows ) { |
364 | | - $output .= ', showArrows: false'; |
365 | | - } |
| 357 | + if ( !$showarrows ) { |
| 358 | + $output .= ', showArrows: false'; |
| 359 | + } |
366 | 360 | |
367 | | - if ( !$showinfopane ) { |
368 | | - $output .= ', showInfopane: false'; |
369 | | - } |
| 361 | + if ( !$showinfopane ) { |
| 362 | + $output .= ', showInfopane: false'; |
| 363 | + } |
370 | 364 | |
371 | | - $output .= '});'; |
372 | | - $output .= '}'; |
373 | | - $output .= 'addOnloadHook(startGallery_' . $name . ');'; |
374 | | - $output .= '</script>'; |
| 365 | + $output .= '});'; |
| 366 | + $output .= '}'; |
| 367 | + $output .= 'addOnloadHook(startGallery_' . $name . ');'; |
| 368 | + $output .= '</script>'; |
375 | 369 | |
376 | | - //Finished, let's send it out |
377 | | - return $output; |
| 370 | + //Finished, let's send it out |
| 371 | + return $output; |
378 | 372 | } |
379 | 373 | |
380 | 374 | /** |
— | — | @@ -381,34 +375,34 @@ |
382 | 376 | * Does nothing if $parserOutput->mSmoothGalleryTag is not set |
383 | 377 | */ |
384 | 378 | 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; |
389 | 383 | } |
390 | 384 | |
391 | 385 | /** |
392 | 386 | * Load the SmoothGallery internationalization file |
393 | 387 | */ |
394 | 388 | function loadSmoothGalleryI18n() { |
395 | | - global $wgContLang, $wgMessageCache; |
| 389 | + global $wgContLang, $wgMessageCache; |
396 | 390 | |
397 | | - static $initialized = false; |
| 391 | + static $initialized = false; |
398 | 392 | |
399 | | - if ( $initialized ) return true; |
| 393 | + if ( $initialized ) return true; |
400 | 394 | |
401 | | - $messages = array(); |
| 395 | + $messages = array(); |
402 | 396 | |
403 | | - $f = dirname( __FILE__ ) . '/SmoothGallery.i18n.php'; |
404 | | - include( $f ); |
| 397 | + $f = dirname( __FILE__ ) . '/SmoothGallery.i18n.php'; |
| 398 | + include( $f ); |
405 | 399 | |
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 ); |
408 | 402 | |
409 | | - $initialized = true; |
410 | | - $wgMessageCache->addMessages( $messages ); |
| 403 | + $initialized = true; |
| 404 | + $wgMessageCache->addMessages( $messages ); |
411 | 405 | |
412 | | - return true; |
| 406 | + return true; |
413 | 407 | } |
414 | 408 | |
415 | 409 | |
— | — | @@ -416,10 +410,10 @@ |
417 | 411 | * Add extension information to Special:Version |
418 | 412 | */ |
419 | 413 | $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 | +); |
426 | 420 | ?> |
Index: trunk/extensions/SpecialFileList/SpecialFilelist.php |
— | — | @@ -178,10 +178,9 @@ |
179 | 179 | $ut = $s->img_user_text; |
180 | 180 | |
181 | 181 | $nt = Title::newFromText( $name, NS_IMAGE ); |
182 | | - $img = new Image( $nt ); |
183 | 182 | $ul = $this->sk->makeLinkObj( Title::makeTitle( NS_USER, $ut ), $ut ); |
184 | 183 | |
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" ); |
186 | 185 | |
187 | 186 | $timestamp = wfTimestamp( TS_MW, $s->img_timestamp ); |
188 | 187 | if( empty( $firstTimestamp ) ) { |
Index: trunk/extensions/UserImages/UserImages.class.php |
— | — | @@ -80,10 +80,8 @@ |
81 | 81 | $gallery->setCaption( $this->getCaption() ); |
82 | 82 | $gallery->useSkin( $this->parser->getOptions()->getSkin() ); |
83 | 83 | 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 ); |
88 | 86 | } |
89 | 87 | return $gallery->toHtml(); |
90 | 88 | } else { |
Index: trunk/extensions/FileSearch/FileSearchIndexer.php |
— | — | @@ -46,7 +46,12 @@ |
47 | 47 | public static function index( $id, $namespace, $title, $text ) { |
48 | 48 | if( $namespace == NS_IMAGE ) { |
49 | 49 | 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 | + } |
51 | 56 | $extractor = self::getExtractor( ( $mime = $image->getMimeType() ) ); |
52 | 57 | if( $extractor instanceof Extractor ) { |
53 | 58 | wfDebugLog( 'filesearch', 'Using extractor ' . get_class( $extractor ) ); |
— | — | @@ -94,4 +99,4 @@ |
95 | 100 | |
96 | 101 | } |
97 | 102 | |
98 | | -?> |
\ No newline at end of file |
| 103 | +?> |
Index: trunk/extensions/Player/PlayerClass.php |
— | — | @@ -49,9 +49,10 @@ |
50 | 50 | static function newFromTitle( $title, $options, $sizeDefault = 'imagesize' ) { |
51 | 51 | loadPlayerI18n(); |
52 | 52 | |
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 | + } |
56 | 57 | |
57 | 58 | return new Player( $image, $options, $sizeDefault ); |
58 | 59 | } |
Index: trunk/extensions/Logo/Logo.php |
— | — | @@ -23,8 +23,8 @@ |
24 | 24 | if( is_object( $title ) ) { |
25 | 25 | if( $title->getNamespace() != NS_IMAGE ) |
26 | 26 | $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() ) |
29 | 29 | $wgLogo = $wgLogoAutoScale ? $logo->createThumb( 135 ) : $logo->getUrl(); |
30 | 30 | } |
31 | 31 | } |
— | — | @@ -35,4 +35,4 @@ |
36 | 36 | die( 1 ); |
37 | 37 | } |
38 | 38 | |
39 | | -?> |
\ No newline at end of file |
| 39 | +?> |
Index: trunk/extensions/ProofreadPage/ProofreadPage.php |
— | — | @@ -108,8 +108,8 @@ |
109 | 109 | return true; |
110 | 110 | } |
111 | 111 | |
112 | | - $image = new Image( $imageTitle ); |
113 | | - if ( $image->exists() ) { |
| 112 | + $image = function_exists( 'wfFindFile' ) ? wfFindFile( $imageTitle ) : new Image( $imageTitle ); |
| 113 | + if ( $image && $image->exists() ) { |
114 | 114 | $width = intval( $image->getWidth() ); |
115 | 115 | $height = intval( $image->getHeight() ); |
116 | 116 | if($m[2]) { |
Index: trunk/extensions/PicturePopup/PicturePopup_body.php |
— | — | @@ -64,8 +64,8 @@ |
65 | 65 | } |
66 | 66 | |
67 | 67 | 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() ) { |
70 | 70 | return self::jsonError( 'picturepopup_no_image' ); |
71 | 71 | } |
72 | 72 | $licenseData = $this->getImageLicenseMetadata( $this->mTitle ); |
Index: trunk/extensions/Filepath/SpecialFilepath_body.php |
— | — | @@ -28,8 +28,8 @@ |
29 | 29 | $cform = new FilepathForm( $title ); |
30 | 30 | $cform->execute(); |
31 | 31 | } 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() ) { |
34 | 34 | $wgOut->redirect( $file->getURL() ); |
35 | 35 | } else { |
36 | 36 | $wgOut->setStatusCode( 404 ); |
Index: trunk/extensions/News/NewsRenderer.php |
— | — | @@ -612,7 +612,12 @@ |
613 | 613 | } |
614 | 614 | |
615 | 615 | $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 | + |
617 | 622 | $thumb = $image ? $image->getThumbnail(80, 16) : NULL; |
618 | 623 | if ($image && !$thumb) $thumb = $image; |
619 | 624 | $iconurl = $thumb ? $thumb->getUrl() : NULL; |
— | — | @@ -848,4 +853,4 @@ |
849 | 854 | $this->view( false ); |
850 | 855 | } |
851 | 856 | } |
852 | | -?> |
\ No newline at end of file |
| 857 | +?> |