102 private static $modeMapping;
116 $context = RequestContext::getMainAndWarn( __METHOD__ );
120 $mode = $galleryOptions[
'mode'];
125 if ( isset( self::$modeMapping[$mode] ) ) {
126 $class = self::$modeMapping[$mode];
127 return new $class( $mode, $context );
133 private static function loadModes() {
134 if ( self::$modeMapping ===
null ) {
135 self::$modeMapping = [
136 'traditional' => TraditionalImageGallery::class,
137 'nolines' => NolinesImageGallery::class,
138 'packed' => PackedImageGallery::class,
139 'packed-hover' => PackedHoverImageGallery::class,
140 'packed-overlay' => PackedOverlayImageGallery::class,
141 'slideshow' => SlideshowImageGallery::class,
145 ->onGalleryGetModes( self::$modeMapping );
169 $this->mShowBytes = $galleryOptions[
'showBytes'];
170 $this->mShowDimensions = $galleryOptions[
'showDimensions'];
171 $this->mShowFilename =
true;
172 $this->mParser =
false;
173 $this->mHideBadImages =
false;
174 $this->mPerRow = $galleryOptions[
'imagesPerRow'];
175 $this->mWidths = $galleryOptions[
'imageWidth'];
176 $this->mHeights = $galleryOptions[
'imageHeight'];
177 $this->mCaptionLength = $galleryOptions[
'captionLength'];
178 $this->mMode = $mode;
180 if ( $this->mCaptionLength !==
true ) {
182 "\$wgGalleryOptions['captionLength'] is deprecated, use CSS to truncate captions instead",
199 $this->mParser = $parser;
206 $this->mHideBadImages = $flag;
215 $this->mCaption = htmlspecialchars( $caption );
224 $this->mCaption = $caption;
235 $this->mPerRow = (int)$num;
251 $parsed = $parser->parseWidthParam( $num,
false );
252 if ( isset( $parsed[
'width'] ) && $parsed[
'width'] > 0 ) {
253 $this->mWidths = $parsed[
'width'];
269 $parsed = $parser->parseWidthParam( $num,
false );
270 if ( isset( $parsed[
'width'] ) && $parsed[
'width'] > 0 ) {
271 $this->mHeights = $parsed[
'width'];
305 $loading = self::LOADING_DEFAULT,
306 ?array $imageOptions =
null
308 if ( $title instanceof
File ) {
310 $title = $title->getTitle();
312 $this->mImages[] = [ $title, $html, $alt, $link, $handlerOpts, $loading, $imageOptions ];
313 wfDebug(
'ImageGallery::add ' . $title->getText() );
334 $loading = self::LOADING_DEFAULT,
335 ?array $imageOptions =
null
337 if ( $title instanceof
File ) {
339 $title = $title->getTitle();
341 array_unshift( $this->mImages, [ $title, $html, $alt, $link, $handlerOpts, $loading, $imageOptions ] );
358 return $this->mImages === [];
368 $this->mShowDimensions = (bool)$f;
378 $this->mShowBytes = (bool)$f;
388 $this->mShowFilename = (bool)$f;
401 $this->mAttribs = $attribs;
415 return count( $this->mImages );
424 $this->contextTitle = $title;
441 return $this->mParser
442 ? $this->mParser->getTargetLanguage()
448class_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.
wfDeprecatedMsg( $msg, $version=false, $component=false, $callerOffset=2)
Log a deprecation warning with arbitrary message text.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that a deprecated feature was used.
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.