Commit 828ba665 authored by Dries's avatar Dries

- Bugfix: fixed utf-8 problem for people that use PHP 4.2.x or below.  Patch #33 by Al.

- Bugfix: fixed translation problems in the user module and the block module.  Patch by Stefan.

- Improvement: made it impossible to delete user role #1 and #2.  Patch #38 by Al.

- Improvement: fixed the "Allowed HTML tag" issues.  Makes for better code and improved usability.  Patch #35 by Al.

  NOTE: as soon the compose tips make their way into CVS, most of this code can be removed.
parent 0c5b3248
......@@ -203,7 +203,15 @@ function variable_del($name) {
}
function drupal_specialchars($input, $quotes = ENT_NOQUOTES) {
return htmlspecialchars($input, $quotes, "utf-8");
/*
** Note that we'd like to go 'htmlspecialchars($input, $quotes, "utf-8")'
** like the PHP manual tells us to, but we can't because there's a bug in
** PHP <4.3 that makes it mess up multibyte charsets if we specify the
** charset. Change this later once we make PHP 4.3 a requirement.
*/
return htmlspecialchars($input, $quotes);
}
function table_cell($cell, $header = 0) {
......@@ -877,6 +885,10 @@ function form_weight($title = NULL, $name = "weight", $value = 0, $delta = 10, $
return form_select($title, $name, $value, $weights, $description, $extra);
}
function form_allowed_tags_text() {
return variable_get("allowed_html", "") ? (t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", ""))) : "";
}
function url($url = NULL, $query = NULL) {
global $base_url;
......
......@@ -135,7 +135,7 @@ function block_admin_display() {
$blocks = _block_rehash();
$header = array(t("block"), t("enabled"), t("custom"), t("weight"), t("region"), t("path"), array("data" => "operations", "colspan" => 2));
$header = array(t("block"), t("enabled"), t("custom"), t("weight"), t("region"), t("path"), array("data" => t("operations"), "colspan" => 2));
foreach ($blocks as $block) {
if ($block["module"] == "block") {
......@@ -147,11 +147,11 @@ function block_admin_display() {
$delete = "";
}
$rows[] = array($block["info"], array("data" => form_checkbox(NULL, $block["module"]."][".$block["delta"]."][status", 1, $block["status"]), "align" => "center"), array("data" => form_checkbox(NULL, $block["module"]."][".$block["delta"]."][custom", 1, $block["custom"]), "align" => "center"), form_weight(NULL, $block["module"]."][".$block["delta"]."][weight", $block["weight"]), form_select(NULL, $block["module"]."][".$block["delta"]."][region", $block["region"], array("left", "right")), form_textfield(NULL, $block["module"]."][".$block["delta"]."][path", $block["path"], 10, 255), $edit, $delete);
$rows[] = array($block["info"], array("data" => form_checkbox(NULL, $block["module"]."][".$block["delta"]."][status", 1, $block["status"]), "align" => "center"), array("data" => form_checkbox(NULL, $block["module"]."][".$block["delta"]."][custom", 1, $block["custom"]), "align" => "center"), form_weight(NULL, $block["module"]."][".$block["delta"]."][weight", $block["weight"]), form_select(NULL, $block["module"]."][".$block["delta"]."][region", $block["region"], array(t("left"), t("right"))), form_textfield(NULL, $block["module"]."][".$block["delta"]."][path", $block["path"], 10, 255), $edit, $delete);
}
$output = table($header, $rows);
$output .= form_submit("Save blocks");
$output .= form_submit(t("Save blocks"));
print form($output);
}
......@@ -178,9 +178,9 @@ function block_admin_preview() {
$output .= "<h3>". t("Themes with both left and right sidebars") .":</h3>\n";
$output .= "<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\">\n";
$output .= " <tr><td colspan=\"3\" style=\"text-align: center;\">header</td></tr>\n";
$output .= " <tr><td colspan=\"3\" style=\"text-align: center;\">". t("header") ."</td></tr>\n";
$output .= " <tr><td>\n". ($lblocks ? $lblocks : "&nbsp;") ."</td><td style=\"width: 300px;\">&nbsp;</td><td>\n". ($rblocks ? $rblocks : "&nbsp;") ."</td></tr>\n";
$output .= " <tr><td colspan=\"3\" style=\"text-align: center;\">footer</td></tr>\n";
$output .= " <tr><td colspan=\"3\" style=\"text-align: center;\">". t("footer") ."</td></tr>\n";
$output .= "</table>\n";
$result = db_query("SELECT * FROM blocks WHERE status > 0 ORDER BY weight");
......@@ -194,16 +194,16 @@ function block_admin_preview() {
$output .= "<h3>". t("Themes with right-sidebar only") .":</h3>\n";
$output .= "<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\">\n";
$output .= " <tr><td colspan=\"2\" style=\"text-align: center;\">header</td></tr>\n";
$output .= " <tr><td colspan=\"2\" style=\"text-align: center;\">". t("header") ."</td></tr>\n";
$output .= " <tr><td style=\"width: 400px;\">&nbsp;</td><td>\n". ($blocks ? $blocks : "&nbsp;") ."</td></tr>\n";
$output .= " <tr><td colspan=\"2\" style=\"text-align: center;\">footer</td></tr>\n";
$output .= " <tr><td colspan=\"2\" style=\"text-align: center;\">". t("footer") ."</td></tr>\n";
$output .= "</table>\n";
$output .= "<h3>". t("Themes with left-sidebar only") .":</h3>\n";
$output .= "<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\">\n";
$output .= " <tr><td colspan=\"2\" style=\"text-align: center;\">header</td></tr>\n";
$output .= " <tr><td colspan=\"2\" style=\"text-align: center;\">". t("header") ."</td></tr>\n";
$output .= " <tr><td>\n". ($blocks ? $blocks : "&nbsp;") ."</td><td style=\"width: 400px;\">&nbsp;</td></tr>\n";
$output .= " <tr><td colspan=\"2\" style=\"text-align: center;\">footer</td></tr>\n";
$output .= " <tr><td colspan=\"2\" style=\"text-align: center;\">". t("footer") ."</td></tr>\n";
$output .= "</table>\n";
print $output;
......@@ -216,18 +216,18 @@ function block_box_get($bid) {
function block_box_form($edit = array()) {
$type = array(0 => "HTML", 1 => "PHP");
$form = form_textfield("Title", "title", $edit["title"], 50, 64);
$form .= form_textfield("Description", "info", $edit["info"], 50, 64);
$form .= form_textarea("Body", "body", $edit["body"], 70, 10);
$form = form_textfield(t("Title"), "title", $edit["title"], 50, 64);
$form .= form_textfield(t("Description"), "info", $edit["info"], 50, 64);
$form .= form_textarea(t("Body"), "body", $edit["body"], 70, 10);
if (user_access("create php content")) {
$form .= form_select("Type", "type", $edit["type"], $type);
$form .= form_select(t("Type"), "type", $edit["type"], $type);
}
if ($edit["bid"]) {
$form .= form_hidden("bid", $edit["bid"]);
}
$form .= form_submit("Save block");
$form .= form_submit(t("Save block"));
print form($form);
}
......@@ -279,12 +279,12 @@ function block_admin() {
cache_clear_all();
block_admin_display();
break;
case "Save block":
case t("Save block"):
print status(block_box_save($edit));
cache_clear_all();
block_admin_display();
break;
case "Save blocks":
case t("Save blocks"):
print status(block_admin_save($edit));
cache_clear_all();
// fall through
......@@ -330,4 +330,4 @@ function block_user($type, &$edit, &$user) {
}
}
?>
?>
\ No newline at end of file
......@@ -135,7 +135,7 @@ function block_admin_display() {
$blocks = _block_rehash();
$header = array(t("block"), t("enabled"), t("custom"), t("weight"), t("region"), t("path"), array("data" => "operations", "colspan" => 2));
$header = array(t("block"), t("enabled"), t("custom"), t("weight"), t("region"), t("path"), array("data" => t("operations"), "colspan" => 2));
foreach ($blocks as $block) {
if ($block["module"] == "block") {
......@@ -147,11 +147,11 @@ function block_admin_display() {
$delete = "";
}
$rows[] = array($block["info"], array("data" => form_checkbox(NULL, $block["module"]."][".$block["delta"]."][status", 1, $block["status"]), "align" => "center"), array("data" => form_checkbox(NULL, $block["module"]."][".$block["delta"]."][custom", 1, $block["custom"]), "align" => "center"), form_weight(NULL, $block["module"]."][".$block["delta"]."][weight", $block["weight"]), form_select(NULL, $block["module"]."][".$block["delta"]."][region", $block["region"], array("left", "right")), form_textfield(NULL, $block["module"]."][".$block["delta"]."][path", $block["path"], 10, 255), $edit, $delete);
$rows[] = array($block["info"], array("data" => form_checkbox(NULL, $block["module"]."][".$block["delta"]."][status", 1, $block["status"]), "align" => "center"), array("data" => form_checkbox(NULL, $block["module"]."][".$block["delta"]."][custom", 1, $block["custom"]), "align" => "center"), form_weight(NULL, $block["module"]."][".$block["delta"]."][weight", $block["weight"]), form_select(NULL, $block["module"]."][".$block["delta"]."][region", $block["region"], array(t("left"), t("right"))), form_textfield(NULL, $block["module"]."][".$block["delta"]."][path", $block["path"], 10, 255), $edit, $delete);
}
$output = table($header, $rows);
$output .= form_submit("Save blocks");
$output .= form_submit(t("Save blocks"));
print form($output);
}
......@@ -178,9 +178,9 @@ function block_admin_preview() {
$output .= "<h3>". t("Themes with both left and right sidebars") .":</h3>\n";
$output .= "<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\">\n";
$output .= " <tr><td colspan=\"3\" style=\"text-align: center;\">header</td></tr>\n";
$output .= " <tr><td colspan=\"3\" style=\"text-align: center;\">". t("header") ."</td></tr>\n";
$output .= " <tr><td>\n". ($lblocks ? $lblocks : "&nbsp;") ."</td><td style=\"width: 300px;\">&nbsp;</td><td>\n". ($rblocks ? $rblocks : "&nbsp;") ."</td></tr>\n";
$output .= " <tr><td colspan=\"3\" style=\"text-align: center;\">footer</td></tr>\n";
$output .= " <tr><td colspan=\"3\" style=\"text-align: center;\">". t("footer") ."</td></tr>\n";
$output .= "</table>\n";
$result = db_query("SELECT * FROM blocks WHERE status > 0 ORDER BY weight");
......@@ -194,16 +194,16 @@ function block_admin_preview() {
$output .= "<h3>". t("Themes with right-sidebar only") .":</h3>\n";
$output .= "<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\">\n";
$output .= " <tr><td colspan=\"2\" style=\"text-align: center;\">header</td></tr>\n";
$output .= " <tr><td colspan=\"2\" style=\"text-align: center;\">". t("header") ."</td></tr>\n";
$output .= " <tr><td style=\"width: 400px;\">&nbsp;</td><td>\n". ($blocks ? $blocks : "&nbsp;") ."</td></tr>\n";
$output .= " <tr><td colspan=\"2\" style=\"text-align: center;\">footer</td></tr>\n";
$output .= " <tr><td colspan=\"2\" style=\"text-align: center;\">". t("footer") ."</td></tr>\n";
$output .= "</table>\n";
$output .= "<h3>". t("Themes with left-sidebar only") .":</h3>\n";
$output .= "<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\">\n";
$output .= " <tr><td colspan=\"2\" style=\"text-align: center;\">header</td></tr>\n";
$output .= " <tr><td colspan=\"2\" style=\"text-align: center;\">". t("header") ."</td></tr>\n";
$output .= " <tr><td>\n". ($blocks ? $blocks : "&nbsp;") ."</td><td style=\"width: 400px;\">&nbsp;</td></tr>\n";
$output .= " <tr><td colspan=\"2\" style=\"text-align: center;\">footer</td></tr>\n";
$output .= " <tr><td colspan=\"2\" style=\"text-align: center;\">". t("footer") ."</td></tr>\n";
$output .= "</table>\n";
print $output;
......@@ -216,18 +216,18 @@ function block_box_get($bid) {
function block_box_form($edit = array()) {
$type = array(0 => "HTML", 1 => "PHP");
$form = form_textfield("Title", "title", $edit["title"], 50, 64);
$form .= form_textfield("Description", "info", $edit["info"], 50, 64);
$form .= form_textarea("Body", "body", $edit["body"], 70, 10);
$form = form_textfield(t("Title"), "title", $edit["title"], 50, 64);
$form .= form_textfield(t("Description"), "info", $edit["info"], 50, 64);
$form .= form_textarea(t("Body"), "body", $edit["body"], 70, 10);
if (user_access("create php content")) {
$form .= form_select("Type", "type", $edit["type"], $type);
$form .= form_select(t("Type"), "type", $edit["type"], $type);
}
if ($edit["bid"]) {
$form .= form_hidden("bid", $edit["bid"]);
}
$form .= form_submit("Save block");
$form .= form_submit(t("Save block"));
print form($form);
}
......@@ -279,12 +279,12 @@ function block_admin() {
cache_clear_all();
block_admin_display();
break;
case "Save block":
case t("Save block"):
print status(block_box_save($edit));
cache_clear_all();
block_admin_display();
break;
case "Save blocks":
case t("Save blocks"):
print status(block_admin_save($edit));
cache_clear_all();
// fall through
......@@ -330,4 +330,4 @@ function block_user($type, &$edit, &$user) {
}
}
?>
?>
\ No newline at end of file
......@@ -173,7 +173,7 @@ function blog_form(&$node, &$help, &$error) {
if (function_exists("taxonomy_node_form")) {
$output .= implode("", taxonomy_node_form("blog", $node));
}
$output .= form_textarea(t("Body"), "body", $node->body, 60, 15, $error["body"] ? $error["body"] : t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "")));
$output .= form_textarea(t("Body"), "body", $node->body, 60, 15, $error["body"] ? $error["body"] : form_allowed_tags_text());
return $output;
}
......
......@@ -173,7 +173,7 @@ function blog_form(&$node, &$help, &$error) {
if (function_exists("taxonomy_node_form")) {
$output .= implode("", taxonomy_node_form("blog", $node));
}
$output .= form_textarea(t("Body"), "body", $node->body, 60, 15, $error["body"] ? $error["body"] : t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "")));
$output .= form_textarea(t("Body"), "body", $node->body, 60, 15, $error["body"] ? $error["body"] : form_allowed_tags_text());
return $output;
}
......
......@@ -169,7 +169,7 @@ function book_form(&$node, &$help, &$error) {
$output .= implode("", taxonomy_node_form("book", $node));
}
$output .= form_textarea(t("Body"), "body", $node->body, 60, 20, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "")));
$output .= form_textarea(t("Body"), "body", $node->body, 60, 20, form_allowed_tags_text());
$output .= form_textarea(t("Log message"), "log", $node->log, 60, 5, t("An explanation of the additions or updates being made to help the group understand your motivations."));
if (user_access("administer nodes")) {
......
......@@ -169,7 +169,7 @@ function book_form(&$node, &$help, &$error) {
$output .= implode("", taxonomy_node_form("book", $node));
}
$output .= form_textarea(t("Body"), "body", $node->body, 60, 20, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "")));
$output .= form_textarea(t("Body"), "body", $node->body, 60, 20, form_allowed_tags_text());
$output .= form_textarea(t("Log message"), "log", $node->log, 60, 5, t("An explanation of the additions or updates being made to help the group understand your motivations."));
if (user_access("administer nodes")) {
......
......@@ -112,7 +112,7 @@ function comment_user($type, $edit, &$user) {
break;
case "edit_form":
// when user tries to edit his own data
return form_textarea(t("Signature"), "signature", $edit["signature"], 70, 3, t("Your signature will be publicly displayed at the end of your comments.") ."<br />". t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "<a> <b> <dd> <dl> <dt> <i> <li> <ol> <u> <ul>")));
return form_textarea(t("Signature"), "signature", $edit["signature"], 70, 3, t("Your signature will be publicly displayed at the end of your comments.") ."<br />". form_allowed_tags_text());
case "edit_validate":
// validate user data editing
return array("signature" => $edit["signature"]);
......@@ -149,7 +149,7 @@ function comment_form($edit) {
$form .= form_textfield(t("Subject"), "subject", $edit["subject"], 50, 64);
// comment field:
$form .= form_textarea(t("Comment"), "comment", $edit["comment"] ? $edit["comment"] : $user->signature, 70, 10, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "<a> <b> <dd> <dl> <dt> <i> <li> <ol> <u> <ul>")));
$form .= form_textarea(t("Comment"), "comment", $edit["comment"] ? $edit["comment"] : $user->signature, 70, 10, form_allowed_tags_text());
// preview button:
$form .= form_hidden("cid", $edit["cid"]);
......
......@@ -112,7 +112,7 @@ function comment_user($type, $edit, &$user) {
break;
case "edit_form":
// when user tries to edit his own data
return form_textarea(t("Signature"), "signature", $edit["signature"], 70, 3, t("Your signature will be publicly displayed at the end of your comments.") ."<br />". t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "<a> <b> <dd> <dl> <dt> <i> <li> <ol> <u> <ul>")));
return form_textarea(t("Signature"), "signature", $edit["signature"], 70, 3, t("Your signature will be publicly displayed at the end of your comments.") ."<br />". form_allowed_tags_text());
case "edit_validate":
// validate user data editing
return array("signature" => $edit["signature"]);
......@@ -149,7 +149,7 @@ function comment_form($edit) {
$form .= form_textfield(t("Subject"), "subject", $edit["subject"], 50, 64);
// comment field:
$form .= form_textarea(t("Comment"), "comment", $edit["comment"] ? $edit["comment"] : $user->signature, 70, 10, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "<a> <b> <dd> <dl> <dt> <i> <li> <ol> <u> <ul>")));
$form .= form_textarea(t("Comment"), "comment", $edit["comment"] ? $edit["comment"] : $user->signature, 70, 10, form_allowed_tags_text());
// preview button:
$form .= form_hidden("cid", $edit["cid"]);
......
......@@ -76,8 +76,7 @@ function story_form(&$node, &$help, &$error) {
if (function_exists("taxonomy_node_form")) {
$output .= implode("", taxonomy_node_form("story", $node));
}
$output .= form_textarea(t("Body"), "body", $node->body, 60, 15, $error["body"] ? $error["body"] : t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "")));
$output .= form_textarea(t("Body"), "body", $node->body, 60, 15, $error["body"] ? $error["body"] : form_allowed_tags_text());
return $output;
}
......
......@@ -76,8 +76,7 @@ function story_form(&$node, &$help, &$error) {
if (function_exists("taxonomy_node_form")) {
$output .= implode("", taxonomy_node_form("story", $node));
}
$output .= form_textarea(t("Body"), "body", $node->body, 60, 15, $error["body"] ? $error["body"] : t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "")));
$output .= form_textarea(t("Body"), "body", $node->body, 60, 15, $error["body"] ? $error["body"] : form_allowed_tags_text());
return $output;
}
......
......@@ -318,7 +318,7 @@ function user_block($op = "list", $delta = 0) {
$edit = $_POST["edit"];
if ($op == "list") {
$blocks[0]["info"] = t("Log in");
$blocks[0]["info"] = t("User login");
$blocks[1]["info"] = t("User information");
$blocks[2]["info"] = t("Who's new");
......@@ -1444,7 +1444,12 @@ function user_admin_role($edit = array()) {
$header = array(t("name"), t("operations"));
while ($role = db_fetch_object($result)) {
$rows[] = array($role->name, array("data" => l(t("edit role"), "admin/user/role/$role->rid"), "align" => "center"));
if ($role->name != "anonymous user" && $role->name != "authenticated user") {
$rows[] = array($role->name, array("data" => l(t("edit role"), "admin/user/role/$role->rid"), "align" => "center"));
}
else {
$rows[] = array($role->name, array("data" => "<span class=\"disabled\">". t("locked") ."</span>", "align" => "center"));
}
}
$rows[] = array("<input type=\"text\" size=\"32\" maxlength=\"64\" name=\"edit[name]\" />", "<input type=\"submit\" name=\"op\" value=\"". t("Add role") ."\" />");
......
......@@ -318,7 +318,7 @@ function user_block($op = "list", $delta = 0) {
$edit = $_POST["edit"];
if ($op == "list") {
$blocks[0]["info"] = t("Log in");
$blocks[0]["info"] = t("User login");
$blocks[1]["info"] = t("User information");
$blocks[2]["info"] = t("Who's new");
......@@ -1444,7 +1444,12 @@ function user_admin_role($edit = array()) {
$header = array(t("name"), t("operations"));
while ($role = db_fetch_object($result)) {
$rows[] = array($role->name, array("data" => l(t("edit role"), "admin/user/role/$role->rid"), "align" => "center"));
if ($role->name != "anonymous user" && $role->name != "authenticated user") {
$rows[] = array($role->name, array("data" => l(t("edit role"), "admin/user/role/$role->rid"), "align" => "center"));
}
else {
$rows[] = array($role->name, array("data" => "<span class=\"disabled\">". t("locked") ."</span>", "align" => "center"));
}
}
$rows[] = array("<input type=\"text\" size=\"32\" maxlength=\"64\" name=\"edit[name]\" />", "<input type=\"submit\" name=\"op\" value=\"". t("Add role") ."\" />");
......
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