2020-02-20 16:37:33 +00:00
|
|
|
<?php
|
2020-02-28 17:26:35 +00:00
|
|
|
|
2020-02-20 16:37:33 +00:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
* @since 1.35
|
|
|
|
*/
|
|
|
|
|
2022-05-23 07:32:40 +00:00
|
|
|
namespace MediaWiki\Skins\Vector\FeatureManagement;
|
2020-02-20 16:37:33 +00:00
|
|
|
|
2024-05-07 07:01:55 +00:00
|
|
|
use MediaWiki\Context\IContextSource;
|
2024-03-26 22:02:43 +00:00
|
|
|
use MediaWiki\Skins\Vector\ConfigHelper;
|
2024-01-31 21:11:51 +00:00
|
|
|
use MediaWiki\Skins\Vector\Constants;
|
2022-05-23 07:32:40 +00:00
|
|
|
use MediaWiki\Skins\Vector\FeatureManagement\Requirements\SimpleRequirement;
|
2024-05-06 19:59:33 +00:00
|
|
|
use MediaWiki\User\Options\UserOptionsLookup;
|
2024-07-08 16:25:30 +00:00
|
|
|
use RuntimeException;
|
2020-02-20 16:37:33 +00:00
|
|
|
use Wikimedia\Assert\Assert;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A simple feature manager.
|
|
|
|
*
|
|
|
|
* NOTE: This API hasn't settled. It may change at any time without warning. Please don't bind to
|
|
|
|
* it unless you absolutely need to.
|
|
|
|
*
|
|
|
|
* @unstable
|
|
|
|
*
|
2022-05-23 07:32:40 +00:00
|
|
|
* @package MediaWiki\Skins\Vector\FeatureManagement
|
2020-02-20 16:37:33 +00:00
|
|
|
* @internal
|
2022-12-13 20:28:22 +00:00
|
|
|
* @final
|
2020-02-20 16:37:33 +00:00
|
|
|
*/
|
2022-12-13 20:28:22 +00:00
|
|
|
class FeatureManager {
|
2020-02-20 16:37:33 +00:00
|
|
|
|
|
|
|
/**
|
2020-03-02 12:39:47 +00:00
|
|
|
* A map of feature name to the array of requirements (referenced by name). A feature is only
|
|
|
|
* considered enabled when all of its requirements are met.
|
2020-02-20 16:37:33 +00:00
|
|
|
*
|
|
|
|
* See FeatureManager::registerFeature for additional detail.
|
|
|
|
*
|
|
|
|
* @var Array<string,string[]>
|
|
|
|
*/
|
|
|
|
private $features = [];
|
|
|
|
|
|
|
|
/**
|
2020-03-02 12:39:47 +00:00
|
|
|
* A map of requirement name to the Requirement instance that represents it.
|
2020-02-20 16:37:33 +00:00
|
|
|
*
|
2020-03-02 12:39:47 +00:00
|
|
|
* The names of requirements are assumed to be static for the lifetime of the request. Therefore
|
|
|
|
* we can use them to look up Requirement instances quickly.
|
|
|
|
*
|
|
|
|
* @var Array<string,Requirement>
|
2020-02-20 16:37:33 +00:00
|
|
|
*/
|
2020-02-28 15:42:05 +00:00
|
|
|
private $requirements = [];
|
2020-02-20 16:37:33 +00:00
|
|
|
|
2024-05-06 19:59:33 +00:00
|
|
|
private UserOptionsLookup $userOptionsLookup;
|
2024-05-07 07:01:55 +00:00
|
|
|
private IContextSource $context;
|
2024-05-06 19:59:33 +00:00
|
|
|
|
|
|
|
public function __construct(
|
2024-05-07 07:01:55 +00:00
|
|
|
UserOptionsLookup $userOptionsLookup,
|
|
|
|
IContextSource $context
|
2024-05-06 19:59:33 +00:00
|
|
|
) {
|
|
|
|
$this->userOptionsLookup = $userOptionsLookup;
|
2024-05-07 07:01:55 +00:00
|
|
|
$this->context = $context;
|
2024-05-06 19:59:33 +00:00
|
|
|
}
|
|
|
|
|
2020-02-20 16:37:33 +00:00
|
|
|
/**
|
|
|
|
* Register a feature and its requirements.
|
|
|
|
*
|
|
|
|
* Essentially, a "feature" is a friendly (hopefully) name for some component, however big or
|
|
|
|
* small, that has some requirements. A feature manager allows us to decouple the component's
|
|
|
|
* logic from its requirements, allowing them to vary independently. Moreover, the use of
|
2020-02-28 15:42:05 +00:00
|
|
|
* friendly names wherever possible allows us to define a common language with our non-technical
|
2020-02-20 16:37:33 +00:00
|
|
|
* colleagues.
|
|
|
|
*
|
|
|
|
* ```php
|
2020-02-28 15:42:05 +00:00
|
|
|
* $featureManager->registerFeature( 'featureA', 'requirementA' );
|
2020-02-20 16:37:33 +00:00
|
|
|
* ```
|
|
|
|
*
|
2020-02-28 15:42:05 +00:00
|
|
|
* defines the "featureA" feature, which is enabled when the "requirementA" requirement is met.
|
2020-02-20 16:37:33 +00:00
|
|
|
*
|
|
|
|
* ```php
|
2020-02-28 15:42:05 +00:00
|
|
|
* $featureManager->registerFeature( 'featureB', [ 'requirementA', 'requirementB' ] );
|
2020-02-20 16:37:33 +00:00
|
|
|
* ```
|
|
|
|
*
|
2020-02-28 15:42:05 +00:00
|
|
|
* defines the "featureB" feature, which is enabled when the "requirementA" and "requirementB"
|
|
|
|
* requirements are met. Note well that the feature is only enabled when _all_ requirements are
|
|
|
|
* met, i.e. the requirements are evaluated in order and logically `AND`ed together.
|
2020-02-20 16:37:33 +00:00
|
|
|
*
|
|
|
|
* @param string $feature The name of the feature
|
2020-02-28 15:42:05 +00:00
|
|
|
* @param string|array $requirements The feature's requirements. As above, you can define a
|
|
|
|
* feature that requires a single requirement via the shorthand
|
2020-02-20 16:37:33 +00:00
|
|
|
*
|
|
|
|
* ```php
|
2020-02-28 15:42:05 +00:00
|
|
|
* $featureManager->registerFeature( 'feature', 'requirementA' );
|
|
|
|
* // Equivalent to $featureManager->registerFeature( 'feature', [ 'requirementA' ] );
|
2020-02-20 16:37:33 +00:00
|
|
|
* ```
|
|
|
|
*
|
|
|
|
* @throws \LogicException If the feature is already registered
|
|
|
|
* @throws \Wikimedia\Assert\ParameterAssertionException If the feature's requirements aren't
|
2020-02-28 15:42:05 +00:00
|
|
|
* the name of a single requirement or a list of requirements
|
|
|
|
* @throws \InvalidArgumentException If the feature references a requirement that isn't
|
|
|
|
* registered
|
2020-02-20 16:37:33 +00:00
|
|
|
*/
|
2020-02-28 17:26:35 +00:00
|
|
|
public function registerFeature( string $feature, $requirements ) {
|
2020-02-20 16:37:33 +00:00
|
|
|
//
|
|
|
|
// Validation
|
|
|
|
if ( array_key_exists( $feature, $this->features ) ) {
|
2020-02-28 15:42:05 +00:00
|
|
|
throw new \LogicException( sprintf(
|
|
|
|
'Feature "%s" is already registered.',
|
|
|
|
$feature
|
|
|
|
) );
|
2020-02-20 16:37:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Assert::parameterType( 'string|array', $requirements, 'requirements' );
|
|
|
|
|
|
|
|
$requirements = (array)$requirements;
|
|
|
|
|
|
|
|
Assert::parameterElementType( 'string', $requirements, 'requirements' );
|
|
|
|
|
2020-02-28 15:42:05 +00:00
|
|
|
foreach ( $requirements as $name ) {
|
|
|
|
if ( !array_key_exists( $name, $this->requirements ) ) {
|
|
|
|
throw new \InvalidArgumentException( sprintf(
|
|
|
|
'Feature "%s" references requirement "%s", which hasn\'t been registered',
|
|
|
|
$feature,
|
|
|
|
$name
|
|
|
|
) );
|
2020-02-20 16:37:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Mutation
|
|
|
|
$this->features[$feature] = $requirements;
|
|
|
|
}
|
|
|
|
|
2023-10-17 12:47:38 +00:00
|
|
|
/**
|
2024-01-31 21:11:51 +00:00
|
|
|
* Gets user's preference value
|
2023-10-17 12:47:38 +00:00
|
|
|
*
|
|
|
|
* If user preference is not set or did not appear in config
|
2024-01-31 21:11:51 +00:00
|
|
|
* set it to default value we go back to defualt suffix value
|
2023-10-17 12:47:38 +00:00
|
|
|
* that will ensure that the feature will be enabled when requirements are met
|
|
|
|
*
|
2024-01-31 21:11:51 +00:00
|
|
|
* @param string $preferenceKey User preference key
|
2023-10-17 12:47:38 +00:00
|
|
|
* @return string
|
|
|
|
*/
|
2024-01-31 21:11:51 +00:00
|
|
|
public function getUserPreferenceValue( $preferenceKey ) {
|
2024-05-06 19:59:33 +00:00
|
|
|
return $this->userOptionsLookup->getOption(
|
2024-05-07 07:01:55 +00:00
|
|
|
$this->context->getUser(),
|
2024-01-31 21:11:51 +00:00
|
|
|
$preferenceKey
|
|
|
|
// For client preferences, this should be the same as `preferenceKey`
|
|
|
|
// in 'resources/skins.vector.js/clientPreferences.json'
|
2023-10-17 12:47:38 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-09-01 16:58:56 +00:00
|
|
|
/**
|
|
|
|
* Return a list of classes that should be added to the body tag
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getFeatureBodyClass() {
|
2024-01-11 21:36:03 +00:00
|
|
|
return array_map( function ( $featureName ) {
|
2022-09-01 16:58:56 +00:00
|
|
|
// switch to lower case and switch from camel case to hyphens
|
|
|
|
$featureClass = ltrim( strtolower( preg_replace( '/[A-Z]([A-Z](?![a-z]))*/', '-$0', $featureName ) ), '-' );
|
2024-01-31 21:11:51 +00:00
|
|
|
$prefix = 'vector-feature-' . $featureClass . '-';
|
2024-03-26 22:02:43 +00:00
|
|
|
|
|
|
|
// some features (eg night mode) will require request context to determine status
|
2024-05-07 07:01:55 +00:00
|
|
|
$request = $this->context->getRequest();
|
|
|
|
$config = $this->context->getConfig();
|
|
|
|
$title = $this->context->getTitle();
|
2024-03-26 22:02:43 +00:00
|
|
|
|
2023-07-11 23:13:57 +00:00
|
|
|
// Client side preferences
|
2024-01-31 21:11:51 +00:00
|
|
|
switch ( $featureName ) {
|
2024-07-08 16:25:30 +00:00
|
|
|
// This feature has 3 possible states: 0, 1, 2 and -excluded.
|
|
|
|
// It persists for all users.
|
2024-01-31 21:11:51 +00:00
|
|
|
case CONSTANTS::FEATURE_FONT_SIZE:
|
feature(Vector): Add configurable font size exclusions
This patch introduces the ability to configure font size exclusions
for specific pages within the Vector skin, ensuring certain pages
always use a small font size. This change is part of ongoing improvements
to the Vector skin's customizability features.
Changes:
- Updated `skin.json` to include `VectorFontSizeConfigurableOptions`
- Added new i18n string `vector-feature-custom-font-size-exclusion-notice`
- Modified logic for font size exclusion handling in `FeatureManager.php`
Additional Notes:
- Affects testing and beta deployment environments, ensure relevant
settings are updated in `LocalSettings.php`.
For testing and on beta deployment, these settings should be set in
the LocalSettings.php of the environment, example:
$wgVectorAppearance = [
"logged_in" => true,
"logged_out" => true,
"beta" => true
];
$wgVectorFontSizeConfigurableOptions = [
"exclude" => [
"namespaces" => [ -1, 2, 6, 8, 10, 14, 100, 710, 828 ],
"querystring" => [
"action" => "edit|submit|diff|info|protect|delete|undelete|diff|history",
"diff" => ".+"
]
]
];
Bug: T364887
Change-Id: I23b9c4fb63f35c7d27544197fead3ad7619c67f1
2024-05-15 13:54:26 +00:00
|
|
|
if ( ConfigHelper::shouldDisable(
|
|
|
|
$config->get( 'VectorFontSizeConfigurableOptions' ), $request, $title
|
|
|
|
) ) {
|
|
|
|
return $prefix . 'clientpref--excluded';
|
|
|
|
}
|
2024-01-31 21:11:51 +00:00
|
|
|
$suffixEnabled = 'clientpref-' . $this->getUserPreferenceValue( CONSTANTS::PREF_KEY_FONT_SIZE );
|
2023-10-17 12:47:38 +00:00
|
|
|
$suffixDisabled = 'clientpref-0';
|
|
|
|
break;
|
2024-07-08 16:25:30 +00:00
|
|
|
// This feature has 4 possible states: day, night, os and -excluded.
|
|
|
|
// It persists for all users.
|
2024-01-31 21:11:51 +00:00
|
|
|
case CONSTANTS::PREF_NIGHT_MODE:
|
2024-04-11 04:14:29 +00:00
|
|
|
// if night mode is disabled for the page, add the exclude class instead and return early
|
2024-03-26 22:02:43 +00:00
|
|
|
if ( ConfigHelper::shouldDisable( $config->get( 'VectorNightModeOptions' ), $request, $title ) ) {
|
2024-05-04 02:58:54 +00:00
|
|
|
// The additional "-" prefix, makes this an invalid client preference for anonymous users.
|
|
|
|
return 'skin-theme-clientpref--excluded';
|
2024-03-26 22:02:43 +00:00
|
|
|
}
|
|
|
|
|
2024-05-06 16:13:00 +00:00
|
|
|
$prefix = '';
|
2024-05-07 07:19:13 +00:00
|
|
|
$valueRequest = $request->getRawVal( 'vectornightmode' );
|
2024-02-15 17:34:28 +00:00
|
|
|
// If night mode query string is used, hardcode pref value to the night mode value
|
2024-03-20 18:13:14 +00:00
|
|
|
// NOTE: The query string parameter only works for logged in users.
|
|
|
|
// IF you have set a cookie locally this will be overriden.
|
2024-05-07 07:19:13 +00:00
|
|
|
$value = $valueRequest !== null ? self::resolveNightModeQueryValue( $valueRequest ) :
|
2024-02-15 17:34:28 +00:00
|
|
|
$this->getUserPreferenceValue( CONSTANTS::PREF_KEY_NIGHT_MODE );
|
|
|
|
$suffixEnabled = 'clientpref-' . $value;
|
2024-03-20 18:13:14 +00:00
|
|
|
$suffixDisabled = 'clientpref-day';
|
|
|
|
// Must be hardcoded to 'skin-theme-' to be consistent with Minerva
|
2024-01-31 21:11:51 +00:00
|
|
|
// So that editors can target the same class across skins
|
2024-04-11 04:14:29 +00:00
|
|
|
$prefix .= 'skin-theme-';
|
2024-01-31 21:11:51 +00:00
|
|
|
break;
|
2024-07-08 16:25:30 +00:00
|
|
|
// These features persist for all users and have two valid states: 0 and 1.
|
2024-01-31 21:11:51 +00:00
|
|
|
case CONSTANTS::FEATURE_LIMITED_WIDTH:
|
|
|
|
case CONSTANTS::FEATURE_TOC_PINNED:
|
2024-04-12 03:27:34 +00:00
|
|
|
case CONSTANTS::FEATURE_APPEARANCE_PINNED:
|
2023-07-11 23:13:57 +00:00
|
|
|
$suffixEnabled = 'clientpref-1';
|
|
|
|
$suffixDisabled = 'clientpref-0';
|
|
|
|
break;
|
2024-07-08 16:25:30 +00:00
|
|
|
// These features only persist for logged in users so do not contain the clientpref suffix.
|
|
|
|
// These features have two valid states: enabled and disabled. In future it would be nice if these
|
|
|
|
// were 0 and 1 so that the features.js module cannot be applied to server side only flags.
|
|
|
|
case CONSTANTS::FEATURE_MAIN_MENU_PINNED:
|
|
|
|
case CONSTANTS::FEATURE_PAGE_TOOLS_PINNED:
|
|
|
|
// Server side only feature flags.
|
|
|
|
// Note these classes are fixed and cannot be changed at runtime by JavaScript,
|
|
|
|
// only via modification to LocalSettings.php.
|
|
|
|
case Constants::FEATURE_NIGHT_MODE:
|
|
|
|
case Constants::FEATURE_APPEARANCE:
|
|
|
|
case Constants::FEATURE_LIMITED_WIDTH_CONTENT:
|
|
|
|
case Constants::FEATURE_LANGUAGE_IN_HEADER:
|
|
|
|
case Constants::FEATURE_LANGUAGE_IN_MAIN_PAGE_HEADER:
|
|
|
|
case Constants::FEATURE_STICKY_HEADER:
|
2023-07-11 23:13:57 +00:00
|
|
|
$suffixEnabled = 'enabled';
|
|
|
|
$suffixDisabled = 'disabled';
|
|
|
|
break;
|
2024-07-08 16:25:30 +00:00
|
|
|
default:
|
|
|
|
throw new RuntimeException( "Feature $featureName has no associated feature class." );
|
2023-07-11 23:13:57 +00:00
|
|
|
}
|
2024-01-11 21:36:03 +00:00
|
|
|
return $this->isFeatureEnabled( $featureName ) ?
|
2023-07-11 23:13:57 +00:00
|
|
|
$prefix . $suffixEnabled : $prefix . $suffixDisabled;
|
2022-09-01 16:58:56 +00:00
|
|
|
}, array_keys( $this->features ) );
|
|
|
|
}
|
|
|
|
|
2020-02-20 16:37:33 +00:00
|
|
|
/**
|
|
|
|
* Gets whether the feature's requirements are met.
|
|
|
|
*
|
|
|
|
* @param string $feature
|
|
|
|
* @return bool
|
|
|
|
*
|
|
|
|
* @throws \InvalidArgumentException If the feature isn't registered
|
|
|
|
*/
|
2021-07-23 19:53:14 +00:00
|
|
|
public function isFeatureEnabled( string $feature ): bool {
|
2020-02-20 16:37:33 +00:00
|
|
|
if ( !array_key_exists( $feature, $this->features ) ) {
|
|
|
|
throw new \InvalidArgumentException( "The feature \"{$feature}\" isn't registered." );
|
|
|
|
}
|
|
|
|
|
|
|
|
$requirements = $this->features[$feature];
|
|
|
|
|
2020-02-28 15:42:05 +00:00
|
|
|
foreach ( $requirements as $name ) {
|
2020-03-02 12:39:47 +00:00
|
|
|
if ( !$this->requirements[$name]->isMet() ) {
|
2020-02-20 16:37:33 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-03-02 12:39:47 +00:00
|
|
|
/**
|
2023-03-03 09:40:44 +00:00
|
|
|
* Register a complex {@see Requirement}.
|
2020-03-02 12:39:47 +00:00
|
|
|
*
|
|
|
|
* A complex requirement is one that depends on object that may or may not be fully loaded
|
|
|
|
* while the application is booting, e.g. see `User::isSafeToLoad`.
|
|
|
|
*
|
|
|
|
* Such requirements are expected to be registered during a hook that is run early on in the
|
|
|
|
* application lifecycle, e.g. the `BeforePerformAction` and `APIBeforeMain` hooks.
|
|
|
|
*
|
|
|
|
* @param Requirement $requirement
|
|
|
|
*
|
|
|
|
* @throws \LogicException If the requirement has already been registered
|
|
|
|
*/
|
2020-04-29 14:13:27 +00:00
|
|
|
public function registerRequirement( Requirement $requirement ) {
|
2020-03-02 12:39:47 +00:00
|
|
|
$name = $requirement->getName();
|
|
|
|
|
|
|
|
if ( array_key_exists( $name, $this->requirements ) ) {
|
|
|
|
throw new \LogicException( "The requirement \"{$name}\" is already registered." );
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->requirements[$name] = $requirement;
|
|
|
|
}
|
|
|
|
|
2020-02-20 16:37:33 +00:00
|
|
|
/**
|
2023-03-03 09:40:44 +00:00
|
|
|
* Register a {@see SimpleRequirement}.
|
2020-02-20 16:37:33 +00:00
|
|
|
*
|
2020-02-28 15:42:05 +00:00
|
|
|
* A requirement is some condition of the application state that a feature requires to be true
|
|
|
|
* or false.
|
2020-02-20 16:37:33 +00:00
|
|
|
*
|
2020-02-28 15:42:05 +00:00
|
|
|
* @param string $name The name of the requirement
|
|
|
|
* @param bool $isMet Whether the requirement is met
|
2020-02-20 16:37:33 +00:00
|
|
|
*
|
2020-02-28 15:42:05 +00:00
|
|
|
* @throws \LogicException If the requirement has already been registered
|
2020-02-20 16:37:33 +00:00
|
|
|
*/
|
2020-04-29 14:13:27 +00:00
|
|
|
public function registerSimpleRequirement( string $name, bool $isMet ) {
|
|
|
|
$this->registerRequirement( new SimpleRequirement( $name, $isMet ) );
|
2020-02-20 16:37:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-02-28 15:42:05 +00:00
|
|
|
* Gets whether the requirement is met.
|
2020-02-20 16:37:33 +00:00
|
|
|
*
|
2020-02-28 15:42:05 +00:00
|
|
|
* @param string $name The name of the requirement
|
2020-02-20 16:37:33 +00:00
|
|
|
* @return bool
|
|
|
|
*
|
2020-02-28 15:42:05 +00:00
|
|
|
* @throws \InvalidArgumentException If the requirement isn't registered
|
2020-02-20 16:37:33 +00:00
|
|
|
*/
|
2021-07-23 19:53:14 +00:00
|
|
|
public function isRequirementMet( string $name ): bool {
|
2020-02-28 15:42:05 +00:00
|
|
|
if ( !array_key_exists( $name, $this->requirements ) ) {
|
|
|
|
throw new \InvalidArgumentException( "Requirement \"{$name}\" isn't registered." );
|
2020-02-20 16:37:33 +00:00
|
|
|
}
|
|
|
|
|
2020-03-02 12:39:47 +00:00
|
|
|
return $this->requirements[$name]->isMet();
|
2020-02-20 16:37:33 +00:00
|
|
|
}
|
2024-03-20 18:13:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts "1", "2", and "0" to equivalent values.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
private static function resolveNightModeQueryValue( string $value ) {
|
|
|
|
switch ( $value ) {
|
|
|
|
case 'day':
|
|
|
|
case 'night':
|
|
|
|
case 'os':
|
|
|
|
return $value;
|
|
|
|
case '1':
|
|
|
|
return 'night';
|
|
|
|
case '2':
|
|
|
|
return 'os';
|
|
|
|
default:
|
|
|
|
return 'day';
|
|
|
|
}
|
|
|
|
}
|
2020-02-20 16:37:33 +00:00
|
|
|
}
|