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