109 $mode = $galleryOptions[
'mode'];
114 if ( isset( self::$modeMapping[$mode] ) ) {
115 $class = self::$modeMapping[$mode];
116 return new $class( $mode,
$context );
118 throw new MWException(
"No gallery class registered for mode $mode" );
123 if ( self::$modeMapping ===
false ) {
124 self::$modeMapping = [
125 'traditional' => TraditionalImageGallery::class,
126 'nolines' => NolinesImageGallery::class,
127 'packed' => PackedImageGallery::class,
128 'packed-hover' => PackedHoverImageGallery::class,
129 'packed-overlay' => PackedOverlayImageGallery::class,
130 'slideshow' => SlideshowImageGallery::class,
133 Hooks::run(
'GalleryGetModes', [ &self::$modeMapping ] );
150 $galleryOptions = $this->
getConfig()->get(
'GalleryOptions' );
152 $this->mShowBytes = $galleryOptions[
'showBytes'];
153 $this->mShowDimensions = $galleryOptions[
'showDimensions'];
154 $this->mShowFilename =
true;
155 $this->mParser =
false;
156 $this->mHideBadImages =
false;
157 $this->mPerRow = $galleryOptions[
'imagesPerRow'];
158 $this->mWidths = $galleryOptions[
'imageWidth'];
159 $this->mHeights = $galleryOptions[
'imageHeight'];
160 $this->mCaptionLength = $galleryOptions[
'captionLength'];
161 $this->mMode = $mode;
183 $this->mHideBadImages = $flag;
192 $this->mCaption = htmlspecialchars( $caption );
201 $this->mCaption = $caption;
212 $this->mPerRow = (int)$num;
223 $parsed = Parser::parseWidthParam( $num,
false );
224 if ( isset( $parsed[
'width'] ) && $parsed[
'width'] > 0 ) {
225 $this->mWidths = $parsed[
'width'];
236 $parsed = Parser::parseWidthParam( $num,
false );
237 if ( isset( $parsed[
'width'] ) && $parsed[
'width'] > 0 ) {
238 $this->mHeights = $parsed[
'width'];
262 function add( $title,
$html =
'', $alt =
'',
$link =
'', $handlerOpts = [] ) {
263 if ( $title instanceof
File ) {
265 $title = $title->getTitle();
268 wfDebug(
'ImageGallery::add ' . $title->getText() .
"\n" );
282 if ( $title instanceof
File ) {
284 $title = $title->getTitle();
286 array_unshift( $this->mImages, [ &$title,
$html, $alt,
$link, $handlerOpts ] );
302 return empty( $this->mImages );
312 $this->mShowDimensions = (bool)$f;
322 $this->mShowBytes = (bool)$f;
332 $this->mShowFilename = (bool)$f;
359 return count( $this->mImages );
368 $this->contextTitle =
$title;
377 return is_object( $this->contextTitle ) && $this->contextTitle instanceof
Title
378 ? $this->contextTitle
387 return $this->mParser
388 ? $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.
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.
Parser $mParser
Registered parser object for output callbacks.
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.
Title $contextTitle
Contextual title, used when images are being screened against the bad image list.
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...
static getMainAndWarn( $func=__METHOD__)
Get the RequestContext object associated with the main request and gives a warning to the log,...
Represents a title within MediaWiki.
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the local content language as $wgContLang
do that in ParserLimitReportFormat instead $parser
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
namespace and then decline to actually register it file or subcat img or subcat $title
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses & $html
usually copyright or history_copyright This message must be in HTML not wikitext & $link
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing & $attribs
Interface for objects which can provide a MediaWiki context on request.
getConfig()
Get the site configuration.