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" );
10 define( 'RLH_FOR_UPDATE', 1 );
13 var $mHeaders, $mCookies, $mMetatags, $mKeywords;
14 var $mLinktags, $mPagetitle, $mBodytext, $mDebugtext;
15 var $mHTMLtitle, $mRobotpolicy, $mIsarticle, $mPrintable;
16 var $mSubtitle, $mRedirect;
17 var $mLastModified, $mCategoryLinks;
18 var $mScripts, $mLinkColours;
20 var $mSuppressQuickbar;
23 var $mContainsOldMagic, $mContainsNewMagic;
24 var $mIsArticleRelated;
26 var $mShowFeedLinks = false;
27 var $mEnableClientCache = true;
31 $this->mHeaders
= $this->mCookies
= $this->mMetatags
=
32 $this->mKeywords
= $this->mLinktags
= array();
33 $this->mHTMLtitle
= $this->mPagetitle
= $this->mBodytext
=
34 $this->mRedirect
= $this->mLastModified
=
35 $this->mSubtitle
= $this->mDebugtext
= $this->mRobotpolicy
=
36 $this->mOnloadHandler
= "";
37 $this->mIsArticleRelated
= $this->mIsarticle
= $this->mPrintable
= true;
38 $this->mSuppressQuickbar
= $this->mPrintable
= false;
39 $this->mLanguageLinks
= array();
40 $this->mCategoryLinks
= array() ;
41 $this->mDoNothing
= false;
42 $this->mContainsOldMagic
= $this->mContainsNewMagic
= 0;
43 $this->mParserOptions
= ParserOptions
::newFromUser( $temp = NULL );
44 $this->mSquidMaxage
= 0;
48 function addHeader( $name, $val ) { array_push( $this->mHeaders
, "$name: $val" ) ; }
49 function addCookie( $name, $val ) { array_push( $this->mCookies
, array( $name, $val ) ); }
50 function redirect( $url, $responsecode = '302' ) { $this->mRedirect
= $url; $this->mRedirectCode
= $responsecode; }
52 # To add an http-equiv meta tag, precede the name with "http:"
53 function addMeta( $name, $val ) { array_push( $this->mMetatags
, array( $name, $val ) ); }
54 function addKeyword( $text ) { array_push( $this->mKeywords
, $text ); }
55 function addScript( $script ) { $this->mScripts
.= $script; }
56 function getScript() { return $this->mScripts
; }
58 function addLink( $linkarr ) {
59 # $linkarr should be an associative array of attributes. We'll escape on output.
60 array_push( $this->mLinktags
, $linkarr );
63 function addMetadataLink( $linkarr ) {
64 # note: buggy CC software only reads first "meta" link
65 static $haveMeta = false;
66 $linkarr["rel"] = ($haveMeta) ?
"alternate meta" : "meta";
67 $this->addLink( $linkarr );
71 # checkLastModified tells the client to use the client-cached page if
72 # possible. If sucessful, the OutputPage is disabled so that
73 # any future call to OutputPage->output() have no effect. The method
74 # returns true iff cache-ok headers was sent.
75 function checkLastModified ( $timestamp )
77 global $wgLang, $wgCachePages, $wgUser;
78 if( !$wgCachePages ) {
79 wfDebug( "CACHE DISABLED\n", false );
82 if( preg_match( '/MSIE ([1-4]|5\.0)/', $_SERVER["HTTP_USER_AGENT"] ) ) {
83 # IE 5.0 has probs with our caching
84 wfDebug( "-- bad client, not caching\n", false );
87 if( $wgUser->getOption( "nocache" ) ) {
88 wfDebug( "USER DISABLED CACHE\n", false );
92 $lastmod = gmdate( "D, j M Y H:i:s", wfTimestamp2Unix( max( $timestamp, $wgUser->mTouched
) ) ) . " GMT";
94 if( !empty( $_SERVER["HTTP_IF_MODIFIED_SINCE"] ) ) {
95 # IE sends sizes after the date like this:
96 # Wed, 20 Aug 2003 06:51:19 GMT; length=5202
97 # this breaks strtotime().
98 $modsince = preg_replace( '/;.*$/', '', $_SERVER["HTTP_IF_MODIFIED_SINCE"] );
99 $ismodsince = wfUnix2Timestamp( strtotime( $modsince ) );
100 wfDebug( "-- client send If-Modified-Since: " . $modsince . "\n", false );
101 wfDebug( "-- we might send Last-Modified : $lastmod\n", false );
103 if( ($ismodsince >= $timestamp ) and $wgUser->validateCache( $ismodsince ) ) {
104 # Make sure you're in a place you can leave when you call us!
105 header( "HTTP/1.0 304 Not Modified" );
106 $this->mLastModified
= $lastmod;
107 $this->sendCacheControl();
108 wfDebug( "CACHED client: $ismodsince ; user: $wgUser->mTouched ; page: $timestamp\n", false );
112 wfDebug( "READY client: $ismodsince ; user: $wgUser->mTouched ; page: $timestamp\n", false );
113 $this->mLastModified
= $lastmod;
116 wfDebug( "We're confused.\n", false );
117 $this->mLastModified
= $lastmod;
121 function getPageTitleActionText () {
125 return wfMsg('edit');
127 return wfMsg('history_short');
129 return wfMsg('protect');
131 return wfMsg('unprotect');
133 return wfMsg('delete');
135 return wfMsg('watch');
137 return wfMsg('unwatch');
139 return wfMsg('preview');
141 return wfMsg('info_short');
146 function setRobotpolicy( $str ) { $this->mRobotpolicy
= $str; }
147 function setHTMLTitle( $name ) {$this->mHTMLtitle
= $name; }
148 function setPageTitle( $name ) {
150 $this->mPagetitle
= $name;
151 if(!empty($action)) {
152 $taction = $this->getPageTitleActionText();
153 if( !empty( $taction ) ) {
154 $name .= " - $taction";
157 $this->setHTMLTitle( $name . " - " . wfMsg( "wikititlesuffix" ) );
159 function getHTMLTitle() { return $this->mHTMLtitle
; }
160 function getPageTitle() { return $this->mPagetitle
; }
161 function setSubtitle( $str ) { $this->mSubtitle
= $str; }
162 function getSubtitle() { return $this->mSubtitle
; }
163 function isArticle() { return $this->mIsarticle
; }
164 function setPrintable() { $this->mPrintable
= true; }
165 function isPrintable() { return $this->mPrintable
; }
166 function setSyndicated( $show = true ) { $this->mShowFeedLinks
= $show; }
167 function isSyndicated() { return $this->mShowFeedLinks
; }
168 function setOnloadHandler( $js ) { $this->mOnloadHandler
= $js; }
169 function getOnloadHandler() { return $this->mOnloadHandler
; }
170 function disable() { $this->mDoNothing
= true; }
172 function setArticleRelated( $v )
174 $this->mIsArticleRelated
= $v;
176 $this->mIsarticle
= false;
179 function setArticleFlag( $v ) {
180 $this->mIsarticle
= $v;
182 $this->mIsArticleRelated
= $v;
186 function isArticleRelated()
188 return $this->mIsArticleRelated
;
191 function getLanguageLinks() {
192 return $this->mLanguageLinks
;
194 function addLanguageLinks($newLinkArray) {
195 $this->mLanguageLinks +
= $newLinkArray;
197 function setLanguageLinks($newLinkArray) {
198 $this->mLanguageLinks
= $newLinkArray;
200 function getCategoryLinks() {
201 return $this->mCategoryLinks
;
203 function addCategoryLinks($newLinkArray) {
204 $this->mCategoryLinks +
= $newLinkArray;
206 function setCategoryLinks($newLinkArray) {
207 $this->mCategoryLinks +
= $newLinkArray;
210 function suppressQuickbar() { $this->mSuppressQuickbar
= true; }
211 function isQuickbarSuppressed() { return $this->mSuppressQuickbar
; }
213 function addHTML( $text ) { $this->mBodytext
.= $text; }
214 function debug( $text ) { $this->mDebugtext
.= $text; }
216 function setParserOptions( $options )
218 return wfSetVar( $this->mParserOptions
, $options );
221 # First pass--just handle <nowiki> sections, pass the rest off
222 # to doWikiPass2() which does all the real work.
224 # $cacheArticle - assume this text is the main text for the given article
226 function addWikiText( $text, $linestart = true, $cacheArticle = NULL )
228 global $wgParser, $wgParserCache, $wgUser, $wgTitle;
230 $parserOutput = $wgParser->parse( $text, $wgTitle, $this->mParserOptions
, $linestart );
231 if ( $cacheArticle ) {
232 $wgParserCache->save( $parserOutput, $cacheArticle, $wgUser );
235 $this->mLanguageLinks +
= $parserOutput->getLanguageLinks();
236 $this->mCategoryLinks +
= $parserOutput->getCategoryLinks();
237 $this->addHTML( $parserOutput->getText() );
240 function tryParserCache( $article, $user ) {
241 global $wgParserCache;
242 $parserOutput = $wgParserCache->get( $article, $user );
243 if ( $parserOutput !== false ) {
244 $this->mLanguageLinks +
= $parserOutput->getLanguageLinks();
245 $this->mCategoryLinks +
= $parserOutput->getCategoryLinks();
246 $this->addHTML( $parserOutput->getText() );
253 # Set the maximum cache time on the Squid in seconds
254 function setSquidMaxage( $maxage ) {
255 $this->mSquidMaxage
= $maxage;
258 # Use enableClientCache(false) to force it to send nocache headers
259 function enableClientCache( $state ) {
260 return wfSetVar( $this->mEnableClientCache
, $state );
263 function sendCacheControl() {
264 global $wgUseSquid, $wgUseESI;
265 # FIXME: This header may cause trouble with some versions of Internet Explorer
266 header( "Vary: Accept-Encoding, Cookie" );
267 if( $this->mEnableClientCache
) {
268 if( $wgUseSquid && ! isset( $_COOKIE[ini_get( "session.name") ] ) &&
269 ! $this->isPrintable() && $this->mSquidMaxage
!= 0 )
272 # We'll purge the proxy cache explicitly, but require end user agents
273 # to revalidate against the proxy on each visit.
274 # Surrogate-Control controls our Squid, Cache-Control downstream caches
275 wfDebug( "** proxy caching with ESI; {$this->mLastModified} **\n", false );
276 # start with a shorter timeout for initial testing
277 # header( 'Surrogate-Control: max-age=2678400+2678400, content="ESI/1.0"');
278 header( 'Surrogate-Control: max-age='.$wgSquidMaxage.'+'.$this->mSquidMaxage
.', content="ESI/1.0"');
279 header( 'Cache-Control: s-maxage=0, must-revalidate, max-age=0' );
281 # We'll purge the proxy cache for anons explicitly, but require end user agents
282 # to revalidate against the proxy on each visit.
283 # IMPORTANT! The Squid needs to replace the Cache-Control header with
284 # Cache-Control: s-maxage=0, must-revalidate, max-age=0
285 wfDebug( "** local proxy caching; {$this->mLastModified} **\n", false );
286 # start with a shorter timeout for initial testing
287 # header( "Cache-Control: s-maxage=2678400, must-revalidate, max-age=0" );
288 header( 'Cache-Control: s-maxage='.$this->mSquidMaxage
.', must-revalidate, max-age=0' );
291 # We do want clients to cache if they can, but they *must* check for updates
292 # on revisiting the page.
293 wfDebug( "** private caching; {$this->mLastModified} **\n", false );
294 header( "Expires: -1" );
295 header( "Cache-Control: private, must-revalidate, max-age=0" );
297 if($this->mLastModified
) header( "Last-modified: {$this->mLastModified}" );
299 wfDebug( "** no caching **\n", false );
301 # In general, the absence of a last modified header should be enough to prevent
302 # the client from using its cache. We send a few other things just to make sure.
303 header( "Expires: -1" );
304 header( "Cache-Control: no-cache, no-store, max-age=0, must-revalidate" );
305 header( "Pragma: no-cache" );
309 # Finally, all the text has been munged and accumulated into
310 # the object, let's actually output it:
314 global $wgUser, $wgLang, $wgDebugComments, $wgCookieExpiration;
315 global $wgInputEncoding, $wgOutputEncoding, $wgLanguageCode;
316 global $wgDebugRedirects, $wgMimeType, $wgProfiler;
317 if( $this->mDoNothing
){
320 $fname = "OutputPage::output";
321 wfProfileIn( $fname );
323 $sk = $wgUser->getSkin();
325 if ( "" != $this->mRedirect
) {
326 if( substr( $this->mRedirect
, 0, 4 ) != "http" ) {
327 # Standards require redirect URLs to be absolute
329 $this->mRedirect
= $wgServer . $this->mRedirect
;
331 if( $this->mRedirectCode
== '301') {
332 if( !$wgDebugRedirects ) {
333 header("HTTP/1.1 {$this->mRedirectCode} Moved Permanently");
335 $this->mLastModified
= gmdate( "D, j M Y H:i:s" ) . " GMT";
338 $this->sendCacheControl();
340 if( $wgDebugRedirects ) {
341 $url = htmlspecialchars( $this->mRedirect
);
342 print "<html>\n<head>\n<title>Redirect</title>\n</head>\n<body>\n";
343 print "<p>Location: <a href=\"$url\">$url</a></p>\n";
344 print "</body>\n</html>\n";
346 header( "Location: {$this->mRedirect}" );
348 if ( isset( $wgProfiler ) ) { wfDebug( $wgProfiler->getOutput() ); }
353 $this->sendCacheControl();
354 # Perform link colouring
355 $this->replaceLinkHolders();
357 # Disable temporary placeholders, so that the skin produces HTML
358 $sk->postParseLinkColour( false );
360 header( "Content-type: $wgMimeType; charset={$wgOutputEncoding}" );
361 header( "Content-language: {$wgLanguageCode}" );
363 $exp = time() +
$wgCookieExpiration;
364 foreach( $this->mCookies
as $name => $val ) {
365 setcookie( $name, $val, $exp, "/" );
368 $sk->outputPage( $this );
374 global $wgInputEncoding, $wgOutputEncoding, $wgLang;
375 if ( 0 == strcmp( $wgInputEncoding, $wgOutputEncoding ) ) {
378 $outs = $wgLang->iconv( $wgInputEncoding, $wgOutputEncoding, $ins );
379 if ( false === $outs ) { $outs = $ins; }
384 function setEncodings()
386 global $wgInputEncoding, $wgOutputEncoding;
387 global $wgUser, $wgLang;
389 $wgInputEncoding = strtolower( $wgInputEncoding );
391 if( $wgUser->getOption( 'altencoding' ) ) {
392 $wgLang->setAltEncoding();
396 if ( empty( $_SERVER['HTTP_ACCEPT_CHARSET'] ) ) {
397 $wgOutputEncoding = strtolower( $wgOutputEncoding );
402 # This code is unused anyway!
403 # Commenting out. --bv 2003-11-15
405 $a = explode( ",", $_SERVER['HTTP_ACCEPT_CHARSET'] );
409 foreach ( $a as $s ) {
410 if ( preg_match( "/(.*);q=(.*)/", $s, $m ) ) {
422 #if ( "*" == $bestset ) { $bestset = "iso-8859-1"; }
423 if ( "*" == $bestset ) { $bestset = $wgOutputEncoding; }
424 $wgOutputEncoding = strtolower( $bestset );
429 $wgOutputEncoding = $wgInputEncoding;
432 # Returns a HTML comment with the elapsed time since request.
433 # This method has no side effects.
434 function reportTime()
436 global $wgRequestTime;
439 list( $usec, $sec ) = explode( " ", $wgRequestTime );
440 $start = (float)$sec +
(float)$usec;
441 $elapsed = $now - $start;
443 # Use real server name if available, so we know which machine
444 # in a server farm generated the current page.
445 if ( function_exists( "posix_uname" ) ) {
446 $uname = @posix_uname
();
450 if( is_array( $uname ) && isset( $uname['nodename'] ) ) {
451 $hostname = $uname['nodename'];
453 # This may be a virtual server.
454 $hostname = $_SERVER['SERVER_NAME'];
456 $com = sprintf( "<!-- Served by %s in %01.2f secs. -->",
457 $hostname, $elapsed );
461 # Note: these arguments are keys into wfMsg(), not text!
463 function errorpage( $title, $msg )
467 $this->mDebugtext
.= "Original title: " .
468 $wgTitle->getPrefixedText() . "\n";
469 $this->setPageTitle( wfMsg( $title ) );
470 $this->setHTMLTitle( wfMsg( "errorpagetitle" ) );
471 $this->setRobotpolicy( "noindex,nofollow" );
472 $this->setArticleRelated( false );
473 $this->enableClientCache( false );
474 $this->mRedirect
= "";
476 $this->mBodytext
= "";
477 $this->addHTML( "<p>" . wfMsg( $msg ) . "</p>\n" );
478 $this->returnToMain( false );
484 function sysopRequired()
488 $this->setPageTitle( wfMsg( "sysoptitle" ) );
489 $this->setHTMLTitle( wfMsg( "errorpagetitle" ) );
490 $this->setRobotpolicy( "noindex,nofollow" );
491 $this->setArticleRelated( false );
492 $this->mBodytext
= "";
494 $sk = $wgUser->getSkin();
495 $ap = $sk->makeKnownLink( wfMsg( "administrators" ), "" );
496 $this->addHTML( wfMsg( "sysoptext", $ap ) );
497 $this->returnToMain();
500 function developerRequired()
504 $this->setPageTitle( wfMsg( "developertitle" ) );
505 $this->setHTMLTitle( wfMsg( "errorpagetitle" ) );
506 $this->setRobotpolicy( "noindex,nofollow" );
507 $this->setArticleRelated( false );
508 $this->mBodytext
= "";
510 $sk = $wgUser->getSkin();
511 $ap = $sk->makeKnownLink( wfMsg( "administrators" ), "" );
512 $this->addHTML( wfMsg( "developertext", $ap ) );
513 $this->returnToMain();
516 function loginToUse()
518 global $wgUser, $wgTitle, $wgLang;
520 $this->setPageTitle( wfMsg( "loginreqtitle" ) );
521 $this->setHTMLTitle( wfMsg( "errorpagetitle" ) );
522 $this->setRobotpolicy( "noindex,nofollow" );
523 $this->setArticleFlag( false );
524 $this->mBodytext
= "";
525 $this->addWikiText( wfMsg( "loginreqtext" ) );
527 # We put a comment in the .html file so a Sysop can diagnose the page the
529 $this->addHTML( "\n<!--" .
530 $wgLang->getNsText( $wgTitle->getNamespace() ) .
532 $wgTitle->getDBkey() . "-->" );
533 $this->returnToMain(); # Flip back to the main page after 10 seconds.
536 function databaseError( $fname, $sql, $error, $errno )
538 global $wgUser, $wgCommandLineMode;
540 $this->setPageTitle( wfMsgNoDB( "databaseerror" ) );
541 $this->setRobotpolicy( "noindex,nofollow" );
542 $this->setArticleRelated( false );
543 $this->enableClientCache( false );
544 $this->mRedirect
= "";
546 if ( $wgCommandLineMode ) {
547 $msg = wfMsgNoDB( "dberrortextcl", htmlspecialchars( $sql ),
548 htmlspecialchars( $fname ), $errno, htmlspecialchars( $error ) );
550 $msg = wfMsgNoDB( "dberrortext", htmlspecialchars( $sql ),
551 htmlspecialchars( $fname ), $errno, htmlspecialchars( $error ) );
554 if ( $wgCommandLineMode ||
!is_object( $wgUser )) {
558 $this->mBodytext
= $msg;
563 function readOnlyPage( $source = null, $protected = false )
565 global $wgUser, $wgReadOnlyFile;
567 $this->setRobotpolicy( "noindex,nofollow" );
568 $this->setArticleRelated( false );
571 $this->setPageTitle( wfMsg( "viewsource" ) );
572 $this->addWikiText( wfMsg( "protectedtext" ) );
574 $this->setPageTitle( wfMsg( "readonly" ) );
575 $reason = file_get_contents( $wgReadOnlyFile );
576 $this->addWikiText( wfMsg( "readonlytext", $reason ) );
579 if( is_string( $source ) ) {
580 if( strcmp( $source, "" ) == 0 ) {
581 $source = wfMsg( "noarticletext" );
583 $rows = $wgUser->getOption( "rows" );
584 $cols = $wgUser->getOption( "cols" );
585 $text = "\n<textarea cols='$cols' rows='$rows' readonly='readonly'>" .
586 htmlspecialchars( $source ) . "\n</textarea>";
587 $this->addHTML( $text );
590 $this->returnToMain( false );
593 function fatalError( $message )
595 $this->setPageTitle( wfMsg( "internalerror" ) );
596 $this->setRobotpolicy( "noindex,nofollow" );
597 $this->setArticleRelated( false );
598 $this->enableClientCache( false );
599 $this->mRedirect
= "";
601 $this->mBodytext
= $message;
606 function unexpectedValueError( $name, $val )
608 $this->fatalError( wfMsg( "unexpected", $name, $val ) );
611 function fileCopyError( $old, $new )
613 $this->fatalError( wfMsg( "filecopyerror", $old, $new ) );
616 function fileRenameError( $old, $new )
618 $this->fatalError( wfMsg( "filerenameerror", $old, $new ) );
621 function fileDeleteError( $name )
623 $this->fatalError( wfMsg( "filedeleteerror", $name ) );
626 function fileNotFoundError( $name )
628 $this->fatalError( wfMsg( "filenotfound", $name ) );
631 // return from error messages or notes
632 // auto: automatically redirect the user after 10 seconds
633 // returnto: page title to return to. Default is Main Page.
634 function returnToMain( $auto = true, $returnto = NULL )
636 global $wgUser, $wgOut, $wgRequest;
638 if ( $returnto == NULL ) {
639 $returnto = $wgRequest->getText( 'returnto' );
642 $sk = $wgUser->getSkin();
643 if ( "" == $returnto ) {
644 $returnto = wfMsg( "mainpage" );
646 $link = $sk->makeKnownLink( $returnto, "" );
648 $r = wfMsg( "returnto", $link );
650 $titleObj = Title
::newFromText( $returnto );
651 $wgOut->addMeta( "http:Refresh", "10;url=" . $titleObj->escapeFullURL() );
653 $wgOut->addHTML( "\n<p>$r</p>\n" );
656 # This function takes the existing and broken links for the page
657 # and uses the first 10 of them for META keywords
658 function addMetaTags ()
660 global $wgLinkCache , $wgOut ;
661 $good = array_keys ( $wgLinkCache->mGoodLinks
) ;
662 $bad = array_keys ( $wgLinkCache->mBadLinks
) ;
663 $a = array_merge ( $good , $bad ) ;
664 $a = array_slice ( $a , 0 , 10 ) ; # 10 keywords max
665 $a = implode ( "," , $a ) ;
667 "/<.*?" . ">/" => '',
670 $a = htmlspecialchars(preg_replace(array_keys($strip), array_values($strip),$a ));
672 $wgOut->addMeta ( "KEYWORDS" , $a ) ;
675 /* private */ function headElement()
677 global $wgDocType, $wgDTD, $wgLanguageCode, $wgOutputEncoding, $wgMimeType;
678 global $wgUser, $wgLang, $wgRequest;
680 $xml = ($wgMimeType == 'text/xml');
682 $ret = "<" . "?xml version=\"1.0\" encoding=\"$wgOutputEncoding\" ?" . ">\n";
687 $ret .= "<!DOCTYPE html PUBLIC \"$wgDocType\"\n \"$wgDTD\">\n";
689 if ( "" == $this->mHTMLtitle
) {
690 $this->mHTMLtitle
= wfMsg( "pagetitle", $this->mPagetitle
);
693 $xmlbits = "xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\"";
697 $rtl = $wgLang->isRTL() ?
" dir='RTL'" : "";
698 $ret .= "<html $xmlbits lang=\"$wgLanguageCode\" $rtl>\n";
699 $ret .= "<head>\n<title>" . htmlspecialchars( $this->mHTMLtitle
) . "</title>\n";
700 array_push( $this->mMetatags
, array( "http:Content-type", "$wgMimeType; charset={$wgOutputEncoding}" ) );
702 $ret .= $this->getHeadLinks();
704 if( $this->isPrintable() ) {
707 $media = "media='print'";
709 $printsheet = htmlspecialchars( "$wgStylePath/wikiprintable.css" );
710 $ret .= "<link rel='stylesheet' type='text/css' $media href='$printsheet' />\n";
712 $sk = $wgUser->getSkin();
713 $ret .= $sk->getHeadScripts();
714 $ret .= $this->mScripts
;
715 $ret .= $sk->getUserStyles();
721 function getHeadLinks() {
722 global $wgRequest, $wgStylePath;
724 foreach ( $this->mMetatags
as $tag ) {
725 if ( 0 == strcasecmp( "http:", substr( $tag[0], 0, 5 ) ) ) {
727 $tag[0] = substr( $tag[0], 5 );
731 $ret .= "<meta $a=\"{$tag[0]}\" content=\"{$tag[1]}\" />\n";
733 $p = $this->mRobotpolicy
;
734 if ( "" == $p ) { $p = "index,follow"; }
735 $ret .= "<meta name=\"robots\" content=\"$p\" />\n";
737 if ( count( $this->mKeywords
) > 0 ) {
739 "/<.*?" . ">/" => '',
742 $ret .= "<meta name=\"keywords\" content=\"" .
743 htmlspecialchars(preg_replace(array_keys($strip), array_values($strip),implode( ",", $this->mKeywords
))) . "\" />\n";
745 foreach ( $this->mLinktags
as $tag ) {
747 foreach( $tag as $attr => $val ) {
748 $ret .= " $attr=\"" . htmlspecialchars( $val ) . "\"";
752 if( $this->isSyndicated() ) {
753 # FIXME: centralize the mime-type and name information in Feed.php
754 $link = $wgRequest->escapeAppendQuery( "feed=rss" );
755 $ret .= "<link rel='alternate' type='application/rss+xml' title='RSS 2.0' href='$link' />\n";
756 $link = $wgRequest->escapeAppendQuery( "feed=atom" );
757 $ret .= "<link rel='alternate' type='application/rss+atom' title='Atom 0.3' href='$link' />\n";
759 # FIXME: get these working
760 # $fix = htmlspecialchars( $wgStylePath . "/ie-png-fix.js" );
761 # $ret .= "<!--[if gte IE 5.5000]><script type='text/javascript' src='$fix'>< /script><![endif]-->";
765 # Replace <!--LINK--> link placeholders with actual links, in the buffer
766 # Placeholders created in Skin::makeLinkObj()
767 # Returns an array of links found, indexed by PDBK:
771 # $options is a bit field, RLH_FOR_UPDATE to select for update
772 function replaceLinkHolders( $options = 0 )
774 global $wgUser, $wgLinkCache, $wgUseOldExistenceCheck;
776 if ( $wgUseOldExistenceCheck ) {
780 $fname = 'OutputPage::replaceLinkHolders';
781 wfProfileIn( $fname );
787 # Get placeholders from body
788 wfProfileIn( "$fname-match" );
789 preg_match_all( "/<!--LINK (.*?) (.*?) (.*?) (.*?)-->/", $this->mBodytext
, $tmpLinks );
790 wfProfileOut( "$fname-match" );
792 if ( !empty( $tmpLinks[0] ) ) {
793 wfProfileIn( "$fname-check" );
794 $dbr =& wfGetDB( DB_SLAVE
);
795 $cur = $dbr->tableName( 'cur' );
796 $sk = $wgUser->getSkin();
797 $threshold = $wgUser->getOption('stubthreshold');
799 $namespaces =& $tmpLinks[1];
800 $dbkeys =& $tmpLinks[2];
801 $queries =& $tmpLinks[3];
802 $texts =& $tmpLinks[4];
805 asort( $namespaces );
809 foreach ( $namespaces as $key => $val ) {
811 $dbk = $dbkeys[$key];
812 $title = $titles[$key] = Title
::makeTitle( $val, $dbk );
814 # Skip invalid entries.
815 # Result will be ugly, but prevents crash.
816 if ( is_null( $title ) ) {
819 $pdbk = $pdbks[$key] = $title->getPrefixedDBkey();
821 # Check if it's in the link cache already
822 if ( $wgLinkCache->getGoodLinkID( $pdbk ) ) {
824 } elseif ( $wgLinkCache->isBadLink( $pdbk ) ) {
827 # Not in the link cache, add it to the query
828 if ( !isset( $current ) ) {
830 $query = "SELECT cur_id, cur_namespace, cur_title";
831 if ( $threshold > 0 ) {
832 $query .= ", LENGTH(cur_text) AS cur_len, cur_is_redirect";
834 $query .= " FROM $cur WHERE (cur_namespace=$val AND cur_title IN(";
835 } elseif ( $current != $val ) {
837 $query .= ")) OR (cur_namespace=$val AND cur_title IN(";
842 $query .= $dbr->addQuotes( $dbkeys[$key] );
847 if ( $options & RLH_FOR_UPDATE
) {
848 $query .= " FOR UPDATE";
851 $res = $dbr->query( $query, $fname );
853 # Fetch data and form into an associative array
854 # non-existent = broken
857 while ( $s = $dbr->fetchObject($res) ) {
858 $title = Title
::makeTitle( $s->cur_namespace
, $s->cur_title
);
859 $pdbk = $title->getPrefixedDBkey();
860 $wgLinkCache->addGoodLink( $s->cur_id
, $pdbk );
862 if ( $threshold > 0 ) {
864 if ( $s->cur_is_redirect ||
$s->cur_namespace
!= 0 ||
$length < $threshold ) {
874 wfProfileOut( "$fname-check" );
876 # Construct search and replace arrays
877 wfProfileIn( "$fname-construct" );
878 global $outputReplace;
879 $outputReplace = array();
880 foreach ( $namespaces as $key => $ns ) {
881 $pdbk = $pdbks[$key];
882 $searchkey = $tmpLinks[0][$key];
883 $title = $titles[$key];
884 if ( empty( $colours[$pdbk] ) ) {
885 $wgLinkCache->addBadLink( $pdbk );
887 $outputReplace[$searchkey] = $sk->makeBrokenLinkObj( $title, $texts[$key], $queries[$key] );
888 } elseif ( $colours[$pdbk] == 1 ) {
889 $outputReplace[$searchkey] = $sk->makeKnownLinkObj( $title, $texts[$key], $queries[$key] );
890 } elseif ( $colours[$pdbk] == 2 ) {
891 $outputReplace[$searchkey] = $sk->makeStubLinkObj( $title, $texts[$key], $queries[$key] );
894 wfProfileOut( "$fname-construct" );
897 wfProfileIn( "$fname-replace" );
899 $this->mBodytext
= preg_replace_callback(
900 '/(<!--LINK .*? .*? .*? .*?-->)/',
901 "outputReplaceMatches",
903 wfProfileOut( "$fname-replace" );
905 wfProfileOut( $fname );
910 function &outputReplaceMatches($matches) {
911 global $outputReplace;
912 return $outputReplace[$matches[1]];