diff options
author | Dries Buytaert <dries@buytaert.net> | 2001-06-10 15:01:20 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2001-06-10 15:01:20 +0000 |
commit | d397bbe93587f015cd8db0dbf16ef6d1c1aef78b (patch) | |
tree | 82b3b8dc63b04c11aeadd5b18cee796e4da43144 /modules | |
parent | 6b34310626b960a18646259d8d7caa1b6b2da1da (diff) | |
download | brdo-d397bbe93587f015cd8db0dbf16ef6d1c1aef78b.tar.gz brdo-d397bbe93587f015cd8db0dbf16ef6d1c1aef78b.tar.bz2 |
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
Diffstat (limited to 'modules')
-rw-r--r-- | modules/book.module | 19 | ||||
-rw-r--r-- | modules/book/book.module | 19 | ||||
-rw-r--r-- | modules/forum.module | 5 | ||||
-rw-r--r-- | modules/forum/forum.module | 5 | ||||
-rw-r--r-- | modules/index.module | 4 | ||||
-rw-r--r-- | modules/locale.module | 8 | ||||
-rw-r--r-- | modules/locale/locale.module | 8 | ||||
-rw-r--r-- | modules/moderate.module | 4 | ||||
-rw-r--r-- | modules/node.module | 5 | ||||
-rw-r--r-- | modules/node/node.module | 5 | ||||
-rw-r--r-- | modules/page.module | 27 | ||||
-rw-r--r-- | modules/page/page.module | 27 | ||||
-rw-r--r-- | modules/poll.module | 22 | ||||
-rw-r--r-- | modules/poll/poll.module | 22 | ||||
-rw-r--r-- | modules/story.module | 20 | ||||
-rw-r--r-- | modules/story/story.module | 20 | ||||
-rw-r--r-- | modules/structure.module | 157 |
17 files changed, 130 insertions, 247 deletions
diff --git a/modules/book.module b/modules/book.module index 319165c97..522dcdeff 100644 --- a/modules/book.module +++ b/modules/book.module @@ -108,10 +108,13 @@ function book_toc($parent = "", $indent = "", $toc = array()) { function book_form($edit = array()) { global $REQUEST_URI, $user; + if ($edit[title]) { + $form .= book_view(new Book(node_preview($edit))); + } + $form .= form_item(t("Author"), format_username(($edit[userid] ? $edit[userid] : $user->userid))); $form .= form_hidden(userid, $edit[userid]); $form .= form_textfield(t("Subject"), "title", $edit[title], 50, 64); - $form .= form_item(t("Category"), category_form_select("book", $edit)); if ($edit[pid]) { $node = node_get_object(array("nid" => $edit[pid])); @@ -122,8 +125,8 @@ function book_form($edit = array()) { $form .= form_select(t("Parent"), "parent", $edit[parent], book_toc(), t("The parent subject or category the page belongs in.")); } - $form .= form_textarea(t("Content"), "body", $edit[body], 50, 10, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", ""))); - $form .= form_textarea(t("Log message"), "log", $edit[log], 50, 5, t("An explanation of the additions or updates being made to help the group understand your motivations.")); + $form .= form_textarea(t("Content"), "body", $edit[body], 70, 20, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", ""))); + $form .= form_textarea(t("Log message"), "log", $edit[log], 70, 5, t("An explanation of the additions or updates being made to help the group understand your motivations.")); if (user_access($user, "book")) { $form .= form_select(t("Weight"), "weight", $edit[weight], array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30), t("The heavier nodes will sink and the lighter nodes will be positioned nearer the top.")); @@ -134,10 +137,7 @@ function book_form($edit = array()) { $form .= form_hidden("nid", $edit[nid]); } - if (!$edit) { - $form .= form_submit(t("Preview")); - } - else if (!$edit[title]) { + if (!$edit[title]) { $form .= "<FONT COLOR=\"red\">". t("Warning: you did not supply a title.") ."</FONT><P>\n"; $form .= form_submit(t("Preview")); } @@ -153,10 +153,10 @@ function book_save($edit) { global $status, $user; if (!$edit[nid]) { - node_save($edit, array(author => $user->id, body, cid, comment => variable_get("book_comment", 0), log, moderate => variable_get("book_moderate", ""), parent, promote => variable_get("book_promote", 0), score => 0, status => variable_get("book_status", $status[queued]), tid, timestamp => time(), title, type => "book", votes => 0, weight)); + node_save($edit, array(author => $user->id, body, comment => variable_get("book_comment", 0), log, moderate => variable_get("book_moderate", ""), parent, promote => variable_get("book_promote", 0), score => 0, status => variable_get("book_status", $status[queued]), timestamp => time(), title, type => "book", votes => 0, weight)); } else if (user_access($user)) { - node_save($edit, array(body, cid, log, parent, tid, title, type => "book", weight)); + node_save($edit, array(body, log, parent, title, type => "book", weight)); } } @@ -232,7 +232,6 @@ function book_user() { $theme->box($title, book_update($id)); break; case t("Preview"): - book_view(new Book(node_preview($edit))); $theme->box($title, book_form($edit)); break; case t("Submit"): diff --git a/modules/book/book.module b/modules/book/book.module index 319165c97..522dcdeff 100644 --- a/modules/book/book.module +++ b/modules/book/book.module @@ -108,10 +108,13 @@ function book_toc($parent = "", $indent = "", $toc = array()) { function book_form($edit = array()) { global $REQUEST_URI, $user; + if ($edit[title]) { + $form .= book_view(new Book(node_preview($edit))); + } + $form .= form_item(t("Author"), format_username(($edit[userid] ? $edit[userid] : $user->userid))); $form .= form_hidden(userid, $edit[userid]); $form .= form_textfield(t("Subject"), "title", $edit[title], 50, 64); - $form .= form_item(t("Category"), category_form_select("book", $edit)); if ($edit[pid]) { $node = node_get_object(array("nid" => $edit[pid])); @@ -122,8 +125,8 @@ function book_form($edit = array()) { $form .= form_select(t("Parent"), "parent", $edit[parent], book_toc(), t("The parent subject or category the page belongs in.")); } - $form .= form_textarea(t("Content"), "body", $edit[body], 50, 10, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", ""))); - $form .= form_textarea(t("Log message"), "log", $edit[log], 50, 5, t("An explanation of the additions or updates being made to help the group understand your motivations.")); + $form .= form_textarea(t("Content"), "body", $edit[body], 70, 20, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", ""))); + $form .= form_textarea(t("Log message"), "log", $edit[log], 70, 5, t("An explanation of the additions or updates being made to help the group understand your motivations.")); if (user_access($user, "book")) { $form .= form_select(t("Weight"), "weight", $edit[weight], array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30), t("The heavier nodes will sink and the lighter nodes will be positioned nearer the top.")); @@ -134,10 +137,7 @@ function book_form($edit = array()) { $form .= form_hidden("nid", $edit[nid]); } - if (!$edit) { - $form .= form_submit(t("Preview")); - } - else if (!$edit[title]) { + if (!$edit[title]) { $form .= "<FONT COLOR=\"red\">". t("Warning: you did not supply a title.") ."</FONT><P>\n"; $form .= form_submit(t("Preview")); } @@ -153,10 +153,10 @@ function book_save($edit) { global $status, $user; if (!$edit[nid]) { - node_save($edit, array(author => $user->id, body, cid, comment => variable_get("book_comment", 0), log, moderate => variable_get("book_moderate", ""), parent, promote => variable_get("book_promote", 0), score => 0, status => variable_get("book_status", $status[queued]), tid, timestamp => time(), title, type => "book", votes => 0, weight)); + node_save($edit, array(author => $user->id, body, comment => variable_get("book_comment", 0), log, moderate => variable_get("book_moderate", ""), parent, promote => variable_get("book_promote", 0), score => 0, status => variable_get("book_status", $status[queued]), timestamp => time(), title, type => "book", votes => 0, weight)); } else if (user_access($user)) { - node_save($edit, array(body, cid, log, parent, tid, title, type => "book", weight)); + node_save($edit, array(body, log, parent, title, type => "book", weight)); } } @@ -232,7 +232,6 @@ function book_user() { $theme->box($title, book_update($id)); break; case t("Preview"): - book_view(new Book(node_preview($edit))); $theme->box($title, book_form($edit)); break; case t("Submit"): diff --git a/modules/forum.module b/modules/forum.module index 194979ccd..61d05f561 100644 --- a/modules/forum.module +++ b/modules/forum.module @@ -14,8 +14,7 @@ function forum_form($edit = array()) { global $REQUEST_URI; $form .= form_textfield("Subject", "title", $edit[title], 50, 64); - $form .= structure_form("forum", $edit); - $form .= form_textarea("Body", "body", $edit[body], 50, 10); + $form .= form_textarea("Body", "body", $edit[body], 70, 10); $form .= form_hidden("nid", $edit[nid]); $form .= form_submit("Submit"); @@ -26,7 +25,7 @@ function forum_save($edit) { global $user, $status; if (user_access($user)) { - node_save($edit, array(author => $user->id, body, cid, comment => variable_get("forum_comment", 0), moderate => variable_get("forum_moderate", ""), promote => variable_get("forum_promote", 0), score => 0, status => $status[posted], tid, timestamp => time(), title, type => "forum", votes => 0)); + node_save($edit, array(author => $user->id, body, comment => variable_get("forum_comment", 0), moderate => variable_get("forum_moderate", ""), promote => variable_get("forum_promote", 0), score => 0, status => $status[posted], timestamp => time(), title, type => "forum", votes => 0)); } } diff --git a/modules/forum/forum.module b/modules/forum/forum.module index 194979ccd..61d05f561 100644 --- a/modules/forum/forum.module +++ b/modules/forum/forum.module @@ -14,8 +14,7 @@ function forum_form($edit = array()) { global $REQUEST_URI; $form .= form_textfield("Subject", "title", $edit[title], 50, 64); - $form .= structure_form("forum", $edit); - $form .= form_textarea("Body", "body", $edit[body], 50, 10); + $form .= form_textarea("Body", "body", $edit[body], 70, 10); $form .= form_hidden("nid", $edit[nid]); $form .= form_submit("Submit"); @@ -26,7 +25,7 @@ function forum_save($edit) { global $user, $status; if (user_access($user)) { - node_save($edit, array(author => $user->id, body, cid, comment => variable_get("forum_comment", 0), moderate => variable_get("forum_moderate", ""), promote => variable_get("forum_promote", 0), score => 0, status => $status[posted], tid, timestamp => time(), title, type => "forum", votes => 0)); + node_save($edit, array(author => $user->id, body, comment => variable_get("forum_comment", 0), moderate => variable_get("forum_moderate", ""), promote => variable_get("forum_promote", 0), score => 0, status => $status[posted], timestamp => time(), title, type => "forum", votes => 0)); } } diff --git a/modules/index.module b/modules/index.module index 592eca038..0d06a7b22 100644 --- a/modules/index.module +++ b/modules/index.module @@ -7,13 +7,13 @@ function index_get_array($id) { return db_fetch_array(db_query("SELECT * FROM entry WHERE eid = '". check_input($id) ."'")); } -function index_collection_form($name) { +function index_collection_form($name, $selected = "") { $result = db_query("SELECT * FROM entry WHERE collection = '$name'"); while ($entry = db_fetch_object($result)) { $options[$entry->keyword] = $entry->name; } - return form_select($name, $name, "", $options); + return form_select(ucfirst($name), $name, $selected, $options); } function index_collection_link($name) { diff --git a/modules/locale.module b/modules/locale.module index b4f254cc0..065468e9c 100644 --- a/modules/locale.module +++ b/modules/locale.module @@ -66,7 +66,7 @@ function locale_languages($translation) { function locale_overview() { if (variable_get("locale", 0)) { $result = db_query("SELECT * FROM locales ORDER BY string"); - + $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n"; $output .= " <TR><TH>string</TH><TH>languages</TH><TH COLSPAN=\"2\">operations</TH><TR>\n"; while ($locale = db_fetch_object($result)) { @@ -74,10 +74,12 @@ function locale_overview() { $output .= " <TR><TD>". check_output($locale->string) ."<BR><SMALL><I>$locale->location</I></SMALL></TD><TD ALIGN=\"center\">$languages</TD><TD><A HREF=\"admin.php?mod=locale&op=edit&id=$locale->id\">edit</A></TD><TD><A HREF=\"admin.php?mod=locale&op=delete&id=$locale->id\">delete</A></TD></TR>"; } $output .= "</TABLE>\n"; - + return $output; } - return "Locale disabled."; + else { + return status("locale disabled."); + } } function locale_admin() { diff --git a/modules/locale/locale.module b/modules/locale/locale.module index b4f254cc0..065468e9c 100644 --- a/modules/locale/locale.module +++ b/modules/locale/locale.module @@ -66,7 +66,7 @@ function locale_languages($translation) { function locale_overview() { if (variable_get("locale", 0)) { $result = db_query("SELECT * FROM locales ORDER BY string"); - + $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n"; $output .= " <TR><TH>string</TH><TH>languages</TH><TH COLSPAN=\"2\">operations</TH><TR>\n"; while ($locale = db_fetch_object($result)) { @@ -74,10 +74,12 @@ function locale_overview() { $output .= " <TR><TD>". check_output($locale->string) ."<BR><SMALL><I>$locale->location</I></SMALL></TD><TD ALIGN=\"center\">$languages</TD><TD><A HREF=\"admin.php?mod=locale&op=edit&id=$locale->id\">edit</A></TD><TD><A HREF=\"admin.php?mod=locale&op=delete&id=$locale->id\">delete</A></TD></TR>"; } $output .= "</TABLE>\n"; - + return $output; } - return "Locale disabled."; + else { + return status("locale disabled."); + } } function locale_admin() { diff --git a/modules/moderate.module b/modules/moderate.module index ceef124e5..c3db8abab 100644 --- a/modules/moderate.module +++ b/modules/moderate.module @@ -12,11 +12,11 @@ function moderate_overview($query = array()) { $output .= status($query[0]); $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n"; - $output .= " <TR><TH>node</TH><TH>category / topic</TH><TH>status</TH><TH>author</TH><TH>date</TH><TH>operations</TH></TR>\n"; + $output .= " <TR><TH>node</TH><TH>type</TH><TH>status</TH><TH>author</TH><TH>date</TH><TH>operations</TH></TR>\n"; $r1 = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN users u ON n.author = u.id WHERE n.moderate LIKE '%$user->userid%' ORDER BY n.timestamp DESC LIMIT 30"); while ($node = db_fetch_object($r1)) { - $output .= " <TR><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></TD><TD>". category_name($node->cid) ." / ". topic_name($node->tid) ."</TD><TD>". node_status($node->status) ."</TD><TD>". format_username($node->userid) ."</TD><TD>". format_date($node->timestamp, "small") ."</TD><TD><A HREF=\"admin.php?mod=moderate&type=node&op=edit&id=$node->nid\">edit $node->type</A></TD></TR>\n"; + $output .= " <TR><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></TD><TD>$node->type</TD><TD>". node_status($node->status) ."</TD><TD>". format_username($node->userid) ."</TD><TD>". format_date($node->timestamp, "small") ."</TD><TD><A HREF=\"admin.php?mod=moderate&type=node&op=edit&id=$node->nid\">edit $node->type</A></TD></TR>\n"; $r2 = db_query("SELECT c.*, u.userid FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.lid = '$node->nid' ORDER BY c.timestamp DESC"); while ($comment = db_fetch_object($r2)) { diff --git a/modules/node.module b/modules/node.module index 959ddff19..6b1df2c82 100644 --- a/modules/node.module +++ b/modules/node.module @@ -5,9 +5,8 @@ class Node { global $user; $this->userid = $node[userid] ? $node[userid] : $user->userid; $this->title = $node[title]; + $this->timestamp = $node[attribute]; $this->timestamp = $node[timestamp] ? $node[timestamp] : time(); - $this->cid = $node[cid]; - $this->tid = $node[tid]; } } @@ -67,7 +66,7 @@ function node_overview($query) { $color = array("#ffdc9b", "#dedec4"); $query = node_query($query ? $query : 0); - $result = db_query("SELECT n.*, u.userid, c.name AS category FROM node n LEFT JOIN users u ON n.author = u.id LEFT JOIN category c ON n.cid = c.cid $query[1] LIMIT 50"); + $result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN users u ON n.author = u.id $query[1] LIMIT 50"); $output .= status($query[0]); $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n"; diff --git a/modules/node/node.module b/modules/node/node.module index 959ddff19..6b1df2c82 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -5,9 +5,8 @@ class Node { global $user; $this->userid = $node[userid] ? $node[userid] : $user->userid; $this->title = $node[title]; + $this->timestamp = $node[attribute]; $this->timestamp = $node[timestamp] ? $node[timestamp] : time(); - $this->cid = $node[cid]; - $this->tid = $node[tid]; } } @@ -67,7 +66,7 @@ function node_overview($query) { $color = array("#ffdc9b", "#dedec4"); $query = node_query($query ? $query : 0); - $result = db_query("SELECT n.*, u.userid, c.name AS category FROM node n LEFT JOIN users u ON n.author = u.id LEFT JOIN category c ON n.cid = c.cid $query[1] LIMIT 50"); + $result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN users u ON n.author = u.id $query[1] LIMIT 50"); $output .= status($query[0]); $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n"; diff --git a/modules/page.module b/modules/page.module index 946798d1b..88739cbb4 100644 --- a/modules/page.module +++ b/modules/page.module @@ -2,8 +2,16 @@ $GLOBALS[format] = array(0 => "HTML", 1 => "PHP", 2 => "text"); +class Page { + function Page($page) { + $this = new Node($page); + $this->body = $page[body]; + $this->format = $page[format]; + } +} + function page_view($node, $main = 0) { - global $format, $theme; + global $format; switch ($format[$node->format]) { case "PHP": @@ -24,13 +32,24 @@ function page_status() { } function page_form($edit = array()) { - global $format, $REQUEST_URI; + global $REQUEST_URI, $format; + + if ($edit[title]) { + $form = page_view(new Page(node_preview($edit))); + } $form .= form_textfield("Subject", "title", $edit[title], 50, 64); - $form .= form_textarea("Body", "body", $edit[body], 80, 30); + $form .= form_textarea("Body", "body", $edit[body], 70, 30); $form .= form_select("Type", "format", $edit[format], $format); $form .= form_hidden("nid", $edit[nid]); - $form .= form_submit("Submit"); + + if ($edit[title]) { + $form .= form_submit(t("Preview")); + $form .= form_submit("Submit"); + } + else { + $form .= form_submit(t("Preview")); + } return form($REQUEST_URI, $form); } diff --git a/modules/page/page.module b/modules/page/page.module index 946798d1b..88739cbb4 100644 --- a/modules/page/page.module +++ b/modules/page/page.module @@ -2,8 +2,16 @@ $GLOBALS[format] = array(0 => "HTML", 1 => "PHP", 2 => "text"); +class Page { + function Page($page) { + $this = new Node($page); + $this->body = $page[body]; + $this->format = $page[format]; + } +} + function page_view($node, $main = 0) { - global $format, $theme; + global $format; switch ($format[$node->format]) { case "PHP": @@ -24,13 +32,24 @@ function page_status() { } function page_form($edit = array()) { - global $format, $REQUEST_URI; + global $REQUEST_URI, $format; + + if ($edit[title]) { + $form = page_view(new Page(node_preview($edit))); + } $form .= form_textfield("Subject", "title", $edit[title], 50, 64); - $form .= form_textarea("Body", "body", $edit[body], 80, 30); + $form .= form_textarea("Body", "body", $edit[body], 70, 30); $form .= form_select("Type", "format", $edit[format], $format); $form .= form_hidden("nid", $edit[nid]); - $form .= form_submit("Submit"); + + if ($edit[title]) { + $form .= form_submit(t("Preview")); + $form .= form_submit("Submit"); + } + else { + $form .= form_submit(t("Preview")); + } return form($REQUEST_URI, $form); } diff --git a/modules/poll.module b/modules/poll.module index ba6a0250a..cd9e0e306 100644 --- a/modules/poll.module +++ b/modules/poll.module @@ -28,7 +28,7 @@ function poll_delete($node) { if ($node->nid) { db_query("DELETE FROM poll_choices WHERE nid='" . $node->nid . "'"); - } + } } function poll_get_choices_array($poll) { @@ -87,7 +87,7 @@ function poll_help() { ?> <p>Poll.module allows you to run simple multiple choice polls on your site. After creating the necessary categories, you can add a poll through this administration interface.</p> <p>The poll.module also has a block to show the latest poll. If you combine it with a poll category that doesn't promote to the mainpage, you'll get a side-block only poll system.</p> - <p>If you want to set a limit on the duration of a poll, use the <i>Poll Duration</i> setting. After the specified interval, the poll will automatically be closed, preventing anymore voting.</p> + <p>If you want to set a limit on the duration of a poll, use the <i>Poll Duration</i> setting. After the specified interval, the poll will automatically be closed, preventing anymore voting.</p> <?php } @@ -175,9 +175,13 @@ function poll_form($edit = array(), $nocheck = 0) { 10713600 => t("4 months"), 31536000 => t("1 year")); $active = array(0 => "Closed", 1 => "Active"); - + $admin = ($edit[nid] && user_access($user,"poll")) ? 1 : 0; - + + if ($edit[title]) { + $form .= poll_view(new Poll(node_preview($edit))); + } + if ($admin && !is_array($edit[choices])) $edit = poll_get_choices_array($edit); /* Mini-form for number of choiceboxes */ @@ -198,15 +202,14 @@ function poll_form($edit = array(), $nocheck = 0) { $form .= form_select(t("Poll duration"), "runtime", $edit[runtime] ? $edit[runtime] : t("1 week"), $duration, t("After this period, the poll will automatically be closed.")); if ($admin) $form .= form_select(t("Poll status"), "active", $edit[active], $active); - $form .= structure_form("poll", $edit); - + $form .= node_attributes_edit($edit); // hidden fields: if ($edit[nid] > 0) { $form .= form_hidden("nid", $edit[nid]); } - if ((!$edit) || ($nocheck)) { + if ($nocheck) { $form .= form_submit(t("Preview")); } else if (!$edit[title]) { @@ -229,10 +232,10 @@ function poll_save($edit) { global $status, $user; if (!$edit[nid]) { - $nid = node_save($edit, array(active => 1, author => $user->id, cid, comment => variable_get("poll_comment", 0), moderate => variable_get("poll_moderate", ""), promote => variable_get("poll_promote", 0), runtime, score => 0, status => variable_get("poll_status", $status[queued]), tid, timestamp => time(), title, type => "poll", votes => 0, voters => "")); + $nid = node_save($edit, array(active => 1, attribute => node_attributes_save($edit), author => $user->id, cid, comment => variable_get("poll_comment", 0), moderate => variable_get("poll_moderate", ""), promote => variable_get("poll_promote", 0), runtime, score => 0, status => variable_get("poll_status", $status[queued]), tid, timestamp => time(), title, type => "poll", votes => 0, voters => "")); } else if (user_access($user)) { - $nid = node_save($edit, array(active, cid, tid, runtime, title, type => "poll")); + $nid = node_save($edit, array(active, attribute => node_attributes_save($edit), cid, tid, runtime, title, type => "poll")); db_query("DELETE FROM poll_choices WHERE nid='" . $nid . "'"); } if ($nid) { @@ -270,7 +273,6 @@ function poll_user() { case t("Refresh"): $refresh = 1; case t("Preview"): - poll_view(new Poll(node_preview($edit))); $theme->box(t("Submit"), poll_form($edit, $refresh)); break; case t("Submit"): diff --git a/modules/poll/poll.module b/modules/poll/poll.module index ba6a0250a..cd9e0e306 100644 --- a/modules/poll/poll.module +++ b/modules/poll/poll.module @@ -28,7 +28,7 @@ function poll_delete($node) { if ($node->nid) { db_query("DELETE FROM poll_choices WHERE nid='" . $node->nid . "'"); - } + } } function poll_get_choices_array($poll) { @@ -87,7 +87,7 @@ function poll_help() { ?> <p>Poll.module allows you to run simple multiple choice polls on your site. After creating the necessary categories, you can add a poll through this administration interface.</p> <p>The poll.module also has a block to show the latest poll. If you combine it with a poll category that doesn't promote to the mainpage, you'll get a side-block only poll system.</p> - <p>If you want to set a limit on the duration of a poll, use the <i>Poll Duration</i> setting. After the specified interval, the poll will automatically be closed, preventing anymore voting.</p> + <p>If you want to set a limit on the duration of a poll, use the <i>Poll Duration</i> setting. After the specified interval, the poll will automatically be closed, preventing anymore voting.</p> <?php } @@ -175,9 +175,13 @@ function poll_form($edit = array(), $nocheck = 0) { 10713600 => t("4 months"), 31536000 => t("1 year")); $active = array(0 => "Closed", 1 => "Active"); - + $admin = ($edit[nid] && user_access($user,"poll")) ? 1 : 0; - + + if ($edit[title]) { + $form .= poll_view(new Poll(node_preview($edit))); + } + if ($admin && !is_array($edit[choices])) $edit = poll_get_choices_array($edit); /* Mini-form for number of choiceboxes */ @@ -198,15 +202,14 @@ function poll_form($edit = array(), $nocheck = 0) { $form .= form_select(t("Poll duration"), "runtime", $edit[runtime] ? $edit[runtime] : t("1 week"), $duration, t("After this period, the poll will automatically be closed.")); if ($admin) $form .= form_select(t("Poll status"), "active", $edit[active], $active); - $form .= structure_form("poll", $edit); - + $form .= node_attributes_edit($edit); // hidden fields: if ($edit[nid] > 0) { $form .= form_hidden("nid", $edit[nid]); } - if ((!$edit) || ($nocheck)) { + if ($nocheck) { $form .= form_submit(t("Preview")); } else if (!$edit[title]) { @@ -229,10 +232,10 @@ function poll_save($edit) { global $status, $user; if (!$edit[nid]) { - $nid = node_save($edit, array(active => 1, author => $user->id, cid, comment => variable_get("poll_comment", 0), moderate => variable_get("poll_moderate", ""), promote => variable_get("poll_promote", 0), runtime, score => 0, status => variable_get("poll_status", $status[queued]), tid, timestamp => time(), title, type => "poll", votes => 0, voters => "")); + $nid = node_save($edit, array(active => 1, attribute => node_attributes_save($edit), author => $user->id, cid, comment => variable_get("poll_comment", 0), moderate => variable_get("poll_moderate", ""), promote => variable_get("poll_promote", 0), runtime, score => 0, status => variable_get("poll_status", $status[queued]), tid, timestamp => time(), title, type => "poll", votes => 0, voters => "")); } else if (user_access($user)) { - $nid = node_save($edit, array(active, cid, tid, runtime, title, type => "poll")); + $nid = node_save($edit, array(active, attribute => node_attributes_save($edit), cid, tid, runtime, title, type => "poll")); db_query("DELETE FROM poll_choices WHERE nid='" . $nid . "'"); } if ($nid) { @@ -270,7 +273,6 @@ function poll_user() { case t("Refresh"): $refresh = 1; case t("Preview"): - poll_view(new Poll(node_preview($edit))); $theme->box(t("Submit"), poll_form($edit, $refresh)); break; case t("Submit"): diff --git a/modules/story.module b/modules/story.module index 5bb61851b..3e6f428ce 100644 --- a/modules/story.module +++ b/modules/story.module @@ -38,21 +38,22 @@ function story_view($node, $main = 0) { function story_form($edit = array()) { global $REQUEST_URI, $user; + if ($edit[title]) { + story_view(new Story(node_preview($edit))); + } + $form .= form_item(t("Your name"), format_username(($edit[userid] ? $edit[userid] : $user->userid))); $form .= form_hidden("userid", $edit[userid]); $form .= form_textfield(t("Subject"), "title", $edit[title], 50, 64); - $form .= structure_form("story", $edit); - $form .= form_textarea(t("Abstract"), "abstract", $edit[abstract], 50, 10, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", ""))); - $form .= form_textarea(t("Body"), "body", $edit[body], 50, 15, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", ""))); + $form .= node_attributes_edit($edit); + $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", ""))); if ($edit[nid] > 0) { $form .= form_hidden("nid", $edit[nid]); } - if (!$edit) { - $form .= form_submit(t("Preview")); - } - else if (!$edit[title]) { + if (!$edit[title]) { $form .= "<FONT COLOR=\"red\">". t("Warning: you did not supply a subject.") ."</FONT><P>\n"; $form .= form_submit(t("Preview")); } @@ -72,10 +73,10 @@ function story_save($edit) { global $status, $user; if (!$edit[nid]) { - node_save($edit, array(abstract, author => $user->id, body, cid, 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]), tid, timestamp => time(), title, type => "story", votes => 0)); + node_save($edit, array(abstract, attribute => node_attributes_save($edit), author => $user->id, 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)); } else if (user_access($user)) { - node_save($edit, array(abstract, body, cid, tid, title, type => "story")); + node_save($edit, array(abstract, attribute => node_attributes_save($edit), body, title, type => "story")); } } @@ -84,7 +85,6 @@ function story_user() { switch($op) { case t("Preview"): - story_view(new Story(node_preview($edit))); $theme->box(t("Submit"), story_form($edit)); break; case t("Submit"): diff --git a/modules/story/story.module b/modules/story/story.module index 5bb61851b..3e6f428ce 100644 --- a/modules/story/story.module +++ b/modules/story/story.module @@ -38,21 +38,22 @@ function story_view($node, $main = 0) { function story_form($edit = array()) { global $REQUEST_URI, $user; + if ($edit[title]) { + story_view(new Story(node_preview($edit))); + } + $form .= form_item(t("Your name"), format_username(($edit[userid] ? $edit[userid] : $user->userid))); $form .= form_hidden("userid", $edit[userid]); $form .= form_textfield(t("Subject"), "title", $edit[title], 50, 64); - $form .= structure_form("story", $edit); - $form .= form_textarea(t("Abstract"), "abstract", $edit[abstract], 50, 10, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", ""))); - $form .= form_textarea(t("Body"), "body", $edit[body], 50, 15, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", ""))); + $form .= node_attributes_edit($edit); + $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", ""))); if ($edit[nid] > 0) { $form .= form_hidden("nid", $edit[nid]); } - if (!$edit) { - $form .= form_submit(t("Preview")); - } - else if (!$edit[title]) { + if (!$edit[title]) { $form .= "<FONT COLOR=\"red\">". t("Warning: you did not supply a subject.") ."</FONT><P>\n"; $form .= form_submit(t("Preview")); } @@ -72,10 +73,10 @@ function story_save($edit) { global $status, $user; if (!$edit[nid]) { - node_save($edit, array(abstract, author => $user->id, body, cid, 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]), tid, timestamp => time(), title, type => "story", votes => 0)); + node_save($edit, array(abstract, attribute => node_attributes_save($edit), author => $user->id, 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)); } else if (user_access($user)) { - node_save($edit, array(abstract, body, cid, tid, title, type => "story")); + node_save($edit, array(abstract, attribute => node_attributes_save($edit), body, title, type => "story")); } } @@ -84,7 +85,6 @@ function story_user() { switch($op) { case t("Preview"): - story_view(new Story(node_preview($edit))); $theme->box(t("Submit"), story_form($edit)); break; case t("Submit"): diff --git a/modules/structure.module b/modules/structure.module deleted file mode 100644 index 823da5254..000000000 --- a/modules/structure.module +++ /dev/null @@ -1,157 +0,0 @@ -<?php - -function content_types($name) { - global $types; - if (function_exists($name ."_status")) $types[$name] = $name; -} - -function category_form($edit = array()) { - global $types; - - $threshold_post = array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 11 => 11, 12 => 12, 13 => 13, 14 => 14, 15 => 15, 20 => 20, 25 => 25, 30 => 30, 35 => 35, 40 => 40, 45 => 45, 50 => 50, 60 => 60, 70 => 70, 80 => 80, 90 => 90, 100 => 100); - $threshold_dump = array(-1 => -1, -2 => -2, -3 => -3, -4 => -4, -5 => -5, -6 => -6, -7 => -7, -8 => -8, -9 => -9, -10 => -10, -11 => -11, -12 => -12, -13 => -13, -14 => -14, -15 => -15, -20 => -20, -25 => -25, -30 => -30); - $threshold_expire = array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 11 => 11, 12 => 12, 13 => 13, 14 => 14, 15 => 15, 20 => 20, 25 => 25, 30 => 30, 35 => 35, 40 => 40, 45 => 45, 50 => 50, 60 => 60, 70 => 70, 80 => 80, 90 => 90, 100 => 100); - - module_iterate("content_types"); - - $form .= form_textfield(t("Name"), "name", $edit[name], 30, 55, t("A unique name for this category like 'announcement', 'article', 'column', 'review', etc.")); - $form .= form_select(t("Content type"), "type", $edit[type], $types, t("The content type to bind or associate this category with.")); - $form .= form_select(t("Comment"), "comment", $edit[comment], node_comment_status(), t("By default, allow or dissallow users to post comments in this category.")); - $form .= form_select(t("Promote"), "promote", $edit[promote], node_promote_status(), t("By default, promote new submissions in this category to the front page.")); - - $form .= form_select(t("Submission"), "submission", $edit[submission], node_submission_status(), t("What to do with new submissions in this category?")); - $form .= form_select(t("Post threshold"), "post", $edit[post], $threshold_post, t("If new submissions are subject to moderation, select a post threshold.")); - $form .= form_select(t("Dump threshold"), "dump", $edit[dump], $threshold_dump, t("If new submissions are subject to moderation, select a dump threshold.")); - $form .= form_select(t("Expiration threshold"), "expire", $edit[expire], $threshold_expire, t("If new submissions are subject to moderation, select a expiration threshold.")); - - if ($edit[cid]) { - $form .= form_hidden("cid", $edit[cid]); - $form .= form_submit(t("Save category")); - $form .= form_submit(t("Delete category")); - } - else { - $form .= form_submit(t("Save category")); - } - - return form("admin.php?mod=structure&type=category", $form); -} - -function category_overview() { - $result = db_query("SELECT * FROM category ORDER BY name"); - - $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n"; - $output .= " <TR><TH>name</TH><TH>type</TH><TH>comment</TH><TH>promote</TH><TH>submissions</TH><TH>operations</TH></TR>\n"; - while ($category = db_fetch_object($result)) { - $output .= " <TR><TD>". check_output($category->name) ."</TD><TD>". check_output($category->type) ."</TD><TD>". node_comment_status($category->comment) ."</TD><TD>". node_promote_status($category->promote) ."</TD><TD>". node_submission_status($category->submission) ."". ($category->submission ? "<BR><SMALL>post: $category->post, dump: $category->dump, expire: $category->expire</SMALL>" : "") ."</TD><TD><A HREF=\"admin.php?mod=structure&type=category&op=edit&id=$category->cid\">edit category</A></TD></TR>\n"; - } - $output .= "</TABLE>\n"; - return $output; -} - -// ---- topic ---- - -function topic_form($edit = array()) { - - $result = db_query("SELECT * FROM topic WHERE name != '$edit[name]' ORDER BY name DESC"); - while ($topic = db_fetch_object($result)) { - $topics[$topic->tid] = $topic->name; - } - $topics[0] = " "; - - $form .= form_textfield(t("Name"), "name", $edit[name], 30, 55, t("A unique name for this topic like 'science', 'internet', 'culture', etc.")); - $form .= form_select(t("Parent"), "pid", $edit[pid], $topics, t("The parent topic this topic belongs in.")); - $form .= form_textfield("Moderate", "moderate", $edit[moderate], 35, 255, t("Provide a comma-seperated list of the moderators' usernames.")); - - if ($edit[tid]) { - $form .= form_hidden("tid", $edit[tid]); - $form .= form_submit(t("Save topic")); - $form .= form_submit(t("Delete topic")); - } - else { - $form .= form_submit(t("Save topic")); - } - - return form("admin.php?mod=structure&type=topic", $form); -} - -function topic_overview() { - $tree = topic_tree(); - - $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n"; - $output .= " <TR><TH>name</TH><TH>moderators</TH><TH>operations</TH></TR>\n"; - foreach ($tree as $id=>$name) { - $topic = topic_get_object("tid", $id); - $output .= " <TR><TD>". check_output($name) ."</TD><TD>". check_output($topic->moderate) ."</TD><TD><A HREF=\"admin.php?mod=structure&type=topic&op=edit&id=$topic->tid\">edit topic</A></TD></TR>\n"; - } - $output .= "</TABLE>\n"; - return $output; -} - -// ----- structure ----- - -function structure_overview() { - $output .= "<H3>Categories</H3>\n"; - $output .= category_overview(); - $output .= "<H3>Topics</H3>\n"; - $output .= topic_overview(); - return $output; -} - -function structure_admin() { - global $id, $op, $type, $edit; - - print "<SMALL><A HREF=\"admin.php?mod=structure&type=category&op=add\">add new category</A> | <A HREF=\"admin.php?mod=structure&type=topic&op=add\">add new topic</A> | <A HREF=\"admin.php?mod=structure\">overview</A></SMALL><HR>\n"; - - switch ($type) { - case "category": - switch ($op) { - case "add": - print category_form(); - break; - case "edit": - print category_form(category_get_array("cid", $id)); - break; - case "view": - print category_view($id); - break; - case "Delete category": - print status(category_del($edit[cid])); - print structure_overview(); - break; - case "Save category": - print status(category_save($edit)); - print structure_overview(); - break; - default: - print structure_overview(); - } - break; - case "topic": - switch ($op) { - case "add": - print topic_form(); - break; - case "edit": - print topic_form(topic_get_array("tid", $id)); - break; - case "view": - print topic_view($id); - break; - case "Delete topic": - print status(topic_del($edit[tid])); - print structure_overview(); - break; - case "Save topic": - print status(topic_save($edit)); - print structure_overview(); - break; - default: - print structure_overview(); - } - break; - default: - print structure_overview(); - } -} - -?>
\ No newline at end of file |