non security modules update

This commit is contained in:
Bachir Soussi Chiadmi
2015-04-20 16:32:07 +02:00
parent 6a8d30db08
commit 37fbabab56
466 changed files with 32690 additions and 9652 deletions

View File

@@ -0,0 +1,161 @@
<?php
/**
* @file
* Provides a simple time-based caching option for panel panes.
*/
// Plugin definition
$plugin = array(
'title' => t("Simple cache"),
'description' => t('Simple caching is a time-based cache. This is a hard limit, and once cached it will remain that way until the time limit expires.'),
'cache get' => 'panels_simple_cache_get_cache',
'cache set' => 'panels_simple_cache_set_cache',
'cache clear' => 'panels_simple_cache_clear_cache',
'settings form' => 'panels_simple_cache_settings_form',
'settings form submit' => 'panels_simple_cache_settings_form_submit',
'defaults' => array(
'lifetime' => 15,
'granularity' => 'none',
),
);
/**
* Get cached content.
*/
function panels_simple_cache_get_cache($conf, $display, $args, $contexts, $pane = NULL) {
$cid = panels_simple_cache_get_id($conf, $display, $args, $contexts, $pane);
$cache = cache_get($cid, 'cache_panels');
if (!$cache) {
return FALSE;
}
if ((time() - $cache->created) > $conf['lifetime']) {
return FALSE;
}
return $cache->data;
}
/**
* Set cached content.
*/
function panels_simple_cache_set_cache($conf, $content, $display, $args, $contexts, $pane = NULL) {
$cid = panels_simple_cache_get_id($conf, $display, $args, $contexts, $pane);
cache_set($cid, $content, 'cache_panels');
}
/**
* Clear cached content.
*
* Cache clears are always for an entire display, regardless of arguments.
*/
function panels_simple_cache_clear_cache($display) {
$cid = 'panels_simple_cache';
// If the panel is stored in the database it'll have a numeric did value.
if (is_numeric($display->did)) {
$cid .= ':' . $display->did;
}
// Exported panels won't have a numeric did but may have a usable cache_key.
elseif (!empty($display->cache_key)) {
$cid .= ':' . str_replace('panel_context:', '', $display->cache_key);
}
// Alternatively use the css_id.
elseif (!empty($display->css_id)) {
$cid .= ':' . $display->css_id;
}
// Failover to just appending the did, which may be the completely unusable
// string 'new'.
else {
$cid .= ':' . $display->did;
}
cache_clear_all($cid, 'cache_panels', TRUE);
}
/**
* Figure out an id for our cache based upon input and settings.
*/
function panels_simple_cache_get_id($conf, $display, $args, $contexts, $pane) {
$id = 'panels_simple_cache';
// If the panel is stored in the database it'll have a numeric did value.
if (is_numeric($display->did)) {
$id .= ':' . $display->did;
}
// Exported panels won't have a numeric did but may have a usable cache_key.
elseif (!empty($display->cache_key)) {
$id .= ':' . str_replace('panel_context:', '', $display->cache_key);
}
// Alternatively use the css_id.
elseif (!empty($display->css_id)) {
$id .= ':' . $display->css_id;
}
// Failover to just appending the did, which may be the completely unusable
// string 'new'.
else {
$id .= ':' . $display->did;
}
if ($pane) {
$id .= ':' . $pane->pid;
}
if (user_access('view pane admin links')) {
$id .= ':admin';
}
switch ($conf['granularity']) {
case 'args':
foreach ($args as $arg) {
$id .= ':' . $arg;
}
break;
case 'context':
if (!is_array($contexts)) {
$contexts = array($contexts);
}
foreach ($contexts as $context) {
if (isset($context->argument)) {
$id .= ':' . $context->argument;
}
}
}
if (module_exists('locale')) {
global $language;
$id .= ':' . $language->language;
}
if(!empty($pane->configuration['use_pager']) && !empty($_GET['page'])) {
$id .= ':p' . check_plain($_GET['page']);
}
return $id;
}
function panels_simple_cache_settings_form($conf, $display, $pid) {
$options = drupal_map_assoc(array(15, 30, 60, 120, 180, 240, 300, 600, 900, 1200, 1800, 3600, 7200, 14400, 28800, 43200, 86400, 172800, 259200, 345600, 604800), 'format_interval');
$form['lifetime'] = array(
'#title' => t('Lifetime'),
'#type' => 'select',
'#options' => $options,
'#default_value' => $conf['lifetime'],
);
$form['granularity'] = array(
'#title' => t('Granularity'),
'#type' => 'select',
'#options' => array(
'args' => t('Arguments'),
'context' => t('Context'),
'none' => t('None'),
),
'#description' => t('If "arguments" are selected, this content will be cached per individual argument to the entire display; if "contexts" are selected, this content will be cached per unique context in the pane or display; if "neither" there will be only one cache for this pane.'),
'#default_value' => $conf['granularity'],
);
return $form;
}

View File

