diff --git a/includes/common.inc b/includes/common.inc index 242d6949f5a139656dd68cc263628717af9fafdf..ffeac4561c09f79387457f2c5f2f6f948f49c8c6 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 .= ''; + $output .= '' . t('Built in context') . ''; + $desc = check_plain($context->identifier); + if (isset($context->keyword)) { + $desc .= '
' . t('Keyword: %@keyword', array('@keyword' => $context->keyword)) . '
'; + } + if (isset($context->description)) { + $desc .= '
' . filter_xss_admin($context->description) . '
'; + } + $output .= '' . $desc . ''; + $output .= ''; + $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 .= ''; - $output .= '' . t('Argument @count', array('@count' => $count)) . ''; - $output .= '' . check_plain($argument['identifier']) . ''; + $output .= '' . t('Argument @count', array('@count' => $count)) . ''; + $desc = check_plain($argument['identifier']); + if (isset($argument['keyword'])) { + $desc .= '
' . t('Keyword: %@keyword', array('@keyword' => $argument['keyword'])) . '
'; + } + $output .= '' . $desc . ''; $output .= ''; $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 .= ''; $output .= '' . t('Context @count', array('@count' => $count)) . ''; - $output .= '' . check_plain($context['identifier']) . ''; + $desc = check_plain($context['identifier']); + if (isset($context['keyword'])) { + $desc .= '
' . t('Keyword: %@keyword', array('@keyword' => $context['keyword'])) . '
'; + } + $output .= '' . $desc . ''; $output .= ''; $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 .= ''; - $output .= '' . t('From @title', array('@title' => $titles[$relationship['context']])) . ''; - $output .= '' . check_plain($relationship['identifier']) . ''; + $output .= '' . t('From "@title"', array('@title' => $titles[$relationship['context']])) . ''; + $desc = check_plain($relationship['identifier']); + if (isset($relationship['keyword'])) { + $desc .= '
' . t('Keyword: %@keyword', array('@keyword' => $relationship['keyword'])) . '
'; + } + $output .= '' . $desc . ''; $output .= ''; $titles[panels_context_id($relationship, 'relationship')] = $relationship['identifier']; $count++; } } if ($output) { - return "$output
\n"; + $head = ''; + if ($header) { + $head .= ''; + $head .= '' . $header . ''; + $head .= ''; + } + return "$head$output
\n"; } } diff --git a/includes/delegator.inc b/includes/delegator.inc index 3f0e6f69d34576305d69855554afae513f97b6c9..3d0e751223dd4fb76d24044300f9e98004901692 100644 --- a/includes/delegator.inc +++ b/includes/delegator.inc @@ -9,6 +9,30 @@ * is meant to be. */ +/** + * 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. */ @@ -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' => '
', + '#prefix' => '
', '#suffix' => '
', - '#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 49f024e4a418d77888802dee54df3612f2cfa57d..71b362d604b949f2c6bd3d584aad49b4d9947470 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 6e5b22f809722583c1cac9e4a55a84eeaa931e20..d4dc0386d1e99b986d899987726b504bd15e0802 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); } /**