101 private static $modeMapping;
115 $context = RequestContext::getMainAndWarn( __METHOD__ );
119 $mode = $galleryOptions[
'mode'];
124 if ( isset( self::$modeMapping[$mode] ) ) {
125 $class = self::$modeMapping[$mode];
126 return new $class( $mode, $context );
132 private static function loadModes() {
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,
144 ->onGalleryGetModes( self::$modeMapping );
168 $this->mShowBytes = $galleryOptions[
'showBytes'];
169 $this->mShowDimensions = $galleryOptions[
'showDimensions'];
170 $this->mShowFilename =
true;
171 $this->mParser =
false;
172 $this->mHideBadImages =
false;
173 $this->mPerRow = $galleryOptions[
'imagesPerRow'];
174 $this->mWidths = $galleryOptions[
'imageWidth'];
175 $this->mHeights = $galleryOptions[
'imageHeight'];
176 $this->mCaptionLength = $galleryOptions[
'captionLength'];
177 $this->mMode = $mode;
191 $this->mParser = $parser;
198 $this->mHideBadImages = $flag;
207 $this->mCaption = htmlspecialchars( $caption );
216 $this->mCaption = $caption;
227 $this->mPerRow = (int)$num;
243 $parsed = $parser->parseWidthParam( $num,
false );
244 if ( isset( $parsed[
'width'] ) && $parsed[
'width'] > 0 ) {
245 $this->mWidths = $parsed[
'width'];
261 $parsed = $parser->parseWidthParam( $num,
false );
262 if ( isset( $parsed[
'width'] ) && $parsed[
'width'] > 0 ) {
263 $this->mHeights = $parsed[
'width'];
297 $loading = self::LOADING_DEFAULT,
298 ?array $imageOptions =
null
300 if ( $title instanceof
File ) {
302 $title = $title->getTitle();
304 $this->mImages[] = [ $title, $html, $alt, $link, $handlerOpts, $loading, $imageOptions ];
305 wfDebug(
'ImageGallery::add ' . $title->getText() );
326 $loading = self::LOADING_DEFAULT,
327 ?array $imageOptions =
null
329 if ( $title instanceof
File ) {
331 $title = $title->getTitle();
333 array_unshift( $this->mImages, [ $title, $html, $alt, $link, $handlerOpts, $loading, $imageOptions ] );
350 return $this->mImages === [];
360 $this->mShowDimensions = (bool)$f;
370 $this->mShowBytes = (bool)$f;
380 $this->mShowFilename = (bool)$f;
393 $this->mAttribs = $attribs;
407 return count( $this->mImages );
416 $this->contextTitle = $title;
433 return $this->mParser
434 ? $this->mParser->getTargetLanguage()
440class_alias( ImageGalleryBase::class,
'ImageGalleryBase' );
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that a deprecated feature was used.
Class for exceptions thrown by ImageGalleryBase::factory().
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
setContext(IContextSource $context)
Group all the pieces relevant to the context of a request into one instance.
A class containing constants representing the names of configuration variables.
const GalleryOptions
Name constant for the GalleryOptions setting, for use with Config::get()
Interface for objects which can provide a MediaWiki context on request.