mirror of
https://github.com/StarCitizenTools/mediawiki-skins-Citizen.git
synced 2024-11-24 14:34:09 +00:00
refactor: Create base partial class
This commit is contained in:
parent
24a2a38b4b
commit
ff49d0c9be
|
@ -28,7 +28,6 @@ namespace Citizen\Partials;
|
|||
use Exception;
|
||||
use ResourceLoaderSkinModule;
|
||||
use Skin;
|
||||
use SkinCitizen;
|
||||
|
||||
/**
|
||||
* Drawer partial of Skin Citizen
|
||||
|
@ -38,21 +37,7 @@ use SkinCitizen;
|
|||
* + Special Pages Link
|
||||
* + Upload Link
|
||||
*/
|
||||
class Drawer {
|
||||
|
||||
/**
|
||||
* @var Skin
|
||||
*/
|
||||
private $skin;
|
||||
|
||||
/**
|
||||
* Drawer constructor.
|
||||
* @param SkinCitizen $skin
|
||||
*/
|
||||
public function __construct( SkinCitizen $skin ) {
|
||||
$this->skin = $skin;
|
||||
}
|
||||
|
||||
final class Drawer extends Partial {
|
||||
/**
|
||||
* Get and pick the correct logo based on types and variants
|
||||
* Based on getLogoData() in MW 1.36
|
||||
|
@ -61,8 +46,10 @@ class Drawer {
|
|||
*/
|
||||
public function getLogoData() : array {
|
||||
$logoData = ResourceLoaderSkinModule::getAvailableLogos( $this->skin->getConfig() );
|
||||
|
||||
// check if the logo supports variants
|
||||
$variantsLogos = $logoData['variants'] ?? null;
|
||||
|
||||
if ( $variantsLogos ) {
|
||||
$preferred = $this->skin->getOutput()->getTitle()
|
||||
->getPageViewLanguage()->getCode();
|
||||
|
@ -74,6 +61,7 @@ class Drawer {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $logoData;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,13 +25,10 @@ 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;
|
||||
|
||||
|
@ -43,30 +40,7 @@ use Title;
|
|||
* - Search
|
||||
* - Theme Toggle
|
||||
*/
|
||||
class Header {
|
||||
|
||||
use GetConfigTrait;
|
||||
|
||||
/**
|
||||
* @var Skin
|
||||
*/
|
||||
private $skin;
|
||||
|
||||
/**
|
||||
* Needed for trait
|
||||
*
|
||||
* @var OutputPage
|
||||
*/
|
||||
private $out;
|
||||
|
||||
/**
|
||||
* Header constructor.
|
||||
* @param SkinCitizen $skin
|
||||
*/
|
||||
public function __construct( SkinCitizen $skin ) {
|
||||
$this->skin = $skin;
|
||||
$this->out = $skin->getOutput();
|
||||
}
|
||||
final class Header extends Partial {
|
||||
|
||||
/**
|
||||
* Build Personal Tools menu
|
||||
|
|
|
@ -25,26 +25,9 @@ declare( strict_types=1 );
|
|||
|
||||
namespace Citizen\Partials;
|
||||
|
||||
use Citizen\GetConfigTrait;
|
||||
use Exception;
|
||||
use OutputPage;
|
||||
|
||||
class Metadata {
|
||||
|
||||
use GetConfigTrait;
|
||||
|
||||
/**
|
||||
* @var OutputPage
|
||||
*/
|
||||
private $out;
|
||||
|
||||
/**
|
||||
* Metadata constructor.
|
||||
* @param OutputPage $out
|
||||
*/
|
||||
public function __construct( OutputPage $out ) {
|
||||
$this->out = $out;
|
||||
}
|
||||
final class Metadata extends Partial {
|
||||
|
||||
/**
|
||||
* Adds metadata to the output page
|
||||
|
|
59
includes/Partials/Partial.php
Normal file
59
includes/Partials/Partial.php
Normal file
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
/**
|
||||
* Citizen - A responsive skin developed for the Star Citizen Wiki
|
||||
*
|
||||
* This file is part of Citizen.
|
||||
*
|
||||
* Citizen is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Citizen is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Citizen. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @file
|
||||
* @ingroup Skins
|
||||
*/
|
||||
|
||||
declare( strict_types=1 );
|
||||
|
||||
namespace Citizen\Partials;
|
||||
|
||||
use Citizen\GetConfigTrait;
|
||||
use OutputPage;
|
||||
use SkinCitizen;
|
||||
|
||||
/**
|
||||
* The base class for all skin partials
|
||||
*/
|
||||
abstract class Partial {
|
||||
|
||||
use GetConfigTrait;
|
||||
|
||||
/**
|
||||
* @var SkinCitizen
|
||||
*/
|
||||
protected $skin;
|
||||
|
||||
/**
|
||||
* Needed for trait
|
||||
*
|
||||
* @var OutputPage
|
||||
*/
|
||||
protected $out;
|
||||
|
||||
/**
|
||||
* Drawer constructor.
|
||||
* @param SkinCitizen $skin
|
||||
*/
|
||||
public function __construct( SkinCitizen $skin ) {
|
||||
$this->skin = $skin;
|
||||
$this->out = $skin->getOutput();
|
||||
}
|
||||
}
|
|
@ -25,29 +25,12 @@ declare( strict_types=1 );
|
|||
|
||||
namespace Citizen\Partials;
|
||||
|
||||
use Citizen\GetConfigTrait;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use OutputPage;
|
||||
|
||||
/**
|
||||
* Theme switcher partial of Skin Citizen
|
||||
*/
|
||||
class Theme {
|
||||
|
||||
use GetConfigTrait;
|
||||
|
||||
/**
|
||||
* @var OutputPage
|
||||
*/
|
||||
private $out;
|
||||
|
||||
/**
|
||||
* Theme constructor.
|
||||
* @param OutputPage $out
|
||||
*/
|
||||
public function __construct( OutputPage $out ) {
|
||||
$this->out = $out;
|
||||
}
|
||||
final class Theme extends Partial {
|
||||
|
||||
/**
|
||||
* Sets the corresponding theme class on the <html> element
|
||||
|
|
Loading…
Reference in a new issue