TraditionalImageGallery factor getCaptionHtml into own function
authorMarius Hoch <hoo@online.de>
Tue, 24 Apr 2018 15:52:56 +0000 (17:52 +0200)
committerMarius Hoch <hoo@online.de>
Wed, 25 Apr 2018 11:23:20 +0000 (13:23 +0200)
Better design and also want to override this in Wikibase.

Bug: T192869
Change-Id: I24de654ba9a14b8fe0925007e6ceeabca277c075

includes/gallery/TraditionalImageGallery.php

index 1cb7e6d..cd6aab0 100644 (file)
@@ -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
         *