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; }
73 function addLink( $linkarr ) {
74 # $linkarr should be an associative array of attributes. We'll escape on output.
75 array_push( $this->mLinktags
, $linkarr );
78 function addMetadataLink( $linkarr ) {
79 # note: buggy CC software only reads first "meta" link
80 static $haveMeta = false;
81 $linkarr['rel'] = ($haveMeta) ?
'alternate meta' : 'meta';
82 $this->addLink( $linkarr );
87 * checkLastModified tells the client to use the client-cached page if
88 * possible. If sucessful, the OutputPage is disabled so that
89 * any future call to OutputPage->output() have no effect. The method
90 * returns true iff cache-ok headers was sent.
92 function checkLastModified ( $timestamp ) {
93 global $wgLang, $wgCachePages, $wgUser;
94 if ( !$timestamp ||
$timestamp == '19700101000000' ) {
95 wfDebug( "CACHE DISABLED, NO TIMESTAMP\n" );
98 if( !$wgCachePages ) {
99 wfDebug( "CACHE DISABLED\n", false );
102 if( $wgUser->getOption( 'nocache' ) ) {
103 wfDebug( "USER DISABLED CACHE\n", false );
107 $timestamp=wfTimestamp(TS_MW
,$timestamp);
108 $lastmod = wfTimestamp( TS_RFC2822
, max( $timestamp, $wgUser->mTouched
) );
110 if( !empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) {
111 # IE sends sizes after the date like this:
112 # Wed, 20 Aug 2003 06:51:19 GMT; length=5202
113 # this breaks strtotime().
114 $modsince = preg_replace( '/;.*$/', '', $_SERVER["HTTP_IF_MODIFIED_SINCE"] );
115 $ismodsince = wfTimestamp( TS_MW
, strtotime( $modsince ) );
116 wfDebug( "-- client send If-Modified-Since: " . $modsince . "\n", false );
117 wfDebug( "-- we might send Last-Modified : $lastmod\n", false );
118 if( ($ismodsince >= $timestamp ) && $wgUser->validateCache( $ismodsince ) ) {
119 # Make sure you're in a place you can leave when you call us!
120 header( "HTTP/1.0 304 Not Modified" );
121 $this->mLastModified
= $lastmod;
122 $this->sendCacheControl();
123 wfDebug( "CACHED client: $ismodsince ; user: $wgUser->mTouched ; page: $timestamp\n", false );
127 wfDebug( "READY client: $ismodsince ; user: $wgUser->mTouched ; page: $timestamp\n", false );
128 $this->mLastModified
= $lastmod;
131 wfDebug( "client did not send If-Modified-Since header\n", false );
132 $this->mLastModified
= $lastmod;
136 function getPageTitleActionText () {
140 return wfMsg('edit');
142 return wfMsg('history_short');
144 return wfMsg('protect');
146 return wfMsg('unprotect');
148 return wfMsg('delete');
150 return wfMsg('watch');
152 return wfMsg('unwatch');
154 return wfMsg('preview');
156 return wfMsg('info_short');
162 function setRobotpolicy( $str ) { $this->mRobotpolicy
= $str; }
163 function setHTMLTitle( $name ) {$this->mHTMLtitle
= $name; }
164 function setPageTitle( $name ) {
165 global $action, $wgContLang;
166 $name = $wgContLang->convert($name, true);
167 $this->mPagetitle
= $name;
168 if(!empty($action)) {
169 $taction = $this->getPageTitleActionText();
170 if( !empty( $taction ) ) {
171 $name .= ' - '.$taction;
174 $this->setHTMLTitle( $name . ' - ' . wfMsg( 'wikititlesuffix' ) );
176 function getHTMLTitle() { return $this->mHTMLtitle
; }
177 function getPageTitle() { return $this->mPagetitle
; }
178 function setSubtitle( $str ) { $this->mSubtitle
= /*$this->parse(*/$str/*)*/; } // @bug 2514
179 function getSubtitle() { return $this->mSubtitle
; }
180 function isArticle() { return $this->mIsarticle
; }
181 function setPrintable() { $this->mPrintable
= true; }
182 function isPrintable() { return $this->mPrintable
; }
183 function setSyndicated( $show = true ) { $this->mShowFeedLinks
= $show; }
184 function isSyndicated() { return $this->mShowFeedLinks
; }
185 function setOnloadHandler( $js ) { $this->mOnloadHandler
= $js; }
186 function getOnloadHandler() { return $this->mOnloadHandler
; }
187 function disable() { $this->mDoNothing
= true; }
189 function setArticleRelated( $v ) {
190 $this->mIsArticleRelated
= $v;
192 $this->mIsarticle
= false;
195 function setArticleFlag( $v ) {
196 $this->mIsarticle
= $v;
198 $this->mIsArticleRelated
= $v;
202 function isArticleRelated() { return $this->mIsArticleRelated
; }
204 function getLanguageLinks() { return $this->mLanguageLinks
; }
205 function addLanguageLinks($newLinkArray) {
206 $this->mLanguageLinks +
= $newLinkArray;
208 function setLanguageLinks($newLinkArray) {
209 $this->mLanguageLinks
= $newLinkArray;
212 function getCategoryLinks() {
213 return $this->mCategoryLinks
;
215 function addCategoryLinks($newLinkArray) {
216 $this->mCategoryLinks +
= $newLinkArray;
218 function setCategoryLinks($newLinkArray) {
219 $this->mCategoryLinks +
= $newLinkArray;
222 function suppressQuickbar() { $this->mSuppressQuickbar
= true; }
223 function isQuickbarSuppressed() { return $this->mSuppressQuickbar
; }
225 function addHTML( $text ) { $this->mBodytext
.= $text; }
226 function clearHTML() { $this->mBodytext
= ''; }
227 function getHTML() { return $this->mBodytext
; }
228 function debug( $text ) { $this->mDebugtext
.= $text; }
230 function setParserOptions( $options ) {
231 return wfSetVar( $this->mParserOptions
, $options );
235 * Convert wikitext to HTML and add it to the buffer
236 * Default assumes that the current page title will
239 function addWikiText( $text, $linestart = true ) {
241 $this->addWikiTextTitle($text, $wgTitle, $linestart);
244 function addWikiTextWithTitle($text, &$title, $linestart = true) {
245 $this->addWikiTextTitle($text, $title, $linestart);
248 function addWikiTextTitle($text, &$title, $linestart) {
249 global $wgParser, $wgUseTidy;
250 $parserOutput = $wgParser->parse( $text, $title, $this->mParserOptions
, $linestart );
251 $this->mLanguageLinks +
= $parserOutput->getLanguageLinks();
252 $this->mCategoryLinks +
= $parserOutput->getCategoryLinks();
253 if ( $parserOutput->getCacheTime() == -1 ) {
254 $this->enableClientCache( false );
256 $this->addHTML( $parserOutput->getText() );
260 * Add wikitext to the buffer, assuming that this is the primary text for a page view
261 * Saves the text into the parser cache if possible
263 function addPrimaryWikiText( $text, $cacheArticle ) {
264 global $wgParser, $wgParserCache, $wgUser, $wgTitle, $wgUseTidy;
266 $parserOutput = $wgParser->parse( $text, $wgTitle, $this->mParserOptions
, true );
268 $text = $parserOutput->getText();
270 if ( $cacheArticle && $parserOutput->getCacheTime() != -1 ) {
271 $wgParserCache->save( $parserOutput, $cacheArticle, $wgUser );
274 $this->mLanguageLinks +
= $parserOutput->getLanguageLinks();
275 $this->mCategoryLinks +
= $parserOutput->getCategoryLinks();
276 if ( $parserOutput->getCacheTime() == -1 ) {
277 $this->enableClientCache( false );
279 $this->addHTML( $text );
283 * Add the output of a QuickTemplate to the output buffer
284 * @param QuickTemplate $template
286 function addTemplate( &$template ) {
288 $template->execute();
289 $this->addHtml( ob_get_contents() );
294 * Parse wikitext and return the HTML. This is for special pages that add the text later
296 function parse( $text, $linestart = true ) {
297 global $wgParser, $wgTitle;
298 $parserOutput = $wgParser->parse( $text, $wgTitle, $this->mParserOptions
, $linestart );
299 return $parserOutput->getText();
308 function tryParserCache( $article, $user ) {
309 global $wgParserCache;
310 $parserOutput = $wgParserCache->get( $article, $user );
311 if ( $parserOutput !== false ) {
312 $this->mLanguageLinks +
= $parserOutput->getLanguageLinks();
313 $this->mCategoryLinks +
= $parserOutput->getCategoryLinks();
314 $this->addHTML( $parserOutput->getText() );
315 $t = $parserOutput->getTitleText();
317 $this->setPageTitle( $t );
326 * Set the maximum cache time on the Squid in seconds
329 function setSquidMaxage( $maxage ) {
330 $this->mSquidMaxage
= $maxage;
334 * Use enableClientCache(false) to force it to send nocache headers
337 function enableClientCache( $state ) {
338 return wfSetVar( $this->mEnableClientCache
, $state );
341 function sendCacheControl() {
342 global $wgUseSquid, $wgUseESI;
345 header("ETag: $this->mETag");
347 # don't serve compressed data to clients who can't handle it
348 # maintain different caches for logged-in users and non-logged in ones
349 header( 'Vary: Accept-Encoding, Cookie' );
350 if( $this->mEnableClientCache
) {
351 if( $wgUseSquid && ! isset( $_COOKIE[ini_get( 'session.name') ] ) &&
352 ! $this->isPrintable() && $this->mSquidMaxage
!= 0 )
355 # We'll purge the proxy cache explicitly, but require end user agents
356 # to revalidate against the proxy on each visit.
357 # Surrogate-Control controls our Squid, Cache-Control downstream caches
358 wfDebug( "** proxy caching with ESI; {$this->mLastModified} **\n", false );
359 # start with a shorter timeout for initial testing
360 # header( 'Surrogate-Control: max-age=2678400+2678400, content="ESI/1.0"');
361 header( 'Surrogate-Control: max-age='.$wgSquidMaxage.'+'.$this->mSquidMaxage
.', content="ESI/1.0"');
362 header( 'Cache-Control: s-maxage=0, must-revalidate, max-age=0' );
364 # We'll purge the proxy cache for anons explicitly, but require end user agents
365 # to revalidate against the proxy on each visit.
366 # IMPORTANT! The Squid needs to replace the Cache-Control header with
367 # Cache-Control: s-maxage=0, must-revalidate, max-age=0
368 wfDebug( "** local proxy caching; {$this->mLastModified} **\n", false );
369 # start with a shorter timeout for initial testing
370 # header( "Cache-Control: s-maxage=2678400, must-revalidate, max-age=0" );
371 header( 'Cache-Control: s-maxage='.$this->mSquidMaxage
.', must-revalidate, max-age=0' );
374 # We do want clients to cache if they can, but they *must* check for updates
375 # on revisiting the page.
376 wfDebug( "** private caching; {$this->mLastModified} **\n", false );
377 header( "Expires: -1" );
378 header( "Cache-Control: private, must-revalidate, max-age=0" );
380 if($this->mLastModified
) header( "Last-modified: {$this->mLastModified}" );
382 wfDebug( "** no caching **\n", false );
384 # In general, the absence of a last modified header should be enough to prevent
385 # the client from using its cache. We send a few other things just to make sure.
386 header( 'Expires: -1' );
387 header( 'Cache-Control: no-cache, no-store, max-age=0, must-revalidate' );
388 header( 'Pragma: no-cache' );
393 * Finally, all the text has been munged and accumulated into
394 * the object, let's actually output it:
397 global $wgUser, $wgLang, $wgDebugComments, $wgCookieExpiration;
398 global $wgInputEncoding, $wgOutputEncoding, $wgContLanguageCode;
399 global $wgDebugRedirects, $wgMimeType, $wgProfiler;
401 if( $this->mDoNothing
){
404 $fname = 'OutputPage::output';
405 wfProfileIn( $fname );
406 $sk = $wgUser->getSkin();
408 if ( '' != $this->mRedirect
) {
409 if( substr( $this->mRedirect
, 0, 4 ) != 'http' ) {
410 # Standards require redirect URLs to be absolute
412 $this->mRedirect
= $wgServer . $this->mRedirect
;
414 if( $this->mRedirectCode
== '301') {
415 if( !$wgDebugRedirects ) {
416 header("HTTP/1.1 {$this->mRedirectCode} Moved Permanently");
418 $this->mLastModified
= wfTimestamp( TS_RFC2822
);
421 $this->sendCacheControl();
423 if( $wgDebugRedirects ) {
424 $url = htmlspecialchars( $this->mRedirect
);
425 print "<html>\n<head>\n<title>Redirect</title>\n</head>\n<body>\n";
426 print "<p>Location: <a href=\"$url\">$url</a></p>\n";
427 print "</body>\n</html>\n";
429 header( 'Location: '.$this->mRedirect
);
431 if ( isset( $wgProfiler ) ) { wfDebug( $wgProfiler->getOutput() ); }
436 # Buffer output; final headers may depend on later processing
439 $this->transformBuffer();
441 # Disable temporary placeholders, so that the skin produces HTML
442 $sk->postParseLinkColour( false );
444 header( "Content-type: $wgMimeType; charset={$wgOutputEncoding}" );
445 header( 'Content-language: '.$wgContLanguageCode );
447 $exp = time() +
$wgCookieExpiration;
448 foreach( $this->mCookies
as $name => $val ) {
449 setcookie( $name, $val, $exp, '/' );
452 if ($this->mArticleBodyOnly
) {
453 $this->out($this->mBodytext
);
455 wfProfileIn( 'Output-skin' );
456 $sk->outputPage( $this );
457 wfProfileOut( 'Output-skin' );
460 $this->sendCacheControl();
464 function out( $ins ) {
465 global $wgInputEncoding, $wgOutputEncoding, $wgContLang;
466 if ( 0 == strcmp( $wgInputEncoding, $wgOutputEncoding ) ) {
469 $outs = $wgContLang->iconv( $wgInputEncoding, $wgOutputEncoding, $ins );
470 if ( false === $outs ) { $outs = $ins; }
475 function setEncodings() {
476 global $wgInputEncoding, $wgOutputEncoding;
477 global $wgUser, $wgContLang;
479 $wgInputEncoding = strtolower( $wgInputEncoding );
481 if( $wgUser->getOption( 'altencoding' ) ) {
482 $wgContLang->setAltEncoding();
486 if ( empty( $_SERVER['HTTP_ACCEPT_CHARSET'] ) ) {
487 $wgOutputEncoding = strtolower( $wgOutputEncoding );
490 $wgOutputEncoding = $wgInputEncoding;
494 * Returns a HTML comment with the elapsed time since request.
495 * This method has no side effects.
498 function reportTime() {
499 global $wgRequestTime;
502 list( $usec, $sec ) = explode( ' ', $wgRequestTime );
503 $start = (float)$sec +
(float)$usec;
504 $elapsed = $now - $start;
506 # Use real server name if available, so we know which machine
507 # in a server farm generated the current page.
508 if ( function_exists( 'posix_uname' ) ) {
509 $uname = @posix_uname
();
513 if( is_array( $uname ) && isset( $uname['nodename'] ) ) {
514 $hostname = $uname['nodename'];
516 # This may be a virtual server.
517 $hostname = $_SERVER['SERVER_NAME'];
519 $com = sprintf( "<!-- Served by %s in %01.2f secs. -->",
520 $hostname, $elapsed );
525 * Note: these arguments are keys into wfMsg(), not text!
527 function errorpage( $title, $msg ) {
530 $this->mDebugtext
.= 'Original title: ' .
531 $wgTitle->getPrefixedText() . "\n";
532 $this->setPageTitle( wfMsg( $title ) );
533 $this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
534 $this->setRobotpolicy( 'noindex,nofollow' );
535 $this->setArticleRelated( false );
536 $this->enableClientCache( false );
537 $this->mRedirect
= '';
539 $this->mBodytext
= '';
540 $this->addWikiText( wfMsg( $msg ) );
541 $this->returnToMain( false );
548 * Display an error page indicating that a given version of MediaWiki is
551 * @param mixed $version The version of MediaWiki needed to use the page
553 function versionRequired( $version ) {
556 $this->setPageTitle( wfMsg( 'versionrequired', $version ) );
557 $this->setHTMLTitle( wfMsg( 'versionrequired', $version ) );
558 $this->setRobotpolicy( 'noindex,nofollow' );
559 $this->setArticleRelated( false );
560 $this->mBodytext
= '';
562 $sk = $wgUser->getSkin();
563 $this->addWikiText( wfMsg( 'versionrequiredtext', $version ) );
564 $this->returnToMain();
568 * Display an error page noting that a given permission bit is required.
569 * This should generally replace the sysopRequired, developerRequired etc.
570 * @param string $permission key required
572 function permissionRequired( $permission ) {
575 $this->setPageTitle( wfMsg( 'badaccess' ) );
576 $this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
577 $this->setRobotpolicy( 'noindex,nofollow' );
578 $this->setArticleRelated( false );
579 $this->mBodytext
= '';
581 $sk = $wgUser->getSkin();
582 $ap = $sk->makeKnownLink( wfMsgForContent( 'administrators' ) );
583 $this->addHTML( wfMsgHtml( 'badaccesstext', $ap, $permission ) );
584 $this->returnToMain();
590 function sysopRequired() {
593 $this->setPageTitle( wfMsg( 'sysoptitle' ) );
594 $this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
595 $this->setRobotpolicy( 'noindex,nofollow' );
596 $this->setArticleRelated( false );
597 $this->mBodytext
= '';
599 $sk = $wgUser->getSkin();
600 $ap = $sk->makeKnownLink( wfMsgForContent( 'administrators' ), '' );
601 $this->addHTML( wfMsgHtml( 'sysoptext', $ap ) );
602 $this->returnToMain();
608 function developerRequired() {
611 $this->setPageTitle( wfMsg( 'developertitle' ) );
612 $this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
613 $this->setRobotpolicy( 'noindex,nofollow' );
614 $this->setArticleRelated( false );
615 $this->mBodytext
= '';
617 $sk = $wgUser->getSkin();
618 $ap = $sk->makeKnownLink( wfMsgForContent( 'administrators' ), '' );
619 $this->addHTML( wfMsgHtml( 'developertext', $ap ) );
620 $this->returnToMain();
623 function loginToUse() {
624 global $wgUser, $wgTitle, $wgContLang;
626 $this->setPageTitle( wfMsg( 'loginreqtitle' ) );
627 $this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
628 $this->setRobotpolicy( 'noindex,nofollow' );
629 $this->setArticleFlag( false );
630 $this->mBodytext
= '';
631 $this->addWikiText( wfMsg( 'loginreqtext' ) );
633 # We put a comment in the .html file so a Sysop can diagnose the page the
635 $this->addHTML( "\n<!--" .
636 $wgContLang->getNsText( $wgTitle->getNamespace() ) .
638 $wgTitle->getDBkey() . '-->' );
639 $this->returnToMain(); # Flip back to the main page after 10 seconds.
642 function databaseError( $fname, $sql, $error, $errno ) {
643 global $wgUser, $wgCommandLineMode, $wgShowSQLErrors;
645 $this->setPageTitle( wfMsgNoDB( 'databaseerror' ) );
646 $this->setRobotpolicy( 'noindex,nofollow' );
647 $this->setArticleRelated( false );
648 $this->enableClientCache( false );
649 $this->mRedirect
= '';
651 if( !$wgShowSQLErrors ) {
652 $sql = wfMsg( 'sqlhidden' );
655 if ( $wgCommandLineMode ) {
656 $msg = wfMsgNoDB( 'dberrortextcl', htmlspecialchars( $sql ),
657 htmlspecialchars( $fname ), $errno, htmlspecialchars( $error ) );
659 $msg = wfMsgNoDB( 'dberrortext', htmlspecialchars( $sql ),
660 htmlspecialchars( $fname ), $errno, htmlspecialchars( $error ) );
663 if ( $wgCommandLineMode ||
!is_object( $wgUser )) {
667 $this->mBodytext
= $msg;
672 function readOnlyPage( $source = null, $protected = false ) {
673 global $wgUser, $wgReadOnlyFile, $wgReadOnly;
675 $this->setRobotpolicy( 'noindex,nofollow' );
676 $this->setArticleRelated( false );
679 $this->setPageTitle( wfMsg( 'viewsource' ) );
680 $this->addWikiText( wfMsg( 'protectedtext' ) );
682 $this->setPageTitle( wfMsg( 'readonly' ) );
684 $reason = $wgReadOnly;
686 $reason = file_get_contents( $wgReadOnlyFile );
688 $this->addWikiText( wfMsg( 'readonlytext', $reason ) );
691 if( is_string( $source ) ) {
692 if( strcmp( $source, '' ) == 0 ) {
693 $source = wfMsg( 'noarticletext' );
695 $rows = $wgUser->getOption( 'rows' );
696 $cols = $wgUser->getOption( 'cols' );
697 $text = "\n<textarea cols='$cols' rows='$rows' readonly='readonly'>" .
698 htmlspecialchars( $source ) . "\n</textarea>";
699 $this->addHTML( $text );
702 $this->returnToMain( false );
705 function fatalError( $message ) {
706 $this->setPageTitle( wfMsg( "internalerror" ) );
707 $this->setRobotpolicy( "noindex,nofollow" );
708 $this->setArticleRelated( false );
709 $this->enableClientCache( false );
710 $this->mRedirect
= '';
712 $this->mBodytext
= $message;
717 function unexpectedValueError( $name, $val ) {
718 $this->fatalError( wfMsg( 'unexpected', $name, $val ) );
721 function fileCopyError( $old, $new ) {
722 $this->fatalError( wfMsg( 'filecopyerror', $old, $new ) );
725 function fileRenameError( $old, $new ) {
726 $this->fatalError( wfMsg( 'filerenameerror', $old, $new ) );
729 function fileDeleteError( $name ) {
730 $this->fatalError( wfMsg( 'filedeleteerror', $name ) );
733 function fileNotFoundError( $name ) {
734 $this->fatalError( wfMsg( 'filenotfound', $name ) );
738 * return from error messages or notes
739 * @param $auto automatically redirect the user after 10 seconds
740 * @param $returnto page title to return to. Default is Main Page.
742 function returnToMain( $auto = true, $returnto = NULL ) {
743 global $wgUser, $wgOut, $wgRequest;
745 if ( $returnto == NULL ) {
746 $returnto = $wgRequest->getText( 'returnto' );
748 $returnto = htmlspecialchars( $returnto );
750 $sk = $wgUser->getSkin();
751 if ( '' == $returnto ) {
752 $returnto = wfMsgForContent( 'mainpage' );
754 $link = $sk->makeKnownLink( $returnto, '' );
756 $r = wfMsg( 'returnto', $link );
758 $titleObj = Title
::newFromText( $returnto );
759 $wgOut->addMeta( 'http:Refresh', '10;url=' . $titleObj->escapeFullURL() );
761 $wgOut->addHTML( "\n<p>$r</p>\n" );
765 * This function takes the existing and broken links for the page
766 * and uses the first 10 of them for META keywords
768 function addMetaTags () {
769 global $wgLinkCache , $wgOut ;
770 $good = array_keys ( $wgLinkCache->mGoodLinks
) ;
771 $bad = array_keys ( $wgLinkCache->mBadLinks
) ;
772 $a = array_merge ( $good , $bad ) ;
773 $a = array_slice ( $a , 0 , 10 ) ; # 10 keywords max
774 $a = implode ( ',' , $a ) ;
779 $a = htmlspecialchars(preg_replace(array_keys($strip), array_values($strip),$a ));
781 $wgOut->addMeta ( 'KEYWORDS' , $a ) ;
788 function headElement() {
789 global $wgDocType, $wgDTD, $wgContLanguageCode, $wgOutputEncoding, $wgMimeType;
790 global $wgUser, $wgContLang, $wgRequest;
792 if( $wgMimeType == 'text/xml' ||
$wgMimeType == 'application/xhtml+xml' ||
$wgMimeType == 'application/xml' ) {
793 $ret = "<?xml version=\"1.0\" encoding=\"$wgOutputEncoding\" ?>\n";
798 $ret .= "<!DOCTYPE html PUBLIC \"$wgDocType\"\n \"$wgDTD\">\n";
800 if ( "" == $this->mHTMLtitle
) {
801 $this->mHTMLtitle
= wfMsg( "pagetitle", $this->mPagetitle
);
804 $rtl = $wgContLang->isRTL() ?
" dir='RTL'" : '';
805 $ret .= "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"$wgContLanguageCode\" lang=\"$wgContLanguageCode\" $rtl>\n";
806 $ret .= "<head>\n<title>" . htmlspecialchars( $this->mHTMLtitle
) . "</title>\n";
807 array_push( $this->mMetatags
, array( "http:Content-type", "$wgMimeType; charset={$wgOutputEncoding}" ) );
809 $ret .= $this->getHeadLinks();
811 if( $this->isPrintable() ) {
814 $media = "media='print'";
816 $printsheet = htmlspecialchars( "$wgStylePath/common/wikiprintable.css" );
817 $ret .= "<link rel='stylesheet' type='text/css' $media href='$printsheet' />\n";
819 $sk = $wgUser->getSkin();
820 $ret .= $sk->getHeadScripts();
821 $ret .= $this->mScripts
;
822 $ret .= $sk->getUserStyles();
828 function getHeadLinks() {
829 global $wgRequest, $wgStylePath;
831 foreach ( $this->mMetatags
as $tag ) {
832 if ( 0 == strcasecmp( 'http:', substr( $tag[0], 0, 5 ) ) ) {
834 $tag[0] = substr( $tag[0], 5 );
838 $ret .= "<meta $a=\"{$tag[0]}\" content=\"{$tag[1]}\" />\n";
840 $p = $this->mRobotpolicy
;
841 if ( '' == $p ) { $p = 'index,follow'; }
842 $ret .= "<meta name=\"robots\" content=\"$p\" />\n";
844 if ( count( $this->mKeywords
) > 0 ) {
849 $ret .= "<meta name=\"keywords\" content=\"" .
850 htmlspecialchars(preg_replace(array_keys($strip), array_values($strip),implode( ",", $this->mKeywords
))) . "\" />\n";
852 foreach ( $this->mLinktags
as $tag ) {
854 foreach( $tag as $attr => $val ) {
855 $ret .= " $attr=\"" . htmlspecialchars( $val ) . "\"";
859 if( $this->isSyndicated() ) {
860 # FIXME: centralize the mime-type and name information in Feed.php
861 $link = $wgRequest->escapeAppendQuery( 'feed=rss' );
862 $ret .= "<link rel='alternate' type='application/rss+xml' title='RSS 2.0' href='$link' />\n";
863 $link = $wgRequest->escapeAppendQuery( 'feed=atom' );
864 $ret .= "<link rel='alternate' type='application/rss+atom' title='Atom 0.3' href='$link' />\n";
871 * Run any necessary pre-output transformations on the buffer text
873 function transformBuffer( $options = 0 ) {
878 * Turn off regular page output and return an error reponse
879 * for when rate limiting has triggered.
883 function rateLimited() {
886 wfHttpError( 500, 'Internal Server Error',
887 'Sorry, the server has encountered an internal error. ' .
888 'Please wait a moment and hit "refresh" to submit the request again.' );