Adding hooks for thank you notification links
authorKaldari <rkaldari@wikimedia.org>
Thu, 7 Mar 2013 02:38:00 +0000 (18:38 -0800)
committerKaldari <rkaldari@wikimedia.org>
Tue, 12 Mar 2013 17:37:39 +0000 (10:37 -0700)
These will allow Echo to add a 'thank' link next to the 'undo' links

Change-Id: Ifb93e49b30bb325ecd17ece9f36bcd83c63a2563

RELEASE-NOTES-1.21
docs/hooks.txt
includes/actions/HistoryAction.php
includes/diff/DifferenceEngine.php

index 6beebbc..5864069 100644 (file)
@@ -114,6 +114,7 @@ production.
   oc, pl, pt, rm, ro, ru, rup, sco, sk, sl, smn, sq, sr, sv, tk, tl, tr, tt, uk,
   uz, vi.
 * Added 'CategoryAfterPageAdded' and 'CategoryAfterPageRemoved' hooks.
+* Added 'HistoryRevisionTools' and 'DiffRevisionTools' hooks.
 * (bug 33186) Add image rotation api "imagerotate"
 * (bug 34040) Add "User rights management" link on user page toolbox.
 
index cd1af96..d892b79 100644 (file)
@@ -842,6 +842,11 @@ $title: the diff page title (nullable)
 $old: the ?old= param value from the url
 $new: the ?new= param value from the url
 
+'DiffRevisionTools': Override or extend the revision tools available from the
+diff view, i.e. undo, etc.
+$rev: Revision object
+&$links: Array of HTML links
+
 'DiffViewHeader': Called before diff display
 $diff: DifferenceEngine object that's calling
 $oldRev: Revision object of the "old" revision (may be null/invalid)
@@ -1200,6 +1205,11 @@ $result: User permissions error to add. If none, return true.
 Special:Version, use this to change the list.
 &$extTypes: associative array of repo URLS to viewer URLs.
 
+'HistoryRevisionTools': Override or extend the revision tools available from the
+page history view, i.e. undo, rollback, etc.
+$rev: Revision object
+&$links: Array of HTML links
+
 'ImageBeforeProduceHTML': Called before producing the HTML created by a wiki
 image insertion. You can skip the default logic entirely by returning false, or
 just modify a few things using call-by-reference.
index 2b088b4..e64e3d2 100644 (file)
@@ -657,6 +657,8 @@ class HistoryPager extends ReverseChronologicalPager {
                                $tools[] = "<span class=\"mw-history-undo\">{$undolink}</span>";
                        }
                }
+               // Allow extension to add their own links here
+               wfRunHooks( 'HistoryRevisionTools', array( $rev, &$tools ) );
 
                if ( $tools ) {
                        $s2 .= ' '. $this->msg( 'parentheses' )->rawParams( $lang->pipeList( $tools ) )->escaped();
index 67af7ae..421bee9 100644 (file)
@@ -292,6 +292,7 @@ class DifferenceEngine extends ContextSource {
                                $samePage = false;
                        }
 
+                       $revisionTools = array();
                        if ( $samePage && $this->mNewPage->quickUserCan( 'edit', $user ) ) {
                                if ( $this->mNewRev->isCurrent() && $this->mNewPage->userCan( 'rollback', $user ) ) {
                                        $rollbackLink = Linker::generateRollback( $this->mNewRev, $this->getContext() );
@@ -301,8 +302,7 @@ class DifferenceEngine extends ContextSource {
                                        }
                                }
                                if ( !$this->mOldRev->isDeleted( Revision::DELETED_TEXT ) && !$this->mNewRev->isDeleted( Revision::DELETED_TEXT ) ) {
-                                       $undoLink = ' ' . $this->msg( 'parentheses' )->rawParams(
-                                               Html::element( 'a', array(
+                                       $undoLink = Html::element( 'a', array(
                                                        'href' => $this->mNewPage->getLocalUrl( array(
                                                                'action' => 'edit',
                                                                'undoafter' => $this->mOldid,
@@ -310,7 +310,8 @@ class DifferenceEngine extends ContextSource {
                                                        'title' => Linker::titleAttrib( 'undo' )
                                                ),
                                                $this->msg( 'editundo' )->text()
-                                       ) )->escaped();
+                                       );
+                                       $revisionTools[] = $undoLink;
                                }
                        }
 
@@ -376,7 +377,15 @@ class DifferenceEngine extends ContextSource {
 
                # Handle RevisionDelete links...
                $rdel = $this->revisionDeleteLink( $this->mNewRev );
-               $newRevisionHeader = $this->getRevisionHeader( $this->mNewRev, 'complete' ) . $undoLink;
+
+               # Allow extensions to define their own revision tools
+               wfRunHooks( 'DiffRevisionTools', array( $this->mNewRev, &$revisionTools ) );
+               $formattedRevisionTools = array();
+               // Put each one in parentheses (poor man's button)
+               foreach ( $revisionTools as $tool ) {
+                       $formattedRevisionTools[] = $this->msg( 'parentheses' )->rawParams( $tool )->escaped();
+               }
+               $newRevisionHeader = $this->getRevisionHeader( $this->mNewRev, 'complete' ) . ' ' . implode( ' ', $formattedRevisionTools );
 
                $newHeader = '<div id="mw-diff-ntitle1"><strong>' . $newRevisionHeader . '</strong></div>' .
                        '<div id="mw-diff-ntitle2">' . Linker::revUserTools( $this->mNewRev, !$this->unhide ) .