- Timestamp:
- Nov 23, 2005 9:29:33 PM (18 years ago)
- Location:
- trunk/bin/module_maker
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bin/module_maker/form_template.cli.php
r21 r22 64 64 <tr> 65 65 <td class="right"><label for="$field"<\x3fphp \$fv->err('$field', ' class="error"') \x3f>><\x3fphp echo _("$title"); \x3f></label></td> 66 <td valign="top">66 <td> 67 67 <select name="$field" class="small"> 68 <\x3fphp printSelectForm('<##>_tbl', "CONCAT(<##>_id, '—', <##>)", '$field', \$frm['$field'], true, 'ORDER BY $field DESC'); \x3f>68 <\x3fphp printSelectForm('<##>_tbl', "CONCAT(<##>_id, '—', <##>)", '$field', \$frm['$field'], true, 'ORDER BY $field ASC'); \x3f> 69 69 </select> 70 <span class="commandtext"> 71 <span class="commanditem"><a href="<\x3fphp echo App::oHREF('<##>.php?op=add&boomerang=true'); \x3f>" onClick="javascript:return confirm('<\x3fphp echo _("Notice: You are about to leave this form page and any changes you may have made without saving will be lost."); \x3f>')"><\x3fphp echo _("Add <##>") \x3f></a></span> 72 <\x3fphp if ('' != \$frm['<##>_id']) { \x3f> 73 <span class="commanditem"><a href="<\x3fphp echo App::oHREF('<##>.php?op=edit&boomerang=true&<##>_id=' . \$frm['<##>_id']); \x3f>" onClick="javascript:return confirm('<\x3fphp echo _("Notice: You are about to leave this form page and any changes you may have made without saving will be lost."); \x3f>')"><\x3fphp echo sprintf(_("Edit <##> <em>%s</em>"), \$frm['<##>']) \x3f></a></span> 74 <\x3fphp } \x3f> 75 </span> 70 76 </td> 71 77 </tr> … … 79 85 <tr> 80 86 <td class="right"><label for="$field"<\x3fphp \$fv->err('$field', ' class="error"') \x3f>><\x3fphp echo _("$title"); \x3f></label></td> 81 <td valign="top">87 <td> 82 88 <input type="file" name="$field" /> 83 89 <\x3fphp if ('' != \$upload->getFilenameGlob(getFormData('$primary_key_field') . '_*') && getFormData('op') == 'edit' || getFormData('op') == 'update') { \x3f> 84 <div class="help"><\x3fphp printf(_("The current file <a href=\"%s/%2\ $s\"><strong>%2\$s</strong></a> will be deleted if a new file is selected for upload."), '/_db_files/<##>', \$upload->getFilenameGlob(getFormData('$primary_key_field') . '_*')) \x3f></div>90 <div class="help"><\x3fphp printf(_("The current file <a href=\"%s/%2\\\$s\"><strong>%2\\\$s</strong></a> will be deleted if a new file is selected for upload."), '/_db_files/<##>', \$upload->getFilenameGlob(getFormData('$primary_key_field') . '_*')) \x3f></div> 85 91 <\x3fphp } \x3f> 86 92 <div class="help"><\x3fphp printf(_("File to upload must have one of the following file-name extensions: %s."), join(', ', \$upload->getParam('valid_file_extensions'))) \x3f></div> … … 96 102 <tr> 97 103 <td class="right"><label for="$field"<\x3fphp \$fv->err('$field', ' class="error"') \x3f>><\x3fphp echo _("$title"); \x3f></label></td> 98 <td valign="top">104 <td> 99 105 <input type="password" class="medium" size="50" name="$field" value="<\x3fphp echo oTxt(\$frm['$field']); \x3f>" /> 100 106 </td> … … 111 117 <tr> 112 118 <td class="right"><label for="$field"<\x3fphp \$fv->err('$field', ' class="error"') \x3f>><\x3fphp echo _("$title"); \x3f></label></td> 113 <td valign="top">119 <td> 114 120 <select name="$field"> 115 121 <\x3fphp printSetSelectForm('$db_tbl', '$field', \$frm['$field'], true); \x3f> … … 125 131 <tr> 126 132 <td class="right"><label for="$field"<\x3fphp \$fv->err('$field', ' class="error"') \x3f>><\x3fphp echo _("$title"); \x3f></label></td> 127 <td valign="top">133 <td> 128 134 <\x3fphp printSetCheckboxes('$db_tbl', '$field', \$frm['$field'], 1) \x3f> 129 135 </td> … … 156 162 <tr> 157 163 <td class="right"><label for="$field"<\x3fphp \$fv->err('$field', ' class="error"') \x3f>><\x3fphp echo _("$title"); \x3f></label></td> 158 <td valign="top">164 <td> 159 165 <textarea class="large" cols="75" rows="4" name="$field"><\x3fphp echo oTxt(\$frm['$field']); \x3f></textarea> 160 166 </td> … … 195 201 <tr> 196 202 <td class="right"><label for="$field"<\x3fphp \$fv->err('$field', ' class="error"') \x3f>><\x3fphp echo _("$title"); \x3f></label></td> 197 <td valign="top">203 <td> 198 204 <input type="text" class="medium" size="50" name="$field" value="<\x3fphp echo oTxt(\$frm['$field']); \x3f>" /> 199 205 </td> -
trunk/bin/module_maker/module.cli.php
r21 r22 207 207 $search['admin_upload_insert'] = '/%ADMIN_UPLOAD_INSERT%/'; 208 208 $replace['admin_upload_insert'] = ''; 209 $search['admin_upload_insert2'] = '/%ADMIN_UPLOAD_INSERT2%/';210 $replace['admin_upload_insert2'] = '';211 209 $search['admin_upload_update'] = '/%ADMIN_UPLOAD_UPDATE%/'; 212 210 $replace['admin_upload_update'] = ''; 213 211 214 212 if ($upload_file_capability) { 213 // Form arguments 215 214 $replace['admin_form_tag_init'] = "<form enctype=\"multipart/form-data\" method=\"post\" action=\"<\x3fphp echo \$_SERVER['PHP_SELF']; \x3f>\">\n<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"<##>\" />"; 216 215 216 // Include statement. 217 217 $replace['admin_upload_include'] = "require_once 'codebase/lib/Upload.inc.php';\n"; 218 218 219 // Config 219 220 $replace['admin_upload_config'] = <<<E_O_F 220 221 … … 230 231 E_O_F; 231 232 233 // Main init. 232 234 $replace['admin_upload_init'] = <<<E_O_F 233 235 … … 238 240 E_O_F; 239 241 242 // Delete. 240 243 $replace['admin_upload_del'] = <<<E_O_F 241 244 … … 246 249 E_O_F; 247 250 251 // Insert 1. 248 252 $replace['admin_upload_insert'] = <<<E_O_F 249 253 250 // Upload file. 251 if (!\$new_files = \$upload->process('<##>')) { 252 // Upload failed. Reload form, displaying errors. 253 \$frm =& addRecordForm(); 254 \$frm = array_merge(\$frm, getFormData()); 255 \$nav->addPage(_("Add %ITEM_TITLE%")); 256 \$main_template = '%ADMIN_FORM_TEMPLATE%'; 257 break; 254 // Upload files with prepended primary key. 255 \$new_file = \$upload->process('<##>', \$%PRIMARY_KEY% . '_' . getFormData('<##>')); 256 257 // If file upload errors, redirect to edit operation for the inserted record. 258 if (\$upload->anyErrors() || false === \$new_file) { 259 App::dieURL(\$_SERVER['PHP_SELF'] . '?op=edit&%PRIMARY_KEY%=' . \$%PRIMARY_KEY%); 258 260 } 259 261 E_O_F; 260 262 261 $replace['admin_upload_insert2'] = <<<E_O_F 262 263 // Record inserted successfuly. Now we know the primary key, prepend to filename. 264 \$upload->moveFile(\$new_files[0]['name'], \$%PRIMARY_KEY% . '_' . \$new_files[0]['name']); 265 E_O_F; 266 263 // Update. 267 264 $replace['admin_upload_update'] = <<<E_O_F 268 265 269 // Upload new file .266 // Upload new files. 270 267 if (getFormData('<##>')) { 271 if (\$upload->process('<##>', getFormData('%PRIMARY_KEY%') . '_' . getFormData('<##>'))) { 272 // Upload success. Delete old file. 273 if ('' != \$upload->getFilenameGlob(getFormData('%PRIMARY_KEY%') . '_*')) { 274 \$upload->deleteFile(\$upload->getFilenameGlob(getFormData('%PRIMARY_KEY%') . '_*')); 275 } 276 } else { 277 // Upload failed. Reload form, displaying errors. 268 // Get old file names for deletion. 269 \$old_file = \$upload->getFilenameGlob(getFormData('%PRIMARY_KEY%') . '_*'); 270 // Process new file upload with prepended primary key. 271 \$new_file = \$upload->process('<##>', getFormData('%PRIMARY_KEY%') . '_' . getFormData('<##>')); 272 if (false === \$new_file || \$upload->anyErrors()) { 273 // Upload failed. Reload form. Display errors. 278 274 \$frm =& editRecordForm(getFormData('%PRIMARY_KEY%')); 279 275 \$frm = array_merge(\$frm, getFormData()); … … 281 277 \$main_template = '%ADMIN_FORM_TEMPLATE%'; 282 278 break; 283 } 279 } else { 280 // Upload succeeded. Delete old files. 281 if ('' != \$old_file && \$old_file != \$new_file[0]['name']) { 282 \$upload->deleteFile(\$old_file); 283 } 284 } 284 285 } 285 286 E_O_F; 286 } // End if.287 } // End upload_file_capability. 287 288 288 289 -
trunk/bin/module_maker/skel/adm_form.ihtml
r21 r22 9 9 <tr> 10 10 <td> </td> 11 <td valign="top"><?php printSubmitButtons($frm['submit_buttons']); ?></td>11 <td><?php printSubmitButtons($frm['submit_buttons']); ?></td> 12 12 </tr> 13 13 %ADM_FORM_TABLE_ROWS% 14 14 <tr> 15 15 <td> </td> 16 <td valign="top"><?php printSubmitButtons($frm['submit_buttons']); ?></td>16 <td><?php printSubmitButtons($frm['submit_buttons']); ?></td> 17 17 </tr> 18 18 </table> -
trunk/bin/module_maker/skel/admin.php
r21 r22 92 92 // $auth->requireAccessClearance(ZONE_ADMIN_%NAME_UPPER%_FUNC_ADD); 93 93 if (getFormdata('cancel', false)) { 94 if (App::validBoomerangURL('%NAME_PLURAL%')) { 95 // Display boomerang page. 96 App::dieBoomerangURL('%NAME_PLURAL%'); 97 } 98 // Display default page. 94 99 App::dieURL($_SERVER['PHP_SELF']); 95 100 } … … 100 105 $nav->addPage(_("Add %ITEM_TITLE%")); 101 106 $main_template = '%ADMIN_FORM_TEMPLATE%'; 102 } else { %ADMIN_UPLOAD_INSERT%103 $%PRIMARY_KEY% = insertRecord(getFormData());%ADMIN_UPLOAD_INSERT 2%107 } else { 108 $%PRIMARY_KEY% = insertRecord(getFormData());%ADMIN_UPLOAD_INSERT% 104 109 if (getFormdata('repeat', false)) { 105 110 // Display function again. … … 122 127 if (getFormdata('cancel', false)) { 123 128 // Remove lock 124 $lock =& RecordLock::getInstance($GLOBALS['auth']);125 129 $lock->select('%DB_TBL%', '%PRIMARY_KEY%', getFormData('%PRIMARY_KEY%')); 126 130 $lock->remove(); … … 202 206 function &editRecordForm($id) 203 207 { 204 $lock =& RecordLock::getInstance($GLOBALS['auth']); 208 global $lock; 209 205 210 $lock->select('%DB_TBL%', '%PRIMARY_KEY%', $id); 206 211 if ($lock->isLocked() && !$lock->isMine()) { … … 240 245 function deleteRecord($id) 241 246 { 242 $lock =& RecordLock::getInstance($GLOBALS['auth']); 247 global $lock; 248 243 249 $lock->select('%DB_TBL%', '%PRIMARY_KEY%', $id); 244 250 if ($lock->isLocked() && !$lock->isMine()) { … … 291 297 function updateRecord($frm) 292 298 { 293 global $auth; 294 295 $lock =& RecordLock::getInstance($GLOBALS['auth']); 299 global $auth, $lock; 300 296 301 $lock->select('%DB_TBL%', '%PRIMARY_KEY%', $frm['%PRIMARY_KEY%']); 297 302 if ($lock->isLocked() && !$lock->isMine()) {
Note: See TracChangeset
for help on using the changeset viewer.