mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-12 08:58:25 +00:00
Merge "Add hook to override SkinOptions, and allow overriding tabs output"
This commit is contained in:
commit
7bd31a1ef9
|
@ -234,9 +234,12 @@ class MinervaHooks {
|
|||
SkinOptions::OPTION_OVERFLOW_SUBMENU => $featureManager->isFeatureAvailableForCurrentUser(
|
||||
self::FEATURE_OVERFLOW_PAGE_ACTIONS
|
||||
),
|
||||
SkinOptions::OPTION_TABS_ON_SPECIALS => false,
|
||||
] );
|
||||
Hooks::run( 'SkinMinervaOptionsInit', [ $skin, $skinOptions ] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ResourceLoaderGetConfigVars hook handler.
|
||||
* Used for setting JS variables which are pulled in dynamically with RL
|
||||
|
|
|
@ -35,6 +35,7 @@ final class SkinOptions {
|
|||
const OPTIONS_TALK_AT_TOP = 'talkAtTop';
|
||||
const OPTIONS_HISTORY_PAGE_ACTIONS = 'historyInPageActions';
|
||||
const OPTION_OVERFLOW_SUBMENU = 'overflowSubmenu';
|
||||
const OPTION_TABS_ON_SPECIALS = 'tabsOnSpecials';
|
||||
|
||||
/** @var array skin specific options */
|
||||
private $skinOptions = [
|
||||
|
|
|
@ -229,9 +229,7 @@ class MinervaTemplate extends BaseTemplate {
|
|||
$internalBanner = $data[ 'internalBanner' ];
|
||||
$preBodyHtml = isset( $data['prebodyhtml'] ) ? $data['prebodyhtml'] : '';
|
||||
$hasHeadingHolder = $internalBanner || $preBodyHtml || isset( $data['page_actions'] );
|
||||
$hasPageActions = !$this->isSpecialPage && !$this->isMainPage &&
|
||||
Action::getActionName( RequestContext::getMain() ) === 'view';
|
||||
$hasTalkTabs = $hasPageActions && !$this->isMainPageTalk;
|
||||
$hasPageActions = $this->hasPageActions( $data['skin']->getContext() );
|
||||
|
||||
// prepare template data
|
||||
$templateData = [
|
||||
|
@ -268,7 +266,8 @@ class MinervaTemplate extends BaseTemplate {
|
|||
'secondaryactionshtml' => $this->getSecondaryActionsHtml(),
|
||||
'footer' => $this->getFooterTemplateData( $data ),
|
||||
'isBeta' => $skinOptions->get( SkinOptions::OPTIONS_MOBILE_BETA ),
|
||||
'tabs' => $hasTalkTabs && $skinOptions->get( SkinOptions::OPTIONS_TALK_AT_TOP ) ? [
|
||||
'tabs' => $this->showTalkTabs( $hasPageActions, $skinOptions ) &&
|
||||
$skinOptions->get( SkinOptions::OPTIONS_TALK_AT_TOP ) ? [
|
||||
'items' => array_values( $data['content_navigation']['namespaces'] ),
|
||||
] : false,
|
||||
];
|
||||
|
@ -280,4 +279,27 @@ class MinervaTemplate extends BaseTemplate {
|
|||
</html>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* @param IContextSource $context
|
||||
* @return bool
|
||||
*/
|
||||
private function hasPageActions( IContextSource $context ) {
|
||||
return !$this->isSpecialPage && !$this->isMainPage &&
|
||||
Action::getActionName( $context ) === 'view';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $hasPageActions
|
||||
* @param SkinOptions $skinOptions
|
||||
* @return bool
|
||||
*/
|
||||
private function showTalkTabs( $hasPageActions, SkinOptions $skinOptions ) {
|
||||
$hasTalkTabs = $hasPageActions && !$this->isMainPageTalk;
|
||||
if ( !$hasTalkTabs && $this->isSpecialPage &&
|
||||
$skinOptions->get( SkinOptions::OPTION_TABS_ON_SPECIALS ) ) {
|
||||
$hasTalkTabs = true;
|
||||
}
|
||||
return $hasTalkTabs;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue