Add a hook to Title::getEditNotices() so extensions can add them
authorRoan Kattouw <roan.kattouw@gmail.com>
Wed, 24 Jul 2013 00:28:47 +0000 (17:28 -0700)
committerRoan Kattouw <roan.kattouw@gmail.com>
Wed, 24 Jul 2013 00:31:27 +0000 (17:31 -0700)
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
includes/EditPage.php
includes/Title.php

index fb9a528..9967666 100644 (file)
@@ -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.
index 96cc908..c41d9a1 100644 (file)
@@ -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( "<div class='mw-explainconflict'>\n$1\n</div>", 'explainconflict' );
index 0c223af..7818742 100644 (file)
@@ -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;
        }
 }