summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKjartan Mannes <kjartan@2.no-reply.drupal.org>2001-07-17 20:08:05 +0000
committerKjartan Mannes <kjartan@2.no-reply.drupal.org>2001-07-17 20:08:05 +0000
commit6fdef1725780711d1f52a9943e0048f291213e0c (patch)
tree774b075d2f03d2f3fe02b5ccf18b32e7cb6cf25c
parent64ce2fb5fba4d399584c3c873b07013eebbff1f8 (diff)
downloadbrdo-6fdef1725780711d1f52a9943e0048f291213e0c.tar.gz
brdo-6fdef1725780711d1f52a9943e0048f291213e0c.tar.bz2
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.
-rw-r--r--modules/node.module23
-rw-r--r--modules/node/node.module23
-rw-r--r--modules/page.module24
-rw-r--r--modules/page/page.module24
4 files changed, 62 insertions, 32 deletions
diff --git a/modules/node.module b/modules/node.module
index add0673c5..ba12cc7c5 100644
--- a/modules/node.module
+++ b/modules/node.module
@@ -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");
+ }
}
}
diff --git a/modules/node/node.module b/modules/node/node.module
index add0673c5..ba12cc7c5 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -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");
+ }
}
}
diff --git a/modules/page.module b/modules/page.module
index bdb6c7ba2..42d409f34 100644
--- a/modules/page.module
+++ b/modules/page.module
@@ -10,21 +10,31 @@ class 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
diff --git a/modules/page/page.module b/modules/page/page.module
index bdb6c7ba2..42d409f34 100644
--- a/modules/page/page.module
+++ b/modules/page/page.module
@@ -10,21 +10,31 @@ class 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