Had a bash at cleaning up the horrendous-looking deletion log on the edit page:
[lhc/web/wiklou.git] / includes / OutputPage.php
1 <?php
2 if ( ! defined( 'MEDIAWIKI' ) )
3 die( 1 );
4 /**
5 */
6
7 /**
8 * @todo document
9 */
10 class OutputPage {
11 var $mMetatags, $mKeywords;
12 var $mLinktags, $mPagetitle, $mBodytext, $mDebugtext;
13 var $mHTMLtitle, $mRobotpolicy, $mIsarticle, $mPrintable;
14 var $mSubtitle, $mRedirect, $mStatusCode;
15 var $mLastModified, $mETag, $mCategoryLinks;
16 var $mScripts, $mLinkColours, $mPageLinkTitle;
17
18 var $mAllowUserJs;
19 var $mSuppressQuickbar;
20 var $mOnloadHandler;
21 var $mDoNothing;
22 var $mContainsOldMagic, $mContainsNewMagic;
23 var $mIsArticleRelated;
24 protected $mParserOptions; // lazy initialised, use parserOptions()
25 var $mShowFeedLinks = false;
26 var $mEnableClientCache = true;
27 var $mArticleBodyOnly = false;
28
29 var $mNewSectionLink = false;
30 var $mNoGallery = false;
31
32 /**
33 * Constructor
34 * Initialise private variables
35 */
36 function __construct() {
37 global $wgAllowUserJs;
38 $this->mAllowUserJs = $wgAllowUserJs;
39 $this->mMetatags = $this->mKeywords = $this->mLinktags = array();
40 $this->mHTMLtitle = $this->mPagetitle = $this->mBodytext =
41 $this->mRedirect = $this->mLastModified =
42 $this->mSubtitle = $this->mDebugtext = $this->mRobotpolicy =
43 $this->mOnloadHandler = $this->mPageLinkTitle = '';
44 $this->mIsArticleRelated = $this->mIsarticle = $this->mPrintable = true;
45 $this->mSuppressQuickbar = $this->mPrintable = false;
46 $this->mLanguageLinks = array();
47 $this->mCategoryLinks = array();
48 $this->mDoNothing = false;
49 $this->mContainsOldMagic = $this->mContainsNewMagic = 0;
50 $this->mParserOptions = null;
51 $this->mSquidMaxage = 0;
52 $this->mScripts = '';
53 $this->mHeadItems = array();
54 $this->mETag = false;
55 $this->mRevisionId = null;
56 $this->mNewSectionLink = false;
57 $this->mTemplateIds = array();
58 $this->mImageTimestamps = array();
59 }
60
61 public function redirect( $url, $responsecode = '302' ) {
62 # Strip newlines as a paranoia check for header injection in PHP<5.1.2
63 $this->mRedirect = str_replace( "\n", '', $url );
64 $this->mRedirectCode = $responsecode;
65 }
66
67 /**
68 * Set the HTTP status code to send with the output.
69 *
70 * @param int $statusCode
71 * @return nothing
72 */
73 function setStatusCode( $statusCode ) { $this->mStatusCode = $statusCode; }
74
75 # To add an http-equiv meta tag, precede the name with "http:"
76 function addMeta( $name, $val ) { array_push( $this->mMetatags, array( $name, $val ) ); }
77 function addKeyword( $text ) { array_push( $this->mKeywords, $text ); }
78 function addScript( $script ) { $this->mScripts .= "\t\t".$script; }
79 function addStyle( $style ) {
80 global $wgStylePath, $wgStyleVersion;
81 $this->addLink(
82 array(
83 'rel' => 'stylesheet',
84 'href' => $wgStylePath . '/' . $style . '?' . $wgStyleVersion ) );
85 }
86
87 /**
88 * Add a self-contained script tag with the given contents
89 * @param string $script JavaScript text, no <script> tags
90 */
91 function addInlineScript( $script ) {
92 global $wgJsMimeType;
93 $this->mScripts .= "<script type=\"$wgJsMimeType\">/*<![CDATA[*/\n$script\n/*]]>*/</script>";
94 }
95
96 function getScript() {
97 return $this->mScripts . $this->getHeadItems();
98 }
99
100 function getHeadItems() {
101 $s = '';
102 foreach ( $this->mHeadItems as $item ) {
103 $s .= $item;
104 }
105 return $s;
106 }
107
108 function addHeadItem( $name, $value ) {
109 $this->mHeadItems[$name] = $value;
110 }
111
112 function setETag($tag) { $this->mETag = $tag; }
113 function setArticleBodyOnly($only) { $this->mArticleBodyOnly = $only; }
114 function getArticleBodyOnly($only) { return $this->mArticleBodyOnly; }
115
116 function addLink( $linkarr ) {
117 # $linkarr should be an associative array of attributes. We'll escape on output.
118 array_push( $this->mLinktags, $linkarr );
119 }
120
121 function addMetadataLink( $linkarr ) {
122 # note: buggy CC software only reads first "meta" link
123 static $haveMeta = false;
124 $linkarr['rel'] = ($haveMeta) ? 'alternate meta' : 'meta';
125 $this->addLink( $linkarr );
126 $haveMeta = true;
127 }
128
129 /**
130 * checkLastModified tells the client to use the client-cached page if
131 * possible. If sucessful, the OutputPage is disabled so that
132 * any future call to OutputPage->output() have no effect.
133 *
134 * @return bool True iff cache-ok headers was sent.
135 */
136 function checkLastModified ( $timestamp ) {
137 global $wgCachePages, $wgCacheEpoch, $wgUser, $wgRequest;
138 $fname = 'OutputPage::checkLastModified';
139
140 if ( !$timestamp || $timestamp == '19700101000000' ) {
141 wfDebug( "$fname: CACHE DISABLED, NO TIMESTAMP\n" );
142 return;
143 }
144 if( !$wgCachePages ) {
145 wfDebug( "$fname: CACHE DISABLED\n", false );
146 return;
147 }
148 if( $wgUser->getOption( 'nocache' ) ) {
149 wfDebug( "$fname: USER DISABLED CACHE\n", false );
150 return;
151 }
152
153 $timestamp=wfTimestamp(TS_MW,$timestamp);
154 $lastmod = wfTimestamp( TS_RFC2822, max( $timestamp, $wgUser->mTouched, $wgCacheEpoch ) );
155
156 if( !empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) {
157 # IE sends sizes after the date like this:
158 # Wed, 20 Aug 2003 06:51:19 GMT; length=5202
159 # this breaks strtotime().
160 $modsince = preg_replace( '/;.*$/', '', $_SERVER["HTTP_IF_MODIFIED_SINCE"] );
161 $modsinceTime = strtotime( $modsince );
162 $ismodsince = wfTimestamp( TS_MW, $modsinceTime ? $modsinceTime : 1 );
163 wfDebug( "$fname: -- client send If-Modified-Since: " . $modsince . "\n", false );
164 wfDebug( "$fname: -- we might send Last-Modified : $lastmod\n", false );
165 if( ($ismodsince >= $timestamp ) && $wgUser->validateCache( $ismodsince ) && $ismodsince >= $wgCacheEpoch ) {
166 # Make sure you're in a place you can leave when you call us!
167 $wgRequest->response()->header( "HTTP/1.0 304 Not Modified" );
168 $this->mLastModified = $lastmod;
169 $this->sendCacheControl();
170 wfDebug( "$fname: CACHED client: $ismodsince ; user: $wgUser->mTouched ; page: $timestamp ; site $wgCacheEpoch\n", false );
171 $this->disable();
172
173 // Don't output a compressed blob when using ob_gzhandler;
174 // it's technically against HTTP spec and seems to confuse
175 // Firefox when the response gets split over two packets.
176 wfClearOutputBuffers();
177
178 return true;
179 } else {
180 wfDebug( "$fname: READY client: $ismodsince ; user: $wgUser->mTouched ; page: $timestamp ; site $wgCacheEpoch\n", false );
181 $this->mLastModified = $lastmod;
182 }
183 } else {
184 wfDebug( "$fname: client did not send If-Modified-Since header\n", false );
185 $this->mLastModified = $lastmod;
186 }
187 }
188
189 function getPageTitleActionText () {
190 global $action;
191 switch($action) {
192 case 'edit':
193 case 'delete':
194 case 'protect':
195 case 'unprotect':
196 case 'watch':
197 case 'unwatch':
198 // Display title is already customized
199 return '';
200 case 'history':
201 return wfMsg('history_short');
202 case 'submit':
203 // FIXME: bug 2735; not correct for special pages etc
204 return wfMsg('preview');
205 case 'info':
206 return wfMsg('info_short');
207 default:
208 return '';
209 }
210 }
211
212 public function setRobotpolicy( $str ) { $this->mRobotpolicy = $str; }
213 public function setHTMLTitle( $name ) {$this->mHTMLtitle = $name; }
214 public function setPageTitle( $name ) {
215 global $action, $wgContLang;
216 $name = $wgContLang->convert($name, true);
217 $this->mPagetitle = $name;
218 if(!empty($action)) {
219 $taction = $this->getPageTitleActionText();
220 if( !empty( $taction ) ) {
221 $name .= ' - '.$taction;
222 }
223 }
224
225 $this->setHTMLTitle( wfMsg( 'pagetitle', $name ) );
226 }
227 public function getHTMLTitle() { return $this->mHTMLtitle; }
228 public function getPageTitle() { return $this->mPagetitle; }
229 public function setSubtitle( $str ) { $this->mSubtitle = /*$this->parse(*/$str/*)*/; } // @bug 2514
230 public function getSubtitle() { return $this->mSubtitle; }
231 public function isArticle() { return $this->mIsarticle; }
232 public function setPrintable() { $this->mPrintable = true; }
233 public function isPrintable() { return $this->mPrintable; }
234 public function setSyndicated( $show = true ) { $this->mShowFeedLinks = $show; }
235 public function isSyndicated() { return $this->mShowFeedLinks; }
236 public function setOnloadHandler( $js ) { $this->mOnloadHandler = $js; }
237 public function getOnloadHandler() { return $this->mOnloadHandler; }
238 public function disable() { $this->mDoNothing = true; }
239
240 public function setArticleRelated( $v ) {
241 $this->mIsArticleRelated = $v;
242 if ( !$v ) {
243 $this->mIsarticle = false;
244 }
245 }
246 public function setArticleFlag( $v ) {
247 $this->mIsarticle = $v;
248 if ( $v ) {
249 $this->mIsArticleRelated = $v;
250 }
251 }
252
253 public function isArticleRelated() { return $this->mIsArticleRelated; }
254
255 public function getLanguageLinks() { return $this->mLanguageLinks; }
256 public function addLanguageLinks($newLinkArray) {
257 $this->mLanguageLinks += $newLinkArray;
258 }
259 public function setLanguageLinks($newLinkArray) {
260 $this->mLanguageLinks = $newLinkArray;
261 }
262
263 public function getCategoryLinks() {
264 return $this->mCategoryLinks;
265 }
266
267 /**
268 * Add an array of categories, with names in the keys
269 */
270 public function addCategoryLinks($categories) {
271 global $wgUser, $wgContLang;
272
273 if ( !is_array( $categories ) ) {
274 return;
275 }
276 # Add the links to the link cache in a batch
277 $arr = array( NS_CATEGORY => $categories );
278 $lb = new LinkBatch;
279 $lb->setArray( $arr );
280 $lb->execute();
281
282 $sk = $wgUser->getSkin();
283 foreach ( $categories as $category => $unused ) {
284 $title = Title::makeTitleSafe( NS_CATEGORY, $category );
285 $text = $wgContLang->convertHtml( $title->getText() );
286 $this->mCategoryLinks[] = $sk->makeLinkObj( $title, $text );
287 }
288 }
289
290 public function setCategoryLinks($categories) {
291 $this->mCategoryLinks = array();
292 $this->addCategoryLinks($categories);
293 }
294
295 public function suppressQuickbar() { $this->mSuppressQuickbar = true; }
296 public function isQuickbarSuppressed() { return $this->mSuppressQuickbar; }
297
298 public function disallowUserJs() { $this->mAllowUserJs = false; }
299 public function isUserJsAllowed() { return $this->mAllowUserJs; }
300
301 public function addHTML( $text ) { $this->mBodytext .= $text; }
302 public function clearHTML() { $this->mBodytext = ''; }
303 public function getHTML() { return $this->mBodytext; }
304 public function debug( $text ) { $this->mDebugtext .= $text; }
305
306 /* @deprecated */
307 public function setParserOptions( $options ) {
308 return $this->parserOptions( $options );
309 }
310
311 public function parserOptions( $options = null ) {
312 if ( !$this->mParserOptions ) {
313 $this->mParserOptions = new ParserOptions;
314 }
315 return wfSetVar( $this->mParserOptions, $options );
316 }
317
318 /**
319 * Set the revision ID which will be seen by the wiki text parser
320 * for things such as embedded {{REVISIONID}} variable use.
321 * @param mixed $revid an integer, or NULL
322 * @return mixed previous value
323 */
324 public function setRevisionId( $revid ) {
325 $val = is_null( $revid ) ? null : intval( $revid );
326 return wfSetVar( $this->mRevisionId, $val );
327 }
328
329 /**
330 * Convert wikitext to HTML and add it to the buffer
331 * Default assumes that the current page title will
332 * be used.
333 *
334 * @param string $text
335 * @param bool $linestart
336 */
337 public function addWikiText( $text, $linestart = true ) {
338 global $wgTitle;
339 $this->addWikiTextTitle($text, $wgTitle, $linestart);
340 }
341
342 public function addWikiTextWithTitle($text, &$title, $linestart = true) {
343 $this->addWikiTextTitle($text, $title, $linestart);
344 }
345
346 function addWikiTextTitleTidy($text, &$title, $linestart = true) {
347 $this->addWikiTextTitle( $text, $title, $linestart, true );
348 }
349
350 public function addWikiTextTitle($text, &$title, $linestart, $tidy = false) {
351 global $wgParser;
352
353 $fname = 'OutputPage:addWikiTextTitle';
354 wfProfileIn($fname);
355
356 wfIncrStats('pcache_not_possible');
357
358 $popts = $this->parserOptions();
359 $popts->setTidy($tidy);
360
361 $parserOutput = $wgParser->parse( $text, $title, $popts,
362 $linestart, true, $this->mRevisionId );
363
364 $this->addParserOutput( $parserOutput );
365
366 wfProfileOut($fname);
367 }
368
369 /**
370 * @todo document
371 * @param ParserOutput object &$parserOutput
372 */
373 public function addParserOutputNoText( &$parserOutput ) {
374 $this->mLanguageLinks += $parserOutput->getLanguageLinks();
375 $this->addCategoryLinks( $parserOutput->getCategories() );
376 $this->mNewSectionLink = $parserOutput->getNewSection();
377 $this->addKeywords( $parserOutput );
378 if ( $parserOutput->getCacheTime() == -1 ) {
379 $this->enableClientCache( false );
380 }
381 if ( $parserOutput->mHTMLtitle != "" ) {
382 $this->mPagetitle = $parserOutput->mHTMLtitle ;
383 }
384 if ( $parserOutput->mSubtitle != '' ) {
385 $this->mSubtitle .= $parserOutput->mSubtitle ;
386 }
387 $this->mNoGallery = $parserOutput->getNoGallery();
388 $this->mHeadItems = array_merge( $this->mHeadItems, (array)$parserOutput->mHeadItems );
389 // Versioning...
390 $this->mTemplateIds += (array)$parserOutput->mTemplateIds;
391 $this->mImageTimestamps += (array)$parserOutput->mImageTimestamps;
392
393 wfRunHooks( 'OutputPageParserOutput', array( &$this, $parserOutput ) );
394 }
395
396 /**
397 * @todo document
398 * @param ParserOutput &$parserOutput
399 */
400 function addParserOutput( &$parserOutput ) {
401 $this->addParserOutputNoText( $parserOutput );
402 $text = $parserOutput->getText();
403 wfRunHooks( 'OutputPageBeforeHTML',array( &$this, &$text ) );
404 $this->addHTML( $text );
405 }
406
407 /**
408 * Add wikitext to the buffer, assuming that this is the primary text for a page view
409 * Saves the text into the parser cache if possible.
410 *
411 * @param string $text
412 * @param Article $article
413 * @param bool $cache
414 * @deprecated Use Article::outputWikitext
415 */
416 public function addPrimaryWikiText( $text, $article, $cache = true ) {
417 global $wgParser, $wgUser;
418
419 $popts = $this->parserOptions();
420 $popts->setTidy(true);
421 $parserOutput = $wgParser->parse( $text, $article->mTitle,
422 $popts, true, true, $this->mRevisionId );
423 $popts->setTidy(false);
424 if ( $cache && $article && $parserOutput->getCacheTime() != -1 ) {
425 $parserCache =& ParserCache::singleton();
426 $parserCache->save( $parserOutput, $article, $wgUser );
427 }
428
429 $this->addParserOutput( $parserOutput );
430 }
431
432 /**
433 * @deprecated use addWikiTextTidy()
434 */
435 public function addSecondaryWikiText( $text, $linestart = true ) {
436 global $wgTitle;
437 $this->addWikiTextTitleTidy($text, $wgTitle, $linestart);
438 }
439
440 /**
441 * Add wikitext with tidy enabled
442 */
443 public function addWikiTextTidy( $text, $linestart = true ) {
444 global $wgTitle;
445 $this->addWikiTextTitleTidy($text, $wgTitle, $linestart);
446 }
447
448
449 /**
450 * Add the output of a QuickTemplate to the output buffer
451 *
452 * @param QuickTemplate $template
453 */
454 public function addTemplate( &$template ) {
455 ob_start();
456 $template->execute();
457 $this->addHTML( ob_get_contents() );
458 ob_end_clean();
459 }
460
461 /**
462 * Parse wikitext and return the HTML.
463 *
464 * @param string $text
465 * @param bool $linestart Is this the start of a line?
466 * @param bool $interface ??
467 */
468 public function parse( $text, $linestart = true, $interface = false ) {
469 global $wgParser, $wgTitle;
470 $popts = $this->parserOptions();
471 if ( $interface) { $popts->setInterfaceMessage(true); }
472 $parserOutput = $wgParser->parse( $text, $wgTitle, $popts,
473 $linestart, true, $this->mRevisionId );
474 if ( $interface) { $popts->setInterfaceMessage(false); }
475 return $parserOutput->getText();
476 }
477
478 /**
479 * @param Article $article
480 * @param User $user
481 *
482 * @return bool True if successful, else false.
483 */
484 public function tryParserCache( &$article, $user ) {
485 $parserCache =& ParserCache::singleton();
486 $parserOutput = $parserCache->get( $article, $user );
487 if ( $parserOutput !== false ) {
488 $this->addParserOutput( $parserOutput );
489 return true;
490 } else {
491 return false;
492 }
493 }
494
495 /**
496 * @param int $maxage Maximum cache time on the Squid, in seconds.
497 */
498 public function setSquidMaxage( $maxage ) {
499 $this->mSquidMaxage = $maxage;
500 }
501
502 /**
503 * Use enableClientCache(false) to force it to send nocache headers
504 * @param $state ??
505 */
506 public function enableClientCache( $state ) {
507 return wfSetVar( $this->mEnableClientCache, $state );
508 }
509
510 function uncacheableBecauseRequestvars() {
511 global $wgRequest;
512 return $wgRequest->getText('useskin', false) === false
513 && $wgRequest->getText('uselang', false) === false;
514 }
515
516 public function sendCacheControl() {
517 global $wgUseSquid, $wgUseESI, $wgUseETag, $wgSquidMaxage, $wgRequest;
518 $fname = 'OutputPage::sendCacheControl';
519
520 if ($wgUseETag && $this->mETag)
521 $wgRequest->response()->header("ETag: $this->mETag");
522
523 # don't serve compressed data to clients who can't handle it
524 # maintain different caches for logged-in users and non-logged in ones
525 $wgRequest->response()->header( 'Vary: Accept-Encoding, Cookie' );
526 if( !$this->uncacheableBecauseRequestvars() && $this->mEnableClientCache ) {
527 if( $wgUseSquid && session_id() == '' &&
528 ! $this->isPrintable() && $this->mSquidMaxage != 0 )
529 {
530 if ( $wgUseESI ) {
531 # We'll purge the proxy cache explicitly, but require end user agents
532 # to revalidate against the proxy on each visit.
533 # Surrogate-Control controls our Squid, Cache-Control downstream caches
534 wfDebug( "$fname: proxy caching with ESI; {$this->mLastModified} **\n", false );
535 # start with a shorter timeout for initial testing
536 # header( 'Surrogate-Control: max-age=2678400+2678400, content="ESI/1.0"');
537 $wgRequest->response()->header( 'Surrogate-Control: max-age='.$wgSquidMaxage.'+'.$this->mSquidMaxage.', content="ESI/1.0"');
538 $wgRequest->response()->header( 'Cache-Control: s-maxage=0, must-revalidate, max-age=0' );
539 } else {
540 # We'll purge the proxy cache for anons explicitly, but require end user agents
541 # to revalidate against the proxy on each visit.
542 # IMPORTANT! The Squid needs to replace the Cache-Control header with
543 # Cache-Control: s-maxage=0, must-revalidate, max-age=0
544 wfDebug( "$fname: local proxy caching; {$this->mLastModified} **\n", false );
545 # start with a shorter timeout for initial testing
546 # header( "Cache-Control: s-maxage=2678400, must-revalidate, max-age=0" );
547 $wgRequest->response()->header( 'Cache-Control: s-maxage='.$this->mSquidMaxage.', must-revalidate, max-age=0' );
548 }
549 } else {
550 # We do want clients to cache if they can, but they *must* check for updates
551 # on revisiting the page.
552 wfDebug( "$fname: private caching; {$this->mLastModified} **\n", false );
553 $wgRequest->response()->header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', 0 ) . ' GMT' );
554 $wgRequest->response()->header( "Cache-Control: private, must-revalidate, max-age=0" );
555 }
556 if($this->mLastModified) $wgRequest->response()->header( "Last-modified: {$this->mLastModified}" );
557 } else {
558 wfDebug( "$fname: no caching **\n", false );
559
560 # In general, the absence of a last modified header should be enough to prevent
561 # the client from using its cache. We send a few other things just to make sure.
562 $wgRequest->response()->header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', 0 ) . ' GMT' );
563 $wgRequest->response()->header( 'Cache-Control: no-cache, no-store, max-age=0, must-revalidate' );
564 $wgRequest->response()->header( 'Pragma: no-cache' );
565 }
566 }
567
568 /**
569 * Finally, all the text has been munged and accumulated into
570 * the object, let's actually output it:
571 */
572 public function output() {
573 global $wgUser, $wgOutputEncoding, $wgRequest;
574 global $wgContLanguageCode, $wgDebugRedirects, $wgMimeType;
575 global $wgJsMimeType, $wgStylePath, $wgUseAjax, $wgAjaxSearch, $wgAjaxWatch;
576 global $wgServer, $wgStyleVersion;
577
578 if( $this->mDoNothing ){
579 return;
580 }
581 $fname = 'OutputPage::output';
582 wfProfileIn( $fname );
583 $sk = $wgUser->getSkin();
584
585 if ( $wgUseAjax ) {
586 $this->addScript( "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/ajax.js?$wgStyleVersion\"></script>\n" );
587
588 wfRunHooks( 'AjaxAddScript', array( &$this ) );
589
590 if( $wgAjaxSearch ) {
591 $this->addScript( "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/ajaxsearch.js?$wgStyleVersion\"></script>\n" );
592 $this->addScript( "<script type=\"{$wgJsMimeType}\">hookEvent(\"load\", sajax_onload);</script>\n" );
593 }
594
595 if( $wgAjaxWatch && $wgUser->isLoggedIn() ) {
596 $this->addScript( "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/ajaxwatch.js?$wgStyleVersion\"></script>\n" );
597 }
598 }
599
600 if ( '' != $this->mRedirect ) {
601 if( substr( $this->mRedirect, 0, 4 ) != 'http' ) {
602 # Standards require redirect URLs to be absolute
603 global $wgServer;
604 $this->mRedirect = $wgServer . $this->mRedirect;
605 }
606 if( $this->mRedirectCode == '301') {
607 if( !$wgDebugRedirects ) {
608 $wgRequest->response()->header("HTTP/1.1 {$this->mRedirectCode} Moved Permanently");
609 }
610 $this->mLastModified = wfTimestamp( TS_RFC2822 );
611 }
612
613 $this->sendCacheControl();
614
615 $wgRequest->response()->header("Content-Type: text/html; charset=utf-8");
616 if( $wgDebugRedirects ) {
617 $url = htmlspecialchars( $this->mRedirect );
618 print "<html>\n<head>\n<title>Redirect</title>\n</head>\n<body>\n";
619 print "<p>Location: <a href=\"$url\">$url</a></p>\n";
620 print "</body>\n</html>\n";
621 } else {
622 $wgRequest->response()->header( 'Location: '.$this->mRedirect );
623 }
624 wfProfileOut( $fname );
625 return;
626 }
627 elseif ( $this->mStatusCode )
628 {
629 $statusMessage = array(
630 100 => 'Continue',
631 101 => 'Switching Protocols',
632 102 => 'Processing',
633 200 => 'OK',
634 201 => 'Created',
635 202 => 'Accepted',
636 203 => 'Non-Authoritative Information',
637 204 => 'No Content',
638 205 => 'Reset Content',
639 206 => 'Partial Content',
640 207 => 'Multi-Status',
641 300 => 'Multiple Choices',
642 301 => 'Moved Permanently',
643 302 => 'Found',
644 303 => 'See Other',
645 304 => 'Not Modified',
646 305 => 'Use Proxy',
647 307 => 'Temporary Redirect',
648 400 => 'Bad Request',
649 401 => 'Unauthorized',
650 402 => 'Payment Required',
651 403 => 'Forbidden',
652 404 => 'Not Found',
653 405 => 'Method Not Allowed',
654 406 => 'Not Acceptable',
655 407 => 'Proxy Authentication Required',
656 408 => 'Request Timeout',
657 409 => 'Conflict',
658 410 => 'Gone',
659 411 => 'Length Required',
660 412 => 'Precondition Failed',
661 413 => 'Request Entity Too Large',
662 414 => 'Request-URI Too Large',
663 415 => 'Unsupported Media Type',
664 416 => 'Request Range Not Satisfiable',
665 417 => 'Expectation Failed',
666 422 => 'Unprocessable Entity',
667 423 => 'Locked',
668 424 => 'Failed Dependency',
669 500 => 'Internal Server Error',
670 501 => 'Not Implemented',
671 502 => 'Bad Gateway',
672 503 => 'Service Unavailable',
673 504 => 'Gateway Timeout',
674 505 => 'HTTP Version Not Supported',
675 507 => 'Insufficient Storage'
676 );
677
678 if ( $statusMessage[$this->mStatusCode] )
679 $wgRequest->response()->header( 'HTTP/1.1 ' . $this->mStatusCode . ' ' . $statusMessage[$this->mStatusCode] );
680 }
681
682 # Buffer output; final headers may depend on later processing
683 ob_start();
684
685 # Disable temporary placeholders, so that the skin produces HTML
686 $sk->postParseLinkColour( false );
687
688 $wgRequest->response()->header( "Content-type: $wgMimeType; charset={$wgOutputEncoding}" );
689 $wgRequest->response()->header( 'Content-language: '.$wgContLanguageCode );
690
691 if ($this->mArticleBodyOnly) {
692 $this->out($this->mBodytext);
693 } else {
694 wfProfileIn( 'Output-skin' );
695 $sk->outputPage( $this );
696 wfProfileOut( 'Output-skin' );
697 }
698
699 $this->sendCacheControl();
700 ob_end_flush();
701 wfProfileOut( $fname );
702 }
703
704 /**
705 * @todo document
706 * @param string $ins
707 */
708 public function out( $ins ) {
709 global $wgInputEncoding, $wgOutputEncoding, $wgContLang;
710 if ( 0 == strcmp( $wgInputEncoding, $wgOutputEncoding ) ) {
711 $outs = $ins;
712 } else {
713 $outs = $wgContLang->iconv( $wgInputEncoding, $wgOutputEncoding, $ins );
714 if ( false === $outs ) { $outs = $ins; }
715 }
716 print $outs;
717 }
718
719 /**
720 * @todo document
721 */
722 public static function setEncodings() {
723 global $wgInputEncoding, $wgOutputEncoding;
724 global $wgUser, $wgContLang;
725
726 $wgInputEncoding = strtolower( $wgInputEncoding );
727
728 if ( empty( $_SERVER['HTTP_ACCEPT_CHARSET'] ) ) {
729 $wgOutputEncoding = strtolower( $wgOutputEncoding );
730 return;
731 }
732 $wgOutputEncoding = $wgInputEncoding;
733 }
734
735 /**
736 * Deprecated, use wfReportTime() instead.
737 * @return string
738 * @deprecated
739 */
740 public function reportTime() {
741 $time = wfReportTime();
742 return $time;
743 }
744
745 /**
746 * Produce a "user is blocked" page.
747 *
748 * @param bool $return Whether to have a "return to $wgTitle" message or not.
749 * @return nothing
750 */
751 function blockedPage( $return = true ) {
752 global $wgUser, $wgContLang, $wgTitle, $wgLang;
753
754 $this->setPageTitle( wfMsg( 'blockedtitle' ) );
755 $this->setRobotpolicy( 'noindex,nofollow' );
756 $this->setArticleRelated( false );
757
758 $id = $wgUser->blockedBy();
759 $reason = $wgUser->blockedFor();
760 $ip = wfGetIP();
761
762 if ( is_numeric( $id ) ) {
763 $name = User::whoIs( $id );
764 } else {
765 $name = $id;
766 }
767 $link = '[[' . $wgContLang->getNsText( NS_USER ) . ":{$name}|{$name}]]";
768
769 $blockid = $wgUser->mBlock->mId;
770
771 $blockExpiry = $wgUser->mBlock->mExpiry;
772 if ( $blockExpiry == 'infinity' ) {
773 // Entry in database (table ipblocks) is 'infinity' but 'ipboptions' uses 'infinite' or 'indefinite'
774 // Search for localization in 'ipboptions'
775 $scBlockExpiryOptions = wfMsg( 'ipboptions' );
776 foreach ( explode( ',', $scBlockExpiryOptions ) as $option ) {
777 if ( strpos( $option, ":" ) === false )
778 continue;
779 list( $show, $value ) = explode( ":", $option );
780 if ( $value == 'infinite' || $value == 'indefinite' ) {
781 $blockExpiry = $show;
782 break;
783 }
784 }
785 } else {
786 $blockExpiry = $wgLang->timeanddate( wfTimestamp( TS_MW, $blockExpiry ), true );
787 }
788
789 if ( $wgUser->mBlock->mAuto ) {
790 $msg = 'autoblockedtext';
791 } else {
792 $msg = 'blockedtext';
793 }
794
795 /* $ip returns who *is* being blocked, $intended contains who was meant to be blocked.
796 * This could be a username, an ip range, or a single ip. */
797 $intended = $wgUser->mBlock->mAddress;
798
799 $this->addWikiText( wfMsg( $msg, $link, $reason, $ip, $name, $blockid, $blockExpiry, $intended ) );
800
801 # Don't auto-return to special pages
802 if( $return ) {
803 $return = $wgTitle->getNamespace() > -1 ? $wgTitle->getPrefixedText() : NULL;
804 $this->returnToMain( false, $return );
805 }
806 }
807
808 /**
809 * Output a standard error page
810 *
811 * @param string $title Message key for page title
812 * @param string $msg Message key for page text
813 * @param array $params Message parameters
814 */
815 public function showErrorPage( $title, $msg, $params = array() ) {
816 global $wgTitle;
817
818 $this->mDebugtext .= 'Original title: ' .
819 $wgTitle->getPrefixedText() . "\n";
820 $this->setPageTitle( wfMsg( $title ) );
821 $this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
822 $this->setRobotpolicy( 'noindex,nofollow' );
823 $this->setArticleRelated( false );
824 $this->enableClientCache( false );
825 $this->mRedirect = '';
826 $this->mBodytext = '';
827
828 array_unshift( $params, $msg );
829 $message = call_user_func_array( 'wfMsg', $params );
830 $this->addWikiText( $message );
831
832 $this->returnToMain( false );
833 }
834
835 /** @deprecated */
836 public function errorpage( $title, $msg ) {
837 throw new ErrorPageError( $title, $msg );
838 }
839
840 /**
841 * Display an error page indicating that a given version of MediaWiki is
842 * required to use it
843 *
844 * @param mixed $version The version of MediaWiki needed to use the page
845 */
846 public function versionRequired( $version ) {
847 $this->setPageTitle( wfMsg( 'versionrequired', $version ) );
848 $this->setHTMLTitle( wfMsg( 'versionrequired', $version ) );
849 $this->setRobotpolicy( 'noindex,nofollow' );
850 $this->setArticleRelated( false );
851 $this->mBodytext = '';
852
853 $this->addWikiText( wfMsg( 'versionrequiredtext', $version ) );
854 $this->returnToMain();
855 }
856
857 /**
858 * Display an error page noting that a given permission bit is required.
859 *
860 * @param string $permission key required
861 */
862 public function permissionRequired( $permission ) {
863 global $wgGroupPermissions, $wgUser;
864
865 $this->setPageTitle( wfMsg( 'badaccess' ) );
866 $this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
867 $this->setRobotpolicy( 'noindex,nofollow' );
868 $this->setArticleRelated( false );
869 $this->mBodytext = '';
870
871 $groups = array();
872 foreach( $wgGroupPermissions as $key => $value ) {
873 if( isset( $value[$permission] ) && $value[$permission] == true ) {
874 $groupName = User::getGroupName( $key );
875 $groupPage = User::getGroupPage( $key );
876 if( $groupPage ) {
877 $skin = $wgUser->getSkin();
878 $groups[] = $skin->makeLinkObj( $groupPage, $groupName );
879 } else {
880 $groups[] = $groupName;
881 }
882 }
883 }
884 $n = count( $groups );
885 $groups = implode( ', ', $groups );
886 switch( $n ) {
887 case 0:
888 case 1:
889 case 2:
890 $message = wfMsgHtml( "badaccess-group$n", $groups );
891 break;
892 default:
893 $message = wfMsgHtml( 'badaccess-groups', $groups );
894 }
895 $this->addHtml( $message );
896 $this->returnToMain( false );
897 }
898
899 /**
900 * Use permissionRequired.
901 * @deprecated
902 */
903 public function sysopRequired() {
904 throw new MWException( "Call to deprecated OutputPage::sysopRequired() method\n" );
905 }
906
907 /**
908 * Use permissionRequired.
909 * @deprecated
910 */
911 public function developerRequired() {
912 throw new MWException( "Call to deprecated OutputPage::developerRequired() method\n" );
913 }
914
915 /**
916 * Produce the stock "please login to use the wiki" page
917 */
918 public function loginToUse() {
919 global $wgUser, $wgTitle, $wgContLang;
920
921 if( $wgUser->isLoggedIn() ) {
922 $this->permissionRequired( 'read' );
923 return;
924 }
925
926 $skin = $wgUser->getSkin();
927
928 $this->setPageTitle( wfMsg( 'loginreqtitle' ) );
929 $this->setHtmlTitle( wfMsg( 'errorpagetitle' ) );
930 $this->setRobotPolicy( 'noindex,nofollow' );
931 $this->setArticleFlag( false );
932
933 $loginTitle = SpecialPage::getTitleFor( 'Userlogin' );
934 $loginLink = $skin->makeKnownLinkObj( $loginTitle, wfMsgHtml( 'loginreqlink' ), 'returnto=' . $wgTitle->getPrefixedUrl() );
935 $this->addHtml( wfMsgWikiHtml( 'loginreqpagetext', $loginLink ) );
936 $this->addHtml( "\n<!--" . $wgTitle->getPrefixedUrl() . "-->" );
937
938 # Don't return to the main page if the user can't read it
939 # otherwise we'll end up in a pointless loop
940 $mainPage = Title::newMainPage();
941 if( $mainPage->userCanRead() )
942 $this->returnToMain( true, $mainPage );
943 }
944
945 /** @deprecated */
946 public function databaseError( $fname, $sql, $error, $errno ) {
947 throw new MWException( "OutputPage::databaseError is obsolete\n" );
948 }
949
950 /**
951 * @todo document
952 * @param bool $protected Is the reason the page can't be reached because it's protected?
953 * @param mixed $source
954 */
955 public function readOnlyPage( $source = null, $protected = false ) {
956 global $wgUser, $wgReadOnlyFile, $wgReadOnly, $wgTitle;
957 $skin = $wgUser->getSkin();
958
959 $this->setRobotpolicy( 'noindex,nofollow' );
960 $this->setArticleRelated( false );
961
962 if( $protected ) {
963 $this->setPageTitle( wfMsg( 'viewsource' ) );
964 $this->setSubtitle( wfMsg( 'viewsourcefor', $skin->makeKnownLinkObj( $wgTitle ) ) );
965
966 list( $cascadeSources, /* $restrictions */ ) = $wgTitle->getCascadeProtectionSources();
967
968 # Determine if protection is due to the page being a system message
969 # and show an appropriate explanation
970 if( $wgTitle->getNamespace() == NS_MEDIAWIKI ) {
971 $this->addWikiText( wfMsg( 'protectedinterface' ) );
972 } if ( $cascadeSources && count($cascadeSources) > 0 ) {
973 $titles = '';
974
975 foreach ( $cascadeSources as $title ) {
976 $titles .= '* [[:' . $title->getPrefixedText() . "]]\n";
977 }
978
979 $notice = wfMsgExt( 'cascadeprotected', array('parsemag'), count($cascadeSources) ) . "\n$titles";
980
981 $this->addWikiText( $notice );
982 } else {
983 $this->addWikiText( wfMsg( 'protectedpagetext' ) );
984 }
985 } else {
986 $this->setPageTitle( wfMsg( 'readonly' ) );
987 if ( $wgReadOnly ) {
988 $reason = $wgReadOnly;
989 } else {
990 $reason = file_get_contents( $wgReadOnlyFile );
991 }
992 $this->addWikiText( wfMsg( 'readonlytext', $reason ) );
993 }
994
995 if( is_string( $source ) ) {
996 $this->addWikiText( wfMsg( 'viewsourcetext' ) );
997 $rows = $wgUser->getIntOption( 'rows' );
998 $cols = $wgUser->getIntOption( 'cols' );
999 $text = "\n<textarea name='wpTextbox1' id='wpTextbox1' cols='$cols' rows='$rows' readonly='readonly'>" .
1000 htmlspecialchars( $source ) . "\n</textarea>";
1001 $this->addHTML( $text );
1002 }
1003 $article = new Article($wgTitle);
1004 $this->addHTML( $skin->formatTemplates($article->getUsedTemplates()) );
1005
1006 $this->returnToMain( false );
1007 }
1008
1009 /** @deprecated */
1010 public function fatalError( $message ) {
1011 throw new FatalError( $message );
1012 }
1013
1014 /** @deprecated */
1015 public function unexpectedValueError( $name, $val ) {
1016 throw new FatalError( wfMsg( 'unexpected', $name, $val ) );
1017 }
1018
1019 /** @deprecated */
1020 public function fileCopyError( $old, $new ) {
1021 throw new FatalError( wfMsg( 'filecopyerror', $old, $new ) );
1022 }
1023
1024 /** @deprecated */
1025 public function fileRenameError( $old, $new ) {
1026 throw new FatalError( wfMsg( 'filerenameerror', $old, $new ) );
1027 }
1028
1029 /** @deprecated */
1030 public function fileDeleteError( $name ) {
1031 throw new FatalError( wfMsg( 'filedeleteerror', $name ) );
1032 }
1033
1034 /** @deprecated */
1035 public function fileNotFoundError( $name ) {
1036 throw new FatalError( wfMsg( 'filenotfound', $name ) );
1037 }
1038
1039 public function showFatalError( $message ) {
1040 $this->setPageTitle( wfMsg( "internalerror" ) );
1041 $this->setRobotpolicy( "noindex,nofollow" );
1042 $this->setArticleRelated( false );
1043 $this->enableClientCache( false );
1044 $this->mRedirect = '';
1045 $this->mBodytext = $message;
1046 }
1047
1048 public function showUnexpectedValueError( $name, $val ) {
1049 $this->showFatalError( wfMsg( 'unexpected', $name, $val ) );
1050 }
1051
1052 public function showFileCopyError( $old, $new ) {
1053 $this->showFatalError( wfMsg( 'filecopyerror', $old, $new ) );
1054 }
1055
1056 public function showFileRenameError( $old, $new ) {
1057 $this->showFatalError( wfMsg( 'filerenameerror', $old, $new ) );
1058 }
1059
1060 public function showFileDeleteError( $name ) {
1061 $this->showFatalError( wfMsg( 'filedeleteerror', $name ) );
1062 }
1063
1064 public function showFileNotFoundError( $name ) {
1065 $this->showFatalError( wfMsg( 'filenotfound', $name ) );
1066 }
1067
1068 /**
1069 * return from error messages or notes
1070 * @param $auto automatically redirect the user after 10 seconds
1071 * @param $returnto page title to return to. Default is Main Page.
1072 */
1073 public function returnToMain( $auto = true, $returnto = NULL ) {
1074 global $wgUser, $wgOut, $wgRequest;
1075
1076 if ( $returnto == NULL ) {
1077 $returnto = $wgRequest->getText( 'returnto' );
1078 }
1079
1080 if ( '' === $returnto ) {
1081 $returnto = Title::newMainPage();
1082 }
1083
1084 if ( is_object( $returnto ) ) {
1085 $titleObj = $returnto;
1086 } else {
1087 $titleObj = Title::newFromText( $returnto );
1088 }
1089 if ( !is_object( $titleObj ) ) {
1090 $titleObj = Title::newMainPage();
1091 }
1092
1093 $sk = $wgUser->getSkin();
1094 $link = $sk->makeLinkObj( $titleObj, '' );
1095
1096 $r = wfMsg( 'returnto', $link );
1097 if ( $auto ) {
1098 $wgOut->addMeta( 'http:Refresh', '10;url=' . $titleObj->escapeFullURL() );
1099 }
1100 $wgOut->addHTML( "\n<p>$r</p>\n" );
1101 }
1102
1103 /**
1104 * This function takes the title (first item of mGoodLinks), categories, existing and broken links for the page
1105 * and uses the first 10 of them for META keywords
1106 *
1107 * @param ParserOutput &$parserOutput
1108 */
1109 private function addKeywords( &$parserOutput ) {
1110 global $wgTitle;
1111 $this->addKeyword( $wgTitle->getPrefixedText() );
1112 $count = 1;
1113 $links2d =& $parserOutput->getLinks();
1114 if ( !is_array( $links2d ) ) {
1115 return;
1116 }
1117 foreach ( $links2d as $dbkeys ) {
1118 foreach( $dbkeys as $dbkey => $unused ) {
1119 $this->addKeyword( $dbkey );
1120 if ( ++$count > 10 ) {
1121 break 2;
1122 }
1123 }
1124 }
1125 }
1126
1127 /**
1128 * @return string The doctype, opening <html>, and head element.
1129 */
1130 public function headElement() {
1131 global $wgDocType, $wgDTD, $wgContLanguageCode, $wgOutputEncoding, $wgMimeType;
1132 global $wgXhtmlDefaultNamespace, $wgXhtmlNamespaces;
1133 global $wgUser, $wgContLang, $wgUseTrackbacks, $wgTitle, $wgStyleVersion;
1134
1135 if( $wgMimeType == 'text/xml' || $wgMimeType == 'application/xhtml+xml' || $wgMimeType == 'application/xml' ) {
1136 $ret = "<?xml version=\"1.0\" encoding=\"$wgOutputEncoding\" ?>\n";
1137 } else {
1138 $ret = '';
1139 }
1140
1141 $ret .= "<!DOCTYPE html PUBLIC \"$wgDocType\"\n \"$wgDTD\">\n";
1142
1143 if ( '' == $this->getHTMLTitle() ) {
1144 $this->setHTMLTitle( wfMsg( 'pagetitle', $this->getPageTitle() ));
1145 }
1146
1147 $rtl = $wgContLang->isRTL() ? " dir='RTL'" : '';
1148 $ret .= "<html xmlns=\"{$wgXhtmlDefaultNamespace}\" ";
1149 foreach($wgXhtmlNamespaces as $tag => $ns) {
1150 $ret .= "xmlns:{$tag}=\"{$ns}\" ";
1151 }
1152 $ret .= "xml:lang=\"$wgContLanguageCode\" lang=\"$wgContLanguageCode\" $rtl>\n";
1153 $ret .= "<head>\n<title>" . htmlspecialchars( $this->getHTMLTitle() ) . "</title>\n";
1154 array_push( $this->mMetatags, array( "http:Content-type", "$wgMimeType; charset={$wgOutputEncoding}" ) );
1155
1156 $ret .= $this->getHeadLinks();
1157 global $wgStylePath;
1158 if( $this->isPrintable() ) {
1159 $media = '';
1160 } else {
1161 $media = "media='print'";
1162 }
1163 $printsheet = htmlspecialchars( "$wgStylePath/common/wikiprintable.css?$wgStyleVersion" );
1164 $ret .= "<link rel='stylesheet' type='text/css' $media href='$printsheet' />\n";
1165
1166 $sk = $wgUser->getSkin();
1167 $ret .= $sk->getHeadScripts( $this->mAllowUserJs );
1168 $ret .= $this->mScripts;
1169 $ret .= $sk->getUserStyles();
1170 $ret .= $this->getHeadItems();
1171
1172 if ($wgUseTrackbacks && $this->isArticleRelated())
1173 $ret .= $wgTitle->trackbackRDF();
1174
1175 $ret .= "</head>\n";
1176 return $ret;
1177 }
1178
1179 /**
1180 * @return string HTML tag links to be put in the header.
1181 */
1182 public function getHeadLinks() {
1183 global $wgRequest;
1184 $ret = '';
1185 foreach ( $this->mMetatags as $tag ) {
1186 if ( 0 == strcasecmp( 'http:', substr( $tag[0], 0, 5 ) ) ) {
1187 $a = 'http-equiv';
1188 $tag[0] = substr( $tag[0], 5 );
1189 } else {
1190 $a = 'name';
1191 }
1192 $ret .= "<meta $a=\"{$tag[0]}\" content=\"{$tag[1]}\" />\n";
1193 }
1194
1195 $p = $this->mRobotpolicy;
1196 if( $p !== '' && $p != 'index,follow' ) {
1197 // http://www.robotstxt.org/wc/meta-user.html
1198 // Only show if it's different from the default robots policy
1199 $ret .= "<meta name=\"robots\" content=\"$p\" />\n";
1200 }
1201
1202 if ( count( $this->mKeywords ) > 0 ) {
1203 $strip = array(
1204 "/<.*?>/" => '',
1205 "/_/" => ' '
1206 );
1207 $ret .= "\t\t<meta name=\"keywords\" content=\"" .
1208 htmlspecialchars(preg_replace(array_keys($strip), array_values($strip),implode( ",", $this->mKeywords ))) . "\" />\n";
1209 }
1210 foreach ( $this->mLinktags as $tag ) {
1211 $ret .= "\t\t<link";
1212 foreach( $tag as $attr => $val ) {
1213 $ret .= " $attr=\"" . htmlspecialchars( $val ) . "\"";
1214 }
1215 $ret .= " />\n";
1216 }
1217 if( $this->isSyndicated() ) {
1218 # FIXME: centralize the mime-type and name information in Feed.php
1219 $link = $wgRequest->escapeAppendQuery( 'feed=rss' );
1220 $ret .= "<link rel='alternate' type='application/rss+xml' title='RSS 2.0' href='$link' />\n";
1221 $link = $wgRequest->escapeAppendQuery( 'feed=atom' );
1222 $ret .= "<link rel='alternate' type='application/atom+xml' title='Atom 1.0' href='$link' />\n";
1223 }
1224
1225 return $ret;
1226 }
1227
1228 /**
1229 * Turn off regular page output and return an error reponse
1230 * for when rate limiting has triggered.
1231 * @todo i18n
1232 */
1233 public function rateLimited() {
1234 global $wgOut;
1235 $wgOut->disable();
1236 wfHttpError( 500, 'Internal Server Error',
1237 'Sorry, the server has encountered an internal error. ' .
1238 'Please wait a moment and hit "refresh" to submit the request again.' );
1239 }
1240
1241 /**
1242 * Show an "add new section" link?
1243 *
1244 * @return bool True if the parser output instructs us to add one
1245 */
1246 public function showNewSectionLink() {
1247 return $this->mNewSectionLink;
1248 }
1249
1250 /**
1251 * Show a warning about slave lag
1252 *
1253 * If the lag is higher than 30 seconds, then the warning is
1254 * a bit more obvious
1255 *
1256 * @param int $lag Slave lag
1257 */
1258 public function showLagWarning( $lag ) {
1259 global $wgSlaveLagWarning, $wgSlaveLagCritical;
1260
1261 if ($lag < $wgSlaveLagWarning)
1262 return;
1263
1264 $message = ($lag >= $wgSlaveLagCritical) ? 'lag-warn-high' : 'lag-warn-normal';
1265 $warning = wfMsgHtml( $message, htmlspecialchars( $lag ) );
1266 $this->addHtml( "<div class=\"mw-{$message}\">\n{$warning}\n</div>\n" );
1267 }
1268
1269 }
1270
1271 ?>