summaryrefslogtreecommitdiff
path: root/modules/upload
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2007-07-04 15:42:38 +0000
committerDries Buytaert <dries@buytaert.net>2007-07-04 15:42:38 +0000
commit2ceae6ad581701a0ee72eede787583e9140a5eda (patch)
treec5e2a20a20ad3385868ff44415e92ceb877c7cc5 /modules/upload
parent4b3efeffca3c8743ad175eea3171bfd0346e4b70 (diff)
downloadbrdo-2ceae6ad581701a0ee72eede787583e9140a5eda.tar.gz
brdo-2ceae6ad581701a0ee72eede787583e9140a5eda.tar.bz2
- Patch #154398 by quicksketch et al: add dynamic AHAH submission properties to Forms API. This patch was ready for a long time and is somewhat of a usability improvement (enabler).
Diffstat (limited to 'modules/upload')
-rw-r--r--modules/upload/upload.module28
1 files changed, 12 insertions, 16 deletions
diff --git a/modules/upload/upload.module b/modules/upload/upload.module
index 434c87c59..22419573c 100644
--- a/modules/upload/upload.module
+++ b/modules/upload/upload.module
@@ -368,9 +368,6 @@ function upload_form_alter(&$form, $form_state, $form_id) {
if (isset($form['type']) && isset($form['#node'])) {
$node = $form['#node'];
if ($form['type']['#value'] .'_node_form' == $form_id && variable_get("upload_$node->type", TRUE)) {
- drupal_add_js('misc/progress.js');
- drupal_add_js('misc/upload.js');
-
// Attachments fieldset
$form['attachments'] = array(
'#type' => 'fieldset',
@@ -384,7 +381,7 @@ function upload_form_alter(&$form, $form_state, $form_id) {
'#weight' => 30,
);
- // Wrapper for fieldset contents (used by upload JS).
+ // Wrapper for fieldset contents (used by ahah.js).
$form['attachments']['wrapper'] = array(
'#prefix' => '<div id="attach-wrapper">',
'#suffix' => '</div>',
@@ -633,12 +630,6 @@ function _upload_form($node) {
if (user_access('upload files')) {
$limits = _upload_file_limits($user);
-
- // This div is hidden when the user uploads through JS.
- $form['new'] = array(
- '#prefix' => '<div id="attach-hide">',
- '#suffix' => '</div>',
- );
$form['new']['upload'] = array(
'#type' => 'file',
'#title' => t('Attach new file'),
@@ -649,14 +640,13 @@ function _upload_form($node) {
'#type' => 'submit',
'#value' => t('Attach'),
'#name' => 'attach',
- '#id' => 'attach-button',
+ '#ahah_path' => 'upload/js',
+ '#ahah_wrapper' => 'attach-wrapper',
'#submit' => array(),
);
- // The class triggers the js upload behaviour.
- $form['attach-url'] = array('#type' => 'hidden', '#value' => url('upload/js', array('absolute' => TRUE)), '#attributes' => array('class' => 'upload'));
}
- // Needed for JS.
+ // This value is used in upload_js().
$form['current']['vid'] = array('#type' => 'hidden', '#value' => isset($node->vid) ? $node->vid : 0);
return $form;
}
@@ -708,6 +698,7 @@ function upload_load($node) {
function upload_js() {
// We only do the upload.module part of the node validation process.
$node = (object)$_POST;
+ $files = isset($_POST['files']) ? $_POST['files'] : array();
// Load existing node files.
$node->files = upload_load($node);
@@ -725,8 +716,13 @@ function upload_js() {
drupal_alter('form', $form, array(), 'upload_js');
$form_state = array('submitted' => FALSE);
$form = form_builder('upload_js', $form, $form_state);
- // @todo: Put status messages inside wrapper, instead of above so they do not
- // persist across ajax reloads.
+
+ // Maintain the list and delete checkboxes values.
+ foreach ($files as $fid => $file) {
+ $form['files'][$fid]['list']['#value'] = isset($file['list']) ? 1 : 0;
+ $form['files'][$fid]['remove']['#value'] = isset($file['remove']) ? 1 : 0;
+ }
+
$output = theme('status_messages') . drupal_render($form);
// We send the updated file attachments form.