MDL-10092:
[moodle-linuxchix.git] / theme / index.php
blobd38dc6f436a1ddf8958d4a1896da000c4440d646
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 admin_externalpage_setup('themeselector');
10 unset($SESSION->theme);
12 $stradministration = get_string("administration");
13 $strconfiguration = get_string("configuration");
14 $strthemes = get_string("themes");
15 $strpreview = get_string("preview");
16 $strchoose = get_string("choose");
17 $strinfo = get_string("info");
18 $strtheme = get_string("theme");
19 $strthemesaved = get_string("themesaved");
20 $strscreenshot = get_string("screenshot");
21 $stroldtheme = get_string("oldtheme");
24 if ($choose and confirm_sesskey()) {
25 if (!is_dir($CFG->themedir .'/'. $choose)) {
26 error("This theme is not installed!");
28 if (set_config("theme", $choose)) {
29 theme_setup($choose);
30 admin_externalpage_print_header();
31 print_heading(get_string("themesaved"));
32 print_continue("$CFG->wwwroot/");
34 if (file_exists("$choose/README.html")) {
35 print_simple_box_start("center");
36 readfile("$choose/README.html");
37 print_simple_box_end();
39 } else if (file_exists("$choose/README.txt")) {
40 print_simple_box_start("center");
41 $file = file("$choose/README.txt");
42 echo format_text(implode('', $file), FORMAT_MOODLE);
43 print_simple_box_end();
45 admin_externalpage_print_footer();
46 exit;
47 } else {
48 error("Could not set the theme!");
52 admin_externalpage_print_header('themeselector');
55 print_heading($strthemes);
57 $themes = get_list_of_plugins("theme");
58 $sesskey = !empty($USER->id) ? $USER->sesskey : '';
60 echo "<table style=\"margin-left:auto;margin-right:auto;\" cellpadding=\"7\" cellspacing=\"5\">\n";
62 if (!$USER->screenreader) {
63 echo "\t<tr class=\"generaltableheader\">\n\t\t<th scope=\"col\">$strtheme</th>\n";
64 echo "\t\t<th scope=\"col\">$strinfo</th>\n\t</tr>\n";
67 $original_theme = fullclone($THEME);
69 foreach ($themes as $theme) {
71 unset($THEME);
73 if (!file_exists($CFG->themedir.'/'.$theme.'/config.php')) { // bad folder
74 continue;
77 include($CFG->themedir.'/'.$theme.'/config.php');
79 $readme = '';
80 $screenshot = '';
81 $screenshotpath = '';
83 if (file_exists("$theme/README.html")) {
84 $readme = "\t\t\t\t<li>".
85 link_to_popup_window($CFG->themewww .'/'. $theme .'/README.html', $theme, $strinfo, 400, 500, '', 'none', true)."</li>\n";
86 } else if (file_exists("$theme/README.txt")) {
87 $readme = "\t\t\t\t<li>".
88 link_to_popup_window($CFG->themewww .'/'. $theme .'/README.txt', $theme, $strinfo, 400, 500, '', 'none', true)."</li>\n";
90 if (file_exists("$theme/screenshot.png")) {
91 $screenshotpath = "$theme/screenshot.png";
92 } else if (file_exists("$theme/screenshot.jpg")) {
93 $screenshotpath = "$theme/screenshot.jpg";
96 echo "\t<tr>\n";
98 // no point showing this if user is using screen reader
99 if (!$USER->screenreader) {
100 echo "\t\t<td align=\"center\">\n";
101 if ($screenshotpath) {
102 $screenshot = "\t\t\t\t<li><a href=\"$theme/screenshot.jpg\">$strscreenshot</a></li>\n";
103 echo "\t\t\t<object type=\"text/html\" data=\"$screenshotpath\" height=\"200\" width=\"400\">$theme</object>\n\t\t</td>\n";
104 } else {
105 echo "\t\t\t<object type=\"text/html\" data=\"preview.php?preview=$theme\" height=\"200\" width=\"400\">$theme</object>\n\t\t</td>\n";
109 if ($CFG->theme == $theme) {
110 echo "\t\t" . '<td valign="top" style="border-style:solid; border-width:1px; border-color=#555555">'."\n";
111 } else {
112 echo "\t\t" . '<td valign="top">'."\n";
115 if (isset($THEME->sheets)) {
116 echo "\t\t\t" . '<p style="font-size:1.5em;font-style:bold;">'.$theme.'</p>'."\n";
117 } else {
118 echo "\t\t\t" . '<p style="font-size:1.5em;font-style:bold;color:red;">'.$theme.' (Moodle 1.4)</p>'."\n";
121 if ($screenshot or $readme) {
122 echo "\t\t\t<ul>\n";
123 if (!$USER->screenreader) {
124 echo "\t\t\t\t<li><a href=\"preview.php?preview=$theme\">$strpreview</a></li>\n";
126 echo $screenshot.$readme;
127 echo "\t\t\t</ul>\n";
130 $options = null;
131 $options['choose'] = $theme;
132 $options['sesskey'] = $sesskey;
133 echo "\t\t\t" . print_single_button('index.php', $options, $strchoose, 'get', null, true) . "\n";
134 echo "\t\t</td>\n";
135 echo "\t</tr>\n";
137 echo "</table>\n";
139 $THEME = $original_theme;
141 admin_externalpage_print_footer();