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 if ( !$timestamp ||
$timestamp == '19700101000000' ) {
90 wfDebug( "CACHE DISABLED, NO TIMESTAMP\n" );
93 if( !$wgCachePages ) {
94 wfDebug( "CACHE DISABLED\n", false );
97 if( $wgUser->getOption( 'nocache' ) ) {
98 wfDebug( "USER DISABLED CACHE\n", false );
102 $timestamp=wfTimestamp(TS_MW
,$timestamp);
103 $lastmod = wfTimestamp( TS_RFC2822
, max( $timestamp, $wgUser->mTouched
) );
105 if( !empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) {
106 # IE sends sizes after the date like this:
107 # Wed, 20 Aug 2003 06:51:19 GMT; length=5202
108 # this breaks strtotime().
109 $modsince = preg_replace( '/;.*$/', '', $_SERVER["HTTP_IF_MODIFIED_SINCE"] );
110 $ismodsince = wfTimestamp( TS_MW
, strtotime( $modsince ) );
111 wfDebug( "-- client send If-Modified-Since: " . $modsince . "\n", false );
112 wfDebug( "-- we might send Last-Modified : $lastmod\n", false );
113 if( ($ismodsince >= $timestamp ) && $wgUser->validateCache( $ismodsince ) ) {
114 # Make sure you're in a place you can leave when you call us!
115 header( "HTTP/1.0 304 Not Modified" );
116 $this->mLastModified
= $lastmod;
117 $this->sendCacheControl();
118 wfDebug( "CACHED client: $ismodsince ; user: $wgUser->mTouched ; page: $timestamp\n", false );
122 wfDebug( "READY client: $ismodsince ; user: $wgUser->mTouched ; page: $timestamp\n", false );
123 $this->mLastModified
= $lastmod;
126 wfDebug( "client did not send If-Modified-Since header\n", false );
127 $this->mLastModified
= $lastmod;
131 function getPageTitleActionText () {
135 return wfMsg('edit');
137 return wfMsg('history_short');
139 return wfMsg('protect');
141 return wfMsg('unprotect');
143 return wfMsg('delete');
145 return wfMsg('watch');
147 return wfMsg('unwatch');
149 return wfMsg('preview');
151 return wfMsg('info_short');
157 function setRobotpolicy( $str ) { $this->mRobotpolicy
= $str; }
158 function setHTMLTitle( $name ) {$this->mHTMLtitle
= $name; }
159 function setPageTitle( $name ) {
160 global $action, $wgContLang;
161 $name = $wgContLang->convert($name, true);
162 $this->mPagetitle
= $name;
163 if(!empty($action)) {
164 $taction = $this->getPageTitleActionText();
165 if( !empty( $taction ) ) {
166 $name .= ' - '.$taction;
169 $this->setHTMLTitle( $name . ' - ' . wfMsg( 'wikititlesuffix' ) );
171 function getHTMLTitle() { return $this->mHTMLtitle
; }
172 function getPageTitle() { return $this->mPagetitle
; }
173 function setSubtitle( $str ) { $this->mSubtitle
= $str; }
174 function getSubtitle() { return $this->mSubtitle
; }
175 function isArticle() { return $this->mIsarticle
; }
176 function setPrintable() { $this->mPrintable
= true; }
177 function isPrintable() { return $this->mPrintable
; }
178 function setSyndicated( $show = true ) { $this->mShowFeedLinks
= $show; }
179 function isSyndicated() { return $this->mShowFeedLinks
; }
180 function setOnloadHandler( $js ) { $this->mOnloadHandler
= $js; }
181 function getOnloadHandler() { return $this->mOnloadHandler
; }
182 function disable() { $this->mDoNothing
= true; }
184 function setArticleRelated( $v ) {
185 $this->mIsArticleRelated
= $v;
187 $this->mIsarticle
= false;
190 function setArticleFlag( $v ) {
191 $this->mIsarticle
= $v;
193 $this->mIsArticleRelated
= $v;
197 function isArticleRelated() { return $this->mIsArticleRelated
; }
199 function getLanguageLinks() { return $this->mLanguageLinks
; }
200 function addLanguageLinks($newLinkArray) {
201 $this->mLanguageLinks +
= $newLinkArray;
203 function setLanguageLinks($newLinkArray) {
204 $this->mLanguageLinks
= $newLinkArray;
207 function getCategoryLinks() {
208 return $this->mCategoryLinks
;
210 function addCategoryLinks($newLinkArray) {
211 $this->mCategoryLinks +
= $newLinkArray;
213 function setCategoryLinks($newLinkArray) {
214 $this->mCategoryLinks +
= $newLinkArray;
217 function suppressQuickbar() { $this->mSuppressQuickbar
= true; }
218 function isQuickbarSuppressed() { return $this->mSuppressQuickbar
; }
220 function addHTML( $text ) { $this->mBodytext
.= $text; }
221 function clearHTML() { $this->mBodytext
= ''; }
222 function debug( $text ) { $this->mDebugtext
.= $text; }
224 function setParserOptions( $options ) {
225 return wfSetVar( $this->mParserOptions
, $options );
229 * Convert wikitext to HTML and add it to the buffer
231 function addWikiText( $text, $linestart = true ) {
232 global $wgParser, $wgTitle, $wgUseTidy;
234 $parserOutput = $wgParser->parse( $text, $wgTitle, $this->mParserOptions
, $linestart );
235 $this->mLanguageLinks +
= $parserOutput->getLanguageLinks();
236 $this->mCategoryLinks +
= $parserOutput->getCategoryLinks();
237 $this->addHTML( $parserOutput->getText() );
241 * Add wikitext to the buffer, assuming that this is the primary text for a page view
242 * Saves the text into the parser cache if possible
244 function addPrimaryWikiText( $text, $cacheArticle ) {
245 global $wgParser, $wgParserCache, $wgUser, $wgTitle, $wgUseTidy;
247 $parserOutput = $wgParser->parse( $text, $wgTitle, $this->mParserOptions
, true );
249 $text = $parserOutput->getText();
251 if ( $cacheArticle ) {
252 $wgParserCache->save( $parserOutput, $cacheArticle, $wgUser );
255 $this->mLanguageLinks +
= $parserOutput->getLanguageLinks();
256 $this->mCategoryLinks +
= $parserOutput->getCategoryLinks();
257 $this->addHTML( $text );
261 * Add the output of a QuickTemplate to the output buffer
262 * @param QuickTemplate $template
264 function addTemplate( &$template ) {
266 $template->execute();
267 $this->addHtml( ob_get_contents() );
272 * Parse wikitext and return the HTML. This is for special pages that add the text later
274 function parse( $text, $linestart = true ) {
275 global $wgParser, $wgTitle;
276 $parserOutput = $wgParser->parse( $text, $wgTitle, $this->mParserOptions
, $linestart );
277 return $parserOutput->getText();
284 function tryParserCache( $article, $user ) {
285 global $wgParserCache;
286 $parserOutput = $wgParserCache->get( $article, $user );
287 if ( $parserOutput !== false ) {
288 $this->mLanguageLinks +
= $parserOutput->getLanguageLinks();
289 $this->mCategoryLinks +
= $parserOutput->getCategoryLinks();
290 $this->addHTML( $parserOutput->getText() );
298 * Set the maximum cache time on the Squid in seconds
301 function setSquidMaxage( $maxage ) {
302 $this->mSquidMaxage
= $maxage;
306 * Use enableClientCache(false) to force it to send nocache headers
309 function enableClientCache( $state ) {
310 return wfSetVar( $this->mEnableClientCache
, $state );
313 function sendCacheControl() {
314 global $wgUseSquid, $wgUseESI;
315 # don't serve compressed data to clients who can't handle it
316 # maintain different caches for logged-in users and non-logged in ones
317 header( 'Vary: Accept-Encoding, Cookie' );
318 if( $this->mEnableClientCache
) {
319 if( $wgUseSquid && ! isset( $_COOKIE[ini_get( 'session.name') ] ) &&
320 ! $this->isPrintable() && $this->mSquidMaxage
!= 0 )
323 # We'll purge the proxy cache explicitly, but require end user agents
324 # to revalidate against the proxy on each visit.
325 # Surrogate-Control controls our Squid, Cache-Control downstream caches
326 wfDebug( "** proxy caching with ESI; {$this->mLastModified} **\n", false );
327 # start with a shorter timeout for initial testing
328 # header( 'Surrogate-Control: max-age=2678400+2678400, content="ESI/1.0"');
329 header( 'Surrogate-Control: max-age='.$wgSquidMaxage.'+'.$this->mSquidMaxage
.', content="ESI/1.0"');
330 header( 'Cache-Control: s-maxage=0, must-revalidate, max-age=0' );
332 # We'll purge the proxy cache for anons explicitly, but require end user agents
333 # to revalidate against the proxy on each visit.
334 # IMPORTANT! The Squid needs to replace the Cache-Control header with
335 # Cache-Control: s-maxage=0, must-revalidate, max-age=0
336 wfDebug( "** local proxy caching; {$this->mLastModified} **\n", false );
337 # start with a shorter timeout for initial testing
338 # header( "Cache-Control: s-maxage=2678400, must-revalidate, max-age=0" );
339 header( 'Cache-Control: s-maxage='.$this->mSquidMaxage
.', must-revalidate, max-age=0' );
342 # We do want clients to cache if they can, but they *must* check for updates
343 # on revisiting the page.
344 wfDebug( "** private caching; {$this->mLastModified} **\n", false );
345 header( "Expires: -1" );
346 header( "Cache-Control: private, must-revalidate, max-age=0" );
348 if($this->mLastModified
) header( "Last-modified: {$this->mLastModified}" );
350 wfDebug( "** no caching **\n", false );
352 # In general, the absence of a last modified header should be enough to prevent
353 # the client from using its cache. We send a few other things just to make sure.
354 header( 'Expires: -1' );
355 header( 'Cache-Control: no-cache, no-store, max-age=0, must-revalidate' );
356 header( 'Pragma: no-cache' );
361 * Finally, all the text has been munged and accumulated into
362 * the object, let's actually output it:
365 global $wgUser, $wgLang, $wgDebugComments, $wgCookieExpiration;
366 global $wgInputEncoding, $wgOutputEncoding, $wgContLanguageCode;
367 global $wgDebugRedirects, $wgMimeType, $wgProfiler;
369 if( $this->mDoNothing
){
372 $fname = 'OutputPage::output';
373 wfProfileIn( $fname );
374 $sk = $wgUser->getSkin();
376 if ( '' != $this->mRedirect
) {
377 if( substr( $this->mRedirect
, 0, 4 ) != 'http' ) {
378 # Standards require redirect URLs to be absolute
380 $this->mRedirect
= $wgServer . $this->mRedirect
;
382 if( $this->mRedirectCode
== '301') {
383 if( !$wgDebugRedirects ) {
384 header("HTTP/1.1 {$this->mRedirectCode} Moved Permanently");
386 $this->mLastModified
= wfTimestamp( TS_RFC2822
);
389 $this->sendCacheControl();
391 if( $wgDebugRedirects ) {
392 $url = htmlspecialchars( $this->mRedirect
);
393 print "<html>\n<head>\n<title>Redirect</title>\n</head>\n<body>\n";
394 print "<p>Location: <a href=\"$url\">$url</a></p>\n";
395 print "</body>\n</html>\n";
397 header( 'Location: '.$this->mRedirect
);
399 if ( isset( $wgProfiler ) ) { wfDebug( $wgProfiler->getOutput() ); }
404 # Buffer output; final headers may depend on later processing
407 $this->transformBuffer();
409 # Disable temporary placeholders, so that the skin produces HTML
410 $sk->postParseLinkColour( false );
412 header( "Content-type: $wgMimeType; charset={$wgOutputEncoding}" );
413 header( 'Content-language: '.$wgContLanguageCode );
415 $exp = time() +
$wgCookieExpiration;
416 foreach( $this->mCookies
as $name => $val ) {
417 setcookie( $name, $val, $exp, '/' );
420 wfProfileIn( 'Output-skin' );
421 $sk->outputPage( $this );
422 wfProfileOut( 'Output-skin' );
424 $this->sendCacheControl();
428 function out( $ins ) {
429 global $wgInputEncoding, $wgOutputEncoding, $wgContLang;
430 if ( 0 == strcmp( $wgInputEncoding, $wgOutputEncoding ) ) {
433 $outs = $wgContLang->iconv( $wgInputEncoding, $wgOutputEncoding, $ins );
434 if ( false === $outs ) { $outs = $ins; }
439 function setEncodings() {
440 global $wgInputEncoding, $wgOutputEncoding;
441 global $wgUser, $wgContLang;
443 $wgInputEncoding = strtolower( $wgInputEncoding );
445 if( $wgUser->getOption( 'altencoding' ) ) {
446 $wgContLang->setAltEncoding();
450 if ( empty( $_SERVER['HTTP_ACCEPT_CHARSET'] ) ) {
451 $wgOutputEncoding = strtolower( $wgOutputEncoding );
456 # This code is unused anyway!
457 # Commenting out. --bv 2003-11-15
459 $a = explode( ",", $_SERVER['HTTP_ACCEPT_CHARSET'] );
463 foreach ( $a as $s ) {
464 if ( preg_match( "/(.*);q=(.*)/", $s, $m ) ) {
476 #if ( "*" == $bestset ) { $bestset = "iso-8859-1"; }
477 if ( "*" == $bestset ) { $bestset = $wgOutputEncoding; }
478 $wgOutputEncoding = strtolower( $bestset );
483 $wgOutputEncoding = $wgInputEncoding;
487 * Returns a HTML comment with the elapsed time since request.
488 * This method has no side effects.
491 function reportTime() {
492 global $wgRequestTime;
495 list( $usec, $sec ) = explode( ' ', $wgRequestTime );
496 $start = (float)$sec +
(float)$usec;
497 $elapsed = $now - $start;
499 # Use real server name if available, so we know which machine
500 # in a server farm generated the current page.
501 if ( function_exists( 'posix_uname' ) ) {
502 $uname = @posix_uname
();
506 if( is_array( $uname ) && isset( $uname['nodename'] ) ) {
507 $hostname = $uname['nodename'];
509 # This may be a virtual server.
510 $hostname = $_SERVER['SERVER_NAME'];
512 $com = sprintf( "<!-- Served by %s in %01.2f secs. -->",
513 $hostname, $elapsed );
518 * Note: these arguments are keys into wfMsg(), not text!
520 function errorpage( $title, $msg ) {
523 $this->mDebugtext
.= 'Original title: ' .
524 $wgTitle->getPrefixedText() . "\n";
525 $this->setPageTitle( wfMsg( $title ) );
526 $this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
527 $this->setRobotpolicy( 'noindex,nofollow' );
528 $this->setArticleRelated( false );
529 $this->enableClientCache( false );
530 $this->mRedirect
= '';
532 $this->mBodytext
= '';
533 $this->addHTML( '<p>' . wfMsg( $msg ) . "</p>\n" );
534 $this->returnToMain( false );
540 function sysopRequired() {
543 $this->setPageTitle( wfMsg( 'sysoptitle' ) );
544 $this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
545 $this->setRobotpolicy( 'noindex,nofollow' );
546 $this->setArticleRelated( false );
547 $this->mBodytext
= '';
549 $sk = $wgUser->getSkin();
550 $ap = $sk->makeKnownLink( wfMsgForContent( 'administrators' ), '' );
551 $this->addHTML( wfMsg( 'sysoptext', $ap ) );
552 $this->returnToMain();
555 function developerRequired() {
558 $this->setPageTitle( wfMsg( 'developertitle' ) );
559 $this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
560 $this->setRobotpolicy( 'noindex,nofollow' );
561 $this->setArticleRelated( false );
562 $this->mBodytext
= '';
564 $sk = $wgUser->getSkin();
565 $ap = $sk->makeKnownLink( wfMsgForContent( 'administrators' ), '' );
566 $this->addHTML( wfMsg( 'developertext', $ap ) );
567 $this->returnToMain();
570 function loginToUse() {
571 global $wgUser, $wgTitle, $wgContLang;
573 $this->setPageTitle( wfMsg( 'loginreqtitle' ) );
574 $this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
575 $this->setRobotpolicy( 'noindex,nofollow' );
576 $this->setArticleFlag( false );
577 $this->mBodytext
= '';
578 $this->addWikiText( wfMsg( 'loginreqtext' ) );
580 # We put a comment in the .html file so a Sysop can diagnose the page the
582 $this->addHTML( "\n<!--" .
583 $wgContLang->getNsText( $wgTitle->getNamespace() ) .
585 $wgTitle->getDBkey() . '-->' );
586 $this->returnToMain(); # Flip back to the main page after 10 seconds.
589 function databaseError( $fname, $sql, $error, $errno ) {
590 global $wgUser, $wgCommandLineMode, $wgShowSQLErrors;
592 $this->setPageTitle( wfMsgNoDB( 'databaseerror' ) );
593 $this->setRobotpolicy( 'noindex,nofollow' );
594 $this->setArticleRelated( false );
595 $this->enableClientCache( false );
596 $this->mRedirect
= '';
598 if( $wgShowSQLErrors ) {
599 if ( $wgCommandLineMode ) {
600 $msg = wfMsgNoDB( 'dberrortextcl', htmlspecialchars( $sql ),
601 htmlspecialchars( $fname ), $errno, htmlspecialchars( $error ) );
603 $msg = wfMsgNoDB( 'dberrortext', htmlspecialchars( $sql ),
604 htmlspecialchars( $fname ), $errno, htmlspecialchars( $error ) );
607 if( $wgCommandLineMode ) {
608 $msg = wfMsg( 'internalerror' );
610 $msg = htmlspecialchars( wfMsg( 'internalerror' ) );
614 if ( $wgCommandLineMode ||
!is_object( $wgUser )) {
618 $this->mBodytext
= $msg;
623 function readOnlyPage( $source = null, $protected = false ) {
624 global $wgUser, $wgReadOnlyFile;
626 $this->setRobotpolicy( 'noindex,nofollow' );
627 $this->setArticleRelated( false );
630 $this->setPageTitle( wfMsg( 'viewsource' ) );
631 $this->addWikiText( wfMsg( 'protectedtext' ) );
633 $this->setPageTitle( wfMsg( 'readonly' ) );
634 $reason = file_get_contents( $wgReadOnlyFile );
635 $this->addWikiText( wfMsg( 'readonlytext', $reason ) );
638 if( is_string( $source ) ) {
639 if( strcmp( $source, '' ) == 0 ) {
640 $source = wfMsg( 'noarticletext' );
642 $rows = $wgUser->getOption( 'rows' );
643 $cols = $wgUser->getOption( 'cols' );
644 $text = "\n<textarea cols='$cols' rows='$rows' readonly='readonly'>" .
645 htmlspecialchars( $source ) . "\n</textarea>";
646 $this->addHTML( $text );
649 $this->returnToMain( false );
652 function fatalError( $message ) {
653 $this->setPageTitle( wfMsg( "internalerror" ) );
654 $this->setRobotpolicy( "noindex,nofollow" );
655 $this->setArticleRelated( false );
656 $this->enableClientCache( false );
657 $this->mRedirect
= '';
659 $this->mBodytext
= $message;
664 function unexpectedValueError( $name, $val ) {
665 $this->fatalError( wfMsg( 'unexpected', $name, $val ) );
668 function fileCopyError( $old, $new ) {
669 $this->fatalError( wfMsg( 'filecopyerror', $old, $new ) );
672 function fileRenameError( $old, $new ) {
673 $this->fatalError( wfMsg( 'filerenameerror', $old, $new ) );
676 function fileDeleteError( $name ) {
677 $this->fatalError( wfMsg( 'filedeleteerror', $name ) );
680 function fileNotFoundError( $name ) {
681 $this->fatalError( wfMsg( 'filenotfound', $name ) );
685 * return from error messages or notes
686 * @param $auto automatically redirect the user after 10 seconds
687 * @param $returnto page title to return to. Default is Main Page.
689 function returnToMain( $auto = true, $returnto = NULL ) {
690 global $wgUser, $wgOut, $wgRequest;
692 if ( $returnto == NULL ) {
693 $returnto = $wgRequest->getText( 'returnto' );
695 $returnto = htmlspecialchars( $returnto );
697 $sk = $wgUser->getSkin();
698 if ( '' == $returnto ) {
699 $returnto = wfMsgForContent( 'mainpage' );
701 $link = $sk->makeKnownLink( $returnto, '' );
703 $r = wfMsg( 'returnto', $link );
705 $titleObj = Title
::newFromText( $returnto );
706 $wgOut->addMeta( 'http:Refresh', '10;url=' . $titleObj->escapeFullURL() );
708 $wgOut->addHTML( "\n<p>$r</p>\n" );
712 * This function takes the existing and broken links for the page
713 * and uses the first 10 of them for META keywords
715 function addMetaTags () {
716 global $wgLinkCache , $wgOut ;
717 $good = array_keys ( $wgLinkCache->mGoodLinks
) ;
718 $bad = array_keys ( $wgLinkCache->mBadLinks
) ;
719 $a = array_merge ( $good , $bad ) ;
720 $a = array_slice ( $a , 0 , 10 ) ; # 10 keywords max
721 $a = implode ( ',' , $a ) ;
723 "/<.*?" . ">/" => '',
726 $a = htmlspecialchars(preg_replace(array_keys($strip), array_values($strip),$a ));
728 $wgOut->addMeta ( 'KEYWORDS' , $a ) ;
735 function headElement() {
736 global $wgDocType, $wgDTD, $wgContLanguageCode, $wgOutputEncoding, $wgMimeType;
737 global $wgUser, $wgContLang, $wgRequest;
739 if( $wgMimeType == 'text/xml' ||
$wgMimeType == 'application/xhtml+xml' ||
$wgMimeType == 'application/xml' ) {
740 $ret = "<" . "?xml version=\"1.0\" encoding=\"$wgOutputEncoding\" ?" . ">\n";
745 $ret .= "<!DOCTYPE html PUBLIC \"$wgDocType\"\n \"$wgDTD\">\n";
747 if ( "" == $this->mHTMLtitle
) {
748 $this->mHTMLtitle
= wfMsg( "pagetitle", $this->mPagetitle
);
751 $rtl = $wgContLang->isRTL() ?
" dir='RTL'" : '';
752 $ret .= "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"$wgContLanguageCode\" lang=\"$wgContLanguageCode\" $rtl>\n";
753 $ret .= "<head>\n<title>" . htmlspecialchars( $this->mHTMLtitle
) . "</title>\n";
754 array_push( $this->mMetatags
, array( "http:Content-type", "$wgMimeType; charset={$wgOutputEncoding}" ) );
756 $ret .= $this->getHeadLinks();
758 if( $this->isPrintable() ) {
761 $media = "media='print'";
763 $printsheet = htmlspecialchars( "$wgStylePath/common/wikiprintable.css" );
764 $ret .= "<link rel='stylesheet' type='text/css' $media href='$printsheet' />\n";
766 $sk = $wgUser->getSkin();
767 $ret .= $sk->getHeadScripts();
768 $ret .= $this->mScripts
;
769 $ret .= $sk->getUserStyles();
775 function getHeadLinks() {
776 global $wgRequest, $wgStylePath;
778 foreach ( $this->mMetatags
as $tag ) {
779 if ( 0 == strcasecmp( 'http:', substr( $tag[0], 0, 5 ) ) ) {
781 $tag[0] = substr( $tag[0], 5 );
785 $ret .= "<meta $a=\"{$tag[0]}\" content=\"{$tag[1]}\" />\n";
787 $p = $this->mRobotpolicy
;
788 if ( '' == $p ) { $p = 'index,follow'; }
789 $ret .= "<meta name=\"robots\" content=\"$p\" />\n";
791 if ( count( $this->mKeywords
) > 0 ) {
793 "/<.*?" . ">/" => '',
796 $ret .= "<meta name=\"keywords\" content=\"" .
797 htmlspecialchars(preg_replace(array_keys($strip), array_values($strip),implode( ",", $this->mKeywords
))) . "\" />\n";
799 foreach ( $this->mLinktags
as $tag ) {
801 foreach( $tag as $attr => $val ) {
802 $ret .= " $attr=\"" . htmlspecialchars( $val ) . "\"";
806 if( $this->isSyndicated() ) {
807 # FIXME: centralize the mime-type and name information in Feed.php
808 $link = $wgRequest->escapeAppendQuery( 'feed=rss' );
809 $ret .= "<link rel='alternate' type='application/rss+xml' title='RSS 2.0' href='$link' />\n";
810 $link = $wgRequest->escapeAppendQuery( 'feed=atom' );
811 $ret .= "<link rel='alternate' type='application/rss+atom' title='Atom 0.3' href='$link' />\n";
818 * Run any necessary pre-output transformations on the buffer text
820 function transformBuffer( $options = 0 ) {