* roughly equivalent to PHPTAL 0.7.
*
* @param string $classname
- * @param bool|string $repository Subdirectory where we keep template files
- * @param bool|string $cache_dir
* @return QuickTemplate
* @private
*/
- function setupTemplate( $classname, $repository = false, $cache_dir = false ) {
+ function setupTemplate( $classname ) {
return new $classname( $this->getConfig() );
}
$user = $this->getUser();
$title = $this->getTitle();
- $tpl = $this->setupTemplate( $this->template, 'skins' );
+ $tpl = $this->setupTemplate( $this->template );
$this->thispage = $title->getPrefixedDBkey();
$this->titletxt = $title->getPrefixedText();
}
/**
- * initialize various variables and generate the template
- *
- * @param OutputPage|null $out
+ * Initialize various variables and generate the template
*/
- function outputPage( OutputPage $out = null ) {
- 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() );
- }
-
+ function outputPage() {
+ Profiler::instance()->setAllowOutput();
$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 $wgScript, $wgStylePath, $wgMimeType, $wgJsMimeType,
+ global $wgScript, $wgStylePath, $wgMimeType,
$wgSitename, $wgLogo, $wgMaxCredits,
$wgShowCreditsIfMax, $wgArticlePath,
$wgScriptPath, $wgServer;
}
$tpl->set( 'mimetype', $wgMimeType );
- $tpl->set( 'jsmimetype', $wgJsMimeType );
$tpl->set( 'charset', 'UTF-8' );
$tpl->set( 'wgScript', $wgScript );
$tpl->set( 'skinname', $this->skinname );
$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 );
$tpl->set( 'credits', false );
$tpl->set( 'numberofwatchingusers', false );
if ( $title->exists() ) {
- if ( $out->isArticle() && $this->isRevisionCurrent() ) {
+ if ( $out->isArticle() && $out->isRevisionCurrent() ) {
if ( $wgMaxCredits != 0 ) {
/** @var CreditsAction $action */
$action = Action::factory(
$request = $this->getRequest();
$pageurl = $title->getLocalURL();
$authManager = AuthManager::singleton();
+ $permissionManager = MediaWikiServices::getInstance()->getPermissionManager();
/* set up the default links for the personal toolbar */
$personal_urls = [];
$returnto['returnto'] = $page;
$query = $request->getVal( 'returntoquery', $this->thisquery );
$paramsArray = wfCgiToArray( $query );
- unset( $paramsArray['logoutToken'] );
$query = wfArrayToCgi( $paramsArray );
if ( $query != '' ) {
$returnto['returntoquery'] = $query;
'href' => self::makeSpecialUrl( 'Userlogout',
// Note: userlogout link must always contain an & character, otherwise we might not be able
// to detect a buggy precaching proxy (T19790)
- ( $title->isSpecial( 'Preferences' ) ? [] : $returnto )
- + [ 'logoutToken' => $this->getUser()->getEditToken( 'logoutToken', $this->getRequest() ) ] ),
+ ( $title->isSpecial( 'Preferences' ) ? [] : $returnto ) ),
'active' => false
];
}
];
// No need to show Talk and Contributions to anons if they can't contribute!
- if ( User::groupHasPermission( '*', 'edit' ) ) {
+ if ( $permissionManager->groupHasPermission( '*', 'edit' ) ) {
// Because of caching, we can't link directly to the IP talk and
// contributions pages. Instead we use the special page shortcuts
// (which work correctly regardless of caching). This means we can't
}
if ( $authManager->canAuthenticateNow() ) {
- $key = User::groupHasPermission( '*', 'read' )
+ $key = $permissionManager->groupHasPermission( '*', 'read' )
? 'login'
: 'login-private';
$personal_urls[$key] = $login_url;
$out = $this->getOutput();
$request = $this->getRequest();
$user = $this->getUser();
+ $permissionManager = MediaWikiServices::getInstance()->getPermissionManager();
$content_navigation = [
'namespaces' => [],
// parameters
$action = $request->getVal( 'action', 'view' );
- $userCanRead = $title->quickUserCan( 'read', $user );
+ $userCanRead = $permissionManager->quickUserCan( 'read', $user, $title );
// Avoid PHP 7.1 warning of passing $this by reference
$skinTemplate = $this;
}
// Checks if user can edit the current page if it exists or create it otherwise
- if ( $title->quickUserCan( 'edit', $user )
- && ( $title->exists() || $title->quickUserCan( 'create', $user ) )
+ if ( $permissionManager->quickUserCan( 'edit', $user, $title ) &&
+ ( $title->exists() ||
+ $permissionManager->quickUserCan( 'create', $user, $title ) )
) {
// Builds CSS class for talk page links
$isTalkClass = $isTalk ? ' istalk' : '';
// Whether to show the "Add a new section" tab
// Checks if this is a current rev of talk page and is not forced to be hidden
$showNewSection = !$out->forceHideNewSectionLink()
- && ( ( $isTalk && $this->isRevisionCurrent() ) || $out->showNewSectionLink() );
+ && ( ( $isTalk && $out->isRevisionCurrent() ) || $out->showNewSectionLink() );
$section = $request->getVal( 'section' );
if ( $title->exists()
'href' => $title->getLocalURL( 'action=history' ),
];
- if ( $title->quickUserCan( 'delete', $user ) ) {
+ if ( $permissionManager->quickUserCan( 'delete', $user, $title ) ) {
$content_navigation['actions']['delete'] = [
'class' => ( $onPage && $action == 'delete' ) ? 'selected' : false,
'text' => wfMessageFallback( "$skname-action-delete", 'delete' )
];
}
- if ( $title->quickUserCan( 'move', $user ) ) {
+ if ( $permissionManager->quickUserCan( 'move', $user, $title ) ) {
$moveTitle = SpecialPage::getTitleFor( 'Movepage', $title->getPrefixedDBkey() );
$content_navigation['actions']['move'] = [
'class' => $this->getTitle()->isSpecial( 'Movepage' ) ? 'selected' : false,
}
} else {
// article doesn't exist or is deleted
- if ( $title->quickUserCan( 'deletedhistory', $user ) ) {
+ if ( $permissionManager->quickUserCan( 'deletedhistory', $user, $title ) ) {
$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 = $title->quickUserCan( 'undelete', $user ) ? 'undelete' : 'viewdeleted';
+ $msgKey = $permissionManager->quickUserCan( 'undelete',
+ $user, $title ) ? '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() &&
- MediaWikiServices::getInstance()->getNamespaceInfo()->
- getRestrictionLevels( $title->getNamespace(), $user ) !== [ '' ]
+ if ( $permissionManager->quickUserCan( 'protect', $user, $title ) &&
+ $title->getRestrictionTypes() &&
+ $permissionManager->getNamespaceRestrictionLevels( $title->getNamespace(),
+ $user ) !== [ '' ]
) {
$mode = $title->isProtected() ? 'unprotect' : 'protect';
$content_navigation['actions'][$mode] = [
}
// Checks if the user is logged in
- if ( $this->loggedin && $user->isAllowedAll( 'viewmywatchlist', 'editmywatchlist' ) ) {
+ if ( $this->loggedin && $permissionManager->userHasAllRights( $user,
+ 'viewmywatchlist', 'editmywatchlist' )
+ ) {
/**
* The following actions use messages which, if made particular to
* the any specific skins, would break the Ajax code which makes this
$nav_urls['contributions'] = false;
$nav_urls['log'] = false;
$nav_urls['blockip'] = false;
+ $nav_urls['mute'] = false;
$nav_urls['emailuser'] = false;
$nav_urls['userrights'] = false;
if ( $out->isArticle() ) {
// Also add a "permalink" while we're at it
- $revid = $this->getRevisionId();
+ $revid = $this->getOutput()->getRevisionId();
if ( $revid ) {
$nav_urls['permalink'] = [
'text' => $this->msg( 'permalink' )->text(),
}
if ( !$user->isAnon() ) {
+ if ( $this->getUser()->isRegistered() && $this->getConfig()->get( 'EnableSpecialMute' ) ) {
+ $nav_urls['mute'] = [
+ 'text' => $this->msg( 'mute-preferences' )->text(),
+ 'href' => self::makeSpecialUrlSubpage( 'Mute', $rootUser )
+ ];
+ }
+
$sur = new UserrightsPage;
$sur->setContext( $this->getContext() );
$canChange = $sur->userCanChangeRights( $user );