mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-28 08:00:32 +00:00
9150aec131
Two new feature flags: 1) MinervaPersonalMenu 2) MinervaAdvancedMainMenu Changes: * AMC defaults to false on desktop - desktop doesn't have AMC mode it just enables several skin options. * WHen inserting a link at the bottom of the page check whether the talk at top of the page (tabs) is enabled.. not AMC * Update ServiceWiring to construct menu based on MinervaAdvancedMainMenu and MinervaPersonalMenu - note when former is enabled but not latter there is no way to logout. Noted in README. * Use one entry point for skins.minerva.amc.styles/index.less * Document files inside skins.minerva.amc.styles to make it clear which features they are associated with * Drop history page styles when AMC is disabled - it's not possible to ever get to these as the history page redirects in non-AMC mode * Rename the class .minerva--amc-enabled to minerva--history-page-action-enabled to reflect its real purpose and move styles from skins.minerva.base.styles to skins.minerva.amc.styles No need to worry about cached HTML as AMC runs without cache... * Remove isAnyAMCOptionEnabled - it's an antipattern and should be discouraged as it discourages the art of feature flagging. Nothing is using it after these changes. * The AMC_MODE flag is disabled. There is no need for this - AMC is not a feature and therefore not a skin option. It is a mechanism for turning on other skin options. Tests are updated. Testing: It should now be possible to enable any feature in `beta` and see it in the beta of the site. Bug: T229295 Change-Id: I48959905f5c09721b14a27aa1a5ad82849ac6263
121 lines
3.8 KiB
PHP
121 lines
3.8 KiB
PHP
<?php
|
|
/**
|
|
* 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
|
|
*/
|
|
namespace MediaWiki\Minerva;
|
|
|
|
/**
|
|
* A wrapper for all available Skin options.
|
|
*/
|
|
final class SkinOptions {
|
|
|
|
const MOBILE_OPTIONS = 'mobileOptionsLink';
|
|
const CATEGORIES = 'categories';
|
|
const BACK_TO_TOP = 'backToTop';
|
|
const PAGE_ISSUES = 'pageIssues';
|
|
const SHARE_BUTTON = 'shareButton';
|
|
const TOGGLING = 'toggling';
|
|
const BETA_MODE = 'beta';
|
|
const TALK_AT_TOP = 'talkAtTop';
|
|
const HISTORY_IN_PAGE_ACTIONS = 'historyInPageActions';
|
|
const TOOLBAR_SUBMENU = 'overflowSubmenu';
|
|
const TABS_ON_SPECIALS = 'tabsOnSpecials';
|
|
const MAIN_MENU_EXPANDED = 'mainMenuExpanded';
|
|
const PERSONAL_MENU = 'personalMenu';
|
|
|
|
/** @var array skin specific options, initialized with default values */
|
|
// Note stable skin options default to true for desktop-Minerva and are expected to be
|
|
// overridden on mobile.
|
|
private $skinOptions = [
|
|
self::BETA_MODE => false,
|
|
/**
|
|
* Whether the main menu should include a link to
|
|
* Special:Preferences of Special:MobileOptions
|
|
*/
|
|
self::MOBILE_OPTIONS => false,
|
|
/** Whether a categories button should appear at the bottom of the skin. */
|
|
self::CATEGORIES => false,
|
|
/** Whether a back to top button appears at the bottom of the view page */
|
|
self::BACK_TO_TOP => false,
|
|
/** Whether a share button should appear in icons section */
|
|
self::SHARE_BUTTON => false,
|
|
/** Whether sections can be collapsed (requires MobileFrontend and MobileFormatter) */
|
|
self::TOGGLING => false,
|
|
/** requires a wiki using Template:Ambox */
|
|
self::PAGE_ISSUES => false,
|
|
/** no extension requirements */
|
|
self::TALK_AT_TOP => true,
|
|
/** no extension requirements */
|
|
self::HISTORY_IN_PAGE_ACTIONS => true,
|
|
/** no extension requirements */
|
|
self::TOOLBAR_SUBMENU => true,
|
|
/** Whether to show tabs on special pages */
|
|
self::TABS_ON_SPECIALS => false,
|
|
/** whether to show a personal menu */
|
|
self::PERSONAL_MENU => true,
|
|
/** whether to show a main menu with additional items */
|
|
self::MAIN_MENU_EXPANDED => true,
|
|
];
|
|
|
|
/**
|
|
* override an existing option or options with new values
|
|
* @param array $options
|
|
*/
|
|
public function setMultiple( array $options ) {
|
|
foreach ( $options as $option => $value ) {
|
|
if ( !array_key_exists( $option, $this->skinOptions ) ) {
|
|
throw new \OutOfBoundsException( "SkinOption $option is not defined" );
|
|
}
|
|
}
|
|
$this->skinOptions = array_merge( $this->skinOptions, $options );
|
|
}
|
|
|
|
/**
|
|
* Return whether a skin option is truthy. Should be one of self:* constants
|
|
* @param string $key
|
|
* @return bool
|
|
*/
|
|
public function get( $key ) {
|
|
if ( !array_key_exists( $key, $this->skinOptions ) ) {
|
|
throw new \OutOfBoundsException( "SkinOption $key doesn't exist" );
|
|
}
|
|
return $this->skinOptions[$key];
|
|
}
|
|
|
|
/**
|
|
* Get all skin options
|
|
* @return array
|
|
*/
|
|
public function getAll() {
|
|
return $this->skinOptions;
|
|
}
|
|
|
|
/**
|
|
* Return whether any of the skin options have been set
|
|
* @return bool
|
|
*/
|
|
public function hasSkinOptions() {
|
|
foreach ( $this->skinOptions as $key => $val ) {
|
|
if ( $val ) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
}
|