You are here

function delta_load_theme_settings_callback in Delta 7.2

1 call to delta_load_theme_settings_callback()
delta_layout_configure in ./delta_ui.admin.inc
delta_template_configure function.

File

./delta_ui.admin.inc, line 317
Delta UI functionality

Code

function delta_load_theme_settings_callback($theme, $layout) {
  if ($theme != 'none') {
    $key = $theme;
    $var = 'theme_delta_' . $layout . '_settings';
    $themes = system_rebuild_theme_data();
    $features = $themes[$key]->info['features'];
    $form = array();
    $form_state['build_info']['args'][0] = $key;

    // Call engine-specific settings.
    $function = $themes[$key]->prefix . '_engine_settings';
    if (function_exists($function)) {
      $form['engine_specific'] = array(
        '#type' => 'fieldset',
        '#title' => t('Theme-engine-specific settings'),
        '#description' => t('These settings only exist for the themes based on the %engine theme engine.', array(
          '%engine' => $themes[$key]->prefix,
        )),
      );
      $function($form, $form_state);
    }

    // create the variable we will store the data in.
    $form['var'] = $form['delta_template'] = array(
      '#type' => 'hidden',
      '#value' => $var,
    );

    // Create a list which includes the current theme and all its base themes.
    if (isset($themes[$key]->base_themes)) {
      $theme_keys = array_keys($themes[$key]->base_themes);
      $theme_keys[] = $key;
    }
    else {
      $theme_keys = array(
        $key,
      );
    }

    // Save the name of the current theme (if any), so that we can temporarily
    // override the current theme and allow theme_get_setting() to work
    // without having to pass the theme name to it.
    $default_theme = !empty($GLOBALS['theme_key']) ? $GLOBALS['theme_key'] : NULL;
    $GLOBALS['theme_key'] = $key;

    // Process the theme and all its base themes.
    foreach ($theme_keys as $theme) {

      // Include the theme-settings.php file.
      $filename = DRUPAL_ROOT . '/' . str_replace("/{$theme}.info", '', $themes[$theme]->filename) . '/theme-settings.php';
      if (file_exists($filename)) {
        require_once $filename;
      }

      // Call theme-specific settings.
      $function = $theme . '_form_system_theme_settings_alter';
      if (function_exists($function)) {
        $function($form, $form_state, $theme);
      }
    }

    // Restore the original current theme.
    if (isset($default_theme)) {
      $GLOBALS['theme_key'] = $default_theme;
    }
    else {
      unset($GLOBALS['theme_key']);
    }

    //krumo($form);

    //$variable = variable_get('theme_delta_omega_starterkit_omega-starterkit-home-layout_settings');

    //krumo($variable);

    //module_load_include('inc', 'system', 'system.admin');

    //$form = drupal_get_form('system_theme_settings', $theme);
    return $form;
  }
  else {
    return t('<div id="theme_settings_replace"><p>Unable to load theme settings form group... WTF...</p></div>');
  }
}