You are here

function theme_spaces_block_customizer_settings_form in Spaces 6.2

Same name and namespace in other branches
  1. 6 spaces.module \theme_spaces_block_customizer_settings_form()

Form theming for the block customizer settings form.

1 theme call to theme_spaces_block_customizer_settings_form()
space_customizer_block::form in ./spaces.spaces.inc
Implementation of form().

File

./spaces.theme.inc, line 6

Code

function theme_spaces_block_customizer_settings_form($form) {

  // Add draggable weights
  drupal_add_js('misc/tableheader.js');
  drupal_add_css(drupal_get_path('module', 'spaces') . '/spaces.css');
  $output = '';
  $contexts = element_children($form['contexts']);
  foreach ($contexts as $identifier) {
    $output .= "<div class='spaces-block-customizer clear-block'>";

    // Add a context heading if there is more than 1 context in this feature
    if (count($contexts) > 1) {
      $output .= "<h3>{$form['contexts'][$identifier]['#title']}</h3>";
    }

    // List of block regions that should force an empty display
    $force_empty = array(
      'content',
    );
    global $theme_key;
    init_theme();
    $regions = system_region_list($theme_key);
    foreach ($force_empty as $region) {
      if (empty($form['contexts'][$identifier][$region]) && !empty($regions[$region])) {
        $output .= "<div class='region-{$region}'>";
        $output .= "<strong class='region'>{$regions[$region]}</strong>";
        $output .= "<div class='spaces-empty'>" . t('There are no options available for this region.') . "</div>";
        $output .= "</div>";
      }
    }
    foreach (element_children($form['contexts'][$identifier]) as $a) {
      drupal_add_tabledrag("spaces-customizer-blocks-{$identifier}-{$a}", 'order', 'sibling', 'block-weight');
      $rows = array();
      uasort($form['contexts'][$identifier][$a], 'element_sort');
      foreach (element_children($form['contexts'][$identifier][$a]) as $b) {
        $form['contexts'][$identifier][$a][$b]['weight']['#attributes'] = array(
          'class' => 'block-weight',
        );
        $row = array(
          'dummy' => '',
          'status' => drupal_render($form['contexts'][$identifier][$a][$b]['status']),
          'title' => array(
            'data' => drupal_render($form['contexts'][$identifier][$a][$b]['subject']),
            'class' => 'fill',
          ),
          'weight' => drupal_render($form['contexts'][$identifier][$a][$b]['weight']),
        );
        $rows[] = array(
          'data' => $row,
          'class' => 'draggable',
        );
      }
      $output .= "<div class='region-{$a}'>";
      $output .= "<strong class='region'>{$form['contexts'][$identifier][$a]['#title']}</strong>";
      $output .= theme('table', array(), $rows, array(
        'id' => "spaces-customizer-blocks-{$identifier}-{$a}",
      ));
      $output .= "</div>";
    }
    $output .= "</div>";
  }
  $output .= drupal_render($form);
  return $output;
}