You are here

function theme_context_ui_block_ui in Context 6.2

Same name and namespace in other branches
  1. 5 context_ui/context_ui_admin.inc \theme_context_ui_block_ui()
  2. 6 context_ui/context_ui.admin.inc \theme_context_ui_block_ui()

Generates the AJAX enabled block administration portion of the context_ui admin form.

1 theme call to theme_context_ui_block_ui()
context_ui_form in context_ui/context_ui.admin.inc
Generates the omnibus context definition editing form. Note: submission and validation handlers are in context_ui.admin.inc

File

context_ui/context_ui.admin.inc, line 802

Code

function theme_context_ui_block_ui($form) {

  // Add draggable weights
  drupal_add_js('misc/tableheader.js');
  $output = '';
  foreach (element_children($form) as $region) {
    $table_id = 'context-ui-region-' . str_replace('_', '-', $region);
    drupal_add_tabledrag($table_id, 'order', 'sibling', 'block-weight', NULL, NULL, FALSE);
    $rows = array();
    foreach (element_children($form[$region]) as $id) {
      $form[$region][$id]['weight']['#attributes'] = array(
        'class' => 'block-weight',
      );
      $label = $form[$region][$id]['#value'];
      if ($id == 'system') {
        $remove = '';
      }
      else {
        $remove = l(t('X'), $_GET['q'], array(
          'fragment' => 'remove',
          'attributes' => array(
            'class' => 'remove',
          ),
        ));
      }
      $rows[] = array(
        'data' => array(
          $label . drupal_render($form[$region][$id]['weight']),
          $remove,
        ),
        'class' => 'draggable',
        'id' => $id,
      );
    }
    $output .= "<div class='label'>";
    $output .= l(t('+ Add'), $_GET['q'], array(
      'fragment' => $region,
      'attributes' => array(
        'class' => 'add-block',
      ),
    ));
    $output .= $form[$region]['#title'];
    $output .= "</div>";
    $output .= theme('table', array(), $rows, array(
      'id' => $table_id,
    ));
  }
  return $output;
}