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, $mCategoryLinks;
25 var $mScripts, $mLinkColours;
27 var $mSuppressQuickbar;
30 var $mContainsOldMagic, $mContainsNewMagic;
31 var $mIsArticleRelated;
33 var $mShowFeedLinks = false;
34 var $mEnableClientCache = true;
38 * Initialise private variables
40 function OutputPage() {
41 $this->mHeaders
= $this->mCookies
= $this->mMetatags
=
42 $this->mKeywords
= $this->mLinktags
= array();
43 $this->mHTMLtitle
= $this->mPagetitle
= $this->mBodytext
=
44 $this->mRedirect
= $this->mLastModified
=
45 $this->mSubtitle
= $this->mDebugtext
= $this->mRobotpolicy
=
46 $this->mOnloadHandler
= '';
47 $this->mIsArticleRelated
= $this->mIsarticle
= $this->mPrintable
= true;
48 $this->mSuppressQuickbar
= $this->mPrintable
= false;
49 $this->mLanguageLinks
= array();
50 $this->mCategoryLinks
= array() ;
51 $this->mDoNothing
= false;
52 $this->mContainsOldMagic
= $this->mContainsNewMagic
= 0;
53 $this->mParserOptions
= ParserOptions
::newFromUser( $temp = NULL );
54 $this->mSquidMaxage
= 0;
58 function addHeader( $name, $val ) { array_push( $this->mHeaders
, $name.': '.$val ) ; }
59 function addCookie( $name, $val ) { array_push( $this->mCookies
, array( $name, $val ) ); }
60 function redirect( $url, $responsecode = '302' ) { $this->mRedirect
= $url; $this->mRedirectCode
= $responsecode; }
62 # To add an http-equiv meta tag, precede the name with "http:"
63 function addMeta( $name, $val ) { array_push( $this->mMetatags
, array( $name, $val ) ); }
64 function addKeyword( $text ) { array_push( $this->mKeywords
, $text ); }
65 function addScript( $script ) { $this->mScripts
.= $script; }
66 function getScript() { return $this->mScripts
; }
68 function addLink( $linkarr ) {
69 # $linkarr should be an associative array of attributes. We'll escape on output.
70 array_push( $this->mLinktags
, $linkarr );
73 function addMetadataLink( $linkarr ) {
74 # note: buggy CC software only reads first "meta" link
75 static $haveMeta = false;
76 $linkarr['rel'] = ($haveMeta) ?
'alternate meta' : 'meta';
77 $this->addLink( $linkarr );
82 * checkLastModified tells the client to use the client-cached page if
83 * possible. If sucessful, the OutputPage is disabled so that
84 * any future call to OutputPage->output() have no effect. The method
85 * returns true iff cache-ok headers was sent.
87 function checkLastModified ( $timestamp ) {
88 global $wgLang, $wgCachePages, $wgUser;
89 $timestamp=wfTimestamp(TS_MW
,$timestamp);
90 if( !$wgCachePages ) {
91 wfDebug( "CACHE DISABLED\n", false );
94 if( $wgUser->getOption( 'nocache' ) ) {
95 wfDebug( "USER DISABLED CACHE\n", false );
99 $lastmod = wfTimestamp( TS_RFC2822
, max( $timestamp, $wgUser->mTouched
) );
101 if( !empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) {
102 # IE sends sizes after the date like this:
103 # Wed, 20 Aug 2003 06:51:19 GMT; length=5202
104 # this breaks strtotime().
105 $modsince = preg_replace( '/;.*$/', '', $_SERVER["HTTP_IF_MODIFIED_SINCE"] );
106 $ismodsince = wfTimestamp( TS_MW
, strtotime( $modsince ) );
107 wfDebug( "-- client send If-Modified-Since: " . $modsince . "\n", false );
108 wfDebug( "-- we might send Last-Modified : $lastmod\n", false );
109 if( ($ismodsince >= $timestamp ) && $wgUser->validateCache( $ismodsince ) ) {
110 # Make sure you're in a place you can leave when you call us!
111 header( "HTTP/1.0 304 Not Modified" );
112 $this->mLastModified
= $lastmod;
113 $this->sendCacheControl();
114 wfDebug( "CACHED client: $ismodsince ; user: $wgUser->mTouched ; page: $timestamp\n", false );
118 wfDebug( "READY client: $ismodsince ; user: $wgUser->mTouched ; page: $timestamp\n", false );
119 $this->mLastModified
= $lastmod;
122 wfDebug( "We're confused.\n", false );
123 $this->mLastModified
= $lastmod;
127 function getPageTitleActionText () {
131 return wfMsg('edit');
133 return wfMsg('history_short');
135 return wfMsg('protect');
137 return wfMsg('unprotect');
139 return wfMsg('delete');
141 return wfMsg('watch');
143 return wfMsg('unwatch');
145 return wfMsg('preview');
147 return wfMsg('info_short');
153 function setRobotpolicy( $str ) { $this->mRobotpolicy
= $str; }
154 function setHTMLTitle( $name ) {$this->mHTMLtitle
= $name; }
155 function setPageTitle( $name ) {
156 global $action, $wgContLang;
157 $name = $wgContLang->convert($name, true);
158 $this->mPagetitle
= $name;
159 if(!empty($action)) {
160 $taction = $this->getPageTitleActionText();
161 if( !empty( $taction ) ) {
162 $name .= ' - '.$taction;
165 $this->setHTMLTitle( $name . ' - ' . wfMsg( 'wikititlesuffix' ) );
167 function getHTMLTitle() { return $this->mHTMLtitle
; }
168 function getPageTitle() { return $this->mPagetitle
; }
169 function setSubtitle( $str ) { $this->mSubtitle
= $str; }
170 function getSubtitle() { return $this->mSubtitle
; }
171 function isArticle() { return $this->mIsarticle
; }
172 function setPrintable() { $this->mPrintable
= true; }
173 function isPrintable() { return $this->mPrintable
; }
174 function setSyndicated( $show = true ) { $this->mShowFeedLinks
= $show; }
175 function isSyndicated() { return $this->mShowFeedLinks
; }
176 function setOnloadHandler( $js ) { $this->mOnloadHandler
= $js; }
177 function getOnloadHandler() { return $this->mOnloadHandler
; }
178 function disable() { $this->mDoNothing
= true; }
180 function setArticleRelated( $v ) {
181 $this->mIsArticleRelated
= $v;
183 $this->mIsarticle
= false;
186 function setArticleFlag( $v ) {
187 $this->mIsarticle
= $v;
189 $this->mIsArticleRelated
= $v;
193 function isArticleRelated() { return $this->mIsArticleRelated
; }
195 function getLanguageLinks() { return $this->mLanguageLinks
; }
196 function addLanguageLinks($newLinkArray) {
197 $this->mLanguageLinks +
= $newLinkArray;
199 function setLanguageLinks($newLinkArray) {
200 $this->mLanguageLinks
= $newLinkArray;
203 function getCategoryLinks() {
204 return $this->mCategoryLinks
;
206 function addCategoryLinks($newLinkArray) {
207 $this->mCategoryLinks +
= $newLinkArray;
209 function setCategoryLinks($newLinkArray) {
210 $this->mCategoryLinks +
= $newLinkArray;
213 function suppressQuickbar() { $this->mSuppressQuickbar
= true; }
214 function isQuickbarSuppressed() { return $this->mSuppressQuickbar
; }
216 function addHTML( $text ) { $this->mBodytext
.= $text; }
217 function clearHTML() { $this->mBodytext
= ''; }
218 function debug( $text ) { $this->mDebugtext
.= $text; }
220 function setParserOptions( $options ) {
221 return wfSetVar( $this->mParserOptions
, $options );
225 * Convert wikitext to HTML and add it to the buffer
227 function addWikiText( $text, $linestart = true ) {
228 global $wgParser, $wgTitle, $wgUseTidy;
230 $parserOutput = $wgParser->parse( $text, $wgTitle, $this->mParserOptions
, $linestart );
231 $this->mLanguageLinks +
= $parserOutput->getLanguageLinks();
232 $this->mCategoryLinks +
= $parserOutput->getCategoryLinks();
233 $this->addHTML( $parserOutput->getText() );
237 * Add wikitext to the buffer, assuming that this is the primary text for a page view
238 * Saves the text into the parser cache if possible
240 function addPrimaryWikiText( $text, $cacheArticle ) {
241 global $wgParser, $wgParserCache, $wgUser, $wgTitle, $wgUseTidy;
243 $parserOutput = $wgParser->parse( $text, $wgTitle, $this->mParserOptions
, true );
245 $text = $parserOutput->getText();
247 if ( $cacheArticle ) {
248 $wgParserCache->save( $parserOutput, $cacheArticle, $wgUser );
251 $this->mLanguageLinks +
= $parserOutput->getLanguageLinks();
252 $this->mCategoryLinks +
= $parserOutput->getCategoryLinks();
253 $this->addHTML( $text );
257 * Add the output of a QuickTemplate to the output buffer
258 * @param QuickTemplate $template
260 function addTemplate( &$template ) {
262 $template->execute();
263 $this->addHtml( ob_get_contents() );
268 * Parse wikitext and return the HTML. This is for special pages that add the text later
270 function parse( $text, $linestart = true ) {
271 global $wgParser, $wgTitle;
272 $parserOutput = $wgParser->parse( $text, $wgTitle, $this->mParserOptions
, $linestart );
273 return $parserOutput->getText();
280 function tryParserCache( $article, $user ) {
281 global $wgParserCache;
282 $parserOutput = $wgParserCache->get( $article, $user );
283 if ( $parserOutput !== false ) {
284 $this->mLanguageLinks +
= $parserOutput->getLanguageLinks();
285 $this->mCategoryLinks +
= $parserOutput->getCategoryLinks();
286 $this->addHTML( $parserOutput->getText() );
294 * Set the maximum cache time on the Squid in seconds
297 function setSquidMaxage( $maxage ) {
298 $this->mSquidMaxage
= $maxage;
302 * Use enableClientCache(false) to force it to send nocache headers
305 function enableClientCache( $state ) {
306 return wfSetVar( $this->mEnableClientCache
, $state );
309 function sendCacheControl() {
310 global $wgUseSquid, $wgUseESI;
311 # FIXME: This header may cause trouble with some versions of Internet Explorer
312 header( 'Vary: Accept-Encoding, Cookie' );
313 if( $this->mEnableClientCache
) {
314 if( $wgUseSquid && ! isset( $_COOKIE[ini_get( 'session.name') ] ) &&
315 ! $this->isPrintable() && $this->mSquidMaxage
!= 0 )
318 # We'll purge the proxy cache explicitly, but require end user agents
319 # to revalidate against the proxy on each visit.
320 # Surrogate-Control controls our Squid, Cache-Control downstream caches
321 wfDebug( "** proxy caching with ESI; {$this->mLastModified} **\n", false );
322 # start with a shorter timeout for initial testing
323 # header( 'Surrogate-Control: max-age=2678400+2678400, content="ESI/1.0"');
324 header( 'Surrogate-Control: max-age='.$wgSquidMaxage.'+'.$this->mSquidMaxage
.', content="ESI/1.0"');
325 header( 'Cache-Control: s-maxage=0, must-revalidate, max-age=0' );
327 # We'll purge the proxy cache for anons explicitly, but require end user agents
328 # to revalidate against the proxy on each visit.
329 # IMPORTANT! The Squid needs to replace the Cache-Control header with
330 # Cache-Control: s-maxage=0, must-revalidate, max-age=0
331 wfDebug( "** local proxy caching; {$this->mLastModified} **\n", false );
332 # start with a shorter timeout for initial testing
333 # header( "Cache-Control: s-maxage=2678400, must-revalidate, max-age=0" );
334 header( 'Cache-Control: s-maxage='.$this->mSquidMaxage
.', must-revalidate, max-age=0' );
337 # We do want clients to cache if they can, but they *must* check for updates
338 # on revisiting the page.
339 wfDebug( "** private caching; {$this->mLastModified} **\n", false );
340 header( "Expires: -1" );
341 header( "Cache-Control: private, must-revalidate, max-age=0" );
343 if($this->mLastModified
) header( "Last-modified: {$this->mLastModified}" );
345 wfDebug( "** no caching **\n", false );
347 # In general, the absence of a last modified header should be enough to prevent
348 # the client from using its cache. We send a few other things just to make sure.
349 header( 'Expires: -1' );
350 header( 'Cache-Control: no-cache, no-store, max-age=0, must-revalidate' );
351 header( 'Pragma: no-cache' );
356 * Finally, all the text has been munged and accumulated into
357 * the object, let's actually output it:
360 global $wgUser, $wgLang, $wgDebugComments, $wgCookieExpiration;
361 global $wgInputEncoding, $wgOutputEncoding, $wgContLanguageCode;
362 global $wgDebugRedirects, $wgMimeType, $wgProfiler;
364 if( $this->mDoNothing
){
367 $fname = 'OutputPage::output';
368 wfProfileIn( $fname );
369 $sk = $wgUser->getSkin();
371 if ( '' != $this->mRedirect
) {
372 if( substr( $this->mRedirect
, 0, 4 ) != 'http' ) {
373 # Standards require redirect URLs to be absolute
375 $this->mRedirect
= $wgServer . $this->mRedirect
;
377 if( $this->mRedirectCode
== '301') {
378 if( !$wgDebugRedirects ) {
379 header("HTTP/1.1 {$this->mRedirectCode} Moved Permanently");
381 $this->mLastModified
= wfTimestamp( TS_RFC2822
);
384 $this->sendCacheControl();
386 if( $wgDebugRedirects ) {
387 $url = htmlspecialchars( $this->mRedirect
);
388 print "<html>\n<head>\n<title>Redirect</title>\n</head>\n<body>\n";
389 print "<p>Location: <a href=\"$url\">$url</a></p>\n";
390 print "</body>\n</html>\n";
392 header( 'Location: '.$this->mRedirect
);
394 if ( isset( $wgProfiler ) ) { wfDebug( $wgProfiler->getOutput() ); }
399 # Buffer output; final headers may depend on later processing
402 $this->transformBuffer();
404 # Disable temporary placeholders, so that the skin produces HTML
405 $sk->postParseLinkColour( false );
407 header( "Content-type: $wgMimeType; charset={$wgOutputEncoding}" );
408 header( 'Content-language: '.$wgContLanguageCode );
410 $exp = time() +
$wgCookieExpiration;
411 foreach( $this->mCookies
as $name => $val ) {
412 setcookie( $name, $val, $exp, '/' );
415 wfProfileIn( 'Output-skin' );
416 $sk->outputPage( $this );
417 wfProfileOut( 'Output-skin' );
419 $this->sendCacheControl();
423 function out( $ins ) {
424 global $wgInputEncoding, $wgOutputEncoding, $wgContLang;
425 if ( 0 == strcmp( $wgInputEncoding, $wgOutputEncoding ) ) {
428 $outs = $wgContLang->iconv( $wgInputEncoding, $wgOutputEncoding, $ins );
429 if ( false === $outs ) { $outs = $ins; }
434 function setEncodings() {
435 global $wgInputEncoding, $wgOutputEncoding;
436 global $wgUser, $wgContLang;
438 $wgInputEncoding = strtolower( $wgInputEncoding );
440 if( $wgUser->getOption( 'altencoding' ) ) {
441 $wgContLang->setAltEncoding();
445 if ( empty( $_SERVER['HTTP_ACCEPT_CHARSET'] ) ) {
446 $wgOutputEncoding = strtolower( $wgOutputEncoding );
451 # This code is unused anyway!
452 # Commenting out. --bv 2003-11-15
454 $a = explode( ",", $_SERVER['HTTP_ACCEPT_CHARSET'] );
458 foreach ( $a as $s ) {
459 if ( preg_match( "/(.*);q=(.*)/", $s, $m ) ) {
471 #if ( "*" == $bestset ) { $bestset = "iso-8859-1"; }
472 if ( "*" == $bestset ) { $bestset = $wgOutputEncoding; }
473 $wgOutputEncoding = strtolower( $bestset );
478 $wgOutputEncoding = $wgInputEncoding;
482 * Returns a HTML comment with the elapsed time since request.
483 * This method has no side effects.
485 function reportTime() {
486 global $wgRequestTime;
489 list( $usec, $sec ) = explode( ' ', $wgRequestTime );
490 $start = (float)$sec +
(float)$usec;
491 $elapsed = $now - $start;
493 # Use real server name if available, so we know which machine
494 # in a server farm generated the current page.
495 if ( function_exists( 'posix_uname' ) ) {
496 $uname = @posix_uname
();
500 if( is_array( $uname ) && isset( $uname['nodename'] ) ) {
501 $hostname = $uname['nodename'];
503 # This may be a virtual server.
504 $hostname = $_SERVER['SERVER_NAME'];
506 $com = sprintf( "<!-- Served by %s in %01.2f secs. -->",
507 $hostname, $elapsed );
512 * Note: these arguments are keys into wfMsg(), not text!
514 function errorpage( $title, $msg ) {
517 $this->mDebugtext
.= 'Original title: ' .
518 $wgTitle->getPrefixedText() . "\n";
519 $this->setPageTitle( wfMsg( $title ) );
520 $this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
521 $this->setRobotpolicy( 'noindex,nofollow' );
522 $this->setArticleRelated( false );
523 $this->enableClientCache( false );
524 $this->mRedirect
= '';
526 $this->mBodytext
= '';
527 $this->addHTML( '<p>' . wfMsg( $msg ) . "</p>\n" );
528 $this->returnToMain( false );
534 function sysopRequired() {
537 $this->setPageTitle( wfMsg( 'sysoptitle' ) );
538 $this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
539 $this->setRobotpolicy( 'noindex,nofollow' );
540 $this->setArticleRelated( false );
541 $this->mBodytext
= '';
543 $sk = $wgUser->getSkin();
544 $ap = $sk->makeKnownLink( wfMsgForContent( 'administrators' ), '' );
545 $this->addHTML( wfMsg( 'sysoptext', $ap ) );
546 $this->returnToMain();
549 function developerRequired() {
552 $this->setPageTitle( wfMsg( 'developertitle' ) );
553 $this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
554 $this->setRobotpolicy( 'noindex,nofollow' );
555 $this->setArticleRelated( false );
556 $this->mBodytext
= '';
558 $sk = $wgUser->getSkin();
559 $ap = $sk->makeKnownLink( wfMsgForContent( 'administrators' ), '' );
560 $this->addHTML( wfMsg( 'developertext', $ap ) );
561 $this->returnToMain();
564 function loginToUse() {
565 global $wgUser, $wgTitle, $wgContLang;
567 $this->setPageTitle( wfMsg( 'loginreqtitle' ) );
568 $this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
569 $this->setRobotpolicy( 'noindex,nofollow' );
570 $this->setArticleFlag( false );
571 $this->mBodytext
= '';
572 $this->addWikiText( wfMsg( 'loginreqtext' ) );
574 # We put a comment in the .html file so a Sysop can diagnose the page the
576 $this->addHTML( "\n<!--" .
577 $wgContLang->getNsText( $wgTitle->getNamespace() ) .
579 $wgTitle->getDBkey() . '-->' );
580 $this->returnToMain(); # Flip back to the main page after 10 seconds.
583 function databaseError( $fname, $sql, $error, $errno ) {
584 global $wgUser, $wgCommandLineMode, $wgShowSQLErrors;
586 $this->setPageTitle( wfMsgNoDB( 'databaseerror' ) );
587 $this->setRobotpolicy( 'noindex,nofollow' );
588 $this->setArticleRelated( false );
589 $this->enableClientCache( false );
590 $this->mRedirect
= '';
592 if( $wgShowSQLErrors ) {
593 if ( $wgCommandLineMode ) {
594 $msg = wfMsgNoDB( 'dberrortextcl', htmlspecialchars( $sql ),
595 htmlspecialchars( $fname ), $errno, htmlspecialchars( $error ) );
597 $msg = wfMsgNoDB( 'dberrortext', htmlspecialchars( $sql ),
598 htmlspecialchars( $fname ), $errno, htmlspecialchars( $error ) );
601 if( $wgCommandLineMode ) {
602 $msg = wfMsg( 'internalerror' );
604 $msg = htmlspecialchars( wfMsg( 'internalerror' ) );
608 if ( $wgCommandLineMode ||
!is_object( $wgUser )) {
612 $this->mBodytext
= $msg;
617 function readOnlyPage( $source = null, $protected = false ) {
618 global $wgUser, $wgReadOnlyFile;
620 $this->setRobotpolicy( 'noindex,nofollow' );
621 $this->setArticleRelated( false );
624 $this->setPageTitle( wfMsg( 'viewsource' ) );
625 $this->addWikiText( wfMsg( 'protectedtext' ) );
627 $this->setPageTitle( wfMsg( 'readonly' ) );
628 $reason = file_get_contents( $wgReadOnlyFile );
629 $this->addWikiText( wfMsg( 'readonlytext', $reason ) );
632 if( is_string( $source ) ) {
633 if( strcmp( $source, '' ) == 0 ) {
634 $source = wfMsg( 'noarticletext' );
636 $rows = $wgUser->getOption( 'rows' );
637 $cols = $wgUser->getOption( 'cols' );
638 $text = "\n<textarea cols='$cols' rows='$rows' readonly='readonly'>" .
639 htmlspecialchars( $source ) . "\n</textarea>";
640 $this->addHTML( $text );
643 $this->returnToMain( false );
646 function fatalError( $message ) {
647 $this->setPageTitle( wfMsg( "internalerror" ) );
648 $this->setRobotpolicy( "noindex,nofollow" );
649 $this->setArticleRelated( false );
650 $this->enableClientCache( false );
651 $this->mRedirect
= '';
653 $this->mBodytext
= $message;
658 function unexpectedValueError( $name, $val ) {
659 $this->fatalError( wfMsg( 'unexpected', $name, $val ) );
662 function fileCopyError( $old, $new ) {
663 $this->fatalError( wfMsg( 'filecopyerror', $old, $new ) );
666 function fileRenameError( $old, $new ) {
667 $this->fatalError( wfMsg( 'filerenameerror', $old, $new ) );
670 function fileDeleteError( $name ) {
671 $this->fatalError( wfMsg( 'filedeleteerror', $name ) );
674 function fileNotFoundError( $name ) {
675 $this->fatalError( wfMsg( 'filenotfound', $name ) );
679 * return from error messages or notes
680 * @param $auto automatically redirect the user after 10 seconds
681 * @param $returnto page title to return to. Default is Main Page.
683 function returnToMain( $auto = true, $returnto = NULL ) {
684 global $wgUser, $wgOut, $wgRequest;
686 if ( $returnto == NULL ) {
687 $returnto = $wgRequest->getText( 'returnto' );
689 $returnto = htmlspecialchars( $returnto );
691 $sk = $wgUser->getSkin();
692 if ( '' == $returnto ) {
693 $returnto = wfMsgForContent( 'mainpage' );
695 $link = $sk->makeKnownLink( $returnto, '' );
697 $r = wfMsg( 'returnto', $link );
699 $titleObj = Title
::newFromText( $returnto );
700 $wgOut->addMeta( 'http:Refresh', '10;url=' . $titleObj->escapeFullURL() );
702 $wgOut->addHTML( "\n<p>$r</p>\n" );
706 * This function takes the existing and broken links for the page
707 * and uses the first 10 of them for META keywords
709 function addMetaTags () {
710 global $wgLinkCache , $wgOut ;
711 $good = array_keys ( $wgLinkCache->mGoodLinks
) ;
712 $bad = array_keys ( $wgLinkCache->mBadLinks
) ;
713 $a = array_merge ( $good , $bad ) ;
714 $a = array_slice ( $a , 0 , 10 ) ; # 10 keywords max
715 $a = implode ( ',' , $a ) ;
717 "/<.*?" . ">/" => '',
720 $a = htmlspecialchars(preg_replace(array_keys($strip), array_values($strip),$a ));
722 $wgOut->addMeta ( 'KEYWORDS' , $a ) ;
728 function headElement() {
729 global $wgDocType, $wgDTD, $wgContLanguageCode, $wgOutputEncoding, $wgMimeType;
730 global $wgUser, $wgContLang, $wgRequest;
732 $xml = ($wgMimeType == 'text/xml');
734 $ret = "<" . "?xml version=\"1.0\" encoding=\"$wgOutputEncoding\" ?" . ">\n";
739 $ret .= "<!DOCTYPE html PUBLIC \"$wgDocType\"\n \"$wgDTD\">\n";
741 if ( "" == $this->mHTMLtitle
) {
742 $this->mHTMLtitle
= wfMsg( "pagetitle", $this->mPagetitle
);
745 $xmlbits = "xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\"";
749 $rtl = $wgContLang->isRTL() ?
" dir='RTL'" : '';
750 $ret .= "<html $xmlbits lang=\"$wgContLanguageCode\" $rtl>\n";
751 $ret .= "<head>\n<title>" . htmlspecialchars( $this->mHTMLtitle
) . "</title>\n";
752 array_push( $this->mMetatags
, array( "http:Content-type", "$wgMimeType; charset={$wgOutputEncoding}" ) );
754 $ret .= $this->getHeadLinks();
756 if( $this->isPrintable() ) {
759 $media = "media='print'";
761 $printsheet = htmlspecialchars( "$wgStylePath/common/wikiprintable.css" );
762 $ret .= "<link rel='stylesheet' type='text/css' $media href='$printsheet' />\n";
764 $sk = $wgUser->getSkin();
765 $ret .= $sk->getHeadScripts();
766 $ret .= $this->mScripts
;
767 $ret .= $sk->getUserStyles();
773 function getHeadLinks() {
774 global $wgRequest, $wgStylePath;
776 foreach ( $this->mMetatags
as $tag ) {
777 if ( 0 == strcasecmp( 'http:', substr( $tag[0], 0, 5 ) ) ) {
779 $tag[0] = substr( $tag[0], 5 );
783 $ret .= "<meta $a=\"{$tag[0]}\" content=\"{$tag[1]}\" />\n";
785 $p = $this->mRobotpolicy
;
786 if ( '' == $p ) { $p = 'index,follow'; }
787 $ret .= "<meta name=\"robots\" content=\"$p\" />\n";
789 if ( count( $this->mKeywords
) > 0 ) {
791 "/<.*?" . ">/" => '',
794 $ret .= "<meta name=\"keywords\" content=\"" .
795 htmlspecialchars(preg_replace(array_keys($strip), array_values($strip),implode( ",", $this->mKeywords
))) . "\" />\n";
797 foreach ( $this->mLinktags
as $tag ) {
799 foreach( $tag as $attr => $val ) {
800 $ret .= " $attr=\"" . htmlspecialchars( $val ) . "\"";
804 if( $this->isSyndicated() ) {
805 # FIXME: centralize the mime-type and name information in Feed.php
806 $link = $wgRequest->escapeAppendQuery( 'feed=rss' );
807 $ret .= "<link rel='alternate' type='application/rss+xml' title='RSS 2.0' href='$link' />\n";
808 $link = $wgRequest->escapeAppendQuery( 'feed=atom' );
809 $ret .= "<link rel='alternate' type='application/rss+atom' title='Atom 0.3' href='$link' />\n";
816 * Run any necessary pre-output transformations on the buffer text
818 function transformBuffer( $options = 0 ) {