diff options
author | Dries Buytaert <dries@buytaert.net> | 2001-06-04 16:03:10 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2001-06-04 16:03:10 +0000 |
commit | 8fafe12188a1532843ba798bcecef502c7cea415 (patch) | |
tree | e9aac64543b6e33abfedcdf501094ae736b80e56 | |
parent | c75057bb0fc99d56e1b7a48c5fecfe0cf0f6498d (diff) | |
download | brdo-8fafe12188a1532843ba798bcecef502c7cea415.tar.gz brdo-8fafe12188a1532843ba798bcecef502c7cea415.tar.bz2 |
CHANGES:
- Improvement to node listings.
- Patched story.module to work with new node.module!
NOTE:
- UnConeD: poll.module needs updating. Let me know if you want me to do
it as I assume you will update it unless otherwise mentioned.
-rw-r--r-- | modules/node.module | 19 | ||||
-rw-r--r-- | modules/node/node.module | 19 | ||||
-rw-r--r-- | modules/story.module | 81 | ||||
-rw-r--r-- | modules/story/story.module | 81 |
4 files changed, 20 insertions, 180 deletions
diff --git a/modules/node.module b/modules/node.module index 8aeb5715c..587c428f6 100644 --- a/modules/node.module +++ b/modules/node.module @@ -45,10 +45,11 @@ function node_cron() { db_query("UPDATE node SET status = '". node_status("dumped") ."', timestamp_posted = '' WHERE timestamp_hidden > 0 AND timestamp_hidden < ". time()); } -function node_overview($query = array()) { +function node_overview($query) { global $user; - $colors = array("#ffdc9b", "#dedec4"); + $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"); @@ -65,10 +66,10 @@ function node_overview($query = array()) { $link[] = user_access($user, "node") ? "<A HREF=\"admin.php?mod=node&op=attribute&id=$node->nid\">edit attributes</A>" : "edit attributes"; $link[] = user_access($user, "node") ? "<A HREF=\"admin.php?mod=node&op=delete&id=$node->nid\">delete node</A>" : "delete node"; - $color = $colors[$i++ % sizeof($colors)]; + $bg = $color[$i++ % sizeof($color)]; - $output .= " <TR BGCOLOR=\"$color\"><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">$node->type</TD><TD>". node_status($node->status) ."</TD><TD>". check_output($node->attribute) ."</TD><TD>". format_username($node->userid) ."</TD><TD>". format_date($node->timestamp, "small") ."</TD></TR>\n"; - $output .= " <TR BGCOLOR=\"$color\"><TD ALIGN=\"right\" COLSPAN=\"6\"><SMALL>". implode(", ", $link) ."</SMALL></TD>\n"; + $output .= " <TR BGCOLOR=\"$bg\"><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">$node->type</TD><TD>". node_status($node->status) ."</TD><TD>". check_output($node->attribute) ."</TD><TD>". format_username($node->userid) ."</TD><TD>". format_date($node->timestamp, "small") ."</TD></TR>\n"; + $output .= " <TR BGCOLOR=\"$bg\"><TD ALIGN=\"right\" COLSPAN=\"6\"><SMALL>". implode(", ", $link) ."</SMALL></TD>\n"; } $output .= "</TABLE>\n"; @@ -150,7 +151,7 @@ function node_query($type = "") { function node_listing($queries) { global $mod; foreach ($queries as $key=>$array) { - $output .= "<LI><A HREF=\"admin.php?mod=$mod&type=$key\">$array[0]</A></LI>\n"; + $output .= "<LI><A HREF=\"admin.php?mod=$mod&query=$key\">$array[0]</A></LI>\n"; } return "<OL>$output</OL>\n"; } @@ -259,7 +260,7 @@ function node_admin() { break; case "delete": print status(node_delete($id)); - print node_overview(); + print node_overview($query); break; case "listing": print node_listing(node_query()); @@ -274,7 +275,7 @@ function node_admin() { break; case "Save node": print node_admin_save($edit); - print node_overview(); + print node_overview($query); break; case "edit": print node_module_edit(node_get_array(array("nid" => $id)), $type); @@ -286,7 +287,7 @@ function node_admin() { print status(node_module_save($edit, $type)); // fall through: default: - print node_overview(node_query($query ? $query : 0)); + print node_overview($query); } } diff --git a/modules/node/node.module b/modules/node/node.module index 8aeb5715c..587c428f6 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -45,10 +45,11 @@ function node_cron() { db_query("UPDATE node SET status = '". node_status("dumped") ."', timestamp_posted = '' WHERE timestamp_hidden > 0 AND timestamp_hidden < ". time()); } -function node_overview($query = array()) { +function node_overview($query) { global $user; - $colors = array("#ffdc9b", "#dedec4"); + $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"); @@ -65,10 +66,10 @@ function node_overview($query = array()) { $link[] = user_access($user, "node") ? "<A HREF=\"admin.php?mod=node&op=attribute&id=$node->nid\">edit attributes</A>" : "edit attributes"; $link[] = user_access($user, "node") ? "<A HREF=\"admin.php?mod=node&op=delete&id=$node->nid\">delete node</A>" : "delete node"; - $color = $colors[$i++ % sizeof($colors)]; + $bg = $color[$i++ % sizeof($color)]; - $output .= " <TR BGCOLOR=\"$color\"><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">$node->type</TD><TD>". node_status($node->status) ."</TD><TD>". check_output($node->attribute) ."</TD><TD>". format_username($node->userid) ."</TD><TD>". format_date($node->timestamp, "small") ."</TD></TR>\n"; - $output .= " <TR BGCOLOR=\"$color\"><TD ALIGN=\"right\" COLSPAN=\"6\"><SMALL>". implode(", ", $link) ."</SMALL></TD>\n"; + $output .= " <TR BGCOLOR=\"$bg\"><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">$node->type</TD><TD>". node_status($node->status) ."</TD><TD>". check_output($node->attribute) ."</TD><TD>". format_username($node->userid) ."</TD><TD>". format_date($node->timestamp, "small") ."</TD></TR>\n"; + $output .= " <TR BGCOLOR=\"$bg\"><TD ALIGN=\"right\" COLSPAN=\"6\"><SMALL>". implode(", ", $link) ."</SMALL></TD>\n"; } $output .= "</TABLE>\n"; @@ -150,7 +151,7 @@ function node_query($type = "") { function node_listing($queries) { global $mod; foreach ($queries as $key=>$array) { - $output .= "<LI><A HREF=\"admin.php?mod=$mod&type=$key\">$array[0]</A></LI>\n"; + $output .= "<LI><A HREF=\"admin.php?mod=$mod&query=$key\">$array[0]</A></LI>\n"; } return "<OL>$output</OL>\n"; } @@ -259,7 +260,7 @@ function node_admin() { break; case "delete": print status(node_delete($id)); - print node_overview(); + print node_overview($query); break; case "listing": print node_listing(node_query()); @@ -274,7 +275,7 @@ function node_admin() { break; case "Save node": print node_admin_save($edit); - print node_overview(); + print node_overview($query); break; case "edit": print node_module_edit(node_get_array(array("nid" => $id)), $type); @@ -286,7 +287,7 @@ function node_admin() { print status(node_module_save($edit, $type)); // fall through: default: - print node_overview(node_query($query ? $query : 0)); + print node_overview($query); } } diff --git a/modules/story.module b/modules/story.module index e6f48b5d3..b9b41f76d 100644 --- a/modules/story.module +++ b/modules/story.module @@ -79,87 +79,6 @@ function story_save($edit) { } } -function story_block() { -/* - // - // disabled for now - // - global $status; - $result = db_query("SELECT s.lid, COUNT(c.cid) AS comments, s.title FROM story s LEFT JOIN comments c ON s.lid = c.lid WHERE s.status = '$status[posted]' AND c.link = 'story' GROUP BY s.lid ORDER BY comments DESC LIMIT 10"); - while ($story = db_fetch_object($result)) { - $content .= "<LI><A HREF=\"node.php?id=$story->id\">". check_output($story->title) ."</A><BR><SMALL>(". format_plural($story->comments, "comment", "comments") .")</SMALL></LI>\n"; - } - - $blocks[0][subject] = "Top 10:<BR>all stories"; - $blocks[0][content] = $content; - $blocks[0][info] = "Top 10: all stories"; - - unset($content); - - $result = db_query("SELECT s.lid, COUNT(c.cid) AS comments, s.title FROM story s LEFT JOIN comments c ON s.lid = c.lid WHERE s.status = '$status[posted]' AND c.link = 'story' AND ". time() ." - s.timestamp < 2419200 GROUP BY s.lid ORDER BY comments DESC LIMIT 10"); - while ($story = db_fetch_object($result)) { - $content .= "<LI><A HREF=\"node.php?id=$story->id\">". check_output($story->title) ."</A><BR><SMALL>(". format_plural($story->comments, "comment", "comments") .")</SMALL></LI>\n"; - } - - $blocks[1][subject] = "Top 10:<BR>recent stories"; - $blocks[1][content] = $content; - $blocks[1][info] = "Top 10: recent stories"; - - return $blocks; -*/ -} - -function story_query($type = "") { - global $status; - $queries = array(array("recent stories", "WHERE n.type = 'story' ORDER BY n.timestamp DESC"), array("posted stories", "WHERE n.type = 'story' AND n.status = '$status[posted]' ORDER BY n.timestamp DESC"), array("queued stories", "WHERE n.type = 'story' AND n.status = '$status[queued]' ORDER BY n.timestamp DESC"), array("dumped stories", "WHERE n.type = 'story' AND n.status = '$status[dumped]' ORDER BY n.timestamp DESC"), array("stories without category (integrity)", "WHERE n.type = 'story' AND n.cid = '0' ORDER BY n.timestamp DESC"), array("stories without topic (integrity)", "WHERE n.type = 'story' AND n.tid = '0' ORDER BY n.timestamp DESC")); - return ($queries[$type] ? $queries[$type] : $queries); -} - -function story_overview($query = array()) { - return node_overview($query); -} - -function story_admin() { - global $id, $edit, $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"; - - $type = ($type ? $type : 0); - - switch ($op) { - case "add": - print story_form(); - break; - case "delete": - print story_delete($id); - print story_overview(story_query($type)); - break; - case "edit": - print story_form(node_get_array(array("nid" => check_input($id)))); - break; - case "help": - story_help(); - break; - case "listing": - print node_listing(story_query()); - break; - case "search": - print search_form($keys); - print search_data($keys, $mod); - break; - case t("Preview"): - story_view(new Story(node_preview($edit))); - print story_form($edit); - break; - case t("Submit"): - story_save($edit); - // fall through: - default: - print story_overview(story_query($type)); - } -} - - function story_user() { global $edit, $op, $theme, $user; diff --git a/modules/story/story.module b/modules/story/story.module index e6f48b5d3..b9b41f76d 100644 --- a/modules/story/story.module +++ b/modules/story/story.module @@ -79,87 +79,6 @@ function story_save($edit) { } } -function story_block() { -/* - // - // disabled for now - // - global $status; - $result = db_query("SELECT s.lid, COUNT(c.cid) AS comments, s.title FROM story s LEFT JOIN comments c ON s.lid = c.lid WHERE s.status = '$status[posted]' AND c.link = 'story' GROUP BY s.lid ORDER BY comments DESC LIMIT 10"); - while ($story = db_fetch_object($result)) { - $content .= "<LI><A HREF=\"node.php?id=$story->id\">". check_output($story->title) ."</A><BR><SMALL>(". format_plural($story->comments, "comment", "comments") .")</SMALL></LI>\n"; - } - - $blocks[0][subject] = "Top 10:<BR>all stories"; - $blocks[0][content] = $content; - $blocks[0][info] = "Top 10: all stories"; - - unset($content); - - $result = db_query("SELECT s.lid, COUNT(c.cid) AS comments, s.title FROM story s LEFT JOIN comments c ON s.lid = c.lid WHERE s.status = '$status[posted]' AND c.link = 'story' AND ". time() ." - s.timestamp < 2419200 GROUP BY s.lid ORDER BY comments DESC LIMIT 10"); - while ($story = db_fetch_object($result)) { - $content .= "<LI><A HREF=\"node.php?id=$story->id\">". check_output($story->title) ."</A><BR><SMALL>(". format_plural($story->comments, "comment", "comments") .")</SMALL></LI>\n"; - } - - $blocks[1][subject] = "Top 10:<BR>recent stories"; - $blocks[1][content] = $content; - $blocks[1][info] = "Top 10: recent stories"; - - return $blocks; -*/ -} - -function story_query($type = "") { - global $status; - $queries = array(array("recent stories", "WHERE n.type = 'story' ORDER BY n.timestamp DESC"), array("posted stories", "WHERE n.type = 'story' AND n.status = '$status[posted]' ORDER BY n.timestamp DESC"), array("queued stories", "WHERE n.type = 'story' AND n.status = '$status[queued]' ORDER BY n.timestamp DESC"), array("dumped stories", "WHERE n.type = 'story' AND n.status = '$status[dumped]' ORDER BY n.timestamp DESC"), array("stories without category (integrity)", "WHERE n.type = 'story' AND n.cid = '0' ORDER BY n.timestamp DESC"), array("stories without topic (integrity)", "WHERE n.type = 'story' AND n.tid = '0' ORDER BY n.timestamp DESC")); - return ($queries[$type] ? $queries[$type] : $queries); -} - -function story_overview($query = array()) { - return node_overview($query); -} - -function story_admin() { - global $id, $edit, $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"; - - $type = ($type ? $type : 0); - - switch ($op) { - case "add": - print story_form(); - break; - case "delete": - print story_delete($id); - print story_overview(story_query($type)); - break; - case "edit": - print story_form(node_get_array(array("nid" => check_input($id)))); - break; - case "help": - story_help(); - break; - case "listing": - print node_listing(story_query()); - break; - case "search": - print search_form($keys); - print search_data($keys, $mod); - break; - case t("Preview"): - story_view(new Story(node_preview($edit))); - print story_form($edit); - break; - case t("Submit"): - story_save($edit); - // fall through: - default: - print story_overview(story_query($type)); - } -} - - function story_user() { global $edit, $op, $theme, $user; |