Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Changes related to new way of setting and recalling themes.

The CFG->theme variable is now obsolete in config.php - use the
admin page to set themes interactively.
  • Loading branch information...
commit 1e3e716f1df58f611f1f6ebc9f4364a855015804 1 parent 76e73fe
martin authored
View
5 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] = "<P><A HREF=\"site.php\">".get_string("sitesettings")."</A></P>".
- "<P><A HREF=\"../course/log.php?id=$site->id\">".get_string("sitelogs")."</A></P>";
+ "<P><A HREF=\"../course/log.php?id=$site->id\">".get_string("sitelogs")."</A></P>".
+ "<P><A HREF=\"../theme/index.php\">".get_string("choosetheme")."</A></P>";
$table->data[0][1] = "<P><A HREF=\"../course/edit.php\">".get_string("addnewcourse")."</A></P>".
"<P><A HREF=\"../course/teacher.php\">".get_string("assignteachers")."</A></P>".
"<P><A HREF=\"../course/delete.php\">".get_string("deletecourse")."</A></P>";
View
7 config-dist.php
@@ -59,13 +59,6 @@
$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.
View
2  course/lib.php
@@ -511,6 +511,8 @@ function print_admin_links ($siteid) {
$modicon[]=$icon;
$moddata[]="<A HREF=\"$CFG->wwwroot/admin/site.php\">".get_string("sitesettings")."</A>";
$modicon[]=$icon;
+ $moddata[]="<A HREF=\"$CFG->wwwroot/theme/index.php\">".get_string("choosetheme")."</A>";
+ $modicon[]=$icon;
$moddata[]="<A HREF=\"$CFG->wwwroot/course/edit.php\">".get_string("addnewcourse")."</A>";
$modicon[]=$icon;
$moddata[]="<A HREF=\"$CFG->wwwroot/course/teacher.php\">".get_string("assignteachers")."</A>";
View
5 lang/en/moodle.php
@@ -32,6 +32,7 @@
$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[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[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";
View
29 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 "<TABLE WIDTH=100% BORDER=0 valign=top align=center cellpadding=10 cellspacing=1>\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.
View
44 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 @@ class object {};
$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);
-
?>
View
74 theme/index.php
@@ -0,0 +1,74 @@
+<?PHP // $Id$
+
+ require("../config.php");
+
+ optional_variable($preview); // which theme to show
+ optional_variable($choose); // set this theme as default
+
+ if ($choose) {
+ $preview = $choose;
+ }
+
+ if ($preview) {
+ $CFG->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,
+ "<A HREF=\"$CFG->wwwroot/admin\">$stradministration</A> -> $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 "<TABLE ALIGN=CENTER cellpadding=7 cellspacing=5>";
+ echo "<TR><TH>$strtheme<TH>&nbsp;</TR>";
+ foreach ($themes as $theme) {
+ include ("$theme/config.php");
+ echo "<TR>";
+ if ($CFG->theme == $theme) {
+ echo "<TD ALIGN=CENTER BGCOLOR=\"$THEME->body\">$theme</TD>";
+ echo "<TD ALIGN=CENTER><A HREF=\"index.php?choose=$theme\">$strsavechanges</A></TD>";
+ } else {
+ echo "<TD ALIGN=CENTER BGCOLOR=\"$THEME->body\">";
+ echo "<A TITLE=\"$strpreview\" HREF=\"index.php?preview=$theme\">$theme</A>";
+ echo "</TD>";
+ echo "<TD>&nbsp;</TD>";
+ }
+ echo "</TR>";
+ }
+ echo "</TABLE>";
+
+ print_footer();
+
+?>
Please sign in to comment.
Something went wrong with that request. Please try again.