MediaWiki  1.30.0
SkinVector.php
Go to the documentation of this file.
1 <?php
29 class SkinVector extends SkinTemplate {
30  public $skinname = 'vector';
31  public $stylename = 'Vector';
32  public $template = 'VectorTemplate';
36  private $vectorConfig;
37  private $responsiveMode = false;
38 
39  public function __construct() {
40  $this->vectorConfig = \MediaWiki\MediaWikiServices::getInstance()->getConfigFactory()
41  ->makeConfig( 'vector' );
42  }
43 
45  public function getPageClasses( $title ) {
46  $className = parent::getPageClasses( $title );
47  if ( $this->vectorConfig->get( 'VectorExperimentalPrintStyles' ) ) {
48  $className .= ' vector-experimental-print-styles';
49  }
50  return $className;
51  }
52 
56  public function enableResponsiveMode() {
57  if ( !$this->responsiveMode ) {
58  $out = $this->getOutput();
59  $out->addMeta( 'viewport', 'width=device-width, initial-scale=1' );
60  $out->addModuleStyles( 'skins.vector.styles.responsive' );
61  $this->responsiveMode = true;
62  }
63  }
64 
69  public function initPage( OutputPage $out ) {
70  parent::initPage( $out );
71 
72  if ( $this->vectorConfig->get( 'VectorResponsive' ) ) {
73  $this->enableResponsiveMode();
74  }
75 
76  // Print styles are feature flagged.
77  // This flag can be removed when T169732 is resolved.
78  if ( $this->vectorConfig->get( 'VectorExperimentalPrintStyles' ) ) {
79  // Note, when deploying (T169732) we'll want to fold the stylesheet into
80  // skins.vector.styles and remove this module altogether.
81  $out->addModuleStyles( 'skins.vector.styles.experimental.print' );
82  }
83 
84  $out->addModules( 'skins.vector.js' );
85  }
86 
92  parent::setupSkinUserCss( $out );
93 
94  $styles = [ 'mediawiki.skinning.interface', 'skins.vector.styles' ];
95  Hooks::run( 'SkinVectorStyleModules', [ $this, &$styles ] );
96  $out->addModuleStyles( $styles );
97  }
98 
106  public function setupTemplate( $classname, $repository = false, $cache_dir = false ) {
107  return new $classname( $this->vectorConfig );
108  }
109 
115  public function shouldPreloadLogo() {
116  return true;
117  }
118 }
SkinVector\setupSkinUserCss
setupSkinUserCss(OutputPage $out)
Loads skin and user CSS files.
Definition: SkinVector.php:91
SkinVector\$stylename
$stylename
Definition: SkinVector.php:31
SkinVector\$vectorConfig
Config $vectorConfig
Definition: SkinVector.php:36
SkinVector\$responsiveMode
$responsiveMode
Definition: SkinVector.php:37
php
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
Config
Interface for configuration instances.
Definition: Config.php:28
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:932
SkinVector\$template
$template
Definition: SkinVector.php:32
ContextSource\getOutput
getOutput()
Get the OutputPage object.
Definition: ContextSource.php:123
SkinVector\getPageClasses
getPageClasses( $title)
@inheritDoc
Definition: SkinVector.php:45
OutputPage
This class should be covered by a general architecture document which does not exist as of January 20...
Definition: OutputPage.php:44
SkinVector\$skinname
$skinname
Definition: SkinVector.php:30
SkinVector\setupTemplate
setupTemplate( $classname, $repository=false, $cache_dir=false)
Override to pass our Config instance to it.
Definition: SkinVector.php:106
SkinVector\__construct
__construct()
Definition: SkinVector.php:39
SkinVector
SkinTemplate class for Vector skin.
Definition: SkinVector.php:29
SkinVector\initPage
initPage(OutputPage $out)
Initializes output page and sets up skin-specific parameters.
Definition: SkinVector.php:69
SkinVector\shouldPreloadLogo
shouldPreloadLogo()
Whether the logo should be preloaded with an HTTP link header or not.
Definition: SkinVector.php:115
SkinVector\enableResponsiveMode
enableResponsiveMode()
Enables the responsive mode.
Definition: SkinVector.php:56
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:203
SkinTemplate
Base class for template-based skins.
Definition: SkinTemplate.php:38
$out
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
Definition: hooks.txt:781