e4f79a17033b01ce21700011eb4bc5208fc9d363
[lhc/web/wiklou.git] / includes / OutputPage.php
1 <?php
2 # See design.doc
3
4 if($wgUseTeX) include_once( "Math.php" );
5
6 class OutputPage {
7 var $mHeaders, $mCookies, $mMetatags, $mKeywords;
8 var $mLinktags, $mPagetitle, $mBodytext, $mDebugtext;
9 var $mHTMLtitle, $mRobotpolicy, $mIsarticle, $mPrintable;
10 var $mSubtitle, $mRedirect, $mHeadtext;
11 var $mLastModified, $mCategoryLinks;
12
13 var $mSuppressQuickbar;
14 var $mOnloadHandler;
15 var $mDoNothing;
16 var $mContainsOldMagic, $mContainsNewMagic;
17 var $mIsArticleRelated;
18 var $mParserOptions;
19 var $mShowFeedLinks = false;
20 var $mEnableClientCache = true;
21
22 function OutputPage()
23 {
24 $this->mHeaders = $this->mCookies = $this->mMetatags =
25 $this->mKeywords = $this->mLinktags = array();
26 $this->mHTMLtitle = $this->mPagetitle = $this->mBodytext =
27 $this->mRedirect = $this->mLastModified =
28 $this->mSubtitle = $this->mDebugtext = $this->mRobotpolicy =
29 $this->mOnloadHandler = "";
30 $this->mIsArticleRelated = $this->mIsarticle = $this->mPrintable = true;
31 $this->mSuppressQuickbar = $this->mPrintable = false;
32 $this->mLanguageLinks = array();
33 $this->mCategoryLinks = array() ;
34 $this->mDoNothing = false;
35 $this->mContainsOldMagic = $this->mContainsNewMagic = 0;
36 $this->mParserOptions = ParserOptions::newFromUser( $temp = NULL );
37 $this->mSquidMaxage = 0;
38 }
39
40 function addHeader( $name, $val ) { array_push( $this->mHeaders, "$name: $val" ) ; }
41 function addCookie( $name, $val ) { array_push( $this->mCookies, array( $name, $val ) ); }
42 function redirect( $url, $responsecode = '302' ) { $this->mRedirect = $url; $this->mRedirectCode = $responsecode; }
43
44 # To add an http-equiv meta tag, precede the name with "http:"
45 function addMeta( $name, $val ) { array_push( $this->mMetatags, array( $name, $val ) ); }
46 function addKeyword( $text ) { array_push( $this->mKeywords, $text ); }
47 function addLink( $rel, $rev, $target, $type="", $media="" ) { array_push( $this->mLinktags, array( $rel, $rev, $target, $type, $media ) ); }
48
49 # checkLastModified tells the client to use the client-cached page if
50 # possible. If sucessful, the OutputPage is disabled so that
51 # any future call to OutputPage->output() have no effect. The method
52 # returns true iff cache-ok headers was sent.
53 function checkLastModified ( $timestamp )
54 {
55 global $wgLang, $wgCachePages, $wgUser;
56 if( !$wgCachePages ) {
57 wfDebug( "CACHE DISABLED\n", false );
58 return;
59 }
60 if( preg_match( '/MSIE ([1-4]|5\.0)/', $_SERVER["HTTP_USER_AGENT"] ) ) {
61 # IE 5.0 has probs with our caching
62 wfDebug( "-- bad client, not caching\n", false );
63 return;
64 }
65 if( $wgUser->getOption( "nocache" ) ) {
66 wfDebug( "USER DISABLED CACHE\n", false );
67 return;
68 }
69
70 $lastmod = gmdate( "D, j M Y H:i:s", wfTimestamp2Unix(
71 max( $timestamp, $wgUser->mTouched ) ) ) . " GMT";
72
73 if( !empty( $_SERVER["HTTP_IF_MODIFIED_SINCE"] ) ) {
74 # IE sends sizes after the date like this:
75 # Wed, 20 Aug 2003 06:51:19 GMT; length=5202
76 # this breaks strtotime().
77 $modsince = preg_replace( '/;.*$/', '', $_SERVER["HTTP_IF_MODIFIED_SINCE"] );
78 $ismodsince = wfUnix2Timestamp( strtotime( $modsince ) );
79 wfDebug( "-- client send If-Modified-Since: " . $modsince . "\n", false );
80 wfDebug( "-- we might send Last-Modified : $lastmod\n", false );
81
82 if( ($ismodsince >= $timestamp ) and $wgUser->validateCache( $ismodsince ) ) {
83 # Make sure you're in a place you can leave when you call us!
84 header( "HTTP/1.0 304 Not Modified" );
85 $this->mLastModified = $lastmod;
86 $this->sendCacheControl();
87 wfDebug( "CACHED client: $ismodsince ; user: $wgUser->mTouched ; page: $timestamp\n", false );
88 $this->disable();
89 return true;
90 } else {
91 wfDebug( "READY client: $ismodsince ; user: $wgUser->mTouched ; page: $timestamp\n", false );
92 $this->mLastModified = $lastmod;
93 }
94 } else {
95 wfDebug( "We're confused.\n", false );
96 $this->mLastModified = $lastmod;
97 }
98 }
99
100 function setRobotpolicy( $str ) { $this->mRobotpolicy = $str; }
101 function setHTMLtitle( $name ) { $this->mHTMLtitle = $name; }
102 function setPageTitle( $name ) { $this->mPagetitle = $name; }
103 function getPageTitle() { return $this->mPagetitle; }
104 function setSubtitle( $str ) { $this->mSubtitle = $str; }
105 function getSubtitle() { return $this->mSubtitle; }
106 function isArticle() { return $this->mIsarticle; }
107 function setPrintable() { $this->mPrintable = true; }
108 function isPrintable() { return $this->mPrintable; }
109 function setSyndicated( $show = true ) { $this->mShowFeedLinks = $show; }
110 function isSyndicated() { return $this->mShowFeedLinks; }
111 function setOnloadHandler( $js ) { $this->mOnloadHandler = $js; }
112 function getOnloadHandler() { return $this->mOnloadHandler; }
113 function disable() { $this->mDoNothing = true; }
114
115 function setArticleRelated( $v )
116 {
117 $this->mIsArticleRelated = $v;
118 if ( !$v ) {
119 $this->mIsarticle = false;
120 }
121 }
122 function setArticleFlag( $v ) {
123 $this->mIsarticle = $v;
124 if ( $v ) {
125 $this->mIsArticleRelated = $v;
126 }
127 }
128
129 function isArticleRelated()
130 {
131 return $this->mIsArticleRelated;
132 }
133
134 function getLanguageLinks() {
135 global $wgTitle, $wgLanguageCode;
136 global $wgDBconnection, $wgDBname;
137 return $this->mLanguageLinks;
138 }
139 function suppressQuickbar() { $this->mSuppressQuickbar = true; }
140 function isQuickbarSuppressed() { return $this->mSuppressQuickbar; }
141
142 function addHTML( $text ) { $this->mBodytext .= $text; }
143 function addHeadtext( $text ) { $this->mHeadtext .= $text; }
144 function debug( $text ) { $this->mDebugtext .= $text; }
145
146 function setParserOptions( $options )
147 {
148 return wfSetVar( $this->mParserOptions, $options );
149 }
150
151 # First pass--just handle <nowiki> sections, pass the rest off
152 # to doWikiPass2() which does all the real work.
153 #
154 # $cacheArticle - assume this text is the main text for the given article
155 #
156 function addWikiText( $text, $linestart = true, $cacheArticle = NULL )
157 {
158 global $wgParser, $wgParserCache, $wgUser, $wgTitle;
159
160 $parserOutput = false;
161 if ( $cacheArticle ) {
162 $parserOutput = $wgParserCache->get( $cacheArticle, $wgUser );
163 }
164
165 if ( $parserOutput === false ) {
166 $parserOutput = $wgParser->parse( $text, $wgTitle, $this->mParserOptions, $linestart );
167 if ( $cacheArticle ) {
168 $wgParserCache->save( $parserOutput, $cacheArticle, $wgUser );
169 }
170 }
171
172 $this->mLanguageLinks += $parserOutput->getLanguageLinks();
173 $this->mCategoryLinks += $parserOutput->getCategoryLinks();
174
175 $this->addHTML( $parserOutput->getText() );
176
177 }
178
179 # Set the maximum cache time on the Squid in seconds
180 function setSquidMaxage( $maxage ) {
181 $this->mSquidMaxage = $maxage;
182 }
183
184 # Use enableClientCache(false) to force it to send nocache headers
185 function enableClientCache( $state ) {
186 return wfSetVar( $this->mEnableClientCache, $state );
187 }
188
189 function sendCacheControl() {
190 global $wgUseSquid, $wgUseESI;
191 # FIXME: This header may cause trouble with some versions of Internet Explorer
192 header( "Vary: Accept-Encoding, Cookie" );
193 if( $this->mEnableClientCache && $this->mLastModified != "" ) {
194 if( $wgUseSquid && ! isset( $_COOKIE[ini_get( "session.name") ] ) &&
195 ! $this->isPrintable() )
196 {
197 if ( $wgUseESI ) {
198 # We'll purge the proxy cache explicitly, but require end user agents
199 # to revalidate against the proxy on each visit.
200 # Surrogate-Control controls our Squid, Cache-Control downstream caches
201 wfDebug( "** proxy caching with ESI; {$this->mLastModified} **\n", false );
202 # start with a shorter timeout for initial testing
203 # header( 'Surrogate-Control: max-age=2678400+2678400, content="ESI/1.0"');
204 header( 'Surrogate-Control: max-age='.$wgSquidMaxage.'+'.$this->mSquidMaxage.', content="ESI/1.0"');
205 header( 'Cache-Control: s-maxage=0, must-revalidate, max-age=0' );
206 } else {
207 # We'll purge the proxy cache for anons explicitly, but require end user agents
208 # to revalidate against the proxy on each visit.
209 # IMPORTANT! The Squid needs to replace the Cache-Control header with
210 # Cache-Control: s-maxage=0, must-revalidate, max-age=0
211 wfDebug( "** local proxy caching; {$this->mLastModified} **\n", false );
212 # start with a shorter timeout for initial testing
213 # header( "Cache-Control: s-maxage=2678400, must-revalidate, max-age=0" );
214 header( 'Cache-Control: s-maxage='.$this->mSquidMaxage.', must-revalidate, max-age=0' );
215 }
216 } else {
217 # We do want clients to cache if they can, but they *must* check for updates
218 # on revisiting the page.
219 wfDebug( "** private caching; {$this->mLastModified} **\n", false );
220 header( "Expires: -1" );
221 header( "Cache-Control: private, must-revalidate, max-age=0" );
222 }
223 header( "Last-modified: {$this->mLastModified}" );
224 } else {
225 wfDebug( "** no caching **\n", false );
226
227 # In general, the absence of a last modified header should be enough to prevent
228 # the client from using its cache. We send a few other things just to make sure.
229 header( "Expires: -1" );
230 header( "Cache-Control: no-cache, no-store, max-age=0, must-revalidate" );
231 header( "Pragma: no-cache" );
232 }
233 }
234
235 # Finally, all the text has been munged and accumulated into
236 # the object, let's actually output it:
237 #
238 function output()
239 {
240 global $wgUser, $wgLang, $wgDebugComments, $wgCookieExpiration;
241 global $wgInputEncoding, $wgOutputEncoding, $wgLanguageCode;
242 global $wgDebugRedirects, $wgMimeType;
243 if( $this->mDoNothing ){
244 return;
245 }
246 $fname = "OutputPage::output";
247 wfProfileIn( $fname );
248
249 $sk = $wgUser->getSkin();
250
251 if ( "" != $this->mRedirect ) {
252 if( substr( $this->mRedirect, 0, 4 ) != "http" ) {
253 # Standards require redirect URLs to be absolute
254 global $wgServer;
255 $this->mRedirect = $wgServer . $this->mRedirect;
256 }
257 if( $this->mRedirectCode == '301') {
258 if( !$wgDebugRedirects ) {
259 header("HTTP/1.1 {$this->mRedirectCode} Moved Permanently");
260 }
261 $this->mLastModified = gmdate( "D, j M Y H:i:s" ) . " GMT";
262 }
263
264 $this->sendCacheControl();
265
266 if( $wgDebugRedirects ) {
267 $url = htmlspecialchars( $this->mRedirect );
268 print "<html>\n<head>\n<title>Redirect</title>\n</head>\n<body>\n";
269 print "<p>Location: <a href=\"$url\">$url</a></p>\n";
270 print "</body>\n</html>\n";
271 } else {
272 header( "Location: {$this->mRedirect}" );
273 }
274 return;
275 }
276
277
278 $this->sendCacheControl();
279
280 header( "Content-type: $wgMimeType; charset={$wgOutputEncoding}" );
281 header( "Content-language: {$wgLanguageCode}" );
282
283 $exp = time() + $wgCookieExpiration;
284 foreach( $this->mCookies as $name => $val ) {
285 setcookie( $name, $val, $exp, "/" );
286 }
287
288 $sk->outputPage( $this );
289 # flush();
290 }
291
292 function out( $ins )
293 {
294 global $wgInputEncoding, $wgOutputEncoding, $wgLang;
295 if ( 0 == strcmp( $wgInputEncoding, $wgOutputEncoding ) ) {
296 $outs = $ins;
297 } else {
298 $outs = $wgLang->iconv( $wgInputEncoding, $wgOutputEncoding, $ins );
299 if ( false === $outs ) { $outs = $ins; }
300 }
301 print $outs;
302 }
303
304 function setEncodings()
305 {
306 global $wgInputEncoding, $wgOutputEncoding;
307 global $wgUser, $wgLang;
308
309 $wgInputEncoding = strtolower( $wgInputEncoding );
310
311 if( $wgUser->getOption( 'altencoding' ) ) {
312 $wgLang->setAltEncoding();
313 return;
314 }
315
316 if ( empty( $_SERVER['HTTP_ACCEPT_CHARSET'] ) ) {
317 $wgOutputEncoding = strtolower( $wgOutputEncoding );
318 return;
319 }
320
321 /*
322 # This code is unused anyway!
323 # Commenting out. --bv 2003-11-15
324
325 $a = explode( ",", $_SERVER['HTTP_ACCEPT_CHARSET'] );
326 $best = 0.0;
327 $bestset = "*";
328
329 foreach ( $a as $s ) {
330 if ( preg_match( "/(.*);q=(.*)/", $s, $m ) ) {
331 $set = $m[1];
332 $q = (float)($m[2]);
333 } else {
334 $set = $s;
335 $q = 1.0;
336 }
337 if ( $q > $best ) {
338 $bestset = $set;
339 $best = $q;
340 }
341 }
342 #if ( "*" == $bestset ) { $bestset = "iso-8859-1"; }
343 if ( "*" == $bestset ) { $bestset = $wgOutputEncoding; }
344 $wgOutputEncoding = strtolower( $bestset );
345
346 # Disable for now
347 #
348 */
349 $wgOutputEncoding = $wgInputEncoding;
350 }
351
352 # Returns a HTML comment with the elapsed time since request.
353 # This method has no side effects.
354 function reportTime()
355 {
356 global $wgRequestTime;
357
358 $now = wfTime();
359 list( $usec, $sec ) = explode( " ", $wgRequestTime );
360 $start = (float)$sec + (float)$usec;
361 $elapsed = $now - $start;
362 $com = sprintf( "<!-- Time since request: %01.2f secs. -->",
363 $elapsed );
364 return $com;
365 }
366
367 # Note: these arguments are keys into wfMsg(), not text!
368 #
369 function errorpage( $title, $msg )
370 {
371 global $wgTitle;
372
373 $this->mDebugtext .= "Original title: " .
374 $wgTitle->getPrefixedText() . "\n";
375 $this->setHTMLTitle( wfMsg( "errorpagetitle" ) );
376 $this->setPageTitle( wfMsg( $title ) );
377 $this->setRobotpolicy( "noindex,nofollow" );
378 $this->setArticleRelated( false );
379 $this->enableClientCache( false );
380
381 $this->mBodytext = "";
382 $this->addHTML( "<p>" . wfMsg( $msg ) . "\n" );
383 $this->returnToMain( false );
384
385 $this->output();
386 wfAbruptExit();
387 }
388
389 function sysopRequired()
390 {
391 global $wgUser;
392
393 $this->setHTMLTitle( wfMsg( "errorpagetitle" ) );
394 $this->setPageTitle( wfMsg( "sysoptitle" ) );
395 $this->setRobotpolicy( "noindex,nofollow" );
396 $this->setArticleRelated( false );
397 $this->mBodytext = "";
398
399 $sk = $wgUser->getSkin();
400 $ap = $sk->makeKnownLink( wfMsg( "administrators" ), "" );
401 $this->addHTML( wfMsg( "sysoptext", $ap ) );
402 $this->returnToMain();
403 }
404
405 function developerRequired()
406 {
407 global $wgUser;
408
409 $this->setHTMLTitle( wfMsg( "errorpagetitle" ) );
410 $this->setPageTitle( wfMsg( "developertitle" ) );
411 $this->setRobotpolicy( "noindex,nofollow" );
412 $this->setArticleRelated( false );
413 $this->mBodytext = "";
414
415 $sk = $wgUser->getSkin();
416 $ap = $sk->makeKnownLink( wfMsg( "administrators" ), "" );
417 $this->addHTML( wfMsg( "developertext", $ap ) );
418 $this->returnToMain();
419 }
420
421 function loginToUse()
422 {
423 global $wgUser, $wgTitle, $wgLang;
424
425 $this->setHTMLTitle( wfMsg( "errorpagetitle" ) );
426 $this->setPageTitle( wfMsg( "loginreqtitle" ) );
427 $this->setRobotpolicy( "noindex,nofollow" );
428 $this->setArticleFlag( false );
429 $this->mBodytext = "";
430 $this->addWikiText( wfMsg( "loginreqtext" ) );
431
432 # We put a comment in the .html file so a Sysop can diagnose the page the
433 # user can't see.
434 $this->addHTML( "\n<!--" .
435 $wgLang->getNsText( $wgTitle->getNamespace() ) .
436 ":" .
437 $wgTitle->getDBkey() . "-->" );
438 $this->returnToMain(); # Flip back to the main page after 10 seconds.
439 }
440
441 function databaseError( $fname, &$conn )
442 {
443 global $wgUser, $wgCommandLineMode;
444
445 $this->setPageTitle( wfMsgNoDB( "databaseerror" ) );
446 $this->setRobotpolicy( "noindex,nofollow" );
447 $this->setArticleRelated( false );
448 $this->enableClientCache( false );
449
450 if ( $wgCommandLineMode ) {
451 $msg = wfMsgNoDB( "dberrortextcl" );
452 } else {
453 $msg = wfMsgNoDB( "dberrortext" );
454 }
455
456 $msg = str_replace( "$1", htmlspecialchars( $conn->lastQuery() ), $msg );
457 $msg = str_replace( "$2", htmlspecialchars( $fname ), $msg );
458 $msg = str_replace( "$3", $conn->lastErrno(), $msg );
459 $msg = str_replace( "$4", htmlspecialchars( $conn->lastError() ), $msg );
460
461 if ( $wgCommandLineMode || !is_object( $wgUser )) {
462 print "$msg\n";
463 wfAbruptExit();
464 }
465 $sk = $wgUser->getSkin();
466 $shlink = $sk->makeKnownLink( wfMsgNoDB( "searchhelppage" ),
467 wfMsgNoDB( "searchingwikipedia" ) );
468 $msg = str_replace( "$5", $shlink, $msg );
469 $this->mBodytext = $msg;
470 $this->output();
471 wfAbruptExit();
472 }
473
474 function readOnlyPage( $source = "", $protected = false )
475 {
476 global $wgUser, $wgReadOnlyFile;
477
478 $this->setRobotpolicy( "noindex,nofollow" );
479 $this->setArticleRelated( false );
480
481 if( $protected ) {
482 $this->setPageTitle( wfMsg( "viewsource" ) );
483 $this->addWikiText( wfMsg( "protectedtext" ) );
484 } else {
485 $this->setPageTitle( wfMsg( "readonly" ) );
486 $reason = file_get_contents( $wgReadOnlyFile );
487 $this->addHTML( wfMsg( "readonlytext", $reason ) );
488 }
489
490 if($source) {
491 $rows = $wgUser->getOption( "rows" );
492 $cols = $wgUser->getOption( "cols" );
493 $text .= "</p>\n<textarea cols='$cols' rows='$rows' readonly>" .
494 htmlspecialchars( $source ) . "\n</textarea>";
495 $this->addHTML( $text );
496 }
497
498 $this->returnToMain( false );
499 }
500
501 function fatalError( $message )
502 {
503 $this->setPageTitle( wfMsg( "internalerror" ) );
504 $this->setRobotpolicy( "noindex,nofollow" );
505 $this->setArticleRelated( false );
506 $this->enableClientCache( false );
507
508 $this->mBodytext = $message;
509 $this->output();
510 wfAbruptExit();
511 }
512
513 function unexpectedValueError( $name, $val )
514 {
515 $this->fatalError( wfMsg( "unexpected", $name, $val ) );
516 }
517
518 function fileCopyError( $old, $new )
519 {
520 $this->fatalError( wfMsg( "filecopyerror", $old, $new ) );
521 }
522
523 function fileRenameError( $old, $new )
524 {
525 $this->fatalError( wfMsg( "filerenameerror", $old, $new ) );
526 }
527
528 function fileDeleteError( $name )
529 {
530 $this->fatalError( wfMsg( "filedeleteerror", $name ) );
531 }
532
533 function fileNotFoundError( $name )
534 {
535 $this->fatalError( wfMsg( "filenotfound", $name ) );
536 }
537
538 function returnToMain( $auto = true, $returnto = NULL )
539 {
540 global $wgUser, $wgOut, $wgRequest;
541
542 if ( $returnto == NULL ) {
543 $returnto = $wgRequest->getText( 'returnto' );
544 }
545
546 $sk = $wgUser->getSkin();
547 if ( "" == $returnto ) {
548 $returnto = wfMsg( "mainpage" );
549 }
550 $link = $sk->makeKnownLink( $returnto, "" );
551
552 $r = wfMsg( "returnto", $link );
553 if ( $auto ) {
554 $titleObj = Title::newFromText( $returnto );
555 $wgOut->addMeta( "http:Refresh", "10;url=" . $titleObj->escapeFullURL() );
556 }
557 $wgOut->addHTML( "\n<p>$r</p>\n" );
558 }
559
560 # This function takes the existing and broken links for the page
561 # and uses the first 10 of them for META keywords
562 function addMetaTags ()
563 {
564 global $wgLinkCache , $wgOut ;
565 $good = array_keys ( $wgLinkCache->mGoodLinks ) ;
566 $bad = array_keys ( $wgLinkCache->mBadLinks ) ;
567 $a = array_merge ( $good , $bad ) ;
568 $a = array_slice ( $a , 0 , 10 ) ; # 10 keywords max
569 $a = implode ( "," , $a ) ;
570 $wgOut->addMeta ( "KEYWORDS" , $a ) ;
571 }
572
573 /* private */ function headElement()
574 {
575 global $wgDocType, $wgDTD, $wgLanguageCode, $wgOutputEncoding, $wgMimeType;
576 global $wgUser, $wgLang, $wgRequest;
577
578 $xml = ($wgMimeType == 'text/xml');
579 if( $xml ) {
580 $ret = "<" . "?xml version=\"1.0\" encoding=\"$wgOutputEncoding\" ?" . ">\n";
581 } else {
582 $ret = "";
583 }
584
585 $ret .= "<!DOCTYPE HTML PUBLIC \"$wgDocType\"\n \"$wgDTD\">\n";
586
587 if ( "" == $this->mHTMLtitle ) {
588 $this->mHTMLtitle = $this->mPagetitle;
589 }
590 if( $xml ) {
591 $xmlbits = "xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\"";
592 } else {
593 $xmlbits = "";
594 }
595 $rtl = $wgLang->isRTL() ? " dir='RTL'" : "";
596 $ret .= "<html $xmlbits lang=\"$wgLanguageCode\" $rtl>\n";
597 $ret .= "<head>\n<title>{$this->mHTMLtitle}</title>\n";
598 array_push( $this->mMetatags, array( "http:Content-type", "$wgMimeType; charset={$wgOutputEncoding}" ) );
599 foreach ( $this->mMetatags as $tag ) {
600 if ( 0 == strcasecmp( "http:", substr( $tag[0], 0, 5 ) ) ) {
601 $a = "http-equiv";
602 $tag[0] = substr( $tag[0], 5 );
603 } else {
604 $a = "name";
605 }
606 $ret .= "<meta $a=\"{$tag[0]}\" content=\"{$tag[1]}\" />\n";
607 }
608 $p = $this->mRobotpolicy;
609 if ( "" == $p ) { $p = "index,follow"; }
610 $ret .= "<meta name=\"robots\" content=\"$p\" />\n";
611
612 if ( count( $this->mKeywords ) > 0 ) {
613 $ret .= "<meta name=\"keywords\" content=\"" .
614 implode( ",", $this->mKeywords ) . "\" />\n";
615 }
616 foreach ( $this->mLinktags as $tag ) {
617 $ret .= "<link ";
618 if ( "" != $tag[0] ) { $ret .= "rel=\"{$tag[0]}\" "; }
619 if ( "" != $tag[1] ) { $ret .= "rev=\"{$tag[1]}\" "; }
620 if ( !empty( $tag[3] ) ) { $ret .= "type=\"{$tag[3]}\" "; }
621 if ( !empty( $tag[4] ) ) { $ret .= "media=\"{$tag[4]}\" "; }
622 $ret .= "href=\"{$tag[2]}\" />\n";
623 }
624 if( $this->isSyndicated() ) {
625 $link = $wgRequest->escapeAppendQuery( "feed=rss" );
626 $ret .= "<link rel='alternate' type='application/rss+xml' title='RSS' href='$link' />\n";
627 }
628 global $wgStyleSheetPath;
629 if( $this->isPrintable() ) {
630 $media = "";
631 } else {
632 $media = "media='print'";
633 }
634 $printsheet = htmlspecialchars( "$wgStyleSheetPath/wikiprintable.css" );
635 $ret .= "<link rel='stylesheet' type='text/css' $media href='$printsheet' />\n";
636
637 $sk = $wgUser->getSkin();
638 $ret .= $sk->getHeadScripts();
639 $ret .= $sk->getUserStyles();
640
641 $ret .= "</head>\n";
642 return $ret;
643 }
644 }
645 ?>