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 --- modules/account.module | 2 +- modules/book.module | 2 +- modules/book/book.module | 2 +- modules/settings.module | 9 +++--- modules/story.module | 69 +++++++++++++++++++++++----------------------- modules/story/story.module | 69 +++++++++++++++++++++++----------------------- 6 files changed, 77 insertions(+), 76 deletions(-) (limited to 'modules') 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() { appleMatches any string that has the text "apple" in it. ^apple$Matches the exact string "apple". ^appleMatches any string that starts with "apple". - domain\.com$Matches any string that ends with "@domain.com". Note that you have to escape the dot in domain.com. + domain\.com$Matches any string that ends with "domain.com". Note that you have to escape the dot in domain.com.
\n"; $output .= "The fully qualified URL of this website: starts with \"http://\" and ends with a trailing slash!

\n"; + $output .= "Footer message:
\n"; + $output .= "
\n"; + $output .= "This text will be displayed at the bottom of each page. Useful to add a copyright notice to your pages.

\n"; + $output .= "Anonymous user:
\n"; $output .= "
\n"; $output .= "The name displayed for anonymous users.

\n"; - $output .= "


\n"; $output .= "

Comment settings

\n"; @@ -72,10 +75,6 @@ function settings_conf() { $output .= "
\n"; $output .= "The default theme displayed for anonymous users.

\n"; - $output .= "Footer message:
\n"; - $output .= "
\n"; - $output .= "This text will be displayed at the bottom of each page. Useful to add a copyright notice to your pages.

\n"; - $output .= "


\n"; $output .= "

Development settings

\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 .= "
\n"; $output .= "". t("Your name") .":
\n"; - $output .= "\n"; - $output .= format_username(($edit[userid] ? $edit[userid] : $user->userid)) ."

"; + $output .= "\n"; + $output .= format_username(($story[userid] ? $story[userid] : $user->userid)) ."

"; $output .= "". t("Subject") .":
\n"; - $output .= "

\n"; + $output .= "

\n"; - $output .= "". t("Section") .":
\n"; - foreach ($sections = section_get() as $value) $options .= " \n"; - $output .= "

\n"; + $output .= structure_form("story"); $output .= "". t("Abstract") .":
\n"; - $output .= "
\n"; + $output .= "
\n"; $output .= "". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".

\n"; $output .= "". t("Body") .":
\n"; - $output .= "
\n"; + $output .= "
\n"; $output .= "". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".

\n"; if (user_access($user, "story")) { - $output .= "\n"; - $output .= "\n"; + $output .= "\n"; + $output .= "\n"; } $duplicate = db_result(db_query("SELECT COUNT(nid) FROM node WHERE title = '$title'")); - if (!$edit) { + if (!$story) { $output .= "\n"; } - else if (!$edit[title]) { + else if (!$story[title]) { $output .= "". t("Warning: you did not supply a subject.") ."

\n"; $output .= "\n"; } - else if (!$edit[section]) { + else if (!$story[section]) { $output .= "". t("Warning: you did not supply a section.") ."

\n"; $output .= "\n"; } - else if (!$edit[abstract]) { + else if (!$story[abstract]) { $output .= "". t("Warning: you did not supply an abstract.") ."

\n"; $output .= "\n"; } - else if (!$edit[nid] && $duplicate) { + else if (!$story[nid] && $duplicate) { $output .= "". t("Warning: there is already a story with that subject.") ."

\n"; $output .= "\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 "add new story | story listing | search story | overview | help


\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 .= "\n"; $output .= "". t("Your name") .":
\n"; - $output .= "\n"; - $output .= format_username(($edit[userid] ? $edit[userid] : $user->userid)) ."

"; + $output .= "\n"; + $output .= format_username(($story[userid] ? $story[userid] : $user->userid)) ."

"; $output .= "". t("Subject") .":
\n"; - $output .= "

\n"; + $output .= "

\n"; - $output .= "". t("Section") .":
\n"; - foreach ($sections = section_get() as $value) $options .= " \n"; - $output .= "

\n"; + $output .= structure_form("story"); $output .= "". t("Abstract") .":
\n"; - $output .= "
\n"; + $output .= "
\n"; $output .= "". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".

\n"; $output .= "". t("Body") .":
\n"; - $output .= "
\n"; + $output .= "
\n"; $output .= "". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".

\n"; if (user_access($user, "story")) { - $output .= "\n"; - $output .= "\n"; + $output .= "\n"; + $output .= "\n"; } $duplicate = db_result(db_query("SELECT COUNT(nid) FROM node WHERE title = '$title'")); - if (!$edit) { + if (!$story) { $output .= "\n"; } - else if (!$edit[title]) { + else if (!$story[title]) { $output .= "". t("Warning: you did not supply a subject.") ."

\n"; $output .= "\n"; } - else if (!$edit[section]) { + else if (!$story[section]) { $output .= "". t("Warning: you did not supply a section.") ."

\n"; $output .= "\n"; } - else if (!$edit[abstract]) { + else if (!$story[abstract]) { $output .= "". t("Warning: you did not supply an abstract.") ."

\n"; $output .= "\n"; } - else if (!$edit[nid] && $duplicate) { + else if (!$story[nid] && $duplicate) { $output .= "". t("Warning: there is already a story with that subject.") ."

\n"; $output .= "\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 "add new story | story listing | search story | overview | help


\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()); } } -- cgit v1.2.3