Index: flexinode.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/flexinode/flexinode.module,v
retrieving revision 1.53
diff -u -r1.53 flexinode.module
--- flexinode.module	14 Sep 2005 12:39:07 -0000	1.53
+++ flexinode.module	27 Sep 2005 06:50:31 -0000
@@ -479,7 +479,7 @@
     $ctype = flexinode_load_content_type($ctype->ctype_id);
     $rows[] = array(t($ctype->name), $ctype->description, l(t('edit content type'), 'admin/node/types/edit_type/' . $ctype->ctype_id));
 
-    $data = t('Title') . '<br />';
+		$data = '';
     foreach ($ctype->fields as $field) {
       $data .= t($field->label) . ' (' . l(t('edit field'), 'admin/node/types/edit_field/' . $field->field_id) . ')<br />';
     }
@@ -821,7 +821,7 @@
   $ctype = db_fetch_object(db_query('SELECT * FROM {flexinode_type} WHERE ctype_id = %d', $ctype_id));
 
   $ctype->fields = array();
-  $result = db_query('SELECT * FROM {flexinode_field} WHERE ctype_id = %d ORDER BY weight ASC, label ASC', $ctype_id);
+  $result = db_query('SELECT * FROM {flexinode_field} WHERE ctype_id = %d ORDER BY is_title DESC, weight ASC, label ASC', $ctype_id);
   while ($field = db_fetch_object($result)) {
     $field->options = unserialize($field->options);
     $ctype->fields[] = $field;
@@ -924,9 +924,10 @@
   }
   else {
     $ctype_id = db_next_id('{flexinode_ctype}');
     db_query("INSERT INTO {flexinode_type} (name, description, help, ctype_id) VALUES ('%s', '%s', '%s', %d)", $edit['name'], $edit['description'], $edit['help'], $ctype_id);
 
+		$field_id = db_next_id('{flexinode_field}');
+		db_query("INSERT INTO {flexinode_field} (field_id, ctype_id, label, field_type, options, description, is_title) VALUES (%d, %d, '%s', '%s', '%s', '%s', %d)", $field_id, $ctype_id, 'Title', 'textfield', serialize(array()), 'You can provide a descriptive title label appropriate for the kind of content your flexinode content will store.<br />Examples: "Book title," "Song name," "Headline," etc.', 1);
     drupal_set_message(t('created new content type "%name".', array('%name' => $edit['name'])));
   }
 
@@ -970,26 +971,30 @@
  * Generate a form for the editing of a content type field.
  */
 function flexinode_edit_field($edit) {
-  $form = form_textfield(t('Field label'), 'label', $edit['label'], 60, 128, '', NULL, TRUE);
-
-  $form .= form_textfield(t('Description'), 'description', $edit['description'], 60, 128, t('A brief description of the field, to be displayed on the content submission form.'));
-
-  $field->field_type = $edit['field_type'];
-  $form .= flexinode_invoke('config', $field, $edit);
-
-  $form .= form_checkbox(t('Required field'), 'required', 1, $edit['required'], t('Whether the user must fill in the field when creating content.'));
-  $form .= form_checkbox(t('Show in teaser'), 'show_teaser', 1, $edit['show_teaser'], t('Whether this field should be shown as part of the teaser.'));
-  $form .= form_checkbox(t('Show in table'), 'show_table', 1, $edit['show_table'], t('Whether this field should be shown as part of this content type\'s <a href="%table">tabular view</a>.', array('%table' => url('flexinode/table/'. $edit['ctype_id']))));
-  $form .= form_weight(t('Weight'), 'weight', $edit['weight'], 10, t('Optional. On the content editing form, the heavier fields will sink and the lighter fields will be positioned nearer the top.'));
+  $form = form_textfield(t('Title field label'), 'label', $edit['label'], 60, 128, 'You can provide a descriptive title label appropriate for the kind of content your flexinode content will store.<br />Examples: "Book title," "Song name," "Headline," etc.', NULL, TRUE);
+  if (!$edit['is_title']) {
+	  $form .= form_textfield(t('Description'), 'description', $edit['description'], 60, 128, t('A brief description of the field, to be displayed on the content submission form.'));
+
+	  $field->field_type = $edit['field_type'];
+	  $form .= flexinode_invoke('config', $field, $edit);
+
+	  $form .= form_checkbox(t('Required field'), 'required', 1, $edit['required'], t('Whether the user must fill in the field when creating content.'));
+	  $form .= form_checkbox(t('Show in teaser'), 'show_teaser', 1, $edit['show_teaser'], t('Whether this field should be shown as part of the teaser.'));
+	  $form .= form_checkbox(t('Show in table'), 'show_table', 1, $edit['show_table'], t('Whether this field should be shown as part of this content type\'s <a href="%table">tabular view</a>.', array('%table' => url('flexinode/table/'. $edit['ctype_id']))));
+	  $form .= form_weight(t('Weight'), 'weight', $edit['weight'], 10, t('Optional. On the content editing form, the heavier fields will sink and the lighter fields will be positioned nearer the top.'));
+	}
 
   $form .= form_submit(t('Submit'));
   if ($edit['field_id']) {
-    $form .= form_submit(t('Delete'));
+  	if (!$edit['is_title']) {
+    	$form .= form_submit(t('Delete'));
+    }
     $form .= form_hidden('field_id', $edit['field_id']);
   }
 
   $form .= form_hidden('ctype_id', $edit['ctype_id']);
   $form .= form_hidden('field_type', $edit['field_type']);
+  $form .= form_hidden('is_title', $edit['is_title']);
 
   return form($form);
 }
@@ -1012,6 +1017,12 @@
  * Save a custom field to the database.
  */
 function flexinode_save_field($edit) {
+	if ($edit['is_title']) {
+		db_query("UPDATE {flexinode_field} SET label = '%s' WHERE field_id = %d", $edit['label'], $edit['field_id']);
+		drupal_set_message(t('updated title label'));
+		return $edit['field_id'];
+	}
+
   $options = array(0 => 0); // Placeholder for "none" option.
   if (!empty($edit['options'])) {
     foreach ($edit['options'] as $option) {
