continue; } if (empty($CFG->themedesignermode) && $theme->hidefromselector) { // The theme doesn't want to be shown in the theme selector and as theme // designer mode is switched off we will respect that decision. continue; } $strthemename = get_string('pluginname', 'theme_'.$themename); // Build the table row, and also a list of items to go in the second cell. $row = array(); $infoitems = array(); $rowclasses = array(); // Set up bools whether this theme is chosen either main or legacy $ischosentheme = ($themename == get_selected_theme_for_device_type($device)); if ($ischosentheme) { // Is the chosen main theme $rowclasses[] = 'selectedtheme'; } // link to the screenshot, now mandatory - the image path is hardcoded because we need image from other themes, not the current one $screenshotpath = new moodle_url('/theme/image.php', array('theme'=>$themename, 'image'=>'screenshot', 'component'=>'theme')); // Contents of the first screenshot/preview cell. $row[] = html_writer::empty_tag('img', array('src'=>$screenshotpath, 'alt'=>$strthemename)); // Contents of the second cell. $infocell = $OUTPUT->heading($strthemename, 3); // Button to choose this as the main theme or unset this theme for // devices other then default
/** * Work out the theme this page should use. * * This depends on numerous $CFG settings, and the properties of this page. * * @return string the name of the theme that should be used on this page. */ protected function resolve_theme() { global $CFG, $USER, $SESSION; if (empty($CFG->themeorder)) { $themeorder = array('course', 'category', 'session', 'user', 'site'); } else { $themeorder = $CFG->themeorder; // Just in case, make sure we always use the site theme if nothing else matched. $themeorder[] = 'site'; } $mnetpeertheme = ''; if (isloggedin() and isset($CFG->mnet_localhost_id) and $USER->mnethostid != $CFG->mnet_localhost_id) { require_once($CFG->dirroot.'/mnet/peer.php'); $mnetpeer = new mnet_peer(); $mnetpeer->set_id($USER->mnethostid); if ($mnetpeer->force_theme == 1 && $mnetpeer->theme != '') { $mnetpeertheme = $mnetpeer->theme; } } foreach ($themeorder as $themetype) { switch ($themetype) { case 'course': if (!empty($CFG->allowcoursethemes) && !empty($this->_course->theme) && $this->devicetypeinuse == 'default') { return $this->_course->theme; } case 'category': if (!empty($CFG->allowcategorythemes) && $this->devicetypeinuse == 'default') { $categories = $this->categories; foreach ($categories as $category) { if (!empty($category->theme)) { return $category->theme; } } } case 'session': if (!empty($SESSION->theme)) { return $SESSION->theme; } case 'user': if (!empty($CFG->allowuserthemes) && !empty($USER->theme) && $this->devicetypeinuse == 'default') { if ($mnetpeertheme) { return $mnetpeertheme; } else { return $USER->theme; } } case 'site': if ($mnetpeertheme) { return $mnetpeertheme; } // First try for the device the user is using. $devicetheme = get_selected_theme_for_device_type($this->devicetypeinuse); if (!empty($devicetheme)) { return $devicetheme; } // Next try for the default device (as a fallback) $devicetheme = get_selected_theme_for_device_type('default'); if (!empty($devicetheme)) { return $devicetheme; } // The default device theme isn't set up - use the overall default theme. return theme_config::DEFAULT_THEME; } } }