summaryrefslogtreecommitdiff
path: root/modules/field
diff options
context:
space:
mode:
Diffstat (limited to 'modules/field')
-rw-r--r--modules/field/field.api.php6
-rw-r--r--modules/field/field.attach.inc12
-rw-r--r--modules/field/field.default.inc35
-rw-r--r--modules/field/field.module16
-rw-r--r--modules/field/modules/text/text.module13
-rw-r--r--modules/field/theme/field.tpl.php2
6 files changed, 32 insertions, 52 deletions
diff --git a/modules/field/field.api.php b/modules/field/field.api.php
index 24f5e5839..4accf941f 100644
--- a/modules/field/field.api.php
+++ b/modules/field/field.api.php
@@ -657,10 +657,10 @@ function hook_field_attach_delete_revision($obj_type, $object) {
* The type of $object; e.g. 'node' or 'user'.
* @param $object
* The object with fields to render.
- * @param $teaser
- * Whether to display the teaser only, as on the main page.
+ * @param $build_mode
+ * Build mode, e.g. 'full', 'teaser'...
*/
-function hook_field_attach_view_alter($output, $obj_type, $object, $teaser) {
+function hook_field_attach_view_alter($output, $obj_type, $object, $build_mode) {
}
/**
diff --git a/modules/field/field.attach.inc b/modules/field/field.attach.inc
index db5c59935..523855793 100644
--- a/modules/field/field.attach.inc
+++ b/modules/field/field.attach.inc
@@ -149,7 +149,7 @@ define('FIELD_STORAGE_INSERT', 'insert');
* The fully formed $obj_type object.
* @param $a
* - The $form in the 'form' operation.
- * - The value of $teaser in the 'view' operation.
+ * - The value of $build_mode in the 'view' operation.
* - Otherwise NULL.
* @param $b
* - The $form_state in the 'submit' operation.
@@ -883,19 +883,19 @@ function field_attach_query_revisions($field_name, $conditions, $result_format =
* The type of $object; e.g. 'node' or 'user'.
* @param $object
* The object with fields to render.
- * @param $teaser
- * Whether to display the teaser only, as on the main page.
+ * @param $build_mode
+ * Build mode, e.g. 'full', 'teaser'...
* @return
* A structured content array tree for drupal_render().
*/
-function field_attach_view($obj_type, $object, $teaser = FALSE) {
+function field_attach_view($obj_type, $object, $build_mode = 'full') {
// Let field modules sanitize their data for output.
_field_invoke('sanitize', $obj_type, $object);
- $output = _field_invoke_default('view', $obj_type, $object, $teaser);
+ $output = _field_invoke_default('view', $obj_type, $object, $build_mode);
// Let other modules make changes after rendering the view.
- drupal_alter('field_attach_view', $output, $obj_type, $object, $teaser);
+ drupal_alter('field_attach_view', $output, $obj_type, $object, $build_mode);
return $output;
diff --git a/modules/field/field.default.inc b/modules/field/field.default.inc
index f60693676..f0bcc4dc3 100644
--- a/modules/field/field.default.inc
+++ b/modules/field/field.default.inc
@@ -76,8 +76,8 @@ function field_default_insert($obj_type, $object, $field, $instance, &$items) {
* '#field_name' => 'field_name',
* '#object' => $object,
* '#object_type' => $obj_type,
- * // Value of the $teaser param of hook_node('view').
- * '#teaser' => $teaser,
+ * // Value of the $build_mode param of hook_node('view').
+ * '#build_mode' => $build_mode,
* 'items' =>
* 0 => array(
* '#item' => $items[0],
@@ -112,27 +112,14 @@ function field_default_insert($obj_type, $object, $field, $instance, &$items) {
* ),
* );
*/
-function field_default_view($obj_type, $object, $field, $instance, $items, $teaser) {
+function field_default_view($obj_type, $object, $field, $instance, $items, $build_mode) {
list($id, $vid, $bundle) = field_attach_extract_ids($obj_type, $object);
$addition = array();
- // Entities without build modes should provide a 'full' context.
- // NODE_BUILD_NORMAL is 0, and ('whatever' == 0) is TRUE, so we need a ===.
- if (!isset($object->build_mode)) {
- $context = 'full';
- }
- elseif ($object->build_mode === NODE_BUILD_NORMAL
- || $object->build_mode == NODE_BUILD_PREVIEW) {
- $context = $teaser ? 'teaser' : 'full';
- }
- else {
- $context = $object->build_mode;
- }
-
// If we don't have specific settings for the current build_mode, we use the
// (required) 'full' build_mode.
- $display = isset($instance['display'][$context]) ? $instance['display'][$context] : $instance['display']['full'];
+ $display = isset($instance['display'][$build_mode]) ? $instance['display'][$build_mode] : $instance['display']['full'];
// Ensure we have a valid formatter and formatter settings.
$display = _field_get_formatter($display, $field);
@@ -141,7 +128,7 @@ function field_default_view($obj_type, $object, $field, $instance, $items, $teas
$single = (field_behaviors_formatter('multiple values', $display) == FIELD_BEHAVIOR_DEFAULT);
$label_display = $display['label'];
- if (isset($object->build_mode) && $object->build_mode == NODE_BUILD_SEARCH_INDEX) {
+ if ($build_mode == 'search_index') {
$label_display = 'hidden';
}
@@ -157,7 +144,7 @@ function field_default_view($obj_type, $object, $field, $instance, $items, $teas
'#title' => check_plain(t($instance['label'])),
'#access' => field_access('view', $field),
'#label_display' => $label_display,
- '#teaser' => $teaser,
+ '#build_mode' => $build_mode,
'#single' => $single,
'items' => array(),
);
@@ -196,7 +183,7 @@ function field_default_view($obj_type, $object, $field, $instance, $items, $teas
'field' => $element,
'#weight' => $instance['weight'],
'#post_render' => array('field_wrapper_post_render'),
- '#context' => $context,
+ '#build_mode' => $build_mode,
);
$addition = array($field['field_name'] => $wrapper);
@@ -209,7 +196,7 @@ function field_default_view($obj_type, $object, $field, $instance, $items, $teas
*/
function field_wrapper_post_render($content, $element) {
$instance = field_info_instance($element['#field_name'], $element['#bundle']);
- if (theme('field_exclude', $content, $instance, $element['#context'])) {
+ if (theme('field_exclude', $content, $instance, $element['#build_mode'])) {
return '';
}
return $content;
@@ -231,10 +218,10 @@ function field_wrapper_post_render($content, $element) {
* 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, $context) {
+function theme_field_exclude($content, $object, $build_mode) {
if (empty($object['display'])
- || empty($object['display'][$context])
- || empty($object['display'][$context]['exclude'])) {
+ || empty($object['display'][$build_mode])
+ || empty($object['display'][$build_mode]['exclude'])) {
return FALSE;
}
else {
diff --git a/modules/field/field.module b/modules/field/field.module
index f518169f9..ef1fb1e5d 100644
--- a/modules/field/field.module
+++ b/modules/field/field.module
@@ -482,8 +482,7 @@ function field_format($obj_type, $object, $field, $item, $formatter_name = NULL,
* $FIELD_NAME_rendered variables instead.
*
* By default, the field is displayed using the settings defined for the
- * 'full' or 'teaser' contexts (depending on the value of the $teaser param).
- * Set $node->build_mode to a different value to use a different context.
+ * 'full' or 'teaser' contexts (depending on the value of the $build_mode param).
*
* Different settings can be specified by adjusting $field['display'].
*
@@ -492,19 +491,16 @@ function field_format($obj_type, $object, $field, $item, $formatter_name = NULL,
* @param $object
* The object containing the field to display. Must at least contain the id key,
* revision key (if applicable), bundle key, and the field data.
- * @param $teaser
- * Similar to hook_node('view')
+ * @param $build_mode
+ * Build mode, e.g. 'full', 'teaser'...
* @return
* The themed output for the field.
*/
-function field_view_field($obj_type, $object, $field, $instance, $teaser = FALSE) {
+function field_view_field($obj_type, $object, $field, $instance, $build_mode = 'full') {
$output = '';
if (isset($object->$field['field_name'])) {
$items = $object->$field['field_name'];
- // Use 'full'/'teaser' if not specified otherwise.
- $object->build_mode = isset($object->build_mode) ? $object->build_mode : NODE_BUILD_NORMAL;
-
// One-field equivalent to _field_invoke('sanitize').
$function = $field['module'] . '_field_sanitize';
if (drupal_function_exists($function)) {
@@ -512,7 +508,7 @@ function field_view_field($obj_type, $object, $field, $instance, $teaser = FALSE
$object->$field['field_name'] = $items;
}
- $view = field_default_view($obj_type, $object, $field, $instance, $items, $teaser);
+ $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'
@@ -594,7 +590,7 @@ function template_preprocess_field(&$variables) {
$variables['items'][0]['view'] = drupal_render_children($element, array('items'));
}
- $variables['teaser'] = $element['#teaser'];
+ $variables['build_mode'] = $element['#build_mode'];
$variables['page'] = (bool)menu_get_object();
$field_empty = TRUE;
diff --git a/modules/field/modules/text/text.module b/modules/field/modules/text/text.module
index 00ba52017..fe6e1da80 100644
--- a/modules/field/modules/text/text.module
+++ b/modules/field/modules/text/text.module
@@ -176,12 +176,10 @@ function text_field_load($obj_type, $objects, $field, $instances, &$items) {
// handled by text_field_sanitize().
$format = $item['format'];
if (filter_format_allowcache($format)) {
- // TODO D7 : this code is really node-related.
- $check = is_null($object) || (isset($object->build_mode) && $object->build_mode == NODE_BUILD_PREVIEW);
$lang = isset($object->language) ? $object->language : $language->language;
- $items[$id][$delta]['safe'] = isset($item['value']) ? check_markup($item['value'], $format, $lang, $check, FALSE) : '';
+ $items[$id][$delta]['safe'] = isset($item['value']) ? check_markup($item['value'], $format, $lang, FALSE, FALSE) : '';
if ($field['type'] == 'text_with_summary') {
- $items[$id][$delta]['safe_summary'] = isset($item['summary']) ? check_markup($item['summary'], $format, $lang, $check, FALSE) : '';
+ $items[$id][$delta]['safe_summary'] = isset($item['summary']) ? check_markup($item['summary'], $format, $lang, FALSE, FALSE) : '';
}
}
}
@@ -209,12 +207,10 @@ function text_field_sanitize($obj_type, $object, $field, $instance, &$items) {
if (!isset($items[$delta]['safe'])) {
if (!empty($instance['settings']['text_processing'])) {
$format = $item['format'];
- // TODO D7 : this code is really node-related.
- $check = is_null($object) || (isset($object->build_mode) && $object->build_mode == NODE_BUILD_PREVIEW);
$lang = isset($object->language) ? $object->language : $language->language;
- $items[$delta]['safe'] = isset($item['value']) ? check_markup($item['value'], $format, $lang, $check) : '';
+ $items[$delta]['safe'] = isset($item['value']) ? check_markup($item['value'], $format, $lang, FALSE) : '';
if ($field['type'] == 'text_with_summary') {
- $items[$delta]['safe_summary'] = isset($item['summary']) ? check_markup($item['summary'], $format, $lang, $check) : '';
+ $items[$delta]['safe_summary'] = isset($item['summary']) ? check_markup($item['summary'], $format, $lang, FALSE) : '';
}
}
else {
@@ -770,3 +766,4 @@ function theme_text_textarea_with_summary($element) {
return $element['#children'];
}
}
+
diff --git a/modules/field/theme/field.tpl.php b/modules/field/theme/field.tpl.php
index 037d4380c..efa629da1 100644
--- a/modules/field/theme/field.tpl.php
+++ b/modules/field/theme/field.tpl.php
@@ -9,7 +9,7 @@
* - $object: The object to which the field is attached.
* - $field: The field array.
* - $items: An array of values for each item in the field array.
- * - $teaser: Whether this is displayed as a teaser.
+ * - $build_mode: Build mode, e.g. 'full', 'teaser'...
* - $page: Whether this is displayed as a page.
* - $field_name: The field name.
* - $field_type: The field type.