summaryrefslogtreecommitdiff
path: root/modules/page/page.module
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2001-04-07 15:02:28 +0000
committerDries Buytaert <dries@buytaert.net>2001-04-07 15:02:28 +0000
commit38806b4a39a6bdfc9d4a09f86b7bbaf0173c298d (patch)
treea445eab5750bd259731134cd31412305b55b8acb /modules/page/page.module
parent8213f5b2627a6b63db9f84b572918bd7e3254dff (diff)
downloadbrdo-38806b4a39a6bdfc9d4a09f86b7bbaf0173c298d.tar.gz
brdo-38806b4a39a6bdfc9d4a09f86b7bbaf0173c298d.tar.bz2
- fixed bug in common.inc: throttle()
- streamlined method invocation in node.inc - added node_status() function to modules - added NEW (mostly static) page module - added NEW settings module
Diffstat (limited to 'modules/page/page.module')
-rw-r--r--modules/page/page.module83
1 files changed, 83 insertions, 0 deletions
diff --git a/modules/page/page.module b/modules/page/page.module
new file mode 100644
index 000000000..13b3d6d9f
--- /dev/null
+++ b/modules/page/page.module
@@ -0,0 +1,83 @@
+<?php
+
+$module = array("page" => "page_page",
+ "admin" => "page_admin");
+
+$format = array(0 => HTML, 1 => PHP, 2 => text);
+
+function page_view($node) {
+ global $format, $theme;
+
+ 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);
+ }
+
+ $theme->header();
+ $theme->box(check_output($node->title), $output);
+ $theme->footer();
+}
+
+function page_status() {
+ return array(dumped, posted);
+}
+
+function page_form($edit = array()) {
+ global $format;
+
+ $output .= "<FORM ACTION=\"admin.php?mod=page\" METHOD=\"post\">\n";
+
+ $output .= "<B>Name:</B><BR>\n";
+ $output .= "<INPUT NAME=\"edit[title]\" SIZE=\"55\" VALUE=\"". check_textfield($edit[title]) ."\"><P>\n";
+
+ $output .= "<B>Body:</B><BR>\n";
+ $output .= "<TEXTAREA NAME=\"edit[body]\" COLS=\"55\" ROWS=\"10\" WRAP=\"virtual\">". check_textarea($edit[body]) ."</TEXTAREA><P>\n";
+
+ $output .= "<B>Type:</B><BR>\n";
+ foreach ($format as $key=>$value) $options .= "<OPTION VALUE=\"$key\"". ($edit[format] == $key ? " SELECTED" : "") .">$value</OPTION>\n";
+ $output .= "<SELECT NAME=\"edit[format]\">$options</SELECT><P>\n";
+
+ $output .= "<INPUT TYPE=\"hidden\" NAME=\"edit[nid]\" VALUE=\"$edit[nid]\">\n";
+
+ $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Save page\">\n";
+ $output .= "</FORM>\n";
+
+ return $output;
+}
+
+function page_save($edit) {
+ global $status;
+ node_save(array_merge($edit, array(type => "page", status => $status[posted])));
+}
+
+function page_overview() {
+ return node_overview("type = 'page'");
+}
+
+function page_admin() {
+ global $id, $op, $edit;
+
+ print "<SMALL><A HREF=\"admin.php?mod=page&op=add\">add new page</A> | <A HREF=\"admin.php?mod=page\">overview</A> | <A HREF=\"admin.php?mod=page&op=help\">help</A></SMALL><HR>\n";
+
+ switch ($op) {
+ case "add":
+ print page_form();
+ break;
+ case "edit":
+ print page_form(node_get_array(nid, $id));
+ break;
+ case "Save page":
+ print status(page_save($edit));
+ // fall through:
+ default:
+ print page_overview();
+ }
+}
+
+?> \ No newline at end of file