X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FImageGallery.php;h=4d5f067ca7dcd23bfab19f5d4cccfbfa1b37b7ad;hb=48bbe8b848fd7021a0d32729b9c8c77038762fa1;hp=7d161e0fbeb18a91599227c568af90bca020f9f6;hpb=1030cb25fd392928d165f4c6ec8588029a64851d;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/ImageGallery.php b/includes/ImageGallery.php index 7d161e0fbe..4d5f067ca7 100644 --- a/includes/ImageGallery.php +++ b/includes/ImageGallery.php @@ -9,12 +9,9 @@ if ( ! defined( 'MEDIAWIKI' ) ) * * @ingroup Media */ -class ImageGallery -{ +class ImageGallery { var $mImages, $mShowBytes, $mShowFilename; var $mCaption = false; - var $mSkin = false; - var $mRevisionId = 0; /** * Hide blacklisted images? @@ -23,6 +20,7 @@ class ImageGallery /** * Registered parser object for output callbacks + * @var Parser */ var $mParser; @@ -34,10 +32,18 @@ class ImageGallery private $mAttribs = array(); + /** + * Fixed margins + */ + const THUMB_PADDING = 30; + const GB_PADDING = 5; + // 2px borders on each side + 2px implied padding on each side + const GB_BORDERS = 8; + /** * Create a new image gallery object. */ - function __construct( ) { + function __construct() { global $wgGalleryOptions; $this->mImages = array(); $this->mShowBytes = $wgGalleryOptions['showBytes']; @@ -52,6 +58,8 @@ class ImageGallery /** * Register a parser object + * + * @param $parser Parser */ function setParser( $parser ) { $this->mParser = $parser; @@ -89,7 +97,7 @@ class ImageGallery * invalid numbers will be rejected */ public function setPerRow( $num ) { - if ($num >= 0) { + if ( $num >= 0 ) { $this->mPerRow = (int)$num; } } @@ -100,7 +108,7 @@ class ImageGallery * @param $num Integer > 0; invalid numbers will be ignored */ public function setWidths( $num ) { - if ($num > 0) { + if ( $num > 0 ) { $this->mWidths = (int)$num; } } @@ -111,7 +119,7 @@ class ImageGallery * @param $num Integer > 0; invalid numbers will be ignored */ public function setHeights( $num ) { - if ($num > 0) { + if ( $num > 0 ) { $this->mHeights = (int)$num; } } @@ -120,56 +128,44 @@ class ImageGallery * Instruct the class to use a specific skin for rendering * * @param $skin Skin object + * @deprecated since 1.18 Not used anymore */ function useSkin( $skin ) { - $this->mSkin = $skin; - } - - /** - * Return the skin that should be used - * - * @return Skin object - */ - function getSkin() { - if( !$this->mSkin ) { - global $wgUser; - $skin = $wgUser->getSkin(); - } else { - $skin = $this->mSkin; - } - return $skin; + wfDeprecated( __METHOD__ ); + /* no op */ } /** * Add an image to the gallery. * * @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 $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 */ - function add( $title, $html='' ) { + function add( $title, $html = '', $alt = '' ) { if ( $title instanceof File ) { // Old calling convention $title = $title->getTitle(); } - $this->mImages[] = array( $title, $html ); - wfDebug( "ImageGallery::add " . $title->getText() . "\n" ); + $this->mImages[] = array( $title, $html, $alt ); + wfDebug( 'ImageGallery::add ' . $title->getText() . "\n" ); } /** * Add an image at the beginning of the gallery. * * @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 $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 */ - function insert( $title, $html='' ) { + function insert( $title, $html = '', $alt = '' ) { if ( $title instanceof File ) { // Old calling convention $title = $title->getTitle(); } - array_unshift( $this->mImages, array( &$title, $html ) ); + array_unshift( $this->mImages, array( &$title, $html, $alt ) ); } - /** * isEmpty() returns true if the gallery contains no images */ @@ -223,46 +219,56 @@ class ImageGallery function toHTML() { global $wgLang; - $sk = $this->getSkin(); - if ( $this->mPerRow > 0 ) { - $maxwidth = $this->mPerRow * ( $this->mWidths + 50 ); - $this->mAttribs['style'] = "max-width: {$maxwidth}px;_width: {$maxwidth}px;"; + $maxwidth = $this->mPerRow * ( $this->mWidths + self::THUMB_PADDING + self::GB_PADDING + self::GB_BORDERS ); + $oldStyle = isset( $this->mAttribs['style'] ) ? $this->mAttribs['style'] : ''; + # _width is ignored by any sane browser. IE6 doesn't know max-width so it uses _width instead + $this->mAttribs['style'] = "max-width: {$maxwidth}px;_width: {$maxwidth}px;" . $oldStyle; } $attribs = Sanitizer::mergeAttributes( - array( - 'class' => 'gallery'), - $this->mAttribs ); - $s = Xml::openElement( 'ul', $attribs ); + array( 'class' => 'gallery' ), $this->mAttribs ); + + $output = Xml::openElement( 'ul', $attribs ); if ( $this->mCaption ) { - $s .= "\n\t