2014-08-07 07:40:21 -04:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* MonoBook nouveau.
|
|
|
|
*
|
|
|
|
* Translated from gwicke's previous TAL template version to remove
|
|
|
|
* dependency on PHPTAL.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @ingroup Skins
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Inherit main code from SkinTemplate, set the CSS and template filter.
|
|
|
|
* @ingroup Skins
|
|
|
|
*/
|
|
|
|
class SkinMonoBook extends SkinTemplate {
|
|
|
|
/** Using MonoBook. */
|
|
|
|
public $skinname = 'monobook';
|
|
|
|
public $stylename = 'MonoBook';
|
|
|
|
public $template = 'MonoBookTemplate';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param OutputPage $out
|
|
|
|
*/
|
2018-11-01 16:02:34 -04:00
|
|
|
public function setupSkinUserCss( OutputPage $out ) {
|
2014-08-07 07:40:21 -04:00
|
|
|
parent::setupSkinUserCss( $out );
|
|
|
|
|
2018-06-03 18:50:36 -04:00
|
|
|
if ( $out->getUser()->getOption( 'monobook-responsive' ) ) {
|
|
|
|
$out->addMeta( 'viewport',
|
|
|
|
'width=device-width, initial-scale=1.0, ' .
|
|
|
|
'user-scalable=yes, minimum-scale=0.25, maximum-scale=5.0'
|
|
|
|
);
|
|
|
|
$styleModule = 'skins.monobook.responsive';
|
|
|
|
$out->addModules( [
|
|
|
|
'skins.monobook.mobile'
|
|
|
|
] );
|
|
|
|
|
|
|
|
if ( ExtensionRegistry::getInstance()->isLoaded( 'Echo' ) && $out->getUser()->isLoggedIn() ) {
|
|
|
|
$out->addModules( [ 'skins.monobook.mobile.echohack' ] );
|
|
|
|
}
|
|
|
|
if ( ExtensionRegistry::getInstance()->isLoaded( 'UniversalLanguageSelector' ) ) {
|
|
|
|
$out->addModules( [ 'skins.monobook.mobile.uls' ] );
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$styleModule = 'skins.monobook.styles';
|
|
|
|
}
|
2018-05-01 15:44:43 -04:00
|
|
|
|
2017-05-16 12:53:26 -04:00
|
|
|
$out->addModuleStyles( [
|
2014-08-27 17:17:15 -04:00
|
|
|
'mediawiki.skinning.content.externallinks',
|
2018-06-03 18:50:36 -04:00
|
|
|
$styleModule
|
2018-05-03 15:45:10 -04:00
|
|
|
] );
|
2014-08-07 07:40:21 -04:00
|
|
|
|
2018-05-01 15:44:43 -04:00
|
|
|
// Force desktop styles in IE 8-; no support for @media widths
|
2019-10-12 17:22:40 -04:00
|
|
|
// FIXME: Remove conditional comment dependency.
|
2018-05-01 15:44:43 -04:00
|
|
|
$out->addStyle( $this->stylename . '/resources/screen-desktop.css', 'screen', 'lt IE 9' );
|
2014-08-07 07:40:21 -04:00
|
|
|
}
|
2018-05-19 14:42:05 -04:00
|
|
|
|
2018-06-03 18:50:36 -04:00
|
|
|
/**
|
|
|
|
* @param User $user
|
|
|
|
* @param array &$preferences
|
|
|
|
*/
|
|
|
|
public static function onGetPreferences( User $user, array &$preferences ) {
|
2020-02-26 18:14:10 -05:00
|
|
|
$preferences['monobook-responsive'] = [
|
|
|
|
'type' => 'toggle',
|
|
|
|
'label-message' => 'monobook-responsive-label',
|
|
|
|
'section' => 'rendering/skin/skin-prefs',
|
|
|
|
// Only show this section when the Monobook skin is checked. The JavaScript client also uses
|
|
|
|
// this state to determine whether to show or hide the whole section.
|
|
|
|
'hide-if' => [ '!==', 'wpskin', 'monobook' ],
|
|
|
|
];
|
2018-06-03 18:50:36 -04:00
|
|
|
}
|
|
|
|
|
2018-05-19 14:42:05 -04:00
|
|
|
/**
|
|
|
|
* Handler for ResourceLoaderRegisterModules hook
|
2018-05-20 06:29:50 -04:00
|
|
|
* Check if extensions are loaded
|
2018-05-19 14:42:05 -04:00
|
|
|
*
|
|
|
|
* @param ResourceLoader $resourceLoader
|
|
|
|
*/
|
2018-11-01 16:02:34 -04:00
|
|
|
public static function registerMobileExtensionStyles( ResourceLoader $resourceLoader ) {
|
2018-05-19 14:42:05 -04:00
|
|
|
if ( ExtensionRegistry::getInstance()->isLoaded( 'Echo' ) ) {
|
|
|
|
$resourceLoader->register( 'skins.monobook.mobile.echohack', [
|
|
|
|
'localBasePath' => __DIR__ . '/..',
|
2018-05-20 10:41:05 -04:00
|
|
|
'remoteSkinPath' => 'MonoBook',
|
2018-05-19 14:42:05 -04:00
|
|
|
|
|
|
|
'targets' => [ 'desktop', 'mobile' ],
|
|
|
|
'scripts' => [ 'resources/mobile-echo.js' ],
|
|
|
|
'styles' => [ 'resources/mobile-echo.less' => [
|
2018-06-05 05:19:01 -04:00
|
|
|
'media' => 'screen and (max-width: 550px)'
|
2018-05-19 14:42:05 -04:00
|
|
|
] ],
|
2019-06-25 10:27:55 -04:00
|
|
|
'dependencies' => [ 'oojs-ui.styles.icons-alerts', 'mediawiki.util' ],
|
2018-05-19 14:42:05 -04:00
|
|
|
'messages' => [ 'monobook-notifications-link', 'monobook-notifications-link-none' ]
|
|
|
|
] );
|
|
|
|
}
|
2018-05-20 06:29:50 -04:00
|
|
|
|
|
|
|
if ( ExtensionRegistry::getInstance()->isLoaded( 'UniversalLanguageSelector' ) ) {
|
|
|
|
$resourceLoader->register( 'skins.monobook.mobile.uls', [
|
|
|
|
'localBasePath' => __DIR__ . '/..',
|
2018-05-20 10:41:05 -04:00
|
|
|
'remoteSkinPath' => 'MonoBook',
|
2018-05-20 06:29:50 -04:00
|
|
|
|
2019-01-24 18:16:30 -05:00
|
|
|
'targets' => [ 'desktop' ],
|
2018-05-20 06:29:50 -04:00
|
|
|
'scripts' => [ 'resources/mobile-uls.js' ],
|
|
|
|
'dependencies' => [ 'ext.uls.interface' ],
|
|
|
|
] );
|
|
|
|
}
|
2018-05-19 14:42:05 -04:00
|
|
|
}
|
2014-08-07 07:40:21 -04:00
|
|
|
}
|