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/structure.inc | 54 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 8 deletions(-) (limited to 'includes/structure.inc') 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 -- cgit v1.2.3