r32077 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r32076‎ | r32077 | r32078 >
Date:21:05, 17 March 2008
Author:raymond
Status:old
Tags:
Comment:
Some rework on 'mainUploadForm':
* Add a nice fieldset around the input form
* Add a CSS id for the table
* Found CSS classes for aligning in shared.css -> use them!
* Fix indention
Modified paths:
  • /trunk/phase3/includes/SpecialUpload.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SpecialUpload.php
@@ -911,7 +911,7 @@
912912 * @access private
913913 */
914914 function mainUploadForm( $msg='' ) {
915 - global $wgOut, $wgUser, $wgContLang;
 915+ global $wgOut, $wgUser;
916916 global $wgUseCopyrightUpload, $wgUseAjax, $wgAjaxUploadDestCheck, $wgAjaxLicensePreview;
917917 global $wgRequest, $wgAllowCopyUploads;
918918 global $wgStylePath, $wgStyleVersion;
@@ -979,25 +979,25 @@
980980 # MIME type here, it's incomprehensible to most people and too long.
981981 global $wgCheckFileExtensions, $wgStrictFileExtensions,
982982 $wgFileExtensions, $wgFileBlacklist;
 983+
 984+ $allowedExtensions = '';
983985 if( $wgCheckFileExtensions ) {
984986 $delim = wfMsgExt( 'comma-separator', array( 'escapenoentities' ) );
985987 if( $wgStrictFileExtensions ) {
986988 # Everything not permitted is banned
987 - $wgOut->addHTML(
 989+ $extensionsList =
988990 '<div id="mw-upload-permitted">' .
989991 wfMsgWikiHtml( 'upload-permitted', implode( $wgFileExtensions, $delim ) ) .
990 - "</div>\n"
991 - );
 992+ "</div>\n";
992993 } else {
993994 # We have to list both preferred and prohibited
994 - $wgOut->addHTML(
 995+ $extensionsList =
995996 '<div id="mw-upload-preferred">' .
996997 wfMsgWikiHtml( 'upload-preferred', implode( $wgFileExtensions, $delim ) ) .
997998 "</div>\n" .
998999 '<div id="mw-upload-prohibited">' .
9991000 wfMsgWikiHtml( 'upload-prohibited', implode( $wgFileBlacklist, $delim ) ) .
1000 - "</div>\n"
1001 - );
 1001+ "</div>\n";
10021002 }
10031003 }
10041004
@@ -1014,7 +1014,6 @@
10151015
10161016
10171017 $titleObj = SpecialPage::getTitleFor( 'Upload' );
1018 - $action = $titleObj->escapeLocalURL();
10191018
10201019 $encDestName = htmlspecialchars( $this->mDesiredDestName );
10211020
@@ -1060,57 +1059,73 @@
10611060 }
10621061
10631062 $encComment = htmlspecialchars( $this->mComment );
1064 - $align1 = $wgContLang->isRTL() ? 'left' : 'right';
1065 - $align2 = $wgContLang->isRTL() ? 'right' : 'left';
10661063
1067 - $wgOut->addHTML( <<<EOT
1068 - <form id='upload' method='post' enctype='multipart/form-data' action="$action">
1069 - <table border='0'>
1070 - <tr>
1071 - {$this->uploadFormTextTop}
1072 - <td align='$align1' valign='top'><label for='wpUploadFile'>{$sourcefilename}</label></td>
1073 - <td align='$align2'>
1074 - {$filename_form}
1075 - </td>
1076 - </tr>
1077 - <tr>
1078 - <td align='$align1'><label for='wpDestFile'>{$destfilename}</label></td>
1079 - <td align='$align2'>
1080 - <input tabindex='2' type='text' name='wpDestFile' id='wpDestFile' size='60'
1081 - value="$encDestName" onchange='toggleFilenameFiller()' $destOnkeyup />
1082 - </td>
1083 - </tr>
1084 - <tr>
1085 - <td align='$align1'><label for='wpUploadDescription'>{$summary}</label></td>
1086 - <td align='$align2'>
1087 - <textarea tabindex='3' name='wpUploadDescription' id='wpUploadDescription' rows='6'
1088 - cols='{$cols}'{$width}>$encComment</textarea>
 1064+ $wgOut->addHTML(
 1065+ Xml::openElement( 'form', array( 'method' => 'post', 'action' => $titleObj->getLocalURL(),
 1066+ 'enctype' => 'multipart/form-data', 'id' => 'mw-upload-form' ) ) .
 1067+ Xml::openElement( 'fieldset' ) .
 1068+ Xml::element( 'legend', null, wfMsg( 'upload' ) ) .
 1069+ Xml::openElement( 'table', array( 'border' => '0', 'id' => 'mw-upload-table' ) ) .
 1070+ "<tr>
 1071+ {$this->uploadFormTextTop}
 1072+ <td class='mw-label'>
 1073+ <label for='wpUploadFile'>{$sourcefilename}</label>
 1074+ </td>
 1075+ <td class='mw-input'>
 1076+ {$filename_form}
 1077+ </td>
 1078+ </tr>
 1079+ <tr>
 1080+ <td></td>
 1081+ <td>
 1082+ {$extensionsList}
 1083+ </td>
 1084+ </tr>
 1085+ <tr>
 1086+ <td class='mw-label'>
 1087+ <label for='wpDestFile'>{$destfilename}</label>
 1088+ </td>
 1089+ <td class='mw-input'>
 1090+ <input tabindex='2' type='text' name='wpDestFile' id='wpDestFile' size='60'
 1091+ value=\"{$encDestName}\" onchange='toggleFilenameFiller()' $destOnkeyup />
 1092+ </td>
 1093+ </tr>
 1094+ <tr>
 1095+ <td class='mw-label'>
 1096+ <label for='wpUploadDescription'>{$summary}</label>
 1097+ </td>
 1098+ <td class='mw-input'>
 1099+ <textarea tabindex='3' name='wpUploadDescription' id='wpUploadDescription' rows='6'
 1100+ cols='{$cols}'{$width}>$encComment</textarea>
10891101 {$this->uploadFormTextAfterSummary}
1090 - </td>
1091 - </tr>
1092 - <tr>
1093 -EOT
 1102+ </td>
 1103+ </tr>
 1104+ <tr>"
10941105 );
10951106
10961107 if ( $licenseshtml != '' ) {
10971108 global $wgStylePath;
10981109 $wgOut->addHTML( "
1099 - <td align='$align1'><label for='wpLicense'>$license</label></td>
1100 - <td align='$align2'>
1101 - <select name='wpLicense' id='wpLicense' tabindex='4'
1102 - onchange='licenseSelectorCheck()'>
1103 - <option value=''>$nolicense</option>
1104 - $licenseshtml
1105 - </select>
1106 - </td>
1107 - </tr>
1108 - <tr>" );
 1110+ <td class='mw-label'>
 1111+ <label for='wpLicense'>$license</label>
 1112+ </td>
 1113+ <td class='mw-input'>
 1114+ <select name='wpLicense' id='wpLicense' tabindex='4'
 1115+ onchange='licenseSelectorCheck()'>
 1116+ <option value=''>$nolicense</option>
 1117+ $licenseshtml
 1118+ </select>
 1119+ </td>
 1120+ </tr>
 1121+ <tr>"
 1122+ );
11091123 if( $useAjaxLicensePreview ) {
11101124 $wgOut->addHtml( "
1111 - <td></td>
1112 - <td id=\"mw-license-preview\"></td>
1113 - </tr>
1114 - <tr>" );
 1125+ <td></td>
 1126+ <td id=\"mw-license-preview\"></td>
 1127+ </tr>
 1128+ <tr>"
 1129+ );
11151130 }
11161131 }
11171132
@@ -1121,45 +1136,55 @@
11221137 $uploadsource = htmlspecialchars( $this->mCopyrightSource );
11231138
11241139 $wgOut->addHTML( "
1125 - <td align='$align1' nowrap='nowrap'><label for='wpUploadCopyStatus'>$filestatus</label></td>
1126 - <td><input tabindex='5' type='text' name='wpUploadCopyStatus' id='wpUploadCopyStatus'
1127 - value=\"$copystatus\" size='60' /></td>
 1140+ <td class='mw-label' style='white-space: nowrap;'>
 1141+ <label for='wpUploadCopyStatus'>$filestatus</label></td>
 1142+ <td class='mw-input'>
 1143+ <input tabindex='5' type='text' name='wpUploadCopyStatus' id='wpUploadCopyStatus'
 1144+ value=\"$copystatus\" size='60' />
 1145+ </td>
 1146+ </tr>
 1147+ <tr>
 1148+ <td class='mw-label'>
 1149+ <label for='wpUploadCopyStatus'>$filesource</label>
 1150+ </td>
 1151+ <td class='mw-input'>
 1152+ <input tabindex='6' type='text' name='wpUploadSource' id='wpUploadCopyStatus'
 1153+ value=\"$uploadsource\" size='60' />
 1154+ </td>
 1155+ </tr>
 1156+ <tr>"
 1157+ );
 1158+ }
 1159+
 1160+ $wgOut->addHtml( "
 1161+ <td></td>
 1162+ <td>
 1163+ <input tabindex='7' type='checkbox' name='wpWatchthis' id='wpWatchthis' $watchChecked value='true' />
 1164+ <label for='wpWatchthis'>" . wfMsgHtml( 'watchthisupload' ) . "</label>
 1165+ <input tabindex='8' type='checkbox' name='wpIgnoreWarning' id='wpIgnoreWarning' value='true' $warningChecked/>
 1166+ <label for='wpIgnoreWarning'>" . wfMsgHtml( 'ignorewarnings' ) . "</label>
 1167+ </td>
11281168 </tr>
 1169+ $warningRow
11291170 <tr>
1130 - <td align='$align1'><label for='wpUploadCopyStatus'>$filesource</label></td>
1131 - <td><input tabindex='6' type='text' name='wpUploadSource' id='wpUploadCopyStatus'
1132 - value=\"$uploadsource\" size='60' /></td>
 1171+ <td></td>
 1172+ <td class='mw-input'>
 1173+ <input tabindex='9' type='submit' name='wpUpload' value=\"{$ulb}\"" . $wgUser->getSkin()->tooltipAndAccesskey( 'upload' ) . " />
 1174+ </td>
11331175 </tr>
11341176 <tr>
1135 - ");
1136 - }
1137 -
1138 - $wgOut->addHtml( "
1139 - <td></td>
1140 - <td>
1141 - <input tabindex='7' type='checkbox' name='wpWatchthis' id='wpWatchthis' $watchChecked value='true' />
1142 - <label for='wpWatchthis'>" . wfMsgHtml( 'watchthisupload' ) . "</label>
1143 - <input tabindex='8' type='checkbox' name='wpIgnoreWarning' id='wpIgnoreWarning' value='true' $warningChecked/>
1144 - <label for='wpIgnoreWarning'>" . wfMsgHtml( 'ignorewarnings' ) . "</label>
1145 - </td>
1146 - </tr>
1147 - $warningRow
1148 - <tr>
1149 - <td></td>
1150 - <td align='$align2'><input tabindex='9' type='submit' name='wpUpload' value=\"{$ulb}\"" . $wgUser->getSkin()->tooltipAndAccesskey( 'upload' ) . " /></td>
1151 - </tr>
1152 - <tr>
1153 - <td></td>
1154 - <td align='$align2'>
1155 - " );
 1177+ <td></td>
 1178+ <td class='mw-input'>"
 1179+ );
11561180 $wgOut->addWikiText( wfMsgForContent( 'edittools' ) );
11571181 $wgOut->addHTML( "
1158 - </td>
1159 - </tr>
1160 -
1161 - </table>
1162 - <input type='hidden' name='wpDestFileWarningAck' id='wpDestFileWarningAck' value=''/>
1163 - </form>" );
 1182+ </td>
 1183+ </tr>" .
 1184+ Xml::closeElement( 'table' ) .
 1185+ Xml::hidden( 'wpDestFileWarningAck', '' ) .
 1186+ Xml::closeElement( 'fieldset' ) .
 1187+ Xml::closeElement( 'form' )
 1188+ );
11641189 $uploadfooter = wfMsgNoTrans( 'uploadfooter' );
11651190 if( $uploadfooter != '-' && !wfEmptyMsg( 'uploadfooter', $uploadfooter ) ){
11661191 $wgOut->addWikiText( Xml::tags( 'div',

Follow-up revisions

RevisionCommit summaryAuthorDate
r32217* (Bug 13448) Fix regression from r32077: Readd CSS id for hidden field....raymond10:46, 20 March 2008

Status & tagging log