Fix bug 56, which causes sections to be dropped or duplicated
[lhc/web/wiklou.git] / includes / ImageGallery.php
1
2 <?php
3 /**
4 * @package MediaWiki
5 */
6
7 /**
8 * This is not a valid entry point, perform no further processing unless MEDIAWIKI is defined
9 */
10 if( defined( 'MEDIAWIKI' ) ) {
11
12
13 /**
14 * Image gallery
15 * @package MediaWiki
16 */
17 class ImageGallery
18 {
19 var $mImages;
20
21 function ImageGallery( ) {
22 $this->mImages=array();
23 }
24
25 function add( $image, $text='' ) {
26 $this->mImages[] = array( &$image, $text );
27 }
28
29 function toHTML() {
30 global $wgLang, $wgUser;
31
32 $sk = $wgUser->getSkin();
33
34 $s = '<table style="border:solid 1px #DDDDDD; cellspacing:0; cellpadding:0; margin:1em;">';
35 $i = 0;
36 foreach ( $this->mImages as $pair ) {
37 $img =& $pair[0];
38 $text = $pair[1];
39
40 $name = $img->getName();
41 $nt = $img->getTitle();
42
43 //TODO
44 //$ul = $sk->makeLink( $wgLang->getNsText( Namespace::getUser() ) . ":{$ut}", $ut );
45
46 $ilink = '<a href="' . $img->getURL() . '">' . $nt->getText() . '</a>';
47 $nb = wfMsg( "nbytes", $wgLang->formatNum( $img->getSize() ) );
48
49 $s .= ($i%4==0) ? '<tr>' : '';
50 $s .= '<td valign="top" width="150px" style="background-color:#F0F0F0;">' .
51 '<table width="100%" height="150px">'.
52 '<tr><td align="center" valign="center" style="background-color:#F8F8F8;border:solid 1px #888888;">' .
53 '<img src="'.$img->createThumb(120,120).'" alt=""></td></tr></table> ' .
54 '(' . $sk->makeKnownLinkObj( $nt, wfMsg( "imgdesc" ) ) .
55 ") {$ilink}<br />{$text}{$nb}<br />" ;
56
57 $s .= '</td>' . (($i%4==3) ? '</tr>' : '');
58
59 $i++;
60 }
61 $s .= '</table>';
62
63 return $s;
64 }
65
66 } //class
67
68
69
70
71 } // defined( 'MEDIAWIKI' )
72 ?>