本文整理汇总了PHP中panels_edit_cache_set函数的典型用法代码示例。如果您正苦于以下问题:PHP panels_edit_cache_set函数的具体用法?PHP panels_edit_cache_set怎么用?PHP panels_edit_cache_set使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了panels_edit_cache_set函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ajax_change_layout
/**
* AJAX entry point to create the controller form for an IPE.
*/
function ajax_change_layout($break = NULL)
{
if ($this->ipe_test_lock('change_layout', $break)) {
return;
}
// At this point, we want to save the cache to ensure that we have a lock.
$this->cache->ipe_locked = TRUE;
panels_edit_cache_set($this->cache);
ctools_include('plugins', 'panels');
ctools_include('common', 'panels');
// @todo figure out a solution for this, it's critical
if (isset($this->display->allowed_layouts)) {
$layouts = $this->display->allowed_layouts;
} else {
$layouts = panels_common_get_allowed_layouts('panels_page');
}
// Filter out builders
$layouts = array_filter($layouts, '_panels_builder_filter');
// Define the current layout
$current_layout = $this->plugins['layout']['name'];
$output = panels_common_print_layout_links($layouts, $this->get_url('set_layout'), array('attributes' => array('class' => array('use-ajax'))), $current_layout);
$this->commands[] = ctools_modal_command_display(t('Change layout'), $output);
$this->commands[] = array('command' => 'IPEsetLockState', 'key' => $this->clean_key, 'lockPath' => $this->get_url('unlock_ipe'));
}
示例2: ajax_set_layout
function ajax_set_layout($layout)
{
ctools_include('context');
ctools_include('display-layout', 'panels');
$form_state = array('layout' => $layout, 'display' => $this->display, 'finish' => t('Save'), 'no_redirect' => TRUE);
// Reset the $_POST['ajax_html_ids'] values to preserve
// proper IDs on form elements when they are rebuilt
// by the Panels IPE without refreshing the page
$_POST['ajax_html_ids'] = array();
$output = drupal_build_form('panels_change_layout', $form_state);
$output = drupal_render($output);
if (!empty($form_state['executed'])) {
if (isset($form_state['back'])) {
return $this->ajax_change_layout();
}
if (!empty($form_state['clicked_button']['#save-display'])) {
// Saved. Save the cache.
panels_edit_cache_save($this->cache);
panels_edit_cache_set($this->cache);
$this->display->skip_cache;
// Since the layout changed, we have to update these things in the
// renderer in order to get the right settings.
$layout = panels_get_layout($this->display->layout);
$this->plugins['layout'] = $layout;
if (!isset($layout['regions'])) {
$this->plugins['layout']['regions'] = panels_get_regions($layout, $this->display);
}
$this->meta_location = 'inline';
$this->commands[] = ajax_command_replace("#panels-ipe-display-{$this->clean_key}", panels_render_display($this->display, $this));
$this->commands[] = ctools_modal_command_dismiss();
return;
}
}
$this->commands[] = ctools_modal_command_display(t('Change layout'), $output);
}
示例3: ajax_access_configure_test
/**
* AJAX entry point for to configure vsibility rule.
*/
function ajax_access_configure_test($pid = NULL, $id = NULL) {
if (empty($this->display->content[$pid])) {
ctools_modal_render(t('Error'), t('Invalid pane id.'));
}
$pane = &$this->display->content[$pid];
$subtype = ctools_content_get_subtype($pane->type, $pane->subtype);
// Set this up here because $id gets changed later.
$url = $this->get_url('access-configure-test', $pid, $id);
// If we're adding a new one, get the stored data from cache and
// add it. It's stored as a cache so that if this is closed
// we don't accidentally add an unconfigured plugin.
if ($id == 'add') {
$pane->access['plugins'][] = $this->cache->new_plugin;
$id = max(array_keys($pane->access['plugins']));
}
else if (empty($pane->access['plugins'][$id])) {
ctools_modal_render(t('Error'), t('Invalid test id.'));
}
$form_state = array(
'display' => &$this->display,
'pane' => &$pane,
'ajax' => TRUE,
'title' => t('Configure visibility rule for !subtype_title', array('!subtype_title' => $subtype['title'])),
'test' => &$pane->access['plugins'][$id],
'plugin' => ctools_get_access_plugin($pane->access['plugins'][$id]['name']),
'url' => url($url, array('absolute' => TRUE)),
);
$output = ctools_modal_form_wrapper('panels_edit_configure_access_test_form', $form_state);
if (empty($form_state['executed'])) {
$this->commands = $output;
return;
}
// Unset the new plugin
if (isset($this->cache->new_plugin)) {
unset($this->cache->new_plugin);
}
if (!empty($form_state['remove'])) {
unset($pane->access['plugins'][$id]);
}
panels_edit_cache_set($this->cache);
$this->command_update_pane($pid);
$this->commands[] = ctools_modal_command_dismiss();
}
示例4: ajax_save_form
/**
* AJAX entry point to create the controller form for an IPE.
*/
function ajax_save_form($break = NULL)
{
ctools_include('form');
if (!empty($this->cache->locked)) {
if ($break != 'break') {
$account = user_load($this->cache->locked->uid);
$name = theme('username', $account);
$lock_age = format_interval(time() - $this->cache->locked->updated);
$message = t("This panel is being edited by user !user, and is therefore locked from editing by others. This lock is !age old.\n\nClick OK to break this lock and discard any changes made by !user.", array('!user' => $name, '!age' => $lock_age));
$this->commands[] = array('command' => 'unlockIPE', 'message' => $message, 'break_path' => url($this->get_url('save-form', 'break')));
return;
}
// Break the lock.
panels_edit_cache_break_lock($this->cache);
}
$form_state = array('display' => &$this->display, 'content_types' => $this->cache->content_types, 'rerender' => FALSE, 'no_redirect' => TRUE, 'layout' => $this->plugins['layout']);
$output = ctools_build_form('panels_ipe_edit_control_form', $form_state);
if ($output) {
// At this point, we want to save the cache to ensure that we have a lock.
panels_edit_cache_set($this->cache);
$this->commands[] = array('command' => 'initIPE', 'key' => $this->clean_key, 'data' => $output);
return;
}
// no output == submit
if (!empty($form_state['clicked_button']['#save-display'])) {
// Saved. Save the cache.
panels_edit_cache_save($this->cache);
} else {
// Cancelled. Clear the cache.
panels_edit_cache_clear($this->cache);
}
$this->commands[] = array('command' => 'endIPE', 'key' => $this->clean_key, 'data' => $output);
}
示例5: edit_form
function edit_form(&$form, &$form_state)
{
ctools_include('plugins', 'panels');
// If the plugin is not set, then it should be provided as an argument:
if (!isset($form_state['item']->plugin)) {
$form_state['item']->plugin = $form_state['function args'][2];
}
parent::edit_form($form, $form_state);
$form['category'] = array('#type' => 'textfield', '#title' => t('Category'), '#description' => t('What category this layout should appear in. If left blank the category will be "Miscellaneous".'), '#default_value' => $form_state['item']->category);
ctools_include('context');
ctools_include('display-edit', 'panels');
ctools_include('content');
// Provide actual layout admin UI here.
// Create a display for editing:
$cache_key = 'builder-' . $form_state['item']->name;
// Load the display being edited from cache, if possible.
if (!empty($_POST) && is_object($cache = panels_edit_cache_get($cache_key))) {
$display =& $cache->display;
} else {
$content_types = ctools_content_get_available_types();
panels_cache_clear('display', $cache_key);
$cache = new stdClass();
$display = panels_new_display();
$display->did = $form_state['item']->name;
$display->layout = $form_state['item']->plugin;
$display->layout_settings = $form_state['item']->settings;
$display->cache_key = $cache_key;
$display->editing_layout = TRUE;
$cache->display = $display;
$cache->content_types = $content_types;
$cache->display_title = FALSE;
panels_edit_cache_set($cache);
}
// Set up lipsum content in all of the existing panel regions:
$display->content = array();
$display->panels = array();
$custom = ctools_get_content_type('custom');
$layout = panels_get_layout($display->layout);
$regions = panels_get_regions($layout, $display);
foreach ($regions as $id => $title) {
$pane = panels_new_pane('custom', 'custom');
$pane->pid = $id;
$pane->panel = $id;
$pane->configuration = ctools_content_get_defaults($custom, 'custom');
$pane->configuration['title'] = 'Lorem Ipsum';
$pane->configuration['body'] = $this->lipsum;
$display->content[$id] = $pane;
$display->panels[$id] = array($id);
}
$form_state['display'] =& $display;
// Tell the Panels form not to display buttons.
$form_state['no buttons'] = TRUE;
$form_state['no display settings'] = TRUE;
$form_state['cache_key'] = $cache_key;
$form_state['content_types'] = $cache->content_types;
$form_state['display_title'] = FALSE;
$form_state['renderer'] = panels_get_renderer_handler('editor', $cache->display);
$form_state['renderer']->cache =& $cache;
$form = panels_edit_display_form($form, $form_state);
// If we leave the standard submit handler, it'll try to reconcile
// content from the input, but we've not exposed that to the user. This
// makes previews work with the content we forced in.
$form['preview']['button']['#submit'] = array('panels_edit_display_form_preview');
}
示例6: ajax_edit_pane
/**
* AJAX entry point to edit a pane.
*/
function ajax_edit_pane($pid = NULL, $step = NULL)
{
if (empty($this->cache->display->content[$pid])) {
ctools_modal_render(t('Error'), t('Invalid pane id.'));
}
$pane =& $this->cache->display->content[$pid];
// Check if we should skip pane translation.
if (_mlpanels_pane_skip($pane->type, $pane->subtype)) {
// Pass to default renderer.
return parent::ajax_edit_pane($pid, $step);
}
$content_type = ctools_get_content_type($pane->type);
$subtype = ctools_content_get_subtype($content_type, $pane->subtype);
$settings = _mlpanels_settings();
if (empty($step)) {
$messages[] = t('You can translate settings for different languages,
but you must set %renderer as display renderer in order to see result.', array('%renderer' => t('Multilingual Standard')));
}
if ($settings['show_types']) {
$messages[] = t('Pane type to disable %type', array('%type' => $pane->type . '::' . $pane->subtype));
}
// Get language.
$path = explode('/', $_GET['q']);
$tmp = explode('_', end($path));
if ($tmp[0] == 'mlpanels') {
$conf_lng = $tmp[1];
}
if (empty($conf_lng)) {
$conf_lng = LANGUAGE_NONE;
}
// Prepare language dependent config.
if (!empty($pane->configuration['mlpanels'])) {
$ml_config = $pane->configuration['mlpanels'];
$ml_config[LANGUAGE_NONE] = $pane->configuration;
unset($ml_config[LANGUAGE_NONE]['mlpanels']);
} else {
$ml_config[LANGUAGE_NONE] = $pane->configuration;
}
if (!empty($ml_config[$conf_lng])) {
$configuration = $ml_config[$conf_lng];
} else {
$messages[] = t('No configuration exists for this language yet, using default.');
$configuration = $ml_config[LANGUAGE_NONE];
}
// Safety check.
if (isset($configuration['mlpanels'])) {
unset($configuration['mlpanels']);
}
// Change finish button text.
$finish_text = t('Finish');
if ($conf_lng != LANGUAGE_NONE) {
if (_mlpanels_settings('keep_window')) {
$finish_text = t('Save Translation and Continue');
} else {
$finish_text = t('Save Translation and Finish');
}
}
$form_state = array('display' => &$this->cache->display, 'contexts' => $this->cache->display->context, 'pane' => &$pane, 'display cache' => &$this->cache, 'ajax' => TRUE, 'modal' => TRUE, 'modal return' => TRUE, 'commands' => array());
$form_info = array('path' => $this->get_url('edit-pane', $pid, '%step', 'mlpanels_' . $conf_lng), 'show cancel' => TRUE, 'finish text' => $finish_text, 'next callback' => 'panels_ajax_edit_pane_next', 'finish callback' => 'panels_ajax_edit_pane_finish', 'cancel callback' => 'panels_ajax_edit_pane_cancel');
// This is used to get our form in form alter.
if ($conf_lng != LANGUAGE_NONE) {
$form_info['untranslate text'] = t('Remove Translation');
$form_info['untranslate hidden'] = empty($ml_config[$conf_lng]);
}
// Building form.
$output = ctools_content_form('edit', $form_info, $form_state, $content_type, $pane->subtype, $subtype, $configuration, $step);
// Add language links to the form.
$languages = array(LANGUAGE_NONE => (object) array('name' => t('Default'), 'language' => LANGUAGE_NONE)) + language_list();
foreach ($languages as $lng) {
$class = array('ctools-use-modal');
$class[] = $lng->language;
if (empty($ml_config[$lng->language])) {
$class[] = 'empty';
}
if ($conf_lng == $lng->language) {
$class[] = 'current';
}
$links[] = l($lng->name, $this->get_url('edit-pane', $pid, $form_state['step'], 'mlpanels_' . $lng->language), array('attributes' => array('class' => $class), 'html' => TRUE));
}
$output['mlpanels'] = array('#markup' => theme('item_list', array('items' => $links, 'attributes' => array('class' => array('mlpanels_lnd_list')))));
$output['mlpanels_messages'] = array('#markup' => '<div class="message-target"></div>');
// If $rc is FALSE, there was no actual form.
if ($output === FALSE || !empty($form_state['cancel'])) {
// Dismiss the modal.
$this->commands[] = ctools_modal_command_dismiss();
} elseif (!empty($form_state['clicked_button']) && $form_state['clicked_button']['#wizard type'] == 'untranslate') {
// Unset surrent translation.
unset($ml_config[$conf_lng]);
// Update pane configuration.
$form_state['pane']->configuration = array('mlpanels' => $ml_config) + $ml_config[LANGUAGE_NONE];
// References get blown away with AJAX caching. This will fix that.
$this->cache->display->content[$pid] = $form_state['pane'];
panels_edit_cache_set($this->cache);
$this->command_update_pane($pid);
if (_mlpanels_settings('keep_window') && $conf_lng != LANGUAGE_NONE) {
drupal_set_message(t('Translation removed.'));
$this->commands[] = ajax_command_remove('#modal-content .messages');
//.........这里部分代码省略.........