diff options
Diffstat (limited to 'includes')
-rw-r--r-- | includes/comment.inc | 2 | ||||
-rw-r--r-- | includes/node.inc | 8 | ||||
-rw-r--r-- | includes/structure.inc | 54 | ||||
-rw-r--r-- | includes/timer.inc | 2 |
4 files changed, 55 insertions, 11 deletions
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"), "<DIV ALIGN=\"center\">". comment_controls($threshold, $mode, $order) ."</DIV>"); + $theme->box(t("Comment control"), comment_controls($threshold, $mode, $order)); // Print moderation form: print "<FORM METHOD=\"post\" ACTION=\"$REQUEST_URI\">\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 .= "<OPTION VALUE=\"$category->cid\"". ($edit[$category->cid] ? "SELECTED" : "") .">". check_select($category->name) ."</OPTION>"; + } + return "<SELECT NAME=\"category[]\" SIZE=\"$size\"". ($size > 1 ? "MULTIPLE" : "") .">$options</SELECT>\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 .= "<OPTION VALUE=\"$tid\">$name</OPTION>\n"; + $options .= "<OPTION VALUE=\"$tid\"". ($edit[$tid] ? "SELECTED" : "") .">". check_select($name) ."</OPTION>"; } - return "<B>". t("Topic") .":</B><BR><SELECT NAME=\"edit[topic][]\" SIZE=\"$size\"". ($size > 1 ? "MULTIPLE" : "") .">$options</SELECT><P>\n"; + return "<SELECT NAME=\"topic[]\" SIZE=\"$size\"". ($size > 1 ? "MULTIPLE" : "") .">$options</SELECT>\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 .= "<B>Category and topic:</B><BR>\n"; + $output .= category_form_select($type, $edit, $size) ." ". topic_form_select($edit, $size) ."<BR>"; + $output .= "<SMALL><I>". t("Select the category and the topic this sumbission belongs in.") ."</I></SMALL><P>"; + 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 "<PRE>execution time: $diff ms</PRE>"; } |