MediaWiki  REL1_22
PackedImageGallery.php
Go to the documentation of this file.
00001 <?php
00023 class PackedImageGallery extends TraditionalImageGallery {
00024 
00025     function __construct( $mode = 'traditional' ) {
00026         parent::__construct( $mode );
00027         // Does not support per row option.
00028         $this->mPerRow = 0;
00029     }
00030 
00036     const SCALE_FACTOR = 1.5;
00037 
00038     protected function getVPad( $boxHeight, $thumbHeight ) {
00039         return ( $this->getThumbPadding() + $boxHeight - $thumbHeight / self::SCALE_FACTOR ) / 2;
00040     }
00041 
00042     protected function getThumbPadding() {
00043         return 0;
00044     }
00045 
00046     protected function getGBPadding() {
00047         return 2;
00048     }
00049 
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         // self::SCALE_FACTOR so the js has some room to manipulate sizes.
00062         return array(
00063             'width' => $width * self::SCALE_FACTOR,
00064             'height' => $this->mHeights * self::SCALE_FACTOR,
00065         );
00066     }
00067 
00068     protected function getThumbDivWidth( $thumbWidth ) {
00069         // Require at least 60px wide, so caption is wide enough to work.
00070         if ( $thumbWidth < 60 * self::SCALE_FACTOR ) {
00071             $thumbWidth = 60 * self::SCALE_FACTOR;
00072         }
00073         return $thumbWidth / self::SCALE_FACTOR + $this->getThumbPadding();
00074     }
00075 
00079     protected function getGBWidth( $thumb ) {
00080         $thumbWidth = $thumb ? $thumb->getWidth() : $this->mWidths * self::SCALE_FACTOR;
00081         return $this->getThumbDivWidth( $thumbWidth ) + $this->getGBPadding();
00082     }
00083 
00084     protected function adjustImageParameters( $thumb, &$imageParameters ) {
00085         // Re-adjust back to normal size.
00086         $imageParameters['override-width'] = ceil( $thumb->getWidth() / self::SCALE_FACTOR );
00087         $imageParameters['override-height'] = ceil( $thumb->getHeight() / self::SCALE_FACTOR );
00088     }
00089 
00094     protected function getModules() {
00095         return array( 'mediawiki.page.gallery' );
00096     }
00097 
00102     public function setPerRow( $num ) {
00103         return;
00104     }
00105 }