"HTML", 1 => "PHP", 2 => "text"); class Page { function Page($page) { $this = new Node($page); $this->body = $page[body]; $this->format = $page[format]; } } function page_link($type) { if ($type == "page") { $result = db_query("SELECT nid,link FROM page WHERE link != '' ORDER BY link"); while ($page = db_fetch_object($result)) { $links[] = "nid\">$page->link"; } } return $links ? $links : array(); } function page_view($node, $main = 0) { global $format, $theme; switch ($format[$node->format]) { case "PHP": print eval($node->body); break; case "text": $theme->box($node->title, nl2br(htmlentities($node->body))); break; default: $theme->box($node->title, check_output($node->body, 1)); } } function page_status() { return array(dumped, posted); } function page_form($edit = array()) { global $REQUEST_URI, $format, $op; if ($op != t("Preview") && $format[$edit[format]] == "PHP") { $edit[body] = addslashes($edit[body]); } if ($edit[title]) { print "\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]); if ($edit[title]) { $form .= form_submit(t("Preview")); $form .= form_submit(t("Submit")); } else { $form .= form_submit(t("Preview")); } return form($REQUEST_URI, $form); } function page_save($edit) { global $status, $user; 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)); } ?>