? .cache
? .settings
Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.1067
diff -u -p -r1.1067 common.inc
--- includes/common.inc	21 Dec 2009 07:58:59 -0000	1.1067
+++ includes/common.inc	21 Dec 2009 20:50:46 -0000
@@ -6328,6 +6328,7 @@ function entity_get_info($entity_type = 
 function entity_info_cache_clear() {
   drupal_static_reset('entity_get_info');
   cache_clear_all('entity_info', 'cache');
+  drupal_static_reset('entity_view_mode_info');
 }
 
 /**
@@ -6388,6 +6389,29 @@ function entity_create_stub_entity($enti
 }
 
 /**
+ * Returns informations about view modes for an entity type.
+ *
+ * @see hook_entity_view_mode_info()
+ * @see hook_entity_view_mode_info_alter()
+ *
+ * @param $entity_type
+ *   The entity type; e.g. 'node' or 'user'.
+ *
+ * @return
+ *   The array of view modes available for the entity type.
+ */
+function entity_view_mode_info($entity_type) {
+  $info = &drupal_static(__FUNCTION__, NULL);
+
+  if (!isset($info)) {
+    $info = module_invoke_all('entity_view_mode_info');
+    drupal_alter('entity_view_mode_info', $info);
+  }
+
+  return (isset($info[$entity_type]) ? $info[$entity_type] : array());
+}
+
+/**
  * Load entities from the database.
  *
  * This function should be used whenever you need to load more than one entity
Index: modules/blog/blog.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/blog/blog.module,v
retrieving revision 1.346
diff -u -p -r1.346 blog.module
--- modules/blog/blog.module	17 Dec 2009 19:22:25 -0000	1.346
+++ modules/blog/blog.module	21 Dec 2009 20:00:05 -0000
@@ -66,7 +66,7 @@ function blog_form($node, $form_state) {
 /**
  * Implements hook_view().
  */
-function blog_view($node, $build_mode) {
+function blog_view($node, $view_mode) {
   if ((bool)menu_get_object()) {
     // Breadcrumb navigation.
     drupal_set_breadcrumb(array(l(t('Home'), NULL), l(t('Blogs'), 'blog'), l(t("!name's blog", array('!name' => format_username($node))), 'blog/' . $node->uid)));
@@ -77,8 +77,8 @@ function blog_view($node, $build_mode) {
 /**
  * Implements hook_node_view().
  */
-function blog_node_view($node, $build_mode = 'full') {
-  if ($build_mode != 'rss') {
+function blog_node_view($node, $view_mode = 'full') {
+  if ($view_mode != 'rss') {
     if ($node->type == 'blog' && arg(0) != 'blog' || arg(1) != $node->uid) {
       $links['blog_usernames_blog'] = array(
         'title' => t("!username's blog", array('!username' => format_username($node))),
Index: modules/book/book.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/book/book.module,v
retrieving revision 1.531
diff -u -p -r1.531 book.module
--- modules/book/book.module	21 Dec 2009 13:47:31 -0000	1.531
+++ modules/book/book.module	21 Dec 2009 20:00:06 -0000
@@ -87,11 +87,11 @@ function book_permission() {
 /**
  * Inject links into $node as needed.
  */
-function book_node_view_link($node, $build_mode) {
+function book_node_view_link($node, $view_mode) {
   $links = array();
 
   if (isset($node->book['depth'])) {
-    if ($build_mode == 'full') {
+    if ($view_mode == 'full') {
       $child_type = variable_get('book_child_type', 'book');
       if ((user_access('add content to books') || user_access('administer book outlines')) && node_access('create', $child_type) && $node->status == 1 && $node->book['depth'] < MENU_MAX_DEPTH) {
         $links['book_add_child'] = array(
@@ -220,15 +220,15 @@ function book_init() {
 }
 
 /**
- * Implements hook_field_build_modes().
+ * Implements hook_entity_view_mode_info().
  */
-function book_field_build_modes($obj_type) {
-  $modes = array();
-  if ($obj_type == 'node') {
-    $modes = array(
-      'print' => t('Print'),
-    );
-  }
+function book_entity_view_mode_info() {
+  $modes['node'] = array(
+    'print' => array(
+      'label' => t('Print'),
+    ),
+  );
+
   return $modes;
 }
 
@@ -759,8 +759,8 @@ function book_node_load($nodes, $types) 
 /**
  * Implements hook_node_view().
  */
-function book_node_view($node, $build_mode) {
-  if ($build_mode == 'full') {
+function book_node_view($node, $view_mode) {
+  if ($view_mode == 'full') {
     if (!empty($node->book['bid']) && empty($node->in_preview)) {
       $node->content['book_navigation'] = array(
         '#markup' => theme('book_navigation', array('book_link' => $node->book)),
@@ -769,8 +769,8 @@ function book_node_view($node, $build_mo
     }
   }
 
-  if ($build_mode != 'rss') {
-    book_node_view_link($node, $build_mode);
+  if ($view_mode != 'rss') {
+    book_node_view_link($node, $view_mode);
   }
 }
 
Index: modules/comment/comment.api.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.api.php,v
retrieving revision 1.14
diff -u -p -r1.14 comment.api.php
--- modules/comment/comment.api.php	21 Dec 2009 13:47:32 -0000	1.14
+++ modules/comment/comment.api.php	21 Dec 2009 19:56:29 -0000
@@ -91,7 +91,7 @@ function hook_comment_view($comment) {
  */
 function hook_comment_view_alter($build) {
   // Check for the existence of a field added by another module.
-  if ($build['#build_mode'] == 'full' && isset($build['an_additional_field'])) {
+  if ($build['#view_mode'] == 'full' && isset($build['an_additional_field'])) {
     // Change its weight.
     $build['an_additional_field']['#weight'] = -10;
   }
Index: modules/comment/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v
retrieving revision 1.819
diff -u -p -r1.819 comment.module
--- modules/comment/comment.module	21 Dec 2009 13:47:32 -0000	1.819
+++ modules/comment/comment.module	21 Dec 2009 20:13:21 -0000
@@ -484,11 +484,11 @@ function theme_comment_block() {
 /**
  * Implements hook_node_view().
  */
-function comment_node_view($node, $build_mode) {
+function comment_node_view($node, $view_mode) {
   $links = array();
 
   if ($node->comment) {
-    if ($build_mode == 'rss') {
+    if ($view_mode == 'rss') {
       if ($node->comment != COMMENT_NODE_HIDDEN) {
         // Add a comments RSS element which is a URL to the comments of this node.
         $node->rss_elements[] = array(
@@ -497,7 +497,7 @@ function comment_node_view($node, $build
         );
       }
     }
-    elseif ($build_mode == 'teaser') {
+    elseif ($view_mode == 'teaser') {
       // Main page: display the number of comments that have been posted.
       if (user_access('access comments')) {
         if (!empty($node->comment_count)) {
@@ -576,7 +576,7 @@ function comment_node_view($node, $build
     // Only append comments when we are building a node on its own node detail
     // page. We compare $node and $page_node to ensure that comments are not
     // appended to other nodes shown on the page, for example a node_reference
-    // displayed in 'full' build mode within another node.
+    // displayed in 'full' view mode within another node.
     $page_node = menu_get_object();
     if ($node->comment && isset($page_node->nid) && $page_node->nid == $node->nid && empty($node->in_preview) && user_access('access comments')) {
       $node->content['comments'] = comment_node_page_additions($node);
@@ -779,15 +779,15 @@ function comment_prepare_thread(&$commen
  *   A comment object.
  * @param $node
  *   The node the comment is attached to.
- * @param $build_mode
- *   Build mode, e.g. 'full', 'teaser'...
+ * @param $view_mode
+ *   View mode, e.g. 'full', 'teaser'...
  *
  * @return
  *   An array as expected by drupal_render().
  */
-function comment_view($comment, $node, $build_mode = 'full') {
+function comment_view($comment, $node, $view_mode = 'full') {
   // Populate $comment->content with a render() array.
-  comment_build_content($comment, $node, $build_mode);
+  comment_build_content($comment, $node, $view_mode);
 
   $build = $comment->content;
   // We don't need duplicate rendering info in comment->content.
@@ -797,7 +797,7 @@ function comment_view($comment, $node, $
     '#theme' => 'comment',
     '#comment' => $comment,
     '#node' => $node,
-    '#build_mode' => $build_mode,
+    '#view_mode' => $view_mode,
   );
 
   $prefix = '';
@@ -832,16 +832,16 @@ function comment_view($comment, $node, $
  * Builds a structured array representing the comment's content.
  *
  * The content built for the comment (field values, comments, file attachments or
- * other comment components) will vary depending on the $build_mode parameter.
+ * other comment components) will vary depending on the $view_mode parameter.
  *
  * @param $comment
  *   A comment object.
  * @param $node
  *   The node the comment is attached to.
- * @param $build_mode
- *   Build mode, e.g. 'full', 'teaser'...
+ * @param $view_mode
+ *   View mode, e.g. 'full', 'teaser'...
  */
-function comment_build_content($comment, $node, $build_mode = 'full') {
+function comment_build_content($comment, $node, $view_mode = 'full') {
   // Remove previously built content, if exists.
   $comment->content = array();
 
@@ -851,8 +851,8 @@ function comment_build_content($comment,
   );
 
   // Build fields content.
-  field_attach_prepare_view('comment', array($comment->cid => $comment), $build_mode);
-  $comment->content += field_attach_view('comment', $comment, $build_mode);
+  field_attach_prepare_view('comment', array($comment->cid => $comment), $view_mode);
+  $comment->content += field_attach_view('comment', $comment, $view_mode);
 
   if (empty($comment->in_preview)) {
     $comment->content['links']['comment'] = array(
@@ -863,7 +863,7 @@ function comment_build_content($comment,
   }
 
   // Allow modules to make their own additions to the comment.
-  module_invoke_all('comment_view', $comment, $build_mode);
+  module_invoke_all('comment_view', $comment, $view_mode);
 }
 
 /**
@@ -934,21 +934,21 @@ function comment_links($comment, $node) 
  *   An array of comments as returned by comment_load_multiple().
  * @param $node
  *   The node the comments are attached to.
- * @param $build_mode
- *   Build mode, e.g. 'full', 'teaser'...
+ * @param $view_mode
+ *   View mode, e.g. 'full', 'teaser'...
  * @param $weight
  *   An integer representing the weight of the first comment in the list.
  * @return
  *   An array in the format expected by drupal_render().
  */
-function comment_view_multiple($comments, $node, $build_mode = 'full', $weight = 0) {
-  field_attach_prepare_view('comment', $comments, $build_mode);
+function comment_view_multiple($comments, $node, $view_mode = 'full', $weight = 0) {
+  field_attach_prepare_view('comment', $comments, $view_mode);
 
   $build = array(
     '#sorted' => TRUE,
   );
   foreach ($comments as $comment) {
-    $build[$comment->cid] = comment_view($comment, $node, $build_mode);
+    $build[$comment->cid] = comment_view($comment, $node, $view_mode);
     $build[$comment->cid]['#weight'] = $weight;
     $weight++;
   }
@@ -1409,7 +1409,7 @@ function comment_save($comment) {
   catch (Exception $e) {
     $transaction->rollback('comment', $e->getMessage(), array(), WATCHDOG_ERROR);
   }
-  
+
 }
 
 /**
Index: modules/field/field.api.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/field.api.php,v
retrieving revision 1.56
diff -u -p -r1.56 field.api.php
--- modules/field/field.api.php	21 Dec 2009 13:47:32 -0000	1.56
+++ modules/field/field.api.php	21 Dec 2009 19:58:49 -0000
@@ -1030,7 +1030,7 @@ function hook_field_attach_delete_revisi
  *   An associative array containing:
  *   - obj_type: The type of $object; e.g. 'node' or 'user'.
  *   - object: The object with fields to render.
- *   - build_mode: Build mode, e.g. 'full', 'teaser'...
+ *   - view_mode: View mode, e.g. 'full', 'teaser'...
  *   - langcode: The language in which the field values will be displayed.
  */
 function hook_field_attach_view_alter(&$output, $context) {
@@ -1579,16 +1579,6 @@ function hook_field_read_instance($insta
  **********************************************************************/
 
 /**
- * TODO
- *
- * Note : Right now this belongs to the "Fieldable Type API".
- * Whether 'build modes' is actually a 'fields' concept is to be debated
- * in a separate overhaul patch for core.
- */
-function hook_field_build_modes($obj_type) {
-}
-
-/**
  * Determine whether the user has access to a given field.
  *
  * @param $op
Index: modules/field/field.attach.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/field.attach.inc,v
retrieving revision 1.66
diff -u -p -r1.66 field.attach.inc
--- modules/field/field.attach.inc	21 Dec 2009 13:47:32 -0000	1.66
+++ modules/field/field.attach.inc	21 Dec 2009 20:14:00 -0000
@@ -143,7 +143,7 @@ define('FIELD_STORAGE_INSERT', 'insert')
  *   The fully formed $obj_type object.
  * @param $a
  *   - The $form in the 'form' operation.
- *   - The value of $build_mode in the 'view' operation.
+ *   - The value of $view_mode in the 'view' operation.
  *   - Otherwise NULL.
  * @param $b
  *   - The $form_state in the 'submit' operation.
@@ -1113,20 +1113,20 @@ function field_attach_query_revisions($f
 /**
  * Allow formatters to act on fieldable objects prior to rendering.
  */
-function field_attach_prepare_view($obj_type, $objects, $build_mode = 'full') {
+function field_attach_prepare_view($obj_type, $objects, $view_mode = 'full') {
   // First let the field types do their preparation.
   _field_invoke_multiple('prepare_view', $obj_type, $objects);
   // Then let the formatters do their own specific massaging.
   // field_default_prepare_view() takes care of dispatching to the correct
-  // formatters according to the display settings for the build mode.
-  _field_invoke_multiple_default('prepare_view', $obj_type, $objects, $build_mode);
+  // formatters according to the display settings for the view mode.
+  _field_invoke_multiple_default('prepare_view', $obj_type, $objects, $view_mode);
 }
 
 /**
  * Returns a renderable array for the fields on an object.
  *
  * Each field is displayed according to the display options specified in the
- * $instance definition for the given $build_mode.
+ * $instance definition for the given $view_mode.
  *
  * Sample structure:
  * @code
@@ -1138,7 +1138,7 @@ function field_attach_prepare_view($obj_
  *     '#object' => the fieldable object being displayed,
  *     '#object_type' => the type of the object being displayed,
  *     '#language' => the language of the field values being displayed,
- *     '#build_mode' => the build mode,
+ *     '#view_mode' => the view mode,
  *     '#field_name' => the name of the field,
  *     '#field_type' => the type of the field,
  *     '#formatter' => the name of the formatter,
@@ -1153,15 +1153,15 @@ function field_attach_prepare_view($obj_
  *   The type of $object; e.g. 'node' or 'user'.
  * @param $object
  *   The object with fields to render.
- * @param $build_mode
- *   Build mode, e.g. 'full', 'teaser'...
+ * @param $view_mode
+ *   View mode, e.g. 'full', 'teaser'...
  * @param $langcode
  *   The language the field values are to be shown in. If no language is
  *   provided the current language is used.
  * @return
  *   A renderable array for the field values.
  */
-function field_attach_view($obj_type, $object, $build_mode = 'full', $langcode = NULL) {
+function field_attach_view($obj_type, $object, $view_mode = 'full', $langcode = NULL) {
   // If no language is provided use the current UI language.
   $options = array('language' => field_multilingual_valid_language($langcode, FALSE));
 
@@ -1169,7 +1169,7 @@ function field_attach_view($obj_type, $o
   $null = NULL;
   _field_invoke('sanitize', $obj_type, $object, $null, $null, $options);
 
-  $output = _field_invoke_default('view', $obj_type, $object, $build_mode, $null, $options);
+  $output = _field_invoke_default('view', $obj_type, $object, $view_mode, $null, $options);
 
   // Add custom weight handling.
   list($id, $vid, $bundle) = entity_extract_ids($obj_type, $object);
@@ -1181,7 +1181,7 @@ function field_attach_view($obj_type, $o
   $context = array(
     'obj_type' => $obj_type,
     'object' => $object,
-    'build_mode' => $build_mode,
+    'view_mode' => $view_mode,
     'langcode' => $langcode,
   );
   drupal_alter('field_attach_view', $output, $context);
Index: modules/field/field.crud.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/field.crud.inc,v
retrieving revision 1.43
diff -u -p -r1.43 field.crud.inc
--- modules/field/field.crud.inc	20 Dec 2009 19:45:07 -0000	1.43
+++ modules/field/field.crud.inc	21 Dec 2009 20:14:30 -0000
@@ -149,11 +149,11 @@
  *     - module (string, read-only)
  *         The name of the module that implements the widget type.
  * - display (array)
- *     A sub-array of key/value pairs identifying build modes and the way the
- *     field values should be displayed in each build mode.
+ *     A sub-array of key/value pairs identifying view modes and the way the
+ *     field values should be displayed in each mode.
  *     - full (array)
  *         A sub-array of key/value pairs of the display options to be used
- *         when the field is being displayed in the "full" build mode.
+ *         when the field is being displayed in the "full" view mode.
  *         - label (string)
  *             Position of the label. 'inline', 'above' and 'hidden' are the
  *             values recognized by the default 'field' theme implementation.
@@ -164,12 +164,12 @@
  *             the formatter.
  *        - weight (float)
  *            The weight of the field relative to the other object components
- *            displayed in this build mode.
+ *            displayed in this view mode.
  *         - module (string, read-only)
  *             The name of the module which implements the display formatter.
  *     - teaser
  *         - ...
- *     - other_build_mode
+ *     - other_mode
  *        - ...
  *
  * Bundles are represented by two strings, an entity type and a bundle name.
@@ -588,7 +588,7 @@ function field_delete_field($field_name)
  *     - settings: each omitted setting is given the default value specified in
  *       hook_field_widget_info().
  *   - display:
- *     Settings for the 'full' build mode will be added, and each build mode
+ *     Settings for the 'full' view mode will be added, and each view mode
  *     will be completed with the following default values:
  *     - label: 'above'
  *     - type: the default formatter specified in hook_field_info().
@@ -621,7 +621,7 @@ function field_create_instance($instance
 
   // TODO: Check that the widget type is known and can handle the field type ?
   // TODO: Check that the formatters are known and can handle the field type ?
-  // TODO: Check that the display build modes are known for the object type ?
+  // TODO: Check that the display view modes are known for the object type ?
   // Those checks should probably happen in _field_write_instance() ?
   // Problem : this would mean that a UI module cannot update an instance with a disabled formatter.
 
@@ -722,23 +722,23 @@ function _field_write_instance($instance
   $instance['widget']['module'] = $widget_type['module'];
   $instance['widget']['settings'] += field_info_widget_settings($instance['widget']['type']);
 
-  // Make sure there is at least display info for the 'full' build mode.
+  // Make sure there is at least display info for the 'full' view mode.
   $instance['display'] += array(
     'full' => array(),
   );
-  // Set default display settings for each build mode.
-  foreach ($instance['display'] as $build_mode => $display) {
-    $instance['display'][$build_mode] += array(
+  // Set default display settings for each view mode.
+  foreach ($instance['display'] as $view_mode => $display) {
+    $instance['display'][$view_mode] += array(
       'label' => 'above',
       // TODO: what if no 'default_formatter' specified ?
       'type' => $field_type['default_formatter'],
       'settings' => array(),
       'weight' => 0,
     );
-    $formatter_type = field_info_formatter_types($instance['display'][$build_mode]['type']);
+    $formatter_type = field_info_formatter_types($instance['display'][$view_mode]['type']);
     // TODO : 'hidden' will raise PHP warnings.
-    $instance['display'][$build_mode]['module'] = $formatter_type['module'];
-    $instance['display'][$build_mode]['settings'] += field_info_formatter_settings($instance['display'][$build_mode]['type']);
+    $instance['display'][$view_mode]['module'] = $formatter_type['module'];
+    $instance['display'][$view_mode]['settings'] += field_info_formatter_settings($instance['display'][$view_mode]['type']);
   }
 
   // The serialized 'data' column contains everything from $instance that does
Index: modules/field/field.default.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/field.default.inc,v
retrieving revision 1.28
diff -u -p -r1.28 field.default.inc
--- modules/field/field.default.inc	21 Dec 2009 13:47:32 -0000	1.28
+++ modules/field/field.default.inc	21 Dec 2009 20:14:42 -0000
@@ -114,7 +114,7 @@ function field_default_insert($obj_type,
  *   Array of field values already loaded for the objects, keyed by object id.
  * @param $display
  *   Can be either:
- *   - the name of a build mode
+ *   - the name of a view mode
  *   - or an array of display settings to use for display, as found in the
  *     'display' entry of $instance definitions.
 */
@@ -161,7 +161,7 @@ function field_default_prepare_view($obj
  *   Array of field values already loaded for the objects, keyed by object id.
  * @param $display
  *   Can be either:
- *   - the name of a build mode;
+ *   - the name of a view mode;
  *   - or an array of custom display settings, as found in the 'display' entry
  *     of $instance definitions.
  */
@@ -172,16 +172,16 @@ function field_default_view($obj_type, $
 
   // Prepare incoming display specifications.
   if (is_string($display)) {
-    $build_mode = $display;
-    $display = $instance['display'][$build_mode];
+    $view_mode = $display;
+    $display = $instance['display'][$view_mode];
   }
   else {
-    $build_mode = '_custom_display';
+    $view_mode = '_custom_display';
   }
 
   if ($display['type'] !== 'hidden') {
     // We never want to index fields labels.
-    if ($build_mode == 'search_index') {
+    if ($view_mode == 'search_index') {
       $display['label'] = 'hidden';
     }
 
@@ -199,7 +199,7 @@ function field_default_view($obj_type, $
         '#title' => t($instance['label']),
         '#access' => field_access('view', $field, $obj_type, $object),
         '#label_display' => $display['label'],
-        '#build_mode' => $build_mode,
+        '#view_mode' => $view_mode,
         '#language' => $langcode,
         '#field_name' => $field['field_name'],
         '#field_type' => $field['type'],
Index: modules/field/field.info.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/field.info.inc,v
retrieving revision 1.35
diff -u -p -r1.35 field.info.inc
--- modules/field/field.info.inc	20 Dec 2009 22:38:05 -0000	1.35
+++ modules/field/field.info.inc	21 Dec 2009 20:50:39 -0000
@@ -29,7 +29,6 @@ function field_info_cache_clear() {
   entity_info_cache_clear();
 
   _field_info_collate_types(TRUE);
-  drupal_static_reset('field_build_modes');
   _field_info_collate_fields(TRUE);
 }
 
@@ -280,14 +279,14 @@ function _field_info_prepare_instance($i
 
   $instance['widget'] = _field_info_prepare_instance_widget($field, $instance['widget']);
 
-  foreach ($instance['display'] as $build_mode => $display) {
-    $instance['display'][$build_mode] = _field_info_prepare_instance_display($field, $display);
+  foreach ($instance['display'] as $view_mode => $display) {
+    $instance['display'][$view_mode] = _field_info_prepare_instance_display($field, $display);
   }
 
-  // Fallback to 'full' display settings for unspecified build modes.
-  foreach (field_build_modes($instance['object_type']) as $build_mode => $label) {
-    if (!isset($instance['display'][$build_mode])) {
-      $instance['display'][$build_mode] = $instance['display']['full'];
+  // Fallback to 'full' display settings for unspecified view modes.
+  foreach (entity_view_mode_info($instance['object_type']) as $view_mode => $info) {
+    if (!isset($instance['display'][$view_mode])) {
+      $instance['display'][$view_mode] = $instance['display']['full'];
     }
   }
 
@@ -301,7 +300,7 @@ function _field_info_prepare_instance($i
  *   The field structure for the instance.
  * @param $display
  *   Display specifications as found in
- *   $instance['display']['some_build_mode'].
+ *   $instance['display']['some_view_mode'].
  */
 function _field_info_prepare_instance_display($field, $display) {
   $field_type = field_info_field_types($field['type']);
Index: modules/field/field.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/field.module,v
retrieving revision 1.55
diff -u -p -r1.55 field.module
--- modules/field/field.module	20 Dec 2009 21:08:26 -0000	1.55
+++ modules/field/field.module	21 Dec 2009 20:15:17 -0000
@@ -368,18 +368,6 @@ function _field_sort_items_value_helper(
 }
 
 /**
- * Registry of available build modes.
- */
-function field_build_modes($obj_type) {
-  $info = &drupal_static(__FUNCTION__, array());
-
-  if (!isset($info[$obj_type])) {
-    $info[$obj_type] = module_invoke_all('field_build_modes', $obj_type);
-  }
-  return $info[$obj_type];
-}
-
-/**
  * Registry of pseudo-field components in a given bundle.
  *
  * @param $bundle_name
@@ -588,11 +576,11 @@ function field_format($obj_type, $object
  *   The name of the field to display.
  * @param $display
  *   Can be either:
- *   - The name of a build mode. The field will be displayed according to the
- *     display settings specified for this build mode in the $instance
+ *   - The name of a view mode. The field will be displayed according to the
+ *     display settings specified for this view mode in the $instance
  *     definition for the field in the object's bundle.
- *     If no display settings are found for the build mode, the settings for
- *     the 'full' build mode will be used.
+ *     If no display settings are found for the view mode, the settings for
+ *     the 'full' view mode will be used.
  *   - An array of display settings, as found in the 'display' entry of
  *     $instance definitions. The following kay/value pairs are allowed:
  *     - label: (string) Position of the label. The default 'field' theme
@@ -624,8 +612,8 @@ function field_view_field($obj_type, $ob
       $display = _field_info_prepare_instance_display($field, $display);
     }
     else {
-      // When using a build mode, make sure we have settings for it, or fall
-      // back to the 'full' build mode.
+      // When using a view mode, make sure we have settings for it, or fall
+      // back to the 'full' view mode.
       list(, , $bundle) = entity_extract_ids($obj_type, $object);
       $instance = field_info_instance($obj_type, $field_name, $bundle);
       if (!isset($instance['display'][$display])) {
@@ -651,7 +639,7 @@ function field_view_field($obj_type, $ob
     $context = array(
       'obj_type' => $obj_type,
       'object' => $object,
-      'build_mode' => '_custom',
+      'view_mode' => '_custom',
       'langcode' => $langcode,
     );
     drupal_alter('field_attach_view', $result, $context);
@@ -759,7 +747,7 @@ function template_preprocess_field(&$var
     'object' => $element['#object'],
     'field' => $field,
     'instance' => $instance,
-    'build_mode' => $element['#build_mode'],
+    'view_mode' => $element['#view_mode'],
     'items' => $items,
     'field_type' => $field['type'],
     'field_name' => $field['field_name'],
Index: modules/field/tests/field.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/tests/field.test,v
retrieving revision 1.9
diff -u -p -r1.9 field.test
--- modules/field/tests/field.test	20 Dec 2009 21:08:26 -0000	1.9
+++ modules/field/tests/field.test	21 Dec 2009 20:23:59 -0000
@@ -1339,10 +1339,10 @@ class FieldInfoTestCase extends FieldTes
     $this->assertIdentical($instance['widget']['settings'], $widget_type['settings'] , t('All expected widget settings are present.'));
 
     // Check that the default formatter is used and expected settings are in place.
-    foreach (field_build_modes('test_entity') as $build_mode => $label) {
-      $this->assertIdentical($instance['display'][$build_mode]['type'], $field_type['default_formatter'], t('Unavailable formatter replaced with default formatter in build_mode %build_mode', array('%build_mode' => $build_mode)));
-      $formatter_type = field_info_formatter_types($instance['display'][$build_mode]['type']);
-      $this->assertIdentical($instance['display'][$build_mode]['settings'], $formatter_type['settings'] , t('All expected formatter settings are present in build_mode %build_mode', array('%build_mode' => $build_mode)));
+    foreach (entity_view_mode_info('test_entity') as $view_mode => $info) {
+      $this->assertIdentical($instance['display'][$view_mode]['type'], $field_type['default_formatter'], t('Unavailable formatter replaced with default formatter in view_mode %view_mode', array('%view_mode' => $view_mode)));
+      $formatter_type = field_info_formatter_types($instance['display'][$view_mode]['type']);
+      $this->assertIdentical($instance['display'][$view_mode]['settings'], $formatter_type['settings'] , t('All expected formatter settings are present in view_mode %view_mode', array('%view_mode' => $view_mode)));
     }
   }
 
@@ -1807,7 +1807,7 @@ class FieldDisplayAPITestCase extends Fi
     }
     $this->assertText($setting . '|' . implode('|', $array), t('Values were displayed with expected setting.'));
 
-    // Build mode: check that display settings specified in the instance are
+    // View mode: check that display settings specified in the instance are
     // used.
     $output = field_view_field('test_entity', $this->entity, $this->field_name, 'full');
     $this->drupalSetContent(drupal_render($output));
@@ -1817,9 +1817,9 @@ class FieldDisplayAPITestCase extends Fi
       $this->assertText($setting . '|' . $value['value'], t('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
     }
 
-    // Unknown build mode: check that display settings for 'full' build mode
+    // Unknown view mode: check that display settings for 'full' view mode
     // are used.
-    $output = field_view_field('test_entity', $this->entity, $this->field_name, 'unknown_build_mode');
+    $output = field_view_field('test_entity', $this->entity, $this->field_name, 'unknown_view_mode');
     $this->drupalSetContent(drupal_render($output));
     $setting = $this->instance['display']['full']['settings']['test_formatter_setting'];
     $this->assertText($this->label, t('Label was displayed.'));
@@ -2327,13 +2327,13 @@ class FieldInstanceCrudTestCase extends 
     $this->assertIdentical($record['data']['label'], $this->instance_definition['field_name'], t('Label defaults to field name.'));
     $this->assertIdentical($record['data']['description'], '', t('Description defaults to empty string.'));
     $this->assertIdentical($record['data']['widget']['type'], $field_type['default_widget'], t('Default widget has been written.'));
-    $this->assertTrue(isset($record['data']['display']['full']), t('Display for "full" build_mode has been written.'));
-    $this->assertIdentical($record['data']['display']['full']['type'], $field_type['default_formatter'], t('Default formatter for "full" build_mode has been written.'));
+    $this->assertTrue(isset($record['data']['display']['full']), t('Display for "full" view_mode has been written.'));
+    $this->assertIdentical($record['data']['display']['full']['type'], $field_type['default_formatter'], t('Default formatter for "full" view_mode has been written.'));
 
     // Check that default settings are set.
     $this->assertIdentical($record['data']['settings'], $field_type['instance_settings'] , t('Default instance settings have been written.'));
     $this->assertIdentical($record['data']['widget']['settings'], $widget_type['settings'] , t('Default widget settings have been written.'));
-    $this->assertIdentical($record['data']['display']['full']['settings'], $formatter_type['settings'], t('Default formatter settings for "full" build_mode have been written.'));
+    $this->assertIdentical($record['data']['display']['full']['settings'], $formatter_type['settings'], t('Default formatter settings for "full" view_mode have been written.'));
 
     // Guarantee that the field/bundle combination is unique.
     try {
@@ -2411,17 +2411,17 @@ class FieldInstanceCrudTestCase extends 
     $settings = $info['settings'];
     $this->assertIdentical($settings, array_intersect_key($instance_new['display']['full']['settings'], $settings) , t('Changing formatter type updates default settings.'));
 
-    // Check that adding a new build mode is saved and gets default settings.
+    // Check that adding a new view mode is saved and gets default settings.
     $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']);
     $instance['display']['teaser'] = array();
     field_update_instance($instance);
 
     $instance_new = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']);
-    $this->assertTrue(isset($instance_new['display']['teaser']), t('Display for the new build_mode has been written.'));
-    $this->assertIdentical($instance_new['display']['teaser']['type'], $field_type['default_formatter'], t('Default formatter for the new build_mode has been written.'));
+    $this->assertTrue(isset($instance_new['display']['teaser']), t('Display for the new view_mode has been written.'));
+    $this->assertIdentical($instance_new['display']['teaser']['type'], $field_type['default_formatter'], t('Default formatter for the new view_mode has been written.'));
     $info = field_info_formatter_types($instance_new['display']['teaser']['type']);
     $settings = $info['settings'];
-    $this->assertIdentical($settings, $instance_new['display']['teaser']['settings'] , t('Default formatter settings for the new build_mode have been written.'));
+    $this->assertIdentical($settings, $instance_new['display']['teaser']['settings'] , t('Default formatter settings for the new view_mode have been written.'));
 
     // TODO: test failures.
   }
Index: modules/field/tests/field_test.entity.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/tests/field_test.entity.inc,v
retrieving revision 1.1
diff -u -p -r1.1 field_test.entity.inc
--- modules/field/tests/field_test.entity.inc	20 Nov 2009 23:29:28 -0000	1.1
+++ modules/field/tests/field_test.entity.inc	21 Dec 2009 19:22:28 -0000
@@ -53,6 +53,24 @@ function field_test_entity_info_alter(&$
 }
 
 /**
+ * Implements hook_entity_view_mode_info().
+ */
+function field_test_entity_view_mode_info() {
+  $test_entity_modes = array(
+    'full' => array(
+      'label' => t('Full object'),
+    ),
+    'teaser' => array(
+      'label' => t('Teaser'),
+    ),
+  );
+  $modes['test_entity'] = $test_entity_modes;
+  $modes['test_cacheable_entity'] = $test_entity_modes;
+
+  return $modes;
+}
+
+/**
  * Creates a new bundle for test_entity objects.
  *
  * @param $bundle
@@ -110,20 +128,6 @@ function field_test_delete_bundle($bundl
 }
 
 /**
- * Implements hook_field_build_modes().
- */
-function field_test_field_build_modes($obj_type) {
-  $modes = array();
-  if ($obj_type == 'test_entity' || $obj_type == 'test_cacheable_entity') {
-    $modes = array(
-      'full' => t('Full node'),
-      'teaser' => t('Teaser'),
-    );
-  }
-  return $modes;
-}
-
-/**
  * Creates a basic test_entity object.
  */
 function field_test_create_stub_entity($id = 1, $vid = 1, $bundle = 'test_bundle') {
Index: modules/field/theme/field.tpl.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/theme/field.tpl.php,v
retrieving revision 1.8
diff -u -p -r1.8 field.tpl.php
--- modules/field/theme/field.tpl.php	12 Dec 2009 20:16:03 -0000	1.8
+++ modules/field/theme/field.tpl.php	21 Dec 2009 19:57:37 -0000
@@ -24,7 +24,7 @@
  * Other variables:
  * - $object: The object to which the field is attached.
  * - $field: The field array.
- * - $build_mode: Build mode, e.g. 'full', 'teaser'...
+ * - $view_mode: View mode, e.g. 'full', 'teaser'...
  * - $field_name: The field name.
  * - $field_type: The field type.
  * - $field_name_css: The css-compatible field name.
Index: modules/field_ui/field_ui.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/field_ui/field_ui.admin.inc,v
retrieving revision 1.31
diff -u -p -r1.31 field_ui.admin.inc
--- modules/field_ui/field_ui.admin.inc	2 Dec 2009 19:26:22 -0000	1.31
+++ modules/field_ui/field_ui.admin.inc	21 Dec 2009 20:33:19 -0000
@@ -469,8 +469,8 @@ function field_ui_field_overview_form_su
     if (in_array($key, $form['#fields'])) {
       $instance = field_read_instance($obj_type, $key, $bundle);
       $instance['widget']['weight'] = $values['weight'];
-      foreach($instance['display'] as $build_mode => $display) {
-        $instance['display'][$build_mode]['weight'] = $values['weight'];
+      foreach($instance['display'] as $view_mode => $display) {
+        $instance['display'][$view_mode]['weight'] = $values['weight'];
       }
       field_update_instance($instance);
     }
@@ -568,9 +568,9 @@ function field_ui_field_overview_form_su
  * Menu callback; presents a listing of fields display settings for a content type.
  *
  * This form includes form widgets to select which fields appear in teaser and
- * full build modes, and how the field labels should be rendered.
+ * full view modes, and how the field labels should be rendered.
  */
-function field_ui_display_overview_form($form, &$form_state, $obj_type, $bundle, $build_modes_selector = 'basic') {
+function field_ui_display_overview_form($form, &$form_state, $obj_type, $bundle, $view_modes_selector = 'basic') {
   $bundle = field_extract_bundle($obj_type, $bundle);
 
   field_ui_inactive_message($obj_type, $bundle);
@@ -579,14 +579,14 @@ function field_ui_display_overview_form(
   // Gather type information.
   $instances = field_info_instances($obj_type, $bundle);
   $field_types = field_info_field_types();
-  $build_modes = field_ui_build_modes_tabs($obj_type, $build_modes_selector);
+  $view_modes = field_ui_view_modes_tabs($obj_type, $view_modes_selector);
 
   $form += array(
     '#tree' => TRUE,
     '#object_type' => $obj_type,
     '#bundle' => $bundle,
     '#fields' => array_keys($instances),
-    '#contexts' => $build_modes_selector,
+    '#contexts' => $view_modes_selector,
   );
 
   if (empty($instances)) {
@@ -612,14 +612,14 @@ function field_ui_display_overview_form(
 
     $formatter_options = field_ui_formatter_options($field['type']);
     $formatter_options['hidden'] = t('<Hidden>');
-    foreach ($build_modes as $build_mode => $label) {
-      $display = isset($instance['display'][$build_mode]) ? $instance['display'][$build_mode] : $instance['display']['full'];
-      $form[$name][$build_mode]['label'] = array(
+    foreach ($view_modes as $view_mode) {
+      $display = isset($instance['display'][$view_mode]) ? $instance['display'][$view_mode] : $instance['display']['full'];
+      $form[$name][$view_mode]['label'] = array(
         '#type' => 'select',
         '#options' => $label_options,
         '#default_value' => $display['label'],
       );
-      $form[$name][$build_mode]['type'] = array(
+      $form[$name][$view_mode]['type'] = array(
         '#type' => 'select',
         '#options' => $formatter_options,
         '#default_value' => $display['type'],
@@ -639,7 +639,12 @@ function template_preprocess_field_ui_di
   $form = &$vars['form'];
 
   $contexts_selector = $form['#contexts'];
-  $vars['contexts'] = field_ui_build_modes_tabs($form['#object_type'], $contexts_selector);
+  $view_modes = field_ui_view_modes_tabs($form['#object_type'], $contexts_selector);
+  $view_modes_info = entity_view_mode_info($form['#object_type']);
+  $vars['contexts'] = array();
+  foreach ($view_modes as $view_mode) {
+    $vars['contexts'][$view_mode] = $view_modes_info[$view_mode]['label'];
+  }
 
   $order = _field_ui_overview_order($form, $form['#fields']);
   if (empty($order)) {
@@ -676,9 +681,9 @@ function field_ui_display_overview_form_
   foreach ($form_values as $key => $values) {
     if (in_array($key, $form['#fields'])) {
       $instance = field_info_instance($form['#object_type'], $key, $form['#bundle']);
-      foreach ($instance['display'] as $build_mode => $display) {
-        if (isset($values[$build_mode])) {
-          $instance['display'][$build_mode] = array_merge($instance['display'][$build_mode], $values[$build_mode]);
+      foreach ($instance['display'] as $view_mode => $display) {
+        if (isset($values[$view_mode])) {
+          $instance['display'][$view_mode] = array_merge($instance['display'][$view_mode], $values[$view_mode]);
         }
       }
       field_update_instance($instance);
Index: modules/field_ui/field_ui.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/field_ui/field_ui.module,v
retrieving revision 1.19
diff -u -p -r1.19 field_ui.module
--- modules/field_ui/field_ui.module	12 Dec 2009 23:04:57 -0000	1.19
+++ modules/field_ui/field_ui.module	21 Dec 2009 20:28:02 -0000
@@ -117,7 +117,7 @@ function field_ui_menu() {
             'weight' => 2,
             'file' => 'field_ui.admin.inc',
           ) + $access;
-          $tabs = field_ui_build_modes_tabs($obj_type);
+          $tabs = field_ui_view_modes_tabs($obj_type);
           foreach ($tabs as $key => $tab) {
             $items["$path/display/$key"] = array(
               'title' => $tab['title'],
@@ -171,26 +171,26 @@ function field_ui_theme() {
 }
 
 /**
- * Group available build modes on tabs on the 'Manage display' page.
+ * Group available view modes on tabs on the 'Manage display' page.
  *
  * @todo Remove this completely and use vertical tabs?
  */
-function field_ui_build_modes_tabs($obj_type, $tab_selector = NULL) {
+function field_ui_view_modes_tabs($obj_type, $tab_selector = NULL) {
   $info = &drupal_static(__FUNCTION__);
 
   if (!isset($info[$obj_type])) {
-    $info[$obj_type] = module_invoke_all('field_ui_build_modes_tabs');
-    // Collect titles, and filter out non active modes.
-    $active_modes = field_build_modes($obj_type);
+    $info[$obj_type] = module_invoke_all('field_ui_view_modes_tabs', $obj_type);
+    // Filter out inactive modes.
+    $active_modes = entity_view_mode_info($obj_type);
     foreach ($info[$obj_type] as $tab => $values) {
       $modes = array();
-      foreach ($info[$obj_type][$tab]['build modes'] as $mode) {
+      foreach ($info[$obj_type][$tab]['view modes'] as $mode) {
         if (isset($active_modes[$mode])) {
-          $modes[$mode] = $active_modes[$mode];
+          $modes[] = $mode;
         }
       }
       if ($modes) {
-        $info[$obj_type][$tab]['build modes'] = $modes;
+        $info[$obj_type][$tab]['view modes'] = $modes;
       }
       else {
         unset($info[$obj_type][$tab]);
@@ -198,16 +198,16 @@ function field_ui_build_modes_tabs($obj_
     }
   }
   if ($tab_selector) {
-    return isset($info[$obj_type][$tab_selector]) ? $info[$obj_type][$tab_selector]['build modes'] : array();
+    return isset($info[$obj_type][$tab_selector]) ? $info[$obj_type][$tab_selector]['view modes'] : array();
   }
   return $info[$obj_type];
 }
 
 /**
- * Implements hook_field_ui_build_modes_tabs() on behalf of other core modules.
+ * Implements hook_field_ui_view_modes_tabs() on behalf of other core modules.
  *
  * @return
- *   An array describing the build modes defined by the module, grouped by tabs.
+ *   An array describing the view modes defined by the module, grouped by tabs.
  *
  * A module can add its render modes to a tab defined by another module.
  * Expected format:
@@ -215,7 +215,7 @@ function field_ui_build_modes_tabs($obj_
  *   array(
  *     'tab1' => array(
  *       'title' => t('The human-readable title of the tab'),
- *       'build modes' => array('mymodule_mode1', 'mymodule_mode2'),
+ *       'view modes' => array('mymodule_mode1', 'mymodule_mode2'),
  *     ),
  *     'tab2' => array(
  *       // ...
@@ -223,23 +223,23 @@ function field_ui_build_modes_tabs($obj_
  *   );
  * @endcode
  */
-function field_ui_field_ui_build_modes_tabs() {
+function field_ui_field_ui_view_modes_tabs() {
   $modes = array(
     'basic' => array(
       'title' => t('Basic'),
-      'build modes' => array('teaser', 'full'),
+      'view modes' => array('teaser', 'full'),
     ),
     'rss' => array(
       'title' => t('RSS'),
-      'build modes' => array('rss'),
+      'view modes' => array('rss'),
     ),
     'print' => array(
       'title' => t('Print'),
-      'build modes' => array('print'),
+      'view modes' => array('print'),
     ),
     'search' => array(
       'title' => t('Search'),
-      'build modes' => array('search_index', 'search_result'),
+      'view modes' => array('search_index', 'search_result'),
     ),
   );
   return $modes;
Index: modules/forum/forum.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/forum/forum.module,v
retrieving revision 1.544
diff -u -p -r1.544 forum.module
--- modules/forum/forum.module	17 Dec 2009 19:22:25 -0000	1.544
+++ modules/forum/forum.module	21 Dec 2009 20:01:51 -0000
@@ -235,7 +235,7 @@ function _forum_node_check_node_type($no
 /**
  * Implements hook_node_view().
  */
-function forum_node_view($node, $build_mode) {
+function forum_node_view($node, $view_mode) {
   $vid = variable_get('forum_nav_vocabulary', 0);
   $vocabulary = taxonomy_vocabulary_load($vid);
   if (_forum_node_check_node_type($node)) {
Index: modules/locale/locale.field.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/locale/locale.field.inc,v
retrieving revision 1.5
diff -u -p -r1.5 locale.field.inc
--- modules/locale/locale.field.inc	11 Dec 2009 16:49:40 -0000	1.5
+++ modules/locale/locale.field.inc	21 Dec 2009 20:02:59 -0000
@@ -65,7 +65,7 @@ function locale_field_fallback_view(&$ou
           // Cache fallback values per language as fields might have different
           // fallback values.
           if (!isset($fallback_values[$langcode])) {
-            $fallback_values[$langcode] = field_attach_view($context['obj_type'], $context['object'], $context['build_mode'], $langcode);
+            $fallback_values[$langcode] = field_attach_view($context['obj_type'], $context['object'], $context['view_mode'], $langcode);
           }
           // We are done, skip to the next field.
           $output[$field_name] = $fallback_values[$langcode][$field_name];
Index: modules/locale/locale.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/locale/locale.test,v
retrieving revision 1.55
diff -u -p -r1.55 locale.test
--- modules/locale/locale.test	7 Dec 2009 06:07:19 -0000	1.55
+++ modules/locale/locale.test	21 Dec 2009 20:17:04 -0000
@@ -1712,8 +1712,8 @@ class LocaleMultilingualFieldsFunctional
     $settings['body[full][type]'] = 'hidden';
     $this->drupalPost('admin/structure/types/manage/page/display', $settings, t('Save'));
     $select_xpath = '//select[@id="edit-body-full-type"]/option[@selected="selected"]';
-    // Check if body display is actually "hidden" for the "full" build mode.
-    $this->assertEqual(current($this->xpath($select_xpath)), '<Hidden>', 'Body display is actually "hidden" for the "full" build mode');
+    // Check if body display is actually "hidden" for the "full" view mode.
+    $this->assertEqual(current($this->xpath($select_xpath)), '<Hidden>', 'Body display is actually "hidden" for the "full" view mode');
     $this->drupalGet("node/$node->nid");
     // Check if node body is not showed.
     $this->assertFalse(is_array($this->xpath($body_xpath)), 'Body correctly not showed.');
Index: modules/node/node.api.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.api.php,v
retrieving revision 1.50
diff -u -p -r1.50 node.api.php
--- modules/node/node.api.php	21 Dec 2009 13:47:32 -0000	1.50
+++ modules/node/node.api.php	21 Dec 2009 22:55:44 -0000
@@ -545,13 +545,11 @@ function hook_node_validate($node, $form
 /**
  * Act on a node that is being assembled before rendering.
  *
- * TODO D7 This needs work to clearly explain the different build modes.
- *
  * The module may add elements to $node->content prior to rendering. This hook
  * will be called after hook_view(). The structure of $node->content is a
  * renderable array as expected by drupal_render().
  *
- * When $build_mode is 'rss', modules can also add extra RSS elements and
+ * When $view_mode is 'rss', modules can also add extra RSS elements and
  * namespaces to $node->rss_elements and $node->rss_namespaces respectively for
  * the RSS item generated for this node.
  * For details on how this is used @see node_feed()
@@ -562,10 +560,10 @@ function hook_node_validate($node, $form
  *
  * @param $node
  *   The node that is being assembled for rendering.
- * @param $build_mode
- *   The $build_mode parameter from node_view().
+ * @param $view_mode
+ *   The $view_mode parameter from node_view().
  */
-function hook_node_view($node, $build_mode) {
+function hook_node_view($node, $view_mode) {
   $node->content['my_additional_field'] = array(
     '#value' => $additional_field,
     '#weight' => 10,
@@ -591,7 +589,7 @@ function hook_node_view($node, $build_mo
  * @see node_view()
  */
 function hook_node_view_alter($build) {
-  if ($build['#build_mode'] == 'full' && isset($build['an_additional_field'])) {
+  if ($build['#view_mode'] == 'full' && isset($build['an_additional_field'])) {
     // Change its weight.
     $build['an_additional_field']['#weight'] = -10;
   }
@@ -982,8 +980,8 @@ function hook_validate($node, &$form) {
  *
  * @param $node
  *   The node to be displayed, as returned by node_load().
- * @param $build_mode
- *   Build mode, e.g. 'full', 'teaser', ...
+ * @param $view_mode
+ *   View mode, e.g. 'full', 'teaser', ...
  * @return
  *   $node. The passed $node parameter should be modified as necessary and
  *   returned so it can be properly presented. Nodes are prepared for display
@@ -998,7 +996,7 @@ function hook_validate($node, &$form) {
  *
  * For a detailed usage example, see node_example.module.
  */
-function hook_view($node, $build_mode = 'full') {
+function hook_view($node, $view_mode = 'full') {
   if ((bool)menu_get_object()) {
     $breadcrumb = array();
     $breadcrumb[] = array('path' => 'example', 'title' => t('example'));
Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.1186
diff -u -p -r1.1186 node.module
--- modules/node/node.module	21 Dec 2009 13:47:32 -0000	1.1186
+++ modules/node/node.module	21 Dec 2009 20:18:13 -0000
@@ -222,27 +222,34 @@ function node_entity_info() {
   return $return;
 }
 
-
 /**
- * Implements hook_field_build_modes().
+ * Implements hook_entity_view_mode_info().
  */
-function node_field_build_modes($obj_type) {
-  $modes = array();
-  if ($obj_type == 'node') {
-    $modes = array(
-      'teaser' => t('Teaser'),
-      'full' => t('Full node'),
-      'rss' => t('RSS'),
+function node_entity_view_mode_info() {
+  $modes['node'] = array(
+    'full' => array(
+      'label' => t('Full node'),
+    ),
+    'teaser' => array(
+      'label' => t('Teaser'),
+    ),
+    'rss' => array(
+      'label' => t('RSS'),
+    ),
+  );
+  // Search integration is provided by node.module, so search-related
+  // view modes for nodes are defined here and not in search.module.
+  if (module_exists('search')) {
+    $modes['node'] += array(
+      'search_index' => array(
+        'label' => t('Search Index'),
+      ),
+      'search_result' => array(
+        'label' => t('Search Result'),
+      ),
     );
-    // Search integration is provided by node.module, so search-related
-    // build-modes for nodes are defined here and not in search.module.
-    if (module_exists('search')) {
-      $modes += array(
-        'search_index' => t('Search Index'),
-        'search_result' => t('Search Result'),
-      );
-    }
   }
+
   return $modes;
 }
 
@@ -1167,15 +1174,15 @@ function node_revision_delete($revision_
  *
  * @param $node
  *   A node object.
- * @param $build_mode
- *   Build mode, e.g. 'full', 'teaser'...
+ * @param $view_mode
+ *   View mode, e.g. 'full', 'teaser'...
  *
  * @return
  *   An array as expected by drupal_render().
  */
-function node_view($node, $build_mode = 'full') {
+function node_view($node, $view_mode = 'full') {
   // Populate $node->content with a render() array.
-  node_build_content($node, $build_mode);
+  node_build_content($node, $view_mode);
 
   $build = $node->content;
   // We don't need duplicate rendering info in node->content.
@@ -1184,10 +1191,10 @@ function node_view($node, $build_mode = 
   $build += array(
     '#theme' => 'node',
     '#node' => $node,
-    '#build_mode' => $build_mode,
+    '#view_mode' => $view_mode,
   );
   // Add contextual links for this node.
-  // @todo Make this configurable per build mode.
+  // @todo Make this configurable per view mode.
   $build['#contextual_links']['node'] = array('node', array($node->nid));
 
   // Allow modules to modify the structured node.
@@ -1200,9 +1207,9 @@ function node_view($node, $build_mode = 
  * Builds a structured array representing the node's content.
  *
  * The content built for the node (field values, comments, file attachments or
- * other node components) will vary depending on the $build_mode parameter.
+ * other node components) will vary depending on the $view_mode parameter.
  *
- * Drupal core defines the following build modes for nodes, with the following
+ * Drupal core defines the following view modes for nodes, with the following
  * default use cases:
  *   - full (default): node is being displayed on its own page (node/123)
  *   - teaser: node is being displayed on the default home page listing, on
@@ -1213,34 +1220,34 @@ function node_view($node, $build_mode = 
  *   - search_result: node is being displayed as a search result.
  *   If book.module is enabled:
  *   - print: node is being displayed in print-friendly mode.
- * Contributed modules might define additional build modes, or use existing
- * build modes in additional contexts.
+ * Contributed modules might define additional view modes, or use existing
+ * view modes in additional contexts.
  *
  * @param $node
  *   A node object.
- * @param $build_mode
- *   Build mode, e.g. 'full', 'teaser'...
+ * @param $view_mode
+ *   View mode, e.g. 'full', 'teaser'...
  */
-function node_build_content($node, $build_mode = 'full') {
+function node_build_content($node, $view_mode = 'full') {
   // Remove previously built content, if exists.
   $node->content = array();
 
   // The 'view' hook can be implemented to overwrite the default function
   // to display nodes.
   if (node_hook($node, 'view')) {
-    $node = node_invoke($node, 'view', $build_mode);
+    $node = node_invoke($node, 'view', $view_mode);
   }
 
   // Build fields content.
   // @todo field_attach_prepare_view() is only invoked by node_view_multiple(),
   //   all other entities invoke it _here_.
-  //field_attach_prepare_view('node', array($node->nid => $node), $build_mode);
-  $node->content += field_attach_view('node', $node, $build_mode);
+  //field_attach_prepare_view('node', array($node->nid => $node), $view_mode);
+  $node->content += field_attach_view('node', $node, $view_mode);
 
   // Always display a read more link on teasers because we have no way
   // to know when a teaser view is different than a full view.
   $links = array();
-  if ($build_mode == 'teaser') {
+  if ($view_mode == 'teaser') {
     $links['node_readmore'] = array(
       'title' => t('Read more'),
       'href' => 'node/' . $node->nid,
@@ -1254,7 +1261,7 @@ function node_build_content($node, $buil
   );
 
   // Allow modules to make their own additions to the node.
-  module_invoke_all('node_view', $node, $build_mode);
+  module_invoke_all('node_view', $node, $view_mode);
 }
 
 /**
@@ -1334,15 +1341,15 @@ function node_show($node, $message = FAL
  *
  * The $variables array contains the following arguments:
  * - $node
- * - $build_mode
+ * - $view_mode
  * - $page
  *
  * @see node.tpl.php
  */
 function template_preprocess_node(&$variables) {
-  $variables['build_mode'] = $variables['elements']['#build_mode'];
+  $variables['view_mode'] = $variables['elements']['#view_mode'];
   // Provide a distinct $teaser boolean.
-  $variables['teaser'] = $variables['build_mode'] == 'teaser';
+  $variables['teaser'] = $variables['view_mode'] == 'teaser';
   $variables['node'] = $variables['elements']['#node'];
   $node = $variables['node'];
 
@@ -2129,18 +2136,18 @@ function node_feed($nids = FALSE, $chann
  *
  * @param $nodes
  *   An array of nodes as returned by node_load_multiple().
- * @param $build_mode
- *   Build mode, e.g. 'full', 'teaser'...
+ * @param $view_mode
+ *   View mode, e.g. 'full', 'teaser'...
  * @param $weight
  *   An integer representing the weight of the first node in the list.
  * @return
  *   An array in the format expected by drupal_render().
  */
-function node_view_multiple($nodes, $build_mode = 'teaser', $weight = 0) {
-  field_attach_prepare_view('node', $nodes, $build_mode);
+function node_view_multiple($nodes, $view_mode = 'teaser', $weight = 0) {
+  field_attach_prepare_view('node', $nodes, $view_mode);
   $build = array();
   foreach ($nodes as $node) {
-    $build['nodes'][$node->nid] = node_view($node, $build_mode);
+    $build['nodes'][$node->nid] = node_view($node, $view_mode);
     $build['nodes'][$node->nid]['#weight'] = $weight;
     $weight++;
   }
Index: modules/node/node.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.test,v
retrieving revision 1.59
diff -u -p -r1.59 node.test
--- modules/node/node.test	2 Dec 2009 19:52:23 -0000	1.59
+++ modules/node/node.test	21 Dec 2009 20:21:04 -0000
@@ -630,11 +630,11 @@ class NodeRSSContentTestCase extends Dru
 
     $this->drupalGet('rss.xml');
 
-    // Check that content added in 'rss' build mode appear in RSS feed.
+    // Check that content added in 'rss' view mode appear in RSS feed.
     $rss_only_content = t('Extra data that should appear only in the RSS feed for node !nid.', array('!nid' => $node->nid));
     $this->assertText($rss_only_content, t('Node content designated for RSS appear in RSS feed.'));
 
-    // Check that content added in build modes other than 'rss' doesn't
+    // Check that content added in view modes other than 'rss' doesn't
     // appear in RSS feed.
     $non_rss_content = t('Extra data that should appear everywhere except the RSS feed for node !nid.', array('!nid' => $node->nid));
     $this->assertNoText($non_rss_content, t('Node content not designed for RSS doesn\'t appear in RSS feed.'));
@@ -648,7 +648,7 @@ class NodeRSSContentTestCase extends Dru
     $this->assertRaw(format_xml_elements(array($test_element)), t('Extra RSS elements appear in RSS feed.'));
     $this->assertRaw($test_ns, t('Extra namespaces appear in RSS feed.'));
 
-    // Check that content added in 'rss' build mode doesn't appear when
+    // Check that content added in 'rss' view mode doesn't appear when
     // viewing node.
     $this->drupalGet("node/$node->nid");
     $this->assertNoText($rss_only_content, t('Node content designed for RSS doesn\'t appear when viewing node.'));
Index: modules/node/node.tpl.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.tpl.php,v
retrieving revision 1.29
diff -u -p -r1.29 node.tpl.php
--- modules/node/node.tpl.php	6 Dec 2009 01:00:27 -0000	1.29
+++ modules/node/node.tpl.php	21 Dec 2009 20:04:29 -0000
@@ -46,8 +46,8 @@
  * - $id: Position of the node. Increments each time it's output.
  *
  * Node status variables:
- * - $build_mode: Build mode, e.g. 'full', 'teaser'...
- * - $teaser: Flag for the teaser state (shortcut for $build_mode == 'teaser').
+ * - $view_mode: View mode, e.g. 'full', 'teaser'...
+ * - $teaser: Flag for the teaser state (shortcut for $view_mode == 'teaser').
  * - $page: Flag for the full page state.
  * - $promote: Flag for front page promotion state.
  * - $sticky: Flags for sticky post setting.
Index: modules/node/tests/node_test.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/tests/node_test.module,v
retrieving revision 1.8
diff -u -p -r1.8 node_test.module
--- modules/node/tests/node_test.module	4 Dec 2009 16:49:47 -0000	1.8
+++ modules/node/tests/node_test.module	21 Dec 2009 20:03:25 -0000
@@ -10,8 +10,8 @@
 /**
  * Implements hook_node_view().
  */
-function node_test_node_view($node, $build_mode) {
-  if ($build_mode == 'rss') {
+function node_test_node_view($node, $view_mode) {
+  if ($view_mode == 'rss') {
     // Add RSS elements and namespaces when building the RSS feed.
     $node->rss_elements[] = array(
       'key' => 'testElement',
@@ -26,7 +26,7 @@ function node_test_node_view($node, $bui
     );
   }
 
-  if ($build_mode != 'rss') {
+  if ($view_mode != 'rss') {
     // Add content that should NOT be displayed in the RSS feed.
     $node->content['extra_non_feed_content'] = array(
       '#markup' => '<p>' . t('Extra data that should appear everywhere except the RSS feed for node !nid.', array('!nid' => $node->nid)) . '</p>',
Index: modules/poll/poll.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/poll/poll.module,v
retrieving revision 1.329
diff -u -p -r1.329 poll.module
--- modules/poll/poll.module	14 Dec 2009 20:38:15 -0000	1.329
+++ modules/poll/poll.module	21 Dec 2009 20:04:45 -0000
@@ -598,7 +598,7 @@ function poll_block_latest_poll_view($no
 /**
  * Implements hook_view().
  */
-function poll_view($node, $build_mode = 'full') {
+function poll_view($node, $view_mode = 'full') {
   global $user;
   $output = '';
 
@@ -606,7 +606,7 @@ function poll_view($node, $build_mode = 
     $node->content['poll_view_voting'] = drupal_get_form('poll_view_voting', $node);
   }
   else {
-    $node->content['poll_view_results'] = array('#markup' => poll_view_results($node, $build_mode));
+    $node->content['poll_view_results'] = array('#markup' => poll_view_results($node, $view_mode));
   }
   return $node;
 }
@@ -726,7 +726,7 @@ function template_preprocess_poll_vote(&
 /**
  * Generates a graphical representation of the results of a poll.
  */
-function poll_view_results($node, $build_mode, $block = FALSE) {
+function poll_view_results($node, $view_mode, $block = FALSE) {
   // Count the votes and find the maximum
   $total_votes = 0;
   $max_votes = 0;
Index: modules/statistics/statistics.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/statistics/statistics.module,v
retrieving revision 1.328
diff -u -p -r1.328 statistics.module
--- modules/statistics/statistics.module	14 Dec 2009 20:38:15 -0000	1.328
+++ modules/statistics/statistics.module	21 Dec 2009 20:05:04 -0000
@@ -106,8 +106,8 @@ function statistics_permission() {
 /**
  * Implements hook_node_view().
  */
-function statistics_node_view($node, $build_mode) {
-  if ($build_mode != 'rss') {
+function statistics_node_view($node, $view_mode) {
+  if ($view_mode != 'rss') {
     $links = array();
     if (user_access('view post access counter')) {
       $statistics = statistics_get($node->nid);
Index: modules/system/system.api.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.api.php,v
retrieving revision 1.110
diff -u -p -r1.110 system.api.php
--- modules/system/system.api.php	17 Dec 2009 08:00:59 -0000	1.110
+++ modules/system/system.api.php	21 Dec 2009 22:53:31 -0000
@@ -55,7 +55,7 @@ function hook_hook_info() {
  *
  * @return
  *   An array whose keys are entity type names and whose values identify
- *   properties of those types that the  system needs to know about:
+ *   properties of those types that the system needs to know about:
  *   - name: The human-readable name of the type.
  *   - controller class: The name of the class that is used to load the objects.
  *     The class has to implement the DrupalEntityControllerInterface interface.
@@ -149,6 +149,74 @@ function hook_entity_info_alter(&$entity
 }
 
 /**
+ * Exposes information about view modes for entity types.
+ *
+ * View modes let entities be displayed differently depending on the display
+ * context. For instance, a node can be displayed differently on its own page
+ * ('full' mode), on the home page or taxonomy listings ('teaser' mode), or in
+ * an RSS feed ('rss' mode).
+ *
+ * Modules taking part in the display of the entity (notably the Field API) can
+ * adjust their behavior depending on the requested view mode.
+ *
+ * Modules defining entity types should use this hook to define the set of
+ * build modes that makes sense for their own display contexts. Third party
+ * modules can also use this hook to define additional build modes for existing
+ * entity types.
+ *
+ * @see entity_view_mode_info()
+ * @see hook_entity_view_mode_info_alter()
+ *
+ * @return
+ *   An array of view modes, keyed by entity type and view mode name. Each view
+ *   mode is described by an array with the following key/value pairs:
+ *   - label: The human-readable name of the view mode
+ */
+function hook_entity_view_mode_info() {
+  // Sample code from node.module:
+
+  $modes['node'] = array(
+    'full' => array(
+      'label' => t('Full node'),
+    ),
+    'teaser' => array(
+      'label' => t('Teaser'),
+    ),
+    'rss' => array(
+      'label' => t('RSS'),
+    ),
+  );
+  // Search integration is provided by node.module, so search-related
+  // view modes for nodes are defined here and not in search.module.
+  if (module_exists('search')) {
+    $modes['node'] += array(
+      'search_index' => array(
+        'label' => t('Search Index'),
+      ),
+      'search_result' => array(
+        'label' => t('Search Result'),
+      ),
+    );
+  }
+
+  return $modes;
+}
+
+/**
+ * Alters entity view modes information.
+ *
+ * @see entity_view_mode_info()
+ * @see hook_entity_view_mode_info()
+ *
+ * @param $view_mode_info
+ *   The array of view modes, keyed by entity type and view mode name.
+ */
+function hook_entity_view_mode_info_alter(&$view_mode_info) {
+  $view_mode_info['some_entity_type']['some_mode']['label'] = t('Some other text');
+  unset($view_mode_info['some_entity_type']['some_other_mode']);
+}
+
+/**
  * Act on entities when loaded.
  *
  * This is a generic load hook called for all entity types loaded via the
Index: modules/taxonomy/taxonomy.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v
retrieving revision 1.552
diff -u -p -r1.552 taxonomy.module
--- modules/taxonomy/taxonomy.module	21 Dec 2009 13:47:32 -0000	1.552
+++ modules/taxonomy/taxonomy.module	21 Dec 2009 19:23:00 -0000
@@ -125,6 +125,21 @@ function taxonomy_entity_info() {
 }
 
 /**
+ * Implements hook_entity_view_mode_info().
+ *
+ * @todo View mode for display as a field (when attached to nodes etc.).
+ */
+function taxonomy_entity_view_mode_info() {
+  $modes['term'] = array(
+    'full' => array(
+      'label' => t('Taxonomy term page'),
+    ),
+  );
+
+  return $modes;
+}
+
+/**
  * Return nodes attached to a term across all field instances.
  *
  * This function requires taxonomy module to be maintaining its own tables,
@@ -179,21 +194,6 @@ function taxonomy_select_nodes($tid, $pa
 }
 
 /**
- * Implements hook_field_build_modes().
- *
- * @TODO: build mode for display as a field (when attached to nodes etc.).
- */
-function taxonomy_field_build_modes($obj_type) {
-  $modes = array();
-  if ($obj_type == 'term') {
-    $modes = array(
-      'full' => t('Taxonomy term page'),
-    );
-  }
-  return $modes;
-}
-
-/**
  * Implements hook_theme().
  */
 function taxonomy_theme() {
Index: modules/translation/translation.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/translation/translation.module,v
retrieving revision 1.68
diff -u -p -r1.68 translation.module
--- modules/translation/translation.module	6 Dec 2009 17:56:05 -0000	1.68
+++ modules/translation/translation.module	21 Dec 2009 20:05:23 -0000
@@ -169,7 +169,7 @@ function translation_form_alter(&$form, 
  * Display translation links with native language names, if this node
  * is part of a translation set.
  */
-function translation_node_view($node, $build_mode) {
+function translation_node_view($node, $view_mode) {
   if (isset($node->tnid) && $translations = translation_node_get_translations($node->tnid)) {
     $path = 'node/' . $node->nid;
     $links = language_negotiation_get_switch_links(LANGUAGE_TYPE_CONTENT, $path);
Index: modules/trigger/trigger.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/trigger/trigger.module,v
retrieving revision 1.57
diff -u -p -r1.57 trigger.module
--- modules/trigger/trigger.module	12 Dec 2009 21:05:20 -0000	1.57
+++ modules/trigger/trigger.module	21 Dec 2009 20:05:51 -0000
@@ -296,8 +296,8 @@ function _trigger_node($node, $hook, $a3
 /**
  * Implements hook_node_view().
  */
-function trigger_node_view($node, $build_mode) {
-  _trigger_node($node, 'node_view', $build_mode);
+function trigger_node_view($node, $view_mode) {
+  _trigger_node($node, 'node_view', $view_mode);
 }
 
 /**
Index: modules/user/user.api.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.api.php,v
retrieving revision 1.17
diff -u -p -r1.17 user.api.php
--- modules/user/user.api.php	21 Dec 2009 13:47:32 -0000	1.17
+++ modules/user/user.api.php	21 Dec 2009 20:06:28 -0000
@@ -314,10 +314,10 @@ function hook_user_logout($account) {
  *
  * @param $account
  *   The user object on which the operation is being performed.
- * @param $build_mode
- *   Build mode, e.g. 'full'.
+ * @param $view_mode
+ *   View mode, e.g. 'full'.
  */
-function hook_user_view($account, $build_mode) {
+function hook_user_view($account, $view_mode) {
   if (user_access('create blog content', $account)) {
     $account->content['summary']['blog'] =  array(
       '#type' => 'user_profile_item',
@@ -402,7 +402,7 @@ function hook_user_role_update($role) {
  * Inform other modules that a user role has been deleted.
  *
  * This hook allows you act when a user role has been deleted.
- * If your module stores references to roles, it's recommended that you 
+ * If your module stores references to roles, it's recommended that you
  * implement this hook and delete existing instances of the deleted role
  * in your module database tables.
  *
Index: modules/user/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.module,v
retrieving revision 1.1093
diff -u -p -r1.1093 user.module
--- modules/user/user.module	21 Dec 2009 13:47:32 -0000	1.1093
+++ modules/user/user.module	21 Dec 2009 20:18:37 -0000
@@ -148,15 +148,15 @@ function user_entity_info() {
 }
 
 /**
- * Implements hook_field_build_modes().
+ * Implements hook_entity_view_mode_info().
  */
-function user_field_build_modes($obj_type) {
-  $modes = array();
-  if ($obj_type == 'user') {
-    $modes = array(
-      'full' => t('User account'),
-    );
-  }
+function user_entity_view_mode_info() {
+  $modes['user'] = array(
+    'full' => array(
+      'label' => t('User account'),
+    ),
+  );
+
   return $modes;
 }
 
@@ -2129,15 +2129,15 @@ function _user_cancel($edit, $account, $
  *
  * @param $account
  *   A user object.
- * @param $build_mode
- *   Build mode, e.g. 'full'.
+ * @param $view_mode
+ *   View mode, e.g. 'full'.
  *
  * @return
  *   An array as expected by drupal_render().
  */
-function user_view($account, $build_mode = 'full') {
+function user_view($account, $view_mode = 'full') {
   // Retrieve all profile fields and attach to $account->content.
-  user_build_content($account, $build_mode);
+  user_build_content($account, $view_mode);
 
   $build = $account->content;
   // We don't need duplicate rendering info in account->content.
@@ -2146,7 +2146,7 @@ function user_view($account, $build_mode
   $build += array(
     '#theme' => 'user_profile',
     '#account' => $account,
-    '#build_mode' => $build_mode,
+    '#view_mode' => $view_mode,
   );
 
   // Allow modules to modify the structured user.
@@ -2160,19 +2160,19 @@ function user_view($account, $build_mode
  *
  * @param $account
  *   A user object.
- * @param $build_mode
- *   Build mode, e.g. 'full'.
+ * @param $view_mode
+ *   View mode, e.g. 'full'.
  */
-function user_build_content($account, $build_mode = 'full') {
+function user_build_content($account, $view_mode = 'full') {
   // Remove previously built content, if exists.
   $account->content = array();
 
   // Build fields content.
-  field_attach_prepare_view('user', array($account->uid => $account), $build_mode);
-  $account->content += field_attach_view('user', $account, $build_mode);
+  field_attach_prepare_view('user', array($account->uid => $account), $view_mode);
+  $account->content += field_attach_view('user', $account, $view_mode);
 
   // Populate $account->content with a render() array.
-  module_invoke_all('user_view', $account, $build_mode);
+  module_invoke_all('user_view', $account, $view_mode);
 }
 
 /**
