67 lines
1.6 KiB
Plaintext
67 lines
1.6 KiB
Plaintext
<?php
|
|
|
|
$GLOBALS[format] = array(0 => "HTML", 1 => "PHP", 2 => "text");
|
|
|
|
class Page {
|
|
function Page($page) {
|
|
$this = new Node($page);
|
|
$this->body = $page[body];
|
|
$this->format = $page[format];
|
|
}
|
|
}
|
|
|
|
function page_view($node, $main = 0) {
|
|
global $format;
|
|
|
|
switch ($format[$node->format]) {
|
|
case "PHP":
|
|
$output = eval($node->body);
|
|
break;
|
|
case "text":
|
|
$output = nl2br(htmlentities($node->body));
|
|
break;
|
|
default:
|
|
$output = check_output($node->body, 1);
|
|
}
|
|
|
|
print $output;
|
|
}
|
|
|
|
function page_status() {
|
|
return array(dumped, posted);
|
|
}
|
|
|
|
function page_form($edit = array()) {
|
|
global $REQUEST_URI, $format, $op;
|
|
|
|
if ($op != "Preview" && $format[$edit[format]] == "PHP") {
|
|
$edit[body] = addslashes($edit[body]);
|
|
}
|
|
|
|
if ($edit[title]) {
|
|
$form = page_view(new Page(node_preview($edit)));
|
|
}
|
|
|
|
$form .= form_textfield("Subject", "title", $edit[title], 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("Preview");
|
|
$form .= form_submit("Submit");
|
|
}
|
|
else {
|
|
$form .= form_submit("Preview");
|
|
}
|
|
|
|
return form($REQUEST_URI, $form);
|
|
}
|
|
|
|
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));
|
|
}
|
|
|
|
?> |