Commit 48805032 authored by Kjartan's avatar Kjartan

- Applied modified version of almaw's 0064 patch: form item attributes.

- Applied modified version of mathias' 0073 patch: node form name.
  $params["options"] is now an array so some contrib modules might
  need minor changes.

- Applied mathhias' 0074 patch: missing access check on who is new
  block.
parent c6b215c0
......@@ -848,35 +848,35 @@ function form($form, $method = "post", $action = 0, $options = 0) {
if (!$action) {
$action = request_uri();
}
return "<form action=\"$action\" method=\"$method\"". ($options ? " $options" : "") .">\n$form\n</form>\n";
return "<form action=\"$action\" method=\"$method\"". drupal_attributes($options) .">\n$form\n</form>\n";
}
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_radio($title, $name, $value = 1, $checked = 0, $description = 0) {
return form_item(0, "<input type=\"radio\" class=\"form-radio\" name=\"edit[$name]\" value=\"". $value ."\"". ($checked ? " checked=\"checked\"" : "") ." /> $title", $description);
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);
}
function form_checkbox($title, $name, $value = 1, $checked = 0, $description = 0) {
return form_hidden($name, 0) . form_item(0, "<input type=\"checkbox\" class=\"form-checkbox\" name=\"edit[$name]\" value=\"". $value ."\"". ($checked ? " checked=\"checked\"" : "") ." /> $title", $description);
function form_checkbox($title, $name, $value = 1, $checked = 0, $description = 0, $attributes = 0) {
return form_hidden($name, 0) . form_item(0, "<input type=\"checkbox\" class=\"form-checkbox\" name=\"edit[$name]\" value=\"". $value ."\"". ($checked ? " checked=\"checked\"" : "") . drupal_attributes($attributes) ." /> $title", $description);
}
function form_textfield($title, $name, $value, $size, $maxlength, $description = 0) {
function form_textfield($title, $name, $value, $size, $maxlength, $description = 0, $attributes = 0) {
$size = $size ? " size=\"$size\"" : "";
return form_item($title, "<input type=\"text\" maxlength=\"$maxlength\" class=\"form-text\" name=\"edit[$name]\"$size value=\"". check_form($value) ."\" />", $description);
return form_item($title, "<input type=\"text\" maxlength=\"$maxlength\" class=\"form-text\" name=\"edit[$name]\"$size value=\"". check_form($value) ."\"". drupal_attributes($attributes) ." />", $description);
}
function form_password($title, $name, $value, $size, $maxlength, $description = 0) {
function form_password($title, $name, $value, $size, $maxlength, $description = 0, $attributes = 0) {
$size = $size ? " size=\"$size\"" : "";
return form_item($title, "<input type=\"password\" class=\"form-password\" maxlength=\"$maxlength\" name=\"edit[$name]\"$size value=\"". check_form($value) ."\" />", $description);
return form_item($title, "<input type=\"password\" class=\"form-password\" maxlength=\"$maxlength\" name=\"edit[$name]\"$size value=\"". check_form($value) ."\"". drupal_attributes($attributes) ." />", $description);
}
function form_textarea($title, $name, $value, $cols, $rows, $description = 0) {
function form_textarea($title, $name, $value, $cols, $rows, $description = 0, $attributes = 0) {
$cols = $cols ? " cols=\"$cols\"" : "";
module_invoke_all("textarea", $name); // eg. optionally plug in a WYSIWYG editor
return form_item($title, "<textarea wrap=\"virtual\"$cols rows=\"$rows\" name=\"edit[$name]\" id=\"edit[$name]\">". check_form($value) ."</textarea>", $description);
return form_item($title, "<textarea wrap=\"virtual\"$cols rows=\"$rows\" name=\"edit[$name]\" id=\"edit[$name]\"". drupal_attributes($attributes) .">". check_form($value) ."</textarea>", $description);
}
function form_select($title, $name, $value, $options, $description = 0, $extra = 0, $multiple = 0) {
......@@ -905,7 +905,7 @@ function form_hidden($name, $value) {
return "<input type=\"hidden\" name=\"edit[$name]\" value=\"". check_form($value) ."\" />\n";
}
function form_submit($value, $name = "op") {
function form_submit($value, $name = "op", $attributes = 0) {
return "<input type=\"submit\" class=\"form-submit\" name=\"$name\" value=\"". check_form($value) ."\" />\n";
}
......@@ -973,14 +973,18 @@ function url($url = NULL, $query = NULL) {
}
}
function l($text, $url, $attributes = array(), $query = NULL) {
$t = array();
foreach ($attributes as $key => $value) {
$t[] = "$key=\"$value\"";
function drupal_attributes($attributes = 0) {
if (is_array($attributes)) {
$t = array();
foreach ($attributes as $key => $value) {
$t[] = "$key=\"$value\"";
}
return " ". implode($t, " ");
}
}
return "<a href=\"". url($url, $query) ."\" ". implode($t, " ") .">$text</a>";
function l($text, $url, $attributes = array(), $query = NULL) {
return "<a href=\"". url($url, $query) ."\"". drupal_attributes($attributes) .">$text</a>";
}
function field_get($string, $name) {
......
......@@ -360,7 +360,6 @@ function node_save($node) {
function node_view($node, $main = 0) {
$node = array2object($node);
/*
......@@ -1259,7 +1258,7 @@ function node_form($edit, $error = NULL) {
$output .= "</div></div>";
return form($output, ($param["method"] ? $param["method"] : "post"), $param["action"], $param["options"]);
return form($output, ($param["method"] ? $param["method"] : "post"), $param["action"], array_merge($param["options"], array("id" => "node-form")));
}
function node_add($type) {
......
......@@ -360,7 +360,6 @@ function node_save($node) {
function node_view($node, $main = 0) {
$node = array2object($node);
/*
......@@ -1259,7 +1258,7 @@ function node_form($edit, $error = NULL) {
$output .= "</div></div>";
return form($output, ($param["method"] ? $param["method"] : "post"), $param["action"], $param["options"]);
return form($output, ($param["method"] ? $param["method"] : "post"), $param["action"], array_merge($param["options"], array("id" => "node-form")));
}
function node_add($type) {
......
......@@ -413,16 +413,18 @@ function user_block($op = "list", $delta = 0) {
}
break;
case 2:
$result = db_query_range("SELECT uid, name FROM {users} WHERE status != '0' ORDER BY uid DESC", 0, 5);
while ($account = db_fetch_object($result)) {
$items[] = l((strlen($account->name) > 15 ? substr($account->name, 0, 15) . '...' : $account->name), "user/view/$account->uid");
}
if (user_access("access content")) {
$result = db_query_range("SELECT uid, name FROM {users} WHERE status != '0' ORDER BY uid DESC", 0, 5);
while ($account = db_fetch_object($result)) {
$items[] = l((strlen($account->name) > 15 ? substr($account->name, 0, 15) . '...' : $account->name), "user/view/$account->uid");
}
$output = theme("theme_user_list", $items);
$output = theme("theme_user_list", $items);
$block["subject"] = t("Who's new");
$block["content"] = $output;
return $block;
$block["subject"] = t("Who's new");
$block["content"] = $output;
return $block;
}
}
}
}
......
......@@ -413,16 +413,18 @@ function user_block($op = "list", $delta = 0) {
}
break;
case 2:
$result = db_query_range("SELECT uid, name FROM {users} WHERE status != '0' ORDER BY uid DESC", 0, 5);
while ($account = db_fetch_object($result)) {
$items[] = l((strlen($account->name) > 15 ? substr($account->name, 0, 15) . '...' : $account->name), "user/view/$account->uid");
}
if (user_access("access content")) {
$result = db_query_range("SELECT uid, name FROM {users} WHERE status != '0' ORDER BY uid DESC", 0, 5);
while ($account = db_fetch_object($result)) {
$items[] = l((strlen($account->name) > 15 ? substr($account->name, 0, 15) . '...' : $account->name), "user/view/$account->uid");
}
$output = theme("theme_user_list", $items);
$output = theme("theme_user_list", $items);
$block["subject"] = t("Who's new");
$block["content"] = $output;
return $block;
$block["subject"] = t("Who's new");
$block["content"] = $output;
return $block;
}
}
}
}
......
......@@ -59,7 +59,7 @@ function header($title = "") {
function node($node, $main = 0) {
if (module_exist("taxonomy")) {
$terms = taxonomy_link("taxonomy terms", $node);
$terms = taxonomy_link("taxonomy terms", $node);
}
print "\n<!-- node: \"$node->title\" -->\n";
......
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