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