2020-06-17 02:56:40 +00:00
|
|
|
<?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
|
|
|
|
*/
|
|
|
|
|
2022-05-26 20:54:52 +00:00
|
|
|
namespace MediaWiki\Skins\Citizen;
|
|
|
|
|
|
|
|
use MediaWiki\Skins\Citizen\Partials\BodyContent;
|
|
|
|
use MediaWiki\Skins\Citizen\Partials\Drawer;
|
|
|
|
use MediaWiki\Skins\Citizen\Partials\Footer;
|
|
|
|
use MediaWiki\Skins\Citizen\Partials\Header;
|
|
|
|
use MediaWiki\Skins\Citizen\Partials\Metadata;
|
|
|
|
use MediaWiki\Skins\Citizen\Partials\PageTools;
|
|
|
|
use MediaWiki\Skins\Citizen\Partials\Tagline;
|
|
|
|
use MediaWiki\Skins\Citizen\Partials\Theme;
|
|
|
|
use MediaWiki\Skins\Citizen\Partials\Title;
|
|
|
|
use SkinMustache;
|
2020-08-09 18:26:31 +00:00
|
|
|
|
2020-06-17 02:56:40 +00:00
|
|
|
/**
|
2020-08-10 03:06:38 +00:00
|
|
|
* Skin subclass for Citizen
|
2020-06-17 02:56:40 +00:00
|
|
|
* @ingroup Skins
|
|
|
|
*/
|
2020-08-10 03:06:38 +00:00
|
|
|
class SkinCitizen extends SkinMustache {
|
2021-01-28 11:21:58 +00:00
|
|
|
use GetConfigTrait;
|
2021-01-28 11:19:50 +00:00
|
|
|
|
2020-06-17 02:56:40 +00:00
|
|
|
/**
|
2020-08-10 03:06:38 +00:00
|
|
|
* Overrides template, styles and scripts module
|
|
|
|
*
|
2020-08-09 18:26:31 +00:00
|
|
|
* @inheritDoc
|
2020-06-17 02:56:40 +00:00
|
|
|
*/
|
2020-08-10 03:06:38 +00:00
|
|
|
public function __construct( $options = [] ) {
|
2021-04-09 17:08:01 +00:00
|
|
|
// Add skin-specific features
|
|
|
|
$this->buildSkinFeatures( $options );
|
2020-08-10 03:06:38 +00:00
|
|
|
parent::__construct( $options );
|
2020-08-09 18:26:31 +00:00
|
|
|
}
|
|
|
|
|
2021-01-28 11:21:58 +00:00
|
|
|
/**
|
2022-10-12 16:44:05 +00:00
|
|
|
* @inheritDoc
|
2021-01-28 11:21:58 +00:00
|
|
|
*/
|
2021-07-30 02:49:01 +00:00
|
|
|
public function getTemplateData(): array {
|
2022-05-26 21:57:57 +00:00
|
|
|
$data = [];
|
2022-10-06 00:59:47 +00:00
|
|
|
$title = $this->getOutput()->getTitle();
|
2022-04-14 04:30:33 +00:00
|
|
|
$parentData = parent::getTemplateData();
|
2020-08-09 18:26:31 +00:00
|
|
|
|
2021-01-28 11:27:55 +00:00
|
|
|
$header = new Header( $this );
|
2021-01-28 19:35:31 +00:00
|
|
|
$drawer = new Drawer( $this );
|
2022-05-21 20:24:35 +00:00
|
|
|
$pageTitle = new Title( $this );
|
2021-03-16 17:10:54 +00:00
|
|
|
$tagline = new Tagline( $this );
|
2021-03-02 22:16:24 +00:00
|
|
|
$bodycontent = new BodyContent( $this );
|
2021-01-28 19:35:31 +00:00
|
|
|
$footer = new Footer( $this );
|
|
|
|
$tools = new PageTools( $this );
|
2021-01-28 11:19:50 +00:00
|
|
|
|
2020-08-10 03:31:33 +00:00
|
|
|
// Naming conventions for Mustache parameters.
|
|
|
|
//
|
|
|
|
// Value type (first segment):
|
|
|
|
// - Prefix "is" or "has" for boolean values.
|
|
|
|
// - Prefix "msg-" for interface message text.
|
|
|
|
// - Prefix "html-" for raw HTML.
|
2020-08-10 03:06:38 +00:00
|
|
|
// - Prefix "data-" for an array of template parameters that should be passed directly
|
|
|
|
// to a template partial.
|
|
|
|
// - Prefix "array-" for lists of any values.
|
|
|
|
//
|
|
|
|
// Source of value (first or second segment)
|
|
|
|
// - Segment "page-" for data relating to the current page (e.g. Title, WikiPage, or OutputPage).
|
|
|
|
// - Segment "hook-" for any thing generated from a hook.
|
|
|
|
// It should be followed by the name of the hook in hyphenated lowercase.
|
|
|
|
//
|
|
|
|
// Conditionally used values must use null to indicate absence (not false or '').
|
2022-05-26 21:33:59 +00:00
|
|
|
|
2022-05-26 21:57:57 +00:00
|
|
|
$data += [
|
2022-05-26 21:33:59 +00:00
|
|
|
// Booleans
|
2022-10-06 00:59:47 +00:00
|
|
|
'toc-enabled' => !empty( $parentData['data-toc'] ),
|
2022-05-26 21:33:59 +00:00
|
|
|
// Data objects
|
2022-10-05 02:20:29 +00:00
|
|
|
'data-sitestats' => $drawer->getSiteStatsData(),
|
2022-10-05 21:23:51 +00:00
|
|
|
'data-user-info' => $header->getUserInfoData( $parentData['data-portlets']['data-user-page'] ),
|
2022-05-26 21:33:59 +00:00
|
|
|
// HTML strings
|
|
|
|
'html-title-heading--formatted' => $pageTitle->buildTitle( $parentData, $title ),
|
2022-10-19 19:24:02 +00:00
|
|
|
'html-citizen-jumptotop' => $parentData['msg-citizen-jumptotop'] . ' [home]',
|
2022-05-26 21:33:59 +00:00
|
|
|
'html-body-content--formatted' => $bodycontent->buildBodyContent(),
|
|
|
|
'html-tagline' => $tagline->getTagline(),
|
2022-10-05 00:08:06 +00:00
|
|
|
// Messages
|
|
|
|
// Needed to be parsed here as it should be wikitext
|
|
|
|
'msg-citizen-footer-desc' => $this->msg( "citizen-footer-desc" )->inContentLanguage()->parse(),
|
|
|
|
'msg-citizen-footer-tagline' => $this->msg( "citizen-footer-tagline" )->inContentLanguage()->parse(),
|
2022-10-05 02:20:29 +00:00
|
|
|
// Decorate data provided by core
|
2022-10-05 02:40:23 +00:00
|
|
|
'data-search-box' => $header->decorateSearchBoxData( $parentData['data-search-box'] ),
|
2022-10-05 02:20:29 +00:00
|
|
|
'data-portlets-sidebar' => $drawer->decorateSidebarData( $parentData['data-portlets-sidebar'] ),
|
|
|
|
'data-footer' => $footer->decorateFooterData( $parentData['data-footer'] ),
|
2020-08-10 03:06:38 +00:00
|
|
|
];
|
2022-05-26 21:57:57 +00:00
|
|
|
|
2022-10-03 19:48:56 +00:00
|
|
|
$data += $tools->getPageToolsData( $parentData );
|
|
|
|
|
|
|
|
// Show some portlet labels
|
|
|
|
// NOTE: This is only placed here temporarily
|
|
|
|
if ( $parentData['data-portlets']['data-variants']['is-empty'] === false ) {
|
|
|
|
$parentData['data-portlets']['data-variants']['has-label'] = true;
|
|
|
|
}
|
|
|
|
|
2022-05-26 21:57:57 +00:00
|
|
|
return array_merge( $parentData, $data );
|
2021-01-19 20:56:42 +00:00
|
|
|
}
|
|
|
|
|
2021-03-02 22:16:24 +00:00
|
|
|
/**
|
|
|
|
* Change access to public, as it is used in partials
|
|
|
|
*
|
2021-03-03 00:09:39 +00:00
|
|
|
* @param Title $title
|
|
|
|
* @param string $html body text
|
2021-03-03 08:05:13 +00:00
|
|
|
* @return string
|
2021-03-02 22:16:24 +00:00
|
|
|
*/
|
|
|
|
final public function wrapHTMLPublic( $title, $html ) {
|
|
|
|
return parent::wrapHTML( $title, $html );
|
|
|
|
}
|
|
|
|
|
2021-01-28 11:21:58 +00:00
|
|
|
/**
|
2021-01-27 21:53:01 +00:00
|
|
|
* @inheritDoc
|
|
|
|
*
|
2022-05-18 23:33:39 +00:00
|
|
|
* Manually disable some site-wide tools in TOOLBOX
|
|
|
|
* They are re-added in the drawer
|
2021-01-27 21:53:01 +00:00
|
|
|
*
|
2022-05-18 23:33:39 +00:00
|
|
|
* TODO: Remove this hack when Desktop Improvements separate page and site tools
|
2022-05-18 23:45:19 +00:00
|
|
|
*
|
2021-01-27 21:53:01 +00:00
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
protected function buildNavUrls() {
|
|
|
|
$urls = parent::buildNavUrls();
|
|
|
|
|
|
|
|
$urls['upload'] = false;
|
|
|
|
$urls['specialpages'] = false;
|
|
|
|
|
|
|
|
return $urls;
|
|
|
|
}
|
2021-04-09 17:08:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set up optional skin features
|
|
|
|
*
|
|
|
|
* @param array &$options
|
|
|
|
*/
|
|
|
|
private function buildSkinFeatures( array &$options ) {
|
2022-10-06 00:59:47 +00:00
|
|
|
$title = $this->getOutput()->getTitle();
|
2021-04-09 17:08:01 +00:00
|
|
|
|
|
|
|
$metadata = new Metadata( $this );
|
|
|
|
$skinTheme = new Theme( $this );
|
|
|
|
|
|
|
|
// Add metadata
|
|
|
|
$metadata->addMetadata();
|
|
|
|
|
|
|
|
// Add theme handler
|
|
|
|
$skinTheme->setSkinTheme( $options );
|
|
|
|
|
2022-10-06 17:45:23 +00:00
|
|
|
// Disable default ToC since it is handled by Citizen
|
|
|
|
$options['toc'] = false;
|
|
|
|
|
2021-04-09 17:08:01 +00:00
|
|
|
// Collapsible sections
|
|
|
|
// Load in content pages
|
|
|
|
if ( $title !== null && $title->isContentPage() ) {
|
|
|
|
// Load Citizen collapsible sections modules if enabled
|
|
|
|
if ( $this->getConfigValue( 'CitizenEnableCollapsibleSections' ) === true ) {
|
|
|
|
$options['scripts'][] = 'skins.citizen.scripts.sections';
|
|
|
|
$options['styles'][] = 'skins.citizen.styles.sections';
|
|
|
|
}
|
2021-04-18 01:24:08 +00:00
|
|
|
}
|
2021-04-09 17:08:01 +00:00
|
|
|
|
2022-10-27 20:53:12 +00:00
|
|
|
// CJK fonts
|
|
|
|
if ( $this->getConfigValue( 'CitizenEnableCJKFonts' ) === true ) {
|
|
|
|
$options['styles'][] = 'skins.citizen.styles.fonts.cjk';
|
|
|
|
}
|
|
|
|
|
2021-04-09 17:08:01 +00:00
|
|
|
// Drawer sitestats
|
|
|
|
if ( $this->getConfigValue( 'CitizenEnableDrawerSiteStats' ) === true ) {
|
|
|
|
$options['styles'][] = 'skins.citizen.styles.sitestats';
|
|
|
|
}
|
|
|
|
|
|
|
|
// Drawer subsearch
|
|
|
|
if ( $this->getConfigValue( 'CitizenEnableDrawerSubSearch' ) === true ) {
|
|
|
|
$options['scripts'][] = 'skins.citizen.scripts.drawer';
|
|
|
|
}
|
|
|
|
|
|
|
|
// Debug styles
|
|
|
|
if (
|
|
|
|
$this->getConfigValue( 'ShowDebug' ) === true
|
|
|
|
|| $this->getConfigValue( 'ShowExceptionDetails' ) === true
|
2021-04-09 17:08:41 +00:00
|
|
|
) {
|
2021-04-09 17:08:01 +00:00
|
|
|
$options['styles'][] = 'skins.citizen.styles.debug';
|
|
|
|
}
|
|
|
|
}
|
2020-06-17 02:56:40 +00:00
|
|
|
}
|