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