From 63ed711017c62a683579b1458095be113aff2663 Mon Sep 17 00:00:00 2001 From: Earl Miles <merlin@logrus.com> Date: Fri, 6 Feb 2009 22:32:21 +0000 Subject: [PATCH] #367213: Do not throw away an already built form when falling back. Just render what we have. --- css/dropdown.css | 2 +- delegator/plugins/tasks/node_edit.inc | 6 ++++-- includes/dropdown.theme.inc | 19 +++++++++++++++---- plugins/contexts/node_add_form.inc | 7 +++++-- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/css/dropdown.css b/css/dropdown.css index c02673c3..293dba7d 100644 --- a/css/dropdown.css +++ b/css/dropdown.css @@ -28,7 +28,7 @@ html.js div.ctools-dropdown div.ctools-dropdown-container ul li { /* Everything from here down is purely visual style and can be overridden. */ -html.js div.ctools-dropdown a.ctools-dropdown-link { +html.js div.ctools-dropdown a.ctools-dropdown-text-link { background: url(../images/collapsible-expanded.png) 3px 5px no-repeat; padding-left: 12px; } diff --git a/delegator/plugins/tasks/node_edit.inc b/delegator/plugins/tasks/node_edit.inc index fccda22d..32078c6f 100644 --- a/delegator/plugins/tasks/node_edit.inc +++ b/delegator/plugins/tasks/node_edit.inc @@ -76,8 +76,10 @@ function delegator_node_edit($node) { $output = ctools_context_handler_render($task, '', $contexts); if ($output === FALSE) { // Fall back! - module_load_include('inc', 'node', 'node.pages'); - $output = drupal_get_form($node->type . '_node_form', $node); + // We've already built the form with the context, so we can't build it again, or + // form_clean_id will mess up our ids. But we don't really need to, either: + $context = current($contexts); + $output = drupal_render_form($context->form_id, $context->form); } return $output; diff --git a/includes/dropdown.theme.inc b/includes/dropdown.theme.inc index c68cf919..0b5f2265 100644 --- a/includes/dropdown.theme.inc +++ b/includes/dropdown.theme.inc @@ -34,7 +34,7 @@ */ function ctools_dropdown_theme(&$items) { $items['ctools_dropdown'] = array( - 'arguments' => array('title' => NULL, 'links' => NULL), + 'arguments' => array('title' => NULL, 'links' => NULL, 'image' => FALSE, 'class' => ''), 'file' => 'includes/dropdown.theme.inc', ); } @@ -47,12 +47,15 @@ function ctools_dropdown_theme(&$items) { * @param $links * A list of links to provide within the dropdown, suitable for use * in via Drupal's theme('links'). + * @param $image + * If true, the dropdown link is an image and will not get extra decorations + * that a text dropdown link will. * @param $class * An optional class to add to the dropdown's container div to allow you * to style a single dropdown however you like without interfering with * other dropdowns. */ -function theme_ctools_dropdown($title, $links, $class = '') { +function theme_ctools_dropdown($title, $links, $image = FALSE, $class = '') { // Provide a unique identifier for every dropdown on the page. static $id = 0; $id++; @@ -65,12 +68,20 @@ function theme_ctools_dropdown($title, $links, $class = '') { $output = ''; $output .= '<div class="' . $class . '" id="ctools-dropdown-' . $id . '">'; - $output .= '<div class="ctools-dropdown-link-wrapper">'; // Test fix for IE - $output .= '<a href="#" class="ctools-dropdown-link">' . check_plain($title) . '</a>'; + $output .= '<div class="ctools-dropdown-link-wrapper">'; + if ($image) { + $output .= '<a href="#" class="ctools-dropdown-link ctools-dropdown-image-link">' . $title . '</a>'; + } + else { + $output .= '<a href="#" class="ctools-dropdown-link ctools-dropdown-text-link">' . check_plain($title) . '</a>'; + } + $output .= '</div>'; // wrapper + $output .= '<div class="ctools-dropdown-container-wrapper">'; $output .= '<div class="ctools-dropdown-container">'; $output .= theme('links', $links); $output .= '</div>'; // container + $output .= '</div>'; // container wrapper $output .= '</div>'; // dropdown return $output; } diff --git a/plugins/contexts/node_add_form.inc b/plugins/contexts/node_add_form.inc index 63c6f6f8..f30e724b 100644 --- a/plugins/contexts/node_add_form.inc +++ b/plugins/contexts/node_add_form.inc @@ -48,8 +48,11 @@ function ctools_context_create_node_add_form($empty, $data = NULL, $conf = FALSE global $user; $node = array('uid' => $user->uid, 'name' => $user->name, 'type' => $type); - $form = drupal_retrieve_form($type . '_node_form', $node); - drupal_process_form($type . '_node_form', $form); + ctools_include('form'); + $form_id = $node->type . '_node_form'; + + $form_state = array('want form' => TRUE, 'args' => array($node)); + $form = ctools_build_form($form_id, $form_state); // In a form, $data is the object being edited. $context->data = $type; $context->title = $types[$type]->name; -- GitLab