Index: theme/content-admin-display-overview-form.tpl.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cck/theme/Attic/content-admin-display-overview-form.tpl.php,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 content-admin-display-overview-form.tpl.php
--- theme/content-admin-display-overview-form.tpl.php	12 Sep 2008 14:33:12 -0000	1.1.2.1
+++ theme/content-admin-display-overview-form.tpl.php	22 Sep 2008 11:49:01 -0000
@@ -9,11 +9,11 @@
     <thead>
       <tr>
         <th><?php print t('Field'); ?></th>
-        <?php if ($simple): ?>
+        <?php if ($basic): ?>
           <th><?php print t('Label'); ?></th>
         <?php endif; ?>
-        <?php foreach ($contexts as $context => $title): ?>
-          <th><?php print $title; ?></th>
+        <?php foreach ($contexts as $key => $value): ?>
+          <th><?php print $value['title']; ?></th>
         <?php endforeach; ?>
       </tr>
     </thead>
@@ -23,7 +23,7 @@
       foreach ($rows as $row): ?>
         <tr class="<?php print $count % 2 == 0 ? 'odd' : 'even'; ?>">
           <td><?php print $row->indentation; ?><span class="<?php print $row->label_class; ?>"><?php print $row->human_name; ?></span></td>
-          <?php if ($simple): ?>
+          <?php if ($basic): ?>
             <td><?php print $row->label; ?></td>
           <?php endif; ?>
           <?php foreach ($contexts as $context => $title): ?>
Index: theme/theme.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cck/theme/Attic/theme.inc,v
retrieving revision 1.1.2.3
diff -u -r1.1.2.3 theme.inc
--- theme/theme.inc	21 Sep 2008 13:00:56 -0000	1.1.2.3
+++ theme/theme.inc	22 Sep 2008 11:49:01 -0000
@@ -131,7 +131,7 @@
   }
   $order = $dummy ? explode(' ', trim(drupal_render($dummy))) : array();
 
