2006-05-16 22:21:14 +00:00
|
|
|
<?php
|
2012-05-12 20:33:02 +00:00
|
|
|
/**
|
|
|
|
|
* Image gallery.
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
|
|
|
|
* @file
|
|
|
|
|
*/
|
|
|
|
|
|
2018-07-29 12:24:54 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
|
|
|
|
|
2004-09-14 20:57:54 +00:00
|
|
|
/**
|
|
|
|
|
* Image gallery
|
2006-01-07 13:09:30 +00:00
|
|
|
*
|
2004-09-30 21:36:12 +00:00
|
|
|
* Add images to the gallery using add(), then render that list to HTML using toHTML().
|
2020-07-13 09:20:52 +00:00
|
|
|
* @stable to extend
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup Media
|
2004-09-14 20:57:54 +00:00
|
|
|
*/
|
New more slick gallery display
This extension adds a "mode" parameter to the gallery
tag, allowing different formats for the gallery tag
(galleries in the ui can be controlled by a global)
The added modes are:
*traditional - The original gallery
*nolines - Like the original, no borders, less padding
*packed - All images aligned by having same height.
JS also justifies the images.
(I think this one is the one that will go over best
with users.)
*packed-overlay - like packed, but caption goes over
top the image in a transloucent box.
*packed-hover - like packed-overlay, but caption only
visible on hover. Degrades gracefully on screen
readers, and falls back to packed-overlay if
you are using a touch screen. I kind of like
this mode when the caption is not that important
(ex a category where its just the file name).
This also adds a hook to allow people to make their
own gallery version. I believe there would be interest
in this, as different people have done different
experiments. For example:
* Wikia: http://community.wikia.com/wiki/Help:Galleries,_Slideshows,_and_Sliders/wikitext
* Wikinews: https://en.wikinews.org/wiki/Template:Picture_select
What I would like to see for this patch, is first it gets
enabled, with the default still "traditional". After
about a month or two we consult with users. If feedback
is positive, we change the default mode to one of the
others (probably "packed").
Adds a "mode" parameter to gallery for different
mode, including one 'height-constrained-overlay'
which looks much more like other modern websites.
Note: This makes one change to the old gallery format.
It makes Nonexistent files be rendered like thumbnails
(i.e. they are rendered with a little grey border).
One thing I'm slightly worried about with this patch,
is that I added an option to MediaTransformOutput::toHtml
to override the width attribute. I'm not sure if that
is the best approach, and would appreciate thoughts
on that.
This should be merged at the same time as Ie82c1548
Change-Id: I33462a8b52502ed76aeb163b66e3704c8618ba23
2013-06-08 04:47:07 +00:00
|
|
|
abstract class ImageGalleryBase extends ContextSource {
|
2020-05-21 17:30:58 +00:00
|
|
|
public const LOADING_DEFAULT = 1;
|
|
|
|
|
public const LOADING_LAZY = 2;
|
|
|
|
|
|
2014-05-10 12:35:20 +00:00
|
|
|
/**
|
2019-10-11 14:06:45 +00:00
|
|
|
* @var array[] Gallery images
|
2020-05-21 17:30:58 +00:00
|
|
|
* @phan-var array<int,array{0:Title,1:string,2:string,3:string,4:array,5:int}>
|
2014-05-10 12:35:20 +00:00
|
|
|
*/
|
2015-02-04 19:28:29 +00:00
|
|
|
protected $mImages;
|
2013-11-24 19:14:18 +00:00
|
|
|
|
2014-05-10 12:35:20 +00:00
|
|
|
/**
|
|
|
|
|
* @var bool Whether to show the filesize in bytes in categories
|
|
|
|
|
*/
|
2015-02-04 19:28:29 +00:00
|
|
|
protected $mShowBytes;
|
2013-11-24 19:14:18 +00:00
|
|
|
|
2017-03-06 12:32:38 +00:00
|
|
|
/**
|
|
|
|
|
* @var bool Whether to show the dimensions in categories
|
|
|
|
|
*/
|
|
|
|
|
protected $mShowDimensions;
|
|
|
|
|
|
2014-05-10 12:35:20 +00:00
|
|
|
/**
|
|
|
|
|
* @var bool Whether to show the filename. Default: true
|
|
|
|
|
*/
|
2015-02-04 19:28:29 +00:00
|
|
|
protected $mShowFilename;
|
2013-11-24 19:14:18 +00:00
|
|
|
|
2014-05-10 12:35:20 +00:00
|
|
|
/**
|
|
|
|
|
* @var string Gallery mode. Default: traditional
|
|
|
|
|
*/
|
2015-02-04 19:28:29 +00:00
|
|
|
protected $mMode;
|
2013-11-24 19:14:18 +00:00
|
|
|
|
2014-05-10 12:35:20 +00:00
|
|
|
/**
|
|
|
|
|
* @var bool|string Gallery caption. Default: false
|
|
|
|
|
*/
|
2015-02-04 19:28:29 +00:00
|
|
|
protected $mCaption = false;
|
2007-02-02 03:32:03 +00:00
|
|
|
|
2018-04-13 10:45:32 +00:00
|
|
|
/**
|
|
|
|
|
* Length to truncate filename to in caption when using "showfilename".
|
|
|
|
|
* A value of 'true' will truncate the filename to one line using CSS
|
|
|
|
|
* and will be the behaviour after deprecation.
|
|
|
|
|
*
|
|
|
|
|
* @var bool|int
|
|
|
|
|
*/
|
|
|
|
|
protected $mCaptionLength = true;
|
|
|
|
|
|
2006-05-16 19:15:58 +00:00
|
|
|
/**
|
2013-11-24 19:06:17 +00:00
|
|
|
* @var bool Hide blacklisted images?
|
2006-05-16 19:15:58 +00:00
|
|
|
*/
|
2015-02-04 19:28:29 +00:00
|
|
|
protected $mHideBadImages;
|
2007-08-22 13:40:22 +00:00
|
|
|
|
|
|
|
|
/**
|
2019-08-30 16:01:28 +00:00
|
|
|
* @var Parser|false Registered parser object for output callbacks
|
2007-08-22 13:40:22 +00:00
|
|
|
*/
|
2014-05-03 17:12:18 +00:00
|
|
|
public $mParser;
|
2007-02-02 03:32:03 +00:00
|
|
|
|
2007-01-20 22:34:05 +00:00
|
|
|
/**
|
2019-08-27 17:21:28 +00:00
|
|
|
* @var Title|null Contextual title, used when images are being screened against
|
2013-11-24 19:06:17 +00:00
|
|
|
* the bad image list
|
2007-01-20 22:34:05 +00:00
|
|
|
*/
|
2019-08-27 17:21:28 +00:00
|
|
|
protected $contextTitle = null;
|
2004-09-14 20:57:54 +00:00
|
|
|
|
2013-11-24 19:06:17 +00:00
|
|
|
/** @var array */
|
2016-02-17 09:09:32 +00:00
|
|
|
protected $mAttribs = [];
|
2007-02-02 03:32:03 +00:00
|
|
|
|
2019-09-11 09:07:30 +00:00
|
|
|
/** @var int */
|
|
|
|
|
protected $mPerRow;
|
|
|
|
|
|
|
|
|
|
/** @var int */
|
|
|
|
|
protected $mWidths;
|
|
|
|
|
|
|
|
|
|
/** @var int */
|
|
|
|
|
protected $mHeights;
|
|
|
|
|
|
2019-08-30 16:01:28 +00:00
|
|
|
/** @var array */
|
|
|
|
|
private static $modeMapping;
|
New more slick gallery display
This extension adds a "mode" parameter to the gallery
tag, allowing different formats for the gallery tag
(galleries in the ui can be controlled by a global)
The added modes are:
*traditional - The original gallery
*nolines - Like the original, no borders, less padding
*packed - All images aligned by having same height.
JS also justifies the images.
(I think this one is the one that will go over best
with users.)
*packed-overlay - like packed, but caption goes over
top the image in a transloucent box.
*packed-hover - like packed-overlay, but caption only
visible on hover. Degrades gracefully on screen
readers, and falls back to packed-overlay if
you are using a touch screen. I kind of like
this mode when the caption is not that important
(ex a category where its just the file name).
This also adds a hook to allow people to make their
own gallery version. I believe there would be interest
in this, as different people have done different
experiments. For example:
* Wikia: http://community.wikia.com/wiki/Help:Galleries,_Slideshows,_and_Sliders/wikitext
* Wikinews: https://en.wikinews.org/wiki/Template:Picture_select
What I would like to see for this patch, is first it gets
enabled, with the default still "traditional". After
about a month or two we consult with users. If feedback
is positive, we change the default mode to one of the
others (probably "packed").
Adds a "mode" parameter to gallery for different
mode, including one 'height-constrained-overlay'
which looks much more like other modern websites.
Note: This makes one change to the old gallery format.
It makes Nonexistent files be rendered like thumbnails
(i.e. they are rendered with a little grey border).
One thing I'm slightly worried about with this patch,
is that I added an option to MediaTransformOutput::toHtml
to override the width attribute. I'm not sure if that
is the best approach, and would appreciate thoughts
on that.
This should be merged at the same time as Ie82c1548
Change-Id: I33462a8b52502ed76aeb163b66e3704c8618ba23
2013-06-08 04:47:07 +00:00
|
|
|
|
2011-03-14 21:08:32 +00:00
|
|
|
/**
|
New more slick gallery display
This extension adds a "mode" parameter to the gallery
tag, allowing different formats for the gallery tag
(galleries in the ui can be controlled by a global)
The added modes are:
*traditional - The original gallery
*nolines - Like the original, no borders, less padding
*packed - All images aligned by having same height.
JS also justifies the images.
(I think this one is the one that will go over best
with users.)
*packed-overlay - like packed, but caption goes over
top the image in a transloucent box.
*packed-hover - like packed-overlay, but caption only
visible on hover. Degrades gracefully on screen
readers, and falls back to packed-overlay if
you are using a touch screen. I kind of like
this mode when the caption is not that important
(ex a category where its just the file name).
This also adds a hook to allow people to make their
own gallery version. I believe there would be interest
in this, as different people have done different
experiments. For example:
* Wikia: http://community.wikia.com/wiki/Help:Galleries,_Slideshows,_and_Sliders/wikitext
* Wikinews: https://en.wikinews.org/wiki/Template:Picture_select
What I would like to see for this patch, is first it gets
enabled, with the default still "traditional". After
about a month or two we consult with users. If feedback
is positive, we change the default mode to one of the
others (probably "packed").
Adds a "mode" parameter to gallery for different
mode, including one 'height-constrained-overlay'
which looks much more like other modern websites.
Note: This makes one change to the old gallery format.
It makes Nonexistent files be rendered like thumbnails
(i.e. they are rendered with a little grey border).
One thing I'm slightly worried about with this patch,
is that I added an option to MediaTransformOutput::toHtml
to override the width attribute. I'm not sure if that
is the best approach, and would appreciate thoughts
on that.
This should be merged at the same time as Ie82c1548
Change-Id: I33462a8b52502ed76aeb163b66e3704c8618ba23
2013-06-08 04:47:07 +00:00
|
|
|
* Get a new image gallery. This is the method other callers
|
|
|
|
|
* should use to get a gallery.
|
|
|
|
|
*
|
2014-04-14 19:43:18 +00:00
|
|
|
* @param string|bool $mode Mode to use. False to use the default
|
2014-08-22 20:36:59 +00:00
|
|
|
* @param IContextSource|null $context
|
2014-08-23 20:34:25 +00:00
|
|
|
* @return ImageGalleryBase
|
2013-11-24 19:06:17 +00:00
|
|
|
* @throws MWException
|
2011-03-14 21:08:32 +00:00
|
|
|
*/
|
2020-05-10 08:39:38 +00:00
|
|
|
public static function factory( $mode = false, IContextSource $context = null ) {
|
New more slick gallery display
This extension adds a "mode" parameter to the gallery
tag, allowing different formats for the gallery tag
(galleries in the ui can be controlled by a global)
The added modes are:
*traditional - The original gallery
*nolines - Like the original, no borders, less padding
*packed - All images aligned by having same height.
JS also justifies the images.
(I think this one is the one that will go over best
with users.)
*packed-overlay - like packed, but caption goes over
top the image in a transloucent box.
*packed-hover - like packed-overlay, but caption only
visible on hover. Degrades gracefully on screen
readers, and falls back to packed-overlay if
you are using a touch screen. I kind of like
this mode when the caption is not that important
(ex a category where its just the file name).
This also adds a hook to allow people to make their
own gallery version. I believe there would be interest
in this, as different people have done different
experiments. For example:
* Wikia: http://community.wikia.com/wiki/Help:Galleries,_Slideshows,_and_Sliders/wikitext
* Wikinews: https://en.wikinews.org/wiki/Template:Picture_select
What I would like to see for this patch, is first it gets
enabled, with the default still "traditional". After
about a month or two we consult with users. If feedback
is positive, we change the default mode to one of the
others (probably "packed").
Adds a "mode" parameter to gallery for different
mode, including one 'height-constrained-overlay'
which looks much more like other modern websites.
Note: This makes one change to the old gallery format.
It makes Nonexistent files be rendered like thumbnails
(i.e. they are rendered with a little grey border).
One thing I'm slightly worried about with this patch,
is that I added an option to MediaTransformOutput::toHtml
to override the width attribute. I'm not sure if that
is the best approach, and would appreciate thoughts
on that.
This should be merged at the same time as Ie82c1548
Change-Id: I33462a8b52502ed76aeb163b66e3704c8618ba23
2013-06-08 04:47:07 +00:00
|
|
|
self::loadModes();
|
2014-08-22 20:36:59 +00:00
|
|
|
if ( !$context ) {
|
|
|
|
|
$context = RequestContext::getMainAndWarn( __METHOD__ );
|
|
|
|
|
}
|
New more slick gallery display
This extension adds a "mode" parameter to the gallery
tag, allowing different formats for the gallery tag
(galleries in the ui can be controlled by a global)
The added modes are:
*traditional - The original gallery
*nolines - Like the original, no borders, less padding
*packed - All images aligned by having same height.
JS also justifies the images.
(I think this one is the one that will go over best
with users.)
*packed-overlay - like packed, but caption goes over
top the image in a transloucent box.
*packed-hover - like packed-overlay, but caption only
visible on hover. Degrades gracefully on screen
readers, and falls back to packed-overlay if
you are using a touch screen. I kind of like
this mode when the caption is not that important
(ex a category where its just the file name).
This also adds a hook to allow people to make their
own gallery version. I believe there would be interest
in this, as different people have done different
experiments. For example:
* Wikia: http://community.wikia.com/wiki/Help:Galleries,_Slideshows,_and_Sliders/wikitext
* Wikinews: https://en.wikinews.org/wiki/Template:Picture_select
What I would like to see for this patch, is first it gets
enabled, with the default still "traditional". After
about a month or two we consult with users. If feedback
is positive, we change the default mode to one of the
others (probably "packed").
Adds a "mode" parameter to gallery for different
mode, including one 'height-constrained-overlay'
which looks much more like other modern websites.
Note: This makes one change to the old gallery format.
It makes Nonexistent files be rendered like thumbnails
(i.e. they are rendered with a little grey border).
One thing I'm slightly worried about with this patch,
is that I added an option to MediaTransformOutput::toHtml
to override the width attribute. I'm not sure if that
is the best approach, and would appreciate thoughts
on that.
This should be merged at the same time as Ie82c1548
Change-Id: I33462a8b52502ed76aeb163b66e3704c8618ba23
2013-06-08 04:47:07 +00:00
|
|
|
if ( !$mode ) {
|
2016-01-24 18:14:04 +00:00
|
|
|
$galleryOptions = $context->getConfig()->get( 'GalleryOptions' );
|
|
|
|
|
$mode = $galleryOptions['mode'];
|
New more slick gallery display
This extension adds a "mode" parameter to the gallery
tag, allowing different formats for the gallery tag
(galleries in the ui can be controlled by a global)
The added modes are:
*traditional - The original gallery
*nolines - Like the original, no borders, less padding
*packed - All images aligned by having same height.
JS also justifies the images.
(I think this one is the one that will go over best
with users.)
*packed-overlay - like packed, but caption goes over
top the image in a transloucent box.
*packed-hover - like packed-overlay, but caption only
visible on hover. Degrades gracefully on screen
readers, and falls back to packed-overlay if
you are using a touch screen. I kind of like
this mode when the caption is not that important
(ex a category where its just the file name).
This also adds a hook to allow people to make their
own gallery version. I believe there would be interest
in this, as different people have done different
experiments. For example:
* Wikia: http://community.wikia.com/wiki/Help:Galleries,_Slideshows,_and_Sliders/wikitext
* Wikinews: https://en.wikinews.org/wiki/Template:Picture_select
What I would like to see for this patch, is first it gets
enabled, with the default still "traditional". After
about a month or two we consult with users. If feedback
is positive, we change the default mode to one of the
others (probably "packed").
Adds a "mode" parameter to gallery for different
mode, including one 'height-constrained-overlay'
which looks much more like other modern websites.
Note: This makes one change to the old gallery format.
It makes Nonexistent files be rendered like thumbnails
(i.e. they are rendered with a little grey border).
One thing I'm slightly worried about with this patch,
is that I added an option to MediaTransformOutput::toHtml
to override the width attribute. I'm not sure if that
is the best approach, and would appreciate thoughts
on that.
This should be merged at the same time as Ie82c1548
Change-Id: I33462a8b52502ed76aeb163b66e3704c8618ba23
2013-06-08 04:47:07 +00:00
|
|
|
}
|
|
|
|
|
|
2018-07-29 12:24:54 +00:00
|
|
|
$mode = MediaWikiServices::getInstance()->getContentLanguage()->lc( $mode );
|
New more slick gallery display
This extension adds a "mode" parameter to the gallery
tag, allowing different formats for the gallery tag
(galleries in the ui can be controlled by a global)
The added modes are:
*traditional - The original gallery
*nolines - Like the original, no borders, less padding
*packed - All images aligned by having same height.
JS also justifies the images.
(I think this one is the one that will go over best
with users.)
*packed-overlay - like packed, but caption goes over
top the image in a transloucent box.
*packed-hover - like packed-overlay, but caption only
visible on hover. Degrades gracefully on screen
readers, and falls back to packed-overlay if
you are using a touch screen. I kind of like
this mode when the caption is not that important
(ex a category where its just the file name).
This also adds a hook to allow people to make their
own gallery version. I believe there would be interest
in this, as different people have done different
experiments. For example:
* Wikia: http://community.wikia.com/wiki/Help:Galleries,_Slideshows,_and_Sliders/wikitext
* Wikinews: https://en.wikinews.org/wiki/Template:Picture_select
What I would like to see for this patch, is first it gets
enabled, with the default still "traditional". After
about a month or two we consult with users. If feedback
is positive, we change the default mode to one of the
others (probably "packed").
Adds a "mode" parameter to gallery for different
mode, including one 'height-constrained-overlay'
which looks much more like other modern websites.
Note: This makes one change to the old gallery format.
It makes Nonexistent files be rendered like thumbnails
(i.e. they are rendered with a little grey border).
One thing I'm slightly worried about with this patch,
is that I added an option to MediaTransformOutput::toHtml
to override the width attribute. I'm not sure if that
is the best approach, and would appreciate thoughts
on that.
This should be merged at the same time as Ie82c1548
Change-Id: I33462a8b52502ed76aeb163b66e3704c8618ba23
2013-06-08 04:47:07 +00:00
|
|
|
|
|
|
|
|
if ( isset( self::$modeMapping[$mode] ) ) {
|
2015-12-03 17:59:56 +00:00
|
|
|
$class = self::$modeMapping[$mode];
|
|
|
|
|
return new $class( $mode, $context );
|
New more slick gallery display
This extension adds a "mode" parameter to the gallery
tag, allowing different formats for the gallery tag
(galleries in the ui can be controlled by a global)
The added modes are:
*traditional - The original gallery
*nolines - Like the original, no borders, less padding
*packed - All images aligned by having same height.
JS also justifies the images.
(I think this one is the one that will go over best
with users.)
*packed-overlay - like packed, but caption goes over
top the image in a transloucent box.
*packed-hover - like packed-overlay, but caption only
visible on hover. Degrades gracefully on screen
readers, and falls back to packed-overlay if
you are using a touch screen. I kind of like
this mode when the caption is not that important
(ex a category where its just the file name).
This also adds a hook to allow people to make their
own gallery version. I believe there would be interest
in this, as different people have done different
experiments. For example:
* Wikia: http://community.wikia.com/wiki/Help:Galleries,_Slideshows,_and_Sliders/wikitext
* Wikinews: https://en.wikinews.org/wiki/Template:Picture_select
What I would like to see for this patch, is first it gets
enabled, with the default still "traditional". After
about a month or two we consult with users. If feedback
is positive, we change the default mode to one of the
others (probably "packed").
Adds a "mode" parameter to gallery for different
mode, including one 'height-constrained-overlay'
which looks much more like other modern websites.
Note: This makes one change to the old gallery format.
It makes Nonexistent files be rendered like thumbnails
(i.e. they are rendered with a little grey border).
One thing I'm slightly worried about with this patch,
is that I added an option to MediaTransformOutput::toHtml
to override the width attribute. I'm not sure if that
is the best approach, and would appreciate thoughts
on that.
This should be merged at the same time as Ie82c1548
Change-Id: I33462a8b52502ed76aeb163b66e3704c8618ba23
2013-06-08 04:47:07 +00:00
|
|
|
} else {
|
|
|
|
|
throw new MWException( "No gallery class registered for mode $mode" );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-23 13:42:32 +00:00
|
|
|
private static function loadModes() {
|
2019-08-30 16:01:28 +00:00
|
|
|
if ( self::$modeMapping === null ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
self::$modeMapping = [
|
2018-01-13 00:02:09 +00:00
|
|
|
'traditional' => TraditionalImageGallery::class,
|
|
|
|
|
'nolines' => NolinesImageGallery::class,
|
|
|
|
|
'packed' => PackedImageGallery::class,
|
|
|
|
|
'packed-hover' => PackedHoverImageGallery::class,
|
|
|
|
|
'packed-overlay' => PackedOverlayImageGallery::class,
|
|
|
|
|
'slideshow' => SlideshowImageGallery::class,
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
New more slick gallery display
This extension adds a "mode" parameter to the gallery
tag, allowing different formats for the gallery tag
(galleries in the ui can be controlled by a global)
The added modes are:
*traditional - The original gallery
*nolines - Like the original, no borders, less padding
*packed - All images aligned by having same height.
JS also justifies the images.
(I think this one is the one that will go over best
with users.)
*packed-overlay - like packed, but caption goes over
top the image in a transloucent box.
*packed-hover - like packed-overlay, but caption only
visible on hover. Degrades gracefully on screen
readers, and falls back to packed-overlay if
you are using a touch screen. I kind of like
this mode when the caption is not that important
(ex a category where its just the file name).
This also adds a hook to allow people to make their
own gallery version. I believe there would be interest
in this, as different people have done different
experiments. For example:
* Wikia: http://community.wikia.com/wiki/Help:Galleries,_Slideshows,_and_Sliders/wikitext
* Wikinews: https://en.wikinews.org/wiki/Template:Picture_select
What I would like to see for this patch, is first it gets
enabled, with the default still "traditional". After
about a month or two we consult with users. If feedback
is positive, we change the default mode to one of the
others (probably "packed").
Adds a "mode" parameter to gallery for different
mode, including one 'height-constrained-overlay'
which looks much more like other modern websites.
Note: This makes one change to the old gallery format.
It makes Nonexistent files be rendered like thumbnails
(i.e. they are rendered with a little grey border).
One thing I'm slightly worried about with this patch,
is that I added an option to MediaTransformOutput::toHtml
to override the width attribute. I'm not sure if that
is the best approach, and would appreciate thoughts
on that.
This should be merged at the same time as Ie82c1548
Change-Id: I33462a8b52502ed76aeb163b66e3704c8618ba23
2013-06-08 04:47:07 +00:00
|
|
|
// Allow extensions to make a new gallery format.
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
Hooks::runner()->onGalleryGetModes( self::$modeMapping );
|
New more slick gallery display
This extension adds a "mode" parameter to the gallery
tag, allowing different formats for the gallery tag
(galleries in the ui can be controlled by a global)
The added modes are:
*traditional - The original gallery
*nolines - Like the original, no borders, less padding
*packed - All images aligned by having same height.
JS also justifies the images.
(I think this one is the one that will go over best
with users.)
*packed-overlay - like packed, but caption goes over
top the image in a transloucent box.
*packed-hover - like packed-overlay, but caption only
visible on hover. Degrades gracefully on screen
readers, and falls back to packed-overlay if
you are using a touch screen. I kind of like
this mode when the caption is not that important
(ex a category where its just the file name).
This also adds a hook to allow people to make their
own gallery version. I believe there would be interest
in this, as different people have done different
experiments. For example:
* Wikia: http://community.wikia.com/wiki/Help:Galleries,_Slideshows,_and_Sliders/wikitext
* Wikinews: https://en.wikinews.org/wiki/Template:Picture_select
What I would like to see for this patch, is first it gets
enabled, with the default still "traditional". After
about a month or two we consult with users. If feedback
is positive, we change the default mode to one of the
others (probably "packed").
Adds a "mode" parameter to gallery for different
mode, including one 'height-constrained-overlay'
which looks much more like other modern websites.
Note: This makes one change to the old gallery format.
It makes Nonexistent files be rendered like thumbnails
(i.e. they are rendered with a little grey border).
One thing I'm slightly worried about with this patch,
is that I added an option to MediaTransformOutput::toHtml
to override the width attribute. I'm not sure if that
is the best approach, and would appreciate thoughts
on that.
This should be merged at the same time as Ie82c1548
Change-Id: I33462a8b52502ed76aeb163b66e3704c8618ba23
2013-06-08 04:47:07 +00:00
|
|
|
}
|
|
|
|
|
}
|
2011-03-14 21:08:32 +00:00
|
|
|
|
2006-01-07 13:09:30 +00:00
|
|
|
/**
|
2004-09-30 21:36:12 +00:00
|
|
|
* Create a new image gallery object.
|
New more slick gallery display
This extension adds a "mode" parameter to the gallery
tag, allowing different formats for the gallery tag
(galleries in the ui can be controlled by a global)
The added modes are:
*traditional - The original gallery
*nolines - Like the original, no borders, less padding
*packed - All images aligned by having same height.
JS also justifies the images.
(I think this one is the one that will go over best
with users.)
*packed-overlay - like packed, but caption goes over
top the image in a transloucent box.
*packed-hover - like packed-overlay, but caption only
visible on hover. Degrades gracefully on screen
readers, and falls back to packed-overlay if
you are using a touch screen. I kind of like
this mode when the caption is not that important
(ex a category where its just the file name).
This also adds a hook to allow people to make their
own gallery version. I believe there would be interest
in this, as different people have done different
experiments. For example:
* Wikia: http://community.wikia.com/wiki/Help:Galleries,_Slideshows,_and_Sliders/wikitext
* Wikinews: https://en.wikinews.org/wiki/Template:Picture_select
What I would like to see for this patch, is first it gets
enabled, with the default still "traditional". After
about a month or two we consult with users. If feedback
is positive, we change the default mode to one of the
others (probably "packed").
Adds a "mode" parameter to gallery for different
mode, including one 'height-constrained-overlay'
which looks much more like other modern websites.
Note: This makes one change to the old gallery format.
It makes Nonexistent files be rendered like thumbnails
(i.e. they are rendered with a little grey border).
One thing I'm slightly worried about with this patch,
is that I added an option to MediaTransformOutput::toHtml
to override the width attribute. I'm not sure if that
is the best approach, and would appreciate thoughts
on that.
This should be merged at the same time as Ie82c1548
Change-Id: I33462a8b52502ed76aeb163b66e3704c8618ba23
2013-06-08 04:47:07 +00:00
|
|
|
*
|
|
|
|
|
* You should not call this directly, but instead use
|
|
|
|
|
* ImageGalleryBase::factory().
|
2020-07-13 09:20:52 +00:00
|
|
|
*
|
|
|
|
|
* @stable to call
|
|
|
|
|
* @note constructors of subclasses must have a compatible signature
|
|
|
|
|
* for use by the factory() method.
|
|
|
|
|
*
|
2014-08-14 18:22:52 +00:00
|
|
|
* @param string $mode
|
2014-08-22 20:36:59 +00:00
|
|
|
* @param IContextSource|null $context
|
2004-09-30 21:36:12 +00:00
|
|
|
*/
|
2019-11-30 23:03:59 +00:00
|
|
|
public function __construct( $mode = 'traditional', IContextSource $context = null ) {
|
2014-08-22 20:36:59 +00:00
|
|
|
if ( $context ) {
|
|
|
|
|
$this->setContext( $context );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$galleryOptions = $this->getConfig()->get( 'GalleryOptions' );
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->mImages = [];
|
2014-08-22 20:36:59 +00:00
|
|
|
$this->mShowBytes = $galleryOptions['showBytes'];
|
2017-03-06 12:32:38 +00:00
|
|
|
$this->mShowDimensions = $galleryOptions['showDimensions'];
|
2004-11-13 10:53:46 +00:00
|
|
|
$this->mShowFilename = true;
|
2007-08-22 13:40:22 +00:00
|
|
|
$this->mParser = false;
|
|
|
|
|
$this->mHideBadImages = false;
|
2014-08-22 20:36:59 +00:00
|
|
|
$this->mPerRow = $galleryOptions['imagesPerRow'];
|
|
|
|
|
$this->mWidths = $galleryOptions['imageWidth'];
|
|
|
|
|
$this->mHeights = $galleryOptions['imageHeight'];
|
|
|
|
|
$this->mCaptionLength = $galleryOptions['captionLength'];
|
New more slick gallery display
This extension adds a "mode" parameter to the gallery
tag, allowing different formats for the gallery tag
(galleries in the ui can be controlled by a global)
The added modes are:
*traditional - The original gallery
*nolines - Like the original, no borders, less padding
*packed - All images aligned by having same height.
JS also justifies the images.
(I think this one is the one that will go over best
with users.)
*packed-overlay - like packed, but caption goes over
top the image in a transloucent box.
*packed-hover - like packed-overlay, but caption only
visible on hover. Degrades gracefully on screen
readers, and falls back to packed-overlay if
you are using a touch screen. I kind of like
this mode when the caption is not that important
(ex a category where its just the file name).
This also adds a hook to allow people to make their
own gallery version. I believe there would be interest
in this, as different people have done different
experiments. For example:
* Wikia: http://community.wikia.com/wiki/Help:Galleries,_Slideshows,_and_Sliders/wikitext
* Wikinews: https://en.wikinews.org/wiki/Template:Picture_select
What I would like to see for this patch, is first it gets
enabled, with the default still "traditional". After
about a month or two we consult with users. If feedback
is positive, we change the default mode to one of the
others (probably "packed").
Adds a "mode" parameter to gallery for different
mode, including one 'height-constrained-overlay'
which looks much more like other modern websites.
Note: This makes one change to the old gallery format.
It makes Nonexistent files be rendered like thumbnails
(i.e. they are rendered with a little grey border).
One thing I'm slightly worried about with this patch,
is that I added an option to MediaTransformOutput::toHtml
to override the width attribute. I'm not sure if that
is the best approach, and would appreciate thoughts
on that.
This should be merged at the same time as Ie82c1548
Change-Id: I33462a8b52502ed76aeb163b66e3704c8618ba23
2013-06-08 04:47:07 +00:00
|
|
|
$this->mMode = $mode;
|
2006-05-16 19:15:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
New more slick gallery display
This extension adds a "mode" parameter to the gallery
tag, allowing different formats for the gallery tag
(galleries in the ui can be controlled by a global)
The added modes are:
*traditional - The original gallery
*nolines - Like the original, no borders, less padding
*packed - All images aligned by having same height.
JS also justifies the images.
(I think this one is the one that will go over best
with users.)
*packed-overlay - like packed, but caption goes over
top the image in a transloucent box.
*packed-hover - like packed-overlay, but caption only
visible on hover. Degrades gracefully on screen
readers, and falls back to packed-overlay if
you are using a touch screen. I kind of like
this mode when the caption is not that important
(ex a category where its just the file name).
This also adds a hook to allow people to make their
own gallery version. I believe there would be interest
in this, as different people have done different
experiments. For example:
* Wikia: http://community.wikia.com/wiki/Help:Galleries,_Slideshows,_and_Sliders/wikitext
* Wikinews: https://en.wikinews.org/wiki/Template:Picture_select
What I would like to see for this patch, is first it gets
enabled, with the default still "traditional". After
about a month or two we consult with users. If feedback
is positive, we change the default mode to one of the
others (probably "packed").
Adds a "mode" parameter to gallery for different
mode, including one 'height-constrained-overlay'
which looks much more like other modern websites.
Note: This makes one change to the old gallery format.
It makes Nonexistent files be rendered like thumbnails
(i.e. they are rendered with a little grey border).
One thing I'm slightly worried about with this patch,
is that I added an option to MediaTransformOutput::toHtml
to override the width attribute. I'm not sure if that
is the best approach, and would appreciate thoughts
on that.
This should be merged at the same time as Ie82c1548
Change-Id: I33462a8b52502ed76aeb163b66e3704c8618ba23
2013-06-08 04:47:07 +00:00
|
|
|
* Register a parser object. If you do not set this
|
|
|
|
|
* and the output of this gallery ends up in parser
|
|
|
|
|
* cache, the javascript will break!
|
|
|
|
|
*
|
|
|
|
|
* @note This also triggers using the page's target
|
|
|
|
|
* language instead of the user language.
|
2011-05-28 18:59:42 +00:00
|
|
|
*
|
2014-04-14 19:43:18 +00:00
|
|
|
* @param Parser $parser
|
2006-05-16 19:15:58 +00:00
|
|
|
*/
|
2020-05-10 08:39:38 +00:00
|
|
|
public function setParser( $parser ) {
|
2007-08-22 13:40:22 +00:00
|
|
|
$this->mParser = $parser;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-08-14 18:22:52 +00:00
|
|
|
* @param bool $flag
|
2007-08-22 13:40:22 +00:00
|
|
|
*/
|
2020-05-10 08:39:38 +00:00
|
|
|
public function setHideBadImages( $flag = true ) {
|
2007-08-22 13:40:22 +00:00
|
|
|
$this->mHideBadImages = $flag;
|
2004-09-14 20:57:54 +00:00
|
|
|
}
|
2007-02-02 03:32:03 +00:00
|
|
|
|
2006-06-24 00:12:34 +00:00
|
|
|
/**
|
2007-01-04 19:47:11 +00:00
|
|
|
* Set the caption (as plain text)
|
2006-06-24 00:12:34 +00:00
|
|
|
*
|
2017-12-28 15:06:10 +00:00
|
|
|
* @param string $caption
|
2006-06-24 00:12:34 +00:00
|
|
|
*/
|
2020-05-10 08:39:38 +00:00
|
|
|
public function setCaption( $caption ) {
|
2007-01-04 19:47:11 +00:00
|
|
|
$this->mCaption = htmlspecialchars( $caption );
|
|
|
|
|
}
|
2007-02-02 03:32:03 +00:00
|
|
|
|
2007-01-04 19:47:11 +00:00
|
|
|
/**
|
|
|
|
|
* Set the caption (as HTML)
|
|
|
|
|
*
|
2017-12-28 15:06:10 +00:00
|
|
|
* @param string $caption
|
2007-01-04 19:47:11 +00:00
|
|
|
*/
|
2007-02-02 03:32:03 +00:00
|
|
|
public function setCaptionHtml( $caption ) {
|
2006-06-24 00:12:34 +00:00
|
|
|
$this->mCaption = $caption;
|
|
|
|
|
}
|
|
|
|
|
|
2007-02-02 03:32:03 +00:00
|
|
|
/**
|
|
|
|
|
* Set how many images will be displayed per row.
|
|
|
|
|
*
|
2013-11-24 19:06:17 +00:00
|
|
|
* @param int $num Integer >= 0; If perrow=0 the gallery layout will adapt
|
|
|
|
|
* to screensize invalid numbers will be rejected
|
2007-02-02 03:32:03 +00:00
|
|
|
*/
|
|
|
|
|
public function setPerRow( $num ) {
|
2011-05-16 13:04:57 +00:00
|
|
|
if ( $num >= 0 ) {
|
2007-02-02 03:32:03 +00:00
|
|
|
$this->mPerRow = (int)$num;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set how wide each image will be, in pixels.
|
|
|
|
|
*
|
2016-06-19 06:41:43 +00:00
|
|
|
* @param string $num Number. Unit other than 'px is invalid. Invalid numbers
|
|
|
|
|
* and those below 0 are ignored.
|
2007-02-02 03:32:03 +00:00
|
|
|
*/
|
|
|
|
|
public function setWidths( $num ) {
|
2016-06-19 06:41:43 +00:00
|
|
|
$parsed = Parser::parseWidthParam( $num, false );
|
|
|
|
|
if ( isset( $parsed['width'] ) && $parsed['width'] > 0 ) {
|
|
|
|
|
$this->mWidths = $parsed['width'];
|
2007-02-02 03:32:03 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set how high each image will be, in pixels.
|
|
|
|
|
*
|
2016-06-19 06:41:43 +00:00
|
|
|
* @param string $num Number. Unit other than 'px is invalid. Invalid numbers
|
|
|
|
|
* and those below 0 are ignored.
|
2007-02-02 03:32:03 +00:00
|
|
|
*/
|
|
|
|
|
public function setHeights( $num ) {
|
2016-06-19 06:41:43 +00:00
|
|
|
$parsed = Parser::parseWidthParam( $num, false );
|
|
|
|
|
if ( isset( $parsed['width'] ) && $parsed['width'] > 0 ) {
|
|
|
|
|
$this->mHeights = $parsed['width'];
|
2007-02-02 03:32:03 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
New more slick gallery display
This extension adds a "mode" parameter to the gallery
tag, allowing different formats for the gallery tag
(galleries in the ui can be controlled by a global)
The added modes are:
*traditional - The original gallery
*nolines - Like the original, no borders, less padding
*packed - All images aligned by having same height.
JS also justifies the images.
(I think this one is the one that will go over best
with users.)
*packed-overlay - like packed, but caption goes over
top the image in a transloucent box.
*packed-hover - like packed-overlay, but caption only
visible on hover. Degrades gracefully on screen
readers, and falls back to packed-overlay if
you are using a touch screen. I kind of like
this mode when the caption is not that important
(ex a category where its just the file name).
This also adds a hook to allow people to make their
own gallery version. I believe there would be interest
in this, as different people have done different
experiments. For example:
* Wikia: http://community.wikia.com/wiki/Help:Galleries,_Slideshows,_and_Sliders/wikitext
* Wikinews: https://en.wikinews.org/wiki/Template:Picture_select
What I would like to see for this patch, is first it gets
enabled, with the default still "traditional". After
about a month or two we consult with users. If feedback
is positive, we change the default mode to one of the
others (probably "packed").
Adds a "mode" parameter to gallery for different
mode, including one 'height-constrained-overlay'
which looks much more like other modern websites.
Note: This makes one change to the old gallery format.
It makes Nonexistent files be rendered like thumbnails
(i.e. they are rendered with a little grey border).
One thing I'm slightly worried about with this patch,
is that I added an option to MediaTransformOutput::toHtml
to override the width attribute. I'm not sure if that
is the best approach, and would appreciate thoughts
on that.
This should be merged at the same time as Ie82c1548
Change-Id: I33462a8b52502ed76aeb163b66e3704c8618ba23
2013-06-08 04:47:07 +00:00
|
|
|
/**
|
|
|
|
|
* Allow setting additional options. This is meant
|
|
|
|
|
* to allow extensions to add additional parameters to
|
|
|
|
|
* <gallery> parser tag.
|
|
|
|
|
*
|
2020-07-13 09:20:52 +00:00
|
|
|
* @stable to override
|
2020-07-10 16:14:50 +00:00
|
|
|
*
|
2014-04-14 19:43:18 +00:00
|
|
|
* @param array $options Attributes of gallery tag
|
New more slick gallery display
This extension adds a "mode" parameter to the gallery
tag, allowing different formats for the gallery tag
(galleries in the ui can be controlled by a global)
The added modes are:
*traditional - The original gallery
*nolines - Like the original, no borders, less padding
*packed - All images aligned by having same height.
JS also justifies the images.
(I think this one is the one that will go over best
with users.)
*packed-overlay - like packed, but caption goes over
top the image in a transloucent box.
*packed-hover - like packed-overlay, but caption only
visible on hover. Degrades gracefully on screen
readers, and falls back to packed-overlay if
you are using a touch screen. I kind of like
this mode when the caption is not that important
(ex a category where its just the file name).
This also adds a hook to allow people to make their
own gallery version. I believe there would be interest
in this, as different people have done different
experiments. For example:
* Wikia: http://community.wikia.com/wiki/Help:Galleries,_Slideshows,_and_Sliders/wikitext
* Wikinews: https://en.wikinews.org/wiki/Template:Picture_select
What I would like to see for this patch, is first it gets
enabled, with the default still "traditional". After
about a month or two we consult with users. If feedback
is positive, we change the default mode to one of the
others (probably "packed").
Adds a "mode" parameter to gallery for different
mode, including one 'height-constrained-overlay'
which looks much more like other modern websites.
Note: This makes one change to the old gallery format.
It makes Nonexistent files be rendered like thumbnails
(i.e. they are rendered with a little grey border).
One thing I'm slightly worried about with this patch,
is that I added an option to MediaTransformOutput::toHtml
to override the width attribute. I'm not sure if that
is the best approach, and would appreciate thoughts
on that.
This should be merged at the same time as Ie82c1548
Change-Id: I33462a8b52502ed76aeb163b66e3704c8618ba23
2013-06-08 04:47:07 +00:00
|
|
|
*/
|
2013-11-24 18:36:13 +00:00
|
|
|
public function setAdditionalOptions( $options ) {
|
|
|
|
|
}
|
New more slick gallery display
This extension adds a "mode" parameter to the gallery
tag, allowing different formats for the gallery tag
(galleries in the ui can be controlled by a global)
The added modes are:
*traditional - The original gallery
*nolines - Like the original, no borders, less padding
*packed - All images aligned by having same height.
JS also justifies the images.
(I think this one is the one that will go over best
with users.)
*packed-overlay - like packed, but caption goes over
top the image in a transloucent box.
*packed-hover - like packed-overlay, but caption only
visible on hover. Degrades gracefully on screen
readers, and falls back to packed-overlay if
you are using a touch screen. I kind of like
this mode when the caption is not that important
(ex a category where its just the file name).
This also adds a hook to allow people to make their
own gallery version. I believe there would be interest
in this, as different people have done different
experiments. For example:
* Wikia: http://community.wikia.com/wiki/Help:Galleries,_Slideshows,_and_Sliders/wikitext
* Wikinews: https://en.wikinews.org/wiki/Template:Picture_select
What I would like to see for this patch, is first it gets
enabled, with the default still "traditional". After
about a month or two we consult with users. If feedback
is positive, we change the default mode to one of the
others (probably "packed").
Adds a "mode" parameter to gallery for different
mode, including one 'height-constrained-overlay'
which looks much more like other modern websites.
Note: This makes one change to the old gallery format.
It makes Nonexistent files be rendered like thumbnails
(i.e. they are rendered with a little grey border).
One thing I'm slightly worried about with this patch,
is that I added an option to MediaTransformOutput::toHtml
to override the width attribute. I'm not sure if that
is the best approach, and would appreciate thoughts
on that.
This should be merged at the same time as Ie82c1548
Change-Id: I33462a8b52502ed76aeb163b66e3704c8618ba23
2013-06-08 04:47:07 +00:00
|
|
|
|
2004-09-30 21:36:12 +00:00
|
|
|
/**
|
2005-01-05 22:07:44 +00:00
|
|
|
* Add an image to the gallery.
|
2004-09-30 21:36:12 +00:00
|
|
|
*
|
2013-11-24 19:06:17 +00:00
|
|
|
* @param Title $title Title object of the image that is added to the gallery
|
|
|
|
|
* @param string $html Additional HTML text to be shown. The name and size
|
|
|
|
|
* of the image are always shown.
|
|
|
|
|
* @param string $alt Alt text for the image
|
|
|
|
|
* @param string $link Override image link (optional)
|
|
|
|
|
* @param array $handlerOpts Array of options for image handler (aka page number)
|
2020-05-21 17:30:58 +00:00
|
|
|
* @param int $loading Sets loading attribute of the underlying <img> (optional)
|
2004-09-30 21:36:12 +00:00
|
|
|
*/
|
2020-05-21 17:30:58 +00:00
|
|
|
public function add(
|
|
|
|
|
$title,
|
|
|
|
|
$html = '',
|
|
|
|
|
$alt = '',
|
|
|
|
|
$link = '',
|
|
|
|
|
$handlerOpts = [],
|
|
|
|
|
$loading = self::LOADING_DEFAULT
|
|
|
|
|
) {
|
2007-05-30 21:02:32 +00:00
|
|
|
if ( $title instanceof File ) {
|
|
|
|
|
// Old calling convention
|
|
|
|
|
$title = $title->getTitle();
|
|
|
|
|
}
|
2020-05-21 17:30:58 +00:00
|
|
|
$this->mImages[] = [ $title, $html, $alt, $link, $handlerOpts, $loading ];
|
2020-06-01 05:00:39 +00:00
|
|
|
wfDebug( 'ImageGallery::add ' . $title->getText() );
|
2004-09-14 20:57:54 +00:00
|
|
|
}
|
2005-01-05 22:07:44 +00:00
|
|
|
|
2004-12-21 03:26:43 +00:00
|
|
|
/**
|
2012-04-10 10:30:17 +00:00
|
|
|
* Add an image at the beginning of the gallery.
|
|
|
|
|
*
|
2013-11-24 19:06:17 +00:00
|
|
|
* @param Title $title Title object of the image that is added to the gallery
|
|
|
|
|
* @param string $html Additional HTML text to be shown. The name and size
|
|
|
|
|
* of the image are always shown.
|
|
|
|
|
* @param string $alt Alt text for the image
|
2014-02-05 11:02:29 +00:00
|
|
|
* @param string $link Override image link (optional)
|
2013-11-24 19:06:17 +00:00
|
|
|
* @param array $handlerOpts Array of options for image handler (aka page number)
|
2020-05-21 17:30:58 +00:00
|
|
|
* @param int $loading Sets loading attribute of the underlying <img> (optional)
|
2012-04-10 10:30:17 +00:00
|
|
|
*/
|
2020-05-21 17:30:58 +00:00
|
|
|
public function insert(
|
|
|
|
|
$title,
|
|
|
|
|
$html = '',
|
|
|
|
|
$alt = '',
|
|
|
|
|
$link = '',
|
|
|
|
|
$handlerOpts = [],
|
|
|
|
|
$loading = self::LOADING_DEFAULT
|
|
|
|
|
) {
|
2007-06-15 15:02:44 +00:00
|
|
|
if ( $title instanceof File ) {
|
|
|
|
|
// Old calling convention
|
|
|
|
|
$title = $title->getTitle();
|
|
|
|
|
}
|
2020-05-21 17:30:58 +00:00
|
|
|
array_unshift( $this->mImages, [ &$title, $html, $alt, $link, $handlerOpts, $loading ] );
|
2004-12-21 03:26:43 +00:00
|
|
|
}
|
2004-09-14 20:57:54 +00:00
|
|
|
|
2014-06-13 23:08:52 +00:00
|
|
|
/**
|
|
|
|
|
* Returns the list of images this gallery contains
|
2019-11-04 18:17:18 +00:00
|
|
|
* @return array[]
|
|
|
|
|
* @phan-return array<int,array{0:Title,1:string,2:string,3:string,4:array}>
|
2014-06-13 23:08:52 +00:00
|
|
|
*/
|
|
|
|
|
public function getImages() {
|
|
|
|
|
return $this->mImages;
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-30 21:36:12 +00:00
|
|
|
/**
|
2005-04-16 04:33:34 +00:00
|
|
|
* isEmpty() returns true if the gallery contains no images
|
2012-02-09 21:33:27 +00:00
|
|
|
* @return bool
|
2004-09-30 21:36:12 +00:00
|
|
|
*/
|
2020-05-10 08:39:38 +00:00
|
|
|
public function isEmpty() {
|
2004-09-30 21:36:12 +00:00
|
|
|
return empty( $this->mImages );
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-06 12:32:38 +00:00
|
|
|
/**
|
|
|
|
|
* Enable/Disable showing of the dimensions of an image in the gallery.
|
|
|
|
|
* Enabled by default.
|
|
|
|
|
*
|
|
|
|
|
* @param bool $f Set to false to disable
|
|
|
|
|
*/
|
2020-05-10 08:39:38 +00:00
|
|
|
public function setShowDimensions( $f ) {
|
2017-03-06 12:32:38 +00:00
|
|
|
$this->mShowDimensions = (bool)$f;
|
|
|
|
|
}
|
|
|
|
|
|
2004-11-13 10:53:46 +00:00
|
|
|
/**
|
|
|
|
|
* Enable/Disable showing of the file size of an image in the gallery.
|
|
|
|
|
* Enabled by default.
|
2006-01-07 13:09:30 +00:00
|
|
|
*
|
2014-04-14 19:43:18 +00:00
|
|
|
* @param bool $f Set to false to disable
|
2004-11-13 10:53:46 +00:00
|
|
|
*/
|
2020-05-10 08:39:38 +00:00
|
|
|
public function setShowBytes( $f ) {
|
2010-06-09 15:06:11 +00:00
|
|
|
$this->mShowBytes = (bool)$f;
|
2004-11-13 10:53:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Enable/Disable showing of the filename of an image in the gallery.
|
|
|
|
|
* Enabled by default.
|
2006-01-07 13:09:30 +00:00
|
|
|
*
|
2014-04-14 19:43:18 +00:00
|
|
|
* @param bool $f Set to false to disable
|
2004-11-13 10:53:46 +00:00
|
|
|
*/
|
2020-05-10 08:39:38 +00:00
|
|
|
public function setShowFilename( $f ) {
|
2010-06-09 15:06:11 +00:00
|
|
|
$this->mShowFilename = (bool)$f;
|
2004-11-13 10:53:46 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2007-07-13 17:25:06 +00:00
|
|
|
/**
|
|
|
|
|
* Set arbitrary attributes to go on the HTML gallery output element.
|
2010-11-29 00:11:19 +00:00
|
|
|
* Should be suitable for a <ul> element.
|
2008-04-14 07:45:50 +00:00
|
|
|
*
|
2007-07-13 17:25:06 +00:00
|
|
|
* Note -- if taking from user input, you should probably run through
|
|
|
|
|
* Sanitizer::validateAttributes() first.
|
|
|
|
|
*
|
2013-11-24 19:06:17 +00:00
|
|
|
* @param array $attribs Array of HTML attribute pairs
|
2007-07-13 17:25:06 +00:00
|
|
|
*/
|
2020-05-10 08:39:38 +00:00
|
|
|
public function setAttributes( $attribs ) {
|
2007-07-13 17:25:06 +00:00
|
|
|
$this->mAttribs = $attribs;
|
|
|
|
|
}
|
2004-11-13 10:53:46 +00:00
|
|
|
|
2004-09-30 21:36:12 +00:00
|
|
|
/**
|
New more slick gallery display
This extension adds a "mode" parameter to the gallery
tag, allowing different formats for the gallery tag
(galleries in the ui can be controlled by a global)
The added modes are:
*traditional - The original gallery
*nolines - Like the original, no borders, less padding
*packed - All images aligned by having same height.
JS also justifies the images.
(I think this one is the one that will go over best
with users.)
*packed-overlay - like packed, but caption goes over
top the image in a transloucent box.
*packed-hover - like packed-overlay, but caption only
visible on hover. Degrades gracefully on screen
readers, and falls back to packed-overlay if
you are using a touch screen. I kind of like
this mode when the caption is not that important
(ex a category where its just the file name).
This also adds a hook to allow people to make their
own gallery version. I believe there would be interest
in this, as different people have done different
experiments. For example:
* Wikia: http://community.wikia.com/wiki/Help:Galleries,_Slideshows,_and_Sliders/wikitext
* Wikinews: https://en.wikinews.org/wiki/Template:Picture_select
What I would like to see for this patch, is first it gets
enabled, with the default still "traditional". After
about a month or two we consult with users. If feedback
is positive, we change the default mode to one of the
others (probably "packed").
Adds a "mode" parameter to gallery for different
mode, including one 'height-constrained-overlay'
which looks much more like other modern websites.
Note: This makes one change to the old gallery format.
It makes Nonexistent files be rendered like thumbnails
(i.e. they are rendered with a little grey border).
One thing I'm slightly worried about with this patch,
is that I added an option to MediaTransformOutput::toHtml
to override the width attribute. I'm not sure if that
is the best approach, and would appreciate thoughts
on that.
This should be merged at the same time as Ie82c1548
Change-Id: I33462a8b52502ed76aeb163b66e3704c8618ba23
2013-06-08 04:47:07 +00:00
|
|
|
* Display an html representation of the gallery
|
2006-01-07 13:09:30 +00:00
|
|
|
*
|
2013-11-24 19:06:17 +00:00
|
|
|
* @return string The html
|
2004-09-30 21:36:12 +00:00
|
|
|
*/
|
New more slick gallery display
This extension adds a "mode" parameter to the gallery
tag, allowing different formats for the gallery tag
(galleries in the ui can be controlled by a global)
The added modes are:
*traditional - The original gallery
*nolines - Like the original, no borders, less padding
*packed - All images aligned by having same height.
JS also justifies the images.
(I think this one is the one that will go over best
with users.)
*packed-overlay - like packed, but caption goes over
top the image in a transloucent box.
*packed-hover - like packed-overlay, but caption only
visible on hover. Degrades gracefully on screen
readers, and falls back to packed-overlay if
you are using a touch screen. I kind of like
this mode when the caption is not that important
(ex a category where its just the file name).
This also adds a hook to allow people to make their
own gallery version. I believe there would be interest
in this, as different people have done different
experiments. For example:
* Wikia: http://community.wikia.com/wiki/Help:Galleries,_Slideshows,_and_Sliders/wikitext
* Wikinews: https://en.wikinews.org/wiki/Template:Picture_select
What I would like to see for this patch, is first it gets
enabled, with the default still "traditional". After
about a month or two we consult with users. If feedback
is positive, we change the default mode to one of the
others (probably "packed").
Adds a "mode" parameter to gallery for different
mode, including one 'height-constrained-overlay'
which looks much more like other modern websites.
Note: This makes one change to the old gallery format.
It makes Nonexistent files be rendered like thumbnails
(i.e. they are rendered with a little grey border).
One thing I'm slightly worried about with this patch,
is that I added an option to MediaTransformOutput::toHtml
to override the width attribute. I'm not sure if that
is the best approach, and would appreciate thoughts
on that.
This should be merged at the same time as Ie82c1548
Change-Id: I33462a8b52502ed76aeb163b66e3704c8618ba23
2013-06-08 04:47:07 +00:00
|
|
|
abstract public function toHTML();
|
2007-02-02 03:32:03 +00:00
|
|
|
|
2006-11-24 06:41:02 +00:00
|
|
|
/**
|
2013-11-24 19:06:17 +00:00
|
|
|
* @return int Number of images in the gallery
|
2006-11-24 06:41:02 +00:00
|
|
|
*/
|
|
|
|
|
public function count() {
|
|
|
|
|
return count( $this->mImages );
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2007-01-20 22:34:05 +00:00
|
|
|
/**
|
|
|
|
|
* Set the contextual title
|
|
|
|
|
*
|
2019-08-27 17:21:28 +00:00
|
|
|
* @param Title|null $title Contextual title
|
2007-01-20 22:34:05 +00:00
|
|
|
*/
|
|
|
|
|
public function setContextTitle( $title ) {
|
|
|
|
|
$this->contextTitle = $title;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2007-01-20 22:34:05 +00:00
|
|
|
/**
|
|
|
|
|
* Get the contextual title, if applicable
|
|
|
|
|
*
|
2019-08-27 17:21:28 +00:00
|
|
|
* @return Title|null
|
2007-01-20 22:34:05 +00:00
|
|
|
*/
|
|
|
|
|
public function getContextTitle() {
|
2019-08-27 17:21:28 +00:00
|
|
|
return $this->contextTitle;
|
2007-01-20 22:34:05 +00:00
|
|
|
}
|
2004-09-14 20:57:54 +00:00
|
|
|
|
2013-03-09 13:59:36 +00:00
|
|
|
/**
|
|
|
|
|
* Determines the correct language to be used for this image gallery
|
2013-11-24 19:06:17 +00:00
|
|
|
* @return Language
|
2013-03-09 13:59:36 +00:00
|
|
|
*/
|
New more slick gallery display
This extension adds a "mode" parameter to the gallery
tag, allowing different formats for the gallery tag
(galleries in the ui can be controlled by a global)
The added modes are:
*traditional - The original gallery
*nolines - Like the original, no borders, less padding
*packed - All images aligned by having same height.
JS also justifies the images.
(I think this one is the one that will go over best
with users.)
*packed-overlay - like packed, but caption goes over
top the image in a transloucent box.
*packed-hover - like packed-overlay, but caption only
visible on hover. Degrades gracefully on screen
readers, and falls back to packed-overlay if
you are using a touch screen. I kind of like
this mode when the caption is not that important
(ex a category where its just the file name).
This also adds a hook to allow people to make their
own gallery version. I believe there would be interest
in this, as different people have done different
experiments. For example:
* Wikia: http://community.wikia.com/wiki/Help:Galleries,_Slideshows,_and_Sliders/wikitext
* Wikinews: https://en.wikinews.org/wiki/Template:Picture_select
What I would like to see for this patch, is first it gets
enabled, with the default still "traditional". After
about a month or two we consult with users. If feedback
is positive, we change the default mode to one of the
others (probably "packed").
Adds a "mode" parameter to gallery for different
mode, including one 'height-constrained-overlay'
which looks much more like other modern websites.
Note: This makes one change to the old gallery format.
It makes Nonexistent files be rendered like thumbnails
(i.e. they are rendered with a little grey border).
One thing I'm slightly worried about with this patch,
is that I added an option to MediaTransformOutput::toHtml
to override the width attribute. I'm not sure if that
is the best approach, and would appreciate thoughts
on that.
This should be merged at the same time as Ie82c1548
Change-Id: I33462a8b52502ed76aeb163b66e3704c8618ba23
2013-06-08 04:47:07 +00:00
|
|
|
protected function getRenderLang() {
|
2013-03-09 13:59:36 +00:00
|
|
|
return $this->mParser
|
|
|
|
|
? $this->mParser->getTargetLanguage()
|
New more slick gallery display
This extension adds a "mode" parameter to the gallery
tag, allowing different formats for the gallery tag
(galleries in the ui can be controlled by a global)
The added modes are:
*traditional - The original gallery
*nolines - Like the original, no borders, less padding
*packed - All images aligned by having same height.
JS also justifies the images.
(I think this one is the one that will go over best
with users.)
*packed-overlay - like packed, but caption goes over
top the image in a transloucent box.
*packed-hover - like packed-overlay, but caption only
visible on hover. Degrades gracefully on screen
readers, and falls back to packed-overlay if
you are using a touch screen. I kind of like
this mode when the caption is not that important
(ex a category where its just the file name).
This also adds a hook to allow people to make their
own gallery version. I believe there would be interest
in this, as different people have done different
experiments. For example:
* Wikia: http://community.wikia.com/wiki/Help:Galleries,_Slideshows,_and_Sliders/wikitext
* Wikinews: https://en.wikinews.org/wiki/Template:Picture_select
What I would like to see for this patch, is first it gets
enabled, with the default still "traditional". After
about a month or two we consult with users. If feedback
is positive, we change the default mode to one of the
others (probably "packed").
Adds a "mode" parameter to gallery for different
mode, including one 'height-constrained-overlay'
which looks much more like other modern websites.
Note: This makes one change to the old gallery format.
It makes Nonexistent files be rendered like thumbnails
(i.e. they are rendered with a little grey border).
One thing I'm slightly worried about with this patch,
is that I added an option to MediaTransformOutput::toHtml
to override the width attribute. I'm not sure if that
is the best approach, and would appreciate thoughts
on that.
This should be merged at the same time as Ie82c1548
Change-Id: I33462a8b52502ed76aeb163b66e3704c8618ba23
2013-06-08 04:47:07 +00:00
|
|
|
: $this->getLanguage();
|
2013-03-09 13:59:36 +00:00
|
|
|
}
|
New more slick gallery display
This extension adds a "mode" parameter to the gallery
tag, allowing different formats for the gallery tag
(galleries in the ui can be controlled by a global)
The added modes are:
*traditional - The original gallery
*nolines - Like the original, no borders, less padding
*packed - All images aligned by having same height.
JS also justifies the images.
(I think this one is the one that will go over best
with users.)
*packed-overlay - like packed, but caption goes over
top the image in a transloucent box.
*packed-hover - like packed-overlay, but caption only
visible on hover. Degrades gracefully on screen
readers, and falls back to packed-overlay if
you are using a touch screen. I kind of like
this mode when the caption is not that important
(ex a category where its just the file name).
This also adds a hook to allow people to make their
own gallery version. I believe there would be interest
in this, as different people have done different
experiments. For example:
* Wikia: http://community.wikia.com/wiki/Help:Galleries,_Slideshows,_and_Sliders/wikitext
* Wikinews: https://en.wikinews.org/wiki/Template:Picture_select
What I would like to see for this patch, is first it gets
enabled, with the default still "traditional". After
about a month or two we consult with users. If feedback
is positive, we change the default mode to one of the
others (probably "packed").
Adds a "mode" parameter to gallery for different
mode, including one 'height-constrained-overlay'
which looks much more like other modern websites.
Note: This makes one change to the old gallery format.
It makes Nonexistent files be rendered like thumbnails
(i.e. they are rendered with a little grey border).
One thing I'm slightly worried about with this patch,
is that I added an option to MediaTransformOutput::toHtml
to override the width attribute. I'm not sure if that
is the best approach, and would appreciate thoughts
on that.
This should be merged at the same time as Ie82c1548
Change-Id: I33462a8b52502ed76aeb163b66e3704c8618ba23
2013-06-08 04:47:07 +00:00
|
|
|
}
|