Merge "Indicate the actual version of HHVM in use"
[lhc/web/wiklou.git] / includes / gallery / ImageGalleryBase.php
index 837a731..b0a593d 100644 (file)
 abstract class ImageGalleryBase extends ContextSource {
        /**
         * @var array Gallery images
-        * @deprecated in 1.23 (was declared "var") and will be removed in 1.24
+        * @deprecated since 1.23 (was declared "var") and will be removed in 1.24
         */
        public $mImages;
 
        /**
         * @var bool Whether to show the filesize in bytes in categories
-        * @deprecated in 1.23 (was declared "var") and will be removed in 1.24
+        * @deprecated since 1.23 (was declared "var") and will be removed in 1.24
         */
        public $mShowBytes;
 
        /**
         * @var bool Whether to show the filename. Default: true
-        * @deprecated in 1.23 (was declared "var") and will be removed in 1.24
+        * @deprecated since 1.23 (was declared "var") and will be removed in 1.24
         */
        public $mShowFilename;
 
        /**
         * @var string Gallery mode. Default: traditional
-        * @deprecated in 1.23 (was declared "var") and will be removed in 1.24
+        * @deprecated since 1.23 (was declared "var") and will be removed in 1.24
         */
        public $mMode;
 
        /**
         * @var bool|string Gallery caption. Default: false
-        * @deprecated in 1.23 (was declared "var") and will be removed in 1.24
+        * @deprecated since 1.23 (was declared "var") and will be removed in 1.24
         */
        public $mCaption = false;
 
        /**
         * @var bool Hide blacklisted images?
-        * @deprecated in 1.23 (was declared "var") and will be removed in 1.24
+        * @deprecated since 1.23 (was declared "var") and will be removed in 1.24
         */
        public $mHideBadImages;
 
@@ -86,19 +86,25 @@ abstract class ImageGalleryBase extends ContextSource {
         * should use to get a gallery.
         *
         * @param string|bool $mode Mode to use. False to use the default
+        * @param IContextSource|null $context
+        * @return ImageGalleryBase
         * @throws MWException
         */
-       static function factory( $mode = false ) {
-               global $wgGalleryOptions, $wgContLang;
+       static function factory( $mode = false, IContextSource $context = null ) {
+               global $wgContLang;
                self::loadModes();
+               if ( !$context ) {
+                       $context = RequestContext::getMainAndWarn( __METHOD__ );
+               }
                if ( !$mode ) {
-                       $mode = $wgGalleryOptions['mode'];
+                       $galleryOpions = $context->getConfig()->get( 'GalleryOptions' );
+                       $mode = $galleryOpions['mode'];
                }
 
                $mode = $wgContLang->lc( $mode );
 
                if ( isset( self::$modeMapping[$mode] ) ) {
-                       return new self::$modeMapping[$mode]( $mode );
+                       return new self::$modeMapping[$mode]( $mode, $context );
                } else {
                        throw new MWException( "No gallery class registered for mode $mode" );
                }
@@ -123,18 +129,24 @@ abstract class ImageGalleryBase extends ContextSource {
         *
         * You should not call this directly, but instead use
         * ImageGalleryBase::factory().
+        * @param string $mode
+        * @param IContextSource|null $context
         */
-       function __construct( $mode = 'traditional' ) {
-               global $wgGalleryOptions;
+       function __construct( $mode = 'traditional', IContextSource $context = null ) {
+               if ( $context ) {
+                       $this->setContext( $context );
+               }
+
+               $galleryOptions = $this->getConfig()->get( 'GalleryOptions' );
                $this->mImages = array();
-               $this->mShowBytes = $wgGalleryOptions['showBytes'];
+               $this->mShowBytes = $galleryOptions['showBytes'];
                $this->mShowFilename = true;
                $this->mParser = false;
                $this->mHideBadImages = false;
-               $this->mPerRow = $wgGalleryOptions['imagesPerRow'];
-               $this->mWidths = $wgGalleryOptions['imageWidth'];
-               $this->mHeights = $wgGalleryOptions['imageHeight'];
-               $this->mCaptionLength = $wgGalleryOptions['captionLength'];
+               $this->mPerRow = $galleryOptions['imagesPerRow'];
+               $this->mWidths = $galleryOptions['imageWidth'];
+               $this->mHeights = $galleryOptions['imageHeight'];
+               $this->mCaptionLength = $galleryOptions['captionLength'];
                $this->mMode = $mode;
        }
 
@@ -154,6 +166,7 @@ abstract class ImageGalleryBase extends ContextSource {
 
        /**
         * Set bad image flag
+        * @param bool $flag
         */
        function setHideBadImages( $flag = true ) {
                $this->mHideBadImages = $flag;