Index: flexinode.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/flexinode/flexinode.module,v
retrieving revision 1.54
diff -u -r1.54 flexinode.module
--- flexinode.module	29 Sep 2005 02:44:08 -0000	1.54
+++ flexinode.module	29 Sep 2005 05:31:38 -0000
@@ -479,9 +479,16 @@
     $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 />';
+    	if (!$row_count) {
+    		$data = '<strong>' . t('Title field:') . '</strong><br />';
+    	}
+       $data .= t($field->label) . ' (' . l(t('edit field'), 'admin/node/types/edit_field/' . $field->field_id) . ')<br />';
+      if (!$row_count) {
+      	$data .= '<br />';
+      	$row_count++;
+      }
     }
 
     $url = 'admin/node/types/add_field/'.  $ctype->ctype_id;
@@ -644,7 +651,6 @@
 function flexinode_validate(&$node) {
   if (isset($node->ctype_id)) {
     $ctype = flexinode_load_content_type($node->ctype_id);
-
     $error = array();
     foreach ($ctype->fields as $field) {
       $fieldname = 'flexinode_'. $field->field_id;
@@ -663,6 +669,9 @@
       }
 
       if ($error[$fieldname] == '') unset($error[$fieldname]);
+      if ($field->is_title) {
+      	$node->title = $node->$fieldname;
+      }
     }
 
     // Pre-render the body and teaser fields, so the Drupal search works.
@@ -694,7 +703,7 @@
 
     foreach ($ctype->fields as $field) {
       $fieldname = 'flexinode_'. $field->field_id;
-      if (isset($node->$fieldname)) {
+      if (isset($node->$fieldname) && !$field->is_title) {
         $data = flexinode_invoke('format', $field, $node, $teaser);
         if (!empty($data) && $data) {
           $node->body .= theme('flexinode_'. $field->field_type, $field->field_id, $field->label, $node->$fieldname, $data);
@@ -821,7 +830,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,10 +933,12 @@
   }
   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()), '', 1);
     drupal_set_message(t('created new content type "%name".', array('%name' => $edit['name'])));
+
   }
 
   // update the cached "create content" menu
@@ -970,26 +981,32 @@
  * 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.'));
+	if ($edit['is_title']) {
+  	$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);
+  } else {
+  	$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_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 +1029,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) {
