diff options
author | Dries Buytaert <dries@buytaert.net> | 2001-12-06 17:33:05 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2001-12-06 17:33:05 +0000 |
commit | 20b4b7166f851221eef4c845d396af2efd581822 (patch) | |
tree | d922952bac8cdacae68139b8ffa9008fe19b3174 /modules/page/page.module | |
parent | 2b01b838c802226ad8f097aa5b7f4512de73d8e7 (diff) | |
download | brdo-20b4b7166f851221eef4c845d396af2efd581822.tar.gz brdo-20b4b7166f851221eef4c845d396af2efd581822.tar.bz2 |
- book.module:
+ Added (1) support for "PHP pages" (dynamic pages), and (2) made
it possible to link other node types into the book's tree/outline.
It works just fine, yet the only (obvious) downside of (2) is
that the navigation tree/links gets "interrupted" when you view
non-book pages in the book.
[SQL update required, see update.php]
+ Tidied up the book table.
[SQL update required, see update.php]
- various updates:
+ Fine-tuned the new node system.
+ Updated the inline/code documentation.
+ Improved teaser handling of all node types.
+ Made several small usability improvements to the node admin
pages.
Diffstat (limited to 'modules/page/page.module')
-rw-r--r-- | modules/page/page.module | 65 |
1 files changed, 47 insertions, 18 deletions
diff --git a/modules/page/page.module b/modules/page/page.module index 70d00b49b..d715de045 100644 --- a/modules/page/page.module +++ b/modules/page/page.module @@ -1,8 +1,6 @@ <?php // $Id$ -$GLOBALS["format"] = array(0 => "HTML", 1 => "PHP", 2 => "text"); - 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."); @@ -17,6 +15,7 @@ function page_access($op, $node) { } function page_save($op, $node) { + if ($op == "approve") { return array("status" => 1); } @@ -48,6 +47,8 @@ function page_delete(&$node) { function page_load($node) { $page = db_fetch_object(db_query("SELECT format, link FROM page WHERE nid = '$node->nid'")); + + return $page; } @@ -62,31 +63,59 @@ function page_link($type) { 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_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 $format, $op; + global $op; - if ($op != t("Preview") && $format[$node->format] == "PHP") { - $node->body = addslashes($node->body); + 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, $format); + $output .= form_select("Type", "format", $node->format, array(0 => "HTML / text", 1 => "PHP")); return $output; } |