]> git.mjollnir.org Git - moodle.git/commitdiff
Merged in latest changes from STABLE
authormoodler <moodler>
Mon, 21 Jun 2004 13:07:44 +0000 (13:07 +0000)
committermoodler <moodler>
Mon, 21 Jun 2004 13:07:44 +0000 (13:07 +0000)
lib/moodlelib.php
lib/setup.php
lib/weblib.php

index 80a78432b5d418324c58221e2db6afd4a6561a67..1093b438fbd4326507902d13912370f0d6e6e9b6 100644 (file)
@@ -2312,6 +2312,30 @@ function moodle_needs_upgrading() {
 
 /// MISCELLANEOUS ////////////////////////////////////////////////////////////////////
 
+function moodle_setlocale($locale='') {
+
+    global $SESSION, $USER, $CFG;
+
+    if ($locale) {
+        $CFG->locale = $locale;
+    } else if (!empty($CFG->courselang) and ($CFG->courselang != $CFG->lang) ) {
+        $CFG->locale = get_string('locale');
+    } else if (!empty($SESSION->lang) and ($SESSION->lang != $CFG->lang) ) {
+        $CFG->locale = get_string('locale');
+    } else if (!empty($USER->lang) and ($USER->lang != $CFG->lang) ) {
+        $CFG->locale = get_string('locale');
+    } else if (empty($CFG->locale)) {
+        $CFG->locale = get_string('locale');
+        set_config('locale', $CFG->locale);   // cache it to save lookups in future
+    }
+    setlocale (LC_TIME, $CFG->locale);
+    setlocale (LC_COLLATE, $CFG->locale);
+
+    if ($CFG->locale != 'tr_TR') {            // To workaround a well-known PHP bug with Turkish
+        setlocale (LC_CTYPE, $CFG->locale);
+    }
+}
+
 function moodle_strtolower ($string, $encoding='') {
 /// Converts string to lowercase using most compatible  function available
     if (function_exists('mb_strtolower')) {
index fe6c9db7746ef9f1943f904ba0166094c63aacd2..ecce1a2226eb7c80061a1bb06f13fa4657c2bbab 100644 (file)
     if (empty($CFG->lang)) {
         $CFG->lang = "en";
     }
-    if (!empty($SESSION->lang) and ($SESSION->lang != $CFG->lang) ) {
-        $CFG->locale = get_string('locale');
-    } else if (!empty($USER->lang) and ($USER->lang != $CFG->lang) ) {
-        $CFG->locale = get_string('locale');
-    } else if (empty($CFG->locale)) {
-        $CFG->locale = get_string('locale');
-        set_config('locale', $CFG->locale);   // cache it to save lookups in future
-    }
-    setlocale (LC_TIME, $CFG->locale);
-    setlocale (LC_COLLATE, $CFG->locale);
 
-    if ($CFG->locale != 'tr_TR') {            // To workaround a well-known PHP bug with Turkish
-        setlocale (LC_CTYPE, $CFG->locale);
-    }
+    moodle_setlocale();
 
     if (!empty($CFG->opentogoogle)) {
         if (empty($_SESSION['USER'])) {
index 54f71e265c1732557bb32706116127b05ed71076..51aeb34c6dda89be9f85516e0a15c22276b668a1 100644 (file)
@@ -970,11 +970,15 @@ function print_header ($title="", $heading="", $navigation="", $focus="", $meta=
 
     if (!empty($CFG->unicode)) {
         $encoding = "utf-8";
-    } else if (!empty($SESSION->encoding) and empty($CFG->courselang)) {
-        $encoding = $SESSION->encoding;
-    } else {
+    } else if (!empty($CFG->courselang)) {
         $encoding = get_string("thischarset");
-        $SESSION->encoding = $encoding;
+        moodle_setlocale();
+    } else {
+        if (!empty($SESSION->encoding)) {
+            $encoding = $SESSION->encoding;
+        } else {
+            $SESSION->encoding = $encoding = get_string("thischarset");
+        }
     }
     $meta = "<meta http-equiv=\"content-type\" content=\"text/html; charset=$encoding\" />\n$meta\n";
 
@@ -1866,7 +1870,7 @@ function navmenu($course, $cm=NULL, $targetwindow="self") {
                 $selectmod = $mod;
                 $backmod = $previousmod;
                 $flag = true; // set flag so we know to use next mod for "next"
-                $mod->name = get_string('jumpto');
+                $mod->name = $strjumpto;
                 $strjumpto = '';
             } else {
                 $mod->name = strip_tags(urldecode($mod->name));
@@ -1948,19 +1952,22 @@ function print_time_selector($hour, $minute, $currenttime=0, $step=5) {
     choose_from_menu($minutes, $minute, $currentdate['minutes'], "");
 }
 
-function print_timer_selector($timelimit = 0) {
+function print_timer_selector($timelimit = 0, $unit = "") {
 /// Prints time limit value selector
-/// to add or edit quiz's time limit
 
     global $CFG;
 
+    if ($unit) {
+        $unit = ' '.$unit;
+    }
+
     // Max timelimit is sessiontimeout - 10 minutes.
     $maxvalue = ($CFG->sessiontimeout / 60) - 10;
 
-    for ($i=0; $i<=$maxvalue; $i++) {
-        $minutes[$i] = sprintf("%02d",$i);
+    for ($i=1; $i<=$maxvalue; $i++) {
+        $minutes[$i] = $i.$unit;
     }
-    choose_from_menu($minutes, "timelimit", $timelimit,"");
+    choose_from_menu($minutes, "timelimit", $timelimit, get_string("none"));
 }
 
 function print_grade_menu($courseid, $name, $current, $includenograde=true) {