mirror of
https://github.com/StarCitizenTools/mediawiki-skins-Citizen.git
synced 2024-11-24 22:35:45 +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 Exception;
|
||||||
use ResourceLoaderSkinModule;
|
use ResourceLoaderSkinModule;
|
||||||
use Skin;
|
use Skin;
|
||||||
use SkinCitizen;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Drawer partial of Skin Citizen
|
* Drawer partial of Skin Citizen
|
||||||
|
@ -38,21 +37,7 @@ use SkinCitizen;
|
||||||
* + Special Pages Link
|
* + Special Pages Link
|
||||||
* + Upload Link
|
* + Upload Link
|
||||||
*/
|
*/
|
||||||
class Drawer {
|
final class Drawer extends Partial {
|
||||||
|
|
||||||
/**
|
|
||||||
* @var Skin
|
|
||||||
*/
|
|
||||||
private $skin;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Drawer constructor.
|
|
||||||
* @param SkinCitizen $skin
|
|
||||||
*/
|
|
||||||
public function __construct( SkinCitizen $skin ) {
|
|
||||||
$this->skin = $skin;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get and pick the correct logo based on types and variants
|
* Get and pick the correct logo based on types and variants
|
||||||
* Based on getLogoData() in MW 1.36
|
* Based on getLogoData() in MW 1.36
|
||||||
|
@ -61,8 +46,10 @@ class Drawer {
|
||||||
*/
|
*/
|
||||||
public function getLogoData() : array {
|
public function getLogoData() : array {
|
||||||
$logoData = ResourceLoaderSkinModule::getAvailableLogos( $this->skin->getConfig() );
|
$logoData = ResourceLoaderSkinModule::getAvailableLogos( $this->skin->getConfig() );
|
||||||
|
|
||||||
// check if the logo supports variants
|
// check if the logo supports variants
|
||||||
$variantsLogos = $logoData['variants'] ?? null;
|
$variantsLogos = $logoData['variants'] ?? null;
|
||||||
|
|
||||||
if ( $variantsLogos ) {
|
if ( $variantsLogos ) {
|
||||||
$preferred = $this->skin->getOutput()->getTitle()
|
$preferred = $this->skin->getOutput()->getTitle()
|
||||||
->getPageViewLanguage()->getCode();
|
->getPageViewLanguage()->getCode();
|
||||||
|
@ -74,6 +61,7 @@ class Drawer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $logoData;
|
return $logoData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,13 +25,10 @@ declare( strict_types=1 );
|
||||||
|
|
||||||
namespace Citizen\Partials;
|
namespace Citizen\Partials;
|
||||||
|
|
||||||
use Citizen\GetConfigTrait;
|
|
||||||
use Linker;
|
use Linker;
|
||||||
use MediaWiki\MediaWikiServices;
|
use MediaWiki\MediaWikiServices;
|
||||||
use MWException;
|
use MWException;
|
||||||
use OutputPage;
|
|
||||||
use Skin;
|
use Skin;
|
||||||
use SkinCitizen;
|
|
||||||
use SpecialPage;
|
use SpecialPage;
|
||||||
use Title;
|
use Title;
|
||||||
|
|
||||||
|
@ -43,30 +40,7 @@ use Title;
|
||||||
* - Search
|
* - Search
|
||||||
* - Theme Toggle
|
* - Theme Toggle
|
||||||
*/
|
*/
|
||||||
class Header {
|
final class Header extends Partial {
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build Personal Tools menu
|
* Build Personal Tools menu
|
||||||
|
|
|
@ -25,26 +25,9 @@ declare( strict_types=1 );
|
||||||
|
|
||||||
namespace Citizen\Partials;
|
namespace Citizen\Partials;
|
||||||
|
|
||||||
use Citizen\GetConfigTrait;
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use OutputPage;
|
|
||||||
|
|
||||||
class Metadata {
|
final class Metadata extends Partial {
|
||||||
|
|
||||||
use GetConfigTrait;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var OutputPage
|
|
||||||
*/
|
|
||||||
private $out;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Metadata constructor.
|
|
||||||
* @param OutputPage $out
|
|
||||||
*/
|
|
||||||
public function __construct( OutputPage $out ) {
|
|
||||||
$this->out = $out;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds metadata to the output page
|
* 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;
|
namespace Citizen\Partials;
|
||||||
|
|
||||||
use Citizen\GetConfigTrait;
|
|
||||||
use MediaWiki\MediaWikiServices;
|
use MediaWiki\MediaWikiServices;
|
||||||
use OutputPage;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Theme switcher partial of Skin Citizen
|
* Theme switcher partial of Skin Citizen
|
||||||
*/
|
*/
|
||||||
class Theme {
|
final class Theme extends Partial {
|
||||||
|
|
||||||
use GetConfigTrait;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var OutputPage
|
|
||||||
*/
|
|
||||||
private $out;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Theme constructor.
|
|
||||||
* @param OutputPage $out
|
|
||||||
*/
|
|
||||||
public function __construct( OutputPage $out ) {
|
|
||||||
$this->out = $out;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the corresponding theme class on the <html> element
|
* Sets the corresponding theme class on the <html> element
|
||||||
|
|
Loading…
Reference in a new issue