Index: text.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cck/text.module,v
retrieving revision 1.41.2.12
diff -u -p -r1.41.2.12 text.module
--- text.module	12 Mar 2007 00:50:34 -0000	1.41.2.12
+++ text.module	23 Oct 2007 21:06:34 -0000
@@ -22,13 +22,24 @@ function text_field_settings($op, $field
   switch ($op) {
     case 'form':
       $form = array();
-      $options = array(0 => t('Plain text'), 1 => t('Filtered text (user selects input format)'));
+      $options = array(0 => t('Plain text'), 1 => t('Filtered text (user selects input format)'), 2 => t('Filtered text (fixed input format)'));
       $form['text_processing'] = array(
         '#type' => 'radios',
         '#title' => t('Text processing'),
         '#default_value' => isset($field['text_processing']) ? $field['text_processing'] : 0,
         '#options' => $options,
       );
+      $formats = filter_formats();
+      foreach ($formats as $id=>$format) {
+        $formats[$id]=$format->name;
+      }
+      $form['default_format'] = array(
+        '#type' => 'select',
+        '#title' => t('Default format'),
+        '#description' => t('The default format will only have an effect when the field is not processed as plain text. When the format can be selected by the user, this default does not override normal access permissions.'),
+        '#options' => $formats,
+        '#default_value' => isset($field['default_format']) ? $field['default_format'] : variable_get('filter_default_format', 1),
+      );
       $form['max_length'] = array(
         '#type' => 'textfield',
         '#title' => t('Maximum length'),
@@ -60,7 +71,7 @@ function text_field_settings($op, $field
       return $form;
 
     case 'save':
-      return array('text_processing', 'max_length', 'allowed_values', 'allowed_values_php');
+      return array('text_processing', 'default_format', 'max_length', 'allowed_values', 'allowed_values_php');
 
     case 'database columns':
       $columns = array(
@@ -73,7 +84,7 @@ function text_field_settings($op, $field
       else {
         $columns['value']['length'] = $field['max_length'];
       }
-      if ($field['text_processing'] == 0) {
+      if ($field['text_processing'] != 1) {
         unset($columns['format']);
       }
       return $columns;
@@ -181,6 +192,9 @@ function text_field_formatter($field, $i
   }
 
   if ($field['text_processing']) {
+    if ($item['format'] == 0) {
+      $item['format'] = $field['default_format'];
+    }
     return check_markup($text, $item['format'], is_null($node) || isset($node->in_preview));
   }
   else {
@@ -263,7 +277,8 @@ function text_widget($op, &$node, $field
                 '#weight' => $field['widget']['weight'],
               );
             }
-            if ($field['text_processing']) {
+            if ($field['text_processing'] == 1) {
+              $data['format'] = $data['format'] ? $data['format'] : $field['default_format'];
               $form[$field['field_name']][$delta]['format'] = filter_form($data['format'], $form[$field['field_name']][$delta]['value']['#weight'] + 1, array($field['field_name'], $delta, 'format'));
             }
             $delta++;
@@ -290,7 +305,8 @@ function text_widget($op, &$node, $field
               '#weight' => $field['widget']['weight'],
             );
           }
-          if ($field['text_processing']) {
+          if ($field['text_processing'] == 1) {
+            $items[$delta]['format'] = $items[$delta]['format'] ? $items[$delta]['format'] : $field['default_format'];
             $form[$field['field_name']][$delta]['format'] = filter_form($items[$delta]['format'], $form[$field['field_name']][$delta]['value']['#weight'] + 1, array($field['field_name'], $delta, 'format'));
           }
         }
@@ -318,7 +334,8 @@ function text_widget($op, &$node, $field
             '#weight' => $field['widget']['weight'],
           );
         }
-        if ($field['text_processing']) {
+        if ($field['text_processing'] == 1) {
+          $items[0]['format'] = $items[0]['format'] ? $items[0]['format'] : $field['default_format'];
           $form[$field['field_name']][0]['format'] = filter_form($items[0]['format'], $form[$field['field_name']][0]['value']['#weight'] + 1, array($field['field_name'], 0, 'format'));
         }
       }
