summaryrefslogtreecommitdiff
path: root/modules
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 /modules
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
Diffstat (limited to 'modules')
-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
6 files changed, 77 insertions, 76 deletions
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());
}
}