(Bug 30364) LanguageConverter should depend on the page content language instead...
[lhc/web/wiklou.git] / includes / Article.php
1 <?php
2 /**
3 * File for articles
4 * @file
5 */
6
7 /**
8 * Class for viewing MediaWiki article and history.
9 *
10 * This maintains WikiPage functions for backwards compatibility.
11 *
12 * @TODO: move and rewrite code to an Action class
13 *
14 * See design.txt for an overview.
15 * Note: edit user interface and cache support functions have been
16 * moved to separate EditPage and HTMLFileCache classes.
17 *
18 * @internal documentation reviewed 15 Mar 2010
19 */
20 class Article extends Page {
21 /**@{{
22 * @private
23 */
24
25 /**
26 * @var RequestContext
27 */
28 protected $mContext;
29
30 /**
31 * @var WikiPage
32 */
33 protected $mPage;
34
35 var $mContent; // !<
36 var $mContentLoaded = false; // !<
37 var $mOldId; // !<
38
39 /**
40 * @var Title
41 */
42 var $mRedirectedFrom = null;
43
44 /**
45 * @var mixed: boolean false or URL string
46 */
47 var $mRedirectUrl = false; // !<
48 var $mRevIdFetched = 0; // !<
49
50 /**
51 * @var Revision
52 */
53 var $mRevision = null;
54
55 /**
56 * @var ParserOutput
57 */
58 var $mParserOutput;
59
60 /**@}}*/
61
62 /**
63 * Constructor and clear the article
64 * @param $title Title Reference to a Title object.
65 * @param $oldId Integer revision ID, null to fetch from request, zero for current
66 */
67 public function __construct( Title $title, $oldId = null ) {
68 $this->mOldId = $oldId;
69 $this->mPage = $this->newPage( $title );
70 }
71
72 protected function newPage( Title $title ) {
73 return new WikiPage( $title );
74 }
75
76 /**
77 * Constructor from a page id
78 * @param $id Int article ID to load
79 */
80 public static function newFromID( $id ) {
81 $t = Title::newFromID( $id );
82 # @todo FIXME: Doesn't inherit right
83 return $t == null ? null : new self( $t );
84 # return $t == null ? null : new static( $t ); // PHP 5.3
85 }
86
87 /**
88 * Create an Article object of the appropriate class for the given page.
89 *
90 * @param $title Title
91 * @param $context RequestContext
92 * @return Article object
93 */
94 public static function newFromTitle( $title, RequestContext $context ) {
95 if ( NS_MEDIA == $title->getNamespace() ) {
96 // FIXME: where should this go?
97 $title = Title::makeTitle( NS_FILE, $title->getDBkey() );
98 }
99
100 $page = null;
101 wfRunHooks( 'ArticleFromTitle', array( &$title, &$page ) );
102 if ( !$page ) {
103 switch( $title->getNamespace() ) {
104 case NS_FILE:
105 $page = new ImagePage( $title );
106 break;
107 case NS_CATEGORY:
108 $page = new CategoryPage( $title );
109 break;
110 default:
111 $page = new Article( $title );
112 }
113 }
114 $page->setContext( $context );
115
116 return $page;
117 }
118
119 /**
120 * Tell the page view functions that this view was redirected
121 * from another page on the wiki.
122 * @param $from Title object.
123 */
124 public function setRedirectedFrom( Title $from ) {
125 $this->mRedirectedFrom = $from;
126 }
127
128 /**
129 * Get the title object of the article
130 * @return Title object of this page
131 */
132 public function getTitle() {
133 return $this->mPage->getTitle();
134 }
135
136 /**
137 * Clear the object
138 * @todo FIXME: Shouldn't this be public?
139 * @private
140 */
141 public function clear() {
142 $this->mContentLoaded = false;
143
144 $this->mRedirectedFrom = null; # Title object if set
145 $this->mRevIdFetched = 0;
146 $this->mRedirectUrl = false;
147
148 $this->mPage->clear();
149 }
150
151 /**
152 * Note that getContent/loadContent do not follow redirects anymore.
153 * If you need to fetch redirectable content easily, try
154 * the shortcut in Article::followRedirect()
155 *
156 * This function has side effects! Do not use this function if you
157 * only want the real revision text if any.
158 *
159 * @return Return the text of this revision
160 */
161 public function getContent() {
162 global $wgUser;
163
164 wfProfileIn( __METHOD__ );
165
166 if ( $this->mPage->getID() === 0 ) {
167 # If this is a MediaWiki:x message, then load the messages
168 # and return the message value for x.
169 if ( $this->getTitle()->getNamespace() == NS_MEDIAWIKI ) {
170 $text = $this->getTitle()->getDefaultMessageText();
171 if ( $text === false ) {
172 $text = '';
173 }
174 } else {
175 $text = wfMsgExt( $wgUser->isLoggedIn() ? 'noarticletext' : 'noarticletextanon', 'parsemag' );
176 }
177 wfProfileOut( __METHOD__ );
178
179 return $text;
180 } else {
181 $this->loadContent();
182 wfProfileOut( __METHOD__ );
183
184 return $this->mContent;
185 }
186 }
187
188 /**
189 * @return int The oldid of the article that is to be shown, 0 for the
190 * current revision
191 */
192 public function getOldID() {
193 if ( is_null( $this->mOldId ) ) {
194 $this->mOldId = $this->getOldIDFromRequest();
195 }
196
197 return $this->mOldId;
198 }
199
200 /**
201 * Sets $this->mRedirectUrl to a correct URL if the query parameters are incorrect
202 *
203 * @return int The old id for the request
204 */
205 public function getOldIDFromRequest() {
206 global $wgRequest;
207
208 $this->mRedirectUrl = false;
209
210 $oldid = $wgRequest->getVal( 'oldid' );
211
212 if ( isset( $oldid ) ) {
213 $oldid = intval( $oldid );
214 if ( $wgRequest->getVal( 'direction' ) == 'next' ) {
215 $nextid = $this->getTitle()->getNextRevisionID( $oldid );
216 if ( $nextid ) {
217 $oldid = $nextid;
218 } else {
219 $this->mRedirectUrl = $this->getTitle()->getFullURL( 'redirect=no' );
220 }
221 } elseif ( $wgRequest->getVal( 'direction' ) == 'prev' ) {
222 $previd = $this->getTitle()->getPreviousRevisionID( $oldid );
223 if ( $previd ) {
224 $oldid = $previd;
225 }
226 }
227 }
228
229 if ( !$oldid ) {
230 $oldid = 0;
231 }
232
233 return $oldid;
234 }
235
236 /**
237 * Load the revision (including text) into this object
238 */
239 function loadContent() {
240 if ( $this->mContentLoaded ) {
241 return;
242 }
243
244 wfProfileIn( __METHOD__ );
245
246 $this->fetchContent( $this->getOldID() );
247
248 wfProfileOut( __METHOD__ );
249 }
250
251 /**
252 * Get text of an article from database
253 * Does *NOT* follow redirects.
254 *
255 * @param $oldid Int: 0 for whatever the latest revision is
256 * @return mixed string containing article contents, or false if null
257 */
258 function fetchContent( $oldid = 0 ) {
259 if ( $this->mContentLoaded ) {
260 return $this->mContent;
261 }
262
263 # Pre-fill content with error message so that if something
264 # fails we'll have something telling us what we intended.
265 $t = $this->getTitle()->getPrefixedText();
266 $d = $oldid ? wfMsgExt( 'missingarticle-rev', array( 'escape' ), $oldid ) : '';
267 $this->mContent = wfMsgNoTrans( 'missing-article', $t, $d ) ;
268
269 if ( $oldid ) {
270 $revision = Revision::newFromId( $oldid );
271 if ( !$revision ) {
272 wfDebug( __METHOD__ . " failed to retrieve specified revision, id $oldid\n" );
273 return false;
274 }
275 // Revision title doesn't match the page title given?
276 if ( $this->mPage->getID() != $revision->getPage() ) {
277 $function = array( get_class( $this->mPage ), 'newFromID' );
278 $this->mPage = call_user_func( $function, $revision->getPage() );
279 if ( !$this->mPage->getId() ) {
280 wfDebug( __METHOD__ . " failed to get page data linked to revision id $oldid\n" );
281 return false;
282 }
283 }
284 } else {
285 if ( !$this->mPage->getLatest() ) {
286 wfDebug( __METHOD__ . " failed to find page data for title " . $this->getTitle()->getPrefixedText() . "\n" );
287 return false;
288 }
289
290 $revision = $this->mPage->getRevision();
291 if ( !$revision ) {
292 wfDebug( __METHOD__ . " failed to retrieve current page, rev_id " . $this->mPage->getLatest() . "\n" );
293 return false;
294 }
295 }
296
297 // @todo FIXME: Horrible, horrible! This content-loading interface just plain sucks.
298 // We should instead work with the Revision object when we need it...
299 $this->mContent = $revision->getText( Revision::FOR_THIS_USER ); // Loads if user is allowed
300
301 $this->mRevIdFetched = $revision->getId();
302 $this->mContentLoaded = true;
303 $this->mRevision =& $revision;
304
305 wfRunHooks( 'ArticleAfterFetchContent', array( &$this, &$this->mContent ) );
306
307 return $this->mContent;
308 }
309
310 /**
311 * No-op
312 * @deprecated since 1.18
313 */
314 public function forUpdate() {
315 wfDeprecated( __METHOD__ );
316 }
317
318 /**
319 * Returns true if the currently-referenced revision is the current edit
320 * to this page (and it exists).
321 * @return bool
322 */
323 public function isCurrent() {
324 # If no oldid, this is the current version.
325 if ( $this->getOldID() == 0 ) {
326 return true;
327 }
328
329 return $this->mPage->exists() && $this->mRevision && $this->mRevision->isCurrent();
330 }
331
332 /**
333 * Use this to fetch the rev ID used on page views
334 *
335 * @return int revision ID of last article revision
336 */
337 public function getRevIdFetched() {
338 if ( $this->mRevIdFetched ) {
339 return $this->mRevIdFetched;
340 } else {
341 return $this->mPage->getLatest();
342 }
343 }
344
345 /**
346 * This is the default action of the index.php entry point: just view the
347 * page of the given title.
348 */
349 public function view() {
350 global $wgUser, $wgOut, $wgRequest, $wgParser;
351 global $wgUseFileCache, $wgUseETag;
352
353 wfProfileIn( __METHOD__ );
354
355 # Get variables from query string
356 $oldid = $this->getOldID();
357
358 # getOldID may want us to redirect somewhere else
359 if ( $this->mRedirectUrl ) {
360 $wgOut->redirect( $this->mRedirectUrl );
361 wfDebug( __METHOD__ . ": redirecting due to oldid\n" );
362 wfProfileOut( __METHOD__ );
363
364 return;
365 }
366
367 # Set page title (may be overridden by DISPLAYTITLE)
368 $wgOut->setPageTitle( $this->getTitle()->getPrefixedText() );
369
370 # If we got diff in the query, we want to see a diff page instead of the article.
371 if ( $wgRequest->getCheck( 'diff' ) ) {
372 wfDebug( __METHOD__ . ": showing diff page\n" );
373 $this->showDiffPage();
374 wfProfileOut( __METHOD__ );
375
376 return;
377 }
378
379 $wgOut->setArticleFlag( true );
380 # Allow frames by default
381 $wgOut->allowClickjacking();
382
383 $parserCache = ParserCache::singleton();
384
385 $parserOptions = $this->mPage->getParserOptions();
386 # Render printable version, use printable version cache
387 if ( $wgOut->isPrintable() ) {
388 $parserOptions->setIsPrintable( true );
389 $parserOptions->setEditSection( false );
390 } elseif ( $wgUseETag && !$this->getTitle()->quickUserCan( 'edit' ) ) {
391 $parserOptions->setEditSection( false );
392 }
393
394 # Try client and file cache
395 if ( $oldid === 0 && $this->mPage->checkTouched() ) {
396 if ( $wgUseETag ) {
397 $wgOut->setETag( $parserCache->getETag( $this, $parserOptions ) );
398 }
399
400 # Is it client cached?
401 if ( $wgOut->checkLastModified( $this->mPage->getTouched() ) ) {
402 wfDebug( __METHOD__ . ": done 304\n" );
403 wfProfileOut( __METHOD__ );
404
405 return;
406 # Try file cache
407 } elseif ( $wgUseFileCache && $this->tryFileCache() ) {
408 wfDebug( __METHOD__ . ": done file cache\n" );
409 # tell wgOut that output is taken care of
410 $wgOut->disable();
411 $this->mPage->viewUpdates();
412 wfProfileOut( __METHOD__ );
413
414 return;
415 }
416 }
417
418 if ( !$wgUseETag && !$this->getTitle()->quickUserCan( 'edit' ) ) {
419 $parserOptions->setEditSection( false );
420 }
421
422 # Should the parser cache be used?
423 $useParserCache = $this->useParserCache( $oldid );
424 wfDebug( 'Article::view using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" );
425 if ( $wgUser->getStubThreshold() ) {
426 wfIncrStats( 'pcache_miss_stub' );
427 }
428
429 $wasRedirected = $this->showRedirectedFromHeader();
430 $this->showNamespaceHeader();
431
432 # Iterate through the possible ways of constructing the output text.
433 # Keep going until $outputDone is set, or we run out of things to do.
434 $pass = 0;
435 $outputDone = false;
436 $this->mParserOutput = false;
437
438 while ( !$outputDone && ++$pass ) {
439 switch( $pass ) {
440 case 1:
441 wfRunHooks( 'ArticleViewHeader', array( &$this, &$outputDone, &$useParserCache ) );
442 break;
443 case 2:
444 # Try the parser cache
445 if ( $useParserCache ) {
446 $this->mParserOutput = $parserCache->get( $this, $parserOptions );
447
448 if ( $this->mParserOutput !== false ) {
449 wfDebug( __METHOD__ . ": showing parser cache contents\n" );
450 $wgOut->addParserOutput( $this->mParserOutput );
451 # Ensure that UI elements requiring revision ID have
452 # the correct version information.
453 $wgOut->setRevisionId( $this->mPage->getLatest() );
454 $outputDone = true;
455 # Preload timestamp to avoid a DB hit
456 if ( isset( $this->mParserOutput->mTimestamp ) ) {
457 $this->mPage->setTimestamp( $this->mParserOutput->mTimestamp );
458 }
459 }
460 }
461 break;
462 case 3:
463 $text = $this->getContent();
464 if ( $text === false || $this->mPage->getID() == 0 ) {
465 wfDebug( __METHOD__ . ": showing missing article\n" );
466 $this->showMissingArticle();
467 wfProfileOut( __METHOD__ );
468 return;
469 }
470
471 # Another whitelist check in case oldid is altering the title
472 if ( !$this->getTitle()->userCanRead() ) {
473 wfDebug( __METHOD__ . ": denied on secondary read check\n" );
474 $wgOut->loginToUse();
475 $wgOut->output();
476 $wgOut->disable();
477 wfProfileOut( __METHOD__ );
478 return;
479 }
480
481 # Are we looking at an old revision
482 if ( $oldid && !is_null( $this->mRevision ) ) {
483 $this->setOldSubtitle( $oldid );
484
485 if ( !$this->showDeletedRevisionHeader() ) {
486 wfDebug( __METHOD__ . ": cannot view deleted revision\n" );
487 wfProfileOut( __METHOD__ );
488 return;
489 }
490
491 # If this "old" version is the current, then try the parser cache...
492 if ( $oldid === $this->mPage->getLatest() && $this->useParserCache( false ) ) {
493 $this->mParserOutput = $parserCache->get( $this, $parserOptions );
494 if ( $this->mParserOutput ) {
495 wfDebug( __METHOD__ . ": showing parser cache for current rev permalink\n" );
496 $wgOut->addParserOutput( $this->mParserOutput );
497 $wgOut->setRevisionId( $this->mPage->getLatest() );
498 $outputDone = true;
499 break;
500 }
501 }
502 }
503
504 # Ensure that UI elements requiring revision ID have
505 # the correct version information.
506 $wgOut->setRevisionId( $this->getRevIdFetched() );
507
508 # Pages containing custom CSS or JavaScript get special treatment
509 if ( $this->getTitle()->isCssOrJsPage() || $this->getTitle()->isCssJsSubpage() ) {
510 wfDebug( __METHOD__ . ": showing CSS/JS source\n" );
511 $this->showCssOrJsPage();
512 $outputDone = true;
513 } elseif( !wfRunHooks( 'ArticleViewCustom', array( $this->mContent, $this->getTitle(), $wgOut ) ) ) {
514 # Allow extensions do their own custom view for certain pages
515 $outputDone = true;
516 } else {
517 $rt = Title::newFromRedirectArray( $text );
518 if ( $rt ) {
519 wfDebug( __METHOD__ . ": showing redirect=no page\n" );
520 # Viewing a redirect page (e.g. with parameter redirect=no)
521 # Don't append the subtitle if this was an old revision
522 $wgOut->addHTML( $this->viewRedirect( $rt, !$wasRedirected && $this->isCurrent() ) );
523 # Parse just to get categories, displaytitle, etc.
524 $this->mParserOutput = $wgParser->parse( $text, $this->getTitle(), $parserOptions );
525 $wgOut->addParserOutputNoText( $this->mParserOutput );
526 $outputDone = true;
527 }
528 }
529 break;
530 case 4:
531 # Run the parse, protected by a pool counter
532 wfDebug( __METHOD__ . ": doing uncached parse\n" );
533
534 $key = $parserCache->getKey( $this, $parserOptions );
535 $poolArticleView = new PoolWorkArticleView( $this, $key, $useParserCache, $parserOptions );
536
537 if ( !$poolArticleView->execute() ) {
538 # Connection or timeout error
539 wfProfileOut( __METHOD__ );
540 return;
541 } else {
542 $outputDone = true;
543 }
544 break;
545 # Should be unreachable, but just in case...
546 default:
547 break 2;
548 }
549 }
550
551 # Adjust the title if it was set by displaytitle, -{T|}- or language conversion
552 if ( $this->mParserOutput ) {
553 $titleText = $this->mParserOutput->getTitleText();
554
555 if ( strval( $titleText ) !== '' ) {
556 $wgOut->setPageTitle( $titleText );
557 }
558 }
559
560 # For the main page, overwrite the <title> element with the con-
561 # tents of 'pagetitle-view-mainpage' instead of the default (if
562 # that's not empty).
563 # This message always exists because it is in the i18n files
564 if ( $this->getTitle()->equals( Title::newMainPage() ) ) {
565 $msg = wfMessage( 'pagetitle-view-mainpage' )->inContentLanguage();
566 if ( !$msg->isDisabled() ) {
567 $wgOut->setHTMLTitle( $msg->title( $this->getTitle() )->text() );
568 }
569 }
570
571 # Now that we've filled $this->mParserOutput, we know whether
572 # there are any __NOINDEX__ tags on the page
573 $policy = $this->getRobotPolicy( 'view' );
574 $wgOut->setIndexPolicy( $policy['index'] );
575 $wgOut->setFollowPolicy( $policy['follow'] );
576
577 $this->showViewFooter();
578 $this->mPage->viewUpdates();
579 wfProfileOut( __METHOD__ );
580 }
581
582 /**
583 * Show a diff page according to current request variables. For use within
584 * Article::view() only, other callers should use the DifferenceEngine class.
585 */
586 public function showDiffPage() {
587 global $wgRequest, $wgUser;
588
589 $diff = $wgRequest->getVal( 'diff' );
590 $rcid = $wgRequest->getVal( 'rcid' );
591 $diffOnly = $wgRequest->getBool( 'diffonly', $wgUser->getOption( 'diffonly' ) );
592 $purge = $wgRequest->getVal( 'action' ) == 'purge';
593 $unhide = $wgRequest->getInt( 'unhide' ) == 1;
594 $oldid = $this->getOldID();
595
596 $de = new DifferenceEngine( $this->getTitle(), $oldid, $diff, $rcid, $purge, $unhide );
597 // DifferenceEngine directly fetched the revision:
598 $this->mRevIdFetched = $de->mNewid;
599 $de->showDiffPage( $diffOnly );
600
601 if ( $diff == 0 || $diff == $this->mPage->getLatest() ) {
602 # Run view updates for current revision only
603 $this->mPage->viewUpdates();
604 }
605 }
606
607 /**
608 * Show a page view for a page formatted as CSS or JavaScript. To be called by
609 * Article::view() only.
610 *
611 * This is hooked by SyntaxHighlight_GeSHi to do syntax highlighting of these
612 * page views.
613 */
614 protected function showCssOrJsPage() {
615 global $wgOut;
616
617 $dir = $this->getContext()->getLang()->getDir();
618 $lang = $this->getContext()->getLang()->getCode();
619
620 $wgOut->wrapWikiMsg( "<div id='mw-clearyourcache' lang='$lang' dir='$dir' class='mw-content-$dir'>\n$1\n</div>",
621 'clearyourcache' );
622
623 // Give hooks a chance to customise the output
624 if ( wfRunHooks( 'ShowRawCssJs', array( $this->mContent, $this->getTitle(), $wgOut ) ) ) {
625 // Wrap the whole lot in a <pre> and don't parse
626 $m = array();
627 preg_match( '!\.(css|js)$!u', $this->getTitle()->getText(), $m );
628 $wgOut->addHTML( "<pre class=\"mw-code mw-{$m[1]}\" dir=\"ltr\">\n" );
629 $wgOut->addHTML( htmlspecialchars( $this->mContent ) );
630 $wgOut->addHTML( "\n</pre>\n" );
631 }
632 }
633
634 /**
635 * Get the robot policy to be used for the current view
636 * @param $action String the action= GET parameter
637 * @return Array the policy that should be set
638 * TODO: actions other than 'view'
639 */
640 public function getRobotPolicy( $action ) {
641 global $wgOut, $wgArticleRobotPolicies, $wgNamespaceRobotPolicies;
642 global $wgDefaultRobotPolicy, $wgRequest;
643
644 $ns = $this->getTitle()->getNamespace();
645
646 if ( $ns == NS_USER || $ns == NS_USER_TALK ) {
647 # Don't index user and user talk pages for blocked users (bug 11443)
648 if ( !$this->getTitle()->isSubpage() ) {
649 if ( Block::newFromTarget( null, $this->getTitle()->getText() ) instanceof Block ) {
650 return array(
651 'index' => 'noindex',
652 'follow' => 'nofollow'
653 );
654 }
655 }
656 }
657
658 if ( $this->mPage->getID() === 0 || $this->getOldID() ) {
659 # Non-articles (special pages etc), and old revisions
660 return array(
661 'index' => 'noindex',
662 'follow' => 'nofollow'
663 );
664 } elseif ( $wgOut->isPrintable() ) {
665 # Discourage indexing of printable versions, but encourage following
666 return array(
667 'index' => 'noindex',
668 'follow' => 'follow'
669 );
670 } elseif ( $wgRequest->getInt( 'curid' ) ) {
671 # For ?curid=x urls, disallow indexing
672 return array(
673 'index' => 'noindex',
674 'follow' => 'follow'
675 );
676 }
677
678 # Otherwise, construct the policy based on the various config variables.
679 $policy = self::formatRobotPolicy( $wgDefaultRobotPolicy );
680
681 if ( isset( $wgNamespaceRobotPolicies[$ns] ) ) {
682 # Honour customised robot policies for this namespace
683 $policy = array_merge(
684 $policy,
685 self::formatRobotPolicy( $wgNamespaceRobotPolicies[$ns] )
686 );
687 }
688 if ( $this->getTitle()->canUseNoindex() && is_object( $this->mParserOutput ) && $this->mParserOutput->getIndexPolicy() ) {
689 # __INDEX__ and __NOINDEX__ magic words, if allowed. Incorporates
690 # a final sanity check that we have really got the parser output.
691 $policy = array_merge(
692 $policy,
693 array( 'index' => $this->mParserOutput->getIndexPolicy() )
694 );
695 }
696
697 if ( isset( $wgArticleRobotPolicies[$this->getTitle()->getPrefixedText()] ) ) {
698 # (bug 14900) site config can override user-defined __INDEX__ or __NOINDEX__
699 $policy = array_merge(
700 $policy,
701 self::formatRobotPolicy( $wgArticleRobotPolicies[$this->getTitle()->getPrefixedText()] )
702 );
703 }
704
705 return $policy;
706 }
707
708 /**
709 * Converts a String robot policy into an associative array, to allow
710 * merging of several policies using array_merge().
711 * @param $policy Mixed, returns empty array on null/false/'', transparent
712 * to already-converted arrays, converts String.
713 * @return Array: 'index' => <indexpolicy>, 'follow' => <followpolicy>
714 */
715 public static function formatRobotPolicy( $policy ) {
716 if ( is_array( $policy ) ) {
717 return $policy;
718 } elseif ( !$policy ) {
719 return array();
720 }
721
722 $policy = explode( ',', $policy );
723 $policy = array_map( 'trim', $policy );
724
725 $arr = array();
726 foreach ( $policy as $var ) {
727 if ( in_array( $var, array( 'index', 'noindex' ) ) ) {
728 $arr['index'] = $var;
729 } elseif ( in_array( $var, array( 'follow', 'nofollow' ) ) ) {
730 $arr['follow'] = $var;
731 }
732 }
733
734 return $arr;
735 }
736
737 /**
738 * If this request is a redirect view, send "redirected from" subtitle to
739 * $wgOut. Returns true if the header was needed, false if this is not a
740 * redirect view. Handles both local and remote redirects.
741 *
742 * @return boolean
743 */
744 public function showRedirectedFromHeader() {
745 global $wgOut, $wgRequest, $wgRedirectSources;
746
747 $rdfrom = $wgRequest->getVal( 'rdfrom' );
748
749 if ( isset( $this->mRedirectedFrom ) ) {
750 // This is an internally redirected page view.
751 // We'll need a backlink to the source page for navigation.
752 if ( wfRunHooks( 'ArticleViewRedirect', array( &$this ) ) ) {
753 $redir = Linker::link(
754 $this->mRedirectedFrom,
755 null,
756 array(),
757 array( 'redirect' => 'no' ),
758 array( 'known', 'noclasses' )
759 );
760
761 $s = wfMsgExt( 'redirectedfrom', array( 'parseinline', 'replaceafter' ), $redir );
762 $wgOut->setSubtitle( $s );
763
764 // Set the fragment if one was specified in the redirect
765 if ( strval( $this->getTitle()->getFragment() ) != '' ) {
766 $fragment = Xml::escapeJsString( $this->getTitle()->getFragmentForURL() );
767 $wgOut->addInlineScript( "redirectToFragment(\"$fragment\");" );
768 }
769
770 // Add a <link rel="canonical"> tag
771 $wgOut->addLink( array( 'rel' => 'canonical',
772 'href' => $this->getTitle()->getLocalURL() )
773 );
774
775 return true;
776 }
777 } elseif ( $rdfrom ) {
778 // This is an externally redirected view, from some other wiki.
779 // If it was reported from a trusted site, supply a backlink.
780 if ( $wgRedirectSources && preg_match( $wgRedirectSources, $rdfrom ) ) {
781 $redir = Linker::makeExternalLink( $rdfrom, $rdfrom );
782 $s = wfMsgExt( 'redirectedfrom', array( 'parseinline', 'replaceafter' ), $redir );
783 $wgOut->setSubtitle( $s );
784
785 return true;
786 }
787 }
788
789 return false;
790 }
791
792 /**
793 * Show a header specific to the namespace currently being viewed, like
794 * [[MediaWiki:Talkpagetext]]. For Article::view().
795 */
796 public function showNamespaceHeader() {
797 global $wgOut;
798
799 if ( $this->getTitle()->isTalkPage() ) {
800 if ( !wfMessage( 'talkpageheader' )->isDisabled() ) {
801 $wgOut->wrapWikiMsg( "<div class=\"mw-talkpageheader\">\n$1\n</div>", array( 'talkpageheader' ) );
802 }
803 }
804 }
805
806 /**
807 * Show the footer section of an ordinary page view
808 */
809 public function showViewFooter() {
810 global $wgOut, $wgUseTrackbacks;
811
812 # check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page
813 if ( $this->getTitle()->getNamespace() == NS_USER_TALK && IP::isValid( $this->getTitle()->getText() ) ) {
814 $wgOut->addWikiMsg( 'anontalkpagetext' );
815 }
816
817 # If we have been passed an &rcid= parameter, we want to give the user a
818 # chance to mark this new article as patrolled.
819 $this->showPatrolFooter();
820
821 # Trackbacks
822 if ( $wgUseTrackbacks ) {
823 $this->addTrackbacks();
824 }
825
826 wfRunHooks( 'ArticleViewFooter', array( $this ) );
827
828 }
829
830 /**
831 * If patrol is possible, output a patrol UI box. This is called from the
832 * footer section of ordinary page views. If patrol is not possible or not
833 * desired, does nothing.
834 */
835 public function showPatrolFooter() {
836 global $wgOut, $wgRequest, $wgUser;
837
838 $rcid = $wgRequest->getVal( 'rcid' );
839
840 if ( !$rcid || !$this->getTitle()->quickUserCan( 'patrol' ) ) {
841 return;
842 }
843
844 $token = $wgUser->editToken( $rcid );
845 $wgOut->preventClickjacking();
846
847 $wgOut->addHTML(
848 "<div class='patrollink'>" .
849 wfMsgHtml(
850 'markaspatrolledlink',
851 Linker::link(
852 $this->getTitle(),
853 wfMsgHtml( 'markaspatrolledtext' ),
854 array(),
855 array(
856 'action' => 'markpatrolled',
857 'rcid' => $rcid,
858 'token' => $token,
859 ),
860 array( 'known', 'noclasses' )
861 )
862 ) .
863 '</div>'
864 );
865 }
866
867 /**
868 * Show the error text for a missing article. For articles in the MediaWiki
869 * namespace, show the default message text. To be called from Article::view().
870 */
871 public function showMissingArticle() {
872 global $wgOut, $wgRequest, $wgUser;
873
874 # Show info in user (talk) namespace. Does the user exist? Is he blocked?
875 if ( $this->getTitle()->getNamespace() == NS_USER || $this->getTitle()->getNamespace() == NS_USER_TALK ) {
876 $parts = explode( '/', $this->getTitle()->getText() );
877 $rootPart = $parts[0];
878 $user = User::newFromName( $rootPart, false /* allow IP users*/ );
879 $ip = User::isIP( $rootPart );
880
881 if ( !$user->isLoggedIn() && !$ip ) { # User does not exist
882 $wgOut->wrapWikiMsg( "<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>",
883 array( 'userpage-userdoesnotexist-view', wfEscapeWikiText( $rootPart ) ) );
884 } elseif ( $user->isBlocked() ) { # Show log extract if the user is currently blocked
885 LogEventsList::showLogExtract(
886 $wgOut,
887 'block',
888 $user->getUserPage()->getPrefixedText(),
889 '',
890 array(
891 'lim' => 1,
892 'showIfEmpty' => false,
893 'msgKey' => array(
894 'blocked-notice-logextract',
895 $user->getName() # Support GENDER in notice
896 )
897 )
898 );
899 }
900 }
901
902 wfRunHooks( 'ShowMissingArticle', array( $this ) );
903
904 # Show delete and move logs
905 LogEventsList::showLogExtract( $wgOut, array( 'delete', 'move' ), $this->getTitle()->getPrefixedText(), '',
906 array( 'lim' => 10,
907 'conds' => array( "log_action != 'revision'" ),
908 'showIfEmpty' => false,
909 'msgKey' => array( 'moveddeleted-notice' ) )
910 );
911
912 # Show error message
913 $oldid = $this->getOldID();
914 if ( $oldid ) {
915 $text = wfMsgNoTrans( 'missing-article',
916 $this->getTitle()->getPrefixedText(),
917 wfMsgNoTrans( 'missingarticle-rev', $oldid ) );
918 } elseif ( $this->getTitle()->getNamespace() === NS_MEDIAWIKI ) {
919 // Use the default message text
920 $text = $this->getTitle()->getDefaultMessageText();
921 } else {
922 $createErrors = $this->getTitle()->getUserPermissionsErrors( 'create', $wgUser );
923 $editErrors = $this->getTitle()->getUserPermissionsErrors( 'edit', $wgUser );
924 $errors = array_merge( $createErrors, $editErrors );
925
926 if ( !count( $errors ) ) {
927 $text = wfMsgNoTrans( 'noarticletext' );
928 } else {
929 $text = wfMsgNoTrans( 'noarticletext-nopermission' );
930 }
931 }
932 $text = "<div class='noarticletext'>\n$text\n</div>";
933
934 if ( !$this->mPage->hasViewableContent() ) {
935 // If there's no backing content, send a 404 Not Found
936 // for better machine handling of broken links.
937 $wgRequest->response()->header( "HTTP/1.1 404 Not Found" );
938 }
939
940 $wgOut->addWikiText( $text );
941 }
942
943 /**
944 * If the revision requested for view is deleted, check permissions.
945 * Send either an error message or a warning header to $wgOut.
946 *
947 * @return boolean true if the view is allowed, false if not.
948 */
949 public function showDeletedRevisionHeader() {
950 global $wgOut, $wgRequest;
951
952 if ( !$this->mRevision->isDeleted( Revision::DELETED_TEXT ) ) {
953 // Not deleted
954 return true;
955 }
956
957 // If the user is not allowed to see it...
958 if ( !$this->mRevision->userCan( Revision::DELETED_TEXT ) ) {
959 $wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
960 'rev-deleted-text-permission' );
961
962 return false;
963 // If the user needs to confirm that they want to see it...
964 } elseif ( $wgRequest->getInt( 'unhide' ) != 1 ) {
965 # Give explanation and add a link to view the revision...
966 $oldid = intval( $this->getOldID() );
967 $link = $this->getTitle()->getFullUrl( "oldid={$oldid}&unhide=1" );
968 $msg = $this->mRevision->isDeleted( Revision::DELETED_RESTRICTED ) ?
969 'rev-suppressed-text-unhide' : 'rev-deleted-text-unhide';
970 $wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
971 array( $msg, $link ) );
972
973 return false;
974 // We are allowed to see...
975 } else {
976 $msg = $this->mRevision->isDeleted( Revision::DELETED_RESTRICTED ) ?
977 'rev-suppressed-text-view' : 'rev-deleted-text-view';
978 $wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n", $msg );
979
980 return true;
981 }
982 }
983
984 /**
985 * Execute the uncached parse for action=view
986 */
987 public function doViewParse() {
988 global $wgOut;
989
990 $oldid = $this->getOldID();
991 $parserOptions = $this->mPage->getParserOptions();
992
993 # Render printable version, use printable version cache
994 $parserOptions->setIsPrintable( $wgOut->isPrintable() );
995
996 # Don't show section-edit links on old revisions... this way lies madness.
997 if ( !$this->isCurrent() || $wgOut->isPrintable() || !$this->getTitle()->quickUserCan( 'edit' ) ) {
998 $parserOptions->setEditSection( false );
999 }
1000
1001 $useParserCache = $this->useParserCache( $oldid );
1002 $this->outputWikiText( $this->getContent(), $useParserCache, $parserOptions );
1003
1004 return true;
1005 }
1006
1007 /**
1008 * Try to fetch an expired entry from the parser cache. If it is present,
1009 * output it and return true. If it is not present, output nothing and
1010 * return false. This is used as a callback function for
1011 * PoolCounter::executeProtected().
1012 *
1013 * @return boolean
1014 */
1015 public function tryDirtyCache() {
1016 global $wgOut;
1017 $parserCache = ParserCache::singleton();
1018 $options = $this->mPage->getParserOptions();
1019
1020 if ( $wgOut->isPrintable() ) {
1021 $options->setIsPrintable( true );
1022 $options->setEditSection( false );
1023 }
1024
1025 $output = $parserCache->getDirty( $this, $options );
1026
1027 if ( $output ) {
1028 wfDebug( __METHOD__ . ": sending dirty output\n" );
1029 wfDebugLog( 'dirty', "dirty output " . $parserCache->getKey( $this, $options ) . "\n" );
1030 $wgOut->setSquidMaxage( 0 );
1031 $this->mParserOutput = $output;
1032 $wgOut->addParserOutput( $output );
1033 $wgOut->addHTML( "<!-- parser cache is expired, sending anyway due to pool overload-->\n" );
1034
1035 return true;
1036 } else {
1037 wfDebugLog( 'dirty', "dirty missing\n" );
1038 wfDebug( __METHOD__ . ": no dirty cache\n" );
1039
1040 return false;
1041 }
1042 }
1043
1044 /**
1045 * View redirect
1046 *
1047 * @param $target Title|Array of destination(s) to redirect
1048 * @param $appendSubtitle Boolean [optional]
1049 * @param $forceKnown Boolean: should the image be shown as a bluelink regardless of existence?
1050 * @return string containing HMTL with redirect link
1051 */
1052 public function viewRedirect( $target, $appendSubtitle = true, $forceKnown = false ) {
1053 global $wgOut, $wgStylePath;
1054
1055 if ( !is_array( $target ) ) {
1056 $target = array( $target );
1057 }
1058
1059 $lang = $this->getTitle()->getPageLanguage();
1060 $imageDir = $lang->getDir();
1061
1062 if ( $appendSubtitle ) {
1063 $wgOut->appendSubtitle( wfMsgHtml( 'redirectpagesub' ) );
1064 }
1065
1066 // the loop prepends the arrow image before the link, so the first case needs to be outside
1067 $title = array_shift( $target );
1068
1069 if ( $forceKnown ) {
1070 $link = Linker::linkKnown( $title, htmlspecialchars( $title->getFullText() ) );
1071 } else {
1072 $link = Linker::link( $title, htmlspecialchars( $title->getFullText() ) );
1073 }
1074
1075 $nextRedirect = $wgStylePath . '/common/images/nextredirect' . $imageDir . '.png';
1076 $alt = $lang->isRTL() ? '←' : '→';
1077 // Automatically append redirect=no to each link, since most of them are redirect pages themselves.
1078 foreach ( $target as $rt ) {
1079 $link .= Html::element( 'img', array( 'src' => $nextRedirect, 'alt' => $alt ) );
1080 if ( $forceKnown ) {
1081 $link .= Linker::linkKnown( $rt, htmlspecialchars( $rt->getFullText(), array(), array( 'redirect' => 'no' ) ) );
1082 } else {
1083 $link .= Linker::link( $rt, htmlspecialchars( $rt->getFullText() ), array(), array( 'redirect' => 'no' ) );
1084 }
1085 }
1086
1087 $imageUrl = $wgStylePath . '/common/images/redirect' . $imageDir . '.png';
1088 return '<div class="redirectMsg">' .
1089 Html::element( 'img', array( 'src' => $imageUrl, 'alt' => '#REDIRECT' ) ) .
1090 '<span class="redirectText">' . $link . '</span></div>';
1091 }
1092
1093 /**
1094 * Builds trackback links for article display if $wgUseTrackbacks is set to true
1095 */
1096 public function addTrackbacks() {
1097 global $wgOut;
1098
1099 $dbr = wfGetDB( DB_SLAVE );
1100 $tbs = $dbr->select( 'trackbacks',
1101 array( 'tb_id', 'tb_title', 'tb_url', 'tb_ex', 'tb_name' ),
1102 array( 'tb_page' => $this->mPage->getID() )
1103 );
1104
1105 if ( !$dbr->numRows( $tbs ) ) {
1106 return;
1107 }
1108
1109 $wgOut->preventClickjacking();
1110
1111 $tbtext = "";
1112 foreach ( $tbs as $o ) {
1113 $rmvtxt = "";
1114
1115 if ( $this->getContext()->getUser()->isAllowed( 'trackback' ) ) {
1116 $delurl = $this->getTitle()->getFullURL( "action=deletetrackback&tbid=" .
1117 $o->tb_id . "&token=" . urlencode( $this->getContext()->getUser()->editToken() ) );
1118 $rmvtxt = wfMsg( 'trackbackremove', htmlspecialchars( $delurl ) );
1119 }
1120
1121 $tbtext .= "\n";
1122 $tbtext .= wfMsgNoTrans( strlen( $o->tb_ex ) ? 'trackbackexcerpt' : 'trackback',
1123 $o->tb_title,
1124 $o->tb_url,
1125 $o->tb_ex,
1126 $o->tb_name,
1127 $rmvtxt );
1128 }
1129
1130 $wgOut->wrapWikiMsg( "<div id='mw_trackbacks'>\n$1\n</div>\n", array( 'trackbackbox', $tbtext ) );
1131 }
1132
1133 /**
1134 * Removes trackback record for current article from trackbacks table
1135 * @deprecated since 1.18
1136 */
1137 public function deletetrackback() {
1138 return Action::factory( 'deletetrackback', $this )->show();
1139 }
1140
1141 /**
1142 * Handle action=render
1143 */
1144
1145 public function render() {
1146 global $wgOut;
1147
1148 $wgOut->setArticleBodyOnly( true );
1149 $this->view();
1150 }
1151
1152 /**
1153 * Handle action=purge
1154 */
1155 public function purge() {
1156 return Action::factory( 'purge', $this )->show();
1157 }
1158
1159 /**
1160 * Mark this particular edit/page as patrolled
1161 * @deprecated since 1.18
1162 */
1163 public function markpatrolled() {
1164 Action::factory( 'markpatrolled', $this )->show();
1165 }
1166
1167 /**
1168 * User-interface handler for the "watch" action.
1169 * Requires Request to pass a token as of 1.18.
1170 * @deprecated since 1.18
1171 */
1172 public function watch() {
1173 Action::factory( 'watch', $this )->show();
1174 }
1175
1176 /**
1177 * Add this page to $wgUser's watchlist
1178 *
1179 * This is safe to be called multiple times
1180 *
1181 * @return bool true on successful watch operation
1182 * @deprecated since 1.18
1183 */
1184 public function doWatch() {
1185 global $wgUser;
1186 return WatchAction::doWatch( $this->getTitle(), $wgUser );
1187 }
1188
1189 /**
1190 * User interface handler for the "unwatch" action.
1191 * Requires Request to pass a token as of 1.18.
1192 * @deprecated since 1.18
1193 */
1194 public function unwatch() {
1195 Action::factory( 'unwatch', $this )->show();
1196 }
1197
1198 /**
1199 * Stop watching a page
1200 * @return bool true on successful unwatch
1201 * @deprecated since 1.18
1202 */
1203 public function doUnwatch() {
1204 global $wgUser;
1205 return WatchAction::doUnwatch( $this->getTitle(), $wgUser );
1206 }
1207
1208 /**
1209 * action=protect handler
1210 */
1211 public function protect() {
1212 $form = new ProtectionForm( $this );
1213 $form->execute();
1214 }
1215
1216 /**
1217 * action=unprotect handler (alias)
1218 */
1219 public function unprotect() {
1220 $this->protect();
1221 }
1222
1223 /**
1224 * Info about this page
1225 * Called for ?action=info when $wgAllowPageInfo is on.
1226 */
1227 public function info() {
1228 Action::factory( 'info', $this )->show();
1229 }
1230
1231 /**
1232 * Overriden by ImagePage class, only present here to avoid a fatal error
1233 * Called for ?action=revert
1234 */
1235 public function revert() {
1236 Action::factory( 'revert', $this )->show();
1237 }
1238
1239 /**
1240 * User interface for rollback operations
1241 */
1242 public function rollback() {
1243 Action::factory( 'rollback', $this )->show();
1244 }
1245
1246 /**
1247 * Output a redirect back to the article.
1248 * This is typically used after an edit.
1249 *
1250 * @deprecated in 1.18; call $wgOut->redirect() directly
1251 * @param $noRedir Boolean: add redirect=no
1252 * @param $sectionAnchor String: section to redirect to, including "#"
1253 * @param $extraQuery String: extra query params
1254 */
1255 public function doRedirect( $noRedir = false, $sectionAnchor = '', $extraQuery = '' ) {
1256 wfDeprecated( __METHOD__ );
1257 global $wgOut;
1258
1259 if ( $noRedir ) {
1260 $query = 'redirect=no';
1261 if ( $extraQuery )
1262 $query .= "&$extraQuery";
1263 } else {
1264 $query = $extraQuery;
1265 }
1266
1267 $wgOut->redirect( $this->getTitle()->getFullURL( $query ) . $sectionAnchor );
1268 }
1269
1270 /**
1271 * UI entry point for page deletion
1272 */
1273 public function delete() {
1274 global $wgOut, $wgRequest;
1275
1276 $confirm = $wgRequest->wasPosted() &&
1277 $this->getContext()->getUser()->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) );
1278
1279 $this->DeleteReasonList = $wgRequest->getText( 'wpDeleteReasonList', 'other' );
1280 $this->DeleteReason = $wgRequest->getText( 'wpReason' );
1281
1282 $reason = $this->DeleteReasonList;
1283
1284 if ( $reason != 'other' && $this->DeleteReason != '' ) {
1285 // Entry from drop down menu + additional comment
1286 $reason .= wfMsgForContent( 'colon-separator' ) . $this->DeleteReason;
1287 } elseif ( $reason == 'other' ) {
1288 $reason = $this->DeleteReason;
1289 }
1290
1291 # Flag to hide all contents of the archived revisions
1292 $suppress = $wgRequest->getVal( 'wpSuppress' ) && $this->getContext()->getUser()->isAllowed( 'suppressrevision' );
1293
1294 # This code desperately needs to be totally rewritten
1295
1296 # Read-only check...
1297 if ( wfReadOnly() ) {
1298 $wgOut->readOnlyPage();
1299
1300 return;
1301 }
1302
1303 # Check permissions
1304 $permission_errors = $this->getTitle()->getUserPermissionsErrors( 'delete', $this->getContext()->getUser() );
1305
1306 if ( count( $permission_errors ) > 0 ) {
1307 $wgOut->showPermissionsErrorPage( $permission_errors );
1308
1309 return;
1310 }
1311
1312 $wgOut->setPagetitle( wfMsg( 'delete-confirm', $this->getTitle()->getPrefixedText() ) );
1313
1314 # Better double-check that it hasn't been deleted yet!
1315 $dbw = wfGetDB( DB_MASTER );
1316 $conds = $this->getTitle()->pageCond();
1317 $latest = $dbw->selectField( 'page', 'page_latest', $conds, __METHOD__ );
1318 if ( $latest === false ) {
1319 $wgOut->showFatalError(
1320 Html::rawElement(
1321 'div',
1322 array( 'class' => 'error mw-error-cannotdelete' ),
1323 wfMsgExt( 'cannotdelete', array( 'parse' ),
1324 wfEscapeWikiText( $this->getTitle()->getPrefixedText() ) )
1325 )
1326 );
1327 $wgOut->addHTML( Xml::element( 'h2', null, LogPage::logName( 'delete' ) ) );
1328 LogEventsList::showLogExtract(
1329 $wgOut,
1330 'delete',
1331 $this->getTitle()->getPrefixedText()
1332 );
1333
1334 return;
1335 }
1336
1337 # Hack for big sites
1338 $bigHistory = $this->mPage->isBigDeletion();
1339 if ( $bigHistory && !$this->getTitle()->userCan( 'bigdelete' ) ) {
1340 global $wgLang, $wgDeleteRevisionsLimit;
1341
1342 $wgOut->wrapWikiMsg( "<div class='error'>\n$1\n</div>\n",
1343 array( 'delete-toobig', $wgLang->formatNum( $wgDeleteRevisionsLimit ) ) );
1344
1345 return;
1346 }
1347
1348 if ( $confirm ) {
1349 $this->doDelete( $reason, $suppress );
1350
1351 if ( $wgRequest->getCheck( 'wpWatch' ) && $this->getContext()->getUser()->isLoggedIn() ) {
1352 $this->doWatch();
1353 } elseif ( $this->getTitle()->userIsWatching() ) {
1354 $this->doUnwatch();
1355 }
1356
1357 return;
1358 }
1359
1360 // Generate deletion reason
1361 $hasHistory = false;
1362 if ( !$reason ) {
1363 $reason = $this->generateReason( $hasHistory );
1364 }
1365
1366 // If the page has a history, insert a warning
1367 if ( $hasHistory && !$confirm ) {
1368 global $wgLang;
1369
1370 $revisions = $this->mPage->estimateRevisionCount();
1371 // @todo FIXME: i18n issue/patchwork message
1372 $wgOut->addHTML( '<strong class="mw-delete-warning-revisions">' .
1373 wfMsgExt( 'historywarning', array( 'parseinline' ), $wgLang->formatNum( $revisions ) ) .
1374 wfMsgHtml( 'word-separator' ) . Linker::link( $this->getTitle(),
1375 wfMsgHtml( 'history' ),
1376 array( 'rel' => 'archives' ),
1377 array( 'action' => 'history' ) ) .
1378 '</strong>'
1379 );
1380
1381 if ( $bigHistory ) {
1382 global $wgDeleteRevisionsLimit;
1383 $wgOut->wrapWikiMsg( "<div class='error'>\n$1\n</div>\n",
1384 array( 'delete-warning-toobig', $wgLang->formatNum( $wgDeleteRevisionsLimit ) ) );
1385 }
1386 }
1387
1388 return $this->confirmDelete( $reason );
1389 }
1390
1391 /**
1392 * Output deletion confirmation dialog
1393 * @todo FIXME: Move to another file?
1394 * @param $reason String: prefilled reason
1395 */
1396 public function confirmDelete( $reason ) {
1397 global $wgOut;
1398
1399 wfDebug( "Article::confirmDelete\n" );
1400
1401 $deleteBackLink = Linker::linkKnown( $this->getTitle() );
1402 $wgOut->setSubtitle( wfMsgHtml( 'delete-backlink', $deleteBackLink ) );
1403 $wgOut->setRobotPolicy( 'noindex,nofollow' );
1404 $wgOut->addWikiMsg( 'confirmdeletetext' );
1405
1406 wfRunHooks( 'ArticleConfirmDelete', array( $this, $wgOut, &$reason ) );
1407
1408 if ( $this->getContext()->getUser()->isAllowed( 'suppressrevision' ) ) {
1409 $suppress = "<tr id=\"wpDeleteSuppressRow\">
1410 <td></td>
1411 <td class='mw-input'><strong>" .
1412 Xml::checkLabel( wfMsg( 'revdelete-suppress' ),
1413 'wpSuppress', 'wpSuppress', false, array( 'tabindex' => '4' ) ) .
1414 "</strong></td>
1415 </tr>";
1416 } else {
1417 $suppress = '';
1418 }
1419 $checkWatch = $this->getContext()->getUser()->getBoolOption( 'watchdeletion' ) || $this->getTitle()->userIsWatching();
1420
1421 $form = Xml::openElement( 'form', array( 'method' => 'post',
1422 'action' => $this->getTitle()->getLocalURL( 'action=delete' ), 'id' => 'deleteconfirm' ) ) .
1423 Xml::openElement( 'fieldset', array( 'id' => 'mw-delete-table' ) ) .
1424 Xml::tags( 'legend', null, wfMsgExt( 'delete-legend', array( 'parsemag', 'escapenoentities' ) ) ) .
1425 Xml::openElement( 'table', array( 'id' => 'mw-deleteconfirm-table' ) ) .
1426 "<tr id=\"wpDeleteReasonListRow\">
1427 <td class='mw-label'>" .
1428 Xml::label( wfMsg( 'deletecomment' ), 'wpDeleteReasonList' ) .
1429 "</td>
1430 <td class='mw-input'>" .
1431 Xml::listDropDown( 'wpDeleteReasonList',
1432 wfMsgForContent( 'deletereason-dropdown' ),
1433 wfMsgForContent( 'deletereasonotherlist' ), '', 'wpReasonDropDown', 1 ) .
1434 "</td>
1435 </tr>
1436 <tr id=\"wpDeleteReasonRow\">
1437 <td class='mw-label'>" .
1438 Xml::label( wfMsg( 'deleteotherreason' ), 'wpReason' ) .
1439 "</td>
1440 <td class='mw-input'>" .
1441 Html::input( 'wpReason', $reason, 'text', array(
1442 'size' => '60',
1443 'maxlength' => '255',
1444 'tabindex' => '2',
1445 'id' => 'wpReason',
1446 'autofocus'
1447 ) ) .
1448 "</td>
1449 </tr>";
1450
1451 # Disallow watching if user is not logged in
1452 if ( $this->getContext()->getUser()->isLoggedIn() ) {
1453 $form .= "
1454 <tr>
1455 <td></td>
1456 <td class='mw-input'>" .
1457 Xml::checkLabel( wfMsg( 'watchthis' ),
1458 'wpWatch', 'wpWatch', $checkWatch, array( 'tabindex' => '3' ) ) .
1459 "</td>
1460 </tr>";
1461 }
1462
1463 $form .= "
1464 $suppress
1465 <tr>
1466 <td></td>
1467 <td class='mw-submit'>" .
1468 Xml::submitButton( wfMsg( 'deletepage' ),
1469 array( 'name' => 'wpConfirmB', 'id' => 'wpConfirmB', 'tabindex' => '5' ) ) .
1470 "</td>
1471 </tr>" .
1472 Xml::closeElement( 'table' ) .
1473 Xml::closeElement( 'fieldset' ) .
1474 Html::hidden( 'wpEditToken', $this->getContext()->getUser()->editToken() ) .
1475 Xml::closeElement( 'form' );
1476
1477 if ( $this->getContext()->getUser()->isAllowed( 'editinterface' ) ) {
1478 $title = Title::makeTitle( NS_MEDIAWIKI, 'Deletereason-dropdown' );
1479 $link = Linker::link(
1480 $title,
1481 wfMsgHtml( 'delete-edit-reasonlist' ),
1482 array(),
1483 array( 'action' => 'edit' )
1484 );
1485 $form .= '<p class="mw-delete-editreasons">' . $link . '</p>';
1486 }
1487
1488 $wgOut->addHTML( $form );
1489 $wgOut->addHTML( Xml::element( 'h2', null, LogPage::logName( 'delete' ) ) );
1490 LogEventsList::showLogExtract( $wgOut, 'delete',
1491 $this->getTitle()->getPrefixedText()
1492 );
1493 }
1494
1495 /**
1496 * Perform a deletion and output success or failure messages
1497 */
1498 public function doDelete( $reason, $suppress = false ) {
1499 global $wgOut;
1500
1501 $id = $this->getTitle()->getArticleID( Title::GAID_FOR_UPDATE );
1502
1503 $error = '';
1504 if ( $this->mPage->doDeleteArticle( $reason, $suppress, $id, $error ) ) {
1505 $deleted = $this->getTitle()->getPrefixedText();
1506
1507 $wgOut->setPagetitle( wfMsg( 'actioncomplete' ) );
1508 $wgOut->setRobotPolicy( 'noindex,nofollow' );
1509
1510 $loglink = '[[Special:Log/delete|' . wfMsgNoTrans( 'deletionlog' ) . ']]';
1511
1512 $wgOut->addWikiMsg( 'deletedtext', wfEscapeWikiText( $deleted ), $loglink );
1513 $wgOut->returnToMain( false );
1514 } else {
1515 if ( $error == '' ) {
1516 $wgOut->showFatalError(
1517 Html::rawElement(
1518 'div',
1519 array( 'class' => 'error mw-error-cannotdelete' ),
1520 wfMsgExt( 'cannotdelete', array( 'parse' ),
1521 wfEscapeWikiText( $this->getTitle()->getPrefixedText() ) )
1522 )
1523 );
1524
1525 $wgOut->addHTML( Xml::element( 'h2', null, LogPage::logName( 'delete' ) ) );
1526
1527 LogEventsList::showLogExtract(
1528 $wgOut,
1529 'delete',
1530 $this->getTitle()->getPrefixedText()
1531 );
1532 } else {
1533 $wgOut->showFatalError( $error );
1534 }
1535 }
1536 }
1537
1538 /**
1539 * Generate the navigation links when browsing through an article revisions
1540 * It shows the information as:
1541 * Revision as of \<date\>; view current revision
1542 * \<- Previous version | Next Version -\>
1543 *
1544 * @param $oldid String: revision ID of this article revision
1545 */
1546 public function setOldSubtitle( $oldid = 0 ) {
1547 global $wgLang, $wgOut, $wgUser, $wgRequest;
1548
1549 if ( !wfRunHooks( 'DisplayOldSubtitle', array( &$this, &$oldid ) ) ) {
1550 return;
1551 }
1552
1553 $unhide = $wgRequest->getInt( 'unhide' ) == 1;
1554
1555 # Cascade unhide param in links for easy deletion browsing
1556 $extraParams = array();
1557 if ( $wgRequest->getVal( 'unhide' ) ) {
1558 $extraParams['unhide'] = 1;
1559 }
1560
1561 $revision = Revision::newFromId( $oldid );
1562 $timestamp = $revision->getTimestamp();
1563
1564 $current = ( $oldid == $this->mPage->getLatest() );
1565 $td = $wgLang->timeanddate( $timestamp, true );
1566 $tddate = $wgLang->date( $timestamp, true );
1567 $tdtime = $wgLang->time( $timestamp, true );
1568
1569 $lnk = $current
1570 ? wfMsgHtml( 'currentrevisionlink' )
1571 : Linker::link(
1572 $this->getTitle(),
1573 wfMsgHtml( 'currentrevisionlink' ),
1574 array(),
1575 $extraParams,
1576 array( 'known', 'noclasses' )
1577 );
1578 $curdiff = $current
1579 ? wfMsgHtml( 'diff' )
1580 : Linker::link(
1581 $this->getTitle(),
1582 wfMsgHtml( 'diff' ),
1583 array(),
1584 array(
1585 'diff' => 'cur',
1586 'oldid' => $oldid
1587 ) + $extraParams,
1588 array( 'known', 'noclasses' )
1589 );
1590 $prev = $this->getTitle()->getPreviousRevisionID( $oldid ) ;
1591 $prevlink = $prev
1592 ? Linker::link(
1593 $this->getTitle(),
1594 wfMsgHtml( 'previousrevision' ),
1595 array(),
1596 array(
1597 'direction' => 'prev',
1598 'oldid' => $oldid
1599 ) + $extraParams,
1600 array( 'known', 'noclasses' )
1601 )
1602 : wfMsgHtml( 'previousrevision' );
1603 $prevdiff = $prev
1604 ? Linker::link(
1605 $this->getTitle(),
1606 wfMsgHtml( 'diff' ),
1607 array(),
1608 array(
1609 'diff' => 'prev',
1610 'oldid' => $oldid
1611 ) + $extraParams,
1612 array( 'known', 'noclasses' )
1613 )
1614 : wfMsgHtml( 'diff' );
1615 $nextlink = $current
1616 ? wfMsgHtml( 'nextrevision' )
1617 : Linker::link(
1618 $this->getTitle(),
1619 wfMsgHtml( 'nextrevision' ),
1620 array(),
1621 array(
1622 'direction' => 'next',
1623 'oldid' => $oldid
1624 ) + $extraParams,
1625 array( 'known', 'noclasses' )
1626 );
1627 $nextdiff = $current
1628 ? wfMsgHtml( 'diff' )
1629 : Linker::link(
1630 $this->getTitle(),
1631 wfMsgHtml( 'diff' ),
1632 array(),
1633 array(
1634 'diff' => 'next',
1635 'oldid' => $oldid
1636 ) + $extraParams,
1637 array( 'known', 'noclasses' )
1638 );
1639
1640 $cdel = '';
1641
1642 // User can delete revisions or view deleted revisions...
1643 $canHide = $wgUser->isAllowed( 'deleterevision' );
1644 if ( $canHide || ( $revision->getVisibility() && $wgUser->isAllowed( 'deletedhistory' ) ) ) {
1645 if ( !$revision->userCan( Revision::DELETED_RESTRICTED ) ) {
1646 $cdel = Linker::revDeleteLinkDisabled( $canHide ); // rev was hidden from Sysops
1647 } else {
1648 $query = array(
1649 'type' => 'revision',
1650 'target' => $this->getTitle()->getPrefixedDbkey(),
1651 'ids' => $oldid
1652 );
1653 $cdel = Linker::revDeleteLink( $query, $revision->isDeleted( File::DELETED_RESTRICTED ), $canHide );
1654 }
1655 $cdel .= ' ';
1656 }
1657
1658 # Show user links if allowed to see them. If hidden, then show them only if requested...
1659 $userlinks = Linker::revUserTools( $revision, !$unhide );
1660
1661 $infomsg = $current && !wfMessage( 'revision-info-current' )->isDisabled()
1662 ? 'revision-info-current'
1663 : 'revision-info';
1664
1665 $r = "\n\t\t\t\t<div id=\"mw-{$infomsg}\">" .
1666 wfMsgExt(
1667 $infomsg,
1668 array( 'parseinline', 'replaceafter' ),
1669 $td,
1670 $userlinks,
1671 $revision->getID(),
1672 $tddate,
1673 $tdtime,
1674 $revision->getUser()
1675 ) .
1676 "</div>\n" .
1677 "\n\t\t\t\t<div id=\"mw-revision-nav\">" . $cdel . wfMsgExt( 'revision-nav', array( 'escapenoentities', 'parsemag', 'replaceafter' ),
1678 $prevdiff, $prevlink, $lnk, $curdiff, $nextlink, $nextdiff ) . "</div>\n\t\t\t";
1679
1680 $wgOut->setSubtitle( $r );
1681 }
1682
1683 /* Caching functions */
1684
1685 /**
1686 * checkLastModified returns true if it has taken care of all
1687 * output to the client that is necessary for this request.
1688 * (that is, it has sent a cached version of the page)
1689 *
1690 * @return boolean true if cached version send, false otherwise
1691 */
1692 protected function tryFileCache() {
1693 static $called = false;
1694
1695 if ( $called ) {
1696 wfDebug( "Article::tryFileCache(): called twice!?\n" );
1697 return false;
1698 }
1699
1700 $called = true;
1701 if ( $this->isFileCacheable() ) {
1702 $cache = new HTMLFileCache( $this->getTitle() );
1703 if ( $cache->isFileCacheGood( $this->mPage->getTouched() ) ) {
1704 wfDebug( "Article::tryFileCache(): about to load file\n" );
1705 $cache->loadFromFileCache();
1706 return true;
1707 } else {
1708 wfDebug( "Article::tryFileCache(): starting buffer\n" );
1709 ob_start( array( &$cache, 'saveToFileCache' ) );
1710 }
1711 } else {
1712 wfDebug( "Article::tryFileCache(): not cacheable\n" );
1713 }
1714
1715 return false;
1716 }
1717
1718 /**
1719 * Check if the page can be cached
1720 * @return bool
1721 */
1722 public function isFileCacheable() {
1723 $cacheable = false;
1724
1725 if ( HTMLFileCache::useFileCache() ) {
1726 $cacheable = $this->mPage->getID() && !$this->mRedirectedFrom && !$this->getTitle()->isRedirect();
1727 // Extension may have reason to disable file caching on some pages.
1728 if ( $cacheable ) {
1729 $cacheable = wfRunHooks( 'IsFileCacheable', array( &$this ) );
1730 }
1731 }
1732
1733 return $cacheable;
1734 }
1735
1736 /**#@-*/
1737
1738 /**
1739 * Add the primary page-view wikitext to the output buffer
1740 * Saves the text into the parser cache if possible.
1741 * Updates templatelinks if it is out of date.
1742 *
1743 * @param $text String
1744 * @param $cache Boolean
1745 * @param $parserOptions mixed ParserOptions object, or boolean false
1746 */
1747 public function outputWikiText( $text, $cache = true, $parserOptions = false ) {
1748 global $wgOut;
1749
1750 $this->mParserOutput = $this->getOutputFromWikitext( $text, $cache, $parserOptions );
1751
1752 $this->doCascadeProtectionUpdates( $this->mParserOutput );
1753
1754 $wgOut->addParserOutput( $this->mParserOutput );
1755 }
1756
1757 /**
1758 * Lightweight method to get the parser output for a page, checking the parser cache
1759 * and so on. Doesn't consider most of the stuff that WikiPage::view is forced to
1760 * consider, so it's not appropriate to use there.
1761 *
1762 * @since 1.16 (r52326) for LiquidThreads
1763 *
1764 * @param $oldid mixed integer Revision ID or null
1765 * @param $user User The relevant user
1766 * @return ParserOutput or false if the given revsion ID is not found
1767 */
1768 public function getParserOutput( $oldid = null, User $user = null ) {
1769 global $wgEnableParserCache, $wgUser;
1770 $user = is_null( $user ) ? $wgUser : $user;
1771
1772 wfProfileIn( __METHOD__ );
1773 // Should the parser cache be used?
1774 $useParserCache = $wgEnableParserCache &&
1775 $user->getStubThreshold() == 0 &&
1776 $this->mPage->exists() &&
1777 $oldid === null;
1778
1779 wfDebug( __METHOD__ . ': using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" );
1780
1781 if ( $user->getStubThreshold() ) {
1782 wfIncrStats( 'pcache_miss_stub' );
1783 }
1784
1785 if ( $useParserCache ) {
1786 $parserOutput = ParserCache::singleton()->get( $this, $this->mPage->getParserOptions() );
1787 if ( $parserOutput !== false ) {
1788 wfProfileOut( __METHOD__ );
1789 return $parserOutput;
1790 }
1791 }
1792
1793 // Cache miss; parse and output it.
1794 if ( $oldid === null ) {
1795 $text = $this->mPage->getRawText();
1796 } else {
1797 $rev = Revision::newFromTitle( $this->getTitle(), $oldid );
1798 if ( $rev === null ) {
1799 wfProfileOut( __METHOD__ );
1800 return false;
1801 }
1802 $text = $rev->getText();
1803 }
1804
1805 $output = $this->getOutputFromWikitext( $text, $useParserCache );
1806 wfProfileOut( __METHOD__ );
1807 return $output;
1808 }
1809
1810 /**
1811 * This does all the heavy lifting for outputWikitext, except it returns the parser
1812 * output instead of sending it straight to $wgOut. Makes things nice and simple for,
1813 * say, embedding thread pages within a discussion system (LiquidThreads)
1814 *
1815 * @param $text string
1816 * @param $cache boolean
1817 * @param $parserOptions parsing options, defaults to false
1818 * @return ParserOutput
1819 */
1820 public function getOutputFromWikitext( $text, $cache = true, $parserOptions = false ) {
1821 global $wgParser, $wgEnableParserCache, $wgUseFileCache;
1822
1823 if ( !$parserOptions ) {
1824 $parserOptions = $this->mPage->getParserOptions();
1825 }
1826
1827 $time = - wfTime();
1828 $this->mParserOutput = $wgParser->parse( $text, $this->getTitle(),
1829 $parserOptions, true, true, $this->getRevIdFetched() );
1830 $time += wfTime();
1831
1832 # Timing hack
1833 if ( $time > 3 ) {
1834 wfDebugLog( 'slow-parse', sprintf( "%-5.2f %s", $time,
1835 $this->getTitle()->getPrefixedDBkey() ) );
1836 }
1837
1838 if ( $wgEnableParserCache && $cache && $this->mParserOutput->isCacheable() ) {
1839 $parserCache = ParserCache::singleton();
1840 $parserCache->save( $this->mParserOutput, $this, $parserOptions );
1841 }
1842
1843 // Make sure file cache is not used on uncacheable content.
1844 // Output that has magic words in it can still use the parser cache
1845 // (if enabled), though it will generally expire sooner.
1846 if ( !$this->mParserOutput->isCacheable() || $this->mParserOutput->containsOldMagic() ) {
1847 $wgUseFileCache = false;
1848 }
1849
1850 if ( $this->isCurrent() ) {
1851 $this->mPage->doCascadeProtectionUpdates( $this->mParserOutput );
1852 }
1853
1854 return $this->mParserOutput;
1855 }
1856
1857 /**
1858 * Sets the context this Article is executed in
1859 *
1860 * @param $context RequestContext
1861 * @since 1.18
1862 */
1863 public function setContext( $context ) {
1864 $this->mContext = $context;
1865 }
1866
1867 /**
1868 * Gets the context this Article is executed in
1869 *
1870 * @return RequestContext
1871 * @since 1.18
1872 */
1873 public function getContext() {
1874 if ( $this->mContext instanceof RequestContext ) {
1875 return $this->mContext;
1876 } else {
1877 wfDebug( __METHOD__ . " called and \$mContext is null. Return RequestContext::getMain(); for sanity\n" );
1878 return RequestContext::getMain();
1879 }
1880 }
1881
1882 /**
1883 * Use PHP's magic __get handler to handle accessing of
1884 * raw WikiPage fields for backwards compatibility.
1885 *
1886 * @param $fname String Field name
1887 */
1888 public function __get( $fname ) {
1889 if ( property_exists( $this->mPage, $fname ) ) {
1890 #wfWarn( "Access to raw $fname field " . __CLASS__ );
1891 return $this->mPage->$fname;
1892 }
1893 trigger_error( 'Inaccessible property via __get(): ' . $fname, E_USER_NOTICE );
1894 }
1895
1896 /**
1897 * Use PHP's magic __set handler to handle setting of
1898 * raw WikiPage fields for backwards compatibility.
1899 *
1900 * @param $fname String Field name
1901 * @param $fvalue mixed New value
1902 */
1903 public function __set( $fname, $fvalue ) {
1904 if ( property_exists( $this->mPage, $fname ) ) {
1905 #wfWarn( "Access to raw $fname field of " . __CLASS__ );
1906 $this->mPage->$fname = $fvalue;
1907 // Note: extensions may want to toss on new fields
1908 } elseif ( !in_array( $fname, array( 'mContext', 'mPage' ) ) ) {
1909 $this->mPage->$fname = $fvalue;
1910 } else {
1911 trigger_error( 'Inaccessible property via __set(): ' . $fname, E_USER_NOTICE );
1912 }
1913 }
1914
1915 /**
1916 * Use PHP's magic __call handler to transform instance calls to
1917 * WikiPage functions for backwards compatibility.
1918 *
1919 * @param $fname String Name of called method
1920 * @param $args Array Arguments to the method
1921 */
1922 public function __call( $fname, $args ) {
1923 if ( is_callable( array( $this->mPage, $fname ) ) ) {
1924 #wfWarn( "Call to " . __CLASS__ . "::$fname; please use WikiPage instead" );
1925 return call_user_func_array( array( $this->mPage, $fname ), $args );
1926 }
1927 trigger_error( 'Inaccessible function via __call(): ' . $fname, E_USER_ERROR );
1928 }
1929
1930 // ****** B/C functions to work-around PHP silliness with __call and references ****** //
1931 public function updateRestrictions( $limit = array(), $reason = '', &$cascade = 0, $expiry = array() ) {
1932 return $this->mPage->updateRestrictions( $limit, $reason, $cascade, $expiry );
1933 }
1934
1935 public function doDeleteArticle( $reason, $suppress = false, $id = 0, $commit = true, &$error = '' ) {
1936 return $this->mPage->doDeleteArticle( $reason, $suppress, $id, $commit, $error );
1937 }
1938
1939 public function doRollback( $fromP, $summary, $token, $bot, &$resultDetails, User $user = null ) {
1940 global $wgUser;
1941 $user = is_null( $user ) ? $wgUser : $user;
1942 return $this->mPage->doRollback( $fromP, $summary, $token, $bot, $resultDetails, $user );
1943 }
1944
1945 public function commitRollback( $fromP, $summary, $bot, &$resultDetails, User $guser = null ) {
1946 global $wgUser;
1947 $guser = is_null( $guser ) ? $wgUser : $guser;
1948 return $this->mPage->commitRollback( $fromP, $summary, $bot, $resultDetails, $guser );
1949 }
1950
1951 public function generateReason( &$hasHistory ) {
1952 return $this->mPage->getAutoDeleteReason( $hasHistory );
1953 }
1954
1955 // ****** B/C functions for static methods ( __callStatic is PHP>=5.3 ) ****** //
1956 public static function selectFields() {
1957 return WikiPage::selectFields();
1958 }
1959
1960 public static function onArticleCreate( $title ) {
1961 return WikiPage::onArticleCreate( $title );
1962 }
1963
1964 public static function onArticleDelete( $title ) {
1965 return WikiPage::onArticleDelete( $title );
1966 }
1967
1968 public static function onArticleEdit( $title ) {
1969 return WikiPage::onArticleEdit( $title );
1970 }
1971
1972 public static function getAutosummary( $oldtext, $newtext, $flags ) {
1973 return WikiPage::getAutosummary( $oldtext, $newtext, $flags );
1974 }
1975 // ******
1976 }
1977
1978 class PoolWorkArticleView extends PoolCounterWork {
1979
1980 /**
1981 * @var Article
1982 */
1983 private $mArticle;
1984
1985 function __construct( $article, $key, $useParserCache, $parserOptions ) {
1986 parent::__construct( 'ArticleView', $key );
1987 $this->mArticle = $article;
1988 $this->cacheable = $useParserCache;
1989 $this->parserOptions = $parserOptions;
1990 }
1991
1992 function doWork() {
1993 return $this->mArticle->doViewParse();
1994 }
1995
1996 function getCachedWork() {
1997 global $wgOut;
1998
1999 $parserCache = ParserCache::singleton();
2000 $this->mArticle->mParserOutput = $parserCache->get( $this->mArticle, $this->parserOptions );
2001
2002 if ( $this->mArticle->mParserOutput !== false ) {
2003 wfDebug( __METHOD__ . ": showing contents parsed by someone else\n" );
2004 $wgOut->addParserOutput( $this->mArticle->mParserOutput );
2005 # Ensure that UI elements requiring revision ID have
2006 # the correct version information.
2007 $wgOut->setRevisionId( $this->mArticle->getLatest() );
2008 return true;
2009 }
2010 return false;
2011 }
2012
2013 function fallback() {
2014 return $this->mArticle->tryDirtyCache();
2015 }
2016
2017 /**
2018 * @param $status Status
2019 */
2020 function error( $status ) {
2021 global $wgOut;
2022
2023 $wgOut->clearHTML(); // for release() errors
2024 $wgOut->enableClientCache( false );
2025 $wgOut->setRobotPolicy( 'noindex,nofollow' );
2026
2027 $errortext = $status->getWikiText( false, 'view-pool-error' );
2028 $wgOut->addWikiText( '<div class="errorbox">' . $errortext . '</div>' );
2029
2030 return false;
2031 }
2032 }