? pimped_cck_ui.patch Index: content.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/cck/Attic/content.module,v retrieving revision 1.301.2.106 diff -u -p -r1.301.2.106 content.module --- content.module 2 Jun 2009 12:24:04 -0000 1.301.2.106 +++ content.module 23 Jun 2009 20:49:55 -0000 @@ -116,13 +116,14 @@ function content_menu() { 'weight' => 2, ); $contexts = content_build_modes('_tabs'); + $weight = 0; foreach ($contexts as $key => $tab) { $items['admin/content/node-type/'. $type_url_str .'/display/'. $key] = array( 'title' => $tab['title'], 'page arguments' => array('content_display_overview_form', $type_name, $key), 'access arguments' => array('administer content types'), - 'type' => $key == 'basic' ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK, - 'weight' => $key == 'basic' ? 0 : 1, + 'type' => $key == 'node' ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK, + 'weight' => $weight++, ); } // Cast as an array in case this is called before any fields have @@ -328,6 +329,10 @@ function content_delete_revision(&$node) * Generate field render arrays. */ function content_view(&$node, $teaser = FALSE, $page = FALSE) { + // Set the build mode for the node. + $node->build_mode = ($page) ? 'node' : 'teaser'; + if ($node->build_mode == 'teaser' && $node->sticky == 1) $node->build_mode = 'sticky'; + // Let field modules sanitize their data for output. _content_field_invoke('sanitize', $node, $teaser, $page); @@ -755,7 +760,7 @@ function content_field($op, &$node, $fie $theme = $formatter['module'] .'_formatter_'. $formatter_name; $single = (content_handle('formatter', 'multiple values', $formatter) == CONTENT_HANDLE_CORE); - $label_display = isset($field['display_settings']['label']['format']) ? $field['display_settings']['label']['format'] : 'above'; + $label_display = isset($field['display_settings'][$node->build_mode]['label']['format']) ? $field['display_settings'][$node->build_mode]['label']['format'] : 'above'; // Do not include field labels when indexing content. if ($context == NODE_BUILD_SEARCH_INDEX) { $label_display = 'hidden'; @@ -806,10 +811,16 @@ function content_field($op, &$node, $fie // to populate the $FIELD_NAME_rendered variable for node templates, // and hide it from the $content variable if needed. // See 'preprocess_node' op and theme_content_field_wrapper()? + $selector_order_key = $node->build_mode .'order'; + $weight = isset($field['display_settings'][$selector_order_key]) ? $field['display_settings'][$selector_order_key] : 0; + $region = isset($field['display_settings'][$node->build_mode]['region']) ? $field['display_settings'][$node->build_mode]['region'] : 'main'; + $exclude = isset($field['display_settings'][$node->build_mode]['exclude']) ? $field['display_settings'][$node->build_mode]['exclude'] : FALSE; $wrapper = array( + '#region' => $region, 'field' => $element, - '#weight' => $field['widget']['weight'], - '#post_render' => array('content_field_wrapper_post_render'), + '#weight' => $weight, + //'#post_render' => array('content_field_wrapper_post_render'), + '#exclude' => $exclude, '#field_name' => $field['field_name'], '#type_name' => $node->type, '#context' => $context, @@ -866,14 +877,23 @@ function content_field($op, &$node, $fie $wrapper = NULL; if (isset($node->content[$field['field_name']])) { $wrapper = $node->content[$field['field_name']]; + $region = $node->content[$field['field_name']]['#region']; + $weight = $node->content[$field['field_name']]['#weight']; + $exclude = $node->content[$field['field_name']]['#exclude']; } elseif (module_exists('fieldgroup') && ($group_name = fieldgroup_get_group($node->type, $field['field_name'])) && isset($node->content[$group_name]['group'][$field['field_name']])) { $wrapper = $node->content[$group_name]['group'][$field['field_name']]; + $region = $node->content[$group_name]['group'][$field['field_name']]['#region']; + $weight = $node->content[$group_name]['group'][$field['field_name']]['#weight']; + $exclude = $node->content[$group_name]['group'][$field['field_name']]['#exclude']; } if ($wrapper) { // '#chilren' is not set if the field is empty. - $addition[$field['field_name'] .'_rendered'] = isset($wrapper['#children']) ? $wrapper['#children'] : ''; + $addition[$field['field_name'] .'_rendered']['value'] = isset($wrapper['#children']) ? $wrapper['#children'] : ''; + $addition[$field['field_name'] .'_rendered']['region'] = $region; + $addition[$field['field_name'] .'_rendered']['weight'] = $weight; + $addition[$field['field_name'] .'_rendered']['exclude'] = $exclude; } return $addition; @@ -1850,15 +1870,29 @@ function content_build_modes($selector = */ function node_content_build_modes() { return array( - 'basic' => array( - 'title' => t('Basic'), + 'node' => array( + 'title' => t('Full node'), + 'build modes' => array( + 'node' => array( + 'title' => t('Node'), + 'views style' => TRUE, + ), + ), + ), + 'teaser' => array( + 'title' => t('Teaser'), 'build modes' => array( 'teaser' => array( 'title' => t('Teaser'), 'views style' => TRUE, ), - 'full' => array( - 'title' => t('Full node'), + ), + ), + 'sticky' => array( + 'title' => t('Sticky'), + 'build modes' => array( + 'sticky' => array( + 'title' => t('Sticky'), 'views style' => TRUE, ), ), @@ -2316,6 +2350,42 @@ function content_preprocess_content_fiel function content_preprocess_node(&$vars) { $additions = _content_field_invoke_default('preprocess_node', $vars['node']); $vars = array_merge($vars, $additions); + + // Put all additions in their region. + $regions = array(); + foreach ($additions as $name => $value) { + if ($value['exclude'] != 1) + $regions[$value['region']][$value['weight']] = $value['value']; + } + + $content = ''; + $region_classes = array(); + $content_regions = content_node_regions(); + foreach ($content_regions as $region_key => $region_name) { + if (isset($regions[$region_key])) { + if ($region_key == 'left' || $region_key == 'right') { + $region_classes[] = $region_key; + } + $content .= '
'; + ksort($regions[$region_key]); + foreach ($regions[$region_key] as $key => $value) { + $content .= $value; + } + $content .= '
'; + } + } + + $vars['node_classes'] = array(); + if (in_array('left', $region_classes) && in_array('right', $region_classes)) $vars['node_classes'][] = 'two-sidebars'; + elseif (in_array('left', $region_classes) && !in_array('right', $region_classes)) $vars['node_classes'][] = 'one-sidebar sidebar-left'; + elseif (!in_array('left', $region_classes) && in_array('right', $region_classes)) $vars['node_classes'][] = 'one-sidebar sidebar-right'; + else $vars['node_classes'][] = 'no-sidebars'; + $vars['node_classes'] = implode(' ', $vars['node_classes']); + + // We need to add other keys later on, but for now, + // let's only add cck fields. + $vars['content'] = $content; + } /** @@ -2533,3 +2603,16 @@ function content_inactive_fields($type_n } return $inactive; } + +/** + * Return array of all the available node regions. + */ +function content_node_regions() { + return array( + 'header' => t('Header'), + 'left' => t('Left'), + 'main' => t('Middle'), + 'right' => t('Right'), + 'footer' => t('Footer'), + ); +} Index: includes/content.admin.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/cck/includes/Attic/content.admin.inc,v retrieving revision 1.181.2.69 diff -u -p -r1.181.2.69 content.admin.inc --- includes/content.admin.inc 18 Jun 2009 19:23:02 -0000 1.181.2.69 +++ includes/content.admin.inc 23 Jun 2009 20:49:57 -0000 @@ -552,7 +552,7 @@ function content_field_overview_form_sub * Form includes form widgets to select which fields appear for teaser, full node * and how the field labels should be rendered. */ -function content_display_overview_form(&$form_state, $type_name, $contexts_selector = 'basic') { +function content_display_overview_form(&$form_state, $type_name, $contexts_selector = 'node') { content_inactive_message($type_name); // Gather type information. @@ -560,9 +560,10 @@ function content_display_overview_form(& $field_types = _content_field_types(); $fields = $type['fields']; - $groups = array(); + $groups = $group_options = array(); if (module_exists('fieldgroup')) { $groups = fieldgroup_groups($type['type']); + $group_options = _fieldgroup_groups_label($type['type']); } $contexts = content_build_modes($contexts_selector); @@ -574,18 +575,27 @@ function content_display_overview_form(& '#contexts' => $contexts_selector, ); + /** + * This isn't true in our case, just leave it commented out. + */ if (empty($fields)) { drupal_set_message(t('There are no fields configured for this content type. You can add new fields on the Manage fields page.', array( '@link' => url('admin/content/node-type/'. $type['url_str'] .'/fields'))), 'warning'); return $form; } + // Create order key. + $order_key = $contexts_selector .'order'; + $form['contexts_order_key'] = array('#type' => 'hidden', '#value' => $order_key); + // Fields. $label_options = array( 'above' => t('Above'), 'inline' => t('Inline'), 'hidden' => t(''), ); + $region_options = content_node_regions(); + foreach ($fields as $name => $field) { $field_type = $field_types[$field['type']]; $defaults = $field['display_settings']; @@ -593,18 +603,17 @@ function content_display_overview_form(& $form[$name] = array( 'human_name' => array('#value' => check_plain($field['widget']['label'])), - 'weight' => array('#type' => 'value', '#value' => $weight), + 'weight' => array('#type' => 'value', '#default_value' => $weight), 'parent' => array('#type' => 'value', '#value' => ''), ); - // Label - if ($contexts_selector == 'basic') { - $form[$name]['label']['format'] = array( - '#type' => 'select', - '#options' => $label_options, - '#default_value' => isset($defaults['label']['format']) ? $defaults['label']['format'] : 'above', - ); - } + $weight = isset($field['display_settings'][$order_key]) ? $field['display_settings'][$order_key] : 0; + $form[$name]['weight'] = array('#type' => 'value', '#default_value' => $weight); + $form[$name][$order_key] = array( + '#type' => 'weight', + '#default_value' => $weight, + '#delta' => 20, + ); // Formatters. $options = array(); @@ -614,6 +623,12 @@ function content_display_overview_form(& $options['hidden'] = t(''); foreach ($contexts as $key => $value) { + $form[$name][$key]['label']['format'] = array( + '#type' => 'select', + '#options' => $label_options, + '#default_value' => isset($defaults[$key]['label']['format']) ? $defaults[$key]['label']['format'] : 'above', + ); + $form[$name][$key]['format'] = array( '#type' => 'select', '#options' => $options, @@ -625,6 +640,14 @@ function content_display_overview_form(& '#options' => array(0 => t('Include'), 1 => t('Exclude')), '#default_value' => isset($defaults[$key]['exclude']) ? $defaults[$key]['exclude'] : 0, ); + + // select region + $form[$name][$key]['region'] = array( + '#type' => 'select', + '#options' => $region_options, + '#default_value' => isset($defaults[$key]['region']) ? $defaults[$key]['region'] : 0, + ); + } } Index: theme/content-admin-display-overview-form.tpl.php =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/cck/theme/Attic/content-admin-display-overview-form.tpl.php,v retrieving revision 1.1.2.3 diff -u -p -r1.1.2.3 content-admin-display-overview-form.tpl.php --- theme/content-admin-display-overview-form.tpl.php 9 Oct 2008 20:58:26 -0000 1.1.2.3 +++ theme/content-admin-display-overview-form.tpl.php 23 Jun 2009 20:49:57 -0000 @@ -1,40 +1,38 @@ -
- -
+ - - - + $value): ?> - + + + - + - - - $title): ?> + + +
format
indentation; ?>human_name; ?>label; ?> {$context}->label; ?> {$context}->format; ?> {$context}->exclude; ?> {$context}->region; ?>{$contexts_order_key}; ?>
- + \ No newline at end of file Index: theme/content-admin-field-overview-form.tpl.php =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/cck/theme/Attic/content-admin-field-overview-form.tpl.php,v retrieving revision 1.1.2.5 diff -u -p -r1.1.2.5 content-admin-field-overview-form.tpl.php --- theme/content-admin-field-overview-form.tpl.php 16 Oct 2008 14:40:54 -0000 1.1.2.5 +++ theme/content-admin-field-overview-form.tpl.php 23 Jun 2009 20:49:57 -0000 @@ -8,7 +8,6 @@ - @@ -16,6 +15,7 @@ @@ -26,7 +26,6 @@ indentation; ?> label; ?> - weight . $row->parent . $row->hidden_name; ?> field_name; ?> type; ?> configure; ?>  remove; ?> @@ -36,19 +35,10 @@ indentation; ?> label; ?> - weight . $row->parent . $row->hidden_name; ?> group_name; ?> group_type; ?> configure; ?>  remove; ?> - - indentation; ?> - label; ?> - - weight . $row->parent . $row->hidden_name; ?> - description; ?> - label; ?> -
 
