You are here

function styleswitcher_admin in Style Switcher 6.2

Same name and namespace in other branches
  1. 7.2 styleswitcher.admin.inc \styleswitcher_admin()
  2. 7 styleswitcher.module \styleswitcher_admin()

Page callback: Constructs a form for the Styleswitcher configuration.

See also

styleswitcher_admin_submit()

styleswitcher_menu()

1 string reference to 'styleswitcher_admin'
styleswitcher_menu in ./styleswitcher.module
Implements hook_menu().

File

./styleswitcher.admin.inc, line 16
Styleswitcher configuration functionality.

Code

function styleswitcher_admin(&$form_state) {
  $styles = styleswitcher_custom_styles();
  ksort($styles);
  $header = array(
    t('Style'),
    array(
      'data' => t('Operations'),
      'colspan' => '2',
    ),
  );
  $rows = array();
  foreach ($styles as $name => $style) {
    $name_hyphenated = strtr($name, '_', '-');

    // Build the table row.
    $row = array();
    $row[] = theme('styleswitcher_admin_style_overview', $style);
    $row[] = l(t('edit'), 'admin/settings/styleswitcher/' . $name_hyphenated);

    // Do not allow to delete the blank style.
    $delete = l(t('delete'), 'admin/settings/styleswitcher/' . $name_hyphenated . '/delete');
    $row[] = isset($style['path']) ? $delete : '';
    $rows[] = $row;
  }
  $form['styleswitcher_custom_styles'] = array(
    '#value' => theme('table', $header, $rows),
  );
  $form['styleswitcher_enable_overlay'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable overlay'),
    '#description' => t('Enable the overlay and fade when switching stylesheets.'),
    '#default_value' => variable_get('styleswitcher_enable_overlay', 1),
  );
  $form['#submit'][] = 'styleswitcher_admin_submit';
  return system_settings_form($form);
}