From: moodler Date: Sun, 30 Jan 2005 19:27:46 +0000 (+0000) Subject: New theme chooser (with better preview using iframes) X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=8ba55c01aef7d8ffb947d8c768c49661719ac191;p=moodle.git New theme chooser (with better preview using iframes) It's a bit rough but it works. --- diff --git a/theme/index.php b/theme/index.php index 03fd1b6014..e81c9fda1b 100644 --- a/theme/index.php +++ b/theme/index.php @@ -2,7 +2,6 @@ require_once("../config.php"); - $preview = optional_param("preview",'',PARAM_FILE); // which theme to show $choose = optional_param("choose",'',PARAM_FILE); // set this theme as default if (! $site = get_site()) { @@ -15,35 +14,26 @@ error("You must be an administrator to change themes."); } - if ($choose) { - if (!is_dir($choose)) { - error("This theme is not installed!"); - } - $preview = $choose; - } - - if ($preview and confirm_sesskey()) { - $CFG->theme = $preview; - $CFG->stylesheet = "$CFG->wwwroot/theme/$CFG->theme/styles.php?themename=$preview"; - $CFG->header = "$CFG->dirroot/theme/$CFG->theme/header.html"; - $CFG->footer = "$CFG->dirroot/theme/$CFG->theme/footer.html"; - include ("$CFG->theme/config.php"); - } + unset($SESSION->theme); $stradministration = get_string("administration"); $strconfiguration = get_string("configuration"); $strthemes = get_string("themes"); $strpreview = get_string("preview"); - $strsavechanges = get_string("savechanges"); + $strchoose = get_string("choose"); + $strinfo = get_string("info"); $strtheme = get_string("theme"); $strthemesaved = get_string("themesaved"); - print_header("$site->shortname: $strthemes", $site->fullname, - "wwwroot/$CFG->admin/index.php\">$stradministration -> ". - "wwwroot/$CFG->admin/configure.php\">$strconfiguration -> $strthemes"); if ($choose and confirm_sesskey()) { + if (!is_dir($choose)) { + error("This theme is not installed!"); + } if (set_config("theme", $choose)) { + print_header("$site->shortname: $strthemes", $site->fullname, + "wwwroot/$CFG->admin/index.php\">$stradministration -> ". + "wwwroot/$CFG->admin/configure.php\">$strconfiguration -> $strthemes"); print_heading(get_string("themesaved")); print_continue("$CFG->wwwroot/"); @@ -65,30 +55,44 @@ } } - print_heading(get_string("previeworchoose")); + print_header("$site->shortname: $strthemes", $site->fullname, + "wwwroot/$CFG->admin/index.php\">$stradministration -> ". + "wwwroot/$CFG->admin/configure.php\">$strconfiguration -> $strthemes"); + + + print_heading($strthemes); $themes = get_list_of_plugins("theme"); $sesskey = !empty($USER->id) ? $USER->sesskey : ''; echo ""; - echo ""; + echo ""; foreach ($themes as $theme) { if (!file_exists("$CFG->dirroot/theme/$theme/config.php")) { // bad folder continue; } - include ("$CFG->dirroot/theme/$theme/config.php"); echo ""; + echo ""; + if ($CFG->theme == $theme) { - echo ""; - echo ""; + echo '"; - echo ""; + echo ''; echo ""; } echo "
$strtheme 
$strtheme$strinfo
body\">$theme$strsavechanges'; } else { - echo "body\">"; - echo "$theme"; - echo " '; + } + echo "

$theme

"; + echo "

$strpreview

"; + + if (file_exists("$theme/README.html")) { + link_to_popup_window('/theme/'.$theme.'/README.html', $theme, $strinfo); + } else if (file_exists("$theme/README.txt")) { + link_to_popup_window('/theme/'.$theme.'/README.txt', $theme, $strinfo); + } + if ($CFG->theme != $theme) { + echo "

$strchoose

"; } + echo '
"; diff --git a/theme/preview.php b/theme/preview.php new file mode 100644 index 0000000000..08b7bd1a62 --- /dev/null +++ b/theme/preview.php @@ -0,0 +1,42 @@ +theme = $preview; + $CFG->header = "$CFG->dirroot/theme/$CFG->theme/header.html"; + $CFG->footer = "$CFG->dirroot/theme/$CFG->theme/footer.html"; + + print_header(); + $stradministration = get_string("administration"); + $strconfiguration = get_string("configuration"); + $strthemes = get_string("themes"); + $strpreview = get_string("preview"); + $strsavechanges = get_string("savechanges"); + $strtheme = get_string("theme"); + $strthemesaved = get_string("themesaved"); + + print_header("$site->shortname: $strpreview", $site->fullname, "$strthemes -> $strpreview"); + + print_simple_box_start('center', '80%'); + print_heading($preview); + print_simple_box_end(); + + print_footer(); + +?>