mirror of
https://github.com/StarCitizenTools/mediawiki-skins-Citizen.git
synced 2024-11-27 15:50:34 +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 */
|
/* 1 week */
|
||||||
private const CACHE_MAX_AGE = 604800;
|
private const CACHE_MAX_AGE = 604800;
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*/
|
|
||||||
public function __construct() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the requested Api actions.
|
* Execute the requested Api actions.
|
||||||
*/
|
*/
|
||||||
|
@ -124,6 +118,11 @@ class ApiWebappManifest extends ApiBase {
|
||||||
return $icons;
|
return $icons;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get src, sizes, and type for each icon for the manifest
|
||||||
|
*
|
||||||
|
* @return array|null
|
||||||
|
*/
|
||||||
private function getIconData( $logoPath, $logoContent ) {
|
private function getIconData( $logoPath, $logoContent ) {
|
||||||
$imageSize = getimagesizefromstring( $logoContent );
|
$imageSize = getimagesizefromstring( $logoContent );
|
||||||
if ( $imageSize !== false ) {
|
if ( $imageSize !== false ) {
|
||||||
|
|
|
@ -38,9 +38,9 @@ class CitizenComponentPageHeading implements CitizenComponent {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param MessageLocalizer $localizer
|
* @param MessageLocalizer $localizer
|
||||||
|
* @param OutputPage $out
|
||||||
* @param Language|StubUserLang $pageLang
|
* @param Language|StubUserLang $pageLang
|
||||||
* @param Title $title
|
* @param Title $title
|
||||||
* @param OutputPage $out
|
|
||||||
* @param string $titleData
|
* @param string $titleData
|
||||||
* @param UserIdentity $user
|
* @param UserIdentity $user
|
||||||
*/
|
*/
|
||||||
|
@ -192,7 +192,13 @@ class CitizenComponentPageHeading implements CitizenComponent {
|
||||||
return $localizer->msg( 'citizen-tagline-ns-talk' )->parse();
|
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 ) {
|
if ( $isRootUserPage ) {
|
||||||
// Build user tagline if it is a top-level user page
|
// Build user tagline if it is a top-level user page
|
||||||
return $this->buildUserTagline();
|
return $this->buildUserTagline();
|
||||||
|
|
|
@ -43,8 +43,8 @@ class CitizenComponentPageTools implements CitizenComponent {
|
||||||
/**
|
/**
|
||||||
* @param Config $config
|
* @param Config $config
|
||||||
* @param MessageLocalizer $localizer
|
* @param MessageLocalizer $localizer
|
||||||
* @param UserIdentity $user
|
|
||||||
* @param Title $title
|
* @param Title $title
|
||||||
|
* @param UserIdentity $user
|
||||||
* @param int $numLanguages
|
* @param int $numLanguages
|
||||||
* @param array $sidebarData
|
* @param array $sidebarData
|
||||||
* @param array $languagesData
|
* @param array $languagesData
|
||||||
|
@ -137,10 +137,9 @@ class CitizenComponentPageTools implements CitizenComponent {
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function getTemplateData(): array {
|
public function getTemplateData(): array {
|
||||||
$hasLanguages = (
|
$hasLanguages =
|
||||||
$this->languagesData && $this->languagesData[ 'is-empty'] !== true ||
|
( $this->languagesData && $this->languagesData[ 'is-empty' ] !== true ) ||
|
||||||
$this->variantsData && $this->variantsData[ 'is-empty'] !== true
|
( $this->variantsData && $this->variantsData[ 'is-empty' ] !== true );
|
||||||
);
|
|
||||||
$articleTools = $this->getArticleToolsData();
|
$articleTools = $this->getArticleToolsData();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
|
@ -19,21 +19,16 @@ class CitizenComponentSearchBox implements CitizenComponent {
|
||||||
/** @var array */
|
/** @var array */
|
||||||
private $searchBoxData;
|
private $searchBoxData;
|
||||||
|
|
||||||
/** @var Skin */
|
|
||||||
private $skin;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param MessageLocalizer $localizer
|
* @param MessageLocalizer $localizer
|
||||||
* @param array $searchBoxData
|
* @param array $searchBoxData
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
MessageLocalizer $localizer,
|
MessageLocalizer $localizer,
|
||||||
array $searchBoxData,
|
array $searchBoxData
|
||||||
Skin $skin
|
|
||||||
) {
|
) {
|
||||||
$this->localizer = $localizer;
|
$this->localizer = $localizer;
|
||||||
$this->searchBoxData = $searchBoxData;
|
$this->searchBoxData = $searchBoxData;
|
||||||
$this->skin = $skin;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -74,13 +69,14 @@ class CitizenComponentSearchBox implements CitizenComponent {
|
||||||
*/
|
*/
|
||||||
public function getTemplateData(): array {
|
public function getTemplateData(): array {
|
||||||
$searchBoxData = $this->searchBoxData;
|
$searchBoxData = $this->searchBoxData;
|
||||||
|
$randompageUrl = SpecialPage::getTitleFor( 'Randompage' )->getLocalURL();
|
||||||
|
|
||||||
return $searchBoxData += [
|
return $searchBoxData += [
|
||||||
'array-keyboard-hint' => $this->getKeyboardHintData(),
|
'array-keyboard-hint' => $this->getKeyboardHintData(),
|
||||||
'msg-citizen-search-footer' => $this->getFooterMessage(),
|
'msg-citizen-search-footer' => $this->getFooterMessage(),
|
||||||
'msg-citizen-search-toggle-shortcut' => '[/]',
|
'msg-citizen-search-toggle-shortcut' => '[/]',
|
||||||
// TODO: Replace with SkinComponentUtils on 1.43
|
// 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
|
* @param Config $config
|
||||||
*/
|
|
||||||
private function getConfig(): Config {
|
|
||||||
return $this->config;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param MessageLocalizer $localizer
|
* @param MessageLocalizer $localizer
|
||||||
* @param Language|StubUserLang $pageLang
|
* @param Language|StubUserLang $pageLang
|
||||||
*/
|
*/
|
||||||
|
@ -75,7 +69,7 @@ class CitizenComponentSiteStats implements CitizenComponent {
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function getTemplateData(): array {
|
public function getTemplateData(): array {
|
||||||
$config = $this->getConfig();
|
$config = $this->config;
|
||||||
if ( !$config->get( 'CitizenEnableDrawerSiteStats' ) ) {
|
if ( !$config->get( 'CitizenEnableDrawerSiteStats' ) ) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,8 +143,7 @@ class SkinCitizen extends SkinMustache {
|
||||||
),
|
),
|
||||||
'data-search-box' => new CitizenComponentSearchBox(
|
'data-search-box' => new CitizenComponentSearchBox(
|
||||||
$localizer,
|
$localizer,
|
||||||
$parentData['data-search-box'],
|
$parentData['data-search-box']
|
||||||
$this
|
|
||||||
),
|
),
|
||||||
'data-site-stats' => new CitizenComponentSiteStats(
|
'data-site-stats' => new CitizenComponentSiteStats(
|
||||||
$config,
|
$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