mImages=array(); } /** * Add an image to the gallery. * * @param Image $image Image object that is added to the gallery * @param string $text Additional text to be shown. The name and size of the image are always shown. */ function add( $image, $text='' ) { $this->mImages[] = array( &$image, $text ); } /** * isEmpty() returns false iff the gallery doesn't contain any images */ function isEmpty() { return empty( $this->mImages ); } /** * Return a HTML representation of the image gallery * * 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 * */ function toHTML() { global $wgLang, $wgContLang, $wgUser; $sk = $wgUser->getSkin(); $s = ''; $i = 0; foreach ( $this->mImages as $pair ) { $img =& $pair[0]; $text = $pair[1]; $name = $img->getName(); $nt = $img->getTitle(); //TODO //$ul = $sk->makeLink( $wgContLang->getNsText( Namespace::getUser() ) . ":{$ut}", $ut ); $nb = wfMsg( "nbytes", $wgLang->formatNum( $img->getSize() ) ); $s .= ($i%4==0) ? '' : ''; $s .= '' . (($i%4==3) ? '' : ''); $i++; } $s .= '
' . ''. '
' . $sk->makeKnownLinkObj( $nt, '' ) . '
' . $sk->makeKnownLinkObj( $nt, Language::truncate( $nt->getText(), 20, '...' ) ) . "
{$text}{$nb}
" ; $s .= '
'; return $s; } } //class } // defined( 'MEDIAWIKI' ) ?>