Index: content_admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cck/content_admin.inc,v
retrieving revision 1.28.2.16
diff -u -r1.28.2.16 content_admin.inc
--- content_admin.inc	10 Jan 2007 12:52:17 -0000	1.28.2.16
+++ content_admin.inc	13 Jan 2007 00:09:36 -0000
@@ -786,6 +786,137 @@
   return 'admin/content/types/'. $type['url_str'] .'/fields';
 }
 
+function content_admin_field_display_form($type_name) {
+  $form = array();
+
+  $type = content_types($type_name);
+  $field_types = _content_field_types();
+
+  // Create a dummy node form to produce an array of fields and weights
+  // added to the node by content.module.
+  $dummy_node = new StdClass();
+  $dummy_node->type = $type['type'];
+  $dummy_form = array_merge(node_form($dummy_node), content_form($dummy_node));
+
+  if (!$type['fields']) {
+    drupal_set_message(t('There are no fields configured for this content type.'));
+  }
+
+  if (!$type['fields'] && !$form['#groups']) {
+    return $form;
+  }
+
+  // Iterate through the dummy form and add top-level fields and weights to a table.
+  // Construct the table values in an array '#table' that FAPI will ignore, keyed on the item's weight.
+  // Create separate form elements for each weight and group value and put a placeholder for each in #table.
+
+  $form['#tree'] = TRUE;
+  foreach ($dummy_form as $key => $value) {
+    // Limiting weight to < 10 will keep workflow and submit elements from being added to the overview table.
+    // They're outside the weight range allowed for CCK fields, so won't interfere with field placement.
+    if (is_array($value) && (isset($value['#weight']) || $key == 'body_filter') && $value['#weight'] <= 10) {
+      if (substr($key, 0, 6) == 'field_') {
+        $form['fields'][$key] = _content_admin_build_display_row($type['fields'][$key], $field_types);
+      }
+    }
+  }
+
+  $form['type_name'] = array('#type' => 'hidden', '#value' => $type['type']);
+  $form['submit'] = array('#type' => 'submit', '#value' => t('Submit'));
+
+  return $form;
+}
+
+function theme_content_admin_field_display_form($form) {
+  $header = array(t('Field'), t('Type'), t('Label'));
+  foreach (_content_admin_display_contexts() as $key => $title) {
+    $header[] = $title;
+  }
+  $rows = array();
+
+  foreach (element_children($form['fields']) as $field) {
+    $row = array();
+    foreach (element_children($form['fields'][$field]) as $key) {
+      $row[] = drupal_render($form['fields'][$field][$key]);
+    }
+    $rows[] = $row;
+  }
+
+  $output  = theme('table', $header, $rows, array('class' => 'content-field-overview'));
+  $output .= drupal_render($form);
+  return $output;
+}
+
+function content_admin_field_display_form_submit($form_id, $form_values) {
+  $type = $form_values['type_name'];
+  foreach ($form_values['fields'] as $fieldname => $fieldvalues) {
+    $display_settings = array();
+    foreach ($fieldvalues as $key => $value) {
+      $display_settings[$key] = $value;
+    }
+
+    db_query("UPDATE {node_field_instance} SET display_settings = '%s' WHERE type_name = '%s' AND field_name = '%s'",
+      serialize($display_settings), $form_values['type_name'], $fieldname);
+  }
+
+  content_clear_type_cache();
+}
+
+function _content_admin_build_display_row($field, $field_types) {
+  $defaults = $field['display_settings'];
+
+  foreach ($field_types[$field['type']]['formatters'] as $name => $formatter_info) {
+    $options[$name] = $formatter_info['label'];
+  }
+
+  $label_options = array(
+    'inline' => t('Inline'),
+    'header' => t('Header'),
+  );
+
+  $row = array();
+  $row['type_label']  = array('#value' => $field['widget']['label']);
+  $row['type']        = array('#value' => $field_types[$field['type']]['label']);
+
+  $row['label'] = array(
+    '#prefix' => '<div class="container-inline">',
+    '#suffix' => '</div>',
+  );
+  $row['label']['enabled'] = array(
+    '#type' => 'checkbox',
+    '#default_value' => isset($defaults['label']['enabled']) ? $defaults['label']['enabled'] : 1,
+  );
+  $row['label']['format'] = array(
+    '#type' => 'select',
+    '#options' => $label_options,
+    '#default_value' => isset($defaults['label']['format']) ? $defaults['label']['format'] : 'header',
+  );
+
+  foreach (_content_admin_display_contexts() as $key => $title) {
+    $row[$key] = array(
+      '#prefix' => '<div class="container-inline">',
+      '#suffix' => '</div>',
+    );
+    $row[$key]['enabled'] = array(
+      '#type' => 'checkbox',
+      '#default_value' => isset($defaults[$key]['enabled']) ? $defaults[$key]['enabled'] : 1,
+    );
+    $row[$key]['format'] = array(
+      '#type' => 'select',
+      '#options' => $options,
+      '#default_value' => isset($defaults[$key]['format']) ? $defaults[$key]['format'] : NULL,
+    );
+  }
+  return $row;
+}
+
+function _content_admin_display_contexts() {
+  return array(
+    'teaser' => t('Teaser'),
+    'full' => t('Full'),
+    'page' => t('Page'),
+  );
+}
 
 /**
  * Perform adds, alters, and drops as needed to synchronize the database with
Index: content.css
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cck/content.css,v
retrieving revision 1.2.2.5
diff -u -r1.2.2.5 content.css
--- content.css	5 Jan 2007 23:33:23 -0000	1.2.2.5
+++ content.css	13 Jan 2007 00:05:59 -0000
@@ -15,3 +15,17 @@
   text-align:center;
 }
 
+.field .field-label,
+.field .field-label-inline,
+.field .field-label-inline-first {
+  font-weight:bold;
+}
+
+.field .field-label-inline,
+.field .field-label-inline-first {
+  display:inline;
+}
+
+.field .field-label-inline {
+  visibility:hidden;
+}
Index: content.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cck/content.install,v
retrieving revision 1.14.2.6
diff -u -r1.14.2.6 content.install
--- content.install	7 Jan 2007 00:06:36 -0000	1.14.2.6
+++ content.install	13 Jan 2007 00:09:36 -0000
@@ -28,6 +28,7 @@
         label varchar(255) NOT NULL default '',
         widget_type varchar(32) NOT NULL default '',
         widget_settings mediumtext NOT NULL,
+        display_settings mediumtext NOT NULL,
         description mediumtext NOT NULL,
         PRIMARY KEY  (field_name,type_name)
       ) /*!40100 DEFAULT CHARACTER SET utf8 */");
