diff options
Diffstat (limited to 'includes/ImageGallery.php')
-rw-r--r-- | includes/ImageGallery.php | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/includes/ImageGallery.php b/includes/ImageGallery.php index 91c3190f..1556ad94 100644 --- a/includes/ImageGallery.php +++ b/includes/ImageGallery.php @@ -93,7 +93,7 @@ class ImageGallery { /** * Set the caption (as plain text) * - * @param $caption string Caption + * @param string $caption Caption */ function setCaption( $caption ) { $this->mCaption = htmlspecialchars( $caption ); @@ -102,7 +102,7 @@ class ImageGallery { /** * Set the caption (as HTML) * - * @param $caption String: Caption + * @param string $caption Caption */ public function setCaptionHtml( $caption ) { $this->mCaption = $caption; @@ -161,7 +161,7 @@ class ImageGallery { * @param $alt String: Alt text for the image * @param $link String: Override image link (optional) */ - function add( $title, $html = '', $alt = '', $link = '') { + function add( $title, $html = '', $alt = '', $link = '' ) { if ( $title instanceof File ) { // Old calling convention $title = $title->getTitle(); @@ -220,7 +220,7 @@ class ImageGallery { * Note -- if taking from user input, you should probably run through * Sanitizer::validateAttributes() first. * - * @param $attribs Array of HTML attribute pairs + * @param array $attribs of HTML attribute pairs */ function setAttributes( $attribs ) { $this->mAttribs = $attribs; @@ -238,8 +238,6 @@ class ImageGallery { * @return string */ function toHTML() { - global $wgLang; - if ( $this->mPerRow > 0 ) { $maxwidth = $this->mPerRow * ( $this->mWidths + self::THUMB_PADDING + self::GB_PADDING + self::GB_BORDERS ); $oldStyle = isset( $this->mAttribs['style'] ) ? $this->mAttribs['style'] : ''; @@ -255,6 +253,7 @@ class ImageGallery { $output .= "\n\t<li class='gallerycaption'>{$this->mCaption}</li>"; } + $lang = $this->getLang(); $params = array( 'width' => $this->mWidths, 'height' => $this->mHeights @@ -337,7 +336,7 @@ class ImageGallery { if( $this->mShowBytes ) { if( $img ) { - $fileSize = htmlspecialchars( $wgLang->formatSize( $img->getSize() ) ); + $fileSize = htmlspecialchars( $lang->formatSize( $img->getSize() ) ); } else { $fileSize = wfMessage( 'filemissing' )->escaped(); } @@ -349,19 +348,19 @@ class ImageGallery { $textlink = $this->mShowFilename ? Linker::link( $nt, - htmlspecialchars( $wgLang->truncate( $nt->getText(), $this->mCaptionLength ) ), + htmlspecialchars( $lang->truncate( $nt->getText(), $this->mCaptionLength ) ), array(), array(), array( 'known', 'noclasses' ) ) . "<br />\n" : - '' ; + ''; # ATTENTION: The newline after <div class="gallerytext"> 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 # Weird double wrapping (the extra div inside the li) needed due to FF2 bug - # Can be safely removed if FF2 falls completely out of existance + # Can be safely removed if FF2 falls completely out of existence $output .= "\n\t\t" . '<li class="gallerybox" style="width: ' . ( $this->mWidths + self::THUMB_PADDING + self::GB_PADDING ) . 'px">' . '<div style="width: ' . ( $this->mWidths + self::THUMB_PADDING + self::GB_PADDING ) . 'px">' @@ -403,4 +402,15 @@ class ImageGallery { : false; } + /** + * Determines the correct language to be used for this image gallery + * @return Language object + */ + private function getLang() { + global $wgLang; + return $this->mParser + ? $this->mParser->getTargetLanguage() + : $wgLang; + } + } //class |