From 4d8b485fad960ea6551111e58f8c59df053b4456 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Thu, 1 Nov 2001 22:54:16 +0000 Subject: - Added error handling support to the _form hook. --- modules/blog/blog.module | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'modules/blog/blog.module') diff --git a/modules/blog/blog.module b/modules/blog/blog.module index a0489928b..397fb56cf 100644 --- a/modules/blog/blog.module +++ b/modules/blog/blog.module @@ -178,20 +178,25 @@ function blog_page_last() { $theme->box(t("User blogs"), $output, "main"); } -function blog_form($edit) { +function blog_form($node, $error) { global $nid, $iid; - if (!$edit->body) { + if ($node->body) { + if (count(explode(" ", $node->body)) < variable_get("minimum_node_size", 0)) { + $error["body"] = "
". t("The body of your blog is too short.") ."
"; + } + } + else { if ($nid && $blog = node_load(array("nid" => $nid))) { - $edit->body = "". $blog->body ." [uid&date=$blog->created\">$blog->name]"; + $node->body = "". $blog->body ." [uid&date=$blog->created\">$blog->name]"; } if ($iid && $item = db_fetch_object(db_query("SELECT i.*, f.title as ftitle, f.link as flink FROM item i, feed f WHERE i.iid = '". check_input($iid) ."' AND i.fid = f.fid"))) { - $edit->body = "link\">$item->title - ". check_output($item->description) ." [flink\">$item->ftitle]\n"; + $node->body = "link\">$item->title - ". check_output($item->description) ." [flink\">$item->ftitle]\n"; } } - $output = form_textarea(t("Body"), "body", $edit->body, 60, 15, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", ""))); + $output = form_textarea(t("Body"), "body", $node->body, 60, 15, $error["body"] ? $error["body"] : t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", ""))); return $output; } -- cgit v1.2.3