]> git.mjollnir.org Git - moodle.git/commitdiff
Changes related to new way of setting and recalling themes.
authormartin <martin>
Sat, 17 Aug 2002 13:01:06 +0000 (13:01 +0000)
committermartin <martin>
Sat, 17 Aug 2002 13:01:06 +0000 (13:01 +0000)
The CFG->theme variable is now obsolete in config.php - use the
admin page to set themes interactively.

admin/index.php
config-dist.php
course/lib.php
lang/en/moodle.php
lib/moodlelib.php
lib/setup.php
theme/index.php [new file with mode: 0644]

index 14d1ce2f28e5407cc70642efa0835e20ce68a9ef..7e88a45885e43f7a26e877ebb9ad13ce1d3aff40 100644 (file)
@@ -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!");
     }
 
     $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>";
index 5a38ae50912fdcaec4bf7643e971240bf09f3795..a58b7442d5b5882c34154b33138fe6a3780f73a0 100644 (file)
@@ -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.
 
index 90be1537e8a02ed8f2471a35cd8a6c43f4d393f3..935344e8fee2336e215cc0b71c861751c1d0e6f3 100644 (file)
@@ -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>";
index 06dd4c5b0c6e4a13b86f1a55de0c9001de640976..2a58161eb0f71d01186257798d4e5a86767cfa5d 100644 (file)
@@ -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";
index 245b4472228156319d017e1cd1fa73336d46200d..54799b962b7d48f4f4209958b0736fe9d43d6e0d 100644 (file)
@@ -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.
 
index 90af95571c4facfa659c67b6316d0d596676d72a..ec80e1ccbdd30de18fa19b8a749e7d52dbf5e5cf 100644 (file)
 
     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";
     $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) {
    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
 
     $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 (file)
index 0000000..74dccb2
--- /dev/null
@@ -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();
+
+?>