You are here

function theme_context_ui_form in Context 6

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

Theme function for context_ui_form()

1 theme call to theme_context_ui_form()
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 344

Code

function theme_context_ui_form($form) {
  drupal_add_css(drupal_get_path("module", "context_ui") . "/context_ui.css");
  drupal_add_js(drupal_get_path("module", "context_ui") . "/context_ui.js");
  $output = '';

  // Render space / key / value trio in a 3-column table
  $rows = array(
    'trio' => array(
      'class' => 'trio',
    ),
    'description' => array(),
  );
  $rows['trio']['data'][] = array(
    'data' => drupal_render($form['namespace']),
    'class' => 'namespace',
  );
  $rows['trio']['data'][] = array(
    'data' => drupal_render($form['attribute']),
    'class' => 'attribute',
  );
  $rows['trio']['data'][] = array(
    'data' => drupal_render($form['value']),
    'class' => 'value',
  );
  $rows['description'] = array(
    array(
      'data' => drupal_render($form['description']),
      'colspan' => 3,
    ),
  );
  $output .= theme('table', array(), $rows, array(
    'id' => 'context-ui-trio',
  ));

  // Render setters / getters as a two column split
  $widgets = '';
  $display = "<div class='label'>";
  $display .= t('Conditions');
  $display .= "<span class='description'>" . t('trigger the activation of this context') . "</span>";
  $display .= "</div>";
  foreach (array_keys(context_conditions()) as $id) {
    $widgets .= "<div id='widget-{$id}' class='widget'>" . drupal_render($form['items'][$id]) . "</div>";
    $display .= context_ui_item_display($id, $form['items'][$id]);
  }
  $display .= "<div class='label'>";
  $display .= t('Reactions');
  $display .= "<span class='description'>" . t('respond when this context is active') . "</span>";
  $display .= "</div>";
  foreach (array_keys(context_reactions()) as $id) {
    $widgets .= "<div id='widget-{$id}' class='widget'>" . drupal_render($form['items'][$id]) . "</div>";
    $display .= context_ui_item_display($id, $form['items'][$id]);
  }
  $rows = array(
    array(
      array(
        'data' => $display,
        'class' => 'display',
      ),
      array(
        'data' => $widgets,
        'class' => 'widget',
      ),
    ),
  );
  $output .= theme('table', array(), $rows, array(
    'id' => 'context-ui-items',
  ));

  // Render block visibility
  $rows = array(
    array(
      array(
        'data' => drupal_render($form['block']['blocks']),
        'class' => 'display',
      ),
      array(
        'data' => drupal_render($form['block']['selector']) . drupal_render($form['block']['help']),
        'class' => 'widget',
      ),
    ),
  );
  $output .= theme('table', array(), $rows, array(
    'id' => 'context-ui-blocks',
  ));
  $output .= drupal_render($form);
  return $output;
}