Drop outdated "documentation reviewed" tags
[lhc/web/wiklou.git] / includes / page / Article.php
index 96e315f..5752262 100644 (file)
@@ -30,8 +30,6 @@
  * See design.txt for an overview.
  * Note: edit user interface and cache support functions have been
  * moved to separate EditPage and HTMLFileCache classes.
- *
- * @internal documentation reviewed 15 Mar 2010
  */
 class Article implements Page {
        /** @var IContextSource The context this Article is executed in */
@@ -120,7 +118,7 @@ class Article implements Page {
                }
 
                $page = null;
-               wfRunHooks( 'ArticleFromTitle', array( &$title, &$page, $context ) );
+               Hooks::run( 'ArticleFromTitle', array( &$title, &$page, $context ) );
                if ( !$page ) {
                        switch ( $title->getNamespace() ) {
                                case NS_FILE:
@@ -428,7 +426,7 @@ class Article implements Page {
                );
                $this->mRevIdFetched = $this->mRevision->getId();
 
-               wfRunHooks( 'ArticleAfterFetchContentObject', array( &$this, &$this->mContentObject ) );
+               Hooks::run( 'ArticleAfterFetchContentObject', array( &$this, &$this->mContentObject ) );
 
                wfProfileOut( __METHOD__ );
 
@@ -602,7 +600,7 @@ class Article implements Page {
                while ( !$outputDone && ++$pass ) {
                        switch ( $pass ) {
                                case 1:
-                                       wfRunHooks( 'ArticleViewHeader', array( &$this, &$outputDone, &$useParserCache ) );
+                                       Hooks::run( 'ArticleViewHeader', array( &$this, &$outputDone, &$useParserCache ) );
                                        break;
                                case 2:
                                        # Early abort if the page doesn't exist
@@ -665,7 +663,7 @@ class Article implements Page {
                                                wfDebug( __METHOD__ . ": showing CSS/JS source\n" );
                                                $this->showCssOrJsPage();
                                                $outputDone = true;
-                                       } elseif ( !wfRunHooks( 'ArticleContentViewCustom',
+                                       } elseif ( !Hooks::run( 'ArticleContentViewCustom',
                                                        array( $this->fetchContentObject(), $this->getTitle(), $outputPage ) ) ) {
 
                                                # Allow extensions do their own custom view for certain pages
@@ -995,7 +993,7 @@ class Article implements Page {
                if ( isset( $this->mRedirectedFrom ) ) {
                        // This is an internally redirected page view.
                        // We'll need a backlink to the source page for navigation.
-                       if ( wfRunHooks( 'ArticleViewRedirect', array( &$this ) ) ) {
+                       if ( Hooks::run( 'ArticleViewRedirect', array( &$this ) ) ) {
                                $redir = Linker::linkKnown(
                                        $this->mRedirectedFrom,
                                        null,
@@ -1003,7 +1001,9 @@ class Article implements Page {
                                        array( 'redirect' => 'no' )
                                );
 
-                               $outputPage->addSubtitle( wfMessage( 'redirectedfrom' )->rawParams( $redir ) );
+                               $outputPage->addSubtitle( "<span class=\"mw-redirectedfrom\">" .
+                                       wfMessage( 'redirectedfrom' )->rawParams( $redir )->parse()
+                               . "</span>" );
 
                                // Add the script to update the displayed URL and
                                // set the fragment if one was specified in the redirect
@@ -1025,7 +1025,9 @@ class Article implements Page {
                        // If it was reported from a trusted site, supply a backlink.
                        if ( $wgRedirectSources && preg_match( $wgRedirectSources, $rdfrom ) ) {
                                $redir = Linker::makeExternalLink( $rdfrom, $rdfrom );
-                               $outputPage->addSubtitle( wfMessage( 'redirectedfrom' )->rawParams( $redir ) );
+                               $outputPage->addSubtitle( "<span class=\"mw-redirectedfrom\">" .
+                                       wfMessage( 'redirectedfrom' )->rawParams( $redir )->parse()
+                               . "</span>" );
 
                                // Add the script to update the displayed URL
                                $outputPage->addJsConfigVars( array(
@@ -1069,7 +1071,7 @@ class Article implements Page {
                // Show a footer allowing the user to patrol the shown revision or page if possible
                $patrolFooterShown = $this->showPatrolFooter();
 
-               wfRunHooks( 'ArticleViewFooter', array( $this, $patrolFooterShown ) );
+               Hooks::run( 'ArticleViewFooter', array( $this, $patrolFooterShown ) );
        }
 
        /**
@@ -1218,7 +1220,8 @@ class Article implements Page {
                        if ( !( $user && $user->isLoggedIn() ) && !$ip ) { # User does not exist
                                $outputPage->wrapWikiMsg( "<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>",
                                        array( 'userpage-userdoesnotexist-view', wfEscapeWikiText( $rootPart ) ) );
-                       } elseif ( !is_null( $block ) && $block->getType() != Block::TYPE_AUTO ) { # Show log extract if the user is currently blocked
+                       } elseif ( !is_null( $block ) && $block->getType() != Block::TYPE_AUTO ) {
+                               # Show log extract if the user is currently blocked
                                LogEventsList::showLogExtract(
                                        $outputPage,
                                        'block',
@@ -1239,24 +1242,20 @@ class Article implements Page {
                        }
                }
 
-               wfRunHooks( 'ShowMissingArticle', array( $this ) );
+               Hooks::run( 'ShowMissingArticle', array( $this ) );
 
                // Give extensions a chance to hide their (unrelated) log entries
                $logTypes = array( 'delete', 'move' );
                $conds = array( "log_action != 'revision'" );
-               wfRunHooks( 'Article::MissingArticleConditions', array( &$conds, $logTypes ) );
+               Hooks::run( 'Article::MissingArticleConditions', array( &$conds, $logTypes ) );
 
                # Show delete and move logs
-               $member = $title->getNamespace() . ':' . $title->getDBkey();
-               // @todo: move optimization to showLogExtract()?
-               if ( BloomCache::get( 'main' )->check( wfWikiId(), 'TitleHasLogs', $member ) ) {
-                       LogEventsList::showLogExtract( $outputPage, $logTypes, $title, '',
-                               array( 'lim' => 10,
-                                       'conds' => $conds,
-                                       'showIfEmpty' => false,
-                                       'msgKey' => array( 'moveddeleted-notice' ) )
-                       );
-               }
+               LogEventsList::showLogExtract( $outputPage, $logTypes, $title, '',
+                       array( 'lim' => 10,
+                               'conds' => $conds,
+                               'showIfEmpty' => false,
+                               'msgKey' => array( 'moveddeleted-notice' ) )
+               );
 
                if ( !$this->mPage->hasViewableContent() && $wgSend404Code && !$validUserPage ) {
                        // If there's no backing content, send a 404 Not Found
@@ -1269,7 +1268,7 @@ class Article implements Page {
                $outputPage->setIndexPolicy( $policy['index'] );
                $outputPage->setFollowPolicy( $policy['follow'] );
 
-               $hookResult = wfRunHooks( 'BeforeDisplayNoArticleText', array( $this ) );
+               $hookResult = Hooks::run( 'BeforeDisplayNoArticleText', array( $this ) );
 
                if ( !$hookResult ) {
                        return;
@@ -1345,7 +1344,7 @@ class Article implements Page {
         * @param int $oldid Revision ID of this article revision
         */
        public function setOldSubtitle( $oldid = 0 ) {
-               if ( !wfRunHooks( 'DisplayOldSubtitle', array( &$this, &$oldid ) ) ) {
+               if ( !Hooks::run( 'DisplayOldSubtitle', array( &$this, &$oldid ) ) ) {
                        return;
                }
 
@@ -1381,9 +1380,14 @@ class Article implements Page {
                        : 'revision-info';
 
                $outputPage = $this->getContext()->getOutput();
-               $outputPage->addSubtitle( "<div id=\"mw-{$infomsg}\">" . wfMessage( $infomsg,
-                       $td )->rawParams( $userlinks )->params( $revision->getID(), $tddate,
-                       $tdtime, $revision->getUserText() )->rawParams( Linker::revComment( $revision, true, true ) )->parse() . "</div>" );
+               $outputPage->addSubtitle( "<div id=\"mw-{$infomsg}\">" .
+                       wfMessage( $infomsg, $td )
+                               ->rawParams( $userlinks )
+                               ->params( $revision->getID(), $tddate, $tdtime, $revision->getUserText() )
+                               ->rawParams( Linker::revComment( $revision, true, true ) )
+                               ->parse() .
+                       "</div>"
+               );
 
                $lnk = $current
                        ? wfMessage( 'currentrevisionlink' )->escaped()
@@ -1553,7 +1557,8 @@ class Article implements Page {
                # This code desperately needs to be totally rewritten
 
                $title = $this->getTitle();
-               $user = $this->getContext()->getUser();
+               $context = $this->getContext();
+               $user = $context->getUser();
 
                # Check permissions
                $permissionErrors = $title->getUserPermissionsErrors( 'delete', $user );
@@ -1570,8 +1575,8 @@ class Article implements Page {
                $this->mPage->loadPageData( 'fromdbmaster' );
                if ( !$this->mPage->exists() ) {
                        $deleteLogPage = new LogPage( 'delete' );
-                       $outputPage = $this->getContext()->getOutput();
-                       $outputPage->setPageTitle( wfMessage( 'cannotdelete-title', $title->getPrefixedText() ) );
+                       $outputPage = $context->getOutput();
+                       $outputPage->setPageTitle( $context->msg( 'cannotdelete-title', $title->getPrefixedText() ) );
                        $outputPage->wrapWikiMsg( "<div class=\"error mw-error-cannotdelete\">\n$1\n</div>",
                                        array( 'cannotdelete', wfEscapeWikiText( $title->getPrefixedText() ) )
                                );
@@ -1587,7 +1592,7 @@ class Article implements Page {
                        return;
                }
 
-               $request = $this->getContext()->getRequest();
+               $request = $context->getRequest();
                $deleteReasonList = $request->getText( 'wpDeleteReasonList', 'other' );
                $deleteReason = $request->getText( 'wpReason' );
 
@@ -1631,10 +1636,11 @@ class Article implements Page {
                if ( $hasHistory ) {
                        $title = $this->getTitle();
 
-                       // The following can use the real revision count as this is only being shown for users that can delete
-                       // this page.
-                       // This, as a side-effect, also makes sure that the following query isn't being run for pages with a
-                       // larger history, unless the user has the 'bigdelete' right (and is about to delete this page).
+                       // The following can use the real revision count as this is only being shown for users
+                       // that can delete this page.
+                       // This, as a side-effect, also makes sure that the following query isn't being run for
+                       // pages with a larger history, unless the user has the 'bigdelete' right
+                       // (and is about to delete this page).
                        $dbr = wfGetDB( DB_SLAVE );
                        $revisions = $edits = (int)$dbr->selectField(
                                'revision',
@@ -1644,10 +1650,11 @@ class Article implements Page {
                        );
 
                        // @todo FIXME: i18n issue/patchwork message
-                       $this->getContext()->getOutput()->addHTML( '<strong class="mw-delete-warning-revisions">' .
-                               wfMessage( 'historywarning' )->numParams( $revisions )->parse() .
-                               wfMessage( 'word-separator' )->plain() . Linker::linkKnown( $title,
-                                       wfMessage( 'history' )->escaped(),
+                       $context->getOutput()->addHTML(
+                               '<strong class="mw-delete-warning-revisions">' .
+                               $context->msg( 'historywarning' )->numParams( $revisions )->parse() .
+                               $context->msg( 'word-separator' )->escaped() . Linker::linkKnown( $title,
+                                       $context->msg( 'history' )->escaped(),
                                        array( 'rel' => 'archives' ),
                                        array( 'action' => 'history' ) ) .
                                '</strong>'
@@ -1655,10 +1662,10 @@ class Article implements Page {
 
                        if ( $title->isBigDeletion() ) {
                                global $wgDeleteRevisionsLimit;
-                               $this->getContext()->getOutput()->wrapWikiMsg( "<div class='error'>\n$1\n</div>\n",
+                               $context->getOutput()->wrapWikiMsg( "<div class='error'>\n$1\n</div>\n",
                                        array(
                                                'delete-warning-toobig',
-                                               $this->getContext()->getLanguage()->formatNum( $wgDeleteRevisionsLimit )
+                                               $context->getLanguage()->formatNum( $wgDeleteRevisionsLimit )
                                        )
                                );
                        }
@@ -1689,7 +1696,7 @@ class Article implements Page {
                }
                $outputPage->addWikiMsg( 'confirmdeletetext' );
 
-               wfRunHooks( 'ArticleConfirmDelete', array( $this, $outputPage, &$reason ) );
+               Hooks::run( 'ArticleConfirmDelete', array( $this, $outputPage, &$reason ) );
 
                $user = $this->getContext()->getUser();
 
@@ -1799,6 +1806,9 @@ class Article implements Page {
                        $loglink = '[[Special:Log/delete|' . wfMessage( 'deletionlog' )->text() . ']]';
 
                        $outputPage->addWikiMsg( 'deletedtext', wfEscapeWikiText( $deleted ), $loglink );
+
+                       Hooks::run( 'ArticleDeleteAfterSuccess', array( $this->getTitle(), $outputPage ) );
+
                        $outputPage->returnToMain( false );
                } else {
                        $outputPage->setPageTitle(
@@ -1871,7 +1881,7 @@ class Article implements Page {
                                && !$this->mRedirectedFrom && !$this->getTitle()->isRedirect();
                        // Extension may have reason to disable file caching on some pages.
                        if ( $cacheable ) {
-                               $cacheable = wfRunHooks( 'IsFileCacheable', array( &$this ) );
+                               $cacheable = Hooks::run( 'IsFileCacheable', array( &$this ) );
                        }
                }