You are here

function theme_spaces_overrides_form in Spaces 6.3

Theme function for spaces_overrides_form.

File

./spaces.theme.inc, line 53

Code

function theme_spaces_overrides_form($form) {
  drupal_add_js(drupal_get_path('module', 'spaces') . '/spaces.js');
  drupal_add_css(drupal_get_path('module', 'spaces') . '/spaces.css');
  $header = array(
    theme('table_select_header_cell'),
    array(
      'data' => t('Type'),
      'colspan' => 1,
    ),
    array(
      'data' => t('Override value'),
      'colspan' => 2,
    ),
  );
  $rows = array();
  foreach (array_keys(spaces_controllers()) as $controller) {
    if (!empty($form[$controller])) {
      foreach (element_children($form[$controller]) as $key) {
        $label = $form[$controller][$key]['#title'];
        $value = $form[$controller][$key]['#description'];
        $inherited = !empty($form[$controller][$key]['#disabled']);
        unset($form[$controller][$key]['#title'], $form[$controller][$key]['#description']);
        $row = array(
          'data' => array(
            array(
              'class' => 'option',
              'data' => drupal_render($form[$controller][$key]),
            ),
            array(
              'class' => 'controller',
              'data' => $controller,
            ),
            array(
              'class' => 'key',
              'data' => l($label, $_GET['q'], array(
                'fragment' => $key,
              )) . '<span class="override-value"><pre>' . $value . '</pre></span>',
              'colspan' => $inherited ? 1 : 2,
            ),
          ),
        );
        if ($inherited) {
          $row['class'] = 'inherited';
          $row['data'][] = array(
            'class' => 'tag',
            'data' => t('inherited'),
          );
        }
        $rows[] = $row;
      }
    }
  }
  if (count($rows)) {
    if (isset($form['preset'])) {
      $preset_label = $form['preset']['#title'];
      unset($form['preset']['#title']);
      $rows[] = array(
        array(
          'data' => $preset_label,
          'class' => 'action-label',
          'colspan' => 2,
        ),
        array(
          'data' => drupal_render($form['preset']),
          'class' => 'action-form',
          'colspan' => 3,
        ),
      );
    }
    if (isset($form['revert'])) {
      $revert_label = $form['revert']['#title'];
      unset($form['revert']['#title']);
      $rows[] = array(
        array(
          'data' => $revert_label,
          'class' => 'action-label',
          'colspan' => 2,
        ),
        array(
          'data' => drupal_render($form['revert']),
          'class' => 'action-form',
          'colspan' => 3,
        ),
      );
    }
  }
  else {
    $rows[] = array(
      array(
        'data' => t('No overrides present.'),
        'colspan' => 5,
      ),
    );
  }
  $output = theme('table', $header, $rows, array(
    'class' => 'spaces',
  ));
  $output .= drupal_render($form);
  return $output;
}