weight . $row->parent . $row->hidden_name; ?>
 
field_name; ?>
 
type; ?>
 
widget_type; ?> @@ -73,7 +62,6 @@ label; ?> -
 
weight . $row->parent . $row->hidden_name; ?>
 
field_name; ?>
 
widget_type; ?> label; ?> -
 
weight . $row->parent . $row->hidden_name; ?>
 
group_name; ?>
 
group_type; ?>
 
group_option; ?> Index: theme/theme.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/cck/theme/theme.inc,v retrieving revision 1.1.2.13 diff -u -p -r1.1.2.13 theme.inc --- theme/theme.inc 28 Apr 2009 23:06:37 -0000 1.1.2.13 +++ theme/theme.inc 23 Jun 2009 20:49:57 -0000 @@ -1,6 +1,8 @@ '. t('You can add a field to a group by dragging it below and to the right of the group.'); + $vars['help'] .= '
'. t('You can add a field to a group by dragging it below and to the right of the group.'); } if (!module_exists('advanced_help')) { $vars['help'] .= '
' . t('Note: Installing the Advanced help module will let you access more and better help.', array('!adv_help' => 'http://drupal.org/project/advanced_help')); @@ -39,7 +41,7 @@ function template_preprocess_content_fie if (empty($remaining_rows) && empty($element['#depth'])) { $row = new stdClass(); $row->row_type = 'separator'; - $row->class = 'tabledrag-leaf region'; + $row->class = 'region';//'tabledrag-leaf region'; $rows[] = $row; $added_separator = TRUE; } @@ -48,8 +50,6 @@ function template_preprocess_content_fie $row = new stdClass(); // Add target classes for the tabledrag behavior. - $element['weight']['#attributes']['class'] = 'field-weight'; - $element['parent']['#attributes']['class'] = 'group-parent'; $element['hidden_name']['#attributes']['class'] = 'field-name'; // Add target classes for the update selects behavior. switch ($element['#row_type']) { @@ -58,7 +58,7 @@ function template_preprocess_content_fie $element['widget_type']['#attributes']['class'] = 'content-widget-type-select'; break; case 'add_existing_field': - $element['field_name']['#attributes']['class'] = 'content-field-select'; + $element['field_name']['#attplatform_content_display_overview_formributes']['class'] = 'content-field-select'; $element['widget_type']['#attributes']['class'] = 'content-widget-type-select'; $element['label']['#attributes']['class'] = 'content-label-textfield'; break; @@ -69,7 +69,6 @@ function template_preprocess_content_fie $row->label_class = 'label-'. strtr($element['#row_type'], '_', '-'); $row->row_type = $element['#row_type']; $row->indentation = theme('indentation', isset($element['#depth']) ? $element['#depth'] : 0); - $row->class = 'draggable'; $row->class .= isset($element['#disabled_row']) ? ' menu-disabled' : ''; $row->class .= isset($element['#add_new']) ? ' content-add-new' : ''; $row->class .= isset($element['#leaf']) ? ' tabledrag-leaf' : ''; @@ -81,12 +80,6 @@ function template_preprocess_content_fie $vars['rows'] = $rows; $vars['submit'] = drupal_render($form); - // Add tabledrag behavior. -// drupal_add_tabledrag('content-field-overview', 'match', 'parent', 'group-parent', 'group-parent', 'field-name', FALSE, 1); - drupal_add_tabledrag('content-field-overview', 'match', 'parent', 'group-parent', 'group-parent', 'field-name', TRUE, 1); -// drupal_add_tabledrag('content-field-overview', 'order', 'sibling', 'field-weight', NULL, NULL, FALSE); - drupal_add_tabledrag('content-field-overview', 'order', 'sibling', 'field-weight'); - // Add settings for the update selects behavior. $js_fields = array(); foreach (array_keys(content_existing_field_options($form['#type_name'])) as $field_name) { @@ -96,7 +89,6 @@ function template_preprocess_content_fie drupal_add_js(array('contentWidgetTypes' => content_widget_type_options(), 'contentFields' => $js_fields), 'setting'); drupal_add_js(drupal_get_path('module', 'content') .'/content.js'); } - /** * Theme preprocess function for content-admin-display-overview-form.tpl.php. */ @@ -107,15 +99,6 @@ function template_preprocess_content_dis $vars['basic'] = $contexts_selector == 'basic'; $vars['contexts'] = content_build_modes($contexts_selector); - if ($contexts_selector == 'basic') { - $help = t("Configure how this content type's fields and field labels should be displayed when it's viewed in teaser and full-page mode."); - } - else { - $help = t("Configure how this content type's fields should be displayed when it's rendered in the following contexts."); - } - $help .= ' '. t("Use the 'Exclude' checkbox to exclude an item from the !content value passed to the node template.", array('!content' => '$content')); - $vars['help'] = $help; - $order = _content_overview_order($form, $form['#fields'], $form['#groups']); if (empty($order)) { $vars['rows'] = array(); @@ -127,19 +110,41 @@ function template_preprocess_content_dis foreach ($order as $key) { $element = &$form[$key]; $row = new stdClass(); + + $element[$form['contexts_order_key']['#value']]['#attributes']['class'] = 'field-'. $form['contexts_order_key']['#value']; + foreach (element_children($element) as $child) { if (!array_key_exists('exclude', $element[$child])) { + // Process weight. + if ($child == $form['contexts_order_key']['#value']) { + $element[$child] = process_weight($element[$child]); + } $row->{$child} = drupal_render($element[$child]); } else { + $row->{$child}->label = drupal_render($element[$child]['label']); $row->{$child}->format = drupal_render($element[$child]['format']); $row->{$child}->exclude = drupal_render($element[$child]['exclude']); + $row->{$child}->region = drupal_render($element[$child]['region']); } + } + + // Add draggable. + $row->class = 'draggable'; + + // Parent. + $row->parent = 0; + $row->label_class = in_array($key, $form['#groups']) ? 'label-group' : 'label-field'; $row->indentation = theme('indentation', isset($element['#depth']) ? $element['#depth'] : 0); $rows[] = $row; } + + drupal_add_tabledrag('content-display-overview', 'order', 'sibling', 'field-'. $form['contexts_order_key']['#value']); + + $vars['contexts_order_key'] = $form['contexts_order_key']['#value']; $vars['rows'] = $rows; $vars['submit'] = drupal_render($form); + } \ No newline at end of file