You are here

function context_layouts_reaction_block::options_form_submit in Context 7.3

Same name and namespace in other branches
  1. 6.3 context_layouts/plugins/context_layouts_reaction_block.inc \context_layouts_reaction_block::options_form_submit()
  2. 6 context_layouts/plugins/context_layouts_reaction_block.inc \context_layouts_reaction_block::options_form_submit()

Override of submit handler.

Overrides context_reaction_block::options_form_submit

File

context_layouts/plugins/context_layouts_reaction_block.inc, line 152

Class

context_layouts_reaction_block

Code

function options_form_submit($values) {
  $options = parent::options_form_submit($values);

  // Only alter the options form if the theme provides layouts.
  $theme_key = variable_get('theme_default', 'garland');
  $layouts = context_layouts_get_layouts($theme_key);

  // Check that this is a valid layout.
  if (!empty($values['layout']) && isset($layouts[$values['layout']])) {
    $layout = $values['layout'];
    $options['layout'] = $layout;

    // Remove blocks that don't belong to regions in this layout.
    if (isset($layouts[$layout]['regions'])) {
      foreach ($options['blocks'] as $bid => $block) {
        if (!in_array($block['region'], $layouts[$layout]['regions'])) {
          unset($options['blocks'][$bid]);
        }
      }
    }
  }
  return $options;
}