MediaWiki  REL1_24
PackedImageGallery.php
Go to the documentation of this file.
00001 <?php
00023 class PackedImageGallery extends TraditionalImageGallery {
00024     function __construct( $mode = 'traditional' ) {
00025         parent::__construct( $mode );
00026         // Does not support per row option.
00027         $this->mPerRow = 0;
00028     }
00029 
00035     const SCALE_FACTOR = 1.5;
00036 
00037     protected function getVPad( $boxHeight, $thumbHeight ) {
00038         return ( $this->getThumbPadding() + $boxHeight - $thumbHeight / self::SCALE_FACTOR ) / 2;
00039     }
00040 
00041     protected function getThumbPadding() {
00042         return 0;
00043     }
00044 
00045     protected function getGBPadding() {
00046         return 2;
00047     }
00048 
00053     protected function getThumbParams( $img ) {
00054         if ( $img && $img->getMediaType() === MEDIATYPE_AUDIO ) {
00055             $width = $this->mWidths;
00056         } else {
00057             // We want the width not to be the constraining
00058             // factor, so use random big number.
00059             $width = $this->mHeights * 10 + 100;
00060         }
00061 
00062         // self::SCALE_FACTOR so the js has some room to manipulate sizes.
00063         return array(
00064             'width' => $width * self::SCALE_FACTOR,
00065             'height' => $this->mHeights * self::SCALE_FACTOR,
00066         );
00067     }
00068 
00069     protected function getThumbDivWidth( $thumbWidth ) {
00070         // Require at least 60px wide, so caption is wide enough to work.
00071         if ( $thumbWidth < 60 * self::SCALE_FACTOR ) {
00072             $thumbWidth = 60 * self::SCALE_FACTOR;
00073         }
00074 
00075         return $thumbWidth / self::SCALE_FACTOR + $this->getThumbPadding();
00076     }
00077 
00083     protected function getGBWidth( $thumb ) {
00084         $thumbWidth = $thumb ? $thumb->getWidth() : $this->mWidths * self::SCALE_FACTOR;
00085 
00086         return $this->getThumbDivWidth( $thumbWidth ) + $this->getGBPadding();
00087     }
00088 
00089     protected function adjustImageParameters( $thumb, &$imageParameters ) {
00090         // Re-adjust back to normal size.
00091         $imageParameters['override-width'] = ceil( $thumb->getWidth() / self::SCALE_FACTOR );
00092         $imageParameters['override-height'] = ceil( $thumb->getHeight() / self::SCALE_FACTOR );
00093     }
00094 
00100     protected function getModules() {
00101         return array( 'mediawiki.page.gallery' );
00102     }
00103 
00109     public function setPerRow( $num ) {
00110         return;
00111     }
00112 }