diff --git a/admin/lang.php b/admin/lang.php index 65341c63cf227..309e6bf91cc5b 100644 --- a/admin/lang.php +++ b/admin/lang.php @@ -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 "

".get_string("stringsnotset","","$langdir/$file")."

";
                         $first = false;
@@ -188,6 +189,7 @@
                 echo "cellheading\" VALIGN=TOP>$envalue";
 
                 $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");
         }
diff --git a/course/lib.php b/course/lib.php
index 48295e186fb72..59f945028d478 100644
--- a/course/lib.php
+++ b/course/lib.php
@@ -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 "

"; print_string("displayingrecords", "", $totalcountlogs); echo "

"; @@ -173,7 +179,7 @@ function print_log($course, $user=0, $date=0, $order="ORDER BY l.time ASC") { echo "course\">".$courses[$log->course].""; } echo "".userdate($log->time, "%A").""; - echo "".userdate($log->time, "%d %B %Y, %I:%M %p").""; + echo "".userdate($log->time, $strftimedatetime).""; echo ""; link_to_popup_window("/lib/ipatlas/plot.php?address=$log->ip&user=$log->userid", "ipatlas","$log->ip", 400, 700); echo ""; @@ -306,7 +312,7 @@ function print_recent_activity($course) { } else { echo "

"; echo get_string("yourlastlogin").":
"; - echo userdate($USER->lastlogin, "%A, %d %b %Y, %H:%M"); + echo userdate($USER->lastlogin, get_string("strftimerecentfull")); echo "

"; } diff --git a/course/log.php b/course/log.php index 775b3e0f0524c..05878f1c64fa1 100644 --- a/course/log.php +++ b/course/log.php @@ -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) { diff --git a/course/weeks.php b/course/weeks.php index 9d369d76a9ae9..99f966cc69ac0 100644 --- a/course/weeks.php +++ b/course/weeks.php @@ -113,6 +113,8 @@ $weekofseconds = 604800; $course->enddate = $course->startdate + ($weekofseconds * $course->numsections); + $strftimedateshort = " ".get_string("strftimedateshort"); + while ($weekdate < $course->enddate) { $nextweekdate = $weekdate + ($weekofseconds); @@ -127,8 +129,8 @@ $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\""; diff --git a/file.php b/file.php index cfed50f60c09b..ec4b6c246ef09 100644 --- 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; diff --git a/lang/en/moodle.php b/lang/en/moodle.php index 962da4724bf27..a357f0914bc8b 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -459,6 +459,14 @@ $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"; diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 7c30e73e8a367..e45d4fa638b9f 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -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; diff --git a/mod/assignment/lib.php b/mod/assignment/lib.php index d31b9ae309fc9..1efcc909e724c 100644 --- a/mod/assignment/lib.php +++ b/mod/assignment/lib.php @@ -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 "

$date - $assignment->firstname $assignment->lastname
"; echo "\"wwwroot/mod/assignment/$assignment->url\">"; echo "$assignment->name"; diff --git a/mod/choice/report.php b/mod/choice/report.php index 250fd222a8975..c333dcfadf142 100644 --- a/mod/choice/report.php +++ b/mod/choice/report.php @@ -53,7 +53,11 @@ $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) { diff --git a/mod/forum/lib.php b/mod/forum/lib.php index 8170a1cbaf9be..89a3394feea2e 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -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 "

$date - $post->firstname $post->lastname
"; echo "\"
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 "

".userdate($discussion->modified, "%d %b, %H:%M")." - $discussion->firstname"; + echo "

".userdate($discussion->modified, $strftimerecent)." - $discussion->firstname"; echo "
$discussion->subject "; echo "
wwwroot/mod/forum/discuss.php?d=$discussion->discussion\">"; - echo get_string("more", "forum")."..."; + echo $strmore."..."; echo "

\n"; break; case "header": diff --git a/mod/journal/lib.php b/mod/journal/lib.php index 721609711c769..526c13018682b 100644 --- a/mod/journal/lib.php +++ b/mod/journal/lib.php @@ -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 "

$date - $journal->firstname $journal->lastname
"; echo "\"wwwroot/mod/journal/$journal->url\">"; echo "$journal->name"; diff --git a/mod/resource/view.php b/mod/resource/view.php index 7f4a9257334ee..00842ee4a9623 100644 --- a/mod/resource/view.php +++ b/mod/resource/view.php @@ -52,7 +52,7 @@ break; case WEBPAGE: - if ($frameset) { + if (!empty($frameset)) { print_header("$course->shortname: $resource->name", "$course->fullname", "$navigation reference\" TITLE=\"$resource->reference\">$resource->name", "", "", 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 "

".text_to_html($resource->summary, true, false)."
"; diff --git a/mod/survey/lib.php b/mod/survey/lib.php index bf0e6f2216b27..eb2f223b0b9fc 100644 --- a/mod/survey/lib.php +++ b/mod/survey/lib.php @@ -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 "

$date - $survey->firstname $survey->lastname
"; echo "\"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 ""; echo ""; @@ -220,7 +223,7 @@ function survey_print_all_responses($survey, $results) { echo ""; echo ""; - echo ""; + echo ""; echo ""; echo ""; } diff --git a/mod/survey/report.php b/mod/survey/report.php index ca3c51eb1ca9a..47f442caa8ffd 100644 --- a/mod/survey/report.php +++ b/mod/survey/report.php @@ -216,6 +216,7 @@ $strtime = get_string("time", "survey"); $stractual = get_string("actual", "survey"); $strpreferred = get_string("preferred", "survey"); + $strdateformat = get_string("strftimedatetime"); echo "
NameTimeAnswered
id&id=$survey\">$a->firstname $a->lastname".userdate($a->time, "%d %B %Y, %I:%M %p")."".userdate($a->time, $dateformat)."$a->numanswers
"; @@ -226,7 +227,7 @@ print_user_picture($a->userid, $course->id, $a->picture, false); echo ""; echo ""; - echo ""; + echo ""; echo "
 $strname$strtime$stractual$strpreferred

userid\">$a->firstname $a->lastname

".userdate($a->time, "%d %B %Y, %I:%M %p")."

".userdate($a->time, $strdateformat)."

cellcontent\">

"; if ($a->answer1) { echo "$a->answer1 - ".$answers[$a->answer1 - 1];