*
* @param $out OutputPage
*/
- function setupSkinUserCss( OutputPage $out ){
+ function setupSkinUserCss( OutputPage $out ) {
$out->addModuleStyles( array( 'mediawiki.legacy.shared', 'mediawiki.legacy.commonPrint' ) );
}
*/
function outputPage( OutputPage $out ) {
global $wgUser, $wgLang, $wgContLang;
- global $wgScript, $wgStylePath, $wgLanguageCode;
+ global $wgScript, $wgStylePath;
global $wgMimeType, $wgJsMimeType, $wgRequest;
global $wgXhtmlDefaultNamespace, $wgXhtmlNamespaces, $wgHtml5Version;
global $wgDisableCounters, $wgLogo, $wgHideInterlanguageLinks;
wfProfileIn( __METHOD__ );
Profiler::instance()->setTemplated( true );
- $oldid = $wgRequest->getVal( 'oldid' );
- $diff = $wgRequest->getVal( 'diff' );
- $action = $wgRequest->getVal( 'action', 'view' );
-
wfProfileIn( __METHOD__ . '-init' );
$this->initPage( $out );
wfProfileIn( __METHOD__ . '-stuff' );
$this->thispage = $this->getTitle()->getPrefixedDBkey();
- $this->thisurl = $this->getTitle()->getPrefixedURL();
+ $this->userpage = $this->getUser()->getUserPage()->getPrefixedText();
$query = array();
if ( !$wgRequest->wasPosted() ) {
$query = $wgRequest->getValues();
unset( $query['returnto'] );
unset( $query['returntoquery'] );
}
- $this->thisquery = wfUrlencode( wfArrayToCGI( $query ) );
+ $this->thisquery = wfArrayToCGI( $query );
$this->loggedin = $wgUser->isLoggedIn();
- $this->iscontent = ( $this->getTitle()->getNamespace() != NS_SPECIAL );
- $this->iseditable = ( $this->iscontent and !( $action == 'edit' or $action == 'submit' ) );
$this->username = $wgUser->getName();
if ( $wgUser->isLoggedIn() || $this->showIPinHeader() ) {
wfProfileOut( __METHOD__ . '-stuff' );
wfProfileIn( __METHOD__ . '-stuff-head' );
- if ( $this->useHeadElement ) {
- $pagecss = $this->setupPageCss();
- if( $pagecss )
- $out->addInlineStyle( $pagecss );
- } else {
- $this->setupUserCss( $out );
-
- $tpl->set( 'pagecss', $this->setupPageCss() );
+ if ( !$this->useHeadElement ) {
+ $tpl->set( 'pagecss', false );
$tpl->set( 'usercss', false );
$this->userjs = $this->userjsprev = false;
$tpl->setRef( 'xhtmldefaultnamespace', $wgXhtmlDefaultNamespace );
$tpl->set( 'xhtmlnamespaces', $wgXhtmlNamespaces );
$tpl->set( 'html5version', $wgHtml5Version );
- $tpl->set( 'headlinks', $out->getHeadLinks( $this ) );
- $tpl->set( 'csslinks', $out->buildCssLinks( $this ) );
+ $tpl->set( 'headlinks', $out->getHeadLinks() );
+ $tpl->set( 'csslinks', $out->buildCssLinks() );
if( $wgUseTrackbacks && $out->isArticleRelated() ) {
$tpl->set( 'trackbackhtml', $out->getTitle()->trackbackRDF() );
} else {
$tpl->set( 'trackbackhtml', null );
}
+
+ $tpl->set( 'pageclass', $this->getPageClasses( $this->getTitle() ) );
+ $tpl->set( 'skinnameclass', ( 'skin-' . Sanitizer::escapeClass( $this->getSkinName() ) ) );
}
wfProfileOut( __METHOD__ . '-stuff-head' );
$tpl->set( 'title', $out->getPageTitle() );
$tpl->set( 'pagetitle', $out->getHTMLTitle() );
$tpl->set( 'displaytitle', $out->mPageLinkTitle );
- $tpl->set( 'pageclass', $this->getPageClasses( $this->getTitle() ) );
- $tpl->set( 'skinnameclass', ( 'skin-' . Sanitizer::escapeClass( $this->getSkinName() ) ) );
-
- $nsname = MWNamespace::exists( $this->getTitle()->getNamespace() ) ?
- MWNamespace::getCanonicalName( $this->getTitle()->getNamespace() ) :
- $this->getTitle()->getNsText();
- $tpl->set( 'nscanonical', $nsname );
- $tpl->set( 'nsnumber', $this->getTitle()->getNamespace() );
$tpl->set( 'titleprefixeddbkey', $this->getTitle()->getPrefixedDBKey() );
$tpl->set( 'titletext', $this->getTitle()->getText() );
$tpl->set( 'articleid', $this->getTitle()->getArticleId() );
- $tpl->set( 'currevisionid', $this->getTitle()->getLatestRevID() );
$tpl->set( 'isarticle', $out->isArticle() );
$tpl->setRef( 'serverurl', $wgServer );
$tpl->setRef( 'logopath', $wgLogo );
- $lang = wfUILang();
- $tpl->set( 'lang', $lang->getCode() );
- $tpl->set( 'dir', $lang->getDir() );
- $tpl->set( 'rtl', $lang->isRTL() );
+ $contentlang = $wgContLang->getCode();
+ $contentdir = $wgContLang->getDir();
+ $userlang = $wgLang->getCode();
+ $userdir = $wgLang->getDir();
+
+ $tpl->set( 'lang', $userlang );
+ $tpl->set( 'dir', $userdir );
+ $tpl->set( 'rtl', $wgLang->isRTL() );
$tpl->set( 'capitalizeallnouns', $wgLang->capitalizeAllNouns() ? ' capitalize-all-nouns' : '' );
$tpl->set( 'showjumplinks', $wgUser->getOption( 'showjumplinks' ) );
$tpl->set( 'username', $wgUser->isAnon() ? null : $this->username );
$tpl->setRef( 'userpage', $this->userpage );
$tpl->setRef( 'userpageurl', $this->userpageUrlDetails['href'] );
- $tpl->set( 'userlang', $wgLang->getCode() );
+ $tpl->set( 'userlang', $userlang );
// Users can have their language set differently than the
// content of the wiki. For these users, tell the web browser
// that interface elements are in a different language.
$tpl->set( 'userlangattributes', '' );
- $tpl->set( 'specialpageattributes', '' );
-
- $lang = $wgLang->getCode();
- $dir = $wgLang->getDir();
- if ( $lang !== $wgContLang->getCode() || $dir !== $wgContLang->getDir() ) {
- $attrs = " lang='$lang' dir='$dir'";
+ $tpl->set( 'specialpageattributes', '' ); # obsolete
+ if ( $userlang !== $contentlang || $userdir !== $contentdir ) {
+ $attrs = " lang='$userlang' dir='$userdir'";
$tpl->set( 'userlangattributes', $attrs );
-
- // The content of SpecialPages should be presented in the
- // user's language. Content of regular pages should not be touched.
- if( $this->getTitle()->isSpecialPage() ) {
- $tpl->set( 'specialpageattributes', $attrs );
- }
}
- $newtalks = $this->getNewtalks( $out );
-
wfProfileOut( __METHOD__ . '-stuff2' );
wfProfileIn( __METHOD__ . '-stuff3' );
- $tpl->setRef( 'newtalk', $newtalks );
+ $tpl->set( 'newtalk', $this->getNewtalks() );
$tpl->setRef( 'skin', $this );
$tpl->set( 'logo', $this->logoText() );
- if ( $out->isArticle() && ( !isset( $oldid ) || isset( $diff ) ) &&
- $this->getTitle()->exists() )
- {
- $article = new Article( $this->getTitle(), 0 );
- if ( !$wgDisableCounters ) {
- $viewcount = $wgLang->formatNum( $article->getCount() );
- if ( $viewcount ) {
- $tpl->set( 'viewcount', wfMsgExt( 'viewcount', array( 'parseinline' ), $viewcount ) );
- } else {
- $tpl->set( 'viewcount', false );
+
+ $tpl->set( 'copyright', false );
+ $tpl->set( 'viewcount', false );
+ $tpl->set( 'lastmod', false );
+ $tpl->set( 'credits', false );
+ $tpl->set( 'numberofwatchingusers', false );
+ if ( $out->isArticle() && $this->getTitle()->exists() ) {
+ if ( $this->isRevisionCurrent() ) {
+ $article = new Article( $this->getTitle(), 0 );
+ if ( !$wgDisableCounters ) {
+ $viewcount = $wgLang->formatNum( $article->getCount() );
+ if ( $viewcount ) {
+ $tpl->set( 'viewcount', wfMsgExt( 'viewcount', array( 'parseinline' ), $viewcount ) );
+ }
}
- } else {
- $tpl->set( 'viewcount', false );
- }
- if( $wgPageShowWatchingUsers ) {
- $dbr = wfGetDB( DB_SLAVE );
- $res = $dbr->select( 'watchlist',
- array( 'COUNT(*) AS n' ),
- array( 'wl_title' => $dbr->strencode( $this->getTitle()->getDBkey() ), 'wl_namespace' => $this->getTitle()->getNamespace() ),
- __METHOD__
- );
- $x = $dbr->fetchObject( $res );
- $numberofwatchingusers = $x->n;
- if( $numberofwatchingusers > 0 ) {
- $tpl->set( 'numberofwatchingusers',
- wfMsgExt( 'number_of_watching_users_pageview', array( 'parseinline' ),
- $wgLang->formatNum( $numberofwatchingusers ) )
+ if( $wgPageShowWatchingUsers ) {
+ $dbr = wfGetDB( DB_SLAVE );
+ $num = $dbr->selectField( 'watchlist', 'COUNT(*)',
+ array( 'wl_title' => $this->getTitle()->getDBkey(), 'wl_namespace' => $this->getTitle()->getNamespace() ),
+ __METHOD__
);
- } else {
- $tpl->set( 'numberofwatchingusers', false );
+ if( $num > 0 ) {
+ $tpl->set( 'numberofwatchingusers',
+ wfMsgExt( 'number_of_watching_users_pageview', array( 'parseinline' ),
+ $wgLang->formatNum( $num ) )
+ );
+ }
}
- } else {
- $tpl->set( 'numberofwatchingusers', false );
- }
-
- $tpl->set( 'copyright', $this->getCopyright() );
-
- $this->credits = false;
- if( $wgMaxCredits != 0 ){
- $this->credits = Action::factory( 'credits', $article )->getCredits( $wgMaxCredits, $wgShowCreditsIfMax );
- } else {
- $tpl->set( 'lastmod', $this->lastModified( $article ) );
+ if ( $wgMaxCredits != 0 ) {
+ $tpl->set( 'credits', Action::factory( 'credits', $article )->getCredits( $wgMaxCredits, $wgShowCreditsIfMax ) );
+ } else {
+ $tpl->set( 'lastmod', $this->lastModified( $article ) );
+ }
}
-
- $tpl->setRef( 'credits', $this->credits );
-
- } elseif ( isset( $oldid ) && !isset( $diff ) ) {
$tpl->set( 'copyright', $this->getCopyright() );
- $tpl->set( 'viewcount', false );
- $tpl->set( 'lastmod', false );
- $tpl->set( 'credits', false );
- $tpl->set( 'numberofwatchingusers', false );
- } else {
- $tpl->set( 'copyright', false );
- $tpl->set( 'viewcount', false );
- $tpl->set( 'lastmod', false );
- $tpl->set( 'credits', false );
- $tpl->set( 'numberofwatchingusers', false );
}
wfProfileOut( __METHOD__ . '-stuff3' );
$tpl->set( 'reporttime', wfReportTime() );
$tpl->set( 'sitenotice', $this->getSiteNotice() );
- $tpl->set( 'bottomscripts', $this->bottomScripts( $out ) );
+ $tpl->set( 'bottomscripts', $this->bottomScripts() );
$tpl->set( 'printfooter', $this->printSource() );
- global $wgBetterDirectionality;
- if ( $wgBetterDirectionality && $this->getTitle()->getNamespace() != NS_SPECIAL ) {
- if( $this->getTitle()->getNamespace() == NS_MEDIAWIKI ) {
- // If the page is in the MediaWiki NS, the lang and dir attribute should depend on that,
- // i.e. MediaWiki:Message/ar -> lang=ar, dir=rtl. This assumes every message is translated,
- // but it's anyway better than assuming it is always in the content lang
- $nsMWTitle = $wgContLang->lcfirst( $this->getTitle()->getText() );
- list( $nsMWName, $nsMWLang ) = MessageCache::singleton()->figureMessage( $nsMWTitle );
- $nsMWDir = Language::factory( $nsMWLang )->getDir();
- $realBodyAttribs = array( 'lang' => $nsMWLang, 'dir' => $nsMWDir );
- } else {
- // Body text is in the site content language (see also bug 6100 and 28970)
- $realBodyAttribs = array( 'lang' => $wgLanguageCode, 'dir' => $wgContLang->getDir() );
- }
+ # Add a <div class="mw-content-ltr/rtl"> around the body text
+ # not for special pages or file pages AND only when viewing AND if the page exists
+ # (or is in MW namespace, because that has default content)
+ if( !in_array( $this->getTitle()->getNamespace(), array( NS_SPECIAL, NS_FILE ) ) &&
+ in_array( $wgRequest->getVal( 'action', 'view' ), array( 'view', 'historysubmit' ) ) &&
+ ( $this->getTitle()->exists() || $this->getTitle()->getNamespace() == NS_MEDIAWIKI ) ) {
+ $pageLang = $this->getTitle()->getPageLanguage();
+ $realBodyAttribs = array( 'lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir(),
+ 'class' => 'mw-content-'.$pageLang->getDir() );
$out->mBodytext = Html::rawElement( 'div', $realBodyAttribs, $out->mBodytext );
}
+
$tpl->setRef( 'bodytext', $out->mBodytext );
# Language links
/* set up the default links for the personal toolbar */
$personal_urls = array();
- // Get the returnto and returntoquery parameters from the query string
- // or fall back on $this->thisurl or $this->thisquery
- // We can't use getVal()'s default value feature here because
- // stuff from $wgRequest needs to be escaped, but thisurl and thisquery
- // are already escaped.
- $page = $wgRequest->getVal( 'returnto' );
- if ( !is_null( $page ) ) {
- $page = wfUrlencode( $page );
- } else {
- $page = $this->thisurl;
- }
- $query = $wgRequest->getVal( 'returntoquery' );
- if ( !is_null( $query ) ) {
- $query = wfUrlencode( $query );
- } else {
- $query = $this->thisquery;
- }
- $returnto = "returnto=$page";
+ $page = $wgRequest->getVal( 'returnto', $this->thispage );
+ $query = $wgRequest->getVal( 'returntoquery', $this->thisquery );
+ $a = array( 'returnto' => $page );
if( $query != '' ) {
- $returnto .= "&returntoquery=$query";
+ $a['returntoquery'] = $query;
}
+ $returnto = wfArrayToCGI( $a );
if( $this->loggedin ) {
$personal_urls['userpage'] = array(
'text' => $this->username,
}
} else {
// article doesn't exist or is deleted
- if ( $wgUser->isAllowed( 'deletedhistory' ) ) {
- $n = $title->isDeleted();
+ if ( $wgUser->isAllowed( 'deletedhistory' ) && !$wgUser->isBlocked() ) {
+ $includeSuppressed = $wgUser->isAllowed( 'suppressrevision' );
+ $n = $title->isDeleted( $includeSuppressed );
if( $n ) {
$undelTitle = SpecialPage::getTitleFor( 'Undelete' );
// If the user can't undelete but can view deleted history show them a "View .. deleted" tab instead
wfProfileIn( __METHOD__ );
- $action = $wgRequest->getVal( 'action', 'view' );
-
$nav_urls = array();
$nav_urls['mainpage'] = array( 'href' => self::makeMainPageUrl() );
if( $wgUploadNavigationUrl ) {
// 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( $out->isArticle() ) {
if ( !$out->isPrintable() ) {
$nav_urls['print'] = array(
'text' => wfMsg( 'printableversion' ),
global $wgRequest, $wgJsMimeType;
wfProfileIn( __METHOD__ );
- $action = $wgRequest->getVal( 'action', 'view' );
-
if( $allowUserJs && $this->loggedin ) {
- if( $this->getTitle()->isJsSubpage() and $this->userCanPreview( $action ) ) {
+ if( $this->getTitle()->isJsSubpage() and $this->getOutput()->userCanPreview() ) {
# XXX: additional security check/prompt?
$this->userjsprev = '/*<![CDATA[*/ ' . $wgRequest->getText( 'wpTextbox1' ) . ' /*]]>*/';
} else {
wfProfileOut( __METHOD__ );
}
- /**
- * Code for extensions to hook into to provide per-page CSS, see
- * extensions/PageCSS/PageCSS.php for an implementation of this.
- *
- * @private
- */
- function setupPageCss() {
- wfProfileIn( __METHOD__ );
- $out = false;
- wfRunHooks( 'SkinTemplateSetupPageCss', array( &$out ) );
- wfProfileOut( __METHOD__ );
- return $out;
- }
-
public function commonPrintStylesheet() {
return false;
}
* @private
*/
function msgWiki( $str ) {
- global $wgParser, $wgOut;
+ global $wgOut;
$text = $this->translator->translate( $str );
- $parserOutput = $wgParser->parse( $text, $wgOut->getTitle(),
- $wgOut->parserOptions(), true );
- echo $parserOutput->getText();
+ echo $wgOut->parse( $text );
}
/**
}
$attrs = array();
- foreach ( array( 'href', 'id', 'class', 'rel', 'type' ) as $attr ) {
+ foreach ( array( 'href', 'id', 'class', 'rel', 'type', 'target') as $attr ) {
if ( isset( $item[$attr] ) ) {
$attrs[$attr] = $item[$attr];
}
} else {
$attrs = array_merge(
$attrs,
- $this->skin->tooltipAndAccesskeyAttribs( $item['single-id'] )
+ Linker::tooltipAndAccesskeyAttribs( $item['single-id'] )
);
}
}
}
} else {
$link = array();
- foreach ( array( 'text', 'msg', 'href', 'rel', 'type', 'tooltiponly' ) as $k ) {
+ foreach ( array( 'text', 'msg', 'href', 'rel', 'type', 'tooltiponly', 'target' ) as $k ) {
if ( isset( $item[$k] ) ) {
$link[$k] = $item[$k];
}
'name' => 'search',
'value' => isset( $this->data['search'] ) ? $this->data['search'] : '',
);
- $realAttrs = array_merge( $realAttrs, $this->skin->tooltipAndAccesskeyAttribs( 'search' ), $attrs );
+ $realAttrs = array_merge( $realAttrs, Linker::tooltipAndAccesskeyAttribs( 'search' ), $attrs );
return Html::element( 'input', $realAttrs );
}
);
$realAttrs = array_merge(
$realAttrs,
- $this->skin->tooltipAndAccesskeyAttribs( "search-$mode" ),
+ Linker::tooltipAndAccesskeyAttribs( "search-$mode" ),
$attrs
);
return Html::element( 'input', $realAttrs );
);
$buttonAttrs = array_merge(
$buttonAttrs,
- $this->skin->tooltipAndAccesskeyAttribs( 'search-fulltext' ),
+ Linker::tooltipAndAccesskeyAttribs( 'search-fulltext' ),
$attrs
);
unset( $buttonAttrs['src'] );