summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
Diffstat (limited to 'includes')
-rw-r--r--includes/comment.inc2
-rw-r--r--includes/function.inc26
-rw-r--r--includes/locale.inc2
-rw-r--r--includes/search.inc2
-rw-r--r--includes/theme.inc33
-rw-r--r--includes/timer.inc17
6 files changed, 51 insertions, 31 deletions
diff --git a/includes/comment.inc b/includes/comment.inc
index 4f9ee3ac5..dcd4557eb 100644
--- a/includes/comment.inc
+++ b/includes/comment.inc
@@ -205,7 +205,7 @@ function comment_moderation($comment) {
$output .= "</SELECT>\n";
}
else {
- $output .= "<TABLE BORDER=\"0\" CELLSPACING=\"1\" CELLPADDING=\"1\"><TR><TD>score:</TD><TD>". format_data($comment->score) ."</TD></TR><TR><TD>votes:</TD><TD>". format_data($comment->votes) ."</TR></TABLE>\n";
+ $output .= "<TABLE BORDER=\"0\" CELLSPACING=\"1\" CELLPADDING=\"1\"><TR><TD>score:</TD><TD>". check_output($comment->score) ."</TD></TR><TR><TD>votes:</TD><TD>". check_output($comment->votes) ."</TR></TABLE>\n";
}
return $output;
diff --git a/includes/function.inc b/includes/function.inc
index c8b027934..1305d4b96 100644
--- a/includes/function.inc
+++ b/includes/function.inc
@@ -1,5 +1,7 @@
<?
+$na = "<I>na</I>";
+
function check_textfield($message) {
global $allowed_html;
return strip_tags(str_replace("\"", "&quot;", stripslashes($message)), $allowed_html);
@@ -20,13 +22,16 @@ function check_code($message) {
}
function check_output($message, $nl2br = 0) {
- global $allowed_html;
- if ($nl2br == 1) return nl2br(strip_tags(stripslashes($message), $allowed_html));
- else return strip_tags(stripslashes($message), $allowed_html);
+ 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;
}
function format_plural($count, $singular, $plural) {
- return ($count == 1) ? "$count $singular" : "$count $plural";
+ return ($count == 1) ? "$count ". t($singular) : "$count ". t($plural);
}
function format_interval($timestamp) {
@@ -72,9 +77,6 @@ function format_date($timestamp, $type = "medium") {
return $date;
}
-function format_data($field, $replacement = "<I>na</I>") {
- return ($field) ? $field : $replacement;
-}
function format_username($username) {
global $user;
@@ -83,16 +85,14 @@ function format_username($username) {
}
function format_email($address) {
- return ($address) ? "<A HREF=\"mailto:$address\">$address</A>" : format_data($address);
+ global $na;
+ return ($address) ? "<A HREF=\"mailto:$address\">$address</A>" : $na;
}
function format_url($address, $description = "") {
- // POSSIBLE EXTENSIONS:
- // 1. add `http://' in case it's missing.
- // 2. add a trailing `/' in case it's missing.
- // 3. remove any parameters in the URI.
+ global $na;
$description = ($description) ? $description : $address;
- return ($address) ? "<A HREF=\"$address\">$description</A>" : format_data($address);
+ return ($address) ? "<A HREF=\"$address\">$description</A>" : $na;
}
?>
diff --git a/includes/locale.inc b/includes/locale.inc
index 6fd51a5a6..ab0a49eb5 100644
--- a/includes/locale.inc
+++ b/includes/locale.inc
@@ -1,6 +1,8 @@
<?
function t($string) {
+ $result = db_query("SELECT id FROM locales WHERE english = '". addslashes($string) ."'");
+ if (!db_fetch_object($result)) db_query("INSERT INTO locales (english) VALUES ('". addslashes($string) ."')");
return $string;
}
diff --git a/includes/search.inc b/includes/search.inc
index 2fd527a90..f80636665 100644
--- a/includes/search.inc
+++ b/includes/search.inc
@@ -21,7 +21,7 @@ function search_data($keys, $type) {
}
if (!$output) {
- $output .= "<P><SMALL>Your search yielded no results:</P><UL><LI>try using fewer words.</LI><LI>try using more general keywords.</LI><LI>try using different keywords.</LI></UL></SMALL>\n";
+ $output .= t("Your search yielded no results.");
}
return $output;
diff --git a/includes/theme.inc b/includes/theme.inc
index 35573ecb8..57b2f7d29 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -30,15 +30,13 @@ function theme_account($theme) {
module_iterate("menu");
// Display account settings:
- $content .= "<LI><A HREF=\"account.php?op=track&topic=comments\">track your comments</A></LI>\n";
- $content .= "<LI><A HREF=\"account.php?op=track&topic=stories\">track your stories</A></LI>\n";
- $content .= "<LI><A HREF=\"account.php?op=track&topic=site\">track $site_name</A></LI>\n";
+ $content .= "<LI><A HREF=\"account.php?op=track&topic=comments\">". t("track your comments") ."</A></LI>\n";
+ $content .= "<LI><A HREF=\"account.php?op=track&topic=stories\">". t("track your stories") ."</A></LI>\n";
+ $content .= "<LI><A HREF=\"account.php?op=track&topic=site\">". t("track") ." $site_name</A></LI>\n";
$content .= "<P>\n";
- $content .= "<LI><A HREF=\"submission.php\">submission queue</A> (<FONT COLOR=\"red\">". submission_number() ."</FONT>)</LI>\n";
- $content .= "<P>\n";
- $content .= "<LI><A HREF=\"account.php?op=edit&topic=user\">edit your information</A></LI>\n";
- $content .= "<LI><A HREF=\"account.php?op=edit&topic=site\">edit your preferences</A></LI>\n";
- $content .= "<LI><A HREF=\"account.php?op=edit&topic=content\">edit your content</A></LI>\n";
+ $content .= "<LI><A HREF=\"account.php?op=edit&topic=user\">". t("edit your information") ."</A></LI>\n";
+ $content .= "<LI><A HREF=\"account.php?op=edit&topic=site\">". t("edit your preferences") ."</A></LI>\n";
+ $content .= "<LI><A HREF=\"account.php?op=edit&topic=content\">". t("edit your content") ."</A></LI>\n";
$content .= "<P>\n";
if (user_permission($user)) {
@@ -46,26 +44,29 @@ function theme_account($theme) {
$content .= "<P>\n";
}
+ $content .= "<LI><A HREF=\"submission.php\">". t("submission queue") ."</A> (<FONT COLOR=\"red\">". submission_number() ."</FONT>)</LI>\n";
+ $content .= "<P>\n";
+
if ($menu && ksort($menu)) {
- foreach ($menu as $link=>$url) $content .= "<LI><A HREF=\"$url\">$link</A></LI>\n";
+ foreach ($menu as $link=>$url) $content .= "<LI><A HREF=\"$url\">". t($link) ."</A></LI>\n";
$content .= "<P>\n";
}
- $content .= "<LI><A HREF=\"account.php?op=logout\">logout</A></LI>\n";
+ $content .= "<LI><A HREF=\"account.php?op=logout\">". t("logout") ."</A></LI>\n";
- $theme->box("$user->userid's configuration", "$content");
+ $theme->box(strtr(t("%s's configuration"), array("%s" => $user->userid)), "$content");
}
else {
$output .= "<CENTER>\n";
$output .= " <FORM ACTION=\"account.php?op=Login\" METHOD=\"post\">\n";
- $output .= " <P><B>Username:</B><BR><INPUT NAME=\"userid\" SIZE=\"15\"></P>\n";
- $output .= " <P><B>Password:</B><BR><INPUT NAME=\"passwd\" SIZE=\"15\" TYPE=\"password\"></P>\n";
+ $output .= " <P><B>". t("Username") .":</B><BR><INPUT NAME=\"userid\" SIZE=\"15\"></P>\n";
+ $output .= " <P><B>". t("Password") .":</B><BR><INPUT NAME=\"passwd\" SIZE=\"15\" TYPE=\"password\"></P>\n";
$output .= " <P><INPUT NAME=\"op\" TYPE=\"submit\" VALUE=\"Login\"></P>\n";
- $output .= " <P><A HREF=\"account.php\">REGISTER</A></P>\n";
+ $output .= " <P><A HREF=\"account.php\">". t("REGISTER") ."</A></P>\n";
$output .= " </FORM>\n";
$output .= "</CENTER>\n";
- $theme->box("Login", $output);
+ $theme->box(t("Login"), $output);
}
}
@@ -84,7 +85,7 @@ function theme_blocks($region, $theme) {
else $result = db_query("SELECT * FROM blocks WHERE status = 2 ORDER BY weight");
while ($block = db_fetch_object($result)) {
$blocks = module_execute($block->module, "block");
- $theme->box($blocks[$block->offset]["subject"], $blocks[$block->offset]["content"]);
+ $theme->box(t($blocks[$block->offset]["subject"]), $blocks[$block->offset]["content"]);
}
break;
}
diff --git a/includes/timer.inc b/includes/timer.inc
new file mode 100644
index 000000000..39034a297
--- /dev/null
+++ b/includes/timer.inc
@@ -0,0 +1,17 @@
+<?
+
+$timer = 0;
+
+function timer_print() {
+ global $timer;
+ $stop = explode(" ", microtime());
+ $diff = $timer[0] - $stop[0];
+ print "<PRE>execution time: $diff ms</PRE>";
+}
+
+function timer_start() {
+ global $timer;
+ $timer = explode(" ", microtime());
+}
+
+?> \ No newline at end of file