8 * This is not a valid entry point, perform no further processing unless MEDIAWIKI is defined
10 if( defined( 'MEDIAWIKI' ) ) {
14 if($wgUseTeX) require_once( 'Math.php' );
21 var $mHeaders, $mCookies, $mMetatags, $mKeywords;
22 var $mLinktags, $mPagetitle, $mBodytext, $mDebugtext;
23 var $mHTMLtitle, $mRobotpolicy, $mIsarticle, $mPrintable;
24 var $mSubtitle, $mRedirect;
25 var $mLastModified, $mCategoryLinks;
26 var $mScripts, $mLinkColours;
28 var $mSuppressQuickbar;
31 var $mContainsOldMagic, $mContainsNewMagic;
32 var $mIsArticleRelated;
34 var $mShowFeedLinks = false;
35 var $mEnableClientCache = true;
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;
59 function addHeader( $name, $val ) { array_push( $this->mHeaders
, $name.': '.$val ) ; }
60 function addCookie( $name, $val ) { array_push( $this->mCookies
, array( $name, $val ) ); }
61 function redirect( $url, $responsecode = '302' ) { $this->mRedirect
= $url; $this->mRedirectCode
= $responsecode; }
63 # To add an http-equiv meta tag, precede the name with "http:"
64 function addMeta( $name, $val ) { array_push( $this->mMetatags
, array( $name, $val ) ); }
65 function addKeyword( $text ) { array_push( $this->mKeywords
, $text ); }
66 function addScript( $script ) { $this->mScripts
.= $script; }
67 function getScript() { return $this->mScripts
; }
69 function addLink( $linkarr ) {
70 # $linkarr should be an associative array of attributes. We'll escape on output.
71 array_push( $this->mLinktags
, $linkarr );
74 function addMetadataLink( $linkarr ) {
75 # note: buggy CC software only reads first "meta" link
76 static $haveMeta = false;
77 $linkarr['rel'] = ($haveMeta) ?
'alternate meta' : 'meta';
78 $this->addLink( $linkarr );
83 * checkLastModified tells the client to use the client-cached page if
84 * possible. If sucessful, the OutputPage is disabled so that
85 * any future call to OutputPage->output() have no effect. The method
86 * returns true iff cache-ok headers was sent.
88 function checkLastModified ( $timestamp ) {
89 global $wgLang, $wgCachePages, $wgUser;
90 $timestamp=wfTimestamp(TS_MW
,$timestamp);
91 if( !$wgCachePages ) {
92 wfDebug( "CACHE DISABLED\n", false );
95 if( preg_match( '/MSIE ([1-4]|5\.0)/', $_SERVER["HTTP_USER_AGENT"] ) ) {
96 # IE 5.0 has probs with our caching
97 wfDebug( "-- bad client, not caching\n", false );
100 if( $wgUser->getOption( 'nocache' ) ) {
101 wfDebug( "USER DISABLED CACHE\n", false );
105 $lastmod = gmdate( 'D, j M Y H:i:s', wfTimestamp(TS_UNIX
, max( $timestamp, $wgUser->mTouched
) ) ) . ' GMT';
107 if( !empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) {
108 # IE sends sizes after the date like this:
109 # Wed, 20 Aug 2003 06:51:19 GMT; length=5202
110 # this breaks strtotime().
111 $modsince = preg_replace( '/;.*$/', '', $_SERVER["HTTP_IF_MODIFIED_SINCE"] );
112 $ismodsince = wfTimestamp( TS_MW
, strtotime( $modsince ) );
113 wfDebug( "-- client send If-Modified-Since: " . $modsince . "\n", false );
114 wfDebug( "-- we might send Last-Modified : $lastmod\n", false );
115 if( ($ismodsince >= $timestamp ) and $wgUser->validateCache( $ismodsince ) ) {
116 # Make sure you're in a place you can leave when you call us!
117 header( "HTTP/1.0 304 Not Modified" );
118 $this->mLastModified
= $lastmod;
119 $this->sendCacheControl();
120 wfDebug( "CACHED client: $ismodsince ; user: $wgUser->mTouched ; page: $timestamp\n", false );
124 wfDebug( "READY client: $ismodsince ; user: $wgUser->mTouched ; page: $timestamp\n", false );
125 $this->mLastModified
= $lastmod;
128 wfDebug( "We're confused.\n", false );
129 $this->mLastModified
= $lastmod;
133 function getPageTitleActionText () {
137 return wfMsg('edit');
139 return wfMsg('history_short');
141 return wfMsg('protect');
143 return wfMsg('unprotect');
145 return wfMsg('delete');
147 return wfMsg('watch');
149 return wfMsg('unwatch');
151 return wfMsg('preview');
153 return wfMsg('info_short');
159 function setRobotpolicy( $str ) { $this->mRobotpolicy
= $str; }
160 function setHTMLTitle( $name ) {$this->mHTMLtitle
= $name; }
161 function setPageTitle( $name ) {
162 global $action, $wgContLang;
163 $name = $wgContLang->convert($name, true);
164 $this->mPagetitle
= $name;
165 if(!empty($action)) {
166 $taction = $this->getPageTitleActionText();
167 if( !empty( $taction ) ) {
168 $name .= ' - '.$taction;
171 $this->setHTMLTitle( $name . ' - ' . wfMsg( 'wikititlesuffix' ) );
173 function getHTMLTitle() { return $this->mHTMLtitle
; }
174 function getPageTitle() { return $this->mPagetitle
; }
175 function setSubtitle( $str ) { $this->mSubtitle
= $str; }
176 function getSubtitle() { return $this->mSubtitle
; }
177 function isArticle() { return $this->mIsarticle
; }
178 function setPrintable() { $this->mPrintable
= true; }
179 function isPrintable() { return $this->mPrintable
; }
180 function setSyndicated( $show = true ) { $this->mShowFeedLinks
= $show; }
181 function isSyndicated() { return $this->mShowFeedLinks
; }
182 function setOnloadHandler( $js ) { $this->mOnloadHandler
= $js; }
183 function getOnloadHandler() { return $this->mOnloadHandler
; }
184 function disable() { $this->mDoNothing
= true; }
186 function setArticleRelated( $v ) {
187 $this->mIsArticleRelated
= $v;
189 $this->mIsarticle
= false;
192 function setArticleFlag( $v ) {
193 $this->mIsarticle
= $v;
195 $this->mIsArticleRelated
= $v;
199 function isArticleRelated() { return $this->mIsArticleRelated
; }
201 function getLanguageLinks() { return $this->mLanguageLinks
; }
202 function addLanguageLinks($newLinkArray) {
203 $this->mLanguageLinks +
= $newLinkArray;
205 function setLanguageLinks($newLinkArray) {
206 $this->mLanguageLinks
= $newLinkArray;
209 function getCategoryLinks() {
210 return $this->mCategoryLinks
;
212 function addCategoryLinks($newLinkArray) {
213 $this->mCategoryLinks +
= $newLinkArray;
215 function setCategoryLinks($newLinkArray) {
216 $this->mCategoryLinks +
= $newLinkArray;
219 function suppressQuickbar() { $this->mSuppressQuickbar
= true; }
220 function isQuickbarSuppressed() { return $this->mSuppressQuickbar
; }
222 function addHTML( $text ) { $this->mBodytext
.= $text; }
223 function clearHTML() { $this->mBodytext
= ''; }
224 function debug( $text ) { $this->mDebugtext
.= $text; }
226 function setParserOptions( $options ) {
227 return wfSetVar( $this->mParserOptions
, $options );
231 * Convert wikitext to HTML and add it to the buffer
233 function addWikiText( $text, $linestart = true ) {
234 global $wgParser, $wgTitle, $wgUseTidy;
236 $parserOutput = $wgParser->parse( $text, $wgTitle, $this->mParserOptions
, $linestart );
237 $this->mLanguageLinks +
= $parserOutput->getLanguageLinks();
238 $this->mCategoryLinks +
= $parserOutput->getCategoryLinks();
239 $this->addHTML( $parserOutput->getText() );
243 * Add wikitext to the buffer, assuming that this is the primary text for a page view
244 * Saves the text into the parser cache if possible
246 function addPrimaryWikiText( $text, $cacheArticle ) {
247 global $wgParser, $wgParserCache, $wgUser, $wgTitle, $wgUseTidy;
249 $parserOutput = $wgParser->parse( $text, $wgTitle, $this->mParserOptions
, true );
251 $text = $parserOutput->getText();
253 if ( $cacheArticle ) {
254 $wgParserCache->save( $parserOutput, $cacheArticle, $wgUser );
257 $this->mLanguageLinks +
= $parserOutput->getLanguageLinks();
258 $this->mCategoryLinks +
= $parserOutput->getCategoryLinks();
259 $this->addHTML( $text );
266 function tryParserCache( $article, $user ) {
267 global $wgParserCache;
268 $parserOutput = $wgParserCache->get( $article, $user );
269 if ( $parserOutput !== false ) {
270 $this->mLanguageLinks +
= $parserOutput->getLanguageLinks();
271 $this->mCategoryLinks +
= $parserOutput->getCategoryLinks();
272 $this->addHTML( $parserOutput->getText() );
280 * Set the maximum cache time on the Squid in seconds
283 function setSquidMaxage( $maxage ) {
284 $this->mSquidMaxage
= $maxage;
288 * Use enableClientCache(false) to force it to send nocache headers
291 function enableClientCache( $state ) {
292 return wfSetVar( $this->mEnableClientCache
, $state );
295 function sendCacheControl() {
296 global $wgUseSquid, $wgUseESI;
297 # FIXME: This header may cause trouble with some versions of Internet Explorer
298 header( 'Vary: Accept-Encoding, Cookie' );
299 if( $this->mEnableClientCache
) {
300 if( $wgUseSquid && ! isset( $_COOKIE[ini_get( 'session.name') ] ) &&
301 ! $this->isPrintable() && $this->mSquidMaxage
!= 0 )
304 # We'll purge the proxy cache explicitly, but require end user agents
305 # to revalidate against the proxy on each visit.
306 # Surrogate-Control controls our Squid, Cache-Control downstream caches
307 wfDebug( "** proxy caching with ESI; {$this->mLastModified} **\n", false );
308 # start with a shorter timeout for initial testing
309 # header( 'Surrogate-Control: max-age=2678400+2678400, content="ESI/1.0"');
310 header( 'Surrogate-Control: max-age='.$wgSquidMaxage.'+'.$this->mSquidMaxage
.', content="ESI/1.0"');
311 header( 'Cache-Control: s-maxage=0, must-revalidate, max-age=0' );
313 # We'll purge the proxy cache for anons explicitly, but require end user agents
314 # to revalidate against the proxy on each visit.
315 # IMPORTANT! The Squid needs to replace the Cache-Control header with
316 # Cache-Control: s-maxage=0, must-revalidate, max-age=0
317 wfDebug( "** local proxy caching; {$this->mLastModified} **\n", false );
318 # start with a shorter timeout for initial testing
319 # header( "Cache-Control: s-maxage=2678400, must-revalidate, max-age=0" );
320 header( 'Cache-Control: s-maxage='.$this->mSquidMaxage
.', must-revalidate, max-age=0' );
323 # We do want clients to cache if they can, but they *must* check for updates
324 # on revisiting the page.
325 wfDebug( "** private caching; {$this->mLastModified} **\n", false );
326 header( "Expires: -1" );
327 header( "Cache-Control: private, must-revalidate, max-age=0" );
329 if($this->mLastModified
) header( "Last-modified: {$this->mLastModified}" );
331 wfDebug( "** no caching **\n", false );
333 # In general, the absence of a last modified header should be enough to prevent
334 # the client from using its cache. We send a few other things just to make sure.
335 header( 'Expires: -1' );
336 header( 'Cache-Control: no-cache, no-store, max-age=0, must-revalidate' );
337 header( 'Pragma: no-cache' );
342 * Finally, all the text has been munged and accumulated into
343 * the object, let's actually output it:
346 global $wgUser, $wgLang, $wgDebugComments, $wgCookieExpiration;
347 global $wgInputEncoding, $wgOutputEncoding, $wgContLanguageCode;
348 global $wgDebugRedirects, $wgMimeType, $wgProfiler;
350 if( $this->mDoNothing
){
353 $fname = 'OutputPage::output';
354 wfProfileIn( $fname );
355 $sk = $wgUser->getSkin();
357 if ( '' != $this->mRedirect
) {
358 if( substr( $this->mRedirect
, 0, 4 ) != 'http' ) {
359 # Standards require redirect URLs to be absolute
361 $this->mRedirect
= $wgServer . $this->mRedirect
;
363 if( $this->mRedirectCode
== '301') {
364 if( !$wgDebugRedirects ) {
365 header("HTTP/1.1 {$this->mRedirectCode} Moved Permanently");
367 $this->mLastModified
= gmdate( 'D, j M Y H:i:s' ) . ' GMT';
370 $this->sendCacheControl();
372 if( $wgDebugRedirects ) {
373 $url = htmlspecialchars( $this->mRedirect
);
374 print "<html>\n<head>\n<title>Redirect</title>\n</head>\n<body>\n";
375 print "<p>Location: <a href=\"$url\">$url</a></p>\n";
376 print "</body>\n</html>\n";
378 header( 'Location: '.$this->mRedirect
);
380 if ( isset( $wgProfiler ) ) { wfDebug( $wgProfiler->getOutput() ); }
385 $this->sendCacheControl();
386 $this->transformBuffer();
388 # Disable temporary placeholders, so that the skin produces HTML
389 $sk->postParseLinkColour( false );
391 header( "Content-type: $wgMimeType; charset={$wgOutputEncoding}" );
392 header( 'Content-language: '.$wgContLanguageCode );
394 $exp = time() +
$wgCookieExpiration;
395 foreach( $this->mCookies
as $name => $val ) {
396 setcookie( $name, $val, $exp, '/' );
399 $sk->outputPage( $this );
403 function out( $ins ) {
404 global $wgInputEncoding, $wgOutputEncoding, $wgContLang;
405 if ( 0 == strcmp( $wgInputEncoding, $wgOutputEncoding ) ) {
408 $outs = $wgContLang->iconv( $wgInputEncoding, $wgOutputEncoding, $ins );
409 if ( false === $outs ) { $outs = $ins; }
414 function setEncodings() {
415 global $wgInputEncoding, $wgOutputEncoding;
416 global $wgUser, $wgContLang;
418 $wgInputEncoding = strtolower( $wgInputEncoding );
420 if( $wgUser->getOption( 'altencoding' ) ) {
421 $wgContLang->setAltEncoding();
425 if ( empty( $_SERVER['HTTP_ACCEPT_CHARSET'] ) ) {
426 $wgOutputEncoding = strtolower( $wgOutputEncoding );
431 # This code is unused anyway!
432 # Commenting out. --bv 2003-11-15
434 $a = explode( ",", $_SERVER['HTTP_ACCEPT_CHARSET'] );
438 foreach ( $a as $s ) {
439 if ( preg_match( "/(.*);q=(.*)/", $s, $m ) ) {
451 #if ( "*" == $bestset ) { $bestset = "iso-8859-1"; }
452 if ( "*" == $bestset ) { $bestset = $wgOutputEncoding; }
453 $wgOutputEncoding = strtolower( $bestset );
458 $wgOutputEncoding = $wgInputEncoding;
462 * Returns a HTML comment with the elapsed time since request.
463 * This method has no side effects.
465 function reportTime() {
466 global $wgRequestTime;
469 list( $usec, $sec ) = explode( ' ', $wgRequestTime );
470 $start = (float)$sec +
(float)$usec;
471 $elapsed = $now - $start;
473 # Use real server name if available, so we know which machine
474 # in a server farm generated the current page.
475 if ( function_exists( 'posix_uname' ) ) {
476 $uname = @posix_uname
();
480 if( is_array( $uname ) && isset( $uname['nodename'] ) ) {
481 $hostname = $uname['nodename'];
483 # This may be a virtual server.
484 $hostname = $_SERVER['SERVER_NAME'];
486 $com = sprintf( "<!-- Served by %s in %01.2f secs. -->",
487 $hostname, $elapsed );
492 * Note: these arguments are keys into wfMsg(), not text!
494 function errorpage( $title, $msg ) {
497 $this->mDebugtext
.= 'Original title: ' .
498 $wgTitle->getPrefixedText() . "\n";
499 $this->setPageTitle( wfMsg( $title ) );
500 $this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
501 $this->setRobotpolicy( 'noindex,nofollow' );
502 $this->setArticleRelated( false );
503 $this->suppressQuickbar();
505 $this->enableClientCache( false );
506 $this->mRedirect
= '';
508 $this->mBodytext
= '';
509 $this->addHTML( '<p>' . wfMsg( $msg ) . "</p>\n" );
510 $this->returnToMain( false );
516 function sysopRequired() {
519 $this->setPageTitle( wfMsg( 'sysoptitle' ) );
520 $this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
521 $this->setRobotpolicy( 'noindex,nofollow' );
522 $this->setArticleRelated( false );
523 $this->mBodytext
= '';
525 $sk = $wgUser->getSkin();
526 $ap = $sk->makeKnownLink( wfMsgForContent( 'administrators' ), '' );
527 $this->addHTML( wfMsg( 'sysoptext', $ap ) );
528 $this->returnToMain();
531 function developerRequired() {
534 $this->setPageTitle( wfMsg( 'developertitle' ) );
535 $this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
536 $this->setRobotpolicy( 'noindex,nofollow' );
537 $this->setArticleRelated( false );
538 $this->mBodytext
= '';
540 $sk = $wgUser->getSkin();
541 $ap = $sk->makeKnownLink( wfMsgForContent( 'administrators' ), '' );
542 $this->addHTML( wfMsg( 'developertext', $ap ) );
543 $this->returnToMain();
546 function loginToUse() {
547 global $wgUser, $wgTitle, $wgContLang;
549 $this->setPageTitle( wfMsg( 'loginreqtitle' ) );
550 $this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
551 $this->setRobotpolicy( 'noindex,nofollow' );
552 $this->setArticleFlag( false );
553 $this->mBodytext
= '';
554 $this->addWikiText( wfMsg( 'loginreqtext' ) );
556 # We put a comment in the .html file so a Sysop can diagnose the page the
558 $this->addHTML( "\n<!--" .
559 $wgContLang->getNsText( $wgTitle->getNamespace() ) .
561 $wgTitle->getDBkey() . '-->' );
562 $this->returnToMain(); # Flip back to the main page after 10 seconds.
565 function databaseError( $fname, $sql, $error, $errno ) {
566 global $wgUser, $wgCommandLineMode;
568 $this->setPageTitle( wfMsgNoDB( 'databaseerror' ) );
569 $this->setRobotpolicy( 'noindex,nofollow' );
570 $this->setArticleRelated( false );
571 $this->enableClientCache( false );
572 $this->mRedirect
= '';
574 if ( $wgCommandLineMode ) {
575 $msg = wfMsgNoDB( 'dberrortextcl', htmlspecialchars( $sql ),
576 htmlspecialchars( $fname ), $errno, htmlspecialchars( $error ) );
578 $msg = wfMsgNoDB( 'dberrortext', htmlspecialchars( $sql ),
579 htmlspecialchars( $fname ), $errno, htmlspecialchars( $error ) );
582 if ( $wgCommandLineMode ||
!is_object( $wgUser )) {
586 $this->mBodytext
= $msg;
591 function readOnlyPage( $source = null, $protected = false ) {
592 global $wgUser, $wgReadOnlyFile;
594 $this->setRobotpolicy( 'noindex,nofollow' );
595 $this->setArticleRelated( false );
598 $this->setPageTitle( wfMsg( 'viewsource' ) );
599 $this->addWikiText( wfMsg( 'protectedtext' ) );
601 $this->setPageTitle( wfMsg( 'readonly' ) );
602 $reason = file_get_contents( $wgReadOnlyFile );
603 $this->addWikiText( wfMsg( 'readonlytext', $reason ) );
606 if( is_string( $source ) ) {
607 if( strcmp( $source, '' ) == 0 ) {
608 $source = wfMsg( 'noarticletext' );
610 $rows = $wgUser->getOption( 'rows' );
611 $cols = $wgUser->getOption( 'cols' );
612 $text = "\n<textarea cols='$cols' rows='$rows' readonly='readonly'>" .
613 htmlspecialchars( $source ) . "\n</textarea>";
614 $this->addHTML( $text );
617 $this->returnToMain( false );
620 function fatalError( $message ) {
621 $this->setPageTitle( wfMsg( "internalerror" ) );
622 $this->setRobotpolicy( "noindex,nofollow" );
623 $this->setArticleRelated( false );
624 $this->enableClientCache( false );
625 $this->mRedirect
= '';
627 $this->mBodytext
= $message;
632 function unexpectedValueError( $name, $val ) {
633 $this->fatalError( wfMsg( 'unexpected', $name, $val ) );
636 function fileCopyError( $old, $new ) {
637 $this->fatalError( wfMsg( 'filecopyerror', $old, $new ) );
640 function fileRenameError( $old, $new ) {
641 $this->fatalError( wfMsg( 'filerenameerror', $old, $new ) );
644 function fileDeleteError( $name ) {
645 $this->fatalError( wfMsg( 'filedeleteerror', $name ) );
648 function fileNotFoundError( $name ) {
649 $this->fatalError( wfMsg( 'filenotfound', $name ) );
653 * return from error messages or notes
654 * @param $auto automatically redirect the user after 10 seconds
655 * @param $returnto page title to return to. Default is Main Page.
657 function returnToMain( $auto = true, $returnto = NULL ) {
658 global $wgUser, $wgOut, $wgRequest;
660 if ( $returnto == NULL ) {
661 $returnto = $wgRequest->getText( 'returnto' );
663 $returnto = htmlspecialchars( $returnto );
665 $sk = $wgUser->getSkin();
666 if ( '' == $returnto ) {
667 $returnto = wfMsgForContent( 'mainpage' );
669 $link = $sk->makeKnownLink( $returnto, '' );
671 $r = wfMsg( 'returnto', $link );
673 $titleObj = Title
::newFromText( $returnto );
674 $wgOut->addMeta( 'http:Refresh', '10;url=' . $titleObj->escapeFullURL() );
676 $wgOut->addHTML( "\n<p>$r</p>\n" );
680 * This function takes the existing and broken links for the page
681 * and uses the first 10 of them for META keywords
683 function addMetaTags () {
684 global $wgLinkCache , $wgOut ;
685 $good = array_keys ( $wgLinkCache->mGoodLinks
) ;
686 $bad = array_keys ( $wgLinkCache->mBadLinks
) ;
687 $a = array_merge ( $good , $bad ) ;
688 $a = array_slice ( $a , 0 , 10 ) ; # 10 keywords max
689 $a = implode ( ',' , $a ) ;
691 "/<.*?" . ">/" => '',
694 $a = htmlspecialchars(preg_replace(array_keys($strip), array_values($strip),$a ));
696 $wgOut->addMeta ( 'KEYWORDS' , $a ) ;
702 function headElement() {
703 global $wgDocType, $wgDTD, $wgContLanguageCode, $wgOutputEncoding, $wgMimeType;
704 global $wgUser, $wgContLang, $wgRequest;
706 $xml = ($wgMimeType == 'text/xml');
708 $ret = "<" . "?xml version=\"1.0\" encoding=\"$wgOutputEncoding\" ?" . ">\n";
713 $ret .= "<!DOCTYPE html PUBLIC \"$wgDocType\"\n \"$wgDTD\">\n";
715 if ( "" == $this->mHTMLtitle
) {
716 $this->mHTMLtitle
= wfMsg( "pagetitle", $this->mPagetitle
);
719 $xmlbits = "xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\"";
723 $rtl = $wgContLang->isRTL() ?
" dir='RTL'" : '';
724 $ret .= "<html $xmlbits lang=\"$wgContLanguageCode\" $rtl>\n";
725 $ret .= "<head>\n<title>" . htmlspecialchars( $this->mHTMLtitle
) . "</title>\n";
726 array_push( $this->mMetatags
, array( "http:Content-type", "$wgMimeType; charset={$wgOutputEncoding}" ) );
728 $ret .= $this->getHeadLinks();
730 if( $this->isPrintable() ) {
733 $media = "media='print'";
735 $printsheet = htmlspecialchars( "$wgStylePath/common/wikiprintable.css" );
736 $ret .= "<link rel='stylesheet' type='text/css' $media href='$printsheet' />\n";
738 $sk = $wgUser->getSkin();
739 $ret .= $sk->getHeadScripts();
740 $ret .= $this->mScripts
;
741 $ret .= $sk->getUserStyles();
747 function getHeadLinks() {
748 global $wgRequest, $wgStylePath;
750 foreach ( $this->mMetatags
as $tag ) {
751 if ( 0 == strcasecmp( 'http:', substr( $tag[0], 0, 5 ) ) ) {
753 $tag[0] = substr( $tag[0], 5 );
757 $ret .= "<meta $a=\"{$tag[0]}\" content=\"{$tag[1]}\" />\n";
759 $p = $this->mRobotpolicy
;
760 if ( '' == $p ) { $p = 'index,follow'; }
761 $ret .= "<meta name=\"robots\" content=\"$p\" />\n";
763 if ( count( $this->mKeywords
) > 0 ) {
765 "/<.*?" . ">/" => '',
768 $ret .= "<meta name=\"keywords\" content=\"" .
769 htmlspecialchars(preg_replace(array_keys($strip), array_values($strip),implode( ",", $this->mKeywords
))) . "\" />\n";
771 foreach ( $this->mLinktags
as $tag ) {
773 foreach( $tag as $attr => $val ) {
774 $ret .= " $attr=\"" . htmlspecialchars( $val ) . "\"";
778 if( $this->isSyndicated() ) {
779 # FIXME: centralize the mime-type and name information in Feed.php
780 $link = $wgRequest->escapeAppendQuery( 'feed=rss' );
781 $ret .= "<link rel='alternate' type='application/rss+xml' title='RSS 2.0' href='$link' />\n";
782 $link = $wgRequest->escapeAppendQuery( 'feed=atom' );
783 $ret .= "<link rel='alternate' type='application/rss+atom' title='Atom 0.3' href='$link' />\n";
785 # FIXME: get these working
786 # $fix = htmlspecialchars( $wgStylePath . "/ie-png-fix.js" );
787 # $ret .= "<!--[if gte IE 5.5000]><script type='text/javascript' src='$fix'>< /script><![endif]-->";
792 * Run any necessary pre-output transformations on the buffer text
794 function transformBuffer( $options = 0 ) {