--- jquery_ui.module 2008-06-22 22:09:58.000000000 +0200 +++ jquery_ui_new.module 2008-07-05 14:47:01.000000000 +0200 @@ -72,6 +72,70 @@ function jquery_ui_add($files = array()) } /** + * Implementation of hook_form_form_id_alter(). + */ +function jquery_ui_form_system_theme_settings_alter(&$form, $form_state) { + // Determine which Drupal theme's settings page we're looking at. + $key = $form['var']['#value']; + $key = ($key == 'theme_settings') ? '' : preg_replace('/(^theme_|_settings$)/', '', $key); + + $themes = jquery_ui_get_themes(); + $settings = jquery_get_settings($key); + + $form['jquery_ui'] = array( + '#type' => 'fieldset', + '#title' => t('jQuery UI'), + '#collapsible' => TRUE, + '#collapsed' => TRUE, + '#tree' => TRUE, + '#weight' => -10, + ); + $form['jquery_ui']['theme'] = array( + '#type' => 'select', + '#title' => t('jQuery UI theme'), + '#options' => $themes, + '#default_value' => $settings['theme'], + '#description' => t('The theme used by jQuery UI for its widgets.'), + ); +} + +/** + * Retrieve the jQuery UI settings for the theme. + */ +function jquery_ui_get_settings($key) { + $default_settings = array( + 'jquery_ui' => array( + 'theme' => 'flora', + ) + ); + $settings = array_merge($default_settings, theme_get_settings($key)); + + return $settings['jquery_ui']; +} + +/** + * Retrieve list of themes that can be selected. + */ +function jquery_ui_get_themes() { + $themes_path = JQUERY_UI_PATH . '/themes'; + $themes = array(); + + // Find all files in the themes folder, without recursing. Loop through and + // check for directories with dirname.css files within them. + $files = file_scan_directory($themes_path, '.*', array('.', '..', 'CVS'), 0, FALSE); + foreach ($files as $file) { + if (is_dir($file->filename)) { + $css_path = $themes_path . "/$file->basename/$file->basename.css"; + if (file_exists($css_path)) { + $themes[$file->basename] = $file->basename; + } + } + } + + return $themes; +} + +/** * Return the version of jQuery UI installed. */ function jquery_ui_get_version() {