X-Git-Url: https://scripts.mit.edu/gitweb/autoinstallsdev/mediawiki.git/blobdiff_plain/19e297c21b10b1b8a3acad5e73fc71dcb35db44a..6932310fd58ebef145fa01eb76edf7150284d8ea:/skins/vector/SkinVector.php diff --git a/skins/vector/SkinVector.php b/skins/vector/SkinVector.php new file mode 100644 index 00000000..f6848910 --- /dev/null +++ b/skins/vector/SkinVector.php @@ -0,0 +1,118 @@ +vectorConfig = \MediaWiki\MediaWikiServices::getInstance()->getConfigFactory() + ->makeConfig( 'vector' ); + } + + /** @inheritDoc */ + public function getPageClasses( $title ) { + $className = parent::getPageClasses( $title ); + if ( $this->vectorConfig->get( 'VectorExperimentalPrintStyles' ) ) { + $className .= ' vector-experimental-print-styles'; + } + return $className; + } + + /** + * Enables the responsive mode + */ + public function enableResponsiveMode() { + if ( !$this->responsiveMode ) { + $out = $this->getOutput(); + $out->addMeta( 'viewport', 'width=device-width, initial-scale=1' ); + $out->addModuleStyles( 'skins.vector.styles.responsive' ); + $this->responsiveMode = true; + } + } + + /** + * Initializes output page and sets up skin-specific parameters + * @param OutputPage $out Object to initialize + */ + public function initPage( OutputPage $out ) { + parent::initPage( $out ); + + if ( $this->vectorConfig->get( 'VectorResponsive' ) ) { + $this->enableResponsiveMode(); + } + + // Print styles are feature flagged. + // This flag can be removed when T169732 is resolved. + if ( $this->vectorConfig->get( 'VectorExperimentalPrintStyles' ) ) { + // Note, when deploying (T169732) we'll want to fold the stylesheet into + // skins.vector.styles and remove this module altogether. + $out->addModuleStyles( 'skins.vector.styles.experimental.print' ); + } + + $out->addModules( 'skins.vector.js' ); + } + + /** + * Loads skin and user CSS files. + * @param OutputPage $out + */ + function setupSkinUserCss( OutputPage $out ) { + parent::setupSkinUserCss( $out ); + + $styles = [ 'mediawiki.skinning.interface', 'skins.vector.styles' ]; + Hooks::run( 'SkinVectorStyleModules', [ $this, &$styles ] ); + $out->addModuleStyles( $styles ); + } + + /** + * Override to pass our Config instance to it + * @param string $classname + * @param bool|string $repository + * @param bool|string $cache_dir + * @return QuickTemplate + */ + public function setupTemplate( $classname, $repository = false, $cache_dir = false ) { + return new $classname( $this->vectorConfig ); + } + + /** + * Whether the logo should be preloaded with an HTTP link header or not + * @since 1.29 + * @return bool + */ + public function shouldPreloadLogo() { + return true; + } +}