summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEarl Miles2008-11-20 22:15:02 (GMT)
committer Earl Miles2008-11-20 22:15:02 (GMT)
commitd23acb0e4739b172ad5fe2fa21e18aa76e3d9ff6 (patch)
tree5187413d40b13179a6010bd381891c27b5f33ebd
parenteca84c6d6408239940961f0ee20bdc58c3a67124 (diff)
More updates for delegator.
-rw-r--r--includes/common.inc51
-rw-r--r--includes/delegator.inc37
-rw-r--r--panels_page/panels_page.css_filter.inc8
-rw-r--r--plugins/task_handlers/panel_node_view.inc31
4 files changed, 110 insertions, 17 deletions
diff --git a/includes/common.inc b/includes/common.inc
index 242d694..ffeac45 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -494,16 +494,39 @@ function theme_panels_common_content_list($display) {
*
* Contexts must be preloaded.
*/
-function theme_panels_common_context_list($object) {
+function theme_panels_common_context_list($object, $header = '') {
$titles = array();
$output = '';
$count = 1;
+ // Describe 'built in' contexts.
+ if (!empty($object->base_contexts)) {
+ foreach ($object->base_contexts as $id => $context) {
+ $output .= '<tr>';
+ $output .= '<td valign="top"><em>' . t('Built in context') . '</em></td>';
+ $desc = check_plain($context->identifier);
+ if (isset($context->keyword)) {
+ $desc .= '<div class="description">' . t('Keyword: %@keyword', array('@keyword' => $context->keyword)) . '</div>';
+ }
+ if (isset($context->description)) {
+ $desc .= '<div class="description">' . filter_xss_admin($context->description) . '</div>';
+ }
+ $output .= '<td>' . $desc . '</td>';
+ $output .= '</tr>';
+ $titles[$id] = $context->identifier;
+ $count++;
+ }
+ }
+
// First, make a list of arguments. Arguments are pretty simple.
if (!empty($object->arguments)) {
foreach ($object->arguments as $argument) {
$output .= '<tr>';
- $output .= '<td><em>' . t('Argument @count', array('@count' => $count)) . '</em></td>';
- $output .= '<td>' . check_plain($argument['identifier']) . '</td>';
+ $output .= '<td valign="top"><em>' . t('Argument @count', array('@count' => $count)) . '</em></td>';
+ $desc = check_plain($argument['identifier']);
+ if (isset($argument['keyword'])) {
+ $desc .= '<div class="description">' . t('Keyword: %@keyword', array('@keyword' => $argument['keyword'])) . '</div>';
+ }
+ $output .= '<td>' . $desc . '</td>';
$output .= '</tr>';
$titles[panels_context_id($argument, 'argument')] = $argument['identifier'];
$count++;
@@ -515,7 +538,11 @@ function theme_panels_common_context_list($object) {
foreach ($object->contexts as $context) {
$output .= '<tr>';
$output .= '<td><em>' . t('Context @count', array('@count' => $count)) . '</em></td>';
- $output .= '<td>' . check_plain($context['identifier']) . '</td>';
+ $desc = check_plain($context['identifier']);
+ if (isset($context['keyword'])) {
+ $desc .= '<div class="description">' . t('Keyword: %@keyword', array('@keyword' => $context['keyword'])) . '</div>';
+ }
+ $output .= '<td>' . $desc . '</td>';
$output .= '</tr>';
$titles[panels_context_id($context)] = $context['identifier'];
$count++;
@@ -525,15 +552,25 @@ function theme_panels_common_context_list($object) {
if (!empty($object->relationships)) {
foreach ($object->relationships as $relationship) {
$output .= '<tr>';
- $output .= '<td><em>' . t('From @title', array('@title' => $titles[$relationship['context']])) . '</em></td>';
- $output .= '<td>' . check_plain($relationship['identifier']) . '</td>';
+ $output .= '<td valign="top"><em>' . t('From "@title"', array('@title' => $titles[$relationship['context']])) . '</em></td>';
+ $desc = check_plain($relationship['identifier']);
+ if (isset($relationship['keyword'])) {
+ $desc .= '<div class="description">' . t('Keyword: %@keyword', array('@keyword' => $relationship['keyword'])) . '</div>';
+ }
+ $output .= '<td>' . $desc . '</td>';
$output .= '</tr>';
$titles[panels_context_id($relationship, 'relationship')] = $relationship['identifier'];
$count++;
}
}
if ($output) {
- return "<table><tbody>$output</tbody></table>\n";
+ $head = '';
+ if ($header) {
+ $head .= '<thead><tr>';
+ $head .= '<th colspan="2">' . $header . '</th>';
+ $head .= '</tr></thead>';
+ }
+ return "<table>$head<tbody>$output</tbody></table>\n";
}
}
diff --git a/includes/delegator.inc b/includes/delegator.inc
index 3f0e6f6..3d0e751 100644
--- a/includes/delegator.inc
+++ b/includes/delegator.inc
@@ -10,6 +10,30 @@
*/
/**
+ * Callback to allow the handler to react to being saved.
+ */
+function panels_delegator_save(&$handler, $update) {
+ // @todo Save the display
+
+ // Re-cache the CSS.
+ // Delete any previous cache file.
+ if (!empty($handler->conf['css_cache'])) {
+ file_delete($handler->conf['css_cache']);
+ }
+
+ if (!empty($handler->conf['css'])) {
+ // And generate a new one.
+ ctools_include('css');
+ $handler->conf['css_cache'] = ctools_css_cache($handler->conf['css']);
+ }
+ else {
+ $handler->conf['css_cache'] = '';
+ }
+}
+
+
+
+/**
* Choose a layout for this panel.
*/
function panels_delegator_edit_choose(&$form, &$form_state) {
@@ -159,7 +183,7 @@ function panels_delegator_edit_layout_settings(&$form, &$form_state) {
*
* @todo -- this probably needs more information to be truly flexible.
*/
-function panels_delegator_get_context($plugin, $handler) {
+function panels_delegator_get_context($plugin, $handler, $base_only = FALSE) {
if ($function = ctools_plugin_get_function($plugin, 'get context')) {
$contexts = $function();
}
@@ -167,10 +191,12 @@ function panels_delegator_get_context($plugin, $handler) {
$contexts = array();
}
+ $object = $base_only ? new stdClass : (object) $handler->conf;
+
// This function expects the contexts to be on an object, but our conf
// is an array, so we have to convert.
- return panels_context_load_contexts((object) $handler->conf, TRUE, $contexts);
+ return panels_context_load_contexts($object, TRUE, $contexts);
}
/**
@@ -253,7 +279,7 @@ function panels_delegator_edit_context(&$form, &$form_state) {
else {
$cache = new stdClass;
$cache->name = $handler->name;
- $cache->base_contexts = panels_delegator_get_context($form_state['plugin'], $form_state['handler']);
+ $cache->base_contexts = panels_delegator_get_context($form_state['plugin'], $form_state['handler'], TRUE);
$cache->contexts = isset($handler->conf['contexts']) ? $handler->conf['contexts'] : array();
$cache->relationships = isset($handler->conf['relationships']) ? $handler->conf['relationships'] : array();
panels_cache_set('panel_object:delegator', $handler->name, $cache);
@@ -277,11 +303,12 @@ function panels_delegator_edit_context(&$form, &$form_state) {
panels_common_add_context_js($settings);
$form['left']['summary'] = array(
- '#prefix' => '<div class="description">',
+ '#prefix' => '<div class="delegator-contexts">',
'#suffix' => '</div>',
- '#value' => t('This should be a summary of the contexts provided by the task, so for node_view here it will tell you about the node context it provides.'),
+ '#value' => theme('panels_common_context_list', $cache, t('Summary of contexts')),
);
+ drupal_add_css(panels_get_path('css/panels_admin.css'));
$form_state['cache'] = &$cache;
}
diff --git a/panels_page/panels_page.css_filter.inc b/panels_page/panels_page.css_filter.inc
index 49f024e..71b362d 100644
--- a/panels_page/panels_page.css_filter.inc
+++ b/panels_page/panels_page.css_filter.inc
@@ -2,7 +2,7 @@
/* $Id$ */
/*
- * @file panels_page/panels_page.css_filter.inc
+ * @file
* CSS filtering functions. Contains a disassembler, filter, compressor, and
* decompressor. Separated out into this file for cleanliness, as it's likely
* that these won't live in panels_page for long.
@@ -93,7 +93,7 @@ function panels_page_disassemble_css($css) {
foreach ($statements as $statement) {
// Get the selector(s) and declaration.
list($selector_str, $declaration) = explode('{', $statement);
-
+
// If the selector exists, then disassemble it, check it, and regenerate
// the selector string.
$selector_str = empty($selector_str) ? FALSE : panels_page_disassemble_css_selector($selector_str);
@@ -101,7 +101,7 @@ function panels_page_disassemble_css($css) {
// No valid selectors. Bomb out and start the next item.
continue;
}
-
+
// Disassemble the declaration, check it and tuck it into an array.
$disassembled_css[$selector_str] = panels_page_disassemble_css_declaration(strtolower($declaration));
}
@@ -173,7 +173,7 @@ function panels_page_filter_css($css, $allowed_properties = array(), $allowed_va
// Define disallowed url() value contents, if none is provided.
// $disallowed_values_regex = !empty($disallowed_values_regex) ? $disallowed_values_regex : '/[url|expression]\s*\(\s*[^\s)]+?\s*\)\s*/';
$disallowed_values_regex = !empty($disallowed_values_regex) ? $disallowed_values_regex : '/(url|expression)/';
-
+
foreach ($css as $selector_str => $declaration) {
foreach ($declaration as $property => $value) {
if (!in_array($property, $allowed_properties)) {
diff --git a/plugins/task_handlers/panel_node_view.inc b/plugins/task_handlers/panel_node_view.inc
index 6e5b22f..d4dc038 100644
--- a/plugins/task_handlers/panel_node_view.inc
+++ b/plugins/task_handlers/panel_node_view.inc
@@ -25,6 +25,7 @@ function panels_panel_node_view_delegator_task_handlers() {
'layout-settings' => t('Layout settings'),
'node_type' => t('Node type'),
),
+ 'save' => 'panels_panel_node_view_save',
'forms' => array(
'node_type' => array(
'form' => 'panels_panel_node_view_edit_node_type',
@@ -71,6 +72,7 @@ function panels_panel_node_view_delegator_task_handlers() {
),
'form' => 'panels_delegator_edit_content',
'submit' => 'panels_edit_display_form_submit',
+ 'no blocks' => TRUE,
),
'context' => array(
'include' => drupal_get_path('module', 'panels') . '/includes/delegator.inc',
@@ -83,6 +85,7 @@ function panels_panel_node_view_delegator_task_handlers() {
'no_blocks' => FALSE,
'css_id' => '',
'css' => '',
+ 'css_cache_file' => '',
'contexts' => array(),
'relationships' => array(),
),
@@ -115,12 +118,38 @@ function panels_panel_node_view_render($handler, $node) {
$display->context = array(
'panel-node' => $context,
);
+ $display->css_id = $handler->conf['css_id'];
+
+ // Check to see if there is any CSS.
+ if ($handler->conf['css_cache']) {
+ if (!file_exists($handler->conf['css_cache'])) {
+ // This will force the task handler to re-cache the CSS and save the filename:
+ delegator_save_task_handler($handler);
+ }
+ dsm("Addning: " . $handler->conf['css_cache']);
+ drupal_add_css($handler->conf['css_cache']);
+ }
// Since we're not using node_show() we need to emulate what it used to do.
// Update the history table, stating that this user viewed this node.
node_tag_new($node->nid);
- return panels_render_display($display);
+ $output = panels_render_display($display);
+ if (!empty($handler->conf['no_blocks'])) {
+ print theme('page', $output, FALSE);
+ // We return TRUE to let it know we handled this but have already
+ // handled the output rendering ourselves.
+ return TRUE;
+ }
+ return $output;
+}
+
+/**
+ * Call through to the delegator function for this.
+ */
+function panels_panel_node_view_save(&$handler, $update) {
+ panels_load_include('delegator');
+ return panels_delegator_save($handler, $update);
}
/**