示例#1
0
/**
 * Allows the user to switch the device they are seeing the theme for.
 * This allows mobile users to switch back to the default theme, or theme for any other device.
 *
 * @param string $newdevice The device the user is currently using.
 * @return string The device the user has switched to
 */
function set_user_device_type($newdevice) {
    global $USER;

    $devicetype = get_device_type();
    $devicetypes = get_device_type_list();

    if ($newdevice == $devicetype) {
        unset_user_preference('switchdevice'.$devicetype);
    } else if (in_array($newdevice, $devicetypes)) {
        set_user_preference('switchdevice'.$devicetype, $newdevice);
    }
}
示例#2
0
文件: index.php 项目: verbazend/AWFA
$table = new html_table();
$table->data = array();
$heading = '';
if (!empty($CFG->enabledevicedetection) && empty($device)) {
    $heading = get_string('selectdevice', 'admin');
    // Display a list of devices that a user can select a theme for.

    $strthemenotselected = get_string('themenoselected', 'admin');
    $strthemeselect = get_string('themeselect', 'admin');

    // Display the device selection screen
    $table->id = 'admindeviceselector';
    $table->head = array(get_string('devicetype', 'admin'), get_string('currenttheme', 'admin'), get_string('info'));

    $devices = get_device_type_list();
    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
示例#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";
         }
     }
 }