MediaWiki REL1_33
ImageGalleryBase Class Reference

Image gallery. More...

Inheritance diagram for ImageGalleryBase:
Collaboration diagram for ImageGalleryBase:

Public Member Functions

 __construct ( $mode='traditional', IContextSource $context=null)
 Create a new image gallery object.
 
 add ( $title, $html='', $alt='', $link='', $handlerOpts=[])
 Add an image to the gallery.
 
 count ()
 
 getContextTitle ()
 Get the contextual title, if applicable.
 
 getImages ()
 Returns the list of images this gallery contains.
 
 insert ( $title, $html='', $alt='', $link='', $handlerOpts=[])
 Add an image at the beginning of the gallery.
 
 isEmpty ()
 isEmpty() returns true if the gallery contains no images
 
 setAdditionalOptions ( $options)
 Allow setting additional options.
 
 setAttributes ( $attribs)
 Set arbitrary attributes to go on the HTML gallery output element.
 
 setCaption ( $caption)
 Set the caption (as plain text)
 
 setCaptionHtml ( $caption)
 Set the caption (as HTML)
 
 setContextTitle ( $title)
 Set the contextual title.
 
 setHeights ( $num)
 Set how high each image will be, in pixels.
 
 setHideBadImages ( $flag=true)
 Set bad image flag.
 
 setParser ( $parser)
 Register a parser object.
 
 setPerRow ( $num)
 Set how many images will be displayed per row.
 
 setShowBytes ( $f)
 Enable/Disable showing of the file size of an image in the gallery.
 
 setShowDimensions ( $f)
 Enable/Disable showing of the dimensions of an image in the gallery.
 
 setShowFilename ( $f)
 Enable/Disable showing of the filename of an image in the gallery.
 
 setWidths ( $num)
 Set how wide each image will be, in pixels.
 
 toHTML ()
 Display an html representation of the gallery.
 
- Public Member Functions inherited from ContextSource
 canUseWikiPage ()
 Check whether a WikiPage object can be get with getWikiPage().
 
 exportSession ()
 Export the resolved user IP, HTTP headers, user ID, and session ID.
 
 getConfig ()
 
 getContext ()
 Get the base IContextSource object.
 
 getLanguage ()
 
 getOutput ()
 
 getRequest ()
 
 getSkin ()
 
 getStats ()
 
 getTiming ()
 
 getTitle ()
 
 getUser ()
 
 getWikiPage ()
 Get the WikiPage object.
 
 msg ( $key)
 Get a Message object with context set Parameters are the same as wfMessage()
 
 setContext (IContextSource $context)
 

Static Public Member Functions

static factory ( $mode=false, IContextSource $context=null)
 Get a new image gallery.
 

Public Attributes

Parser $mParser
 Registered parser object for output callbacks.
 

Protected Member Functions

 getRenderLang ()
 Determines the correct language to be used for this image gallery.
 

Protected Attributes

Title $contextTitle = false
 Contextual title, used when images are being screened against the bad image list.
 
array $mAttribs = []
 
bool string $mCaption = false
 Gallery caption.
 
bool int $mCaptionLength = true
 Length to truncate filename to in caption when using "showfilename".
 
bool $mHideBadImages
 Hide blacklisted images?
 
array $mImages
 Gallery images.
 
string $mMode
 Gallery mode.
 
bool $mShowBytes
 Whether to show the filesize in bytes in categories.
 
bool $mShowDimensions
 Whether to show the dimensions in categories.
 
bool $mShowFilename
 Whether to show the filename.
 

Static Private Member Functions

static loadModes ()
 

Static Private Attributes

static bool $modeMapping = false
 

Detailed Description

Image gallery.

Add images to the gallery using add(), then render that list to HTML using toHTML().

Definition at line 32 of file ImageGalleryBase.php.

Constructor & Destructor Documentation

◆ __construct()

ImageGalleryBase::__construct ( $mode = 'traditional',
IContextSource $context = null )

Create a new image gallery object.

You should not call this directly, but instead use ImageGalleryBase::factory().

Parameters
string$mode
IContextSource | null$context

Reimplemented in PackedImageGallery, and SlideshowImageGallery.

Definition at line 146 of file ImageGalleryBase.php.

References ContextSource\$context, ContextSource\getConfig(), and ContextSource\setContext().

Member Function Documentation

◆ add()

ImageGalleryBase::add ( $title,
$html = '',
$alt = '',
$link = '',
$handlerOpts = [] )

Add an image to the gallery.

