115 $context = RequestContext::getMainAndWarn( __METHOD__ );
118 $galleryOptions =
$context->getConfig()->get(
'GalleryOptions' );
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;
233 $parsed = Parser::parseWidthParam( $num,
false );
234 if ( isset( $parsed[
'width'] ) && $parsed[
'width'] > 0 ) {
235 $this->mWidths = $parsed[
'width'];
246 $parsed = Parser::parseWidthParam( $num,
false );
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 ] );
304 return $this->mImages;
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;
387 return $this->contextTitle;
395 return $this->mParser
396 ? $this->mParser->getTargetLanguage()
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
setContext(IContextSource $context)
Implements some public methods and some protected utility functions which are required by multiple ch...
setShowDimensions( $f)
Enable/Disable showing of the dimensions of an image in the gallery.
bool string $mCaption
Gallery caption.
Parser false $mParser
Registered parser object for output callbacks.
setHeights( $num)
Set how high each image will be, in pixels.
bool $mShowDimensions
Whether to show the dimensions in categories.
__construct( $mode='traditional', IContextSource $context=null)
Create a new image gallery object.
isEmpty()
isEmpty() returns true if the gallery contains no images
setAttributes( $attribs)
Set arbitrary attributes to go on the HTML gallery output element.
bool $mHideBadImages
Hide blacklisted images?
setCaption( $caption)
Set the caption (as plain text)
setHideBadImages( $flag=true)
Set bad image flag.
static array $modeMapping
Title null $contextTitle
Contextual title, used when images are being screened against the bad image list.
setCaptionHtml( $caption)
Set the caption (as HTML)
bool int $mCaptionLength
Length to truncate filename to in caption when using "showfilename".
getContextTitle()
Get the contextual title, if applicable.
string $mMode
Gallery mode.
setAdditionalOptions( $options)
Allow setting additional options.
setPerRow( $num)
Set how many images will be displayed per row.
insert( $title, $html='', $alt='', $link='', $handlerOpts=[])
Add an image at the beginning of the gallery.
setContextTitle( $title)
Set the contextual title.
bool $mShowFilename
Whether to show the filename.
setParser( $parser)
Register a parser object.
static factory( $mode=false, IContextSource $context=null)
Get a new image gallery.
bool $mShowBytes
Whether to show the filesize in bytes in categories.
toHTML()
Display an html representation of the gallery.
setShowBytes( $f)
Enable/Disable showing of the file size of an image in the gallery.
getRenderLang()
Determines the correct language to be used for this image gallery.
setWidths( $num)
Set how wide each image will be, in pixels.
getImages()
Returns the list of images this gallery contains.
setShowFilename( $f)
Enable/Disable showing of the filename of an image in the gallery.
array $mImages
Gallery images.
add( $title, $html='', $alt='', $link='', $handlerOpts=[])
Add an image to the gallery.
PHP Parser - Processes wiki markup (which uses a more user-friendly syntax, such as "[[link]]" for ma...
Represents a title within MediaWiki.
Interface for objects which can provide a MediaWiki context on request.