Added LinuxChix theme
[moodle-linuxchix.git] / theme / index.php
blob8ef5e4cecbdfbca90ccbec91b02d75f539d117d1
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"));
33 if (file_exists("$choose/README.html")) {
34 print_simple_box_start("center");
35 readfile("$choose/README.html");
36 print_simple_box_end();
38 } else if (file_exists("$choose/README.txt")) {
39 print_simple_box_start("center");
40 $file = file("$choose/README.txt");
41 echo format_text(implode('', $file), FORMAT_MOODLE);
42 print_simple_box_end();
45 print_continue("$CFG->wwwroot/");
47 admin_externalpage_print_footer();
48 exit;
49 } else {
50 error("Could not set the theme!");
54 admin_externalpage_print_header('themeselector');
57 print_heading($strthemes);
59 $themes = get_list_of_plugins("theme");
60 $sesskey = !empty($USER->id) ? $USER->sesskey : '';
62 echo "<table style=\"margin-left:auto;margin-right:auto;\" cellpadding=\"7\" cellspacing=\"5\">\n";
64 if (!$USER->screenreader) {
65 echo "\t<tr class=\"generaltableheader\">\n\t\t<th scope=\"col\">$strtheme</th>\n";
66 echo "\t\t<th scope=\"col\">$strinfo</th>\n\t</tr>\n";
69 $original_theme = fullclone($THEME);
71 foreach ($themes as $theme) {
73 unset($THEME);
75 if (!file_exists($CFG->themedir.'/'.$theme.'/config.php')) { // bad folder
76 continue;
79 include($CFG->themedir.'/'.$theme.'/config.php');
81 $readme = '';
82 $screenshot = '';
83 $screenshotpath = '';
85 if (file_exists("$theme/README.html")) {
86 $readme = "\t\t\t\t<li>".
87 link_to_popup_window($CFG->themewww .'/'. $theme .'/README.html', $theme, $strinfo, 400, 500, '', 'none', true)."</li>\n";
88 } else if (file_exists("$theme/README.txt")) {
89 $readme = "\t\t\t\t<li>".
90 link_to_popup_window($CFG->themewww .'/'. $theme .'/README.txt', $theme, $strinfo, 400, 500, '', 'none', true)."</li>\n";
92 if (file_exists("$theme/screenshot.png")) {
93 $screenshotpath = "$theme/screenshot.png";
94 } else if (file_exists("$theme/screenshot.jpg")) {
95 $screenshotpath = "$theme/screenshot.jpg";
98 echo "\t<tr>\n";
100 // no point showing this if user is using screen reader
101 if (!$USER->screenreader) {
102 echo "\t\t<td align=\"center\">\n";
103 if ($screenshotpath) {
104 $screenshot = "\t\t\t\t<li><a href=\"$theme/screenshot.jpg\">$strscreenshot</a></li>\n";
105 echo "\t\t\t<object type=\"text/html\" data=\"$screenshotpath\" height=\"200\" width=\"400\">$theme</object>\n\t\t</td>\n";
106 } else {
107 echo "\t\t\t<object type=\"text/html\" data=\"preview.php?preview=$theme\" height=\"200\" width=\"400\">$theme</object>\n\t\t</td>\n";
111 if ($CFG->theme == $theme) {
112 echo "\t\t" . '<td valign="top" style="border-style:solid; border-width:1px; border-color:#555555">'."\n";
113 } else {
114 echo "\t\t" . '<td valign="top">'."\n";
117 if (isset($THEME->sheets)) {
118 echo "\t\t\t" . '<p style="font-size:1.5em;font-weight:bold;">'.$theme.'</p>'."\n";
119 } else {
120 echo "\t\t\t" . '<p style="font-size:1.5em;font-weight:bold;color:red;">'.$theme.' (Moodle 1.4)</p>'."\n";
123 if ($screenshot or $readme) {
124 echo "\t\t\t<ul>\n";
125 if (!$USER->screenreader) {
126 echo "\t\t\t\t<li><a href=\"preview.php?preview=$theme\">$strpreview</a></li>\n";
128 echo $screenshot.$readme;
129 echo "\t\t\t</ul>\n";
132 $options = null;
133 $options['choose'] = $theme;
134 $options['sesskey'] = $sesskey;
135 echo "\t\t\t" . print_single_button('index.php', $options, $strchoose, 'get', null, true) . "\n";
136 echo "\t\t</td>\n";
137 echo "\t</tr>\n";
139 echo "</table>\n";
141 $THEME = $original_theme;
143 admin_externalpage_print_footer();