Browse files

Consistent use of get_site() instead of checking course->category dir…

…ectly
  • Loading branch information...
1 parent bec7ff3 commit a83fded1a9b5144f92b547b51c1e348cf094006d martin committed Jul 11, 2002
Showing with 17 additions and 40 deletions.
  1. +2 −3 admin/index.php
  2. +1 −1 admin/site.php
  3. +1 −1 admin/user.php
  4. +1 −1 course/edit.php
  5. +1 −1 course/enrol.php
  6. +1 −1 course/lib.php
  7. +10 −32 lib/moodlelib.php
View
5 admin/index.php
@@ -79,7 +79,7 @@
}
// Set up the overall site name etc.
- if (! $course = get_record("course", "category", 0)) {
+ if (! $site = get_site()) {
redirect("site.php");
}
@@ -93,7 +93,7 @@
// At this point, the databases exist, and the user is an admin
- print_header("$course->fullname: Administration Page","$course->fullname: Administration Page", "Admin");
+ print_header("$site->fullname: Administration Page","$site->fullname: Administration Page", "Admin");
echo "<UL>";
echo "<LI><B><A HREF=\"site.php\">Site settings</A></B>";
@@ -104,7 +104,6 @@
echo "<LI><B>View Logs</B>";
echo "</UL>";
-
print_footer();
?>
View
2 admin/site.php
@@ -2,7 +2,7 @@
require("../config.php");
- $course = get_record("course", "category", 0);
+ $course = get_site();
/// If data submitted, then process and store.
View
2 admin/user.php
@@ -28,7 +28,7 @@
error("User ID was incorrect (can't find it)");
}
- if (! $course = get_record("course", "category", 0)) {
+ if (! $course = get_site()) {
error("Could not find site-level course");
}
View
2 course/edit.php
@@ -22,7 +22,7 @@
error("Only administrators can use this page");
}
- if (! $site = get_record("course", "category", 0)) {
+ if (! $site = get_site()) {
redirect("$CFG->wwwroot/admin/");
}
}
View
2 course/enrol.php
@@ -43,7 +43,7 @@
}
- if (! $site = get_record("course", "category", "0") ) {
+ if (! $site = get_site()) {
error("Could not find a site!");
}
View
2 course/lib.php
@@ -192,7 +192,7 @@ function print_course($course) {
global $CFG;
- if (! $site = get_record("course", "category", "0") ) {
+ if (! $site = get_site()) {
error("Could not find a site!");
}
View
42 lib/moodlelib.php
@@ -54,7 +54,7 @@ function print_navigation ($navigation) {
global $CFG;
if ($navigation) {
- if (! $site = get_record("course", "category", 0)) {
+ if (! $site = get_site()) {
$site->shortname = get_string("home");;
}
echo "<A TARGET=_top HREF=\"$CFG->wwwroot/\">$site->shortname</A> -> $navigation";
@@ -749,7 +749,7 @@ function get_user_info_from_db($field, $value) {
$rs->MoveNext();
}
- if ($course = get_record("course", "category", 0)) {
+ if ($course = get_site()) {
// Everyone is always a member of the top course
$user->student["$course->id"] = true;
}
@@ -1094,16 +1094,19 @@ function get_directory_list( $rootdir ) {
/// STRING TRANSLATION ////////////////////////////////////////
-function print_string($identifier, $module="", $a="", $b="", $c="") {
- echo get_string($identifier, $module, $a, $b, $c);
+function print_string($identifier, $module="", $a=NULL) {
+ echo get_string($identifier, $module, $a);
}
-function get_string($identifier, $module="", $a="", $b="", $c="") {
+function get_string($identifier, $module="", $a=NULL) {
// Return the translated string specified by $identifier as
// for $module. Uses the same format files as STphp.
-// $a, $b and $c are optional variables that may be used
+// $a is an object, string or number that can be used
// within translation strings
+//
+// eg "hello \$a->firstname \$a->lastname"
+// or "hello \$a"
global $CFG, $USER;
@@ -1153,20 +1156,6 @@ function get_string($identifier, $module="", $a="", $b="", $c="") {
}
-function get_string_variable_list($string) {
-// This function is only used from get_string_from_file().
- if (empty ($string))
- return;
-
- // Match on all variables in $string
- $count = preg_match_all("/\\\$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/",
- $string, $matches);
-
- // Return array of matches ($matches[0] is most useful)
- return $matches;
-}
-
-
function get_string_from_file($identifier, $langfile, $destination) {
// This function is only used from get_string().
include ($langfile);
@@ -1175,18 +1164,7 @@ function get_string_from_file($identifier, $langfile, $destination) {
return false;
}
- $value = "sprintf(\"".$string[$identifier]."\");";
- $variables = get_string_variable_list($value);
- if (empty($variables[0]))
- return "$destination = $value";
- else {
- foreach ($variables[0] as $variable) {
- $variablecheck .= "if (!isset ($variable))\n" .
- "die (\"Variable specified in translation " .
- "not set.\");\n";
- }
- return "$variablecheck $destination = $value";
- }
+ return "$destination = sprintf(\"".$string[$identifier]."\");";
}

0 comments on commit a83fded

Please sign in to comment.