mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-13 17:37:07 +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(
|
SkinOptions::OPTION_OVERFLOW_SUBMENU => $featureManager->isFeatureAvailableForCurrentUser(
|
||||||
self::FEATURE_OVERFLOW_PAGE_ACTIONS
|
self::FEATURE_OVERFLOW_PAGE_ACTIONS
|
||||||
),
|
),
|
||||||
|
SkinOptions::OPTION_TABS_ON_SPECIALS => false,
|
||||||
] );
|
] );
|
||||||
|
Hooks::run( 'SkinMinervaOptionsInit', [ $skin, $skinOptions ] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ResourceLoaderGetConfigVars hook handler.
|
* ResourceLoaderGetConfigVars hook handler.
|
||||||
* Used for setting JS variables which are pulled in dynamically with RL
|
* 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_TALK_AT_TOP = 'talkAtTop';
|
||||||
const OPTIONS_HISTORY_PAGE_ACTIONS = 'historyInPageActions';
|
const OPTIONS_HISTORY_PAGE_ACTIONS = 'historyInPageActions';
|
||||||
const OPTION_OVERFLOW_SUBMENU = 'overflowSubmenu';
|
const OPTION_OVERFLOW_SUBMENU = 'overflowSubmenu';
|
||||||
|
const OPTION_TABS_ON_SPECIALS = 'tabsOnSpecials';
|
||||||
|
|
||||||
/** @var array skin specific options */
|
/** @var array skin specific options */
|
||||||
private $skinOptions = [
|
private $skinOptions = [
|
||||||
|
|
|
@ -229,9 +229,7 @@ class MinervaTemplate extends BaseTemplate {
|
||||||
$internalBanner = $data[ 'internalBanner' ];
|
$internalBanner = $data[ 'internalBanner' ];
|
||||||
$preBodyHtml = isset( $data['prebodyhtml'] ) ? $data['prebodyhtml'] : '';
|
$preBodyHtml = isset( $data['prebodyhtml'] ) ? $data['prebodyhtml'] : '';
|
||||||
$hasHeadingHolder = $internalBanner || $preBodyHtml || isset( $data['page_actions'] );
|
$hasHeadingHolder = $internalBanner || $preBodyHtml || isset( $data['page_actions'] );
|
||||||
$hasPageActions = !$this->isSpecialPage && !$this->isMainPage &&
|
$hasPageActions = $this->hasPageActions( $data['skin']->getContext() );
|
||||||
Action::getActionName( RequestContext::getMain() ) === 'view';
|
|
||||||
$hasTalkTabs = $hasPageActions && !$this->isMainPageTalk;
|
|
||||||
|
|
||||||
// prepare template data
|
// prepare template data
|
||||||
$templateData = [
|
$templateData = [
|
||||||
|
@ -268,7 +266,8 @@ class MinervaTemplate extends BaseTemplate {
|
||||||
'secondaryactionshtml' => $this->getSecondaryActionsHtml(),
|
'secondaryactionshtml' => $this->getSecondaryActionsHtml(),
|
||||||
'footer' => $this->getFooterTemplateData( $data ),
|
'footer' => $this->getFooterTemplateData( $data ),
|
||||||
'isBeta' => $skinOptions->get( SkinOptions::OPTIONS_MOBILE_BETA ),
|
'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'] ),
|
'items' => array_values( $data['content_navigation']['namespaces'] ),
|
||||||
] : false,
|
] : false,
|
||||||
];
|
];
|
||||||
|
@ -280,4 +279,27 @@ class MinervaTemplate extends BaseTemplate {
|
||||||
</html>
|
</html>
|
||||||
<?php
|
<?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