Index: l10n_community/l10n_community.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/l10n_server/l10n_community/Attic/l10n_community.module,v
retrieving revision 1.1.2.23.2.39
diff -u -r1.1.2.23.2.39 l10n_community.module
--- l10n_community/l10n_community.module	19 Aug 2009 21:55:54 -0000	1.1.2.23.2.39
+++ l10n_community/l10n_community.module	20 Aug 2009 22:13:37 -0000
@@ -76,7 +76,7 @@
     'position' => 'right',
     'weight' => -5,
   );
-  
+
   $items['admin/l10n_server/l10n_community'] = array(
     'title' => 'General settings',
     'description' => 'Set up general settings for the localization server.',
@@ -284,6 +284,13 @@
     'type' => MENU_LOCAL_TASK,
     'weight' => 10,
   );
+  $items['l10n_server/changereleases/js'] = array(
+    'title' => 'Export',
+    'page callback' => 'l10n_community_export_page_js',
+    'access arguments' => array('access localization community'),
+    'file' => 'export.inc',
+    'type' => MENU_CALLBACK,
+  );
 
   return $items;
 }
@@ -517,11 +524,11 @@
  */
 function l10n_community_form_alter(&$form, $form_state, $form_id) {
   if (in_array($form_id, array('system_themes_form', 'system_modules'))) {
-    // On the system themes and modules forms, set up a memory of the current 
+    // On the system themes and modules forms, set up a memory of the current
     // properties of languages and restore after the import batch was run.
     $form['#submit'][] = 'l10n_community_batch_restore_plurals';
   }
-  
+
   elseif ($form_id == 'locale_translate_import_form') {
     // Protect the plural forms when importing, going against Drupal's
     // default behavior. The number of plurals is important for the user
@@ -534,13 +541,13 @@
       array('l10n_community_import_restore_plurals')
     );
   }
-  
+
   elseif ($form_id == 'locale_languages_predefined_form') {
     // Add our submit handler to match the plural formula to the language
     // if we have a known formula for it.
     $form['#submit'][] = 'l10n_community_predefined_plural_formula_submit';
   }
-  
+
   elseif (in_array($form_id, array('locale_languages_custom_form', 'locale_languages_edit_form'))) {
     // Build a list of examples we have with existing languages.
     $formulas = l10n_community_plural_formulas();
@@ -553,7 +560,7 @@
     foreach ($types as $plural_formula => $languages) {
       $examples[] = t('<strong>@formula</strong> used by %languages', array('@formula' => $plural_formula, '%languages' => join(', ', $languages)));
     }
-    
+
     // Pick form root depending on form.
     $form_root = &$form;
     if ($form_id == 'locale_languages_custom_form') {
@@ -567,7 +574,7 @@
         $plural_formula = 'nplurals='. $language->plurals .'; plural='. strtr($language->formula, array('$' => '')) .';';
       }
     }
-    
+
     // Add text field to enter the plural formula.
     $form_root['submit']['#weight'] = 200;
     $form_root['direction']['#weight'] = 180;
