Index: ahah_helper.module =================================================================== --- ahah_helper.module (revision 53443) +++ ahah_helper.module (revision 53537) @@ -33,6 +33,14 @@ 'access callback' => TRUE, 'type' => MENU_CALLBACK, ); + $items['admin/settings/ahah_helper'] = array( + 'title' => 'AHAH helper', + 'description' => 'Adjust AHAH helper settings.', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('ahah_helper_admin_settings'), + 'access arguments' => array('administer site configuration'), + 'type' => MENU_NORMAL_ITEM, + ); return $items; } // If the form is being rebuilt due to something else than a pressed button, @@ -193,14 +201,44 @@ // Get the JS settings so we can merge them. $javascript = drupal_add_js(NULL, NULL, 'header'); $settings = call_user_func_array('array_merge_recursive', $javascript['setting']); + $settings = _ahah_get_configured_settings_list($settings); drupal_json(array( 'status' => TRUE, 'data' => theme('status_messages') . drupal_render($form_item), - 'settings' => array('ahah' => $settings['ahah']), + 'settings' => $settings, )); } +/** + * Module configuration form + */ +function ahah_helper_admin_settings() { + + $form = array(); + $form['drupal_settings'] = array( + '#type' => 'fieldset', + '#title' => t('Drupal settings'), + ); + $form['drupal_settings']['ahah_helper_drupal_settings'] = array( + '#type' => 'textarea', + '#title' => t('Merged Drupal settings'), + '#default_value' => variable_get('ahah_helper_drupal_settings', ''), + '#description' => t('By default this module updates just ahah setting. + If there are other modules that need to update their Drupal.settings branch + after AJAX reload you can list them here. Please use one setting name per line. + You don\'t need to add line ahah. It\'s added automatically. + For example, if you use tabledrag behavior and date_popup element in your form + you might want to add following settings: + +
+tableDrag +datePopup +'), + ); + + return system_settings_form($form); +} //---------------------------------------------------------------------------- // Private functions. @@ -256,6 +294,23 @@ } } +function _ahah_get_configured_settings_list($settings) { + $new_settings = array( + 'ahah' => $settings['ahah'] + ); + $configured_settings = variable_get('ahah_helper_drupal_settings', ''); + if (!empty($configured_settings)) { + $configured_settings = explode("\r\n", $configured_settings); + foreach ($configured_settings as $setting) { + $setting = trim($setting); + if (!empty($setting) && !empty($settings[$setting])) { + $new_settings[$setting] = $settings[$setting]; + } + } + } + + return $new_settings; +} //---------------------------------------------------------------------------- // Additional PHP functions. @@ -321,3 +376,4 @@ return $form; } +