/**
  * Main entry point to clone an item.
  */
 function clone_page($js, $input, $original, $step = NULL)
 {
     drupal_set_title($this->get_page_title('clone', $original));
     // If a step not set, they are trying to create a new clone. If a step
     // is set, they're in the process of cloning an item.
     if (!empty($this->plugin['use wizard']) && !empty($step)) {
         $item = $this->edit_cache_get(NULL, 'clone');
     }
     if (empty($item)) {
         // To make a clone of an item, we first export it and then re-import it.
         // Export the handler, which is a fantastic way to clean database IDs out of it.
         $export = ctools_export_crud_export($this->plugin['schema'], $original);
         $item = ctools_export_crud_import($this->plugin['schema'], $export);
         $item->{$this->plugin['export']['key']} = 'clone_of_' . $item->{$this->plugin['export']['key']};
     }
     // Tabs and breadcrumb disappearing, this helps alleviate through cheating.
     ctools_include('menu');
     $trail = ctools_get_menu_trail(ctools_export_ui_plugin_base_path($this->plugin));
     menu_set_active_trail($trail);
     $name = $original->{$this->plugin['export']['key']};
     $form_state = array('plugin' => $this->plugin, 'object' => &$this, 'ajax' => $js, 'item' => $item, 'op' => 'add', 'form type' => 'clone', 'original name' => $name, 'rerender' => TRUE, 'no_redirect' => TRUE, 'step' => $step, 'function args' => func_get_args());
     $output = $this->edit_execute_form($form_state);
     if (!empty($form_state['executed'])) {
         $export_key = $this->plugin['export']['key'];
         drupal_goto(str_replace('%ctools_export_ui', $form_state['item']->{$export_key}, $this->plugin['redirect']['clone']));
     }
     return $output;
 }
Exemplo n.º 2
0
 /**
  * Set LC breadcrumbs
  *
  * @return void
  */
 protected function setBreadcrumbs()
 {
     $widget = $this->getHandler()->getWidget('\\XLite\\View\\Location');
     $lcNodes = array_map(function (\XLite\View\Location\Node $node) {
         return $node->getContent();
     }, $widget->getNodes());
     array_shift($lcNodes);
     // Add store root node
     $trails = menu_get_active_trail();
     array_splice($trails, 1, 0, array(array('title' => t('Store'), 'href' => \XLite\Core\Converter::buildFullURL(), 'link_path' => '', 'localized_options' => array(), 'type' => MENU_VISIBLE_IN_BREADCRUMB)));
     menu_set_active_trail($trails);
     $drupalNodes = array_slice(drupal_get_breadcrumb(), 0, 2);
     drupal_set_breadcrumb(array_merge($drupalNodes, $lcNodes));
 }