2017-07-12 15:12:40 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2018-04-15 23:21:12 +00:00
|
|
|
* This program 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 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
*
|
|
|
|
* @file
|
2017-07-12 15:12:40 +00:00
|
|
|
*/
|
2018-04-15 23:21:12 +00:00
|
|
|
|
2022-03-04 16:40:54 +00:00
|
|
|
namespace MediaWiki\Minerva\Skins;
|
|
|
|
|
|
|
|
use ExtensionRegistry;
|
|
|
|
use Language;
|
2024-02-29 20:35:21 +00:00
|
|
|
use MediaWiki\Cache\GenderCache;
|
2022-12-12 22:13:05 +00:00
|
|
|
use MediaWiki\Extension\Notifications\Controller\NotificationController;
|
2024-01-06 15:31:38 +00:00
|
|
|
use MediaWiki\Html\Html;
|
2024-02-29 20:35:21 +00:00
|
|
|
use MediaWiki\Linker\LinkRenderer;
|
2020-03-04 02:53:53 +00:00
|
|
|
use MediaWiki\Linker\LinkTarget;
|
2017-07-12 15:12:40 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
2024-03-24 09:01:40 +00:00
|
|
|
use MediaWiki\Minerva\LanguagesHelper;
|
2024-03-24 15:08:11 +00:00
|
|
|
use MediaWiki\Minerva\Menu\Definitions;
|
2024-03-25 09:54:20 +00:00
|
|
|
use MediaWiki\Minerva\Menu\Main\AdvancedMainMenuBuilder;
|
|
|
|
use MediaWiki\Minerva\Menu\Main\DefaultMainMenuBuilder;
|
2019-08-02 09:00:18 +00:00
|
|
|
use MediaWiki\Minerva\Menu\Main\MainMenuDirector;
|
2022-03-04 16:40:54 +00:00
|
|
|
use MediaWiki\Minerva\Menu\PageActions\PageActionsDirector;
|
2024-03-24 15:08:11 +00:00
|
|
|
use MediaWiki\Minerva\Menu\User\AdvancedUserMenuBuilder;
|
|
|
|
use MediaWiki\Minerva\Menu\User\DefaultUserMenuBuilder;
|
2022-03-04 16:40:54 +00:00
|
|
|
use MediaWiki\Minerva\Menu\User\UserMenuDirector;
|
2019-05-24 00:07:27 +00:00
|
|
|
use MediaWiki\Minerva\Permissions\IMinervaPagePermissions;
|
2024-03-23 19:16:47 +00:00
|
|
|
use MediaWiki\Minerva\Permissions\MinervaPagePermissions;
|
2019-04-08 17:08:57 +00:00
|
|
|
use MediaWiki\Minerva\SkinOptions;
|
2024-02-29 20:35:21 +00:00
|
|
|
use MediaWiki\Revision\RevisionLookup;
|
2024-01-06 15:31:38 +00:00
|
|
|
use MediaWiki\SpecialPage\SpecialPage;
|
2024-02-29 20:35:21 +00:00
|
|
|
use MediaWiki\Title\NamespaceInfo;
|
2023-08-19 04:23:00 +00:00
|
|
|
use MediaWiki\Title\Title;
|
2024-02-29 20:35:21 +00:00
|
|
|
use MediaWiki\User\Options\UserOptionsManager;
|
2024-03-25 09:54:20 +00:00
|
|
|
use MediaWiki\User\UserIdentityUtils;
|
2024-01-06 15:31:38 +00:00
|
|
|
use MediaWiki\Utils\MWTimestamp;
|
2022-03-04 16:40:54 +00:00
|
|
|
use RuntimeException;
|
|
|
|
use SkinMustache;
|
|
|
|
use SkinTemplate;
|
|
|
|
use SpecialMobileHistory;
|
2017-07-12 15:12:40 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Minerva: Born from the godhead of Jupiter with weapons!
|
|
|
|
* A skin that works on both desktop and mobile
|
|
|
|
* @ingroup Skins
|
|
|
|
*/
|
2020-10-02 20:03:14 +00:00
|
|
|
class SkinMinerva extends SkinMustache {
|
2017-08-22 14:12:32 +00:00
|
|
|
/** @const LEAD_SECTION_NUMBER integer which corresponds to the lead section
|
2020-01-26 19:26:31 +00:00
|
|
|
* in editing mode
|
|
|
|
*/
|
2020-05-19 22:43:34 +00:00
|
|
|
public const LEAD_SECTION_NUMBER = 0;
|
2017-07-12 15:12:40 +00:00
|
|
|
|
2020-11-05 02:02:15 +00:00
|
|
|
/** @var string Name of this skin */
|
2017-07-12 15:12:40 +00:00
|
|
|
public $skinname = 'minerva';
|
2020-11-05 02:02:15 +00:00
|
|
|
/** @var string Name of this used template */
|
2017-07-12 15:12:40 +00:00
|
|
|
public $template = 'MinervaTemplate';
|
2019-04-10 12:52:34 +00:00
|
|
|
|
2022-02-04 17:17:01 +00:00
|
|
|
/** @var array|null */
|
|
|
|
private $contentNavigationUrls;
|
|
|
|
|
2024-02-29 20:35:21 +00:00
|
|
|
private GenderCache $genderCache;
|
|
|
|
|
|
|
|
private LinkRenderer $linkRenderer;
|
|
|
|
|
2024-03-24 09:01:40 +00:00
|
|
|
private LanguagesHelper $languagesHelper;
|
|
|
|
|
2024-03-24 15:08:11 +00:00
|
|
|
private Definitions $definitions;
|
|
|
|
|
2024-03-23 19:16:47 +00:00
|
|
|
private IMinervaPagePermissions $permissions;
|
|
|
|
|
2024-03-23 17:20:57 +00:00
|
|
|
private SkinOptions $skinOptions;
|
|
|
|
|
2024-03-24 10:49:33 +00:00
|
|
|
private SkinUserPageHelper $skinUserPageHelper;
|
|
|
|
|
2024-02-29 20:35:21 +00:00
|
|
|
private NamespaceInfo $namespaceInfo;
|
|
|
|
|
|
|
|
private RevisionLookup $revisionLookup;
|
|
|
|
|
2024-03-25 09:54:20 +00:00
|
|
|
private UserIdentityUtils $userIdentityUtils;
|
|
|
|
|
2024-02-29 20:35:21 +00:00
|
|
|
private UserOptionsManager $userOptionsManager;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param GenderCache $genderCache
|
|
|
|
* @param LinkRenderer $linkRenderer
|
2024-03-24 09:01:40 +00:00
|
|
|
* @param LanguagesHelper $languagesHelper
|
2024-03-24 15:08:11 +00:00
|
|
|
* @param Definitions $definitions
|
2024-03-23 19:16:47 +00:00
|
|
|
* @param MinervaPagePermissions $permissions
|
2024-03-23 17:20:57 +00:00
|
|
|
* @param SkinOptions $skinOptions
|
2024-03-24 10:49:33 +00:00
|
|
|
* @param SkinUserPageHelper $skinUserPageHelper
|
2024-02-29 20:35:21 +00:00
|
|
|
* @param NamespaceInfo $namespaceInfo
|
|
|
|
* @param RevisionLookup $revisionLookup
|
2024-03-25 09:54:20 +00:00
|
|
|
* @param UserIdentityUtils $userIdentityUtils
|
2024-02-29 20:35:21 +00:00
|
|
|
* @param UserOptionsManager $userOptionsManager
|
|
|
|
* @param array $options
|
|
|
|
*/
|
|
|
|
public function __construct(
|
|
|
|
GenderCache $genderCache,
|
|
|
|
LinkRenderer $linkRenderer,
|
2024-03-24 09:01:40 +00:00
|
|
|
LanguagesHelper $languagesHelper,
|
2024-03-24 15:08:11 +00:00
|
|
|
Definitions $definitions,
|
2024-03-23 19:16:47 +00:00
|
|
|
MinervaPagePermissions $permissions,
|
2024-03-23 17:20:57 +00:00
|
|
|
SkinOptions $skinOptions,
|
2024-03-24 10:49:33 +00:00
|
|
|
SkinUserPageHelper $skinUserPageHelper,
|
2024-02-29 20:35:21 +00:00
|
|
|
NamespaceInfo $namespaceInfo,
|
|
|
|
RevisionLookup $revisionLookup,
|
2024-03-25 09:54:20 +00:00
|
|
|
UserIdentityUtils $userIdentityUtils,
|
2024-02-29 20:35:21 +00:00
|
|
|
UserOptionsManager $userOptionsManager,
|
|
|
|
$options = []
|
|
|
|
) {
|
|
|
|
parent::__construct( $options );
|
|
|
|
$this->genderCache = $genderCache;
|
|
|
|
$this->linkRenderer = $linkRenderer;
|
2024-03-24 09:01:40 +00:00
|
|
|
$this->languagesHelper = $languagesHelper;
|
2024-03-24 15:08:11 +00:00
|
|
|
$this->definitions = $definitions
|
|
|
|
->setContext( $this->getContext() );
|
2024-03-23 19:16:47 +00:00
|
|
|
$this->permissions = $permissions
|
|
|
|
->setContext( $this->getContext() );
|
2024-03-23 17:20:57 +00:00
|
|
|
$this->skinOptions = $skinOptions;
|
2024-03-24 10:49:33 +00:00
|
|
|
$this->skinUserPageHelper = $skinUserPageHelper
|
|
|
|
->setContext( $this->getContext() )
|
|
|
|
->setTitle( $this->getTitle() );
|
2024-02-29 20:35:21 +00:00
|
|
|
$this->namespaceInfo = $namespaceInfo;
|
|
|
|
$this->revisionLookup = $revisionLookup;
|
2024-03-25 09:54:20 +00:00
|
|
|
$this->userIdentityUtils = $userIdentityUtils;
|
2024-02-29 20:35:21 +00:00
|
|
|
$this->userOptionsManager = $userOptionsManager;
|
|
|
|
}
|
|
|
|
|
2021-10-19 18:16:43 +00:00
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
private function hasPageActions() {
|
|
|
|
$title = $this->getTitle();
|
|
|
|
return !$title->isSpecialPage() && !$title->isMainPage() &&
|
2022-04-15 21:05:22 +00:00
|
|
|
$this->getContext()->getActionName() === 'view';
|
2021-10-19 18:16:43 +00:00
|
|
|
}
|
|
|
|
|
2021-10-20 16:40:25 +00:00
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
private function hasSecondaryActions() {
|
2024-03-24 10:49:33 +00:00
|
|
|
return !$this->skinUserPageHelper->isUserPage();
|
2021-10-20 16:40:25 +00:00
|
|
|
}
|
|
|
|
|
2021-10-19 18:16:43 +00:00
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
private function isFallbackEditor() {
|
2023-04-17 16:54:48 +00:00
|
|
|
$action = $this->getContext()->getActionName();
|
2021-10-19 18:16:43 +00:00
|
|
|
return $action === 'edit';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-10-19 18:49:54 +00:00
|
|
|
* Returns available page actions if the page has any.
|
|
|
|
*
|
2021-11-12 19:51:08 +00:00
|
|
|
* @param array $nav result of SkinTemplate::buildContentNavigationUrls
|
2021-10-19 18:49:54 +00:00
|
|
|
* @return array|null
|
2021-10-19 18:16:43 +00:00
|
|
|
*/
|
2021-11-12 19:51:08 +00:00
|
|
|
private function getPageActions( array $nav ) {
|
|
|
|
if ( $this->isFallbackEditor() || !$this->hasPageActions() ) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
$services = MediaWikiServices::getInstance();
|
2022-03-04 16:40:54 +00:00
|
|
|
/** @var PageActionsDirector $pageActionsDirector */
|
2021-11-12 19:51:08 +00:00
|
|
|
$pageActionsDirector = $services->getService( 'Minerva.Menu.PageActionsDirector' );
|
2022-02-08 03:34:37 +00:00
|
|
|
$sidebar = $this->buildSidebar();
|
2021-11-12 19:51:08 +00:00
|
|
|
$actions = $nav['actions'] ?? [];
|
2023-09-27 00:17:21 +00:00
|
|
|
$views = $nav['views'] ?? [];
|
|
|
|
return $pageActionsDirector->buildMenu( $sidebar['TOOLBOX'], $actions, $views );
|
2021-10-19 18:16:43 +00:00
|
|
|
}
|
|
|
|
|
2022-02-08 16:41:14 +00:00
|
|
|
/**
|
|
|
|
* A notification icon that links to Special:Mytalk when Echo is not installed.
|
|
|
|
* Consider upstreaming this to core or removing at a future date.
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
private function getNotificationFallbackButton() {
|
|
|
|
return [
|
2024-02-28 07:02:37 +00:00
|
|
|
'icon' => 'bellOutline-base20',
|
|
|
|
'href' => SpecialPage::getTitleFor( 'Mytalk' )->getLocalURL(
|
|
|
|
[ 'returnto' => $this->getTitle()->getPrefixedText() ]
|
|
|
|
),
|
2022-02-08 16:41:14 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2022-12-12 22:13:05 +00:00
|
|
|
/**
|
|
|
|
* @param array $alert
|
|
|
|
* @param array $notice
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
private function getCombinedNotificationButton( array $alert, array $notice ) {
|
|
|
|
// Sum the notifications from the two original buttons
|
|
|
|
$notifCount = ( $alert['data']['counter-num'] ?? 0 ) + ( $notice['data']['counter-num'] ?? 0 );
|
|
|
|
$alert['data']['counter-num'] = $notifCount;
|
|
|
|
// @phan-suppress-next-line PhanUndeclaredClassReference
|
|
|
|
if ( class_exists( NotificationController::class ) ) {
|
|
|
|
// @phan-suppress-next-line PhanUndeclaredClassMethod
|
|
|
|
$alert['data']['counter-text'] = NotificationController::formatNotificationCount( $notifCount );
|
|
|
|
} else {
|
|
|
|
$alert['data']['counter-text'] = $notifCount;
|
|
|
|
}
|
|
|
|
|
2022-12-13 01:58:09 +00:00
|
|
|
$linkClassAlert = $alert['link-class'] ?? [];
|
|
|
|
$hasUnseenAlerts = is_array( $linkClassAlert ) && in_array( 'mw-echo-unseen-notifications', $linkClassAlert );
|
|
|
|
// The circle should only appear if there are unseen notifications.
|
|
|
|
// Once the notifications are seen (by opening the notification drawer)
|
|
|
|
// then the icon reverts to a gray circle, but on page refresh
|
|
|
|
// it should revert back to a bell icon.
|
|
|
|
// If you try and change this behaviour, at time of writing
|
|
|
|
// (December 2022) JavaScript will correct it.
|
|
|
|
if ( $notifCount > 0 && $hasUnseenAlerts ) {
|
|
|
|
$linkClass = $notice['link-class'] ?? [];
|
|
|
|
$hasUnseenNotices = is_array( $linkClass ) && in_array( 'mw-echo-unseen-notifications', $linkClass );
|
|
|
|
return $this->getNotificationCircleButton( $alert, $hasUnseenNotices );
|
2022-12-12 22:13:05 +00:00
|
|
|
} else {
|
|
|
|
return $this->getNotificationButton( $alert );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-08 16:41:14 +00:00
|
|
|
/**
|
|
|
|
* Minerva differs from other skins in that for users with unread notifications
|
|
|
|
* instead of a bell with a small square indicating the number of notifications
|
|
|
|
* it shows a red circle with a number inside. Ideally Vector and Minerva would
|
|
|
|
* be treated the same but we'd need to talk to a designer about consolidating these
|
|
|
|
* before making such a decision.
|
|
|
|
*
|
|
|
|
* @param array $alert
|
2022-12-13 01:58:09 +00:00
|
|
|
* @param bool $hasUnseenNotices does the user have unseen notices?
|
2022-02-08 16:41:14 +00:00
|
|
|
* @return array
|
|
|
|
*/
|
2022-12-13 01:58:09 +00:00
|
|
|
private function getNotificationCircleButton( array $alert, bool $hasUnseenNotices ) {
|
2022-02-08 16:41:14 +00:00
|
|
|
$alertCount = $alert['data']['counter-num'] ?? 0;
|
2022-12-13 01:58:09 +00:00
|
|
|
$linkClass = $alert['link-class'] ?? [];
|
|
|
|
$hasSeenAlerts = is_array( $linkClass ) && in_array( 'mw-echo-unseen-notifications', $linkClass );
|
2022-06-13 18:42:27 +00:00
|
|
|
$alertText = $alert['data']['counter-text'] ?? $alertCount;
|
2023-08-01 00:12:59 +00:00
|
|
|
$alert['icon'] = 'circle';
|
2022-12-13 01:58:09 +00:00
|
|
|
$alert['class'] = 'notification-count';
|
|
|
|
if ( $hasSeenAlerts || $hasUnseenNotices ) {
|
|
|
|
$alert['class'] .= ' notification-unseen mw-echo-unseen-notifications';
|
|
|
|
}
|
2022-02-08 16:41:14 +00:00
|
|
|
return $alert;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes the OOUI icon class and adds Minerva notification classes.
|
|
|
|
*
|
|
|
|
* @param array $alert
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
private function getNotificationButton( array $alert ) {
|
|
|
|
$linkClass = $alert['link-class'];
|
|
|
|
$alert['link-class'] = array_filter(
|
|
|
|
$linkClass,
|
|
|
|
static function ( $class ) {
|
|
|
|
return $class !== 'oo-ui-icon-bellOutline';
|
|
|
|
}
|
|
|
|
);
|
2023-09-05 17:07:13 +00:00
|
|
|
$alert['icon'] = 'bellOutline-base20';
|
2022-02-08 16:41:14 +00:00
|
|
|
return $alert;
|
|
|
|
}
|
|
|
|
|
2022-02-04 17:17:01 +00:00
|
|
|
/**
|
|
|
|
* Caches content navigation urls locally for use inside getTemplateData
|
|
|
|
*
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
|
|
|
protected function runOnSkinTemplateNavigationHooks( SkinTemplate $skin, &$contentNavigationUrls ) {
|
|
|
|
parent::runOnSkinTemplateNavigationHooks( $skin, $contentNavigationUrls );
|
|
|
|
// There are some SkinTemplate modifications that occur after the execution of this hook
|
|
|
|
// to add rel attributes and ID attributes.
|
|
|
|
// The only one Minerva needs is this one so we manually add it.
|
2022-09-23 16:10:21 +00:00
|
|
|
foreach ( array_keys( $contentNavigationUrls['associated-pages'] ) as $id ) {
|
2022-02-04 17:17:01 +00:00
|
|
|
if ( in_array( $id, [ 'user_talk', 'talk' ] ) ) {
|
2022-09-23 16:10:21 +00:00
|
|
|
$contentNavigationUrls['associated-pages'][ $id ]['rel'] = 'discussion';
|
2022-02-04 17:17:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
$this->contentNavigationUrls = $contentNavigationUrls;
|
2023-08-01 00:12:59 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Echo Technical debt!!
|
|
|
|
// * Convert the Echo button into a single button
|
|
|
|
// * Switch out the icon.
|
|
|
|
//
|
2022-02-08 16:41:14 +00:00
|
|
|
if ( $this->getUser()->isRegistered() ) {
|
|
|
|
if ( count( $contentNavigationUrls['notifications'] ) === 0 ) {
|
2022-12-12 22:13:05 +00:00
|
|
|
// Shown to logged in users when Echo is not installed:
|
2022-02-08 16:41:14 +00:00
|
|
|
$contentNavigationUrls['notifications']['mytalks'] = $this->getNotificationFallbackButton();
|
2024-03-23 17:20:57 +00:00
|
|
|
} elseif ( $this->skinOptions->get( SkinOptions::SINGLE_ECHO_BUTTON ) ) {
|
2022-12-12 22:13:05 +00:00
|
|
|
// Combine notification icons. Minerva only shows one entry point to notifications.
|
|
|
|
// This can be reconsidered with a solution to https://phabricator.wikimedia.org/T142981
|
2022-02-08 16:41:14 +00:00
|
|
|
$alert = $contentNavigationUrls['notifications']['notifications-alert'] ?? null;
|
2022-12-12 22:13:05 +00:00
|
|
|
$notice = $contentNavigationUrls['notifications']['notifications-notice'] ?? null;
|
|
|
|
if ( $alert && $notice ) {
|
|
|
|
unset( $contentNavigationUrls['notifications']['notifications-notice'] );
|
|
|
|
$contentNavigationUrls['notifications']['notifications-alert'] =
|
|
|
|
$this->getCombinedNotificationButton( $alert, $notice );
|
2022-02-08 16:41:14 +00:00
|
|
|
}
|
2022-12-13 01:45:57 +00:00
|
|
|
} else {
|
|
|
|
// Show desktop alert icon.
|
|
|
|
$alert = $contentNavigationUrls['notifications']['notifications-alert'] ?? null;
|
|
|
|
if ( $alert ) {
|
|
|
|
// Correct the icon to be the bell filled rather than the outline to match
|
|
|
|
// Echo's badge.
|
|
|
|
$linkClass = $alert['link-class'] ?? [];
|
2023-08-01 00:12:59 +00:00
|
|
|
$alert['link-class'] = array_filter( $linkClass, static function ( $class ) {
|
|
|
|
return $class !== 'oo-ui-icon-bellOutline';
|
|
|
|
} );
|
2022-12-13 01:45:57 +00:00
|
|
|
$contentNavigationUrls['notifications']['notifications-alert'] = $alert;
|
|
|
|
}
|
2022-02-08 16:41:14 +00:00
|
|
|
}
|
|
|
|
}
|
2022-02-04 17:17:01 +00:00
|
|
|
}
|
|
|
|
|
2020-10-02 20:03:14 +00:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
2021-11-12 19:51:08 +00:00
|
|
|
public function getTemplateData(): array {
|
2024-03-10 23:28:35 +00:00
|
|
|
$data = parent::getTemplateData();
|
|
|
|
// FIXME: Can we use $data instead of calling buildContentNavigationUrls ?
|
|
|
|
$nav = $this->contentNavigationUrls;
|
|
|
|
if ( $nav === null ) {
|
|
|
|
throw new RuntimeException( 'contentNavigationUrls was not set as expected.' );
|
|
|
|
}
|
|
|
|
if ( !$this->hasCategoryLinks() ) {
|
|
|
|
unset( $data['html-categories'] );
|
|
|
|
}
|
2021-04-28 21:58:51 +00:00
|
|
|
|
2024-03-10 23:28:35 +00:00
|
|
|
// Special handling for certain pages.
|
|
|
|
// This is technical debt that should be upstreamed to core.
|
2024-03-24 10:49:33 +00:00
|
|
|
$isUserPage = $this->skinUserPageHelper->isUserPage();
|
|
|
|
$isUserPageAccessible = $this->skinUserPageHelper->isUserPageAccessibleToCurrentUser();
|
2024-03-10 23:28:35 +00:00
|
|
|
if ( $isUserPage && $isUserPageAccessible ) {
|
|
|
|
$data['html-title-heading'] = $this->getUserPageHeadingHtml( $data['html-title-heading' ] );
|
|
|
|
}
|
2021-11-05 18:21:09 +00:00
|
|
|
|
2024-03-10 23:28:35 +00:00
|
|
|
$usermessage = $data['html-user-message'] ?? '';
|
|
|
|
if ( $usermessage ) {
|
|
|
|
$data['html-user-message'] = Html::warningBox(
|
|
|
|
'<span class="minerva-icon minerva-icon--userTalk-warning"></span> '
|
|
|
|
. $usermessage,
|
|
|
|
'minerva-anon-talk-message'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
$allLanguages = $data['data-portlets']['data-languages']['array-items'] ?? [];
|
|
|
|
$allVariants = $data['data-portlets']['data-variants']['array-items'] ?? [];
|
|
|
|
$notifications = $data['data-portlets']['data-notifications']['array-items'] ?? [];
|
|
|
|
$associatedPages = $data['data-portlets']['data-associated-pages'] ?? [];
|
|
|
|
|
|
|
|
return $data + [
|
|
|
|
'has-minerva-languages' => $allLanguages || $allVariants,
|
|
|
|
'array-minerva-banners' => $this->prepareBanners( $data['html-site-notice'] ),
|
|
|
|
'data-minerva-search-box' => $data['data-search-box'] + [
|
|
|
|
'data-btn' => [
|
2023-07-24 22:12:24 +00:00
|
|
|
'data-icon' => [
|
2024-03-10 23:28:35 +00:00
|
|
|
'icon' => 'search-base20',
|
2023-07-24 22:12:24 +00:00
|
|
|
],
|
2024-03-10 23:28:35 +00:00
|
|
|
'label' => $this->msg( 'searchbutton' )->escaped(),
|
|
|
|
'classes' => 'skin-minerva-search-trigger',
|
2023-08-01 00:12:59 +00:00
|
|
|
'array-attributes' => [
|
2023-07-24 22:12:24 +00:00
|
|
|
[
|
|
|
|
'key' => 'id',
|
2024-03-10 23:28:35 +00:00
|
|
|
'value' => 'searchIcon',
|
|
|
|
]
|
|
|
|
]
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'data-minerva-main-menu-btn' => [
|
|
|
|
'data-icon' => [
|
|
|
|
'icon' => 'menu-base20',
|
|
|
|
],
|
|
|
|
'tag-name' => 'label',
|
|
|
|
'classes' => 'toggle-list__toggle',
|
|
|
|
'array-attributes' => [
|
|
|
|
[
|
|
|
|
'key' => 'for',
|
|
|
|
'value' => 'main-menu-input',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'key' => 'id',
|
|
|
|
'value' => 'mw-mf-main-menu-button',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'key' => 'aria-hidden',
|
|
|
|
'value' => 'true',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'key' => 'data-event-name',
|
|
|
|
'value' => 'ui.mainmenu',
|
2023-07-24 22:12:24 +00:00
|
|
|
],
|
|
|
|
],
|
2024-03-10 23:28:35 +00:00
|
|
|
'text' => $this->msg( 'mobile-frontend-main-menu-button-tooltip' )->escaped(),
|
|
|
|
],
|
|
|
|
'data-minerva-main-menu' => $this->getMainMenu()->getMenuData(
|
|
|
|
$nav,
|
|
|
|
$this->buildSidebar()
|
|
|
|
)['items'],
|
|
|
|
'html-minerva-tagline' => $this->getTaglineHtml(),
|
|
|
|
'html-minerva-user-menu' => $this->getPersonalToolsMenu( $nav['user-menu'] ),
|
2024-03-23 17:20:57 +00:00
|
|
|
'is-minerva-beta' => $this->skinOptions->get( SkinOptions::BETA_MODE ),
|
2024-03-10 23:28:35 +00:00
|
|
|
'data-minerva-notifications' => $notifications ? [
|
|
|
|
'array-buttons' => $this->getNotificationButtons( $notifications ),
|
|
|
|
] : null,
|
|
|
|
'data-minerva-tabs' => $this->getTabsData( $nav, $associatedPages ),
|
|
|
|
'data-minerva-page-actions' => $this->getPageActions( $nav ),
|
|
|
|
'data-minerva-secondary-actions' => $this->getSecondaryActions( $nav ),
|
|
|
|
'html-minerva-subject-link' => $this->getSubjectPage(),
|
|
|
|
'data-minerva-history-link' => $this->getHistoryLink( $this->getTitle() ),
|
|
|
|
];
|
2020-10-02 20:03:14 +00:00
|
|
|
}
|
|
|
|
|
2023-08-01 00:12:59 +00:00
|
|
|
/**
|
|
|
|
* Prepares the notification badges for the Button template.
|
|
|
|
*
|
|
|
|
* @internal
|
|
|
|
* @param array $notifications
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public static function getNotificationButtons( array $notifications ) {
|
|
|
|
$btns = [];
|
|
|
|
|
|
|
|
foreach ( $notifications as $notification ) {
|
|
|
|
$linkData = $notification['array-links'][ 0 ] ?? [];
|
|
|
|
$icon = $linkData['icon'] ?? null;
|
|
|
|
if ( !$icon ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$id = $notification['id'] ?? null;
|
|
|
|
$classes = '';
|
|
|
|
$attributes = [];
|
|
|
|
|
|
|
|
// We don't want to output multiple attributes.
|
|
|
|
// Iterate through the attributes and pull out ID and class which
|
|
|
|
// will be defined separately.
|
|
|
|
foreach ( $linkData[ 'array-attributes' ] as $keyValuePair ) {
|
|
|
|
if ( $keyValuePair['key'] === 'class' ) {
|
|
|
|
$classes = $keyValuePair['value'];
|
|
|
|
} elseif ( $keyValuePair['key'] === 'id' ) {
|
|
|
|
// ignore. We want to use the LI `id` instead.
|
|
|
|
} else {
|
|
|
|
$attributes[] = $keyValuePair;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// add LI ID to end for use on the button.
|
|
|
|
if ( $id ) {
|
|
|
|
$attributes[] = [
|
|
|
|
'key' => 'id',
|
|
|
|
'value' => $id,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
$btns[] = [
|
|
|
|
'tag-name' => 'a',
|
|
|
|
// FIXME: Move preg_replace when Echo no longer provides this class.
|
|
|
|
'classes' => preg_replace( '/oo-ui-icon-(bellOutline|tray)/', '', $classes ),
|
|
|
|
'array-attributes' => $attributes,
|
|
|
|
'data-icon' => [
|
|
|
|
'icon' => $icon,
|
|
|
|
],
|
|
|
|
'label' => $linkData['text'] ?? '',
|
|
|
|
];
|
|
|
|
}
|
|
|
|
return $btns;
|
|
|
|
}
|
|
|
|
|
2024-03-10 23:28:35 +00:00
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
2024-01-29 22:17:17 +00:00
|
|
|
private function isHistoryPage() {
|
2024-03-28 21:00:03 +00:00
|
|
|
return $this->getRequest()->getRawVal( 'action' ) === 'history';
|
2024-01-29 22:17:17 +00:00
|
|
|
}
|
|
|
|
|
2021-10-19 18:16:43 +00:00
|
|
|
/**
|
|
|
|
* Tabs are available if a page has page actions but is not the talk page of
|
|
|
|
* the main page.
|
|
|
|
*
|
|
|
|
* Special pages have tabs if SkinOptions::TABS_ON_SPECIALS is enabled.
|
|
|
|
* This is used by Extension:GrowthExperiments
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
private function hasPageTabs() {
|
|
|
|
$title = $this->getTitle();
|
2023-12-14 00:30:55 +00:00
|
|
|
$isSpecialPageOrHistory = $title->isSpecialPage() ||
|
2024-01-29 22:17:17 +00:00
|
|
|
$this->isHistoryPage();
|
2024-02-29 20:35:21 +00:00
|
|
|
$subjectPage = $this->namespaceInfo->getSubjectPage( $title );
|
2021-10-19 18:16:43 +00:00
|
|
|
$isMainPageTalk = Title::newFromLinkTarget( $subjectPage )->isMainPage();
|
|
|
|
return (
|
2022-04-08 19:21:50 +00:00
|
|
|
$this->hasPageActions() && !$isMainPageTalk &&
|
2024-03-23 17:20:57 +00:00
|
|
|
$this->skinOptions->get( SkinOptions::TALK_AT_TOP )
|
2021-10-19 18:16:43 +00:00
|
|
|
) || (
|
2023-12-14 00:30:55 +00:00
|
|
|
$isSpecialPageOrHistory &&
|
2024-03-23 17:20:57 +00:00
|
|
|
$this->skinOptions->get( SkinOptions::TABS_ON_SPECIALS )
|
2021-10-19 18:16:43 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-11-12 19:51:08 +00:00
|
|
|
* @param array $contentNavigationUrls
|
2023-12-21 19:54:31 +00:00
|
|
|
* @param array $associatedPages - data-associated-pages from template data, currently only used for ID
|
2021-10-19 18:16:43 +00:00
|
|
|
* @return array
|
|
|
|
*/
|
2023-12-21 19:54:31 +00:00
|
|
|
private function getTabsData( array $contentNavigationUrls, array $associatedPages ) {
|
2022-04-08 19:21:50 +00:00
|
|
|
$hasPageTabs = $this->hasPageTabs();
|
|
|
|
if ( !$hasPageTabs ) {
|
2021-10-19 18:16:43 +00:00
|
|
|
return [];
|
|
|
|
}
|
2021-11-12 19:51:08 +00:00
|
|
|
return $contentNavigationUrls ? [
|
2022-09-23 16:10:21 +00:00
|
|
|
'items' => array_values( $contentNavigationUrls['associated-pages'] ),
|
2023-12-21 19:54:31 +00:00
|
|
|
'id' => $associatedPages['id'] ?? null,
|
2021-10-19 18:16:43 +00:00
|
|
|
] : [];
|
|
|
|
}
|
|
|
|
|
2019-04-08 17:08:57 +00:00
|
|
|
/**
|
|
|
|
* Build the Main Menu Director by passing the skin options
|
|
|
|
*
|
|
|
|
* @return MainMenuDirector
|
|
|
|
*/
|
2019-06-21 16:52:22 +00:00
|
|
|
protected function getMainMenu(): MainMenuDirector {
|
2024-03-25 09:54:20 +00:00
|
|
|
$showMobileOptions = $this->skinOptions->get( SkinOptions::MOBILE_OPTIONS );
|
|
|
|
// Add a donate link (see https://phabricator.wikimedia.org/T219793)
|
|
|
|
$showDonateLink = $this->skinOptions->get( SkinOptions::SHOW_DONATE );
|
|
|
|
$builder = $this->skinOptions->get( SkinOptions::MAIN_MENU_EXPANDED ) ?
|
|
|
|
new AdvancedMainMenuBuilder(
|
|
|
|
$showMobileOptions,
|
|
|
|
$showDonateLink,
|
|
|
|
$this->definitions
|
|
|
|
) :
|
|
|
|
new DefaultMainMenuBuilder(
|
|
|
|
$showMobileOptions,
|
|
|
|
$showDonateLink,
|
|
|
|
$this->getUser(),
|
|
|
|
$this->definitions,
|
|
|
|
$this->userIdentityUtils
|
|
|
|
);
|
|
|
|
return new MainMenuDirector( $builder );
|
2019-04-08 17:08:57 +00:00
|
|
|
}
|
|
|
|
|
2019-08-02 14:12:26 +00:00
|
|
|
/**
|
|
|
|
* Prepare all Minerva menus
|
2021-11-12 19:51:08 +00:00
|
|
|
*
|
2022-01-13 00:38:16 +00:00
|
|
|
* @param array $personalUrls result of SkinTemplate::buildPersonalUrls
|
2021-11-10 23:58:07 +00:00
|
|
|
* @return string|null
|
2019-08-02 14:12:26 +00:00
|
|
|
*/
|
2022-01-13 00:38:16 +00:00
|
|
|
private function getPersonalToolsMenu( array $personalUrls ) {
|
2024-03-24 15:08:11 +00:00
|
|
|
$builder = $this->skinOptions->get( SkinOptions::PERSONAL_MENU ) ?
|
|
|
|
new AdvancedUserMenuBuilder(
|
|
|
|
$this->getContext(),
|
|
|
|
$this->getUser(),
|
|
|
|
$this->definitions
|
|
|
|
) :
|
|
|
|
new DefaultUserMenuBuilder();
|
|
|
|
|
|
|
|
$userMenuDirector = new UserMenuDirector(
|
|
|
|
$builder,
|
|
|
|
$this->getContext()->getSkin()
|
|
|
|
);
|
2022-01-13 00:38:16 +00:00
|
|
|
return $userMenuDirector->renderMenuData( $personalUrls );
|
2019-08-02 14:12:26 +00:00
|
|
|
}
|
|
|
|
|
2017-07-12 15:12:40 +00:00
|
|
|
/**
|
2021-10-04 22:03:29 +00:00
|
|
|
* @return string
|
2017-07-12 15:12:40 +00:00
|
|
|
*/
|
2021-10-04 22:03:29 +00:00
|
|
|
protected function getSubjectPage() {
|
2017-07-12 15:12:40 +00:00
|
|
|
$title = $this->getTitle();
|
|
|
|
|
|
|
|
// If it's a talk page, add a link to the main namespace page
|
2019-02-26 18:24:42 +00:00
|
|
|
// In AMC we do not need to do this as there is an easy way back to the article page
|
|
|
|
// via the talk/article tabs.
|
2024-03-23 17:20:57 +00:00
|
|
|
if ( $title->isTalkPage() && !$this->skinOptions->get( SkinOptions::TALK_AT_TOP ) ) {
|
2017-07-12 15:12:40 +00:00
|
|
|
// if it's a talk page for which we have a special message, use it
|
|
|
|
switch ( $title->getNamespace() ) {
|
|
|
|
case NS_USER_TALK:
|
|
|
|
$msg = 'mobile-frontend-talk-back-to-userpage';
|
|
|
|
break;
|
|
|
|
case NS_PROJECT_TALK:
|
|
|
|
$msg = 'mobile-frontend-talk-back-to-projectpage';
|
|
|
|
break;
|
|
|
|
case NS_FILE_TALK:
|
|
|
|
$msg = 'mobile-frontend-talk-back-to-filepage';
|
|
|
|
break;
|
2024-02-28 07:02:37 +00:00
|
|
|
default:
|
|
|
|
// generic (all other NS)
|
2017-07-12 15:12:40 +00:00
|
|
|
$msg = 'mobile-frontend-talk-back-to-page';
|
|
|
|
}
|
2024-02-29 20:35:21 +00:00
|
|
|
$subjectPage = $this->namespaceInfo->getSubjectPage( $title );
|
2019-08-02 15:02:28 +00:00
|
|
|
|
2024-02-29 20:35:21 +00:00
|
|
|
return $this->linkRenderer->makeLink(
|
2019-08-02 15:02:28 +00:00
|
|
|
$subjectPage,
|
2017-07-12 15:12:40 +00:00
|
|
|
$this->msg( $msg, $title->getText() )->text(),
|
2021-11-05 00:52:30 +00:00
|
|
|
[
|
|
|
|
'data-event-name' => 'talk.returnto',
|
|
|
|
'class' => 'return-link'
|
|
|
|
]
|
2021-10-04 22:03:29 +00:00
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return '';
|
2017-07-12 15:12:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-10-20 19:56:45 +00:00
|
|
|
* Modifies the template data before parsing in SkinMustache.
|
|
|
|
*
|
|
|
|
* @inheritDoc
|
2017-07-12 15:12:40 +00:00
|
|
|
*/
|
2023-10-20 19:56:45 +00:00
|
|
|
final protected function doEditSectionLinksHTML( array $links, Language $lang ) {
|
|
|
|
$transformedLinks = [];
|
|
|
|
foreach ( $links as $key => $link ) {
|
|
|
|
$transformedLinks[] = $link + [
|
2023-08-09 02:56:03 +00:00
|
|
|
'data-icon' => [
|
2023-10-20 19:56:45 +00:00
|
|
|
'icon' => $link['icon'],
|
2023-08-09 02:56:03 +00:00
|
|
|
],
|
2023-10-20 19:56:45 +00:00
|
|
|
];
|
2017-07-12 15:12:40 +00:00
|
|
|
}
|
2023-10-20 19:56:45 +00:00
|
|
|
return parent::doEditSectionLinksHTML( $transformedLinks, $lang );
|
2017-07-12 15:12:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Takes a title and returns classes to apply to the body tag
|
|
|
|
* @param Title $title
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getPageClasses( $title ) {
|
|
|
|
$className = parent::getPageClasses( $title );
|
2024-03-23 17:20:57 +00:00
|
|
|
$className .= ' ' . ( $this->skinOptions->get( SkinOptions::BETA_MODE )
|
2019-04-10 21:43:50 +00:00
|
|
|
? 'beta' : 'stable' );
|
2017-07-12 15:12:40 +00:00
|
|
|
|
2020-12-18 03:09:15 +00:00
|
|
|
if ( $this->getUser()->isRegistered() ) {
|
2017-07-12 15:12:40 +00:00
|
|
|
$className .= ' is-authenticated';
|
|
|
|
}
|
2024-01-30 19:21:36 +00:00
|
|
|
|
2018-11-12 20:32:28 +00:00
|
|
|
// The new treatment should only apply to the main namespace
|
|
|
|
if (
|
|
|
|
$title->getNamespace() === NS_MAIN &&
|
2024-03-23 17:20:57 +00:00
|
|
|
$this->skinOptions->get( SkinOptions::PAGE_ISSUES )
|
2018-11-12 20:32:28 +00:00
|
|
|
) {
|
|
|
|
$className .= ' issues-group-B';
|
|
|
|
}
|
2024-01-30 19:21:36 +00:00
|
|
|
|
2017-07-12 15:12:40 +00:00
|
|
|
return $className;
|
|
|
|
}
|
|
|
|
|
2024-03-18 19:14:23 +00:00
|
|
|
/**
|
|
|
|
* Converts "1", "2", and "0" to equivalent values.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
private static function resolveNightModeQueryValue( string $value ) {
|
|
|
|
switch ( $value ) {
|
|
|
|
case 'day':
|
|
|
|
case 'night':
|
|
|
|
case 'os':
|
|
|
|
return $value;
|
|
|
|
case '1':
|
|
|
|
return 'night';
|
|
|
|
case '2':
|
|
|
|
return 'os';
|
|
|
|
default:
|
|
|
|
return 'day';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-30 19:21:36 +00:00
|
|
|
/**
|
|
|
|
* Provides skin-specific modifications to the HTML element attributes
|
|
|
|
*
|
|
|
|
* Currently only used for adding the night mode class
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getHtmlElementAttributes() {
|
|
|
|
$attributes = parent::getHtmlElementAttributes();
|
|
|
|
|
2024-02-05 22:45:49 +00:00
|
|
|
// check to see if night mode is enabled via query params or by config
|
2024-02-06 22:26:55 +00:00
|
|
|
$webRequest = $this->getContext()->getRequest();
|
2024-03-28 21:00:03 +00:00
|
|
|
$forceNightMode = $webRequest->getRawVal( 'minervanightmode' );
|
2024-02-06 22:26:55 +00:00
|
|
|
|
|
|
|
// get skin config of night mode to check what is execluded
|
|
|
|
$nightModeConfig = $this->getConfig()->get( 'MinervaNightModeOptions' );
|
|
|
|
$featuresHelper = new FeaturesHelper();
|
|
|
|
$shouldDisableNightMode = $featuresHelper->shouldDisableNightMode( $nightModeConfig,
|
|
|
|
$webRequest,
|
|
|
|
$this->getContext()->getTitle()
|
|
|
|
);
|
|
|
|
|
2024-02-08 22:52:46 +00:00
|
|
|
if (
|
2024-03-28 21:00:03 +00:00
|
|
|
$this->skinOptions->get( SkinOptions::NIGHT_MODE ) || $forceNightMode !== null
|
2024-02-08 22:52:46 +00:00
|
|
|
) {
|
2024-02-01 23:05:55 +00:00
|
|
|
$user = $this->getUser();
|
2024-03-18 19:14:23 +00:00
|
|
|
$value = $this->userOptionsManager->getOption( $user, 'minerva-theme' );
|
2024-02-01 23:05:55 +00:00
|
|
|
|
2024-02-05 22:45:49 +00:00
|
|
|
// if forcing a (valid) setting via query params, take priority over the user option
|
2024-03-18 19:14:23 +00:00
|
|
|
if ( $forceNightMode !== null && in_array( $forceNightMode, [ '1', '0', '2', 'day', 'night', 'os' ] ) ) {
|
|
|
|
$value = self::resolveNightModeQueryValue( $forceNightMode );
|
2024-02-05 22:45:49 +00:00
|
|
|
}
|
2024-02-08 22:52:46 +00:00
|
|
|
|
|
|
|
// For T356653 add a class to the page to allow the client to detect we've
|
|
|
|
// intentionally disabled night mode.
|
|
|
|
if ( $shouldDisableNightMode ) {
|
|
|
|
$attributes[ 'class' ] .= ' skin-night-mode-page-disabled';
|
|
|
|
return $attributes;
|
|
|
|
}
|
|
|
|
|
2024-03-18 19:14:23 +00:00
|
|
|
$attributes[ 'class' ] .= " skin-theme-clientpref-$value";
|
2024-01-30 19:21:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return $attributes;
|
|
|
|
}
|
|
|
|
|
2017-07-12 15:12:40 +00:00
|
|
|
/**
|
|
|
|
* Whether the output page contains category links and the category feature is enabled.
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
private function hasCategoryLinks() {
|
2024-03-23 17:20:57 +00:00
|
|
|
if ( !$this->skinOptions->get( SkinOptions::CATEGORIES ) ) {
|
2017-07-12 15:12:40 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
$categoryLinks = $this->getOutput()->getCategoryLinks();
|
|
|
|
|
|
|
|
if ( !count( $categoryLinks ) ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return !empty( $categoryLinks['normal'] ) || !empty( $categoryLinks['hidden'] );
|
|
|
|
}
|
|
|
|
|
2017-11-22 18:55:24 +00:00
|
|
|
/**
|
|
|
|
* Get a history link which describes author and relative time of last edit
|
|
|
|
* @param Title $title The Title object of the page being viewed
|
2020-01-04 12:24:24 +00:00
|
|
|
* @param string $timestamp
|
2017-11-22 18:55:24 +00:00
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
protected function getRelativeHistoryLink( Title $title, $timestamp ) {
|
|
|
|
$user = $this->getUser();
|
2019-05-14 10:40:56 +00:00
|
|
|
$userDate = $this->getLanguage()->userDate( $timestamp, $user );
|
2017-11-22 18:55:24 +00:00
|
|
|
$text = $this->msg(
|
2019-05-14 10:40:56 +00:00
|
|
|
'minerva-last-modified-date', $userDate,
|
2017-11-22 18:55:24 +00:00
|
|
|
$this->getLanguage()->userTime( $timestamp, $user )
|
|
|
|
)->parse();
|
|
|
|
return [
|
|
|
|
// Use $edit['timestamp'] (Unix format) instead of $timestamp (MW format)
|
|
|
|
'data-timestamp' => wfTimestamp( TS_UNIX, $timestamp ),
|
|
|
|
'href' => $this->getHistoryUrl( $title ),
|
|
|
|
'text' => $text,
|
|
|
|
] + $this->getRevisionEditorData( $title );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a history link which makes no reference to user or last edited time
|
|
|
|
* @param Title $title The Title object of the page being viewed
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
protected function getGenericHistoryLink( Title $title ) {
|
|
|
|
$text = $this->msg( 'mobile-frontend-history' )->plain();
|
|
|
|
return [
|
|
|
|
'href' => $this->getHistoryUrl( $title ),
|
|
|
|
'text' => $text,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2024-01-29 22:17:17 +00:00
|
|
|
/**
|
|
|
|
* Checks if the Special:History page is being used.
|
|
|
|
* @param Title $title The Title object of the page being viewed
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
private function shouldUseSpecialHistory( Title $title ) {
|
|
|
|
return ExtensionRegistry::getInstance()->isLoaded( 'MobileFrontend' ) &&
|
|
|
|
SpecialMobileHistory::shouldUseSpecialHistory( $title, $this->getUser() );
|
|
|
|
}
|
|
|
|
|
2017-11-22 18:55:24 +00:00
|
|
|
/**
|
|
|
|
* Get the URL for the history page for the given title using Special:History
|
|
|
|
* when available.
|
|
|
|
* @param Title $title The Title object of the page being viewed
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
protected function getHistoryUrl( Title $title ) {
|
2024-01-29 22:17:17 +00:00
|
|
|
return $this->shouldUseSpecialHistory( $title ) ?
|
2017-11-22 18:55:24 +00:00
|
|
|
SpecialPage::getTitleFor( 'History', $title )->getLocalURL() :
|
|
|
|
$title->getLocalURL( [ 'action' => 'history' ] );
|
|
|
|
}
|
|
|
|
|
2017-07-12 15:12:40 +00:00
|
|
|
/**
|
|
|
|
* Prepare the content for the 'last edited' message, e.g. 'Last edited on 30 August
|
|
|
|
* 2013, at 23:31'. This message is different for the main page since main page
|
2019-01-11 12:13:49 +00:00
|
|
|
* content is typically transcluded rather than edited directly.
|
2019-08-02 13:38:18 +00:00
|
|
|
*
|
|
|
|
* The relative time is only rendered on the latest revision.
|
|
|
|
* For older revisions the last modified information will not render with a relative time
|
|
|
|
* nor will it show the name of the editor.
|
2017-07-12 15:12:40 +00:00
|
|
|
* @param Title $title The Title object of the page being viewed
|
2021-10-29 19:47:02 +00:00
|
|
|
* @return array|null
|
2017-07-12 15:12:40 +00:00
|
|
|
*/
|
2017-11-22 18:55:24 +00:00
|
|
|
protected function getHistoryLink( Title $title ) {
|
2022-03-31 09:01:04 +00:00
|
|
|
if ( !$title->exists() ||
|
2022-04-15 21:05:22 +00:00
|
|
|
$this->getContext()->getActionName() !== 'view'
|
2022-03-31 09:01:04 +00:00
|
|
|
) {
|
|
|
|
return null;
|
2017-11-16 23:21:05 +00:00
|
|
|
}
|
2023-11-06 19:46:12 +00:00
|
|
|
// Do not show the last modified bar on diff pages [T350515]
|
|
|
|
$request = $this->getRequest();
|
2024-03-28 21:00:03 +00:00
|
|
|
if ( $request->getCheck( 'diff' ) ) {
|
2023-11-06 19:46:12 +00:00
|
|
|
return null;
|
|
|
|
}
|
2021-11-29 20:34:09 +00:00
|
|
|
|
2022-03-31 09:01:04 +00:00
|
|
|
$out = $this->getOutput();
|
2021-11-29 20:34:09 +00:00
|
|
|
|
2022-06-28 16:10:35 +00:00
|
|
|
if ( !$out->getRevisionId() || !$out->isRevisionCurrent() || $title->isMainPage() ) {
|
2022-03-31 09:01:04 +00:00
|
|
|
$historyLink = $this->getGenericHistoryLink( $title );
|
|
|
|
} else {
|
|
|
|
// Get rev_timestamp of current revision (preloaded by MediaWiki core)
|
|
|
|
$timestamp = $out->getRevisionTimestamp();
|
|
|
|
if ( !$timestamp ) {
|
|
|
|
# No cached timestamp, load it from the database
|
2024-02-29 20:35:21 +00:00
|
|
|
$timestamp = $this->revisionLookup->getTimestampFromId( $out->getRevisionId() );
|
2022-03-31 09:01:04 +00:00
|
|
|
}
|
|
|
|
$historyLink = $this->getRelativeHistoryLink( $title, $timestamp );
|
2021-11-29 20:34:09 +00:00
|
|
|
}
|
2021-10-29 19:47:02 +00:00
|
|
|
|
2022-03-31 09:01:04 +00:00
|
|
|
return $historyLink + [
|
2023-07-19 11:00:13 +00:00
|
|
|
'historyIcon' => [
|
2023-09-21 22:11:03 +00:00
|
|
|
'icon' => 'modified-history',
|
2023-08-09 21:49:19 +00:00
|
|
|
'size' => 'medium'
|
2023-07-19 11:00:13 +00:00
|
|
|
],
|
|
|
|
'arrowIcon' => [
|
|
|
|
'icon' => 'expand',
|
2023-08-09 21:49:19 +00:00
|
|
|
'size' => 'small'
|
2023-07-19 11:00:13 +00:00
|
|
|
]
|
2022-03-31 09:01:04 +00:00
|
|
|
];
|
2017-07-12 15:12:40 +00:00
|
|
|
}
|
2017-09-06 15:20:16 +00:00
|
|
|
|
|
|
|
/**
|
2017-11-22 18:55:24 +00:00
|
|
|
* Returns data attributes representing the editor for the current revision.
|
2020-03-04 02:53:53 +00:00
|
|
|
* @param LinkTarget $title The Title object of the page being viewed
|
2017-11-22 18:55:24 +00:00
|
|
|
* @return array representing user with name and gender fields. Empty if the editor no longer
|
|
|
|
* exists in the database or is hidden from public view.
|
2017-09-06 15:20:16 +00:00
|
|
|
*/
|
2020-03-04 02:53:53 +00:00
|
|
|
private function getRevisionEditorData( LinkTarget $title ) {
|
2024-02-29 20:35:21 +00:00
|
|
|
$rev = $this->revisionLookup->getRevisionByTitle( $title );
|
2017-11-22 18:55:24 +00:00
|
|
|
$result = [];
|
|
|
|
if ( $rev ) {
|
2020-03-04 02:53:53 +00:00
|
|
|
$revUser = $rev->getUser();
|
2017-11-22 18:55:24 +00:00
|
|
|
// Note the user will only be returned if that information is public
|
2020-03-04 02:53:53 +00:00
|
|
|
if ( $revUser ) {
|
2017-11-22 18:55:24 +00:00
|
|
|
$editorName = $revUser->getName();
|
2024-02-29 20:35:21 +00:00
|
|
|
$editorGender = $this->genderCache->getGenderOf( $revUser, __METHOD__ );
|
2017-11-22 18:55:24 +00:00
|
|
|
$result += [
|
|
|
|
'data-user-name' => $editorName,
|
|
|
|
'data-user-gender' => $editorGender,
|
|
|
|
];
|
|
|
|
}
|
2017-09-06 15:20:16 +00:00
|
|
|
}
|
2017-11-22 18:55:24 +00:00
|
|
|
return $result;
|
2017-09-06 15:20:16 +00:00
|
|
|
}
|
|
|
|
|
2017-07-12 15:12:40 +00:00
|
|
|
/**
|
|
|
|
* Returns the HTML representing the tagline
|
|
|
|
* @return string HTML for tagline
|
|
|
|
*/
|
|
|
|
protected function getTaglineHtml() {
|
2017-11-28 21:55:58 +00:00
|
|
|
$tagline = '';
|
2017-07-12 15:12:40 +00:00
|
|
|
|
2024-03-24 10:49:33 +00:00
|
|
|
if ( $this->skinUserPageHelper->isUserPage() ) {
|
|
|
|
$pageUser = $this->skinUserPageHelper->getPageUser();
|
2017-07-12 15:12:40 +00:00
|
|
|
$fromDate = $pageUser->getRegistration();
|
2021-04-29 20:24:13 +00:00
|
|
|
|
2024-03-24 10:49:33 +00:00
|
|
|
if ( $this->skinUserPageHelper->isUserPageAccessibleToCurrentUser() && is_string( $fromDate ) ) {
|
2017-07-12 15:12:40 +00:00
|
|
|
$fromDateTs = wfTimestamp( TS_UNIX, $fromDate );
|
|
|
|
|
|
|
|
// This is shown when js is disabled. js enhancement made due to caching
|
|
|
|
$tagline = $this->msg( 'mobile-frontend-user-page-member-since',
|
|
|
|
$this->getLanguage()->userDate( new MWTimestamp( $fromDateTs ), $this->getUser() ),
|
2018-09-04 05:58:45 +00:00
|
|
|
$pageUser )->text();
|
2017-07-12 15:12:40 +00:00
|
|
|
|
|
|
|
// Define html attributes for usage with js enhancement (unix timestamp, gender)
|
|
|
|
$attrs = [ 'id' => 'tagline-userpage',
|
|
|
|
'data-userpage-registration-date' => $fromDateTs,
|
2024-02-29 20:35:21 +00:00
|
|
|
'data-userpage-gender' => $this->genderCache->getGenderOf( $pageUser, __METHOD__ ) ];
|
2017-07-12 15:12:40 +00:00
|
|
|
}
|
|
|
|
} else {
|
2024-03-24 15:47:31 +00:00
|
|
|
if ( $this->getTitle() ) {
|
2018-10-31 21:37:17 +00:00
|
|
|
$out = $this->getOutput();
|
|
|
|
$tagline = $out->getProperty( 'wgMFDescription' );
|
2017-07-12 15:12:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$attrs[ 'class' ] = 'tagline';
|
2017-11-28 21:55:58 +00:00
|
|
|
return Html::element( 'div', $attrs, $tagline );
|
2017-07-12 15:12:40 +00:00
|
|
|
}
|
2019-10-11 19:04:00 +00:00
|
|
|
|
2017-07-12 15:12:40 +00:00
|
|
|
/**
|
|
|
|
* Returns the HTML representing the heading.
|
2021-11-05 18:21:09 +00:00
|
|
|
*
|
|
|
|
* @param string $heading The heading suggested by core.
|
2017-07-12 15:12:40 +00:00
|
|
|
* @return string HTML for header
|
|
|
|
*/
|
2021-11-05 18:21:09 +00:00
|
|
|
private function getUserPageHeadingHtml( $heading ) {
|
|
|
|
// The heading is just the username without namespace
|
2024-03-23 21:01:14 +00:00
|
|
|
return Html::element( 'h1',
|
2021-11-05 18:21:09 +00:00
|
|
|
// These IDs and classes should match Skin::getTemplateData
|
|
|
|
[
|
|
|
|
'id' => 'firstHeading',
|
|
|
|
'class' => 'firstHeading mw-first-heading mw-minerva-user-heading',
|
|
|
|
],
|
2024-03-24 10:49:33 +00:00
|
|
|
$this->skinUserPageHelper->getPageUser()->getName()
|
2021-11-05 18:21:09 +00:00
|
|
|
);
|
2017-07-12 15:12:40 +00:00
|
|
|
}
|
2019-06-21 20:07:11 +00:00
|
|
|
|
2017-07-12 15:12:40 +00:00
|
|
|
/**
|
|
|
|
* Load internal banner content to show in pre content in template
|
|
|
|
* Beware of HTML caching when using this function.
|
|
|
|
* Content set as "internalbanner"
|
2021-11-10 23:58:07 +00:00
|
|
|
* @param string $siteNotice HTML fragment
|
|
|
|
* @return array
|
2017-07-12 15:12:40 +00:00
|
|
|
*/
|
2021-11-10 23:58:07 +00:00
|
|
|
protected function prepareBanners( $siteNotice ) {
|
2021-12-10 11:11:35 +00:00
|
|
|
$banners = [];
|
|
|
|
if ( $siteNotice && $this->getConfig()->get( 'MinervaEnableSiteNotice' ) ) {
|
2024-04-25 00:09:54 +00:00
|
|
|
$banners[] = $siteNotice;
|
2021-12-10 11:11:35 +00:00
|
|
|
} else {
|
|
|
|
$banners[] = '<div id="siteNotice"></div>';
|
2017-07-12 15:12:40 +00:00
|
|
|
}
|
2021-11-10 23:58:07 +00:00
|
|
|
return $banners;
|
2017-07-12 15:12:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an array with details for a language button.
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
protected function getLanguageButton() {
|
|
|
|
return [
|
2023-08-01 00:12:59 +00:00
|
|
|
'array-attributes' => [
|
2023-07-24 22:12:24 +00:00
|
|
|
[
|
|
|
|
'key' => 'href',
|
|
|
|
'value' => '#p-lang'
|
|
|
|
]
|
2017-07-12 15:12:40 +00:00
|
|
|
],
|
2023-07-24 22:12:24 +00:00
|
|
|
'tag-name' => 'a',
|
|
|
|
'classes' => 'language-selector button',
|
2017-07-12 15:12:40 +00:00
|
|
|
'label' => $this->msg( 'mobile-frontend-language-article-heading' )->text()
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an array with details for a talk button.
|
|
|
|
* @param Title $talkTitle Title object of the talk page
|
2019-10-17 22:46:07 +00:00
|
|
|
* @param string $label Button label
|
2017-07-12 15:12:40 +00:00
|
|
|
* @return array
|
|
|
|
*/
|
2022-10-02 12:44:18 +00:00
|
|
|
protected function getTalkButton( $talkTitle, $label ) {
|
2017-07-12 15:12:40 +00:00
|
|
|
return [
|
2023-08-01 00:12:59 +00:00
|
|
|
'array-attributes' => [
|
2023-07-24 22:12:24 +00:00
|
|
|
[
|
|
|
|
'key' => 'href',
|
|
|
|
'value' => $talkTitle->getLinkURL(),
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'key' => 'data-title',
|
|
|
|
'value' => $talkTitle->getFullText(),
|
|
|
|
]
|
2017-07-12 15:12:40 +00:00
|
|
|
],
|
2023-07-24 22:12:24 +00:00
|
|
|
'tag-name' => 'a',
|
|
|
|
'classes' => 'talk button',
|
2019-10-17 22:46:07 +00:00
|
|
|
'label' => $label,
|
2017-07-12 15:12:40 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an array of links for page secondary actions
|
2021-11-12 19:51:08 +00:00
|
|
|
* @param array $contentNavigationUrls
|
2021-10-26 16:02:42 +00:00
|
|
|
* @return array|null
|
2017-07-12 15:12:40 +00:00
|
|
|
*/
|
2021-11-12 19:51:08 +00:00
|
|
|
protected function getSecondaryActions( array $contentNavigationUrls ) {
|
2021-10-26 16:02:42 +00:00
|
|
|
if ( $this->isFallbackEditor() || !$this->hasSecondaryActions() ) {
|
|
|
|
return null;
|
2021-10-20 16:40:25 +00:00
|
|
|
}
|
|
|
|
|
2017-07-12 15:12:40 +00:00
|
|
|
$buttons = [];
|
|
|
|
// always add a button to link to the talk page
|
2019-10-17 22:46:07 +00:00
|
|
|
// it will link to the wikitext talk page
|
2017-07-12 15:12:40 +00:00
|
|
|
$title = $this->getTitle();
|
2024-02-29 20:35:21 +00:00
|
|
|
$subjectPage = Title::newFromLinkTarget( $this->namespaceInfo->getSubjectPage( $title ) );
|
2024-03-23 17:20:57 +00:00
|
|
|
$talkAtBottom = !$this->skinOptions->get( SkinOptions::TALK_AT_TOP ) ||
|
2019-10-17 22:46:07 +00:00
|
|
|
$subjectPage->isMainPage();
|
2024-03-24 10:49:33 +00:00
|
|
|
if ( !$this->skinUserPageHelper->isUserPage() &&
|
2024-03-23 19:16:47 +00:00
|
|
|
$this->permissions->isTalkAllowed() && $talkAtBottom &&
|
2021-10-18 21:04:03 +00:00
|
|
|
// When showing talk at the bottom we restrict this so it is not shown to anons
|
|
|
|
// https://phabricator.wikimedia.org/T54165
|
|
|
|
// This whole code block can be removed when SkinOptions::TALK_AT_TOP is always true
|
2022-10-02 12:44:18 +00:00
|
|
|
$this->getUser()->isRegistered()
|
2019-01-10 22:59:56 +00:00
|
|
|
) {
|
2022-09-23 16:10:21 +00:00
|
|
|
$namespaces = $contentNavigationUrls['associated-pages'];
|
2017-07-12 15:12:40 +00:00
|
|
|
// FIXME [core]: This seems unnecessary..
|
|
|
|
$subjectId = $title->getNamespaceKey( '' );
|
|
|
|
$talkId = $subjectId === 'main' ? 'talk' : "{$subjectId}_talk";
|
2017-09-28 20:06:39 +00:00
|
|
|
|
|
|
|
if ( isset( $namespaces[$talkId] ) ) {
|
2017-07-12 15:12:40 +00:00
|
|
|
$talkButton = $namespaces[$talkId];
|
2024-02-29 20:35:21 +00:00
|
|
|
$talkTitle = Title::newFromLinkTarget( $this->namespaceInfo->getTalkPage( $title ) );
|
2019-08-02 15:02:28 +00:00
|
|
|
|
2019-10-17 22:46:07 +00:00
|
|
|
$buttons['talk'] = $this->getTalkButton( $talkTitle, $talkButton['text'] );
|
2017-07-12 15:12:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-23 21:43:33 +00:00
|
|
|
if (
|
2024-03-24 09:01:40 +00:00
|
|
|
$this->languagesHelper->doesTitleHasLanguagesOrVariants( $this->getOutput(), $title ) &&
|
2024-03-23 21:43:33 +00:00
|
|
|
$title->isMainPage()
|
|
|
|
) {
|
2017-07-12 15:12:40 +00:00
|
|
|
$buttons['language'] = $this->getLanguageButton();
|
|
|
|
}
|
|
|
|
|
|
|
|
return $buttons;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-04-21 22:44:18 +00:00
|
|
|
* @inheritDoc
|
2017-07-12 15:12:40 +00:00
|
|
|
* @return array
|
|
|
|
*/
|
2021-07-23 00:57:37 +00:00
|
|
|
protected function getJsConfigVars(): array {
|
2020-04-21 22:44:18 +00:00
|
|
|
return array_merge( parent::getJsConfigVars(), [
|
2019-09-18 23:07:21 +00:00
|
|
|
'wgMinervaPermissions' => [
|
2024-03-23 19:16:47 +00:00
|
|
|
'watchable' => $this->permissions->isAllowed( IMinervaPagePermissions::WATCHABLE ),
|
|
|
|
'watch' => $this->permissions->isAllowed( IMinervaPagePermissions::WATCH ),
|
2019-09-18 23:07:21 +00:00
|
|
|
],
|
2024-03-23 17:20:57 +00:00
|
|
|
'wgMinervaFeatures' => $this->skinOptions->getAll(),
|
2017-11-28 21:17:27 +00:00
|
|
|
'wgMinervaDownloadNamespaces' => $this->getConfig()->get( 'MinervaDownloadNamespaces' ),
|
2020-04-21 22:44:18 +00:00
|
|
|
] );
|
2017-07-12 15:12:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the javascript entry modules to load. Only modules that need to
|
|
|
|
* be overriden or added conditionally should be placed here.
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getDefaultModules() {
|
|
|
|
$modules = parent::getDefaultModules();
|
2019-05-14 09:01:04 +00:00
|
|
|
|
|
|
|
// FIXME: T223204: Dequeue default content modules except for the history
|
2023-03-30 17:22:36 +00:00
|
|
|
// action. Allow default content modules on history action in order to
|
|
|
|
// enable toggling of the filters.
|
|
|
|
// Long term this won't be necessary when T111565 is resolved and a
|
2019-05-14 09:01:04 +00:00
|
|
|
// more general solution can be used.
|
2022-04-15 21:05:22 +00:00
|
|
|
if ( $this->getContext()->getActionName() !== 'history' ) {
|
2023-03-30 17:22:36 +00:00
|
|
|
// dequeue default content modules (toc, collapsible, etc.)
|
2020-07-14 12:59:40 +00:00
|
|
|
$modules['content'] = array_diff( $modules['content'], [
|
|
|
|
// T111565
|
|
|
|
'jquery.makeCollapsible',
|
|
|
|
// Minerva provides its own implementation. Loading this will break display.
|
|
|
|
'mediawiki.toc'
|
|
|
|
] );
|
2019-05-14 09:01:04 +00:00
|
|
|
// dequeue styles associated with `content` key.
|
2020-07-14 12:59:40 +00:00
|
|
|
$modules['styles']['content'] = array_diff( $modules['styles']['content'], [
|
|
|
|
// T111565
|
|
|
|
'jquery.makeCollapsible.styles',
|
|
|
|
] );
|
2019-05-14 09:01:04 +00:00
|
|
|
}
|
2017-07-12 15:12:40 +00:00
|
|
|
|
2024-04-03 12:48:52 +00:00
|
|
|
$modules['styles']['skin.page'] = $this->getPageSpecificStyles();
|
|
|
|
$modules['styles']['skin.features'] = $this->getFeatureSpecificStyles();
|
2017-07-12 15:12:40 +00:00
|
|
|
|
|
|
|
return $modules;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-08-06 15:28:47 +00:00
|
|
|
* Provide styles required to present the server rendered page in this skin. Additional styles
|
|
|
|
* may be loaded dynamically by the client.
|
|
|
|
*
|
|
|
|
* Any styles returned by this method are loaded on the critical rendering path as linked
|
|
|
|
* stylesheets. I.e., they are required to load on the client before first paint.
|
|
|
|
*
|
2017-07-12 15:12:40 +00:00
|
|
|
* @return array
|
|
|
|
*/
|
2024-04-03 12:48:52 +00:00
|
|
|
protected function getPageSpecificStyles() {
|
|
|
|
$styles = [];
|
2017-07-12 15:12:40 +00:00
|
|
|
$title = $this->getTitle();
|
2023-02-11 19:48:00 +00:00
|
|
|
$request = $this->getRequest();
|
2023-04-17 16:54:48 +00:00
|
|
|
$requestAction = $this->getContext()->getActionName();
|
|
|
|
$viewAction = $requestAction === 'view';
|
2023-02-11 19:48:00 +00:00
|
|
|
|
|
|
|
// Warning box styles are needed when reviewing old revisions
|
|
|
|
// and inside the fallback editor styles to action=edit page.
|
|
|
|
if (
|
|
|
|
$title->getNamespace() !== NS_MAIN ||
|
2024-03-28 21:00:03 +00:00
|
|
|
$request->getCheck( 'oldid' ) ||
|
2023-02-11 19:48:00 +00:00
|
|
|
!$viewAction
|
|
|
|
) {
|
|
|
|
$styles[] = 'skins.minerva.messageBox.styles';
|
|
|
|
}
|
|
|
|
|
2017-07-12 15:12:40 +00:00
|
|
|
if ( $title->isMainPage() ) {
|
|
|
|
$styles[] = 'skins.minerva.mainPage.styles';
|
2024-03-24 10:49:33 +00:00
|
|
|
} elseif ( $this->skinUserPageHelper->isUserPage() ) {
|
2018-02-14 00:14:54 +00:00
|
|
|
$styles[] = 'skins.minerva.userpage.styles';
|
2017-07-12 15:12:40 +00:00
|
|
|
}
|
2019-10-17 22:46:07 +00:00
|
|
|
|
2020-12-18 03:09:15 +00:00
|
|
|
if ( $this->getUser()->isRegistered() ) {
|
2017-12-13 01:25:10 +00:00
|
|
|
$styles[] = 'skins.minerva.loggedin.styles';
|
|
|
|
}
|
2017-07-12 15:12:40 +00:00
|
|
|
|
2019-08-22 20:31:31 +00:00
|
|
|
// When any of these features are enabled in production
|
|
|
|
// remove the if condition
|
|
|
|
// and move the associated LESS file inside `skins.minerva.amc.styles`
|
|
|
|
// into a more appropriate module.
|
|
|
|
if (
|
2024-01-29 22:17:17 +00:00
|
|
|
// T356117 - enable on all special pages - some special pages e.g. Special:Contribute have tabs.
|
|
|
|
$title->isSpecialPage() ||
|
|
|
|
( $this->isHistoryPage() && !$this->shouldUseSpecialHistory( $title ) ) ||
|
2024-03-23 17:20:57 +00:00
|
|
|
$this->skinOptions->get( SkinOptions::PERSONAL_MENU ) ||
|
|
|
|
$this->skinOptions->get( SkinOptions::TALK_AT_TOP ) ||
|
|
|
|
$this->skinOptions->get( SkinOptions::HISTORY_IN_PAGE_ACTIONS ) ||
|
|
|
|
$this->skinOptions->get( SkinOptions::TOOLBAR_SUBMENU )
|
2019-08-22 20:31:31 +00:00
|
|
|
) {
|
2021-10-19 18:45:43 +00:00
|
|
|
// SkinOptions::PERSONAL_MENU + SkinOptions::TOOLBAR_SUBMENU uses ToggleList
|
2019-08-22 20:31:31 +00:00
|
|
|
// SkinOptions::TALK_AT_TOP uses tabs.less
|
|
|
|
// SkinOptions::HISTORY_IN_PAGE_ACTIONS + SkinOptions::TOOLBAR_SUBMENU uses pageactions.less
|
2019-01-10 22:59:56 +00:00
|
|
|
$styles[] = 'skins.minerva.amc.styles';
|
2019-08-22 20:31:31 +00:00
|
|
|
}
|
|
|
|
|
2024-04-03 12:48:52 +00:00
|
|
|
return $styles;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Provide styles required to present the server rendered page with related features in this skin.
|
|
|
|
* Additional styles may be loaded dynamically by the client.
|
|
|
|
*
|
|
|
|
* Any styles returned by this method are loaded on the critical rendering path as linked
|
|
|
|
* stylesheets. I.e., they are required to load on the client before first paint.
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
protected function getFeatureSpecificStyles() {
|
|
|
|
$styles = [];
|
|
|
|
|
|
|
|
if ( $this->hasCategoryLinks() ) {
|
|
|
|
$styles[] = 'skins.minerva.categories.styles';
|
|
|
|
}
|
|
|
|
|
2024-03-23 17:20:57 +00:00
|
|
|
if ( $this->skinOptions->get( SkinOptions::PERSONAL_MENU ) ) {
|
2019-08-22 22:13:57 +00:00
|
|
|
// If ever enabled as the default, please remove the duplicate icons
|
|
|
|
// inside skins.minerva.mainMenu.icons. See comment for MAIN_MENU_EXPANDED
|
|
|
|
$styles[] = 'skins.minerva.personalMenu.icons';
|
|
|
|
}
|
|
|
|
|
2020-03-25 02:02:02 +00:00
|
|
|
if (
|
2024-03-23 17:20:57 +00:00
|
|
|
$this->skinOptions->get( SkinOptions::MAIN_MENU_EXPANDED )
|
2020-03-25 02:02:02 +00:00
|
|
|
) {
|
2019-08-22 22:13:57 +00:00
|
|
|
// If ever enabled as the default, please review skins.minerva.mainMenu.icons
|
|
|
|
// and remove any unneeded icons
|
|
|
|
$styles[] = 'skins.minerva.mainMenu.advanced.icons';
|
|
|
|
}
|
2024-04-03 12:48:52 +00:00
|
|
|
|
2019-08-22 20:31:31 +00:00
|
|
|
if (
|
2024-03-23 17:20:57 +00:00
|
|
|
$this->skinOptions->get( SkinOptions::PERSONAL_MENU ) ||
|
|
|
|
$this->skinOptions->get( SkinOptions::TOOLBAR_SUBMENU )
|
2019-08-22 20:31:31 +00:00
|
|
|
) {
|
|
|
|
// SkinOptions::PERSONAL_MENU requires the `userTalk` icon.
|
2020-03-25 02:02:02 +00:00
|
|
|
// SkinOptions::TOOLBAR_SUBMENU requires the rest of the icons including `overflow`.
|
2020-04-01 23:25:04 +00:00
|
|
|
// Note `skins.minerva.overflow.icons` is pulled down by skins.minerva.scripts but the menu can
|
2019-08-22 20:31:31 +00:00
|
|
|
// work without JS.
|
2020-04-01 23:25:04 +00:00
|
|
|
$styles[] = 'skins.minerva.overflow.icons';
|
2019-01-10 22:59:56 +00:00
|
|
|
}
|
2019-08-02 14:23:28 +00:00
|
|
|
|
2017-07-12 15:12:40 +00:00
|
|
|
return $styles;
|
|
|
|
}
|
|
|
|
}
|