r88233 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88232‎ | r88233 | r88234 >
Date:13:04, 16 May 2011
Author:ashley
Status:deferred
Tags:
Comment:
some coding style tweaks
Modified paths:
  • /trunk/phase3/includes/ImageGallery.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/ImageGallery.php
@@ -9,8 +9,7 @@
1010 *
1111 * @ingroup Media
1212 */
13 -class ImageGallery
14 -{
 13+class ImageGallery {
1514 var $mImages, $mShowBytes, $mShowFilename;
1615 var $mCaption = false;
1716
@@ -38,13 +37,13 @@
3938 */
4039 const THUMB_PADDING = 30;
4140 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
4342 const GB_BORDERS = 8;
4443
4544 /**
4645 * Create a new image gallery object.
4746 */
48 - function __construct( ) {
 47+ function __construct() {
4948 global $wgGalleryOptions;
5049 $this->mImages = array();
5150 $this->mShowBytes = $wgGalleryOptions['showBytes'];
@@ -96,7 +95,7 @@
9796 * invalid numbers will be rejected
9897 */
9998 public function setPerRow( $num ) {
100 - if ($num >= 0) {
 99+ if ( $num >= 0 ) {
101100 $this->mPerRow = (int)$num;
102101 }
103102 }
@@ -107,7 +106,7 @@
108107 * @param $num Integer > 0; invalid numbers will be ignored
109108 */
110109 public function setWidths( $num ) {
111 - if ($num > 0) {
 110+ if ( $num > 0 ) {
112111 $this->mWidths = (int)$num;
113112 }
114113 }
@@ -118,7 +117,7 @@
119118 * @param $num Integer > 0; invalid numbers will be ignored
120119 */
121120 public function setHeights( $num ) {
122 - if ($num > 0) {
 121+ if ( $num > 0 ) {
123122 $this->mHeights = (int)$num;
124123 }
125124 }
@@ -147,7 +146,7 @@
148147 $title = $title->getTitle();
149148 }
150149 $this->mImages[] = array( $title, $html, $alt );
151 - wfDebug( "ImageGallery::add " . $title->getText() . "\n" );
 150+ wfDebug( 'ImageGallery::add ' . $title->getText() . "\n" );
152151 }
153152
154153 /**
@@ -157,7 +156,7 @@
158157 * @param $html String: Additional HTML text to be shown. The name and size of the image are always shown.
159158 * @param $alt String: Alt text for the image
160159 */
161 - function insert( $title, $html='', $alt='' ) {
 160+ function insert( $title, $html = '', $alt = '' ) {
162161 if ( $title instanceof File ) {
163162 // Old calling convention
164163 $title = $title->getTitle();
@@ -165,7 +164,6 @@
166165 array_unshift( $this->mImages, array( &$title, $html, $alt ) );
167166 }
168167
169 -
170168 /**
171169 * isEmpty() returns true if the gallery contains no images
172170 */
@@ -221,7 +219,7 @@
222220
223221 if ( $this->mPerRow > 0 ) {
224222 $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'] : '';
226224 # _width is ignored by any sane browser. IE6 doesn't know max-width so it uses _width instead
227225 $this->mAttribs['style'] = "max-width: {$maxwidth}px;_width: {$maxwidth}px;" . $oldStyle;
228226 }
@@ -234,7 +232,10 @@
235233 $output .= "\n\t<li class='gallerycaption'>{$this->mCaption}</li>";
236234 }
237235
238 - $params = array( 'width' => $this->mWidths, 'height' => $this->mHeights );
 236+ $params = array(
 237+ 'width' => $this->mWidths,
 238+ 'height' => $this->mHeights
 239+ );
239240 # Output each image...
240241 foreach ( $this->mImages as $pair ) {
241242 $nt = $pair[0];
@@ -260,11 +261,11 @@
261262
262263 if( !$img ) {
263264 # 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;">'
265266 . htmlspecialchars( $nt->getText() ) . '</div>';
266267 } elseif( $this->mHideBadImages && wfIsBadImage( $nt->getDBkey(), $this->getContextTitle() ) ) {
267268 # 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;">' .
269270 Linker::link(
270271 $nt,
271272 htmlspecialchars( $nt->getText() ),
@@ -275,14 +276,13 @@
276277 '</div>';
277278 } elseif( !( $thumb = $img->transform( $params ) ) ) {
278279 # 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;">'
280281 . htmlspecialchars( $img->getLastError() ) . '</div>';
281282 } else {
282283 # We get layout problems with the margin, if the image is smaller
283284 # than the line-height (17), so we add less margin in these cases.
284285 $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 );
287287
288288 $imageParameters = array(
289289 'desc-link' => true,
@@ -295,12 +295,12 @@
296296 }
297297
298298 # 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;">'
301301 # Auto-margin centering for block-level elements. Needed now that we have video
302302 # handlers since they may emit block-level elements as opposed to simple <img> tags.
303303 # ref http://css-discuss.incutio.com/?page=CenteringBlockElement
304 - . '<div style="margin:'.$vpad.'px auto;">'
 304+ . '<div style="margin:' . $vpad . 'px auto;">'
305305 . $thumb->toHtml( $imageParameters ) . '</div></div>';
306306
307307 // Call parser transform hook

Status & tagging log