From 7eb33053b2a7347b82539d0f3abc20e845ba819d Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sat, 20 Sep 2003 16:08:57 +0000 Subject: - Updated the blog module to use the _validate hook. Fixes bug #2920 reported by Jonathan. --- modules/blog/blog.module | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'modules/blog/blog.module') diff --git a/modules/blog/blog.module b/modules/blog/blog.module index 852d1c58e..e66460334 100644 --- a/modules/blog/blog.module +++ b/modules/blog/blog.module @@ -155,17 +155,30 @@ function blog_page_last() { print "
". l("\"\"", "blog/feed", array("title" => t("Read the XML version of all blogs."))) ."
"; } +function blog_validate(&$node) { + + /* + ** Validate the size of the blog: + */ + + if (isset($node->body) && count(explode(" ", $node->body)) < variable_get("minimum_blog_size", 0)) { + $error["body"] = theme("theme_error", t("The body of your blog is too short.")); + } + + return $error; +} + function blog_form(&$node, &$help, &$error) { global $nid; $iid = $_GET["iid"]; - if (empty($node->body)) { - /* - ** Carry out some explanation or submission guidelines: - */ + /* + ** Carry out some explanation or submission guidelines: + */ - $help = variable_get("blog_help", ""); + $help = variable_get("blog_help", ""); + if (empty($node->body)) { /* ** If the user clicked a "blog it" link, we load the data from the ** database and quote it in the blog: @@ -180,19 +193,11 @@ function blog_form(&$node, &$help, &$error) { $node->body = "link\">$item->title - ". check_output($item->description) ." [flink\">$item->ftitle]\n"; } } - else { - /* - ** Validate the size of the blog: - */ - - if (count(explode(" ", $node->body)) < variable_get("minimum_blog_size", 0)) { - $error["body"] = theme("theme_error", t("The body of your blog is too short.")); - } - } if (function_exists("taxonomy_node_form")) { $output .= implode("", taxonomy_node_form("blog", $node)); } + $output .= form_textarea(t("Body"), "body", $node->body, 60, 15, $error["body"] ? $error["body"] : form_allowed_tags_text()); return $output; -- cgit v1.2.3