ci: lint code to MediaWiki standards

Check commit and GitHub actions for more details
This commit is contained in:
github-actions 2021-01-09 22:15:47 +00:00
parent affe2ddc66
commit 002240b384
2 changed files with 48 additions and 48 deletions

View file

@ -153,30 +153,30 @@ class CitizenHooks {
return MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 'Citizen' )->get( $name );
}
/**
* @param User $user
* @param array $preferences
*/
public static function onGetPreferences( $user, &$preferences ) {
$options = MediaWikiServices::getInstance()
->getUserOptionsLookup()
->getOptions( $user );
/**
* @param User $user
* @param array &$preferences
*/
public static function onGetPreferences( $user, &$preferences ) {
$options = MediaWikiServices::getInstance()
->getUserOptionsLookup()
->getOptions( $user );
if ( $options['skin'] !== 'citizen' ) {
return;
}
if ( $options['skin'] !== 'citizen' ) {
return;
}
// A checkbox
$preferences['citizen-color-scheme'] = [
'type' => 'select',
'label-message' => 'citizen-upo-style',
'section' => 'rendering/skin',
'options' => [
wfMessage( 'citizen-upo-style-auto' )->escaped() => 'auto',
wfMessage( 'citizen-upo-style-light' )->escaped() => 'light',
wfMessage( 'citizen-upo-style-dark' )->escaped() => 'dark',
],
'default' => $options['citizen-color-scheme'] ?? 'auto'
];
}
// A checkbox
$preferences['citizen-color-scheme'] = [
'type' => 'select',
'label-message' => 'citizen-upo-style',
'section' => 'rendering/skin',
'options' => [
wfMessage( 'citizen-upo-style-auto' )->escaped() => 'auto',
wfMessage( 'citizen-upo-style-light' )->escaped() => 'light',
wfMessage( 'citizen-upo-style-dark' )->escaped() => 'dark',
],
'default' => $options['citizen-color-scheme'] ?? 'auto'
];
}
}

View file

@ -736,32 +736,32 @@ class SkinCitizen extends SkinMustache {
}
}
/**
* 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
*
* @param OutputPage $out
* @param array $skinOptions
*/
/**
* 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
*
* @param OutputPage $out
* @param array &$skinOptions
*/
private function setSkinColorScheme( OutputPage $out, array &$skinOptions ) {
$options = MediaWikiServices::getInstance()
->getUserOptionsLookup()
->getOptions( $this->getUser() );
$options = MediaWikiServices::getInstance()
->getUserOptionsLookup()
->getOptions( $this->getUser() );
$skinStyle = $this->getConfigValue( 'ColorScheme' );
$skinStyle = $this->getConfigValue( 'ColorScheme' );
$setDarkClass = $skinStyle === 'dark' || $options['citizen-color-scheme'] === 'dark';
$setLightClass = $skinStyle === 'light' || $options['citizen-color-scheme'] === 'light';
$setDarkClass = $skinStyle === 'dark' || $options['citizen-color-scheme'] === 'dark';
$setLightClass = $skinStyle === 'light' || $options['citizen-color-scheme'] === 'light';
if ( $setDarkClass ) {
$out->addHtmlClasses( 'skin-citizen-dark' );
} elseif ($setLightClass) {
$out->addHtmlClasses( 'skin-citizen-light' );
} else {
$skinOptions['scripts'] = array_merge(
$skinOptions['scripts'],
[ 'skins.citizen.scripts.theme-switcher' ]
);
}
}
if ( $setDarkClass ) {
$out->addHtmlClasses( 'skin-citizen-dark' );
} elseif ( $setLightClass ) {
$out->addHtmlClasses( 'skin-citizen-light' );
} else {
$skinOptions['scripts'] = array_merge(
$skinOptions['scripts'],
[ 'skins.citizen.scripts.theme-switcher' ]
);
}
}
}