Permalink
Browse files

Added new header to all pages to set the current charset, to help bro…

…wsers
  • Loading branch information...
1 parent 53e61ab commit 4bfa92e714f06cc8da2a8720786beadc9719c233 moodler committed Oct 2, 2002
Showing with 21 additions and 7 deletions.
  1. +21 −7 lib/moodlelib.php
View
@@ -39,14 +39,22 @@ function print_header ($title="", $heading="", $navigation="", $focus="", $meta=
$button = "<FONT SIZE=2><A HREF=\"$CFG->wwwroot/login/index.php\">".get_string("login")."</A></FONT>";
}
}
+
+ // Specify character set ... default is iso-8859-1 but some languages might need something else
+ // Could be optimised by carrying the charset variable around in $USER
+ if (current_language() == "en") {
+ $meta .= "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-1\">\n";
+ } else {
+ $meta .= "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=".get_string("thischarset")."\">\n";
+ }
if (!$cache) { // Do everything we can to prevent clients and proxies caching
@header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
@header("Pragma: no-cache");
$meta .= "\n<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">";
$meta .= "\n<META HTTP-EQUIV=\"Expires\" CONTENT=\"0\">";
}
-
+
include ("$CFG->dirroot/theme/$CFG->theme/header.html");
}
@@ -1569,6 +1577,16 @@ function print_string($identifier, $module="", $a=NULL) {
echo get_string($identifier, $module, $a);
}
+function current_language() {
+// Returns the code for the current language
+ global $CFG, $USER;
+
+ if (isset($USER->lang)) { // User language can override site language
+ return $USER->lang;
+ } else {
+ return $CFG->lang;
+ }
+}
function get_string($identifier, $module="", $a=NULL) {
// Return the translated string specified by $identifier as
@@ -1579,13 +1597,9 @@ function get_string($identifier, $module="", $a=NULL) {
// eg "hello \$a->firstname \$a->lastname"
// or "hello \$a"
- global $CFG, $USER;
+ global $CFG;
- if (isset($USER->lang)) { // User language can override site language
- $lang = $USER->lang;
- } else {
- $lang = $CFG->lang;
- }
+ $lang = current_language();
if ($module == "") {
$module = "moodle";

0 comments on commit 4bfa92e

Please sign in to comment.