You are here

function context_reaction_block::options_form in Context 6.3

Same name and namespace in other branches
  1. 6 plugins/context_reaction_block.inc \context_reaction_block::options_form()
  2. 7.3 plugins/context_reaction_block.inc \context_reaction_block::options_form()

Options form.

Overrides context_reaction::options_form

1 call to context_reaction_block::options_form()
context_layouts_reaction_block::options_form in context_layouts/plugins/context_layouts_reaction_block.inc
Override of options form.
1 method overrides context_reaction_block::options_form()
context_layouts_reaction_block::options_form in context_layouts/plugins/context_layouts_reaction_block.inc
Override of options form.

File

plugins/context_reaction_block.inc, line 10

Class

context_reaction_block
Expose blocks as context reactions.

Code

function options_form($context) {

  // Rebuild the block info cache if necessary.
  $this
    ->get_blocks(NULL, NULL, $this
    ->rebuild_needed());
  $this
    ->rebuild_needed(FALSE);
  $theme_key = variable_get('theme_default', 'garland');
  $weight_delta = $this
    ->max_block_weight();
  $form = array(
    '#tree' => TRUE,
    '#theme' => 'context_block_form',
    'max_block_weight' => array(
      '#value' => $weight_delta,
      '#type' => 'value',
    ),
    'state' => array(
      '#type' => 'hidden',
      '#attributes' => array(
        'class' => 'context-blockform-state',
      ),
    ),
  );

  /**
   * Selector.
   */
  $modules = module_list();
  $form['selector'] = array(
    '#type' => 'item',
    '#tree' => TRUE,
    '#prefix' => '<div class="context-blockform-selector">',
    '#suffix' => '</div>',
  );
  foreach ($this
    ->get_blocks() as $block) {
    if (!isset($form['selector'][$block->module])) {
      $form['selector'][$block->module] = array(
        '#type' => 'checkboxes',
        '#title' => $modules[$block->module],
        '#options' => array(),
      );
    }
    $form['selector'][$block->module]['#options'][$block->bid] = check_plain($block->info);
  }
  ksort($form['selector']);

  /**
   * Regions.
   */
  $form['blocks'] = array(
    '#tree' => TRUE,
    '#theme' => 'context_block_regions_form',
  );
  foreach (system_region_list($theme_key) as $region => $label) {
    $form['blocks'][$region] = array(
      '#type' => 'item',
      '#title' => $label,
      '#tree' => TRUE,
    );
    foreach ($this
      ->get_blocks($region, $context) as $block) {
      if (!empty($block->context)) {
        $form['blocks'][$region][$block->bid] = array(
          '#value' => check_plain($block->info),
          '#weight' => $block->weight,
          '#type' => 'markup',
          '#tree' => TRUE,
          'weight' => array(
            '#type' => 'weight',
            '#delta' => $weight_delta,
            '#default_value' => 0,
          ),
        );
      }
    }
  }
  return $form;
}