106 $context = RequestContext::getMainAndWarn( __METHOD__ );
110 $mode = $galleryOptions[
'mode'];
113 $mode = MediaWikiServices::getInstance()->getContentLanguage()->lc( $mode );
115 if ( isset( self::$modeMapping[$mode] ) ) {
116 $class = self::$modeMapping[$mode];
117 return new $class( $mode,
$context );
119 throw new MWException(
"No gallery class registered for mode $mode" );
124 if ( self::$modeMapping ===
false ) {
125 self::$modeMapping = [
126 'traditional' => TraditionalImageGallery::class,
127 'nolines' => NolinesImageGallery::class,
128 'packed' => PackedImageGallery::class,
129 'packed-hover' => PackedHoverImageGallery::class,
130 'packed-overlay' => PackedOverlayImageGallery::class,
131 'slideshow' => SlideshowImageGallery::class,
134 Hooks::run(
'GalleryGetModes', [ &self::$modeMapping ] );
151 $galleryOptions = $this->
getConfig()->get(
'GalleryOptions' );
153 $this->mShowBytes = $galleryOptions[
'showBytes'];
154 $this->mShowDimensions = $galleryOptions[
'showDimensions'];
155 $this->mShowFilename =
true;
156 $this->mParser =
false;
157 $this->mHideBadImages =
false;
158 $this->mPerRow = $galleryOptions[
'imagesPerRow'];
159 $this->mWidths = $galleryOptions[
'imageWidth'];
160 $this->mHeights = $galleryOptions[
'imageHeight'];
161 $this->mCaptionLength = $galleryOptions[
'captionLength'];
162 $this->mMode = $mode;
184 $this->mHideBadImages = $flag;
193 $this->mCaption = htmlspecialchars( $caption );
202 $this->mCaption = $caption;
213 $this->mPerRow = (int)$num;
224 $parsed = Parser::parseWidthParam( $num,
false );
225 if ( isset( $parsed[
'width'] ) && $parsed[
'width'] > 0 ) {
226 $this->mWidths = $parsed[
'width'];
237 $parsed = Parser::parseWidthParam( $num,
false );
238 if ( isset( $parsed[
'width'] ) && $parsed[
'width'] > 0 ) {
239 $this->mHeights = $parsed[
'width'];
263 function add( $title,
$html =
'', $alt =
'',
$link =
'', $handlerOpts = [] ) {
264 if ( $title instanceof
File ) {
266 $title = $title->getTitle();
269 wfDebug(
'ImageGallery::add ' . $title->getText() .
"\n" );
283 if ( $title instanceof
File ) {
285 $title = $title->getTitle();
287 array_unshift( $this->mImages, [ &$title,
$html, $alt,
$link, $handlerOpts ] );
303 return empty( $this->mImages );
313 $this->mShowDimensions = (bool)$f;
323 $this->mShowBytes = (bool)$f;
333 $this->mShowFilename = (bool)$f;
360 return count( $this->mImages );
369 $this->contextTitle =
$title;
378 return is_object( $this->contextTitle ) && $this->contextTitle instanceof
Title
379 ? $this->contextTitle
388 return $this->mParser
389 ? $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...
Represents a title within MediaWiki.
see documentation in includes Linker php for Linker::makeImageLink or false for current used if you return false $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.
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))