Go to the documentation of this file.
119 $mode = $galleryOptions[
'mode'];
122 $mode = MediaWikiServices::getInstance()->getContentLanguage()->lc( $mode );
124 if ( isset( self::$modeMapping[$mode] ) ) {
125 $class = self::$modeMapping[$mode];
126 return new $class( $mode,
$context );
128 throw new MWException(
"No gallery class registered for mode $mode" );
133 if ( self::$modeMapping ===
null ) {
134 self::$modeMapping = [
135 'traditional' => TraditionalImageGallery::class,
136 'nolines' => NolinesImageGallery::class,
137 'packed' => PackedImageGallery::class,
138 'packed-hover' => PackedHoverImageGallery::class,
139 'packed-overlay' => PackedOverlayImageGallery::class,
140 'slideshow' => SlideshowImageGallery::class,
143 Hooks::run(
'GalleryGetModes', [ &self::$modeMapping ] );
160 $galleryOptions = $this->
getConfig()->get(
'GalleryOptions' );
162 $this->mShowBytes = $galleryOptions[
'showBytes'];
163 $this->mShowDimensions = $galleryOptions[
'showDimensions'];
164 $this->mShowFilename =
true;
165 $this->mParser =
false;
166 $this->mHideBadImages =
false;
167 $this->mPerRow = $galleryOptions[
'imagesPerRow'];
168 $this->mWidths = $galleryOptions[
'imageWidth'];
169 $this->mHeights = $galleryOptions[
'imageHeight'];
170 $this->mCaptionLength = $galleryOptions[
'captionLength'];
171 $this->mMode = $mode;
185 $this->mParser = $parser;
193 $this->mHideBadImages = $flag;
202 $this->mCaption = htmlspecialchars( $caption );
211 $this->mCaption = $caption;
222 $this->mPerRow = (int)$num;
234 if ( isset( $parsed[
'width'] ) && $parsed[
'width'] > 0 ) {
235 $this->mWidths = $parsed[
'width'];
247 if ( isset( $parsed[
'width'] ) && $parsed[
'width'] > 0 ) {
248 $this->mHeights = $parsed[
'width'];
272 function add(
$title, $html =
'', $alt =
'', $link =
'', $handlerOpts = [] ) {
277 $this->mImages[] = [
$title, $html, $alt, $link, $handlerOpts ];
291 function insert(
$title, $html =
'', $alt =
'', $link =
'', $handlerOpts = [] ) {
296 array_unshift( $this->mImages, [ &
$title, $html, $alt, $link, $handlerOpts ] );
312 return empty( $this->mImages );
322 $this->mShowDimensions = (bool)$f;
332 $this->mShowBytes = (bool)$f;
342 $this->mShowFilename = (bool)$f;
355 $this->mAttribs = $attribs;
369 return count( $this->mImages );
378 $this->contextTitle =
$title;
395 return $this->mParser
396 ? $this->mParser->getTargetLanguage()
setShowBytes( $f)
Enable/Disable showing of the file size of an image in the gallery.
setParser( $parser)
Register a parser object.
bool $mShowDimensions
Whether to show the dimensions in categories.
setHeights( $num)
Set how high each image will be, in pixels.
static array $modeMapping
setContextTitle( $title)
Set the contextual title.
string $mMode
Gallery mode.
setWidths( $num)
Set how wide each image will be, in pixels.
setCaption( $caption)
Set the caption (as plain text)
getContextTitle()
Get the contextual title, if applicable.
setShowFilename( $f)
Enable/Disable showing of the filename of an image in the gallery.
insert( $title, $html='', $alt='', $link='', $handlerOpts=[])
Add an image at the beginning of the gallery.
bool string $mCaption
Gallery caption.
setAdditionalOptions( $options)
Allow setting additional options.
bool int $mCaptionLength
Length to truncate filename to in caption when using "showfilename".
add( $title, $html='', $alt='', $link='', $handlerOpts=[])
Add an image to the gallery.
setAttributes( $attribs)
Set arbitrary attributes to go on the HTML gallery output element.
Implements some public methods and some protected utility functions which are required by multiple ch...
setHideBadImages( $flag=true)
Set bad image flag.
setPerRow( $num)
Set how many images will be displayed per row.
bool $mShowFilename
Whether to show the filename.
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
static getMainAndWarn( $func=__METHOD__)
Get the RequestContext object associated with the main request and gives a warning to the log,...
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
setContext(IContextSource $context)
getImages()
Returns the list of images this gallery contains.
__construct( $mode='traditional', IContextSource $context=null)
Create a new image gallery object.
array $mImages
Gallery images.
Parser false $mParser
Registered parser object for output callbacks.
bool $mShowBytes
Whether to show the filesize in bytes in categories.
PHP Parser - Processes wiki markup (which uses a more user-friendly syntax, such as "[[link]]" for ma...
setCaptionHtml( $caption)
Set the caption (as HTML)
Interface for objects which can provide a MediaWiki context on request.
getRenderLang()
Determines the correct language to be used for this image gallery.
Represents a title within MediaWiki.
isEmpty()
isEmpty() returns true if the gallery contains no images
setShowDimensions( $f)
Enable/Disable showing of the dimensions of an image in the gallery.
getConfig()
Get the site configuration.
Title null $contextTitle
Contextual title, used when images are being screened against the bad image list.
static factory( $mode=false, IContextSource $context=null)
Get a new image gallery.
static parseWidthParam( $value, $parseHeight=true)
Parsed a width param of imagelink like 300px or 200x300px.
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
toHTML()
Display an html representation of the gallery.
bool $mHideBadImages
Hide blacklisted images?