Replace wfRunHooks calls with direct Hooks::run calls
[lhc/web/wiklou.git] / includes / diff / DifferenceEngine.php
index ee918f3..c887193 100644 (file)
@@ -224,8 +224,11 @@ class DifferenceEngine extends ContextSource {
                }
 
                $out->setPageTitle( $this->msg( 'errorpagetitle' ) );
-               $out->addWikiMsg( 'difference-missing-revision',
-                       $this->getLanguage()->listToText( $missing ), count( $missing ) );
+               $msg = $this->msg( 'difference-missing-revision' )
+                       ->params( $this->getLanguage()->listToText( $missing ) )
+                       ->numParams( count( $missing ) )
+                       ->parseAsBlock();
+               $out->addHtml( $msg );
        }
 
        public function showDiffPage( $diffOnly = false ) {
@@ -280,7 +283,7 @@ class DifferenceEngine extends ContextSource {
                        $samePage = true;
                        $oldHeader = '';
                } else {
-                       wfRunHooks( 'DiffViewHeader', array( $this, $this->mOldRev, $this->mNewRev ) );
+                       Hooks::run( 'DiffViewHeader', array( $this, $this->mOldRev, $this->mNewRev ) );
 
                        if ( $this->mNewPage->equals( $this->mOldPage ) ) {
                                $out->setPageTitle( $this->msg( 'difference-title', $this->mNewPage->getPrefixedText() ) );
@@ -310,11 +313,11 @@ class DifferenceEngine extends ContextSource {
                                                                'undoafter' => $this->mOldid,
                                                                'undo' => $this->mNewid
                                                        ) ),
-                                                       'title' => Linker::titleAttrib( 'undo' )
+                                                       'title' => Linker::titleAttrib( 'undo' ),
                                                ),
                                                $this->msg( 'editundo' )->text()
                                        );
-                                       $revisionTools[] = $undoLink;
+                                       $revisionTools['mw-diff-undo'] = $undoLink;
                                }
                        }
 
@@ -384,11 +387,17 @@ class DifferenceEngine extends ContextSource {
                $rdel = $this->revisionDeleteLink( $this->mNewRev );
 
                # Allow extensions to define their own revision tools
-               wfRunHooks( 'DiffRevisionTools', array( $this->mNewRev, &$revisionTools, $this->mOldRev ) );
+               Hooks::run( 'DiffRevisionTools', array( $this->mNewRev, &$revisionTools, $this->mOldRev ) );
                $formattedRevisionTools = array();
                // Put each one in parentheses (poor man's button)
-               foreach ( $revisionTools as $tool ) {
-                       $formattedRevisionTools[] = $this->msg( 'parentheses' )->rawParams( $tool )->escaped();
+               foreach ( $revisionTools as $key => $tool ) {
+                       $toolClass = is_string( $key ) ? $key : 'mw-diff-tool';
+                       $element = Html::rawElement(
+                               'span',
+                               array( 'class' => $toolClass ),
+                               $this->msg( 'parentheses' )->rawParams( $tool )->escaped()
+                       );
+                       $formattedRevisionTools[] = $element;
                }
                $newRevisionHeader = $this->getRevisionHeader( $this->mNewRev, 'complete' ) .
                        ' ' . implode( ' ', $formattedRevisionTools );
@@ -546,7 +555,7 @@ class DifferenceEngine extends ContextSource {
                <h2 class='diff-currentversion-title'>{$revHeader}</h2>\n" );
                # Page content may be handled by a hooked call instead...
                # @codingStandardsIgnoreStart Ignoring long lines.
-               if ( wfRunHooks( 'ArticleContentOnDiff', array( $this, $out ) ) ) {
+               if ( Hooks::run( 'ArticleContentOnDiff', array( $this, $out ) ) ) {
                        $this->loadNewText();
                        $out->setRevisionId( $this->mNewid );
                        $out->setRevisionTimestamp( $this->mNewRev->getTimestamp() );
@@ -566,7 +575,7 @@ class DifferenceEngine extends ContextSource {
                                                $out->addParserOutputContent( $po );
                                        }
                                }
-                       } elseif ( !wfRunHooks( 'ArticleContentViewCustom', array( $this->mNewContent, $this->mNewPage, $out ) ) ) {
+                       } elseif ( !Hooks::run( 'ArticleContentViewCustom', array( $this->mNewContent, $this->mNewPage, $out ) ) ) {
                                // Handled by extension
                        } elseif ( !ContentHandler::runLegacyHooks( 'ArticleViewCustom', array( $this->mNewContent, $this->mNewPage, $out ) ) ) {
                                // NOTE: deprecated hook, B/C only
@@ -733,7 +742,7 @@ class DifferenceEngine extends ContextSource {
                $difftext = $this->generateContentDiffBody( $this->mOldContent, $this->mNewContent );
 
                // Save to cache for 7 days
-               if ( !wfRunHooks( 'AbortDiffCache', array( &$this ) ) ) {
+               if ( !Hooks::run( 'AbortDiffCache', array( &$this ) ) ) {
                        wfIncrStats( 'diff_uncacheable' );
                } elseif ( $key !== false && $difftext !== false ) {
                        wfIncrStats( 'diff_cache_miss' );
@@ -1052,8 +1061,13 @@ class DifferenceEngine extends ContextSource {
 
                        $key = $title->quickUserCan( 'edit', $user ) ? 'editold' : 'viewsourceold';
                        $msg = $this->msg( $key )->escaped();
-                       $header .= ' ' . $this->msg( 'parentheses' )->rawParams(
-                               Linker::linkKnown( $title, $msg, array(), $editQuery ) )->plain();
+                       $editLink = $this->msg( 'parentheses' )->rawParams(
+                               Linker::linkKnown( $title, $msg, array( ), $editQuery ) )->plain();
+                       $header .= ' ' . Html::rawElement(
+                               'span',
+                               array( 'class' => 'mw-diff-edit' ),
+                               $editLink
+                       );
                        if ( $rev->isDeleted( Revision::DELETED_TEXT ) ) {
                                $header = Html::rawElement(
                                        'span',
@@ -1210,7 +1224,7 @@ class DifferenceEngine extends ContextSource {
                        $this->mNewid = 0;
                }
 
-               wfRunHooks(
+               Hooks::run(
                        'NewDifferenceEngine',
                        array( $this->getTitle(), &$this->mOldid, &$this->mNewid, $old, $new )
                );