2 if( defined( "MEDIAWIKI" ) ) {
6 if($wgUseTeX) require_once( "Math.php" );
9 var $mHeaders, $mCookies, $mMetatags, $mKeywords;
10 var $mLinktags, $mPagetitle, $mBodytext, $mDebugtext;
11 var $mHTMLtitle, $mRobotpolicy, $mIsarticle, $mPrintable;
12 var $mSubtitle, $mRedirect;
13 var $mLastModified, $mCategoryLinks;
16 var $mSuppressQuickbar;
19 var $mContainsOldMagic, $mContainsNewMagic;
20 var $mIsArticleRelated;
22 var $mShowFeedLinks = false;
23 var $mEnableClientCache = true;
27 $this->mHeaders
= $this->mCookies
= $this->mMetatags
=
28 $this->mKeywords
= $this->mLinktags
= array();
29 $this->mHTMLtitle
= $this->mPagetitle
= $this->mBodytext
=
30 $this->mRedirect
= $this->mLastModified
=
31 $this->mSubtitle
= $this->mDebugtext
= $this->mRobotpolicy
=
32 $this->mOnloadHandler
= "";
33 $this->mIsArticleRelated
= $this->mIsarticle
= $this->mPrintable
= true;
34 $this->mSuppressQuickbar
= $this->mPrintable
= false;
35 $this->mLanguageLinks
= array();
36 $this->mCategoryLinks
= array() ;
37 $this->mDoNothing
= false;
38 $this->mContainsOldMagic
= $this->mContainsNewMagic
= 0;
39 $this->mParserOptions
= ParserOptions
::newFromUser( $temp = NULL );
40 $this->mSquidMaxage
= 0;
44 function addHeader( $name, $val ) { array_push( $this->mHeaders
, "$name: $val" ) ; }
45 function addCookie( $name, $val ) { array_push( $this->mCookies
, array( $name, $val ) ); }
46 function redirect( $url, $responsecode = '302' ) { $this->mRedirect
= $url; $this->mRedirectCode
= $responsecode; }
48 # To add an http-equiv meta tag, precede the name with "http:"
49 function addMeta( $name, $val ) { array_push( $this->mMetatags
, array( $name, $val ) ); }
50 function addKeyword( $text ) { array_push( $this->mKeywords
, $text ); }
51 function addScript( $script ) { $this->mScripts
.= $script; }
52 function getScript() { return $this->mScripts
; }
54 function addLink( $linkarr ) {
55 # $linkarr should be an associative array of attributes. We'll escape on output.
56 array_push( $this->mLinktags
, $linkarr );
59 function addMetadataLink( $linkarr ) {
60 # note: buggy CC software only reads first "meta" link
61 static $haveMeta = false;
62 $linkarr["rel"] = ($haveMeta) ?
"alternate meta" : "meta";
63 $this->addLink( $linkarr );
67 # checkLastModified tells the client to use the client-cached page if
68 # possible. If sucessful, the OutputPage is disabled so that
69 # any future call to OutputPage->output() have no effect. The method
70 # returns true iff cache-ok headers was sent.
71 function checkLastModified ( $timestamp )
73 global $wgLang, $wgCachePages, $wgUser;
74 if( !$wgCachePages ) {
75 wfDebug( "CACHE DISABLED\n", false );
78 if( preg_match( '/MSIE ([1-4]|5\.0)/', $_SERVER["HTTP_USER_AGENT"] ) ) {
79 # IE 5.0 has probs with our caching
80 wfDebug( "-- bad client, not caching\n", false );
83 if( $wgUser->getOption( "nocache" ) ) {
84 wfDebug( "USER DISABLED CACHE\n", false );
88 $lastmod = gmdate( "D, j M Y H:i:s", wfTimestamp2Unix( max( $timestamp, $wgUser->mTouched
) ) ) . " GMT";
90 if( !empty( $_SERVER["HTTP_IF_MODIFIED_SINCE"] ) ) {
91 # IE sends sizes after the date like this:
92 # Wed, 20 Aug 2003 06:51:19 GMT; length=5202
93 # this breaks strtotime().
94 $modsince = preg_replace( '/;.*$/', '', $_SERVER["HTTP_IF_MODIFIED_SINCE"] );
95 $ismodsince = wfUnix2Timestamp( strtotime( $modsince ) );
96 wfDebug( "-- client send If-Modified-Since: " . $modsince . "\n", false );
97 wfDebug( "-- we might send Last-Modified : $lastmod\n", false );
99 if( ($ismodsince >= $timestamp ) and $wgUser->validateCache( $ismodsince ) ) {
100 # Make sure you're in a place you can leave when you call us!
101 header( "HTTP/1.0 304 Not Modified" );
102 $this->mLastModified
= $lastmod;
103 $this->sendCacheControl();
104 wfDebug( "CACHED client: $ismodsince ; user: $wgUser->mTouched ; page: $timestamp\n", false );
108 wfDebug( "READY client: $ismodsince ; user: $wgUser->mTouched ; page: $timestamp\n", false );
109 $this->mLastModified
= $lastmod;
112 wfDebug( "We're confused.\n", false );
113 $this->mLastModified
= $lastmod;
117 function getPageTitleActionText () {
121 return wfMsg('edit');
123 return wfMsg('history_short');
125 return wfMsg('protect');
127 return wfMsg('unprotect');
129 return wfMsg('delete');
131 return wfMsg('watch');
133 return wfMsg('unwatch');
135 return wfMsg('preview');
137 return wfMsg('info_short');
142 function setRobotpolicy( $str ) { $this->mRobotpolicy
= $str; }
143 function setHTMLTitle( $name ) {$this->mHTMLtitle
= $name; }
144 function setPageTitle( $name ) {
146 $this->mPagetitle
= $name;
147 if(!empty($action)) {
148 $taction = $this->getPageTitleActionText();
149 if( !empty( $taction ) ) {
150 $name .= " - $taction";
153 $this->setHTMLTitle( $name . " - " . wfMsg( "wikititlesuffix" ) );
155 function getHTMLTitle() { return $this->mHTMLtitle
; }
156 function getPageTitle() { return $this->mPagetitle
; }
157 function setSubtitle( $str ) { $this->mSubtitle
= $str; }
158 function getSubtitle() { return $this->mSubtitle
; }
159 function isArticle() { return $this->mIsarticle
; }
160 function setPrintable() { $this->mPrintable
= true; }
161 function isPrintable() { return $this->mPrintable
; }
162 function setSyndicated( $show = true ) { $this->mShowFeedLinks
= $show; }
163 function isSyndicated() { return $this->mShowFeedLinks
; }
164 function setOnloadHandler( $js ) { $this->mOnloadHandler
= $js; }
165 function getOnloadHandler() { return $this->mOnloadHandler
; }
166 function disable() { $this->mDoNothing
= true; }
168 function setArticleRelated( $v )
170 $this->mIsArticleRelated
= $v;
172 $this->mIsarticle
= false;
175 function setArticleFlag( $v ) {
176 $this->mIsarticle
= $v;
178 $this->mIsArticleRelated
= $v;
182 function isArticleRelated()
184 return $this->mIsArticleRelated
;
187 function getLanguageLinks() {
188 return $this->mLanguageLinks
;
190 function addLanguageLinks($newLinkArray) {
191 $this->mLanguageLinks +
= $newLinkArray;
193 function setLanguageLinks($newLinkArray) {
194 $this->mLanguageLinks
= $newLinkArray;
196 function getCategoryLinks() {
197 return $this->mCategoryLinks
;
199 function addCategoryLinks($newLinkArray) {
200 $this->mCategoryLinks +
= $newLinkArray;
202 function setCategoryLinks($newLinkArray) {
203 $this->mCategoryLinks +
= $newLinkArray;
206 function suppressQuickbar() { $this->mSuppressQuickbar
= true; }
207 function isQuickbarSuppressed() { return $this->mSuppressQuickbar
; }
209 function addHTML( $text ) { $this->mBodytext
.= $text; }
210 function debug( $text ) { $this->mDebugtext
.= $text; }
212 function setParserOptions( $options )
214 return wfSetVar( $this->mParserOptions
, $options );
217 # First pass--just handle <nowiki> sections, pass the rest off
218 # to doWikiPass2() which does all the real work.
220 # $cacheArticle - assume this text is the main text for the given article
222 function addWikiText( $text, $linestart = true, $cacheArticle = NULL )
224 global $wgParser, $wgParserCache, $wgUser, $wgTitle;
226 $parserOutput = $wgParser->parse( $text, $wgTitle, $this->mParserOptions
, $linestart );
227 if ( $cacheArticle ) {
228 $wgParserCache->save( $parserOutput, $cacheArticle, $wgUser );
231 $this->mLanguageLinks +
= $parserOutput->getLanguageLinks();
232 $this->mCategoryLinks +
= $parserOutput->getCategoryLinks();
233 $this->addHTML( $parserOutput->getText() );
236 function tryParserCache( $article, $user ) {
237 global $wgParserCache;
238 $parserOutput = $wgParserCache->get( $article, $user );
239 if ( $parserOutput !== false ) {
240 $this->mLanguageLinks +
= $parserOutput->getLanguageLinks();
241 $this->mCategoryLinks +
= $parserOutput->getCategoryLinks();
242 $this->addHTML( $parserOutput->getText() );
249 # Set the maximum cache time on the Squid in seconds
250 function setSquidMaxage( $maxage ) {
251 $this->mSquidMaxage
= $maxage;
254 # Use enableClientCache(false) to force it to send nocache headers
255 function enableClientCache( $state ) {
256 return wfSetVar( $this->mEnableClientCache
, $state );
259 function sendCacheControl() {
260 global $wgUseSquid, $wgUseESI;
261 # FIXME: This header may cause trouble with some versions of Internet Explorer
262 header( "Vary: Accept-Encoding, Cookie" );
263 if( $this->mEnableClientCache
) {
264 if( $wgUseSquid && ! isset( $_COOKIE[ini_get( "session.name") ] ) &&
265 ! $this->isPrintable() && $this->mSquidMaxage
!= 0 )
268 # We'll purge the proxy cache explicitly, but require end user agents
269 # to revalidate against the proxy on each visit.
270 # Surrogate-Control controls our Squid, Cache-Control downstream caches
271 wfDebug( "** proxy caching with ESI; {$this->mLastModified} **\n", false );
272 # start with a shorter timeout for initial testing
273 # header( 'Surrogate-Control: max-age=2678400+2678400, content="ESI/1.0"');
274 header( 'Surrogate-Control: max-age='.$wgSquidMaxage.'+'.$this->mSquidMaxage
.', content="ESI/1.0"');
275 header( 'Cache-Control: s-maxage=0, must-revalidate, max-age=0' );
277 # We'll purge the proxy cache for anons explicitly, but require end user agents
278 # to revalidate against the proxy on each visit.
279 # IMPORTANT! The Squid needs to replace the Cache-Control header with
280 # Cache-Control: s-maxage=0, must-revalidate, max-age=0
281 wfDebug( "** local proxy caching; {$this->mLastModified} **\n", false );
282 # start with a shorter timeout for initial testing
283 # header( "Cache-Control: s-maxage=2678400, must-revalidate, max-age=0" );
284 header( 'Cache-Control: s-maxage='.$this->mSquidMaxage
.', must-revalidate, max-age=0' );
287 # We do want clients to cache if they can, but they *must* check for updates
288 # on revisiting the page.
289 wfDebug( "** private caching; {$this->mLastModified} **\n", false );
290 header( "Expires: -1" );
291 header( "Cache-Control: private, must-revalidate, max-age=0" );
293 if($this->mLastModified
) header( "Last-modified: {$this->mLastModified}" );
295 wfDebug( "** no caching **\n", false );
297 # In general, the absence of a last modified header should be enough to prevent
298 # the client from using its cache. We send a few other things just to make sure.
299 header( "Expires: -1" );
300 header( "Cache-Control: no-cache, no-store, max-age=0, must-revalidate" );
301 header( "Pragma: no-cache" );
305 # Finally, all the text has been munged and accumulated into
306 # the object, let's actually output it:
310 global $wgUser, $wgLang, $wgDebugComments, $wgCookieExpiration;
311 global $wgInputEncoding, $wgOutputEncoding, $wgLanguageCode;
312 global $wgDebugRedirects, $wgMimeType, $wgProfiler;
313 if( $this->mDoNothing
){
316 $fname = "OutputPage::output";
317 wfProfileIn( $fname );
319 $sk = $wgUser->getSkin();
321 if ( "" != $this->mRedirect
) {
322 if( substr( $this->mRedirect
, 0, 4 ) != "http" ) {
323 # Standards require redirect URLs to be absolute
325 $this->mRedirect
= $wgServer . $this->mRedirect
;
327 if( $this->mRedirectCode
== '301') {
328 if( !$wgDebugRedirects ) {
329 header("HTTP/1.1 {$this->mRedirectCode} Moved Permanently");
331 $this->mLastModified
= gmdate( "D, j M Y H:i:s" ) . " GMT";
334 $this->sendCacheControl();
336 if( $wgDebugRedirects ) {
337 $url = htmlspecialchars( $this->mRedirect
);
338 print "<html>\n<head>\n<title>Redirect</title>\n</head>\n<body>\n";
339 print "<p>Location: <a href=\"$url\">$url</a></p>\n";
340 print "</body>\n</html>\n";
342 header( "Location: {$this->mRedirect}" );
344 if ( isset( $wgProfiler ) ) { wfDebug( $wgProfiler->getOutput() ); }
349 $this->sendCacheControl();
350 # Perform link colouring
351 $this->mBodytext
= $this->parseLinkHolders();
353 # Disable temporary placeholders, so that the skin produces HTML
354 $sk->postParseLinkColour( false );
356 header( "Content-type: $wgMimeType; charset={$wgOutputEncoding}" );
357 header( "Content-language: {$wgLanguageCode}" );
359 $exp = time() +
$wgCookieExpiration;
360 foreach( $this->mCookies
as $name => $val ) {
361 setcookie( $name, $val, $exp, "/" );
364 $sk->outputPage( $this );
370 global $wgInputEncoding, $wgOutputEncoding, $wgLang;
371 if ( 0 == strcmp( $wgInputEncoding, $wgOutputEncoding ) ) {
374 $outs = $wgLang->iconv( $wgInputEncoding, $wgOutputEncoding, $ins );
375 if ( false === $outs ) { $outs = $ins; }
380 function setEncodings()
382 global $wgInputEncoding, $wgOutputEncoding;
383 global $wgUser, $wgLang;
385 $wgInputEncoding = strtolower( $wgInputEncoding );
387 if( $wgUser->getOption( 'altencoding' ) ) {
388 $wgLang->setAltEncoding();
392 if ( empty( $_SERVER['HTTP_ACCEPT_CHARSET'] ) ) {
393 $wgOutputEncoding = strtolower( $wgOutputEncoding );
398 # This code is unused anyway!
399 # Commenting out. --bv 2003-11-15
401 $a = explode( ",", $_SERVER['HTTP_ACCEPT_CHARSET'] );
405 foreach ( $a as $s ) {
406 if ( preg_match( "/(.*);q=(.*)/", $s, $m ) ) {
418 #if ( "*" == $bestset ) { $bestset = "iso-8859-1"; }
419 if ( "*" == $bestset ) { $bestset = $wgOutputEncoding; }
420 $wgOutputEncoding = strtolower( $bestset );
425 $wgOutputEncoding = $wgInputEncoding;
428 # Returns a HTML comment with the elapsed time since request.
429 # This method has no side effects.
430 function reportTime()
432 global $wgRequestTime;
435 list( $usec, $sec ) = explode( " ", $wgRequestTime );
436 $start = (float)$sec +
(float)$usec;
437 $elapsed = $now - $start;
439 # Use real server name if available, so we know which machine
440 # in a server farm generated the current page.
441 if ( function_exists( "posix_uname" ) ) {
442 $uname = @posix_uname
();
446 if( is_array( $uname ) && isset( $uname['nodename'] ) ) {
447 $hostname = $uname['nodename'];
449 # This may be a virtual server.
450 $hostname = $_SERVER['SERVER_NAME'];
452 $com = sprintf( "<!-- Served by %s in %01.2f secs. -->",
453 $hostname, $elapsed );
457 # Note: these arguments are keys into wfMsg(), not text!
459 function errorpage( $title, $msg )
463 $this->mDebugtext
.= "Original title: " .
464 $wgTitle->getPrefixedText() . "\n";
465 $this->setPageTitle( wfMsg( $title ) );
466 $this->setHTMLTitle( wfMsg( "errorpagetitle" ) );
467 $this->setRobotpolicy( "noindex,nofollow" );
468 $this->setArticleRelated( false );
469 $this->enableClientCache( false );
470 $this->mRedirect
= "";
472 $this->mBodytext
= "";
473 $this->addHTML( "<p>" . wfMsg( $msg ) . "</p>\n" );
474 $this->returnToMain( false );
480 function sysopRequired()
484 $this->setPageTitle( wfMsg( "sysoptitle" ) );
485 $this->setHTMLTitle( wfMsg( "errorpagetitle" ) );
486 $this->setRobotpolicy( "noindex,nofollow" );
487 $this->setArticleRelated( false );
488 $this->mBodytext
= "";
490 $sk = $wgUser->getSkin();
491 $ap = $sk->makeKnownLink( wfMsg( "administrators" ), "" );
492 $this->addHTML( wfMsg( "sysoptext", $ap ) );
493 $this->returnToMain();
496 function developerRequired()
500 $this->setPageTitle( wfMsg( "developertitle" ) );
501 $this->setHTMLTitle( wfMsg( "errorpagetitle" ) );
502 $this->setRobotpolicy( "noindex,nofollow" );
503 $this->setArticleRelated( false );
504 $this->mBodytext
= "";
506 $sk = $wgUser->getSkin();
507 $ap = $sk->makeKnownLink( wfMsg( "administrators" ), "" );
508 $this->addHTML( wfMsg( "developertext", $ap ) );
509 $this->returnToMain();
512 function loginToUse()
514 global $wgUser, $wgTitle, $wgLang;
516 $this->setPageTitle( wfMsg( "loginreqtitle" ) );
517 $this->setHTMLTitle( wfMsg( "errorpagetitle" ) );
518 $this->setRobotpolicy( "noindex,nofollow" );
519 $this->setArticleFlag( false );
520 $this->mBodytext
= "";
521 $this->addWikiText( wfMsg( "loginreqtext" ) );
523 # We put a comment in the .html file so a Sysop can diagnose the page the
525 $this->addHTML( "\n<!--" .
526 $wgLang->getNsText( $wgTitle->getNamespace() ) .
528 $wgTitle->getDBkey() . "-->" );
529 $this->returnToMain(); # Flip back to the main page after 10 seconds.
532 function databaseError( $fname, $sql, $error, $errno )
534 global $wgUser, $wgCommandLineMode;
536 $this->setPageTitle( wfMsgNoDB( "databaseerror" ) );
537 $this->setRobotpolicy( "noindex,nofollow" );
538 $this->setArticleRelated( false );
539 $this->enableClientCache( false );
540 $this->mRedirect
= "";
542 if ( $wgCommandLineMode ) {
543 $msg = wfMsgNoDB( "dberrortextcl", htmlspecialchars( $sql ),
544 htmlspecialchars( $fname ), $errno, htmlspecialchars( $error ) );
546 $msg = wfMsgNoDB( "dberrortext", htmlspecialchars( $sql ),
547 htmlspecialchars( $fname ), $errno, htmlspecialchars( $error ) );
550 if ( $wgCommandLineMode ||
!is_object( $wgUser )) {
554 $sk = $wgUser->getSkin();
555 $shlink = $sk->makeKnownLink( wfMsgNoDB( "searchhelppage" ),
556 wfMsgNoDB( "searchingwikipedia" ) );
557 $msg = str_replace( "$5", $shlink, $msg );
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 ) ;
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 ) {
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 # Parse <!--LINK--> link placeholders to avoid using linkcache
766 # Placeholders created in Skin::makeLinkObj()
767 function parseLinkHolders()
771 $fname = 'OutputPage::parseLinkHolders';
772 wfProfileIn( $fname );
774 # Get placeholders from body
775 preg_match_all( "/<!--LINK (.*?) (.*?) (.*?) (.*?)-->/", $this->mBodytext
, $tmpLinks );
777 if ( !empty( $tmpLinks[0] ) ) {
778 $dbr =& wfGetDB( DB_SLAVE
);
779 $cur = $dbr->tableName( 'cur' );
780 $sk = $wgUser->getSkin();
781 $threshold = $wgUser->getOption('stubthreshold');
783 $namespaces =& $tmpLinks[1];
784 $dbkeys =& $tmpLinks[2];
785 $queries =& $tmpLinks[3];
786 $texts =& $tmpLinks[4];
789 asort( $namespaces );
792 foreach ( $namespaces as $key => $val ) {
793 if ( !isset( $current ) ) {
795 $query = "SELECT cur_namespace, cur_title";
796 if ( $threshold > 0 ) {
797 $query .= ", LENGTH(cur_text) AS cur_len, cur_is_redirect";
799 $query .= " FROM $cur WHERE (cur_namespace=$val AND cur_title IN(";
800 } elseif ( $current != $val ) {
802 $query .= ")) OR (cur_namespace=$val AND cur_title IN(";
807 $query .= $dbr->addQuotes( $dbkeys[$key] );
812 $res = $dbr->query( $query, $fname );
814 # Fetch data and form into an associative array
815 # non-existent = broken
819 while ( $s = $dbr->fetchObject($res) ) {
820 $key = $s->cur_namespace
. ' ' . $s->cur_title
;
821 if ( $threshold > 0 ) {
823 if ( $s->cur_is_redirect ||
$s->cur_namespace
!= 0 ||
$length < $threshold ) {
828 $colours[$key] = array( $s->cur_len
, $s->cur_is_redirect
);
834 # Construct search and replace arrays
835 $search = $replace = array();
836 foreach ( $namespaces as $key => $ns ) {
837 $cKey = $ns . ' ' . $dbkeys[$key];
838 $search[] = $tmpLinks[0][$key];
839 $title = Title
::makeTitle( $ns, $dbkeys[$key] );
840 if ( empty( $colours[$cKey] ) ) {
841 $replace[] = $sk->makeBrokenLinkObj( $title, $texts[$key], $queries[$key] );
842 } elseif ( $colours[$cKey] == 1 ) {
843 $replace[] = $sk->makeKnownLinkObj( $title, $texts[$key], $queries[$key] );
844 } elseif ( $colours[$cKey] == 2 ) {
845 $replace[] = $sk->makeStubLinkObj( $title, $texts[$key], $queries[$key] );
850 $out = str_replace( $search, $replace, $this->mBodytext
);
852 $out = $this->mBodytext
;
855 wfProfileOut( $fname );