mirror of
https://github.com/StarCitizenTools/mediawiki-skins-Citizen.git
synced 2024-11-24 14:34:09 +00:00
refactor: Lint code
This commit is contained in:
parent
75965bec27
commit
c1086c9295
|
@ -175,7 +175,10 @@ class CitizenHooks {
|
|||
wfMessage( 'prefs-citizen-theme-option-light' )->escaped() => 'light',
|
||||
wfMessage( 'prefs-citizen-theme-option-dark' )->escaped() => 'dark',
|
||||
],
|
||||
'default' => MediaWikiServices::getInstance()->getUserOptionsLookup()->getOption( $user, 'CitizenThemeUser' ) ?? 'auto',
|
||||
'default' => MediaWikiServices::getInstance()->getUserOptionsLookup()->getOption(
|
||||
$user,
|
||||
'CitizenThemeUser'
|
||||
) ?? 'auto',
|
||||
// Only show this section when the Citizen skin is checked. The JavaScript client also uses
|
||||
// this state to determine whether to show or hide the whole section.
|
||||
'hide-if' => [ '!==', 'wpskin', 'citizen' ],
|
||||
|
|
|
@ -45,6 +45,10 @@ class Drawer {
|
|||
*/
|
||||
private $skin;
|
||||
|
||||
/**
|
||||
* Drawer constructor.
|
||||
* @param SkinCitizen $skin
|
||||
*/
|
||||
public function __construct( SkinCitizen $skin ) {
|
||||
$this->skin = $skin;
|
||||
}
|
||||
|
|
|
@ -26,10 +26,14 @@ declare( strict_types=1 );
|
|||
namespace Citizen\Partials;
|
||||
|
||||
use Citizen\GetConfigTrait;
|
||||
use Linker;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MWException;
|
||||
use OutputPage;
|
||||
use Skin;
|
||||
use SkinCitizen;
|
||||
use SpecialPage;
|
||||
use Title;
|
||||
|
||||
/**
|
||||
* Header partial of Skin Citizen
|
||||
|
@ -55,7 +59,11 @@ class Header {
|
|||
*/
|
||||
private $out;
|
||||
|
||||
public function __construct( \SkinCitizen $skin ) {
|
||||
/**
|
||||
* Header constructor.
|
||||
* @param SkinCitizen $skin
|
||||
*/
|
||||
public function __construct( SkinCitizen $skin ) {
|
||||
$this->skin = $skin;
|
||||
$this->out = $skin->getOutput();
|
||||
}
|
||||
|
@ -133,7 +141,7 @@ class Header {
|
|||
*/
|
||||
public function buildSearchProps() : array {
|
||||
$toggleMsg = $this->skin->msg( 'citizen-search-toggle' )->text();
|
||||
$accessKey = \Linker::accesskey( 'search' );
|
||||
$accessKey = Linker::accesskey( 'search' );
|
||||
|
||||
return [
|
||||
'msg-citizen-search-toggle' => $toggleMsg,
|
||||
|
@ -141,7 +149,7 @@ class Header {
|
|||
'form-action' => $this->getConfigValue( 'Script' ),
|
||||
'html-input' => $this->skin->makeSearchInput( [ 'id' => 'searchInput' ] ),
|
||||
'msg-search' => $this->skin->msg( 'search' ),
|
||||
'page-title' => \SpecialPage::getTitleFor( 'Search' )->getPrefixedDBkey(),
|
||||
'page-title' => SpecialPage::getTitleFor( 'Search' )->getPrefixedDBkey(),
|
||||
'html-random-href' => Skin::makeSpecialUrl( 'Randompage' ),
|
||||
'msg-random' => $this->skin->msg( 'Randompage' )->text(),
|
||||
];
|
||||
|
@ -185,14 +193,15 @@ class Header {
|
|||
$msgName = 'group-%s';
|
||||
|
||||
foreach ( $groups as $group ) {
|
||||
$groupPage = \Title::newFromText(
|
||||
$groupPage = Title::newFromText(
|
||||
$this->skin->msg( sprintf( $msgName, $group ) )->text(),
|
||||
NS_PROJECT
|
||||
);
|
||||
|
||||
$groupLinks[$group] = [
|
||||
'msg' => sprintf( $msgName, $group ),
|
||||
'href' => $groupPage->getLinkURL(), // Nullpointer should not happen
|
||||
// Nullpointer should not happen
|
||||
'href' => $groupPage->getLinkURL(),
|
||||
'tooltiponly' => true,
|
||||
'id' => sprintf( $msgName, $group ),
|
||||
// 'exists' => $groupPage->exists() - This will add an additional DB call
|
||||
|
|
|
@ -38,6 +38,10 @@ class Metadata {
|
|||
*/
|
||||
private $out;
|
||||
|
||||
/**
|
||||
* Metadata constructor.
|
||||
* @param OutputPage $out
|
||||
*/
|
||||
public function __construct( OutputPage $out ) {
|
||||
$this->out = $out;
|
||||
}
|
||||
|
@ -85,7 +89,7 @@ class Metadata {
|
|||
*/
|
||||
private function addManifest() {
|
||||
if ( $this->getConfigValue( 'CitizenEnableManifest' ) !== true ) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -107,7 +111,7 @@ return;
|
|||
*/
|
||||
private function addPreConnect() {
|
||||
if ( $this->getConfigValue( 'CitizenEnablePreconnect' ) !== true ) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
$this->out->addLink( [
|
||||
|
|
|
@ -41,6 +41,10 @@ class Theme {
|
|||
*/
|
||||
private $out;
|
||||
|
||||
/**
|
||||
* Theme constructor.
|
||||
* @param OutputPage $out
|
||||
*/
|
||||
public function __construct( OutputPage $out ) {
|
||||
$this->out = $out;
|
||||
}
|
||||
|
@ -79,6 +83,7 @@ class Theme {
|
|||
}
|
||||
|
||||
// Script content at 'skins.citizen.scripts.theme/inline.js
|
||||
// @phpcs:ignore Generic.Files.LineLength.TooLong
|
||||
$this->out->getOutput()->addHeadItem( 'theme-switcher', '<script>window.switchTheme=(()=>{try{const t=document.cookie.match(/skin-citizen-theme=(dark|light|auto)/),e=null!==t?t.pop():null;null!==e&&(document.documentElement.classList.remove(...["auto","dark","light"].map(t=>"skin-citizen-"+t)),document.documentElement.classList.add("skin-citizen-"+e))}catch(t){}}),window.switchTheme();</script>' );
|
||||
|
||||
// Add styles and scripts module
|
||||
|
|
|
@ -105,8 +105,8 @@ class SkinCitizen extends SkinMustache {
|
|||
$out = $this->getOutput();
|
||||
$title = $out->getTitle();
|
||||
|
||||
$skinDrawer = new Drawer( $this );
|
||||
$skinHeader = new Header( $this );
|
||||
$drawer = new Drawer( $this );
|
||||
$header = new Header( $this );
|
||||
|
||||
// Naming conventions for Mustache parameters.
|
||||
//
|
||||
|
@ -133,14 +133,14 @@ class SkinCitizen extends SkinMustache {
|
|||
'href' => Skin::makeMainPageUrl(),
|
||||
]
|
||||
),
|
||||
'data-logos' => $skinDrawer->getLogoData(),
|
||||
'data-logos' => $drawer->getLogoData(),
|
||||
|
||||
'data-header' => [
|
||||
'data-drawer' => $skinDrawer->buildDrawer(),
|
||||
'data-extratools' => $skinHeader->getExtraTools(),
|
||||
'data-personal-menu' => $skinHeader->buildPersonalMenu(),
|
||||
'data-theme-toggle' => $skinHeader->buildThemeToggleProps(),
|
||||
'data-search-box' => $skinHeader->buildSearchProps(),
|
||||
'data-drawer' => $drawer->buildDrawer(),
|
||||
'data-extratools' => $header->getExtraTools(),
|
||||
'data-personal-menu' => $header->buildPersonalMenu(),
|
||||
'data-theme-toggle' => $header->buildThemeToggleProps(),
|
||||
'data-search-box' => $header->buildSearchProps(),
|
||||
],
|
||||
|
||||
'data-pagetools' => $this->buildPageTools(),
|
||||
|
@ -380,15 +380,13 @@ class SkinCitizen extends SkinMustache {
|
|||
];
|
||||
}
|
||||
|
||||
$data = [
|
||||
return [
|
||||
'html-lastmodified' => $lastMod,
|
||||
'array-footer-rows' => $footerRows,
|
||||
'array-footer-icons' => $footerIconRows,
|
||||
'msg-citizen-footer-desc' => $skin->msg( 'citizen-footer-desc' )->text(),
|
||||
'msg-citizen-footer-tagline' => $skin->msg( 'citizen-footer-tagline' )->text(),
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue