Kaldari has uploaded a new change for review. https://gerrit.wikimedia.org/r/52579
Change subject: Adding hooks for thank you notification links ...................................................................... Adding hooks for thank you notification links These will allow Echo to add a 'thank' link next to the 'undo' links Change-Id: Ifb93e49b30bb325ecd17ece9f36bcd83c63a2563 --- M RELEASE-NOTES-1.21 M docs/hooks.txt M includes/actions/HistoryAction.php M includes/diff/DifferenceEngine.php 4 files changed, 26 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/79/52579/1 diff --git a/RELEASE-NOTES-1.21 b/RELEASE-NOTES-1.21 index 17bca70..75da843 100644 --- a/RELEASE-NOTES-1.21 +++ b/RELEASE-NOTES-1.21 @@ -114,6 +114,7 @@ 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 fixes in 1.21 === * (bug 40353) SpecialDoubleRedirect should support interwiki redirects. diff --git a/docs/hooks.txt b/docs/hooks.txt index cd1af96..d892b79 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -842,6 +842,11 @@ $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 @@ 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 d26228a..8bdd831 100644 --- a/includes/actions/HistoryAction.php +++ b/includes/actions/HistoryAction.php @@ -654,6 +654,8 @@ $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(); diff --git a/includes/diff/DifferenceEngine.php b/includes/diff/DifferenceEngine.php index c8f1d7f..8699187 100644 --- a/includes/diff/DifferenceEngine.php +++ b/includes/diff/DifferenceEngine.php @@ -292,6 +292,7 @@ $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 @@ } } 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 @@ 'title' => Linker::titleAttrib( 'undo' ) ), $this->msg( 'editundo' )->text() - ) )->escaped(); + ); + $revisionTools[] = $undoLink; } } @@ -376,7 +377,15 @@ # 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 ) . -- To view, visit https://gerrit.wikimedia.org/r/52579 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ifb93e49b30bb325ecd17ece9f36bcd83c63a2563 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Kaldari <rkald...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits