Merge "Use consistent function names to SkinVector"

This commit is contained in:
jenkins-bot 2020-04-30 22:16:06 +00:00 committed by Gerrit Code Review
commit 48b680744d
1 changed files with 28 additions and 11 deletions

View File

@ -78,6 +78,23 @@ class VectorTemplate extends BaseTemplate {
$this->templateRoot = $isLegacy ? 'legacy' : 'index';
}
/**
* Amends the default behavior of BaseTemplate to return rather
* than echo.
* @param string $key
* @return Message
*/
public function msg( $key ) {
return $this->getMsg( $key );
}
/**
* @return Config
*/
private function getConfig() {
return $this->config;
}
/**
* The template parser might be undefined. This function will check if it set first
*
@ -100,7 +117,7 @@ class VectorTemplate extends BaseTemplate {
$contentNavigation = $this->get( 'content_navigation', [] );
// Move the watch/unwatch star outside of the collapsed "actions" menu to the main "views" menu
if ( $this->config->get( 'VectorUseIconWatch' ) ) {
if ( $this->getConfig()->get( 'VectorUseIconWatch' ) ) {
$mode = ( $this->getSkin()->getRelevantTitle()->isWatchable() &&
MediaWikiServices::getInstance()->getPermissionManager()->userHasRight(
$this->getSkin()->getUser(),
@ -157,7 +174,7 @@ class VectorTemplate extends BaseTemplate {
'html-title' => $this->get( 'title', '' ),
'html-prebodyhtml' => $this->get( 'prebodyhtml', '' ),
'msg-tagline' => $this->getMsg( 'tagline' )->text(),
'msg-tagline' => $this->msg( 'tagline' )->text(),
// TODO: mediawiki/SkinTemplate should expose langCode and langDir properly.
'html-userlangattributes' => $this->get( 'userlangattributes', '' ),
// From OutputPage::getSubtitle()
@ -170,8 +187,8 @@ class VectorTemplate extends BaseTemplate {
// From Skin::getNewtalks(). Always returns string, cast to null if empty.
'html-newtalk' => $this->get( 'newtalk', '' ) ?: null,
'msg-jumptonavigation' => $this->getMsg( 'vector-jumptonavigation' )->text(),
'msg-jumptosearch' => $this->getMsg( 'vector-jumptosearch' )->text(),
'msg-jumptonavigation' => $this->msg( 'vector-jumptonavigation' )->text(),
'msg-jumptosearch' => $this->msg( 'vector-jumptosearch' )->text(),
// Result of OutputPage::addHTML calls
'html-bodycontent' => $this->get( 'bodycontent' ),
@ -188,7 +205,7 @@ class VectorTemplate extends BaseTemplate {
'html-hook-vector-before-footer' => $htmlHookVectorBeforeFooter,
'array-footer-rows' => $this->getTemplateFooterRows(),
],
'html-navigation-heading' => $this->getMsg( 'navigation-heading' ),
'html-navigation-heading' => $this->msg( 'navigation-heading' ),
'data-search-box' => $this->buildSearchProps(),
// Header
@ -209,7 +226,7 @@ class VectorTemplate extends BaseTemplate {
false,
'mw-prefsection-rendering-skin-skin-prefs'
)->getLinkURL( 'wprov=' . self::OPT_OUT_LINK_TRACKING_CODE ),
'text' => $this->getMsg( 'vector-opt-out' )->text()
'text' => $this->msg( 'vector-opt-out' )->text()
];
}
@ -393,7 +410,7 @@ class VectorTemplate extends BaseTemplate {
public function makeListItem( $key, $item, $options = [] ) {
// For fancy styling of watch/unwatch star
if (
$this->config->get( 'VectorUseIconWatch' )
$this->getConfig()->get( 'VectorUseIconWatch' )
&& ( $key === 'watch' || $key === 'unwatch' )
) {
if ( !isset( $item['class'] ) ) {
@ -445,7 +462,7 @@ class VectorTemplate extends BaseTemplate {
'label-id' => "p-{$label}-label",
// For some menu items, there is no language key corresponding with its menu key.
// These inconsitencies are captured in MENU_LABEL_KEYS
'label' => $this->getMsg( self::MENU_LABEL_KEYS[ $label ] ?? $label )->text(),
'label' => $this->msg( self::MENU_LABEL_KEYS[ $label ] ?? $label )->text(),
'html-userlangattributes' => $this->get( 'userlangattributes', '' ),
'html-items' => '',
];
@ -481,7 +498,7 @@ class VectorTemplate extends BaseTemplate {
$loggedIn =
Html::element( 'li',
[ 'id' => 'pt-anonuserpage' ],
$this->getMsg( 'notloggedin' )->text()
$this->msg( 'notloggedin' )->text()
);
} else {
$loggedIn = '';
@ -535,7 +552,7 @@ class VectorTemplate extends BaseTemplate {
$props = [
'searchHeaderAttrsHTML' => $this->get( 'userlangattributes', '' ),
'searchActionURL' => $this->get( 'wgScript', '' ),
'searchDivID' => $this->config->get( 'VectorUseSimpleSearch' ) ? 'simpleSearch' : '',
'searchDivID' => $this->getConfig()->get( 'VectorUseSimpleSearch' ) ? 'simpleSearch' : '',
'searchInputHTML' => $this->makeSearchInput( [ 'id' => 'searchInput' ] ),
'titleHTML' => Html::hidden( 'title', $this->get( 'searchtitle', null ) ),
'fallbackSearchButtonHTML' => $this->makeSearchButton(
@ -546,7 +563,7 @@ class VectorTemplate extends BaseTemplate {
'go',
[ 'id' => 'searchButton', 'class' => 'searchButton' ]
),
'searchInputLabel' => $this->getMsg( 'search' )
'searchInputLabel' => $this->msg( 'search' )
];
return $props;
}