mirror of
https://github.com/StarCitizenTools/mediawiki-skins-Citizen.git
synced 2024-11-23 14:06:58 +00:00
refactor(core): ♻️ fix various phpcs issues
This commit is contained in:
parent
7b9522b395
commit
4e48a19503
|
@ -40,12 +40,6 @@ class ApiWebappManifest extends ApiBase {
|
|||
/* 1 week */
|
||||
private const CACHE_MAX_AGE = 604800;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the requested Api actions.
|
||||
*/
|
||||
|
@ -124,6 +118,11 @@ class ApiWebappManifest extends ApiBase {
|
|||
return $icons;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get src, sizes, and type for each icon for the manifest
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
private function getIconData( $logoPath, $logoContent ) {
|
||||
$imageSize = getimagesizefromstring( $logoContent );
|
||||
if ( $imageSize !== false ) {
|
||||
|
|
|
@ -38,9 +38,9 @@ class CitizenComponentPageHeading implements CitizenComponent {
|
|||
|
||||
/**
|
||||
* @param MessageLocalizer $localizer
|
||||
* @param OutputPage $out
|
||||
* @param Language|StubUserLang $pageLang
|
||||
* @param Title $title
|
||||
* @param OutputPage $out
|
||||
* @param string $titleData
|
||||
* @param UserIdentity $user
|
||||
*/
|
||||
|
@ -192,7 +192,13 @@ class CitizenComponentPageHeading implements CitizenComponent {
|
|||
return $localizer->msg( 'citizen-tagline-ns-talk' )->parse();
|
||||
}
|
||||
|
||||
$isRootUserPage = $title->inNamespace( NS_USER ) || ( defined( 'NS_USER_WIKI' ) && $title->inNamespace( NS_USER_WIKI ) ) || ( defined( 'NS_USER_WIKI' ) && $title->inNamespace( NS_USER_PROFILE ) ) && !$title->isSubpage();
|
||||
$isRootUserPage = (
|
||||
$title->inNamespace( NS_USER ) ||
|
||||
( defined( 'NS_USER_WIKI' ) && $title->inNamespace( NS_USER_WIKI ) ) ||
|
||||
( defined( 'NS_USER_WIKI' ) && $title->inNamespace( NS_USER_PROFILE ) )
|
||||
) &&
|
||||
!$title->isSubpage();
|
||||
|
||||
if ( $isRootUserPage ) {
|
||||
// Build user tagline if it is a top-level user page
|
||||
return $this->buildUserTagline();
|
||||
|
|
|
@ -43,8 +43,8 @@ class CitizenComponentPageTools implements CitizenComponent {
|
|||
/**
|
||||
* @param Config $config
|
||||
* @param MessageLocalizer $localizer
|
||||
* @param UserIdentity $user
|
||||
* @param Title $title
|
||||
* @param UserIdentity $user
|
||||
* @param int $numLanguages
|
||||
* @param array $sidebarData
|
||||
* @param array $languagesData
|
||||
|
@ -137,10 +137,9 @@ class CitizenComponentPageTools implements CitizenComponent {
|
|||
* @inheritDoc
|
||||
*/
|
||||
public function getTemplateData(): array {
|
||||
$hasLanguages = (
|
||||
$this->languagesData && $this->languagesData[ 'is-empty'] !== true ||
|
||||
$this->variantsData && $this->variantsData[ 'is-empty'] !== true
|
||||
);
|
||||
$hasLanguages =
|
||||
( $this->languagesData && $this->languagesData[ 'is-empty' ] !== true ) ||
|
||||
( $this->variantsData && $this->variantsData[ 'is-empty' ] !== true );
|
||||
$articleTools = $this->getArticleToolsData();
|
||||
|
||||
return [
|
||||
|
|
|
@ -19,21 +19,16 @@ class CitizenComponentSearchBox implements CitizenComponent {
|
|||
/** @var array */
|
||||
private $searchBoxData;
|
||||
|
||||
/** @var Skin */
|
||||
private $skin;
|
||||
|
||||
/**
|
||||
* @param MessageLocalizer $localizer
|
||||
* @param array $searchBoxData
|
||||
*/
|
||||
public function __construct(
|
||||
MessageLocalizer $localizer,
|
||||
array $searchBoxData,
|
||||
Skin $skin
|
||||
array $searchBoxData
|
||||
) {
|
||||
$this->localizer = $localizer;
|
||||
$this->searchBoxData = $searchBoxData;
|
||||
$this->skin = $skin;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -74,13 +69,14 @@ class CitizenComponentSearchBox implements CitizenComponent {
|
|||
*/
|
||||
public function getTemplateData(): array {
|
||||
$searchBoxData = $this->searchBoxData;
|
||||
$randompageUrl = SpecialPage::getTitleFor( 'Randompage' )->getLocalURL();
|
||||
|
||||
return $searchBoxData += [
|
||||
'array-keyboard-hint' => $this->getKeyboardHintData(),
|
||||
'msg-citizen-search-footer' => $this->getFooterMessage(),
|
||||
'msg-citizen-search-toggle-shortcut' => '[/]',
|
||||
// TODO: Replace with SkinComponentUtils on 1.43
|
||||
'html-random-href' => SpecialPage::getTitleFor( 'Randompage' )->getLocalURL(),
|
||||
'html-random-href' => $randompageUrl,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,13 +34,7 @@ class CitizenComponentSiteStats implements CitizenComponent {
|
|||
];
|
||||
|
||||
/**
|
||||
* @return Config
|
||||
*/
|
||||
private function getConfig(): Config {
|
||||
return $this->config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Config $config
|
||||
* @param MessageLocalizer $localizer
|
||||
* @param Language|StubUserLang $pageLang
|
||||
*/
|
||||
|
@ -75,7 +69,7 @@ class CitizenComponentSiteStats implements CitizenComponent {
|
|||
* @inheritDoc
|
||||
*/
|
||||
public function getTemplateData(): array {
|
||||
$config = $this->getConfig();
|
||||
$config = $this->config;
|
||||
if ( !$config->get( 'CitizenEnableDrawerSiteStats' ) ) {
|
||||
return [];
|
||||
}
|
||||
|
|
|
@ -143,8 +143,7 @@ class SkinCitizen extends SkinMustache {
|
|||
),
|
||||
'data-search-box' => new CitizenComponentSearchBox(
|
||||
$localizer,
|
||||
$parentData['data-search-box'],
|
||||
$this
|
||||
$parentData['data-search-box']
|
||||
),
|
||||
'data-site-stats' => new CitizenComponentSiteStats(
|
||||
$config,
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare( strict_types=1 );
|
||||
|
||||
namespace MediaWiki\Skins\Citizen\Components;
|
||||
|
||||
/**
|
||||
* CitizenComponentMenuListItem component
|
||||
*/
|
||||
class CitizenComponentMenuListItem implements CitizenComponent {
|
||||
/** @var CitizenComponentLink */
|
||||
private $link;
|
||||
/** @var string */
|
||||
private $class;
|
||||
/** @var string */
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @param CitizenComponentLink $link
|
||||
* @param string $class
|
||||
* @param string $id
|
||||
*/
|
||||
public function __construct( CitizenComponentLink $link, string $class = '', string $id = '' ) {
|
||||
$this->link = $link;
|
||||
$this->class = $class;
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getTemplateData(): array {
|
||||
return $this->link->getTemplateData() + [
|
||||
'item-class' => $this->class,
|
||||
'item-id' => $this->id,
|
||||
];
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue