2001-03-10 11:07:52 +00:00
<?php
2000-12-14 14:13:37 +00:00
2001-03-24 16:56:10 +00:00
class Story {
2001-04-16 11:38:12 +00:00
function Story($story) {
2001-05-05 13:57:29 +00:00
$this = new Node($story);
2001-04-15 17:01:32 +00:00
$this->abstract = $story[abstract];
$this->body = $story[body];
2001-03-24 16:56:10 +00:00
}
}
2001-04-07 15:02:28 +00:00
function story_status() {
return array(dumped, queued, posted);
}
2001-05-09 18:28:09 +00:00
function story_search($keys) {
2001-09-16 14:05:10 +00:00
global $PHP_SELF, $status;
2001-06-22 19:41:30 +00:00
$result = db_query("SELECT n.*, s.* FROM story s LEFT JOIN node n ON n.nid = s.nid AND n.lid = s.lid WHERE n.status = '$status[posted]' AND (n.title LIKE '%$keys%' OR s.abstract LIKE '%$keys%' OR s.body LIKE '%$keys%') ORDER BY n.timestamp DESC LIMIT 20");
2001-02-07 22:01:57 +00:00
while ($story = db_fetch_object($result)) {
2001-09-27 20:51:26 +00:00
$find[$i++] = array("title" => check_output($story->title), "link" => (strstr($PHP_SELF, "admin.php") ? "admin.php?mod=node&type=story&op=edit&id=$story->nid" : "node.php?id=$story->nid"), "user" => $story->name, "date" => $story->timestamp);
2001-02-07 22:01:57 +00:00
}
return $find;
}
2001-01-07 19:21:28 +00:00
function story_help() {
?>
2001-02-05 16:42:38 +00:00
<P>Queued stories: user-contributed stories are automatically whisked away to a submission queue for moderators (i.e. registered user) to frown at. Moderators vote whether or not a story should be posted to the front page for discussion.</P>
<P>Posted stories: published stories accessible to all visitors.</P>
<P>Dumped stories: rejected stories that are no longer available to visitors.</P>
2001-03-10 11:07:52 +00:00
<?php
2001-01-07 19:21:28 +00:00
}
2001-07-15 17:00:24 +00:00
function story_summary($node) {
return $node->abstract;
}
2001-04-16 18:21:22 +00:00
function story_view($node, $main = 0) {
global $theme;
2001-05-27 20:50:34 +00:00
$node->body = ((!$main) && ($node->body)) ? "$node->abstract<HR>$node->body" : $node->abstract;
2001-05-24 10:05:18 +00:00
$theme->node($node, $main);
2001-03-24 16:56:10 +00:00
}
2000-12-24 15:44:29 +00:00
2001-04-16 11:38:12 +00:00
function story_form($edit = array()) {
2001-09-28 16:20:55 +00:00
global $user;
2000-12-24 15:44:29 +00:00
This a rather large commit that needs a lot of fine-tuning. If you
update, you'll break your site as you need switching from structure
to index.module: so this can be considered an intermediate commit.
If you upgrade, and you are welcome to, just create a collection
called "section" (for now) and assign your nodes some attributes
in the described format.
Feedback and bugreports are welcomed. Questions will be answered.
CHANGES:
- comment system:
+ when replying to a node (rather then to a comment), that
node is displayed above the reply form.
+ when replying to a comment (rather then to a node), that
comment is displayd above the reply form.
- removed structure.inc, removed structure.module.
- node.inc:
+ added 2 new node functions called 'node_attribute_edit()' and
'node_attribute_save()' used to 'hook in' any indexing system
including your home-brewed stuff if you'd want to. Currently,
index.module is the facto default index system.
See story.module for usage.
- book.module, story.module, poll.module, page.module, forum.module:
+ added preview functionality to administration section (via node
module).
+ removed all references to structure.inc (category, topic).
- moderate.module:
+ removed all references to structure.inc (category, topic).
- book.module, story.module, page.module, forum.module:
+ increased the sizes of some textareas.
- submit.php:
+ removed all references to structure.inc (category, topic).
- marvin.theme:
+ removed dead code: function story() was depricated.
- unconed.theme:
+ removed hardcoded references to drop.org.
- marvin.theme, unconed.theme, jeroen.theme, yaroon.theme, example.theme:
+ removed all references to structure.inc (category, topic).
TODO:
- file.module, trip_link.module:
+ update preview functionality:
see story.module for example.
+ remove references to 'cid' and 'tid', use 'attribute' instead:
see story.module for example.
- extend and build upon index.module as well as making it configurable
2001-06-10 15:01:20 +00:00
if ($edit[title]) {
story_view(new Story(node_preview($edit)));
}
2001-09-16 11:33:14 +00:00
$form .= form_item(t("Your name"), ($edit[name] ? $edit[name] : ($user->name ? $user->name : variable_get(anonymous, "Anonymous"))));
2001-08-11 14:54:39 +00:00
$form .= form_hidden("name", $edit[name]);
2001-04-30 17:13:08 +00:00
$form .= form_textfield(t("Subject"), "title", $edit[title], 50, 64);
2001-06-15 07:30:44 +00:00
$form .= node_attributes_edit("story", $edit);
This a rather large commit that needs a lot of fine-tuning. If you
update, you'll break your site as you need switching from structure
to index.module: so this can be considered an intermediate commit.
If you upgrade, and you are welcome to, just create a collection
called "section" (for now) and assign your nodes some attributes
in the described format.
Feedback and bugreports are welcomed. Questions will be answered.
CHANGES:
- comment system:
+ when replying to a node (rather then to a comment), that
node is displayed above the reply form.
+ when replying to a comment (rather then to a node), that
comment is displayd above the reply form.
- removed structure.inc, removed structure.module.
- node.inc:
+ added 2 new node functions called 'node_attribute_edit()' and
'node_attribute_save()' used to 'hook in' any indexing system
including your home-brewed stuff if you'd want to. Currently,
index.module is the facto default index system.
See story.module for usage.
- book.module, story.module, poll.module, page.module, forum.module:
+ added preview functionality to administration section (via node
module).
+ removed all references to structure.inc (category, topic).
- moderate.module:
+ removed all references to structure.inc (category, topic).
- book.module, story.module, page.module, forum.module:
+ increased the sizes of some textareas.
- submit.php:
+ removed all references to structure.inc (category, topic).
- marvin.theme:
+ removed dead code: function story() was depricated.
- unconed.theme:
+ removed hardcoded references to drop.org.
- marvin.theme, unconed.theme, jeroen.theme, yaroon.theme, example.theme:
+ removed all references to structure.inc (category, topic).
TODO:
- file.module, trip_link.module:
+ update preview functionality:
see story.module for example.
+ remove references to 'cid' and 'tid', use 'attribute' instead:
see story.module for example.
- extend and build upon index.module as well as making it configurable
2001-06-10 15:01:20 +00:00
$form .= form_textarea(t("Abstract"), "abstract", $edit[abstract], 70, 10, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "")));
$form .= form_textarea(t("Body"), "body", $edit[body], 70, 20, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "")));
2001-03-24 16:56:10 +00:00
2001-05-15 18:38:57 +00:00
if ($edit[nid] > 0) {
$form .= form_hidden("nid", $edit[nid]);
}
2001-02-17 15:52:40 +00:00
2001-07-15 17:32:33 +00:00
if (!$edit) {
$form .= form_submit(t("Preview"));
}
else if ($edit && !$edit[title]) {
2001-05-12 21:06:13 +00:00
$form .= "<FONT COLOR=\"red\">". t("Warning: you did not supply a subject.") ."</FONT><P>\n";
2001-04-30 17:13:08 +00:00
$form .= form_submit(t("Preview"));
2001-03-24 16:56:10 +00:00
}
2001-06-17 18:31:25 +00:00
else if ($edit && !$edit[abstract]) {
2001-05-12 21:06:13 +00:00
$form .= "<FONT COLOR=\"red\">". t("Warning: you did not supply an abstract.") ."</FONT><P>\n";
2001-04-30 17:13:08 +00:00
$form .= form_submit(t("Preview"));
2001-03-24 16:56:10 +00:00
}
else {
2001-04-30 17:13:08 +00:00
$form .= form_submit(t("Preview"));
$form .= form_submit(t("Submit"));
2001-03-24 16:56:10 +00:00
}
2001-01-07 19:21:28 +00:00
2001-09-28 16:20:55 +00:00
return form($form);
2001-01-07 19:21:28 +00:00
}
2001-04-16 11:38:12 +00:00
function story_save($edit) {
2001-05-15 18:38:57 +00:00
global $status, $user;
if (!$edit[nid]) {
2001-09-16 11:33:14 +00:00
node_save($edit, array(abstract, attributes => node_attributes_save("story", $edit), author => $user->uid, body, comment => variable_get("story_comment", 0), moderate => variable_get("story_moderate", ""), promote => variable_get("story_promote", 0), score => 0, status => variable_get("story_status", $status[queued]), timestamp => time(), title, type => "story", votes => 0));
2001-05-15 18:38:57 +00:00
}
2001-06-29 22:08:57 +00:00
else if (user_access("administer nodes")) {
2001-06-15 07:30:44 +00:00
node_save($edit, array(abstract, attributes => node_attributes_save("story", $edit), body, title, type => "story"));
2001-05-15 18:38:57 +00:00
}
2001-01-07 19:21:28 +00:00
}
2001-03-24 16:56:10 +00:00
function story_user() {
2001-09-16 11:33:14 +00:00
global $edit, $op, $theme;
2001-03-24 16:56:10 +00:00
switch($op) {
case t("Preview"):
2001-04-16 11:38:12 +00:00
$theme->box(t("Submit"), story_form($edit));
2001-01-07 19:21:28 +00:00
break;
2001-03-24 16:56:10 +00:00
case t("Submit"):
2001-04-16 11:38:12 +00:00
story_save($edit);
2001-04-15 17:01:32 +00:00
$theme->box(t("Submit"), t("Thank you for your submission."));
2000-12-14 14:13:37 +00:00
break;
default:
2001-04-16 11:38:12 +00:00
$theme->box(t("Submit"), story_form());
2000-12-14 14:13:37 +00:00
}
}
2000-12-24 15:44:29 +00:00
?>