summaryrefslogtreecommitdiff
path: root/modules/field
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-12-26 12:48:14 +0000
committerDries Buytaert <dries@buytaert.net>2009-12-26 12:48:14 +0000
commit814f4c8e3f739fcf3155bddf5ee9b726a165cfde (patch)
tree95f4de42961f4c1999bbf5498bfbe23bbe0d41c7 /modules/field
parent95a0f85a8053e3c2bda56a204db243a2daa95aa7 (diff)
downloadbrdo-814f4c8e3f739fcf3155bddf5ee9b726a165cfde.tar.gz
brdo-814f4c8e3f739fcf3155bddf5ee9b726a165cfde.tar.bz2
- Patch #667040 by effulgentsia: optimize template_preprocess_field().
Diffstat (limited to 'modules/field')
-rw-r--r--modules/field/field.default.inc1
-rw-r--r--modules/field/field.module16
-rw-r--r--modules/field/theme/field.tpl.php4
3 files changed, 10 insertions, 11 deletions
diff --git a/modules/field/field.default.inc b/modules/field/field.default.inc
index 2914abc1e..f26f46ba3 100644
--- a/modules/field/field.default.inc
+++ b/modules/field/field.default.inc
@@ -203,6 +203,7 @@ function field_default_view($obj_type, $object, $field, $instance, $langcode, $i
'#language' => $langcode,
'#field_name' => $field['field_name'],
'#field_type' => $field['type'],
+ '#field_translatable' => $field['translatable'],
'#object_type' => $obj_type,
'#bundle' => $bundle,
'#object' => $object,
diff --git a/modules/field/field.module b/modules/field/field.module
index f0dc6bb8e..f4dba7cbe 100644
--- a/modules/field/field.module
+++ b/modules/field/field.module
@@ -742,13 +742,11 @@ function field_extract_bundle($obj_type, $bundle) {
*/
function template_preprocess_field(&$variables) {
$element = $variables['element'];
- $instance = field_info_instance($element['#object_type'], $element['#field_name'], $element['#bundle']);
- $field = field_info_field($element['#field_name']);
// @todo Convert to using drupal_html_class() after benchmarking the impact of
// doing so.
- $field_type_css = strtr($field['type'], '_', '-');
- $field_name_css = strtr($field['field_name'], '_', '-');
+ $field_type_css = strtr($element['#field_type'], '_', '-');
+ $field_name_css = strtr($element['#field_name'], '_', '-');
// Prepare an $items variable that the template can simply loop on.
// Filter out non-children properties that might have been added if the
@@ -757,20 +755,19 @@ function template_preprocess_field(&$variables) {
$additions = array(
'object' => $element['#object'],
- 'field' => $field,
- 'instance' => $instance,
'build_mode' => $element['#build_mode'],
'items' => $items,
- 'field_type' => $field['type'],
- 'field_name' => $field['field_name'],
+ 'field_type' => $element['#field_type'],
+ 'field_name' => $element['#field_name'],
'field_type_css' => $field_type_css,
'field_name_css' => $field_name_css,
'label' => check_plain($element['#title']),
'label_display' => $element['#label_display'],
'label_hidden' => $element['#label_display'] == 'hidden',
'field_language' => $element['#language'],
- 'field_translatable' => $field['translatable'],
+ 'field_translatable' => $element['#field_translatable'],
'classes_array' => array(
+ 'field',
'field-name-' . $field_name_css,
'field-type-' . $field_type_css,
'field-label-' . $element['#label_display'],
@@ -785,6 +782,7 @@ function template_preprocess_field(&$variables) {
$variables = array_merge($variables, $additions);
// Initialize attributes for each item.
+ $variables['item_attributes_array'] = array();
foreach ($variables['items'] as $delta => $item) {
$variables['item_attributes_array'][$delta] = array();
}
diff --git a/modules/field/theme/field.tpl.php b/modules/field/theme/field.tpl.php
index 1c8be235d..069ed48fa 100644
--- a/modules/field/theme/field.tpl.php
+++ b/modules/field/theme/field.tpl.php
@@ -13,6 +13,7 @@
* CSS. It can be manipulated through the variable $classes_array from
* preprocess functions. The default values can be one or more of the
* following:
+ * - field: The current template type, i.e., "theming hook".
* - field-name-[field_name]: The current field name. For example, if the
* field name is "field_description" it would result in
* "field-name-field-description".
@@ -23,7 +24,6 @@
*
* Other variables:
* - $object: The object to which the field is attached.
- * - $field: The field array.
* - $build_mode: Build mode, e.g. 'full', 'teaser'...
* - $field_name: The field name.
* - $field_type: The field type.
@@ -38,7 +38,7 @@
* @see template_preprocess_field()
*/
?>
-<div class="field <?php print $classes; ?> clearfix"<?php print $attributes; ?>>
+<div class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>
<?php if (!$label_hidden) : ?>
<div class="field-label"<?php print $title_attributes; ?>><?php print $label ?>:&nbsp;</div>
<?php endif; ?>