You are here

function skinr_export_form in Skinr 6

Skinr settings export form.

1 string reference to 'skinr_export_form'
skinr_menu in ./skinr.module
Implementation of hook_menu().

File

./skinr.admin.inc, line 14

Code

function skinr_export_form(&$form_state, $theme = NULL) {
  $form = array();
  $themes = list_themes();
  if ($theme) {

    // Export an individual theme.
    $theme = str_replace('-', '_', $theme);
    $code = '$skinr = ' . var_export(skinr_get($theme), TRUE) . ';';
    $lines = substr_count($code, "\n") + 1;
    $form['theme'] = array(
      '#type' => 'textfield',
      '#title' => t('Theme'),
      '#value' => $themes[$theme]->info['name'],
      '#disabled' => TRUE,
    );
    $form['skinr_settings'] = array(
      '#type' => 'textarea',
      '#title' => t('Skinr settings'),
      '#default_value' => $code,
      '#rows' => min($lines, 150),
    );
  }
  else {

    // Give the option for which theme to export.
    $options = array();
    ksort($themes);
    $current_theme = skinr_current_theme();

    // Put default theme at the top.
    $options[$current_theme] = $themes[$current_theme]->info['name'] . ' [' . t('default') . ']';
    foreach ($themes as $theme) {
      if ($theme->name == $current_theme) {

        // Do nothing.
      }
      elseif ($theme->status) {
        $options[$theme->name] = $theme->info['name'] . ' [' . t('enabled') . ']';
      }
      else {
        $options[$theme->name] = $theme->info['name'];
      }
    }
    $form['theme'] = array(
      '#type' => 'select',
      '#title' => t('Theme'),
      '#description' => t('Theme to export the skinr settings for.'),
      '#options' => $options,
      '#required' => TRUE,
    );
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Export'),
    );
  }
  return $form;
}