You are here

function panels_node_override_basic_submit in Panels 6.3

Submit function to store the form data in our cache.

File

plugins/page_wizards/node_override.inc, line 125

Code

function panels_node_override_basic_submit(&$form, &$form_state) {
  $cache =& $form_state['cache'];
  $cache->display->layout = $form_state['values']['layout'];
  $cache->type = $form_state['values']['type'];

  // Create a new handler object and cache it; this way we can use the
  // handler object for retrieving contexts properly.
  // Create the the panel context variant configured with our display
  $plugin = page_manager_get_task_handler('panel_context');

  // Create a new handler.
  $cache->handler = page_manager_new_task_handler($plugin);
  $cache->handler->conf['title'] = $form_state['types'][$cache->type]->name;
  $cache->handler->conf['pipeline'] = 'ipe';
  $cache->handler->conf['access'] = array(
    'plugins' => array(
      0 => array(
        'name' => 'node_type',
        'settings' => array(
          'type' => array(
            $cache->type => $cache->type,
          ),
        ),
        'context' => 'argument_nid_1',
        'not' => FALSE,
      ),
    ),
    'logic' => 'and',
  );

  // Find a region by trying some basic main content region IDs.
  $layout = panels_get_layout($form_state['values']['layout']);
  $regions = panels_get_regions($layout, $cache->display);
  foreach (array(
    'center',
    'middle',
    'content',
    'main',
  ) as $candidate) {
    if (!empty($regions[$candidate])) {
      $region = $candidate;
      break;
    }
  }

  // If all of the above failed, use the first region.
  if (empty($region)) {
    $keys = array_keys($regions);
    $region = reset($keys);
  }

  // Populate the layout with content. This is from an export, with minor
  // changes to ensure defaults are correct and to add stuff to the proper region.
  $pane = new stdClass();
  $pane->pid = 'new-1';
  $pane->panel = $region;
  $pane->type = 'node_content';
  $pane->subtype = 'node_content';
  $pane->shown = TRUE;
  $pane->access = array();
  $pane->configuration = array(
    'links' => 1,
    'page' => 1,
    'no_extras' => 0,
    'override_title' => 0,
    'override_title_text' => '',
    'identifier' => '',
    'link' => 0,
    'leave_node_title' => 0,
    'context' => 'argument_nid_1',
    'build_mode' => 'full',
  );
  $pane->cache = array();
  $pane->style = array(
    'settings' => NULL,
  );
  $pane->css = array();
  $pane->extras = array();
  $pane->position = 0;
  $cache->display->content['new-1'] = $pane;
  $cache->display->panels[$region][0] = 'new-1';
  $pane = new stdClass();
  $pane->pid = 'new-2';
  $pane->panel = $region;
  $pane->type = 'node_comments';
  $pane->subtype = 'node_comments';
  $pane->shown = TRUE;
  $pane->access = array();
  $pane->configuration = array(
    'mode' => variable_get('comment_default_mode', COMMENT_MODE_THREADED_EXPANDED),
    'order' => variable_get('comment_default_order', COMMENT_ORDER_NEWEST_FIRST),
    'comments_per_page' => variable_get('comment_default_per_page', '50'),
    'context' => 'argument_nid_1',
    'override_title' => 0,
    'override_title_text' => '',
  );
  $pane->cache = array();
  $pane->style = array(
    'settings' => NULL,
  );
  $pane->css = array();
  $pane->extras = array();
  $pane->position = 1;
  $cache->display->content['new-2'] = $pane;
  $cache->display->panels[$region][1] = 'new-2';
  $pane = new stdClass();
  $pane->pid = 'new-3';
  $pane->panel = $region;
  $pane->type = 'node_comment_form';
  $pane->subtype = 'node_comment_form';
  $pane->shown = TRUE;
  $pane->access = array();
  $pane->configuration = array(
    'anon_links' => 1,
    'context' => 'argument_nid_1',
    'override_title' => 0,
    'override_title_text' => '',
  );
  $pane->cache = array();
  $pane->style = array(
    'settings' => NULL,
  );
  $pane->css = array();
  $pane->extras = array();
  $pane->position = 2;
  $cache->display->content['new-3'] = $pane;
  $cache->display->panels[$region][2] = 'new-3';
  $task = page_manager_get_task('node_view');
  ctools_include('context');
  ctools_include('context-task-handler');
  $cache->context = ctools_context_handler_get_all_contexts($task, NULL, $cache->handler);
}