Ejemplo n.º 1
0
 /**
  * Get a new image gallery. This is the method other callers
  * 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, IContextSource $context = null)
 {
     global $wgContLang;
     self::loadModes();
     if (!$context) {
         $context = RequestContext::getMainAndWarn(__METHOD__);
     }
     if (!$mode) {
         $galleryOpions = $context->getConfig()->get('GalleryOptions');
         $mode = $galleryOpions['mode'];
     }
     $mode = $wgContLang->lc($mode);
     if (isset(self::$modeMapping[$mode])) {
         return new self::$modeMapping[$mode]($mode, $context);
     } else {
         throw new MWException("No gallery class registered for mode {$mode}");
     }
 }