Patch by Leon Weber that adds a hook 'UploadForm:initial' before the upload form...
authorAndrew Garrett <werdna@users.mediawiki.org>
Fri, 24 Nov 2006 23:48:22 +0000 (23:48 +0000)
committerAndrew Garrett <werdna@users.mediawiki.org>
Fri, 24 Nov 2006 23:48:22 +0000 (23:48 +0000)
RELEASE-NOTES
includes/SpecialUpload.php

index 34b9b25..94450e5 100644 (file)
@@ -217,7 +217,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * Installer support for experimental MySQL 4.1/5.0 binary-safe schema
 * Use INSERT IGNORE for db-based BagOStuff add/insert, for more memcache-like
   behavior when keys already exist on add (instead of dying with an error...)
-
+* Add a hook 'UploadForm:initial' before the upload form is generated, and two
+  member variable for text injection into the form, which can be filled by the hooks.
 
 == Languages updated ==
 
index 937d9fc..fc262e1 100644 (file)
@@ -29,6 +29,12 @@ class UploadForm {
        var $mUploadCopyStatus, $mUploadSource, $mReUpload, $mAction, $mUpload;
        var $mOname, $mSessionKey, $mStashed, $mDestFile, $mRemoveTempFile, $mSourceType;
        var $mUploadTempFileSize = 0;
+
+       # Placeholders for text injection by hooks (must be HTML)
+       # extensions should take care to _append_ to the present value
+       var $uploadFormTextTop;
+       var $uploadFormTextAfterSummary;
+
        /**#@-*/
 
        /**
@@ -45,6 +51,10 @@ class UploadForm {
                        return;
                }
 
+        # Placeholders for text injection by hooks (empty per default)
+        $this->uploadFormTextTop = "";
+        $this->uploadFormTextAfterSummary = "";
+
                $this->mIgnoreWarning     = $request->getCheck( 'wpIgnoreWarning' );
                $this->mReUpload          = $request->getCheck( 'wpReUpload' );
                $this->mUpload            = $request->getCheck( 'wpUpload' );
@@ -691,6 +701,12 @@ class UploadForm {
                global $wgUseCopyrightUpload;
                global $wgRequest, $wgAllowCopyUploads;
 
+        if( !wfRunHooks( 'UploadForm:initial', array( &$this ) ) )
+        {
+         wfDebug( "Hook 'UploadForm:initial' broke output of the upload form" );
+         return false;
+        }
+
                $cols = intval($wgUser->getOption( 'cols' ));
                $ew = $wgUser->getOption( 'editwidth' );
                if ( $ew ) $ew = " style=\"width:100%\"";
@@ -751,6 +767,7 @@ class UploadForm {
        <form id='upload' method='post' enctype='multipart/form-data' action=\"$action\">
                <table border='0'>
                <tr>
+         {$this->uploadFormTextTop}
                        <td align='right' valign='top'><label for='wpUploadFile'>{$sourcefilename}:</label></td>
                        <td align='left'>
                                {$filename_form}
@@ -766,6 +783,7 @@ class UploadForm {
                        <td align='right'><label for='wpUploadDescription'>{$summary}</label></td>
                        <td align='left'>
                                <textarea tabindex='3' name='wpUploadDescription' id='wpUploadDescription' rows='6' cols='{$cols}'{$ew}>" . htmlspecialchars( $this->mUploadDescription ) . "</textarea>
+          {$this->uploadFormTextAfterSummary}
                        </td>
                </tr>
                <tr>" );