/**
* Set the caption (as plain text)
*
- * @param $caption string Caption
+ * @param string $caption Caption
*/
function setCaption( $caption ) {
$this->mCaption = htmlspecialchars( $caption );
/**
* Set the caption (as HTML)
*
- * @param $caption String: Caption
+ * @param string $caption Caption
*/
public function setCaptionHtml( $caption ) {
$this->mCaption = $caption;
* @param $html String: Additional HTML text to be shown. The name and size of the image are always shown.
* @param $alt String: Alt text for the image
* @param $link String: Override image link (optional)
+ * @param $handlerOpts Array: Array of options for image handler (aka page number)
*/
- function add( $title, $html = '', $alt = '', $link = '' ) {
+ function add( $title, $html = '', $alt = '', $link = '', $handlerOpts = array() ) {
if ( $title instanceof File ) {
// Old calling convention
$title = $title->getTitle();
}
- $this->mImages[] = array( $title, $html, $alt, $link );
+ $this->mImages[] = array( $title, $html, $alt, $link, $handlerOpts );
wfDebug( 'ImageGallery::add ' . $title->getText() . "\n" );
}
* @param $title Title object of the image that is added to the gallery
* @param $html String: Additional HTML text to be shown. The name and size of the image are always shown.
* @param $alt String: Alt text for the image
+ * @param $link String: Override image link (optional)
+ * @param $handlerOpts Array: Array of options for image handler (aka page number)
*/
- function insert( $title, $html = '', $alt = '' ) {
+ function insert( $title, $html = '', $alt = '', $link = '', $handlerOpts = array() ) {
if ( $title instanceof File ) {
// Old calling convention
$title = $title->getTitle();
}
- array_unshift( $this->mImages, array( &$title, $html, $alt ) );
+ array_unshift( $this->mImages, array( &$title, $html, $alt, $link, $handlerOpts ) );
}
/**
* 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;
* @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'] : '';
$output .= "\n\t<li class='gallerycaption'>{$this->mCaption}</li>";
}
+ $lang = $this->getLang();
$params = array(
'width' => $this->mWidths,
'height' => $this->mHeights
$text = $pair[1]; # "text" means "caption" here
$alt = $pair[2];
$link = $pair[3];
+ // $pair[4] is per image handler options
+ $transformOptions = $params + $pair[4];
$descQuery = false;
if ( $nt->getNamespace() == NS_FILE ) {
$img = false;
}
- if( !$img ) {
+ if ( !$img ) {
# We're dealing with a non-image, spit out the name and be done with it.
$thumbhtml = "\n\t\t\t" . '<div style="height: ' . ( self::THUMB_PADDING + $this->mHeights ) . 'px;">'
. htmlspecialchars( $nt->getText() ) . '</div>';
- } elseif( $this->mHideBadImages && wfIsBadImage( $nt->getDBkey(), $this->getContextTitle() ) ) {
+
+ if ( $this->mParser instanceof Parser ) {
+ $this->mParser->addTrackingCategory( 'broken-file-category' );
+ }
+ } elseif ( $this->mHideBadImages && wfIsBadImage( $nt->getDBkey(), $this->getContextTitle() ) ) {
# The image is blacklisted, just show it as a text link.
$thumbhtml = "\n\t\t\t" . '<div style="height: ' . ( self::THUMB_PADDING + $this->mHeights ) . 'px;">' .
Linker::link(
array( 'known', 'noclasses' )
) .
'</div>';
- } elseif( !( $thumb = $img->transform( $params ) ) ) {
+ } elseif ( !( $thumb = $img->transform( $transformOptions ) ) ) {
# Error generating thumbnail.
$thumbhtml = "\n\t\t\t" . '<div style="height: ' . ( self::THUMB_PADDING + $this->mHeights ) . 'px;">'
. htmlspecialchars( $img->getLastError() ) . '</div>';
} else {
- $vpad = ( self::THUMB_PADDING + $this->mHeights - $thumb->height ) /2;
+ $vpad = ( self::THUMB_PADDING + $this->mHeights - $thumb->height ) / 2;
$imageParameters = array(
'desc-link' => true,
// $linkTarget = Title::newFromText( $wgContLang->getNsText( MWNamespace::getUser() ) . ":{$ut}" );
// $ul = Linker::link( $linkTarget, $ut );
- if( $this->mShowBytes ) {
- if( $img ) {
- $fileSize = htmlspecialchars( $wgLang->formatSize( $img->getSize() ) );
+ if ( $this->mShowBytes ) {
+ if ( $img ) {
+ $fileSize = htmlspecialchars( $lang->formatSize( $img->getSize() ) );
} else {
$fileSize = wfMessage( 'filemissing' )->escaped();
}
$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' )
# 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">'
: 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