2021-09-09 22:13:48 +00:00
|
|
|
<?php
|
2022-02-19 00:53:42 +00:00
|
|
|
|
2022-05-23 07:32:40 +00:00
|
|
|
namespace MediaWiki\Skins\Vector;
|
2022-02-19 00:53:42 +00:00
|
|
|
|
2023-01-07 00:51:14 +00:00
|
|
|
use ExtensionRegistry;
|
2022-10-27 16:09:12 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
2022-12-07 01:05:22 +00:00
|
|
|
use MediaWiki\Skins\Vector\Components\VectorComponentDropdown;
|
2023-01-06 01:45:38 +00:00
|
|
|
use MediaWiki\Skins\Vector\Components\VectorComponentIconLink;
|
2023-01-07 00:51:14 +00:00
|
|
|
use MediaWiki\Skins\Vector\Components\VectorComponentLanguageButton;
|
2022-12-16 18:03:07 +00:00
|
|
|
use MediaWiki\Skins\Vector\Components\VectorComponentLanguageDropdown;
|
2022-10-27 23:52:23 +00:00
|
|
|
use MediaWiki\Skins\Vector\Components\VectorComponentMainMenu;
|
2023-01-06 01:45:38 +00:00
|
|
|
use MediaWiki\Skins\Vector\Components\VectorComponentMenu;
|
|
|
|
use MediaWiki\Skins\Vector\Components\VectorComponentMenuListItem;
|
2023-01-07 01:08:39 +00:00
|
|
|
use MediaWiki\Skins\Vector\Components\VectorComponentMenuVariants;
|
2022-12-02 18:09:52 +00:00
|
|
|
use MediaWiki\Skins\Vector\Components\VectorComponentPageTools;
|
2023-01-06 01:21:22 +00:00
|
|
|
use MediaWiki\Skins\Vector\Components\VectorComponentPinnableContainer;
|
2022-10-27 16:11:32 +00:00
|
|
|
use MediaWiki\Skins\Vector\Components\VectorComponentSearchBox;
|
2022-12-07 00:42:31 +00:00
|
|
|
use MediaWiki\Skins\Vector\Components\VectorComponentStickyHeader;
|
|
|
|
use MediaWiki\Skins\Vector\Components\VectorComponentTableOfContents;
|
2023-01-06 01:21:22 +00:00
|
|
|
use MediaWiki\Skins\Vector\Components\VectorComponentTableOfContentsContainer;
|
2023-01-06 01:45:38 +00:00
|
|
|
use MediaWiki\Skins\Vector\Components\VectorComponentUserLinks;
|
2023-01-07 00:51:14 +00:00
|
|
|
use RuntimeException;
|
|
|
|
use SkinMustache;
|
|
|
|
use SkinTemplate;
|
2022-10-27 16:09:12 +00:00
|
|
|
|
2021-09-09 22:13:48 +00:00
|
|
|
/**
|
|
|
|
* @ingroup Skins
|
|
|
|
* @package Vector
|
|
|
|
* @internal
|
|
|
|
*/
|
2023-01-07 00:51:14 +00:00
|
|
|
class SkinVector22 extends SkinMustache {
|
2022-07-11 15:10:26 +00:00
|
|
|
private const STICKY_HEADER_ENABLED_CLASS = 'vector-sticky-header-enabled';
|
2023-01-07 00:51:14 +00:00
|
|
|
/** @var null|array for caching purposes */
|
|
|
|
private $languages;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
|
|
|
protected function runOnSkinTemplateNavigationHooks( SkinTemplate $skin, &$content_navigation ) {
|
|
|
|
parent::runOnSkinTemplateNavigationHooks( $skin, $content_navigation );
|
|
|
|
Hooks::onSkinTemplateNavigation( $skin, $content_navigation );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
|
|
|
public function isResponsive() {
|
|
|
|
// Check it's enabled by user preference and configuration
|
|
|
|
$responsive = parent::isResponsive() && $this->getConfig()->get( 'VectorResponsive' );
|
|
|
|
// For historic reasons, the viewport is added when Vector is loaded on the mobile
|
|
|
|
// domain. This is only possible for 3rd parties or by useskin parameter as there is
|
|
|
|
// no preference for changing mobile skin. Only need to check if $responsive is falsey.
|
|
|
|
if ( !$responsive && ExtensionRegistry::getInstance()->isLoaded( 'MobileFrontend' ) ) {
|
|
|
|
$mobFrontContext = MediaWikiServices::getInstance()->getService( 'MobileFrontend.Context' );
|
|
|
|
if ( $mobFrontContext->shouldDisplayMobileView() ) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $responsive;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This should be upstreamed to the Skin class in core once the logic is finalized.
|
|
|
|
* Returns false if the page is a special page without any languages, or if an action
|
|
|
|
* other than view is being used.
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
private function canHaveLanguages(): bool {
|
|
|
|
if ( $this->getContext()->getActionName() !== 'view' ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
$title = $this->getTitle();
|
|
|
|
// Defensive programming - if a special page has added languages explicitly, best to show it.
|
|
|
|
if ( $title && $title->isSpecialPage() && empty( $this->getLanguagesCached() ) ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $location Either 'top' or 'bottom' is accepted.
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
protected function isLanguagesInContentAt( $location ) {
|
|
|
|
if ( !$this->canHaveLanguages() ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
$featureManager = VectorServices::getFeatureManager();
|
|
|
|
$inContent = $featureManager->isFeatureEnabled(
|
|
|
|
Constants::FEATURE_LANGUAGE_IN_HEADER
|
|
|
|
);
|
|
|
|
$isMainPage = $this->getTitle() ? $this->getTitle()->isMainPage() : false;
|
|
|
|
|
|
|
|
switch ( $location ) {
|
|
|
|
case 'top':
|
|
|
|
return $isMainPage ? $inContent && $featureManager->isFeatureEnabled(
|
|
|
|
Constants::FEATURE_LANGUAGE_IN_MAIN_PAGE_HEADER
|
|
|
|
) : $inContent;
|
|
|
|
case 'bottom':
|
|
|
|
return $inContent && $isMainPage && !$featureManager->isFeatureEnabled(
|
|
|
|
Constants::FEATURE_LANGUAGE_IN_MAIN_PAGE_HEADER
|
|
|
|
);
|
|
|
|
default:
|
|
|
|
throw new RuntimeException( 'unknown language button location' );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether or not the languages are out of the sidebar and in the content either at
|
|
|
|
* the top or the bottom.
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
final protected function isLanguagesInContent() {
|
|
|
|
return $this->isLanguagesInContentAt( 'top' ) || $this->isLanguagesInContentAt( 'bottom' );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Calls getLanguages with caching.
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
protected function getLanguagesCached(): array {
|
|
|
|
if ( $this->languages === null ) {
|
|
|
|
$this->languages = $this->getLanguages();
|
|
|
|
}
|
|
|
|
return $this->languages;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check whether ULS is enabled
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
final protected function isULSExtensionEnabled(): bool {
|
|
|
|
return ExtensionRegistry::getInstance()->isLoaded( 'UniversalLanguageSelector' );
|
|
|
|
}
|
2022-03-17 23:02:39 +00:00
|
|
|
|
2022-10-27 21:18:53 +00:00
|
|
|
/**
|
|
|
|
* Show the ULS button if it's modern Vector, languages in header is enabled,
|
|
|
|
* and the ULS extension is enabled. Hide it otherwise.
|
|
|
|
* There is no point in showing the language button if ULS extension is unavailable
|
|
|
|
* as there is no ways to add languages without it.
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
protected function shouldHideLanguages(): bool {
|
|
|
|
return !$this->isLanguagesInContent() || !$this->isULSExtensionEnabled();
|
|
|
|
}
|
|
|
|
|
2022-10-27 19:36:08 +00:00
|
|
|
/**
|
|
|
|
* Determines if the language switching alert box should be in the sidebar.
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
private function shouldLanguageAlertBeInSidebar(): bool {
|
|
|
|
$featureManager = VectorServices::getFeatureManager();
|
|
|
|
$isMainPage = $this->getTitle() ? $this->getTitle()->isMainPage() : false;
|
|
|
|
$shouldShowOnMainPage = $isMainPage && !empty( $this->getLanguagesCached() ) &&
|
|
|
|
$featureManager->isFeatureEnabled( Constants::FEATURE_LANGUAGE_IN_MAIN_PAGE_HEADER );
|
|
|
|
return ( $this->isLanguagesInContentAt( 'top' ) && !$isMainPage && !$this->shouldHideLanguages() &&
|
|
|
|
$featureManager->isFeatureEnabled( Constants::FEATURE_LANGUAGE_ALERT_IN_SIDEBAR ) ) ||
|
|
|
|
$shouldShowOnMainPage;
|
|
|
|
}
|
|
|
|
|
2022-04-27 19:32:19 +00:00
|
|
|
/**
|
|
|
|
* Merges the `view-overflow` menu into the `action` menu.
|
|
|
|
* This ensures that the previous state of the menu e.g. emptyPortlet class
|
|
|
|
* is preserved.
|
|
|
|
* @param array $data
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
private function mergeViewOverflowIntoActions( $data ) {
|
|
|
|
$portlets = $data['data-portlets'];
|
|
|
|
$actions = $portlets['data-actions'];
|
|
|
|
$overflow = $portlets['data-views-overflow'];
|
2022-04-29 18:16:08 +00:00
|
|
|
// if the views overflow menu is not empty, then signal that the more menu despite
|
|
|
|
// being initially empty now has collapsible items.
|
|
|
|
if ( !$overflow['is-empty'] ) {
|
|
|
|
$data['data-portlets']['data-actions']['class'] .= ' vector-has-collapsible-items';
|
|
|
|
}
|
2022-04-27 19:32:19 +00:00
|
|
|
$data['data-portlets']['data-actions']['html-items'] = $overflow['html-items'] . $actions['html-items'];
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
2022-07-11 15:10:26 +00:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
|
|
|
public function getHtmlElementAttributes() {
|
|
|
|
$original = parent::getHtmlElementAttributes();
|
|
|
|
|
|
|
|
if ( VectorServices::getFeatureManager()->isFeatureEnabled( Constants::FEATURE_STICKY_HEADER ) ) {
|
|
|
|
// T290518: Add scroll padding to root element when the sticky header is
|
|
|
|
// enabled. This class needs to be server rendered instead of added from
|
|
|
|
// JS in order to correctly handle situations where the sticky header
|
|
|
|
// isn't visible yet but we still need scroll padding applied (e.g. when
|
|
|
|
// the user navigates to a page with a hash fragment in the URI). For this
|
|
|
|
// reason, we can't rely on the `vector-sticky-header-visible` class as it
|
|
|
|
// is added too late.
|
|
|
|
//
|
|
|
|
// Please note that this class applies scroll padding which does not work
|
|
|
|
// when applied to the body tag in Chrome, Safari, and Firefox (and
|
|
|
|
// possibly others). It must instead be applied to the html tag.
|
|
|
|
$original['class'] = implode( ' ', [ $original['class'] ?? '', self::STICKY_HEADER_ENABLED_CLASS ] );
|
|
|
|
}
|
|
|
|
|
|
|
|
return $original;
|
|
|
|
}
|
|
|
|
|
2022-10-27 16:09:12 +00:00
|
|
|
/**
|
|
|
|
* Determines wheather the initial state of sidebar is visible on not
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
private function isMainMenuVisible() {
|
|
|
|
$skin = $this->getSkin();
|
|
|
|
if ( $skin->getUser()->isRegistered() ) {
|
|
|
|
$userOptionsLookup = MediaWikiServices::getInstance()->getUserOptionsLookup();
|
|
|
|
$userPrefSidebarState = $userOptionsLookup->getOption(
|
|
|
|
$skin->getUser(),
|
|
|
|
Constants::PREF_KEY_SIDEBAR_VISIBLE
|
|
|
|
);
|
|
|
|
|
|
|
|
$defaultLoggedinSidebarState = $this->getConfig()->get(
|
|
|
|
Constants::CONFIG_KEY_DEFAULT_SIDEBAR_VISIBLE_FOR_AUTHORISED_USER
|
|
|
|
);
|
|
|
|
|
|
|
|
// If the sidebar user preference has been set, return that value,
|
|
|
|
// if not, then the default sidebar state for logged-in users.
|
|
|
|
return ( $userPrefSidebarState !== null )
|
|
|
|
? (bool)$userPrefSidebarState
|
|
|
|
: $defaultLoggedinSidebarState;
|
|
|
|
}
|
|
|
|
return $this->getConfig()->get(
|
|
|
|
Constants::CONFIG_KEY_DEFAULT_SIDEBAR_VISIBLE_FOR_ANONYMOUS_USER
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-01-05 20:02:40 +00:00
|
|
|
/**
|
|
|
|
* Pulls the page tools menu out of $sidebar into $pageToolsMenu
|
|
|
|
*
|
|
|
|
* @param array &$sidebar
|
|
|
|
* @param array &$pageToolsMenu
|
|
|
|
*/
|
|
|
|
private static function extractPageToolsFromSidebar( &$sidebar, &$pageToolsMenu ) {
|
|
|
|
$restPortlets = $sidebar[ 'array-portlets-rest' ] ?? [];
|
|
|
|
$toolboxMenuIndex = array_search(
|
|
|
|
VectorComponentPageTools::TOOLBOX_ID,
|
|
|
|
array_column(
|
|
|
|
$restPortlets,
|
|
|
|
'id'
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
if ( $toolboxMenuIndex !== false ) {
|
|
|
|
// Splice removes the toolbox menu from the $restPortlets array
|
|
|
|
// and current returns the first value of array_splice, i.e. the $toolbox menu data.
|
|
|
|
$pageToolsMenu = array_splice( $restPortlets, $toolboxMenuIndex );
|
|
|
|
$sidebar['array-portlets-rest'] = $restPortlets;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-07 00:51:14 +00:00
|
|
|
/**
|
|
|
|
* Get the ULS button label, accounting for the number of available
|
|
|
|
* languages.
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
final protected function getULSLabels(): array {
|
|
|
|
$numLanguages = count( $this->getLanguagesCached() );
|
|
|
|
|
|
|
|
if ( $numLanguages === 0 ) {
|
|
|
|
return [
|
|
|
|
'label' => $this->msg( 'vector-no-language-button-label' )->text(),
|
|
|
|
'aria-label' => $this->msg( 'vector-no-language-button-aria-label' )->text()
|
|
|
|
];
|
|
|
|
} else {
|
|
|
|
return [
|
|
|
|
'label' => $this->msg( 'vector-language-button-label' )->numParams( $numLanguages )->escaped(),
|
|
|
|
'aria-label' => $this->msg( 'vector-language-button-aria-label' )->numParams( $numLanguages )->escaped()
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-19 00:53:42 +00:00
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getTemplateData(): array {
|
2022-04-01 15:53:03 +00:00
|
|
|
$featureManager = VectorServices::getFeatureManager();
|
|
|
|
$parentData = parent::getTemplateData();
|
2023-01-06 01:21:22 +00:00
|
|
|
$localizer = $this->getContext();
|
2022-04-27 19:32:19 +00:00
|
|
|
$parentData = $this->mergeViewOverflowIntoActions( $parentData );
|
2023-01-06 01:45:38 +00:00
|
|
|
$portlets = $parentData['data-portlets'];
|
2022-04-27 19:32:19 +00:00
|
|
|
|
2022-10-27 23:46:19 +00:00
|
|
|
$langData = $parentData['data-portlets']['data-languages'] ?? null;
|
2022-12-13 20:28:22 +00:00
|
|
|
$config = $this->getConfig();
|
|
|
|
|
2022-11-08 19:55:23 +00:00
|
|
|
$isPageToolsEnabled = $featureManager->isFeatureEnabled( Constants::FEATURE_PAGE_TOOLS );
|
2022-12-02 18:09:52 +00:00
|
|
|
$sidebar = $parentData[ 'data-portlets-sidebar' ];
|
2023-01-05 20:02:40 +00:00
|
|
|
$pageToolsMenu = [];
|
2022-11-08 19:55:23 +00:00
|
|
|
if ( $isPageToolsEnabled ) {
|
2023-01-05 20:02:40 +00:00
|
|
|
self::extractPageToolsFromSidebar( $sidebar, $pageToolsMenu );
|
2022-12-02 18:09:52 +00:00
|
|
|
}
|
2022-12-13 20:28:22 +00:00
|
|
|
|
2022-12-16 18:03:07 +00:00
|
|
|
$langButtonClass = $langData['class'] ?? '';
|
|
|
|
$ulsLabels = $this->getULSLabels();
|
2023-01-06 01:45:38 +00:00
|
|
|
$returnto = $this->getReturnToParam();
|
|
|
|
$user = $this->getUser();
|
|
|
|
$logoutData = $this->buildLogoutLinkData();
|
|
|
|
$loginLinkData = $this->buildLoginData( $returnto, $this->useCombinedLoginLink() );
|
|
|
|
$createAccountData = $this->buildCreateAccountData( $returnto );
|
2023-01-07 00:51:14 +00:00
|
|
|
$localizer = $this->getContext();
|
2023-01-12 21:44:54 +00:00
|
|
|
$tocData = $parentData['data-toc'];
|
|
|
|
// If the table of contents has no items, we won't output it.
|
|
|
|
// empty array is interpreted by Mustache as falsey.
|
|
|
|
$isTocUnavailable = empty( $tocData ) || empty( $tocData[ 'array-sections' ] );
|
2022-10-27 19:36:08 +00:00
|
|
|
$components = [
|
2023-01-07 01:08:39 +00:00
|
|
|
'data-vector-variants' => new VectorComponentMenuVariants(
|
|
|
|
$parentData['data-portlets']['data-variants'],
|
|
|
|
$this->getTitle()->getPageLanguage(),
|
|
|
|
$this->msg( 'vector-language-variant-switcher-label' )
|
|
|
|
),
|
2023-01-06 01:45:38 +00:00
|
|
|
'data-vector-user-links' => new VectorComponentUserLinks(
|
2023-01-07 00:51:14 +00:00
|
|
|
$localizer,
|
2023-01-06 01:45:38 +00:00
|
|
|
$user,
|
|
|
|
new VectorComponentMenu(
|
|
|
|
$portlets['data-user-menu']
|
|
|
|
),
|
|
|
|
new VectorComponentMenu( [
|
|
|
|
// this menu should have no label
|
|
|
|
'label' => '',
|
|
|
|
] + $portlets[ 'data-vector-user-menu-overflow' ] ),
|
|
|
|
new VectorComponentMenu(
|
|
|
|
[],
|
|
|
|
$user->isRegistered() ? [
|
|
|
|
new VectorComponentMenuListItem(
|
|
|
|
new VectorComponentIconLink(
|
|
|
|
$logoutData[ 'href'],
|
|
|
|
$logoutData[ 'text' ],
|
|
|
|
$logoutData[ 'icon' ],
|
|
|
|
$this,
|
|
|
|
'pt-logout'
|
|
|
|
),
|
|
|
|
'vector-user-menu-logout',
|
|
|
|
'pt-logout'
|
|
|
|
)
|
|
|
|
] : [
|
|
|
|
new VectorComponentMenuListItem(
|
|
|
|
new VectorComponentIconLink(
|
|
|
|
$createAccountData['href'] ?? null,
|
|
|
|
$createAccountData['text'] ?? null,
|
|
|
|
$createAccountData['icon'] ?? null,
|
|
|
|
$this,
|
|
|
|
'create-account'
|
|
|
|
),
|
|
|
|
'vector-user-menu-create-account user-links-collapsible-item'
|
|
|
|
),
|
|
|
|
new VectorComponentMenuListItem(
|
|
|
|
new VectorComponentIconLink(
|
|
|
|
$loginLinkData['href'] ?? null,
|
|
|
|
$loginLinkData['text'] ?? null,
|
|
|
|
$loginLinkData['icon'] ?? null,
|
|
|
|
$this,
|
|
|
|
'login'
|
|
|
|
),
|
|
|
|
'vector-user-menu-login'
|
|
|
|
)
|
|
|
|
]
|
|
|
|
),
|
|
|
|
),
|
2022-12-16 18:03:07 +00:00
|
|
|
'data-lang-btn' => $langData ? new VectorComponentLanguageDropdown(
|
|
|
|
$ulsLabels['label'],
|
|
|
|
$ulsLabels['aria-label'],
|
|
|
|
$this->isLanguagesInContentAt( 'top' ) ?
|
|
|
|
$langButtonClass . ' mw-ui-icon-flush-right' : $langButtonClass,
|
|
|
|
count( $this->getLanguagesCached() ),
|
|
|
|
$langData['html-items'] ?? '',
|
|
|
|
$langData['html-before-portal'] ?? '',
|
2022-12-19 15:57:48 +00:00
|
|
|
$langData['html-after-portal'] ?? '',
|
|
|
|
$this->getTitle()
|
2022-12-16 18:03:07 +00:00
|
|
|
) : null,
|
2023-01-12 21:44:54 +00:00
|
|
|
'data-toc-container' => $isTocUnavailable ? null : new VectorComponentTableOfContentsContainer(
|
2023-01-06 01:21:22 +00:00
|
|
|
$localizer,
|
|
|
|
),
|
2023-01-12 21:44:54 +00:00
|
|
|
'data-toc' => $isTocUnavailable ? null : new VectorComponentTableOfContents(
|
|
|
|
$tocData,
|
2023-01-06 01:21:22 +00:00
|
|
|
$localizer,
|
2023-01-05 20:02:40 +00:00
|
|
|
$this->getConfig()
|
|
|
|
),
|
|
|
|
'data-search-box' => new VectorComponentSearchBox(
|
|
|
|
$parentData['data-search-box'],
|
|
|
|
true,
|
|
|
|
// is primary mode of search
|
|
|
|
true,
|
|
|
|
'searchform',
|
|
|
|
true,
|
|
|
|
$config,
|
|
|
|
Constants::SEARCH_BOX_INPUT_LOCATION_MOVED,
|
2023-01-07 00:51:14 +00:00
|
|
|
$localizer
|
2023-01-05 20:02:40 +00:00
|
|
|
),
|
|
|
|
'data-main-menu' => new VectorComponentMainMenu(
|
|
|
|
$sidebar,
|
|
|
|
$this->shouldLanguageAlertBeInSidebar(),
|
|
|
|
$parentData['data-portlets']['data-languages'] ?? [],
|
2023-01-07 00:51:14 +00:00
|
|
|
$localizer,
|
2023-01-05 20:02:40 +00:00
|
|
|
$this->getUser(),
|
|
|
|
VectorServices::getFeatureManager(),
|
|
|
|
$this,
|
|
|
|
),
|
|
|
|
'data-main-menu-dropdown' => new VectorComponentDropdown(
|
|
|
|
VectorComponentMainMenu::ID . '-dropdown',
|
|
|
|
$this->msg( VectorComponentMainMenu::ID . '-label' )->text(),
|
|
|
|
VectorComponentMainMenu::ID . '-dropdown' . ' mw-ui-icon-flush-left mw-ui-icon-flush-right',
|
|
|
|
'menu'
|
|
|
|
),
|
|
|
|
'data-page-tools' => $isPageToolsEnabled ? new VectorComponentPageTools(
|
|
|
|
array_merge( [ $parentData['data-portlets']['data-actions'] ?? [] ], $pageToolsMenu ),
|
2023-01-07 00:51:14 +00:00
|
|
|
$localizer,
|
2023-01-05 20:02:40 +00:00
|
|
|
$this->getUser(),
|
|
|
|
$featureManager
|
|
|
|
) : null,
|
|
|
|
'data-page-tools-dropdown' => $isPageToolsEnabled ? new VectorComponentDropdown(
|
|
|
|
VectorComponentPageTools::ID . '-dropdown',
|
|
|
|
$this->msg( 'toolbox' )->text(),
|
|
|
|
VectorComponentPageTools::ID . '-dropdown',
|
|
|
|
) : null,
|
2023-01-12 21:44:54 +00:00
|
|
|
'data-page-titlebar-toc-dropdown' => $isTocUnavailable ? null : new VectorComponentDropdown(
|
2023-01-06 01:21:22 +00:00
|
|
|
'vector-page-titlebar-toc',
|
|
|
|
// no label,
|
|
|
|
'',
|
|
|
|
// class
|
|
|
|
'vector-page-titlebar-toc mw-ui-icon-flush-left',
|
|
|
|
// icon
|
|
|
|
'listBullet',
|
|
|
|
),
|
|
|
|
'data-page-titlebar-pinnable-container' => new VectorComponentPinnableContainer(
|
|
|
|
'vector-page-titlebar-toc',
|
|
|
|
true
|
|
|
|
),
|
2023-01-07 00:51:14 +00:00
|
|
|
'data-vector-sticky-header' => $featureManager->isFeatureEnabled(
|
|
|
|
Constants::FEATURE_STICKY_HEADER
|
|
|
|
) ? new VectorComponentStickyHeader(
|
|
|
|
$localizer,
|
|
|
|
new VectorComponentSearchBox(
|
|
|
|
$parentData['data-search-box'],
|
|
|
|
// Collapse inside search box is disabled.
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
'vector-sticky-search-form',
|
|
|
|
false,
|
|
|
|
$config,
|
|
|
|
Constants::SEARCH_BOX_INPUT_LOCATION_MOVED,
|
|
|
|
$localizer
|
|
|
|
),
|
|
|
|
// Show sticky ULS if the ULS extension is enabled and the ULS in header is not hidden
|
|
|
|
$this->isULSExtensionEnabled() && !$this->shouldHideLanguages() ?
|
|
|
|
new VectorComponentLanguageButton( $ulsLabels[ 'label' ] ) : null,
|
|
|
|
$featureManager->isFeatureEnabled(
|
|
|
|
Constants::FEATURE_STICKY_HEADER_EDIT
|
|
|
|
)
|
|
|
|
) : null
|
2022-10-27 19:36:08 +00:00
|
|
|
];
|
|
|
|
foreach ( $components as $key => $component ) {
|
|
|
|
// Array of components or null values.
|
|
|
|
if ( $component ) {
|
|
|
|
$parentData[$key] = $component->getTemplateData();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-25 20:13:58 +00:00
|
|
|
return array_merge( $parentData, [
|
2022-10-27 21:18:53 +00:00
|
|
|
'is-language-in-content' => $this->isLanguagesInContent(),
|
|
|
|
'is-language-in-content-top' => $this->isLanguagesInContentAt( 'top' ),
|
|
|
|
'is-language-in-content-bottom' => $this->isLanguagesInContentAt( 'bottom' ),
|
2022-10-27 16:09:12 +00:00
|
|
|
'is-main-menu-visible' => $this->isMainMenuVisible(),
|
2022-07-25 20:13:58 +00:00
|
|
|
// Cast empty string to null
|
|
|
|
'html-subtitle' => $parentData['html-subtitle'] === '' ? null : $parentData['html-subtitle'],
|
2022-11-08 19:55:23 +00:00
|
|
|
'is-page-tools-enabled' => $isPageToolsEnabled
|
2022-07-25 20:13:58 +00:00
|
|
|
] );
|
2022-02-19 00:53:42 +00:00
|
|
|
}
|
2021-09-09 22:13:48 +00:00
|
|
|
}
|