/**
  * Implements Drupal\configuration\Config\Configuration::saveToActiveStore().
  */
 public function saveToActiveStore(ConfigIteratorSettings &$settings)
 {
     ctools_include('export');
     $object = ctools_export_crud_load($this->getComponent(), $this->getIdentifier());
     if ($object) {
         ctools_export_crud_delete($this->getComponent(), $object);
     }
     $data = $this->getData();
     $data->export_type = NULL;
     // get title_pane key if configured.
     if (isset($data->conf['display']->title_pane)) {
         $title_pane = $data->conf['display']->title_pane;
     }
     $display = panels_save_display($data->conf['display']);
     // title_pane configuration workaround.
     if (isset($display->content[$title_pane])) {
         $pid = $display->content[$title_pane]->pid;
         $display->{$title_pane} = $pid;
         db_update('panels_display')->fields(array('title_pane' => $pid))->condition('did', $display->did)->execute();
     }
     $data->conf['did'] = $data->conf['display']->did;
     unset($data->conf['display']);
     ctools_export_crud_save($this->getComponent(), $data);
     $settings->addInfo('imported', $this->getUniqueId());
 }
예제 #2
0
 /**
  * Implements Drupal\configuration\Config\Configuration::saveToActiveStore().
  */
 public function saveToActiveStore(ConfigIteratorSettings &$settings)
 {
     ctools_include('export');
     $object = ctools_export_crud_load($this->getComponent(), $this->getIdentifier());
     if ($object) {
         ctools_export_crud_delete($this->getComponent(), $object);
     }
     $data = $this->getData();
     $data->export_type = NULL;
     $group = field_group_unpack($data);
     ctools_export_crud_save($this->getComponent(), $group);
     $settings->addInfo('imported', $this->getUniqueId());
 }
 /**
  * Implements Drupal\configuration\Config\Configuration::saveToActiveStore().
  */
 public function saveToActiveStore(ConfigIteratorSettings &$settings)
 {
     ctools_include('export');
     $object = ctools_export_crud_load($this->getComponent(), $this->getIdentifier());
     if ($object) {
         ctools_export_crud_delete($this->getComponent(), $object);
     }
     $data = $this->getData();
     $data->export_type = NULL;
     panels_save_display($data->conf['display']);
     $data->conf['did'] = $data->conf['display']->did;
     unset($data->conf['display']);
     ctools_export_crud_save($this->getComponent(), $data);
     $settings->addInfo('imported', $this->getUniqueId());
 }
 /**
  * Switched page callback to give the overview page
  */
 function page_overview($js, $input, $entity)
 {
     $header = array(t('View mode'), t('Status'), t('Operations'));
     list($entity_id, $revision_id, $bundle) = entity_extract_ids($this->entity_type, $entity);
     $rows = array();
     $base_url = $this->entity_base_url($entity);
     foreach ($this->plugin['view modes'] as $view_mode => $view_mode_info) {
         if (!$this->is_panelized($bundle . '.' . $view_mode)) {
             continue;
         }
         $row = array();
         $row[] = $view_mode_info['label'];
         $panelized = TRUE;
         if (!empty($entity->panelizer[$view_mode]->name)) {
             ctools_include('export');
             $panelizer = ctools_export_crud_load('panelizer_defaults', $entity->panelizer[$view_mode]->name);
             $status = !empty($panelizer->title) ? check_plain($panelizer->title) : t('Default');
         } else {
             if (!empty($entity->panelizer[$view_mode]->did)) {
                 $status = t('Custom');
             } else {
                 $status = t('Not panelized');
                 $panelized = FALSE;
             }
         }
         $row[] = $status;
         if ($panelized) {
             $links_array = array();
             foreach (panelizer_operations() as $path => $operation) {
                 if ($this->panelizer_access($path, $entity, $view_mode)) {
                     $links_array[$path] = array('title' => $operation['link title'], 'href' => $base_url . '/' . $view_mode . '/' . $path);
                 }
             }
             if ($status == t('Custom')) {
                 $links_array['reset'] = array('title' => t('reset'), 'href' => $base_url . '/' . $view_mode . '/reset');
             }
         } else {
             $links_array = array('panelize' => array('title' => t('panelize'), 'href' => $base_url . '/' . $view_mode));
         }
         // Allow applications to add additional panelizer tabs.
         $context = array('entity' => $entity, 'view_mode' => $view_mode, 'status' => $status, 'panelized' => $panelized);
         drupal_alter('panelizer_overview_links', $links_array, $this->entity_type, $context);
         $links = theme('links', array('links' => $links_array, 'attributes' => array('class' => array('links', 'inline'))));
         $row[] = $links;
         $rows[] = $row;
     }
     return array('#theme' => 'table', '#header' => $header, '#rows' => $rows, '#prefix' => '<p>' . t('Changes made here will override the default (Panelizer) displays and will only affect this @entity.', array('@entity' => $this->entity_type)) . "</p>\n");
 }
 /**
  * Loads the snippet data
  * @param $item_name
  */
 function load_item($item_name, $rid = NULL)
 {
     $snippet = ctools_export_crud_load($this->plugin['schema'], $item_name);
     $snippet_revision = db_select('snippet_revision', 'sr')->fields('sr', array())->condition('name', $item_name);
     if ($rid) {
         $snippet_revision = $snippet_revision->condition('rid', $rid);
     } else {
         $snippet_revision = $snippet_revision->condition('is_current', 1);
     }
     $snippet_revision = $snippet_revision->execute()->fetch();
     $snippet->content = !empty($snippet_revision->content) ? $snippet_revision->content : '';
     $snippet->content_format = !empty($snippet_revision->content_format) ? $snippet_revision->content_format : NULL;
     $snippet->timestamp = !empty($snippet_revision->timestamp) ? $snippet_revision->timestamp : NULL;
     $snippet->is_current = !empty($snippet_revision->is_current) ? $snippet_revision->is_current : NULL;
     $snippet->rid = !empty($snippet_revision->rid) ? $snippet_revision->rid : NULL;
     $snippet->title_revision = !empty($snippet_revision->title) ? $snippet_revision->title : NULL;
     return $snippet;
 }
 /**
  * Called by ctools_export_ui_load to load the item.
  *
  * This can be overridden for modules that want to be able to export
  * items currently being edited, for example.
  */
 function load_item($item_name)
 {
     $item = ctools_export_crud_load($this->plugin['schema'], $item_name);
     return empty($item) ? FALSE : $item;
 }
