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