r17917 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r17916‎ | r17917 | r17918 >
Date:23:48, 24 November 2006
Author:werdna
Status:old
Tags:
Comment:
Patch by Leon Weber that adds 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.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/SpecialUpload.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SpecialUpload.php
@@ -29,6 +29,12 @@
3030 var $mUploadCopyStatus, $mUploadSource, $mReUpload, $mAction, $mUpload;
3131 var $mOname, $mSessionKey, $mStashed, $mDestFile, $mRemoveTempFile, $mSourceType;
3232 var $mUploadTempFileSize = 0;
 33+
 34+ # Placeholders for text injection by hooks (must be HTML)
 35+ # extensions should take care to _append_ to the present value
 36+ var $uploadFormTextTop;
 37+ var $uploadFormTextAfterSummary;
 38+
3339 /**#@-*/
3440
3541 /**
@@ -45,6 +51,10 @@
4652 return;
4753 }
4854
 55+ # Placeholders for text injection by hooks (empty per default)
 56+ $this->uploadFormTextTop = "";
 57+ $this->uploadFormTextAfterSummary = "";
 58+
4959 $this->mIgnoreWarning = $request->getCheck( 'wpIgnoreWarning' );
5060 $this->mReUpload = $request->getCheck( 'wpReUpload' );
5161 $this->mUpload = $request->getCheck( 'wpUpload' );
@@ -691,6 +701,12 @@
692702 global $wgUseCopyrightUpload;
693703 global $wgRequest, $wgAllowCopyUploads;
694704
 705+ if( !wfRunHooks( 'UploadForm:initial', array( &$this ) ) )
 706+ {
 707+ wfDebug( "Hook 'UploadForm:initial' broke output of the upload form" );
 708+ return false;
 709+ }
 710+
695711 $cols = intval($wgUser->getOption( 'cols' ));
696712 $ew = $wgUser->getOption( 'editwidth' );
697713 if ( $ew ) $ew = " style=\"width:100%\"";
@@ -751,6 +767,7 @@
752768 <form id='upload' method='post' enctype='multipart/form-data' action=\"$action\">
753769 <table border='0'>
754770 <tr>
 771+ {$this->uploadFormTextTop}
755772 <td align='right' valign='top'><label for='wpUploadFile'>{$sourcefilename}:</label></td>
756773 <td align='left'>
757774 {$filename_form}
@@ -766,6 +783,7 @@
767784 <td align='right'><label for='wpUploadDescription'>{$summary}</label></td>
768785 <td align='left'>
769786 <textarea tabindex='3' name='wpUploadDescription' id='wpUploadDescription' rows='6' cols='{$cols}'{$ew}>" . htmlspecialchars( $this->mUploadDescription ) . "</textarea>
 787+ {$this->uploadFormTextAfterSummary}
770788 </td>
771789 </tr>
772790 <tr>" );
Index: trunk/phase3/RELEASE-NOTES
@@ -217,8 +217,9 @@
218218 * Installer support for experimental MySQL 4.1/5.0 binary-safe schema
219219 * Use INSERT IGNORE for db-based BagOStuff add/insert, for more memcache-like
220220 behavior when keys already exist on add (instead of dying with an error...)
 221+* Add a hook 'UploadForm:initial' before the upload form is generated, and two
 222+ member variable for text injection into the form, which can be filled by the hooks.
221223
222 -
223224 == Languages updated ==
224225
225226 * Bishnupriya Manipuri (bpy)

Follow-up revisions

RevisionCommit summaryAuthorDate
r17923hooks.txt documentation for UploadForm:initial hook added in r17917werdna13:51, 25 November 2006