Commit 1f056580 authored by Dries's avatar Dries

- 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
parent f1716fbd
......@@ -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 @@ function account_track_site() {
account_user($user->userid);
}
if (variable_get(dev_timing, 0)) timer_print();
?>
\ No newline at end of file
......@@ -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";
......
......@@ -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";
......
......@@ -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
......@@ -5,7 +5,7 @@
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>";
}
......
......@@ -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 @@
while ($story = db_fetch_object($result)) $theme->story($story);
$theme->footer();
if (variable_get(dev_timing, 0)) timer_print();
?>
<?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();
?>
......@@ -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
}
......
......@@ -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":
......
......@@ -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":
......
......@@ -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";
......
......@@ -11,12 +11,14 @@
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());
}
}
......
......@@ -11,12 +11,14 @@
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());
}
}
......
......@@ -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 @@ function node_history($node) {
node_failure();
}
if (variable_get(dev_timing, 0)) timer_print();
?>
\ No newline at end of file
......@@ -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 @@ function submit_type($name, $module) {
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);
}
}
......
......@@ -61,7 +61,7 @@ function story($story, $reply = 0) {
<?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 @@ function footer() {
<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>
......
......@@ -145,7 +145,7 @@ function footer() {
<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>
......
# 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)
);