예제 #7
0
/**
 * Replacement for ctools_export_ui_edit_name_validate(). Allow dashes.
 */
function context_ui_edit_name_validate($element, &$form_state)
{
    $plugin = $form_state['plugin'];
    // Check for string identifier sanity
    if (!preg_match('!^[a-z0-9_-]+$!', $element['#value'])) {
        form_error($element, t('The name can only consist of lowercase letters, underscores, dashes, and numbers.'));
        return;
    }
    // Check for name collision
    if ($form_state['op'] != 'edit') {
        if (empty($form_state['item']->export_ui_allow_overwrite) && ($exists = ctools_export_crud_load($plugin['schema'], $element['#value']))) {
            form_error($element, t('A @plugin with this name already exists. Please choose another name or delete the existing item before creating a new one.', array('@plugin' => $plugin['title singular'])));
        }
    }
}
예제 #8
0
/**
 * Form callback to edit an exportable item using the wizard
 *
 * This simply loads the object defined in the plugin and hands it off.
 */
function views_ui_clone_form($form, &$form_state)
{
    $counter = 1;
    if (!isset($form_state['item'])) {
        $view = views_get_view($form_state['original name']);
    } else {
        $view = $form_state['item'];
    }
    do {
        if (empty($form_state['item']->is_template)) {
            $name = format_plural($counter, 'Clone of', 'Clone @count of') . ' ' . $view->get_human_name();
        } else {
            $name = $view->get_human_name();
            if ($counter > 1) {
                $name .= ' ' . $counter;
            }
        }
        $counter++;
        $machine_name = preg_replace('/[^a-z0-9_]+/', '_', drupal_strtolower($name));
    } while (ctools_export_crud_load($form_state['plugin']['schema'], $machine_name));
    $form['human_name'] = array('#type' => 'textfield', '#title' => t('View name'), '#default_value' => $name, '#size' => 32, '#maxlength' => 255);
    $form['name'] = array('#title' => t('View name'), '#type' => 'machine_name', '#required' => TRUE, '#maxlength' => 32, '#size' => 32, '#machine_name' => array('exists' => 'ctools_export_ui_edit_name_exists', 'source' => array('human_name')));
    $form['submit'] = array('#type' => 'submit', '#value' => t('Continue'));
    return $form;
}
예제 #9
0
 /**
  * Load a CTools exportable.
  *
  * @param string $object_type
  *   Type of object to load:
  *   map|layer|source|control|interaction|style|component .
  * @param string $export_id
  *   The exportable id.
  *
  * @return array
  *   The exported object.
  */
 public static function loadExportable($object_type, $export_id)
 {
     ctools_include('export');
     return ctools_export_crud_load('openlayers_' . drupal_strtolower(check_plain($object_type)) . 's', $export_id);
 }
 /**
  * Load the named default panel for the bundle.
  */
 public function get_default_panelizer_object($bundle, $name)
 {
     if (strpos($bundle, '.') !== FALSE) {
         list($bundle, $view_mode) = explode('.', $bundle);
     } else {
         $view_mode = 'page_manager';
     }
     // If the name is not in the format of entitytype:bundle:name which is
     // the machine name used, split that out automatically.
     if (strpos($name, ':') === FALSE) {
         $name = implode(':', array($this->entity_type, $bundle, $name));
         // This is the default view mode and older defaults won't have this,
         // so we don't enforce it.
         if ($view_mode != 'page_manager') {
             $name .= ':' . $view_mode;
         }
     }
     ctools_include('export');
     return ctools_export_crud_load('panelizer_defaults', $name);
 }
 /**
  * Page callback to import information for an exportable item.
  */
 function import_page($js, $input, $step = NULL)
 {
     drupal_set_title($this->get_page_title('import'));
     // Import is basically a multi step wizard form, so let's go ahead and
     // use CTools' wizard.inc for it.
     // If a step not set, they are trying to create a new item. If a step
     // is set, they're in the process of creating an item.
     if (!empty($step)) {
         $item = $this->edit_cache_get(NULL, 'import');
     }
     if (empty($item)) {
         $item = ctools_export_crud_new($this->plugin['schema']);
     }
     $form_state = array('plugin' => $this->plugin, 'object' => &$this, 'ajax' => $js, 'item' => $item, 'op' => 'add', 'form type' => 'import', 'rerender' => TRUE, 'no_redirect' => TRUE, 'step' => $step, 'function args' => func_get_args());
     // import always uses the wizard.
     $output = $this->edit_execute_form_wizard($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']['add']));
     }
     return $output;
     return;
     $form_info = array('id' => 'ctools_export_ui_import', 'path' => ctools_export_ui_plugin_menu_path($this->plugin, 'import') . '/%step', 'return path' => $this->plugin['redirect']['import'], 'show trail' => TRUE, 'show back' => TRUE, 'show return' => FALSE, 'show cancel' => TRUE, 'finish callback' => 'ctools_export_ui_import_finish', 'cancel callback' => 'ctools_export_ui_import_cancel', 'order' => array('code' => t('Import code'), 'edit' => t('Edit')), 'forms' => array('code' => array('form id' => 'ctools_export_ui_import_code'), 'edit' => array('form id' => 'ctools_export_ui_import_edit')));
     $form_state = array('plugin' => $this->plugin, 'input' => $input, 'rerender' => TRUE, 'no_redirect' => TRUE, 'object' => &$this, 'export' => '', 'overwrite' => FALSE, 'function args' => func_get_args());
     if ($step == 'code') {
         // This is only used if the BACK button was hit.
         if (!empty($_SESSION['ctools_export_ui_import'][$this->plugin['name']])) {
             $form_state['item'] = $_SESSION['ctools_export_ui_import'][$this->plugin['name']];
             $form_state['export'] = $form_state['item']->export_ui_code;
             $form_state['overwrite'] = $form_state['item']->export_ui_allow_overwrite;
         }
     } else {
         if ($step == 'begin') {
             $step = 'code';
             if (!empty($_SESSION['ctools_export_ui_import'][$this->plugin['name']])) {
                 unset($_SESSION['ctools_export_ui_import'][$this->plugin['name']]);
             }
         } else {
             if ($step != 'code') {
                 $form_state['item'] = $_SESSION['ctools_export_ui_import'][$this->plugin['name']];
                 $form_state['op'] = 'add';
                 if (!empty($form_state['item']->export_ui_allow_overwrite)) {
                     // if allow overwrite was enabled, set this to 'edit' only if the key already existed.
                     $export_key = $this->plugin['export']['key'];
                     if (ctools_export_crud_load($this->plugin['schema'], $form_state['item']->{$export_key})) {
                         $form_state['op'] = 'edit';
                     }
                 }
             }
         }
     }
     ctools_include('wizard');
     return ctools_wizard_multistep_form($form_info, $step, $form_state);
 }
/**
 * Test for #machine_name type to see if an export exists.
 */
function ctools_export_ui_edit_name_exists($name, $element, &$form_state) {
  $plugin = $form_state['plugin'];

  return (empty($form_state['item']->export_ui_allow_overwrite) && ctools_export_crud_load($plugin['schema'], $name));
}
<?php

// Use view machine name.
$views = array('example_view_one', 'example_view_two');
foreach ($views as $view_name) {
    ctools_include('export');
    $view = ctools_export_crud_load('views_view', $view_name);
    if ($view) {
        $view->delete();
    }
}
// Clear caches.
drupal_flush_all_caches();