From 7c70229eba0fa9df79a39c4754c8385fb06dfa8a Mon Sep 17 00:00:00 2001 From: David Mudrak Date: Mon, 12 Jul 2010 15:03:42 +0000 Subject: [PATCH] MDL-21137 MNet: UI to choose peer theme replaced with simple selector There is no need to have whole featured theme selector with previews etc here. Following the same form element as they have in Mahara, the theme can now be selected for a given peer at 'Review host details' tab. I have also noticed that force_theme and theme columns are redundant at the moment. Keeping them both for future improvements, though. --- admin/mnet/mnet_themes.html | 122 ------------------------------------ admin/mnet/mnet_themes.php | 77 ----------------------- admin/mnet/peer_forms.php | 7 +++ admin/mnet/peers.php | 8 +++ admin/mnet/tabs.php | 2 - lang/en/mnet.php | 1 - 6 files changed, 15 insertions(+), 202 deletions(-) delete mode 100644 admin/mnet/mnet_themes.html delete mode 100644 admin/mnet/mnet_themes.php diff --git a/admin/mnet/mnet_themes.html b/admin/mnet/mnet_themes.html deleted file mode 100644 index 11701645594..00000000000 --- a/admin/mnet/mnet_themes.html +++ /dev/null @@ -1,122 +0,0 @@ -header(); -echo $OUTPUT->heading(get_string('themes')); -$original_theme = fullclone($THEME); - $currenttab = 'mnetthemes'; - require_once($CFG->dirroot .'/'.$CFG->admin.'/mnet/tabs.php'); - - $themes = get_list_of_plugins("theme"); - $sesskey = sesskey(); - - echo ''; - - if (count($report)) { - echo ''; - echo ''; - echo ''; - } - - if (!$USER->screenreader) { - echo ""; - echo ""; - } - - echo ""; - echo ''; - if ($mnet_peer->theme == '') { - echo ''; - echo ""; - - foreach ($themes as $theme) { - - unset($THEME); - - if (!file_exists($CFG->themedir.'/'.$theme.'/config.php')) { // bad folder - continue; - } - - include($CFG->themedir.'/'.$theme.'/config.php'); - - $readme = ''; - $screenshot = ''; - $screenshotpath = ''; - - if (file_exists($CFG->themedir.'/'.$theme.'/README.html')) { - $readme = '
  • '. - $link = $CFG->themewww .'/'. $theme .'/README.html'; - $action = new popup_action('click', $link, $theme, array('height' => 400, 'width' => 500)); - echo $OUTPUT->action_link($link, strinfo, $action); - } else if (file_exists($CFG->themedir.'/'.$theme.'/README.txt')) { - $readme = '
  • '. - $link = $CFG->themewww .'/'. $theme .'/README.txt'; - $action = new popup_action('click', $link, $theme, array('height' => 400, 'width' => 500)); - echo $OUTPUT->action_link($link, $strinfo, $action); - } - if (file_exists("$theme/screenshot.png")) { - $screenshotpath = "$theme/screenshot.png"; - } else if (file_exists("$theme/screenshot.jpg")) { - $screenshotpath = "$theme/screenshot.jpg"; - } - - echo "
  • "; - - // no point showing this if user is using screen reader - if (!$USER->screenreader) { - echo ""; - } else { - echo ''.$theme.''; - } - } - - if ($mnet_peer->theme == $theme) { - echo ''; - echo ""; - } - echo "
    '; - echo ''.$report[0].''; - echo '
    $strtheme$strinfo
    Choose this option to use your site\'s default theme: '.$CFG->theme.'.'; - } else { - echo ''; - } - echo '

    Site Theme

    '; - $options = null; - $options['choose'] = $unlikely_name;// Something unlikely to ever be a theme name... initially $unlikely_name = 'ZoqZoqZ'; - $options['sesskey'] = $sesskey; - $options['hostid'] = $mnet_peer->id; - echo $OUTPUT->single_button(new moodle_url('mnet_themes.php', $options), $strchoose); - echo '
    "; - if ($screenshotpath) { - $screenshot = '
  • '.$strscreenshot.'
  • '; - echo "$theme
    '; - } else { - echo ''; - } - - if (isset($THEME->sheets)) { - echo '

    '.$theme.'

    '; - } else { - echo '

    '.$theme.' (Moodle 1.4)

    '; - } - - if ($screenshot or $readme) { - echo '
      '; - if (!$USER->screenreader) { - echo '
    • '.$strpreview.'
    • '; - } - echo $screenshot.$readme; - echo '
    '; - } - - $options = null; - $options['choose'] = $theme; - $options['sesskey'] = $sesskey; - $options['hostid'] = $mnet_peer->id; - echo $OUTPUT->single_button(new moodle_url('mnet_themes.php', $options), $strchoose); - echo '
    "; - -$THEME = $original_theme; -echo $OUTPUT->footer(); - diff --git a/admin/mnet/mnet_themes.php b/admin/mnet/mnet_themes.php deleted file mode 100644 index 9d1cf87dd59..00000000000 --- a/admin/mnet/mnet_themes.php +++ /dev/null @@ -1,77 +0,0 @@ -libdir.'/adminlib.php'); - include_once($CFG->dirroot.'/mnet/lib.php'); - require_login(); - admin_externalpage_setup('mnetpeers'); - - $context = get_context_instance(CONTEXT_SYSTEM); - - require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions"); - - $site = get_site(); - -/// Initialize variables. - - $hostid = required_param('hostid', PARAM_INT); - - $stradministration = get_string('administration'); - $strconfiguration = get_string('configuration'); - - $strmnetedithost = get_string('reviewhostdetails', 'mnet'); - $strmnetsettings = get_string('mnetsettings', 'mnet'); - $strmnetservices = get_string('mnetservices', 'mnet'); - $strmnetthemes = get_string('mnetthemes', 'mnet'); - $strmnetlog = get_string('mnetlog', 'mnet'); - - - $mnet_peer = new mnet_peer(); - if (is_int($hostid)) { - $mnet_peer->set_id($hostid); - } - - $choose = optional_param("choose",'',PARAM_FILE); // set this theme as default - $stradministration = get_string("administration"); - $strconfiguration = get_string("configuration"); - $strthemes = get_string("themes"); - $strpreview = get_string("preview"); - $strchoose = get_string("choose"); - $strinfo = get_string("info"); - $strtheme = get_string("theme"); - $strthemesaved = get_string("themesaved"); - $strscreenshot = get_string("screenshot"); - $stroldtheme = get_string("oldtheme"); - $report = array(); - $unlikely_name = 'ZoqZoqZ'; // Something unlikely to ever be a theme name - - if ($choose) { - if (confirm_sesskey()) { - if ($choose == $unlikely_name) { - $mnet_peer->force_theme = 1; - $mnet_peer->theme = ''; - if ($mnet_peer->commit()) { - $report = array(get_string('themesaved'), 'informationbox'); - } else { - $report = array(get_string('themesavederror', 'mnet'), 'errorbox'); - } - } elseif (!is_dir($CFG->themedir .'/'. $choose) || !file_exists($CFG->themedir .'/'. $choose .'/config.php')) { - echo 'CHOOSE -'.$choose.' '. $CFG->themedir .'/'. $choose .'/config.php' ; - $report = array('This theme is not installed!'.'3', 'errorbox'); - } else { - $mnet_peer->force_theme = 1; - $mnet_peer->theme = $choose; - if ($mnet_peer->commit()) { - $report = array(get_string('themesaved').'1', 'informationbox'); - } else { - $report = array(get_string('themesavederror', 'mnet').'2', 'errorbox'); - } - } - } - } - $adminroot = admin_get_root(); - require('./mnet_themes.html'); diff --git a/admin/mnet/peer_forms.php b/admin/mnet/peer_forms.php index 722e3a3d07f..c34a7188961 100644 --- a/admin/mnet/peer_forms.php +++ b/admin/mnet/peer_forms.php @@ -86,6 +86,13 @@ class mnet_review_host_form extends moodleform { $mform->addElement('text', 'wwwroot', get_string('hostname', 'mnet')); $mform->setType('wwwroot', PARAM_URL); + + $themes = array('' => get_string('forceno')); + foreach (array_keys(get_plugin_list('theme')) as $themename) { + $themes[$themename] = get_string('pluginname', 'theme_'.$themename); + } + $mform->addElement('select', 'theme', get_string('forcetheme'), $themes); + $mform->addElement('textarea', 'public_key', get_string('publickey', 'mnet'), array('rows' => 17, 'cols' => 100, 'class' => 'smalltext')); $mform->setType('public_key', PARAM_PEM); diff --git a/admin/mnet/peers.php b/admin/mnet/peers.php index c65f03d81d8..75a03f93cdb 100644 --- a/admin/mnet/peers.php +++ b/admin/mnet/peers.php @@ -159,6 +159,14 @@ if ($formdata = $reviewform->get_data()) { $mnet_peer->set_name($formdata->name); } + if (empty($formdata->theme)) { + $mnet_peer->force_theme = 0; + $mnet_peer->theme = null; + } else { + $mnet_peer->force_theme = 1; + $mnet_peer->theme = $formdata->theme; + } + $mnet_peer->updateparams->deleted = $formdata->deleted; $oldkey = $mnet_peer->public_key; $mnet_peer->public_key = $formdata->public_key; diff --git a/admin/mnet/tabs.php b/admin/mnet/tabs.php index 3548c2d24f2..8648895352e 100644 --- a/admin/mnet/tabs.php +++ b/admin/mnet/tabs.php @@ -35,7 +35,6 @@ if (!defined('MOODLE_INTERNAL')) { $strmnetservices = get_string('mnetservices', 'mnet'); $strmnetlog = get_string('mnetlog', 'mnet'); $strmnetedithost = get_string('reviewhostdetails', 'mnet'); -$strmnetthemes = get_string('mnetthemes', 'mnet'); $logurl = $CFG->wwwroot. '/course/report/log/index.php?chooselog=1&showusers=1&showcourses=1&host_course='.$mnet_peer->id. @@ -46,7 +45,6 @@ $tabs = array(); if (isset($mnet_peer->id) && $mnet_peer->id > 0) { $tabs[] = new tabobject('mnetdetails', 'peers.php?step=update&hostid='.$mnet_peer->id, $strmnetedithost, $strmnetedithost, false); $tabs[] = new tabobject('mnetservices', 'services.php?hostid='.$mnet_peer->id, $strmnetservices, $strmnetservices, false); - $tabs[] = new tabobject('mnetthemes', 'mnet_themes.php?step=list&hostid='.$mnet_peer->id, $strmnetthemes, $strmnetthemes, false); if ($mnet_peer->application->name == 'moodle' && $mnet_peer->id != $CFG->mnet_all_hosts_id) { $tabs[] = new tabobject('mnetlog', $logurl, $strmnetlog, $strmnetlog, false); } diff --git a/lang/en/mnet.php b/lang/en/mnet.php index aa98b3d4090..5412586a2a0 100644 --- a/lang/en/mnet.php +++ b/lang/en/mnet.php @@ -145,7 +145,6 @@ $string['mnetpeers'] = 'Peers'; $string['mnetservices'] = 'Services'; $string['mnet_session_prohibited'] = 'Users from your home server are not currently permitted to roam to {$a}.'; $string['mnetsettings'] = 'Moodle network settings'; -$string['mnetthemes'] = 'Themes'; $string['moodle_home_help'] = 'The path to the homepage of Moodle on the remote host, e.g. /moodle/.'; $string['moodleloc'] = 'Moodle location'; $string['name'] = 'Name';