You are here

function magic_export_settings in Magic 7.2

Same name and namespace in other branches
  1. 7 magic.module \magic_export_settings()

Exports theme settings.

1 string reference to 'magic_export_settings'
magic_menu in ./magic.module
Implements hook_menu().

File

includes/magic.export.inc, line 11
Form and utility functions for exporting theme settings.

Code

function magic_export_settings($form, &$form_state, $theme) {
  $form_state['theme'] = $theme;
  $path = drupal_get_path('theme', $theme);
  $info = drupal_parse_info_file("{$path}/{$theme}.info");
  drupal_set_title(t('Export theme settings for @theme', array(
    '@theme' => $info['name'],
  )));
  $info['settings'] = !empty($info['settings']) ? $info['settings'] : array();
  $info['settings'] = variable_get('theme_' . $theme . '_settings', $info['settings']);
  $form['info'] = array(
    '#type' => 'textarea',
    '#title' => t("Export for the theme's .info file", array(
      '@theme' => $theme,
    )),
    '#description' => t("Make any changes you want and submit the form to overwrite the theme's .info file. Note: this will not overwrite settings set within the database, but will only allow documentation within code of settings."),
    '#rows' => 20,
    '#default_value' => _magic_build_info_file($info),
  );
  $form['settings'] = array(
    '#type' => 'textarea',
    '#title' => t('Export for settings.php'),
    '#description' => t('For a permanent settings override, manually copy and paste this into your settings.php file. If you do this, you cannot change the settings with the UI any longer. You may choose to only write some of the settings here, and not include everything in the settings.php.'),
    '#default_value' => _magic_build_settings_php_export($info, $theme),
  );
  $form['actions']['#type'] = 'actions';
  $form['actions']['save'] = array(
    '#type' => 'submit',
    '#value' => t("Write to the theme's .info file", array(
      '@theme' => $theme,
    )),
  );
  return $form;
}