7 * This is not a valid entry point, perform no further processing unless MEDIAWIKI is defined
9 if( defined( 'MEDIAWIKI' ) ) {
13 if($wgUseTeX) require_once( 'Math.php' );
20 var $mHeaders, $mCookies, $mMetatags, $mKeywords;
21 var $mLinktags, $mPagetitle, $mBodytext, $mDebugtext;
22 var $mHTMLtitle, $mRobotpolicy, $mIsarticle, $mPrintable;
23 var $mSubtitle, $mRedirect;
24 var $mLastModified, $mETag, $mCategoryLinks;
25 var $mScripts, $mLinkColours;
27 var $mSuppressQuickbar;
30 var $mContainsOldMagic, $mContainsNewMagic;
31 var $mIsArticleRelated;
33 var $mShowFeedLinks = false;
34 var $mEnableClientCache = true;
35 var $mArticleBodyOnly = false;
39 * Initialise private variables
41 function OutputPage() {
42 $this->mHeaders
= $this->mCookies
= $this->mMetatags
=
43 $this->mKeywords
= $this->mLinktags
= array();
44 $this->mHTMLtitle
= $this->mPagetitle
= $this->mBodytext
=
45 $this->mRedirect
= $this->mLastModified
=
46 $this->mSubtitle
= $this->mDebugtext
= $this->mRobotpolicy
=
47 $this->mOnloadHandler
= '';
48 $this->mIsArticleRelated
= $this->mIsarticle
= $this->mPrintable
= true;
49 $this->mSuppressQuickbar
= $this->mPrintable
= false;
50 $this->mLanguageLinks
= array();
51 $this->mCategoryLinks
= array() ;
52 $this->mDoNothing
= false;
53 $this->mContainsOldMagic
= $this->mContainsNewMagic
= 0;
54 $this->mParserOptions
= ParserOptions
::newFromUser( $temp = NULL );
55 $this->mSquidMaxage
= 0;
60 function addHeader( $name, $val ) { array_push( $this->mHeaders
, $name.': '.$val ) ; }
61 function addCookie( $name, $val ) { array_push( $this->mCookies
, array( $name, $val ) ); }
62 function redirect( $url, $responsecode = '302' ) { $this->mRedirect
= $url; $this->mRedirectCode
= $responsecode; }
64 # To add an http-equiv meta tag, precede the name with "http:"
65 function addMeta( $name, $val ) { array_push( $this->mMetatags
, array( $name, $val ) ); }
66 function addKeyword( $text ) { array_push( $this->mKeywords
, $text ); }
67 function addScript( $script ) { $this->mScripts
.= $script; }
68 function getScript() { return $this->mScripts
; }
70 function setETag($tag) { $this->mETag
= $tag; }
71 function setArticleBodyOnly($only) { $this->mArticleBodyOnly
= $only; }
72 function getArticleBodyOnly($only) { return $this->mArticleBodyOnly
; }
74 function addLink( $linkarr ) {
75 # $linkarr should be an associative array of attributes. We'll escape on output.
76 array_push( $this->mLinktags
, $linkarr );
79 function addMetadataLink( $linkarr ) {
80 # note: buggy CC software only reads first "meta" link
81 static $haveMeta = false;
82 $linkarr['rel'] = ($haveMeta) ?
'alternate meta' : 'meta';
83 $this->addLink( $linkarr );
88 * checkLastModified tells the client to use the client-cached page if
89 * possible. If sucessful, the OutputPage is disabled so that
90 * any future call to OutputPage->output() have no effect. The method
91 * returns true iff cache-ok headers was sent.
93 function checkLastModified ( $timestamp ) {
94 global $wgLang, $wgCachePages, $wgUser;
95 if ( !$timestamp ||
$timestamp == '19700101000000' ) {
96 wfDebug( "CACHE DISABLED, NO TIMESTAMP\n" );
99 if( !$wgCachePages ) {
100 wfDebug( "CACHE DISABLED\n", false );
103 if( $wgUser->getOption( 'nocache' ) ) {
104 wfDebug( "USER DISABLED CACHE\n", false );
108 $timestamp=wfTimestamp(TS_MW
,$timestamp);
109 $lastmod = wfTimestamp( TS_RFC2822
, max( $timestamp, $wgUser->mTouched
) );
111 if( !empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) {
112 # IE sends sizes after the date like this:
113 # Wed, 20 Aug 2003 06:51:19 GMT; length=5202
114 # this breaks strtotime().
115 $modsince = preg_replace( '/;.*$/', '', $_SERVER["HTTP_IF_MODIFIED_SINCE"] );
116 $modsinceTime = strtotime( $modsince );
117 $ismodsince = wfTimestamp( TS_MW
, $modsinceTime ?
$modsinceTime : 1 );
118 wfDebug( "-- client send If-Modified-Since: " . $modsince . "\n", false );
119 wfDebug( "-- we might send Last-Modified : $lastmod\n", false );
120 if( ($ismodsince >= $timestamp ) && $wgUser->validateCache( $ismodsince ) ) {
121 # Make sure you're in a place you can leave when you call us!
122 header( "HTTP/1.0 304 Not Modified" );
123 $this->mLastModified
= $lastmod;
124 $this->sendCacheControl();
125 wfDebug( "CACHED client: $ismodsince ; user: $wgUser->mTouched ; page: $timestamp\n", false );
127 @ob_end_clean
(); // Don't output compressed blob
130 wfDebug( "READY client: $ismodsince ; user: $wgUser->mTouched ; page: $timestamp\n", false );
131 $this->mLastModified
= $lastmod;
134 wfDebug( "client did not send If-Modified-Since header\n", false );
135 $this->mLastModified
= $lastmod;
139 function getPageTitleActionText () {
143 return wfMsg('edit');
145 return wfMsg('history_short');
147 return wfMsg('protect');
149 return wfMsg('unprotect');
151 return wfMsg('delete');
153 return wfMsg('watch');
155 return wfMsg('unwatch');
157 return wfMsg('preview');
159 return wfMsg('info_short');
165 function setRobotpolicy( $str ) { $this->mRobotpolicy
= $str; }
166 function setHTMLTitle( $name ) {$this->mHTMLtitle
= $name; }
167 function setPageTitle( $name ) {
168 global $action, $wgContLang;
169 $name = $wgContLang->convert($name, true);
170 $this->mPagetitle
= $name;
171 if(!empty($action)) {
172 $taction = $this->getPageTitleActionText();
173 if( !empty( $taction ) ) {
174 $name .= ' - '.$taction;
177 $this->setHTMLTitle( $name . ' - ' . wfMsg( 'wikititlesuffix' ) );
179 function getHTMLTitle() { return $this->mHTMLtitle
; }
180 function getPageTitle() { return $this->mPagetitle
; }
181 function setSubtitle( $str ) { $this->mSubtitle
= /*$this->parse(*/$str/*)*/; } // @bug 2514
182 function getSubtitle() { return $this->mSubtitle
; }
183 function isArticle() { return $this->mIsarticle
; }
184 function setPrintable() { $this->mPrintable
= true; }
185 function isPrintable() { return $this->mPrintable
; }
186 function setSyndicated( $show = true ) { $this->mShowFeedLinks
= $show; }
187 function isSyndicated() { return $this->mShowFeedLinks
; }
188 function setOnloadHandler( $js ) { $this->mOnloadHandler
= $js; }
189 function getOnloadHandler() { return $this->mOnloadHandler
; }
190 function disable() { $this->mDoNothing
= true; }
192 function setArticleRelated( $v ) {
193 $this->mIsArticleRelated
= $v;
195 $this->mIsarticle
= false;
198 function setArticleFlag( $v ) {
199 $this->mIsarticle
= $v;
201 $this->mIsArticleRelated
= $v;
205 function isArticleRelated() { return $this->mIsArticleRelated
; }
207 function getLanguageLinks() { return $this->mLanguageLinks
; }
208 function addLanguageLinks($newLinkArray) {
209 $this->mLanguageLinks +
= $newLinkArray;
211 function setLanguageLinks($newLinkArray) {
212 $this->mLanguageLinks
= $newLinkArray;
215 function getCategoryLinks() {
216 return $this->mCategoryLinks
;
218 function addCategoryLinks($newLinkArray) {
219 $this->mCategoryLinks +
= $newLinkArray;
221 function setCategoryLinks($newLinkArray) {
222 $this->mCategoryLinks +
= $newLinkArray;
225 function suppressQuickbar() { $this->mSuppressQuickbar
= true; }
226 function isQuickbarSuppressed() { return $this->mSuppressQuickbar
; }
228 function addHTML( $text ) { $this->mBodytext
.= $text; }
229 function clearHTML() { $this->mBodytext
= ''; }
230 function getHTML() { return $this->mBodytext
; }
231 function debug( $text ) { $this->mDebugtext
.= $text; }
233 function setParserOptions( $options ) {
234 return wfSetVar( $this->mParserOptions
, $options );
238 * Convert wikitext to HTML and add it to the buffer
239 * Default assumes that the current page title will
242 function addWikiText( $text, $linestart = true ) {
244 $this->addWikiTextTitle($text, $wgTitle, $linestart);
247 function addWikiTextWithTitle($text, &$title, $linestart = true) {
248 $this->addWikiTextTitle($text, $title, $linestart);
251 function addWikiTextTitle($text, &$title, $linestart) {
252 global $wgParser, $wgUseTidy;
253 $parserOutput = $wgParser->parse( $text, $title, $this->mParserOptions
, $linestart );
254 $this->mLanguageLinks +
= $parserOutput->getLanguageLinks();
255 $this->mCategoryLinks +
= $parserOutput->getCategoryLinks();
256 if ( $parserOutput->getCacheTime() == -1 ) {
257 $this->enableClientCache( false );
259 $this->addHTML( $parserOutput->getText() );
263 * Add wikitext to the buffer, assuming that this is the primary text for a page view
264 * Saves the text into the parser cache if possible
266 function addPrimaryWikiText( $text, $cacheArticle ) {
267 global $wgParser, $wgParserCache, $wgUser, $wgTitle, $wgUseTidy;
269 $parserOutput = $wgParser->parse( $text, $wgTitle, $this->mParserOptions
, true );
271 $text = $parserOutput->getText();
273 if ( $cacheArticle && $parserOutput->getCacheTime() != -1 ) {
274 $wgParserCache->save( $parserOutput, $cacheArticle, $wgUser );
277 $this->mLanguageLinks +
= $parserOutput->getLanguageLinks();
278 $this->mCategoryLinks +
= $parserOutput->getCategoryLinks();
279 if ( $parserOutput->getCacheTime() == -1 ) {
280 $this->enableClientCache( false );
282 $this->addHTML( $text );
286 * Add the output of a QuickTemplate to the output buffer
287 * @param QuickTemplate $template
289 function addTemplate( &$template ) {
291 $template->execute();
292 $this->addHtml( ob_get_contents() );
297 * Parse wikitext and return the HTML. This is for special pages that add the text later
299 function parse( $text, $linestart = true ) {
300 global $wgParser, $wgTitle;
301 $parserOutput = $wgParser->parse( $text, $wgTitle, $this->mParserOptions
, $linestart );
302 return $parserOutput->getText();
311 function tryParserCache( $article, $user ) {
312 global $wgParserCache;
313 $parserOutput = $wgParserCache->get( $article, $user );
314 if ( $parserOutput !== false ) {
315 $this->mLanguageLinks +
= $parserOutput->getLanguageLinks();
316 $this->mCategoryLinks +
= $parserOutput->getCategoryLinks();
317 $this->addHTML( $parserOutput->getText() );
318 $t = $parserOutput->getTitleText();
320 $this->setPageTitle( $t );
329 * Set the maximum cache time on the Squid in seconds
332 function setSquidMaxage( $maxage ) {
333 $this->mSquidMaxage
= $maxage;
337 * Use enableClientCache(false) to force it to send nocache headers
340 function enableClientCache( $state ) {
341 return wfSetVar( $this->mEnableClientCache
, $state );
344 function uncacheableBecauseRequestvars() {
346 return $wgRequest->getText('useskin', false) === false
347 && $wgRequest->getText('uselang', false) === false;
350 function sendCacheControl() {
351 global $wgUseSquid, $wgUseESI;
354 header("ETag: $this->mETag");
356 # don't serve compressed data to clients who can't handle it
357 # maintain different caches for logged-in users and non-logged in ones
358 header( 'Vary: Accept-Encoding, Cookie' );
359 if( !$this->uncacheableBecauseRequestvars() && $this->mEnableClientCache
) {
360 if( $wgUseSquid && ! isset( $_COOKIE[ini_get( 'session.name') ] ) &&
361 ! $this->isPrintable() && $this->mSquidMaxage
!= 0 )
364 # We'll purge the proxy cache explicitly, but require end user agents
365 # to revalidate against the proxy on each visit.
366 # Surrogate-Control controls our Squid, Cache-Control downstream caches
367 wfDebug( "** proxy caching with ESI; {$this->mLastModified} **\n", false );
368 # start with a shorter timeout for initial testing
369 # header( 'Surrogate-Control: max-age=2678400+2678400, content="ESI/1.0"');
370 header( 'Surrogate-Control: max-age='.$wgSquidMaxage.'+'.$this->mSquidMaxage
.', content="ESI/1.0"');
371 header( 'Cache-Control: s-maxage=0, must-revalidate, max-age=0' );
373 # We'll purge the proxy cache for anons explicitly, but require end user agents
374 # to revalidate against the proxy on each visit.
375 # IMPORTANT! The Squid needs to replace the Cache-Control header with
376 # Cache-Control: s-maxage=0, must-revalidate, max-age=0
377 wfDebug( "** local proxy caching; {$this->mLastModified} **\n", false );
378 # start with a shorter timeout for initial testing
379 # header( "Cache-Control: s-maxage=2678400, must-revalidate, max-age=0" );
380 header( 'Cache-Control: s-maxage='.$this->mSquidMaxage
.', must-revalidate, max-age=0' );
383 # We do want clients to cache if they can, but they *must* check for updates
384 # on revisiting the page.
385 wfDebug( "** private caching; {$this->mLastModified} **\n", false );
386 header( "Expires: -1" );
387 header( "Cache-Control: private, must-revalidate, max-age=0" );
389 if($this->mLastModified
) header( "Last-modified: {$this->mLastModified}" );
391 wfDebug( "** no caching **\n", false );
393 # In general, the absence of a last modified header should be enough to prevent
394 # the client from using its cache. We send a few other things just to make sure.
395 header( 'Expires: -1' );
396 header( 'Cache-Control: no-cache, no-store, max-age=0, must-revalidate' );
397 header( 'Pragma: no-cache' );
402 * Finally, all the text has been munged and accumulated into
403 * the object, let's actually output it:
406 global $wgUser, $wgLang, $wgDebugComments, $wgCookieExpiration;
407 global $wgInputEncoding, $wgOutputEncoding, $wgContLanguageCode;
408 global $wgDebugRedirects, $wgMimeType, $wgProfiler;
410 if( $this->mDoNothing
){
413 $fname = 'OutputPage::output';
414 wfProfileIn( $fname );
415 $sk = $wgUser->getSkin();
417 if ( '' != $this->mRedirect
) {
418 if( substr( $this->mRedirect
, 0, 4 ) != 'http' ) {
419 # Standards require redirect URLs to be absolute
421 $this->mRedirect
= $wgServer . $this->mRedirect
;
423 if( $this->mRedirectCode
== '301') {
424 if( !$wgDebugRedirects ) {
425 header("HTTP/1.1 {$this->mRedirectCode} Moved Permanently");
427 $this->mLastModified
= wfTimestamp( TS_RFC2822
);
430 $this->sendCacheControl();
432 if( $wgDebugRedirects ) {
433 $url = htmlspecialchars( $this->mRedirect
);
434 print "<html>\n<head>\n<title>Redirect</title>\n</head>\n<body>\n";
435 print "<p>Location: <a href=\"$url\">$url</a></p>\n";
436 print "</body>\n</html>\n";
438 header( 'Location: '.$this->mRedirect
);
440 if ( isset( $wgProfiler ) ) { wfDebug( $wgProfiler->getOutput() ); }
445 # Buffer output; final headers may depend on later processing
448 $this->transformBuffer();
450 # Disable temporary placeholders, so that the skin produces HTML
451 $sk->postParseLinkColour( false );
453 header( "Content-type: $wgMimeType; charset={$wgOutputEncoding}" );
454 header( 'Content-language: '.$wgContLanguageCode );
456 $exp = time() +
$wgCookieExpiration;
457 foreach( $this->mCookies
as $name => $val ) {
458 setcookie( $name, $val, $exp, '/' );
461 if ($this->mArticleBodyOnly
) {
462 $this->out($this->mBodytext
);
464 wfProfileIn( 'Output-skin' );
465 $sk->outputPage( $this );
466 wfProfileOut( 'Output-skin' );
469 $this->sendCacheControl();
473 function out( $ins ) {
474 global $wgInputEncoding, $wgOutputEncoding, $wgContLang;
475 if ( 0 == strcmp( $wgInputEncoding, $wgOutputEncoding ) ) {
478 $outs = $wgContLang->iconv( $wgInputEncoding, $wgOutputEncoding, $ins );
479 if ( false === $outs ) { $outs = $ins; }
484 function setEncodings() {
485 global $wgInputEncoding, $wgOutputEncoding;
486 global $wgUser, $wgContLang;
488 $wgInputEncoding = strtolower( $wgInputEncoding );
490 if( $wgUser->getOption( 'altencoding' ) ) {
491 $wgContLang->setAltEncoding();
495 if ( empty( $_SERVER['HTTP_ACCEPT_CHARSET'] ) ) {
496 $wgOutputEncoding = strtolower( $wgOutputEncoding );
499 $wgOutputEncoding = $wgInputEncoding;
503 * Returns a HTML comment with the elapsed time since request.
504 * This method has no side effects.
507 function reportTime() {
508 global $wgRequestTime;
511 list( $usec, $sec ) = explode( ' ', $wgRequestTime );
512 $start = (float)$sec +
(float)$usec;
513 $elapsed = $now - $start;
515 # Use real server name if available, so we know which machine
516 # in a server farm generated the current page.
517 if ( function_exists( 'posix_uname' ) ) {
518 $uname = @posix_uname
();
522 if( is_array( $uname ) && isset( $uname['nodename'] ) ) {
523 $hostname = $uname['nodename'];
525 # This may be a virtual server.
526 $hostname = $_SERVER['SERVER_NAME'];
528 $com = sprintf( "<!-- Served by %s in %01.2f secs. -->",
529 $hostname, $elapsed );
534 * Note: these arguments are keys into wfMsg(), not text!
536 function errorpage( $title, $msg ) {
539 $this->mDebugtext
.= 'Original title: ' .
540 $wgTitle->getPrefixedText() . "\n";
541 $this->setPageTitle( wfMsg( $title ) );
542 $this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
543 $this->setRobotpolicy( 'noindex,nofollow' );
544 $this->setArticleRelated( false );
545 $this->enableClientCache( false );
546 $this->mRedirect
= '';
548 $this->mBodytext
= '';
549 $this->addWikiText( wfMsg( $msg ) );
550 $this->returnToMain( false );
557 * Display an error page indicating that a given version of MediaWiki is
560 * @param mixed $version The version of MediaWiki needed to use the page
562 function versionRequired( $version ) {
565 $this->setPageTitle( wfMsg( 'versionrequired', $version ) );
566 $this->setHTMLTitle( wfMsg( 'versionrequired', $version ) );
567 $this->setRobotpolicy( 'noindex,nofollow' );
568 $this->setArticleRelated( false );
569 $this->mBodytext
= '';
571 $sk = $wgUser->getSkin();
572 $this->addWikiText( wfMsg( 'versionrequiredtext', $version ) );
573 $this->returnToMain();
577 * Display an error page noting that a given permission bit is required.
578 * This should generally replace the sysopRequired, developerRequired etc.
579 * @param string $permission key required
581 function permissionRequired( $permission ) {
584 $this->setPageTitle( wfMsg( 'badaccess' ) );
585 $this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
586 $this->setRobotpolicy( 'noindex,nofollow' );
587 $this->setArticleRelated( false );
588 $this->mBodytext
= '';
590 $sk = $wgUser->getSkin();
591 $ap = $sk->makeKnownLink( wfMsgForContent( 'administrators' ) );
592 $this->addHTML( wfMsgHtml( 'badaccesstext', $ap, $permission ) );
593 $this->returnToMain();
599 function sysopRequired() {
602 $this->setPageTitle( wfMsg( 'sysoptitle' ) );
603 $this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
604 $this->setRobotpolicy( 'noindex,nofollow' );
605 $this->setArticleRelated( false );
606 $this->mBodytext
= '';
608 $sk = $wgUser->getSkin();
609 $ap = $sk->makeKnownLink( wfMsgForContent( 'administrators' ), '' );
610 $this->addHTML( wfMsgHtml( 'sysoptext', $ap ) );
611 $this->returnToMain();
617 function developerRequired() {
620 $this->setPageTitle( wfMsg( 'developertitle' ) );
621 $this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
622 $this->setRobotpolicy( 'noindex,nofollow' );
623 $this->setArticleRelated( false );
624 $this->mBodytext
= '';
626 $sk = $wgUser->getSkin();
627 $ap = $sk->makeKnownLink( wfMsgForContent( 'administrators' ), '' );
628 $this->addHTML( wfMsgHtml( 'developertext', $ap ) );
629 $this->returnToMain();
632 function loginToUse() {
633 global $wgUser, $wgTitle, $wgContLang;
635 $this->setPageTitle( wfMsg( 'loginreqtitle' ) );
636 $this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
637 $this->setRobotpolicy( 'noindex,nofollow' );
638 $this->setArticleFlag( false );
639 $this->mBodytext
= '';
640 $this->addWikiText( wfMsg( 'loginreqtext' ) );
642 # We put a comment in the .html file so a Sysop can diagnose the page the
644 $this->addHTML( "\n<!--" .
645 $wgContLang->getNsText( $wgTitle->getNamespace() ) .
647 $wgTitle->getDBkey() . '-->' );
648 $this->returnToMain(); # Flip back to the main page after 10 seconds.
651 function databaseError( $fname, $sql, $error, $errno ) {
652 global $wgUser, $wgCommandLineMode, $wgShowSQLErrors;
654 $this->setPageTitle( wfMsgNoDB( 'databaseerror' ) );
655 $this->setRobotpolicy( 'noindex,nofollow' );
656 $this->setArticleRelated( false );
657 $this->enableClientCache( false );
658 $this->mRedirect
= '';
660 if( !$wgShowSQLErrors ) {
661 $sql = wfMsg( 'sqlhidden' );
664 if ( $wgCommandLineMode ) {
665 $msg = wfMsgNoDB( 'dberrortextcl', htmlspecialchars( $sql ),
666 htmlspecialchars( $fname ), $errno, htmlspecialchars( $error ) );
668 $msg = wfMsgNoDB( 'dberrortext', htmlspecialchars( $sql ),
669 htmlspecialchars( $fname ), $errno, htmlspecialchars( $error ) );
672 if ( $wgCommandLineMode ||
!is_object( $wgUser )) {
676 $this->mBodytext
= $msg;
681 function readOnlyPage( $source = null, $protected = false ) {
682 global $wgUser, $wgReadOnlyFile, $wgReadOnly;
684 $this->setRobotpolicy( 'noindex,nofollow' );
685 $this->setArticleRelated( false );
688 $this->setPageTitle( wfMsg( 'viewsource' ) );
689 $this->addWikiText( wfMsg( 'protectedtext' ) );
691 $this->setPageTitle( wfMsg( 'readonly' ) );
693 $reason = $wgReadOnly;
695 $reason = file_get_contents( $wgReadOnlyFile );
697 $this->addWikiText( wfMsg( 'readonlytext', $reason ) );
700 if( is_string( $source ) ) {
701 if( strcmp( $source, '' ) == 0 ) {
702 $source = wfMsg( 'noarticletext' );
704 $rows = $wgUser->getOption( 'rows' );
705 $cols = $wgUser->getOption( 'cols' );
706 $text = "\n<textarea cols='$cols' rows='$rows' readonly='readonly'>" .
707 htmlspecialchars( $source ) . "\n</textarea>";
708 $this->addHTML( $text );
711 $this->returnToMain( false );
714 function fatalError( $message ) {
715 $this->setPageTitle( wfMsg( "internalerror" ) );
716 $this->setRobotpolicy( "noindex,nofollow" );
717 $this->setArticleRelated( false );
718 $this->enableClientCache( false );
719 $this->mRedirect
= '';
721 $this->mBodytext
= $message;
726 function unexpectedValueError( $name, $val ) {
727 $this->fatalError( wfMsg( 'unexpected', $name, $val ) );
730 function fileCopyError( $old, $new ) {
731 $this->fatalError( wfMsg( 'filecopyerror', $old, $new ) );
734 function fileRenameError( $old, $new ) {
735 $this->fatalError( wfMsg( 'filerenameerror', $old, $new ) );
738 function fileDeleteError( $name ) {
739 $this->fatalError( wfMsg( 'filedeleteerror', $name ) );
742 function fileNotFoundError( $name ) {
743 $this->fatalError( wfMsg( 'filenotfound', $name ) );
747 * return from error messages or notes
748 * @param $auto automatically redirect the user after 10 seconds
749 * @param $returnto page title to return to. Default is Main Page.
751 function returnToMain( $auto = true, $returnto = NULL ) {
752 global $wgUser, $wgOut, $wgRequest;
754 if ( $returnto == NULL ) {
755 $returnto = $wgRequest->getText( 'returnto' );
757 $returnto = htmlspecialchars( $returnto );
759 $sk = $wgUser->getSkin();
760 if ( '' == $returnto ) {
761 $returnto = wfMsgForContent( 'mainpage' );
763 $link = $sk->makeKnownLink( $returnto, '' );
765 $r = wfMsg( 'returnto', $link );
767 $titleObj = Title
::newFromText( $returnto );
768 $wgOut->addMeta( 'http:Refresh', '10;url=' . $titleObj->escapeFullURL() );
770 $wgOut->addHTML( "\n<p>$r</p>\n" );
774 * This function takes the title (first item of mGoodLinks), categories, existing and broken links for the page
775 * and uses the first 10 of them for META keywords
777 function addMetaTags () {
778 global $wgLinkCache , $wgOut ;
779 $categories = array_keys ( $wgLinkCache->mCategoryLinks
) ;
780 $good = array_keys ( $wgLinkCache->mGoodLinks
) ;
781 $bad = array_keys ( $wgLinkCache->mBadLinks
) ;
782 $a = array_merge ( array_slice ( $good , 0 , 1 ), $categories, array_slice ( $good , 1 , 9 ) , $bad ) ;
783 $a = array_slice ( $a , 0 , 10 ) ; # 10 keywords max
784 $a = implode ( ',' , $a ) ;
789 $a = htmlspecialchars(preg_replace(array_keys($strip), array_values($strip),$a ));
791 $wgOut->addMeta ( 'KEYWORDS' , $a ) ;
798 function headElement() {
799 global $wgDocType, $wgDTD, $wgContLanguageCode, $wgOutputEncoding, $wgMimeType;
800 global $wgUser, $wgContLang, $wgRequest, $wgUseTrackbacks, $wgTitle;
802 if( $wgMimeType == 'text/xml' ||
$wgMimeType == 'application/xhtml+xml' ||
$wgMimeType == 'application/xml' ) {
803 $ret = "<?xml version=\"1.0\" encoding=\"$wgOutputEncoding\" ?>\n";
808 $ret .= "<!DOCTYPE html PUBLIC \"$wgDocType\"\n \"$wgDTD\">\n";
810 if ( "" == $this->mHTMLtitle
) {
811 $this->mHTMLtitle
= wfMsg( "pagetitle", $this->mPagetitle
);
814 $rtl = $wgContLang->isRTL() ?
" dir='RTL'" : '';
815 $ret .= "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"$wgContLanguageCode\" lang=\"$wgContLanguageCode\" $rtl>\n";
816 $ret .= "<head>\n<title>" . htmlspecialchars( $this->mHTMLtitle
) . "</title>\n";
817 array_push( $this->mMetatags
, array( "http:Content-type", "$wgMimeType; charset={$wgOutputEncoding}" ) );
819 $ret .= $this->getHeadLinks();
821 if( $this->isPrintable() ) {
824 $media = "media='print'";
826 $printsheet = htmlspecialchars( "$wgStylePath/common/wikiprintable.css" );
827 $ret .= "<link rel='stylesheet' type='text/css' $media href='$printsheet' />\n";
829 $sk = $wgUser->getSkin();
830 $ret .= $sk->getHeadScripts();
831 $ret .= $this->mScripts
;
832 $ret .= $sk->getUserStyles();
834 if ($wgUseTrackbacks && $this->isArticleRelated())
835 $ret .= $wgTitle->trackbackRDF();
841 function getHeadLinks() {
842 global $wgRequest, $wgStylePath;
844 foreach ( $this->mMetatags
as $tag ) {
845 if ( 0 == strcasecmp( 'http:', substr( $tag[0], 0, 5 ) ) ) {
847 $tag[0] = substr( $tag[0], 5 );
851 $ret .= "<meta $a=\"{$tag[0]}\" content=\"{$tag[1]}\" />\n";
853 $p = $this->mRobotpolicy
;
854 if ( '' == $p ) { $p = 'index,follow'; }
855 $ret .= "<meta name=\"robots\" content=\"$p\" />\n";
857 if ( count( $this->mKeywords
) > 0 ) {
862 $ret .= "<meta name=\"keywords\" content=\"" .
863 htmlspecialchars(preg_replace(array_keys($strip), array_values($strip),implode( ",", $this->mKeywords
))) . "\" />\n";
865 foreach ( $this->mLinktags
as $tag ) {
867 foreach( $tag as $attr => $val ) {
868 $ret .= " $attr=\"" . htmlspecialchars( $val ) . "\"";
872 if( $this->isSyndicated() ) {
873 # FIXME: centralize the mime-type and name information in Feed.php
874 $link = $wgRequest->escapeAppendQuery( 'feed=rss' );
875 $ret .= "<link rel='alternate' type='application/rss+xml' title='RSS 2.0' href='$link' />\n";
876 $link = $wgRequest->escapeAppendQuery( 'feed=atom' );
877 $ret .= "<link rel='alternate' type='application/rss+atom' title='Atom 0.3' href='$link' />\n";
884 * Run any necessary pre-output transformations on the buffer text
886 function transformBuffer( $options = 0 ) {
891 * Turn off regular page output and return an error reponse
892 * for when rate limiting has triggered.
896 function rateLimited() {
899 wfHttpError( 500, 'Internal Server Error',
900 'Sorry, the server has encountered an internal error. ' .
901 'Please wait a moment and hit "refresh" to submit the request again.' );