-  if ($contexts_selector == CONTENT_CONTEXTS_SIMPLE) {
+  if ($contexts_selector == 'basic') {
     $help = t("Configure how this content type's fields and field labels should be displayed when it's viewed in teaser and full-page mode.");
   }
   else {
@@ -145,8 +145,8 @@
     return;
   }
 
-  $vars['simple'] = $contexts_selector == CONTENT_CONTEXTS_SIMPLE;
-  $vars['contexts'] = _content_admin_display_contexts($contexts_selector);
+  $vars['basic'] = $contexts_selector == 'basic';
+  $vars['contexts'] = content_build_modes($contexts_selector);
 
   $rows = array();
   foreach ($order as $key) {
Index: modules/fieldgroup/fieldgroup.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cck/modules/fieldgroup/fieldgroup.module,v
retrieving revision 1.79.2.29
diff -u -r1.79.2.29 fieldgroup.module
--- modules/fieldgroup/fieldgroup.module	21 Sep 2008 00:52:27 -0000	1.79.2.29
+++ modules/fieldgroup/fieldgroup.module	22 Sep 2008 11:49:01 -0000
@@ -140,7 +140,7 @@
     '#required' => FALSE,
   );
   module_load_include('inc', 'content', 'includes/content.admin');
-  foreach (array_merge(array_keys(_content_admin_display_contexts()), array('label')) as $key) {
+  foreach (array_merge(array_keys(content_build_modes()), array('label')) as $key) {
     $form['settings']['display'][$key] = array('#type' => 'value', '#value' => $group['settings']['display'][$key]);
   }
   $form['weight'] = array('#type' => 'hidden', '#default_value' => $group['weight']);
@@ -430,7 +430,7 @@
     'display' => array('description' => '', 'label' => 'above'),
   );
   module_load_include('inc', 'content', 'includes/content.admin');
-  foreach (array_keys(_content_admin_display_contexts()) as $key) {
+  foreach (array_keys(content_build_modes()) as $key) {
     $settings['display'][$key]['format'] = 'fieldset';
   }
   return $settings;
Index: includes/content.token.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cck/includes/content.token.inc,v
retrieving revision 1.5.2.2
diff -u -r1.5.2.2 content.token.inc
--- includes/content.token.inc	17 Sep 2008 20:31:59 -0000	1.5.2.2
+++ includes/content.token.inc	22 Sep 2008 11:49:01 -0000
@@ -1,12 +1,30 @@
 <?php
 // $Id: content.token.inc,v 1.5.2.2 2008/09/17 20:31:59 yched Exp $
 
+/**
+ * Implementation of hook_content_build_modes
+ * (on behalf of token.module)
+ */
+function token_content_build_modes() {
+  return array(
+    'token' => array(
+      'title' => t('Token'),
+      'build modes' => array(
+        'token' => array(
+          'title' => t('Token'),
+          'views style' => FALSE,
+        ),
+      ),
+    ),
+  );
+}
+
 // Two helper functions that generate appropriate tokens for CCK-added fields.
 function content_token_values($type, $object = NULL) {
   $tokens = array();
   if ($type == 'node') {
     $node = $object;
-    $node->build_mode = NODE_BUILD_NORMAL;
+    $node->build_mode = 'token';
     $node->content = array();
     content_view($node);
     // The formatted values will only be known after the content has been rendered.
Index: includes/content.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cck/includes/content.admin.inc,v
retrieving revision 1.181.2.42
diff -u -r1.181.2.42 content.admin.inc
--- includes/content.admin.inc	18 Sep 2008 23:36:41 -0000	1.181.2.42
+++ includes/content.admin.inc	22 Sep 2008 11:49:00 -0000
@@ -503,7 +503,7 @@
  * Form includes form widgets to select which fields appear for teaser, full node
  * and how the field labels should be rendered.
  */
-function content_display_overview_form(&$form_state, $type_name, $contexts_selector = CONTENT_CONTEXTS_SIMPLE) {
+function content_display_overview_form(&$form_state, $type_name, $contexts_selector = 'basic') {
   // Gather type information.
   $type = content_types($type_name);
   $field_types = _content_field_types();
@@ -514,7 +514,7 @@
     $groups = fieldgroup_groups($type['type']);
     $group_options = _fieldgroup_groups_label($type['type']);
   }
-  $contexts = _content_admin_display_contexts($contexts_selector);
+  $contexts = content_build_modes($contexts_selector);
 
   $form = array(
     '#tree' => TRUE,
@@ -549,7 +549,7 @@
     );
 
     // Label
-    if ($contexts_selector == CONTENT_CONTEXTS_SIMPLE) {
+    if ($contexts_selector == 'basic') {
       $form[$name]['label']['format'] = array(
         '#type' => 'select',
         '#options' => $label_options,
@@ -563,7 +563,7 @@
       $options[$formatter_name] = $formatter_info['label'];
     }
     $options['hidden'] = t('<Hidden>');
-    foreach ($contexts as $key => $title) {
+    foreach ($contexts as $key => $value) {
       $form[$name][$key]['format'] = array(
         '#type' => 'select',
         '#options' => $options,
@@ -593,7 +593,7 @@
       'human_name' => array('#value' => check_plain($group['label'])),
       'weight' => array('#type' => 'value', '#value' => $weight),
     );
-    if ($contexts_selector == CONTENT_CONTEXTS_SIMPLE) {
+    if ($contexts_selector == 'basic') {
       $form[$name]['label'] = array(
         '#type' => 'select',
         '#options' => $label_options,
Index: includes/content.crud.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cck/includes/content.crud.inc,v
retrieving revision 1.76.2.9
diff -u -r1.76.2.9 content.crud.inc
--- includes/content.crud.inc	26 Aug 2008 22:45:40 -0000	1.76.2.9
+++ includes/content.crud.inc	22 Sep 2008 11:49:01 -0000
@@ -85,7 +85,7 @@
     $widget['widget_active'] = 1;
   }
 
-  $settings_names = array_merge(array('label'), array_keys(_content_admin_display_contexts()));
+  $settings_names = array_merge(array('label'), array_keys(content_build_modes()));
   $widget['display_settings'] = array();
   foreach ($settings_names as $name) {
     $widget['display_settings'][$name]['format'] = ($name == 'label') ? 'above' : 'default';
Index: content.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cck/content.module,v
retrieving revision 1.301.2.58
diff -u -r1.301.2.58 content.module
--- content.module	18 Sep 2008 19:51:44 -0000	1.301.2.58
+++ content.module	22 Sep 2008 11:48:59 -0000
@@ -8,10 +8,6 @@
 define('CONTENT_DB_STORAGE_PER_FIELD', 0);
 define('CONTENT_DB_STORAGE_PER_CONTENT_TYPE', 1);
 
-define('CONTENT_CONTEXTS_SIMPLE', 0);
-define('CONTENT_CONTEXTS_ADVANCED', 1);
-define('CONTENT_CONTEXTS_ALL', 2);
-
 define('CONTENT_CALLBACK_NONE', 0x0001);
 define('CONTENT_CALLBACK_DEFAULT', 0x0002);
 define('CONTENT_CALLBACK_CUSTOM', 0x0004);
@@ -130,19 +126,16 @@
         'type' => MENU_LOCAL_TASK,
         'weight' => 2,
       );
-      $items['admin/content/node-type/'. $type_url_str .'/display/general'] = array(
-        'title' => 'General',
-        'page arguments' => array('content_display_overview_form', $type_name),
-        'type' => MENU_DEFAULT_LOCAL_TASK,
-        'weight' => 0,
-      );
-      $items['admin/content/node-type/'. $type_url_str .'/display/advanced'] = array(
-        'title' => 'Advanced',
-        'page arguments' => array('content_display_overview_form', $type_name, (string)CONTENT_CONTEXTS_ADVANCED),
-        'access arguments' => array('administer content types'),
-        'type' => MENU_LOCAL_TASK,
-        'weight' => 1,
-      );
+      $contexts = content_build_modes('_menus');
+      foreach ($contexts as $key => $tab) {
+        $items['admin/content/node-type/'. $type_url_str .'/display/'. $key] = array(
+          'title' => $tab['title'],
+          'page arguments' => array('content_display_overview_form', $type_name, $key),
+          'access arguments' => array('administer content types'),
+          'type' => $key == 'basic' ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK,
+          'weight' => $key == 'basic' ? 0 : 1,
+        );
+      }
       // Cast as an array in case this is called before any fields have
       // been added, like when a new content type is created.
       foreach ((array) $content_type['fields'] as $field) {
@@ -1689,25 +1682,117 @@
 }
 
 /**
- * Array of possible display contexts for fields.
+ * Registry of available node build modes.
+ *
+ * @param $selector
+ *   Determines what information should be returned.
+ * @return
+ *   Depending on the value of the $selector parameter:
+ *   - NULL: a flat list of all available build modes.
+ *   The other two options are mainly used internally by CCK's UI:
+ *   - '_tabs': the list of tabs to be shown on the 'Display fields' screens.
+ *   - a string tab id: the build modes in this tab.
  */
-function _content_admin_display_contexts($selector = CONTENT_CONTEXTS_ALL) {
-  $contexts = array();
+function content_build_modes($selector = NULL) {
+  static $info;
 
-  if ($selector == CONTENT_CONTEXTS_ALL || $selector == CONTENT_CONTEXTS_SIMPLE) {
-    $contexts['teaser'] = t('Teaser');
-    $contexts['full'] = t('Full node');
+  if (!isset($info)) {
+    $data = module_invoke_all('content_build_modes');
+    $flat = array();
+    foreach ($data as $tab) {
+      $flat = array_merge($flat, $tab['build modes']);
+    }
+    $info = array('tabs' => $data, 'build modes' => $flat);
   }
 
-  if ($selector == CONTENT_CONTEXTS_ALL || $selector == CONTENT_CONTEXTS_ADVANCED) {
-    $contexts[NODE_BUILD_RSS] = t('RSS Item');
-    if (module_exists('search')) {
-      $contexts[NODE_BUILD_SEARCH_INDEX] = t('Search Index');
-      $contexts[NODE_BUILD_SEARCH_RESULT] = t('Search Result');
-    }
+  if ($selector === '_tabs') {
+    return $info['tabs'];
   }
+  elseif (isset($selector) && isset($info['tabs'][$selector])) {
+    return $info['tabs'][$selector]['contexts'];
+  }
+  else {
+    return $info['build modes'];
+  }
+}
 
-  return $contexts;
+/**
+ * Implementations of hook_content_build_modes
+ * on behalf of core modules.
+ *
+ * @return
+ * An array describing the build modes used by the module.
+ * They are grouped by secondary tabs on CCK's 'Display fields' screens.
+ *
+ * Expected format:
+ * array(
+ *   // The first level keys (tab1_url, tab2_url) will be used to generate
+ *   // the url of the tab: admin/content/node-type/[type_name]/display/[tab1_url]
+ *   // A module can add its render modes to a tab defined by another module.
+ *   // In this case, there's no need to provide a 'title' for this tab.
+ *   'tab1_url' => array(
+ *     'title' => t('The human-readable title of the tab'),
+ *     'build modes' => array(
+ *       // The keys of the 'context' array are the values used in $node->build_mode.
+ *       'mymodule_mode1' => array(
+ *         'title' => t('The human-readable name of the build mode'),
+ *        // The 'views style' property determines if the render mode should be
+ *        // available as an option in Views' 'node' row style (not implemented yet).
+ *        'views style' => TRUE,
+ *       ),
+ *       'mymodule_mode2' => array(
+ *         'title' => t('Mode 2'),
+ *         'views style' => TRUE,
+ *       ),
+ *     ),
+ *   ),
+ *   'tab2_url' => array(
+ *     // ...
+ *   ),
+ * );
+ */
+function node_content_build_modes() {
+  return array(
+    'basic' => array(
+      'title' => t('Basic'),
+      'build modes' => array(
+        'teaser' => array(
+          'title' => t('Teaser'),
+          'views style' => TRUE,
+        ),
+        'full' => array(
+          'title' => t('Full node'),
+          'views style' => TRUE,
+        ),
+      ),
+    ),
+    'rss' => array(
+      'title' => t('RSS'),
+      'build modes' => array(
+        NODE_BUILD_RSS => array(
+          'title' => t('RSS'),
+          'views style' => FALSE,
+        ),
+      ),
+    ),
+  );
+}
+function search_content_build_modes() {
+  return array(
+    'search' => array(
+      'title' => t('Search'),
+      'build modes' => array(
+        NODE_BUILD_SEARCH_INDEX => array(
+          'title' => t('Search Index'),
+          'views style' => FALSE,
+        ),
+        NODE_BUILD_SEARCH_RESULT => array(
+          'title' => t('Search Result'),
+          'views style' => FALSE,
+        ),
+      ),
+    ),
+  );
 }
 
 /**
