mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-24 22:25:27 +00:00
Hygiene: remove deprecated calls from MinervaSkin and MinervaTemplate
Changes: - Title::getTalkPage() is deprecated, use NamespaceInfo instead - Title::getSubjectPage() is deprecated, use NamespaceInfo instead Note: NamespaceInfo returns LinkTarget instance, but most of our logic is wrapped around Titles, that's why we need to call Title::newFromLinkTarget() to be sure that we got Title object. Change-Id: Ibf2237ea369b0cee67ab5f623bdddcd9058eec3e
This commit is contained in:
parent
d8de612e0c
commit
ec77b3ab25
|
@ -45,7 +45,10 @@ class MinervaTemplate extends BaseTemplate {
|
||||||
$this->isSpecialMobileMenuPage = $this->isSpecialPage &&
|
$this->isSpecialMobileMenuPage = $this->isSpecialPage &&
|
||||||
$title->isSpecial( 'MobileMenu' );
|
$title->isSpecial( 'MobileMenu' );
|
||||||
$this->isMainPage = $title->isMainPage();
|
$this->isMainPage = $title->isMainPage();
|
||||||
$this->isMainPageTalk = $title->getSubjectPage()->isMainPage();
|
$subjectPage = MediaWikiServices::getInstance()->getNamespaceInfo()
|
||||||
|
->getSubjectPage( $title );
|
||||||
|
|
||||||
|
$this->isMainPageTalk = Title::newFromLinkTarget( $subjectPage )->isMainPage();
|
||||||
Hooks::run( 'MinervaPreRender', [ $this ] );
|
Hooks::run( 'MinervaPreRender', [ $this ] );
|
||||||
$this->render( $this->data );
|
$this->render( $this->data );
|
||||||
}
|
}
|
||||||
|
|
|
@ -190,6 +190,7 @@ class SkinMinerva extends SkinTemplate {
|
||||||
* @param QuickTemplate $tpl
|
* @param QuickTemplate $tpl
|
||||||
*/
|
*/
|
||||||
protected function preparePageContent( QuickTemplate $tpl ) {
|
protected function preparePageContent( QuickTemplate $tpl ) {
|
||||||
|
$services = MediaWikiServices::getInstance();
|
||||||
$title = $this->getTitle();
|
$title = $this->getTitle();
|
||||||
|
|
||||||
// If it's a talk page, add a link to the main namespace page
|
// If it's a talk page, add a link to the main namespace page
|
||||||
|
@ -210,8 +211,10 @@ class SkinMinerva extends SkinTemplate {
|
||||||
default: // generic (all other NS)
|
default: // generic (all other NS)
|
||||||
$msg = 'mobile-frontend-talk-back-to-page';
|
$msg = 'mobile-frontend-talk-back-to-page';
|
||||||
}
|
}
|
||||||
|
$subjectPage = $services->getNamespaceInfo()->getSubjectPage( $title );
|
||||||
|
|
||||||
$tpl->set( 'subject-page', MediaWikiServices::getInstance()->getLinkRenderer()->makeLink(
|
$tpl->set( 'subject-page', MediaWikiServices::getInstance()->getLinkRenderer()->makeLink(
|
||||||
$title->getSubjectPage(),
|
$subjectPage,
|
||||||
$this->msg( $msg, $title->getText() )->text(),
|
$this->msg( $msg, $title->getText() )->text(),
|
||||||
[ 'class' => 'return-link' ]
|
[ 'class' => 'return-link' ]
|
||||||
) );
|
) );
|
||||||
|
@ -722,15 +725,16 @@ class SkinMinerva extends SkinTemplate {
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function getSecondaryActions( BaseTemplate $tpl ) {
|
protected function getSecondaryActions( BaseTemplate $tpl ) {
|
||||||
|
$services = MediaWikiServices::getInstance();
|
||||||
|
$namespaceInfo = $services->getNamespaceInfo();
|
||||||
/** @var \MediaWiki\Minerva\LanguagesHelper $languagesHelper */
|
/** @var \MediaWiki\Minerva\LanguagesHelper $languagesHelper */
|
||||||
$languagesHelper = MediaWikiServices::getInstance()
|
$languagesHelper = $services->getService( 'Minerva.LanguagesHelper' );
|
||||||
->getService( 'Minerva.LanguagesHelper' );
|
|
||||||
$buttons = [];
|
$buttons = [];
|
||||||
// always add a button to link to the talk page
|
// always add a button to link to the talk page
|
||||||
// in beta it will be the entry point for the talk overlay feature,
|
// in beta it will be the entry point for the talk overlay feature,
|
||||||
// in stable it will link to the wikitext talk page
|
// in stable it will link to the wikitext talk page
|
||||||
$title = $this->getTitle();
|
$title = $this->getTitle();
|
||||||
$subjectPage = $title->getSubjectPage();
|
$subjectPage = Title::newFromLinkTarget( $namespaceInfo->getSubjectPage( $title ) );
|
||||||
$talkAtBottom = !$this->skinOptions->get( SkinOptions::TALK_AT_TOP ) ||
|
$talkAtBottom = !$this->skinOptions->get( SkinOptions::TALK_AT_TOP ) ||
|
||||||
$subjectPage->isMainPage();
|
$subjectPage->isMainPage();
|
||||||
$namespaces = $tpl->data['content_navigation']['namespaces'];
|
$namespaces = $tpl->data['content_navigation']['namespaces'];
|
||||||
|
@ -743,7 +747,8 @@ class SkinMinerva extends SkinTemplate {
|
||||||
|
|
||||||
if ( isset( $namespaces[$talkId] ) ) {
|
if ( isset( $namespaces[$talkId] ) ) {
|
||||||
$talkButton = $namespaces[$talkId];
|
$talkButton = $namespaces[$talkId];
|
||||||
$talkTitle = $title->getTalkPage();
|
$talkTitle = Title::newFromLinkTarget( $namespaceInfo->getTalkPage( $title ) );
|
||||||
|
|
||||||
if ( $title->isTalkPage() ) {
|
if ( $title->isTalkPage() ) {
|
||||||
$talkButton['text'] = wfMessage( 'minerva-talk-add-topic' );
|
$talkButton['text'] = wfMessage( 'minerva-talk-add-topic' );
|
||||||
$buttons['talk'] = $this->getTalkButton( $title, $talkButton, true );
|
$buttons['talk'] = $this->getTalkButton( $title, $talkButton, true );
|
||||||
|
@ -813,7 +818,8 @@ class SkinMinerva extends SkinTemplate {
|
||||||
protected function isWikiTextTalkPage() {
|
protected function isWikiTextTalkPage() {
|
||||||
$title = $this->getTitle();
|
$title = $this->getTitle();
|
||||||
if ( !$title->isTalkPage() ) {
|
if ( !$title->isTalkPage() ) {
|
||||||
$title = $title->getTalkPage();
|
$namespaceInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
|
||||||
|
$title = Title::newFromLinkTarget( $namespaceInfo->getTalkPage( $title ) );
|
||||||
}
|
}
|
||||||
return $title->isWikitextPage();
|
return $title->isWikitextPage();
|
||||||
}
|
}
|
||||||
|
@ -824,7 +830,6 @@ class SkinMinerva extends SkinTemplate {
|
||||||
*/
|
*/
|
||||||
public function getContextSpecificModules() {
|
public function getContextSpecificModules() {
|
||||||
$modules = [];
|
$modules = [];
|
||||||
$user = $this->getUser();
|
|
||||||
$title = $this->getTitle();
|
$title = $this->getTitle();
|
||||||
|
|
||||||
if ( $this->getPermissions()->isAllowed( IMinervaPagePermissions::WATCH ) ) {
|
if ( $this->getPermissions()->isAllowed( IMinervaPagePermissions::WATCH ) ) {
|
||||||
|
|
Loading…
Reference in a new issue