8 * This is not a valid entry point, perform no further processing unless MEDIAWIKI is defined
10 if( defined( 'MEDIAWIKI' ) ) {
16 * Add images to the gallery using add(), then render that list to HTML using toHTML().
22 var $mImages, $mShowBytes, $mShowFilename;
25 * Create a new image gallery object.
27 function ImageGallery( ) {
28 $this->mImages
= array();
29 $this->mShowBytes
= true;
30 $this->mShowFilename
= true;
34 * Add an image to the gallery.
36 * @param Image $image Image object that is added to the gallery
37 * @param string $text Additional text to be shown. The name and size of the image are always shown.
39 function add( $image, $text='' ) {
40 $this->mImages
[] = array( &$image, $text );
44 * isEmpty() returns false iff the gallery doesn't contain any images
47 return empty( $this->mImages
);
51 * Enable/Disable showing of the file size of an image in the gallery.
54 * @param boolean $f set to false to disable
56 function setShowBytes( $f ) {
57 $this->mShowBytes
= ( $f == true);
61 * Enable/Disable showing of the filename of an image in the gallery.
64 * @param boolean $f set to false to disable
66 function setShowFilename( $f ) {
67 $this->mShowFilename
= ( $f == true);
71 * Return a HTML representation of the image gallery
73 * For each image in the gallery, display
76 * - the additional text provided when adding the image
77 * - the size of the image
81 global $wgLang, $wgContLang, $wgUser;
83 $sk = $wgUser->getSkin();
85 $s = '<table style="border:solid 1px #DDDDDD; cellspacing:0; cellpadding:0; margin:1em;">';
87 foreach ( $this->mImages
as $pair ) {
91 $name = $img->getName();
92 $nt = $img->getTitle();
95 //$ul = $sk->makeLink( $wgContLang->getNsText( Namespace::getUser() ) . ":{$ut}", $ut );
97 $nb = $this->mShowBytes ?
98 wfMsg( "nbytes", $wgLang->formatNum( $img->getSize() ) ) . '<br />' :
100 $textlink = $this->mShowFilename ?
101 $sk->makeKnownLinkObj( $nt, Language
::truncate( $nt->getText(), 20, '...' ) ) . '<br />' :
104 $s .= ($i%4
==0) ?
'<tr>' : '';
105 $s .= '<td valign="top" width="150px" style="background-color:#F0F0F0;">' .
106 '<table width="100%" height="150px">'.
107 '<tr><td align="center" valign="center" style="background-color:#F8F8F8;border:solid 1px #888888;">' .
108 $sk->makeKnownLinkObj( $nt, '<img src="'.$img->createThumb(120,120).'" alt="">' ) . '</td></tr></table> ' .
109 $textlink . $text . $nb;
111 $s .= '</td>' . (($i%4
==3) ?
'</tr>' : '');
125 } // defined( 'MEDIAWIKI' )