You are here

function context_reaction_block::options_form_submit in Context 6

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

Options form submit handler.

Overrides context_reaction::options_form_submit

1 call to context_reaction_block::options_form_submit()
context_layouts_reaction_block::options_form_submit in context_layouts/plugins/context_layouts_reaction_block.inc
Override of submit handler.
1 method overrides context_reaction_block::options_form_submit()
context_layouts_reaction_block::options_form_submit in context_layouts/plugins/context_layouts_reaction_block.inc
Override of submit handler.

File

plugins/context_reaction_block.inc, line 84

Class

context_reaction_block
Expose blocks as context reactions.

Code

function options_form_submit($values) {
  $blocks = array();
  $block_info = $this
    ->get_blocks();

  // Retrieve blocks from submitted JSON string.
  if (!empty($values['state'])) {
    $edited = $this
      ->json_decode($values['state']);
  }
  else {
    $edited = array();
  }
  foreach ($edited as $region => $bids) {
    foreach ($bids as $position => $bid) {
      if (isset($block_info[$bid])) {
        $blocks[$bid] = array(
          'module' => $block_info[$bid]->module,
          'delta' => $block_info[$bid]->delta,
          'region' => $region,
          'weight' => $position,
        );
      }
    }
  }
  return array(
    'blocks' => $blocks,
  );
}