mirror of
https://github.com/StarCitizenTools/mediawiki-skins-Citizen.git
synced 2024-12-01 09:26:53 +00:00
ci: lint code to MediaWiki standards
Check commit and GitHub actions for more details
This commit is contained in:
parent
affe2ddc66
commit
002240b384
|
@ -153,30 +153,30 @@ class CitizenHooks {
|
||||||
return MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 'Citizen' )->get( $name );
|
return MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 'Citizen' )->get( $name );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param User $user
|
* @param User $user
|
||||||
* @param array $preferences
|
* @param array &$preferences
|
||||||
*/
|
*/
|
||||||
public static function onGetPreferences( $user, &$preferences ) {
|
public static function onGetPreferences( $user, &$preferences ) {
|
||||||
$options = MediaWikiServices::getInstance()
|
$options = MediaWikiServices::getInstance()
|
||||||
->getUserOptionsLookup()
|
->getUserOptionsLookup()
|
||||||
->getOptions( $user );
|
->getOptions( $user );
|
||||||
|
|
||||||
if ( $options['skin'] !== 'citizen' ) {
|
if ( $options['skin'] !== 'citizen' ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// A checkbox
|
// A checkbox
|
||||||
$preferences['citizen-color-scheme'] = [
|
$preferences['citizen-color-scheme'] = [
|
||||||
'type' => 'select',
|
'type' => 'select',
|
||||||
'label-message' => 'citizen-upo-style',
|
'label-message' => 'citizen-upo-style',
|
||||||
'section' => 'rendering/skin',
|
'section' => 'rendering/skin',
|
||||||
'options' => [
|
'options' => [
|
||||||
wfMessage( 'citizen-upo-style-auto' )->escaped() => 'auto',
|
wfMessage( 'citizen-upo-style-auto' )->escaped() => 'auto',
|
||||||
wfMessage( 'citizen-upo-style-light' )->escaped() => 'light',
|
wfMessage( 'citizen-upo-style-light' )->escaped() => 'light',
|
||||||
wfMessage( 'citizen-upo-style-dark' )->escaped() => 'dark',
|
wfMessage( 'citizen-upo-style-dark' )->escaped() => 'dark',
|
||||||
],
|
],
|
||||||
'default' => $options['citizen-color-scheme'] ?? 'auto'
|
'default' => $options['citizen-color-scheme'] ?? 'auto'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -736,32 +736,32 @@ class SkinCitizen extends SkinMustache {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the corresponding color scheme class on the <html> element
|
* Sets the corresponding color scheme class on the <html> element
|
||||||
* If the color scheme is set to auto, the theme switcher script will be added
|
* If the color scheme is set to auto, the theme switcher script will be added
|
||||||
*
|
*
|
||||||
* @param OutputPage $out
|
* @param OutputPage $out
|
||||||
* @param array $skinOptions
|
* @param array &$skinOptions
|
||||||
*/
|
*/
|
||||||
private function setSkinColorScheme( OutputPage $out, array &$skinOptions ) {
|
private function setSkinColorScheme( OutputPage $out, array &$skinOptions ) {
|
||||||
$options = MediaWikiServices::getInstance()
|
$options = MediaWikiServices::getInstance()
|
||||||
->getUserOptionsLookup()
|
->getUserOptionsLookup()
|
||||||
->getOptions( $this->getUser() );
|
->getOptions( $this->getUser() );
|
||||||
|
|
||||||
$skinStyle = $this->getConfigValue( 'ColorScheme' );
|
$skinStyle = $this->getConfigValue( 'ColorScheme' );
|
||||||
|
|
||||||
$setDarkClass = $skinStyle === 'dark' || $options['citizen-color-scheme'] === 'dark';
|
$setDarkClass = $skinStyle === 'dark' || $options['citizen-color-scheme'] === 'dark';
|
||||||
$setLightClass = $skinStyle === 'light' || $options['citizen-color-scheme'] === 'light';
|
$setLightClass = $skinStyle === 'light' || $options['citizen-color-scheme'] === 'light';
|
||||||
|
|
||||||
if ( $setDarkClass ) {
|
if ( $setDarkClass ) {
|
||||||
$out->addHtmlClasses( 'skin-citizen-dark' );
|
$out->addHtmlClasses( 'skin-citizen-dark' );
|
||||||
} elseif ($setLightClass) {
|
} elseif ( $setLightClass ) {
|
||||||
$out->addHtmlClasses( 'skin-citizen-light' );
|
$out->addHtmlClasses( 'skin-citizen-light' );
|
||||||
} else {
|
} else {
|
||||||
$skinOptions['scripts'] = array_merge(
|
$skinOptions['scripts'] = array_merge(
|
||||||
$skinOptions['scripts'],
|
$skinOptions['scripts'],
|
||||||
[ 'skins.citizen.scripts.theme-switcher' ]
|
[ 'skins.citizen.scripts.theme-switcher' ]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue