Beispiel #1
0
/**
 * Returns the theme selected for a particular device or false if none selected.
 *
 * @param string $devicetype
 * @return string|false The name of the theme to use for the device or the false if not set
 */
function get_selected_theme_for_device_type($devicetype = null) {
    global $CFG;

    if (empty($devicetype)) {
        $devicetype = get_user_device_type();
    }

    $themevarname = get_device_cfg_var_name($devicetype);
    if (empty($CFG->$themevarname)) {
        return false;
    }

    return $CFG->$themevarname;
}
Beispiel #2
0
    foreach ($devices as $thedevice) {

        $headingthemename = ''; // To output the picked theme name when needed
        $themename = get_selected_theme_for_device_type($thedevice);
        if (!$themename && $thedevice == 'default') {
            $themename = theme_config::DEFAULT_THEME;
        }

        $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(get_device_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') {
                $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');
                $unsetthemebutton = $OUTPUT->render($unsetthemebutton);
Beispiel #3
0
 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 = get_device_type_list();
     echo "\nSite themes:\n";
     foreach ($devices as $device) {
         echo "{$device}: ";
         $themename = get_device_cfg_var_name($device);
         if (isset($CFG->{$themename})) {
             echo $CFG->{$themename} . "\n";
         } else {
             echo "<not set>\n";
         }
     }
 }