@@ -50,6 +51,7 @@
         label varchar(255) NOT NULL default '',
         widget_type varchar(32) NOT NULL default '',
         widget_settings text NOT NULL,
+        display_settings text NOT NULL,
         description text NOT NULL,
         PRIMARY KEY  (field_name,type_name)
       )");
@@ -285,3 +287,24 @@
 
   return $ret;
 }
+
+/**
+ * Add display_settings column
+ */
+function content_update_1002() {
+  $ret = array();
+
+  switch ($GLOBALS['db_type']) {
+    case 'pgsql':
+      db_add_column($ret, 'node_field_instance', 'display_settings', 'text', array('not null' => TRUE, 'default' => ''));
+      break;
+
+    case 'mysql':
+    case 'mysqli':
+      // TODO : why not db_add_column ?
+      $ret[] = update_sql("ALTER TABLE {node_field_instance} ADD COLUMN display_settings mediumtext NOT NULL");
+      break;
+  }
+
+  return $ret;
+}
Index: content.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cck/content.module,v
retrieving revision 1.90.2.25
diff -u -r1.90.2.25 content.module
--- content.module	9 Jan 2007 14:54:10 -0000	1.90.2.25
+++ content.module	13 Jan 2007 00:09:36 -0000
@@ -85,6 +85,15 @@
           'type' => MENU_LOCAL_TASK,
           'weight' => 2,
         );
+        $items[] = array(
+          'path' => 'admin/content/types/'. $content_type['url_str'] .'/display',
+          'title' => t('Display'),
+          'callback' => 'drupal_get_form',
+          'access' => $access,
+          'callback arguments' => array('content_admin_field_display_form', $content_type['type']),
+          'type' => MENU_LOCAL_TASK,
+          'weight' => 3,
+        );
 
         if (arg(4) == 'fields' && arg(5) && isset($content_type['fields'][arg(5)])) {
           $items[] = array(
@@ -243,7 +252,7 @@
   if ($node->in_preview) {
     _content_widget_invoke('process form values', $node);
   }
-  $content = _content_field_invoke('view', $node, $teaser, $page);
+  $content = _content_field_view($node, $teaser, $page);
   $node->content = array_merge((array) $node->content, $content);
 }
 
@@ -469,7 +478,6 @@
   }
 }
 
