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( "client did not send If-Modified-Since header\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 # don't serve compressed data to clients who can't handle it
312 # maintain different caches for logged-in users and non-logged in ones
313 header( 'Vary: Accept-Encoding, Cookie' );
314 if( $this->mEnableClientCache
) {
315 if( $wgUseSquid && ! isset( $_COOKIE[ini_get( 'session.name') ] ) &&
316 ! $this->isPrintable() && $this->mSquidMaxage
!= 0 )
319 # We'll purge the proxy cache explicitly, but require end user agents
320 # to revalidate against the proxy on each visit.
321 # Surrogate-Control controls our Squid, Cache-Control downstream caches
322 wfDebug( "** proxy caching with ESI; {$this->mLastModified} **\n", false );
323 # start with a shorter timeout for initial testing
324 # header( 'Surrogate-Control: max-age=2678400+2678400, content="ESI/1.0"');
325 header( 'Surrogate-Control: max-age='.$wgSquidMaxage.'+'.$this->mSquidMaxage
.', content="ESI/1.0"');
326 header( 'Cache-Control: s-maxage=0, must-revalidate, max-age=0' );
328 # We'll purge the proxy cache for anons explicitly, but require end user agents
329 # to revalidate against the proxy on each visit.
330 # IMPORTANT! The Squid needs to replace the Cache-Control header with
331 # Cache-Control: s-maxage=0, must-revalidate, max-age=0
332 wfDebug( "** local proxy caching; {$this->mLastModified} **\n", false );
333 # start with a shorter timeout for initial testing
334 # header( "Cache-Control: s-maxage=2678400, must-revalidate, max-age=0" );
335 header( 'Cache-Control: s-maxage='.$this->mSquidMaxage
.', must-revalidate, max-age=0' );
338 # We do want clients to cache if they can, but they *must* check for updates
339 # on revisiting the page.
340 wfDebug( "** private caching; {$this->mLastModified} **\n", false );
341 header( "Expires: -1" );
342 header( "Cache-Control: private, must-revalidate, max-age=0" );
344 if($this->mLastModified
) header( "Last-modified: {$this->mLastModified}" );
346 wfDebug( "** no caching **\n", false );
348 # In general, the absence of a last modified header should be enough to prevent
349 # the client from using its cache. We send a few other things just to make sure.
350 header( 'Expires: -1' );
351 header( 'Cache-Control: no-cache, no-store, max-age=0, must-revalidate' );
352 header( 'Pragma: no-cache' );
357 * Finally, all the text has been munged and accumulated into
358 * the object, let's actually output it:
361 global $wgUser, $wgLang, $wgDebugComments, $wgCookieExpiration;
362 global $wgInputEncoding, $wgOutputEncoding, $wgContLanguageCode;
363 global $wgDebugRedirects, $wgMimeType, $wgProfiler;
365 if( $this->mDoNothing
){
368 $fname = 'OutputPage::output';
369 wfProfileIn( $fname );
370 $sk = $wgUser->getSkin();
372 if ( '' != $this->mRedirect
) {
373 if( substr( $this->mRedirect
, 0, 4 ) != 'http' ) {
374 # Standards require redirect URLs to be absolute
376 $this->mRedirect
= $wgServer . $this->mRedirect
;
378 if( $this->mRedirectCode
== '301') {
379 if( !$wgDebugRedirects ) {
380 header("HTTP/1.1 {$this->mRedirectCode} Moved Permanently");
382 $this->mLastModified
= wfTimestamp( TS_RFC2822
);
385 $this->sendCacheControl();
387 if( $wgDebugRedirects ) {
388 $url = htmlspecialchars( $this->mRedirect
);
389 print "<html>\n<head>\n<title>Redirect</title>\n</head>\n<body>\n";
390 print "<p>Location: <a href=\"$url\">$url</a></p>\n";
391 print "</body>\n</html>\n";
393 header( 'Location: '.$this->mRedirect
);
395 if ( isset( $wgProfiler ) ) { wfDebug( $wgProfiler->getOutput() ); }
400 # Buffer output; final headers may depend on later processing
403 $this->transformBuffer();
405 # Disable temporary placeholders, so that the skin produces HTML
406 $sk->postParseLinkColour( false );
408 header( "Content-type: $wgMimeType; charset={$wgOutputEncoding}" );
409 header( 'Content-language: '.$wgContLanguageCode );
411 $exp = time() +
$wgCookieExpiration;
412 foreach( $this->mCookies
as $name => $val ) {
413 setcookie( $name, $val, $exp, '/' );
416 wfProfileIn( 'Output-skin' );
417 $sk->outputPage( $this );
418 wfProfileOut( 'Output-skin' );
420 $this->sendCacheControl();
424 function out( $ins ) {
425 global $wgInputEncoding, $wgOutputEncoding, $wgContLang;
426 if ( 0 == strcmp( $wgInputEncoding, $wgOutputEncoding ) ) {
429 $outs = $wgContLang->iconv( $wgInputEncoding, $wgOutputEncoding, $ins );
430 if ( false === $outs ) { $outs = $ins; }
435 function setEncodings() {
436 global $wgInputEncoding, $wgOutputEncoding;
437 global $wgUser, $wgContLang;
439 $wgInputEncoding = strtolower( $wgInputEncoding );
441 if( $wgUser->getOption( 'altencoding' ) ) {
442 $wgContLang->setAltEncoding();
446 if ( empty( $_SERVER['HTTP_ACCEPT_CHARSET'] ) ) {
447 $wgOutputEncoding = strtolower( $wgOutputEncoding );
452 # This code is unused anyway!
453 # Commenting out. --bv 2003-11-15
455 $a = explode( ",", $_SERVER['HTTP_ACCEPT_CHARSET'] );
459 foreach ( $a as $s ) {
460 if ( preg_match( "/(.*);q=(.*)/", $s, $m ) ) {
472 #if ( "*" == $bestset ) { $bestset = "iso-8859-1"; }
473 if ( "*" == $bestset ) { $bestset = $wgOutputEncoding; }
474 $wgOutputEncoding = strtolower( $bestset );
479 $wgOutputEncoding = $wgInputEncoding;
483 * Returns a HTML comment with the elapsed time since request.
484 * This method has no side effects.
486 function reportTime() {
487 global $wgRequestTime;
490 list( $usec, $sec ) = explode( ' ', $wgRequestTime );
491 $start = (float)$sec +
(float)$usec;
492 $elapsed = $now - $start;
494 # Use real server name if available, so we know which machine
495 # in a server farm generated the current page.
496 if ( function_exists( 'posix_uname' ) ) {
497 $uname = @posix_uname
();
501 if( is_array( $uname ) && isset( $uname['nodename'] ) ) {
502 $hostname = $uname['nodename'];
504 # This may be a virtual server.
505 $hostname = $_SERVER['SERVER_NAME'];
507 $com = sprintf( "<!-- Served by %s in %01.2f secs. -->",
508 $hostname, $elapsed );
513 * Note: these arguments are keys into wfMsg(), not text!
515 function errorpage( $title, $msg ) {
518 $this->mDebugtext
.= 'Original title: ' .
519 $wgTitle->getPrefixedText() . "\n";
520 $this->setPageTitle( wfMsg( $title ) );
521 $this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
522 $this->setRobotpolicy( 'noindex,nofollow' );
523 $this->setArticleRelated( false );
524 $this->enableClientCache( false );
525 $this->mRedirect
= '';
527 $this->mBodytext
= '';
528 $this->addHTML( '<p>' . wfMsg( $msg ) . "</p>\n" );
529 $this->returnToMain( false );
535 function sysopRequired() {
538 $this->setPageTitle( wfMsg( 'sysoptitle' ) );
539 $this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
540 $this->setRobotpolicy( 'noindex,nofollow' );
541 $this->setArticleRelated( false );
542 $this->mBodytext
= '';
544 $sk = $wgUser->getSkin();
545 $ap = $sk->makeKnownLink( wfMsgForContent( 'administrators' ), '' );
546 $this->addHTML( wfMsg( 'sysoptext', $ap ) );
547 $this->returnToMain();
550 function developerRequired() {
553 $this->setPageTitle( wfMsg( 'developertitle' ) );
554 $this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
555 $this->setRobotpolicy( 'noindex,nofollow' );
556 $this->setArticleRelated( false );
557 $this->mBodytext
= '';
559 $sk = $wgUser->getSkin();
560 $ap = $sk->makeKnownLink( wfMsgForContent( 'administrators' ), '' );
561 $this->addHTML( wfMsg( 'developertext', $ap ) );
562 $this->returnToMain();
565 function loginToUse() {
566 global $wgUser, $wgTitle, $wgContLang;
568 $this->setPageTitle( wfMsg( 'loginreqtitle' ) );
569 $this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
570 $this->setRobotpolicy( 'noindex,nofollow' );
571 $this->setArticleFlag( false );
572 $this->mBodytext
= '';
573 $this->addWikiText( wfMsg( 'loginreqtext' ) );
575 # We put a comment in the .html file so a Sysop can diagnose the page the
577 $this->addHTML( "\n<!--" .
578 $wgContLang->getNsText( $wgTitle->getNamespace() ) .
580 $wgTitle->getDBkey() . '-->' );
581 $this->returnToMain(); # Flip back to the main page after 10 seconds.
584 function databaseError( $fname, $sql, $error, $errno ) {
585 global $wgUser, $wgCommandLineMode, $wgShowSQLErrors;
587 $this->setPageTitle( wfMsgNoDB( 'databaseerror' ) );
588 $this->setRobotpolicy( 'noindex,nofollow' );
589 $this->setArticleRelated( false );
590 $this->enableClientCache( false );
591 $this->mRedirect
= '';
593 if( $wgShowSQLErrors ) {
594 if ( $wgCommandLineMode ) {
595 $msg = wfMsgNoDB( 'dberrortextcl', htmlspecialchars( $sql ),
596 htmlspecialchars( $fname ), $errno, htmlspecialchars( $error ) );
598 $msg = wfMsgNoDB( 'dberrortext', htmlspecialchars( $sql ),
599 htmlspecialchars( $fname ), $errno, htmlspecialchars( $error ) );
602 if( $wgCommandLineMode ) {
603 $msg = wfMsg( 'internalerror' );
605 $msg = htmlspecialchars( wfMsg( 'internalerror' ) );
609 if ( $wgCommandLineMode ||
!is_object( $wgUser )) {
613 $this->mBodytext
= $msg;
618 function readOnlyPage( $source = null, $protected = false ) {
619 global $wgUser, $wgReadOnlyFile;
621 $this->setRobotpolicy( 'noindex,nofollow' );
622 $this->setArticleRelated( false );
625 $this->setPageTitle( wfMsg( 'viewsource' ) );
626 $this->addWikiText( wfMsg( 'protectedtext' ) );
628 $this->setPageTitle( wfMsg( 'readonly' ) );
629 $reason = file_get_contents( $wgReadOnlyFile );
630 $this->addWikiText( wfMsg( 'readonlytext', $reason ) );
633 if( is_string( $source ) ) {
634 if( strcmp( $source, '' ) == 0 ) {
635 $source = wfMsg( 'noarticletext' );
637 $rows = $wgUser->getOption( 'rows' );
638 $cols = $wgUser->getOption( 'cols' );
639 $text = "\n<textarea cols='$cols' rows='$rows' readonly='readonly'>" .
640 htmlspecialchars( $source ) . "\n</textarea>";
641 $this->addHTML( $text );
644 $this->returnToMain( false );
647 function fatalError( $message ) {
648 $this->setPageTitle( wfMsg( "internalerror" ) );
649 $this->setRobotpolicy( "noindex,nofollow" );
650 $this->setArticleRelated( false );
651 $this->enableClientCache( false );
652 $this->mRedirect
= '';
654 $this->mBodytext
= $message;
659 function unexpectedValueError( $name, $val ) {
660 $this->fatalError( wfMsg( 'unexpected', $name, $val ) );
663 function fileCopyError( $old, $new ) {
664 $this->fatalError( wfMsg( 'filecopyerror', $old, $new ) );
667 function fileRenameError( $old, $new ) {
668 $this->fatalError( wfMsg( 'filerenameerror', $old, $new ) );
671 function fileDeleteError( $name ) {
672 $this->fatalError( wfMsg( 'filedeleteerror', $name ) );
675 function fileNotFoundError( $name ) {
676 $this->fatalError( wfMsg( 'filenotfound', $name ) );
680 * return from error messages or notes
681 * @param $auto automatically redirect the user after 10 seconds
682 * @param $returnto page title to return to. Default is Main Page.
684 function returnToMain( $auto = true, $returnto = NULL ) {
685 global $wgUser, $wgOut, $wgRequest;
687 if ( $returnto == NULL ) {
688 $returnto = $wgRequest->getText( 'returnto' );
690 $returnto = htmlspecialchars( $returnto );
692 $sk = $wgUser->getSkin();
693 if ( '' == $returnto ) {
694 $returnto = wfMsgForContent( 'mainpage' );
696 $link = $sk->makeKnownLink( $returnto, '' );
698 $r = wfMsg( 'returnto', $link );
700 $titleObj = Title
::newFromText( $returnto );
701 $wgOut->addMeta( 'http:Refresh', '10;url=' . $titleObj->escapeFullURL() );
703 $wgOut->addHTML( "\n<p>$r</p>\n" );
707 * This function takes the existing and broken links for the page
708 * and uses the first 10 of them for META keywords
710 function addMetaTags () {
711 global $wgLinkCache , $wgOut ;
712 $good = array_keys ( $wgLinkCache->mGoodLinks
) ;
713 $bad = array_keys ( $wgLinkCache->mBadLinks
) ;
714 $a = array_merge ( $good , $bad ) ;
715 $a = array_slice ( $a , 0 , 10 ) ; # 10 keywords max
716 $a = implode ( ',' , $a ) ;
718 "/<.*?" . ">/" => '',
721 $a = htmlspecialchars(preg_replace(array_keys($strip), array_values($strip),$a ));
723 $wgOut->addMeta ( 'KEYWORDS' , $a ) ;
729 function headElement() {
730 global $wgDocType, $wgDTD, $wgContLanguageCode, $wgOutputEncoding, $wgMimeType;
731 global $wgUser, $wgContLang, $wgRequest;
733 if( $wgMimeType == 'text/xml' ||
$wgMimeType == 'application/xhtml+xml' ||
$wgMimeType == 'application/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 $rtl = $wgContLang->isRTL() ?
" dir='RTL'" : '';
746 $ret .= "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"$wgContLanguageCode\" lang=\"$wgContLanguageCode\" $rtl>\n";
747 $ret .= "<head>\n<title>" . htmlspecialchars( $this->mHTMLtitle
) . "</title>\n";
748 array_push( $this->mMetatags
, array( "http:Content-type", "$wgMimeType; charset={$wgOutputEncoding}" ) );
750 $ret .= $this->getHeadLinks();
752 if( $this->isPrintable() ) {
755 $media = "media='print'";
757 $printsheet = htmlspecialchars( "$wgStylePath/common/wikiprintable.css" );
758 $ret .= "<link rel='stylesheet' type='text/css' $media href='$printsheet' />\n";
760 $sk = $wgUser->getSkin();
761 $ret .= $sk->getHeadScripts();
762 $ret .= $this->mScripts
;
763 $ret .= $sk->getUserStyles();
769 function getHeadLinks() {
770 global $wgRequest, $wgStylePath;
772 foreach ( $this->mMetatags
as $tag ) {
773 if ( 0 == strcasecmp( 'http:', substr( $tag[0], 0, 5 ) ) ) {
775 $tag[0] = substr( $tag[0], 5 );
779 $ret .= "<meta $a=\"{$tag[0]}\" content=\"{$tag[1]}\" />\n";
781 $p = $this->mRobotpolicy
;
782 if ( '' == $p ) { $p = 'index,follow'; }
783 $ret .= "<meta name=\"robots\" content=\"$p\" />\n";
785 if ( count( $this->mKeywords
) > 0 ) {
787 "/<.*?" . ">/" => '',
790 $ret .= "<meta name=\"keywords\" content=\"" .
791 htmlspecialchars(preg_replace(array_keys($strip), array_values($strip),implode( ",", $this->mKeywords
))) . "\" />\n";
793 foreach ( $this->mLinktags
as $tag ) {
795 foreach( $tag as $attr => $val ) {
796 $ret .= " $attr=\"" . htmlspecialchars( $val ) . "\"";
800 if( $this->isSyndicated() ) {
801 # FIXME: centralize the mime-type and name information in Feed.php
802 $link = $wgRequest->escapeAppendQuery( 'feed=rss' );
803 $ret .= "<link rel='alternate' type='application/rss+xml' title='RSS 2.0' href='$link' />\n";
804 $link = $wgRequest->escapeAppendQuery( 'feed=atom' );
805 $ret .= "<link rel='alternate' type='application/rss+atom' title='Atom 0.3' href='$link' />\n";
812 * Run any necessary pre-output transformations on the buffer text
814 function transformBuffer( $options = 0 ) {