From ef7d5e1201df1aff7b536f798d0a53d616722be3 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 29 Apr 2001 12:39:55 +0000 Subject: CHANGES: - Added new form_* functions to common.inc, used for building forms: it should improve 'stability' (no form typos, every- thing properly escaped/unescaped) and should help providing a very consistent user interface (wrt forms). - Adjusted node.module to use the new form functions. (Can be used as an example.) - Adjusted book.module to use the new form functions. (Can be used as an example.) - Merged function.inc into common.inc! - Slowly removing all global $status and $rstatus variables: use node_status() instead. TODO: - Apart from implementing the permission system, I'll spend some time updating most modules today and tomorrow to use the new form functions. --- modules/node/node.module | 42 ++++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 24 deletions(-) (limited to 'modules/node/node.module') diff --git a/modules/node/node.module b/modules/node/node.module index 3c377a2a4..af5292fb4 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -24,40 +24,34 @@ function node_admin_view($id) { $node = node_get_object("nid", $id); $output .= "
nid\" METHOD=\"post\">\n"; - $output .= "Title:
". check_output($node->title) ."

\n"; - $output .= "Author:
". format_username($node->userid) ."

\n"; - $output .= "Status:
". $rstatus[$node->status] ."

\n"; - $output .= "Comment:
". node_comment_status($node->comment) ."

\n"; - $output .= "Promote:
". node_promote_status($node->promote) ."

\n"; - $output .= "Date:
". format_date($node->timestamp) ."

\n"; - $output .= "\n"; - $output .= "\n"; + $output .= form_item("Title", check_output($node->title)); + $output .= form_item("Author", format_username($node->userid)); + $output .= form_item("Status", $rstatus[$node->status]); + $output .= form_item("Comment", node_comment_status($node->comment)); + $output .= form_item("Promote", node_promote_status($node->promote)); + $output .= form_item("Date", format_date($node->timestamp)); + $output .= form_submit("Edit node"); + $output .= form_submit("Delete node"); $output .= "

\n"; return $output; } function node_admin_edit($id) { - global $user, $status; + global $user; $node = node_get_object("nid", $id); - foreach (array($node->userid => $node->author, $user->userid => $user->id) as $value=>$key) $author .= " \n"; - foreach (array(format_date($node->timestamp) ." (original)" => $node->timestamp, format_date(time()) ." (current)" => time()) as $value=>$key) $timestamp .= " \n"; - foreach (node_status($node) as $value) $display .= " \n"; - foreach (node_comment_status() as $key=>$value) $comment .= " \n"; - foreach (node_promote_status() as $key=>$value) $promote .= " \n"; - $output .= "
nid\" METHOD=\"post\">\n"; - $output .= "Title:
". check_output($node->title) ."

\n"; - $output .= "Author:

\n"; - $output .= "Status:

\n"; - $output .= "Comment:

\n"; - $output .= "Promote:

\n"; - $output .= "Date:

\n"; - $output .= "nid\">\n"; - $output .= "\n"; - $output .= "\n"; + $output .= form_item("Title", check_output($node->title)); + $output .= form_select("Author", "author", array($node->author => $node->userid, $user->id => $user->userid), $node->author); + $output .= form_select("Status", "status", node_status($node), $node->status); + $output .= form_select("Comment", "comment", node_comment_status(), $node->comment); + $output .= form_select("Promote", "promote", node_promote_status(), $node->promote); + $output .= form_select("Date", "timestamp", array($node->timestamp => format_date($node->timestamp) ." (original)", time() => format_date(time()) ." (current)"), $node->timestamp); + $output .= form_hidden("nid", $node->nid); + $output .= form_submit("View node"); + $output .= form_submit("Save node"); $output .= "

\n"; return $output; -- cgit v1.2.3