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