X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FImageGallery.php;h=62f9eedb36c443ee5366293ab650b81ec6ca4c06;hb=44eefff24c088ded89ad02dab4516b94e8c3aca5;hp=19f1b5751a910b980a0643b018bfb92185ddcc58;hpb=95c00cce55d4661daf2c8e7ee838f78e1245e326;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/ImageGallery.php b/includes/ImageGallery.php index 19f1b5751a..62f9eedb36 100644 --- a/includes/ImageGallery.php +++ b/includes/ImageGallery.php @@ -2,15 +2,12 @@ if ( ! defined( 'MEDIAWIKI' ) ) die( 1 ); -/** - */ - /** * Image gallery * * Add images to the gallery using add(), then render that list to HTML using toHTML(). * - * @addtogroup Media + * @ingroup Media */ class ImageGallery { @@ -20,9 +17,14 @@ class ImageGallery var $mRevisionId = 0; /** - * Is the gallery on a wiki page (i.e. not a special page) + * Hide blacklisted images? + */ + var $mHideBadImages; + + /** + * Registered parser object for output callbacks */ - var $mParsing; + var $mParser; /** * Contextual title, used when images are being screened @@ -30,24 +32,36 @@ class ImageGallery */ private $contextTitle = false; - private $mPerRow = 4; // How many images wide should the gallery be? - private $mWidths = 120, $mHeights = 120; // How wide/tall each thumbnail should be + private $mAttribs = array(); /** * Create a new image gallery object. */ function __construct( ) { + global $wgGalleryOptions; $this->mImages = array(); - $this->mShowBytes = true; + $this->mShowBytes = $wgGalleryOptions['showBytes']; $this->mShowFilename = true; - $this->mParsing = false; + $this->mParser = false; + $this->mHideBadImages = false; + $this->mPerRow = $wgGalleryOptions['imagesPerRow']; + $this->mWidths = $wgGalleryOptions['imageWidth']; + $this->mHeights = $wgGalleryOptions['imageHeight']; + $this->mCaptionLength = $wgGalleryOptions['captionLength']; + } + + /** + * Register a parser object + */ + function setParser( $parser ) { + $this->mParser = $parser; } /** - * Set the "parse" bit so we know to hide "bad" images + * Set bad image flag */ - function setParsing( $val = true ) { - $this->mParsing = $val; + function setHideBadImages( $flag = true ) { + $this->mHideBadImages = $flag; } /** @@ -62,7 +76,7 @@ class ImageGallery /** * Set the caption (as HTML) * - * @param $caption Caption + * @param $caption String: Caption */ public function setCaptionHtml( $caption ) { $this->mCaption = $caption; @@ -71,10 +85,11 @@ class ImageGallery /** * Set how many images will be displayed per row. * - * @param int $num > 0; invalid numbers will be rejected + * @param $num Integer >= 0; If perrow=0 the gallery layout will adapt to screensize + * invalid numbers will be rejected */ public function setPerRow( $num ) { - if ($num > 0) { + if ($num >= 0) { $this->mPerRow = (int)$num; } } @@ -82,7 +97,7 @@ class ImageGallery /** * Set how wide each image will be, in pixels. * - * @param int $num > 0; invalid numbers will be ignored + * @param $num Integer > 0; invalid numbers will be ignored */ public function setWidths( $num ) { if ($num > 0) { @@ -93,7 +108,7 @@ class ImageGallery /** * Set how high each image will be, in pixels. * - * @param int $num > 0; invalid numbers will be ignored + * @param $num Integer > 0; invalid numbers will be ignored */ public function setHeights( $num ) { if ($num > 0) { @@ -129,7 +144,7 @@ class ImageGallery * 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. */ function add( $title, $html='' ) { if ( $title instanceof File ) { @@ -169,7 +184,7 @@ class ImageGallery * @param $f Boolean: set to false to disable. */ function setShowBytes( $f ) { - $this->mShowBytes = ( $f == true); + $this->mShowBytes = (bool)$f; } /** @@ -179,7 +194,20 @@ class ImageGallery * @param $f Boolean: set to false to disable. */ function setShowFilename( $f ) { - $this->mShowFilename = ( $f == true); + $this->mShowFilename = (bool)$f; + } + + /** + * Set arbitrary attributes to go on the HTML gallery output element. + * Should be suitable for a "; return $s; } /** - * @return int Number of images in the gallery + * @return Integer: number of images in the gallery */ public function count() { return count( $this->mImages ); } - + /** * Set the contextual title * - * @param Title $title Contextual title + * @param $title Title: contextual title */ public function setContextTitle( $title ) { $this->contextTitle = $title; } - + /** * Get the contextual title, if applicable * @@ -305,4 +377,3 @@ class ImageGallery } } //class -?>