Commit 00d638ca authored by Dries's avatar Dries

- Usability improvement: replaced many selection boxes by radio buttons.
  Patch by Stefan.

- Usability improvement: introduced a form_group() function and updated
  the node and comment module to take advantage of it.  Patch #149 by
  Eric Farris.
parent 6735be09
......@@ -905,6 +905,9 @@ function form($form, $method = "post", $action = 0, $options = 0) {
function form_item($title, $value, $description = 0) {
return "<div class=\"form-item\">". ($title ? "<div class=\"title\">$title:</div>" : "") . $value . ($description ? "<div class=\"description\">$description</div>" : "") ."</div>\n";
}
function form_group($legend, $group, $description = 0) {
return "<fieldset>" . ($legend ? "<legend>$legend</legend>" : "") . $group . ($description ? "<div class=\"description\">$description</div>" : "") . "</fieldset>\n";
}
function form_radio($title, $name, $value = 1, $checked = 0, $description = 0, $attributes = 0) {
return form_item(0, "<input type=\"radio\" class=\"form-radio\" name=\"edit[$name]\" value=\"". $value ."\"". ($checked ? " checked=\"checked\"" : "") . drupal_attributes($attributes) ." /> $title", $description);
......
......@@ -1627,7 +1627,7 @@ function comment_nodeapi(&$node, $op, $arg = 0) {
$output = form_radio(t("Disabled"), "comment", 0, ($selected == 0));
$output .= form_radio(t("Read only"), "comment", 1, ($selected == 1));
$output .= form_radio(t("Read/write"), "comment", 2, ($selected == 2));
return form_item(t("Allow user comments"), $output);
return form_group(t("User comments"), $output);
}
break;
case "validate":
......
......@@ -1627,7 +1627,7 @@ function comment_nodeapi(&$node, $op, $arg = 0) {
$output = form_radio(t("Disabled"), "comment", 0, ($selected == 0));
$output .= form_radio(t("Read only"), "comment", 1, ($selected == 1));
$output .= form_radio(t("Read/write"), "comment", 2, ($selected == 2));
return form_item(t("Allow user comments"), $output);
return form_group(t("User comments"), $output);
}
break;
case "validate":
......
......@@ -1127,10 +1127,13 @@ function node_form($edit, $error = NULL) {
if (user_access("administer nodes")) {
$output .= "<div class=\"admin\">";
$author = form_textfield(t("Authored by"), "name", $edit->name, 20, 60, $error["name"]);
$author .= form_textfield(t("Authored on"), "date", $edit->date, 20, 25, $error["date"]);
$output .= "<div class=\"authored\">";
$output .= form_textfield(t("Authored by"), "name", $edit->name, 20, 60, $error["name"]);
$output .= form_textfield(t("Authored on"), "date", $edit->date, 20, 25, $error["date"]);
$output .= "</div>";
$output .= form_group(t("Authoring information"), $author);
$output .= "</div>\n";
$options .= form_checkbox(t("Published"), "status", 1, isset($edit->status) ? $edit->status : variable_get("node_status_$edit->type", 1));
$options .= form_checkbox(t("In moderation queue"), "moderate", 1, isset($edit->moderate) ? $edit->moderate : variable_get("node_moderate_$edit->type", 0));
......@@ -1139,8 +1142,8 @@ function node_form($edit, $error = NULL) {
$options .= form_checkbox(t("Create new revision"), "revision", 1, isset($edit->revision) ? $edit->revision : variable_get("node_revision_$edit->type", 0));
$output .= "<div class=\"options\">";
$output .= form_item(t("Options"), $options);
$output .= "</div>";
$output .= form_group("Options", $options);
$output .= "</div>\n";
$extras .= implode("</div><div class=\"extra\">", node_invoke_nodeapi($edit, "form admin"));
$output .= $extras ? "<div class=\"extra\">$extras</div></div>" : "</div>";
......
......@@ -1127,10 +1127,13 @@ function node_form($edit, $error = NULL) {
if (user_access("administer nodes")) {
$output .= "<div class=\"admin\">";
$author = form_textfield(t("Authored by"), "name", $edit->name, 20, 60, $error["name"]);
$author .= form_textfield(t("Authored on"), "date", $edit->date, 20, 25, $error["date"]);
$output .= "<div class=\"authored\">";
$output .= form_textfield(t("Authored by"), "name", $edit->name, 20, 60, $error["name"]);
$output .= form_textfield(t("Authored on"), "date", $edit->date, 20, 25, $error["date"]);
$output .= "</div>";
$output .= form_group(t("Authoring information"), $author);
$output .= "</div>\n";
$options .= form_checkbox(t("Published"), "status", 1, isset($edit->status) ? $edit->status : variable_get("node_status_$edit->type", 1));
$options .= form_checkbox(t("In moderation queue"), "moderate", 1, isset($edit->moderate) ? $edit->moderate : variable_get("node_moderate_$edit->type", 0));
......@@ -1139,8 +1142,8 @@ function node_form($edit, $error = NULL) {
$options .= form_checkbox(t("Create new revision"), "revision", 1, isset($edit->revision) ? $edit->revision : variable_get("node_revision_$edit->type", 0));
$output .= "<div class=\"options\">";
$output .= form_item(t("Options"), $options);
$output .= "</div>";
$output .= form_group("Options", $options);
$output .= "</div>\n";
$extras .= implode("</div><div class=\"extra\">", node_invoke_nodeapi($edit, "form admin"));
$output .= $extras ? "<div class=\"extra\">$extras</div></div>" : "</div>";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment