* @param $out OutputPage
*/
function outputPage( OutputPage $out ) {
- global $wgArticle, $wgUser, $wgLang, $wgContLang;
+ global $wgUser, $wgLang, $wgContLang;
global $wgScript, $wgStylePath, $wgLanguageCode;
global $wgMimeType, $wgJsMimeType, $wgOutputEncoding, $wgRequest;
global $wgXhtmlDefaultNamespace, $wgXhtmlNamespaces, $wgHtml5Version;
$this->setMembers();
$tpl = $this->setupTemplate( $this->template, 'skins' );
-
- #if ( $wgUseDatabaseMessages ) { // uncomment this to fall back to GetText
- $tpl->setTranslator( new MediaWiki_I18N() );
- #}
wfProfileOut( __METHOD__ . '-init' );
wfProfileIn( __METHOD__ . '-stuff' );
$tpl->setRef( 'usercss', $this->usercss );
$this->userjs = $this->userjsprev = false;
+ # FIXME: this is the only use of OutputPage::isUserJsAllowed() anywhere; can we
+ # get rid of it? For that matter, why is any of this here at all?
$this->setupUserJs( $out->isUserJsAllowed() );
$tpl->setRef( 'userjs', $this->userjs );
$tpl->setRef( 'userjsprev', $this->userjsprev );
$tpl->set( 'xhtmlnamespaces', $wgXhtmlNamespaces );
$tpl->set( 'html5version', $wgHtml5Version );
$tpl->set( 'headlinks', $out->getHeadLinks( $this ) );
- $tpl->set( 'csslinks', $out->buildCssLinks() );
+ $tpl->set( 'csslinks', $out->buildCssLinks( $this ) );
if( $wgUseTrackbacks && $out->isArticleRelated() ) {
$tpl->set( 'trackbackhtml', $out->getTitle()->trackbackRDF() );
$tpl->set( 'titleprefixeddbkey', $this->mTitle->getPrefixedDBKey() );
$tpl->set( 'titletext', $this->mTitle->getText() );
$tpl->set( 'articleid', $this->mTitle->getArticleId() );
- $tpl->set( 'currevisionid', isset( $wgArticle ) ? $wgArticle->getLatest() : 0 );
+ $tpl->set( 'currevisionid', $this->mTitle->getLatestRevID() );
$tpl->set( 'isarticle', $out->isArticle() );
$tpl->setRef( 'thispage', $this->thispage );
- $subpagestr = $this->subPageSubtitle();
+ $subpagestr = $this->subPageSubtitle( $out );
$tpl->set(
'subtitle', !empty( $subpagestr ) ?
'<span class="subpages">' . $subpagestr . '</span>' . $out->getSubtitle() :
''
);
- $tpl->set( 'catlinks', $this->getCategories() );
+ $tpl->set( 'catlinks', $this->getCategories( $out ) );
if( $out->isSyndicated() ) {
$feeds = array();
foreach( $out->getSyndicationLinks() as $format => $link ) {
}
}
- $newtalks = $this->getNewtalks();
+ $newtalks = $this->getNewtalks( $out );
wfProfileOut( __METHOD__ . '-stuff2' );
$tpl->setRef( 'skin', $this );
$tpl->set( 'logo', $this->logoText() );
if ( $out->isArticle() && ( !isset( $oldid ) || isset( $diff ) ) &&
- $wgArticle && 0 != $wgArticle->getID() ){
+ $this->mTitle->exists() )
+ {
+ $article = new Article( $this->mTitle, 0 );
if ( !$wgDisableCounters ) {
- $viewcount = $wgLang->formatNum( $wgArticle->getCount() );
+ $viewcount = $wgLang->formatNum( $article->getCount() );
if ( $viewcount ) {
$tpl->set( 'viewcount', wfMsgExt( 'viewcount', array( 'parseinline' ), $viewcount ) );
} else {
$this->credits = false;
if( $wgMaxCredits != 0 ){
- $this->credits = Credits::getCredits( $wgArticle, $wgMaxCredits, $wgShowCreditsIfMax );
+ $this->credits = Credits::getCredits( $article, $wgMaxCredits, $wgShowCreditsIfMax );
} else {
- $tpl->set( 'lastmod', $this->lastModified() );
+ $tpl->set( 'lastmod', $this->lastModified( $article ) );
}
$tpl->setRef( 'credits', $this->credits );
} else {
$tpl->set( 'copyright', false );
$tpl->set( 'viewcount', false );
- $tpl->set( 'lastmod', false );
+ $tpl->set( 'lastmod', false );
$tpl->set( 'credits', false );
$tpl->set( 'numberofwatchingusers', false );
}
}
$tpl->set( 'reporttime', wfReportTime() );
- $tpl->set( 'sitenotice', wfGetSiteNotice() );
+ $tpl->set( 'sitenotice', $this->getSiteNotice() );
$tpl->set( 'bottomscripts', $this->bottomScripts( $out ) );
+ // @todo Give printfooter userlangattributes
$printfooter = "<div class=\"printfooter\">\n" . $this->printSource() . "</div>\n";
global $wgBetterDirectionality;
if ( $wgBetterDirectionality ) {
$realBodyAttribs = array( 'lang' => $wgLanguageCode, 'dir' => $wgContLang->getDir() );
$out->mBodytext = Html::rawElement( 'div', $realBodyAttribs, $out->mBodytext );
}
- $out->mBodytext .= $printfooter . $this->generateDebugHTML();
+ $out->mBodytext .= $printfooter . $this->generateDebugHTML( $out );
$tpl->setRef( 'bodytext', $out->mBodytext );
# Language links
wfProfileIn( __METHOD__ . '-stuff5' );
# Personal toolbar
- $tpl->set( 'personal_urls', $this->buildPersonalUrls() );
- $content_navigation = $this->buildContentNavigationUrls();
+ $tpl->set( 'personal_urls', $this->buildPersonalUrls( $out ) );
+ $content_navigation = $this->buildContentNavigationUrls( $out );
$content_actions = $this->buildContentActionUrls( $content_navigation );
$tpl->setRef( 'content_navigation', $content_navigation );
$tpl->setRef( 'content_actions', $content_actions );
$tpl->set( 'sidebar', $this->buildSidebar() );
- $tpl->set( 'nav_urls', $this->buildNavUrls() );
+ $tpl->set( 'nav_urls', $this->buildNavUrls( $out ) );
// Set the head scripts near the end, in case the above actions resulted in added scripts
if ( $this->useHeadElement ) {
/**
* build array of urls for personal toolbar
* @return array
- * @private
*/
- function buildPersonalUrls() {
- global $wgOut, $wgRequest;
+ protected function buildPersonalUrls( OutputPage $out ) {
+ global $wgRequest;
- $title = $wgOut->getTitle();
+ $title = $out->getTitle();
$pageurl = $title->getLocalURL();
wfProfileIn( __METHOD__ );
$personal_urls = array();
$page = $wgRequest->getVal( 'returnto', $this->thisurl );
$query = $wgRequest->getVal( 'returntoquery', $this->thisquery );
- $returnto = "returnto=$page";
+ $returnto = wfArrayToCGI( array( 'returnto' => $page ) );
if( $this->thisquery != '' ) {
$returnto .= "&returntoquery=$query";
}
$query = 'action=edit&redlink=1';
}
- $text = wfMsg( $message );
- if ( wfEmptyMsg( $message, $text ) ) {
+ // wfMessageFallback will nicely accept $message as an array of fallbacks
+ // or just a single key
+ $msg = wfMessageFallback( $message );
+ if ( is_array($message) ) {
+ // for hook compatibility just keep the last message name
+ $message = end($message);
+ }
+ if ( $msg->exists() ) {
+ $text = $msg->text();
+ } else {
global $wgContLang;
$text = $wgContLang->getFormattedNsText( MWNamespace::getSubject( $title->getNamespace() ) );
}
* believes that the accesskey should not be added to the tab.
*
* @return array
- * @private
*/
- function buildContentNavigationUrls() {
- global $wgContLang, $wgLang, $wgOut, $wgUser, $wgRequest, $wgArticle;
+ protected function buildContentNavigationUrls( OutputPage $out ) {
+ global $wgContLang, $wgLang, $wgUser, $wgRequest;
global $wgDisableLangConversion;
wfProfileIn( __METHOD__ );
+ $title = $this->getRelevantTitle(); // Display tabs for the relevant title rather than always the title itself
+ $onPage = $title->equals($this->mTitle);
+
$content_navigation = array(
'namespaces' => array(),
'views' => array(),
$action = $wgRequest->getVal( 'action', 'view' );
$section = $wgRequest->getVal( 'section' );
- $userCanRead = $this->mTitle->userCanRead();
+ $userCanRead = $title->userCanRead();
$skname = $this->skinname;
$preventActiveTabs = false;
wfRunHooks( 'SkinTemplatePreventOtherActiveTabs', array( &$this, &$preventActiveTabs ) );
// Checks if page is some kind of content
- if( $this->iscontent ) {
+ if( $title->getNamespace() != NS_SPECIAL ) {
// Gets page objects for the related namespaces
- $subjectPage = $this->mTitle->getSubjectPage();
- $talkPage = $this->mTitle->getTalkPage();
+ $subjectPage = $title->getSubjectPage();
+ $talkPage = $title->getTalkPage();
// Determines if this is a talk page
- $isTalk = $this->mTitle->isTalkPage();
+ $isTalk = $title->isTalkPage();
// Generates XML IDs from namespace names
- $subjectId = $this->mTitle->getNamespaceKey( '' );
+ $subjectId = $title->getNamespaceKey( '' );
if ( $subjectId == 'main' ) {
$talkId = 'talk';
}
// Adds namespace links
+ $subjectMsg = array( "nstab-$subjectId" );
+ if ( $subjectPage->isMainPage() ) {
+ array_unshift($subjectMsg, 'mainpage-nstab');
+ }
$content_navigation['namespaces'][$subjectId] = $this->tabAction(
- $subjectPage, 'nstab-' . $subjectId, !$isTalk && !$preventActiveTabs, '', $userCanRead
+ $subjectPage, $subjectMsg, !$isTalk && !$preventActiveTabs, '', $userCanRead
);
$content_navigation['namespaces'][$subjectId]['context'] = 'subject';
$content_navigation['namespaces'][$talkId] = $this->tabAction(
- $talkPage, 'talk', $isTalk && !$preventActiveTabs, '', $userCanRead
+ $talkPage, array( "nstab-$talkId", 'talk' ), $isTalk && !$preventActiveTabs, '', $userCanRead
);
$content_navigation['namespaces'][$talkId]['context'] = 'talk';
// Adds view view link
- if ( $this->mTitle->exists() && $userCanRead ) {
+ if ( $title->exists() && $userCanRead ) {
$content_navigation['views']['view'] = $this->tabAction(
$isTalk ? $talkPage : $subjectPage,
- !wfEmptyMsg( "$skname-view-view" ) ? "$skname-view-view" : 'view',
- ( $action == 'view' ), '', true
+ array( "$skname-view-view", 'view' ),
+ ( $onPage && ($action == 'view' || $action == 'purge' ) ), '', true
);
$content_navigation['views']['view']['redundant'] = true; // signal to hide this from simple content_actions
}
// Checks if user can...
if (
// read and edit the current page
- $userCanRead && $this->mTitle->quickUserCan( 'edit' ) &&
+ $userCanRead && $title->quickUserCan( 'edit' ) &&
(
// if it exists
- $this->mTitle->exists() ||
+ $title->exists() ||
// or they can create one here
- $this->mTitle->quickUserCan( 'create' )
+ $title->quickUserCan( 'create' )
)
) {
// Builds CSS class for talk page links
// Determines if we're in edit mode
$selected = (
+ $onPage &&
( $action == 'edit' || $action == 'submit' ) &&
( $section != 'new' )
);
- $msgKey = $this->mTitle->exists() || ( $this->mTitle->getNamespace() == NS_MEDIAWIKI && !wfEmptyMsg( $this->mTitle->getText() ) ) ?
+ $msgKey = $title->exists() || ( $title->getNamespace() == NS_MEDIAWIKI && !wfEmptyMsg( $title->getText() ) ) ?
"edit" : "create";
$content_navigation['views']['edit'] = array(
'class' => ( $selected ? 'selected' : '' ) . $isTalkClass,
- 'text' => wfMessageFallback( "$skname-view-$msgKey", $msgKey )->plain(),
- 'href' => $this->mTitle->getLocalURL( $this->editUrlOptions() ),
+ 'text' => wfMessageFallback( "$skname-view-$msgKey", $msgKey )->text(),
+ 'href' => $title->getLocalURL( $this->editUrlOptions() ),
'primary' => true, // don't collapse this in vector
);
// Checks if this is a current rev of talk page and we should show a new
// section link
- if ( ( $isTalk && $wgArticle && $wgArticle->isCurrent() ) || ( $wgOut->showNewSectionLink() ) ) {
+ if ( ( $isTalk && $this->isRevisionCurrent() ) || ( $out->showNewSectionLink() ) ) {
// Checks if we should ever show a new section link
- if ( !$wgOut->forceHideNewSectionLink() ) {
+ if ( !$out->forceHideNewSectionLink() ) {
// Adds new section link
//$content_navigation['actions']['addsection']
$content_navigation['views']['addsection'] = array(
'class' => $section == 'new' ? 'selected' : false,
- 'text' => wfMessageFallback( "$skname-action-addsection", 'addsection' )->plain(),
- 'href' => $this->mTitle->getLocalURL( 'action=edit§ion=new' )
+ 'text' => wfMessageFallback( "$skname-action-addsection", 'addsection' )->text(),
+ 'href' => $title->getLocalURL( 'action=edit§ion=new' )
);
}
}
// Checks if the page has some kind of viewable content
- } elseif ( $this->mTitle->hasSourceText() && $userCanRead ) {
+ } elseif ( $title->hasSourceText() && $userCanRead ) {
// Adds view source view link
$content_navigation['views']['viewsource'] = array(
- 'class' => ( $action == 'edit' ) ? 'selected' : false,
- 'text' => wfMessageFallback( "$skname-action-viewsource", 'viewsource' )->plain(),
- 'href' => $this->mTitle->getLocalURL( $this->editUrlOptions() ),
+ 'class' => ( $onPage && $action == 'edit' ) ? 'selected' : false,
+ 'text' => wfMessageFallback( "$skname-action-viewsource", 'viewsource' )->text(),
+ 'href' => $title->getLocalURL( $this->editUrlOptions() ),
'primary' => true, // don't collapse this in vector
);
}
wfProfileIn( __METHOD__ . '-live' );
// Checks if the page exists
- if ( $this->mTitle->exists() && $userCanRead ) {
+ if ( $title->exists() && $userCanRead ) {
// Adds history view link
$content_navigation['views']['history'] = array(
- 'class' => ( $action == 'history' ) ? 'selected' : false,
- 'text' => wfMessageFallback( "$skname-view-history", 'history_short' )->plain(),
- 'href' => $this->mTitle->getLocalURL( 'action=history' ),
+ 'class' => ( $onPage && $action == 'history' ) ? 'selected' : false,
+ 'text' => wfMessageFallback( "$skname-view-history", 'history_short' )->text(),
+ 'href' => $title->getLocalURL( 'action=history' ),
'rel' => 'archives',
);
if( $wgUser->isAllowed( 'delete' ) ) {
$content_navigation['actions']['delete'] = array(
- 'class' => ( $action == 'delete' ) ? 'selected' : false,
- 'text' => wfMessageFallback( "$skname-action-delete", 'delete' )->plain(),
- 'href' => $this->mTitle->getLocalURL( 'action=delete' )
+ 'class' => ( $onPage && $action == 'delete' ) ? 'selected' : false,
+ 'text' => wfMessageFallback( "$skname-action-delete", 'delete' )->text(),
+ 'href' => $title->getLocalURL( 'action=delete' )
);
}
- if ( $this->mTitle->quickUserCan( 'move' ) ) {
- $moveTitle = SpecialPage::getTitleFor( 'Movepage', $this->thispage );
+ if ( $title->quickUserCan( 'move' ) ) {
+ $moveTitle = SpecialPage::getTitleFor( 'Movepage', $title->getPrefixedDBkey() );
$content_navigation['actions']['move'] = array(
'class' => $this->mTitle->isSpecial( 'Movepage' ) ? 'selected' : false,
- 'text' => wfMessageFallback( "$skname-action-move", 'move' )->plain(),
+ 'text' => wfMessageFallback( "$skname-action-move", 'move' )->text(),
'href' => $moveTitle->getLocalURL()
);
}
- if ( $this->mTitle->getNamespace() !== NS_MEDIAWIKI && $wgUser->isAllowed( 'protect' ) ) {
- $mode = !$this->mTitle->isProtected() ? 'protect' : 'unprotect';
+ if ( $title->getNamespace() !== NS_MEDIAWIKI && $wgUser->isAllowed( 'protect' ) ) {
+ $mode = !$title->isProtected() ? 'protect' : 'unprotect';
$content_navigation['actions'][$mode] = array(
- 'class' => ( $action == $mode ) ? 'selected' : false,
- 'text' => wfMessageFallback( "$skname-action-$mode", $mode )->plain(),
- 'href' => $this->mTitle->getLocalURL( "action=$mode" )
+ 'class' => ( $onPage && $action == $mode ) ? 'selected' : false,
+ 'text' => wfMessageFallback( "$skname-action-$mode", $mode )->text(),
+ 'href' => $title->getLocalURL( "action=$mode" )
);
}
} else {
// article doesn't exist or is deleted
if ( $wgUser->isAllowed( 'deletedhistory' ) ) {
- $n = $this->mTitle->isDeleted();
+ $n = $title->isDeleted();
if( $n ) {
$undelTitle = SpecialPage::getTitleFor( 'Undelete' );
// If the user can't undelete but can view deleted history show them a "View .. deleted" tab instead
$msgKey = $wgUser->isAllowed( 'undelete' ) ? 'undelete' : 'viewdeleted';
$content_navigation['actions']['undelete'] = array(
- 'class' => false,
+ 'class' => $this->mTitle->isSpecial( 'Undelete' ) ? 'selected' : false,
'text' => wfMessageFallback( "$skname-action-$msgKey", "{$msgKey}_short" )
->params( $wgLang->formatNum( $n ) )->text(),
- 'href' => $undelTitle->getLocalURL( array( 'target' => $this->thispage ) )
+ 'href' => $undelTitle->getLocalURL( array( 'target' => $title->getPrefixedDBkey() ) )
);
}
}
- if ( $this->mTitle->getNamespace() !== NS_MEDIAWIKI && $wgUser->isAllowed( 'protect' ) ) {
- $mode = !$this->mTitle->getRestrictions( 'create' ) ? 'protect' : 'unprotect';
+ if ( $title->getNamespace() !== NS_MEDIAWIKI && $wgUser->isAllowed( 'protect' ) ) {
+ $mode = !$title->getRestrictions( 'create' ) ? 'protect' : 'unprotect';
$content_navigation['actions'][$mode] = array(
- 'class' => ( $action == $mode ) ? 'selected' : false,
- 'text' => wfMessageFallback( "$skname-action-$mode", $mode )->plain(),
- 'href' => $this->mTitle->getLocalURL( "action=$mode" )
+ 'class' => ( $onPage && $action == $mode ) ? 'selected' : false,
+ 'text' => wfMessageFallback( "$skname-action-$mode", $mode )->text(),
+ 'href' => $title->getLocalURL( "action=$mode" )
);
}
}
* a change to that procedure these messages will have to remain as
* the global versions.
*/
- $mode = $this->mTitle->userIsWatching() ? 'unwatch' : 'watch';
+ $mode = $title->userIsWatching() ? 'unwatch' : 'watch';
$content_navigation['actions'][$mode] = array(
- 'class' => ( $action == 'watch' || $action == 'unwatch' ) ? 'selected' : false,
+ 'class' => $onPage && ( $action == 'watch' || $action == 'unwatch' ) ? 'selected' : false,
'text' => wfMsg( $mode ), // uses 'watch' or 'unwatch' message
- 'href' => $this->mTitle->getLocalURL( 'action=' . $mode )
+ 'href' => $title->getLocalURL( 'action=' . $mode )
);
}
$content_navigation['variants'][] = array(
'class' => ( $code == $preferred ) ? 'selected' : false,
'text' => $varname,
- 'href' => $this->mTitle->getLocalURL( '', $code )
+ 'href' => $title->getLocalURL( '', $code )
);
}
}
$content_actions = array();
- foreach ( $content_navigation as $section => $links ) {
+ foreach ( $content_navigation as $links ) {
foreach ( $links as $key => $value ) {
* @return array
* @private
*/
- function buildNavUrls() {
- global $wgUseTrackbacks, $wgOut, $wgUser, $wgRequest;
+ protected function buildNavUrls( OutputPage $out ) {
+ global $wgUseTrackbacks, $wgUser, $wgRequest;
global $wgUploadNavigationUrl;
wfProfileIn( __METHOD__ );
// A print stylesheet is attached to all pages, but nobody ever
// figures that out. :) Add a link...
if( $this->iscontent && ( $action == 'view' || $action == 'purge' ) ) {
- if ( !$wgOut->isPrintable() ) {
+ if ( !$out->isPrintable() ) {
$nav_urls['print'] = array(
'text' => wfMsg( 'printableversion' ),
- 'href' => $wgRequest->appendQuery( 'printable=yes' )
+ 'href' => $this->mTitle->getLocalURL( $wgRequest->appendQueryValue( 'printable', 'yes', true ) )
);
}
if ( $this->mRevisionId ) {
$nav_urls['permalink'] = array(
'text' => wfMsg( 'permalink' ),
- 'href' => $wgOut->getTitle()->getLocalURL( "oldid=$this->mRevisionId" )
+ 'href' => $out->getTitle()->getLocalURL( "oldid=$this->mRevisionId" )
);
}
}
if( $wgUseTrackbacks )
$nav_urls['trackbacklink'] = array(
- 'href' => $wgOut->getTitle()->trackbackURL()
+ 'href' => $out->getTitle()->trackbackURL()
);
}
- if( $this->mTitle->getNamespace() == NS_USER || $this->mTitle->getNamespace() == NS_USER_TALK ) {
- $rootUser = strtok( $this->mTitle->getText(), '/' );
- $id = User::idFromName( $rootUser );
- $ip = User::isIP( $rootUser );
+ $user = $this->getRelevantUser();
+ if ( $user ) {
+ $id = $user->getID();
+ $ip = $user->isAnon();
+ $rootUser = $user->getName();
} else {
$id = 0;
$ip = false;
/**
* @private
+ * FIXME: why is this duplicated in/from OutputPage::getHeadScripts()??
*/
function setupUserJs( $allowUserJs ) {
global $wgRequest, $wgJsMimeType;
$msg = $this->translator->translate( $str );
return ( $msg != '-' ) && ( $msg != '' ); # ????
}
+
+ /**
+ * Get the Skin object related to this object
+ *
+ * @return Skin object
+ */
+ public function getSkin() {
+ return $this->data['skin'];
+ }
}
/**
if ( $option == 'icononly' ) {
// Unset any icons which don't have an image
- foreach ( $footericons as $footerIconsKey => &$footerIconsBlock ) {
+ foreach ( $footericons as &$footerIconsBlock ) {
foreach ( $footerIconsBlock as $footerIconKey => $footerIcon ) {
if ( !is_string( $footerIcon ) && !isset( $footerIcon['src'] ) ) {
unset( $footerIconsBlock[$footerIconKey] );
}
}
} elseif ( $option == 'nocopyright' ) {
- $footericons = $this->data['footericons'];
unset( $footericons['copyright']['copyright'] );
if ( count( $footericons['copyright'] ) <= 0 ) {
unset( $footericons['copyright'] );
return $footericons;
}
+ /**
+ * Output the basic end-page trail including bottomscripts, reporttime, and
+ * debug stuff. This should be called right before outputting the closing
+ * body and html tags.
+ */
+ function printTrail() { ?>
+<?php $this->html('bottomscripts'); /* JS call to runBodyOnloadHook */ ?>
+<?php $this->html('reporttime') ?>
+<?php if ( $this->data['debug'] ): ?>
+<!-- Debug output:
+<?php $this->text( 'debug' ); ?>
+
+-->
+<?php endif;
+ }
}