You are here

function theme_styleswitcher_admin_styles_table in Style Switcher 7.2

Same name and namespace in other branches
  1. 8.2 styleswitcher.module \theme_styleswitcher_admin_styles_table()
  2. 6.2 styleswitcher.admin.inc \theme_styleswitcher_admin_styles_table()
  3. 3.0.x styleswitcher.module \theme_styleswitcher_admin_styles_table()

Returns HTML for the styles settings overview form element.

Parameters

array $variables: An associative array containing:

  • form: An element representing the form.
1 theme call to theme_styleswitcher_admin_styles_table()
styleswitcher_config_theme in ./styleswitcher.admin.inc
Page callback: Constructs a form for a theme-specific styles settings.

File

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

Code

function theme_styleswitcher_admin_styles_table(array $variables) {
  $form = $variables['form'];
  $header = array(
    t('Style'),
    t('Enabled'),
    t('Default'),
    t('Weight'),
  );
  $rows = array();
  if (!empty($form['weight'])) {
    foreach (element_children($form['weight']) as $key) {
      if ($key == $form['default']['#default_value']) {
        $form['enabled'][$key]['#attributes']['disabled'] = 'disabled';
      }
      $label = drupal_render($form['label'][$key]);
      $form['enabled'][$key]['#title'] = t('Enable !title', array(
        '!title' => $label,
      ));
      $form['enabled'][$key]['#title_display'] = 'invisible';
      $form['default'][$key]['#title'] = t('Set !title as default', array(
        '!title' => $label,
      ));
      $form['default'][$key]['#title_display'] = 'invisible';

      // Build the table row.
      $row = array(
        array(
          'data' => $form['name'][$key],
        ),
        array(
          'data' => $form['enabled'][$key],
        ),
        array(
          'data' => $form['default'][$key],
        ),
        array(
          'data' => $form['weight'][$key],
        ),
      );
      $rows[] = array(
        'data' => $row,
        'class' => array(
          'draggable',
        ),
      );
    }
  }
  $table_vars = array(
    'header' => $header,
    'rows' => $rows,
    'empty' => t('No styles to switch.'),
    'attributes' => array(
      'id' => 'styleswitcher-styles-table',
    ),
  );
  $output = theme('table', $table_vars);
  drupal_add_tabledrag('styleswitcher-styles-table', 'order', 'sibling', 'styleswitcher-style-weight');
  return $output;
}