* Added EditFilter hook, and output callback on EditPage::showEditForm()
authorBrion Vibber <brion@users.mediawiki.org>
Thu, 29 Sep 2005 23:35:31 +0000 (23:35 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Thu, 29 Sep 2005 23:35:31 +0000 (23:35 +0000)
  for a place to add in captcha-type extensions in the edit flow

RELEASE-NOTES
includes/EditPage.php

index 3ca09e9..76cad8f 100644 (file)
@@ -122,6 +122,8 @@ fully support the editing toolbar, but was found to be too confusing.
 * Add options to dumpBackup.php for making split/partial dumps by page id
 * Fix language name for dv
 * (bug 3503) Update LanguageSq.php from sq.wikipedia.org messages
+* Added EditFilter hook, and output callback on EditPage::showEditForm()
+  for a place to add in captcha-type extensions in the edit flow
 
 
 === Caveats ===
index 3adc22b..a18b06a 100644 (file)
@@ -430,6 +430,12 @@ class EditPage {
                        wfProfileOut( "$fname-checks" );
                        return false;
                }
+               if ( !wfRunHooks( 'EditFilter', array( &$this, $this->textbox1, $this->section ) ) ) {
+                       # Error messages or other handling should be performed by the filter function
+                       wfProfileOut( $fname );
+                       wfProfileOut( "$fname-checks" );
+                       return false;
+               }
                if ( $wgUser->isBlockedFrom( $this->mTitle, false ) ) {
                        # Check block state against master, thus 'false'.
                        $this->blockedIPpage();
@@ -593,8 +599,11 @@ class EditPage {
 
        /**
         * Send the edit form and related headers to $wgOut
+        * @param $formCallback Optional callable that takes an OutputPage
+        *                      parameter; will be called during form output
+        *                      near the top, for captchas and the like.
         */
-       function showEditForm() {
+       function showEditForm( $formCallback=null ) {
                global $wgOut, $wgUser, $wgAllowAnonymousMinor, $wgLang, $wgContLang;
 
                $fname = 'EditPage::showEditForm';
@@ -810,6 +819,12 @@ class EditPage {
 {$toolbar}
 <form id="editform" name="editform" method="post" action="$action"
 enctype="multipart/form-data">
+END
+);
+               if( is_callable( $formCallback ) ) {
+                       call_user_func_array( $formCallback, array( &$wgOut ) );
+               }
+               $wgOut->addHTML( <<<END
 $recreate
 {$commentsubject}
 <textarea tabindex='1' accesskey="," name="wpTextbox1" rows='{$rows}'