Fixes for Bug MDL-8617 "Implement groupings & course modules..."
[moodle-pu.git] / theme / index.php
blobcfebb4b53ce223332b33d80f1bb72ea4e83b3803
1 <?php // $Id$
3 require_once("../config.php");
4 require_once($CFG->libdir.'/adminlib.php');
6 $choose = optional_param("choose",'',PARAM_FILE); // set this theme as default
8 $adminroot = admin_get_root();
9 admin_externalpage_setup('themeselector', $adminroot);
11 unset($SESSION->theme);
13 $stradministration = get_string("administration");
14 $strconfiguration = get_string("configuration");
15 $strthemes = get_string("themes");
16 $strpreview = get_string("preview");
17 $strchoose = get_string("choose");
18 $strinfo = get_string("info");
19 $strtheme = get_string("theme");
20 $strthemesaved = get_string("themesaved");
21 $strscreenshot = get_string("screenshot");
22 $stroldtheme = get_string("oldtheme");
25 if ($choose and confirm_sesskey()) {
26 if (!is_dir($CFG->themedir .'/'. $choose)) {
27 error("This theme is not installed!");
29 if (set_config("theme", $choose)) {
30 theme_setup($choose);
31 admin_externalpage_print_header($adminroot);
32 print_heading(get_string("themesaved"));
33 print_continue("$CFG->wwwroot/");
35 if (file_exists("$choose/README.html")) {
36 print_simple_box_start("center");
37 readfile("$choose/README.html");
38 print_simple_box_end();
40 } else if (file_exists("$choose/README.txt")) {
41 print_simple_box_start("center");
42 $file = file("$choose/README.txt");
43 echo format_text(implode('', $file), FORMAT_MOODLE);
44 print_simple_box_end();
46 admin_externalpage_print_footer($adminroot);
47 exit;
48 } else {
49 error("Could not set the theme!");
53 admin_externalpage_print_header('themeselector');
56 print_heading($strthemes);
58 $themes = get_list_of_plugins("theme");
59 $sesskey = !empty($USER->id) ? $USER->sesskey : '';
61 echo "<table style=\"margin-left:auto;margin-right:auto;\" cellpadding=\"7\" cellspacing=\"5\">";
63 if (!$USER->screenreader) {
64 echo "<tr class=\"generaltableheader\"><th scope=\"col\">$strtheme</th>";
65 echo "<th scope=\"col\">$strinfo</th></tr>";
67 foreach ($themes as $theme) {
69 unset($THEME);
71 if (!file_exists($CFG->themedir.'/'.$theme.'/config.php')) { // bad folder
72 continue;
75 include($CFG->themedir.'/'.$theme.'/config.php');
77 $readme = '';
78 $screenshot = '';
79 $screenshotpath = '';
81 if (file_exists("$theme/README.html")) {
82 $readme = '<li>'.
83 link_to_popup_window($CFG->themewww .'/'. $theme .'/README.html', $theme, $strinfo, 400, 500, '', 'none', true).'</li>';
84 } else if (file_exists("$theme/README.txt")) {
85 $readme = '<li>'.
86 link_to_popup_window($CFG->themewww .'/'. $theme .'/README.txt', $theme, $strinfo, 400, 500, '', 'none', true).'</li>';
88 if (file_exists("$theme/screenshot.png")) {
89 $screenshotpath = "$theme/screenshot.png";
90 } else if (file_exists("$theme/screenshot.jpg")) {
91 $screenshotpath = "$theme/screenshot.jpg";
94 echo "<tr>";
96 // no point showing this if user is using screen reader
97 if (!$USER->screenreader) {
98 echo "<td align=\"center\">";
99 if ($screenshotpath) {
100 $screenshot = "<li><a target=\"$theme\" href=\"$theme/screenshot.jpg\">$strscreenshot</a></li>";
101 echo "<iframe name=\"$theme\" src=\"$screenshotpath\" height=\"200\" width=\"400\"></iframe></td>";
102 } else {
103 echo "<iframe name=\"$theme\" src=\"preview.php?preview=$theme\" height=\"200\" width=\"400\"></iframe></td>";
107 if ($CFG->theme == $theme) {
108 echo '<td valign="top" style="border-style:solid; border-width:1px; border-color=#555555">';
109 } else {
110 echo '<td valign="top">';
113 if (isset($THEME->sheets)) {
114 echo '<p style="font-size:1.5em;font-style:bold;">'.$theme.'</p>';
115 } else {
116 echo '<p style="font-size:1.5em;font-style:bold;color:red;">'.$theme.' (Moodle 1.4)</p>';
119 if ($screenshot or $readme) {
120 echo '<ul>';
121 if (!$USER->screenreader) {
122 echo "<li><a target=\"$theme\" href=\"preview.php?preview=$theme\">$strpreview</a></li>";
124 echo $screenshot.$readme;
125 echo '</ul>';
128 $options = null;
129 $options['choose'] = $theme;
130 $options['sesskey'] = $sesskey;
131 print_single_button('index.php', $options, $strchoose);
132 echo '</td>';
133 echo "</tr>";
135 echo "</table>";
138 admin_externalpage_print_footer($adminroot);