]> git.mjollnir.org Git - moodle.git/commitdiff
Displayed time formats are now stored in lang files
authormoodler <moodler>
Wed, 15 Jan 2003 10:55:54 +0000 (10:55 +0000)
committermoodler <moodler>
Wed, 15 Jan 2003 10:55:54 +0000 (10:55 +0000)
(see the new strftime* strings) so they can be customised per language

14 files changed:
admin/lang.php
course/lib.php
course/log.php
course/weeks.php
file.php
lang/en/moodle.php
lib/moodlelib.php
mod/assignment/lib.php
mod/choice/report.php
mod/forum/lib.php
mod/journal/lib.php
mod/resource/view.php
mod/survey/lib.php
mod/survey/report.php

index 65341c63cf22729f329a698607fb2c1c4bcc14c9..309e6bf91cc5b9e220fb134fb09cf72bdfa0e7f0 100644 (file)
@@ -89,6 +89,7 @@
                 if (!isset($string[$key]) or $string[$key] == "") {
                     $value = htmlspecialchars($value);
                     $value = str_replace("$"."a", "\\$"."a", $value);
+                    $value = str_replace("%%","%",$value);
                     if ($first) {
                         echo "</PRE><HR><P><B>".get_string("stringsnotset","","$langdir/$file")."</B></P><PRE>";
                         $first = false;
                 echo "<TD WIDTH=40% BGCOLOR=\"$THEME->cellheading\" VALIGN=TOP>$envalue</TD>";
 
                 $value = str_replace("\\","",$string[$key]);          // Delete all slashes
+                $value = str_replace("%%","%",$value);
                 $value = htmlspecialchars($value);
 
                 $cellcolour = $value ? $THEME->cellcontent: $THEME->highlight;
@@ -261,6 +263,7 @@ function lang_save_file($path, $file, $strings) {
         $value = str_replace("\\","",$value);               // Delete all slashes
         $value = str_replace("$"."a", "\\$"."a", $value);   // Add slashes for $a
         $value = str_replace("\"", "\\\"", $value);         // Add slashes for "
+        $value = str_replace("%","%%",$value);              // Escape % characters
         if ($id == "string" and $value != ""){
             fwrite($f,"\$string['$stringname'] = \"$value\";\n");
         }
index 48295e186fb72900d4141f99ae612ca93671b9e8..59f945028d478d0d7a2f7bda962788b9ea4d3c65 100644 (file)
@@ -47,6 +47,10 @@ function print_log_selector_form($course, $selecteduser=0, $selecteddate="today"
         asort($courses);
     }
 
+
+    $strftimedate = get_string("strftimedate");
+    $strftimedaydate = get_string("strftimedaydate");
+
     asort($users);
 
     // Get all the possible dates
@@ -59,7 +63,7 @@ function print_log_selector_form($course, $selecteduser=0, $selecteddate="today"
     $timemidnight = $today = usergetmidnight($timenow);
 
     // Put today up the top of the list
-    $dates = array("$timemidnight" => get_string("today").", ".userdate($timenow, "%d %B %Y") );
+    $dates = array("$timemidnight" => get_string("today").", ".userdate($timenow, $strftimedate) );
 
     if (! $course->startdate) {
         $course->startdate = $course->timecreated;
@@ -69,7 +73,7 @@ function print_log_selector_form($course, $selecteduser=0, $selecteddate="today"
     while ($timemidnight > $course->startdate and $numdates < 365) {
         $timemidnight = $timemidnight - 86400;
         $timenow = $timenow - 86400;
-        $dates["$timemidnight"] = userdate($timenow, "%A, %d %B %Y");
+        $dates["$timemidnight"] = userdate($timenow, $strftimedaydate);
         $numdates++;
     }
 
@@ -150,6 +154,8 @@ function print_log($course, $user=0, $date=0, $order="ORDER BY l.time ASC") {
         $totalcountlogs = "$COURSE_MAX_LOGS_PER_PAGE/$totalcountlogs";
     }
 
+    $strftimedatetime = get_string("strftimedatetime");
+
     echo "<P ALIGN=CENTER>";
     print_string("displayingrecords", "", $totalcountlogs);
     echo "</P>";
@@ -173,7 +179,7 @@ function print_log($course, $user=0, $date=0, $order="ORDER BY l.time ASC") {
             echo "<TD NOWRAP><FONT SIZE=2><A HREF=\"view.php?id=$log->course\">".$courses[$log->course]."</A></TD>";
         }
         echo "<TD NOWRAP ALIGN=right><FONT SIZE=2>".userdate($log->time, "%A")."</TD>";
-        echo "<TD NOWRAP><FONT SIZE=2>".userdate($log->time, "%d %B %Y, %I:%M %p")."</TD>";
+        echo "<TD NOWRAP><FONT SIZE=2>".userdate($log->time, $strftimedatetime)."</TD>";
         echo "<TD NOWRAP><FONT SIZE=2>";
         link_to_popup_window("/lib/ipatlas/plot.php?address=$log->ip&user=$log->userid", "ipatlas","$log->ip", 400, 700);
         echo "</TD>";
@@ -306,7 +312,7 @@ function print_recent_activity($course) {
     } else {
         echo "<P ALIGN=CENTER><FONT SIZE=1>";
         echo get_string("yourlastlogin").":<BR>"; 
-        echo userdate($USER->lastlogin, "%A, %d %b %Y, %H:%M");
+        echo userdate($USER->lastlogin, get_string("strftimerecentfull"));
         echo "</FONT></P>";
     }
 
index 775b3e0f0524ccc37edcc6b9199488fea04dae4d..05878f1c64fa1b6cf785a29528c61338de582895 100644 (file)
@@ -40,7 +40,7 @@
             $userinfo = "$u->firstname $u->lastname";
         }
         if ($date) {
-            $dateinfo = userdate($date, "%A, %d %B %Y");
+            $dateinfo = userdate($date, get_string("strftimedaydate"));
         }
 
         if ($course->category) {
index 9d369d76a9ae92de79d6fdd6249563c494bca80d..99f966cc69ac0cad75bb781552363af070594139 100644 (file)
     $weekofseconds = 604800;
     $course->enddate = $course->startdate + ($weekofseconds * $course->numsections);
 
+    $strftimedateshort = " ".get_string("strftimedateshort");
+
     while ($weekdate < $course->enddate) {
 
         $nextweekdate = $weekdate + ($weekofseconds);
 
         $thisweek = (($weekdate <= $timenow) && ($timenow < $nextweekdate));
 
-        $weekday = userdate($weekdate, " %d %B");
-        $endweekday = userdate($weekdate+518400, " %d %B");
+        $weekday = userdate($weekdate, $strftimedateshort);
+        $endweekday = userdate($weekdate+518400, $strftimedateshort);
 
         if ($thisweek) {
             $colorsides = "bgcolor=\"$THEME->cellheading2\" class=\"weeklyoutlinesidehighlight\"";
index cfed50f60c09b0f64faef91a5ef6c0785bc1c73a..ec4b6c246ef09d6dd39514f02f82d556266b99b5 100644 (file)
--- a/file.php
+++ b/file.php
@@ -49,7 +49,7 @@
         header("Content-type: $mimetype");
         readfile("$pathname");
     } else {
-        error("Sorry, but the file you are looking for was not found", "course/view.php?id=$courseid");
+        error("Sorry, but the file you are looking for was not found ($pathname)", "course/view.php?id=$courseid");
     }
 
     exit;
index 962da4724bf27aa5f779b774985704d6decd3bbe..a357f0914bc8b7e6c2e28592ace24cf6e471b822 100644 (file)
@@ -459,6 +459,14 @@ $string['someerrorswerefound'] = "Some information was missing or incorrect. Loo
 $string['startdate'] = "Course start date";
 $string['startsignup'] = "Start now by creating a new account!";
 $string['status'] = "Status";
+$string['strftimedate'] = "%%d %%B %%Y";
+$string['strftimedateshort'] = "%%d %%B";
+$string['strftimedatetime'] = "%%d %%B %%Y, %%I:%%M %%p";
+$string['strftimedaydate'] = "%%A, %%d %%B %%Y";
+$string['strftimedaydatetime'] = "%%A, %%d %%B %%Y, %%I:%%M %%p";
+$string['strftimerecent'] = "%%d %%b, %%H:%%M";
+$string['strftimerecentfull'] = "%%a, %%d %%b %%Y, %%I:%%M %%p";
+$string['strftimetime'] = "%%I:%%M %%p";
 $string['stringsnotset'] = "The following strings are not defined in \$a";
 $string['studentnotallowed'] = "Sorry, but you can not enter this course as '\$a'";
 $string['success'] = "Success";
index 7c30e73e8a367019c2b252f619f76d4360dfc442..e45d4fa638b9f0350b5606dba24397381fac3c8c 100644 (file)
@@ -141,14 +141,12 @@ function userdate($date, $format="", $timezone=99) {
     global $USER;
 
     if ($format == "") {
-        $format      = "%A, %d %B %Y, %I:%M %p";
-        $formatnoday = "%A, DD %B %Y, %I:%M %p";
-        $fixday = true;
-    } else {
-        $formatnoday = str_replace("%d", "DD", $format);
-        $fixday = ($formatnoday != $format);
+        $format = get_string("strftimedaydatetime");
     }
 
+    $formatnoday = str_replace("%d", "DD", $format);
+    $fixday = ($formatnoday != $format);
+
     if ($timezone == 99) {
         if (isset($USER->timezone)) {
             $timezone = (float)$USER->timezone;
index d31b9ae309fc9923c0af0dc30b6600c0e112ea1d..1efcc909e724cc13e8789e5b5e406fce1f370c42 100644 (file)
@@ -197,10 +197,11 @@ function assignment_print_recent_activity(&$logs, $isteacher=false) {
     }
 
     if ($assignments) {
+        $strftimerecent = get_string("strftimerecent");
         $content = true;
         print_headline(get_string("newsubmissions", "assignment").":");
         foreach ($assignments as $assignment) {
-            $date = userdate($assignment->time, "%d %b, %H:%M");
+            $date = userdate($assignment->time, $strftimerecent);
             echo "<P><FONT SIZE=1>$date - $assignment->firstname $assignment->lastname<BR>";
             echo "\"<A HREF=\"$CFG->wwwroot/mod/assignment/$assignment->url\">";
             echo "$assignment->name";
index 250fd222a8975f0506c74192a08eb62bd1363822..c333dcfadf1425486ca9331d48096c073aa91b67 100644 (file)
         $useranswer[$key] = array();
     }
     foreach ($users as $user) {
-        $answer = $answers[$user->id];
+        if (!empty($answers[$user->id])) {
+            $answer = $answers[$user->id];
+        } else {
+            $answer->answer = 0;
+        }
         $useranswer[(int)$answer->answer][] = $user;
     }
     foreach ($choice->answer as $key => $answer) {  
index 8170a1cbaf9bec76911effec7f6e9f34ec8c20ba..89a3394feea2ea5d81b16ba92ab526f329dcd9a5 100644 (file)
@@ -302,6 +302,8 @@ function forum_print_recent_activity(&$logs, $isteacher=false) {
     $heading = false;
     $content = false;
 
+    $strftimerecent = get_string("strftimerecent");
+
     foreach ($logs as $log) {
         if ($log->module == "forum") {
 
@@ -321,7 +323,7 @@ function forum_print_recent_activity(&$logs, $isteacher=false) {
                     $heading = true;
                     $content = true;
                 }
-                $date = userdate($post->modified, "%d %b, %H:%M");
+                $date = userdate($post->modified, $strftimerecent);
                 echo "<P><FONT SIZE=1 $teacherpost>$date - $post->firstname $post->lastname<BR>";
                 echo "\"<A HREF=\"$CFG->wwwroot/mod/forum/$log->url\">";
                 if ($log->action == "add") {
@@ -1468,6 +1470,11 @@ function forum_print_latest_discussions($forum_id=0, $forum_numdiscussions=5, $f
 
     $discussioncount = 0;
 
+    if ($forum_style == "minimal") {
+        $strftimerecent = get_string("strftimerecent");
+        $strmore = get_string("more", "forum");
+    }
+
     foreach ($discussions as $discussion) {
         $discussioncount++;
 
@@ -1488,10 +1495,10 @@ function forum_print_latest_discussions($forum_id=0, $forum_numdiscussions=5, $f
         }
         switch ($forum_style) {
             case "minimal":
-                echo "<P><FONT COLOR=#555555>".userdate($discussion->modified, "%d %b, %H:%M")." - $discussion->firstname</FONT>";
+                echo "<P><FONT COLOR=#555555>".userdate($discussion->modified, $strftimerecent)." - $discussion->firstname</FONT>";
                 echo "<BR>$discussion->subject ";
                 echo "<A HREF=\"$CFG->wwwroot/mod/forum/discuss.php?d=$discussion->discussion\">";
-                echo get_string("more", "forum")."...</A>";
+                echo $strmore."...</A>";
                 echo "</P>\n";
             break;
             case "header":
index 721609711c7693d8cacece78c4cd0234069ad618..526c13018682b0be03b0959256c5c8ed11354976 100644 (file)
@@ -139,9 +139,10 @@ function journal_print_recent_activity(&$logs, $isteacher=false) {
 
     if ($journals) {
         $content = true;
+        $strftimerecent = get_string("strftimerecent");
         print_headline(get_string("newjournalentries", "journal").":");
         foreach ($journals as $journal) {
-            $date = userdate($journal->time, "%d %b, %H:%M");
+            $date = userdate($journal->time, $strftimerecent);
             echo "<P><FONT SIZE=1>$date - $journal->firstname $journal->lastname<BR>";
             echo "\"<A HREF=\"$CFG->wwwroot/mod/journal/$journal->url\">";
             echo "$journal->name";
index 7f4a9257334ee8e3d174700103a3b69f8c9dbdfc..00842ee4a9623527391c201b338762a6924fda77 100644 (file)
@@ -52,7 +52,7 @@
             break;
 
         case WEBPAGE:
-            if ($frameset) {
+            if (!empty($frameset)) {
                 print_header("$course->shortname: $resource->name", "$course->fullname", 
                 "$navigation <A TARGET=_top HREF=\"$resource->reference\" TITLE=\"$resource->reference\">$resource->name</A>",
                 "", "", true, update_module_button($cm->id, $course->id, $strresource), navmenu($course, $cm));
@@ -69,7 +69,7 @@
             break;
 
         case UPLOADEDFILE:
-            if ($frameset) {
+            if (!empty($frameset)) {
                 print_header("$course->shortname: $resource->name", "$course->fullname", "$navigation $resource->name",
                          "", "", true, update_module_button($cm->id, $course->id, $strresource), navmenu($course, $cm));
                 echo "<CENTER><FONT SIZE=-1>".text_to_html($resource->summary, true, false)."</FONT></CENTER>";
index bf0e6f2216b274e3fb37d7c5e6e3e4aeb1f79752..eb2f223b0b9fc312f602dc48c03e26b0f50aedb7 100644 (file)
@@ -116,9 +116,10 @@ function survey_print_recent_activity(&$logs, $isteacher=false) {
 
     if ($surveys) {
         $content = true;
+        $strftimerecent = get_string("strftimerecent");
         print_headline(get_string("newsurveyresponses", "survey").":");
         foreach ($surveys as $survey) {
-            $date = userdate($survey->time, "%d %b, %H:%M");
+            $date = userdate($survey->time, $strftimerecent);
             echo "<P><FONT SIZE=1>$date - $survey->firstname $survey->lastname<BR>";
             echo "\"<A HREF=\"$CFG->wwwroot/mod/survey/$survey->url\">";
             echo "$survey->name";
@@ -213,6 +214,8 @@ function survey_count_responses($survey) {
 function survey_print_all_responses($survey, $results) {
     global $THEME;
 
+    $dateformat = get_string("strftimedatetime");
+
     echo "<TABLE CELLPADDING=5 CELLSPACING=2 ALIGN=CENTER>";
     echo "<TR><TD>Name<TD>Time<TD>Answered</TR>";
 
@@ -220,7 +223,7 @@ function survey_print_all_responses($survey, $results) {
                  
         echo "<TR>";
         echo "<TD><A HREF=\"report.php?action=student&student=$a->id&id=$survey\">$a->firstname $a->lastname</A></TD>";
-        echo "<TD>".userdate($a->time, "%d %B %Y, %I:%M %p")."</TD>";
+        echo "<TD>".userdate($a->time, $dateformat)."</TD>";
         echo "<TD align=right>$a->numanswers</TD>";
         echo "</TR>";
     }
index ca3c51eb1ca9a6922295853ddfd8080752198d5d..47f442caa8ffd361f510891a3d909bffb1ba3be1 100644 (file)
         $strtime = get_string("time", "survey");
         $stractual = get_string("actual", "survey");
         $strpreferred = get_string("preferred", "survey");
+        $strdateformat = get_string("strftimedatetime");
 
         echo "<TABLE ALIGN=center CELLPADDING=0 CELLSPACING=10><TR><TD>&nbsp;<TH align=left>$strname<TH align=left>$strtime<TH align=left>$stractual<TH align=left>$strpreferred</TR>";
 
                 print_user_picture($a->userid, $course->id, $a->picture, false);
                 echo "</TD>";
                 echo "<TD><P><A HREF=\"report.php?id=$id&action=student&student=$a->userid\">$a->firstname $a->lastname</A></TD>";
-                echo "<TD><P>".userdate($a->time, "%d %B %Y, %I:%M %p")."</TD>";
+                echo "<TD><P>".userdate($a->time, $strdateformat)."</TD>";
                 echo "<TD BGCOLOR=\"$THEME->cellcontent\"><P>";
                 if ($a->answer1) {
                     echo "$a->answer1 - ".$answers[$a->answer1 - 1];