From a547b22fce40bacb64a6de14d58ea00b0bf88d36 Mon Sep 17 00:00:00 2001 From: Marius Hoch Date: Tue, 24 Apr 2018 17:52:56 +0200 Subject: [PATCH] TraditionalImageGallery factor getCaptionHtml into own function Better design and also want to override this in Wikibase. Bug: T192869 Change-Id: I24de654ba9a14b8fe0925007e6ceeabca277c075 --- includes/gallery/TraditionalImageGallery.php | 35 ++++++++++++-------- 1 file changed, 22 insertions(+), 13 deletions(-) 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 * -- 2.20.1