Go to the documentation of this file.
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 = [
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'];
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;
354 abstract public function toHTML();
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()
setShowBytes( $f)
Enable/Disable showing of the file size of an image in the gallery.
setParser( $parser)
Register a parser object.
bool $mShowDimensions
Whether to show the dimensions in categories.
setHeights( $num)
Set how high each image will be, in pixels.
setContextTitle( $title)
Set the contextual title.
string $mMode
Gallery mode.
setWidths( $num)
Set how wide each image will be, in pixels.
setCaption( $caption)
Set the caption (as plain text)
getContextTitle()
Get the contextual title, if applicable.
setShowFilename( $f)
Enable/Disable showing of the filename of an image in the gallery.
insert( $title, $html='', $alt='', $link='', $handlerOpts=[])
Add an image at the beginning of the gallery.
bool string $mCaption
Gallery caption.
setAdditionalOptions( $options)
Allow setting additional options.
bool int $mCaptionLength
Length to truncate filename to in caption when using "showfilename".
add( $title, $html='', $alt='', $link='', $handlerOpts=[])
Add an image to the gallery.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
setAttributes( $attribs)
Set arbitrary attributes to go on the HTML gallery output element.
Implements some public methods and some protected utility functions which are required by multiple ch...
setHideBadImages( $flag=true)
Set bad image flag.
setPerRow( $num)
Set how many images will be displayed per row.
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
namespace and then decline to actually register it file or subcat img or subcat $title
bool $mShowFilename
Whether to show the filename.
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
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
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
see documentation in includes Linker php for Linker::makeImageLink or false for current used if you return false $parser
static getMainAndWarn( $func=__METHOD__)
Get the RequestContext object associated with the main request and gives a warning to the log,...
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))
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
setContext(IContextSource $context)
Title $contextTitle
Contextual title, used when images are being screened against the bad image list.
getImages()
Returns the list of images this gallery contains.
__construct( $mode='traditional', IContextSource $context=null)
Create a new image gallery object.
array $mImages
Gallery images.
bool $mShowBytes
Whether to show the filesize in bytes in categories.
setCaptionHtml( $caption)
Set the caption (as HTML)
Interface for objects which can provide a MediaWiki context on request.
getRenderLang()
Determines the correct language to be used for this image gallery.
Represents a title within MediaWiki.
isEmpty()
isEmpty() returns true if the gallery contains no images
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
setShowDimensions( $f)
Enable/Disable showing of the dimensions of an image in the gallery.
getConfig()
Get the site configuration.
usually copyright or history_copyright This message must be in HTML not wikitext & $link
static factory( $mode=false, IContextSource $context=null)
Get a new image gallery.
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
toHTML()
Display an html representation of the gallery.
bool $mHideBadImages
Hide blacklisted images?
Parser $mParser
Registered parser object for output callbacks.