You are here

function template_preprocess_spaces_preset_form in Spaces 7

Same name and namespace in other branches
  1. 7.3 theme/theme.inc \template_preprocess_spaces_preset_form()

Preprocessor for theme('spaces_preset_form').

File

theme/theme.inc, line 43

Code

function template_preprocess_spaces_preset_form(&$variables) {
  $form =& $variables['form'];
  drupal_add_css(drupal_get_path('module', 'spaces') . '/spaces.css');
  $header = array(
    array(
      'data' => check_plain($form['#title']),
      'colspan' => isset($form['storage']) ? 4 : 3,
    ),
  );
  $type = $form['#space_type'];
  $rows = array();
  if (!empty($form['#description'])) {
    $rows[] = array(
      array(
        'data' => "<div class='description'>{$form['#description']}</div>",
        'colspan' => isset($form['storage']) ? 4 : 3,
      ),
    );
  }
  foreach (element_children($form["spaces_preset_{$type}"]) as $preset) {
    $row = array();
    $row[] = array(
      'class' => array(
        'option',
      ),
      'data' => $form["spaces_preset_{$type}"][$preset],
    );
    $row[] = array(
      'class' => array(
        'label',
      ),
      'data' => $form['labels'][$preset],
    );
    if (isset($form['storage'][$preset])) {
      $row[] = array(
        'class' => array(
          'storage',
        ),
        'data' => $form['storage'][$preset],
      );
    }
    $row[] = array(
      'class' => array(
        'actions',
      ),
      'data' => $form['actions'][$preset],
    );
    $rows[] = array(
      'class' => !empty($form["spaces_preset_{$type}"][$preset]) ? array(
        'enabled',
      ) : array(
        'disabled',
      ),
      'data' => $row,
    );
  }
  $table = array(
    'header' => $header,
    'rows' => $rows,
    'attributes' => array(
      'class' => array(
        'spaces',
      ),
    ),
  );
  $variables['presets'] = theme('table', $table);
  unset($form["spaces_preset_{$type}"]);
  unset($form['labels']);
  unset($form['storage']);
  unset($form['actions']);
}