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