From: Kaldari Date: Thu, 7 Mar 2013 02:38:00 +0000 (-0800) Subject: Adding hooks for thank you notification links X-Git-Tag: 1.31.0-rc.0~20365^2 X-Git-Url: https://git.cyclocoop.org/%27.%24link.%27?a=commitdiff_plain;h=930955762a7aaa85329d8baf5c3ac88797bf5344;p=lhc%2Fweb%2Fwiklou.git Adding hooks for thank you notification links These will allow Echo to add a 'thank' link next to the 'undo' links Change-Id: Ifb93e49b30bb325ecd17ece9f36bcd83c63a2563 --- diff --git a/RELEASE-NOTES-1.21 b/RELEASE-NOTES-1.21 index 6beebbc96d..58640699ac 100644 --- a/RELEASE-NOTES-1.21 +++ b/RELEASE-NOTES-1.21 @@ -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. diff --git a/docs/hooks.txt b/docs/hooks.txt index cd1af96cb6..d892b7930c 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -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. diff --git a/includes/actions/HistoryAction.php b/includes/actions/HistoryAction.php index 2b088b4c2b..e64e3d21c6 100644 --- a/includes/actions/HistoryAction.php +++ b/includes/actions/HistoryAction.php @@ -657,6 +657,8 @@ class HistoryPager extends ReverseChronologicalPager { $tools[] = "{$undolink}"; } } + // Allow extension to add their own links here + wfRunHooks( 'HistoryRevisionTools', array( $rev, &$tools ) ); if ( $tools ) { $s2 .= ' '. $this->msg( 'parentheses' )->rawParams( $lang->pipeList( $tools ) )->escaped(); diff --git a/includes/diff/DifferenceEngine.php b/includes/diff/DifferenceEngine.php index 67af7ae4f3..421bee9767 100644 --- a/includes/diff/DifferenceEngine.php +++ b/includes/diff/DifferenceEngine.php @@ -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 = '
' . $newRevisionHeader . '
' . '
' . Linker::revUserTools( $this->mNewRev, !$this->unhide ) .