本文整理汇总了PHP中panels_save_display函数的典型用法代码示例。如果您正苦于以下问题:PHP panels_save_display函数的具体用法?PHP panels_save_display怎么用?PHP panels_save_display使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了panels_save_display函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit
function edit() {
ctools_include('form');
$form_state = array(
'display' => &$this->display,
'renderer' => &$this,
'content_types' => $this->cache->content_types,
're_render' => FALSE,
'no_redirect' => TRUE,
'display_title' => !empty($this->cache->display_title),
'cache key' => $this->display->cache_key,
);
$output = ctools_build_form('panels_edit_display_form', $form_state);
if ($output) {
return $output;
}
// no output == submit
if (!$output) {
if (!empty($form_state['clicked_button']['#save-display'])) {
drupal_set_message(t('Panel content has been updated.'));
panels_save_display($this->display);
}
else {
drupal_set_message(t('Your changes have been discarded.'));
}
panels_cache_clear('display', $this->display->did);
return $this->display;
}
}
示例2: edit
function edit() {
$form_state = array(
'display' => &$this->display,
'renderer' => &$this,
'content_types' => $this->cache->content_types,
'no_redirect' => TRUE,
'display_title' => !empty($this->cache->display_title),
'cache key' => $this->display->cache_key,
);
$output = drupal_build_form('panels_edit_display_form', $form_state);
if (empty($form_state['executed']) || !empty($form_state['clicked_button']['preview'])) {
return $output;
}
if (!empty($form_state['clicked_button']['#save-display'])) {
drupal_set_message(t('Panel content has been updated.'));
panels_save_display($this->display);
}
else {
drupal_set_message(t('Your changes have been discarded.'));
}
panels_cache_clear('display', $this->display->did);
return $this->display;
}
示例3: saveToActiveStore
/**
* 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());
}
示例4: saveToActiveStore
/**
* 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());
}
示例5: hook_entity_update
public function hook_entity_update($entity)
{
list($entity_id, $revision_id, $bundle) = entity_extract_ids($this->entity_type, $entity);
if (!$this->is_panelized($bundle)) {
return;
}
// If there's no panelizer information on the entity then there is nothing
// to do.
if (empty($entity->panelizer)) {
return;
}
// Allow exports or older data to be deployed successfully.
if (is_object($entity->panelizer)) {
$entity->panelizer = array('page_manager' => $entity->panelizer);
}
// When updating many/most objects, make sure the previous revision's
// configuration is loaded too, as they won't be automatically loaded.
// @todo There may be another way of handling this.
if (isset($entity->original, $entity->original->panelizer)) {
foreach ($entity->original->panelizer as $view_mode => $panelizer) {
if (!isset($entity->panelizer[$view_mode])) {
$entity->panelizer[$view_mode] = clone $panelizer;
}
}
}
// Update each panelizer configuration.
foreach ($entity->panelizer as $view_mode => $panelizer) {
// In some cases $panelizer is array, convert it to an object.
if (is_array($panelizer)) {
$panelizer = (object) $panelizer;
}
// Just a safety check to make sure we can't have a missing view mode.
if (empty($view_mode)) {
$view_mode = 'page_manager';
}
// In certain circumstances $panelizer will be the default's name rather
// than a full object.
if (!is_object($panelizer) && is_array($panelizer) && !empty($panelizer['name'])) {
$panelizer = $this->get_default_panelizer_object($bundle . '.' . $view_mode, $panelizer['name']);
$panelizer->did = NULL;
// Ensure original values are maintained.
$panelizer->entity_id = $entity_id;
$panelizer->revision_id = $revision_id;
}
// Determine whether an existing Panelizer record needs to be updated or
// a new one created.
$update = array();
// This entity supports revisions.
if ($this->supports_revisions) {
// If no revision value is assigned, indicating that no record was
// previously saved for this entity/view_mode combination, or a new
// revision is being created, create a new {panelizer_entity} record.
if (empty($panelizer->revision_id) || $panelizer->revision_id != $revision_id) {
$panelizer->revision_id = $revision_id;
// If this has a custom display, flag the system that the display
// needs to be saved as a new record.
if (!empty($panelizer->did)) {
$panelizer->display_is_modified = TRUE;
}
} else {
$update = array('entity_type', 'entity_id', 'revision_id', 'view_mode');
}
} else {
// There is no entity_id set yet, the record was never saved before.
if (empty($panelizer->entity_id)) {
// Nothing to do.
} else {
$update = array('entity_type', 'entity_id', 'view_mode');
}
}
// The editor will set this flag if the display is modified. This lets
// us know if we need to clone a new display or not.
// NOTE: This means that when exporting or deploying, we need to be sure
// to set the display_is_modified flag to ensure this gets written.
if (!empty($panelizer->display_is_modified)) {
// Check if this display is shared and avoid changing other revisions
// displays.
$has_shared_display_args = array(':entity_type' => $this->entity_type, ':entity_id' => $entity_id, ':revision_id' => $revision_id, ':did' => $panelizer->did);
$has_shared_display = db_query('SELECT COUNT(did) FROM {panelizer_entity} WHERE entity_type = :entity_type AND entity_id = :entity_id AND revision_id <> :revision_id AND did = :did', $has_shared_display_args)->fetchField();
// If this is a new entry or the entry is using a display from a
// default, or revision is enabled and this is a shared display, clone
// the display.
if (!$update || empty($panelizer->did) || !empty($has_shared_display)) {
$entity->panelizer[$view_mode] = $panelizer = $this->clone_panelizer($panelizer, $entity);
// Update the cache key since we are adding a new display
$panelizer->display->cache_key = implode(':', array_filter(array('panelizer', $panelizer->entity_type, $panelizer->entity_id, $view_mode, $revision_id)));
}
// First write the display
panels_save_display($panelizer->display);
// Make sure we have the did.
$panelizer->did = $panelizer->display->did;
// Ensure that we always write this as NULL when we have our own panel:
$panelizer->name = NULL;
} else {
$panelizer->entity_type = $this->entity_type;
$panelizer->entity_id = $entity_id;
// The (int) ensures that entities that do not support revisions work
// since the revision_id cannot be NULL.
$panelizer->revision_id = (int) $revision_id;
// Make sure we keep the same did as the original if the layout wasn't
//.........这里部分代码省略.........
示例6: hook_entity_update
public function hook_entity_update($entity)
{
list($entity_id, $revision_id, $bundle) = entity_extract_ids($this->entity_type, $entity);
if (!$this->is_panelized($bundle)) {
return;
}
// If there's no panelizer information on the entity then there is nothing to do.
if (empty($entity->panelizer)) {
return;
}
// Allow exports or older data to be deployed successfully.
if (is_object($entity->panelizer)) {
$entity->panelizer = array('page_manager' => $entity->panelizer);
}
foreach ($entity->panelizer as $view_mode => $panelizer) {
// Just a safety check to make sure we can't have a missing view mode.
if (empty($view_mode)) {
$view_mode = 'page_manager';
}
if ($this->supports_revisions) {
if (empty($panelizer->revision_id) || $panelizer->revision_id != $revision_id) {
$panelizer->revision_id = $revision_id;
$update = array();
} else {
$update = array('entity_type', 'revision_id', 'view_mode');
}
} else {
if (empty($panelizer->entity_id)) {
$update = array();
} else {
$update = array('entity_type', 'entity_id', 'view_mode');
}
}
// The editor will set this flag if the display is modified. This lets
// us know if we need to clone a new display or not.
// NOTE: This means that when exporting or deploying, we need to be sure
// to set the display_is_modified flag to ensure this gets written.
if (!empty($panelizer->display_is_modified)) {
// If this is a new entry or the entry is using a display from a default,
// clone the display.
if (!$update || empty($panelizer->did)) {
$entity->panelizer[$view_mode] = $panelizer = $this->clone_panelizer($panelizer, $entity);
// Update the cache key since we are adding a new display
$panelizer->display->cache_key = implode(':', array('panelizer', $panelizer->entity_type, $panelizer->entity_id, $view_mode));
}
// First write the display
panels_save_display($panelizer->display);
// Make sure we have the did.
$panelizer->did = $panelizer->display->did;
// Ensure that we always write this as NULL when we have our own panel:
$panelizer->name = NULL;
// Make sure there is a view mode.
if (!isset($panelizer->view_mode)) {
$panelizer->view_mode = $view_mode;
}
// And write the new record.
return drupal_write_record('panelizer_entity', $panelizer, $update);
} else {
$panelizer->entity_type = $this->entity_type;
$panelizer->entity_id = $entity_id;
// The (int) ensures that entities that do not support revisions work
// since the revision_id cannot be NULL.
$panelizer->revision_id = (int) $revision_id;
// Make sure there is a view mode.
if (!isset($panelizer->view_mode)) {
$panelizer->view_mode = $view_mode;
}
drupal_write_record('panelizer_entity', $panelizer, $update);
}
}
}
示例7: db_select
<?php
// Set the display name you want to migrate to.
$new_display_name = 'some_display';
// Query the panels_display table and get all of the results.
$results = db_select('panels_display', 'pd')->fields('pd')->execute()->fetchAll();
// Loop through the results and load the display.
foreach ($results as $pd) {
$display = panels_load_display($pd->did);
$display->layout = $new_display_name;
panels_save_display($display);
}
示例8: hw_google_rollout
/**
*
* Make the configuration changes needed for Google Scholar and Infinite loop changes
* hw_google_rollout
*
*/
function hw_google_rollout($jcode, $jnldir, $sitedir)
{
$modulename = "jnl_" . $jcode . "_entity_pages";
$minipanel = "jnl_" . $jcode . "_tab_art";
$pdftab = "jnl_" . $jcode . "_tab_pdf";
$stablebranch = "7.x-1.x-stable";
$commitmsg = "Committing Google Scholar and Infinite Loop Changes ";
$rootdir = $jnldir . "/" . "drupal-webroot";
if (!file_exists($rootdir)) {
hw_drush_error_handler("Site specific directory does not exist. Exit. ", E_USER_ERROR);
}
ctools_include('plugins');
ctools_include('page', 'page_manager', 'plugins/tasks');
ctools_include('page_manager.admin', 'page_manager', '');
ctools_include('export');
$minis = ctools_export_load_object('panels_mini');
// Google Scholar Changes
// Loop through all the mini panels
foreach ($minis as $mini) {
// Update the configuration of article tab mini panel
if ($mini->name == $minipanel) {
foreach ($mini->display->content as $contentObj) {
if ($contentObj->type == 'hw_markup') {
$contentObj->configuration['process']['hw_google_scholar'] = 'hw_google_scholar';
hw_drush_error_handler("Google Scholar configuration changes completed for site " . $jcode . "\n", E_USER_NOTICE);
break;
}
}
// Save panel diplay with updated configuration
$savedDisplay = panels_save_display($mini->display);
$mini->did = $savedDisplay->did;
$mini->display = $savedDisplay;
$update = isset($mini->pid) && $mini->pid != 'new' ? array('pid') : array();
drupal_write_record('panels_mini', $mini, $update);
}
}
// Google Infinity Loop Changes.
// Load all pages
$tasks = page_manager_get_tasks_by_type('page');
$page_types = array();
foreach ($tasks as $task) {
// Get al the page handlers
if ($pages = page_manager_load_task_handlers($task)) {
$page_types[] = $pages;
}
}
// Load all display objects
foreach ($page_types as &$pages) {
foreach ($pages as &$page) {
if ($page && substr($page->name, 0, 9) == 'node_view') {
$display = $page->conf['display'];
foreach ($display->content as $contentobj) {
if ($contentobj->type == "hw_panel_tabs") {
// hw_panel_tabs
$contentobj->configuration['mini_panels'][$pdftab]['url_id'] = "full.pdf+html";
}
}
$savedisplay = panels_save_display($display);
$page->conf['display'] = $savedisplay;
page_manager_save_task_handler($page);
hw_drush_error_handler("Google Infinite Loop changes completed for site " . $jcode . "\n", E_USER_NOTICE);
}
}
}
hw_update_feature_module($modulename, $rootdir);
hw_clear_drupal_cache();
// hw_checkin_feature_updates($jnldir . "/" . $sitedir . "/modules", $modulename, $stablebranch, $commitmsg);
}