diff --git a/admin/index.php b/admin/index.php
index 14d1ce2f28e..7e88a45885e 100644
--- a/admin/index.php
+++ b/admin/index.php
@@ -98,7 +98,7 @@
// Find and check all modules and load them up or upgrade them if necessary
- if (!$mods = get_list_of_modules() ) {
+ if (!$mods = get_list_of_plugins("mod") ) {
error("No modules installed!");
}
@@ -187,7 +187,8 @@
$table->head = array (get_string("site"), get_string("courses"), get_string("users"));
$table->align = array ("CENTER", "CENTER", "CENTER");
$table->data[0][0] = "
".get_string("sitesettings")."
".
- "id\">".get_string("sitelogs")."
";
+ "id\">".get_string("sitelogs")."
".
+ "".get_string("choosetheme")."
";
$table->data[0][1] = "".get_string("addnewcourse")."
".
"".get_string("assignteachers")."
".
"".get_string("deletecourse")."
";
diff --git a/config-dist.php b/config-dist.php
index 5a38ae50912..a58b7442d5b 100644
--- a/config-dist.php
+++ b/config-dist.php
@@ -59,13 +59,6 @@ $CFG->dirroot = "/web/moodle";
$CFG->dataroot = "/home/moodledata";
-// Choose a theme from the "themes" folder. Current choices include
-// "standard", "standardblue", "standardgreen" and "standardred",
-// but feel free to copy one and make new themes!
-
-$CFG->theme = "standard";
-
-
// Choose a sitewide language - this will affect text, buttons etc
// See lib/languages.php for a full list of standard language codes.
diff --git a/course/lib.php b/course/lib.php
index 90be1537e8a..935344e8fee 100644
--- a/course/lib.php
+++ b/course/lib.php
@@ -511,6 +511,8 @@ function print_admin_links ($siteid) {
$modicon[]=$icon;
$moddata[]="wwwroot/admin/site.php\">".get_string("sitesettings")."";
$modicon[]=$icon;
+ $moddata[]="wwwroot/theme/index.php\">".get_string("choosetheme")."";
+ $modicon[]=$icon;
$moddata[]="wwwroot/course/edit.php\">".get_string("addnewcourse")."";
$modicon[]=$icon;
$moddata[]="wwwroot/course/teacher.php\">".get_string("assignteachers")."";
diff --git a/lang/en/moodle.php b/lang/en/moodle.php
index 06dd4c5b0c6..2a58161eb0f 100644
--- a/lang/en/moodle.php
+++ b/lang/en/moodle.php
@@ -32,6 +32,7 @@ $string[choose] = "Choose";
$string[choosecourse] = "Choose a course";
$string[chooselivelogs] = "Or watch current activity";
$string[chooselogs] = "Choose which logs you want to see";
+$string[choosetheme] = "Choose theme";
$string[chooseuser] = "Choose a user";
$string[city] = "City/town";
$string[confirmed] = "Your registration has been confirmed";
@@ -282,6 +283,8 @@ $string[passwordsenttext] = "
$string[people] = "People";
$string[personalprofile] = "Personal profile";
$string[phone] = "Phone";
+$string[preview] = "Preview";
+$string[previeworchoose] = "Preview or choose a theme";
$string[question] = "Question";
$string[recentactivity] = "Recent activity";
$string[resources] = "Resources";
@@ -322,6 +325,8 @@ $string[teacheronly] = "for the \$a only";
$string[textformat] = "Plain text format";
$string[timezone] = "Timezone";
$string[thanks] = "Thanks";
+$string[theme] = "Theme";
+$string[themesaved] = "New theme saved";
$string[today] = "Today";
$string[todaylogs] = "Today's logs";
$string[topic] = "Topic";
diff --git a/lib/moodlelib.php b/lib/moodlelib.php
index 245b4472228..54799b962b7 100644
--- a/lib/moodlelib.php
+++ b/lib/moodlelib.php
@@ -176,6 +176,7 @@ function print_table($table) {
// $table->head is an array of heading names.
// $table->align is an array of column alignments
// $table->data[] is an array of arrays containing the data.
+// $table->width is an percentage of the page
if ($table->align) {
foreach ($table->align as $key => $aa) {
@@ -187,7 +188,11 @@ function print_table($table) {
}
}
- print_simple_box_start("CENTER", "80%", "#FFFFFF", 0);
+ if (!$table->width) {
+ $table->width = "80%";
+ }
+
+ print_simple_box_start("CENTER", "$table->width", "#FFFFFF", 0);
echo "\n";
if ($table->head) {
@@ -1576,7 +1581,7 @@ function moodle_needs_upgrading() {
if ($version > $dversion) {
return true;
}
- if ($mods = get_list_of_modules()) {
+ if ($mods = get_list_of_plugins("mod")) {
foreach ($mods as $mod) {
$fullmod = "$CFG->dirroot/mod/$mod";
unset($module);
@@ -1595,22 +1600,28 @@ function moodle_needs_upgrading() {
}
-function get_list_of_modules() {
+function get_list_of_plugins($plugin="mod") {
+// Lists plugin directories within some directory
+
global $CFG;
- $dir = opendir("$CFG->dirroot/mod");
- while ($mod = readdir($dir)) {
- if ($mod == "." || $mod == ".." || $mod == "CVS") {
+ $basedir = opendir("$CFG->dirroot/$plugin");
+ while ($dir = readdir($basedir)) {
+ if ($dir == "." || $dir == ".." || $dir == "CVS") {
continue;
}
- if (filetype("$CFG->dirroot/mod/$mod") != "dir") {
+ if (filetype("$CFG->dirroot/$plugin/$dir") != "dir") {
continue;
}
- $mods[] = $mod;
+ $plugins[] = $dir;
}
- return $mods;
+ if ($plugins) {
+ asort($plugins);
+ }
+ return $plugins;
}
+
function iswindows() {
// True if this is Windows, False if not.
diff --git a/lib/setup.php b/lib/setup.php
index 90af95571c4..ec80e1ccbdd 100644
--- a/lib/setup.php
+++ b/lib/setup.php
@@ -16,10 +16,31 @@
error_reporting(7); // use 0=none 7=normal 15=all
+// Load up standard libraries
+
+ require("$CFG->libdir/weblib.php"); // Standard web page functions
+ require("$CFG->libdir/adodb/adodb.inc.php"); // Database access functions
+ require("$CFG->libdir/adodb/tohtml.inc.php");// Database display functions
+ require("$CFG->libdir/moodlelib.php"); // Various Moodle functions
+
+// Connect to the database using adodb
+
+ ADOLoadCode($CFG->dbtype);
+ $db = &ADONewConnection();
+ $db->PConnect($CFG->dbhost,$CFG->dbuser,$CFG->dbpass,$CFG->dbname);
+
// Default editing time for posts and the like (in seconds)
$CFG->maxeditingtime = 1800;
+// Load up any configuration from the config table
+
+ if (!$CFG->theme = get_field("config", "value", "name", "theme")) {
+ $theme->name = "theme";
+ $theme->value = $CFG->theme = "standard";
+ insert_record("config", $theme);
+ }
+
// Location of standard files
$CFG->templatedir = "$CFG->dirroot/templates";
@@ -30,6 +51,10 @@
$CFG->header = "$CFG->dirroot/theme/$CFG->theme/header.html";
$CFG->footer = "$CFG->dirroot/theme/$CFG->theme/footer.html";
+// Load up theme variables (colours etc)
+
+ require("$CFG->dirroot/theme/$CFG->theme/config.php");
+
// Set language/locale of printed times (must be supported by OS)
if ($CFG->locale) {
@@ -48,19 +73,6 @@
if (isset($_SERVER)) {
extract($_SERVER);
}
-
-// Load up theme variables (colours etc)
-
- require("$CFG->dirroot/theme/$CFG->theme/config.php");
-
-
-// Load up standard libraries
-
- require("$CFG->libdir/weblib.php"); // Standard web page functions
- require("$CFG->libdir/adodb/adodb.inc.php"); // Database access functions
- require("$CFG->libdir/adodb/tohtml.inc.php");// Database display functions
- require("$CFG->libdir/moodlelib.php"); // Various Moodle functions
-
// Load up global environment variables
@@ -74,11 +86,5 @@
$FULLME = qualified_me();
$ME = strip_querystring($FULLME);
-// Connect to the database using adodb
-
- ADOLoadCode($CFG->dbtype);
- $db = &ADONewConnection();
- $db->PConnect($CFG->dbhost,$CFG->dbuser,$CFG->dbpass,$CFG->dbname);
-
?>
diff --git a/theme/index.php b/theme/index.php
new file mode 100644
index 00000000000..74dccb23282
--- /dev/null
+++ b/theme/index.php
@@ -0,0 +1,74 @@
+theme = $preview;
+ $CFG->stylesheet = "$CFG->wwwroot/theme/$CFG->theme/styles.css";
+ $CFG->header = "$CFG->dirroot/theme/$CFG->theme/header.html";
+ $CFG->footer = "$CFG->dirroot/theme/$CFG->theme/footer.html";
+ include ("$CFG->theme/config.php");
+ }
+
+
+ if (! $site = get_site()) {
+ error("Site doesn't exist!");
+ }
+
+ require_login();
+
+ if (!isadmin()) {
+ error("You must be an administrator to change themes.");
+ }
+
+
+ $stradministration = get_string("administration");
+ $strchoosetheme = get_string("choosetheme");
+ $strpreview = get_string("preview");
+ $strsavechanges = get_string("savechanges");
+ $strtheme = get_string("theme");
+ $strthemesaved = get_string("themesaved");
+
+ print_header("$site->fullname : $strchoosetheme", $site->fullname,
+ "wwwroot/admin\">$stradministration -> $strchoosetheme");
+
+ if ($choose) {
+ set_field("config", "value", $choose, "name", "theme");
+ print_heading(get_string("themesaved"));
+ print_continue("$CFG->wwwroot");
+ print_footer();
+ exit;
+ }
+
+ print_heading(get_string("previeworchoose"));
+
+ $themes = get_list_of_plugins("theme");
+
+ echo "";
+ echo "$strtheme | |
";
+ foreach ($themes as $theme) {
+ include ("$theme/config.php");
+ echo "";
+ if ($CFG->theme == $theme) {
+ echo "body\">$theme | ";
+ echo "$strsavechanges | ";
+ } else {
+ echo "body\">";
+ echo "$theme";
+ echo " | ";
+ echo " | ";
+ }
+ echo "
";
+ }
+ echo "
";
+
+ print_footer();
+
+?>