You are here

function spaces_context_ui_editor_submit in Spaces 7.3

Same name and namespace in other branches
  1. 6.3 spaces.overrides.inc \spaces_context_ui_editor_submit()
  2. 7 spaces.overrides.inc \spaces_context_ui_editor_submit()

Save handler for context_block_editor().

1 string reference to 'spaces_context_ui_editor_submit'
spaces_form_context_ui_editor_alter in ./spaces.overrides.inc
Implements hook_form_alter() for context_ui_context_editor().

File

./spaces.overrides.inc, line 50

Code

function spaces_context_ui_editor_submit(&$form, &$form_state) {
  $space = spaces_get_space();
  if ($space) {
    $saved = FALSE;
    foreach ($form_state['values']['contexts'] as $name => $values) {
      $original = clone $values['context'];
      $context = context_ui_editor_process($values);
      foreach (array_keys(context_conditions(TRUE)) as $condition) {
        if ($context->conditions[$condition] != $original->conditions[$condition]) {
          $space->controllers->context
            ->set("{$context->name}:condition:{$condition}", $context->conditions[$condition]);
          $saved = TRUE;
        }
      }
      foreach (array_keys(context_reactions(TRUE)) as $reaction) {
        if ($context->reactions[$reaction] != $original->reactions[$reaction]) {
          $space->controllers->context
            ->set("{$context->name}:reaction:{$reaction}", $context->reactions[$reaction]);
          $saved = TRUE;
        }
      }
    }
    if ($saved) {
      drupal_set_message(t('Saved %title for %space.', array(
        '%title' => !empty($context->description) ? $context->description : $context->name,
        '%space' => $space
          ->title(),
      )));
    }
  }
}