diff options
Diffstat (limited to 'modules/field')
-rw-r--r-- | modules/field/field.attach.inc | 11 | ||||
-rw-r--r-- | modules/field/field.crud.inc | 5 | ||||
-rw-r--r-- | modules/field/field.default.inc | 60 | ||||
-rw-r--r-- | modules/field/field.module | 11 | ||||
-rw-r--r-- | modules/field/field.test | 16 |
5 files changed, 4 insertions, 99 deletions
diff --git a/modules/field/field.attach.inc b/modules/field/field.attach.inc index 523855793..63d2005ea 100644 --- a/modules/field/field.attach.inc +++ b/modules/field/field.attach.inc @@ -902,17 +902,6 @@ function field_attach_view($obj_type, $object, $build_mode = 'full') { } /** - * To be called in entity preprocessor. - * - * - Adds $FIELD_NAME_rendered variables - * containing the themed output for the whole field. - * - Adds the formatted values in the 'view' key of the items. - */ -function field_attach_preprocess($obj_type, $object) { - return _field_invoke_default('preprocess', $obj_type, $object); -} - -/** * Implement hook_node_prepare_translation. * * TODO D7: We do not yet know if this really belongs in Field API. diff --git a/modules/field/field.crud.inc b/modules/field/field.crud.inc index 956122ecf..9dc190d50 100644 --- a/modules/field/field.crud.inc +++ b/modules/field/field.crud.inc @@ -145,8 +145,6 @@ * - label (string) * Position of the label. 'inline', 'above' and 'hidden' are the * values recognized by the default 'field' theme implementation. - * - exclude (integer) - * TODO This is subject to change, see: http://drupal.org/node/367215 * - type (string) * The type of the display formatter to use for the field in * this context. @@ -405,8 +403,6 @@ function field_delete_field($field_name) { * Settings for the 'full' build mode will be added, and each build mode * will be completed with the follwong default values: * - label: 'above' - * - exclude: FALSE - * TODO This is subject to change, see: http://drupal.org/node/367215 * - type: the default formatter specified in hook_field_info(). * - settings: each omitted setting is given the default value specified in * hook_field_formatter_info(). @@ -540,7 +536,6 @@ function _field_write_instance($instance, $update = FALSE) { foreach ($instance['display'] as $context => $display) { $instance['display'][$context] += array( 'label' => 'above', - 'exclude' => 0, // TODO: what if no 'default_formatter' specified ? 'type' => $field_type['default_formatter'], 'settings' => array(), diff --git a/modules/field/field.default.inc b/modules/field/field.default.inc index f0bcc4dc3..daac08fa0 100644 --- a/modules/field/field.default.inc +++ b/modules/field/field.default.inc @@ -70,7 +70,7 @@ function field_default_insert($obj_type, $object, $field, $instance, &$items) { * designated as such in formatter_info(). * * The $object array will look like: - * $object->content['field_foo']['wrapper'] = array( + * $object->content['field_foo'] = array( * '#theme' => 'field', * '#title' => 'label' * '#field_name' => 'field_name', @@ -141,6 +141,7 @@ function field_default_view($obj_type, $object, $field, $instance, $items, $buil $element = $info + array( '#theme' => 'field', + '#weight' => $instance['weight'], '#title' => check_plain(t($instance['label'])), '#access' => field_access('view', $field), '#label_display' => $label_display, @@ -175,66 +176,11 @@ function field_default_view($obj_type, $object, $field, $instance, $items, $buil $element['items'] += $format_info; } - // The wrapper lets us get the themed output for the whole field - // to populate the $FIELD_NAME_rendered variable for templates, - // and hide it from the $content variable if needed. - // See 'preprocess' op and theme_content_field_wrapper(). - $wrapper = $info + array( - 'field' => $element, - '#weight' => $instance['weight'], - '#post_render' => array('field_wrapper_post_render'), - '#build_mode' => $build_mode, - ); - - $addition = array($field['field_name'] => $wrapper); + $addition = array($field['field_name'] => $element); } return $addition; } -/** - * Hide excluded fields from the $content variable in templates. - */ -function field_wrapper_post_render($content, $element) { - $instance = field_info_instance($element['#field_name'], $element['#bundle']); - if (theme('field_exclude', $content, $instance, $element['#build_mode'])) { - return ''; - } - return $content; -} - -/** - * 'Theme' function for a field's addition to the combined template output, - * i.e. the node's $content or the user's $user_profile value. - * This allows more flexibility in templates : you can use custom markup - * around a few specific fields, and print the rest normally. - * - * This is a theme function, so it can be overridden in different - * themes to produce different results. - * - * The html for individual fields are available in the $FIELD_NAME_rendered - * variables. - * - * @return - * Whether or not the field's content is to be added in this context. - * Uses the 'exclude' value from the field's display settings. - */ -function theme_field_exclude($content, $object, $build_mode) { - if (empty($object['display']) - || empty($object['display'][$build_mode]) - || empty($object['display'][$build_mode]['exclude'])) { - return FALSE; - } - else { - return TRUE; - } -} - -function field_default_preprocess($obj_type, $object, $field, $instance, &$items) { - return array( - $field['field_name'] . '_rendered' => isset($object->content[$field['field_name']]['#children']) ? $object->content[$field['field_name']]['#children'] : '', - ); -} - function field_default_prepare_translation($obj_type, $object, $field, $instance, &$items) { $addition = array(); if (isset($object->translation_source->$field['field_name'])) { diff --git a/modules/field/field.module b/modules/field/field.module index ef1fb1e5d..6b5d184cd 100644 --- a/modules/field/field.module +++ b/modules/field/field.module @@ -169,13 +169,6 @@ function field_theme() { 'arguments' => array('element' => NULL), 'path' => $path, ), - // TODO D7 : do we need exclude in core? See [#367215]. - // This is just adding '#post_render' => array('field_wrapper_post_render') - // at the right places in the render array generated by field_default_view(). - // Can be done in hook_field_attach_post_view if we want. - 'field_exclude' => array( - 'arguments' => array('content' => NULL, 'object' => array(), 'context' => NULL), - ), 'field_multiple_value_form' => array( 'arguments' => array('element' => NULL), ), @@ -511,9 +504,7 @@ function field_view_field($obj_type, $object, $field, $instance, $build_mode = ' $view = field_default_view($obj_type, $object, $field, $instance, $items, $build_mode); // TODO : what about hook_field_attach_view ? - // field_default_view() adds a wrapper to handle variables and 'excluded' - // fields for node templates. We bypass it and return the actual field. - $output = $view[$field['field_name']]['field']; + $output = $view[$field['field_name']]; } return $output; } diff --git a/modules/field/field.test b/modules/field/field.test index 1ac788098..ee816c0aa 100644 --- a/modules/field/field.test +++ b/modules/field/field.test @@ -491,18 +491,11 @@ class FieldAttachTestCase extends DrupalWebTestCase { field_update_instance($this->instance); $entity->content = field_attach_view($entity_type, $entity); $output = drupal_render($entity->content); - $variables = field_attach_preprocess($entity_type, $entity); - $variable = $this->instance['field_name'] . '_rendered'; - $this->assertTrue(isset($variables[$variable]), "Variable $variable is available in templates."); $this->content = $output; $this->assertRaw($this->instance['label'], "Label is displayed."); - $this->content = $variables[$variable]; - $this->assertRaw($this->instance['label'], "Label is displayed (template variable)."); foreach ($values as $delta => $value) { $this->content = $output; $this->assertRaw("$formatter_setting|{$value['value']}", "Value $delta is displayed, formatter settings are applied."); - $this->content = $variables[$variable]; - $this->assertRaw("$formatter_setting|{$value['value']}", "Value $delta is displayed, formatter settings are applied (template variable)."); } // Label hidden. @@ -510,11 +503,8 @@ class FieldAttachTestCase extends DrupalWebTestCase { field_update_instance($this->instance); $entity->content = field_attach_view($entity_type, $entity); $output = drupal_render($entity->content); - $variables = field_attach_preprocess($entity_type, $entity); $this->content = $output; $this->assertNoRaw($this->instance['label'], "Hidden label: label is not displayed."); - $this->content = $variables[$variable]; - $this->assertNoRaw($this->instance['label'], "Hidden label: label is not displayed (template variable)."); // Field hidden. $this->instance['display'] = array( @@ -526,8 +516,6 @@ class FieldAttachTestCase extends DrupalWebTestCase { field_update_instance($this->instance); $entity->content = field_attach_view($entity_type, $entity); $output = drupal_render($entity->content); - $variables = field_attach_preprocess($entity_type, $entity); - $this->assertTrue(isset($variables[$variable]), "Hidden field: variable $variable is available in templates."); $this->content = $output; $this->assertNoRaw($this->instance['label'], "Hidden field: label is not displayed."); foreach ($values as $delta => $value) { @@ -548,18 +536,14 @@ class FieldAttachTestCase extends DrupalWebTestCase { field_update_instance($this->instance); $entity->content = field_attach_view($entity_type, $entity); $output = drupal_render($entity->content); - $variables = field_attach_preprocess($entity_type, $entity); $display = $formatter_setting; foreach ($values as $delta => $value) { $display .= "|$delta:{$value['value']}"; } $this->content = $output; $this->assertRaw($display, "Multiple formatter: all values are displayed, formatter settings are applied."); - $this->content = $variables[$variable]; - $this->assertRaw($display, "Multiple formatter: all values are displayed, formatter settings are applied (template variable)."); // TODO: - // - check that the 'exclude' option works (if we keep it in core) // - check display order with several fields } |