MediaWiki  1.28.0
PackedImageGallery.php
Go to the documentation of this file.
1 <?php
24  function __construct( $mode = 'traditional', IContextSource $context = null ) {
25  parent::__construct( $mode, $context );
26  // Does not support per row option.
27  $this->mPerRow = 0;
28  }
29 
35  const SCALE_FACTOR = 1.5;
36 
37  protected function getVPad( $boxHeight, $thumbHeight ) {
38  return ( $this->getThumbPadding() + $boxHeight - $thumbHeight / self::SCALE_FACTOR ) / 2;
39  }
40 
41  protected function getThumbPadding() {
42  return 0;
43  }
44 
45  protected function getGBPadding() {
46  return 2;
47  }
48 
53  protected function getThumbParams( $img ) {
54  if ( $img && $img->getMediaType() === MEDIATYPE_AUDIO ) {
55  $width = $this->mWidths;
56  } else {
57  // We want the width not to be the constraining
58  // factor, so use random big number.
59  $width = $this->mHeights * 10 + 100;
60  }
61 
62  // self::SCALE_FACTOR so the js has some room to manipulate sizes.
63  return [
64  'width' => $width * self::SCALE_FACTOR,
65  'height' => $this->mHeights * self::SCALE_FACTOR,
66  ];
67  }
68 
69  protected function getThumbDivWidth( $thumbWidth ) {
70  // Require at least 60px wide, so caption is wide enough to work.
71  if ( $thumbWidth < 60 * self::SCALE_FACTOR ) {
72  $thumbWidth = 60 * self::SCALE_FACTOR;
73  }
74 
75  return $thumbWidth / self::SCALE_FACTOR + $this->getThumbPadding();
76  }
77 
83  protected function getGBWidth( $thumb ) {
84  $thumbWidth = $thumb ? $thumb->getWidth() : $this->mWidths * self::SCALE_FACTOR;
85 
86  return $this->getThumbDivWidth( $thumbWidth ) + $this->getGBPadding();
87  }
88 
89  protected function adjustImageParameters( $thumb, &$imageParameters ) {
90  // Re-adjust back to normal size.
91  $imageParameters['override-width'] = ceil( $thumb->getWidth() / self::SCALE_FACTOR );
92  $imageParameters['override-height'] = ceil( $thumb->getHeight() / self::SCALE_FACTOR );
93  }
94 
100  protected function getModules() {
101  return [ 'mediawiki.page.gallery' ];
102  }
103 
109  public function setPerRow( $num ) {
110  return;
111  }
112 }
setPerRow($num)
Do not support per-row on packed.
Interface for objects which can provide a MediaWiki context on request.
getThumbDivWidth($thumbWidth)
IContextSource $context
getVPad($boxHeight, $thumbHeight)
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
const MEDIATYPE_AUDIO
Definition: defines.php:32
const SCALE_FACTOR
We artificially have 1.5 the resolution neccessary so that we can scale it up by that much on the cli...
getModules()
Add javascript which auto-justifies the rows by manipulating the image sizes.
__construct($mode= 'traditional', IContextSource $context=null)
adjustImageParameters($thumb, &$imageParameters)