summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2001-04-15 17:01:32 +0000
committerDries Buytaert <dries@buytaert.net>2001-04-15 17:01:32 +0000
commit1f0565806b1809b4c0c0a157f7fbfb4ac611e16a (patch)
tree85448501218986cca7db81f7ee5f0d3e9f3b7f5d
parentf1716fbd9c4fee630fc091d8d9dc87cd105d77da (diff)
downloadbrdo-1f0565806b1809b4c0c0a157f7fbfb4ac611e16a.tar.gz
brdo-1f0565806b1809b4c0c0a157f7fbfb4ac611e16a.tar.bz2
- 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
-rw-r--r--account.php4
-rw-r--r--includes/comment.inc2
-rw-r--r--includes/node.inc8
-rw-r--r--includes/structure.inc54
-rw-r--r--includes/timer.inc2
-rw-r--r--index.php4
-rw-r--r--module.php2
-rw-r--r--modules/account.module2
-rw-r--r--modules/book.module2
-rw-r--r--modules/book/book.module2
-rw-r--r--modules/settings.module9
-rw-r--r--modules/story.module69
-rw-r--r--modules/story/story.module69
-rw-r--r--node.php4
-rw-r--r--submit.php16
-rw-r--r--themes/example/example.theme4
-rw-r--r--themes/marvin/marvin.theme2
-rw-r--r--themes/yaroon/jeroen2.theme8
-rw-r--r--updates/2.00-to-x.xx.sql46
19 files changed, 200 insertions, 109 deletions
diff --git a/account.php b/account.php
index d88ffdb30..7c51ea019 100644
--- a/account.php
+++ b/account.php
@@ -2,6 +2,8 @@
include_once "includes/common.inc";
+if (variable_get(dev_timing, 0)) timer_start();
+
function account_get_user($uname) {
$result = db_query("SELECT * FROM users WHERE userid = '$uname'");
return db_fetch_object($result);
@@ -562,4 +564,6 @@ switch ($op) {
account_user($user->userid);
}
+if (variable_get(dev_timing, 0)) timer_print();
+
?> \ No newline at end of file
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>";
}
diff --git a/index.php b/index.php
index 1e4433283..d86ebe81f 100644
--- a/index.php
+++ b/index.php
@@ -2,6 +2,8 @@
include_once "includes/common.inc";
+if (variable_get(dev_timing, 0)) timer_start();
+
// Initialize/pre-process variables:
$number = ($user->nodes) ? $user->nodes : 10;
$date = ($date > 0) ? $date : time();
@@ -14,4 +16,6 @@ $theme->header();
while ($story = db_fetch_object($result)) $theme->story($story);
$theme->footer();
+if (variable_get(dev_timing, 0)) timer_print();
+
?>
diff --git a/module.php b/module.php
index 12e191a54..859315a70 100644
--- a/module.php
+++ b/module.php
@@ -1,6 +1,8 @@
<?php
include_once "includes/common.inc";
+if (variable_get(dev_timing, 0)) timer_start();
module_execute($mod, "page");
+if (variable_get(dev_timing, 0)) timer_print();
?>
diff --git a/modules/account.module b/modules/account.module
index b5b19ef3f..72687a0e0 100644
--- a/modules/account.module
+++ b/modules/account.module
@@ -31,7 +31,7 @@ function account_help() {
<TR><TD>apple</TD><TD>Matches any string that has the text "apple" in it.<TD></TR>
<TR><TD>^apple$</TD><TD>Matches the exact string "apple".<TD></TR>
<TR><TD>^apple</TD><TD>Matches any string that starts with "apple".<TD></TR>
- <TR><TD>domain\.com$</TD><TD>Matches any string that ends with "@domain.com". Note that you have to escape the dot in domain.com.</TD></TR>
+ <TR><TD>domain\.com$</TD><TD>Matches any string that ends with "domain.com". Note that you have to escape the dot in domain.com.</TD></TR>
</TABLE>
<?php
}
diff --git a/modules/book.module b/modules/book.module
index b1696d540..6c4ce6a8a 100644
--- a/modules/book.module
+++ b/modules/book.module
@@ -267,7 +267,7 @@ function book_update($id) {
function book_user() {
global $edit, $id, $op, $theme, $user;
- $title = t("Submit a book page");
+ $title = t("Submit");
switch($op) {
case "update":
diff --git a/modules/book/book.module b/modules/book/book.module
index b1696d540..6c4ce6a8a 100644
--- a/modules/book/book.module
+++ b/modules/book/book.module
@@ -267,7 +267,7 @@ function book_update($id) {
function book_user() {
global $edit, $id, $op, $theme, $user;
- $title = t("Submit a book page");
+ $title = t("Submit");
switch($op) {
case "update":
diff --git a/modules/settings.module b/modules/settings.module
index ff7cc72bf..8fdd27276 100644
--- a/modules/settings.module
+++ b/modules/settings.module
@@ -19,11 +19,14 @@ function settings_conf() {
$output .= "<INPUT NAME=\"edit[site_url]\" MAXLENGTH=\"55\" SIZE=\"30\" VALUE=\"". variable_get(site_url, "http://drupal/") ."\"><BR>\n";
$output .= "<I><SMALL>The fully qualified URL of this website: starts with \"http://\" and ends with a trailing slash!</SMALL></I><P>\n";
+ $output .= "<B>Footer message:</B><BR>\n";
+ $output .= "<TEXTAREA NAME=\"edit[site_footer]\" COLS=\"55\" ROWS=\"3\" WRAP=\"virtual\">". variable_get(site_footer, "") ."</TEXTAREA><BR>\n";
+ $output .= "<I><SMALL>This text will be displayed at the bottom of each page. Useful to add a copyright notice to your pages.</SMALL></I><P>\n";
+
$output .= "<B>Anonymous user:</B><BR>\n";
$output .= "<INPUT NAME=\"edit[anonymous]\" MAXLENGTH=\"55\" SIZE=\"30\" VALUE=\"". variable_get(anonymous, "Anonymous") ."\"><BR>\n";
$output .= "<I><SMALL>The name displayed for anonymous users.</SMALL></I><P>\n";
-
$output .= "<HR>\n";
$output .= "<H3>Comment settings</H3>\n";
@@ -72,10 +75,6 @@ function settings_conf() {
$output .= "<SELECT NAME=\"edit[theme_default]\">$options7</SELECT><BR>\n";
$output .= "<I><SMALL>The default theme displayed for anonymous users.</SMALL></I><P>\n";
- $output .= "<B>Footer message:</B><BR>\n";
- $output .= "<TEXTAREA NAME=\"edit[theme_footer]\" COLS=\"55\" ROWS=\"3\" WRAP=\"virtual\">". variable_get(theme_footer, "") ."</TEXTAREA><BR>\n";
- $output .= "<I><SMALL>This text will be displayed at the bottom of each page. Useful to add a copyright notice to your pages.</SMALL></I><P>\n";
-
$output .= "<HR>\n";
$output .= "<H3>Development settings</H3>\n";
diff --git a/modules/story.module b/modules/story.module
index 8c831fad1..19448fcac 100644
--- a/modules/story.module
+++ b/modules/story.module
@@ -11,12 +11,14 @@ $module = array("help" => "story_help",
include_once "includes/section.inc";
class Story {
- function Story($userid, $title, $abstract, $body, $section, $timestamp) { $this->userid = $userid;
- $this->title = $title;
- $this->abstract = $abstract;
- $this->body = $body;
- $this->section = $section;
- $this->timestamp = $timestamp;
+ function Story($story, $category = 0, $topic = 0) {
+ $this->userid = $story[userid] ? $story[userid] : $user->userid;
+ $this->title = $story[title];
+ $this->abstract = $story[abstract];
+ $this->body = $story[body];
+ $this->timestamp = $story[timestamp] ? $story[timestamp] : time();
+ $this->category = ($category ? $category : node_get_category($story[nid]));
+ $this->topic = ($topic ? $topic : node_get_topic($story[nid]));
}
}
@@ -111,53 +113,51 @@ function story_view($node, $page = 1) {
}
}
-function story_form($edit = array()) {
+function story_form($story = array()) {
global $allowed_html, $REQUEST_URI, $user;
$output .= "<FORM ACTION=\"$REQUEST_URI\" METHOD=\"post\">\n";
$output .= "<B>". t("Your name") .":</B><BR>\n";
- $output .= "<INPUT TYPE=\"hidden\" NAME=\"edit[userid]\" VALUE=\"$edit[userid]\">\n";
- $output .= format_username(($edit[userid] ? $edit[userid] : $user->userid)) ."<P>";
+ $output .= "<INPUT TYPE=\"hidden\" NAME=\"story[userid]\" VALUE=\"$story[userid]\">\n";
+ $output .= format_username(($story[userid] ? $story[userid] : $user->userid)) ."<P>";
$output .= "<B>". t("Subject") .":</B><BR>\n";
- $output .= "<INPUT TYPE=\"text\" NAME=\"edit[title]\" SIZE=\"50\" MAXLENGTH=\"60\" VALUE=\"". check_textfield($edit[title]) ."\"><P>\n";
+ $output .= "<INPUT TYPE=\"text\" NAME=\"story[title]\" SIZE=\"50\" MAXLENGTH=\"60\" VALUE=\"". check_textfield($story[title]) ."\"><P>\n";
- $output .= "<B>". t("Section") .":</B><BR>\n";
- foreach ($sections = section_get() as $value) $options .= " <OPTION VALUE=\"". check_select($value) ."\"". ($edit[section] == $value ? " SELECTED" : "") .">". check_output($value) ."</OPTION>\n";
- $output .= "<SELECT NAME=\"edit[section]\">$options</SELECT><P>\n";
+ $output .= structure_form("story");
$output .= "<B>". t("Abstract") .":</B><BR>\n";
- $output .= "<TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"10\" NAME=\"edit[abstract]\">". check_textarea($edit[abstract]) ."</TEXTAREA><BR>\n";
+ $output .= "<TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"10\" NAME=\"story[abstract]\">". check_textarea($story[abstract]) ."</TEXTAREA><BR>\n";
$output .= "<SMALL><I>". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".</I></SMALL><P>\n";
$output .= "<B>". t("Body") .":</B><BR>\n";
- $output .= "<TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"15\" NAME=\"edit[body]\">". check_textarea($edit[body]) ."</TEXTAREA><BR>\n";
+ $output .= "<TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"15\" NAME=\"story[body]\">". check_textarea($story[body]) ."</TEXTAREA><BR>\n";
$output .= "<SMALL><I>". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".</I></SMALL><P>\n";
if (user_access($user, "story")) {
- $output .= "<INPUT TYPE=\"hidden\" NAME=\"edit[timestamp]\" VALUE=\"$edit[timestamp]\">\n";
- $output .= "<INPUT TYPE=\"hidden\" NAME=\"edit[nid]\" VALUE=\"$edit[nid]\">\n";
+ $output .= "<INPUT TYPE=\"hidden\" NAME=\"story[timestamp]\" VALUE=\"$story[timestamp]\">\n";
+ $output .= "<INPUT TYPE=\"hidden\" NAME=\"story[nid]\" VALUE=\"$story[nid]\">\n";
}
$duplicate = db_result(db_query("SELECT COUNT(nid) FROM node WHERE title = '$title'"));
- if (!$edit) {
+ if (!$story) {
$output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Preview") ."\">\n";
}
- else if (!$edit[title]) {
+ else if (!$story[title]) {
$output .= "<FONT COLOR=\"red\">". t("Warning: you did not supply a subject.") ."</FONT><P>\n";
$output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Preview") ."\">\n";
}
- else if (!$edit[section]) {
+ else if (!$story[section]) {
$output .= "<FONT COLOR=\"red\">". t("Warning: you did not supply a section.") ."</FONT><P>\n";
$output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Preview") ."\">\n";
}
- else if (!$edit[abstract]) {
+ else if (!$story[abstract]) {
$output .= "<FONT COLOR=\"red\">". t("Warning: you did not supply an abstract.") ."</FONT><P>\n";
$output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Preview") ."\">\n";
}
- else if (!$edit[nid] && $duplicate) {
+ else if (!$story[nid] && $duplicate) {
$output .= "<FONT COLOR=\"red\">". t("Warning: there is already a story with that subject.") ."</FONT><P>\n";
$output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Preview") ."\">\n";
}
@@ -170,8 +170,9 @@ function story_form($edit = array()) {
return $output;
}
-function story_save($edit) {
- node_save(array_diff(array_merge($edit, array(nid => $edit[nid], type => "story")), array(userid => $edit[userid])));
+function story_save($story, $category, $topic) {
+ node_save(array_diff(array_merge($story, array(nid => $story[nid], type => "story")), array(userid => $story[userid])));
+ structure_save($category, $topic);
}
function story_block() {
@@ -215,7 +216,7 @@ function story_overview($query = array()) {
}
function story_admin() {
- global $id, $edit, $mod, $keys, $op, $theme, $type, $user;
+ global $id, $story, $category, $topic, $mod, $keys, $op, $theme, $type, $user;
print "<SMALL><A HREF=\"admin.php?mod=story&op=add\">add new story</A> | <A HREF=\"admin.php?mod=story&op=listing\">story listing</A> | <A HREF=\"admin.php?mod=story&op=search\">search story</A> | <A HREF=\"admin.php?mod=story\">overview</A> | <A HREF=\"admin.php?mod=story&op=help\">help</A></SMALL><HR>\n";
@@ -243,11 +244,11 @@ function story_admin() {
print search_data($keys, $mod);
break;
case t("Preview"):
- story_view(new Story(($edit[userid] ? $edit[userid] : $user->userid), $edit[title], $edit[abstract], $edit[body], $edit[section], ($edit[timestamp] ? $edit[timestamp] : time())), 0);
- print story_form($edit);
+ story_view(new Story($story, $category, $topic),0);
+ print story_form($story);
break;
case t("Submit"):
- story_save($edit);
+ story_save($story, $category, $topic);
// fall through:
default:
print story_overview(story_query($type));
@@ -256,19 +257,19 @@ function story_admin() {
function story_user() {
- global $edit, $op, $theme, $user;
+ global $story, $category, $topic, $op, $theme, $user;
switch($op) {
case t("Preview"):
- story_view(new Story($user->userid, $edit[title], $edit[abstract], $edit[body], $edit[section], ($edit[timestamp] ? $edit[timestamp] : time())), 0);
- $theme->box("Submit a story", story_form($edit));
+ story_view(new Story($story, $category, $topic), 0);
+ $theme->box("Submit", story_form($story));
break;
case t("Submit"):
- story_save($edit);
- $theme->box(t("Submit a story"), t("Thank you for your submission."));
+ story_save($story, $category, $topic);
+ $theme->box(t("Submit"), t("Thank you for your submission."));
break;
default:
- $theme->box("Submit a story", story_form());
+ $theme->box("Submit", story_form());
}
}
diff --git a/modules/story/story.module b/modules/story/story.module
index 8c831fad1..19448fcac 100644
--- a/modules/story/story.module
+++ b/modules/story/story.module
@@ -11,12 +11,14 @@ $module = array("help" => "story_help",
include_once "includes/section.inc";
class Story {
- function Story($userid, $title, $abstract, $body, $section, $timestamp) { $this->userid = $userid;
- $this->title = $title;
- $this->abstract = $abstract;
- $this->body = $body;
- $this->section = $section;
- $this->timestamp = $timestamp;
+ function Story($story, $category = 0, $topic = 0) {
+ $this->userid = $story[userid] ? $story[userid] : $user->userid;
+ $this->title = $story[title];
+ $this->abstract = $story[abstract];
+ $this->body = $story[body];
+ $this->timestamp = $story[timestamp] ? $story[timestamp] : time();
+ $this->category = ($category ? $category : node_get_category($story[nid]));
+ $this->topic = ($topic ? $topic : node_get_topic($story[nid]));
}
}
@@ -111,53 +113,51 @@ function story_view($node, $page = 1) {
}
}
-function story_form($edit = array()) {
+function story_form($story = array()) {
global $allowed_html, $REQUEST_URI, $user;
$output .= "<FORM ACTION=\"$REQUEST_URI\" METHOD=\"post\">\n";
$output .= "<B>". t("Your name") .":</B><BR>\n";
- $output .= "<INPUT TYPE=\"hidden\" NAME=\"edit[userid]\" VALUE=\"$edit[userid]\">\n";
- $output .= format_username(($edit[userid] ? $edit[userid] : $user->userid)) ."<P>";
+ $output .= "<INPUT TYPE=\"hidden\" NAME=\"story[userid]\" VALUE=\"$story[userid]\">\n";
+ $output .= format_username(($story[userid] ? $story[userid] : $user->userid)) ."<P>";
$output .= "<B>". t("Subject") .":</B><BR>\n";
- $output .= "<INPUT TYPE=\"text\" NAME=\"edit[title]\" SIZE=\"50\" MAXLENGTH=\"60\" VALUE=\"". check_textfield($edit[title]) ."\"><P>\n";
+ $output .= "<INPUT TYPE=\"text\" NAME=\"story[title]\" SIZE=\"50\" MAXLENGTH=\"60\" VALUE=\"". check_textfield($story[title]) ."\"><P>\n";
- $output .= "<B>". t("Section") .":</B><BR>\n";
- foreach ($sections = section_get() as $value) $options .= " <OPTION VALUE=\"". check_select($value) ."\"". ($edit[section] == $value ? " SELECTED" : "") .">". check_output($value) ."</OPTION>\n";
- $output .= "<SELECT NAME=\"edit[section]\">$options</SELECT><P>\n";
+ $output .= structure_form("story");
$output .= "<B>". t("Abstract") .":</B><BR>\n";
- $output .= "<TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"10\" NAME=\"edit[abstract]\">". check_textarea($edit[abstract]) ."</TEXTAREA><BR>\n";
+ $output .= "<TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"10\" NAME=\"story[abstract]\">". check_textarea($story[abstract]) ."</TEXTAREA><BR>\n";
$output .= "<SMALL><I>". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".</I></SMALL><P>\n";
$output .= "<B>". t("Body") .":</B><BR>\n";
- $output .= "<TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"15\" NAME=\"edit[body]\">". check_textarea($edit[body]) ."</TEXTAREA><BR>\n";
+ $output .= "<TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"15\" NAME=\"story[body]\">". check_textarea($story[body]) ."</TEXTAREA><BR>\n";
$output .= "<SMALL><I>". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".</I></SMALL><P>\n";
if (user_access($user, "story")) {
- $output .= "<INPUT TYPE=\"hidden\" NAME=\"edit[timestamp]\" VALUE=\"$edit[timestamp]\">\n";
- $output .= "<INPUT TYPE=\"hidden\" NAME=\"edit[nid]\" VALUE=\"$edit[nid]\">\n";
+ $output .= "<INPUT TYPE=\"hidden\" NAME=\"story[timestamp]\" VALUE=\"$story[timestamp]\">\n";
+ $output .= "<INPUT TYPE=\"hidden\" NAME=\"story[nid]\" VALUE=\"$story[nid]\">\n";
}
$duplicate = db_result(db_query("SELECT COUNT(nid) FROM node WHERE title = '$title'"));
- if (!$edit) {
+ if (!$story) {
$output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Preview") ."\">\n";
}
- else if (!$edit[title]) {
+ else if (!$story[title]) {
$output .= "<FONT COLOR=\"red\">". t("Warning: you did not supply a subject.") ."</FONT><P>\n";
$output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Preview") ."\">\n";
}
- else if (!$edit[section]) {
+ else if (!$story[section]) {
$output .= "<FONT COLOR=\"red\">". t("Warning: you did not supply a section.") ."</FONT><P>\n";
$output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Preview") ."\">\n";
}
- else if (!$edit[abstract]) {
+ else if (!$story[abstract]) {
$output .= "<FONT COLOR=\"red\">". t("Warning: you did not supply an abstract.") ."</FONT><P>\n";
$output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Preview") ."\">\n";
}
- else if (!$edit[nid] && $duplicate) {
+ else if (!$story[nid] && $duplicate) {
$output .= "<FONT COLOR=\"red\">". t("Warning: there is already a story with that subject.") ."</FONT><P>\n";
$output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Preview") ."\">\n";
}
@@ -170,8 +170,9 @@ function story_form($edit = array()) {
return $output;
}
-function story_save($edit) {
- node_save(array_diff(array_merge($edit, array(nid => $edit[nid], type => "story")), array(userid => $edit[userid])));
+function story_save($story, $category, $topic) {
+ node_save(array_diff(array_merge($story, array(nid => $story[nid], type => "story")), array(userid => $story[userid])));
+ structure_save($category, $topic);
}
function story_block() {
@@ -215,7 +216,7 @@ function story_overview($query = array()) {
}
function story_admin() {
- global $id, $edit, $mod, $keys, $op, $theme, $type, $user;
+ global $id, $story, $category, $topic, $mod, $keys, $op, $theme, $type, $user;
print "<SMALL><A HREF=\"admin.php?mod=story&op=add\">add new story</A> | <A HREF=\"admin.php?mod=story&op=listing\">story listing</A> | <A HREF=\"admin.php?mod=story&op=search\">search story</A> | <A HREF=\"admin.php?mod=story\">overview</A> | <A HREF=\"admin.php?mod=story&op=help\">help</A></SMALL><HR>\n";
@@ -243,11 +244,11 @@ function story_admin() {
print search_data($keys, $mod);
break;
case t("Preview"):
- story_view(new Story(($edit[userid] ? $edit[userid] : $user->userid), $edit[title], $edit[abstract], $edit[body], $edit[section], ($edit[timestamp] ? $edit[timestamp] : time())), 0);
- print story_form($edit);
+ story_view(new Story($story, $category, $topic),0);
+ print story_form($story);
break;
case t("Submit"):
- story_save($edit);
+ story_save($story, $category, $topic);
// fall through:
default:
print story_overview(story_query($type));
@@ -256,19 +257,19 @@ function story_admin() {
function story_user() {
- global $edit, $op, $theme, $user;
+ global $story, $category, $topic, $op, $theme, $user;
switch($op) {
case t("Preview"):
- story_view(new Story($user->userid, $edit[title], $edit[abstract], $edit[body], $edit[section], ($edit[timestamp] ? $edit[timestamp] : time())), 0);
- $theme->box("Submit a story", story_form($edit));
+ story_view(new Story($story, $category, $topic), 0);
+ $theme->box("Submit", story_form($story));
break;
case t("Submit"):
- story_save($edit);
- $theme->box(t("Submit a story"), t("Thank you for your submission."));
+ story_save($story, $category, $topic);
+ $theme->box(t("Submit"), t("Thank you for your submission."));
break;
default:
- $theme->box("Submit a story", story_form());
+ $theme->box("Submit", story_form());
}
}
diff --git a/node.php b/node.php
index 991be2639..05c4bfec8 100644
--- a/node.php
+++ b/node.php
@@ -2,6 +2,8 @@
include "includes/common.inc";
+if (variable_get(dev_timing, 0)) timer_start();
+
function node_failure() {
global $theme;
$theme->header();
@@ -57,4 +59,6 @@ else {
node_failure();
}
+if (variable_get(dev_timing, 0)) timer_print();
+
?> \ No newline at end of file
diff --git a/submit.php b/submit.php
index 8cc9d870e..b2e4231ff 100644
--- a/submit.php
+++ b/submit.php
@@ -2,14 +2,6 @@
include_once "includes/common.inc";
-function submit_type($name, $module) {
- global $modules;
- if ($module[user]) {
- $type = module_execute($name, "type");
- $modules[$name] = $type[1];
- }
-}
-
$theme->header();
if ($user->id) {
@@ -17,18 +9,16 @@ if ($user->id) {
module_execute($mod, "user");
}
else {
- module_iterate("submit_type");
+ $result = db_query("SELECT * FROM category");
$output .= "<P>". t("If you have written something or if you have some news or thoughts that you would like to share, then this is the place where you can submit new content. Fill out this form and your contribution will automatically get whisked away to our submission queue where our moderators will frown at it, poke at it and hopefully post it.") ."</P>";
$output .= "<FORM ACTION=\"submit.php\" METHOD=\"get\">\n";
- $output .= "<B>". t("Submission type") .":</B><BR>\n";
- foreach ($modules as $key => $value) $options .= "<OPTION VALUE=\"$key\">$value</OPTION>";
+ $output .= "<B>". t("Category") .":</B><BR>\n";
+ while ($category = db_fetch_object($result)) $options .= "<OPTION VALUE=\"$category->type\">$category->name</OPTION>";
$output .= "<SELECT NAME=\"mod\">$options</SELECT><P>\n";
$output .= "<INPUT NAME=\"op\" TYPE=\"submit\" VALUE=\"". t("Next step") ."\">\n";
- //� reset �
-
$theme->box("Submit", $output);
}
}
diff --git a/themes/example/example.theme b/themes/example/example.theme
index a1984fb4f..dbdad530d 100644
--- a/themes/example/example.theme
+++ b/themes/example/example.theme
@@ -61,7 +61,7 @@
<?php
- echo strtr(t("$how by %a on %b"), array("%a" => format_username($story->userid), "%b" => format_date($story->timestamp, "large")));
+ echo strtr(t("by %a on %b"), array("%a" => format_username($story->userid), "%b" => format_date($story->timestamp, "small")));
?>
</TD>
@@ -192,7 +192,7 @@
<TR>
<TD ALIGN="center" COLSPAN="3">
<P><?php print theme_link(" | "); ?></P>
- <P><SMALL><?php print variable_get(theme_footer, ""); ?></SMALL></P>
+ <P><SMALL><?php print variable_get(site_footer, ""); ?></SMALL></P>
</TD>
</TR>
</TABLE>
diff --git a/themes/marvin/marvin.theme b/themes/marvin/marvin.theme
index 4bab35078..00a415640 100644
--- a/themes/marvin/marvin.theme
+++ b/themes/marvin/marvin.theme
@@ -145,7 +145,7 @@
<TR>
<TD ALIGN="center" COLSPAN="3">
<?php
- print "<P><SMALL>[ ". theme_link(" | ") ." ]</SMALL></P><P>". varaible_get(theme_footer, "") ."</P>\n";
+ print "<P><SMALL>[ ". theme_link(" | ") ." ]</SMALL></P><P>". variable_get(site_footer, "") ."</P>\n";
?>
</TD>
</TR>
diff --git a/themes/yaroon/jeroen2.theme b/themes/yaroon/jeroen2.theme
index afa3eba4c..21086cb77 100644
--- a/themes/yaroon/jeroen2.theme
+++ b/themes/yaroon/jeroen2.theme
@@ -124,7 +124,7 @@
<tr><td bgcolor="<?php echo $color; ?>"><img src="themes/jeroen2/images/pixel.gif" width="1" height="1" alt="" border="0" /></td></tr>
<tr>
<td>
-
+
<?php
echo "<br /><font face=\"Helvetica\">". check_output($story->abstract, 1) ."<br />";
@@ -160,7 +160,7 @@
<tr>
<td class="box">
<img src="themes/jeroen2/images/square.gif" />&nbsp;<b><?php echo check_output($comment->subject); ?></b>
- <font face="Helvetica" size="-1"><?php echo strtr(t(" by %a on %b"), array("%a" => format_username($comment->userid), "%b" => format_date($comment->timestamp), "small")); ?></font>
+ <font face="Helvetica" size="-1"><?php echo strtr(t(" by %a on %b"), array("%a" => format_username($comment->userid), "%b" => format_date($comment->timestamp), "small")); ?></font>
</td>
<td align="right"><?php echo comment_moderation($comment); ?></td>
</tr>
@@ -201,7 +201,7 @@
<table width="90%" border="0" cellpadding="0" cellspacing="1">
<tr>
- <td class="box"><img src="themes/jeroen2/images/square.gif" />&nbsp;<b><font face="Helvetica"><?php echo $subject; ?></font></b></td>
+ <td class="box"><img src="themes/jeroen2/images/square.gif" />&nbsp;<b><font face="Helvetica"><?php echo $subject; ?></font></b></td>
</tr>
<tr><td class="spacer1"><img src="themes/jeroen2/images/pixel.gif" width="1" height="1" alt="" border="0" /><br></td></tr>
<tr>
@@ -222,7 +222,7 @@
function footer() {
?>
-
+
&nbsp; <!-- I call this the super-space, withouth it, the comment section looks crappy at the bottom :) -->
</td>
</tr>
diff --git a/updates/2.00-to-x.xx.sql b/updates/2.00-to-x.xx.sql
index 642cc6a37..1b10a887a 100644
--- a/updates/2.00-to-x.xx.sql
+++ b/updates/2.00-to-x.xx.sql
@@ -1,17 +1,59 @@
# 14/04/2001:
+CREATE TABLE category (
+ cid int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
+ name varchar(32) DEFAULT '' NOT NULL,
+ type varchar(16) DEFAULT '' NOT NULL,
+ post int(3) DEFAULT '0' NOT NULL,
+ dump int(3) DEFAULT '0' NOT NULL,
+ expire int(3) DEFAULT '0' NOT NULL,
+ comment int(2) unsigned DEFAULT '0' NOT NULL,
+ submission int(2) unsigned DEFAULT '0' NOT NULL,
+ UNIQUE (name),
+ PRIMARY KEY (cid)
+);
+
+CREATE TABLE topic (
+ tid int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
+ pid int(10) unsigned DEFAULT '0' NOT NULL,
+ name varchar(32) DEFAULT '' NOT NULL,
+ UNIQUE (name),
+ PRIMARY KEY (tid)
+);
+
+CREATE TABLE node_category (
+ cid int(10) unsigned DEFAULT '0' NOT NULL,
+ nid int(10) unsigned DEFAULT '0' NOT NULL,
+ PRIMARY KEY (cid, nid)
+);
+
+CREATE TABLE node_topic (
+ tid int(10) unsigned DEFAULT '0' NOT NULL,
+ nid int(10) unsigned DEFAULT '0' NOT NULL,
+ PRIMARY KEY (tid, nid)
+);
+
+///// revise
+
CREATE TABLE section (
sid int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
pid int(10) unsigned DEFAULT '0' NOT NULL,
name varchar(32) DEFAULT '' NOT NULL,
+ UNIQUE (name),
PRIMARY KEY (sid)
);
CREATE TABLE section_type (
- sid int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
+ sid int(10) unsigned DEFAULT '0' NOT NULL,
type varchar(16) DEFAULT '' NOT NULL,
PRIMARY KEY (sid, type)
);
+CREATE TABLE section_node (
+ sid int(10) unsigned DEFAULT '0' NOT NULL,
+ nid int(10) unsigned DEFAULT '0' NOT NULL,
+ PRIMARY KEY (sid, nid)
+);
+
# 07/04/2001:
CREATE TABLE page (
lid int(10) unsigned DEFAULT '0' NOT NULL auto_increment,
@@ -23,7 +65,7 @@ CREATE TABLE page (
CREATE TABLE variable (
name varchar(32) DEFAULT '' NOT NULL,
- value varchar(128) DEFAULT '' NOT NULL,
+ value text DEFAULT '' NOT NULL,
PRIMARY KEY (name)
);