| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
use MediaWiki\Context\IContextSource; |
| 24 |
|
| 25 |
class PackedImageGallery extends TraditionalImageGallery { |
| 26 |
public function __construct( $mode = 'traditional', ?IContextSource $context = null ) { |
| 27 |
parent::__construct( $mode, $context ); |
| 28 |
|
| 29 |
$this->mPerRow = 0; |
| 30 |
} |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
private const SCALE_FACTOR = 1.5; |
| 38 |
|
| 39 |
protected function getVPad( $boxHeight, $thumbHeight ) { |
| 40 |
return ( $this->getThumbPadding() + $boxHeight - $thumbHeight / self::SCALE_FACTOR ) / 2; |
| 41 |
} |
| 42 |
|
| 43 |
protected function getThumbPadding() { |
| 44 |
return 0; |
| 45 |
} |
| 46 |
|
| 47 |
protected function getGBPadding() { |
| 48 |
return 2; |
| 49 |
} |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
protected function getThumbParams( $img ) { |
| 56 |
if ( $img && $img->getMediaType() === MEDIATYPE_AUDIO ) { |
| 57 |
$width = $this->mWidths; |
| 58 |
} else { |
| 59 |
|
| 60 |
|
| 61 |
$width = $this->mHeights * 10 + 100; |
| 62 |
} |
| 63 |
|
| 64 |
|
| 65 |
return [ |
| 66 |
'width' => (int)floor( $width * self::SCALE_FACTOR ), |
| 67 |
'height' => (int)floor( $this->mHeights * self::SCALE_FACTOR ), |
| 68 |
]; |
| 69 |
} |
| 70 |
|
| 71 |
protected function getThumbDivWidth( $thumbWidth ) { |
| 72 |
|
| 73 |
if ( $thumbWidth < 60 * self::SCALE_FACTOR ) { |
| 74 |
$thumbWidth = 60 * self::SCALE_FACTOR; |
| 75 |
} |
| 76 |
|
| 77 |
return $thumbWidth / self::SCALE_FACTOR + $this->getThumbPadding(); |
| 78 |
} |
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
protected function getGBWidth( $thumb ) { |
| 86 |
$thumbWidth = $thumb ? $thumb->getWidth() : $this->mWidths * self::SCALE_FACTOR; |
| 87 |
|
| 88 |
return $this->getThumbDivWidth( $thumbWidth ) + $this->getGBPadding(); |
| 89 |
} |
| 90 |
|
| 91 |
protected function adjustImageParameters( $thumb, &$imageParameters ) { |
| 92 |
|
| 93 |
$imageParameters['override-width'] = ceil( $thumb->getWidth() / self::SCALE_FACTOR ); |
| 94 |
$imageParameters['override-height'] = ceil( $thumb->getHeight() / self::SCALE_FACTOR ); |
| 95 |
} |
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
protected function getModules() { |
| 103 |
return [ 'mediawiki.page.gallery' ]; |
| 104 |
} |
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
public function setPerRow( $num ) { |
| 112 |
} |
| 113 |
} |