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
|
|
|
|
|
*/
|
|
|
|
|
|
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().
|
|
|
|
|
*
|
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
|
|
|
*/
|
2011-05-16 13:04:57 +00:00
|
|
|
class ImageGallery {
|
2004-11-13 10:53:46 +00:00
|
|
|
var $mImages, $mShowBytes, $mShowFilename;
|
2006-06-24 00:12:34 +00:00
|
|
|
var $mCaption = false;
|
2007-02-02 03:32:03 +00:00
|
|
|
|
2006-05-16 19:15:58 +00:00
|
|
|
/**
|
2007-08-22 13:40:22 +00:00
|
|
|
* Hide blacklisted images?
|
2006-05-16 19:15:58 +00:00
|
|
|
*/
|
2007-08-22 13:40:22 +00:00
|
|
|
var $mHideBadImages;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Registered parser object for output callbacks
|
2011-03-24 00:43:27 +00:00
|
|
|
* @var Parser
|
2007-08-22 13:40:22 +00:00
|
|
|
*/
|
|
|
|
|
var $mParser;
|
2007-02-02 03:32:03 +00:00
|
|
|
|
2007-01-20 22:34:05 +00:00
|
|
|
/**
|
|
|
|
|
* Contextual title, used when images are being screened
|
|
|
|
|
* against the bad image list
|
|
|
|
|
*/
|
2011-08-17 22:42:49 +00:00
|
|
|
protected $contextTitle = false;
|
2004-09-14 20:57:54 +00:00
|
|
|
|
2011-08-17 22:42:49 +00:00
|
|
|
protected $mAttribs = array();
|
2007-02-02 03:32:03 +00:00
|
|
|
|
2011-03-14 21:08:32 +00:00
|
|
|
/**
|
|
|
|
|
* Fixed margins
|
|
|
|
|
*/
|
|
|
|
|
const THUMB_PADDING = 30;
|
|
|
|
|
const GB_PADDING = 5;
|
2011-05-16 13:04:57 +00:00
|
|
|
// 2px borders on each side + 2px implied padding on each side
|
2011-05-02 18:00:09 +00:00
|
|
|
const GB_BORDERS = 8;
|
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.
|
|
|
|
|
*/
|
2011-05-16 13:04:57 +00:00
|
|
|
function __construct() {
|
2010-03-13 11:42:04 +00:00
|
|
|
global $wgGalleryOptions;
|
2004-11-13 10:53:46 +00:00
|
|
|
$this->mImages = array();
|
2010-03-13 11:42:04 +00:00
|
|
|
$this->mShowBytes = $wgGalleryOptions['showBytes'];
|
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;
|
2010-03-13 11:42:04 +00:00
|
|
|
$this->mPerRow = $wgGalleryOptions['imagesPerRow'];
|
|
|
|
|
$this->mWidths = $wgGalleryOptions['imageWidth'];
|
|
|
|
|
$this->mHeights = $wgGalleryOptions['imageHeight'];
|
|
|
|
|
$this->mCaptionLength = $wgGalleryOptions['captionLength'];
|
2006-05-16 19:15:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2007-08-22 13:40:22 +00:00
|
|
|
* Register a parser object
|
2011-05-28 18:59:42 +00:00
|
|
|
*
|
|
|
|
|
* @param $parser Parser
|
2006-05-16 19:15:58 +00:00
|
|
|
*/
|
2007-08-22 13:40:22 +00:00
|
|
|
function setParser( $parser ) {
|
|
|
|
|
$this->mParser = $parser;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set bad image flag
|
|
|
|
|
*/
|
|
|
|
|
function setHideBadImages( $flag = true ) {
|
|
|
|
|
$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
|
|
|
*
|
2012-02-09 19:30:01 +00:00
|
|
|
* @param $caption string Caption
|
2006-06-24 00:12:34 +00:00
|
|
|
*/
|
|
|
|
|
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)
|
|
|
|
|
*
|
2010-11-13 00:47:51 +00:00
|
|
|
* @param $caption 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.
|
|
|
|
|
*
|
2010-11-29 00:11:19 +00:00
|
|
|
* @param $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.
|
|
|
|
|
*
|
2010-03-01 21:36:57 +00:00
|
|
|
* @param $num Integer > 0; invalid numbers will be ignored
|
2007-02-02 03:32:03 +00:00
|
|
|
*/
|
|
|
|
|
public function setWidths( $num ) {
|
2011-05-16 13:04:57 +00:00
|
|
|
if ( $num > 0 ) {
|
2007-02-02 03:32:03 +00:00
|
|
|
$this->mWidths = (int)$num;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set how high each image will be, in pixels.
|
|
|
|
|
*
|
2010-03-01 21:36:57 +00:00
|
|
|
* @param $num Integer > 0; invalid numbers will be ignored
|
2007-02-02 03:32:03 +00:00
|
|
|
*/
|
|
|
|
|
public function setHeights( $num ) {
|
2011-05-16 13:04:57 +00:00
|
|
|
if ( $num > 0 ) {
|
2007-02-02 03:32:03 +00:00
|
|
|
$this->mHeights = (int)$num;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-11-08 07:12:03 +00:00
|
|
|
/**
|
|
|
|
|
* Instruct the class to use a specific skin for rendering
|
|
|
|
|
*
|
|
|
|
|
* @param $skin Skin object
|
2011-05-06 21:50:18 +00:00
|
|
|
* @deprecated since 1.18 Not used anymore
|
2006-11-08 07:12:03 +00:00
|
|
|
*/
|
|
|
|
|
function useSkin( $skin ) {
|
2011-12-13 05:19:05 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.18' );
|
2011-04-03 12:04:04 +00:00
|
|
|
/* no op */
|
2006-11-08 07:12:03 +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
|
|
|
*
|
2007-05-30 21:02:32 +00:00
|
|
|
* @param $title Title object of the image that is added to the gallery
|
2011-04-25 13:51:54 +00:00
|
|
|
* @param $html String: Additional HTML text to be shown. The name and size of the image are always shown.
|
|
|
|
|
* @param $alt String: Alt text for the image
|
2012-04-10 10:30:17 +00:00
|
|
|
* @param $link String: Override image link (optional)
|
2004-09-30 21:36:12 +00:00
|
|
|
*/
|
2012-04-10 10:30:17 +00:00
|
|
|
function add( $title, $html = '', $alt = '', $link = '') {
|
2007-05-30 21:02:32 +00:00
|
|
|
if ( $title instanceof File ) {
|
|
|
|
|
// Old calling convention
|
|
|
|
|
$title = $title->getTitle();
|
|
|
|
|
}
|
2012-04-10 10:30:17 +00:00
|
|
|
$this->mImages[] = array( $title, $html, $alt, $link );
|
2011-05-16 13:04:57 +00:00
|
|
|
wfDebug( 'ImageGallery::add ' . $title->getText() . "\n" );
|
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.
|
|
|
|
|
*
|
|
|
|
|
* @param $title Title object of the image that is added to the gallery
|
|
|
|
|
* @param $html String: Additional HTML text to be shown. The name and size of the image are always shown.
|
|
|
|
|
* @param $alt String: Alt text for the image
|
|
|
|
|
*/
|
2011-05-16 13:04:57 +00:00
|
|
|
function insert( $title, $html = '', $alt = '' ) {
|
2007-06-15 15:02:44 +00:00
|
|
|
if ( $title instanceof File ) {
|
|
|
|
|
// Old calling convention
|
|
|
|
|
$title = $title->getTitle();
|
|
|
|
|
}
|
2011-04-25 13:51:54 +00:00
|
|
|
array_unshift( $this->mImages, array( &$title, $html, $alt ) );
|
2004-12-21 03:26:43 +00:00
|
|
|
}
|
2004-09-14 20:57:54 +00:00
|
|
|
|
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
|
|
|
*/
|
|
|
|
|
function isEmpty() {
|
|
|
|
|
return empty( $this->mImages );
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
*
|
2006-04-19 15:46:24 +00:00
|
|
|
* @param $f Boolean: set to false to disable.
|
2004-11-13 10:53:46 +00:00
|
|
|
*/
|
|
|
|
|
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
|
|
|
*
|
2006-04-19 15:46:24 +00:00
|
|
|
* @param $f Boolean: set to false to disable.
|
2004-11-13 10:53:46 +00:00
|
|
|
*/
|
|
|
|
|
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.
|
|
|
|
|
*
|
2010-03-01 21:36:57 +00:00
|
|
|
* @param $attribs Array of HTML attribute pairs
|
2007-07-13 17:25:06 +00:00
|
|
|
*/
|
|
|
|
|
function setAttributes( $attribs ) {
|
|
|
|
|
$this->mAttribs = $attribs;
|
|
|
|
|
}
|
2004-11-13 10:53:46 +00:00
|
|
|
|
2004-09-30 21:36:12 +00:00
|
|
|
/**
|
|
|
|
|
* Return a HTML representation of the image gallery
|
2006-01-07 13:09:30 +00:00
|
|
|
*
|
2004-09-30 21:36:12 +00:00
|
|
|
* For each image in the gallery, display
|
|
|
|
|
* - a thumbnail
|
|
|
|
|
* - the image name
|
|
|
|
|
* - the additional text provided when adding the image
|
|
|
|
|
* - the size of the image
|
|
|
|
|
*
|
2012-02-09 21:33:27 +00:00
|
|
|
* @return string
|
2004-09-30 21:36:12 +00:00
|
|
|
*/
|
2004-09-14 20:57:54 +00:00
|
|
|
function toHTML() {
|
2007-04-20 12:31:36 +00:00
|
|
|
global $wgLang;
|
2004-09-14 20:57:54 +00:00
|
|
|
|
2010-11-29 00:11:19 +00:00
|
|
|
if ( $this->mPerRow > 0 ) {
|
2011-03-14 21:08:32 +00:00
|
|
|
$maxwidth = $this->mPerRow * ( $this->mWidths + self::THUMB_PADDING + self::GB_PADDING + self::GB_BORDERS );
|
2011-07-15 23:18:38 +00:00
|
|
|
$oldStyle = isset( $this->mAttribs['style'] ) ? $this->mAttribs['style'] : '';
|
2011-04-25 13:51:54 +00:00
|
|
|
# _width is ignored by any sane browser. IE6 doesn't know max-width so it uses _width instead
|
2011-02-20 21:31:15 +00:00
|
|
|
$this->mAttribs['style'] = "max-width: {$maxwidth}px;_width: {$maxwidth}px;" . $oldStyle;
|
2010-11-29 00:11:19 +00:00
|
|
|
}
|
|
|
|
|
|
2007-07-13 17:25:06 +00:00
|
|
|
$attribs = Sanitizer::mergeAttributes(
|
2011-03-24 01:44:48 +00:00
|
|
|
array( 'class' => 'gallery' ), $this->mAttribs );
|
|
|
|
|
|
2011-04-25 13:51:54 +00:00
|
|
|
$output = Xml::openElement( 'ul', $attribs );
|
2010-11-29 00:11:19 +00:00
|
|
|
if ( $this->mCaption ) {
|
2011-04-25 13:51:54 +00:00
|
|
|
$output .= "\n\t<li class='gallerycaption'>{$this->mCaption}</li>";
|
2010-11-29 00:11:19 +00:00
|
|
|
}
|
2007-02-02 03:32:03 +00:00
|
|
|
|
2011-05-16 13:04:57 +00:00
|
|
|
$params = array(
|
|
|
|
|
'width' => $this->mWidths,
|
|
|
|
|
'height' => $this->mHeights
|
|
|
|
|
);
|
2011-03-23 21:21:31 +00:00
|
|
|
# Output each image...
|
2004-09-14 20:57:54 +00:00
|
|
|
foreach ( $this->mImages as $pair ) {
|
2007-05-30 21:02:32 +00:00
|
|
|
$nt = $pair[0];
|
2009-07-15 04:18:16 +00:00
|
|
|
$text = $pair[1]; # "text" means "caption" here
|
2011-04-25 13:51:54 +00:00
|
|
|
$alt = $pair[2];
|
2012-04-10 10:30:17 +00:00
|
|
|
$link = $pair[3];
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2011-03-24 01:44:48 +00:00
|
|
|
$descQuery = false;
|
2010-11-10 09:16:28 +00:00
|
|
|
if ( $nt->getNamespace() == NS_FILE ) {
|
2011-03-23 21:21:31 +00:00
|
|
|
# Get the file...
|
|
|
|
|
if ( $this->mParser instanceof Parser ) {
|
2011-03-24 01:44:48 +00:00
|
|
|
# Give extensions a chance to select the file revision for us
|
2011-09-06 18:11:53 +00:00
|
|
|
$options = array();
|
2011-03-24 01:44:48 +00:00
|
|
|
wfRunHooks( 'BeforeParserFetchFileAndTitle',
|
2011-09-06 18:11:53 +00:00
|
|
|
array( $this->mParser, $nt, &$options, &$descQuery ) );
|
2011-03-23 21:21:31 +00:00
|
|
|
# Fetch and register the file (file title may be different via hooks)
|
2011-09-06 18:11:53 +00:00
|
|
|
list( $img, $nt ) = $this->mParser->fetchFileAndTitle( $nt, $options );
|
2011-03-23 21:21:31 +00:00
|
|
|
} else {
|
2011-03-24 01:44:48 +00:00
|
|
|
$img = wfFindFile( $nt );
|
2011-03-23 21:21:31 +00:00
|
|
|
}
|
2010-11-10 09:16:28 +00:00
|
|
|
} else {
|
|
|
|
|
$img = false;
|
|
|
|
|
}
|
2004-09-14 20:57:54 +00:00
|
|
|
|
2010-11-10 09:16:28 +00:00
|
|
|
if( !$img ) {
|
2006-06-29 23:27:13 +00:00
|
|
|
# We're dealing with a non-image, spit out the name and be done with it.
|
2011-05-16 13:04:57 +00:00
|
|
|
$thumbhtml = "\n\t\t\t" . '<div style="height: ' . ( self::THUMB_PADDING + $this->mHeights ) . 'px;">'
|
2007-02-02 03:32:03 +00:00
|
|
|
. htmlspecialchars( $nt->getText() ) . '</div>';
|
2007-08-22 13:40:22 +00:00
|
|
|
} elseif( $this->mHideBadImages && wfIsBadImage( $nt->getDBkey(), $this->getContextTitle() ) ) {
|
2006-06-29 23:27:13 +00:00
|
|
|
# The image is blacklisted, just show it as a text link.
|
2011-05-16 13:04:57 +00:00
|
|
|
$thumbhtml = "\n\t\t\t" . '<div style="height: ' . ( self::THUMB_PADDING + $this->mHeights ) . 'px;">' .
|
2011-04-03 12:04:04 +00:00
|
|
|
Linker::link(
|
2009-06-06 17:00:20 +00:00
|
|
|
$nt,
|
|
|
|
|
htmlspecialchars( $nt->getText() ),
|
2009-06-06 17:05:48 +00:00
|
|
|
array(),
|
2009-06-06 17:00:20 +00:00
|
|
|
array(),
|
|
|
|
|
array( 'known', 'noclasses' )
|
|
|
|
|
) .
|
|
|
|
|
'</div>';
|
2007-04-20 12:31:36 +00:00
|
|
|
} elseif( !( $thumb = $img->transform( $params ) ) ) {
|
2006-06-29 23:27:13 +00:00
|
|
|
# Error generating thumbnail.
|
2011-05-16 13:04:57 +00:00
|
|
|
$thumbhtml = "\n\t\t\t" . '<div style="height: ' . ( self::THUMB_PADDING + $this->mHeights ) . 'px;">'
|
2006-06-29 23:27:13 +00:00
|
|
|
. htmlspecialchars( $img->getLastError() ) . '</div>';
|
2007-01-20 22:34:05 +00:00
|
|
|
} else {
|
2011-07-06 18:07:31 +00:00
|
|
|
$vpad = ( self::THUMB_PADDING + $this->mHeights - $thumb->height ) /2;
|
2010-12-22 16:21:02 +00:00
|
|
|
|
2009-07-15 04:18:16 +00:00
|
|
|
$imageParameters = array(
|
|
|
|
|
'desc-link' => true,
|
2011-04-25 13:51:54 +00:00
|
|
|
'desc-query' => $descQuery,
|
|
|
|
|
'alt' => $alt,
|
2012-04-10 10:30:17 +00:00
|
|
|
'custom-url-link' => $link
|
2009-07-15 04:18:16 +00:00
|
|
|
);
|
2011-04-25 13:51:54 +00:00
|
|
|
# In the absence of both alt text and caption, fall back on providing screen readers with the filename as alt text
|
|
|
|
|
if ( $alt == '' && $text == '' ) {
|
2009-07-15 04:18:16 +00:00
|
|
|
$imageParameters['alt'] = $nt->getText();
|
|
|
|
|
}
|
2010-12-22 16:21:02 +00:00
|
|
|
|
2011-02-15 19:39:45 +00:00
|
|
|
# Set both fixed width and min-height.
|
2011-05-16 13:04:57 +00:00
|
|
|
$thumbhtml = "\n\t\t\t" .
|
|
|
|
|
'<div class="thumb" style="width: ' . ( $this->mWidths + self::THUMB_PADDING ) . 'px;">'
|
2007-08-31 02:51:23 +00:00
|
|
|
# Auto-margin centering for block-level elements. Needed now that we have video
|
|
|
|
|
# handlers since they may emit block-level elements as opposed to simple <img> tags.
|
|
|
|
|
# ref http://css-discuss.incutio.com/?page=CenteringBlockElement
|
2011-05-16 13:04:57 +00:00
|
|
|
. '<div style="margin:' . $vpad . 'px auto;">'
|
2009-07-15 04:18:16 +00:00
|
|
|
. $thumb->toHtml( $imageParameters ) . '</div></div>';
|
2007-08-22 13:40:22 +00:00
|
|
|
|
|
|
|
|
// Call parser transform hook
|
|
|
|
|
if ( $this->mParser && $img->getHandler() ) {
|
|
|
|
|
$img->getHandler()->parserTransformHook( $this->mParser, $img );
|
|
|
|
|
}
|
2004-12-07 23:44:04 +00:00
|
|
|
}
|
|
|
|
|
|
2004-09-14 20:57:54 +00:00
|
|
|
//TODO
|
2009-06-06 17:00:20 +00:00
|
|
|
// $linkTarget = Title::newFromText( $wgContLang->getNsText( MWNamespace::getUser() ) . ":{$ut}" );
|
2011-04-03 12:04:04 +00:00
|
|
|
// $ul = Linker::link( $linkTarget, $ut );
|
2004-09-14 20:57:54 +00:00
|
|
|
|
2004-12-05 19:14:31 +00:00
|
|
|
if( $this->mShowBytes ) {
|
2007-05-30 21:02:32 +00:00
|
|
|
if( $img ) {
|
2012-01-19 16:55:42 +00:00
|
|
|
$fileSize = htmlspecialchars( $wgLang->formatSize( $img->getSize() ) );
|
2004-12-05 19:14:31 +00:00
|
|
|
} else {
|
2011-04-25 13:51:54 +00:00
|
|
|
$fileSize = wfMsgHtml( 'filemissing' );
|
2004-12-05 19:14:31 +00:00
|
|
|
}
|
2011-04-25 13:51:54 +00:00
|
|
|
$fileSize = "$fileSize<br />\n";
|
2004-12-05 19:14:31 +00:00
|
|
|
} else {
|
2011-04-25 13:51:54 +00:00
|
|
|
$fileSize = '';
|
2004-12-05 19:14:31 +00:00
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2004-11-13 10:53:46 +00:00
|
|
|
$textlink = $this->mShowFilename ?
|
2011-04-03 12:04:04 +00:00
|
|
|
Linker::link(
|
2009-06-06 17:00:20 +00:00
|
|
|
$nt,
|
2010-03-13 11:42:04 +00:00
|
|
|
htmlspecialchars( $wgLang->truncate( $nt->getText(), $this->mCaptionLength ) ),
|
2009-06-06 17:00:20 +00:00
|
|
|
array(),
|
|
|
|
|
array(),
|
|
|
|
|
array( 'known', 'noclasses' )
|
|
|
|
|
) . "<br />\n" :
|
2004-11-13 10:53:46 +00:00
|
|
|
'' ;
|
2004-09-14 20:57:54 +00:00
|
|
|
|
2006-06-29 23:27:13 +00:00
|
|
|
# ATTENTION: The newline after <div class="gallerytext"> is needed to accommodate htmltidy which
|
|
|
|
|
# in version 4.8.6 generated crackpot html in its absence, see:
|
|
|
|
|
# http://bugzilla.wikimedia.org/show_bug.cgi?id=1765 -Ævar
|
|
|
|
|
|
2011-04-25 13:51:54 +00:00
|
|
|
# Weird double wrapping (the extra div inside the li) needed due to FF2 bug
|
2010-11-29 00:11:19 +00:00
|
|
|
# Can be safely removed if FF2 falls completely out of existance
|
2011-04-25 13:51:54 +00:00
|
|
|
$output .=
|
2011-03-14 21:08:32 +00:00
|
|
|
"\n\t\t" . '<li class="gallerybox" style="width: ' . ( $this->mWidths + self::THUMB_PADDING + self::GB_PADDING ) . 'px">'
|
|
|
|
|
. '<div style="width: ' . ( $this->mWidths + self::THUMB_PADDING + self::GB_PADDING ) . 'px">'
|
2007-02-02 03:32:03 +00:00
|
|
|
. $thumbhtml
|
|
|
|
|
. "\n\t\t\t" . '<div class="gallerytext">' . "\n"
|
2012-04-10 10:30:17 +00:00
|
|
|
. $textlink . $text . $fileSize
|
2007-02-02 03:32:03 +00:00
|
|
|
. "\n\t\t\t</div>"
|
2012-04-10 10:30:17 +00:00
|
|
|
. "\n\t\t</div></li>";
|
2004-09-14 20:57:54 +00:00
|
|
|
}
|
2011-04-25 13:51:54 +00:00
|
|
|
$output .= "\n</ul>";
|
2004-09-14 20:57:54 +00:00
|
|
|
|
2011-04-25 13:51:54 +00:00
|
|
|
return $output;
|
2004-09-14 20:57:54 +00:00
|
|
|
}
|
2007-02-02 03:32:03 +00:00
|
|
|
|
2006-11-24 06:41:02 +00:00
|
|
|
/**
|
2010-03-01 21:36:57 +00:00
|
|
|
* @return Integer: 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
|
|
|
|
|
*
|
2010-03-01 21:36:57 +00:00
|
|
|
* @param $title 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
|
|
|
|
|
*
|
|
|
|
|
* @return mixed Title or false
|
|
|
|
|
*/
|
|
|
|
|
public function getContextTitle() {
|
|
|
|
|
return is_object( $this->contextTitle ) && $this->contextTitle instanceof Title
|
2012-04-10 10:30:17 +00:00
|
|
|
? $this->contextTitle
|
|
|
|
|
: false;
|
2007-01-20 22:34:05 +00:00
|
|
|
}
|
2004-09-14 20:57:54 +00:00
|
|
|
|
|
|
|
|
} //class
|