summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/system/system.module6
-rw-r--r--modules/upload/upload.module28
2 files changed, 15 insertions, 19 deletions
diff --git a/modules/system/system.module b/modules/system/system.module
index 710f5894c..7008353f2 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -103,9 +103,8 @@ function system_elements() {
$type['form'] = array('#method' => 'post', '#action' => request_uri());
// Inputs
- $type['checkbox'] = array('#input' => TRUE, '#return_value' => 1);
- $type['submit'] = array('#input' => TRUE, '#name' => 'op', '#button_type' => 'submit', '#executes_submit_callback' => TRUE);
- $type['button'] = array('#input' => TRUE, '#name' => 'op', '#button_type' => 'submit', '#executes_submit_callback' => FALSE);
+ $type['submit'] = array('#input' => TRUE, '#name' => 'op', '#button_type' => 'submit', '#executes_submit_callback' => TRUE, '#ahah_event' => 'submit', '#process' => array('form_expand_ahah'));
+ $type['button'] = array('#input' => TRUE, '#name' => 'op', '#button_type' => 'submit', '#executes_submit_callback' => FALSE, '#ahah_event' => 'submit', '#process' => array('form_expand_ahah'));
$type['textfield'] = array('#input' => TRUE, '#size' => 60, '#maxlength' => 128, '#autocomplete_path' => FALSE);
$type['password'] = array('#input' => TRUE, '#size' => 60, '#maxlength' => 128);
$type['password_confirm'] = array('#input' => TRUE, '#process' => array('expand_password_confirm'));
@@ -113,6 +112,7 @@ function system_elements() {
$type['radios'] = array('#input' => TRUE, '#process' => array('expand_radios'));
$type['radio'] = array('#input' => TRUE, '#default_value' => NULL);
$type['checkboxes'] = array('#input' => TRUE, '#process' => array('expand_checkboxes'), '#tree' => TRUE);
+ $type['checkbox'] = array('#input' => TRUE, '#return_value' => 1);
$type['select'] = array('#input' => TRUE, '#size' => 0, '#multiple' => FALSE);
$type['weight'] = array('#input' => TRUE, '#delta' => 10, '#default_value' => 0, '#process' => array('process_weight'));
$type['date'] = array('#input' => TRUE, '#process' => array('expand_date' => array()), '#element_validate' => array('date_validate'));
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.