@@ -153,7 +153,7 @@ class panels_renderer_editor extends panels_renderer_standard {
$output = '<div class="' . $class . '" id="panel-pane-' . $pane->pid . '">';
if (!$block->title) {
if (empty($block->title)) {
$block->title = t('No title');
}
@@ -161,7 +161,7 @@ class panels_renderer_editor extends panels_renderer_standard {
if ($buttons) {
$output .= '<span class="buttons">' . $buttons . '</span>';
}
$output .= '<span class="text">' . $title . '</span>';
$output .= '<span class="text" title="' . check_plain($title) . '">' . $title . '</span>';
$output .= '</div>'; // grabber
$output .= '<div class="panel-pane-collapsible">';
@@ -186,12 +186,12 @@ class panels_renderer_editor extends panels_renderer_standard {
$style_title = isset($style['title']) ? $style['title'] : t('Default');
$style_links[] = array(
$style_links['title'] = array(
'title' => $style_title,
'attributes' => array('class' => array('panels-text')),
);
$style_links[] = array(
$style_links['change'] = array(
'title' => t('Change'),
'href' => $this->get_url('style-type', $type, $id),
'attributes' => array('class' => array('ctools-use-modal')),
@@ -199,7 +199,7 @@ class panels_renderer_editor extends panels_renderer_standard {
$function = $type != 'pane' ? 'settings form' : 'pane settings form';
if (panels_plugin_get_function('styles', $style, $function)) {
$style_links[] = array(
$style_links['settings'] = array(
'title' => t('Settings'),
'href' => $this->get_url('style-settings', $type, $id),
'attributes' => array('class' => array('ctools-use-modal')),
@@ -307,14 +307,14 @@ class panels_renderer_editor extends panels_renderer_standard {
$links = array();
if (!empty($pane->shown)) {
$links[] = array(
$links['top']['disabled'] = array(
'title' => t('Disable this pane'),
'href' => $this->get_url('hide', $pane->pid),
'attributes' => array('class' => array('use-ajax')),
);
}
else {
$links[] = array(
$links['top']['enable'] = array(
'title' => t('Enable this pane'),
'href' => $this->get_url('show', $pane->pid),
'attributes' => array('class' => array('use-ajax')),
@@ -322,13 +322,13 @@ class panels_renderer_editor extends panels_renderer_standard {
}
if (isset($this->display->title_pane) && $this->display->title_pane == $pane->pid) {
$links['panels-set-title'] = array(
$links['top']['panels-set-title'] = array(
'title' => t('&#x2713;Panel title'),
'html' => TRUE,
);
}
else {
$links['panels-set-title'] = array(
$links['top']['panels-set-title'] = array(
'title' => t('Panel title'),
'href' => $this->get_url('panel-title', $pane->pid),
'attributes' => array('class' => array('use-ajax')),
@@ -338,7 +338,7 @@ class panels_renderer_editor extends panels_renderer_standard {
$subtype = ctools_content_get_subtype($content_type, $pane->subtype);
if (ctools_content_editable($content_type, $subtype, $pane->configuration)) {
$links[] = array(
$links['top']['settings'] = array(
'title' => isset($content_type['edit text']) ? $content_type['edit text'] : t('Settings'),
'href' => $this->get_url('edit-pane', $pane->pid),
'attributes' => array('class' => array('ctools-use-modal')),
@@ -346,7 +346,7 @@ class panels_renderer_editor extends panels_renderer_standard {
}
if (user_access('administer advanced pane settings')) {
$links[] = array(
$links['top']['css'] = array(
'title' => t('CSS properties'),
'href' => $this->get_url('pane-css', $pane->pid),
'attributes' => array('class' => array('ctools-use-modal')),
@@ -354,26 +354,10 @@ class panels_renderer_editor extends panels_renderer_standard {
}
if (user_access('administer panels styles')) {
$links[] = array(
'title' => '<hr />',
'html' => TRUE,
);
$style_links = $this->get_style_links('pane', $pane->pid);
$links[] = array(
'title' => '<span class="dropdown-header">' . t('Style') . '</span>' . theme_links(array('links' => $style_links, 'attributes' => array(), 'heading' => array())),
'html' => TRUE,
'attributes' => array('class' => array('panels-sub-menu')),
);
$links['style'] = $this->get_style_links('pane', $pane->pid);
}
if (user_access('administer pane access')) {
$links[] = array(
'title' => '<hr />',
'html' => TRUE,
);
$contexts = $this->display->context;
// Make sure we have the logged in user context
if (!isset($contexts['logged-in-user'])) {
@@ -385,7 +369,7 @@ class panels_renderer_editor extends panels_renderer_standard {
if (!empty($pane->access['plugins'])) {
foreach ($pane->access['plugins'] as $id => $test) {
$plugin = ctools_get_access_plugin($test['name']);
$access_title = isset($plugin['title']) ? $plugin['title'] : t('Broken/missing access plugin %plugin', array('%plugin' => $test['name']));
$access_title = isset($plugin['title']) ? $plugin['title'] : t('Broken/missing access plugin %plugin', array('%plugin' => $test['name']));
$access_description = ctools_access_summary($plugin, $contexts, $test);
$visibility_links[] = array(
@@ -396,37 +380,28 @@ class panels_renderer_editor extends panels_renderer_standard {
}
}
if (empty($visibility_links)) {
$visibility_links[] = array(
$visibility_links['no_rules'] = array(
'title' => t('No rules'),
'attributes' => array('class' => array('panels-text')),
);
}
$visibility_links[] = array(
$visibility_links['add_rule'] = array(
'title' => t('Add new rule'),
'href' => $this->get_url('access-add-test', $pane->pid),
'attributes' => array('class' => array('ctools-use-modal')),
);
$visibility_links[] = array(
$visibility_links['settings'] = array(
'title' => t('Settings'),
'href' => $this->get_url('access-settings', $pane->pid),
'attributes' => array('class' => array('ctools-use-modal')),
);
$links[] = array(
'title' => '<span class="dropdown-header">' . t('Visibility rules') . '</span>' . theme_links(array('links' => $visibility_links, 'attributes' => array(), 'heading' => array())),
'html' => TRUE,
'attributes' => array('class' => array('panels-sub-menu')),
);
$links['visibility'] = $visibility_links;
}
if (user_access('use panels locks')) {
$links[] = array(
'title' => '<hr />',
'html' => TRUE,
);
$lock_type = !empty($pane->locks['type']) ? $pane->locks['type'] : 'none';
switch ($lock_type) {
case 'immovable':
@@ -441,62 +416,44 @@ class panels_renderer_editor extends panels_renderer_standard {
break;
}
$lock_links[] = array(
$lock_links['lock'] = array(
'title' => $lock_method,
'attributes' => array('class' => array('panels-text')),
);
$lock_links[] = array(
$lock_links['change'] = array(
'title' => t('Change'),
'href' => $this->get_url('lock', $pane->pid),
'attributes' => array('class' => array('ctools-use-modal')),
);
$links[] = array(
'title' => '<span class="dropdown-header">' . t('Locking') . '</span>' . theme_links(array('links' => $lock_links, 'attributes' => array(), 'heading' => array())),
'html' => TRUE,
'attributes' => array('class' => array('panels-sub-menu')),
);
$links['lock'] = $lock_links;
}
if (panels_get_caches() && user_access('use panels caching features')) {
$links[] = array(
'title' => '<hr />',
'html' => TRUE,
);
$method = isset($pane->cache['method']) ? $pane->cache['method'] : 0;
$info = panels_get_cache($method);
$cache_method = isset($info['title']) ? $info['title'] : t('No caching');
$cache_links[] = array(
$cache_links['title'] = array(
'title' => $cache_method,
'attributes' => array('class' => array('panels-text')),
);
$cache_links[] = array(
$cache_links['change'] = array(
'title' => t('Change'),
'href' => $this->get_url('cache-method', $pane->pid),
'attributes' => array('class' => array('ctools-use-modal')),
);
if (panels_plugin_get_function('cache', $info, 'settings form')) {
$cache_links[] = array(
$cache_links['settings'] = array(
'title' => t('Settings'),
'href' => $this->get_url('cache-settings', $pane->pid),
'attributes' => array('class' => array('ctools-use-modal')),
);
}
$links[] = array(
'title' => '<span class="dropdown-header">' . t('Caching') . '</span>' . theme_links(array('links' => $cache_links, 'attributes' => array(), 'heading' => array())),
'html' => TRUE,
'attributes' => array('class' => array('panels-sub-menu')),
);
$links['cache'] = $cache_links;
}
$links[] = array(
'title' => '<hr />',
'html' => TRUE,
);
$links[] = array(
$links['bottom']['remove'] = array(
'title' => t('Remove'),
'href' => '#',
'attributes' => array(
@@ -505,7 +462,38 @@ class panels_renderer_editor extends panels_renderer_standard {
),
);
return theme('ctools_dropdown', array('title' => theme('image', array('path' => ctools_image_path('icon-configure.png', 'panels'))), 'links' => $links, 'image' => TRUE));
// Allow others to add/remove links from pane context menu.
// Grouped by 'top', 'style', 'visibility', 'lock', 'cache' and 'bottom'
drupal_alter('get_pane_links', $links, $pane, $content_type);
$dropdown_links = $links['top'];
$category_labels = array(
'style' => 'Style',
'visibility' => 'Visibility rules',
'lock' => 'Locking',
'cache' => 'Caching',
);
foreach ($category_labels as $category => $label) {
if (array_key_exists($category, $links)) {
$dropdown_links[] = array(
'title' => '<hr />',
'html' => TRUE,
);
$dropdown_links[] = array(
'title' => '<span class="dropdown-header">' . t($label) . '</span>' . theme_links(array('links' => $links[$category], 'attributes' => array(), 'heading' => array())),
'html' => TRUE,
'attributes' => array('class' => array('panels-sub-menu')),
);
}
}
$dropdown_links[] = array(
'title' => '<hr />',
'html' => TRUE,
);
$dropdown_links = array_merge($dropdown_links, $links['bottom']);
return theme('ctools_dropdown', array('title' => theme('image', array('path' => ctools_image_path('icon-configure.png', 'panels'))), 'links' => $dropdown_links, 'image' => TRUE));
}
// -----------------------------------------------------------------------
@@ -581,7 +569,7 @@ class panels_renderer_editor extends panels_renderer_standard {
* @todo -- this should be in CTools.
*/
function get_category($content_type) {
if (isset($content_type['top level'])) {
if (!empty($content_type['top level'])) {
$category = 'root';
}
else if (isset($content_type['category'])) {
@@ -656,7 +644,19 @@ class panels_renderer_editor extends panels_renderer_standard {
$content_type = ctools_get_content_type($type_name);
$subtype = ctools_content_get_subtype($content_type, $subtype_name);
if (!isset($step) || !isset($this->cache->new_pane)) {
// Determine if we are adding a different pane than previously cached. This
// is used to load the different pane into cache so that multistep forms
// have the correct context instead of a previously cached version that
// does not match the pane currently being added.
$is_different_pane = FALSE;
if (isset($this->cache) && isset($this->cache->new_pane)) {
$diff_type = $type_name != $this->cache->new_pane->type;
$diff_subtype = $subtype_name != $this->cache->new_pane->subtype;
$is_different_pane = $diff_type || $diff_subtype;
}
if (!isset($step) || !isset($this->cache->new_pane) || $is_different_pane) {
$pane = panels_new_pane($type_name, $subtype_name, TRUE);
$this->cache->new_pane = &$pane;
}
@@ -757,6 +757,11 @@ class panels_renderer_editor extends panels_renderer_standard {
// References get blown away with AJAX caching. This will fix that.
$this->cache->display->content[$pid] = $form_state['pane'];
// Conditionally overwrite the context for this panel if present in the form state.
if (!empty($form_state['display_cache']->display->context)) {
$this->cache->display->context = $form_state['display_cache']->display->context;
}
panels_edit_cache_set($this->cache);
$this->command_update_pane($pid);
$this->commands[] = ctools_modal_command_dismiss();
@@ -942,8 +947,11 @@ class panels_renderer_editor extends panels_renderer_standard {
ctools_include('content');
$pane = &$this->display->content[$pid];
$style = isset($pane->style['style']) ? $pane->style['style'] : 'default';
$subtype = ctools_content_get_subtype($pane->type, $pane->subtype);
$title = t('Pane style for "!pane"', array('!pane' => $subtype['title']));
$title = ctools_content_admin_title($pane->type, $pane->subtype, $pane->configuration, $this->display->context);
if (!$title) {
$title = $pane->type;
}
$title = t('Pane style for "!title"', array('!title' => $title));
break;
default:
@@ -1158,7 +1166,23 @@ class panels_renderer_editor extends panels_renderer_standard {
unset($this->cache->style);
}
// $conf was a reference so it should just modify.
if (!empty($form_state['cancel'])) {
// The cache must be saved prior to dismissing the modal.
panels_edit_cache_set($this->cache);
$this->commands[] = ctools_modal_command_dismiss();
return;
}
// Copy settings from form state back into the cache.
if(!empty($form_state['values']['settings'])) {
if ($type == 'pane') {
$this->cache->display->content[$pid]->style['settings'] = $form_state['values']['settings'];
}
else if($type == 'region') {
$this->cache->display->panel_settings['style_settings'][$pid] = $form_state['values']['settings'];
}
}
panels_edit_cache_set($this->cache);
$this->commands[] = ctools_modal_command_dismiss();
@@ -1501,6 +1525,8 @@ function panels_ajax_edit_pane_cancel(&$form_state) {
* Choose cache method form
*/
function panels_edit_cache_method_form($form, &$form_state) {
ctools_form_include($form_state, 'plugins', 'panels');
form_load_include($form_state, 'php', 'panels', '/plugins/display_renderers/panels_renderer_editor.class');
$display = &$form_state['display'];
$conf = &$form_state['conf'];
@@ -1549,6 +1575,8 @@ function panels_edit_cache_method_form_submit($form, &$form_state) {
* Cache settings form
*/
function panels_edit_cache_settings_form($form, &$form_state) {
ctools_form_include($form_state, 'plugins', 'panels');
form_load_include($form_state, 'php', 'panels', '/plugins/display_renderers/panels_renderer_editor.class');
$display = &$form_state['display'];
$conf = &$form_state['conf'];
$pid = $form_state['pid'];
@@ -1609,6 +1637,8 @@ function panels_edit_cache_settings_form_submit($form, &$form_state) {
* Choose style form
*/
function panels_edit_style_type_form($form, &$form_state) {
ctools_form_include($form_state, 'plugins', 'panels');
form_load_include($form_state, 'php', 'panels', '/plugins/display_renderers/panels_renderer_editor.class');
$display = &$form_state['display'];
$style = $form_state['style'];
$type = $form_state['type'];
@@ -1659,6 +1689,8 @@ function panels_edit_style_type_form_submit($form, &$form_state) {
* Style settings form
*/
function panels_edit_style_settings_form($form, &$form_state) {
ctools_form_include($form_state, 'plugins', 'panels');
form_load_include($form_state, 'php', 'panels', '/plugins/display_renderers/panels_renderer_editor.class');
$display = &$form_state['display'];
$conf = &$form_state['conf'];
$pid = $form_state['pid'];
@@ -1683,9 +1715,28 @@ function panels_edit_style_settings_form($form, &$form_state) {
'#value' => t('Save'),
);
// Need a cancel button since the style cache can persist and impact the wrong
// pane (or region, or display).
$form['cancel_style'] = array(
'#type' => 'submit',
'#value' => t('Cancel'),
'#submit' => array('panels_edit_style_settings_form_cancel'),
);
return $form;
}
/**
* Cancel style settings form.
*
* Clears the editing cache to prevent styles being applied to incorrect regions
* or panes.
*/
function panels_edit_style_settings_form_cancel($form, &$form_state) {
$form_state['cancel'] = TRUE;
}
/**
* Validate style settings.
*/
@@ -1713,6 +1764,8 @@ function panels_edit_style_settings_form_submit($form, &$form_state) {
* Configure CSS on a pane form.
*/
function panels_edit_configure_pane_css_form($form, &$form_state) {
ctools_form_include($form_state, 'plugins', 'panels');
form_load_include($form_state, 'php', 'panels', '/plugins/display_renderers/panels_renderer_editor.class');
$display = &$form_state['display'];
$pane = &$form_state['pane'];
@@ -1755,6 +1808,8 @@ function panels_edit_configure_pane_css_form_submit($form, &$form_state) {
* Configure lock on a pane form.
*/
function panels_edit_configure_pane_lock_form($form, &$form_state) {
ctools_form_include($form_state, 'plugins', 'panels');
form_load_include($form_state, 'php', 'panels', '/plugins/display_renderers/panels_renderer_editor.class');
$display = &$form_state['display'];
$pane = &$form_state['pane'];
@@ -1830,6 +1885,8 @@ function panels_edit_configure_pane_lock_form_submit($form, &$form_state) {
* Form to control basic visibility settings.
*/
function panels_edit_configure_access_settings_form($form, &$form_state) {
ctools_form_include($form_state, 'plugins', 'panels');
form_load_include($form_state, 'php', 'panels', '/plugins/display_renderers/panels_renderer_editor.class');
$display = &$form_state['display'];
$pane = &$form_state['pane'];
@@ -1867,6 +1924,8 @@ function panels_edit_configure_access_settings_form_submit($form, &$form_state)
* Form to add a visibility rule.
*/
function panels_edit_add_access_test_form($form, &$form_state) {
ctools_form_include($form_state, 'plugins', 'panels');
form_load_include($form_state, 'php', 'panels', '/plugins/display_renderers/panels_renderer_editor.class');
$display = &$form_state['display'];
$pane = &$form_state['pane'];
@@ -1896,6 +1955,8 @@ function panels_edit_add_access_test_form($form, &$form_state) {
* Form to configure a visibility rule.
*/
function panels_edit_configure_access_test_form($form, &$form_state) {
ctools_form_include($form_state, 'plugins', 'panels');
form_load_include($form_state, 'php', 'panels', '/plugins/display_renderers/panels_renderer_editor.class');
$display = &$form_state['display'];
$test = &$form_state['test'];
$plugin = &$form_state['plugin'];

View File

@@ -259,6 +259,10 @@ class panels_renderer_standard {
}
}
$this->prepared['panes'] = $first + $normal + $last;
// Allow other modules the alter the prepared panes array.
drupal_alter('panels_panes_prepared', $this->prepared['panes'], $this);
return $this->prepared['panes'];
}
@@ -403,17 +407,38 @@ class panels_renderer_standard {
* their CSS added in the right order: inner content before outer content.
*/
function add_meta() {
global $theme;
if (!empty($this->plugins['layout']['css'])) {
if (file_exists(path_to_theme() . '/' . $this->plugins['layout']['css'])) {
$this->add_css(path_to_theme() . '/' . $this->plugins['layout']['css']);
// Do not use the path_to_theme() function, because it returns the
// $GLOBALS['theme_path'] value, which may be overriden in the theme()
// function when the theme hook defines the key 'theme path'.
$theme_path = isset($theme) ? drupal_get_path('theme', $theme) : '';
$css = $this->plugins['layout']['css'];
if (!is_array($css)) {
$css = array($css);
}
else {
$this->add_css($this->plugins['layout']['path'] . '/' . $this->plugins['layout']['css']);
// Load each of the CSS files defined in this layout.
foreach ($css as $file) {
if (!empty($theme_path) && file_exists($theme_path . '/' . $file)) {
$this->add_css($theme_path . '/' . $file);
}
else {
$this->add_css($this->plugins['layout']['path'] . '/' . $file);
}
}
}
if ($this->admin && isset($this->plugins['layout']['admin css'])) {
$this->add_css($this->plugins['layout']['path'] . '/' . $this->plugins['layout']['admin css']);
$admin_css = $this->plugins['layout']['admin css'];
if (!is_array($admin_css)) {
$admin_css = array($admin_css);
}
foreach ($admin_css as $file) {
$this->add_css($this->plugins['layout']['path'] . '/' . $file);
}
}
}
@@ -436,7 +461,7 @@ class panels_renderer_standard {
break;
case 'inline':
$url = base_path() . $filename;
$this->prefix .= '<link type="text/css" rel="stylesheet" href="' . $url . '" />'."\n";
$this->prefix .= '<link type="text/css" rel="stylesheet" href="' . file_create_url($url) . '" />'."\n";
break;
}
}
@@ -473,6 +498,8 @@ class panels_renderer_standard {
* A Panels pane object, as loaded from the database.
*/
function render_pane(&$pane) {
module_invoke_all('panels_pane_prerender', $pane);
$content = $this->render_pane_content($pane);
if ($this->display->hide_title == PANELS_TITLE_PANE && !empty($this->display->title_pane) && $this->display->title_pane == $pane->pid) {
@@ -526,7 +553,6 @@ class panels_renderer_standard {
$this->display->context = array();
}
$content = FALSE;
$caching = !empty($pane->cache['method']) && empty($this->display->skip_cache);
if ($caching && ($cache = panels_get_cached_content($this->display, $this->display->args, $this->display->context, $pane))) {
$content = $cache->content;
@@ -540,10 +566,6 @@ class panels_renderer_standard {
$content = ctools_content_render($pane->type, $pane->subtype, $pane->configuration, array(), $this->display->args, $this->display->context);
if (empty($content)) {
return;
}
foreach (module_implements('panels_pane_content_alter') as $module) {
$function = $module . '_panels_pane_content_alter';
$function($content, $pane, $this->display->args, $this->display->context, $this, $this->display);
@@ -555,14 +577,17 @@ class panels_renderer_standard {
}
}
// Pass long the css_id that is usually available.
if (!empty($pane->css['css_id'])) {
$content->css_id = check_plain($pane->css['css_id']);
}
// If there's content, check if we've css configuration to add.
if (!empty($content)) {
// Pass long the css_id that is usually available.
if (!empty($pane->css['css_id'])) {
$content->css_id = check_plain($pane->css['css_id']);
}
// Pass long the css_class that is usually available.
if (!empty($pane->css['css_class'])) {
$content->css_class = check_plain($pane->css['css_class']);
// Pass long the css_class that is usually available.
if (!empty($pane->css['css_class'])) {
$content->css_class = check_plain($pane->css['css_class']);
}
}
return $content;

View File

@@ -125,9 +125,19 @@ class panels_layouts_ui extends ctools_export_ui {
function edit_form_submit(&$form, &$form_state) {
parent::edit_form_submit($form, $form_state);
// While we short circuited the main submit hook, we need to keep this one.
panels_edit_display_settings_form_submit($form, $form_state);
$form_state['item']->settings = $form_state['display']->layout_settings;
}
function edit_form_validate(&$form, &$form_state) {
parent::edit_form_validate($form, $form_state);
// While we short circuited the main validate hook, we need to keep this one.
panels_edit_display_settings_form_validate($form, $form_state);
}
function list_form(&$form, &$form_state) {
ctools_include('plugins', 'panels');
$this->builders = panels_get_layout_builders();

View File

@@ -17,7 +17,7 @@ Drupal.flexible.fixHeight = function() {
Drupal.behaviors.flexibleAdmin = {
attach: function(context) {
// Show/hide layout manager button
$('input#panels-flexible-toggle-layout:not(.panels-flexible-processed)', context)
$('#panels-flexible-toggle-layout:not(.panels-flexible-processed)', context)
.addClass('panels-flexible-processed')
.click(function() {
$('.panel-flexible-admin')
@@ -290,9 +290,6 @@ Drupal.flexible.splitter = function($splitter) {
// if not moving the right side, adjust the parent padding instead.
splitter.parent.css('padding-left', (splitter.left_padding - moved) + 'px');
splitter.left.parent().css('margin-left', (splitter.left_parent + moved) + 'px');
if (jQuery.browser.msie) {
splitter.left.parent().css('left', splitter.currentLeft);
}
}
return false;
};

View File

@@ -471,15 +471,26 @@ function panels_flexible_render_items($renderer, $list, $owner_id) {
switch ($item['type']) {
case 'column':
$content = panels_flexible_render_items($renderer, $item['children'], $renderer->base['column'] . '-' . $id);
$groups[$location] .= panels_flexible_render_item($renderer, $item, $content, $id, $position, $max);
if (empty($renderer->settings['items'][$id]['hide_empty']) || trim($content)) {
$groups[$location] .= panels_flexible_render_item($renderer, $item, $content, $id, $position, $max);
}
break;
case 'row':
$content = panels_flexible_render_items($renderer, $item['children'], $renderer->base['row'] . '-' . $id);
$groups[$location] .= panels_flexible_render_item($renderer, $item, $content, $id, $position, $max, TRUE);
if (empty($renderer->settings['items'][$id]['hide_empty']) || trim($content)) {
$groups[$location] .= panels_flexible_render_item($renderer, $item, $content, $id, $position, $max, TRUE);
}
break;
case 'region':
$content = isset($renderer->content[$id]) ? $renderer->content[$id] : "&nbsp;";
$groups[$location] .= panels_flexible_render_item($renderer, $item, $content, $id, $position, $max);
if (empty($renderer->settings['items'][$id]['hide_empty'])) {
$content = isset($renderer->content[$id]) ? $renderer->content[$id] : "&nbsp;";
}
else {
$content = isset($renderer->content[$id]) ? trim($renderer->content[$id]) : "";
}
if (empty($renderer->settings['items'][$id]['hide_empty']) || $content) {
$groups[$location] .= panels_flexible_render_item($renderer, $item, $content, $id, $position, $max);
}
break;
}
@@ -747,47 +758,47 @@ function panels_flexible_render_css_group($renderer, $list, $owner_id, $type, $i
$css = array();
// Start off with some generic CSS to properly pad regions
$css['.' . $renderer->item_class['region']] = array(
$css[$owner_id . ' .' . $renderer->item_class['region']] = array(
'padding' => '0',
);
$css['.' . $renderer->item_class['region'] . '-inside'] = array(
$css[$owner_id . ' .' . $renderer->item_class['region'] . '-inside'] = array(
'padding-right' => $renderer->region_separation,
'padding-left' => $renderer->region_separation,
);
$css['.' . $renderer->item_class['region'] . '-inside-first'] = array(
$css[$owner_id . ' .' . $renderer->item_class['region'] . '-inside-first'] = array(
'padding-left' => '0',
);
$css['.' . $renderer->item_class['region'] . '-inside-last'] = array(
$css[$owner_id . ' .' . $renderer->item_class['region'] . '-inside-last'] = array(
'padding-right' => '0',
);
$css['.' . $renderer->item_class['column']] = array(
$css[$owner_id . ' .' . $renderer->item_class['column']] = array(
'padding' => '0',
);
$css['.' . $renderer->item_class['column'] . '-inside'] = array(
$css[$owner_id . ' .' . $renderer->item_class['column'] . '-inside'] = array(
'padding-right' => $renderer->column_separation,
'padding-left' => $renderer->column_separation,
);
$css['.' . $renderer->item_class['column'] . '-inside-first'] = array(
$css[$owner_id . ' .' . $renderer->item_class['column'] . '-inside-first'] = array(
'padding-left' => '0',
);
$css['.' . $renderer->item_class['column'] . '-inside-last'] = array(
$css[$owner_id . ' .' . $renderer->item_class['column'] . '-inside-last'] = array(
'padding-right' => '0',
);
// And properly pad rows too
$css['.' . $renderer->item_class['row']] = array(
$css[$owner_id . ' .' . $renderer->item_class['row']] = array(
'padding' => '0 0 ' . $renderer->row_separation . ' 0',
'margin' => '0',
);
$css['.' . $renderer->item_class['row'] . '-last'] = array(
$css[$owner_id . ' .' . $renderer->item_class['row'] . '-last'] = array(
'padding-bottom' => '0',
);
@@ -1186,6 +1197,12 @@ function panels_flexible_config_item_form($form, &$form_state) {
}
}
$form['hide_empty'] = array(
'#title' => t('Hide element if empty'),
'#type' => 'checkbox',
'#default_value' => !empty($item['hide_empty']) ? 1 : 0,
);
$form['save'] = array(
'#type' => 'submit',
'#value' => t('Save'),
@@ -1223,6 +1240,7 @@ function panels_flexible_config_item_form_submit(&$form, &$form_state) {
else {
$item['contains'] = $form_state['values']['contains'];
}
$item['hide_empty'] = $form_state['values']['hide_empty'];
}
@@ -1486,6 +1504,12 @@ function panels_flexible_add_item_form($form, &$form_state) {
);
}
$form['hide_empty'] = array(
'#title' => t('Hide element if empty'),
'#type' => 'checkbox',
'#default_value' => 0,
);
$form['save'] = array(
'#type' => 'submit',
'#value' => t('Save'),
@@ -1516,6 +1540,8 @@ function panels_flexible_add_item_form_submit(&$form, &$form_state) {
$item['contains'] = $form_state['values']['contains'];
}
$item['hide_empty'] = $form_state['values']['hide_empty'];
if ($item['type'] == 'region') {
// derive the region key from the title
$key = preg_replace("/[^a-z0-9]/", '_', drupal_strtolower($item['title']));

View File

@@ -18,7 +18,7 @@
width: 25%;
}
.panel-3col-stacked .panel-col .inside {
.panel-3col-stacked .panel-col-first .inside {
margin: 0 .5em 1em .5em;
}

View File

@@ -31,6 +31,9 @@ function theme_panels_block_style_render_pane($vars) {
if (!empty($block->title)) {
$block->subject = $block->title;
}
if (!isset($block->subject)) {
$block->subject = '';
}
$block->region = $pane->panel;
if (!isset($block->module)) {

View File

@@ -184,7 +184,7 @@ $plugin = array(
'default conf' => array(
'title' => t('Panel'),
'no_blocks' => FALSE,
'pipeline' => 'standard',
'pipeline' => variable_get('panels_renderer_default', 'standard'),
'body_classes_to_remove' => '',
'body_classes_to_add' => '',
'css_id' => '',
@@ -238,6 +238,28 @@ function &panels_panel_context_get_display(&$handler) {
return $handler->conf['display'];
}
/**
* Build the cache key so that the editor and IPE can properly find
* everything needed for this display.
*/
function panels_panel_context_cache_key($task_name, $handler_id, $args) {
$arguments = array();
foreach ($args as $arg) {
// Sadly things like panels everywhere actually use non-string arguments
// and they basically can't be represented here. Luckily, PE also does
// not use a system where this matters, so replace its args with a 0
// for a placeholder.
if (is_string($arg)) {
$arguments[] = $arg;
}
else {
$arguments[] = '0';
}
}
$cache_key = 'panel_context:' . $task_name . '::' . $handler_id . '::' . implode('\\', $arguments) . '::';
return $cache_key;
}
/**
* Check selection rules and, if passed, render the contexts.
*/
@@ -267,7 +289,7 @@ function panels_panel_context_render($handler, $base_contexts, $args, $test = TR
$display->css_id = $handler->conf['css_id'];
$task_name = page_manager_make_task_name($handler->task, $handler->subtask);
$display->cache_key = 'panel_context:' . $task_name . ':' . $handler->name;
$display->cache_key = panels_panel_context_cache_key($task_name, $handler->name, $args);
// Check to see if there is any CSS.
if (!empty($handler->conf['css'])) {
@@ -284,15 +306,32 @@ function panels_panel_context_render($handler, $base_contexts, $args, $test = TR
panels_get_current_page_display($display);
$renderer = panels_get_renderer($handler->conf['pipeline'], $display);
// If the IPE is enabled, but the user does not have access to edit
// load the standard renderer instead.
$parents = class_parents($renderer);
if (!empty($parents['panels_renderer_editor']) && !user_access('user page manager') && !user_access('use ipe with page manager')) {
$renderer = panels_get_renderer_handler('standard', $display);
}
// Remove and add body element classes
$panel_body_css = &drupal_static('panel_body_css');
if (isset($handler->conf['body_classes_to_remove']) && !isset($panel_body_css['body_classes_to_remove'])) {
$panel_body_css['body_classes_to_remove'] = $handler->conf['body_classes_to_remove'];
if (isset($handler->conf['body_classes_to_remove'])) {
if (!isset($panel_body_css['body_classes_to_remove'])) {
$panel_body_css['body_classes_to_remove'] = $handler->conf['body_classes_to_remove'];
}
else{
$panel_body_css['body_classes_to_remove'] .= ' ' . $handler->conf['body_classes_to_remove'];
}
}
if (isset($handler->conf['body_classes_to_add']) && !isset($panel_body_css['body_classes_to_add'])) {
$panel_body_css['body_classes_to_add'] = $handler->conf['body_classes_to_add'];
if (isset($handler->conf['body_classes_to_add'])) {
if (!isset($panel_body_css['body_classes_to_add'])) {
$panel_body_css['body_classes_to_add'] = $handler->conf['body_classes_to_add'];
}
else {
$panel_body_css['body_classes_to_add'] .= ' '. $handler->conf['body_classes_to_add'];
}
}
$info = array(
@@ -364,7 +403,10 @@ function panels_panel_context_export(&$handler, $indent) {
unset($handler->conf[$item]);
}
}
$display->did = 'new';
$display = (object) array(
'did' => 'new',
'uuid' => ctools_uuid_generate(),
);
$handler->conf['display'] = $display;
}
@@ -629,7 +671,7 @@ function panels_panel_context_edit_move($form, &$form_state) {
$form_state['display'] = &panels_panel_context_get_display($form_state['handler']);
$form_state['layout'] = $form_state['handler']->conf['temp_layout'];
$form_state['cache_key'] = 'panel_context:' . $form_state['task_name'] . ':' . $form_state['handler_id'];
$form_state['cache_key'] = panels_panel_context_cache_key($form_state['task_name'], $form_state['handler_id'], array());
ctools_include('common', 'panels');
ctools_include('display-layout', 'panels');
@@ -666,7 +708,7 @@ function panels_panel_context_edit_content($form, &$form_state) {
ctools_include('context');
ctools_include('context-task-handler');
$cache = panels_edit_cache_get('panel_context:' . $form_state['task_name'] . ':' . $form_state['handler_id']);
$cache = panels_edit_cache_get(panels_panel_context_cache_key($form_state['task_name'], $form_state['handler_id'], array()));
$form_state['renderer'] = panels_get_renderer_handler('editor', $cache->display);
$form_state['renderer']->cache = &$cache;
@@ -731,7 +773,7 @@ function panels_panel_context_edit_settings($form, &$form_state) {
$form['conf']['body_classes_to_remove'] = array(
'#type' => 'textfield',
'#size' => 128,
'#default_value' => $conf['body_classes_to_remove'],
'#default_value' => empty($conf['body_classes_to_remove']) ? '' : $conf['body_classes_to_remove'],
'#title' => t('Remove body CSS classes'),
'#description' => t('The CSS classes to remove from the body element of this page. Separated by a space. For example: no-sidebars one-sidebar sidebar-first sidebar-second two-sidebars.'),
);
@@ -739,7 +781,7 @@ function panels_panel_context_edit_settings($form, &$form_state) {
$form['conf']['body_classes_to_add'] = array(
'#type' => 'textfield',
'#size' => 128,
'#default_value' => $conf['body_classes_to_add'],
'#default_value' => empty($conf['body_classes_to_add']) ? '' : $conf['body_classes_to_add'],
'#title' => t('Add body CSS classes'),
'#description' => t('The CSS classes to add to the body element of this page. Separated by a space. For example: no-sidebars one-sidebar sidebar-first sidebar-second two-sidebars.'),
);
@@ -868,15 +910,28 @@ function panels_panel_context_get_addressable($task, $subtask_name, $handler, $a
$display->context = $contexts;
$display->args = $arguments;
$display->css_id = $handler->conf['css_id'];
$display->cache_key = 'panel_context:' . $task->name . ':' . $handler->name;
$display->cache_key = panels_panel_context_cache_key($task->name, $handler->name, $arguments);
$renderer = panels_get_renderer($handler->conf['pipeline'], $display);
if ($type == 'content') {
$renderer->prepare();
$renderer->prepare();
if ($address) {
$pid = array_shift($address);
if (!empty($renderer->prepared['panes'][$pid])) {
return $renderer->render_pane($renderer->prepared['panes'][$pid]);
if ($type == 'content') {
return $renderer->render_pane($renderer->prepared['panes'][$pid]);
}
elseif ($type == 'pane') {
return $renderer->prepared['panes'][$pid];
}
}
}
else {
if ($type == 'content') {
return $renderer->render();
}
elseif ($type == 'renderer') {
return $renderer;
}
}
}

View File

@@ -137,8 +137,8 @@ class panels_views_plugin_row_fields extends views_plugin_row_fields {
// Now that we have distributed our fields, go through the regions and
// render them into the content array.
foreach ($this->region_fields as $region_id => $fields) {
$this->view->field = $fields;
foreach ($this->region_fields as $region_id => $fields_list) {
$this->view->field = $fields_list;
$content[$region_id] = theme($this->theme_functions(), array('view' => $this->view, 'options' => $this->options, 'row' => $row));
}