Commit 6fdef172 authored by Kjartan's avatar Kjartan

page.module

- added a links option so pages can be displayed on the links of the site in an
  easy way. (Requires an SQL update.)
- made HTML and text type pages be $theme->box()ed again.
- made the page body hidden in a comment during editing, in case things
  crash you should still be able to retrieve your code. Will keep working on a
  better solution.

node.module
- made all node types be listed in the node listings.
parent 64ce2fb5
......@@ -185,22 +185,25 @@ function node_delete($id) {
function node_query($type = -1) {
$queries[] = array("all nodes: recent additions", "ORDER BY n.timestamp DESC");
$queries[] = array("all nodes: status set to 'posted'", "WHERE n.status = '". node_status("posted") ."' ORDER BY n.timestamp DESC");
$queries[] = array("all nodes: status set to 'queued'", "WHERE n.status = '". node_status("queued") ."' ORDER BY n.timestamp DESC");
$queries[] = array("all nodes: status set to 'dumped'", "WHERE n.status = '". node_status("dumped") ."' ORDER BY n.timestamp DESC");
$queries[] = array("all nodes: status set to 'posted'", "WHERE n.status = ". node_status("posted") ." ORDER BY n.timestamp DESC");
$queries[] = array("all nodes: status set to 'queued'", "WHERE n.status = ". node_status("queued") ." ORDER BY n.timestamp DESC");
$queries[] = array("all nodes: status set to 'dumped'", "WHERE n.status = ". node_status("dumped") ." ORDER BY n.timestamp DESC");
$queries[] = array("all nodes: scheduled to be posted", "WHERE n.timestamp_posted > 0 ORDER BY n.timestamp DESC");
$queries[] = array("all nodes: scheduled to be queued", "WHERE n.timestamp_queued > 0 ORDER BY n.timestamp DESC");
$queries[] = array("all nodes: scheduled to be hidden", "WHERE n.timestamp_hidden > 0 ORDER BY n.timestamp DESC");
foreach (module_list() as $name) {
if (module_hook($name, "user")) {
if (module_hook($name, "status")) {
$queries[] = array("$name: recent additions", "WHERE n.type = '$name' ORDER BY n.timestamp DESC");
$queries[] = array("$name: status set to 'posted'", "WHERE n.type = '$name' AND n.status = '". node_status("posted") ."' ORDER BY n.timestamp DESC");
$queries[] = array("$name: status set to 'queued'", "WHERE n.type = '$name' AND n.status = '". node_status("queued") ."' ORDER BY n.timestamp DESC");
$queries[] = array("$name: status set to 'dumped'", "WHERE n.type = '$name' AND n.status = '". node_status("dumped") ."' ORDER BY n.timestamp DESC");
$queries[] = array("$name: scheduled to be posted", "WHERE n.type = '$name' AND n.timestamp_posted > 0 ORDER BY n.timestamp DESC");
$queries[] = array("$name: scheduled to be queued", "WHERE n.type = '$name' AND n.timestamp_queued > 0 ORDER BY n.timestamp DESC");
$queries[] = array("$name: scheduled to be hidden", "WHERE n.type = '$name' AND n.timestamp_hidden > 0 ORDER BY n.timestamp DESC");
$statuses = module_invoke($name, "status");
if (is_array($statuses)) {
foreach (array_reverse($statuses) as $key=>$status) {
$queries[] = array("$name: status set to '$status'", "WHERE n.type = '$name' AND n.status = '". node_status($status) ."' ORDER BY n.timestamp DESC");
}
$queries[] = array("$name: scheduled to be posted", "WHERE n.type = '$name' AND n.timestamp_posted > 0 ORDER BY n.timestamp DESC");
$queries[] = array("$name: scheduled to be queued", "WHERE n.type = '$name' AND n.timestamp_queued > 0 ORDER BY n.timestamp DESC");
$queries[] = array("$name: scheduled to be hidden", "WHERE n.type = '$name' AND n.timestamp_hidden > 0 ORDER BY n.timestamp DESC");
}
}
}
......
......@@ -185,22 +185,25 @@ function node_delete($id) {
function node_query($type = -1) {
$queries[] = array("all nodes: recent additions", "ORDER BY n.timestamp DESC");
$queries[] = array("all nodes: status set to 'posted'", "WHERE n.status = '". node_status("posted") ."' ORDER BY n.timestamp DESC");
$queries[] = array("all nodes: status set to 'queued'", "WHERE n.status = '". node_status("queued") ."' ORDER BY n.timestamp DESC");
$queries[] = array("all nodes: status set to 'dumped'", "WHERE n.status = '". node_status("dumped") ."' ORDER BY n.timestamp DESC");
$queries[] = array("all nodes: status set to 'posted'", "WHERE n.status = ". node_status("posted") ." ORDER BY n.timestamp DESC");
$queries[] = array("all nodes: status set to 'queued'", "WHERE n.status = ". node_status("queued") ." ORDER BY n.timestamp DESC");
$queries[] = array("all nodes: status set to 'dumped'", "WHERE n.status = ". node_status("dumped") ." ORDER BY n.timestamp DESC");
$queries[] = array("all nodes: scheduled to be posted", "WHERE n.timestamp_posted > 0 ORDER BY n.timestamp DESC");
$queries[] = array("all nodes: scheduled to be queued", "WHERE n.timestamp_queued > 0 ORDER BY n.timestamp DESC");
$queries[] = array("all nodes: scheduled to be hidden", "WHERE n.timestamp_hidden > 0 ORDER BY n.timestamp DESC");
foreach (module_list() as $name) {
if (module_hook($name, "user")) {
if (module_hook($name, "status")) {
$queries[] = array("$name: recent additions", "WHERE n.type = '$name' ORDER BY n.timestamp DESC");
$queries[] = array("$name: status set to 'posted'", "WHERE n.type = '$name' AND n.status = '". node_status("posted") ."' ORDER BY n.timestamp DESC");
$queries[] = array("$name: status set to 'queued'", "WHERE n.type = '$name' AND n.status = '". node_status("queued") ."' ORDER BY n.timestamp DESC");
$queries[] = array("$name: status set to 'dumped'", "WHERE n.type = '$name' AND n.status = '". node_status("dumped") ."' ORDER BY n.timestamp DESC");
$queries[] = array("$name: scheduled to be posted", "WHERE n.type = '$name' AND n.timestamp_posted > 0 ORDER BY n.timestamp DESC");
$queries[] = array("$name: scheduled to be queued", "WHERE n.type = '$name' AND n.timestamp_queued > 0 ORDER BY n.timestamp DESC");
$queries[] = array("$name: scheduled to be hidden", "WHERE n.type = '$name' AND n.timestamp_hidden > 0 ORDER BY n.timestamp DESC");
$statuses = module_invoke($name, "status");
if (is_array($statuses)) {
foreach (array_reverse($statuses) as $key=>$status) {
$queries[] = array("$name: status set to '$status'", "WHERE n.type = '$name' AND n.status = '". node_status($status) ."' ORDER BY n.timestamp DESC");
}
$queries[] = array("$name: scheduled to be posted", "WHERE n.type = '$name' AND n.timestamp_posted > 0 ORDER BY n.timestamp DESC");
$queries[] = array("$name: scheduled to be queued", "WHERE n.type = '$name' AND n.timestamp_queued > 0 ORDER BY n.timestamp DESC");
$queries[] = array("$name: scheduled to be hidden", "WHERE n.type = '$name' AND n.timestamp_hidden > 0 ORDER BY n.timestamp DESC");
}
}
}
......
......@@ -10,21 +10,31 @@ function Page($page) {
}
}
function page_link($type) {
if ($type == "page" && user_access("access content")) {
$result = db_query("SELECT nid,link FROM page WHERE link != '' ORDER BY link");
while ($page = db_fetch_object($result)) {
$links[] = "<a href=\"node.php?id=$page->nid\">$page->link</a>";
}
}
return $links ? $links : array();
}
function page_view($node, $main = 0) {
global $format;
global $format, $theme;
switch ($format[$node->format]) {
case "PHP":
$output = eval($node->body);
print eval($node->body);
break;
case "text":
$output = nl2br(htmlentities($node->body));
$theme->box($node->title, nl2br(htmlentities($node->body)));
break;
default:
$output = check_output($node->body, 1);
$theme->box($node->title, check_output($node->body, 1));
}
print $output;
}
function page_status() {
......@@ -39,10 +49,12 @@ function page_form($edit = array()) {
}
if ($edit[title]) {
print "<!-- Don't ask:\n$edit[body] -->\n";
$form = page_view(new Page(node_preview($edit)));
}
$form .= form_textfield("Subject", "title", $edit[title], 50, 64);
$form .= form_textfield("Link", "link", $edit[link], 50, 64);
$form .= form_textarea("Body", "body", $edit[body], 70, 30);
$form .= form_select("Type", "format", $edit[format], $format);
$form .= form_hidden("nid", $edit[nid]);
......@@ -61,7 +73,7 @@ function page_form($edit = array()) {
function page_save($edit) {
global $status, $user;
node_save($edit, array(author => $user->id, body, comment => variable_get("page_comment", 0), format, moderate => variable_get("page_moderate", ""), promote => variable_get("page_promote", 0), score => 0, status => $status[posted], timestamp => time(), title, type => "page", votes => 0));
node_save($edit, array(author => $user->id, link, body, comment => variable_get("page_comment", 0), format, moderate => variable_get("page_moderate", ""), promote => variable_get("page_promote", 0), score => 0, status => $status[posted], timestamp => time(), title, type => "page", votes => 0));
}
?>
\ No newline at end of file
......@@ -10,21 +10,31 @@ function Page($page) {
}
}
function page_link($type) {
if ($type == "page" && user_access("access content")) {
$result = db_query("SELECT nid,link FROM page WHERE link != '' ORDER BY link");
while ($page = db_fetch_object($result)) {
$links[] = "<a href=\"node.php?id=$page->nid\">$page->link</a>";
}
}
return $links ? $links : array();
}
function page_view($node, $main = 0) {
global $format;
global $format, $theme;
switch ($format[$node->format]) {
case "PHP":
$output = eval($node->body);
print eval($node->body);
break;
case "text":
$output = nl2br(htmlentities($node->body));
$theme->box($node->title, nl2br(htmlentities($node->body)));
break;
default:
$output = check_output($node->body, 1);
$theme->box($node->title, check_output($node->body, 1));
}
print $output;
}
function page_status() {
......@@ -39,10 +49,12 @@ function page_form($edit = array()) {
}
if ($edit[title]) {
print "<!-- Don't ask:\n$edit[body] -->\n";
$form = page_view(new Page(node_preview($edit)));
}
$form .= form_textfield("Subject", "title", $edit[title], 50, 64);
$form .= form_textfield("Link", "link", $edit[link], 50, 64);
$form .= form_textarea("Body", "body", $edit[body], 70, 30);
$form .= form_select("Type", "format", $edit[format], $format);
$form .= form_hidden("nid", $edit[nid]);
......@@ -61,7 +73,7 @@ function page_form($edit = array()) {
function page_save($edit) {
global $status, $user;
node_save($edit, array(author => $user->id, body, comment => variable_get("page_comment", 0), format, moderate => variable_get("page_moderate", ""), promote => variable_get("page_promote", 0), score => 0, status => $status[posted], timestamp => time(), title, type => "page", votes => 0));
node_save($edit, array(author => $user->id, link, body, comment => variable_get("page_comment", 0), format, moderate => variable_get("page_moderate", ""), promote => variable_get("page_promote", 0), score => 0, status => $status[posted], timestamp => time(), title, type => "page", votes => 0));
}
?>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment