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 sendCacheControl() {
345 global $wgUseSquid, $wgUseESI;
348 header("ETag: $this->mETag");
350 # don't serve compressed data to clients who can't handle it
351 # maintain different caches for logged-in users and non-logged in ones
352 header( 'Vary: Accept-Encoding, Cookie' );
353 if( $this->mEnableClientCache
) {
354 if( $wgUseSquid && ! isset( $_COOKIE[ini_get( 'session.name') ] ) &&
355 ! $this->isPrintable() && $this->mSquidMaxage
!= 0 )
358 # We'll purge the proxy cache explicitly, but require end user agents
359 # to revalidate against the proxy on each visit.
360 # Surrogate-Control controls our Squid, Cache-Control downstream caches
361 wfDebug( "** proxy caching with ESI; {$this->mLastModified} **\n", false );
362 # start with a shorter timeout for initial testing
363 # header( 'Surrogate-Control: max-age=2678400+2678400, content="ESI/1.0"');
364 header( 'Surrogate-Control: max-age='.$wgSquidMaxage.'+'.$this->mSquidMaxage
.', content="ESI/1.0"');
365 header( 'Cache-Control: s-maxage=0, must-revalidate, max-age=0' );
367 # We'll purge the proxy cache for anons explicitly, but require end user agents
368 # to revalidate against the proxy on each visit.
369 # IMPORTANT! The Squid needs to replace the Cache-Control header with
370 # Cache-Control: s-maxage=0, must-revalidate, max-age=0
371 wfDebug( "** local proxy caching; {$this->mLastModified} **\n", false );
372 # start with a shorter timeout for initial testing
373 # header( "Cache-Control: s-maxage=2678400, must-revalidate, max-age=0" );
374 header( 'Cache-Control: s-maxage='.$this->mSquidMaxage
.', must-revalidate, max-age=0' );
377 # We do want clients to cache if they can, but they *must* check for updates
378 # on revisiting the page.
379 wfDebug( "** private caching; {$this->mLastModified} **\n", false );
380 header( "Expires: -1" );
381 header( "Cache-Control: private, must-revalidate, max-age=0" );
383 if($this->mLastModified
) header( "Last-modified: {$this->mLastModified}" );
385 wfDebug( "** no caching **\n", false );
387 # In general, the absence of a last modified header should be enough to prevent
388 # the client from using its cache. We send a few other things just to make sure.
389 header( 'Expires: -1' );
390 header( 'Cache-Control: no-cache, no-store, max-age=0, must-revalidate' );
391 header( 'Pragma: no-cache' );
396 * Finally, all the text has been munged and accumulated into
397 * the object, let's actually output it:
400 global $wgUser, $wgLang, $wgDebugComments, $wgCookieExpiration;
401 global $wgInputEncoding, $wgOutputEncoding, $wgContLanguageCode;
402 global $wgDebugRedirects, $wgMimeType, $wgProfiler;
404 if( $this->mDoNothing
){
407 $fname = 'OutputPage::output';
408 wfProfileIn( $fname );
409 $sk = $wgUser->getSkin();
411 if ( '' != $this->mRedirect
) {
412 if( substr( $this->mRedirect
, 0, 4 ) != 'http' ) {
413 # Standards require redirect URLs to be absolute
415 $this->mRedirect
= $wgServer . $this->mRedirect
;
417 if( $this->mRedirectCode
== '301') {
418 if( !$wgDebugRedirects ) {
419 header("HTTP/1.1 {$this->mRedirectCode} Moved Permanently");
421 $this->mLastModified
= wfTimestamp( TS_RFC2822
);
424 $this->sendCacheControl();
426 if( $wgDebugRedirects ) {
427 $url = htmlspecialchars( $this->mRedirect
);
428 print "<html>\n<head>\n<title>Redirect</title>\n</head>\n<body>\n";
429 print "<p>Location: <a href=\"$url\">$url</a></p>\n";
430 print "</body>\n</html>\n";
432 header( 'Location: '.$this->mRedirect
);
434 if ( isset( $wgProfiler ) ) { wfDebug( $wgProfiler->getOutput() ); }
439 # Buffer output; final headers may depend on later processing
442 $this->transformBuffer();
444 # Disable temporary placeholders, so that the skin produces HTML
445 $sk->postParseLinkColour( false );
447 header( "Content-type: $wgMimeType; charset={$wgOutputEncoding}" );
448 header( 'Content-language: '.$wgContLanguageCode );
450 $exp = time() +
$wgCookieExpiration;
451 foreach( $this->mCookies
as $name => $val ) {
452 setcookie( $name, $val, $exp, '/' );
455 if ($this->mArticleBodyOnly
) {
456 $this->out($this->mBodytext
);
458 wfProfileIn( 'Output-skin' );
459 $sk->outputPage( $this );
460 wfProfileOut( 'Output-skin' );
463 $this->sendCacheControl();
467 function out( $ins ) {
468 global $wgInputEncoding, $wgOutputEncoding, $wgContLang;
469 if ( 0 == strcmp( $wgInputEncoding, $wgOutputEncoding ) ) {
472 $outs = $wgContLang->iconv( $wgInputEncoding, $wgOutputEncoding, $ins );
473 if ( false === $outs ) { $outs = $ins; }
478 function setEncodings() {
479 global $wgInputEncoding, $wgOutputEncoding;
480 global $wgUser, $wgContLang;
482 $wgInputEncoding = strtolower( $wgInputEncoding );
484 if( $wgUser->getOption( 'altencoding' ) ) {
485 $wgContLang->setAltEncoding();
489 if ( empty( $_SERVER['HTTP_ACCEPT_CHARSET'] ) ) {
490 $wgOutputEncoding = strtolower( $wgOutputEncoding );
493 $wgOutputEncoding = $wgInputEncoding;
497 * Returns a HTML comment with the elapsed time since request.
498 * This method has no side effects.
501 function reportTime() {
502 global $wgRequestTime;
505 list( $usec, $sec ) = explode( ' ', $wgRequestTime );
506 $start = (float)$sec +
(float)$usec;
507 $elapsed = $now - $start;
509 # Use real server name if available, so we know which machine
510 # in a server farm generated the current page.
511 if ( function_exists( 'posix_uname' ) ) {
512 $uname = @posix_uname
();
516 if( is_array( $uname ) && isset( $uname['nodename'] ) ) {
517 $hostname = $uname['nodename'];
519 # This may be a virtual server.
520 $hostname = $_SERVER['SERVER_NAME'];
522 $com = sprintf( "<!-- Served by %s in %01.2f secs. -->",
523 $hostname, $elapsed );
528 * Note: these arguments are keys into wfMsg(), not text!
530 function errorpage( $title, $msg ) {
533 $this->mDebugtext
.= 'Original title: ' .
534 $wgTitle->getPrefixedText() . "\n";
535 $this->setPageTitle( wfMsg( $title ) );
536 $this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
537 $this->setRobotpolicy( 'noindex,nofollow' );
538 $this->setArticleRelated( false );
539 $this->enableClientCache( false );
540 $this->mRedirect
= '';
542 $this->mBodytext
= '';
543 $this->addWikiText( wfMsg( $msg ) );
544 $this->returnToMain( false );
551 * Display an error page indicating that a given version of MediaWiki is
554 * @param mixed $version The version of MediaWiki needed to use the page
556 function versionRequired( $version ) {
559 $this->setPageTitle( wfMsg( 'versionrequired', $version ) );
560 $this->setHTMLTitle( wfMsg( 'versionrequired', $version ) );
561 $this->setRobotpolicy( 'noindex,nofollow' );
562 $this->setArticleRelated( false );
563 $this->mBodytext
= '';
565 $sk = $wgUser->getSkin();
566 $this->addWikiText( wfMsg( 'versionrequiredtext', $version ) );
567 $this->returnToMain();
571 * Display an error page noting that a given permission bit is required.
572 * This should generally replace the sysopRequired, developerRequired etc.
573 * @param string $permission key required
575 function permissionRequired( $permission ) {
578 $this->setPageTitle( wfMsg( 'badaccess' ) );
579 $this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
580 $this->setRobotpolicy( 'noindex,nofollow' );
581 $this->setArticleRelated( false );
582 $this->mBodytext
= '';
584 $sk = $wgUser->getSkin();
585 $ap = $sk->makeKnownLink( wfMsgForContent( 'administrators' ) );
586 $this->addHTML( wfMsgHtml( 'badaccesstext', $ap, $permission ) );
587 $this->returnToMain();
593 function sysopRequired() {
596 $this->setPageTitle( wfMsg( 'sysoptitle' ) );
597 $this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
598 $this->setRobotpolicy( 'noindex,nofollow' );
599 $this->setArticleRelated( false );
600 $this->mBodytext
= '';
602 $sk = $wgUser->getSkin();
603 $ap = $sk->makeKnownLink( wfMsgForContent( 'administrators' ), '' );
604 $this->addHTML( wfMsgHtml( 'sysoptext', $ap ) );
605 $this->returnToMain();
611 function developerRequired() {
614 $this->setPageTitle( wfMsg( 'developertitle' ) );
615 $this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
616 $this->setRobotpolicy( 'noindex,nofollow' );
617 $this->setArticleRelated( false );
618 $this->mBodytext
= '';
620 $sk = $wgUser->getSkin();
621 $ap = $sk->makeKnownLink( wfMsgForContent( 'administrators' ), '' );
622 $this->addHTML( wfMsgHtml( 'developertext', $ap ) );
623 $this->returnToMain();
626 function loginToUse() {
627 global $wgUser, $wgTitle, $wgContLang;
629 $this->setPageTitle( wfMsg( 'loginreqtitle' ) );
630 $this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
631 $this->setRobotpolicy( 'noindex,nofollow' );
632 $this->setArticleFlag( false );
633 $this->mBodytext
= '';
634 $this->addWikiText( wfMsg( 'loginreqtext' ) );
636 # We put a comment in the .html file so a Sysop can diagnose the page the
638 $this->addHTML( "\n<!--" .
639 $wgContLang->getNsText( $wgTitle->getNamespace() ) .
641 $wgTitle->getDBkey() . '-->' );
642 $this->returnToMain(); # Flip back to the main page after 10 seconds.
645 function databaseError( $fname, $sql, $error, $errno ) {
646 global $wgUser, $wgCommandLineMode, $wgShowSQLErrors;
648 $this->setPageTitle( wfMsgNoDB( 'databaseerror' ) );
649 $this->setRobotpolicy( 'noindex,nofollow' );
650 $this->setArticleRelated( false );
651 $this->enableClientCache( false );
652 $this->mRedirect
= '';
654 if( !$wgShowSQLErrors ) {
655 $sql = wfMsg( 'sqlhidden' );
658 if ( $wgCommandLineMode ) {
659 $msg = wfMsgNoDB( 'dberrortextcl', htmlspecialchars( $sql ),
660 htmlspecialchars( $fname ), $errno, htmlspecialchars( $error ) );
662 $msg = wfMsgNoDB( 'dberrortext', htmlspecialchars( $sql ),
663 htmlspecialchars( $fname ), $errno, htmlspecialchars( $error ) );
666 if ( $wgCommandLineMode ||
!is_object( $wgUser )) {
670 $this->mBodytext
= $msg;
675 function readOnlyPage( $source = null, $protected = false ) {
676 global $wgUser, $wgReadOnlyFile, $wgReadOnly;
678 $this->setRobotpolicy( 'noindex,nofollow' );
679 $this->setArticleRelated( false );
682 $this->setPageTitle( wfMsg( 'viewsource' ) );
683 $this->addWikiText( wfMsg( 'protectedtext' ) );
685 $this->setPageTitle( wfMsg( 'readonly' ) );
687 $reason = $wgReadOnly;
689 $reason = file_get_contents( $wgReadOnlyFile );
691 $this->addWikiText( wfMsg( 'readonlytext', $reason ) );
694 if( is_string( $source ) ) {
695 if( strcmp( $source, '' ) == 0 ) {
696 $source = wfMsg( 'noarticletext' );
698 $rows = $wgUser->getOption( 'rows' );
699 $cols = $wgUser->getOption( 'cols' );
700 $text = "\n<textarea cols='$cols' rows='$rows' readonly='readonly'>" .
701 htmlspecialchars( $source ) . "\n</textarea>";
702 $this->addHTML( $text );
705 $this->returnToMain( false );
708 function fatalError( $message ) {
709 $this->setPageTitle( wfMsg( "internalerror" ) );
710 $this->setRobotpolicy( "noindex,nofollow" );
711 $this->setArticleRelated( false );
712 $this->enableClientCache( false );
713 $this->mRedirect
= '';
715 $this->mBodytext
= $message;
720 function unexpectedValueError( $name, $val ) {
721 $this->fatalError( wfMsg( 'unexpected', $name, $val ) );
724 function fileCopyError( $old, $new ) {
725 $this->fatalError( wfMsg( 'filecopyerror', $old, $new ) );
728 function fileRenameError( $old, $new ) {
729 $this->fatalError( wfMsg( 'filerenameerror', $old, $new ) );
732 function fileDeleteError( $name ) {
733 $this->fatalError( wfMsg( 'filedeleteerror', $name ) );
736 function fileNotFoundError( $name ) {
737 $this->fatalError( wfMsg( 'filenotfound', $name ) );
741 * return from error messages or notes
742 * @param $auto automatically redirect the user after 10 seconds
743 * @param $returnto page title to return to. Default is Main Page.
745 function returnToMain( $auto = true, $returnto = NULL ) {
746 global $wgUser, $wgOut, $wgRequest;
748 if ( $returnto == NULL ) {
749 $returnto = $wgRequest->getText( 'returnto' );
751 $returnto = htmlspecialchars( $returnto );
753 $sk = $wgUser->getSkin();
754 if ( '' == $returnto ) {
755 $returnto = wfMsgForContent( 'mainpage' );
757 $link = $sk->makeKnownLink( $returnto, '' );
759 $r = wfMsg( 'returnto', $link );
761 $titleObj = Title
::newFromText( $returnto );
762 $wgOut->addMeta( 'http:Refresh', '10;url=' . $titleObj->escapeFullURL() );
764 $wgOut->addHTML( "\n<p>$r</p>\n" );
768 * This function takes the title (first item of mGoodLinks), categories, existing and broken links for the page
769 * and uses the first 10 of them for META keywords
771 function addMetaTags () {
772 global $wgLinkCache , $wgOut ;
773 $categories = array_keys ( $wgLinkCache->mCategoryLinks
) ;
774 $good = array_keys ( $wgLinkCache->mGoodLinks
) ;
775 $bad = array_keys ( $wgLinkCache->mBadLinks
) ;
776 $a = array_merge ( array_slice ( $good , 0 , 1 ), $categories, array_slice ( $good , 1 , 9 ) , $bad ) ;
777 $a = array_slice ( $a , 0 , 10 ) ; # 10 keywords max
778 $a = implode ( ',' , $a ) ;
783 $a = htmlspecialchars(preg_replace(array_keys($strip), array_values($strip),$a ));
785 $wgOut->addMeta ( 'KEYWORDS' , $a ) ;
792 function headElement() {
793 global $wgDocType, $wgDTD, $wgContLanguageCode, $wgOutputEncoding, $wgMimeType;
794 global $wgUser, $wgContLang, $wgRequest;
796 if( $wgMimeType == 'text/xml' ||
$wgMimeType == 'application/xhtml+xml' ||
$wgMimeType == 'application/xml' ) {
797 $ret = "<?xml version=\"1.0\" encoding=\"$wgOutputEncoding\" ?>\n";
802 $ret .= "<!DOCTYPE html PUBLIC \"$wgDocType\"\n \"$wgDTD\">\n";
804 if ( "" == $this->mHTMLtitle
) {
805 $this->mHTMLtitle
= wfMsg( "pagetitle", $this->mPagetitle
);
808 $rtl = $wgContLang->isRTL() ?
" dir='RTL'" : '';
809 $ret .= "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"$wgContLanguageCode\" lang=\"$wgContLanguageCode\" $rtl>\n";
810 $ret .= "<head>\n<title>" . htmlspecialchars( $this->mHTMLtitle
) . "</title>\n";
811 array_push( $this->mMetatags
, array( "http:Content-type", "$wgMimeType; charset={$wgOutputEncoding}" ) );
813 $ret .= $this->getHeadLinks();
815 if( $this->isPrintable() ) {
818 $media = "media='print'";
820 $printsheet = htmlspecialchars( "$wgStylePath/common/wikiprintable.css" );
821 $ret .= "<link rel='stylesheet' type='text/css' $media href='$printsheet' />\n";
823 $sk = $wgUser->getSkin();
824 $ret .= $sk->getHeadScripts();
825 $ret .= $this->mScripts
;
826 $ret .= $sk->getUserStyles();
832 function getHeadLinks() {
833 global $wgRequest, $wgStylePath;
835 foreach ( $this->mMetatags
as $tag ) {
836 if ( 0 == strcasecmp( 'http:', substr( $tag[0], 0, 5 ) ) ) {
838 $tag[0] = substr( $tag[0], 5 );
842 $ret .= "<meta $a=\"{$tag[0]}\" content=\"{$tag[1]}\" />\n";
844 $p = $this->mRobotpolicy
;
845 if ( '' == $p ) { $p = 'index,follow'; }
846 $ret .= "<meta name=\"robots\" content=\"$p\" />\n";
848 if ( count( $this->mKeywords
) > 0 ) {
853 $ret .= "<meta name=\"keywords\" content=\"" .
854 htmlspecialchars(preg_replace(array_keys($strip), array_values($strip),implode( ",", $this->mKeywords
))) . "\" />\n";
856 foreach ( $this->mLinktags
as $tag ) {
858 foreach( $tag as $attr => $val ) {
859 $ret .= " $attr=\"" . htmlspecialchars( $val ) . "\"";
863 if( $this->isSyndicated() ) {
864 # FIXME: centralize the mime-type and name information in Feed.php
865 $link = $wgRequest->escapeAppendQuery( 'feed=rss' );
866 $ret .= "<link rel='alternate' type='application/rss+xml' title='RSS 2.0' href='$link' />\n";
867 $link = $wgRequest->escapeAppendQuery( 'feed=atom' );
868 $ret .= "<link rel='alternate' type='application/rss+atom' title='Atom 0.3' href='$link' />\n";
875 * Run any necessary pre-output transformations on the buffer text
877 function transformBuffer( $options = 0 ) {
882 * Turn off regular page output and return an error reponse
883 * for when rate limiting has triggered.
887 function rateLimited() {
890 wfHttpError( 500, 'Internal Server Error',
891 'Sorry, the server has encountered an internal error. ' .
892 'Please wait a moment and hit "refresh" to submit the request again.' );