X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/?a=blobdiff_plain;f=includes%2Fgallery%2FTraditionalImageGallery.php;h=cd6aab0f88d53a7153982b5a70802fa9d0c75d53;hb=1054deece9c03a448f03cf3fd03493458d9bee09;hp=7a520bcbd1cd90e38ff1120038d0f584bc30b9cf;hpb=3df3b575c6617df64ec98533cc7141bd2314e274;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/gallery/TraditionalImageGallery.php b/includes/gallery/TraditionalImageGallery.php index 7a520bcbd1..cd6aab0f88 100644 --- a/includes/gallery/TraditionalImageGallery.php +++ b/includes/gallery/TraditionalImageGallery.php @@ -191,29 +191,21 @@ class TraditionalImageGallery extends ImageGalleryBase { } $textlink = $this->mShowFilename ? - // Preloaded into LinkCache above - Linker::linkKnown( - $nt, - htmlspecialchars( - $this->mCaptionLength !== true ? - $lang->truncate( $nt->getText(), $this->mCaptionLength ) : - $nt->getText() - ), - [ - 'class' => 'galleryfilename' . - ( $this->mCaptionLength === true ? ' galleryfilename-truncate' : '' ) - ] - ) . "\n" : + $this->getCaptionHtml( $nt, $lang ) : ''; $galleryText = $textlink . $text . $meta; $galleryText = $this->wrapGalleryText( $galleryText, $thumb ); + $gbWidth = $this->getGBWidth( $thumb ) . 'px'; + if ( $this->getGBWidthOverwrite( $thumb ) ) { + $gbWidth = $this->getGBWidthOverwrite( $thumb ); + } # 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" . '
  • ' - . '
    ' + . $gbWidth . '">' + . '
    ' . $thumbhtml . $galleryText . "\n\t\t
  • "; @@ -223,6 +215,27 @@ class TraditionalImageGallery extends ImageGalleryBase { return $output; } + /** + * @param Title $nt + * @param Language $lang + * @return string HTML + */ + protected function getCaptionHtml( Title $nt, Language $lang ) { + // Preloaded into LinkCache in toHTML + return Linker::linkKnown( + $nt, + htmlspecialchars( + is_int( $this->getCaptionLength() ) ? + $lang->truncate( $nt->getText(), $this->getCaptionLength() ) : + $nt->getText() + ), + [ + 'class' => 'galleryfilename' . + ( $this->getCaptionLength() === true ? ' galleryfilename-truncate' : '' ) + ] + ) . "\n"; + } + /** * Add the wrapper html around the thumb's caption * @@ -272,6 +285,17 @@ class TraditionalImageGallery extends ImageGalleryBase { return 8; } + /** + * Length to truncate filename to in caption when using "showfilename" (if int). + * A value of 'true' will truncate the filename to one line using CSS, while + * 'false' will disable truncating. + * + * @return int|bool + */ + protected function getCaptionLength() { + return $this->mCaptionLength; + } + /** * Get total padding. * @@ -319,7 +343,7 @@ class TraditionalImageGallery extends ImageGalleryBase { } /** - * Width of gallerybox
  • . + * Computed width of gallerybox
  • . * * Generally is the width of the image, plus padding on image * plus padding on gallerybox. @@ -332,6 +356,21 @@ class TraditionalImageGallery extends ImageGalleryBase { return $this->mWidths + $this->getThumbPadding() + $this->getGBPadding(); } + /** + * Allows overwriting the computed width of the gallerybox
  • with a string, + * like '100%'. + * + * Generally is the width of the image, plus padding on image + * plus padding on gallerybox. + * + * @note Important: parameter will be false if no thumb used. + * @param MediaTransformOutput|bool $thumb MediaTransformObject object or false. + * @return bool|string Ignored if false. + */ + protected function getGBWidthOverwrite( $thumb ) { + return false; + } + /** * Get a list of modules to include in the page. *