1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
<?php
// $Id$
function page_node($field) {
$info["name"] = t("static page");
$info["description"] = t("If you just want to add a static page with a link in the menu to your site, this would be the best choice. Unlike a story, a page by-passes the submission queue.");
return $info[$field];
}
function page_access($op, $node) {
if ($op == "view") {
return $node->status;
}
}
function page_save($op, $node) {
if ($op == "approve") {
return array("status" => 1);
}
if ($op == "create") {
return array("format", "link", "promote" => 0, "moderate" => 0, "status" => 1);
}
if ($op == "decline") {
return array("status" => 0);
}
if ($op == "update") {
return array("format", "link");
}
}
function page_insert($node) {
db_query("INSERT INTO page (nid, format, link) VALUES ('$node->nid', '$node->format', '$node->link')");
}
function page_update($node) {
db_query("UPDATE page SET format = '$node->format', link = '$node->link' WHERE nid = '$node->nid'");
}
function page_delete(&$node) {
db_query("DELETE FROM page WHERE nid = '$node->nid'");
}
function page_load($node) {
$page = db_fetch_object(db_query("SELECT format, link FROM page WHERE nid = '$node->nid'"));
return $page;
}
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[] = "<a href=\"node.php?id=$page->nid\">$page->link</a>";
}
}
return $links ? $links : array();
}
function page_body($node) {
global $theme, $op;
if ($node->format) {
/*
** Make sure only authorized users can preview PHP pages.
*/
if ($op == t("Preview") && !user_access("adminster nodes")) {
return;
}
ob_start();
eval($node->body);
$output = ob_get_contents();
ob_end_clean();
}
else {
$output = check_output($node->body, 1);
}
return $output;
}
function page_view($node, $main = 0) {
global $theme;
/*
** Extract the page body. If body is dynamic (using PHP code), the body
** will be generated.
*/
$theme->box($node->title, page_body($body));
}
function page_form(&$node, &$help, &$error) {
global $op;
if ($node->teaser && !$node->format) {
$output .= form_textarea(t("Teaser"), "teaser", $node->teaser, 60, 5, $error["teaser"]);
}
/*
** Q: s this still required?
**
** if ($op != t("Preview") && $node->format) {
** $node->body = addslashes($node->body);
** }
*/
$output .= form_textarea("Body", "body", $node->body, 60, 20);
$output .= form_textfield("Link", "link", $node->link, 60, 64);
$output .= form_select("Type", "format", $node->format, array(0 => "HTML / text", 1 => "PHP"));
return $output;
}
?>
|