3 # This is not a valid entry point, perform no further processing unless MEDIAWIKI is defined
4 if( defined( "MEDIAWIKI" ) ) {
8 if($wgUseTeX) require_once( "Math.php" );
11 var $mHeaders, $mCookies, $mMetatags, $mKeywords;
12 var $mLinktags, $mPagetitle, $mBodytext, $mDebugtext;
13 var $mHTMLtitle, $mRobotpolicy, $mIsarticle, $mPrintable;
14 var $mSubtitle, $mRedirect;
15 var $mLastModified, $mCategoryLinks;
18 var $mSuppressQuickbar;
21 var $mContainsOldMagic, $mContainsNewMagic;
22 var $mIsArticleRelated;
24 var $mShowFeedLinks = false;
25 var $mEnableClientCache = true;
29 $this->mHeaders
= $this->mCookies
= $this->mMetatags
=
30 $this->mKeywords
= $this->mLinktags
= array();
31 $this->mHTMLtitle
= $this->mPagetitle
= $this->mBodytext
=
32 $this->mRedirect
= $this->mLastModified
=
33 $this->mSubtitle
= $this->mDebugtext
= $this->mRobotpolicy
=
34 $this->mOnloadHandler
= "";
35 $this->mIsArticleRelated
= $this->mIsarticle
= $this->mPrintable
= true;
36 $this->mSuppressQuickbar
= $this->mPrintable
= false;
37 $this->mLanguageLinks
= array();
38 $this->mCategoryLinks
= array() ;
39 $this->mDoNothing
= false;
40 $this->mContainsOldMagic
= $this->mContainsNewMagic
= 0;
41 $this->mParserOptions
= ParserOptions
::newFromUser( $temp = NULL );
42 $this->mSquidMaxage
= 0;
46 function addHeader( $name, $val ) { array_push( $this->mHeaders
, "$name: $val" ) ; }
47 function addCookie( $name, $val ) { array_push( $this->mCookies
, array( $name, $val ) ); }
48 function redirect( $url, $responsecode = '302' ) { $this->mRedirect
= $url; $this->mRedirectCode
= $responsecode; }
50 # To add an http-equiv meta tag, precede the name with "http:"
51 function addMeta( $name, $val ) { array_push( $this->mMetatags
, array( $name, $val ) ); }
52 function addKeyword( $text ) { array_push( $this->mKeywords
, $text ); }
53 function addScript( $script ) { $this->mScripts
.= $script; }
54 function getScript() { return $this->mScripts
; }
56 function addLink( $linkarr ) {
57 # $linkarr should be an associative array of attributes. We'll escape on output.
58 array_push( $this->mLinktags
, $linkarr );
61 function addMetadataLink( $linkarr ) {
62 # note: buggy CC software only reads first "meta" link
63 static $haveMeta = false;
64 $linkarr["rel"] = ($haveMeta) ?
"alternate meta" : "meta";
65 $this->addLink( $linkarr );
69 # checkLastModified tells the client to use the client-cached page if
70 # possible. If sucessful, the OutputPage is disabled so that
71 # any future call to OutputPage->output() have no effect. The method
72 # returns true iff cache-ok headers was sent.
73 function checkLastModified ( $timestamp )
75 global $wgLang, $wgCachePages, $wgUser;
76 if( !$wgCachePages ) {
77 wfDebug( "CACHE DISABLED\n", false );
80 if( preg_match( '/MSIE ([1-4]|5\.0)/', $_SERVER["HTTP_USER_AGENT"] ) ) {
81 # IE 5.0 has probs with our caching
82 wfDebug( "-- bad client, not caching\n", false );
85 if( $wgUser->getOption( "nocache" ) ) {
86 wfDebug( "USER DISABLED CACHE\n", false );
90 $lastmod = gmdate( "D, j M Y H:i:s", wfTimestamp2Unix( max( $timestamp, $wgUser->mTouched
) ) ) . " GMT";
92 if( !empty( $_SERVER["HTTP_IF_MODIFIED_SINCE"] ) ) {
93 # IE sends sizes after the date like this:
94 # Wed, 20 Aug 2003 06:51:19 GMT; length=5202
95 # this breaks strtotime().
96 $modsince = preg_replace( '/;.*$/', '', $_SERVER["HTTP_IF_MODIFIED_SINCE"] );
97 $ismodsince = wfUnix2Timestamp( strtotime( $modsince ) );
98 wfDebug( "-- client send If-Modified-Since: " . $modsince . "\n", false );
99 wfDebug( "-- we might send Last-Modified : $lastmod\n", false );
101 if( ($ismodsince >= $timestamp ) and $wgUser->validateCache( $ismodsince ) ) {
102 # Make sure you're in a place you can leave when you call us!
103 header( "HTTP/1.0 304 Not Modified" );
104 $this->mLastModified
= $lastmod;
105 $this->sendCacheControl();
106 wfDebug( "CACHED client: $ismodsince ; user: $wgUser->mTouched ; page: $timestamp\n", false );
110 wfDebug( "READY client: $ismodsince ; user: $wgUser->mTouched ; page: $timestamp\n", false );
111 $this->mLastModified
= $lastmod;
114 wfDebug( "We're confused.\n", false );
115 $this->mLastModified
= $lastmod;
119 function getPageTitleActionText () {
123 return wfMsg('edit');
125 return wfMsg('history_short');
127 return wfMsg('protect');
129 return wfMsg('unprotect');
131 return wfMsg('delete');
133 return wfMsg('watch');
135 return wfMsg('unwatch');
137 return wfMsg('preview');
139 return wfMsg('info_short');
144 function setRobotpolicy( $str ) { $this->mRobotpolicy
= $str; }
145 function setHTMLTitle( $name ) {$this->mHTMLtitle
= $name; }
146 function setPageTitle( $name ) {
148 $this->mPagetitle
= $name;
149 if(!empty($action)) {
150 $taction = $this->getPageTitleActionText();
151 if( !empty( $taction ) ) {
152 $name .= " - $taction";
155 $this->setHTMLTitle( $name . " - " . wfMsg( "wikititlesuffix" ) );
157 function getHTMLTitle() { return $this->mHTMLtitle
; }
158 function getPageTitle() { return $this->mPagetitle
; }
159 function setSubtitle( $str ) { $this->mSubtitle
= $str; }
160 function getSubtitle() { return $this->mSubtitle
; }
161 function isArticle() { return $this->mIsarticle
; }
162 function setPrintable() { $this->mPrintable
= true; }
163 function isPrintable() { return $this->mPrintable
; }
164 function setSyndicated( $show = true ) { $this->mShowFeedLinks
= $show; }
165 function isSyndicated() { return $this->mShowFeedLinks
; }
166 function setOnloadHandler( $js ) { $this->mOnloadHandler
= $js; }
167 function getOnloadHandler() { return $this->mOnloadHandler
; }
168 function disable() { $this->mDoNothing
= true; }
170 function setArticleRelated( $v )
172 $this->mIsArticleRelated
= $v;
174 $this->mIsarticle
= false;
177 function setArticleFlag( $v ) {
178 $this->mIsarticle
= $v;
180 $this->mIsArticleRelated
= $v;
184 function isArticleRelated()
186 return $this->mIsArticleRelated
;
189 function getLanguageLinks() {
190 return $this->mLanguageLinks
;
192 function addLanguageLinks($newLinkArray) {
193 $this->mLanguageLinks +
= $newLinkArray;
195 function setLanguageLinks($newLinkArray) {
196 $this->mLanguageLinks
= $newLinkArray;
198 function getCategoryLinks() {
199 return $this->mCategoryLinks
;
201 function addCategoryLinks($newLinkArray) {
202 $this->mCategoryLinks +
= $newLinkArray;
204 function setCategoryLinks($newLinkArray) {
205 $this->mCategoryLinks +
= $newLinkArray;
208 function suppressQuickbar() { $this->mSuppressQuickbar
= true; }
209 function isQuickbarSuppressed() { return $this->mSuppressQuickbar
; }
211 function addHTML( $text ) { $this->mBodytext
.= $text; }
212 function debug( $text ) { $this->mDebugtext
.= $text; }
214 function setParserOptions( $options )
216 return wfSetVar( $this->mParserOptions
, $options );
219 # First pass--just handle <nowiki> sections, pass the rest off
220 # to doWikiPass2() which does all the real work.
222 # $cacheArticle - assume this text is the main text for the given article
224 function addWikiText( $text, $linestart = true, $cacheArticle = NULL )
226 global $wgParser, $wgParserCache, $wgUser, $wgTitle;
228 $parserOutput = $wgParser->parse( $text, $wgTitle, $this->mParserOptions
, $linestart );
229 if ( $cacheArticle ) {
230 $wgParserCache->save( $parserOutput, $cacheArticle, $wgUser );
233 $this->mLanguageLinks +
= $parserOutput->getLanguageLinks();
234 $this->mCategoryLinks +
= $parserOutput->getCategoryLinks();
235 $this->addHTML( $parserOutput->getText() );
238 function tryParserCache( $article, $user ) {
239 global $wgParserCache;
240 $parserOutput = $wgParserCache->get( $article, $user );
241 if ( $parserOutput !== false ) {
242 $this->mLanguageLinks +
= $parserOutput->getLanguageLinks();
243 $this->mCategoryLinks +
= $parserOutput->getCategoryLinks();
244 $this->addHTML( $parserOutput->getText() );
251 # Set the maximum cache time on the Squid in seconds
252 function setSquidMaxage( $maxage ) {
253 $this->mSquidMaxage
= $maxage;
256 # Use enableClientCache(false) to force it to send nocache headers
257 function enableClientCache( $state ) {
258 return wfSetVar( $this->mEnableClientCache
, $state );
261 function sendCacheControl() {
262 global $wgUseSquid, $wgUseESI;
263 # FIXME: This header may cause trouble with some versions of Internet Explorer
264 header( "Vary: Accept-Encoding, Cookie" );
265 if( $this->mEnableClientCache
) {
266 if( $wgUseSquid && ! isset( $_COOKIE[ini_get( "session.name") ] ) &&
267 ! $this->isPrintable() && $this->mSquidMaxage
!= 0 )
270 # We'll purge the proxy cache explicitly, but require end user agents
271 # to revalidate against the proxy on each visit.
272 # Surrogate-Control controls our Squid, Cache-Control downstream caches
273 wfDebug( "** proxy caching with ESI; {$this->mLastModified} **\n", false );
274 # start with a shorter timeout for initial testing
275 # header( 'Surrogate-Control: max-age=2678400+2678400, content="ESI/1.0"');
276 header( 'Surrogate-Control: max-age='.$wgSquidMaxage.'+'.$this->mSquidMaxage
.', content="ESI/1.0"');
277 header( 'Cache-Control: s-maxage=0, must-revalidate, max-age=0' );
279 # We'll purge the proxy cache for anons explicitly, but require end user agents
280 # to revalidate against the proxy on each visit.
281 # IMPORTANT! The Squid needs to replace the Cache-Control header with
282 # Cache-Control: s-maxage=0, must-revalidate, max-age=0
283 wfDebug( "** local proxy caching; {$this->mLastModified} **\n", false );
284 # start with a shorter timeout for initial testing
285 # header( "Cache-Control: s-maxage=2678400, must-revalidate, max-age=0" );
286 header( 'Cache-Control: s-maxage='.$this->mSquidMaxage
.', must-revalidate, max-age=0' );
289 # We do want clients to cache if they can, but they *must* check for updates
290 # on revisiting the page.
291 wfDebug( "** private caching; {$this->mLastModified} **\n", false );
292 header( "Expires: -1" );
293 header( "Cache-Control: private, must-revalidate, max-age=0" );
295 if($this->mLastModified
) header( "Last-modified: {$this->mLastModified}" );
297 wfDebug( "** no caching **\n", false );
299 # In general, the absence of a last modified header should be enough to prevent
300 # the client from using its cache. We send a few other things just to make sure.
301 header( "Expires: -1" );
302 header( "Cache-Control: no-cache, no-store, max-age=0, must-revalidate" );
303 header( "Pragma: no-cache" );
307 # Finally, all the text has been munged and accumulated into
308 # the object, let's actually output it:
312 global $wgUser, $wgLang, $wgDebugComments, $wgCookieExpiration;
313 global $wgInputEncoding, $wgOutputEncoding, $wgLanguageCode;
314 global $wgDebugRedirects, $wgMimeType, $wgProfiler;
315 if( $this->mDoNothing
){
318 $fname = "OutputPage::output";
319 wfProfileIn( $fname );
321 $sk = $wgUser->getSkin();
323 if ( "" != $this->mRedirect
) {
324 if( substr( $this->mRedirect
, 0, 4 ) != "http" ) {
325 # Standards require redirect URLs to be absolute
327 $this->mRedirect
= $wgServer . $this->mRedirect
;
329 if( $this->mRedirectCode
== '301') {
330 if( !$wgDebugRedirects ) {
331 header("HTTP/1.1 {$this->mRedirectCode} Moved Permanently");
333 $this->mLastModified
= gmdate( "D, j M Y H:i:s" ) . " GMT";
336 $this->sendCacheControl();
338 if( $wgDebugRedirects ) {
339 $url = htmlspecialchars( $this->mRedirect
);
340 print "<html>\n<head>\n<title>Redirect</title>\n</head>\n<body>\n";
341 print "<p>Location: <a href=\"$url\">$url</a></p>\n";
342 print "</body>\n</html>\n";
344 header( "Location: {$this->mRedirect}" );
346 if ( isset( $wgProfiler ) ) { wfDebug( $wgProfiler->getOutput() ); }
351 $this->sendCacheControl();
352 # Perform link colouring
353 $this->mBodytext
= $this->parseLinkHolders();
355 # Disable temporary placeholders, so that the skin produces HTML
356 $sk->postParseLinkColour( false );
358 header( "Content-type: $wgMimeType; charset={$wgOutputEncoding}" );
359 header( "Content-language: {$wgLanguageCode}" );
361 $exp = time() +
$wgCookieExpiration;
362 foreach( $this->mCookies
as $name => $val ) {
363 setcookie( $name, $val, $exp, "/" );
366 $sk->outputPage( $this );
372 global $wgInputEncoding, $wgOutputEncoding, $wgLang;
373 if ( 0 == strcmp( $wgInputEncoding, $wgOutputEncoding ) ) {
376 $outs = $wgLang->iconv( $wgInputEncoding, $wgOutputEncoding, $ins );
377 if ( false === $outs ) { $outs = $ins; }
382 function setEncodings()
384 global $wgInputEncoding, $wgOutputEncoding;
385 global $wgUser, $wgLang;
387 $wgInputEncoding = strtolower( $wgInputEncoding );
389 if( $wgUser->getOption( 'altencoding' ) ) {
390 $wgLang->setAltEncoding();
394 if ( empty( $_SERVER['HTTP_ACCEPT_CHARSET'] ) ) {
395 $wgOutputEncoding = strtolower( $wgOutputEncoding );
400 # This code is unused anyway!
401 # Commenting out. --bv 2003-11-15
403 $a = explode( ",", $_SERVER['HTTP_ACCEPT_CHARSET'] );
407 foreach ( $a as $s ) {
408 if ( preg_match( "/(.*);q=(.*)/", $s, $m ) ) {
420 #if ( "*" == $bestset ) { $bestset = "iso-8859-1"; }
421 if ( "*" == $bestset ) { $bestset = $wgOutputEncoding; }
422 $wgOutputEncoding = strtolower( $bestset );
427 $wgOutputEncoding = $wgInputEncoding;
430 # Returns a HTML comment with the elapsed time since request.
431 # This method has no side effects.
432 function reportTime()
434 global $wgRequestTime;
437 list( $usec, $sec ) = explode( " ", $wgRequestTime );
438 $start = (float)$sec +
(float)$usec;
439 $elapsed = $now - $start;
441 # Use real server name if available, so we know which machine
442 # in a server farm generated the current page.
443 if ( function_exists( "posix_uname" ) ) {
444 $uname = @posix_uname
();
448 if( is_array( $uname ) && isset( $uname['nodename'] ) ) {
449 $hostname = $uname['nodename'];
451 # This may be a virtual server.
452 $hostname = $_SERVER['SERVER_NAME'];
454 $com = sprintf( "<!-- Served by %s in %01.2f secs. -->",
455 $hostname, $elapsed );
459 # Note: these arguments are keys into wfMsg(), not text!
461 function errorpage( $title, $msg )
465 $this->mDebugtext
.= "Original title: " .
466 $wgTitle->getPrefixedText() . "\n";
467 $this->setPageTitle( wfMsg( $title ) );
468 $this->setHTMLTitle( wfMsg( "errorpagetitle" ) );
469 $this->setRobotpolicy( "noindex,nofollow" );
470 $this->setArticleRelated( false );
471 $this->enableClientCache( false );
472 $this->mRedirect
= "";
474 $this->mBodytext
= "";
475 $this->addHTML( "<p>" . wfMsg( $msg ) . "</p>\n" );
476 $this->returnToMain( false );
482 function sysopRequired()
486 $this->setPageTitle( wfMsg( "sysoptitle" ) );
487 $this->setHTMLTitle( wfMsg( "errorpagetitle" ) );
488 $this->setRobotpolicy( "noindex,nofollow" );
489 $this->setArticleRelated( false );
490 $this->mBodytext
= "";
492 $sk = $wgUser->getSkin();
493 $ap = $sk->makeKnownLink( wfMsg( "administrators" ), "" );
494 $this->addHTML( wfMsg( "sysoptext", $ap ) );
495 $this->returnToMain();
498 function developerRequired()
502 $this->setPageTitle( wfMsg( "developertitle" ) );
503 $this->setHTMLTitle( wfMsg( "errorpagetitle" ) );
504 $this->setRobotpolicy( "noindex,nofollow" );
505 $this->setArticleRelated( false );
506 $this->mBodytext
= "";
508 $sk = $wgUser->getSkin();
509 $ap = $sk->makeKnownLink( wfMsg( "administrators" ), "" );
510 $this->addHTML( wfMsg( "developertext", $ap ) );
511 $this->returnToMain();
514 function loginToUse()
516 global $wgUser, $wgTitle, $wgLang;
518 $this->setPageTitle( wfMsg( "loginreqtitle" ) );
519 $this->setHTMLTitle( wfMsg( "errorpagetitle" ) );
520 $this->setRobotpolicy( "noindex,nofollow" );
521 $this->setArticleFlag( false );
522 $this->mBodytext
= "";
523 $this->addWikiText( wfMsg( "loginreqtext" ) );
525 # We put a comment in the .html file so a Sysop can diagnose the page the
527 $this->addHTML( "\n<!--" .
528 $wgLang->getNsText( $wgTitle->getNamespace() ) .
530 $wgTitle->getDBkey() . "-->" );
531 $this->returnToMain(); # Flip back to the main page after 10 seconds.
534 function databaseError( $fname, $sql, $error, $errno )
536 global $wgUser, $wgCommandLineMode;
538 $this->setPageTitle( wfMsgNoDB( "databaseerror" ) );
539 $this->setRobotpolicy( "noindex,nofollow" );
540 $this->setArticleRelated( false );
541 $this->enableClientCache( false );
542 $this->mRedirect
= "";
544 if ( $wgCommandLineMode ) {
545 $msg = wfMsgNoDB( "dberrortextcl", htmlspecialchars( $sql ),
546 htmlspecialchars( $fname ), $errno, htmlspecialchars( $error ) );
548 $msg = wfMsgNoDB( "dberrortext", htmlspecialchars( $sql ),
549 htmlspecialchars( $fname ), $errno, htmlspecialchars( $error ) );
552 if ( $wgCommandLineMode ||
!is_object( $wgUser )) {
556 $sk = $wgUser->getSkin();
557 $shlink = $sk->makeKnownLink( wfMsgNoDB( "searchhelppage" ),
558 wfMsgNoDB( "searchingwikipedia" ) );
559 $msg = str_replace( "$5", $shlink, $msg );
560 $this->mBodytext
= $msg;
565 function readOnlyPage( $source = null, $protected = false )
567 global $wgUser, $wgReadOnlyFile;
569 $this->setRobotpolicy( "noindex,nofollow" );
570 $this->setArticleRelated( false );
573 $this->setPageTitle( wfMsg( "viewsource" ) );
574 $this->addWikiText( wfMsg( "protectedtext" ) );
576 $this->setPageTitle( wfMsg( "readonly" ) );
577 $reason = file_get_contents( $wgReadOnlyFile );
578 $this->addWikiText( wfMsg( "readonlytext", $reason ) );
581 if( is_string( $source ) ) {
582 if( strcmp( $source, "" ) == 0 ) {
583 $source = wfMsg( "noarticletext" );
585 $rows = $wgUser->getOption( "rows" );
586 $cols = $wgUser->getOption( "cols" );
587 $text = "\n<textarea cols='$cols' rows='$rows' readonly='readonly'>" .
588 htmlspecialchars( $source ) . "\n</textarea>";
589 $this->addHTML( $text );
592 $this->returnToMain( false );
595 function fatalError( $message )
597 $this->setPageTitle( wfMsg( "internalerror" ) );
598 $this->setRobotpolicy( "noindex,nofollow" );
599 $this->setArticleRelated( false );
600 $this->enableClientCache( false );
601 $this->mRedirect
= "";
603 $this->mBodytext
= $message;
608 function unexpectedValueError( $name, $val )
610 $this->fatalError( wfMsg( "unexpected", $name, $val ) );
613 function fileCopyError( $old, $new )
615 $this->fatalError( wfMsg( "filecopyerror", $old, $new ) );
618 function fileRenameError( $old, $new )
620 $this->fatalError( wfMsg( "filerenameerror", $old, $new ) );
623 function fileDeleteError( $name )
625 $this->fatalError( wfMsg( "filedeleteerror", $name ) );
628 function fileNotFoundError( $name )
630 $this->fatalError( wfMsg( "filenotfound", $name ) );
633 // return from error messages or notes
634 // auto: automatically redirect the user after 10 seconds
635 // returnto: page title to return to. Default is Main Page.
636 function returnToMain( $auto = true, $returnto = NULL )
638 global $wgUser, $wgOut, $wgRequest;
640 if ( $returnto == NULL ) {
641 $returnto = $wgRequest->getText( 'returnto' );
644 $sk = $wgUser->getSkin();
645 if ( "" == $returnto ) {
646 $returnto = wfMsg( "mainpage" );
648 $link = $sk->makeKnownLink( $returnto, "" );
650 $r = wfMsg( "returnto", $link );
652 $titleObj = Title
::newFromText( $returnto );
653 $wgOut->addMeta( "http:Refresh", "10;url=" . $titleObj->escapeFullURL() );
655 $wgOut->addHTML( "\n<p>$r</p>\n" );
658 # This function takes the existing and broken links for the page
659 # and uses the first 10 of them for META keywords
660 function addMetaTags ()
662 global $wgLinkCache , $wgOut ;
663 $good = array_keys ( $wgLinkCache->mGoodLinks
) ;
664 $bad = array_keys ( $wgLinkCache->mBadLinks
) ;
665 $a = array_merge ( $good , $bad ) ;
666 $a = array_slice ( $a , 0 , 10 ) ; # 10 keywords max
667 $a = implode ( "," , $a ) ;
672 $a = htmlspecialchars(preg_replace(array_keys($strip), array_values($strip),$a ));
674 $wgOut->addMeta ( "KEYWORDS" , $a ) ;
677 /* private */ function headElement()
679 global $wgDocType, $wgDTD, $wgLanguageCode, $wgOutputEncoding, $wgMimeType;
680 global $wgUser, $wgLang, $wgRequest;
682 $xml = ($wgMimeType == 'text/xml');
684 $ret = "<" . "?xml version=\"1.0\" encoding=\"$wgOutputEncoding\" ?" . ">\n";
689 $ret .= "<!DOCTYPE html PUBLIC \"$wgDocType\"\n \"$wgDTD\">\n";
691 if ( "" == $this->mHTMLtitle
) {
692 $this->mHTMLtitle
= wfMsg( "pagetitle", $this->mPagetitle
);
695 $xmlbits = "xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\"";
699 $rtl = $wgLang->isRTL() ?
" dir='RTL'" : "";
700 $ret .= "<html $xmlbits lang=\"$wgLanguageCode\" $rtl>\n";
701 $ret .= "<head>\n<title>" . htmlspecialchars( $this->mHTMLtitle
) . "</title>\n";
702 array_push( $this->mMetatags
, array( "http:Content-type", "$wgMimeType; charset={$wgOutputEncoding}" ) );
704 $ret .= $this->getHeadLinks();
706 if( $this->isPrintable() ) {
709 $media = "media='print'";
711 $printsheet = htmlspecialchars( "$wgStylePath/wikiprintable.css" );
712 $ret .= "<link rel='stylesheet' type='text/css' $media href='$printsheet' />\n";
714 $sk = $wgUser->getSkin();
715 $ret .= $sk->getHeadScripts();
716 $ret .= $this->mScripts
;
717 $ret .= $sk->getUserStyles();
723 function getHeadLinks() {
724 global $wgRequest, $wgStylePath;
726 foreach ( $this->mMetatags
as $tag ) {
727 if ( 0 == strcasecmp( "http:", substr( $tag[0], 0, 5 ) ) ) {
729 $tag[0] = substr( $tag[0], 5 );
733 $ret .= "<meta $a=\"{$tag[0]}\" content=\"{$tag[1]}\" />\n";
735 $p = $this->mRobotpolicy
;
736 if ( "" == $p ) { $p = "index,follow"; }
737 $ret .= "<meta name=\"robots\" content=\"$p\" />\n";
739 if ( count( $this->mKeywords
) > 0 ) {
744 $ret .= "<meta name=\"keywords\" content=\"" .
745 htmlspecialchars(preg_replace(array_keys($strip), array_values($strip),implode( ",", $this->mKeywords
))) . "\" />\n";
747 foreach ( $this->mLinktags
as $tag ) {
749 foreach( $tag as $attr => $val ) {
750 $ret .= " $attr=\"" . htmlspecialchars( $val ) . "\"";
754 if( $this->isSyndicated() ) {
755 # FIXME: centralize the mime-type and name information in Feed.php
756 $link = $wgRequest->escapeAppendQuery( "feed=rss" );
757 $ret .= "<link rel='alternate' type='application/rss+xml' title='RSS 2.0' href='$link' />\n";
758 $link = $wgRequest->escapeAppendQuery( "feed=atom" );
759 $ret .= "<link rel='alternate' type='application/rss+atom' title='Atom 0.3' href='$link' />\n";
761 # FIXME: get these working
762 # $fix = htmlspecialchars( $wgStylePath . "/ie-png-fix.js" );
763 # $ret .= "<!--[if gte IE 5.5000]><script type='text/javascript' src='$fix'>< /script><![endif]-->";
767 # Parse <!--LINK--> link placeholders to avoid using linkcache
768 # Placeholders created in Skin::makeLinkObj()
769 function parseLinkHolders()
773 $fname = 'OutputPage::parseLinkHolders';
774 wfProfileIn( $fname );
776 # Get placeholders from body
777 preg_match_all( "/<!--LINK (.*?) (.*?) (.*?) (.*?)-->/", $this->mBodytext
, $tmpLinks );
779 if ( !empty( $tmpLinks[0] ) ) {
780 $dbr =& wfGetDB( DB_SLAVE
);
781 $cur = $dbr->tableName( 'cur' );
782 $sk = $wgUser->getSkin();
783 $threshold = $wgUser->getOption('stubthreshold');
785 $namespaces =& $tmpLinks[1];
786 $dbkeys =& $tmpLinks[2];
787 $queries =& $tmpLinks[3];
788 $texts =& $tmpLinks[4];
791 asort( $namespaces );
794 foreach ( $namespaces as $key => $val ) {
795 if ( !isset( $current ) ) {
797 $query = "SELECT cur_namespace, cur_title";
798 if ( $threshold > 0 ) {
799 $query .= ", LENGTH(cur_text) AS cur_len, cur_is_redirect";
801 $query .= " FROM $cur WHERE (cur_namespace=$val AND cur_title IN(";
802 } elseif ( $current != $val ) {
804 $query .= ")) OR (cur_namespace=$val AND cur_title IN(";
809 $query .= $dbr->addQuotes( $dbkeys[$key] );
814 $res = $dbr->query( $query, $fname );
816 # Fetch data and form into an associative array
817 # non-existent = broken
821 while ( $s = $dbr->fetchObject($res) ) {
822 $key = $s->cur_namespace
. ' ' . $s->cur_title
;
823 if ( $threshold > 0 ) {
825 if ( $s->cur_is_redirect ||
$s->cur_namespace
!= 0 ||
$length < $threshold ) {
830 $colours[$key] = array( $s->cur_len
, $s->cur_is_redirect
);
836 # Construct search and replace arrays
837 $search = $replace = array();
838 foreach ( $namespaces as $key => $ns ) {
839 $cKey = $ns . ' ' . $dbkeys[$key];
840 $search[] = $tmpLinks[0][$key];
841 $title = Title
::makeTitle( $ns, $dbkeys[$key] );
842 if ( empty( $colours[$cKey] ) ) {
843 $replace[] = $sk->makeBrokenLinkObj( $title, $texts[$key], $queries[$key] );
844 } elseif ( $colours[$cKey] == 1 ) {
845 $replace[] = $sk->makeKnownLinkObj( $title, $texts[$key], $queries[$key] );
846 } elseif ( $colours[$cKey] == 2 ) {
847 $replace[] = $sk->makeStubLinkObj( $title, $texts[$key], $queries[$key] );
852 $out = str_replace( $search, $replace, $this->mBodytext
);
854 $out = $this->mBodytext
;
857 wfProfileOut( $fname );