-
 /**
  * Invoke a field hook.
  *
@@ -514,6 +522,37 @@
 }
 
 /**
+ * Format field output based on display settings.
+ */
+function _content_field_view(&$node, $teaser = NULL, $page = NULL) {
+  $type_name = is_string($node) ? $node : (is_array($node) ? $node['type'] : $node->type);
+  $type = content_types($type_name);
+  $field_types = _content_field_types();
+  $context = $page ? 'page' : ($teaser ? 'teaser' : 'full');
+
+  $return = array();
+  if (count($type['fields'])) {
+    foreach ($type['fields'] as $field) {
+      $node_field = isset($node->$field['field_name']) ? $node->$field['field_name'] : array();
+      $formatter = isset($field['display_settings'][$context]['format']) ? $field['display_settings'][$context]['format'] : 'default';
+      $enabled = isset($field['display_settings'][$context]['enabled']) ? $field['display_settings'][$context]['enabled'] : 1;
+
+      if ($enabled) {
+        foreach ($node_field as $delta => $item) {
+          $items[$delta]['view'] = content_format($field, $item, $formatter, $node);
+        }
+
+        $return[$field['field_name']] = array(
+          '#weight' => $field['widget']['weight'],
+          '#value' => $enabled ? theme('field', $node, $field, $items, $teaser, $page) : '',
+        );
+      }
+    }
+  }
+  return $return;
+}
+
+/**
  * Invoke content.module's version of a field hook.
  */
 function _content_field_invoke_default($op, &$node, $teaser = NULL, $page = NULL) {
@@ -725,7 +764,7 @@
         $type['url_str'] = str_replace('_', '-', $type['type']);
         $type['fields'] = array();
         $type['table'] = _content_tablename($type['type']);
-        $field_result = db_query("SELECT nfi.field_name, nfi.weight, nfi.label, nfi.widget_type, nfi.widget_settings, nfi.description FROM {node_field_instance} nfi WHERE nfi.type_name = '%s' ORDER BY nfi.weight ASC, nfi.label ASC", $type['type']);
+        $field_result = db_query("SELECT nfi.field_name, nfi.weight, nfi.label, nfi.widget_type, nfi.widget_settings, nfi.display_settings, nfi.description FROM {node_field_instance} nfi WHERE nfi.type_name = '%s' ORDER BY nfi.weight ASC, nfi.label ASC", $type['type']);
         while ($field = db_fetch_array($field_result)) {
           // Overwrite global field information with specific information
           $field = array_merge($info['fields'][$field['field_name']], $field);
@@ -742,6 +781,7 @@
           $field['widget']['description'] = $field['description'];
           unset($field['description']);
           $field['type_name'] = $type['type'];
+          $field['display_settings'] = $field['display_settings'] ? unserialize($field['display_settings']) : array();
           $type['fields'][$field['field_name']] = $field;
         }
         $info['content types'][$type['type']] = $type;
@@ -911,16 +951,31 @@
  *   An HTML string containing the fully themed field.
  */
 function theme_field(&$node, &$field, &$items, $teaser, $page) {
+  if (isset($field['display_settings']['label']['enabled'])) {
+    $label = $field['display_settings']['label']['enabled'] ? $field['display_settings']['label']['format'] : 'hidden';
+  }
+  else {
+    $label = 'header';
+  }
+
   $items_output = '';
-  foreach ($items as $item) {
+  foreach ($items as $delta => $item) {
     if (!empty($item['view']) || $item['view'] === "0") {
-      $items_output .= '<div class="field-item">'. $item['view'] .'</div>';
+      $items_output .= '<div class="field-item">';
+      if ($label == 'inline') {
+        $items_output .= '<div class="field-label-inline'. ($delta ? '' : '-first') .'">';
+        $items_output .= $field['widget']['label'] .':</div> ' ;
+      }
+      $items_output .= $item['view'] .'</div>';
     }
   }
+
   $output = '';
   if (!empty($items_output)) {
     $output .= '<div class="field field-type-'. strtr($field['type'], '_', '-') .' field-'. strtr($field['field_name'], '_', '-') .'">';
-    $output .= '<h3 class="field-label">'. $field['widget']['label'] .'</h3>';
+    if ($label == 'header') {
+      $output .= '<div class="field-label">'. $field['widget']['label'] .':</div>';
+    }
     $output .= '<div class="field-items">'. $items_output .'</div>';
     $output .= '</div>';
   }
