From c97e36fb0631f5bc6b85b0d25fb39a6a433cffee Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Tue, 31 Dec 2002 11:37:29 +0000 Subject: - Simplified the page module. Patch by Marco. --- modules/page.module | 58 ++++++++++++++++-------------------------------- modules/page/page.module | 58 ++++++++++++++++-------------------------------- 2 files changed, 38 insertions(+), 78 deletions(-) (limited to 'modules') diff --git a/modules/page.module b/modules/page.module index f4b43fc3b..35e2b1583 100644 --- a/modules/page.module +++ b/modules/page.module @@ -2,8 +2,9 @@ // $Id$ function page_help() { - $output .= "

The page module is used to create a static page. Unlike a story, a static page is a persistent web page on your site which usually shortcuts the typical lifecycle of user generated content (i.e. submit -> moderate -> post -> comment). A static page is usually linked from the main navigation bar, using whatever text the author wishes. To create a static page without this navigation link, simply skip the form field which requests link text. Administrators are the exclusive authors of static pages (i.e. requires the administer nodes in ". la("permission", array("mod" => "user", "op" => "permission")) .").

"; - $output .= "

Site pages, unlike many other forms of Drupal content, may be made of PHP code in addition to HTML and text. All Drupal objects and functions are available to the Site Page author.

"; + $output .= "

The page module is used to create a static page. Unlike a story, a static page is a persistent web page on your site which usually shortcuts the typical lifecycle of user generated content (i.e. submit -> moderate -> post -> comment). A static page is usually linked from the main navigation bar, using whatever text the author wishes. To create a static page without this navigation link, simply skip the form field which requests link text.

"; + $output .= "

Site pages, unlike many other forms of Drupal content, may be made of PHP code in addition to HTML and text. All Drupal objects and functions are available to a site administrator.

"; + return $output; } @@ -95,30 +96,17 @@ function page_link($type) { function page_body($node) { global $theme, $op; - - if ($node->format) { - /* - ** Make sure only authorized users can preview static (PHP) - ** pages. - */ - - if ($op == t("Preview")) { - if (user_access("administer nodes")) { - $node->body = stripslashes($node->body); // see also page_form() - } - else { - return; - } - } - + if ($node->format == 0) { + // HTML type + $output = check_output($node->body); + } + else { + // PHP type ob_start(); eval($node->body); $output = ob_get_contents(); ob_end_clean(); } - else { - $output = check_output($node->body, 1); - } return $output; } @@ -126,36 +114,28 @@ function page_body($node) { function page_view($node, $main = 0) { global $theme; + /* + ** Extract the page body. If body is dynamic (using PHP code), the body + ** will be generated. + */ + + $node->teaser = $node->body = page_body($node); + if ($main) { $theme->node($node, $main); } else { - /* - ** Extract the page body. If body is dynamic (using PHP code), the body - ** will be generated. - */ - - $output .= page_body($node); - /* ** Add the node specific links: */ $output .= "
". $theme->links(link_node($node, $main)) ."
"; - $theme->box($node->title, $output); + $theme->box($node->title, $node->body); } } function page_form(&$node, &$help, &$error) { - global $op; - - if ($node->format) { - if ($op != t("Preview")) { - $node->body = addslashes($node->body); - } - } - if (function_exists("taxonomy_node_form")) { $output .= implode("", taxonomy_node_form("page", $node)); } @@ -163,9 +143,9 @@ function page_form(&$node, &$help, &$error) { $output .= form_textarea(t("Body"), "body", $node->body, 60, 20); $output .= form_textfield(t("Link name"), "link", $node->link, 60, 64, t("To make the page show up in the navigation links, enter the name of the link, otherwise leave blank.")); $output .= form_textfield(t("Link description"), "description", $node->description, 60, 64, t("The description displayed when hovering over the page's link. Leave blank when you don't want a description.")); - $output .= form_select(t("Type"), "format", $node->format, array(0 => "HTML / text", 1 => "PHP")); + $output .= form_select(t("Type"), "format", $node->format, array(0 => "HTML", 1 => "PHP")); return $output; } -?> \ No newline at end of file +?> diff --git a/modules/page/page.module b/modules/page/page.module index f4b43fc3b..35e2b1583 100644 --- a/modules/page/page.module +++ b/modules/page/page.module @@ -2,8 +2,9 @@ // $Id$ function page_help() { - $output .= "