@@ -615,7 +622,7 @@
 function l10n_community_import_save_plurals($form, &$form_state) {
   static $formula = NULL;
   static $plurals = NULL;
-  
+
   if (!empty($form)) {
     // Called with form. Remember values for after import.
     $language = db_fetch_object(db_query("SELECT * FROM {languages} WHERE language = '%s'", $form_state['values']['langcode']));
Index: l10n_community/export.inc
===================================================================
RCS file: /cvs/drupal/contributions/modules/l10n_server/l10n_community/Attic/export.inc,v
retrieving revision 1.1.2.15.2.12
diff -u -r1.1.2.15.2.12 export.inc
--- l10n_community/export.inc	16 Aug 2009 15:00:51 -0000	1.1.2.15.2.12
+++ l10n_community/export.inc	20 Aug 2009 22:13:37 -0000
@@ -39,6 +39,7 @@
 function l10n_community_export_form(&$form_state, $uri = NULL, $langcode = NULL) {
 
   $hide_projects = FALSE;
+  $projects = l10n_community_get_projects();
   if (!isset($uri)) {
     $uri = !empty($form_state['values']['project']) ? $form_state['values']['project'] : (!empty($_GET['project']) ? $_GET['project'] : NULL);
   }
@@ -46,8 +47,14 @@
     // When project was preset from URL, disable the selector.
     $hide_projects = TRUE;
   }
-
-  $projects = l10n_community_get_projects();
+  $form['nojs'] = array(
+    '#type' => 'item',
+    '#value' => '<noscript><div class="warning">'. t('Please enable javascript for a better userinterface') .'</div></noscript>',
+  );
+  $form['js'] = array(
+    '#type' => 'value',
+    '#value' => FALSE,
+  );
   $form['data'] = array(
     '#type' => 'fieldset',
     '#title' => t('Source data'),
@@ -84,7 +91,11 @@
   if (isset($projects[$uri])) {
     // Set this project as default value if identified.
     $form['data']['project']['#default_value'] = $projects[$uri]->title;
-
+    $form['data']['project']['#ahah'] = array(
+        'event' => 'change',
+        'path' => 'l10n_server/changereleases/js',
+        'wrapper' => 'l10n_server_releases',
+    );
     $releases = l10n_community_get_releases($uri);
     $release_options = array('all' => t('All'));
     foreach ($releases as $rid => $this_release) {
@@ -93,8 +104,10 @@
     $form['data']['release'] = array(
       '#title' => t('Release'),
       '#type' => count($release_options) <= 3 ? 'radios' : 'select',
-      '#options' => $release_options,
-      '#default_value' => isset($release) ? $release : 'all',
+      '#options' =>  $release_options,
+      '#default_value' => 'all',
+      '#prefix' => '<div id="l10n_server_releases">',
+      '#suffix' => '</div>',
       '#description' => t('Exporting with all releases is useful for translators, but is not optimal to use for end users because unused data would clutter up their database, when files get imported. Export for all releases if you would like to provide a complete translation, and you work with a desktop tool.'),
     );
   }
@@ -133,6 +146,30 @@
 }
 
 /**
+ * @see http://drupal.org/node/331941
+ * @return json data for the changed values
+ */
+function l10n_community_export_page_js() {
+  $form_state = array('storage' => NULL, 'submitted' => FALSE);
+  $form_build_id = $_POST['form_build_id'];
+  $form = form_get_cache($form_build_id, $form_state);
+  $args = $form['#parameters'];
+  $form_id = array_shift($args);
+  $form_state['post'] = $form['#post'] = $_POST;
+  $form['#programmed'] = $form['#redirect'] = FALSE;
+  // set to TRUE, so we can check that in l10n_community_export_form_submit()
+  $form['js'] = array('#type' => 'value', '#value' => TRUE);
+  drupal_process_form($form_id, $form, $form_state);
+  $form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id);
+  $release_form = $form['data']['release'];
+  unset($release_form['#prefix'], $release_form['#suffix']);
+  $output = theme('status_messages') . drupal_render($release_form);
+  // Final rendering callback.
+drupal_json(array('status' => TRUE, 'data' => $output));
+}
+
+
+/**
  * Release field is mandatory.
  */
 function l10n_community_export_form_validate($form, &$form_state) {
@@ -150,6 +187,10 @@
  * all details available and return the output via HTTP.
  */
 function l10n_community_export_form_submit($form, &$form_state) {
+//if you choose 'All' and you change the project, you get the downloadfile as alert
+if($form_state['values']['js']) {
+  return;
+}
 
   // This was validated to work in the validation code.
   $uri = !empty($form_state['values']['project']) ? l10n_community_project_uri_by_title($form_state['values']['project']) : NULL;
@@ -166,6 +207,7 @@
   elseif ($form_state['values']['release'] != 'all') {
     $releases = l10n_community_get_releases($uri);
     if (!isset($releases[$form_state['values']['release']])) {
+      $form_state['redirect'] = array($_GET['q'], array('project' => $uri));
       form_set_error('release', t('Invalid release chosen.'));
       return;
     }
