mImages = array(); $this->mShowBytes = true; $this->mShowFilename = true; } /** * 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 ); } /** * Enable/Disable showing of the file size of an image in the gallery. * Enabled by default. * * @param boolean $f set to false to disable */ function setShowBytes( $f ) { $this->mShowBytes = ( $f == true); } /** * Enable/Disable showing of the filename of an image in the gallery. * Enabled by default. * * @param boolean $f set to false to disable */ function setShowFilename( $f ) { $this->mShowFilename = ( $f == true); } /** * 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 = $this->mShowBytes ? wfMsg( "nbytes", $wgLang->formatNum( $img->getSize() ) ) . '
' : '' ; $textlink = $this->mShowFilename ? $sk->makeKnownLinkObj( $nt, Language::truncate( $nt->getText(), 20, '...' ) ) . '
' : '' ; $s .= ($i%4==0) ? '' : ''; $s .= '' . (($i%4==3) ? '' : ''); $i++; } $s .= '
' . ''. '
' . $sk->makeKnownLinkObj( $nt, '' ) . '
' . $textlink . $text . $nb; $s .= '
'; return $s; } } //class } // defined( 'MEDIAWIKI' ) ?>