* @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;
$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( '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( '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 );
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__ );
$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__ );
}
// 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';
if ( $title->exists() && $userCanRead ) {
$content_navigation['views']['view'] = $this->tabAction(
$isTalk ? $talkPage : $subjectPage,
- !wfEmptyMsg( "$skname-view-view" ) ? "$skname-view-view" : 'view',
- ( $onPage && $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
}
"edit" : "create";
$content_navigation['views']['edit'] = array(
'class' => ( $selected ? 'selected' : '' ) . $isTalkClass,
- 'text' => wfMessageFallback( "$skname-view-$msgKey", $msgKey )->plain(),
+ '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(),
+ 'text' => wfMessageFallback( "$skname-action-addsection", 'addsection' )->text(),
'href' => $title->getLocalURL( 'action=edit§ion=new' )
);
}
// Adds view source view link
$content_navigation['views']['viewsource'] = array(
'class' => ( $onPage && $action == 'edit' ) ? 'selected' : false,
- 'text' => wfMessageFallback( "$skname-action-viewsource", 'viewsource' )->plain(),
+ 'text' => wfMessageFallback( "$skname-action-viewsource", 'viewsource' )->text(),
'href' => $title->getLocalURL( $this->editUrlOptions() ),
'primary' => true, // don't collapse this in vector
);
// Adds history view link
$content_navigation['views']['history'] = array(
'class' => ( $onPage && $action == 'history' ) ? 'selected' : false,
- 'text' => wfMessageFallback( "$skname-view-history", 'history_short' )->plain(),
+ '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' => ( $onPage && $action == 'delete' ) ? 'selected' : false,
- 'text' => wfMessageFallback( "$skname-action-delete", 'delete' )->plain(),
+ 'text' => wfMessageFallback( "$skname-action-delete", 'delete' )->text(),
'href' => $title->getLocalURL( 'action=delete' )
);
}
$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()
);
}
$mode = !$title->isProtected() ? 'protect' : 'unprotect';
$content_navigation['actions'][$mode] = array(
'class' => ( $onPage && $action == $mode ) ? 'selected' : false,
- 'text' => wfMessageFallback( "$skname-action-$mode", $mode )->plain(),
+ 'text' => wfMessageFallback( "$skname-action-$mode", $mode )->text(),
'href' => $title->getLocalURL( "action=$mode" )
);
}
$mode = !$title->getRestrictions( 'create' ) ? 'protect' : 'unprotect';
$content_navigation['actions'][$mode] = array(
'class' => ( $onPage && $action == $mode ) ? 'selected' : false,
- 'text' => wfMessageFallback( "$skname-action-$mode", $mode )->plain(),
+ 'text' => wfMessageFallback( "$skname-action-$mode", $mode )->text(),
'href' => $title->getLocalURL( "action=$mode" )
);
}
* @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' )
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()
);
}
/**
* @private
+ * FIXME: why is this duplicated in/from OutputPage::getHeadScripts()??
*/
function setupUserJs( $allowUserJs ) {
global $wgRequest, $wgJsMimeType;
}
}
} elseif ( $option == 'nocopyright' ) {
- $footericons = $this->data['footericons'];
unset( $footericons['copyright']['copyright'] );
if ( count( $footericons['copyright'] ) <= 0 ) {
unset( $footericons['copyright'] );