8 * Class for viewing MediaWiki article and history.
10 * This maintains WikiPage functions for backwards compatibility.
12 * @TODO: move and rewrite code to an Action class
14 * See design.txt for an overview.
15 * Note: edit user interface and cache support functions have been
16 * moved to separate EditPage and HTMLFileCache classes.
18 * @internal documentation reviewed 15 Mar 2010
20 class Article
extends Page
{
36 * @var ParserOptions: ParserOptions object for $wgUser articles
38 public $mParserOptions;
41 var $mContentLoaded = false; // !<
47 var $mRedirectedFrom = null;
50 * @var mixed: boolean false or URL string
52 var $mRedirectUrl = false; // !<
53 var $mRevIdFetched = 0; // !<
58 var $mRevision = null;
68 * Constructor and clear the article
69 * @param $title Title Reference to a Title object.
70 * @param $oldId Integer revision ID, null to fetch from request, zero for current
72 public function __construct( Title
$title, $oldId = null ) {
73 $this->mOldId
= $oldId;
74 $this->mPage
= $this->newPage( $title );
81 protected function newPage( Title
$title ) {
82 return new WikiPage( $title );
86 * Constructor from a page id
87 * @param $id Int article ID to load
88 * @return Article|null
90 public static function newFromID( $id ) {
91 $t = Title
::newFromID( $id );
92 # @todo FIXME: Doesn't inherit right
93 return $t == null ?
null : new self( $t );
94 # return $t == null ? null : new static( $t ); // PHP 5.3
98 * Create an Article object of the appropriate class for the given page.
100 * @param $title Title
101 * @param $context IContextSource
102 * @return Article object
104 public static function newFromTitle( $title, IContextSource
$context ) {
105 if ( NS_MEDIA
== $title->getNamespace() ) {
106 // FIXME: where should this go?
107 $title = Title
::makeTitle( NS_FILE
, $title->getDBkey() );
111 wfRunHooks( 'ArticleFromTitle', array( &$title, &$page ) );
113 switch( $title->getNamespace() ) {
115 $page = new ImagePage( $title );
118 $page = new CategoryPage( $title );
121 $page = new Article( $title );
124 $page->setContext( $context );
130 * Create an Article object of the appropriate class for the given page.
132 * @param $page WikiPage
133 * @param $context IContextSource
134 * @return Article object
136 public static function newFromWikiPage( WikiPage
$page, IContextSource
$context ) {
137 $article = self
::newFromTitle( $page->getTitle(), $context );
138 $article->mPage
= $page; // override to keep process cached vars
143 * Tell the page view functions that this view was redirected
144 * from another page on the wiki.
145 * @param $from Title object.
147 public function setRedirectedFrom( Title
$from ) {
148 $this->mRedirectedFrom
= $from;
152 * Get the title object of the article
153 * @return Title object of this page
155 public function getTitle() {
156 return $this->mPage
->getTitle();
162 public function clear() {
163 $this->mContentLoaded
= false;
165 $this->mRedirectedFrom
= null; # Title object if set
166 $this->mRevIdFetched
= 0;
167 $this->mRedirectUrl
= false;
169 $this->mPage
->clear();
173 * Note that getContent/loadContent do not follow redirects anymore.
174 * If you need to fetch redirectable content easily, try
175 * the shortcut in Article::followRedirect()
177 * This function has side effects! Do not use this function if you
178 * only want the real revision text if any.
180 * @return Return the text of this revision
182 public function getContent() {
185 wfProfileIn( __METHOD__
);
187 if ( $this->mPage
->getID() === 0 ) {
188 # If this is a MediaWiki:x message, then load the messages
189 # and return the message value for x.
190 if ( $this->getTitle()->getNamespace() == NS_MEDIAWIKI
) {
191 $text = $this->getTitle()->getDefaultMessageText();
192 if ( $text === false ) {
196 $text = wfMsgExt( $wgUser->isLoggedIn() ?
'noarticletext' : 'noarticletextanon', 'parsemag' );
198 wfProfileOut( __METHOD__
);
202 $this->fetchContent();
203 wfProfileOut( __METHOD__
);
205 return $this->mContent
;
210 * @return int The oldid of the article that is to be shown, 0 for the
213 public function getOldID() {
214 if ( is_null( $this->mOldId
) ) {
215 $this->mOldId
= $this->getOldIDFromRequest();
218 return $this->mOldId
;
222 * Sets $this->mRedirectUrl to a correct URL if the query parameters are incorrect
224 * @return int The old id for the request
226 public function getOldIDFromRequest() {
229 $this->mRedirectUrl
= false;
231 $oldid = $wgRequest->getIntOrNull( 'oldid' );
233 if ( $oldid === null ) {
237 if ( $oldid !== 0 ) {
238 # Load the given revision and check whether the page is another one.
239 # In that case, update this instance to reflect the change.
240 $this->mRevision
= Revision
::newFromId( $oldid );
241 if ( $this->mRevision
!== null ) {
242 // Revision title doesn't match the page title given?
243 if ( $this->mPage
->getID() != $this->mRevision
->getPage() ) {
244 $function = array( get_class( $this->mPage
), 'newFromID' );
245 $this->mPage
= call_user_func( $function, $this->mRevision
->getPage() );
250 if ( $wgRequest->getVal( 'direction' ) == 'next' ) {
251 $nextid = $this->getTitle()->getNextRevisionID( $oldid );
255 $this->mRedirectUrl
= $this->getTitle()->getFullURL( 'redirect=no' );
257 } elseif ( $wgRequest->getVal( 'direction' ) == 'prev' ) {
258 $previd = $this->getTitle()->getPreviousRevisionID( $oldid );
268 * Load the revision (including text) into this object
270 * @deprecated in 1.19; use fetchContent()
272 function loadContent() {
273 wfDeprecated( __METHOD__
, '1.19' );
274 $this->fetchContent();
278 * Get text of an article from database
279 * Does *NOT* follow redirects.
281 * @return mixed string containing article contents, or false if null
283 function fetchContent() {
284 if ( $this->mContentLoaded
) {
285 return $this->mContent
;
288 wfProfileIn( __METHOD__
);
290 $this->mContentLoaded
= true;
292 $oldid = $this->getOldID();
294 # Pre-fill content with error message so that if something
295 # fails we'll have something telling us what we intended.
296 $t = $this->getTitle()->getPrefixedText();
297 $d = $oldid ?
wfMsgExt( 'missingarticle-rev', array( 'escape' ), $oldid ) : '';
298 $this->mContent
= wfMsgNoTrans( 'missing-article', $t, $d ) ;
301 # $this->mRevision might already be fetched by getOldIDFromRequest()
302 if ( !$this->mRevision
) {
303 $this->mRevision
= Revision
::newFromId( $oldid );
304 if ( !$this->mRevision
) {
305 wfDebug( __METHOD__
. " failed to retrieve specified revision, id $oldid\n" );
306 wfProfileOut( __METHOD__
);
311 if ( !$this->mPage
->getLatest() ) {
312 wfDebug( __METHOD__
. " failed to find page data for title " . $this->getTitle()->getPrefixedText() . "\n" );
313 wfProfileOut( __METHOD__
);
317 $this->mRevision
= $this->mPage
->getRevision();
318 if ( !$this->mRevision
) {
319 wfDebug( __METHOD__
. " failed to retrieve current page, rev_id " . $this->mPage
->getLatest() . "\n" );
320 wfProfileOut( __METHOD__
);
325 // @todo FIXME: Horrible, horrible! This content-loading interface just plain sucks.
326 // We should instead work with the Revision object when we need it...
327 $this->mContent
= $this->mRevision
->getText( Revision
::FOR_THIS_USER
); // Loads if user is allowed
328 $this->mRevIdFetched
= $this->mRevision
->getId();
330 wfRunHooks( 'ArticleAfterFetchContent', array( &$this, &$this->mContent
) );
332 wfProfileOut( __METHOD__
);
334 return $this->mContent
;
339 * @deprecated since 1.18
341 public function forUpdate() {
342 wfDeprecated( __METHOD__
, '1.18' );
346 * Returns true if the currently-referenced revision is the current edit
347 * to this page (and it exists).
350 public function isCurrent() {
351 # If no oldid, this is the current version.
352 if ( $this->getOldID() == 0 ) {
356 return $this->mPage
->exists() && $this->mRevision
&& $this->mRevision
->isCurrent();
360 * Get the fetched Revision object depending on request parameters or null
364 * @return Revision|null
366 public function getRevisionFetched() {
367 $this->fetchContent();
369 return $this->mRevision
;
373 * Use this to fetch the rev ID used on page views
375 * @return int revision ID of last article revision
377 public function getRevIdFetched() {
378 if ( $this->mRevIdFetched
) {
379 return $this->mRevIdFetched
;
381 return $this->mPage
->getLatest();
386 * This is the default action of the index.php entry point: just view the
387 * page of the given title.
389 public function view() {
390 global $wgUser, $wgOut, $wgRequest, $wgParser;
391 global $wgUseFileCache, $wgUseETag, $wgDebugToolbar;
393 wfProfileIn( __METHOD__
);
395 # Get variables from query string
396 # As side effect this will load the revision and update the title
397 # in a revision ID is passed in the request, so this should remain
398 # the first call of this method even if $oldid is used way below.
399 $oldid = $this->getOldID();
401 # Another whitelist check in case getOldID() is altering the title
402 $permErrors = $this->getTitle()->getUserPermissionsErrors( 'read', $wgUser );
403 if ( count( $permErrors ) ) {
404 wfDebug( __METHOD__
. ": denied on secondary read check\n" );
405 wfProfileOut( __METHOD__
);
406 throw new PermissionsError( 'read', $permErrors );
409 # getOldID() may as well want us to redirect somewhere else
410 if ( $this->mRedirectUrl
) {
411 $wgOut->redirect( $this->mRedirectUrl
);
412 wfDebug( __METHOD__
. ": redirecting due to oldid\n" );
413 wfProfileOut( __METHOD__
);
418 # If we got diff in the query, we want to see a diff page instead of the article.
419 if ( $wgRequest->getCheck( 'diff' ) ) {
420 wfDebug( __METHOD__
. ": showing diff page\n" );
421 $this->showDiffPage();
422 wfProfileOut( __METHOD__
);
427 # Set page title (may be overridden by DISPLAYTITLE)
428 $wgOut->setPageTitle( $this->getTitle()->getPrefixedText() );
430 $wgOut->setArticleFlag( true );
431 # Allow frames by default
432 $wgOut->allowClickjacking();
434 $parserCache = ParserCache
::singleton();
436 $parserOptions = $this->getParserOptions();
437 # Render printable version, use printable version cache
438 if ( $wgOut->isPrintable() ) {
439 $parserOptions->setIsPrintable( true );
440 $parserOptions->setEditSection( false );
441 } elseif ( !$this->getTitle()->quickUserCan( 'edit' ) ) {
442 $parserOptions->setEditSection( false );
445 # Try client and file cache
446 if ( !$wgDebugToolbar && $oldid === 0 && $this->mPage
->checkTouched() ) {
448 $wgOut->setETag( $parserCache->getETag( $this, $parserOptions ) );
451 # Is it client cached?
452 if ( $wgOut->checkLastModified( $this->mPage
->getTouched() ) ) {
453 wfDebug( __METHOD__
. ": done 304\n" );
454 wfProfileOut( __METHOD__
);
458 } elseif ( $wgUseFileCache && $this->tryFileCache() ) {
459 wfDebug( __METHOD__
. ": done file cache\n" );
460 # tell wgOut that output is taken care of
462 $this->mPage
->doViewUpdates( $wgUser );
463 wfProfileOut( __METHOD__
);
469 # Should the parser cache be used?
470 $useParserCache = $this->mPage
->isParserCacheUsed( $parserOptions, $oldid );
471 wfDebug( 'Article::view using parser cache: ' . ( $useParserCache ?
'yes' : 'no' ) . "\n" );
472 if ( $wgUser->getStubThreshold() ) {
473 wfIncrStats( 'pcache_miss_stub' );
476 $this->showRedirectedFromHeader();
477 $this->showNamespaceHeader();
479 # Iterate through the possible ways of constructing the output text.
480 # Keep going until $outputDone is set, or we run out of things to do.
483 $this->mParserOutput
= false;
485 while ( !$outputDone && ++
$pass ) {
488 wfRunHooks( 'ArticleViewHeader', array( &$this, &$outputDone, &$useParserCache ) );
491 # Early abort if the page doesn't exist
492 if ( !$this->mPage
->exists() ) {
493 wfDebug( __METHOD__
. ": showing missing article\n" );
494 $this->showMissingArticle();
495 wfProfileOut( __METHOD__
);
499 # Try the parser cache
500 if ( $useParserCache ) {
501 $this->mParserOutput
= $parserCache->get( $this, $parserOptions );
503 if ( $this->mParserOutput
!== false ) {
505 wfDebug( __METHOD__
. ": showing parser cache contents for current rev permalink\n" );
506 $this->setOldSubtitle( $oldid );
508 wfDebug( __METHOD__
. ": showing parser cache contents\n" );
510 $wgOut->addParserOutput( $this->mParserOutput
);
511 # Ensure that UI elements requiring revision ID have
512 # the correct version information.
513 $wgOut->setRevisionId( $this->mPage
->getLatest() );
514 # Preload timestamp to avoid a DB hit
515 $cachedTimestamp = $this->mParserOutput
->getTimestamp();
516 if ( $cachedTimestamp !== null ) {
517 $wgOut->setRevisionTimestamp( $cachedTimestamp );
518 $this->mPage
->setTimestamp( $cachedTimestamp );
525 # This will set $this->mRevision if needed
526 $this->fetchContent();
528 # Are we looking at an old revision
529 if ( $oldid && $this->mRevision
) {
530 $this->setOldSubtitle( $oldid );
532 if ( !$this->showDeletedRevisionHeader() ) {
533 wfDebug( __METHOD__
. ": cannot view deleted revision\n" );
534 wfProfileOut( __METHOD__
);
539 # Ensure that UI elements requiring revision ID have
540 # the correct version information.
541 $wgOut->setRevisionId( $this->getRevIdFetched() );
542 # Preload timestamp to avoid a DB hit
543 $wgOut->setRevisionTimestamp( $this->getTimestamp() );
545 # Pages containing custom CSS or JavaScript get special treatment
546 if ( $this->getTitle()->isCssOrJsPage() ||
$this->getTitle()->isCssJsSubpage() ) {
547 wfDebug( __METHOD__
. ": showing CSS/JS source\n" );
548 $this->showCssOrJsPage();
550 } elseif( !wfRunHooks( 'ArticleViewCustom', array( $this->mContent
, $this->getTitle(), $wgOut ) ) ) {
551 # Allow extensions do their own custom view for certain pages
554 $text = $this->getContent();
555 $rt = Title
::newFromRedirectArray( $text );
557 wfDebug( __METHOD__
. ": showing redirect=no page\n" );
558 # Viewing a redirect page (e.g. with parameter redirect=no)
559 $wgOut->addHTML( $this->viewRedirect( $rt ) );
560 # Parse just to get categories, displaytitle, etc.
561 $this->mParserOutput
= $wgParser->parse( $text, $this->getTitle(), $parserOptions );
562 $wgOut->addParserOutputNoText( $this->mParserOutput
);
568 # Run the parse, protected by a pool counter
569 wfDebug( __METHOD__
. ": doing uncached parse\n" );
571 $poolArticleView = new PoolWorkArticleView( $this, $parserOptions,
572 $this->getRevIdFetched(), $useParserCache, $this->getContent() );
574 if ( !$poolArticleView->execute() ) {
575 $error = $poolArticleView->getError();
577 $wgOut->clearHTML(); // for release() errors
578 $wgOut->enableClientCache( false );
579 $wgOut->setRobotPolicy( 'noindex,nofollow' );
581 $errortext = $error->getWikiText( false, 'view-pool-error' );
582 $wgOut->addWikiText( '<div class="errorbox">' . $errortext . '</div>' );
584 # Connection or timeout error
585 wfProfileOut( __METHOD__
);
589 $this->mParserOutput
= $poolArticleView->getParserOutput();
590 $wgOut->addParserOutput( $this->mParserOutput
);
592 # Don't cache a dirty ParserOutput object
593 if ( $poolArticleView->getIsDirty() ) {
594 $wgOut->setSquidMaxage( 0 );
595 $wgOut->addHTML( "<!-- parser cache is expired, sending anyway due to pool overload-->\n" );
600 # Should be unreachable, but just in case...
606 # Get the ParserOutput actually *displayed* here.
607 # Note that $this->mParserOutput is the *current* version output.
608 $pOutput = ( $outputDone instanceof ParserOutput
)
609 ?
$outputDone // object fetched by hook
610 : $this->mParserOutput
;
612 # Adjust title for main page & pages with displaytitle
614 $this->adjustDisplayTitle( $pOutput );
617 # For the main page, overwrite the <title> element with the con-
618 # tents of 'pagetitle-view-mainpage' instead of the default (if
620 # This message always exists because it is in the i18n files
621 if ( $this->getTitle()->isMainPage() ) {
622 $msg = wfMessage( 'pagetitle-view-mainpage' )->inContentLanguage();
623 if ( !$msg->isDisabled() ) {
624 $wgOut->setHTMLTitle( $msg->title( $this->getTitle() )->text() );
628 # Check for any __NOINDEX__ tags on the page using $pOutput
629 $policy = $this->getRobotPolicy( 'view', $pOutput );
630 $wgOut->setIndexPolicy( $policy['index'] );
631 $wgOut->setFollowPolicy( $policy['follow'] );
633 $this->showViewFooter();
634 $this->mPage
->doViewUpdates( $wgUser );
636 wfProfileOut( __METHOD__
);
640 * Adjust title for pages with displaytitle, -{T|}- or language conversion
641 * @param $pOutput ParserOutput
643 public function adjustDisplayTitle( ParserOutput
$pOutput ) {
645 # Adjust the title if it was set by displaytitle, -{T|}- or language conversion
646 $titleText = $pOutput->getTitleText();
647 if ( strval( $titleText ) !== '' ) {
648 $wgOut->setPageTitle( $titleText );
653 * Show a diff page according to current request variables. For use within
654 * Article::view() only, other callers should use the DifferenceEngine class.
656 public function showDiffPage() {
657 global $wgRequest, $wgUser;
659 $diff = $wgRequest->getVal( 'diff' );
660 $rcid = $wgRequest->getVal( 'rcid' );
661 $diffOnly = $wgRequest->getBool( 'diffonly', $wgUser->getOption( 'diffonly' ) );
662 $purge = $wgRequest->getVal( 'action' ) == 'purge';
663 $unhide = $wgRequest->getInt( 'unhide' ) == 1;
664 $oldid = $this->getOldID();
666 $de = new DifferenceEngine( $this->getContext(), $oldid, $diff, $rcid, $purge, $unhide );
667 // DifferenceEngine directly fetched the revision:
668 $this->mRevIdFetched
= $de->mNewid
;
669 $de->showDiffPage( $diffOnly );
671 if ( $diff == 0 ||
$diff == $this->mPage
->getLatest() ) {
672 # Run view updates for current revision only
673 $this->mPage
->doViewUpdates( $wgUser );
678 * Show a page view for a page formatted as CSS or JavaScript. To be called by
679 * Article::view() only.
681 * This is hooked by SyntaxHighlight_GeSHi to do syntax highlighting of these
684 protected function showCssOrJsPage() {
687 $dir = $this->getContext()->getLanguage()->getDir();
688 $lang = $this->getContext()->getLanguage()->getCode();
690 $wgOut->wrapWikiMsg( "<div id='mw-clearyourcache' lang='$lang' dir='$dir' class='mw-content-$dir'>\n$1\n</div>",
693 // Give hooks a chance to customise the output
694 if ( wfRunHooks( 'ShowRawCssJs', array( $this->mContent
, $this->getTitle(), $wgOut ) ) ) {
695 // Wrap the whole lot in a <pre> and don't parse
697 preg_match( '!\.(css|js)$!u', $this->getTitle()->getText(), $m );
698 $wgOut->addHTML( "<pre class=\"mw-code mw-{$m[1]}\" dir=\"ltr\">\n" );
699 $wgOut->addHTML( htmlspecialchars( $this->mContent
) );
700 $wgOut->addHTML( "\n</pre>\n" );
705 * Get the robot policy to be used for the current view
706 * @param $action String the action= GET parameter
707 * @param $pOutput ParserOutput
708 * @return Array the policy that should be set
709 * TODO: actions other than 'view'
711 public function getRobotPolicy( $action, $pOutput ) {
712 global $wgOut, $wgArticleRobotPolicies, $wgNamespaceRobotPolicies;
713 global $wgDefaultRobotPolicy, $wgRequest;
715 $ns = $this->getTitle()->getNamespace();
717 if ( $ns == NS_USER ||
$ns == NS_USER_TALK
) {
718 # Don't index user and user talk pages for blocked users (bug 11443)
719 if ( !$this->getTitle()->isSubpage() ) {
720 if ( Block
::newFromTarget( null, $this->getTitle()->getText() ) instanceof Block
) {
722 'index' => 'noindex',
723 'follow' => 'nofollow'
729 if ( $this->mPage
->getID() === 0 ||
$this->getOldID() ) {
730 # Non-articles (special pages etc), and old revisions
732 'index' => 'noindex',
733 'follow' => 'nofollow'
735 } elseif ( $wgOut->isPrintable() ) {
736 # Discourage indexing of printable versions, but encourage following
738 'index' => 'noindex',
741 } elseif ( $wgRequest->getInt( 'curid' ) ) {
742 # For ?curid=x urls, disallow indexing
744 'index' => 'noindex',
749 # Otherwise, construct the policy based on the various config variables.
750 $policy = self
::formatRobotPolicy( $wgDefaultRobotPolicy );
752 if ( isset( $wgNamespaceRobotPolicies[$ns] ) ) {
753 # Honour customised robot policies for this namespace
754 $policy = array_merge(
756 self
::formatRobotPolicy( $wgNamespaceRobotPolicies[$ns] )
759 if ( $this->getTitle()->canUseNoindex() && is_object( $pOutput ) && $pOutput->getIndexPolicy() ) {
760 # __INDEX__ and __NOINDEX__ magic words, if allowed. Incorporates
761 # a final sanity check that we have really got the parser output.
762 $policy = array_merge(
764 array( 'index' => $pOutput->getIndexPolicy() )
768 if ( isset( $wgArticleRobotPolicies[$this->getTitle()->getPrefixedText()] ) ) {
769 # (bug 14900) site config can override user-defined __INDEX__ or __NOINDEX__
770 $policy = array_merge(
772 self
::formatRobotPolicy( $wgArticleRobotPolicies[$this->getTitle()->getPrefixedText()] )
780 * Converts a String robot policy into an associative array, to allow
781 * merging of several policies using array_merge().
782 * @param $policy Mixed, returns empty array on null/false/'', transparent
783 * to already-converted arrays, converts String.
784 * @return Array: 'index' => <indexpolicy>, 'follow' => <followpolicy>
786 public static function formatRobotPolicy( $policy ) {
787 if ( is_array( $policy ) ) {
789 } elseif ( !$policy ) {
793 $policy = explode( ',', $policy );
794 $policy = array_map( 'trim', $policy );
797 foreach ( $policy as $var ) {
798 if ( in_array( $var, array( 'index', 'noindex' ) ) ) {
799 $arr['index'] = $var;
800 } elseif ( in_array( $var, array( 'follow', 'nofollow' ) ) ) {
801 $arr['follow'] = $var;
809 * If this request is a redirect view, send "redirected from" subtitle to
810 * $wgOut. Returns true if the header was needed, false if this is not a
811 * redirect view. Handles both local and remote redirects.
815 public function showRedirectedFromHeader() {
816 global $wgOut, $wgRequest, $wgRedirectSources;
818 $rdfrom = $wgRequest->getVal( 'rdfrom' );
820 if ( isset( $this->mRedirectedFrom
) ) {
821 // This is an internally redirected page view.
822 // We'll need a backlink to the source page for navigation.
823 if ( wfRunHooks( 'ArticleViewRedirect', array( &$this ) ) ) {
824 $redir = Linker
::linkKnown(
825 $this->mRedirectedFrom
,
828 array( 'redirect' => 'no' )
831 $wgOut->addSubtitle( wfMessage( 'redirectedfrom' )->rawParams( $redir ) );
833 // Set the fragment if one was specified in the redirect
834 if ( strval( $this->getTitle()->getFragment() ) != '' ) {
835 $fragment = Xml
::escapeJsString( $this->getTitle()->getFragmentForURL() );
836 $wgOut->addInlineScript( "redirectToFragment(\"$fragment\");" );
839 // Add a <link rel="canonical"> tag
840 $wgOut->addLink( array( 'rel' => 'canonical',
841 'href' => $this->getTitle()->getLocalURL() )
844 // Tell $wgOut the user arrived at this article through a redirect
845 $wgOut->setRedirectedFrom( $this->mRedirectedFrom
);
849 } elseif ( $rdfrom ) {
850 // This is an externally redirected view, from some other wiki.
851 // If it was reported from a trusted site, supply a backlink.
852 if ( $wgRedirectSources && preg_match( $wgRedirectSources, $rdfrom ) ) {
853 $redir = Linker
::makeExternalLink( $rdfrom, $rdfrom );
854 $wgOut->addSubtitle( wfMessage( 'redirectedfrom' )->rawParams( $redir ) );
864 * Show a header specific to the namespace currently being viewed, like
865 * [[MediaWiki:Talkpagetext]]. For Article::view().
867 public function showNamespaceHeader() {
870 if ( $this->getTitle()->isTalkPage() ) {
871 if ( !wfMessage( 'talkpageheader' )->isDisabled() ) {
872 $wgOut->wrapWikiMsg( "<div class=\"mw-talkpageheader\">\n$1\n</div>", array( 'talkpageheader' ) );
878 * Show the footer section of an ordinary page view
880 public function showViewFooter() {
883 # check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page
884 if ( $this->getTitle()->getNamespace() == NS_USER_TALK
&& IP
::isValid( $this->getTitle()->getText() ) ) {
885 $wgOut->addWikiMsg( 'anontalkpagetext' );
888 # If we have been passed an &rcid= parameter, we want to give the user a
889 # chance to mark this new article as patrolled.
890 $this->showPatrolFooter();
892 wfRunHooks( 'ArticleViewFooter', array( $this ) );
897 * If patrol is possible, output a patrol UI box. This is called from the
898 * footer section of ordinary page views. If patrol is not possible or not
899 * desired, does nothing.
901 public function showPatrolFooter() {
902 global $wgOut, $wgRequest, $wgUser;
904 $rcid = $wgRequest->getVal( 'rcid' );
906 if ( !$rcid ||
!$this->getTitle()->quickUserCan( 'patrol' ) ) {
910 $token = $wgUser->getEditToken( $rcid );
911 $wgOut->preventClickjacking();
914 "<div class='patrollink'>" .
916 'markaspatrolledlink',
919 wfMsgHtml( 'markaspatrolledtext' ),
922 'action' => 'markpatrolled',
926 array( 'known', 'noclasses' )
934 * Show the error text for a missing article. For articles in the MediaWiki
935 * namespace, show the default message text. To be called from Article::view().
937 public function showMissingArticle() {
938 global $wgOut, $wgRequest, $wgUser, $wgSend404Code;
940 # Show info in user (talk) namespace. Does the user exist? Is he blocked?
941 if ( $this->getTitle()->getNamespace() == NS_USER ||
$this->getTitle()->getNamespace() == NS_USER_TALK
) {
942 $parts = explode( '/', $this->getTitle()->getText() );
943 $rootPart = $parts[0];
944 $user = User
::newFromName( $rootPart, false /* allow IP users*/ );
945 $ip = User
::isIP( $rootPart );
947 if ( !($user && $user->isLoggedIn()) && !$ip ) { # User does not exist
948 $wgOut->wrapWikiMsg( "<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>",
949 array( 'userpage-userdoesnotexist-view', wfEscapeWikiText( $rootPart ) ) );
950 } elseif ( $user->isBlocked() ) { # Show log extract if the user is currently blocked
951 LogEventsList
::showLogExtract(
954 $user->getUserPage()->getPrefixedText(),
958 'showIfEmpty' => false,
960 'blocked-notice-logextract',
961 $user->getName() # Support GENDER in notice
968 wfRunHooks( 'ShowMissingArticle', array( $this ) );
970 # Show delete and move logs
971 LogEventsList
::showLogExtract( $wgOut, array( 'delete', 'move' ), $this->getTitle()->getPrefixedText(), '',
973 'conds' => array( "log_action != 'revision'" ),
974 'showIfEmpty' => false,
975 'msgKey' => array( 'moveddeleted-notice' ) )
979 $oldid = $this->getOldID();
981 $text = wfMsgNoTrans( 'missing-article',
982 $this->getTitle()->getPrefixedText(),
983 wfMsgNoTrans( 'missingarticle-rev', $oldid ) );
984 } elseif ( $this->getTitle()->getNamespace() === NS_MEDIAWIKI
) {
985 // Use the default message text
986 $text = $this->getTitle()->getDefaultMessageText();
988 $createErrors = $this->getTitle()->getUserPermissionsErrors( 'create', $wgUser );
989 $editErrors = $this->getTitle()->getUserPermissionsErrors( 'edit', $wgUser );
990 $errors = array_merge( $createErrors, $editErrors );
992 if ( !count( $errors ) ) {
993 $text = wfMsgNoTrans( 'noarticletext' );
995 $text = wfMsgNoTrans( 'noarticletext-nopermission' );
998 $text = "<div class='noarticletext'>\n$text\n</div>";
1000 if ( !$this->mPage
->hasViewableContent() && $wgSend404Code ) {
1001 // If there's no backing content, send a 404 Not Found
1002 // for better machine handling of broken links.
1003 $wgRequest->response()->header( "HTTP/1.1 404 Not Found" );
1006 $wgOut->addWikiText( $text );
1010 * If the revision requested for view is deleted, check permissions.
1011 * Send either an error message or a warning header to $wgOut.
1013 * @return boolean true if the view is allowed, false if not.
1015 public function showDeletedRevisionHeader() {
1016 global $wgOut, $wgRequest;
1018 if ( !$this->mRevision
->isDeleted( Revision
::DELETED_TEXT
) ) {
1023 // If the user is not allowed to see it...
1024 if ( !$this->mRevision
->userCan( Revision
::DELETED_TEXT
) ) {
1025 $wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1026 'rev-deleted-text-permission' );
1029 // If the user needs to confirm that they want to see it...
1030 } elseif ( $wgRequest->getInt( 'unhide' ) != 1 ) {
1031 # Give explanation and add a link to view the revision...
1032 $oldid = intval( $this->getOldID() );
1033 $link = $this->getTitle()->getFullUrl( "oldid={$oldid}&unhide=1" );
1034 $msg = $this->mRevision
->isDeleted( Revision
::DELETED_RESTRICTED
) ?
1035 'rev-suppressed-text-unhide' : 'rev-deleted-text-unhide';
1036 $wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
1037 array( $msg, $link ) );
1040 // We are allowed to see...
1042 $msg = $this->mRevision
->isDeleted( Revision
::DELETED_RESTRICTED
) ?
1043 'rev-suppressed-text-view' : 'rev-deleted-text-view';
1044 $wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n", $msg );
1051 * Generate the navigation links when browsing through an article revisions
1052 * It shows the information as:
1053 * Revision as of \<date\>; view current revision
1054 * \<- Previous version | Next Version -\>
1056 * @param $oldid String: revision ID of this article revision
1058 public function setOldSubtitle( $oldid = 0 ) {
1059 global $wgLang, $wgOut, $wgUser, $wgRequest;
1061 if ( !wfRunHooks( 'DisplayOldSubtitle', array( &$this, &$oldid ) ) ) {
1065 $unhide = $wgRequest->getInt( 'unhide' ) == 1;
1067 # Cascade unhide param in links for easy deletion browsing
1068 $extraParams = array();
1069 if ( $wgRequest->getVal( 'unhide' ) ) {
1070 $extraParams['unhide'] = 1;
1073 $revision = Revision
::newFromId( $oldid );
1074 $timestamp = $revision->getTimestamp();
1076 $current = ( $oldid == $this->mPage
->getLatest() );
1077 $td = $wgLang->timeanddate( $timestamp, true );
1078 $tddate = $wgLang->date( $timestamp, true );
1079 $tdtime = $wgLang->time( $timestamp, true );
1081 # Show user links if allowed to see them. If hidden, then show them only if requested...
1082 $userlinks = Linker
::revUserTools( $revision, !$unhide );
1084 $infomsg = $current && !wfMessage( 'revision-info-current' )->isDisabled()
1085 ?
'revision-info-current'
1088 $wgOut->addSubtitle( "<div id=\"mw-{$infomsg}\">" . wfMessage( $infomsg,
1089 $td )->rawParams( $userlinks )->params( $revision->getID(), $tddate,
1090 $tdtime, $revision->getUser() )->parse() . "</div>" );
1093 ?
wfMsgHtml( 'currentrevisionlink' )
1096 wfMsgHtml( 'currentrevisionlink' ),
1099 array( 'known', 'noclasses' )
1102 ?
wfMsgHtml( 'diff' )
1105 wfMsgHtml( 'diff' ),
1111 array( 'known', 'noclasses' )
1113 $prev = $this->getTitle()->getPreviousRevisionID( $oldid ) ;
1117 wfMsgHtml( 'previousrevision' ),
1120 'direction' => 'prev',
1123 array( 'known', 'noclasses' )
1125 : wfMsgHtml( 'previousrevision' );
1129 wfMsgHtml( 'diff' ),
1135 array( 'known', 'noclasses' )
1137 : wfMsgHtml( 'diff' );
1138 $nextlink = $current
1139 ?
wfMsgHtml( 'nextrevision' )
1142 wfMsgHtml( 'nextrevision' ),
1145 'direction' => 'next',
1148 array( 'known', 'noclasses' )
1150 $nextdiff = $current
1151 ?
wfMsgHtml( 'diff' )
1154 wfMsgHtml( 'diff' ),
1160 array( 'known', 'noclasses' )
1163 $cdel = Linker
::getRevDeleteLink( $wgUser, $revision, $this->getTitle() );
1164 if ( $cdel !== '' ) {
1168 $wgOut->addSubtitle( "<div id=\"mw-revision-nav\">" . $cdel .
1169 wfMsgExt( 'revision-nav', array( 'escapenoentities', 'parsemag', 'replaceafter' ),
1170 $prevdiff, $prevlink, $lnk, $curdiff, $nextlink, $nextdiff ) . "</div>" );
1176 * @param $target Title|Array of destination(s) to redirect
1177 * @param $appendSubtitle Boolean [optional]
1178 * @param $forceKnown Boolean: should the image be shown as a bluelink regardless of existence?
1179 * @return string containing HMTL with redirect link
1181 public function viewRedirect( $target, $appendSubtitle = true, $forceKnown = false ) {
1182 global $wgOut, $wgStylePath;
1184 if ( !is_array( $target ) ) {
1185 $target = array( $target );
1188 $lang = $this->getTitle()->getPageLanguage();
1189 $imageDir = $lang->getDir();
1191 if ( $appendSubtitle ) {
1192 $wgOut->appendSubtitle( wfMsgHtml( 'redirectpagesub' ) );
1195 // the loop prepends the arrow image before the link, so the first case needs to be outside
1200 $title = array_shift( $target );
1202 if ( $forceKnown ) {
1203 $link = Linker
::linkKnown( $title, htmlspecialchars( $title->getFullText() ) );
1205 $link = Linker
::link( $title, htmlspecialchars( $title->getFullText() ) );
1208 $nextRedirect = $wgStylePath . '/common/images/nextredirect' . $imageDir . '.png';
1209 $alt = $lang->isRTL() ?
'←' : '→';
1210 // Automatically append redirect=no to each link, since most of them are redirect pages themselves.
1211 foreach ( $target as $rt ) {
1212 $link .= Html
::element( 'img', array( 'src' => $nextRedirect, 'alt' => $alt ) );
1213 if ( $forceKnown ) {
1214 $link .= Linker
::linkKnown( $rt, htmlspecialchars( $rt->getFullText(), array(), array( 'redirect' => 'no' ) ) );
1216 $link .= Linker
::link( $rt, htmlspecialchars( $rt->getFullText() ), array(), array( 'redirect' => 'no' ) );
1220 $imageUrl = $wgStylePath . '/common/images/redirect' . $imageDir . '.png';
1221 return '<div class="redirectMsg">' .
1222 Html
::element( 'img', array( 'src' => $imageUrl, 'alt' => '#REDIRECT' ) ) .
1223 '<span class="redirectText">' . $link . '</span></div>';
1227 * Handle action=render
1229 public function render() {
1232 $wgOut->setArticleBodyOnly( true );
1237 * action=protect handler
1239 public function protect() {
1240 $form = new ProtectionForm( $this );
1245 * action=unprotect handler (alias)
1247 public function unprotect() {
1252 * UI entry point for page deletion
1254 public function delete() {
1255 global $wgOut, $wgRequest, $wgLang;
1257 # This code desperately needs to be totally rewritten
1259 $title = $this->getTitle();
1260 $user = $this->getContext()->getUser();
1263 $permission_errors = $title->getUserPermissionsErrors( 'delete', $user );
1264 if ( count( $permission_errors ) ) {
1265 throw new PermissionsError( 'delete', $permission_errors );
1268 # Read-only check...
1269 if ( wfReadOnly() ) {
1270 throw new ReadOnlyError
;
1273 # Better double-check that it hasn't been deleted yet!
1274 $dbw = wfGetDB( DB_MASTER
);
1275 $conds = $title->pageCond();
1276 $latest = $dbw->selectField( 'page', 'page_latest', $conds, __METHOD__
);
1277 if ( $latest === false ) {
1278 $wgOut->setPageTitle( wfMessage( 'cannotdelete-title', $title->getPrefixedText() ) );
1279 $wgOut->wrapWikiMsg( "<div class=\"error mw-error-cannotdelete\">\n$1\n</div>",
1280 array( 'cannotdelete', wfEscapeWikiText( $title->getPrefixedText() ) )
1282 $wgOut->addHTML( Xml
::element( 'h2', null, LogPage
::logName( 'delete' ) ) );
1283 LogEventsList
::showLogExtract(
1286 $title->getPrefixedText()
1292 $deleteReasonList = $wgRequest->getText( 'wpDeleteReasonList', 'other' );
1293 $deleteReason = $wgRequest->getText( 'wpReason' );
1295 if ( $deleteReasonList == 'other' ) {
1296 $reason = $deleteReason;
1297 } elseif ( $deleteReason != '' ) {
1298 // Entry from drop down menu + additional comment
1299 $reason = $deleteReasonList . wfMsgForContent( 'colon-separator' ) . $deleteReason;
1301 $reason = $deleteReasonList;
1304 if ( $wgRequest->wasPosted() && $user->matchEditToken( $wgRequest->getVal( 'wpEditToken' ),
1305 array( 'delete', $this->getTitle()->getPrefixedText() ) ) )
1307 # Flag to hide all contents of the archived revisions
1308 $suppress = $wgRequest->getVal( 'wpSuppress' ) && $user->isAllowed( 'suppressrevision' );
1310 $this->doDelete( $reason, $suppress );
1312 if ( $wgRequest->getCheck( 'wpWatch' ) && $user->isLoggedIn() ) {
1314 } elseif ( $title->userIsWatching() ) {
1321 // Generate deletion reason
1322 $hasHistory = false;
1324 $reason = $this->generateReason( $hasHistory );
1327 // If the page has a history, insert a warning
1328 if ( $hasHistory ) {
1329 $revisions = $this->mTitle
->estimateRevisionCount();
1330 // @todo FIXME: i18n issue/patchwork message
1331 $wgOut->addHTML( '<strong class="mw-delete-warning-revisions">' .
1332 wfMsgExt( 'historywarning', array( 'parseinline' ), $wgLang->formatNum( $revisions ) ) .
1333 wfMsgHtml( 'word-separator' ) . Linker
::link( $title,
1334 wfMsgHtml( 'history' ),
1335 array( 'rel' => 'archives' ),
1336 array( 'action' => 'history' ) ) .
1340 if ( $this->mTitle
->isBigDeletion() ) {
1341 global $wgDeleteRevisionsLimit;
1342 $wgOut->wrapWikiMsg( "<div class='error'>\n$1\n</div>\n",
1343 array( 'delete-warning-toobig', $wgLang->formatNum( $wgDeleteRevisionsLimit ) ) );
1347 return $this->confirmDelete( $reason );
1351 * Output deletion confirmation dialog
1352 * @todo FIXME: Move to another file?
1353 * @param $reason String: prefilled reason
1355 public function confirmDelete( $reason ) {
1358 wfDebug( "Article::confirmDelete\n" );
1360 $wgOut->setPageTitle( wfMessage( 'delete-confirm', $this->getTitle()->getPrefixedText() ) );
1361 $wgOut->addBacklinkSubtitle( $this->getTitle() );
1362 $wgOut->setRobotPolicy( 'noindex,nofollow' );
1363 $wgOut->addWikiMsg( 'confirmdeletetext' );
1365 wfRunHooks( 'ArticleConfirmDelete', array( $this, $wgOut, &$reason ) );
1367 $user = $this->getContext()->getUser();
1369 if ( $user->isAllowed( 'suppressrevision' ) ) {
1370 $suppress = "<tr id=\"wpDeleteSuppressRow\">
1372 <td class='mw-input'><strong>" .
1373 Xml
::checkLabel( wfMsg( 'revdelete-suppress' ),
1374 'wpSuppress', 'wpSuppress', false, array( 'tabindex' => '4' ) ) .
1380 $checkWatch = $user->getBoolOption( 'watchdeletion' ) ||
$this->getTitle()->userIsWatching();
1382 $form = Xml
::openElement( 'form', array( 'method' => 'post',
1383 'action' => $this->getTitle()->getLocalURL( 'action=delete' ), 'id' => 'deleteconfirm' ) ) .
1384 Xml
::openElement( 'fieldset', array( 'id' => 'mw-delete-table' ) ) .
1385 Xml
::tags( 'legend', null, wfMsgExt( 'delete-legend', array( 'parsemag', 'escapenoentities' ) ) ) .
1386 Xml
::openElement( 'table', array( 'id' => 'mw-deleteconfirm-table' ) ) .
1387 "<tr id=\"wpDeleteReasonListRow\">
1388 <td class='mw-label'>" .
1389 Xml
::label( wfMsg( 'deletecomment' ), 'wpDeleteReasonList' ) .
1391 <td class='mw-input'>" .
1392 Xml
::listDropDown( 'wpDeleteReasonList',
1393 wfMsgForContent( 'deletereason-dropdown' ),
1394 wfMsgForContent( 'deletereasonotherlist' ), '', 'wpReasonDropDown', 1 ) .
1397 <tr id=\"wpDeleteReasonRow\">
1398 <td class='mw-label'>" .
1399 Xml
::label( wfMsg( 'deleteotherreason' ), 'wpReason' ) .
1401 <td class='mw-input'>" .
1402 Html
::input( 'wpReason', $reason, 'text', array(
1404 'maxlength' => '255',
1412 # Disallow watching if user is not logged in
1413 if ( $user->isLoggedIn() ) {
1417 <td class='mw-input'>" .
1418 Xml
::checkLabel( wfMsg( 'watchthis' ),
1419 'wpWatch', 'wpWatch', $checkWatch, array( 'tabindex' => '3' ) ) .
1428 <td class='mw-submit'>" .
1429 Xml
::submitButton( wfMsg( 'deletepage' ),
1430 array( 'name' => 'wpConfirmB', 'id' => 'wpConfirmB', 'tabindex' => '5' ) ) .
1433 Xml
::closeElement( 'table' ) .
1434 Xml
::closeElement( 'fieldset' ) .
1435 Html
::hidden( 'wpEditToken', $user->getEditToken( array( 'delete', $this->getTitle()->getPrefixedText() ) ) ) .
1436 Xml
::closeElement( 'form' );
1438 if ( $user->isAllowed( 'editinterface' ) ) {
1439 $title = Title
::makeTitle( NS_MEDIAWIKI
, 'Deletereason-dropdown' );
1440 $link = Linker
::link(
1442 wfMsgHtml( 'delete-edit-reasonlist' ),
1444 array( 'action' => 'edit' )
1446 $form .= '<p class="mw-delete-editreasons">' . $link . '</p>';
1449 $wgOut->addHTML( $form );
1450 $wgOut->addHTML( Xml
::element( 'h2', null, LogPage
::logName( 'delete' ) ) );
1451 LogEventsList
::showLogExtract( $wgOut, 'delete',
1452 $this->getTitle()->getPrefixedText()
1457 * Perform a deletion and output success or failure messages
1459 * @param $suppress bool
1461 public function doDelete( $reason, $suppress = false ) {
1465 if ( $this->mPage
->doDeleteArticle( $reason, $suppress, 0, true, $error ) ) {
1466 $deleted = $this->getTitle()->getPrefixedText();
1468 $wgOut->setPageTitle( wfMessage( 'actioncomplete' ) );
1469 $wgOut->setRobotPolicy( 'noindex,nofollow' );
1471 $loglink = '[[Special:Log/delete|' . wfMsgNoTrans( 'deletionlog' ) . ']]';
1473 $wgOut->addWikiMsg( 'deletedtext', wfEscapeWikiText( $deleted ), $loglink );
1474 $wgOut->returnToMain( false );
1476 $wgOut->setPageTitle( wfMessage( 'cannotdelete-title', $this->getTitle()->getPrefixedText() ) );
1477 if ( $error == '' ) {
1478 $wgOut->wrapWikiMsg( "<div class=\"error mw-error-cannotdelete\">\n$1\n</div>",
1479 array( 'cannotdelete', wfEscapeWikiText( $this->getTitle()->getPrefixedText() ) )
1481 $wgOut->addHTML( Xml
::element( 'h2', null, LogPage
::logName( 'delete' ) ) );
1483 LogEventsList
::showLogExtract(
1486 $this->getTitle()->getPrefixedText()
1489 $wgOut->addHTML( $error );
1494 /* Caching functions */
1497 * checkLastModified returns true if it has taken care of all
1498 * output to the client that is necessary for this request.
1499 * (that is, it has sent a cached version of the page)
1501 * @return boolean true if cached version send, false otherwise
1503 protected function tryFileCache() {
1504 static $called = false;
1507 wfDebug( "Article::tryFileCache(): called twice!?\n" );
1512 if ( $this->isFileCacheable() ) {
1513 $cache = HTMLFileCache
::newFromTitle( $this->getTitle(), 'view' );
1514 if ( $cache->isCacheGood( $this->mPage
->getTouched() ) ) {
1515 wfDebug( "Article::tryFileCache(): about to load file\n" );
1516 $cache->loadFromFileCache( $this->getContext() );
1519 wfDebug( "Article::tryFileCache(): starting buffer\n" );
1520 ob_start( array( &$cache, 'saveToFileCache' ) );
1523 wfDebug( "Article::tryFileCache(): not cacheable\n" );
1530 * Check if the page can be cached
1533 public function isFileCacheable() {
1536 if ( HTMLFileCache
::useFileCache( $this->getContext() ) ) {
1537 $cacheable = $this->mPage
->getID()
1538 && !$this->mRedirectedFrom
&& !$this->getTitle()->isRedirect();
1539 // Extension may have reason to disable file caching on some pages.
1541 $cacheable = wfRunHooks( 'IsFileCacheable', array( &$this ) );
1551 * Lightweight method to get the parser output for a page, checking the parser cache
1552 * and so on. Doesn't consider most of the stuff that WikiPage::view is forced to
1553 * consider, so it's not appropriate to use there.
1555 * @since 1.16 (r52326) for LiquidThreads
1557 * @param $oldid mixed integer Revision ID or null
1558 * @param $user User The relevant user
1559 * @return ParserOutput or false if the given revsion ID is not found
1561 public function getParserOutput( $oldid = null, User
$user = null ) {
1564 $user = is_null( $user ) ?
$wgUser : $user;
1565 $parserOptions = $this->mPage
->makeParserOptions( $user );
1567 return $this->mPage
->getParserOutput( $parserOptions, $oldid );
1571 * Get parser options suitable for rendering the primary article wikitext
1572 * @return ParserOptions|false
1574 public function getParserOptions() {
1576 if ( !$this->mParserOptions
) {
1577 $this->mParserOptions
= $this->mPage
->makeParserOptions( $wgUser );
1579 // Clone to allow modifications of the return value without affecting cache
1580 return clone $this->mParserOptions
;
1584 * Sets the context this Article is executed in
1586 * @param $context IContextSource
1589 public function setContext( $context ) {
1590 $this->mContext
= $context;
1594 * Gets the context this Article is executed in
1596 * @return IContextSource
1599 public function getContext() {
1600 if ( $this->mContext
instanceof IContextSource
) {
1601 return $this->mContext
;
1603 wfDebug( __METHOD__
. " called and \$mContext is null. Return RequestContext::getMain(); for sanity\n" );
1604 return RequestContext
::getMain();
1609 * Info about this page
1610 * @deprecated since 1.19
1612 public function info() {
1613 wfDeprecated( __METHOD__
, '1.19' );
1614 Action
::factory( 'info', $this )->show();
1618 * Mark this particular edit/page as patrolled
1619 * @deprecated since 1.18
1621 public function markpatrolled() {
1622 wfDeprecated( __METHOD__
, '1.18' );
1623 Action
::factory( 'markpatrolled', $this )->show();
1627 * Handle action=purge
1628 * @deprecated since 1.19
1630 public function purge() {
1631 return Action
::factory( 'purge', $this )->show();
1635 * Handle action=revert
1636 * @deprecated since 1.19
1638 public function revert() {
1639 wfDeprecated( __METHOD__
, '1.19' );
1640 Action
::factory( 'revert', $this )->show();
1644 * Handle action=rollback
1645 * @deprecated since 1.19
1647 public function rollback() {
1648 wfDeprecated( __METHOD__
, '1.19' );
1649 Action
::factory( 'rollback', $this )->show();
1653 * User-interface handler for the "watch" action.
1654 * Requires Request to pass a token as of 1.18.
1655 * @deprecated since 1.18
1657 public function watch() {
1658 wfDeprecated( __METHOD__
, '1.18' );
1659 Action
::factory( 'watch', $this )->show();
1663 * Add this page to $wgUser's watchlist
1665 * This is safe to be called multiple times
1667 * @return bool true on successful watch operation
1668 * @deprecated since 1.18
1670 public function doWatch() {
1672 wfDeprecated( __METHOD__
, '1.18' );
1673 return WatchAction
::doWatch( $this->getTitle(), $wgUser );
1677 * User interface handler for the "unwatch" action.
1678 * Requires Request to pass a token as of 1.18.
1679 * @deprecated since 1.18
1681 public function unwatch() {
1682 wfDeprecated( __METHOD__
, '1.18' );
1683 Action
::factory( 'unwatch', $this )->show();
1687 * Stop watching a page
1688 * @return bool true on successful unwatch
1689 * @deprecated since 1.18
1691 public function doUnwatch() {
1693 wfDeprecated( __METHOD__
, '1.18' );
1694 return WatchAction
::doUnwatch( $this->getTitle(), $wgUser );
1698 * Output a redirect back to the article.
1699 * This is typically used after an edit.
1701 * @deprecated in 1.18; call $wgOut->redirect() directly
1702 * @param $noRedir Boolean: add redirect=no
1703 * @param $sectionAnchor String: section to redirect to, including "#"
1704 * @param $extraQuery String: extra query params
1706 public function doRedirect( $noRedir = false, $sectionAnchor = '', $extraQuery = '' ) {
1707 wfDeprecated( __METHOD__
, '1.18' );
1711 $query = 'redirect=no';
1713 $query .= "&$extraQuery";
1715 $query = $extraQuery;
1718 $wgOut->redirect( $this->getTitle()->getFullURL( $query ) . $sectionAnchor );
1722 * Use PHP's magic __get handler to handle accessing of
1723 * raw WikiPage fields for backwards compatibility.
1725 * @param $fname String Field name
1727 public function __get( $fname ) {
1728 if ( property_exists( $this->mPage
, $fname ) ) {
1729 #wfWarn( "Access to raw $fname field " . __CLASS__ );
1730 return $this->mPage
->$fname;
1732 trigger_error( 'Inaccessible property via __get(): ' . $fname, E_USER_NOTICE
);
1736 * Use PHP's magic __set handler to handle setting of
1737 * raw WikiPage fields for backwards compatibility.
1739 * @param $fname String Field name
1740 * @param $fvalue mixed New value
1742 public function __set( $fname, $fvalue ) {
1743 if ( property_exists( $this->mPage
, $fname ) ) {
1744 #wfWarn( "Access to raw $fname field of " . __CLASS__ );
1745 $this->mPage
->$fname = $fvalue;
1746 // Note: extensions may want to toss on new fields
1747 } elseif ( !in_array( $fname, array( 'mContext', 'mPage' ) ) ) {
1748 $this->mPage
->$fname = $fvalue;
1750 trigger_error( 'Inaccessible property via __set(): ' . $fname, E_USER_NOTICE
);
1755 * Use PHP's magic __call handler to transform instance calls to
1756 * WikiPage functions for backwards compatibility.
1758 * @param $fname String Name of called method
1759 * @param $args Array Arguments to the method
1761 public function __call( $fname, $args ) {
1762 if ( is_callable( array( $this->mPage
, $fname ) ) ) {
1763 #wfWarn( "Call to " . __CLASS__ . "::$fname; please use WikiPage instead" );
1764 return call_user_func_array( array( $this->mPage
, $fname ), $args );
1766 trigger_error( 'Inaccessible function via __call(): ' . $fname, E_USER_ERROR
);
1769 // ****** B/C functions to work-around PHP silliness with __call and references ****** //
1772 * @param $limit array
1773 * @param $expiry array
1774 * @param $cascade bool
1775 * @param $reason string
1779 public function doUpdateRestrictions( array $limit, array $expiry, &$cascade, $reason, User
$user ) {
1780 return $this->mPage
->doUpdateRestrictions( $limit, $expiry, $cascade, $reason, $user );
1784 * @param $limit array
1785 * @param $reason string
1786 * @param $cascade int
1787 * @param $expiry array
1790 public function updateRestrictions( $limit = array(), $reason = '', &$cascade = 0, $expiry = array() ) {
1791 return $this->mPage
->updateRestrictions( $limit, $reason, $cascade, $expiry );
1795 * @param $reason string
1796 * @param $suppress bool
1798 * @param $commit bool
1799 * @param $error string
1802 public function doDeleteArticle( $reason, $suppress = false, $id = 0, $commit = true, &$error = '' ) {
1803 return $this->mPage
->doDeleteArticle( $reason, $suppress, $id, $commit, $error );
1811 * @param $resultDetails
1815 public function doRollback( $fromP, $summary, $token, $bot, &$resultDetails, User
$user = null ) {
1817 $user = is_null( $user ) ?
$wgUser : $user;
1818 return $this->mPage
->doRollback( $fromP, $summary, $token, $bot, $resultDetails, $user );
1825 * @param $resultDetails
1826 * @param $guser User
1829 public function commitRollback( $fromP, $summary, $bot, &$resultDetails, User
$guser = null ) {
1831 $guser = is_null( $guser ) ?
$wgUser : $guser;
1832 return $this->mPage
->commitRollback( $fromP, $summary, $bot, $resultDetails, $guser );
1836 * @param $hasHistory bool
1839 public function generateReason( &$hasHistory ) {
1840 return $this->mPage
->getAutoDeleteReason( $hasHistory );
1843 // ****** B/C functions for static methods ( __callStatic is PHP>=5.3 ) ****** //
1848 public static function selectFields() {
1849 return WikiPage
::selectFields();
1853 * @param $title Title
1855 public static function onArticleCreate( $title ) {
1856 WikiPage
::onArticleCreate( $title );
1860 * @param $title Title
1862 public static function onArticleDelete( $title ) {
1863 WikiPage
::onArticleDelete( $title );
1867 * @param $title Title
1869 public static function onArticleEdit( $title ) {
1870 WikiPage
::onArticleEdit( $title );
1879 public static function getAutosummary( $oldtext, $newtext, $flags ) {
1880 return WikiPage
::getAutosummary( $oldtext, $newtext, $flags );