diff options
author | Dries Buytaert <dries@buytaert.net> | 2005-09-23 08:47:13 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2005-09-23 08:47:13 +0000 |
commit | 61740bd8ee133c3d0ea2543bccc4d00a62c9e3a0 (patch) | |
tree | 814cc9a6da1ec51a6e3eca921dc001ae6b5dee6a | |
parent | e3a4085a07647878142d1c51a6977a5b98f707ea (diff) | |
download | brdo-61740bd8ee133c3d0ea2543bccc4d00a62c9e3a0.tar.gz brdo-61740bd8ee133c3d0ea2543bccc4d00a62c9e3a0.tar.bz2 |
- Patch #10056: allow the node title forms to be customized.
-rw-r--r-- | modules/blog.module | 9 | ||||
-rw-r--r-- | modules/blog/blog.module | 9 | ||||
-rw-r--r-- | modules/book.module | 5 | ||||
-rw-r--r-- | modules/book/book.module | 5 | ||||
-rw-r--r-- | modules/forum.module | 6 | ||||
-rw-r--r-- | modules/forum/forum.module | 6 | ||||
-rw-r--r-- | modules/node.module | 20 | ||||
-rw-r--r-- | modules/node/node.module | 20 | ||||
-rw-r--r-- | modules/page.module | 9 | ||||
-rw-r--r-- | modules/page/page.module | 9 | ||||
-rw-r--r-- | modules/poll.module | 7 | ||||
-rw-r--r-- | modules/poll/poll.module | 7 | ||||
-rw-r--r-- | modules/story.module | 9 | ||||
-rw-r--r-- | modules/story/story.module | 9 | ||||
-rw-r--r-- | sites/default/settings.php | 4 |
15 files changed, 108 insertions, 26 deletions
diff --git a/modules/blog.module b/modules/blog.module index a773a566e..954dc9906 100644 --- a/modules/blog.module +++ b/modules/blog.module @@ -183,12 +183,21 @@ function blog_page_last() { } /** + * 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 diff --git a/modules/blog/blog.module b/modules/blog/blog.module index a773a566e..954dc9906 100644 --- a/modules/blog/blog.module +++ b/modules/blog/blog.module @@ -183,12 +183,21 @@ function blog_page_last() { } /** + * 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 diff --git a/modules/book.module b/modules/book.module index 746b8e5fe..1a9d9022c 100644 --- a/modules/book.module +++ b/modules/book.module @@ -225,13 +225,16 @@ function book_validate(&$node) { $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)); diff --git a/modules/book/book.module b/modules/book/book.module index 746b8e5fe..1a9d9022c 100644 --- a/modules/book/book.module +++ b/modules/book/book.module @@ -225,13 +225,16 @@ function book_validate(&$node) { $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)); diff --git a/modules/forum.module b/modules/forum.module index 7e6ce4a0c..b87d6ab15 100644 --- a/modules/forum.module +++ b/modules/forum.module @@ -517,6 +517,8 @@ function forum_validate(&$node) { // 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 @@ function forum_update($node) { * 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 @@ function forum_form(&$node) { $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 diff --git a/modules/forum/forum.module b/modules/forum/forum.module index 7e6ce4a0c..b87d6ab15 100644 --- a/modules/forum/forum.module +++ b/modules/forum/forum.module @@ -517,6 +517,8 @@ function forum_validate(&$node) { // 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 @@ function forum_update($node) { * 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 @@ function forum_form(&$node) { $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 diff --git a/modules/node.module b/modules/node.module index 3a17febf5..586ffafba 100644 --- a/modules/node.module +++ b/modules/node.module @@ -1242,13 +1242,6 @@ function node_validate($node) { // 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,16 @@ function node_validate($node) { } /** + * Validate the title of a node + */ +function node_validate_title($node, $message = NULL) { + // Validate the title field. + if (trim($node->title) == '') { + form_set_error('title', isset($message) ? $message : t('You have to specify a title.')); + } +} + +/** * Generate the node editing form. */ function node_form($edit) { @@ -1378,9 +1381,8 @@ function node_form($edit) { $output .= $extras ? '<div class="extra">'. $extras .'</div></div>' : '</div>'; } - // Add the default fields. + // Open the enclosing div. $output .= '<div class="standard">'; - $output .= form_textfield(t('Title'), 'title', $edit->title, 60, 128, NULL, NULL, TRUE); // Add the node-type-specific fields. $output .= $form; diff --git a/modules/node/node.module b/modules/node/node.module index 3a17febf5..586ffafba 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -1242,13 +1242,6 @@ function node_validate($node) { // 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,16 @@ function node_validate($node) { } /** + * Validate the title of a node + */ +function node_validate_title($node, $message = NULL) { + // Validate the title field. + if (trim($node->title) == '') { + form_set_error('title', isset($message) ? $message : t('You have to specify a title.')); + } +} + +/** * Generate the node editing form. */ function node_form($edit) { @@ -1378,9 +1381,8 @@ function node_form($edit) { $output .= $extras ? '<div class="extra">'. $extras .'</div></div>' : '</div>'; } - // Add the default fields. + // Open the enclosing div. $output .= '<div class="standard">'; - $output .= form_textfield(t('Title'), 'title', $edit->title, 60, 128, NULL, NULL, TRUE); // Add the node-type-specific fields. $output .= $form; diff --git a/modules/page.module b/modules/page.module index 638e4de99..1370c9d6d 100644 --- a/modules/page.module +++ b/modules/page.module @@ -64,9 +64,18 @@ function page_menu($may_cache) { } /** + * 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)); } diff --git a/modules/page/page.module b/modules/page/page.module index 638e4de99..1370c9d6d 100644 --- a/modules/page/page.module +++ b/modules/page/page.module @@ -64,9 +64,18 @@ function page_menu($may_cache) { } /** + * 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)); } diff --git a/modules/poll.module b/modules/poll.module index 129705faa..b8249347a 100644 --- a/modules/poll.module +++ b/modules/poll.module @@ -92,6 +92,9 @@ function poll_delete($node) { * 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_validate(&$node) { 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)) { diff --git a/modules/poll/poll.module b/modules/poll/poll.module index 129705faa..b8249347a 100644 --- a/modules/poll/poll.module +++ b/modules/poll/poll.module @@ -92,6 +92,9 @@ function poll_delete($node) { * 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_validate(&$node) { 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)) { diff --git a/modules/story.module b/modules/story.module index 2d98f4f66..517d53b9e 100644 --- a/modules/story.module +++ b/modules/story.module @@ -64,10 +64,17 @@ function story_menu($may_cache) { } /** + * 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)); diff --git a/modules/story/story.module b/modules/story/story.module index 2d98f4f66..517d53b9e 100644 --- a/modules/story/story.module +++ b/modules/story/story.module @@ -64,10 +64,17 @@ function story_menu($may_cache) { } /** + * 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)); diff --git a/sites/default/settings.php b/sites/default/settings.php index 610ef05ee..aac3f43b8 100644 --- a/sites/default/settings.php +++ b/sites/default/settings.php @@ -30,6 +30,10 @@ * 9. sites/org * * 10. sites/default + * + * If you are installing on a non-standard port number, the ':' is + * replaced by a '.'. For example, http://www.drupal.org:8080/mysite/test/ + * could be loaded from sites/www.drupal.org.8080.mysite.test/. */ /** |