2009-07-01 05:54:26 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// This file is part of Moodle - http://moodle.org/
|
|
|
|
//
|
|
|
|
// Moodle is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Moodle is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This page prvides the Administration -> ... -> Theme selector UI.
|
|
|
|
*/
|
|
|
|
|
|
|
|
require_once(dirname(__FILE__) . '/../config.php');
|
|
|
|
require_once($CFG->libdir . '/adminlib.php');
|
|
|
|
|
2009-12-16 18:00:58 +00:00
|
|
|
$choose = optional_param('choose', '', PARAM_SAFEDIR);
|
|
|
|
$reset = optional_param('reset', 0, PARAM_BOOL);
|
2009-07-01 05:54:26 +00:00
|
|
|
|
|
|
|
admin_externalpage_setup('themeselector');
|
|
|
|
|
|
|
|
unset($SESSION->theme);
|
|
|
|
|
2009-12-16 18:00:58 +00:00
|
|
|
if ($reset and confirm_sesskey()) {
|
|
|
|
theme_reset_all_caches();
|
|
|
|
|
|
|
|
} else if ($choose and confirm_sesskey()) {
|
2009-07-01 05:54:26 +00:00
|
|
|
// The user has chosen one theme from the list of all themes, show a
|
|
|
|
// 'You have chosen a new theme' confirmation page.
|
|
|
|
|
2009-12-16 18:00:58 +00:00
|
|
|
$theme = theme_config::load($choose);
|
|
|
|
$choose = $theme->name;
|
2002-09-27 14:19:59 +00:00
|
|
|
|
2009-07-01 05:54:26 +00:00
|
|
|
set_config('theme', $choose);
|
2005-01-30 19:27:46 +00:00
|
|
|
|
2009-07-01 05:54:26 +00:00
|
|
|
admin_externalpage_print_header();
|
2009-08-06 08:25:18 +00:00
|
|
|
echo $OUTPUT->heading(get_string('themesaved'));
|
2005-01-30 19:27:46 +00:00
|
|
|
|
2009-12-16 18:00:58 +00:00
|
|
|
echo $OUTPUT->box_start();
|
|
|
|
$text = get_string('choosereadme', 'theme_'.$CFG->theme);
|
|
|
|
echo format_text($text, FORMAT_MOODLE);
|
|
|
|
echo $OUTPUT->box_end();
|
2002-09-27 14:19:59 +00:00
|
|
|
|
2009-08-18 05:19:44 +00:00
|
|
|
echo $OUTPUT->continue_button($CFG->wwwroot . '/' . $CFG->admin . '/index.php');
|
2007-07-25 12:34:21 +00:00
|
|
|
|
2009-08-06 14:25:44 +00:00
|
|
|
echo $OUTPUT->footer();
|
2009-07-01 05:54:26 +00:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise, show a list of themes.
|
|
|
|
admin_externalpage_print_header('themeselector');
|
2009-08-06 08:25:18 +00:00
|
|
|
echo $OUTPUT->heading(get_string('themes'));
|
2009-07-01 05:54:26 +00:00
|
|
|
|
2009-12-16 18:00:58 +00:00
|
|
|
echo $OUTPUT->button(html_form::make_button('index.php', array('sesskey'=>sesskey(),'reset'=>1), get_string('themeresetcaches', 'admin')));
|
|
|
|
|
2009-08-20 08:50:03 +00:00
|
|
|
$table = new html_table();
|
2009-07-01 05:54:26 +00:00
|
|
|
$table->id = 'adminthemeselector';
|
|
|
|
$table->head = array(get_string('theme'), get_string('info'));
|
|
|
|
|
|
|
|
$themes = get_plugin_list('theme');
|
2009-12-16 18:00:58 +00:00
|
|
|
|
2009-07-01 05:54:26 +00:00
|
|
|
foreach ($themes as $themename => $themedir) {
|
|
|
|
|
|
|
|
// Load the theme config.
|
|
|
|
try {
|
|
|
|
$theme = theme_config::load($themename);
|
2009-12-16 18:00:58 +00:00
|
|
|
} catch (Exception $e) {
|
2009-07-01 05:54:26 +00:00
|
|
|
// Bad theme, just skip it for now.
|
|
|
|
continue;
|
2007-02-07 07:34:53 +00:00
|
|
|
}
|
2009-12-16 18:00:58 +00:00
|
|
|
if ($themename !== $theme->name) {
|
|
|
|
//obsoleted or broken theme, just skip for now
|
|
|
|
continue;
|
|
|
|
}
|
2007-08-23 18:01:27 +00:00
|
|
|
|
2009-07-01 05:54:26 +00:00
|
|
|
// Build the table row, and also a list of items to go in the second cell.
|
|
|
|
$row = array();
|
|
|
|
$infoitems = array();
|
|
|
|
|
|
|
|
|
2009-12-16 18:00:58 +00:00
|
|
|
// link to the screenshot, now mandatory - the image path is hardcoded because we need image from other themes, not the current one
|
|
|
|
$screenshotpath = "$CFG->wwwroot/theme/image.php?theme=$themename&image=screenshot&component=theme";
|
2002-09-27 14:19:59 +00:00
|
|
|
|
2009-07-01 05:54:26 +00:00
|
|
|
// Contents of the first screenshot/preview cell.
|
2009-12-16 18:00:58 +00:00
|
|
|
$row[] = "<img src=\"$screenshotpath\" alt=\"$themename\" />";
|
2009-07-01 05:54:26 +00:00
|
|
|
|
|
|
|
// Contents of the second cell.
|
|
|
|
$infocell = $OUTPUT->heading($themename, 3);
|
|
|
|
if ($themename != $CFG->theme) {
|
2009-12-16 18:00:58 +00:00
|
|
|
$infocell .= $OUTPUT->button(html_form::make_button('index.php', array('choose' => $themename, 'sesskey' => sesskey()), get_string('choose'), 'get'));
|
2009-08-10 05:49:57 +00:00
|
|
|
|
2009-07-01 05:54:26 +00:00
|
|
|
}
|
|
|
|
$row[] = $infocell;
|
|
|
|
|
|
|
|
$table->data[$themename] = $row;
|
|
|
|
if ($themename == $CFG->theme) {
|
2009-07-15 05:37:31 +00:00
|
|
|
$table->rowclasses[$themename] = 'selectedtheme';
|
2009-07-01 05:54:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-20 08:50:03 +00:00
|
|
|
echo $OUTPUT->table($table);
|
2009-07-01 05:54:26 +00:00
|
|
|
|
2009-08-06 14:25:44 +00:00
|
|
|
echo $OUTPUT->footer();
|
2009-12-16 18:00:58 +00:00
|
|
|
|