Commit 86e315e2 authored by Dries's avatar Dries
Browse files

- locale module: added documentation (first draft)
- locale module: improved administration interface
- headline module: fixed small visual glitch in export function
- account: small improvements
parent 9b3cd997
......@@ -20,11 +20,16 @@ function account_email() {
return $output;
}
function account_create($user = "", $error = "") {
function account_create($error = "") {
global $theme;
if ($error) $output .= "<P><FONT COLOR=\"red\">". t("Failed to create account: $error.") ."</FONT></P>\n";
else $output .= "<P>". t("Registering allows you to comment on stories, to moderate comments and pending stories, to customize the look and feel of the site and generally helps you interact with the site more efficiently.") ."</P><P>". t("To create an account, simply fill out this form an click the 'Create account' button below. An e-mail will then be sent to you with instructions on how to validate your account.") ."</P>\n";
if ($error) {
$output .= "<P><FONT COLOR=\"red\">". t("Failed to create account: $error.") ."</FONT></P>\n";
watchdog("message", "failed to create account: $error.");
}
else {
$output .= "<P>". t("Registering allows you to comment on stories, to moderate comments and pending stories, to customize the look and feel of the site and generally helps you interact with the site more efficiently.") ."</P><P>". t("To create an account, simply fill out this form an click the 'Create account' button below. An e-mail will then be sent to you with instructions on how to validate your account.") ."</P>\n";
}
$output .= "<FORM ACTION=\"account.php\" METHOD=\"post\">\n";
$output .= "<B>". t("Username") .":</B><BR>\n";
......@@ -289,7 +294,7 @@ function account_validate($user) {
// Verify whether username and e-mail address are unique:
if (db_num_rows(db_query("SELECT userid FROM users WHERE LOWER(userid) = LOWER('$user[userid]')")) > 0) $error = t("the specified username is already taken");
if (db_num_rows(db_query("SELECT real_email FROM users WHERE LOWER(real_email)=LOWER('$user[real_email]')")) > 0) $error = t("the specified e-mail address is already used for another account");
if (db_num_rows(db_query("SELECT real_email FROM users WHERE LOWER(real_email)=LOWER('$user[real_email]')")) > 0) $error = t("the specified e-mail address is already in use by another account");
return $error;
}
......@@ -336,7 +341,7 @@ function account_create_submit($userid, $email) {
if ($error = account_validate($new)) {
$theme->header();
$theme->box(t("Create user account"), account_create($new, $error));
$theme->box(t("Create user account"), account_create($error));
$theme->footer();
}
else {
......
......@@ -2,6 +2,10 @@
$na = "<I>na</I>";
function check_export($message) {
return strip_tags(str_replace("\"", "&quot;", stripslashes($message)));
}
function check_textfield($message) {
return strip_tags(str_replace("\"", "&quot;", stripslashes($message)));
}
......@@ -22,11 +26,8 @@ function check_code($message) {
function check_output($message, $nl2br = 0) {
global $allowed_html, $na;
if ($message) {
if ($nl2br == 1) return nl2br(strip_tags(stripslashes($message), $allowed_html));
else return strip_tags(stripslashes($message), $allowed_html);
}
else return $na;
$var = strip_tags(stripslashes($message), $allowed_html);
return ($var) ? (($nl2br) ? nl2br($var) : $var) : $na;
}
function format_plural($count, $singular, $plural) {
......
......@@ -143,7 +143,7 @@ function account_access($account) {
$data = explode(";", $account->access);
foreach ($data as $array) {
$access = explode(":", $array);
if ($access[0]) $output .= " $access[0]";
if ($access[0]) $output .= " <A HREF=\"admin.php?mod=$access[0]\">$access[0]</A>";
}
return $output;
}
......@@ -173,15 +173,9 @@ function account_comments($id) {
}
function account_edit_save($name, $edit) {
foreach ($edit as $key=>$value) {
if ($key != "access") $query .= "$key = '". addslashes($value) ."', ";
}
db_query("UPDATE users SET $query access = '' WHERE userid = '$name'");
if ($edit["access"]) {
foreach ($edit["access"] as $key=>$value) user_set(user_load($name), "access", $value, 1);
}
foreach ($edit as $key=>$value) if ($key != "access") $query .= "$key = '". addslashes($value) ."', ";
db_query("UPDATE users SET $query last_access = '". time() ."' WHERE userid = '$name'");
foreach ($edit["access"] as $key=>$value) user_set(user_load($name), "access", $value, 1);
watchdog("message", "account: modified user '$name'");
}
......
......@@ -13,9 +13,9 @@ function drupal_render($id, $cid) {
$output .= " <P>We don't have a real demo site yet but drupal is used by (and created for) <A HREF=\"http://drop.org/\">http://drop.org/</A>. Create an account, play with it for a bit, read the <A HREF=\"module.php?mod=documentation\">documentation</A> and spend some time getting used to it.</P>\n";
$theme->box("Introduction", $output);
$output = "<LI><A HREF=\"drupal/drupal-1.00.tgz\">drupal 1.00</A> (2000/01/15 - latest version)</LI>\n";
$output .= "<LI><A HREF=\"drupal/drupal-1.00-rc2.tgz\">drupal 1.00-rc2</A> (2000/01/08)</LI>\n";
$output .= "<LI><A HREF=\"drupal/drupal-1.00-rc1.tgz\">drupal 1.00-rc1</A> (2000/01/01)</LI>\n";
$output = "<LI><A HREF=\"drupal/drupal-1.00.tgz\">drupal 1.00</A> (2001/01/15 - latest version)</LI>\n";
$output .= "<LI><A HREF=\"drupal/drupal-1.00-rc2.tgz\">drupal 1.00-rc2</A> (2001/01/08)</LI>\n";
$output .= "<LI><A HREF=\"drupal/drupal-1.00-rc1.tgz\">drupal 1.00-rc1</A> (2001/01/01)</LI>\n";
$theme->box("Download", $output);
unset($output);
......
......@@ -13,9 +13,9 @@ function drupal_render($id, $cid) {
$output .= " <P>We don't have a real demo site yet but drupal is used by (and created for) <A HREF=\"http://drop.org/\">http://drop.org/</A>. Create an account, play with it for a bit, read the <A HREF=\"module.php?mod=documentation\">documentation</A> and spend some time getting used to it.</P>\n";
$theme->box("Introduction", $output);
$output = "<LI><A HREF=\"drupal/drupal-1.00.tgz\">drupal 1.00</A> (2000/01/15 - latest version)</LI>\n";
$output .= "<LI><A HREF=\"drupal/drupal-1.00-rc2.tgz\">drupal 1.00-rc2</A> (2000/01/08)</LI>\n";
$output .= "<LI><A HREF=\"drupal/drupal-1.00-rc1.tgz\">drupal 1.00-rc1</A> (2000/01/01)</LI>\n";
$output = "<LI><A HREF=\"drupal/drupal-1.00.tgz\">drupal 1.00</A> (2001/01/15 - latest version)</LI>\n";
$output .= "<LI><A HREF=\"drupal/drupal-1.00-rc2.tgz\">drupal 1.00-rc2</A> (2001/01/08)</LI>\n";
$output .= "<LI><A HREF=\"drupal/drupal-1.00-rc1.tgz\">drupal 1.00-rc1</A> (2001/01/01)</LI>\n";
$theme->box("Download", $output);
unset($output);
......
......@@ -204,7 +204,7 @@ function headline_export($uri) {
while ($story = db_fetch_object($result)) {
print "<item>\n";
print " <title>$story->subject</title>\n";
print " <title>". check_export($story->subject) ."</title>\n";
print " <link>". $site_url ."story.php?id=$story->id</link>\n";
print "</item>\n";
}
......
......@@ -5,7 +5,27 @@
"locale" => "locale_locale");
function locale_help() {
print "under construction";
?>
<P>Normally programs are written and documented in English, and use English to interact with users. This is true for a great deal of websites. However, most people are less comfortable with English than with their own native language, and would prefer to use their mother tongue as much as possible. Many people love see their website showing a lot less of English, and far more of their own language.</P>
<P>Therefore drupal provides a framework to setup a multi-lingual website, or to overwrite the default texts in English. We explored the various alternatives to support internationalization and decided to design the framework in such a way that the impact of internationalization on drupal's sources is minimized, modular and that it doesn't require a HTML or PHP wizard to maintain translations. Maintaining translations had to be simple so it became as easy as filling out forms on the administration page. A side effect is that translation support adds significant overhead to the dynamic generation of your website. If you don't need translation support, consider to turn it off.</P>
<H3>Adding a new language</H3>
<P>Adding a new language requires you to edit your configuration file and to edit your SQL database. Assuming you want to support Dutch (ISO 639 code: "nl") and French (ISO 639 code: "fr"), you add the following line to your configuration file's <CODE>$languages</CODE>-variable:</P>
<PRE>
$languages = array("nl" => "Dutch / Nederlands", "fr" => "French / Francais");
</PRE>
<P>Note that the default language must come first and that if you want to overwrite the default text you can add an entry for English (ISO 639 code: "en"):</P>
<PRE>
$languages = array("en" => "English", "nl" => "Dutch / Nederlands", "fr" => "French / Francais");
</PRE>
<P>After having edited your configuration file, make sure your SQL table "locales" has the required database fields setup to host your new translations. You can add the required rows to your "locales" table from the MySQL prompt:</P>
<PRE>
mysql> ALTER TABLE locales ADD en TEXT DEFAULT '' NOT NULL;
mysql> ALTER TABLE locales ADD nl TEXT DEFAULT '' NOT NULL;
mysql> ALTER TABLE locales ADD fr TEXT DEFAULT '' NOT NULL;
</PRE>
<?
}
function locale_delete($id) {
......@@ -24,10 +44,10 @@ function locale_edit($id) {
if ($translation = db_fetch_object($result)) {
$output .= "<FORM ACTION=\"admin.php?mod=locale\" METHOD=\"post\">\n";
$output .= "<B>Original string:</B><BR>\n";
$output .= check_output($translation->string) ."<P>";
$output .= "<PRE>". wordwrap(check_output($translation->string)) ."</PRE><P>";
foreach ($languages as $code=>$language) {
$output .= "<B>$language:</B><BR>";
$output .= "<INPUT TYPE=\"text\" NAME=\"edit[$code]\" VALUE=\"". check_textfield($translation->$code) ."\"><P>";
$output .= (strlen($translation->string) > 30) ? "<TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"10\" NAME=\"edit[$code]\">". check_textarea($translation->$code) ."</TEXTAREA><P>" : "<INPUT TYPE=\"text\" NAME=\"edit[$code]\" SIZE=\"50\" VALUE=\"". check_textfield($translation->$code) ."\"><P>";
}
$output .= "<INPUT NAME=\"id\" TYPE=\"hidden\" VALUE=\"$id\">\n";
$output .= "<INPUT NAME=\"op\" TYPE=\"submit\" VALUE=\"Save translations\">\n";
......
......@@ -5,7 +5,27 @@
"locale" => "locale_locale");
function locale_help() {
print "under construction";
?>
<P>Normally programs are written and documented in English, and use English to interact with users. This is true for a great deal of websites. However, most people are less comfortable with English than with their own native language, and would prefer to use their mother tongue as much as possible. Many people love see their website showing a lot less of English, and far more of their own language.</P>
<P>Therefore drupal provides a framework to setup a multi-lingual website, or to overwrite the default texts in English. We explored the various alternatives to support internationalization and decided to design the framework in such a way that the impact of internationalization on drupal's sources is minimized, modular and that it doesn't require a HTML or PHP wizard to maintain translations. Maintaining translations had to be simple so it became as easy as filling out forms on the administration page. A side effect is that translation support adds significant overhead to the dynamic generation of your website. If you don't need translation support, consider to turn it off.</P>
<H3>Adding a new language</H3>
<P>Adding a new language requires you to edit your configuration file and to edit your SQL database. Assuming you want to support Dutch (ISO 639 code: "nl") and French (ISO 639 code: "fr"), you add the following line to your configuration file's <CODE>$languages</CODE>-variable:</P>
<PRE>
$languages = array("nl" => "Dutch / Nederlands", "fr" => "French / Francais");
</PRE>
<P>Note that the default language must come first and that if you want to overwrite the default text you can add an entry for English (ISO 639 code: "en"):</P>
<PRE>
$languages = array("en" => "English", "nl" => "Dutch / Nederlands", "fr" => "French / Francais");
</PRE>
<P>After having edited your configuration file, make sure your SQL table "locales" has the required database fields setup to host your new translations. You can add the required rows to your "locales" table from the MySQL prompt:</P>
<PRE>
mysql> ALTER TABLE locales ADD en TEXT DEFAULT '' NOT NULL;
mysql> ALTER TABLE locales ADD nl TEXT DEFAULT '' NOT NULL;
mysql> ALTER TABLE locales ADD fr TEXT DEFAULT '' NOT NULL;
</PRE>
<?
}
function locale_delete($id) {
......@@ -24,10 +44,10 @@ function locale_edit($id) {
if ($translation = db_fetch_object($result)) {
$output .= "<FORM ACTION=\"admin.php?mod=locale\" METHOD=\"post\">\n";
$output .= "<B>Original string:</B><BR>\n";
$output .= check_output($translation->string) ."<P>";
$output .= "<PRE>". wordwrap(check_output($translation->string)) ."</PRE><P>";
foreach ($languages as $code=>$language) {
$output .= "<B>$language:</B><BR>";
$output .= "<INPUT TYPE=\"text\" NAME=\"edit[$code]\" VALUE=\"". check_textfield($translation->$code) ."\"><P>";
$output .= (strlen($translation->string) > 30) ? "<TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"10\" NAME=\"edit[$code]\">". check_textarea($translation->$code) ."</TEXTAREA><P>" : "<INPUT TYPE=\"text\" NAME=\"edit[$code]\" SIZE=\"50\" VALUE=\"". check_textfield($translation->$code) ."\"><P>";
}
$output .= "<INPUT NAME=\"id\" TYPE=\"hidden\" VALUE=\"$id\">\n";
$output .= "<INPUT NAME=\"op\" TYPE=\"submit\" VALUE=\"Save translations\">\n";
......
# 18/02/2001: permissions / access / group
alter table users drop permissions;
alter table users add access varchar(255) DEFAULT '' NOT NULL;
# 14/02/2001: locale / internationalisation
alter table users add language varchar(2) DEFAULT '' NOT NULL;
# 12/02/2001: locale / internationalisation
create table locales (
# 19/02/2001: internationalization / translation
CREATE TABLE locales (
id int(11) DEFAULT '0' NOT NULL auto_increment,
english TEXT DEFAULT '' NOT NULL,
location varchar(128) DEFAULT '' NOT NULL,
string TEXT DEFAULT '' NOT NULL,
en TEXT DEFAULT '' NOT NULL,
PRIMARY KEY (id)
);
# 18/02/2001: permissions / access / group
alter table users drop permissions;
alter table users add access varchar(255) DEFAULT '' NOT NULL;
# 07/02/2001: value calculation
alter table users add rating decimal(8,4) DEFAULT '0' NOT NULL;
......
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