return $languageLinks;
}
+ /**
+ * @return QuickTemplate
+ */
protected function setupTemplateForOutput() {
$request = $this->getRequest();
$user = $this->getUser();
}
/**
- * initialize various variables and generate the template
- *
- * @param OutputPage|null $out
+ * Initialize various variables and generate the template
*/
- function outputPage( OutputPage $out = null ) {
+ function outputPage() {
Profiler::instance()->setTemplated( true );
-
- $oldContext = null;
- if ( $out !== null ) {
- // Deprecated since 1.20, note added in 1.25
- wfDeprecated( __METHOD__, '1.25' );
- $oldContext = $this->getContext();
- $this->setContext( $out->getContext() );
- }
-
$out = $this->getOutput();
$this->initPage( $out );
// result may be an error
$this->printOrError( $res );
-
- if ( $oldContext ) {
- $this->setContext( $oldContext );
- }
}
/**
* @return QuickTemplate The template to be executed by outputPage
*/
protected function prepareQuickTemplate() {
- global $wgContLang, $wgScript, $wgStylePath, $wgMimeType, $wgJsMimeType,
+ global $wgScript, $wgStylePath, $wgMimeType, $wgJsMimeType,
$wgSitename, $wgLogo, $wgMaxCredits,
$wgShowCreditsIfMax, $wgArticlePath,
$wgScriptPath, $wgServer;
$tpl->set( 'handheld', $request->getBool( 'handheld' ) );
$tpl->set( 'loggedin', $this->loggedin );
$tpl->set( 'notspecialpage', !$title->isSpecialPage() );
- $tpl->set( 'searchaction', $this->escapeSearchLink() );
+ $tpl->set( 'searchaction', $this->getSearchLink() );
$tpl->set( 'searchtitle', SpecialPage::getTitleFor( 'Search' )->getPrefixedDBkey() );
$tpl->set( 'search', trim( $request->getVal( 'search' ) ) );
$tpl->set( 'stylepath', $wgStylePath );
// heading for the page title. Defaults to empty string.
$tpl->set( 'prebodyhtml', '' );
- if ( $userLangCode !== $wgContLang->getHtmlCode() || $userLangDir !== $wgContLang->getDir() ) {
+ $contLang = MediaWikiServices::getInstance()->getContentLanguage();
+ if (
+ $userLangCode !== $contLang->getHtmlCode() ||
+ $userLangDir !== $contLang->getDir()
+ ) {
$escUserlang = htmlspecialchars( $userLangCode );
$escUserdir = htmlspecialchars( $userLangDir );
// Attributes must be in double quotes because htmlspecialchars() doesn't
$tpl->set( 'lastmod', false );
$tpl->set( 'credits', false );
$tpl->set( 'numberofwatchingusers', false );
- if ( $out->isArticle() && $title->exists() ) {
- if ( $this->isRevisionCurrent() ) {
+ if ( $title->exists() ) {
+ if ( $out->isArticle() && $this->isRevisionCurrent() ) {
if ( $wgMaxCredits != 0 ) {
- $tpl->set( 'credits', Action::factory( 'credits', $this->getWikiPage(),
- $this->getContext() )->getCredits( $wgMaxCredits, $wgShowCreditsIfMax ) );
+ /** @var CreditsAction $action */
+ $action = Action::factory(
+ 'credits', $this->getWikiPage(), $this->getContext() );
+ $tpl->set( 'credits',
+ $action->getCredits( $wgMaxCredits, $wgShowCreditsIfMax ) );
} else {
$tpl->set( 'lastmod', $this->lastModified() );
}
}
- $tpl->set( 'copyright', $this->getCopyright() );
+ if ( $out->showsCopyright() ) {
+ $tpl->set( 'copyright', $this->getCopyright() );
+ }
}
$tpl->set( 'copyrightico', $this->getCopyrightIcon() );
$html = '';
if ( $personalTools === null ) {
- $personalTools = $tpl->getPersonalTools();
+ $personalTools = ( $tpl instanceof BaseTemplate )
+ ? $tpl->getPersonalTools()
+ : [];
}
foreach ( $personalTools as $key => $item ) {
$tpl = $this->setupTemplateForOutput();
$tpl->set( 'personal_urls', $this->buildPersonalUrls() );
- return $tpl->getPersonalTools();
+ return ( $tpl instanceof BaseTemplate ) ? $tpl->getPersonalTools() : [];
}
/**
$page = Title::newFromText( $request->getVal( 'title', '' ) );
}
$page = $request->getVal( 'returnto', $page );
- $a = [];
+ $returnto = [];
if ( strval( $page ) !== '' ) {
- $a['returnto'] = $page;
+ $returnto['returnto'] = $page;
$query = $request->getVal( 'returntoquery', $this->thisquery );
+ $paramsArray = wfCgiToArray( $query );
+ $query = wfArrayToCgi( $paramsArray );
if ( $query != '' ) {
- $a['returntoquery'] = $query;
+ $returnto['returntoquery'] = $query;
}
}
- $returnto = wfArrayToCgi( $a );
if ( $this->loggedin ) {
$personal_urls['userpage'] = [
'text' => $this->username,
# so it doesn't contain the original alias-with-subpage.
$origTitle = Title::newFromText( $request->getText( 'title' ) );
if ( $origTitle instanceof Title && $origTitle->isSpecialPage() ) {
- list( $spName, $spPar ) = SpecialPageFactory::resolveAlias( $origTitle->getText() );
+ list( $spName, $spPar ) =
+ MediaWikiServices::getInstance()->getSpecialPageFactory()->
+ resolveAlias( $origTitle->getText() );
$active = $spName == 'Contributions'
&& ( ( $spPar && $spPar == $this->username )
|| $request->getText( 'target' ) == $this->username );
$personal_urls['logout'] = [
'text' => $this->msg( 'pt-userlogout' )->text(),
'href' => self::makeSpecialUrl( 'Userlogout',
- // userlogout link must always contain an & character, otherwise we might not be able
+ // Note: userlogout link must always contain an & character, otherwise we might not be able
// to detect a buggy precaching proxy (T19790)
- $title->isSpecial( 'Preferences' ) ? 'noreturnto' : $returnto ),
+ ( $title->isSpecial( 'Preferences' ) ? [] : $returnto ) ),
'active' => false
];
}
}
}
- $linkClass = MediaWikiServices::getInstance()->getLinkRenderer()->getLinkClasses( $title );
+ $services = MediaWikiServices::getInstance();
+ $linkClass = $services->getLinkRenderer()->getLinkClasses( $title );
// wfMessageFallback will nicely accept $message as an array of fallbacks
// or just a single key
if ( $msg->exists() ) {
$text = $msg->text();
} else {
- global $wgContLang;
- $text = $wgContLang->getConverter()->convertNamespace(
- MWNamespace::getSubject( $title->getNamespace() ) );
+ $text = $services->getContentLanguage()->getConverter()->
+ convertNamespace( $services->getNamespaceInfo()->
+ getSubject( $title->getNamespace() ) );
}
// Avoid PHP 7.1 warning of passing $this by reference
}
} else {
// article doesn't exist or is deleted
- if ( $user->isAllowed( 'deletedhistory' ) ) {
+ if ( $title->quickUserCan( 'deletedhistory', $user ) ) {
$n = $title->isDeleted();
if ( $n ) {
$undelTitle = SpecialPage::getTitleFor( 'Undelete', $title->getPrefixedDBkey() );
// If the user can't undelete but can view deleted
// history show them a "View .. deleted" tab instead.
- $msgKey = $user->isAllowed( 'undelete' ) ? 'undelete' : 'viewdeleted';
+ $msgKey = $title->quickUserCan( 'undelete', $user ) ? 'undelete' : 'viewdeleted';
$content_navigation['actions']['undelete'] = [
'class' => $this->getTitle()->isSpecial( 'Undelete' ) ? 'selected' : false,
'text' => wfMessageFallback( "$skname-action-$msgKey", "{$msgKey}_short" )
}
if ( $title->quickUserCan( 'protect', $user ) && $title->getRestrictionTypes() &&
- MWNamespace::getRestrictionLevels( $title->getNamespace(), $user ) !== [ '' ]
+ MediaWikiServices::getInstance()->getNamespaceInfo()->
+ getRestrictionLevels( $title->getNamespace(), $user ) !== [ '' ]
) {
$mode = $title->isProtected() ? 'unprotect' : 'protect';
$content_navigation['actions'][$mode] = [