Commit 66c5b707 authored by Dries's avatar Dries

- Wrapped some hardcoded colors in "theme_invoke()"s; we can still create

  a drupal_error() later on but I think we better get used to theme_invoke().

- Fixed translation bug.  Patch by Moshe.

- Fixed PHP warning.  Patch by ax.
parent 88d6ef3a
......@@ -2,7 +2,7 @@
--
-- Host: localhost Database: drupal_devel
---------------------------------------------------------
-- Server version 3.23.52-nt
-- Server version 3.23.52-nt
--
-- Table structure for table 'access'
......
......@@ -75,6 +75,21 @@ function footer() {
}
function theme_mark() {
/*
** Return a marker. Used to indicate new comments or required form
** fields.
*/
return "<span style=\"color: red;\">*</span>";
}
function theme_error($message) {
/*
** Return an error message.
*/
return "<div style=\"color: red;\">$message</div>";
}
function theme_list() {
static $list;
......@@ -125,12 +140,12 @@ function theme_blocks($region, &$theme) {
function theme_invoke() {
global $theme;
$args = func_get_args();
$function = array_shift($args);
if (method_exists($theme, $function)) {
return call_user_method_array($function, $theme, $args);
}
}
else {
return call_user_func_array($function, $args);
}
......
......@@ -228,7 +228,7 @@ function blog_form(&$node, &$help, &$error) {
*/
if (count(explode(" ", $node->body)) < variable_get("minimum_blog_size", 0)) {
$error["body"] = "<div style=\"color: red;\">". t("The body of your blog is too short.") ."</div>";
$error["body"] = theme_invoke("theme_error", t("The body of your blog is too short."));
}
}
else {
......
......@@ -228,7 +228,7 @@ function blog_form(&$node, &$help, &$error) {
*/
if (count(explode(" ", $node->body)) < variable_get("minimum_blog_size", 0)) {
$error["body"] = "<div style=\"color: red;\">". t("The body of your blog is too short.") ."</div>";
$error["body"] = theme_invoke("theme_error", t("The body of your blog is too short."));
}
}
else {
......
......@@ -727,7 +727,7 @@ function node_validate($node, &$error) {
*/
if (isset($node->title) && !$node->title) {
$error["title"] = "<div style=\"color: red;\">". t("You have to specify a valid title.") ."</div>";
$error["title"] = theme_invoke("theme_error", t("You have to specify a valid title."));
}
if (user_access("administer nodes")) {
......@@ -760,7 +760,7 @@ function node_validate($node, &$error) {
$node->uid = $account->uid;
}
else {
$error["name"] = "<div style=\"color: red;\">". t("The name '%u' does not exist.", array ("%u" => $node->name)) ."</div>";
$error["name"] = theme_invoke("theme_error", t("The name '%u' does not exist.", array ("%u" => $node->name)));
}
/*
......@@ -771,7 +771,7 @@ function node_validate($node, &$error) {
$node->created = strtotime($node->date);
}
else {
$error["date"] = "<div style=\"color: red;\">". t("You have to specifiy a valid date.") ."</div>";
$error["date"] = theme_invoke("theme_error", t("You have to specifiy a valid date."));
}
}
......@@ -933,7 +933,7 @@ function node_add($type) {
if ($edit[$field]) {
$node[$field] = check_input($edit[$field]);
}
}
}
$output = node_form($node);
}
else {
......
......@@ -727,7 +727,7 @@ function node_validate($node, &$error) {
*/
if (isset($node->title) && !$node->title) {
$error["title"] = "<div style=\"color: red;\">". t("You have to specify a valid title.") ."</div>";
$error["title"] = theme_invoke("theme_error", t("You have to specify a valid title."));
}
if (user_access("administer nodes")) {
......@@ -760,7 +760,7 @@ function node_validate($node, &$error) {
$node->uid = $account->uid;
}
else {
$error["name"] = "<div style=\"color: red;\">". t("The name '%u' does not exist.", array ("%u" => $node->name)) ."</div>";
$error["name"] = theme_invoke("theme_error", t("The name '%u' does not exist.", array ("%u" => $node->name)));
}
/*
......@@ -771,7 +771,7 @@ function node_validate($node, &$error) {
$node->created = strtotime($node->date);
}
else {
$error["date"] = "<div style=\"color: red;\">". t("You have to specifiy a valid date.") ."</div>";
$error["date"] = theme_invoke("theme_error", t("You have to specifiy a valid date."));
}
}
......@@ -933,7 +933,7 @@ function node_add($type) {
if ($edit[$field]) {
$node[$field] = check_input($edit[$field]);
}
}
}
$output = node_form($node);
}
else {
......
......@@ -86,12 +86,12 @@ function poll_form(&$node, &$help, &$error) {
}
if ($node->chvotes[$i] < 0) {
$error["chvotes][$i"] = "<span style=\"color: red;\">". t("Negative values are not allowed.") ."</span>";
$error["chvotes][$i"] = theme_invoke("theme_error", t("Negative values are not allowed."));
}
}
if ($actualchoices < 2) {
$error["choice][0"] = "<span style=\"color: red;\">". t("You must fill in at least two choices.") ."</span>";
$error["choice][0"] = theme_invoke("theme_error", t("You must fill in at least two choices."));
}
}
else {
......@@ -125,7 +125,8 @@ function poll_form(&$node, &$help, &$error) {
}
function poll_help() {
?><p>Drupal's poll module allows users with at least content posting privileges to submit multiple-choice questions that others can vote on. Any user with sufficient privileges can vote. Please note that this is fully controlled by Drupal's access control features. For example, users might be required to login before voting (or even seeing the page where the voting occurs) or it could be open to the world.</p>
?>
<p>Drupal's poll module allows users with at least content posting privileges to submit multiple-choice questions that others can vote on. Any user with sufficient privileges can vote. Please note that this is fully controlled by Drupal's access control features. For example, users might be required to login before voting (or even seeing the page where the voting occurs) or it could be open to the world.</p>
<?php
}
......
......@@ -86,12 +86,12 @@ function poll_form(&$node, &$help, &$error) {
}
if ($node->chvotes[$i] < 0) {
$error["chvotes][$i"] = "<span style=\"color: red;\">". t("Negative values are not allowed.") ."</span>";
$error["chvotes][$i"] = theme_invoke("theme_error", t("Negative values are not allowed."));
}
}
if ($actualchoices < 2) {
$error["choice][0"] = "<span style=\"color: red;\">". t("You must fill in at least two choices.") ."</span>";
$error["choice][0"] = theme_invoke("theme_error", t("You must fill in at least two choices."));
}
}
else {
......@@ -125,7 +125,8 @@ function poll_form(&$node, &$help, &$error) {
}
function poll_help() {
?><p>Drupal's poll module allows users with at least content posting privileges to submit multiple-choice questions that others can vote on. Any user with sufficient privileges can vote. Please note that this is fully controlled by Drupal's access control features. For example, users might be required to login before voting (or even seeing the page where the voting occurs) or it could be open to the world.</p>
?>
<p>Drupal's poll module allows users with at least content posting privileges to submit multiple-choice questions that others can vote on. Any user with sufficient privileges can vote. Please note that this is fully controlled by Drupal's access control features. For example, users might be required to login before voting (or even seeing the page where the voting occurs) or it could be open to the world.</p>
<?php
}
......
......@@ -54,9 +54,9 @@ function profile_conf_options() {
$output .= form_select(t("Publicly accessible fields"), "profile_public_fields", variable_get("profile_public_fields", array()), $fields, t("The fields users will be able to set and that will be publicly visible."), "size=\"6\"", 1);
$output .= form_select(t("Private fields"), "profile_private_fields", variable_get("profile_private_fields", array()), $fields, t("The fields users will be able to set, but which are kept private."), "size=\"6\"", 1);
$output .= form_textfield(t("Avatar image path"), "profile_avatar_path", variable_get("profile_avatar_path", "misc/avatars/"), 30, 255, t("Path for avatar directory; it must be writeable and visible from the web."));
$output .= form_textfield(t("Avatar max size"), "profile_avatar_size", variable_get("profile_avatar_size", "85x85"), 10, 10, t("Maximum size for avatars."));
$output .= form_textfield(t("Avatar max filesize"), "profile_avatar_filesize", variable_get("profile_avatar_filesize", "30"), 10, 10, t("Maximum filesize for avatars, in kb."));
$output .= form_textfield(t("Avatar image path"), "profile_avatar_path", variable_get("profile_avatar_path", "misc/avatars/"), 30, 255, t("Path for avatar directory; it must be writeable and visible from the web."));
$output .= form_textfield(t("Avatar max size"), "profile_avatar_size", variable_get("profile_avatar_size", "85x85"), 10, 10, t("Maximum size for avatars."));
$output .= form_textfield(t("Avatar max filesize"), "profile_avatar_filesize", variable_get("profile_avatar_filesize", "30"), 10, 10, t("Maximum filesize for avatars, in kb."));
return $output;
}
......@@ -86,12 +86,12 @@ function profile_user($type, $edit, &$user) {
case "view_private":
// when user looks at his own data
return _profile_user_view($user, "private");
}
}
}
function profile_required($title) {
// this pleads "theme_invoke, theme_invoke" ;)
return $title ." <span style=\"color: red;\">*</span>";
return $title ." ". theme_invoke("theme_mark");
}
function _profile_form($edit, $mode) {
......
......@@ -54,9 +54,9 @@ function profile_conf_options() {
$output .= form_select(t("Publicly accessible fields"), "profile_public_fields", variable_get("profile_public_fields", array()), $fields, t("The fields users will be able to set and that will be publicly visible."), "size=\"6\"", 1);
$output .= form_select(t("Private fields"), "profile_private_fields", variable_get("profile_private_fields", array()), $fields, t("The fields users will be able to set, but which are kept private."), "size=\"6\"", 1);
$output .= form_textfield(t("Avatar image path"), "profile_avatar_path", variable_get("profile_avatar_path", "misc/avatars/"), 30, 255, t("Path for avatar directory; it must be writeable and visible from the web."));
$output .= form_textfield(t("Avatar max size"), "profile_avatar_size", variable_get("profile_avatar_size", "85x85"), 10, 10, t("Maximum size for avatars."));
$output .= form_textfield(t("Avatar max filesize"), "profile_avatar_filesize", variable_get("profile_avatar_filesize", "30"), 10, 10, t("Maximum filesize for avatars, in kb."));
$output .= form_textfield(t("Avatar image path"), "profile_avatar_path", variable_get("profile_avatar_path", "misc/avatars/"), 30, 255, t("Path for avatar directory; it must be writeable and visible from the web."));
$output .= form_textfield(t("Avatar max size"), "profile_avatar_size", variable_get("profile_avatar_size", "85x85"), 10, 10, t("Maximum size for avatars."));
$output .= form_textfield(t("Avatar max filesize"), "profile_avatar_filesize", variable_get("profile_avatar_filesize", "30"), 10, 10, t("Maximum filesize for avatars, in kb."));
return $output;
}
......@@ -86,12 +86,12 @@ function profile_user($type, $edit, &$user) {
case "view_private":
// when user looks at his own data
return _profile_user_view($user, "private");
}
}
}
function profile_required($title) {
// this pleads "theme_invoke, theme_invoke" ;)
return $title ." <span style=\"color: red;\">*</span>";
return $title ." ". theme_invoke("theme_mark");
}
function _profile_form($edit, $mode) {
......
......@@ -48,7 +48,7 @@ function tracker_comments($id = 0) {
$output .= "<ul>";
while ($comment = db_fetch_object($cresult)) {
$output .= " <li>". l(check_output($comment->subject), array("id" => $node->nid, "cid" => $comment->cid, "pid" => $comment->pid), "node", $comment->cid) ." ". t("by") ." ". format_name($comment) ." (". t("replies") .": ". comment_num_replies($comment->cid) .") ". (comment_is_new($comment) ? "<span style=\"color: red;\">*</span>" : "") ."</li>\n";
$output .= " <li>". l(check_output($comment->subject), array("id" => $node->nid, "cid" => $comment->cid, "pid" => $comment->pid), "node", $comment->cid) ." ". t("by") ." ". format_name($comment) ." (". t("replies") .": ". comment_num_replies($comment->cid) .") ". (comment_is_new($comment) ? theme_invoke("theme_mark") : "") ."</li>\n";
}
$output .= " </ul>\n";
}
......
......@@ -48,7 +48,7 @@ function tracker_comments($id = 0) {
$output .= "<ul>";
while ($comment = db_fetch_object($cresult)) {
$output .= " <li>". l(check_output($comment->subject), array("id" => $node->nid, "cid" => $comment->cid, "pid" => $comment->pid), "node", $comment->cid) ." ". t("by") ." ". format_name($comment) ." (". t("replies") .": ". comment_num_replies($comment->cid) .") ". (comment_is_new($comment) ? "<span style=\"color: red;\">*</span>" : "") ."</li>\n";
$output .= " <li>". l(check_output($comment->subject), array("id" => $node->nid, "cid" => $comment->cid, "pid" => $comment->pid), "node", $comment->cid) ." ". t("by") ." ". format_name($comment) ." (". t("replies") .": ". comment_num_replies($comment->cid) .") ". (comment_is_new($comment) ? theme_invoke("theme_mark") : "") ."</li>\n";
}
$output .= " </ul>\n";
}
......
......@@ -77,7 +77,7 @@ function user_load($array = array()) {
$result = db_query("SELECT u.*, r.name AS role FROM users u LEFT JOIN role r ON u.rid = r.rid WHERE $query u.status < 3 LIMIT 1");
$user = db_fetch_object($result);
if ($data = unserialize($user->data)) {
if ($user->data && $data = unserialize($user->data)) {
foreach ($data as $key => $value) {
if (!isset($user->$key)) {
$user->$key = $value;
......@@ -188,7 +188,7 @@ function user_validate_mail($mail) {
*/
if ($mail && !eregi("^[0-9a-z_\.-]+@(([0-9]{1,3}\.){3}[0-9]{1,3}|([0-9a-z][0-9a-z-]*[0-9a-z]\.)+[a-z]{2,})$", $mail)) {
return t("The e-mail address '$mail' is not valid.");
return t("The e-mail address '%mail' is not valid.", array("%mail" => $mail));
}
}
......@@ -579,7 +579,7 @@ function user_login($edit = array(), $msg = "") {
*/
if ($error) {
$output .= "<p><span style=\"color: red;\" class=\"error\">". check_output($error) ."</span></p>";
$output .= theme_invoke("theme_error", check_output($error));
}
/*
......@@ -678,7 +678,7 @@ function user_pass($edit = array()) {
// Display error message if necessary.
if ($error) {
$output .= "<p><span style=\"color: red;\" class=\"error\">". check_output($error) ."</span></p>";
$output .= theme_invoke("theme_error", check_output($error));
}
/*
......@@ -800,7 +800,7 @@ function user_register($edit = array()) {
}
else {
if ($error) {
$output .= "<p><span style=\"color: red;\" class=\"error\">". check_output($error) ."</span></p>";
$output .= theme_invoke("theme_error", check_output($error));
}
}
......@@ -917,7 +917,7 @@ function user_edit($edit = array()) {
}
if ($error) {
$output .= "<p><span style=\"color: red;\" class=\"error\">". check_output($error) ."</span></p>";
$output .= theme_invoke("theme_error", check_output($error));
}
if (!$edit) {
......@@ -1141,7 +1141,7 @@ function user_admin_create($edit = array()) {
else {
if ($error) {
$output .= "<p><span style=\"color: red;\" class=\"error\">". check_output($error) ."</span></p>";
$output .= theme_invoke("theme_error", check_output($error));
}
$output .= form_textfield("Username", "name", $edit["name"], 30, 55);
......@@ -1396,7 +1396,7 @@ function user_admin_edit($edit = array()) {
$output .= status(t("your user information changes have been saved."));
}
else {
$output .= "<p><span style=\"color: red;\" class=\"error\">". check_output($error) ."</span></p>";
$output .= theme_invoke("theme_error", check_output($error));
}
}
else if ($op == "Delete account") {
......
......@@ -77,7 +77,7 @@ function user_load($array = array()) {
$result = db_query("SELECT u.*, r.name AS role FROM users u LEFT JOIN role r ON u.rid = r.rid WHERE $query u.status < 3 LIMIT 1");
$user = db_fetch_object($result);
if ($data = unserialize($user->data)) {
if ($user->data && $data = unserialize($user->data)) {
foreach ($data as $key => $value) {
if (!isset($user->$key)) {
$user->$key = $value;
......@@ -188,7 +188,7 @@ function user_validate_mail($mail) {
*/
if ($mail && !eregi("^[0-9a-z_\.-]+@(([0-9]{1,3}\.){3}[0-9]{1,3}|([0-9a-z][0-9a-z-]*[0-9a-z]\.)+[a-z]{2,})$", $mail)) {
return t("The e-mail address '$mail' is not valid.");
return t("The e-mail address '%mail' is not valid.", array("%mail" => $mail));
}
}
......@@ -579,7 +579,7 @@ function user_login($edit = array(), $msg = "") {
*/
if ($error) {
$output .= "<p><span style=\"color: red;\" class=\"error\">". check_output($error) ."</span></p>";
$output .= theme_invoke("theme_error", check_output($error));
}
/*
......@@ -678,7 +678,7 @@ function user_pass($edit = array()) {
// Display error message if necessary.
if ($error) {
$output .= "<p><span style=\"color: red;\" class=\"error\">". check_output($error) ."</span></p>";
$output .= theme_invoke("theme_error", check_output($error));
}
/*
......@@ -800,7 +800,7 @@ function user_register($edit = array()) {
}
else {
if ($error) {
$output .= "<p><span style=\"color: red;\" class=\"error\">". check_output($error) ."</span></p>";
$output .= theme_invoke("theme_error", check_output($error));
}
}
......@@ -917,7 +917,7 @@ function user_edit($edit = array()) {
}
if ($error) {
$output .= "<p><span style=\"color: red;\" class=\"error\">". check_output($error) ."</span></p>";
$output .= theme_invoke("theme_error", check_output($error));
}
if (!$edit) {
......@@ -1141,7 +1141,7 @@ function user_admin_create($edit = array()) {
else {
if ($error) {
$output .= "<p><span style=\"color: red;\" class=\"error\">". check_output($error) ."</span></p>";
$output .= theme_invoke("theme_error", check_output($error));
}
$output .= form_textfield("Username", "name", $edit["name"], 30, 55);
......@@ -1396,7 +1396,7 @@ function user_admin_edit($edit = array()) {
$output .= status(t("your user information changes have been saved."));
}
else {
$output .= "<p><span style=\"color: red;\" class=\"error\">". check_output($error) ."</span></p>";
$output .= theme_invoke("theme_error", check_output($error));
}
}
else if ($op == "Delete account") {
......
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