foreach ($devices as $thedevice) { $headingthemename = ''; // To output the picked theme name when needed. $themename = core_useragent::get_device_type_theme($thedevice); if (!$themename && $thedevice == 'default') { $themename = theme_config::DEFAULT_THEME; } $themelocked = theme_is_device_locked($thedevice); $screenshotcell = $strthemenotselected; $unsetthemebutton = ''; if ($themename) { // Check the theme exists. $themename = clean_param($themename, PARAM_THEME); if (empty($themename)) { // Likely the theme has been deleted. unset_config(core_useragent::get_device_type_cfg_var_name($thedevice)); } else { $strthemename = get_string('pluginname', 'theme_' . $themename); // Link to the screenshot, now mandatory - the image path is hardcoded because we need image from other themes, // not the current one. $screenshoturl = new moodle_url('/theme/image.php', array('theme' => $themename, 'image' => 'screenshot', 'component' => 'theme')); // Contents of the screenshot/preview cell. $screenshotcell = html_writer::empty_tag('img', array('src' => $screenshoturl, 'alt' => $strthemename)); // Show the name of the picked theme. $headingthemename = $OUTPUT->heading($strthemename, 3); } // If not default device then show option to unset theme. if ($thedevice != 'default' && !$themelocked) { $unsetthemestr = get_string('unsettheme', 'admin'); $unsetthemeurl = new moodle_url('/theme/index.php', array('device' => $thedevice, 'sesskey' => sesskey(), 'unsettheme' => true)); $unsetthemebutton = new single_button($unsetthemeurl, $unsetthemestr, 'get');
/** * Returns the theme named defined in config.php for the given device. * * @return string or null */ function theme_get_locked_theme_for_device($device) { global $CFG; if (!theme_is_device_locked($device)) { return null; } $themeconfigname = core_useragent::get_device_type_cfg_var_name($device); return $CFG->config_php_settings[$themeconfigname]; }
/** * Returns the name of the device type theme var in $CFG because there is not a convention to allow backwards compatibility. * * @deprecated since 2.6 * @param string $devicetype * @return string The config variable to use to determine the theme */ function get_device_cfg_var_name($devicetype = null) { debugging('get_device_cfg_var_name has been deprecated, please update your code to use core_useragent instead.', DEBUG_DEVELOPER); return core_useragent::get_device_type_cfg_var_name($devicetype); }
public function execute() { global $DB, $CFG; //some variables you may want to use //$this->cwd - the directory where moosh command was executed //$this->mooshDir - moosh installation directory //$this->expandedOptions - commandline provided options, merged with defaults //$this->topDir - top Moodle directory //$this->arguments[0] - first argument passed //$options = $this->expandedOptions; //get curse themes if ($CFG->allowcoursethemes) { echo "Course theme overrides enabled\n"; } else { echo "Course theme overrides disabled\n"; } $results = $DB->get_records_sql("SELECT theme, COUNT(*) AS n FROM {course} WHERE theme <> '' GROUP BY theme"); if ($results) { echo "name\ttimes used\n"; foreach ($results as $result) { echo $result->theme . "\t" . $result->n . "\n"; } } else { echo "No theme overrides on the course level\n"; } echo "\n"; //get category themes if ($CFG->allowcategorythemes) { echo "Category theme overrides enabled\n"; } else { echo "Category theme overrides disabled\n"; } $results = $DB->get_records_sql("SELECT theme, COUNT(*) AS n FROM {course_categories} WHERE theme <> '' GROUP BY theme"); if ($results) { echo "name\ttimes used\n"; foreach ($results as $result) { echo $result->theme . "\t" . $result->n . "\n"; } } else { echo "No theme overrides on the category level\n"; } echo "\n"; //get user themes if ($CFG->allowcategorythemes) { echo "User theme overrides enabled\n"; } else { echo "User theme overrides disabled\n"; } $results = $DB->get_records_sql("SELECT theme, COUNT(*) AS n FROM {user} WHERE theme <> '' GROUP BY theme"); if ($results) { echo "name\ttimes used\n"; foreach ($results as $result) { echo $result->theme . "\t" . $result->n . "\n"; } } else { echo "No theme overrides on the user level\n"; } //site themes $devices = \core_useragent::get_device_type_list(); echo "\nSite themes:\n"; foreach ($devices as $device) { echo "{$device}: "; $themename = \core_useragent::get_device_type_cfg_var_name($device); if (isset($CFG->{$themename})) { echo $CFG->{$themename} . "\n"; } else { echo "<not set>\n"; } } }