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().
25 * Create a new image gallery object.
27 function ImageGallery( ) {
28 $this->mImages
=array();
32 * Add an image to the gallery.
34 * @param Image $image Image object that is added to the gallery
35 * @param string $text Additional text to be shown. The name and size of the image are always shown.
37 function add( $image, $text='' ) {
38 $this->mImages
[] = array( &$image, $text );
42 * isEmpty() returns false iff the gallery doesn't contain any images
45 return empty( $this->mImages
);
49 * Return a HTML representation of the image gallery
51 * For each image in the gallery, display
54 * - the additional text provided when adding the image
55 * - the size of the image
59 global $wgLang, $wgContLang, $wgUser;
61 $sk = $wgUser->getSkin();
63 $s = '<table style="border:solid 1px #DDDDDD; cellspacing:0; cellpadding:0; margin:1em;">';
65 foreach ( $this->mImages
as $pair ) {
69 $name = $img->getName();
70 $nt = $img->getTitle();
73 //$ul = $sk->makeLink( $wgContLang->getNsText( Namespace::getUser() ) . ":{$ut}", $ut );
75 $nb = wfMsg( "nbytes", $wgLang->formatNum( $img->getSize() ) );
77 $s .= ($i%4
==0) ?
'<tr>' : '';
78 $s .= '<td valign="top" width="150px" style="background-color:#F0F0F0;">' .
79 '<table width="100%" height="150px">'.
80 '<tr><td align="center" valign="center" style="background-color:#F8F8F8;border:solid 1px #888888;">' .
81 $sk->makeKnownLinkObj( $nt, '<img src="'.$img->createThumb(120,120).'" alt="">' ) . '</td></tr></table> ' .
82 $sk->makeKnownLinkObj( $nt, Language
::truncate( $nt->getText(), 20, '...' ) ) .
83 "<br />{$text}{$nb}<br />" ;
85 $s .= '</td>' . (($i%4
==3) ?
'</tr>' : '');
99 } // defined( 'MEDIAWIKI' )