Merge "Less wild whitespace"
[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 $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 ? $content->getRedirectChain() : null;
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 $poolArticleView = new PoolWorkArticleView( $this->getPage(), $parserOptions,
708 $this->getRevIdFetched(), $useParserCache, $this->getContentObject() );
709
710 if ( !$poolArticleView->execute() ) {
711 $error = $poolArticleView->getError();
712 if ( $error ) {
713 $outputPage->clearHTML(); // for release() errors
714 $outputPage->enableClientCache( false );
715 $outputPage->setRobotPolicy( 'noindex,nofollow' );
716
717 $errortext = $error->getWikiText( false, 'view-pool-error' );
718 $outputPage->addWikiText( '<div class="errorbox">' . $errortext . '</div>' );
719 }
720 # Connection or timeout error
721 wfProfileOut( __METHOD__ );
722 return;
723 }
724
725 $this->mParserOutput = $poolArticleView->getParserOutput();
726 $outputPage->addParserOutput( $this->mParserOutput );
727
728 # Don't cache a dirty ParserOutput object
729 if ( $poolArticleView->getIsDirty() ) {
730 $outputPage->setSquidMaxage( 0 );
731 $outputPage->addHTML( "<!-- parser cache is expired, sending anyway due to pool overload-->\n" );
732 }
733
734 $outputDone = true;
735 break;
736 # Should be unreachable, but just in case...
737 default:
738 break 2;
739 }
740 }
741
742 # Get the ParserOutput actually *displayed* here.
743 # Note that $this->mParserOutput is the *current* version output.
744 $pOutput = ( $outputDone instanceof ParserOutput )
745 ? $outputDone // object fetched by hook
746 : $this->mParserOutput;
747
748 # Adjust title for main page & pages with displaytitle
749 if ( $pOutput ) {
750 $this->adjustDisplayTitle( $pOutput );
751 }
752
753 # For the main page, overwrite the <title> element with the con-
754 # tents of 'pagetitle-view-mainpage' instead of the default (if
755 # that's not empty).
756 # This message always exists because it is in the i18n files
757 if ( $this->getTitle()->isMainPage() ) {
758 $msg = wfMessage( 'pagetitle-view-mainpage' )->inContentLanguage();
759 if ( !$msg->isDisabled() ) {
760 $outputPage->setHTMLTitle( $msg->title( $this->getTitle() )->text() );
761 }
762 }
763
764 # Check for any __NOINDEX__ tags on the page using $pOutput
765 $policy = $this->getRobotPolicy( 'view', $pOutput );
766 $outputPage->setIndexPolicy( $policy['index'] );
767 $outputPage->setFollowPolicy( $policy['follow'] );
768
769 $this->showViewFooter();
770 $this->mPage->doViewUpdates( $user );
771
772 wfProfileOut( __METHOD__ );
773 }
774
775 /**
776 * Adjust title for pages with displaytitle, -{T|}- or language conversion
777 * @param $pOutput ParserOutput
778 */
779 public function adjustDisplayTitle( ParserOutput $pOutput ) {
780 # Adjust the title if it was set by displaytitle, -{T|}- or language conversion
781 $titleText = $pOutput->getTitleText();
782 if ( strval( $titleText ) !== '' ) {
783 $this->getContext()->getOutput()->setPageTitle( $titleText );
784 }
785 }
786
787 /**
788 * Show a diff page according to current request variables. For use within
789 * Article::view() only, other callers should use the DifferenceEngine class.
790 *
791 * @todo: make protected
792 */
793 public function showDiffPage() {
794 $request = $this->getContext()->getRequest();
795 $user = $this->getContext()->getUser();
796 $diff = $request->getVal( 'diff' );
797 $rcid = $request->getVal( 'rcid' );
798 $diffOnly = $request->getBool( 'diffonly', $user->getOption( 'diffonly' ) );
799 $purge = $request->getVal( 'action' ) == 'purge';
800 $unhide = $request->getInt( 'unhide' ) == 1;
801 $oldid = $this->getOldID();
802
803 $rev = $this->getRevisionFetched();
804
805 if ( !$rev ) {
806 $this->getContext()->getOutput()->setPageTitle( wfMessage( 'errorpagetitle' ) );
807 $this->getContext()->getOutput()->addWikiMsg( 'difference-missing-revision', $oldid, 1 );
808 return;
809 }
810
811 $contentHandler = $rev->getContentHandler();
812 $de = $contentHandler->createDifferenceEngine( $this->getContext(), $oldid, $diff, $rcid, $purge, $unhide );
813
814 // DifferenceEngine directly fetched the revision:
815 $this->mRevIdFetched = $de->mNewid;
816 $de->showDiffPage( $diffOnly );
817
818 if ( $diff == 0 || $diff == $this->mPage->getLatest() ) {
819 # Run view updates for current revision only
820 $this->mPage->doViewUpdates( $user );
821 }
822 }
823
824 /**
825 * Show a page view for a page formatted as CSS or JavaScript. To be called by
826 * Article::view() only.
827 *
828 * This is hooked by SyntaxHighlight_GeSHi to do syntax highlighting of these
829 * page views.
830 *
831 * @param bool $showCacheHint whether to show a message telling the user to clear the browser cache (default: true).
832 */
833 protected function showCssOrJsPage( $showCacheHint = true ) {
834 $outputPage = $this->getContext()->getOutput();
835
836 if ( $showCacheHint ) {
837 $dir = $this->getContext()->getLanguage()->getDir();
838 $lang = $this->getContext()->getLanguage()->getCode();
839
840 $outputPage->wrapWikiMsg( "<div id='mw-clearyourcache' lang='$lang' dir='$dir' class='mw-content-$dir'>\n$1\n</div>",
841 'clearyourcache' );
842 }
843
844 $this->fetchContentObject();
845
846 if ( $this->mContentObject ) {
847 // Give hooks a chance to customise the output
848 if ( ContentHandler::runLegacyHooks( 'ShowRawCssJs', array( $this->mContentObject, $this->getTitle(), $outputPage ) ) ) {
849 $po = $this->mContentObject->getParserOutput( $this->getTitle() );
850 $outputPage->addHTML( $po->getText() );
851 }
852 }
853 }
854
855 /**
856 * Get the robot policy to be used for the current view
857 * @param $action String the action= GET parameter
858 * @param $pOutput ParserOutput
859 * @return Array the policy that should be set
860 * TODO: actions other than 'view'
861 */
862 public function getRobotPolicy( $action, $pOutput ) {
863 global $wgArticleRobotPolicies, $wgNamespaceRobotPolicies, $wgDefaultRobotPolicy;
864
865 $ns = $this->getTitle()->getNamespace();
866
867 if ( $ns == NS_USER || $ns == NS_USER_TALK ) {
868 # Don't index user and user talk pages for blocked users (bug 11443)
869 if ( !$this->getTitle()->isSubpage() ) {
870 if ( Block::newFromTarget( null, $this->getTitle()->getText() ) instanceof Block ) {
871 return array(
872 'index' => 'noindex',
873 'follow' => 'nofollow'
874 );
875 }
876 }
877 }
878
879 if ( $this->mPage->getID() === 0 || $this->getOldID() ) {
880 # Non-articles (special pages etc), and old revisions
881 return array(
882 'index' => 'noindex',
883 'follow' => 'nofollow'
884 );
885 } elseif ( $this->getContext()->getOutput()->isPrintable() ) {
886 # Discourage indexing of printable versions, but encourage following
887 return array(
888 'index' => 'noindex',
889 'follow' => 'follow'
890 );
891 } elseif ( $this->getContext()->getRequest()->getInt( 'curid' ) ) {
892 # For ?curid=x urls, disallow indexing
893 return array(
894 'index' => 'noindex',
895 'follow' => 'follow'
896 );
897 }
898
899 # Otherwise, construct the policy based on the various config variables.
900 $policy = self::formatRobotPolicy( $wgDefaultRobotPolicy );
901
902 if ( isset( $wgNamespaceRobotPolicies[$ns] ) ) {
903 # Honour customised robot policies for this namespace
904 $policy = array_merge(
905 $policy,
906 self::formatRobotPolicy( $wgNamespaceRobotPolicies[$ns] )
907 );
908 }
909 if ( $this->getTitle()->canUseNoindex() && is_object( $pOutput ) && $pOutput->getIndexPolicy() ) {
910 # __INDEX__ and __NOINDEX__ magic words, if allowed. Incorporates
911 # a final sanity check that we have really got the parser output.
912 $policy = array_merge(
913 $policy,
914 array( 'index' => $pOutput->getIndexPolicy() )
915 );
916 }
917
918 if ( isset( $wgArticleRobotPolicies[$this->getTitle()->getPrefixedText()] ) ) {
919 # (bug 14900) site config can override user-defined __INDEX__ or __NOINDEX__
920 $policy = array_merge(
921 $policy,
922 self::formatRobotPolicy( $wgArticleRobotPolicies[$this->getTitle()->getPrefixedText()] )
923 );
924 }
925
926 return $policy;
927 }
928
929 /**
930 * Converts a String robot policy into an associative array, to allow
931 * merging of several policies using array_merge().
932 * @param $policy Mixed, returns empty array on null/false/'', transparent
933 * to already-converted arrays, converts String.
934 * @return Array: 'index' => \<indexpolicy\>, 'follow' => \<followpolicy\>
935 */
936 public static function formatRobotPolicy( $policy ) {
937 if ( is_array( $policy ) ) {
938 return $policy;
939 } elseif ( !$policy ) {
940 return array();
941 }
942
943 $policy = explode( ',', $policy );
944 $policy = array_map( 'trim', $policy );
945
946 $arr = array();
947 foreach ( $policy as $var ) {
948 if ( in_array( $var, array( 'index', 'noindex' ) ) ) {
949 $arr['index'] = $var;
950 } elseif ( in_array( $var, array( 'follow', 'nofollow' ) ) ) {
951 $arr['follow'] = $var;
952 }
953 }
954
955 return $arr;
956 }
957
958 /**
959 * If this request is a redirect view, send "redirected from" subtitle to
960 * the output. Returns true if the header was needed, false if this is not
961 * a redirect view. Handles both local and remote redirects.
962 *
963 * @return boolean
964 */
965 public function showRedirectedFromHeader() {
966 global $wgRedirectSources;
967 $outputPage = $this->getContext()->getOutput();
968
969 $rdfrom = $this->getContext()->getRequest()->getVal( 'rdfrom' );
970
971 if ( isset( $this->mRedirectedFrom ) ) {
972 // This is an internally redirected page view.
973 // We'll need a backlink to the source page for navigation.
974 if ( wfRunHooks( 'ArticleViewRedirect', array( &$this ) ) ) {
975 $redir = Linker::linkKnown(
976 $this->mRedirectedFrom,
977 null,
978 array(),
979 array( 'redirect' => 'no' )
980 );
981
982 $outputPage->addSubtitle( wfMessage( 'redirectedfrom' )->rawParams( $redir ) );
983
984 // Set the fragment if one was specified in the redirect
985 if ( strval( $this->getTitle()->getFragment() ) != '' ) {
986 $fragment = Xml::escapeJsString( $this->getTitle()->getFragmentForURL() );
987 $outputPage->addInlineScript( "redirectToFragment(\"$fragment\");" );
988 }
989
990 // Add a <link rel="canonical"> tag
991 $outputPage->addLink( array( 'rel' => 'canonical',
992 'href' => $this->getTitle()->getLocalURL() )
993 );
994
995 // Tell the output object that the user arrived at this article through a redirect
996 $outputPage->setRedirectedFrom( $this->mRedirectedFrom );
997
998 return true;
999 }
1000 } elseif ( $rdfrom ) {
1001 // This is an externally redirected view, from some other wiki.
1002 // If it was reported from a trusted site, supply a backlink.
1003 if ( $wgRedirectSources && preg_match( $wgRedirectSources, $rdfrom ) ) {
1004 $redir = Linker::makeExternalLink( $rdfrom, $rdfrom );
1005 $outputPage->addSubtitle( wfMessage( 'redirectedfrom' )->rawParams( $redir ) );
1006
1007 return true;
1008 }
1009 }
1010
1011 return false;
1012 }
1013
1014 /**
1015 * Show a header specific to the namespace currently being viewed, like
1016 * [[MediaWiki:Talkpagetext]]. For Article::view().
1017 */
1018 public function showNamespaceHeader() {
1019 if ( $this->getTitle()->isTalkPage() ) {
1020 if ( !wfMessage( 'talkpageheader' )->isDisabled() ) {
1021 $this->getContext()->getOutput()->wrapWikiMsg( "<div class=\"mw-talkpageheader\">\n$1\n</div>", array( 'talkpageheader' ) );
1022 }
1023 }
1024 }
1025
1026 /**
1027 * Show the footer section of an ordinary page view
1028 */
1029 public function showViewFooter() {
1030 # check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page
1031 if ( $this->getTitle()->getNamespace() == NS_USER_TALK && IP::isValid( $this->getTitle()->getText() ) ) {
1032 $this->getContext()->getOutput()->addWikiMsg( 'anontalkpagetext' );
1033 }
1034
1035 # If we have been passed an &rcid= parameter, we want to give the user a
1036 # chance to mark this new article as patrolled.
1037 $this->showPatrolFooter();
1038
1039 wfRunHooks( 'ArticleViewFooter', array( $this ) );
1040
1041 }
1042
1043 /**
1044 * If patrol is possible, output a patrol UI box. This is called from the
1045 * footer section of ordinary page views. If patrol is not possible or not
1046 * desired, does nothing.
1047 * Side effect: When the patrol link is build, this method will call
1048 * OutputPage::preventClickjacking() and load mediawiki.page.patrol.ajax.
1049 */
1050 public function showPatrolFooter() {
1051 $request = $this->getContext()->getRequest();
1052 $outputPage = $this->getContext()->getOutput();
1053 $user = $this->getContext()->getUser();
1054 $rcid = $request->getVal( 'rcid' );
1055
1056 if ( !$rcid || !$this->getTitle()->quickUserCan( 'patrol', $user ) ) {
1057 return;
1058 }
1059
1060 $token = $user->getEditToken( $rcid );
1061
1062 $outputPage->preventClickjacking();
1063 $outputPage->addModules( 'mediawiki.page.patrol.ajax' );
1064
1065 $link = Linker::linkKnown(
1066 $this->getTitle(),
1067 wfMessage( 'markaspatrolledtext' )->escaped(),
1068 array(),
1069 array(
1070 'action' => 'markpatrolled',
1071 'rcid' => $rcid,
1072 'token' => $token,
1073 )
1074 );
1075
1076 $outputPage->addHTML(
1077 "<div class='patrollink'>" .
1078 wfMessage( 'markaspatrolledlink' )->rawParams( $link )->escaped() .
1079 '</div>'
1080 );
1081 }
1082
1083 /**
1084 * Show the error text for a missing article. For articles in the MediaWiki
1085 * namespace, show the default message text. To be called from Article::view().
1086 */
1087 public function showMissingArticle() {
1088 global $wgSend404Code;
1089 $outputPage = $this->getContext()->getOutput();
1090
1091 # Show info in user (talk) namespace. Does the user exist? Is he blocked?
1092 if ( $this->getTitle()->getNamespace() == NS_USER || $this->getTitle()->getNamespace() == NS_USER_TALK ) {
1093 $parts = explode( '/', $this->getTitle()->getText() );
1094 $rootPart = $parts[0];
1095 $user = User::newFromName( $rootPart, false /* allow IP users*/ );
1096 $ip = User::isIP( $rootPart );
1097
1098 if ( !($user && $user->isLoggedIn()) && !$ip ) { # User does not exist
1099 $outputPage->wrapWikiMsg( "<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>",
1100 array( 'userpage-userdoesnotexist-view', wfEscapeWikiText( $rootPart ) ) );
1101 } elseif ( $user->isBlocked() ) { # Show log extract if the user is currently blocked
1102 LogEventsList::showLogExtract(
1103 $outputPage,
1104 'block',
1105 $user->getUserPage(),
1106 '',
1107 array(
1108 'lim' => 1,
1109 'showIfEmpty' => false,
1110 'msgKey' => array(
1111 'blocked-notice-logextract',
1112 $user->getName() # Support GENDER in notice
1113 )
1114 )
1115 );
1116 }
1117 }
1118
1119 wfRunHooks( 'ShowMissingArticle', array( $this ) );
1120
1121 # Show delete and move logs
1122 LogEventsList::showLogExtract( $outputPage, array( 'delete', 'move' ), $this->getTitle(), '',
1123 array( 'lim' => 10,
1124 'conds' => array( "log_action != 'revision'" ),
1125 'showIfEmpty' => false,
1126 'msgKey' => array( 'moveddeleted-notice' ) )
1127 );
1128
1129 if ( !$this->mPage->hasViewableContent() && $wgSend404Code ) {
1130 // If there's no backing content, send a 404 Not Found
1131 // for better machine handling of broken links.
1132 $this->getContext()->getRequest()->response()->header( "HTTP/1.1 404 Not Found" );
1133 }
1134
1135 $hookResult = wfRunHooks( 'BeforeDisplayNoArticleText', array( $this ) );
1136
1137 if ( ! $hookResult ) {
1138 return;
1139 }
1140
1141 # Show error message
1142 $oldid = $this->getOldID();
1143 if ( $oldid ) {
1144 $text = wfMessage( 'missing-revision', $oldid )->plain();
1145 } elseif ( $this->getTitle()->getNamespace() === NS_MEDIAWIKI ) {
1146 // Use the default message text
1147 $text = $this->getTitle()->getDefaultMessageText();
1148 } elseif ( $this->getTitle()->quickUserCan( 'create', $this->getContext()->getUser() )
1149 && $this->getTitle()->quickUserCan( 'edit', $this->getContext()->getUser() )
1150 ) {
1151 $text = wfMessage( 'noarticletext' )->plain();
1152 } else {
1153 $text = wfMessage( 'noarticletext-nopermission' )->plain();
1154 }
1155 $text = "<div class='noarticletext'>\n$text\n</div>";
1156
1157 $outputPage->addWikiText( $text );
1158 }
1159
1160 /**
1161 * If the revision requested for view is deleted, check permissions.
1162 * Send either an error message or a warning header to the output.
1163 *
1164 * @return boolean true if the view is allowed, false if not.
1165 */
1166 public function showDeletedRevisionHeader() {
1167 if ( !$this->mRevision->isDeleted( Revision::DELETED_TEXT ) ) {
1168 // Not deleted
1169 return true;
1170 }
1171
1172 $outputPage = $this->getContext()->getOutput();
1173 $user = $this->getContext()->getUser();
1174 // If the user is not allowed to see it...
1175 if ( !$this->mRevision->userCan( Revision::DELETED_TEXT, $user ) ) {
1176 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1177 'rev-deleted-text-permission' );
1178
1179 return false;
1180 // If the user needs to confirm that they want to see it...
1181 } elseif ( $this->getContext()->getRequest()->getInt( 'unhide' ) != 1 ) {
1182 # Give explanation and add a link to view the revision...
1183 $oldid = intval( $this->getOldID() );
1184 $link = $this->getTitle()->getFullUrl( "oldid={$oldid}&unhide=1" );
1185 $msg = $this->mRevision->isDeleted( Revision::DELETED_RESTRICTED ) ?
1186 'rev-suppressed-text-unhide' : 'rev-deleted-text-unhide';
1187 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1188 array( $msg, $link ) );
1189
1190 return false;
1191 // We are allowed to see...
1192 } else {
1193 $msg = $this->mRevision->isDeleted( Revision::DELETED_RESTRICTED ) ?
1194 'rev-suppressed-text-view' : 'rev-deleted-text-view';
1195 $outputPage->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n", $msg );
1196
1197 return true;
1198 }
1199 }
1200
1201 /**
1202 * Generate the navigation links when browsing through an article revisions
1203 * It shows the information as:
1204 * Revision as of \<date\>; view current revision
1205 * \<- Previous version | Next Version -\>
1206 *
1207 * @param $oldid int: revision ID of this article revision
1208 */
1209 public function setOldSubtitle( $oldid = 0 ) {
1210 if ( !wfRunHooks( 'DisplayOldSubtitle', array( &$this, &$oldid ) ) ) {
1211 return;
1212 }
1213
1214 $unhide = $this->getContext()->getRequest()->getInt( 'unhide' ) == 1;
1215
1216 # Cascade unhide param in links for easy deletion browsing
1217 $extraParams = array();
1218 if ( $unhide ) {
1219 $extraParams['unhide'] = 1;
1220 }
1221
1222 if ( $this->mRevision && $this->mRevision->getId() === $oldid ) {
1223 $revision = $this->mRevision;
1224 } else {
1225 $revision = Revision::newFromId( $oldid );
1226 }
1227
1228 $timestamp = $revision->getTimestamp();
1229
1230 $current = ( $oldid == $this->mPage->getLatest() );
1231 $language = $this->getContext()->getLanguage();
1232 $user = $this->getContext()->getUser();
1233
1234 $td = $language->userTimeAndDate( $timestamp, $user );
1235 $tddate = $language->userDate( $timestamp, $user );
1236 $tdtime = $language->userTime( $timestamp, $user );
1237
1238 # Show user links if allowed to see them. If hidden, then show them only if requested...
1239 $userlinks = Linker::revUserTools( $revision, !$unhide );
1240
1241 $infomsg = $current && !wfMessage( 'revision-info-current' )->isDisabled()
1242 ? 'revision-info-current'
1243 : 'revision-info';
1244
1245 $outputPage = $this->getContext()->getOutput();
1246 $outputPage->addSubtitle( "<div id=\"mw-{$infomsg}\">" . wfMessage( $infomsg,
1247 $td )->rawParams( $userlinks )->params( $revision->getID(), $tddate,
1248 $tdtime, $revision->getUser() )->parse() . "</div>" );
1249
1250 $lnk = $current
1251 ? wfMessage( 'currentrevisionlink' )->escaped()
1252 : Linker::linkKnown(
1253 $this->getTitle(),
1254 wfMessage( 'currentrevisionlink' )->escaped(),
1255 array(),
1256 $extraParams
1257 );
1258 $curdiff = $current
1259 ? wfMessage( 'diff' )->escaped()
1260 : Linker::linkKnown(
1261 $this->getTitle(),
1262 wfMessage( 'diff' )->escaped(),
1263 array(),
1264 array(
1265 'diff' => 'cur',
1266 'oldid' => $oldid
1267 ) + $extraParams
1268 );
1269 $prev = $this->getTitle()->getPreviousRevisionID( $oldid ) ;
1270 $prevlink = $prev
1271 ? Linker::linkKnown(
1272 $this->getTitle(),
1273 wfMessage( 'previousrevision' )->escaped(),
1274 array(),
1275 array(
1276 'direction' => 'prev',
1277 'oldid' => $oldid
1278 ) + $extraParams
1279 )
1280 : wfMessage( 'previousrevision' )->escaped();
1281 $prevdiff = $prev
1282 ? Linker::linkKnown(
1283 $this->getTitle(),
1284 wfMessage( 'diff' )->escaped(),
1285 array(),
1286 array(
1287 'diff' => 'prev',
1288 'oldid' => $oldid
1289 ) + $extraParams
1290 )
1291 : wfMessage( 'diff' )->escaped();
1292 $nextlink = $current
1293 ? wfMessage( 'nextrevision' )->escaped()
1294 : Linker::linkKnown(
1295 $this->getTitle(),
1296 wfMessage( 'nextrevision' )->escaped(),
1297 array(),
1298 array(
1299 'direction' => 'next',
1300 'oldid' => $oldid
1301 ) + $extraParams
1302 );
1303 $nextdiff = $current
1304 ? wfMessage( 'diff' )->escaped()
1305 : Linker::linkKnown(
1306 $this->getTitle(),
1307 wfMessage( 'diff' )->escaped(),
1308 array(),
1309 array(
1310 'diff' => 'next',
1311 'oldid' => $oldid
1312 ) + $extraParams
1313 );
1314
1315 $cdel = Linker::getRevDeleteLink( $user, $revision, $this->getTitle() );
1316 if ( $cdel !== '' ) {
1317 $cdel .= ' ';
1318 }
1319
1320 $outputPage->addSubtitle( "<div id=\"mw-revision-nav\">" . $cdel .
1321 wfMessage( 'revision-nav' )->rawParams(
1322 $prevdiff, $prevlink, $lnk, $curdiff, $nextlink, $nextdiff
1323 )->escaped() . "</div>" );
1324 }
1325
1326 /**
1327 * View redirect
1328 *
1329 * @param $target Title|Array of destination(s) to redirect
1330 * @param $appendSubtitle Boolean [optional]
1331 * @param $forceKnown Boolean: should the image be shown as a bluelink regardless of existence?
1332 * @return string containing HMTL with redirect link
1333 */
1334 public function viewRedirect( $target, $appendSubtitle = true, $forceKnown = false ) {
1335 global $wgStylePath;
1336
1337 if ( !is_array( $target ) ) {
1338 $target = array( $target );
1339 }
1340
1341 $lang = $this->getTitle()->getPageLanguage();
1342 $imageDir = $lang->getDir();
1343
1344 if ( $appendSubtitle ) {
1345 $out = $this->getContext()->getOutput();
1346 $out->addSubtitle( wfMessage( 'redirectpagesub' )->escaped() );
1347 }
1348
1349 // the loop prepends the arrow image before the link, so the first case needs to be outside
1350
1351 /**
1352 * @var $title Title
1353 */
1354 $title = array_shift( $target );
1355
1356 if ( $forceKnown ) {
1357 $link = Linker::linkKnown( $title, htmlspecialchars( $title->getFullText() ) );
1358 } else {
1359 $link = Linker::link( $title, htmlspecialchars( $title->getFullText() ) );
1360 }
1361
1362 $nextRedirect = $wgStylePath . '/common/images/nextredirect' . $imageDir . '.png';
1363 $alt = $lang->isRTL() ? '←' : '→';
1364 // Automatically append redirect=no to each link, since most of them are redirect pages themselves.
1365 foreach ( $target as $rt ) {
1366 $link .= Html::element( 'img', array( 'src' => $nextRedirect, 'alt' => $alt ) );
1367 if ( $forceKnown ) {
1368 $link .= Linker::linkKnown( $rt, htmlspecialchars( $rt->getFullText(), array(), array( 'redirect' => 'no' ) ) );
1369 } else {
1370 $link .= Linker::link( $rt, htmlspecialchars( $rt->getFullText() ), array(), array( 'redirect' => 'no' ) );
1371 }
1372 }
1373
1374 $imageUrl = $wgStylePath . '/common/images/redirect' . $imageDir . '.png';
1375 return '<div class="redirectMsg">' .
1376 Html::element( 'img', array( 'src' => $imageUrl, 'alt' => '#REDIRECT' ) ) .
1377 '<span class="redirectText">' . $link . '</span></div>';
1378 }
1379
1380 /**
1381 * Handle action=render
1382 */
1383 public function render() {
1384 $this->getContext()->getOutput()->setArticleBodyOnly( true );
1385 $this->view();
1386 }
1387
1388 /**
1389 * action=protect handler
1390 */
1391 public function protect() {
1392 $form = new ProtectionForm( $this );
1393 $form->execute();
1394 }
1395
1396 /**
1397 * action=unprotect handler (alias)
1398 */
1399 public function unprotect() {
1400 $this->protect();
1401 }
1402
1403 /**
1404 * UI entry point for page deletion
1405 */
1406 public function delete() {
1407 # This code desperately needs to be totally rewritten
1408
1409 $title = $this->getTitle();
1410 $user = $this->getContext()->getUser();
1411
1412 # Check permissions
1413 $permission_errors = $title->getUserPermissionsErrors( 'delete', $user );
1414 if ( count( $permission_errors ) ) {
1415 throw new PermissionsError( 'delete', $permission_errors );
1416 }
1417
1418 # Read-only check...
1419 if ( wfReadOnly() ) {
1420 throw new ReadOnlyError;
1421 }
1422
1423 # Better double-check that it hasn't been deleted yet!
1424 $this->mPage->loadPageData( 'fromdbmaster' );
1425 if ( !$this->mPage->exists() ) {
1426 $deleteLogPage = new LogPage( 'delete' );
1427 $outputPage = $this->getContext()->getOutput();
1428 $outputPage->setPageTitle( wfMessage( 'cannotdelete-title', $title->getPrefixedText() ) );
1429 $outputPage->wrapWikiMsg( "<div class=\"error mw-error-cannotdelete\">\n$1\n</div>",
1430 array( 'cannotdelete', wfEscapeWikiText( $title->getPrefixedText() ) )
1431 );
1432 $outputPage->addHTML(
1433 Xml::element( 'h2', null, $deleteLogPage->getName()->text() )
1434 );
1435 LogEventsList::showLogExtract(
1436 $outputPage,
1437 'delete',
1438 $title
1439 );
1440
1441 return;
1442 }
1443
1444 $request = $this->getContext()->getRequest();
1445 $deleteReasonList = $request->getText( 'wpDeleteReasonList', 'other' );
1446 $deleteReason = $request->getText( 'wpReason' );
1447
1448 if ( $deleteReasonList == 'other' ) {
1449 $reason = $deleteReason;
1450 } elseif ( $deleteReason != '' ) {
1451 // Entry from drop down menu + additional comment
1452 $colonseparator = wfMessage( 'colon-separator' )->inContentLanguage()->text();
1453 $reason = $deleteReasonList . $colonseparator . $deleteReason;
1454 } else {
1455 $reason = $deleteReasonList;
1456 }
1457
1458 if ( $request->wasPosted() && $user->matchEditToken( $request->getVal( 'wpEditToken' ),
1459 array( 'delete', $this->getTitle()->getPrefixedText() ) ) )
1460 {
1461 # Flag to hide all contents of the archived revisions
1462 $suppress = $request->getVal( 'wpSuppress' ) && $user->isAllowed( 'suppressrevision' );
1463
1464 $this->doDelete( $reason, $suppress );
1465
1466 if ( $user->isLoggedIn() && $request->getCheck( 'wpWatch' ) != $user->isWatched( $title ) ) {
1467 if ( $request->getCheck( 'wpWatch' ) ) {
1468 WatchAction::doWatch( $title, $user );
1469 } else {
1470 WatchAction::doUnwatch( $title, $user );
1471 }
1472 }
1473
1474 return;
1475 }
1476
1477 // Generate deletion reason
1478 $hasHistory = false;
1479 if ( !$reason ) {
1480 try {
1481 $reason = $this->generateReason( $hasHistory );
1482 } catch ( MWException $e ) {
1483 # if a page is horribly broken, we still want to be able to delete it. so be lenient about errors here.
1484 wfDebug("Error while building auto delete summary: $e");
1485 $reason = '';
1486 }
1487 }
1488
1489 // If the page has a history, insert a warning
1490 if ( $hasHistory ) {
1491 $revisions = $this->mTitle->estimateRevisionCount();
1492 // @todo FIXME: i18n issue/patchwork message
1493 $this->getContext()->getOutput()->addHTML( '<strong class="mw-delete-warning-revisions">' .
1494 wfMessage( 'historywarning' )->numParams( $revisions )->parse() .
1495 wfMessage( 'word-separator' )->plain() . Linker::linkKnown( $title,
1496 wfMessage( 'history' )->escaped(),
1497 array( 'rel' => 'archives' ),
1498 array( 'action' => 'history' ) ) .
1499 '</strong>'
1500 );
1501
1502 if ( $this->mTitle->isBigDeletion() ) {
1503 global $wgDeleteRevisionsLimit;
1504 $this->getContext()->getOutput()->wrapWikiMsg( "<div class='error'>\n$1\n</div>\n",
1505 array( 'delete-warning-toobig', $this->getContext()->getLanguage()->formatNum( $wgDeleteRevisionsLimit ) ) );
1506 }
1507 }
1508
1509 $this->confirmDelete( $reason );
1510 }
1511
1512 /**
1513 * Output deletion confirmation dialog
1514 * @todo FIXME: Move to another file?
1515 * @param $reason String: prefilled reason
1516 */
1517 public function confirmDelete( $reason ) {
1518 wfDebug( "Article::confirmDelete\n" );
1519
1520 $outputPage = $this->getContext()->getOutput();
1521 $outputPage->setPageTitle( wfMessage( 'delete-confirm', $this->getTitle()->getPrefixedText() ) );
1522 $outputPage->addBacklinkSubtitle( $this->getTitle() );
1523 $outputPage->setRobotPolicy( 'noindex,nofollow' );
1524 $outputPage->addWikiMsg( 'confirmdeletetext' );
1525
1526 wfRunHooks( 'ArticleConfirmDelete', array( $this, $outputPage, &$reason ) );
1527
1528 $user = $this->getContext()->getUser();
1529
1530 if ( $user->isAllowed( 'suppressrevision' ) ) {
1531 $suppress = "<tr id=\"wpDeleteSuppressRow\">
1532 <td></td>
1533 <td class='mw-input'><strong>" .
1534 Xml::checkLabel( wfMessage( 'revdelete-suppress' )->text(),
1535 'wpSuppress', 'wpSuppress', false, array( 'tabindex' => '4' ) ) .
1536 "</strong></td>
1537 </tr>";
1538 } else {
1539 $suppress = '';
1540 }
1541 $checkWatch = $user->getBoolOption( 'watchdeletion' ) || $user->isWatched( $this->getTitle() );
1542
1543 $form = Xml::openElement( 'form', array( 'method' => 'post',
1544 'action' => $this->getTitle()->getLocalURL( 'action=delete' ), 'id' => 'deleteconfirm' ) ) .
1545 Xml::openElement( 'fieldset', array( 'id' => 'mw-delete-table' ) ) .
1546 Xml::tags( 'legend', null, wfMessage( 'delete-legend' )->escaped() ) .
1547 Xml::openElement( 'table', array( 'id' => 'mw-deleteconfirm-table' ) ) .
1548 "<tr id=\"wpDeleteReasonListRow\">
1549 <td class='mw-label'>" .
1550 Xml::label( wfMessage( 'deletecomment' )->text(), 'wpDeleteReasonList' ) .
1551 "</td>
1552 <td class='mw-input'>" .
1553 Xml::listDropDown( 'wpDeleteReasonList',
1554 wfMessage( 'deletereason-dropdown' )->inContentLanguage()->text(),
1555 wfMessage( 'deletereasonotherlist' )->inContentLanguage()->text(), '', 'wpReasonDropDown', 1 ) .
1556 "</td>
1557 </tr>
1558 <tr id=\"wpDeleteReasonRow\">
1559 <td class='mw-label'>" .
1560 Xml::label( wfMessage( 'deleteotherreason' )->text(), 'wpReason' ) .
1561 "</td>
1562 <td class='mw-input'>" .
1563 Html::input( 'wpReason', $reason, 'text', array(
1564 'size' => '60',
1565 'maxlength' => '255',
1566 'tabindex' => '2',
1567 'id' => 'wpReason',
1568 'autofocus'
1569 ) ) .
1570 "</td>
1571 </tr>";
1572
1573 # Disallow watching if user is not logged in
1574 if ( $user->isLoggedIn() ) {
1575 $form .= "
1576 <tr>
1577 <td></td>
1578 <td class='mw-input'>" .
1579 Xml::checkLabel( wfMessage( 'watchthis' )->text(),
1580 'wpWatch', 'wpWatch', $checkWatch, array( 'tabindex' => '3' ) ) .
1581 "</td>
1582 </tr>";
1583 }
1584
1585 $form .= "
1586 $suppress
1587 <tr>
1588 <td></td>
1589 <td class='mw-submit'>" .
1590 Xml::submitButton( wfMessage( 'deletepage' )->text(),
1591 array( 'name' => 'wpConfirmB', 'id' => 'wpConfirmB', 'tabindex' => '5' ) ) .
1592 "</td>
1593 </tr>" .
1594 Xml::closeElement( 'table' ) .
1595 Xml::closeElement( 'fieldset' ) .
1596 Html::hidden( 'wpEditToken', $user->getEditToken( array( 'delete', $this->getTitle()->getPrefixedText() ) ) ) .
1597 Xml::closeElement( 'form' );
1598
1599 if ( $user->isAllowed( 'editinterface' ) ) {
1600 $title = Title::makeTitle( NS_MEDIAWIKI, 'Deletereason-dropdown' );
1601 $link = Linker::link(
1602 $title,
1603 wfMessage( 'delete-edit-reasonlist' )->escaped(),
1604 array(),
1605 array( 'action' => 'edit' )
1606 );
1607 $form .= '<p class="mw-delete-editreasons">' . $link . '</p>';
1608 }
1609
1610 $outputPage->addHTML( $form );
1611
1612 $deleteLogPage = new LogPage( 'delete' );
1613 $outputPage->addHTML( Xml::element( 'h2', null, $deleteLogPage->getName()->text() ) );
1614 LogEventsList::showLogExtract( $outputPage, 'delete',
1615 $this->getTitle()
1616 );
1617 }
1618
1619 /**
1620 * Perform a deletion and output success or failure messages
1621 * @param $reason
1622 * @param $suppress bool
1623 */
1624 public function doDelete( $reason, $suppress = false ) {
1625 $error = '';
1626 $outputPage = $this->getContext()->getOutput();
1627 $status = $this->mPage->doDeleteArticleReal( $reason, $suppress, 0, true, $error );
1628 if ( $status->isGood() ) {
1629 $deleted = $this->getTitle()->getPrefixedText();
1630
1631 $outputPage->setPageTitle( wfMessage( 'actioncomplete' ) );
1632 $outputPage->setRobotPolicy( 'noindex,nofollow' );
1633
1634 $loglink = '[[Special:Log/delete|' . wfMessage( 'deletionlog' )->text() . ']]';
1635
1636 $outputPage->addWikiMsg( 'deletedtext', wfEscapeWikiText( $deleted ), $loglink );
1637 $outputPage->returnToMain( false );
1638 } else {
1639 $outputPage->setPageTitle( wfMessage( 'cannotdelete-title', $this->getTitle()->getPrefixedText() ) );
1640 if ( $error == '' ) {
1641 $outputPage->addWikiText(
1642 "<div class=\"error mw-error-cannotdelete\">\n" . $status->getWikiText() . "\n</div>"
1643 );
1644 $deleteLogPage = new LogPage( 'delete' );
1645 $outputPage->addHTML( Xml::element( 'h2', null, $deleteLogPage->getName()->text() ) );
1646
1647 LogEventsList::showLogExtract(
1648 $outputPage,
1649 'delete',
1650 $this->getTitle()
1651 );
1652 } else {
1653 $outputPage->addHTML( $error );
1654 }
1655 }
1656 }
1657
1658 /* Caching functions */
1659
1660 /**
1661 * checkLastModified returns true if it has taken care of all
1662 * output to the client that is necessary for this request.
1663 * (that is, it has sent a cached version of the page)
1664 *
1665 * @return boolean true if cached version send, false otherwise
1666 */
1667 protected function tryFileCache() {
1668 static $called = false;
1669
1670 if ( $called ) {
1671 wfDebug( "Article::tryFileCache(): called twice!?\n" );
1672 return false;
1673 }
1674
1675 $called = true;
1676 if ( $this->isFileCacheable() ) {
1677 $cache = HTMLFileCache::newFromTitle( $this->getTitle(), 'view' );
1678 if ( $cache->isCacheGood( $this->mPage->getTouched() ) ) {
1679 wfDebug( "Article::tryFileCache(): about to load file\n" );
1680 $cache->loadFromFileCache( $this->getContext() );
1681 return true;
1682 } else {
1683 wfDebug( "Article::tryFileCache(): starting buffer\n" );
1684 ob_start( array( &$cache, 'saveToFileCache' ) );
1685 }
1686 } else {
1687 wfDebug( "Article::tryFileCache(): not cacheable\n" );
1688 }
1689
1690 return false;
1691 }
1692
1693 /**
1694 * Check if the page can be cached
1695 * @return bool
1696 */
1697 public function isFileCacheable() {
1698 $cacheable = false;
1699
1700 if ( HTMLFileCache::useFileCache( $this->getContext() ) ) {
1701 $cacheable = $this->mPage->getID()
1702 && !$this->mRedirectedFrom && !$this->getTitle()->isRedirect();
1703 // Extension may have reason to disable file caching on some pages.
1704 if ( $cacheable ) {
1705 $cacheable = wfRunHooks( 'IsFileCacheable', array( &$this ) );
1706 }
1707 }
1708
1709 return $cacheable;
1710 }
1711
1712 /**#@-*/
1713
1714 /**
1715 * Lightweight method to get the parser output for a page, checking the parser cache
1716 * and so on. Doesn't consider most of the stuff that WikiPage::view is forced to
1717 * consider, so it's not appropriate to use there.
1718 *
1719 * @since 1.16 (r52326) for LiquidThreads
1720 *
1721 * @param $oldid mixed integer Revision ID or null
1722 * @param $user User The relevant user
1723 * @return ParserOutput or false if the given revsion ID is not found
1724 */
1725 public function getParserOutput( $oldid = null, User $user = null ) {
1726 //XXX: bypasses mParserOptions and thus setParserOptions()
1727
1728 if ( $user === null ) {
1729 $parserOptions = $this->getParserOptions();
1730 } else {
1731 $parserOptions = $this->mPage->makeParserOptions( $user );
1732 }
1733
1734 return $this->mPage->getParserOutput( $parserOptions, $oldid );
1735 }
1736
1737 /**
1738 * Override the ParserOptions used to render the primary article wikitext.
1739 *
1740 * @param ParserOptions $options
1741 * @throws MWException if the parser options where already initialized.
1742 */
1743 public function setParserOptions( ParserOptions $options ) {
1744 if ( $this->mParserOptions ) {
1745 throw new MWException( "can't change parser options after they have already been set" );
1746 }
1747
1748 // clone, so if $options is modified later, it doesn't confuse the parser cache.
1749 $this->mParserOptions = clone $options;
1750 }
1751
1752 /**
1753 * Get parser options suitable for rendering the primary article wikitext
1754 * @return ParserOptions
1755 */
1756 public function getParserOptions() {
1757 if ( !$this->mParserOptions ) {
1758 $this->mParserOptions = $this->mPage->makeParserOptions( $this->getContext() );
1759 }
1760 // Clone to allow modifications of the return value without affecting cache
1761 return clone $this->mParserOptions;
1762 }
1763
1764 /**
1765 * Sets the context this Article is executed in
1766 *
1767 * @param $context IContextSource
1768 * @since 1.18
1769 */
1770 public function setContext( $context ) {
1771 $this->mContext = $context;
1772 }
1773
1774 /**
1775 * Gets the context this Article is executed in
1776 *
1777 * @return IContextSource
1778 * @since 1.18
1779 */
1780 public function getContext() {
1781 if ( $this->mContext instanceof IContextSource ) {
1782 return $this->mContext;
1783 } else {
1784 wfDebug( __METHOD__ . " called and \$mContext is null. Return RequestContext::getMain(); for sanity\n" );
1785 return RequestContext::getMain();
1786 }
1787 }
1788
1789 /**
1790 * Info about this page
1791 * @deprecated since 1.19
1792 */
1793 public function info() {
1794 wfDeprecated( __METHOD__, '1.19' );
1795 Action::factory( 'info', $this )->show();
1796 }
1797
1798 /**
1799 * Mark this particular edit/page as patrolled
1800 * @deprecated since 1.18
1801 */
1802 public function markpatrolled() {
1803 wfDeprecated( __METHOD__, '1.18' );
1804 Action::factory( 'markpatrolled', $this )->show();
1805 }
1806
1807 /**
1808 * Handle action=purge
1809 * @deprecated since 1.19
1810 * @return Action|bool|null false if the action is disabled, null if it is not recognised
1811 */
1812 public function purge() {
1813 return Action::factory( 'purge', $this )->show();
1814 }
1815
1816 /**
1817 * Handle action=revert
1818 * @deprecated since 1.19
1819 */
1820 public function revert() {
1821 wfDeprecated( __METHOD__, '1.19' );
1822 Action::factory( 'revert', $this )->show();
1823 }
1824
1825 /**
1826 * Handle action=rollback
1827 * @deprecated since 1.19
1828 */
1829 public function rollback() {
1830 wfDeprecated( __METHOD__, '1.19' );
1831 Action::factory( 'rollback', $this )->show();
1832 }
1833
1834 /**
1835 * User-interface handler for the "watch" action.
1836 * Requires Request to pass a token as of 1.18.
1837 * @deprecated since 1.18
1838 */
1839 public function watch() {
1840 wfDeprecated( __METHOD__, '1.18' );
1841 Action::factory( 'watch', $this )->show();
1842 }
1843
1844 /**
1845 * Add this page to the current user's watchlist
1846 *
1847 * This is safe to be called multiple times
1848 *
1849 * @return bool true on successful watch operation
1850 * @deprecated since 1.18
1851 */
1852 public function doWatch() {
1853 wfDeprecated( __METHOD__, '1.18' );
1854 return WatchAction::doWatch( $this->getTitle(), $this->getContext()->getUser() );
1855 }
1856
1857 /**
1858 * User interface handler for the "unwatch" action.
1859 * Requires Request to pass a token as of 1.18.
1860 * @deprecated since 1.18
1861 */
1862 public function unwatch() {
1863 wfDeprecated( __METHOD__, '1.18' );
1864 Action::factory( 'unwatch', $this )->show();
1865 }
1866
1867 /**
1868 * Stop watching a page
1869 * @return bool true on successful unwatch
1870 * @deprecated since 1.18
1871 */
1872 public function doUnwatch() {
1873 wfDeprecated( __METHOD__, '1.18' );
1874 return WatchAction::doUnwatch( $this->getTitle(), $this->getContext()->getUser() );
1875 }
1876
1877 /**
1878 * Output a redirect back to the article.
1879 * This is typically used after an edit.
1880 *
1881 * @deprecated in 1.18; call OutputPage::redirect() directly
1882 * @param $noRedir Boolean: add redirect=no
1883 * @param $sectionAnchor String: section to redirect to, including "#"
1884 * @param $extraQuery String: extra query params
1885 */
1886 public function doRedirect( $noRedir = false, $sectionAnchor = '', $extraQuery = '' ) {
1887 wfDeprecated( __METHOD__, '1.18' );
1888 if ( $noRedir ) {
1889 $query = 'redirect=no';
1890 if ( $extraQuery ) {
1891 $query .= "&$extraQuery";
1892 }
1893 } else {
1894 $query = $extraQuery;
1895 }
1896
1897 $this->getContext()->getOutput()->redirect( $this->getTitle()->getFullURL( $query ) . $sectionAnchor );
1898 }
1899
1900 /**
1901 * Use PHP's magic __get handler to handle accessing of
1902 * raw WikiPage fields for backwards compatibility.
1903 *
1904 * @param $fname String Field name
1905 */
1906 public function __get( $fname ) {
1907 if ( property_exists( $this->mPage, $fname ) ) {
1908 #wfWarn( "Access to raw $fname field " . __CLASS__ );
1909 return $this->mPage->$fname;
1910 }
1911 trigger_error( 'Inaccessible property via __get(): ' . $fname, E_USER_NOTICE );
1912 }
1913
1914 /**
1915 * Use PHP's magic __set handler to handle setting of
1916 * raw WikiPage fields for backwards compatibility.
1917 *
1918 * @param $fname String Field name
1919 * @param $fvalue mixed New value
1920 */
1921 public function __set( $fname, $fvalue ) {
1922 if ( property_exists( $this->mPage, $fname ) ) {
1923 #wfWarn( "Access to raw $fname field of " . __CLASS__ );
1924 $this->mPage->$fname = $fvalue;
1925 // Note: extensions may want to toss on new fields
1926 } elseif ( !in_array( $fname, array( 'mContext', 'mPage' ) ) ) {
1927 $this->mPage->$fname = $fvalue;
1928 } else {
1929 trigger_error( 'Inaccessible property via __set(): ' . $fname, E_USER_NOTICE );
1930 }
1931 }
1932
1933 /**
1934 * Use PHP's magic __call handler to transform instance calls to
1935 * WikiPage functions for backwards compatibility.
1936 *
1937 * @param $fname String Name of called method
1938 * @param $args Array Arguments to the method
1939 * @return mixed
1940 */
1941 public function __call( $fname, $args ) {
1942 if ( is_callable( array( $this->mPage, $fname ) ) ) {
1943 #wfWarn( "Call to " . __CLASS__ . "::$fname; please use WikiPage instead" );
1944 return call_user_func_array( array( $this->mPage, $fname ), $args );
1945 }
1946 trigger_error( 'Inaccessible function via __call(): ' . $fname, E_USER_ERROR );
1947 }
1948
1949 // ****** B/C functions to work-around PHP silliness with __call and references ****** //
1950
1951 /**
1952 * @param $limit array
1953 * @param $expiry array
1954 * @param $cascade bool
1955 * @param $reason string
1956 * @param $user User
1957 * @return Status
1958 */
1959 public function doUpdateRestrictions( array $limit, array $expiry, &$cascade, $reason, User $user ) {
1960 return $this->mPage->doUpdateRestrictions( $limit, $expiry, $cascade, $reason, $user );
1961 }
1962
1963 /**
1964 * @param $limit array
1965 * @param $reason string
1966 * @param $cascade int
1967 * @param $expiry array
1968 * @return bool
1969 */
1970 public function updateRestrictions( $limit = array(), $reason = '', &$cascade = 0, $expiry = array() ) {
1971 return $this->mPage->doUpdateRestrictions(
1972 $limit,
1973 $expiry,
1974 $cascade,
1975 $reason,
1976 $this->getContext()->getUser()
1977 );
1978 }
1979
1980 /**
1981 * @param $reason string
1982 * @param $suppress bool
1983 * @param $id int
1984 * @param $commit bool
1985 * @param $error string
1986 * @return bool
1987 */
1988 public function doDeleteArticle( $reason, $suppress = false, $id = 0, $commit = true, &$error = '' ) {
1989 return $this->mPage->doDeleteArticle( $reason, $suppress, $id, $commit, $error );
1990 }
1991
1992 /**
1993 * @param $fromP
1994 * @param $summary
1995 * @param $token
1996 * @param $bot
1997 * @param $resultDetails
1998 * @param $user User
1999 * @return array
2000 */
2001 public function doRollback( $fromP, $summary, $token, $bot, &$resultDetails, User $user = null ) {
2002 $user = is_null( $user ) ? $this->getContext()->getUser() : $user;
2003 return $this->mPage->doRollback( $fromP, $summary, $token, $bot, $resultDetails, $user );
2004 }
2005
2006 /**
2007 * @param $fromP
2008 * @param $summary
2009 * @param $bot
2010 * @param $resultDetails
2011 * @param $guser User
2012 * @return array
2013 */
2014 public function commitRollback( $fromP, $summary, $bot, &$resultDetails, User $guser = null ) {
2015 $guser = is_null( $guser ) ? $this->getContext()->getUser() : $guser;
2016 return $this->mPage->commitRollback( $fromP, $summary, $bot, $resultDetails, $guser );
2017 }
2018
2019 /**
2020 * @param $hasHistory bool
2021 * @return mixed
2022 */
2023 public function generateReason( &$hasHistory ) {
2024 $title = $this->mPage->getTitle();
2025 $handler = ContentHandler::getForTitle( $title );
2026 return $handler->getAutoDeleteReason( $title, $hasHistory );
2027 }
2028
2029 // ****** B/C functions for static methods ( __callStatic is PHP>=5.3 ) ****** //
2030
2031 /**
2032 * @return array
2033 */
2034 public static function selectFields() {
2035 return WikiPage::selectFields();
2036 }
2037
2038 /**
2039 * @param $title Title
2040 */
2041 public static function onArticleCreate( $title ) {
2042 WikiPage::onArticleCreate( $title );
2043 }
2044
2045 /**
2046 * @param $title Title
2047 */
2048 public static function onArticleDelete( $title ) {
2049 WikiPage::onArticleDelete( $title );
2050 }
2051
2052 /**
2053 * @param $title Title
2054 */
2055 public static function onArticleEdit( $title ) {
2056 WikiPage::onArticleEdit( $title );
2057 }
2058
2059 /**
2060 * @param $oldtext
2061 * @param $newtext
2062 * @param $flags
2063 * @return string
2064 * @deprecated since 1.21, use ContentHandler::getAutosummary() instead
2065 */
2066 public static function getAutosummary( $oldtext, $newtext, $flags ) {
2067 return WikiPage::getAutosummary( $oldtext, $newtext, $flags );
2068 }
2069 // ******
2070 }