You are here

function magic_export_settings in Magic 7

Same name and namespace in other branches
  1. 7.2 includes/magic.export.inc \magic_export_settings()

Exports theme settings.

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

File

./magic.module, line 57
Keep Frontend DRY; sprinkle it with MAGIC!

Code

function magic_export_settings($form, &$form_state, $theme) {
  $path = drupal_get_path('theme', $theme);
  if ($path == '') {

    // The theme doesn't actually exist, return a 404 page.
    drupal_not_found();
    return;
  }
  $theme_info = drupal_parse_info_file($path . '/' . $theme . '.info');
  unset($theme_info['settings']);
  $name = filter_xss($theme_info['name']);
  drupal_set_title(t('Export theme settings for ' . $name));
  $settings = isset($theme_info['settings']) ? $theme_info['settings'] : array();
  $settings = variable_get('theme_' . $theme . '_settings', $settings);
  $theme_info['settings'] = $settings;
  $built_info = _magic_build_info_file($theme_info);
  $lines = substr_count($built_info, "\n");
  if ($lines > 40) {
    $lines = 40;
  }
  $form = array();
  $form['info'] = array(
    '#title' => t($name . '.info Contents'),
    '#description' => t('Make any changes you want to ' . $name . '.info then press the Save button to overwrite ' . $name . '.info. If the file is saved correctly, the variable settings within the database will be automatically removed.'),
    '#type' => 'textarea',
    '#rows' => $lines,
    '#default_value' => $built_info,
  );
  $form['settings'] = array(
    '#title' => t('Settings.php export'),
    '#type' => 'textarea',
    '#default_value' => _magic_build_settings_php_export($theme_info, $theme),
    '#description' => t('For a permanent settings save, copy and paste this into your settings.php file. If you do this, you cannot change the settings with the UI any longer.'),
  );
  $form['theme'] = array(
    '#type' => 'hidden',
    '#value' => $theme,
  );
  $form['save'] = array(
    '#type' => 'submit',
    '#value' => t('Save ' . $name . '.info'),
  );
  return $form;
}