summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYves Chedemois2009-06-25 00:30:37 (GMT)
committer Yves Chedemois2009-06-25 00:30:37 (GMT)
commitc24fbf9abd080cf0b74747e0e110e3740d9720d3 (patch)
tree66dc9aebf8547ed6a425922523df2822801d34f6
parentf6c3b6ec64f154c8b1d30a76d4b36ea048636ead (diff)
remove 'exclude from $content' feature.
-rw-r--r--includes/cck.admin.inc15
-rw-r--r--modules/fieldgroup/fieldgroup.module51
-rw-r--r--theme/cck-admin-display-overview-form.tpl.php4
-rw-r--r--theme/theme.inc18
4 files changed, 12 insertions, 76 deletions
diff --git a/includes/cck.admin.inc b/includes/cck.admin.inc
index 7947491..1961b2d 100644
--- a/includes/cck.admin.inc
+++ b/includes/cck.admin.inc
@@ -655,12 +655,6 @@ function cck_display_overview_form(&$form_state, $bundle, $contexts_selector = '
'#options' => $options,
'#default_value' => isset($defaults[$key]['type']) ? $defaults[$key]['type'] : 'default',
);
- // exclude from $content
- $form[$name][$key]['exclude'] = array(
- '#type' => 'checkbox',
- '#options' => array(0 => t('Include'), 1 => t('Exclude')),
- '#default_value' => isset($defaults[$key]['exclude']) ? $defaults[$key]['exclude'] : 0,
- );
}
}
@@ -696,12 +690,6 @@ function cck_display_overview_form(&$form_state, $bundle, $contexts_selector = '
'#options' => $options,
'#default_value' => isset($defaults[$key]['format']) ? $defaults[$key]['format'] : 'fieldset',
);
- // exclude in $content
- $form[$name][$key]['exclude'] = array(
- '#type' => 'checkbox',
- '#options' => array(0 => t('Include'), 1 => t('Exclude')),
- '#default_value' => isset($defaults[$key]['exclude']) ? $defaults[$key]['exclude'] : 0,
- );
}
foreach ($group['fields'] as $field_name => $field) {
$form[$field_name]['parent']['#value'] = $name;
@@ -723,9 +711,8 @@ function cck_display_overview_form_submit($form, &$form_state) {
// Groups are handled in fieldgroup_display_overview_form_submit().
if (in_array($key, $form['#fields'])) {
$instance = field_info_instance($key, $form['#bundle']);
- // We have some numeric keys here, so we can't use array_merge.
unset($values['weight'], $values['parent']);
- $instance['display'] = $values + (array) $instance['display'];
+ $instance['display'] = array_merge($instance['display'], $values);
field_update_instance($instance);
}
}
diff --git a/modules/fieldgroup/fieldgroup.module b/modules/fieldgroup/fieldgroup.module
index 0655470..b56ab31 100644
--- a/modules/fieldgroup/fieldgroup.module
+++ b/modules/fieldgroup/fieldgroup.module
@@ -151,7 +151,6 @@ function fieldgroup_group_edit_form(&$form_state, $bundle, $group_name) {
foreach (array_keys(field_build_modes(field_info_bundle_entity($bundle))) as $key) {
$form['settings']['display'][$key]['format'] = array('#type' => 'value', '#value' => isset($group['settings']['display'][$key]['format']) ? $group['settings']['display'][$key]['format'] : 'fieldset');
- $form['settings']['display'][$key]['exclude'] = array('#type' => 'value', '#value' => isset($group['settings']['display'][$key]['exclude']) ? $group['settings']['display'][$key]['exclude'] : 0);
}
$form['settings']['display']['label'] = array('#type' => 'value', '#value' => $group['settings']['display']['label']);
@@ -477,7 +476,6 @@ function field_group_default_settings($group_type, $bundle) {
module_load_include('inc', 'field', 'includes/field.admin');
foreach (array_keys(field_build_modes(field_info_bundle_entity($bundle))) as $key) {
$settings['display'][$key]['format'] = 'fieldset';
- $settings['display'][$key]['exclude'] = 0;
}
// Allow other modules to add new default settings.
$settings = array_merge($settings, module_invoke_all('fieldgroup_default_settings', $group_type));
@@ -490,8 +488,7 @@ function fieldgroup_display_overview_form_submit($form, &$form_state) {
foreach ($form_values as $key => $values) {
if (in_array($key, $form['#groups'])) {
$group = $groups[$key];
- // We have some numeric keys here, so we can't use array_merge.
- $group['settings']['display'] = $values + $group['settings']['display'];
+ $group['settings']['display'] = array_merge($group['settings']['display'], $values);
fieldgroup_save_group($form['#bundle'], $group);
}
}
@@ -571,41 +568,12 @@ function fieldgroup_view(&$node, $teaser) {
}
}
- // The wrapper lets us get the themed output for the group
- // to populate the $GROUP_NAME_rendered variable for node templates,
- // and hide it from the $content variable if needed.
- // See fieldgroup_preprocess_node(), theme_fieldgroup_wrapper().
- $wrapper = array(
- 'group' => $element,
- '#weight' => $group['weight'],
- '#post_render' => array('fieldgroup_wrapper_post_render'),
- '#group_name' => $group_name,
- '#bundle' => $node->type,
- '#context' => $context,
- );
-
- $node->content[$group_name] = $wrapper;
+ $node->content[$group_name] = $element;
}
}
break;
}
-/**
- * Hide specified fields from the $content variable in node templates.
- */
-function fieldgroup_wrapper_post_render($content, $element) {
- $groups = fieldgroup_groups($element['#bundle']);
- $group = $groups[$element['#group_name']];
-
- // The display settings are not in quite the same place in the
- // group and the field, so create the value the theme will expect.
- $group['display_settings'] = $group['settings']['display'];
- if (theme('field_exclude', $content, $group, $element['#context'])) {
- return '';
- }
- return $content;
-}
-
/*
* Get the group name for a field.
* If the field isn't in a group, FALSE will be returned.
@@ -754,18 +722,3 @@ function fieldgroup_preprocess_fieldgroup_simple(&$vars) {
'fieldgroup-simple-'. $element['#group_name'] .'-'. $element['#node']->type,
);
}
-
-/**
- * Theme preprocess function for node.
- *
- * Adds $GROUP_NAME_rendered variables,
- * containing the themed output for the whole group.
- */
-function fieldgroup_preprocess_node(&$vars) {
- $node = $vars['node'];
-
- foreach (fieldgroup_groups($node->type) as $group_name => $group) {
- // '#chilren' might not be set if the group is empty.
- $vars[$group_name .'_rendered'] = isset($node->content[$group_name]['#children']) ? $node->content[$group_name]['#children'] : '';
- }
-} \ No newline at end of file
diff --git a/theme/cck-admin-display-overview-form.tpl.php b/theme/cck-admin-display-overview-form.tpl.php
index 9e13d54..09ac0e3 100644
--- a/theme/cck-admin-display-overview-form.tpl.php
+++ b/theme/cck-admin-display-overview-form.tpl.php
@@ -10,7 +10,7 @@
<tr>
<th>&nbsp;</th>
<?php foreach ($contexts as $key => $value): ?>
- <th colspan="3"><?php print $value; ?>
+ <th colspan="2"><?php print $value; ?>
<?php endforeach; ?>
</tr>
<tr>
@@ -18,7 +18,6 @@
<?php foreach ($contexts as $key => $value): ?>
<th><?php print t('Label'); ?></th>
<th><?php print t('Format'); ?></th>
- <th><?php print t('Exclude'); ?></th>
<?php endforeach; ?>
</tr>
</thead>
@@ -31,7 +30,6 @@
<?php foreach ($contexts as $context => $title): ?>
<td><?php print $row->{$context}->label; ?></td>
<td><?php print $row->{$context}->type; ?></td>
- <td><?php print $row->{$context}->exclude; ?></td>
<?php endforeach; ?>
</tr>
<?php $count++;
diff --git a/theme/theme.inc b/theme/theme.inc
index b21a514..b2bb84c 100644
--- a/theme/theme.inc
+++ b/theme/theme.inc
@@ -8,18 +8,19 @@
function template_preprocess_cck_field_overview_form(&$vars) {
$form = &$vars['form'];
+ // TODO D7: abstract texts over bundles / entity types
switch ($form['#bundle']) {
case 'user':
$vars['help'] = theme('advanced_help_topic', 'cck', 'manage-user-fields') . t('Add fields to the user, and arrange them on user display and input forms.');
break;
default:
$vars['help'] = theme('advanced_help_topic', 'cck', 'manage-fields') . t('Add fields to the Content type, and arrange them on content display and input forms.');
-
}
if (module_exists('fieldgroup')) {
$vars['help'] .= '<br>'. 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')) {
+ // TODO D7
//$vars['help'] .= '<br/>' . t('Note: Installing the <a href="!adv_help">Advanced help</a> module will let you access more and better help.', array('!adv_help' => 'http://drupal.org/project/advanced_help'));
}
@@ -89,9 +90,7 @@ function template_preprocess_cck_field_overview_form(&$vars) {
$vars['submit'] = drupal_render_children($form);
// Add tabledrag behavior.
-// drupal_add_tabledrag('cck-field-overview', 'match', 'parent', 'group-parent', 'group-parent', 'field-name', FALSE, 1);
drupal_add_tabledrag('cck-field-overview', 'match', 'parent', 'group-parent', 'group-parent', 'field-name', TRUE, 1);
-// drupal_add_tabledrag('cck-field-overview', 'order', 'sibling', 'field-weight', NULL, NULL, FALSE);
drupal_add_tabledrag('cck-field-overview', 'order', 'sibling', 'field-weight');
// Add settings for the update selects behavior.
@@ -117,9 +116,10 @@ function template_preprocess_cck_display_overview_form(&$vars) {
$vars['contexts'] = cck_build_modes(field_info_bundle_entity($form['#bundle']), $contexts_selector);
+ // TODO D7: abstract texts over bundles / entity types
switch ($form['#bundle']) {
case 'user':
- $help = t("Configure how user fields and field labels should be displayed. Use the 'Exclude' checkbox to exclude an item from the !content value passed to the user template.", array('!content' => '$user_profile'));
+ $help = t('Configure how user fields and field labels should be displayed.');
break;
default:
@@ -129,7 +129,6 @@ function template_preprocess_cck_display_overview_form(&$vars) {
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;
@@ -145,13 +144,12 @@ function template_preprocess_cck_display_overview_form(&$vars) {
$element = &$form[$key];
$row = new stdClass();
foreach (element_children($element) as $child) {
- if (!array_key_exists('exclude', $element[$child])) {
- $row->{$child} = drupal_render($element[$child]);
- }
- else {
+ if (array_key_exists('label', $element[$child])) {
$row->{$child}->label = drupal_render($element[$child]['label']);
$row->{$child}->type = drupal_render($element[$child]['type']);
- $row->{$child}->exclude = drupal_render($element[$child]['exclude']);
+ }
+ else {
+ $row->{$child} = drupal_render($element[$child]);
}
}
$row->label_class = in_array($key, $form['#groups']) ? 'label-group' : 'label-field';