MediaWiki REL1_34
SkinMonoBook.php
Go to the documentation of this file.
1<?php
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}
This is one of the Core classes and should be read at least once by any new developers.
addMeta( $name, $val)
Add a new "<meta>" tag To add an http-equiv meta tag, precede the name with "http:".
addModuleStyles( $modules)
Load the styles of one or more ResourceLoader modules on this page.
addStyle( $style, $media='', $condition='', $dir='')
Add a local or specified stylesheet, with the given media options.
addModules( $modules)
Load one or more ResourceLoader modules on this page.
ResourceLoader is a loading system for JavaScript and CSS resources.
Inherit main code from SkinTemplate, set the CSS and template filter.
static registerMobileExtensionStyles(ResourceLoader $resourceLoader)
Handler for ResourceLoaderRegisterModules hook Check if extensions are loaded.
setupSkinUserCss(OutputPage $out)
static onGetPreferences(User $user, array &$preferences)
$skinname
Using MonoBook.
Base class for template-based skins.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition User.php:51
getOption( $oname, $defaultOverride=null, $ignoreHidden=false)
Get the user's current setting for a given option.
Definition User.php:3022
$resourceLoader
Definition load.php:44