8184ce498732b3172ea695b588f9f6d416de0776
7 * This is not a valid entry point, perform no further processing unless MEDIAWIKI is defined
9 if( defined( 'MEDIAWIKI' ) ) {
15 * Add images to the gallery using add(), then render that list to HTML using toHTML().
21 var $mImages, $mShowBytes, $mShowFilename;
24 * Create a new image gallery object.
26 function ImageGallery( ) {
27 $this->mImages
= array();
28 $this->mShowBytes
= true;
29 $this->mShowFilename
= true;
33 * Add an image to the gallery.
35 * @param Image $image Image object that is added to the gallery
36 * @param string $text Additional text to be shown. The name and size of the image are always shown.
38 function add( $image, $text='' ) {
39 $this->mImages
[] = array( &$image, $text );
43 * isEmpty() returns false iff the gallery doesn't contain any images
46 return empty( $this->mImages
);
50 * Enable/Disable showing of the file size of an image in the gallery.
53 * @param boolean $f set to false to disable
55 function setShowBytes( $f ) {
56 $this->mShowBytes
= ( $f == true);
60 * Enable/Disable showing of the filename of an image in the gallery.
63 * @param boolean $f set to false to disable
65 function setShowFilename( $f ) {
66 $this->mShowFilename
= ( $f == true);
70 * Return a HTML representation of the image gallery
72 * For each image in the gallery, display
75 * - the additional text provided when adding the image
76 * - the size of the image
80 global $wgLang, $wgContLang, $wgUser;
82 $sk = $wgUser->getSkin();
84 $s = '<table style="border:solid 1px #DDDDDD; cellspacing:0; cellpadding:0; margin:1em;">';
86 foreach ( $this->mImages
as $pair ) {
90 $name = $img->getName();
91 $nt = $img->getTitle();
94 //$ul = $sk->makeLink( $wgContLang->getNsText( Namespace::getUser() ) . ":{$ut}", $ut );
96 $nb = $this->mShowBytes ?
97 wfMsg( "nbytes", $wgLang->formatNum( $img->getSize() ) ) . '<br />' :
99 $textlink = $this->mShowFilename ?
100 $sk->makeKnownLinkObj( $nt, htmlspecialchars( $wgLang->truncate( $nt->getText(), 20, '...' ) ) ) . '<br />' :
103 $s .= ($i%4
==0) ?
'<tr>' : '';
104 $s .= '<td valign="top" width="150px" style="background-color:#F0F0F0;">' .
105 '<table width="100%" height="150px">'.
106 '<tr><td align="center" valign="center" style="background-color:#F8F8F8;border:solid 1px #888888;">' .
107 $sk->makeKnownLinkObj( $nt, '<img src="'.$img->createThumb(120,120).'" alt="" />' ) . '</td></tr></table> ' .
108 $textlink . $text . $nb;
110 $s .= "</td>\n" . (($i%4
==3) ?
"</tr>\n" : '');
127 } // defined( 'MEDIAWIKI' )