MediaWiki  1.34.4
SkinMonoBook.php
Go to the documentation of this file.
1 <?php
31 class SkinMonoBook extends SkinTemplate {
33  public $skinname = 'monobook';
34  public $stylename = 'MonoBook';
35  public $template = 'MonoBookTemplate';
36 
40  public function setupSkinUserCss( OutputPage $out ) {
41  parent::setupSkinUserCss( $out );
42 
43  if ( $out->getUser()->getOption( 'monobook-responsive' ) ) {
44  $out->addMeta( 'viewport',
45  'width=device-width, initial-scale=1.0, ' .
46  'user-scalable=yes, minimum-scale=0.25, maximum-scale=5.0'
47  );
48  $styleModule = 'skins.monobook.responsive';
49  $out->addModules( [
50  'skins.monobook.mobile'
51  ] );
52 
53  if ( ExtensionRegistry::getInstance()->isLoaded( 'Echo' ) && $out->getUser()->isLoggedIn() ) {
54  $out->addModules( [ 'skins.monobook.mobile.echohack' ] );
55  }
56  if ( ExtensionRegistry::getInstance()->isLoaded( 'UniversalLanguageSelector' ) ) {
57  $out->addModules( [ 'skins.monobook.mobile.uls' ] );
58  }
59  } else {
60  $styleModule = 'skins.monobook.styles';
61  }
62 
63  $out->addModuleStyles( [
64  'mediawiki.skinning.interface',
65  'mediawiki.skinning.content.externallinks',
66  $styleModule
67  ] );
68 
69  // TODO: Migrate all of these (get RL support for conditional IE)
70  // Force desktop styles in IE 8-; no support for @media widths
71  $out->addStyle( $this->stylename . '/resources/screen-desktop.css', 'screen', 'lt IE 9' );
72  // Miscellanious fixes
73  $out->addStyle( $this->stylename . '/resources/IE60Fixes.css', 'screen', 'IE 6' );
74  $out->addStyle( $this->stylename . '/resources/IE70Fixes.css', 'screen', 'IE 7' );
75  }
76 
81  public static function onGetPreferences( User $user, array &$preferences ) {
82  if ( $user->getOption( 'skin' ) === 'monobook' ) {
83  $preferences['monobook-responsive'] = [
84  'type' => 'toggle',
85  'label-message' => 'monobook-responsive-label',
86  'section' => 'rendering/skin',
87  ];
88  }
89  }
90 
98  if ( ExtensionRegistry::getInstance()->isLoaded( 'Echo' ) ) {
99  $resourceLoader->register( 'skins.monobook.mobile.echohack', [
100  'localBasePath' => __DIR__ . '/..',
101  'remoteSkinPath' => 'MonoBook',
102 
103  'targets' => [ 'desktop', 'mobile' ],
104  'scripts' => [ 'resources/mobile-echo.js' ],
105  'styles' => [ 'resources/mobile-echo.less' => [
106  'media' => 'screen and (max-width: 550px)'
107  ] ],
108  'dependencies' => [ 'oojs-ui.styles.icons-alerts', 'mediawiki.util' ],
109  'messages' => [ 'monobook-notifications-link', 'monobook-notifications-link-none' ]
110  ] );
111  }
112 
113  if ( ExtensionRegistry::getInstance()->isLoaded( 'UniversalLanguageSelector' ) ) {
114  $resourceLoader->register( 'skins.monobook.mobile.uls', [
115  'localBasePath' => __DIR__ . '/..',
116  'remoteSkinPath' => 'MonoBook',
117 
118  'targets' => [ 'desktop' ],
119  'scripts' => [ 'resources/mobile-uls.js' ],
120  'dependencies' => [ 'ext.uls.interface' ],
121  ] );
122  }
123  }
124 }
OutputPage\addMeta
addMeta( $name, $val)
Add a new "<meta>" tag To add an http-equiv meta tag, precede the name with "http:".
Definition: OutputPage.php:388
SkinMonoBook
Inherit main code from SkinTemplate, set the CSS and template filter.
Definition: SkinMonoBook.php:31
OutputPage\addModuleStyles
addModuleStyles( $modules)
Load the styles of one or more ResourceLoader modules on this page.
Definition: OutputPage.php:568
SkinMonoBook\$template
$template
Definition: SkinMonoBook.php:35
$resourceLoader
$resourceLoader
Definition: load.php:44
SkinMonoBook\registerMobileExtensionStyles
static registerMobileExtensionStyles(ResourceLoader $resourceLoader)
Handler for ResourceLoaderRegisterModules hook Check if extensions are loaded.
Definition: SkinMonoBook.php:97
ContextSource\getUser
getUser()
Definition: ContextSource.php:120
SkinMonoBook\$skinname
$skinname
Using MonoBook.
Definition: SkinMonoBook.php:33
ExtensionRegistry\getInstance
static getInstance()
Definition: ExtensionRegistry.php:106
OutputPage\addStyle
addStyle( $style, $media='', $condition='', $dir='')
Add a local or specified stylesheet, with the given media options.
Definition: OutputPage.php:3680
OutputPage\addModules
addModules( $modules)
Load one or more ResourceLoader modules on this page.
Definition: OutputPage.php:542
SkinMonoBook\setupSkinUserCss
setupSkinUserCss(OutputPage $out)
Definition: SkinMonoBook.php:40
OutputPage
This is one of the Core classes and should be read at least once by any new developers.
Definition: OutputPage.php:46
User\getOption
getOption( $oname, $defaultOverride=null, $ignoreHidden=false)
Get the user's current setting for a given option.
Definition: User.php:3022
ResourceLoader
ResourceLoader is a loading system for JavaScript and CSS resources.
Definition: ResourceLoader.php:44
SkinMonoBook\$stylename
$stylename
Definition: SkinMonoBook.php:34
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:51
SkinTemplate
Base class for template-based skins.
Definition: SkinTemplate.php:38
SkinMonoBook\onGetPreferences
static onGetPreferences(User $user, array &$preferences)
Definition: SkinMonoBook.php:81