Index: modules/node/node.api.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.api.php,v
retrieving revision 1.51
diff -u -r1.51 node.api.php
--- modules/node/node.api.php	22 Dec 2009 20:38:23 -0000	1.51
+++ modules/node/node.api.php	24 Dec 2009 12:27:28 -0000
@@ -545,13 +545,11 @@
 /**
  * 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 @@
  *
  * @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 @@
  * @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 @@
  *
  * @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 @@
  *
  * For a detailed usage example, see node_example.module.
  */
-function hook_view($node, $build_mode = 'full') {
+function hook_view($node, $view_mode = 'full') {
   if (node_is_page($node)) {
     $breadcrumb = array();
     $breadcrumb[] = array('path' => 'example', 'title' => t('example'));
Index: modules/node/node.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.test,v
retrieving revision 1.59
diff -u -r1.59 node.test
--- modules/node/node.test	2 Dec 2009 19:52:23 -0000	1.59
+++ modules/node/node.test	24 Dec 2009 12:27:33 -0000
@@ -630,11 +630,11 @@
 
     $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 @@
     $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.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.1188
diff -u -r1.1188 node.module
--- modules/node/node.module	22 Dec 2009 20:38:23 -0000	1.1188
+++ modules/node/node.module	24 Dec 2009 12:27:31 -0000
@@ -204,8 +204,33 @@
       // Node.module handles its own caching.
       // 'cacheable' => FALSE,
       'bundles' => array(),
+      'view modes' => 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')) {
+    $return['node']['view modes'] += array(
+      'search_index' => array(
+        'label' => t('Search Index'),
+      ),
+      'search_result' => array(
+        'label' => t('Search Result'),
+      ),
+    );
+  }
+
   // Bundles must provide a human readable name so we can create help and error
   // messages, and the path to attach Field admin pages to.
   foreach (node_type_get_names() as $type => $name) {
@@ -219,31 +244,8 @@
       ),
     );
   }
-  return $return;
-}
-
 
-/**
- * Implements hook_field_build_modes().
- */
-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'),
-    );
-    // 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;
+  return $return;
 }
 
 /**
@@ -1167,15 +1169,15 @@
  *
  * @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 +1186,10 @@
   $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 +1202,9 @@
  * 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 +1215,34 @@
  *   - 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 +1256,7 @@
   );
 
   // 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);
 }
 
 /**
@@ -1345,15 +1347,15 @@
  *
  * 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'];
 
@@ -2140,18 +2142,18 @@
  *
  * @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.tpl.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.tpl.php,v
retrieving revision 1.29
diff -u -r1.29 node.tpl.php
--- modules/node/node.tpl.php	6 Dec 2009 01:00:27 -0000	1.29
+++ modules/node/node.tpl.php	24 Dec 2009 12:27:33 -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/field/field.crud.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/field.crud.inc,v
retrieving revision 1.43
diff -u -r1.43 field.crud.inc
--- modules/field/field.crud.inc	20 Dec 2009 19:45:07 -0000	1.43
+++ modules/field/field.crud.inc	24 Dec 2009 12:27:14 -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 @@
  *     - 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 @@
 
   // 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 @@
   $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 -r1.28 field.default.inc
--- modules/field/field.default.inc	21 Dec 2009 13:47:32 -0000	1.28
+++ modules/field/field.default.inc	24 Dec 2009 12:27:14 -0000
@@ -114,7 +114,7 @@
  *   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 @@
  *   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 @@
 
   // 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 @@
         '#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.api.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/field.api.php,v
retrieving revision 1.56
diff -u -r1.56 field.api.php
--- modules/field/field.api.php	21 Dec 2009 13:47:32 -0000	1.56
+++ modules/field/field.api.php	24 Dec 2009 12:27:11 -0000
@@ -1030,7 +1030,7 @@
  *   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 @@
  **********************************************************************/
 
 /**
- * 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.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/field.module,v
retrieving revision 1.55
diff -u -r1.55 field.module
--- modules/field/field.module	20 Dec 2009 21:08:26 -0000	1.55
+++ modules/field/field.module	24 Dec 2009 12:27:16 -0000
@@ -368,18 +368,6 @@
 }
 
 /**
- * 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 @@
  *   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 @@
       $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 @@
     $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 @@
     '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/field.info.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/field.info.inc,v
retrieving revision 1.35
diff -u -r1.35 field.info.inc
--- modules/field/field.info.inc	20 Dec 2009 22:38:05 -0000	1.35
+++ modules/field/field.info.inc	24 Dec 2009 12:27:15 -0000
@@ -29,7 +29,6 @@
   entity_info_cache_clear();
 
   _field_info_collate_types(TRUE);
-  drupal_static_reset('field_build_modes');
   _field_info_collate_fields(TRUE);
 }
 
@@ -280,14 +279,15 @@
 
   $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.
+  $entity_info = entity_get_info($instance['object_type']);
+  foreach ($entity_info['view modes'] as $view_mode => $info) {
+    if (!isset($instance['display'][$view_mode])) {
+      $instance['display'][$view_mode] = $instance['display']['full'];
     }
   }
 
@@ -301,7 +301,7 @@
  *   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.attach.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/field.attach.inc,v
retrieving revision 1.66
diff -u -r1.66 field.attach.inc
--- modules/field/field.attach.inc	21 Dec 2009 13:47:32 -0000	1.66
+++ modules/field/field.attach.inc	24 Dec 2009 12:27:13 -0000
@@ -143,7 +143,7 @@
  *   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 @@
 /**
  * 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 @@
  *     '#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 @@
  *   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 @@
   $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 @@
   $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/system/system.api.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.api.php,v
retrieving revision 1.110
diff -u -r1.110 system.api.php
--- modules/system/system.api.php	17 Dec 2009 08:00:59 -0000	1.110
+++ modules/system/system.api.php	24 Dec 2009 12:27:38 -0000
@@ -55,7 +55,7 @@
  *
  * @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.
@@ -109,6 +109,15 @@
  *       - access callback: As in hook_menu(). 'user_access' will be assumed if
  *         no value is provided.
  *       - access arguments: As in hook_menu().
+ *   - view modes: An array describing the view modes for the entity type. View
+ *     modes let entities be displayed differently depending on the 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. Keys of the array are view mode names. 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_info() {
   $return = array(
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 -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	24 Dec 2009 12:27:22 -0000
@@ -117,7 +117,7 @@
             '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 @@
 }
 
 /**
- * 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.
+    $entity_info = entity_get_info($obj_type);
     foreach ($info[$obj_type] as $tab => $values) {
       $modes = array();
-      foreach ($info[$obj_type][$tab]['build modes'] as $mode) {
-        if (isset($active_modes[$mode])) {
-          $modes[$mode] = $active_modes[$mode];
+      foreach ($info[$obj_type][$tab]['view modes'] as $mode) {
+        if (isset($entity_info['view 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 @@
     }
   }
   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 @@
  *   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 @@
  *   );
  * @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/field_ui/field_ui.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/field_ui/field_ui.admin.inc,v
retrieving revision 1.32
diff -u -r1.32 field_ui.admin.inc
--- modules/field_ui/field_ui.admin.inc	23 Dec 2009 16:49:00 -0000	1.32
+++ modules/field_ui/field_ui.admin.inc	24 Dec 2009 12:27:22 -0000
@@ -469,8 +469,8 @@
     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 @@
  * 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 @@
   // 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 @@
 
     $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'],
@@ -631,7 +631,6 @@
   return $form;
 }
 
-
 /**
  * Theme preprocess function for field_ui-display-overview-form.tpl.php.
  */
@@ -639,7 +638,13 @@
   $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);
+  $entity_info = entity_get_info($form['#object_type']);
+  $view_modes_info = $entity_info['view modes'];
+  $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 @@
   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: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.1069
diff -u -r1.1069 common.inc
--- includes/common.inc	23 Dec 2009 15:39:57 -0000	1.1069
+++ includes/common.inc	24 Dec 2009 12:27:06 -0000
@@ -6325,6 +6325,7 @@
 function entity_info_cache_clear() {
   drupal_static_reset('entity_get_info');
   cache_clear_all('entity_info', 'cache');
+  drupal_static_reset('entity_view_mode_info');
 }
 
 /**
Index: modules/user/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.module,v
retrieving revision 1.1094
diff -u -r1.1094 user.module
--- modules/user/user.module	22 Dec 2009 14:47:14 -0000	1.1094
+++ modules/user/user.module	24 Dec 2009 12:27:44 -0000
@@ -142,25 +142,17 @@
           ),
         ),
       ),
+      'view modes' => array(
+        'full' => array(
+          'label' => t('User account'),
+        ),
+      ),
     ),
   );
   return $return;
 }
 
 /**
- * Implements hook_field_build_modes().
- */
-function user_field_build_modes($obj_type) {
-  $modes = array();
-  if ($obj_type == 'user') {
-    $modes = array(
-      'full' => t('User account'),
-    );
-  }
-  return $modes;
-}
-
-/**
  * Implements hook_field_extra_fields().
  */
 function user_field_extra_fields($bundle) {
@@ -2129,15 +2121,15 @@
  *
  * @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 +2138,7 @@
   $build += array(
     '#theme' => 'user_profile',
     '#account' => $account,
-    '#build_mode' => $build_mode,
+    '#view_mode' => $view_mode,
   );
 
   // Allow modules to modify the structured user.
@@ -2160,19 +2152,19 @@
  *
  * @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);
 }
 
 /**
Index: modules/user/user.api.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.api.php,v
retrieving revision 1.17
diff -u -r1.17 user.api.php
--- modules/user/user.api.php	21 Dec 2009 13:47:32 -0000	1.17
+++ modules/user/user.api.php	24 Dec 2009 12:27:41 -0000
@@ -314,10 +314,10 @@
  *
  * @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 @@
  * 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/taxonomy/taxonomy.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v
retrieving revision 1.552
diff -u -r1.552 taxonomy.module
--- modules/taxonomy/taxonomy.module	21 Dec 2009 13:47:32 -0000	1.552
+++ modules/taxonomy/taxonomy.module	24 Dec 2009 12:27:39 -0000
@@ -98,6 +98,12 @@
         'bundle' => 'machine_name',
       ),
       'bundles' => array(),
+      'view modes' => array(
+        // @todo View mode for display as a field (when attached to nodes etc).
+        'full' => array(
+          'label' => t('Taxonomy term page'),
+        ),
+      ),
     ),
   );
   foreach (taxonomy_vocabulary_get_names() as $machine_name => $vocabulary) {
@@ -179,21 +185,6 @@
 }
 
 /**
- * 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/field/tests/field.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/tests/field.test,v
retrieving revision 1.9
diff -u -r1.9 field.test
--- modules/field/tests/field.test	20 Dec 2009 21:08:26 -0000	1.9
+++ modules/field/tests/field.test	24 Dec 2009 12:27:20 -0000
@@ -1339,10 +1339,11 @@
     $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)));
+    $entity_info = entity_get_info('test_entity');
+    foreach ($entity_info['view modes'] 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 +1808,7 @@
     }
     $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 +1818,9 @@
       $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 +2328,13 @@
     $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 +2412,17 @@
     $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 -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	24 Dec 2009 12:27:20 -0000
@@ -11,6 +11,15 @@
  */
 function field_test_entity_info() {
   $bundles = variable_get('field_test_bundles', array('test_bundle' => array('label' => 'Test Bundle')));
+  $test_entity_modes = array(
+    'full' => array(
+      'label' => t('Full object'),
+    ),
+    'teaser' => array(
+      'label' => t('Teaser'),
+    ),
+  );
+
   return array(
     'test_entity' => array(
       'name' => t('Test Entity'),
@@ -22,6 +31,7 @@
       'cacheable' => FALSE,
       'bundles' => $bundles,
       'fieldable' => TRUE,
+      'view modes' => $test_entity_modes,
     ),
     // This entity type doesn't get form handling for now...
     'test_cacheable_entity' => array(
@@ -34,6 +44,7 @@
       'fieldable' => TRUE,
       'cacheable' => TRUE,
       'bundles' => $bundles,
+      'view modes' => $test_entity_modes,
     ),
   );
 }
@@ -110,20 +121,6 @@
 }
 
 /**
- * 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/trigger/trigger.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/trigger/trigger.module,v
retrieving revision 1.57
diff -u -r1.57 trigger.module
--- modules/trigger/trigger.module	12 Dec 2009 21:05:20 -0000	1.57
+++ modules/trigger/trigger.module	24 Dec 2009 12:27:40 -0000
@@ -296,8 +296,8 @@
 /**
  * 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/book/book.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/book/book.module,v
retrieving revision 1.531
diff -u -r1.531 book.module
--- modules/book/book.module	21 Dec 2009 13:47:31 -0000	1.531
+++ modules/book/book.module	24 Dec 2009 12:27:07 -0000
@@ -87,11 +87,11 @@
 /**
  * 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,16 +220,15 @@
 }
 
 /**
- * Implements hook_field_build_modes().
+ * Implements hook_entity_info_alter().
  */
-function book_field_build_modes($obj_type) {
-  $modes = array();
-  if ($obj_type == 'node') {
-    $modes = array(
-      'print' => t('Print'),
-    );
-  }
-  return $modes;
+function book_entity_info_alter(&$info) {
+  // Add the 'Print' view mode for nodes.
+  $info['node']['view modes'] += array(
+    'print' => array(
+      'label' => t('Print'),
+    ),
+  );
 }
 
 /**
@@ -759,8 +758,8 @@
 /**
  * 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 +768,8 @@
     }
   }
 
-  if ($build_mode != 'rss') {
-    book_node_view_link($node, $build_mode);
+  if ($view_mode != 'rss') {
+    book_node_view_link($node, $view_mode);
   }
 }
 
Index: modules/translation/translation.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/translation/translation.module,v
retrieving revision 1.68
diff -u -r1.68 translation.module
--- modules/translation/translation.module	6 Dec 2009 17:56:05 -0000	1.68
+++ modules/translation/translation.module	24 Dec 2009 12:27:40 -0000
@@ -169,7 +169,7 @@
  * 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/blog/blog.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/blog/blog.module,v
retrieving revision 1.347
diff -u -r1.347 blog.module
--- modules/blog/blog.module	22 Dec 2009 20:38:23 -0000	1.347
+++ modules/blog/blog.module	24 Dec 2009 12:27:06 -0000
@@ -66,7 +66,7 @@
 /**
  * Implements hook_view().
  */
-function blog_view($node, $build_mode) {
+function blog_view($node, $view_mode) {
   if (node_is_page($node)) {
     // 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 @@
 /**
  * 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/poll/poll.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/poll/poll.module,v
retrieving revision 1.329
diff -u -r1.329 poll.module
--- modules/poll/poll.module	14 Dec 2009 20:38:15 -0000	1.329
+++ modules/poll/poll.module	24 Dec 2009 12:27:34 -0000
@@ -598,7 +598,7 @@
 /**
  * Implements hook_view().
  */
-function poll_view($node, $build_mode = 'full') {
+function poll_view($node, $view_mode = 'full') {
   global $user;
   $output = '';
 
@@ -606,7 +606,7 @@
     $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 @@
 /**
  * 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/forum/forum.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/forum/forum.module,v
retrieving revision 1.545
diff -u -r1.545 forum.module
--- modules/forum/forum.module	22 Dec 2009 20:38:23 -0000	1.545
+++ modules/forum/forum.module	24 Dec 2009 12:27:23 -0000
@@ -235,7 +235,7 @@
 /**
  * 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.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/locale/locale.test,v
retrieving revision 1.55
diff -u -r1.55 locale.test
--- modules/locale/locale.test	7 Dec 2009 06:07:19 -0000	1.55
+++ modules/locale/locale.test	24 Dec 2009 12:27:26 -0000
@@ -1712,8 +1712,8 @@
     $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/locale/locale.field.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/locale/locale.field.inc,v
retrieving revision 1.5
diff -u -r1.5 locale.field.inc
--- modules/locale/locale.field.inc	11 Dec 2009 16:49:40 -0000	1.5
+++ modules/locale/locale.field.inc	24 Dec 2009 12:27:23 -0000
@@ -65,7 +65,7 @@
           // 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/comment/comment.api.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.api.php,v
retrieving revision 1.14
diff -u -r1.14 comment.api.php
--- modules/comment/comment.api.php	21 Dec 2009 13:47:32 -0000	1.14
+++ modules/comment/comment.api.php	24 Dec 2009 12:27:07 -0000
@@ -91,7 +91,7 @@
  */
 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.820
diff -u -r1.820 comment.module
--- modules/comment/comment.module	22 Dec 2009 20:38:23 -0000	1.820
+++ modules/comment/comment.module	24 Dec 2009 12:27:10 -0000
@@ -484,11 +484,11 @@
 /**
  * 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 @@
         );
       }
     }
-    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 @@
     // 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.
     if ($node->comment && node_is_page($node) && empty($node->in_preview) && user_access('access comments')) {
       $node->content['comments'] = comment_node_page_additions($node);
     }
@@ -778,15 +778,15 @@
  *   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.
@@ -796,7 +796,7 @@
     '#theme' => 'comment',
     '#comment' => $comment,
     '#node' => $node,
-    '#build_mode' => $build_mode,
+    '#view_mode' => $view_mode,
   );
 
   $prefix = '';
@@ -831,16 +831,16 @@
  * 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();
 
@@ -850,8 +850,8 @@
   );
 
   // 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(
@@ -862,7 +862,7 @@
   }
 
   // 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);
 }
 
 /**
@@ -933,21 +933,21 @@
  *   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++;
   }
@@ -1408,7 +1408,7 @@
   catch (Exception $e) {
     $transaction->rollback('comment', $e->getMessage(), array(), WATCHDOG_ERROR);
   }
-  
+
 }
 
 /**
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 -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	24 Dec 2009 12:27:20 -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/statistics/statistics.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/statistics/statistics.module,v
retrieving revision 1.328
diff -u -r1.328 statistics.module
--- modules/statistics/statistics.module	14 Dec 2009 20:38:15 -0000	1.328
+++ modules/statistics/statistics.module	24 Dec 2009 12:27:34 -0000
@@ -106,8 +106,8 @@
 /**
  * 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/node/tests/node_test.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/tests/node_test.module,v
retrieving revision 1.8
diff -u -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	24 Dec 2009 12:27:33 -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 @@
     );
   }
 
-  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>',
