4 if($wgUseTeX) require_once( "Math.php" );
7 var $mHeaders, $mCookies, $mMetatags, $mKeywords;
8 var $mLinktags, $mPagetitle, $mBodytext, $mDebugtext;
9 var $mHTMLtitle, $mRobotpolicy, $mIsarticle, $mPrintable;
10 var $mSubtitle, $mRedirect;
11 var $mLastModified, $mCategoryLinks;
14 var $mSuppressQuickbar;
17 var $mContainsOldMagic, $mContainsNewMagic;
18 var $mIsArticleRelated;
20 var $mShowFeedLinks = false;
21 var $mEnableClientCache = true;
25 $this->mHeaders
= $this->mCookies
= $this->mMetatags
=
26 $this->mKeywords
= $this->mLinktags
= array();
27 $this->mHTMLtitle
= $this->mPagetitle
= $this->mBodytext
=
28 $this->mRedirect
= $this->mLastModified
=
29 $this->mSubtitle
= $this->mDebugtext
= $this->mRobotpolicy
=
30 $this->mOnloadHandler
= "";
31 $this->mIsArticleRelated
= $this->mIsarticle
= $this->mPrintable
= true;
32 $this->mSuppressQuickbar
= $this->mPrintable
= false;
33 $this->mLanguageLinks
= array();
34 $this->mCategoryLinks
= array() ;
35 $this->mDoNothing
= false;
36 $this->mContainsOldMagic
= $this->mContainsNewMagic
= 0;
37 $this->mParserOptions
= ParserOptions
::newFromUser( $temp = NULL );
38 $this->mSquidMaxage
= 0;
42 function addHeader( $name, $val ) { array_push( $this->mHeaders
, "$name: $val" ) ; }
43 function addCookie( $name, $val ) { array_push( $this->mCookies
, array( $name, $val ) ); }
44 function redirect( $url, $responsecode = '302' ) { $this->mRedirect
= $url; $this->mRedirectCode
= $responsecode; }
46 # To add an http-equiv meta tag, precede the name with "http:"
47 function addMeta( $name, $val ) { array_push( $this->mMetatags
, array( $name, $val ) ); }
48 function addKeyword( $text ) { array_push( $this->mKeywords
, $text ); }
49 function addScript( $script ) { $this->mScripts
.= $script; }
50 function getScript() { return $this->mScripts
; }
52 function addLink( $linkarr ) {
53 # $linkarr should be an associative array of attributes. We'll escape on output.
54 array_push( $this->mLinktags
, $linkarr );
57 function addMetadataLink( $linkarr ) {
58 # note: buggy CC software only reads first "meta" link
59 static $haveMeta = false;
60 $linkarr["rel"] = ($haveMeta) ?
"alternate meta" : "meta";
61 $this->addLink( $linkarr );
65 # checkLastModified tells the client to use the client-cached page if
66 # possible. If sucessful, the OutputPage is disabled so that
67 # any future call to OutputPage->output() have no effect. The method
68 # returns true iff cache-ok headers was sent.
69 function checkLastModified ( $timestamp )
71 global $wgLang, $wgCachePages, $wgUser;
72 if( !$wgCachePages ) {
73 wfDebug( "CACHE DISABLED\n", false );
76 if( preg_match( '/MSIE ([1-4]|5\.0)/', $_SERVER["HTTP_USER_AGENT"] ) ) {
77 # IE 5.0 has probs with our caching
78 wfDebug( "-- bad client, not caching\n", false );
81 if( $wgUser->getOption( "nocache" ) ) {
82 wfDebug( "USER DISABLED CACHE\n", false );
86 $lastmod = gmdate( "D, j M Y H:i:s", wfTimestamp2Unix( max( $timestamp, $wgUser->mTouched
) ) ) . " GMT";
88 if( !empty( $_SERVER["HTTP_IF_MODIFIED_SINCE"] ) ) {
89 # IE sends sizes after the date like this:
90 # Wed, 20 Aug 2003 06:51:19 GMT; length=5202
91 # this breaks strtotime().
92 $modsince = preg_replace( '/;.*$/', '', $_SERVER["HTTP_IF_MODIFIED_SINCE"] );
93 $ismodsince = wfUnix2Timestamp( strtotime( $modsince ) );
94 wfDebug( "-- client send If-Modified-Since: " . $modsince . "\n", false );
95 wfDebug( "-- we might send Last-Modified : $lastmod\n", false );
97 if( ($ismodsince >= $timestamp ) and $wgUser->validateCache( $ismodsince ) ) {
98 # Make sure you're in a place you can leave when you call us!
99 header( "HTTP/1.0 304 Not Modified" );
100 $this->mLastModified
= $lastmod;
101 $this->sendCacheControl();
102 wfDebug( "CACHED client: $ismodsince ; user: $wgUser->mTouched ; page: $timestamp\n", false );
106 wfDebug( "READY client: $ismodsince ; user: $wgUser->mTouched ; page: $timestamp\n", false );
107 $this->mLastModified
= $lastmod;
110 wfDebug( "We're confused.\n", false );
111 $this->mLastModified
= $lastmod;
115 function getPageTitleActionText () {
119 return wfMsg('edit');
121 return wfMsg('history_short');
123 return wfMsg('protect');
125 return wfMsg('unprotect');
127 return wfMsg('delete');
129 return wfMsg('watch');
131 return wfMsg('unwatch');
133 return wfMsg('preview');
135 return wfMsg('info_short');
140 function setRobotpolicy( $str ) { $this->mRobotpolicy
= $str; }
141 function setHTMLTitle( $name ) {$this->mHTMLtitle
= $name; }
142 function setPageTitle( $name ) {
144 $this->mPagetitle
= $name;
145 if(!empty($action)) {
146 $taction = $this->getPageTitleActionText();
147 if( !empty( $taction ) ) {
148 $name .= " - $taction";
151 $this->setHTMLTitle( $name . " - " . wfMsg( "wikititlesuffix" ) );
153 function getHTMLTitle() { return $this->mHTMLtitle
; }
154 function getPageTitle() { return $this->mPagetitle
; }
155 function setSubtitle( $str ) { $this->mSubtitle
= $str; }
156 function getSubtitle() { return $this->mSubtitle
; }
157 function isArticle() { return $this->mIsarticle
; }
158 function setPrintable() { $this->mPrintable
= true; }
159 function isPrintable() { return $this->mPrintable
; }
160 function setSyndicated( $show = true ) { $this->mShowFeedLinks
= $show; }
161 function isSyndicated() { return $this->mShowFeedLinks
; }
162 function setOnloadHandler( $js ) { $this->mOnloadHandler
= $js; }
163 function getOnloadHandler() { return $this->mOnloadHandler
; }
164 function disable() { $this->mDoNothing
= true; }
166 function setArticleRelated( $v )
168 $this->mIsArticleRelated
= $v;
170 $this->mIsarticle
= false;
173 function setArticleFlag( $v ) {
174 $this->mIsarticle
= $v;
176 $this->mIsArticleRelated
= $v;
180 function isArticleRelated()
182 return $this->mIsArticleRelated
;
185 function getLanguageLinks() {
186 return $this->mLanguageLinks
;
188 function addLanguageLinks($newLinkArray) {
189 $this->mLanguageLinks +
= $newLinkArray;
191 function setLanguageLinks($newLinkArray) {
192 $this->mLanguageLinks
= $newLinkArray;
194 function getCategoryLinks() {
195 return $this->mCategoryLinks
;
197 function addCategoryLinks($newLinkArray) {
198 $this->mCategoryLinks +
= $newLinkArray;
200 function setCategoryLinks($newLinkArray) {
201 $this->mCategoryLinks +
= $newLinkArray;
204 function suppressQuickbar() { $this->mSuppressQuickbar
= true; }
205 function isQuickbarSuppressed() { return $this->mSuppressQuickbar
; }
207 function addHTML( $text ) { $this->mBodytext
.= $text; }
208 function debug( $text ) { $this->mDebugtext
.= $text; }
210 function setParserOptions( $options )
212 return wfSetVar( $this->mParserOptions
, $options );
215 # First pass--just handle <nowiki> sections, pass the rest off
216 # to doWikiPass2() which does all the real work.
218 # $cacheArticle - assume this text is the main text for the given article
220 function addWikiText( $text, $linestart = true, $cacheArticle = NULL )
222 global $wgParser, $wgParserCache, $wgUser, $wgTitle;
224 $parserOutput = $wgParser->parse( $text, $wgTitle, $this->mParserOptions
, $linestart );
225 if ( $cacheArticle ) {
226 $wgParserCache->save( $parserOutput, $cacheArticle, $wgUser );
229 $this->mLanguageLinks +
= $parserOutput->getLanguageLinks();
230 $this->mCategoryLinks +
= $parserOutput->getCategoryLinks();
231 $this->addHTML( $parserOutput->getText() );
234 function tryParserCache( $article, $user ) {
235 global $wgParserCache;
236 $parserOutput = $wgParserCache->get( $article, $user );
237 if ( $parserOutput !== false ) {
238 $this->mLanguageLinks +
= $parserOutput->getLanguageLinks();
239 $this->mCategoryLinks +
= $parserOutput->getCategoryLinks();
240 $this->addHTML( $parserOutput->getText() );
247 # Set the maximum cache time on the Squid in seconds
248 function setSquidMaxage( $maxage ) {
249 $this->mSquidMaxage
= $maxage;
252 # Use enableClientCache(false) to force it to send nocache headers
253 function enableClientCache( $state ) {
254 return wfSetVar( $this->mEnableClientCache
, $state );
257 function sendCacheControl() {
258 global $wgUseSquid, $wgUseESI;
259 # FIXME: This header may cause trouble with some versions of Internet Explorer
260 header( "Vary: Accept-Encoding, Cookie" );
261 if( $this->mEnableClientCache
) {
262 if( $wgUseSquid && ! isset( $_COOKIE[ini_get( "session.name") ] ) &&
263 ! $this->isPrintable() && $this->mSquidMaxage
!= 0 )
266 # We'll purge the proxy cache explicitly, but require end user agents
267 # to revalidate against the proxy on each visit.
268 # Surrogate-Control controls our Squid, Cache-Control downstream caches
269 wfDebug( "** proxy caching with ESI; {$this->mLastModified} **\n", false );
270 # start with a shorter timeout for initial testing
271 # header( 'Surrogate-Control: max-age=2678400+2678400, content="ESI/1.0"');
272 header( 'Surrogate-Control: max-age='.$wgSquidMaxage.'+'.$this->mSquidMaxage
.', content="ESI/1.0"');
273 header( 'Cache-Control: s-maxage=0, must-revalidate, max-age=0' );
275 # We'll purge the proxy cache for anons explicitly, but require end user agents
276 # to revalidate against the proxy on each visit.
277 # IMPORTANT! The Squid needs to replace the Cache-Control header with
278 # Cache-Control: s-maxage=0, must-revalidate, max-age=0
279 wfDebug( "** local proxy caching; {$this->mLastModified} **\n", false );
280 # start with a shorter timeout for initial testing
281 # header( "Cache-Control: s-maxage=2678400, must-revalidate, max-age=0" );
282 header( 'Cache-Control: s-maxage='.$this->mSquidMaxage
.', must-revalidate, max-age=0' );
285 # We do want clients to cache if they can, but they *must* check for updates
286 # on revisiting the page.
287 wfDebug( "** private caching; {$this->mLastModified} **\n", false );
288 header( "Expires: -1" );
289 header( "Cache-Control: private, must-revalidate, max-age=0" );
291 if($this->mLastModified
) header( "Last-modified: {$this->mLastModified}" );
293 wfDebug( "** no caching **\n", false );
295 # In general, the absence of a last modified header should be enough to prevent
296 # the client from using its cache. We send a few other things just to make sure.
297 header( "Expires: -1" );
298 header( "Cache-Control: no-cache, no-store, max-age=0, must-revalidate" );
299 header( "Pragma: no-cache" );
303 # Finally, all the text has been munged and accumulated into
304 # the object, let's actually output it:
308 global $wgUser, $wgLang, $wgDebugComments, $wgCookieExpiration;
309 global $wgInputEncoding, $wgOutputEncoding, $wgLanguageCode;
310 global $wgDebugRedirects, $wgMimeType, $wgProfiler;
311 if( $this->mDoNothing
){
314 $fname = "OutputPage::output";
315 wfProfileIn( $fname );
317 $sk = $wgUser->getSkin();
319 if ( "" != $this->mRedirect
) {
320 if( substr( $this->mRedirect
, 0, 4 ) != "http" ) {
321 # Standards require redirect URLs to be absolute
323 $this->mRedirect
= $wgServer . $this->mRedirect
;
325 if( $this->mRedirectCode
== '301') {
326 if( !$wgDebugRedirects ) {
327 header("HTTP/1.1 {$this->mRedirectCode} Moved Permanently");
329 $this->mLastModified
= gmdate( "D, j M Y H:i:s" ) . " GMT";
332 $this->sendCacheControl();
334 if( $wgDebugRedirects ) {
335 $url = htmlspecialchars( $this->mRedirect
);
336 print "<html>\n<head>\n<title>Redirect</title>\n</head>\n<body>\n";
337 print "<p>Location: <a href=\"$url\">$url</a></p>\n";
338 print "</body>\n</html>\n";
340 header( "Location: {$this->mRedirect}" );
342 if ( isset( $wgProfiler ) ) { wfDebug( $wgProfiler->getOutput() ); }
347 $this->sendCacheControl();
348 # Perform link colouring
349 $this->mBodytext
= $this->parseLinkHolders();
351 # Disable temporary placeholders, so that the skin produces HTML
352 $sk->postParseLinkColour( false );
354 header( "Content-type: $wgMimeType; charset={$wgOutputEncoding}" );
355 header( "Content-language: {$wgLanguageCode}" );
357 $exp = time() +
$wgCookieExpiration;
358 foreach( $this->mCookies
as $name => $val ) {
359 setcookie( $name, $val, $exp, "/" );
362 $sk->outputPage( $this );
368 global $wgInputEncoding, $wgOutputEncoding, $wgLang;
369 if ( 0 == strcmp( $wgInputEncoding, $wgOutputEncoding ) ) {
372 $outs = $wgLang->iconv( $wgInputEncoding, $wgOutputEncoding, $ins );
373 if ( false === $outs ) { $outs = $ins; }
378 function setEncodings()
380 global $wgInputEncoding, $wgOutputEncoding;
381 global $wgUser, $wgLang;
383 $wgInputEncoding = strtolower( $wgInputEncoding );
385 if( $wgUser->getOption( 'altencoding' ) ) {
386 $wgLang->setAltEncoding();
390 if ( empty( $_SERVER['HTTP_ACCEPT_CHARSET'] ) ) {
391 $wgOutputEncoding = strtolower( $wgOutputEncoding );
396 # This code is unused anyway!
397 # Commenting out. --bv 2003-11-15
399 $a = explode( ",", $_SERVER['HTTP_ACCEPT_CHARSET'] );
403 foreach ( $a as $s ) {
404 if ( preg_match( "/(.*);q=(.*)/", $s, $m ) ) {
416 #if ( "*" == $bestset ) { $bestset = "iso-8859-1"; }
417 if ( "*" == $bestset ) { $bestset = $wgOutputEncoding; }
418 $wgOutputEncoding = strtolower( $bestset );
423 $wgOutputEncoding = $wgInputEncoding;
426 # Returns a HTML comment with the elapsed time since request.
427 # This method has no side effects.
428 function reportTime()
430 global $wgRequestTime;
433 list( $usec, $sec ) = explode( " ", $wgRequestTime );
434 $start = (float)$sec +
(float)$usec;
435 $elapsed = $now - $start;
437 # Use real server name if available, so we know which machine
438 # in a server farm generated the current page.
439 if ( function_exists( "posix_uname" ) ) {
440 $uname = @posix_uname
();
444 if( is_array( $uname ) && isset( $uname['nodename'] ) ) {
445 $hostname = $uname['nodename'];
447 # This may be a virtual server.
448 $hostname = $_SERVER['SERVER_NAME'];
450 $com = sprintf( "<!-- Served by %s in %01.2f secs. -->",
451 $hostname, $elapsed );
455 # Note: these arguments are keys into wfMsg(), not text!
457 function errorpage( $title, $msg )
461 $this->mDebugtext
.= "Original title: " .
462 $wgTitle->getPrefixedText() . "\n";
463 $this->setPageTitle( wfMsg( $title ) );
464 $this->setHTMLTitle( wfMsg( "errorpagetitle" ) );
465 $this->setRobotpolicy( "noindex,nofollow" );
466 $this->setArticleRelated( false );
467 $this->enableClientCache( false );
468 $this->mRedirect
= "";
470 $this->mBodytext
= "";
471 $this->addHTML( "<p>" . wfMsg( $msg ) . "</p>\n" );
472 $this->returnToMain( false );
478 function sysopRequired()
482 $this->setPageTitle( wfMsg( "sysoptitle" ) );
483 $this->setHTMLTitle( wfMsg( "errorpagetitle" ) );
484 $this->setRobotpolicy( "noindex,nofollow" );
485 $this->setArticleRelated( false );
486 $this->mBodytext
= "";
488 $sk = $wgUser->getSkin();
489 $ap = $sk->makeKnownLink( wfMsg( "administrators" ), "" );
490 $this->addHTML( wfMsg( "sysoptext", $ap ) );
491 $this->returnToMain();
494 function developerRequired()
498 $this->setPageTitle( wfMsg( "developertitle" ) );
499 $this->setHTMLTitle( wfMsg( "errorpagetitle" ) );
500 $this->setRobotpolicy( "noindex,nofollow" );
501 $this->setArticleRelated( false );
502 $this->mBodytext
= "";
504 $sk = $wgUser->getSkin();
505 $ap = $sk->makeKnownLink( wfMsg( "administrators" ), "" );
506 $this->addHTML( wfMsg( "developertext", $ap ) );
507 $this->returnToMain();
510 function loginToUse()
512 global $wgUser, $wgTitle, $wgLang;
514 $this->setPageTitle( wfMsg( "loginreqtitle" ) );
515 $this->setHTMLTitle( wfMsg( "errorpagetitle" ) );
516 $this->setRobotpolicy( "noindex,nofollow" );
517 $this->setArticleFlag( false );
518 $this->mBodytext
= "";
519 $this->addWikiText( wfMsg( "loginreqtext" ) );
521 # We put a comment in the .html file so a Sysop can diagnose the page the
523 $this->addHTML( "\n<!--" .
524 $wgLang->getNsText( $wgTitle->getNamespace() ) .
526 $wgTitle->getDBkey() . "-->" );
527 $this->returnToMain(); # Flip back to the main page after 10 seconds.
530 function databaseError( $fname, $sql, $error, $errno )
532 global $wgUser, $wgCommandLineMode;
534 $this->setPageTitle( wfMsgNoDB( "databaseerror" ) );
535 $this->setRobotpolicy( "noindex,nofollow" );
536 $this->setArticleRelated( false );
537 $this->enableClientCache( false );
538 $this->mRedirect
= "";
540 if ( $wgCommandLineMode ) {
541 $msg = wfMsgNoDB( "dberrortextcl" );
543 $msg = wfMsgNoDB( "dberrortext" );
546 $msg = str_replace( "$1", htmlspecialchars( $sql ), $msg );
547 $msg = str_replace( "$2", htmlspecialchars( $fname ), $msg );
548 $msg = str_replace( "$3", $errno, $msg );
549 $msg = str_replace( "$4", htmlspecialchars( $error ), $msg );
551 if ( $wgCommandLineMode ||
!is_object( $wgUser )) {
555 $sk = $wgUser->getSkin();
556 $shlink = $sk->makeKnownLink( wfMsgNoDB( "searchhelppage" ),
557 wfMsgNoDB( "searchingwikipedia" ) );
558 $msg = str_replace( "$5", $shlink, $msg );
559 $this->mBodytext
= $msg;
564 function readOnlyPage( $source = null, $protected = false )
566 global $wgUser, $wgReadOnlyFile;
568 $this->setRobotpolicy( "noindex,nofollow" );
569 $this->setArticleRelated( false );
572 $this->setPageTitle( wfMsg( "viewsource" ) );
573 $this->addWikiText( wfMsg( "protectedtext" ) );
575 $this->setPageTitle( wfMsg( "readonly" ) );
576 $reason = file_get_contents( $wgReadOnlyFile );
577 $this->addWikiText( wfMsg( "readonlytext", $reason ) );
580 if( is_string( $source ) ) {
581 if( strcmp( $source, "" ) == 0 ) {
582 $source = wfMsg( "noarticletext" );
584 $rows = $wgUser->getOption( "rows" );
585 $cols = $wgUser->getOption( "cols" );
586 $text = "\n<textarea cols='$cols' rows='$rows' readonly='readonly'>" .
587 htmlspecialchars( $source ) . "\n</textarea>";
588 $this->addHTML( $text );
591 $this->returnToMain( false );
594 function fatalError( $message )
596 $this->setPageTitle( wfMsg( "internalerror" ) );
597 $this->setRobotpolicy( "noindex,nofollow" );
598 $this->setArticleRelated( false );
599 $this->enableClientCache( false );
600 $this->mRedirect
= "";
602 $this->mBodytext
= $message;
607 function unexpectedValueError( $name, $val )
609 $this->fatalError( wfMsg( "unexpected", $name, $val ) );
612 function fileCopyError( $old, $new )
614 $this->fatalError( wfMsg( "filecopyerror", $old, $new ) );
617 function fileRenameError( $old, $new )
619 $this->fatalError( wfMsg( "filerenameerror", $old, $new ) );
622 function fileDeleteError( $name )
624 $this->fatalError( wfMsg( "filedeleteerror", $name ) );
627 function fileNotFoundError( $name )
629 $this->fatalError( wfMsg( "filenotfound", $name ) );
632 // return from error messages or notes
633 // auto: automatically redirect the user after 10 seconds
634 // returnto: page title to return to. Default is Main Page.
635 function returnToMain( $auto = true, $returnto = NULL )
637 global $wgUser, $wgOut, $wgRequest;
639 if ( $returnto == NULL ) {
640 $returnto = $wgRequest->getText( 'returnto' );
643 $sk = $wgUser->getSkin();
644 if ( "" == $returnto ) {
645 $returnto = wfMsg( "mainpage" );
647 $link = $sk->makeKnownLink( $returnto, "" );
649 $r = wfMsg( "returnto", $link );
651 $titleObj = Title
::newFromText( $returnto );
652 $wgOut->addMeta( "http:Refresh", "10;url=" . $titleObj->escapeFullURL() );
654 $wgOut->addHTML( "\n<p>$r</p>\n" );
657 # This function takes the existing and broken links for the page
658 # and uses the first 10 of them for META keywords
659 function addMetaTags ()
661 global $wgLinkCache , $wgOut ;
662 $good = array_keys ( $wgLinkCache->mGoodLinks
) ;
663 $bad = array_keys ( $wgLinkCache->mBadLinks
) ;
664 $a = array_merge ( $good , $bad ) ;
665 $a = array_slice ( $a , 0 , 10 ) ; # 10 keywords max
666 $a = implode ( "," , $a ) ;
671 $a = htmlspecialchars(preg_replace(array_keys($strip), array_values($strip),$a ));
673 $wgOut->addMeta ( "KEYWORDS" , $a ) ;
676 /* private */ function headElement()
678 global $wgDocType, $wgDTD, $wgLanguageCode, $wgOutputEncoding, $wgMimeType;
679 global $wgUser, $wgLang, $wgRequest;
681 $xml = ($wgMimeType == 'text/xml');
683 $ret = "<" . "?xml version=\"1.0\" encoding=\"$wgOutputEncoding\" ?" . ">\n";
688 $ret .= "<!DOCTYPE html PUBLIC \"$wgDocType\"\n \"$wgDTD\">\n";
690 if ( "" == $this->mHTMLtitle
) {
691 $this->mHTMLtitle
= wfMsg( "pagetitle", $this->mPagetitle
);
694 $xmlbits = "xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\"";
698 $rtl = $wgLang->isRTL() ?
" dir='RTL'" : "";
699 $ret .= "<html $xmlbits lang=\"$wgLanguageCode\" $rtl>\n";
700 $ret .= "<head>\n<title>" . htmlspecialchars( $this->mHTMLtitle
) . "</title>\n";
701 array_push( $this->mMetatags
, array( "http:Content-type", "$wgMimeType; charset={$wgOutputEncoding}" ) );
703 $ret .= $this->getHeadLinks();
705 if( $this->isPrintable() ) {
708 $media = "media='print'";
710 $printsheet = htmlspecialchars( "$wgStylePath/wikiprintable.css" );
711 $ret .= "<link rel='stylesheet' type='text/css' $media href='$printsheet' />\n";
713 $sk = $wgUser->getSkin();
714 $ret .= $sk->getHeadScripts();
715 $ret .= $this->mScripts
;
716 $ret .= $sk->getUserStyles();
722 function getHeadLinks() {
723 global $wgRequest, $wgStylePath;
725 foreach ( $this->mMetatags
as $tag ) {
726 if ( 0 == strcasecmp( "http:", substr( $tag[0], 0, 5 ) ) ) {
728 $tag[0] = substr( $tag[0], 5 );
732 $ret .= "<meta $a=\"{$tag[0]}\" content=\"{$tag[1]}\" />\n";
734 $p = $this->mRobotpolicy
;
735 if ( "" == $p ) { $p = "index,follow"; }
736 $ret .= "<meta name=\"robots\" content=\"$p\" />\n";
738 if ( count( $this->mKeywords
) > 0 ) {
743 $ret .= "<meta name=\"keywords\" content=\"" .
744 htmlspecialchars(preg_replace(array_keys($strip), array_values($strip),implode( ",", $this->mKeywords
))) . "\" />\n";
746 foreach ( $this->mLinktags
as $tag ) {
748 foreach( $tag as $attr => $val ) {
749 $ret .= " $attr=\"" . htmlspecialchars( $val ) . "\"";
753 if( $this->isSyndicated() ) {
754 # FIXME: centralize the mime-type and name information in Feed.php
755 $link = $wgRequest->escapeAppendQuery( "feed=rss" );
756 $ret .= "<link rel='alternate' type='application/rss+xml' title='RSS 2.0' href='$link' />\n";
757 $link = $wgRequest->escapeAppendQuery( "feed=atom" );
758 $ret .= "<link rel='alternate' type='application/rss+atom' title='Atom 0.3' href='$link' />\n";
760 # FIXME: get these working
761 # $fix = htmlspecialchars( $wgStylePath . "/ie-png-fix.js" );
762 # $ret .= "<!--[if gte IE 5.5000]><script type='text/javascript' src='$fix'>< /script><![endif]-->";
766 # Parse <!--LINK--> link placeholders to avoid using linkcache
767 # Placeholders created in Skin::makeLinkObj()
768 function parseLinkHolders()
772 $fname = 'OutputPage::parseLinkHolders';
773 wfProfileIn( $fname );
775 # Get placeholders from body
776 preg_match_all( "/<!--LINK (.*?) (.*?) (.*?) (.*?)-->/", $this->mBodytext
, $tmpLinks );
778 if ( !empty( $tmpLinks[0] ) ) {
779 $dbr =& wfGetDB( DB_SLAVE
);
780 $cur = $dbr->tableName( 'cur' );
781 $sk = $wgUser->getSkin();
782 $threshold = $wgUser->getOption('stubthreshold');
784 $namespaces =& $tmpLinks[1];
785 $dbkeys =& $tmpLinks[2];
786 $queries =& $tmpLinks[3];
787 $texts =& $tmpLinks[4];
790 asort( $namespaces );
793 foreach ( $namespaces as $key => $val ) {
794 if ( !isset( $current ) ) {
796 $query = "SELECT cur_namespace, cur_title";
797 if ( $threshold > 0 ) {
798 $query .= ", LENGTH(cur_text) AS cur_len, cur_is_redirect";
800 $query .= " FROM $cur WHERE (cur_namespace=$val AND cur_title IN(";
801 } elseif ( $current != $val ) {
803 $query .= ")) OR (cur_namespace=$val AND cur_title IN(";
808 $query .= $dbr->addQuotes( $dbkeys[$key] );
813 $res = $dbr->query( $query, $fname );
815 # Fetch data and form into an associative array
816 # non-existent = broken
820 while ( $s = $dbr->fetchObject($res) ) {
821 $key = $s->cur_namespace
. ' ' . $s->cur_title
;
822 if ( $threshold > 0 ) {
824 if ( $s->cur_is_redirect ||
$s->cur_namespace
!= 0 ||
$length < $threshold ) {
829 $colours[$key] = array( $s->cur_len
, $s->cur_is_redirect
);
835 # Construct search and replace arrays
836 $search = $replace = array();
837 foreach ( $namespaces as $key => $ns ) {
838 $cKey = $ns . ' ' . $dbkeys[$key];
839 $search[] = $tmpLinks[0][$key];
840 $title = Title
::makeTitle( $ns, $dbkeys[$key] );
841 if ( empty( $colours[$cKey] ) ) {
842 $replace[] = $sk->makeBrokenLinkObj( $title, $texts[$key], $queries[$key] );
843 } elseif ( $colours[$cKey] == 1 ) {
844 $replace[] = $sk->makeKnownLinkObj( $title, $texts[$key], $queries[$key] );
845 } elseif ( $colours[$cKey] == 2 ) {
846 $replace[] = $sk->makeStubLinkObj( $title, $texts[$key], $queries[$key] );
851 $out = str_replace( $search, $replace, $this->mBodytext
);
853 $out = $this->mBodytext
;
856 wfProfileOut( $fname );