Index: trunk/phase3/includes/ImageGallery.php |
— | — | @@ -9,8 +9,7 @@ |
10 | 10 | * |
11 | 11 | * @ingroup Media |
12 | 12 | */ |
13 | | -class ImageGallery |
14 | | -{ |
| 13 | +class ImageGallery { |
15 | 14 | var $mImages, $mShowBytes, $mShowFilename; |
16 | 15 | var $mCaption = false; |
17 | 16 | |
— | — | @@ -38,13 +37,13 @@ |
39 | 38 | */ |
40 | 39 | const THUMB_PADDING = 30; |
41 | 40 | const GB_PADDING = 5; |
42 | | - //2px borders on each side + 2px implied padding on each side |
| 41 | + // 2px borders on each side + 2px implied padding on each side |
43 | 42 | const GB_BORDERS = 8; |
44 | 43 | |
45 | 44 | /** |
46 | 45 | * Create a new image gallery object. |
47 | 46 | */ |
48 | | - function __construct( ) { |
| 47 | + function __construct() { |
49 | 48 | global $wgGalleryOptions; |
50 | 49 | $this->mImages = array(); |
51 | 50 | $this->mShowBytes = $wgGalleryOptions['showBytes']; |
— | — | @@ -96,7 +95,7 @@ |
97 | 96 | * invalid numbers will be rejected |
98 | 97 | */ |
99 | 98 | public function setPerRow( $num ) { |
100 | | - if ($num >= 0) { |
| 99 | + if ( $num >= 0 ) { |
101 | 100 | $this->mPerRow = (int)$num; |
102 | 101 | } |
103 | 102 | } |
— | — | @@ -107,7 +106,7 @@ |
108 | 107 | * @param $num Integer > 0; invalid numbers will be ignored |
109 | 108 | */ |
110 | 109 | public function setWidths( $num ) { |
111 | | - if ($num > 0) { |
| 110 | + if ( $num > 0 ) { |
112 | 111 | $this->mWidths = (int)$num; |
113 | 112 | } |
114 | 113 | } |
— | — | @@ -118,7 +117,7 @@ |
119 | 118 | * @param $num Integer > 0; invalid numbers will be ignored |
120 | 119 | */ |
121 | 120 | public function setHeights( $num ) { |
122 | | - if ($num > 0) { |
| 121 | + if ( $num > 0 ) { |
123 | 122 | $this->mHeights = (int)$num; |
124 | 123 | } |
125 | 124 | } |
— | — | @@ -147,7 +146,7 @@ |
148 | 147 | $title = $title->getTitle(); |
149 | 148 | } |
150 | 149 | $this->mImages[] = array( $title, $html, $alt ); |
151 | | - wfDebug( "ImageGallery::add " . $title->getText() . "\n" ); |
| 150 | + wfDebug( 'ImageGallery::add ' . $title->getText() . "\n" ); |
152 | 151 | } |
153 | 152 | |
154 | 153 | /** |
— | — | @@ -157,7 +156,7 @@ |
158 | 157 | * @param $html String: Additional HTML text to be shown. The name and size of the image are always shown. |
159 | 158 | * @param $alt String: Alt text for the image |
160 | 159 | */ |
161 | | - function insert( $title, $html='', $alt='' ) { |
| 160 | + function insert( $title, $html = '', $alt = '' ) { |
162 | 161 | if ( $title instanceof File ) { |
163 | 162 | // Old calling convention |
164 | 163 | $title = $title->getTitle(); |
— | — | @@ -165,7 +164,6 @@ |
166 | 165 | array_unshift( $this->mImages, array( &$title, $html, $alt ) ); |
167 | 166 | } |
168 | 167 | |
169 | | - |
170 | 168 | /** |
171 | 169 | * isEmpty() returns true if the gallery contains no images |
172 | 170 | */ |
— | — | @@ -221,7 +219,7 @@ |
222 | 220 | |
223 | 221 | if ( $this->mPerRow > 0 ) { |
224 | 222 | $maxwidth = $this->mPerRow * ( $this->mWidths + self::THUMB_PADDING + self::GB_PADDING + self::GB_BORDERS ); |
225 | | - $oldStyle = isset( $this->mAttribs['style'] ) ? $this->mAttribs['style'] : ""; |
| 223 | + $oldStyle = isset( $this->mAttribs['style'] ) ? $this->mAttribs['style'] : ''; |
226 | 224 | # _width is ignored by any sane browser. IE6 doesn't know max-width so it uses _width instead |
227 | 225 | $this->mAttribs['style'] = "max-width: {$maxwidth}px;_width: {$maxwidth}px;" . $oldStyle; |
228 | 226 | } |
— | — | @@ -234,7 +232,10 @@ |
235 | 233 | $output .= "\n\t<li class='gallerycaption'>{$this->mCaption}</li>"; |
236 | 234 | } |
237 | 235 | |
238 | | - $params = array( 'width' => $this->mWidths, 'height' => $this->mHeights ); |
| 236 | + $params = array( |
| 237 | + 'width' => $this->mWidths, |
| 238 | + 'height' => $this->mHeights |
| 239 | + ); |
239 | 240 | # Output each image... |
240 | 241 | foreach ( $this->mImages as $pair ) { |
241 | 242 | $nt = $pair[0]; |
— | — | @@ -260,11 +261,11 @@ |
261 | 262 | |
262 | 263 | if( !$img ) { |
263 | 264 | # We're dealing with a non-image, spit out the name and be done with it. |
264 | | - $thumbhtml = "\n\t\t\t".'<div style="height: '.(self::THUMB_PADDING + $this->mHeights).'px;">' |
| 265 | + $thumbhtml = "\n\t\t\t" . '<div style="height: ' . ( self::THUMB_PADDING + $this->mHeights ) . 'px;">' |
265 | 266 | . htmlspecialchars( $nt->getText() ) . '</div>'; |
266 | 267 | } elseif( $this->mHideBadImages && wfIsBadImage( $nt->getDBkey(), $this->getContextTitle() ) ) { |
267 | 268 | # The image is blacklisted, just show it as a text link. |
268 | | - $thumbhtml = "\n\t\t\t".'<div style="height: '.(self::THUMB_PADDING + $this->mHeights).'px;">' . |
| 269 | + $thumbhtml = "\n\t\t\t" . '<div style="height: ' . ( self::THUMB_PADDING + $this->mHeights ) . 'px;">' . |
269 | 270 | Linker::link( |
270 | 271 | $nt, |
271 | 272 | htmlspecialchars( $nt->getText() ), |
— | — | @@ -275,14 +276,13 @@ |
276 | 277 | '</div>'; |
277 | 278 | } elseif( !( $thumb = $img->transform( $params ) ) ) { |
278 | 279 | # Error generating thumbnail. |
279 | | - $thumbhtml = "\n\t\t\t".'<div style="height: '.(self::THUMB_PADDING + $this->mHeights).'px;">' |
| 280 | + $thumbhtml = "\n\t\t\t" . '<div style="height: ' . ( self::THUMB_PADDING + $this->mHeights ) . 'px;">' |
280 | 281 | . htmlspecialchars( $img->getLastError() ) . '</div>'; |
281 | 282 | } else { |
282 | 283 | # We get layout problems with the margin, if the image is smaller |
283 | 284 | # than the line-height (17), so we add less margin in these cases. |
284 | 285 | $minThumbHeight = $thumb->height > 17 ? $thumb->height : 17; |
285 | | - $vpad = floor(( self::THUMB_PADDING + $this->mHeights - $minThumbHeight ) /2); |
286 | | - |
| 286 | + $vpad = floor( ( self::THUMB_PADDING + $this->mHeights - $minThumbHeight ) /2 ); |
287 | 287 | |
288 | 288 | $imageParameters = array( |
289 | 289 | 'desc-link' => true, |
— | — | @@ -295,12 +295,12 @@ |
296 | 296 | } |
297 | 297 | |
298 | 298 | # Set both fixed width and min-height. |
299 | | - $thumbhtml = "\n\t\t\t". |
300 | | - '<div class="thumb" style="width: ' .($this->mWidths + self::THUMB_PADDING).'px;">' |
| 299 | + $thumbhtml = "\n\t\t\t" . |
| 300 | + '<div class="thumb" style="width: ' . ( $this->mWidths + self::THUMB_PADDING ) . 'px;">' |
301 | 301 | # Auto-margin centering for block-level elements. Needed now that we have video |
302 | 302 | # handlers since they may emit block-level elements as opposed to simple <img> tags. |
303 | 303 | # ref http://css-discuss.incutio.com/?page=CenteringBlockElement |
304 | | - . '<div style="margin:'.$vpad.'px auto;">' |
| 304 | + . '<div style="margin:' . $vpad . 'px auto;">' |
305 | 305 | . $thumb->toHtml( $imageParameters ) . '</div></div>'; |
306 | 306 | |
307 | 307 | // Call parser transform hook |