From 589875173b285fc1f51e39a296bf5ac2855b030e Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Sun, 24 Nov 2013 19:40:30 +0100 Subject: [PATCH] Break long lines in gallery classes Change-Id: I49d9618155f0edc3fbeacc7bcec6351ada3886eb --- includes/gallery/ImageGalleryBase.php | 7 +-- includes/gallery/PackedImageGallery.php | 3 +- .../gallery/PackedOverlayImageGallery.php | 10 ++-- includes/gallery/TraditionalImageGallery.php | 54 ++++++++++++------- 4 files changed, 46 insertions(+), 28 deletions(-) diff --git a/includes/gallery/ImageGalleryBase.php b/includes/gallery/ImageGalleryBase.php index 491f12dfa1..e46916e666 100644 --- a/includes/gallery/ImageGalleryBase.php +++ b/includes/gallery/ImageGalleryBase.php @@ -206,7 +206,8 @@ abstract class ImageGalleryBase extends ContextSource { * Add an image to the gallery. * * @param $title Title object of the image that is added to the gallery - * @param $html String: Additional HTML text to be shown. The name and size of the image are always shown. + * @param $html String: Additional HTML text to be shown. The name and + * size of the image are always shown. * @param $alt String: Alt text for the image * @param $link String: Override image link (optional) * @param $handlerOpts Array: Array of options for image handler (aka page number) @@ -224,7 +225,8 @@ abstract class ImageGalleryBase extends ContextSource { * Add an image at the beginning of the gallery. * * @param $title Title object of the image that is added to the gallery - * @param $html String: Additional HTML text to be shown. The name and size of the image are always shown. + * @param $html String: Additional HTML text to be shown. The name and + * size of the image are always shown. * @param $alt String: Alt text for the image * @param $link String: Override image link (optional) * @param $handlerOpts Array: Array of options for image handler (aka page number) @@ -327,4 +329,3 @@ abstract class ImageGalleryBase extends ContextSource { const GB_BORDERS = 8; */ } - diff --git a/includes/gallery/PackedImageGallery.php b/includes/gallery/PackedImageGallery.php index 1cb1fd9575..2d2d0db0cc 100644 --- a/includes/gallery/PackedImageGallery.php +++ b/includes/gallery/PackedImageGallery.php @@ -75,7 +75,8 @@ class PackedImageGallery extends TraditionalImageGallery { } /** - * @param MediaTransformOutput|bool $thumb the thumbnail, or false if no thumb (which can happen) + * @param MediaTransformOutput|bool $thumb the thumbnail, or false if no + * thumb (which can happen) */ protected function getGBWidth( $thumb ) { $thumbWidth = $thumb ? $thumb->getWidth() : $this->mWidths * self::SCALE_FACTOR; diff --git a/includes/gallery/PackedOverlayImageGallery.php b/includes/gallery/PackedOverlayImageGallery.php index ec35db2f5c..bebc39ef63 100644 --- a/includes/gallery/PackedOverlayImageGallery.php +++ b/includes/gallery/PackedOverlayImageGallery.php @@ -26,7 +26,8 @@ class PackedOverlayImageGallery extends PackedImageGallery { * Add the wrapper html around the thumb's caption * * @param String $galleryText The caption - * @param MediaTransformOutput|boolean $thumb The thumb this caption is for or false for bad image. + * @param MediaTransformOutput|boolean $thumb The thumb this caption is for + * or false for bad image. */ protected function wrapGalleryText( $galleryText, $thumb ) { @@ -36,9 +37,10 @@ class PackedOverlayImageGallery extends PackedImageGallery { return ''; } - # ATTENTION: The newline after
is needed to accommodate htmltidy which - # in version 4.8.6 generated crackpot html in its absence, see: - # http://bugzilla.wikimedia.org/show_bug.cgi?id=1765 -Ævar + # ATTENTION: The newline after
is needed to + # accommodate htmltidy which in version 4.8.6 generated crackpot HTML + # in its absence, see: http://bugzilla.wikimedia.org/show_bug.cgi?id=1765 + # -Ævar $thumbWidth = $this->getGBWidth( $thumb ) - $this->getThumbPadding() - $this->getGBPadding(); $captionWidth = ceil( $thumbWidth - 20 ); diff --git a/includes/gallery/TraditionalImageGallery.php b/includes/gallery/TraditionalImageGallery.php index 2ee2d37fa6..05c612b003 100644 --- a/includes/gallery/TraditionalImageGallery.php +++ b/includes/gallery/TraditionalImageGallery.php @@ -36,8 +36,10 @@ class TraditionalImageGallery extends ImageGalleryBase { if ( $this->mPerRow > 0 ) { $maxwidth = $this->mPerRow * ( $this->mWidths + $this->getAllPadding() ); $oldStyle = isset( $this->mAttribs['style'] ) ? $this->mAttribs['style'] : ''; - # _width is ignored by any sane browser. IE6 doesn't know max-width so it uses _width instead - $this->mAttribs['style'] = "max-width: {$maxwidth}px;_width: {$maxwidth}px;" . $oldStyle; + # _width is ignored by any sane browser. IE6 doesn't know max-width + # so it uses _width instead + $this->mAttribs['style'] = "max-width: {$maxwidth}px;_width: {$maxwidth}px;" . + $oldStyle; } $attribs = Sanitizer::mergeAttributes( @@ -88,15 +90,19 @@ class TraditionalImageGallery extends ImageGalleryBase { if ( !$img ) { # We're dealing with a non-image, spit out the name and be done with it. - $thumbhtml = "\n\t\t\t" . '
' + $thumbhtml = "\n\t\t\t" . '
' . htmlspecialchars( $nt->getText() ) . '
'; if ( $this->mParser instanceof Parser ) { $this->mParser->addTrackingCategory( 'broken-file-category' ); } - } elseif ( $this->mHideBadImages && wfIsBadImage( $nt->getDBkey(), $this->getContextTitle() ) ) { + } elseif ( $this->mHideBadImages + && wfIsBadImage( $nt->getDBkey(), $this->getContextTitle() ) + ) { # The image is blacklisted, just show it as a text link. - $thumbhtml = "\n\t\t\t" . '
' . + $thumbhtml = "\n\t\t\t" . '
' . Linker::link( $nt, htmlspecialchars( $nt->getText() ), @@ -107,7 +113,8 @@ class TraditionalImageGallery extends ImageGalleryBase { '
'; } elseif ( !( $thumb = $img->transform( $transformOptions ) ) ) { # Error generating thumbnail. - $thumbhtml = "\n\t\t\t" . '
' + $thumbhtml = "\n\t\t\t" . '
' . htmlspecialchars( $img->getLastError() ) . '
'; } else { $vpad = $this->getVPad( $this->mHeights, $thumb->getHeight() ); @@ -118,7 +125,9 @@ class TraditionalImageGallery extends ImageGalleryBase { 'alt' => $alt, 'custom-url-link' => $link ); - # In the absence of both alt text and caption, fall back on providing screen readers with the filename as alt text + + // In the absence of both alt text and caption, fall back on + // providing screen readers with the filename as alt text if ( $alt == '' && $text == '' ) { $imageParameters['alt'] = $nt->getText(); } @@ -126,11 +135,13 @@ class TraditionalImageGallery extends ImageGalleryBase { $this->adjustImageParameters( $thumb, $imageParameters ); # Set both fixed width and min-height. - $thumbhtml = "\n\t\t\t" . - '
' - # Auto-margin centering for block-level elements. Needed now that we have video - # handlers since they may emit block-level elements as opposed to simple tags. - # ref http://css-discuss.incutio.com/?page=CenteringBlockElement + $thumbhtml = "\n\t\t\t" + . '
' + # Auto-margin centering for block-level elements. Needed + # now that we have video handlers since they may emit block- + # level elements as opposed to simple tags. ref + # http://css-discuss.incutio.com/?page=CenteringBlockElement . '
' . $thumb->toHtml( $imageParameters ) . '
'; @@ -140,8 +151,9 @@ class TraditionalImageGallery extends ImageGalleryBase { } } - //TODO - // $linkTarget = Title::newFromText( $wgContLang->getNsText( MWNamespace::getUser() ) . ":{$ut}" ); + // @todo Code is incomplete. + // $linkTarget = Title::newFromText( $wgContLang->getNsText( MWNamespace::getUser() ) . + // ":{$ut}" ); // $ul = Linker::link( $linkTarget, $ut ); if ( $this->mShowBytes ) { @@ -170,7 +182,8 @@ class TraditionalImageGallery extends ImageGalleryBase { # Weird double wrapping (the extra div inside the li) needed due to FF2 bug # Can be safely removed if FF2 falls completely out of existence - $output .= "\n\t\t" . '
  • ' + $output .= "\n\t\t" . '
  • ' . '
    ' . $thumbhtml . $galleryText @@ -185,12 +198,14 @@ class TraditionalImageGallery extends ImageGalleryBase { * Add the wrapper html around the thumb's caption * * @param String $galleryText The caption - * @param MediaTransformOutput|boolean $thumb The thumb this caption is for or false for bad image. + * @param MediaTransformOutput|boolean $thumb The thumb this caption is for + * or false for bad image. */ protected function wrapGalleryText( $galleryText, $thumb ) { - # ATTENTION: The newline after
    is needed to accommodate htmltidy which - # in version 4.8.6 generated crackpot html in its absence, see: - # http://bugzilla.wikimedia.org/show_bug.cgi?id=1765 -Ævar + # ATTENTION: The newline after
    is needed to + # accommodate htmltidy which in version 4.8.6 generated crackpot html in + # its absence, see: http://bugzilla.wikimedia.org/show_bug.cgi?id=1765 + # -Ævar return "\n\t\t\t" . '
    ' . "\n" . $galleryText @@ -208,7 +223,6 @@ class TraditionalImageGallery extends ImageGalleryBase { } /** - * * @note GB stands for gallerybox (as in the
  • element) * * @return int -- 2.20.1