Add EditPage hooks AlternateEditPreview, EditPage::showStandardInputs:options
authorBrad Jorsch <bjorsch@wikimedia.org>
Sat, 10 Nov 2012 00:54:57 +0000 (16:54 -0800)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 22 Nov 2012 01:13:33 +0000 (01:13 +0000)
Adds two new hooks:
* AlternateEditPreview allows an extension to override the standard
  page preview display.
* EditPage::showStandardInputs:options allows an extension to add
  additional HTML to the end of the editOptions area of the edit form.

Change-Id: Ic5d35c8e9ff71282b5ebccc87c64894a385e5836

RELEASE-NOTES-1.21
docs/hooks.txt
includes/EditPage.php

index 6fdbfb9..a0035d5 100644 (file)
@@ -41,6 +41,10 @@ production.
   for use with Microdata.
 * The HTML5 <mark> tag has been whitelisted.
 * Added ParserCloned hook for when the Parser object is cloned.
+* Added AlternateEditPreview hook to allow extensions to replace the page
+  preview from the edit page.
+* Added EditPage::showStandardInputs:options hook to allow extensions to add
+  new fields to the "editOptions" area of the edit form.
 
 === Bug fixes in 1.21 ===
 * (bug 40353) SpecialDoubleRedirect should support interwiki redirects.
index 46b1b26..a9a7c10 100644 (file)
@@ -310,6 +310,15 @@ before showing the edit form ( EditPage::edit() ). This is triggered
 on &action=edit.
 $EditPage: the EditPage object
 
+'AlternateEditPreview': before generating the preview of the page when editing
+( EditPage::getPreviewText() ).
+$EditPage: the EditPage object
+&$content: the Content object for the text field from the edit page
+&$previewHTML: Text to be placed into the page for the preview
+&$parserOutput: the ParserOutput object for the preview
+return false and set $previewHTML and $parserOutput to output custom page
+preview HTML.
+
 'AlternateUserMailer': Called before mail is sent so that mail could
 be logged (or something else) instead of using PEAR or PHP's mail().
 Return false to skip the regular method of sending mail.  Return a
@@ -886,6 +895,12 @@ yourself. Alternatively, modifying $error and returning true will cause the
 contents of $error to be echoed at the top of the edit form as wikitext.
 Return true without altering $error to allow the edit to proceed.
 
+'EditPage::showStandardInputs:options': allows injection of form fields into
+the editOptions area
+$editor: EditPage instance (object)
+$out: an OutputPage instance to write to
+return value is ignored (should always be true)
+
 'EditPageBeforeConflictDiff': allows modifying the EditPage object and output
 when there's an edit conflict.  Return false to halt normal diff output; in
 this case you're responsible for computing and outputting the entire "conflict"
index 89daf52..5ab5adc 100644 (file)
@@ -2780,7 +2780,9 @@ HTML
                        wfMessage( 'newwindow' )->parse();
                $wgOut->addHTML( "      <span class='cancelLink'>{$cancel}</span>\n" );
                $wgOut->addHTML( "      <span class='editHelp'>{$edithelp}</span>\n" );
-               $wgOut->addHTML( "</div><!-- editButtons -->\n</div><!-- editOptions -->\n" );
+               $wgOut->addHTML( "</div><!-- editButtons -->\n" );
+               wfRunHooks( 'EditPage::showStandardInputs:options', array( $this, $wgOut, &$tabindex ) );
+               $wgOut->addHTML( "</div><!-- editOptions -->\n" );
        }
 
        /**
@@ -2930,6 +2932,12 @@ HTML
                try {
                        $content = $this->toEditContent( $this->textbox1 );
 
+                       $previewHTML = '';
+                       if ( !wfRunHooks( 'AlternateEditPreview', array( $this, &$content, &$previewHTML, &$this->mParserOutput ) ) ) {
+                               wfProfileOut( __METHOD__ );
+                               return $previewHTML;
+                       }
+
                        if ( $this->mTriedSave && !$this->mTokenOk ) {
                                if ( $this->mTokenOkExceptSuffix ) {
                                        $note = wfMessage( 'token_suffix_mismatch' )->plain() ;