From: Marius Hoch Date: Tue, 24 Apr 2018 15:52:56 +0000 (+0200) Subject: TraditionalImageGallery factor getCaptionHtml into own function X-Git-Tag: 1.34.0-rc.0~5613^2 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin//%22%24path/%7B%24disabledImages%5B%24type%5D%7D/%22?a=commitdiff_plain;h=a547b22fce40bacb64a6de14d58ea00b0bf88d36;p=lhc%2Fweb%2Fwiklou.git TraditionalImageGallery factor getCaptionHtml into own function Better design and also want to override this in Wikibase. Bug: T192869 Change-Id: I24de654ba9a14b8fe0925007e6ceeabca277c075 --- diff --git a/includes/gallery/TraditionalImageGallery.php b/includes/gallery/TraditionalImageGallery.php index 1cb7e6d24a..cd6aab0f88 100644 --- a/includes/gallery/TraditionalImageGallery.php +++ b/includes/gallery/TraditionalImageGallery.php @@ -191,19 +191,7 @@ class TraditionalImageGallery extends ImageGalleryBase { } $textlink = $this->mShowFilename ? - // Preloaded into LinkCache above - Linker::linkKnown( - $nt, - htmlspecialchars( - is_int( $this->getCaptionLength() ) ? - $lang->truncate( $nt->getText(), $this->getCaptionLength() ) : - $nt->getText() - ), - [ - 'class' => 'galleryfilename' . - ( $this->getCaptionLength() === true ? ' galleryfilename-truncate' : '' ) - ] - ) . "\n" : + $this->getCaptionHtml( $nt, $lang ) : ''; $galleryText = $textlink . $text . $meta; @@ -227,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 *