From 6bf642d80abe65eea50cdcd0f4e8c0a0fe4e7c08 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Tue, 23 Jul 2013 17:28:47 -0700 Subject: [PATCH] Add a hook to Title::getEditNotices() so extensions can add them FlaggedRevs will have to use this to expose its edit notices to VisualEditor. Also add an $oldid parameter so edit notices can be generated based on the revision ID being edited. Change-Id: Ie44a01ebfa7002fa3a89f081e0f831442666ac03 --- docs/hooks.txt | 5 +++++ includes/EditPage.php | 2 +- includes/Title.php | 5 ++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/hooks.txt b/docs/hooks.txt index fb9a528e90..99676669b2 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -2335,6 +2335,11 @@ $action: Action being performed $doExpensiveQueries: Whether to do expensive DB queries $short: Whether to return immediately on first error +'TitleGetEditNotices': Allows extensions to add edit notices +$title: The Title object for the page the edit notices are for +$oldid: Revision ID that the edit notices are for (or 0 for latest) +&$notices: Array of notices. Keys are i18n message keys, values are parseAsBlock()ed messages. + 'TitleGetRestrictionTypes': Allows extensions to modify the types of protection that can be applied. $title: The title in question. diff --git a/includes/EditPage.php b/includes/EditPage.php index 96cc90858d..c41d9a1229 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -2313,7 +2313,7 @@ class EditPage { } // Add edit notices - $wgOut->addHTML( implode( "\n", $this->mTitle->getEditNotices() ) ); + $wgOut->addHTML( implode( "\n", $this->mTitle->getEditNotices( $this->oldid ) ) ); if ( $this->isConflict ) { $wgOut->wrapWikiMsg( "
\n$1\n
", 'explainconflict' ); diff --git a/includes/Title.php b/includes/Title.php index 0c223aff55..7818742889 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -4751,9 +4751,10 @@ class Title { * they will already be wrapped in paragraphs. * * @since 1.21 + * @param int oldid Revision ID that's being edited * @return Array */ - public function getEditNotices() { + public function getEditNotices( $oldid = 0 ) { $notices = array(); # Optional notices on a per-namespace and per-page basis @@ -4780,6 +4781,8 @@ class Title { $notices[$editnoticeText] = $editnoticeMsg->parseAsBlock(); } } + + wfRunHooks( 'TitleGetEditNotices', array( $this, $oldid, &$notices ) ); return $notices; } } -- 2.20.1