2024-02-06 22:26:55 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace MediaWiki\Minerva\Skins;
|
|
|
|
|
|
|
|
use MediaWiki\Request\WebRequest;
|
2024-03-24 18:26:16 +00:00
|
|
|
use MediaWiki\Skins\Vector\ConfigHelper;
|
2024-02-06 22:26:55 +00:00
|
|
|
use MediaWiki\Title\Title;
|
|
|
|
|
|
|
|
class FeaturesHelper {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Per the $options configuration (for use with $wgMinervaNightModeOptions)
|
|
|
|
* determine whether Night Mode should be disabled on the page.
|
|
|
|
* For the main page: Check the value of $options['exclude']['mainpage']
|
|
|
|
* Night Mode is disabled if:
|
|
|
|
* 1) The current namespace is listed in array $options['exclude']['namespaces']
|
|
|
|
* OR
|
|
|
|
* 2) A query string parameter matches one of the regex patterns in $exclusions['querystring'].
|
|
|
|
* OR
|
|
|
|
* 3) The canonical title matches one of the titles in $options['exclude']['pagetitles']
|
2024-03-19 22:28:41 +00:00
|
|
|
* For this functionality to work the Vector skin MUST be installed.
|
2024-02-06 22:26:55 +00:00
|
|
|
*
|
|
|
|
* @param array $options
|
|
|
|
* @param WebRequest $request
|
|
|
|
* @param Title|null $title
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
* @internal only for use inside tests.
|
|
|
|
*/
|
2024-03-28 19:15:41 +00:00
|
|
|
public function shouldDisableNightMode( array $options, WebRequest $request, Title $title = null ): bool {
|
2024-03-24 18:26:16 +00:00
|
|
|
return class_exists( ConfigHelper::class ) ?
|
|
|
|
ConfigHelper::shouldDisable( $options, $request, $title ) :
|
|
|
|
false;
|
2024-02-06 22:26:55 +00:00
|
|
|
}
|
|
|
|
}
|