Index: modules/blog.module =================================================================== RCS file: /cvs/drupal/drupal/modules/blog.module,v retrieving revision 1.228 diff -u -r1.228 blog.module --- modules/blog.module 18 Sep 2005 10:37:57 -0000 1.228 +++ modules/blog.module 19 Sep 2005 19:14:23 -0000 @@ -183,12 +183,21 @@ } /** + * Implementation of hook_validate(). + */ +function blog_validate(&$node) { + node_validate_title($node); +} + +/** * Implementation of hook_form(). */ function blog_form(&$node) { global $nid; $iid = $_GET['iid']; + $output = form_textfield(t('Title'), 'title', $node->title, 60, 128, NULL, NULL, TRUE); + if (empty($node->body)) { /* ** If the user clicked a "blog it" link, we load the data from the Index: modules/book.module =================================================================== RCS file: /cvs/drupal/drupal/modules/book.module,v retrieving revision 1.316 diff -u -r1.316 book.module --- modules/book.module 18 Sep 2005 11:26:17 -0000 1.316 +++ modules/book.module 19 Sep 2005 19:14:24 -0000 @@ -225,13 +225,16 @@ $node->weight = 0; $node->revision = 1; } + + node_validate_title($node); } /** * Implementation of hook_form(). */ function book_form(&$node) { - $output = form_select(t('Parent'), 'parent', ($node->parent ? $node->parent : arg(4)), book_toc($node->nid), t('The parent that this page belongs in. Note that pages whose parent is <top-level> are regarded as independent, top-level books.')); + $output = form_textfield(t('Title'), 'title', $node->title, 60, 128, NULL, NULL, TRUE); + $output .= form_select(t('Parent'), 'parent', ($node->parent ? $node->parent : arg(4)), book_toc($node->nid), t('The parent that this page belongs in. Note that pages whose parent is <top-level> are regarded as independent, top-level books.')); if (function_exists('taxonomy_node_form')) { $output .= implode('', taxonomy_node_form('book', $node)); Index: modules/forum.module =================================================================== RCS file: /cvs/drupal/drupal/modules/forum.module,v retrieving revision 1.269 diff -u -r1.269 forum.module --- modules/forum.module 8 Sep 2005 19:22:28 -0000 1.269 +++ modules/forum.module 19 Sep 2005 19:14:24 -0000 @@ -517,6 +517,8 @@ // Make sure all fields are set properly: $node->icon = $node->icon ? $node->icon : ''; + node_validate_title($node,t('You have to specify a subject.')); + if ($node->taxonomy) { // Extract the node's proper topic ID. $vocabulary = variable_get('forum_nav_vocabulary', ''); @@ -558,6 +560,8 @@ * Implementation of hook_form(). */ function forum_form(&$node) { + $output = form_textfield(t('Subject'), 'title', $node->title, 60, 128, NULL, NULL, TRUE); + if (!$node->nid) { // new topic $node->taxonomy[] = arg(3); @@ -566,7 +570,7 @@ $node->taxonomy = array($node->tid); } - $output = implode('', taxonomy_node_form('forum', $node)); + $output .= implode('', taxonomy_node_form('forum', $node)); if ($node->nid) { // if editing, give option to leave shadows Index: modules/node.module =================================================================== RCS file: /cvs/drupal/drupal/modules/node.module,v retrieving revision 1.528 diff -u -r1.528 node.module --- modules/node.module 18 Sep 2005 10:37:57 -0000 1.528 +++ modules/node.module 19 Sep 2005 19:14:24 -0000 @@ -1242,13 +1242,6 @@ // Convert the node to an object, if necessary. $node = array2object($node); - // Validate the title field. - if (isset($node->title)) { - if (trim($node->title) == '') { - form_set_error('title', t('You have to specify a title.')); - } - } - // Make sure the body has the minimum number of words. // todo use a better word counting algorithm that will work in other languages if (isset($node->body) && count(explode(' ', $node->body)) < variable_get('minimum_'. $node->type .'_size', 0)) { @@ -1325,6 +1318,19 @@ } /** + * Validate the title of a node + */ +function node_validate_title($node,$message = NULL) { + // Validate the title field. + if (isset($node->title) && trim($node->title) == '') { + if (!$message) { + $message = t('You have to specify a title.'); + } + form_set_error('title', $message); + } +} + +/** * Generate the node editing form. */ function node_form($edit) { @@ -1378,9 +1384,8 @@ $output .= $extras ? '
'. $extras .'
' : ''; } - // Add the default fields. + // Open the enclosing div. $output .= '
'; - $output .= form_textfield(t('Title'), 'title', $edit->title, 60, 128, NULL, NULL, TRUE); // Add the node-type-specific fields. $output .= $form; Index: modules/page.module =================================================================== RCS file: /cvs/drupal/drupal/modules/page.module,v retrieving revision 1.136 diff -u -r1.136 page.module --- modules/page.module 30 Aug 2005 15:22:29 -0000 1.136 +++ modules/page.module 19 Sep 2005 19:14:24 -0000 @@ -64,9 +64,18 @@ } /** + * Implementation of hook_validate(). + */ +function page_validate(&$node) { + node_validate_title($node); +} + +/** * Implementation of hook_form(). */ function page_form(&$node) { + $output = form_textfield(t('Title'), 'title', $node->title, 60, 128, NULL, NULL, TRUE); + if (function_exists('taxonomy_node_form')) { $output .= implode('', taxonomy_node_form('page', $node)); } Index: modules/poll.module =================================================================== RCS file: /cvs/drupal/drupal/modules/poll.module,v retrieving revision 1.169 diff -u -r1.169 poll.module --- modules/poll.module 29 Aug 2005 19:58:49 -0000 1.169 +++ modules/poll.module 19 Sep 2005 19:14:24 -0000 @@ -92,6 +92,9 @@ * Implementation of hook_validate(). */ function poll_validate(&$node) { + + node_validate_title($node,t('You have to specify a question.')); + if (isset($node->title)) { // Check for at least two options and validate amount of votes: $realchoices = 0; @@ -120,8 +123,10 @@ function poll_form(&$node) { $admin = user_access('administer nodes'); + $output = form_textfield(t('Question'), 'title', $node->title, 60, 128, NULL, NULL, TRUE); + if (function_exists('taxonomy_node_form')) { - $output = implode('', taxonomy_node_form('poll', $node)); + $output .= implode('', taxonomy_node_form('poll', $node)); } if (!isset($node->choices)) { Index: modules/story.module =================================================================== RCS file: /cvs/drupal/drupal/modules/story.module,v retrieving revision 1.170 diff -u -r1.170 story.module --- modules/story.module 29 Aug 2005 19:58:49 -0000 1.170 +++ modules/story.module 19 Sep 2005 19:14:24 -0000 @@ -64,10 +64,17 @@ } /** + * Implementation of hook_validate(). + */ +function story_validate(&$node) { + node_validate_title($node); +} + +/** * Implementation of hook_form(). */ function story_form(&$node) { - $output = ''; + $output = form_textfield(t('Title'), 'title', $node->title, 60, 128, NULL, NULL, TRUE); if (function_exists('taxonomy_node_form')) { $output .= implode('', taxonomy_node_form('story', $node));