You are here

function _panels_update_create_handler in Panels 6.3

1 call to _panels_update_create_handler()
panels_update_6302 in ./panels.install

File

./panels.install, line 1334

Code

function _panels_update_create_handler($page, $p, $origin, $info, $arguments, $weight, &$cache) {
  $task = page_manager_get_task($page->task);
  $task_name = 'page-' . $page->name;
  $plugin = page_manager_get_task_handler('panel_context');
  $handler = page_manager_new_task_handler($plugin);
  $handler->weight = $weight;
  $handler->task = $page->task;
  if ($page->task == 'page') {
    $handler->subtask = $page->name;
  }
  $handler->export_type = EXPORT_IN_DATABASE;
  $handler->type = t('Normal');
  $handler->name = page_manager_handler_get_name($task_name, $cache->handlers, $handler);
  $handler->conf['css'] = $p->css;
  $handler->conf['css_id'] = $p->css_id;
  $handler->conf['no_blocks'] = $p->no_blocks;
  if (!empty($info['did']) && is_numeric($info['did'])) {
    $handler->conf['did'] = $info['did'];
  }
  else {
    $d = panels_load_display($p->did);
    if ($d) {
      $display_code = panels_export_display($d);
      eval($display_code);
      $handler->conf['did'] = 'new';
      $handler->conf['display'] = $display;
    }
  }
  $handler->conf['title'] = !empty($info['title']) ? $info['title'] : '';
  $handler->conf['contexts'] = unserialize($p->contexts);
  $handler->conf['relationships'] = unserialize($p->relationships);
  if ($origin && strpos($origin, '-')) {
    $handler->conf['access'] = array(
      'logic' => 'and',
      'plugins' => array(),
    );

    // Only 4 types of arguments supported having their own displays:
    // nid, node_add_form, node_edit_form and term. 3 of those simply used
    // node type and the last simply used vocabulary.
    list($junk, $key) = explode('-', $origin);
    if ($key && $key != 'default') {
      if ($arguments[$info['argument_id']]['name'] == 'term') {
        $handler->conf['access']['plugins'][] = array(
          'name' => 'term_vocabulary',
          'context' => $arguments[$info['argument_id']]['context'],
          'settings' => array(
            'vids' => array(
              $key,
            ),
          ),
        );
      }
      else {
        $handler->conf['access']['plugins'][] = array(
          'name' => 'node_type',
          'context' => $arguments[$info['argument_id']]['context'],
          'settings' => array(
            'type' => array(
              $key,
            ),
          ),
        );
      }
    }
    else {

      // make sure defaults float to the bottom:
      $handler->weight += 100;
    }
  }
  $cache->handlers[$handler->name] = $handler;
  return $handler;
}