From 1f0565806b1809b4c0c0a157f7fbfb4ac611e16a Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 15 Apr 2001 17:01:32 +0000 Subject: - improved submit.php: it now uses the new category code, incl content bindings. You can setup different "categories" which map on a content type. Example: review -> review.module article -> story.module column -> story.module announc. -> story.module addons -> file.module themes -> file.module - "generalised" story.module and book.module's output. - fixed bug in includes/timer.inc - fixed glitch in theme example.theme: it said "$how by" but the variable $how has never been declared. - added "drupal development settings" to display some timings - more work on the categories/topics -> does NOT work yet --- includes/comment.inc | 2 +- includes/node.inc | 8 +++++++- includes/structure.inc | 54 ++++++++++++++++++++++++++++++++++++++++++-------- includes/timer.inc | 2 +- 4 files changed, 55 insertions(+), 11 deletions(-) (limited to 'includes') diff --git a/includes/comment.inc b/includes/comment.inc index 152389414..1a25c11c2 100644 --- a/includes/comment.inc +++ b/includes/comment.inc @@ -289,7 +289,7 @@ function comment_render($lid, $cid) { if ($user->id) { // Comment control: - $theme->box(t("Comment control"), "
". comment_controls($threshold, $mode, $order) ."
"); + $theme->box(t("Comment control"), comment_controls($threshold, $mode, $order)); // Print moderation form: print "
\n"; diff --git a/includes/node.inc b/includes/node.inc index 3f734ff3e..7026efbb6 100644 --- a/includes/node.inc +++ b/includes/node.inc @@ -18,6 +18,13 @@ function node_get_array($field, $value) { return db_fetch_array(_node_get($field, $value)); } +function node_get_category($nid) { + db_fetch_array(db_query("SELECT FROM")); +} + +function node_get_topic($nid) { +} + function node_del($field, $value) { global $status; if ($node = node_get_object($field, $value)) { @@ -123,7 +130,6 @@ function node_save($node) { } } - function node_invoke($node, $name, $arg = 0) { if ($node[type]) $function = $node[type] ."_$name"; if ($node->type) $function = $node->type ."_$name"; diff --git a/includes/structure.inc b/includes/structure.inc index ff697c4d3..838d0e351 100644 --- a/includes/structure.inc +++ b/includes/structure.inc @@ -22,11 +22,26 @@ function category_save($edit) { foreach ($edit as $key=>$value) db_query("UPDATE category SET $key = '". check_input($value) ."' WHERE cid = '$edit[cid]'"); } -function category_del($id) { - db_query("DELETE FROM category WHERE cid = '$id'"); +// delete category $cid: +function category_del($cid) { + db_query("DELETE FROM category WHERE cid = '". check_input($cid) ."'"); + db_query("DELETE FROM node_category WHERE cid = '". check_input($cid) ."'"); +} + +function category_node($nid, $cid) { + db_query("INSERT INTO node_category (nid, cid) VALUES ('". check_input($nid) ."', '". check_input($cid) ."')", 1); +} + +function category_form_select($type, $edit = array(), $size = 1) { + $result = db_query("SELECT * FROM category WHERE type = '$type'"); + while ($category = db_fetch_object($result)) { + $options .= ""; + } + return "\n"; } // ----- topic ----- + function _topic_get($field, $value) { return db_query("SELECT * FROM topic WHERE $field = '$value'"); } @@ -57,16 +72,39 @@ function topic_tree($parent = 0, $name = "", $tree = array()) { return $tree; } -// renders a form to select one or more topics: -function topic_form_select($type, $topics = array(), $size = 1) { +// delete topic $tid: +function topic_del($tid) { + db_query("DELETE FROM topic WHERE tid = '". check_input($tid) ."'"); + db_query("DELETE FROM node_topic WHERE tid = '". check_input($tid) ."'"); +} + +// add node $nid to topic $tid: +function topic_node($nid, $tid) { + db_query("INSERT INTO node_topic (nid, tid) VALUES ('". check_input($nid) ."', '". check_input($tid) ."')", 1); +} + +// renders a HTML form to select one or more topics: +function topic_form_select($edit = array(), $size = 1) { foreach (topic_tree() as $tid=>$name) { - $options .= "\n"; + $options .= ""; } - return "". t("Topic") .":

\n"; + return "\n"; +} + +// ----- structure ----- + +// add node $nid to category $cid and topic $tid: +function structure_save($nid, $cid, $tid) { + category_node($nid, $cid); + topic_node($nid, $tid); } -function topic_del($id) { - db_query("DELETE FROM topic WHERE tid = '$id'"); +// render a HMTL selection form: +function structure_form($type, $edit = array(), $size = 1) { + $output .= "Category and topic:
\n"; + $output .= category_form_select($type, $edit, $size) ." ". topic_form_select($edit, $size) ."
"; + $output .= "". t("Select the category and the topic this sumbission belongs in.") ."

"; + return $output; } ?> \ No newline at end of file diff --git a/includes/timer.inc b/includes/timer.inc index 7e2e9d21a..e6740f366 100644 --- a/includes/timer.inc +++ b/includes/timer.inc @@ -5,7 +5,7 @@ $timer = 0; function timer_print() { global $timer; $stop = explode(" ", microtime()); - $diff = $timer[0] - $stop[0]; + $diff = $stop[0] - $timer[0]; print "

execution time: $diff ms
"; } -- cgit v1.2.3