function page_context($js, $input, $entity, $view_mode) { list($entity_id, $revision_id, $bundle) = entity_extract_ids($this->entity_type, $entity); $cache_key = $entity_id . '.' . $view_mode; $panelizer = panelizer_context_cache_get($this->entity_type, $cache_key); if (empty($panelizer)) { return MENU_NOT_FOUND; } $form_state = array('entity' => $entity, 'revision info' => $this->entity_allows_revisions($entity), 'panelizer' => &$panelizer, 'panelizer type' => $this->entity_type, 'cache key' => $cache_key, 'no_redirect' => TRUE); ctools_include('common', 'panelizer'); $output = drupal_build_form('panelizer_default_context_form', $form_state); if (!empty($form_state['executed'])) { if (!empty($form_state['clicked_button']['#write'])) { drupal_set_message(t('The settings have been updated.')); $entity->panelizer[$view_mode] = $form_state['panelizer']; $this->entity_save($entity); } else { drupal_set_message(t('Changes have been discarded.')); } panelizer_context_cache_clear($this->entity_type, $cache_key); drupal_goto($_GET['q']); } return $this->wrap_entity_panelizer_pages($entity, $view_mode, $output); }
function page_context($js, $input, $entity, $view_mode) { list($entity_id, $revision_id, $bundle) = entity_extract_ids($this->entity_type, $entity); $cache_key = $entity_id . '.' . $view_mode; $panelizer = panelizer_context_cache_get($this->entity_type, $cache_key); if (empty($panelizer)) { return MENU_NOT_FOUND; } $form_state = array('entity' => $entity, 'revision info' => $this->entity_allows_revisions($entity), 'panelizer' => &$panelizer, 'panelizer type' => $this->entity_type, 'cache key' => $cache_key, 'no_redirect' => TRUE); ctools_include('common', 'panelizer'); $output = drupal_build_form('panelizer_default_context_form', $form_state); if (!empty($form_state['executed'])) { if (!empty($form_state['clicked_button']['#write'])) { $entity->panelizer[$view_mode] = $form_state['panelizer']; // Make sure that entity_save knows that the panelizer settings are // modified and must be made local to the entity. if (empty($panelizer->did) || !empty($panelizer->name)) { $panelizer->display_is_modified = TRUE; } // Update the entity. $this->entity_save($entity); drupal_set_message(t('The settings have been updated.')); } else { drupal_set_message(t('Changes have been discarded.')); } // Clear the context cache. panelizer_context_cache_clear($this->entity_type, $cache_key); // Redirect. drupal_goto($_GET['q']); } return $this->wrap_entity_panelizer_pages($entity, $view_mode, $output); }