mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-27 23:50:30 +00:00
Merge "Remove MinervaTemplate::getSecondaryActions"
This commit is contained in:
commit
2a60efef79
|
@ -65,51 +65,6 @@ class MinervaTemplate extends BaseTemplate {
|
|||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function isFallbackEditor() {
|
||||
$action = $this->getSkin()->getRequest()->getVal( 'action' );
|
||||
return $action === 'edit';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get page secondary actions
|
||||
* @return array
|
||||
*/
|
||||
protected function getSecondaryActions() {
|
||||
if ( $this->isFallbackEditor() ) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $this->data['secondary_actions'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get HTML representing secondary page actions like language selector
|
||||
* @return string
|
||||
*/
|
||||
protected function getSecondaryActionsHtml() {
|
||||
$baseClass = MinervaUI::buttonClass( '', 'button' );
|
||||
/** @var SkinMinerva $skin */
|
||||
$skin = $this->getSkin();
|
||||
$html = '';
|
||||
// no secondary actions on the user page
|
||||
if ( $skin instanceof SkinMinerva && !$skin->getUserPageHelper()->isUserPage() ) {
|
||||
foreach ( $this->getSecondaryActions() as $el ) {
|
||||
if ( isset( $el['attributes']['class'] ) ) {
|
||||
$el['attributes']['class'] .= ' ' . $baseClass;
|
||||
} else {
|
||||
$el['attributes']['class'] = $baseClass;
|
||||
}
|
||||
// @phan-suppress-next-line PhanTypeMismatchArgument
|
||||
$html .= Html::element( 'a', $el['attributes'], $el['label'] );
|
||||
}
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the main menu HTML.
|
||||
* @param array $data Data used to build the page
|
||||
|
@ -139,7 +94,6 @@ class MinervaTemplate extends BaseTemplate {
|
|||
'headinghtml' => $data['headinghtml'] ?? '',
|
||||
'postheadinghtml' => $data['postheadinghtml'] ?? '',
|
||||
'userMenuHTML' => $data['userMenuHTML'],
|
||||
'secondaryactionshtml' => $this->getSecondaryActionsHtml(),
|
||||
|
||||
'html-minerva-lastmodified' => $this->getHistoryLinkHtml( $data ),
|
||||
// Note mobile-license is only available on the mobile skin. It is outputted as part of
|
||||
|
|
|
@ -31,8 +31,8 @@ use MediaWiki\Minerva\Skins\SkinUserPageHelper;
|
|||
* @ingroup Skins
|
||||
*/
|
||||
class SkinMinerva extends SkinMustache {
|
||||
/** @var array|null Cached array of content navigation URLs */
|
||||
private $contentNavigationUrls = null;
|
||||
/** @var array Cached array of content navigation URLs */
|
||||
private $contentNavigationUrls = [];
|
||||
/** @var array|null cached array of page action URLs */
|
||||
private $pageActionsMenu = null;
|
||||
|
||||
|
@ -75,6 +75,13 @@ class SkinMinerva extends SkinMustache {
|
|||
Action::getActionName( $this->getContext() ) === 'view';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
private function hasSecondaryActions() {
|
||||
return !$this->getUserPageHelper()->isUserPage();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
|
@ -127,6 +134,7 @@ class SkinMinerva extends SkinMustache {
|
|||
'data-minerva-tabs' => $this->getTabsData(),
|
||||
'html-minerva-page-actions' => $this->getPageActionsHtml(),
|
||||
'html-minerva-subject-link' => $this->getSubjectPage(),
|
||||
'data-minerva-secondary-actions' => $this->hasSecondaryActions() ? $this->getSecondaryActions() : [],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -212,9 +220,6 @@ class SkinMinerva extends SkinMustache {
|
|||
// Generate skin template
|
||||
$tpl = parent::prepareQuickTemplate();
|
||||
|
||||
// Set the links for page secondary actions
|
||||
$tpl->set( 'secondary_actions', $this->getSecondaryActions( $tpl ) );
|
||||
|
||||
// Construct various Minerva-specific interface elements
|
||||
$this->prepareMenus( $tpl );
|
||||
$this->prepareHeaderAndFooter( $tpl );
|
||||
|
@ -733,10 +738,13 @@ class SkinMinerva extends SkinMustache {
|
|||
|
||||
/**
|
||||
* Returns an array of links for page secondary actions
|
||||
* @param BaseTemplate $tpl
|
||||
* @return array
|
||||
*/
|
||||
protected function getSecondaryActions( BaseTemplate $tpl ) {
|
||||
protected function getSecondaryActions() {
|
||||
if ( $this->isFallbackEditor() ) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$services = MediaWikiServices::getInstance();
|
||||
$skinOptions = $this->getSkinOptions();
|
||||
$namespaceInfo = $services->getNamespaceInfo();
|
||||
|
@ -757,7 +765,7 @@ class SkinMinerva extends SkinMustache {
|
|||
$this->getUser()->isRegistered() &&
|
||||
!$this->isTalkPageWithViewAction()
|
||||
) {
|
||||
$namespaces = $tpl->data['content_navigation']['namespaces'];
|
||||
$namespaces = $this->contentNavigationUrls['namespaces'];
|
||||
// FIXME [core]: This seems unnecessary..
|
||||
$subjectId = $title->getNamespaceKey( '' );
|
||||
$talkId = $subjectId === 'main' ? 'talk' : "{$subjectId}_talk";
|
||||
|
|
|
@ -75,7 +75,18 @@
|
|||
{{{html-minerva-subject-link}}}
|
||||
</div>
|
||||
<div class="post-content" id="page-secondary-actions">
|
||||
{{{secondaryactionshtml}}}
|
||||
{{#data-minerva-secondary-actions}}
|
||||
{{#talk}}
|
||||
<a {{#attributes}} href="{{href}}" data-title="{{data-title}}" class="{{class}} mw-ui-button button"{{/attributes}}>
|
||||
{{{label}}}
|
||||
</a>
|
||||
{{/talk}}
|
||||
{{#language}}
|
||||
<a {{#attributes}} href="{{href}}" data-title="{{data-title}}" class="{{class}} mw-ui-button button"{{/attributes}}>
|
||||
{{{label}}}
|
||||
</a>
|
||||
{{/language}}
|
||||
{{/data-minerva-secondary-actions}}
|
||||
</div>
|
||||
{{#html-categories}}
|
||||
<div class="post-content">{{{.}}}</div>
|
||||
|
|
Loading…
Reference in a new issue