The page module is used to create a static page. Unlike a story, a static page is a persistent web page on your site which usually shortcuts the typical lifecycle of user generated content (i.e. submit -> moderate -> post -> comment). A static page is usually linked from the main navigation bar, using whatever text the author wishes. To create a static page without this navigation link, simply skip the form field which requests link text. Administrators are the exclusive authors of static pages (i.e. requires the administer nodes in ". la("permission", array("mod" => "user", "op" => "permission")) .").

"; - $output .= "

Site pages, unlike many other forms of Drupal content, may be made of PHP code in addition to HTML and text. All Drupal objects and functions are available to the Site Page author.

"; + $output .= "

The page module is used to create a static page. Unlike a story, a static page is a persistent web page on your site which usually shortcuts the typical lifecycle of user generated content (i.e. submit -> moderate -> post -> comment). A static page is usually linked from the main navigation bar, using whatever text the author wishes. To create a static page without this navigation link, simply skip the form field which requests link text.

"; + $output .= "

Site pages, unlike many other forms of Drupal content, may be made of PHP code in addition to HTML and text. All Drupal objects and functions are available to a site administrator.

"; + return $output; } @@ -95,30 +96,17 @@ function page_link($type) { function page_body($node) { global $theme, $op; - - if ($node->format) { - /* - ** Make sure only authorized users can preview static (PHP) - ** pages. - */ - - if ($op == t("Preview")) { - if (user_access("administer nodes")) { - $node->body = stripslashes($node->body); // see also page_form() - } - else { - return; - } - } - + if ($node->format == 0) { + // HTML type + $output = check_output($node->body); + } + else { + // PHP type ob_start(); eval($node->body); $output = ob_get_contents(); ob_end_clean(); } - else { - $output = check_output($node->body, 1); - } return $output; } @@ -126,36 +114,28 @@ function page_body($node) { function page_view($node, $main = 0) { global $theme; + /* + ** Extract the page body. If body is dynamic (using PHP code), the body + ** will be generated. + */ + + $node->teaser = $node->body = page_body($node); + if ($main) { $theme->node($node, $main); } else { - /* - ** Extract the page body. If body is dynamic (using PHP code), the body - ** will be generated. - */ - - $output .= page_body($node); - /* ** Add the node specific links: */ $output .= "
". $theme->links(link_node($node, $main)) ."
"; - $theme->box($node->title, $output); + $theme->box($node->title, $node->body); } } function page_form(&$node, &$help, &$error) { - global $op; - - if ($node->format) { - if ($op != t("Preview")) { - $node->body = addslashes($node->body); - } - } - if (function_exists("taxonomy_node_form")) { $output .= implode("", taxonomy_node_form("page", $node)); } @@ -163,9 +143,9 @@ function page_form(&$node, &$help, &$error) { $output .= form_textarea(t("Body"), "body", $node->body, 60, 20); $output .= form_textfield(t("Link name"), "link", $node->link, 60, 64, t("To make the page show up in the navigation links, enter the name of the link, otherwise leave blank.")); $output .= form_textfield(t("Link description"), "description", $node->description, 60, 64, t("The description displayed when hovering over the page's link. Leave blank when you don't want a description.")); - $output .= form_select(t("Type"), "format", $node->format, array(0 => "HTML / text", 1 => "PHP")); + $output .= form_select(t("Type"), "format", $node->format, array(0 => "HTML", 1 => "PHP")); return $output; } -?> \ No newline at end of file +?> -- cgit v1.2.3