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

Static Public Member Functions

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

Public Attributes

Parser $mParser
 Registered parser object for output callbacks. More...
 

Protected Member Functions

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

Protected Attributes

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

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 30 of file ImageGalleryBase.php.

Constructor & Destructor Documentation

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

Definition at line 131 of file ImageGalleryBase.php.

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

Member Function Documentation

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 243 of file ImageGalleryBase.php.

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

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

Definition at line 329 of file ImageGalleryBase.php.

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 87 of file ImageGalleryBase.php.

References ContextSource\$context, $wgContLang, IContextSource\getConfig(), RequestContext\getMainAndWarn(), and global.

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

ImageGalleryBase::getContextTitle ( )

Get the contextual title, if applicable.

Returns
Title|bool Title or false

Definition at line 347 of file ImageGalleryBase.php.

Referenced by TraditionalImageGallery\toHTML().

ImageGalleryBase::getImages ( )

Returns the list of images this gallery contains.

Returns
array

Definition at line 274 of file ImageGalleryBase.php.

References $mImages.

ImageGalleryBase::getRenderLang ( )
protected

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

Returns
Language

Definition at line 357 of file ImageGalleryBase.php.

References ContextSource\getLanguage().

Referenced by TraditionalImageGallery\toHTML().

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 262 of file ImageGalleryBase.php.

References $html, $link, and $title.

ImageGalleryBase::isEmpty ( )

isEmpty() returns true if the gallery contains no images

Returns
bool

Definition at line 282 of file ImageGalleryBase.php.

static ImageGalleryBase::loadModes ( )
staticprivate

Definition at line 108 of file ImageGalleryBase.php.

References Hooks\run().

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

Definition at line 230 of file ImageGalleryBase.php.

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 315 of file ImageGalleryBase.php.

References $attribs.

ImageGalleryBase::setCaption (   $caption)

Set the caption (as plain text)

Parameters
string$captionCaption

Definition at line 176 of file ImageGalleryBase.php.

ImageGalleryBase::setCaptionHtml (   $caption)

Set the caption (as HTML)

Parameters
string$captionCaption

Definition at line 185 of file ImageGalleryBase.php.

ImageGalleryBase::setContextTitle (   $title)

Set the contextual title.

Parameters
Title$titleContextual title

Definition at line 338 of file ImageGalleryBase.php.

References $title.

ImageGalleryBase::setHeights (   $num)

Set how high each image will be, in pixels.

Parameters
int$numInteger > 0; invalid numbers will be ignored

Definition at line 217 of file ImageGalleryBase.php.

ImageGalleryBase::setHideBadImages (   $flag = true)

Set bad image flag.

Parameters
bool$flag

Definition at line 167 of file ImageGalleryBase.php.

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 159 of file ImageGalleryBase.php.

References $parser.

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

Definition at line 195 of file ImageGalleryBase.php.

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 292 of file ImageGalleryBase.php.

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 302 of file ImageGalleryBase.php.

ImageGalleryBase::setWidths (   $num)

Set how wide each image will be, in pixels.

Parameters
int$numInteger > 0; invalid numbers will be ignored

Definition at line 206 of file ImageGalleryBase.php.

ImageGalleryBase::toHTML ( )
abstract

Display an html representation of the gallery.

Returns
string The html

Member Data Documentation

Title ImageGalleryBase::$contextTitle = false
protected

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

Definition at line 70 of file ImageGalleryBase.php.

array ImageGalleryBase::$mAttribs = []
protected

Definition at line 73 of file ImageGalleryBase.php.

bool string ImageGalleryBase::$mCaption = false
protected

Gallery caption.

Default: false

Definition at line 54 of file ImageGalleryBase.php.

bool ImageGalleryBase::$mHideBadImages
protected

Hide blacklisted images?

Definition at line 59 of file ImageGalleryBase.php.

array ImageGalleryBase::$mImages
protected

Gallery images.

Definition at line 34 of file ImageGalleryBase.php.

Referenced by getImages().

string ImageGalleryBase::$mMode
protected

Gallery mode.

Default: traditional

Definition at line 49 of file ImageGalleryBase.php.

bool ImageGalleryBase::$modeMapping = false
staticprivate

Definition at line 76 of file ImageGalleryBase.php.

Parser ImageGalleryBase::$mParser

Registered parser object for output callbacks.

Definition at line 64 of file ImageGalleryBase.php.

bool ImageGalleryBase::$mShowBytes
protected

Whether to show the filesize in bytes in categories.

Definition at line 39 of file ImageGalleryBase.php.

bool ImageGalleryBase::$mShowFilename
protected

Whether to show the filename.

Default: true

Definition at line 44 of file ImageGalleryBase.php.


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