var $mArticleBodyOnly = false;
var $mNewSectionLink = false;
+ var $mHideNewSectionLink = false;
var $mNoGallery = false;
var $mPageTitleActionText = '';
var $mParseWarnings = array();
*
* @return bool True iff cache-ok headers was sent.
*/
- function checkLastModified ( $timestamp ) {
+ function checkLastModified( $timestamp ) {
global $wgCachePages, $wgCacheEpoch, $wgUser, $wgRequest;
if ( !$timestamp || $timestamp == '19700101000000' ) {
# Not modified
# Give a 304 response code and disable body output
wfDebug( __METHOD__ . ": NOT MODIFIED, $info\n", false );
+ ini_set('zlib.output_compression', 0);
$wgRequest->response()->header( "HTTP/1.1 304 Not Modified" );
$this->sendCacheControl();
$this->disable();
}
}
- public function setHTMLTitle( $name ) {$this->mHTMLtitle = $name; }
+ public function setHTMLTitle( $name ) { $this->mHTMLtitle = $name; }
public function setPageTitle( $name ) {
- global $action, $wgContLang;
- $name = $wgContLang->convert($name, true);
+ global $wgContLang;
+ $name = $wgContLang->convert( $name, true );
$this->mPagetitle = $name;
- if(!empty($action)) {
- $taction = $this->getPageTitleActionText();
- if( !empty( $taction ) ) {
- $name .= ' - '.$taction;
- }
+
+ $taction = $this->getPageTitleActionText();
+ if( !empty( $taction ) ) {
+ $name .= ' - '.$taction;
}
$this->setHTMLTitle( wfMsg( 'pagetitle', $name ) );
}
+
public function getHTMLTitle() { return $this->mHTMLtitle; }
public function getPageTitle() { return $this->mPagetitle; }
public function setSubtitle( $str ) { $this->mSubtitle = /*$this->parse(*/$str/*)*/; } // @bug 2514
public function setOnloadHandler( $js ) { $this->mOnloadHandler = $js; }
public function getOnloadHandler() { return $this->mOnloadHandler; }
public function disable() { $this->mDoNothing = true; }
+ public function isDisabled() { return $this->mDoNothing; }
public function setArticleRelated( $v ) {
$this->mIsArticleRelated = $v;
if ( wfRunHooks( 'OutputPageMakeCategoryLinks', array( &$this, $categories, &$this->mCategoryLinks ) ) ) {
$sk = $wgUser->getSkin();
foreach ( $categories as $category => $type ) {
+ $origcategory = $category;
$title = Title::makeTitleSafe( NS_CATEGORY, $category );
+ $wgContLang->findVariantLink( $category, $title, true );
+ if ( $category != $origcategory )
+ if ( array_key_exists( $category, $categories ) )
+ continue;
$text = $wgContLang->convertHtml( $title->getText() );
$this->mCategoryLinks[$type][] = $sk->makeLinkObj( $title, $text );
}
$this->mLanguageLinks += $parserOutput->getLanguageLinks();
$this->addCategoryLinks( $parserOutput->getCategories() );
$this->mNewSectionLink = $parserOutput->getNewSection();
+ $this->mHideNewSectionLink = $parserOutput->getHideNewSection();
if( is_null( $wgExemptFromUserRobotsControl ) ) {
$bannedNamespaces = $wgContentNamespaces;
$this->mNoGallery = $parserOutput->getNoGallery();
$this->mHeadItems = array_merge( $this->mHeadItems, (array)$parserOutput->mHeadItems );
// Versioning...
- $this->mTemplateIds = wfArrayMerge( $this->mTemplateIds, (array)$parserOutput->mTemplateIds );
-
- // Display title
+ foreach ( (array)$parserOutput->mTemplateIds as $ns => $dbks ) {
+ if ( isset( $this->mTemplateIds[$ns] ) ) {
+ $this->mTemplateIds[$ns] = $dbks + $this->mTemplateIds[$ns];
+ } else {
+ $this->mTemplateIds[$ns] = $dbks;
+ }
+ }
+ // Page title
if( ( $dt = $parserOutput->getDisplayTitle() ) !== false )
$this->setPageTitle( $dt );
+ else if ( ( $title = $parserOutput->getTitleText() ) != '' )
+ $this->setPageTitle( $title );
// Hooks registered in the object
global $wgParserOutputHooks;
$popts->setTidy(false);
if ( $cache && $article && $parserOutput->getCacheTime() != -1 ) {
$parserCache = ParserCache::singleton();
- $parserCache->save( $parserOutput, $article, $wgUser );
+ $parserCache->save( $parserOutput, $article, $popts);
}
$this->addParserOutput( $parserOutput );
*/
public function parse( $text, $linestart = true, $interface = false ) {
global $wgParser, $wgTitle;
+ if( is_null( $wgTitle ) ) {
+ throw new MWException( 'Empty $wgTitle in ' . __METHOD__ );
+ }
$popts = $this->parserOptions();
if ( $interface) { $popts->setInterfaceMessage(true); }
$parserOutput = $wgParser->parse( $text, $wgTitle, $popts,
return $parserOutput->getText();
}
+ /** Parse wikitext, strip paragraphs, and return the HTML. */
+ public function parseInline( $text, $linestart = true, $interface = false ) {
+ $parsed = $this->parse( $text, $linestart, $interface );
+
+ $m = array();
+ if ( preg_match( '/^<p>(.*)\n?<\/p>\n?/sU', $parsed, $m ) ) {
+ $parsed = $m[1];
+ }
+
+ return $parsed;
+ }
+
/**
* @param Article $article
* @param User $user
*
* @return bool True if successful, else false.
*/
- public function tryParserCache( &$article, $user ) {
+ public function tryParserCache( &$article ) {
$parserCache = ParserCache::singleton();
- $parserOutput = $parserCache->get( $article, $user );
+ $parserOutput = $parserCache->get( $article, $this->parserOptions() );
if ( $parserOutput !== false ) {
$this->addParserOutput( $parserOutput );
return true;
* If it does, it's very important that we don't allow public caching
*/
function haveCacheVaryCookies() {
- global $wgRequest, $wgCookiePrefix;
+ global $wgRequest;
$cookieHeader = $wgRequest->getHeader( 'cookie' );
if ( $cookieHeader === false ) {
return false;
/** Get a complete X-Vary-Options header */
public function getXVO() {
- global $wgCookiePrefix;
$cvCookies = $this->getCacheVaryCookies();
$xvo = 'X-Vary-Options: Accept-Encoding;list-contains=gzip,Cookie;';
$first = true;
global $wgUser, $wgOutputEncoding, $wgRequest;
global $wgContLanguageCode, $wgDebugRedirects, $wgMimeType;
global $wgJsMimeType, $wgUseAjax, $wgAjaxWatch;
- global $wgEnableMWSuggest;
+ global $wgEnableMWSuggest, $wgUniversalEditButton;
+ global $wgArticle, $wgTitle;
if( $this->mDoNothing ){
return;
$this->addScriptFile( 'rightclickedit.js' );
}
+ if( $wgUniversalEditButton ) {
+ if( isset( $wgArticle ) && isset( $wgTitle ) && $wgTitle->quickUserCan( 'edit' )
+ && ( $wgTitle->exists() || $wgTitle->quickUserCan( 'create' ) ) ) {
+ // Original UniversalEditButton
+ $this->addLink( array(
+ 'rel' => 'alternate',
+ 'type' => 'application/x-wiki',
+ 'title' => wfMsg( 'edit' ),
+ 'href' => $wgTitle->getLocalURL( 'action=edit' )
+ ) );
+ // Alternate edit link
+ $this->addLink( array(
+ 'rel' => 'edit',
+ 'title' => wfMsg( 'edit' ),
+ 'href' => $wgTitle->getLocalURL( 'action=edit' )
+ ) );
+ }
+ }
+
# Buffer output; final headers may depend on later processing
ob_start();
array_unshift( $params, 'parse' );
array_unshift( $params, $msg );
- $this->addHtml( call_user_func_array( 'wfMsgExt', $params ) );
+ $this->addHTML( call_user_func_array( 'wfMsgExt', $params ) );
$this->returnToMain();
}
* @param string $permission key required
*/
public function permissionRequired( $permission ) {
- global $wgUser;
+ global $wgUser, $wgLang;
$this->setPageTitle( wfMsg( 'badaccess' ) );
$this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
User::getGroupsWithPermission( $permission ) );
if( $groups ) {
$this->addWikiMsg( 'badaccess-groups',
- implode( ', ', $groups ),
+ $wgLang->commaList( $groups ),
count( $groups) );
} else {
$this->addWikiMsg( 'badaccess-group0' );
$loginTitle = SpecialPage::getTitleFor( 'Userlogin' );
$loginLink = $skin->makeKnownLinkObj( $loginTitle, wfMsgHtml( 'loginreqlink' ), 'returnto=' . $wgTitle->getPrefixedUrl() );
- $this->addHtml( wfMsgWikiHtml( 'loginreqpagetext', $loginLink ) );
- $this->addHtml( "\n<!--" . $wgTitle->getPrefixedUrl() . "-->" );
+ $this->addHTML( wfMsgWikiHtml( 'loginreqpagetext', $loginLink ) );
+ $this->addHTML( "\n<!--" . $wgTitle->getPrefixedUrl() . "-->" );
# Don't return to the main page if the user can't read it
# otherwise we'll end up in a pointless loop
$text = wfMsgNoTrans( 'permissionserrorstext', count($errors)). "\n\n";
} else {
global $wgLang;
- $action_desc = wfMsg( "right-$action" );
- $action_desc = $wgLang->lcfirst( $action_desc ); // FIXME: TERRIBLE HACK
+ $action_desc = wfMsg( "action-$action" );
$text = wfMsgNoTrans( 'permissionserrorstext-withaction', count($errors), $action_desc ) . "\n\n";
}
*/
public function addReturnTo( $title ) {
global $wgUser;
+ $this->addLink( array( 'rel' => 'next', 'href' => $title->getFullUrl() ) );
$link = wfMsg( 'returnto', $wgUser->getSkin()->makeLinkObj( $title ) );
- $this->addHtml( "<p>{$link}</p>\n" );
+ $this->addHTML( "<p>{$link}</p>\n" );
}
/**
$ret = '';
if( $wgMimeType == 'text/xml' || $wgMimeType == 'application/xhtml+xml' || $wgMimeType == 'application/xml' ) {
- $ret .= "<?xml version=\"1.0\" encoding=\"$wgOutputEncoding\" ?>\n";
+ $ret .= "<?xml version=\"1.0\" encoding=\"$wgOutputEncoding\" ?" . ">\n";
}
$ret .= "<!DOCTYPE html PUBLIC \"$wgDocType\"\n \"$wgDTD\">\n";
protected function addDefaultMeta() {
global $wgVersion;
- $this->addMeta( "generator", "MediaWiki $wgVersion" );
+ $this->addMeta( 'http:Content-Style-Type', 'text/css' ); //bug 15835
+ $this->addMeta( 'generator', "MediaWiki $wgVersion" );
$p = "{$this->mIndexPolicy},{$this->mFollowPolicy}";
if( $p !== 'index,follow' ) {
if ( count( $this->mKeywords ) > 0 ) {
$strip = array(
- "/<.*?>/" => '',
+ "/<.*?" . ">/" => '',
"/_/" => ' '
);
$this->addMeta( 'keywords', preg_replace(array_keys($strip), array_values($strip),implode( ",", $this->mKeywords ) ) );
# or "Breaking news" one). For this, we see if $wgOverrideSiteFeed is defined.
# If so, use it instead.
- global $wgOverrideSiteFeed, $wgSitename;
+ global $wgOverrideSiteFeed, $wgSitename, $wgFeedClasses;
$rctitle = SpecialPage::getTitleFor( 'Recentchanges' );
if ( $wgOverrideSiteFeed ) {
}
}
else if ( $wgTitle->getPrefixedText() != $rctitle->getPrefixedText() ) {
- $tags[] = $this->feedLink(
- 'rss',
- $rctitle->getFullURL( 'feed=rss' ),
- wfMsg( 'site-rss-feed', $wgSitename ) );
- $tags[] = $this->feedLink(
- 'atom',
- $rctitle->getFullURL( 'feed=atom' ),
- wfMsg( 'site-atom-feed', $wgSitename ) );
+ foreach( $wgFeedClasses as $format => $class ) {
+ $tags[] = $this->feedLink(
+ $format,
+ $rctitle->getLocalURL( "feed={$format}" ),
+ wfMsg( "site-{$format}-feed", $wgSitename ) ); # For grep: 'site-rss-feed', 'site-atom-feed'.
+ }
}
}
return $this->mNewSectionLink;
}
+ /**
+ * Forcibly hide the new section link?
+ *
+ * @return bool
+ */
+ public function forceHideNewSectionLink() {
+ return $this->mHideNewSectionLink;
+ }
+
/**
* Show a warning about slave lag
*
? 'lag-warn-normal'
: 'lag-warn-high';
$warning = wfMsgExt( $message, 'parse', $lag );
- $this->addHtml( "<div class=\"mw-{$message}\">\n{$warning}\n</div>\n" );
+ $this->addHTML( "<div class=\"mw-{$message}\">\n{$warning}\n</div>\n" );
}
}
$args = array();
$name = $spec;
}
- $s = str_replace( '$' . ($n+1), wfMsgExt( $name, $options, $args ), $s );
+ $s = str_replace( '$' . ( $n + 1 ), wfMsgExt( $name, $options, $args ), $s );
}
$this->addHTML( $this->parse( $s, /*linestart*/true, /*uilang*/true ) );
}