Parameters
Title$titleTitle object of the image that is added to the gallery
string$htmlAdditional HTML text to be shown. The name and size of the image are always shown.
string$altAlt text for the image
string$linkOverride image link (optional)
array$handlerOptsArray of options for image handler (aka page number)

Definition at line 263 of file ImageGalleryBase.php.

References $html, $link, $title, and(), and wfDebug().

◆ count()

ImageGalleryBase::count ( )
Returns
int Number of images in the gallery

Definition at line 359 of file ImageGalleryBase.php.

References count().

Referenced by count().

◆ factory()

static ImageGalleryBase::factory ( $mode = false,
IContextSource $context = null )
static

Get a new image gallery.

This is the method other callers should use to get a gallery.

Parameters
string | bool$modeMode to use. False to use the default
IContextSource | null$context
Returns
ImageGalleryBase
Exceptions
MWException

Definition at line 103 of file ImageGalleryBase.php.

References ContextSource\$context, and(), IContextSource\getConfig(), and loadModes().

Referenced by CategoryViewer\clearCategoryState(), SpecialUpload\getDupeWarning(), NewFilesPager\getStartBody(), ImageQueryPage\outputResults(), and Parser\renderImageGallery().

◆ getContextTitle()

ImageGalleryBase::getContextTitle ( )

Get the contextual title, if applicable.

Returns
Title|bool Title or false

Definition at line 377 of file ImageGalleryBase.php.

References and().

◆ getImages()

ImageGalleryBase::getImages ( )

Returns the list of images this gallery contains.

Returns
array

Definition at line 294 of file ImageGalleryBase.php.

References $mImages.

◆ getRenderLang()

ImageGalleryBase::getRenderLang ( )
protected

Determines the correct language to be used for this image gallery.

Returns
Language

Definition at line 387 of file ImageGalleryBase.php.

References ContextSource\getLanguage().

Referenced by TraditionalImageGallery\toHTML().

◆ insert()

ImageGalleryBase::insert ( $title,
$html = '',
$alt = '',
$link = '',
$handlerOpts = [] )

Add an image at the beginning of the gallery.

Parameters
Title$titleTitle object of the image that is added to the gallery
string$htmlAdditional HTML text to be shown. The name and size of the image are always shown.
string$altAlt text for the image
string$linkOverride image link (optional)
array$handlerOptsArray of options for image handler (aka page number)

Definition at line 282 of file ImageGalleryBase.php.

References $html, $link, and and().

◆ isEmpty()

ImageGalleryBase::isEmpty ( )

isEmpty() returns true if the gallery contains no images

Returns
bool

Definition at line 302 of file ImageGalleryBase.php.

◆ loadModes()

static ImageGalleryBase::loadModes ( )
staticprivate

Definition at line 123 of file ImageGalleryBase.php.

Referenced by factory().

◆ setAdditionalOptions()

ImageGalleryBase::setAdditionalOptions ( $options)

Allow setting additional options.

This is meant to allow extensions to add additional parameters to <gallery> parser tag.

Parameters
array$optionsAttributes of gallery tag

Reimplemented in SlideshowImageGallery.

Definition at line 250 of file ImageGalleryBase.php.

◆ setAttributes()

ImageGalleryBase::setAttributes ( $attribs)

Set arbitrary attributes to go on the HTML gallery output element.

Should be suitable for a

.

Note – if taking from user input, you should probably run through Sanitizer::validateAttributes() first.

Parameters
array$attribsArray of HTML attribute pairs

Definition at line 345 of file ImageGalleryBase.php.

References $attribs.

◆ setCaption()

ImageGalleryBase::setCaption ( $caption)

Set the caption (as plain text)

Parameters
string$caption

Definition at line 192 of file ImageGalleryBase.php.

References and().

◆ setCaptionHtml()

ImageGalleryBase::setCaptionHtml ( $caption)

Set the caption (as HTML)

Parameters
string$caption

Definition at line 201 of file ImageGalleryBase.php.

References and().

◆ setContextTitle()

ImageGalleryBase::setContextTitle ( $title)

Set the contextual title.

Parameters
Title$titleContextual title

Definition at line 368 of file ImageGalleryBase.php.

References $title.

◆ setHeights()

ImageGalleryBase::setHeights ( $num)

Set how high each image will be, in pixels.

Parameters
string$numNumber. Unit other than 'px is invalid. Invalid numbers and those below 0 are ignored.

Definition at line 236 of file ImageGalleryBase.php.

References and().

◆ setHideBadImages()

ImageGalleryBase::setHideBadImages ( $flag = true)

Set bad image flag.

Parameters
bool$flag

Definition at line 183 of file ImageGalleryBase.php.

References and().

◆ setParser()

ImageGalleryBase::setParser ( $parser)

Register a parser object.

If you do not set this and the output of this gallery ends up in parser cache, the javascript will break!

Note
This also triggers using the page's target language instead of the user language.
Parameters
Parser$parser

Definition at line 175 of file ImageGalleryBase.php.

References $parser.

◆ setPerRow()

ImageGalleryBase::setPerRow ( $num)

Set how many images will be displayed per row.

Parameters
int$numInteger >= 0; If perrow=0 the gallery layout will adapt to screensize invalid numbers will be rejected

Reimplemented in PackedImageGallery.

Definition at line 211 of file ImageGalleryBase.php.

References and().

◆ setShowBytes()

ImageGalleryBase::setShowBytes ( $f)

Enable/Disable showing of the file size of an image in the gallery.

Enabled by default.

Parameters
bool$fSet to false to disable

Definition at line 322 of file ImageGalleryBase.php.

References $f, and and().

◆ setShowDimensions()

ImageGalleryBase::setShowDimensions ( $f)

Enable/Disable showing of the dimensions of an image in the gallery.

Enabled by default.

Parameters
bool$fSet to false to disable

Definition at line 312 of file ImageGalleryBase.php.

References $f, and and().

◆ setShowFilename()

ImageGalleryBase::setShowFilename ( $f)

Enable/Disable showing of the filename of an image in the gallery.

Enabled by default.

Parameters
bool$fSet to false to disable

Definition at line 332 of file ImageGalleryBase.php.

References $f, and and().

◆ setWidths()

ImageGalleryBase::setWidths ( $num)

Set how wide each image will be, in pixels.

Parameters
string$numNumber. Unit other than 'px is invalid. Invalid numbers and those below 0 are ignored.

Definition at line 223 of file ImageGalleryBase.php.

References and().

◆ toHTML()

ImageGalleryBase::toHTML ( )
abstract

Display an html representation of the gallery.

Returns
string The html

Reimplemented in TraditionalImageGallery.

Member Data Documentation

◆ $contextTitle

Title ImageGalleryBase::$contextTitle = false
protected

Contextual title, used when images are being screened against the bad image list.

Definition at line 86 of file ImageGalleryBase.php.

◆ $mAttribs

array ImageGalleryBase::$mAttribs = []
protected

Definition at line 89 of file ImageGalleryBase.php.

◆ $mCaption

bool string ImageGalleryBase::$mCaption = false
protected

Gallery caption.

Default: false

Definition at line 61 of file ImageGalleryBase.php.

◆ $mCaptionLength

bool int ImageGalleryBase::$mCaptionLength = true
protected

Length to truncate filename to in caption when using "showfilename".

A value of 'true' will truncate the filename to one line using CSS and will be the behaviour after deprecation.

Definition at line 70 of file ImageGalleryBase.php.

Referenced by TraditionalImageGallery\getCaptionLength().

◆ $mHideBadImages

bool ImageGalleryBase::$mHideBadImages
protected

Hide blacklisted images?

Definition at line 75 of file ImageGalleryBase.php.

◆ $mImages

array ImageGalleryBase::$mImages
protected

Gallery images.

Definition at line 36 of file ImageGalleryBase.php.

Referenced by getImages().

◆ $mMode

string ImageGalleryBase::$mMode
protected

Gallery mode.

Default: traditional

Definition at line 56 of file ImageGalleryBase.php.

◆ $modeMapping

bool ImageGalleryBase::$modeMapping = false
staticprivate

Definition at line 92 of file ImageGalleryBase.php.

◆ $mParser

Parser ImageGalleryBase::$mParser

Registered parser object for output callbacks.

Definition at line 80 of file ImageGalleryBase.php.

◆ $mShowBytes

bool ImageGalleryBase::$mShowBytes
protected

Whether to show the filesize in bytes in categories.

Definition at line 41 of file ImageGalleryBase.php.

◆ $mShowDimensions

bool ImageGalleryBase::$mShowDimensions
protected

Whether to show the dimensions in categories.

Definition at line 46 of file ImageGalleryBase.php.

◆ $mShowFilename

bool ImageGalleryBase::$mShowFilename
protected

Whether to show the filename.

Default: true

Definition at line 51 of file ImageGalleryBase.php.


The documentation for this class was generated from the following file: