2001-04-02 15:54:37 +00:00
<?php
2001-05-05 13:57:29 +00:00
class Node {
function Node($node) {
global $user;
2001-09-24 18:46:07 +00:00
$this->uid = $node[uid] ? $node[uid] : $user->uid;
$this->nid = $node[nid];
$this->type = $node[type];
2001-09-25 17:10:44 +00:00
$this->comment = $node[comment] ? $node[comment] : variable_get($node[type]."_comment", 0);
2001-08-11 14:54:39 +00:00
$this->name = $node[name] ? $node[name] : $user->name;
2001-05-05 13:57:29 +00:00
$this->title = $node[title];
2001-06-12 11:50:38 +00:00
$this->attributes = $node[attributes];
2001-05-05 13:57:29 +00:00
$this->timestamp = $node[timestamp] ? $node[timestamp] : time();
}
}
2001-04-02 15:54:37 +00:00
2001-06-06 20:26:12 +00:00
function node_help() {
global $mod;
?>
<P>Todo.</P>
<?php
if ($mod == "node") {
foreach (module_list() as $name) {
if (module_hook($name, "status") && $name != "node") {
2001-08-15 14:13:14 +00:00
print "<h3>". ucfirst($name) ." type</h3>";
2001-06-06 20:26:12 +00:00
print module_invoke($name, "help");
}
}
}
}
2001-06-20 20:00:40 +00:00
function node_perm() {
2001-06-30 09:50:36 +00:00
return array("administer nodes", "access content", "post content");
2001-06-20 20:00:40 +00:00
}
2001-06-17 20:35:48 +00:00
function node_conf_options() {
2001-07-03 19:16:20 +00:00
$output .= form_select("Default number of nodes to display", "default_nodes_main", variable_get("default_nodes_main", 10), array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 15 => 15, 20 => 20, 25 => 25, 30 => 30), "The default maximum number of nodes to display on the main page.");
2001-09-25 17:10:44 +00:00
$output .= form_select("Prompt for confirmation when deleting nodes", "default_nodes_confirm_delete", variable_get("default_nodes_confirm_delete", 1), array("Disabled", "Enabled"), "Prompt for confirmation when deleting nodes.");
2001-06-17 20:35:48 +00:00
return $output;
}
2001-05-20 13:51:40 +00:00
function node_conf_filters() {
2001-09-26 20:50:12 +00:00
$output .= form_select(t("Enable HTML tags"), "filter_html", variable_get("filter_html", 0), array("Disabled", "Enabled"), t("Allow HTML and PHP tags in user-contributed content."));
$output .= form_textfield(t("Allowed HTML tags"), "allowed_html", variable_get("allowed_html", "<A><B><BLOCKQUOTE><DD><DL><DT><I><LI><OL><U><UL>"), 64, 128, t("If enabled, optionally specify tags which should not be stripped. 'STYLE' attributes, 'ON' attributes and unclosed tags are always stripped."));
2001-08-15 14:13:14 +00:00
$output .= "<hr />";
2001-09-26 20:50:12 +00:00
$output .= form_select(t("Enable link tags"), "filter_link", variable_get("filter_link", 0), array("Disabled", "Enabled"), t("Substitute special [[nodesubject|text]] tags. Your browser will display 'text', and when you click on it your browser will open the node with the subject 'nodesubject'. Please be aware that you'll need to copy the subject of the target node exactly in order to use this feature."));
2001-08-15 14:13:14 +00:00
$output .= "<hr />";
2001-05-20 13:51:40 +00:00
return $output;
}
function node_filter_html($text) {
$text = eregi_replace("([ \f\r\t\n\'\"])style=[^>]+", "\\1", $text);
$text = eregi_replace("([ \f\r\t\n\'\"])on[a-z]+=[^>]+", "\\1", $text);
$text = strip_tags($text, variable_get("allowed_html", ""));
return $text;
}
function node_filter_link($text) {
2001-05-17 20:50:15 +00:00
$src = array("/\[\[(([^\|]*?)(\|([^\|]*?))?)\]\]/e"); // [link|description]
$dst = array(format_tag('\\2', '\\4')); // [link|description]
return preg_replace($src, $dst, $text);
}
2001-05-20 13:51:40 +00:00
function node_filter($text) {
if (variable_get("filter_html", 0)) $text = node_filter_html($text);
if (variable_get("filter_link", 0)) $text = node_filter_link($text);
return $text;
}
2001-06-04 15:40:39 +00:00
function node_cron() {
db_query("UPDATE node SET status = '". node_status("posted") ."', timestamp_posted = '' WHERE timestamp_posted > 0 AND timestamp_posted < ". time());
2001-06-27 18:06:36 +00:00
db_query("UPDATE node SET status = '". node_status("queued") ."', timestamp_queued = '' WHERE timestamp_queued > 0 AND timestamp_queued < ". time());
db_query("UPDATE node SET status = '". node_status("dumped") ."', timestamp_hidden = '' WHERE timestamp_hidden > 0 AND timestamp_hidden < ". time());
2001-06-04 15:40:39 +00:00
}
2001-07-14 12:12:41 +00:00
function node_link($type, $node = 0) {
2001-06-29 22:08:57 +00:00
2001-07-14 12:12:41 +00:00
if ($type == "admin" && user_access("administer nodes")) {
2001-06-29 22:08:57 +00:00
$links[] = "<a href=\"admin.php?mod=node\">content</a>";
}
2001-07-14 12:12:41 +00:00
if ($type == "node") {
2001-08-02 15:54:09 +00:00
if ($node->links) {
$links = $node->links;
}
2001-06-29 22:08:57 +00:00
if ($node->body) {
$links[] = "<a href=\"node.php?id=". $node->nid ."\">". t("read more") ."</a>";
}
if ($node->comment) {
$links[] = "<a href=\"node.php?id=". $node->nid ."\">". format_plural(node_get_comments($node->nid), "comment", "comments") ."</a>";
}
}
return $links ? $links : array();
}
function node_links($nid, $type) {
2001-06-17 18:31:25 +00:00
global $op;
2001-06-18 18:00:13 +00:00
$link[] = ($op == "view") ? "view node" : "<A HREF=\"node.php?id=$nid\">view node</A>";
2001-06-17 18:31:25 +00:00
$link[] = ($op == "content") ? "edit content" : "<A HREF=\"admin.php?mod=node&type=$type&op=content&id=$nid\">edit content</A>";
$link[] = ($op == "option") ? "edit options" : "<A HREF=\"admin.php?mod=node&op=option&id=$nid\">edit options</A>";
$link[] = ($op == "status") ? "edit status" : "<A HREF=\"admin.php?mod=node&op=status&id=$nid\">edit status</A>";
$link[] = ($op == "attribute") ? "edit attribute" : "<A HREF=\"admin.php?mod=node&op=attribute&id=$nid\">edit attributes</A>";
2001-09-25 17:10:44 +00:00
$link[] = "<a href=\"admin.php?mod=node&op=". (variable_get("default_nodes_confirm_delete", 1) ? "confirm+" : "") ."delete&id=$nid\">delete node</a>";
2001-06-17 18:31:25 +00:00
return $link;
}
2001-06-04 16:03:10 +00:00
function node_overview($query) {
2001-05-02 20:52:19 +00:00
global $user;
2001-04-02 15:54:37 +00:00
2001-06-14 14:14:21 +00:00
$color = array("#ffffff", "#e5e5e5");
2001-06-04 16:03:10 +00:00
$query = node_query($query ? $query : 0);
2001-06-04 15:40:39 +00:00
2001-10-09 21:01:47 +00:00
$result = db_query("SELECT n.*, u.name, u.uid FROM node n LEFT JOIN users u ON n.author = u.uid $query[1] LIMIT 50");
2001-04-02 15:54:37 +00:00
2001-04-10 20:07:27 +00:00
$output .= status($query[0]);
2001-08-15 14:13:14 +00:00
$output .= "<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\">\n";
$output .= " <tr><th>title</th><th>type</th><th>status</th><th>meta attributes</th><th>author</th><th>date</th></tr>\n";
2001-06-04 15:40:39 +00:00
2001-04-02 15:54:37 +00:00
while ($node = db_fetch_object($result)) {
2001-06-04 16:03:10 +00:00
$bg = $color[$i++ % sizeof($color)];
2001-06-04 15:40:39 +00:00
2001-09-16 11:33:14 +00:00
$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->attributes) ."</td><td>". format_name($node) ."</td><td>". format_date($node->timestamp, "small") ."</td></tr>\n";
2001-08-15 14:13:14 +00:00
$output .= " <tr bgcolor=\"$bg\"><td align=\"right\" colspan=\"6\"><small>". implode(", ", node_links($node->nid, $node->type)) ."</small></td>\n";
2001-04-02 15:54:37 +00:00
}
2001-08-15 14:13:14 +00:00
$output .= "</table>\n";
2001-04-02 15:54:37 +00:00
return $output;
}
2001-06-04 15:40:39 +00:00
function node_edit_option($id) {
2001-05-20 16:47:50 +00:00
$node = node_get_object(array("nid" => $id));
2001-04-02 15:54:37 +00:00
2001-06-17 18:31:25 +00:00
$form .= form_item("Title", check_output($node->title));
2001-06-29 22:08:57 +00:00
$form .= form_item("Operations", implode("<br />", node_links($node->nid, $node->type)));
2001-06-17 18:31:25 +00:00
$form .= form_select("Comment", "comment", $node->comment, node_comment_status(), "Allow users to post comments to this node.");
$form .= form_select("Promote", "promote", $node->promote, node_promote_status(), "Promote this node on the main page.");
2001-06-04 15:40:39 +00:00
$form .= form_hidden("nid", $node->nid);
$form .= form_submit("Save node");
2001-04-02 15:54:37 +00:00
2001-09-28 16:20:55 +00:00
return form($form, "post", "admin.php?mod=node&id=$node->nid");
2001-04-02 15:54:37 +00:00
}
2001-06-04 15:40:39 +00:00
function node_edit_attribute($id) {
2001-04-02 15:54:37 +00:00
2001-05-20 16:47:50 +00:00
$node = node_get_object(array("nid" => $id));
2001-04-02 15:54:37 +00:00
2001-06-17 18:31:25 +00:00
$form .= form_item("Title", check_output($node->title));
2001-06-29 22:08:57 +00:00
$form .= form_item("Operations", implode("<br />", node_links($node->nid, $node->type)));
2001-06-17 18:31:25 +00:00
$form .= form_textfield("Attributes", "attributes", $node->attributes, 64, 128, "A comma-seperated list of attributes. Example: 'Software, Webserver, Apache'.");
2001-05-10 19:47:35 +00:00
$form .= form_hidden("nid", $node->nid);
$form .= form_submit("Save node");
2001-04-02 15:54:37 +00:00
2001-09-28 16:20:55 +00:00
return form($form, "post", "admin.php?mod=node&id=$node->nid");
2001-04-02 15:54:37 +00:00
}
2001-06-04 15:40:39 +00:00
function node_edit_status($id) {
$node = node_get_object(array("nid" => $id));
2001-06-17 18:31:25 +00:00
$form .= form_item("Title", check_output($node->title));
2001-06-29 22:08:57 +00:00
$form .= form_item("Operations", implode("<br />", node_links($node->nid, $node->type)));
2001-06-04 15:40:39 +00:00
$form .= form_select("Current status", "status", $node->status, node_status($node->type));
$form .= form_textfield("Automatically post document", "timestamp_posted", ($node->timestamp_posted ? format_date($node->timestamp_posted) : ""), 30, 55, "The date at which your document will be automatically posted. Leave empty if you don't want to schedule this document, or fill out a string containing an English date format. Example input: '". date("j F Y G:i") ."', '". date("m/d/y H:i") ."', '". date("F j, Y H:i") ."', ...");
$form .= form_textfield("Automatically queue document", "timestamp_queued", ($node->timestamp_queued ? format_date($node->timestamp_queued) : ""), 30, 55, "The date at which your document will be automatically queued. Leave empty if you don't want to schedule this document, or fill out a string containing an English date format. Example input: '". date("j F Y G:i") ."', '". date("m/d/y H:i") ."', '". date("F j, Y H:i") ."', ...");
$form .= form_textfield("Automatically hide document", "timestamp_hidden", ($node->timestamp_hidden ? format_date($node->timestamp_hidden) : ""), 30, 55, "The date at which your document will be automatically hidden. Leave empty if you don't want to schedule this document, or fill out a string containing an English date format. Example input: '". date("j F Y G:i") ."', '". date("m/d/y H:i") ."', '". date("F j, Y H:i") ."', ...");
$form .= form_hidden("nid", $node->nid);
$form .= form_submit("Save node");
2001-09-28 16:20:55 +00:00
return form($form);
2001-06-04 15:40:39 +00:00
}
2001-06-17 18:31:25 +00:00
function node_edit_content($edit, $type) {
$edit[type] = $type;
return node_invoke($edit, "form");
}
function node_save_content($edit, $type) {
$edit[type] = $type;
return node_invoke($edit, "save");
}
2001-04-02 15:54:37 +00:00
function node_delete($id) {
2001-09-25 17:10:44 +00:00
return (node_del(array("nid" => $id)) ? "node has been deleted." : "failed to delete node.");
}
2001-09-27 20:51:26 +00:00
2001-09-25 17:10:44 +00:00
function node_delete_confirmation($id) {
2001-09-27 20:51:26 +00:00
2001-09-25 17:10:44 +00:00
$node = node_get_object(array("nid" => $id));
$form .= form_item(t("Do you really want to delete this node"), check_output($node->title));
$form .= form_submit("Delete node");
$form .= form_submit("Keep node");
2001-09-27 20:51:26 +00:00
2001-09-28 16:20:55 +00:00
return form($form, "post", "admin.php?mod=node&id=$node->nid");
2001-09-25 17:10:44 +00:00
2001-04-02 15:54:37 +00:00
}
2001-06-05 18:32:04 +00:00
function node_query($type = -1) {
2001-08-11 14:54:39 +00:00
$queries[] = array("all nodes: recent additions", "ORDER BY timestamp DESC");
2001-08-27 08:20:57 +00:00
$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 timestamp_posted > 0 ORDER BY n.timestamp DESC");
$queries[] = array("all nodes: scheduled to be queued", "WHERE timestamp_queued > 0 ORDER BY n.timestamp DESC");
$queries[] = array("all nodes: scheduled to be hidden", "WHERE timestamp_hidden > 0 ORDER BY n.timestamp DESC");
2001-06-04 15:40:39 +00:00
foreach (module_list() as $name) {
2001-07-17 20:08:05 +00:00
if (module_hook($name, "status")) {
2001-08-11 14:54:39 +00:00
$queries[] = array("$name: recent additions", "WHERE type = '$name' ORDER BY timestamp DESC");
2001-07-17 20:08:05 +00:00
$statuses = module_invoke($name, "status");
if (is_array($statuses)) {
foreach (array_reverse($statuses) as $key=>$status) {
2001-08-30 08:34:28 +00:00
$queries[] = array("$name: status set to '$status'", "WHERE type = '$name' AND n.status = '". node_status($status) ."' ORDER BY timestamp DESC");
2001-07-17 20:08:05 +00:00
}
2001-08-11 14:54:39 +00:00
$queries[] = array("$name: scheduled to be posted", "WHERE type = '$name' AND timestamp_posted > 0 ORDER BY timestamp DESC");
$queries[] = array("$name: scheduled to be queued", "WHERE type = '$name' AND timestamp_queued > 0 ORDER BY timestamp DESC");
$queries[] = array("$name: scheduled to be hidden", "WHERE type = '$name' AND timestamp_hidden > 0 ORDER BY timestamp DESC");
2001-07-17 20:08:05 +00:00
}
2001-06-04 15:40:39 +00:00
}
}
2001-06-05 18:32:04 +00:00
return ($type < 0 ? $queries : $queries[$type]);
2001-04-10 20:07:27 +00:00
}
2001-04-11 19:44:24 +00:00
function node_listing($queries) {
global $mod;
foreach ($queries as $key=>$array) {
2001-06-04 16:03:10 +00:00
$output .= "<LI><A HREF=\"admin.php?mod=$mod&query=$key\">$array[0]</A></LI>\n";
2001-04-10 20:07:27 +00:00
}
return "<OL>$output</OL>\n";
}
2001-06-02 22:12:35 +00:00
function node_setting() {
$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);
foreach (module_list() as $name) {
if (module_hook($name, "user")) {
$form .= "<H3>Default settings for $name nodes</H3>";
2001-06-04 15:40:39 +00:00
$form .= form_select(t("Comment"), $name ."_comment", variable_get($name ."_comment", 0), node_comment_status(), "By default, allow or dissallow users to post comments in this category.");
$form .= form_select(t("Promote"), $name ."_promote", variable_get($name ."_promote", 0), node_promote_status(), "By default, promote new submissions in this category to the front page.");
$form .= form_select(t("Status"), $name ."_status", variable_get($name ."_status", node_status("queued")), node_status($name), "What to do with new submissions in this category?");
$form .= form_select(t("Post threshold"), $name ."_post", variable_get($name ."_post", 4), $threshold_post, "If new submissions are subject to moderation, select a post threshold.");
$form .= form_select(t("Dump threshold"), $name ."_dump", variable_get($name ."_dump", -2), $threshold_dump, "If new submissions are subject to moderation, select a dump threshold.");
$form .= form_select(t("Expiration threshold"), $name ."_expire", variable_get($name ."_expire", 8), $threshold_expire, "If new submissions are subject to moderation, select a expiration threshold.");
2001-06-02 22:12:35 +00:00
}
}
$form .= form_submit("Save settings");
$form .= form_submit("Reset to defaults");
2001-09-28 16:20:55 +00:00
return form($form);
2001-06-02 22:12:35 +00:00
}
2001-06-04 15:40:39 +00:00
function node_admin_save($edit) {
if (isset($edit[status])) {
$edit[timestamp_posted] = (strtotime($edit[timestamp_posted]) > time()) ? strtotime($edit[timestamp_posted]) : 0;
$edit[timestamp_queued] = (strtotime($edit[timestamp_queued]) > time()) ? strtotime($edit[timestamp_queued]) : 0;
$edit[timestamp_hidden] = (strtotime($edit[timestamp_hidden]) > time()) ? strtotime($edit[timestamp_hidden]) : 0;
node_save($edit, array(status, timestamp_posted, timestamp_queued, timestamp_hidden));
}
2001-06-11 20:01:13 +00:00
else if (isset($edit[attributes])) {
node_save($edit, array(attributes));
2001-06-04 15:40:39 +00:00
}
else {
2001-08-11 14:54:39 +00:00
node_save($edit, array(comment, promote));
2001-06-04 15:40:39 +00:00
}
}
2001-10-09 21:01:47 +00:00
function node_module_find() {
foreach (module_list() as $name) {
if (module_hook($name, "user")) {
$options .= "<OPTION VALUE=\"$name\">$name</OPTION>\n";
}
}
$output .= " <input size=\"50\" value=\"". check_form($keys) ."\" name=\"keys\" type=\"text\">\n";
$output .= " <select name=\"type\">$options</select>\n";
$output .= " <input type=\"submit\" value=\"Search\">\n";
return form($output);
}
2001-06-17 18:31:25 +00:00
function node_edit($node) {
$output .= form_item("Title", $node->title);
2001-06-29 22:08:57 +00:00
$output .= form_item("Operations", implode("<br />", node_links($node->nid, $node->type)));
2001-06-17 18:31:25 +00:00
return $output;
2001-06-04 15:40:39 +00:00
}
2001-04-02 15:54:37 +00:00
function node_admin() {
2001-06-29 22:08:57 +00:00
global $op, $id, $edit, $query, $type, $keys;
2001-04-10 20:07:27 +00:00
2001-06-29 22:08:57 +00:00
if (user_access("administer nodes")) {
2001-06-20 20:00:40 +00:00
foreach (module_list() as $name) {
if (module_hook($name, "status") && $name != "node") {
2001-08-15 14:13:14 +00:00
$link[] = "<a href=\"admin.php?mod=node&type=$name&op=add\">add $name</a>";
2001-06-20 20:00:40 +00:00
}
2001-06-04 15:40:39 +00:00
}
2001-08-15 14:13:14 +00:00
print "<small>". implode(" | ", $link) ." | <a href=\"admin.php?mod=node&op=default\">node settings</a> | <a href=\"admin.php?mod=node&op=listing\">node listings</a> | <a href=\"admin.php?mod=node&op=search\">search node</a> | <a href=\"admin.php?mod=node\">overview</a> | <a href=\"admin.php?mod=node&op=help\">help</a></small><hr />\n";
2001-06-20 20:00:40 +00:00
$id = check_input($edit[nid] ? $edit[nid] : $id);
switch ($op) {
case "add":
print module_invoke($type, "form");
break;
case "help":
print node_help();
break;
case "search":
2001-10-09 21:01:47 +00:00
print node_module_find($id);
print search_data($keys, $type);
2001-06-20 20:00:40 +00:00
break;
case "status":
print node_edit_status($id);
break;
case "option":
print node_edit_option($id);
break;
case "attribute":
print node_edit_attribute($id);
break;
case "content":
print node_edit_content(node_get_array(array("nid" => $id)), $type);
break;
case "default":
2001-09-26 18:28:10 +00:00
print node_setting();
2001-06-20 20:00:40 +00:00
break;
2001-09-25 17:10:44 +00:00
case "confirm delete":
print node_delete_confirmation($id);
break;
case "Delete node":
2001-06-20 20:00:40 +00:00
case "delete":
print status(node_delete($id));
print node_overview($query);
break;
case "listing":
print node_listing(node_query());
break;
case "Save settings":
2001-06-25 06:47:55 +00:00
print status(system_save($edit));
2001-06-20 20:00:40 +00:00
print node_setting();
break;
case "Reset to defaults":
2001-10-09 21:01:47 +00:00
print status(conf_default($edit));
2001-06-20 20:00:40 +00:00
print node_setting();
break;
case "Save node":
print node_admin_save($edit);
print node_overview($query);
break;
case "edit":
print node_edit(node_get_object(array("nid" => $id)));
break;
case "view":
print node_module_view(node_get_array(array("nid" => $id)), $type);
break;
2001-07-18 08:09:46 +00:00
case t("Preview"):
2001-06-20 20:00:40 +00:00
print node_edit_content($edit, $type);
break;
2001-07-18 08:09:46 +00:00
case t("Submit"):
2001-06-20 20:00:40 +00:00
print status(node_save_content($edit, $type));
// fall through:
default:
print node_overview($query);
}
}
else {
print message_access();
2001-04-02 15:54:37 +00:00
}
}
2001-07-15 16:56:44 +00:00
function node_block() {
global $theme;
$block[0][subject] = t("Syndicate");
2001-09-21 21:10:47 +00:00
$block[0][content] = "<div align=\"center\"><a href=\"module.php?mod=node&op=feed\"><img src=\"". $theme->image("xml.gif") ."\" width=\"36\" height=\"14\" border=\"0\" alt=\"XML\" /></a></div>\n";
2001-07-15 16:56:44 +00:00
$block[0][info] = "Syndicate";
return $block;
}
function node_feed() {
2001-08-16 20:43:17 +00:00
2001-07-15 16:56:44 +00:00
$result = db_query("SELECT nid, type FROM node WHERE promote = '1' AND status = '". node_status("posted") ."' ORDER BY timestamp DESC LIMIT 15");
while ($node = db_fetch_object($result)) {
$item = node_get_object(array("nid" => $node->nid, "type" => $node->type));
$title = $item->title;
$link = path_uri() ."node.php?id=$item->nid";
$description = module_invoke($item->type, "summary", $item);
$items .= format_rss_item($title, $link, $description);
}
$output .= "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n";
2001-10-09 21:01:47 +00:00
$output .= "<!DOCTYPE rss [<!ENTITY % HTMLlat1 PUBLIC \"-//W3C//ENTITIES Latin 1 for XHTML//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent\">\n";
2001-07-15 16:56:44 +00:00
$output .= "<rss version=\"0.91\">\n";
$output .= format_rss_channel(variable_get("site_name", "drupal"), path_uri() ."module.php?mod=node&op=feed", variable_get("site_slogan", ""), $items);
$output .= "</rss>\n";
2001-08-14 06:52:50 +00:00
header("Content-Type: text/xml");
2001-07-15 16:56:44 +00:00
print $output;
}
function node_page() {
2001-10-09 21:01:47 +00:00
global $op, $theme;
2001-07-15 16:56:44 +00:00
if ($op == "feed") {
node_feed();
}
2001-09-25 22:13:34 +00:00
else {
$theme->header();
if (user_access("access content")) {
$result = db_query("SELECT nid, type FROM node WHERE ". ($meta ? "attributes LIKE '%". check_input($meta) ."%' AND " : "") ." promote = '1' AND status = '". node_status("posted") ."' AND timestamp <= '". ($date > 0 ? check_input($date) : time()) ."' ORDER BY timestamp DESC LIMIT ". ($user->nodes ? $user->nodes : variable_get(default_nodes_main, 10)));
while ($node = db_fetch_object($result)) {
node_view(node_get_object(array("nid" => $node->nid, "type" => $node->type)), 1);
}
}
else {
$theme->box(t("Access denied"), message_access());
}
$theme->footer();
}
2001-07-15 16:56:44 +00:00
}
2001-04-02 15:54:37 +00:00
?>