Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403]

   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  /**
  18   * Classic theme settings file.
  19   *
  20   * @package    theme_classic
  21   * @copyright  2018 Bas Brands
  22   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  defined('MOODLE_INTERNAL') || die;
  25  
  26  if ($ADMIN->fulltree) {
  27  
  28      $settings = new theme_boost_admin_settingspage_tabs('themesettingclassic', get_string('configtitle', 'theme_classic'));
  29      $page = new admin_settingpage('theme_classic_general', get_string('generalsettings', 'theme_boost'));
  30  
  31      $name = 'theme_classic/navbardark';
  32      $title = get_string('navbardark', 'theme_classic');
  33      $description = get_string('navbardarkdesc', 'theme_classic');
  34      $setting = new admin_setting_configcheckbox($name, $title, $description, 0);
  35      $setting->set_updatedcallback('theme_reset_all_caches');
  36      $page->add($setting);
  37  
  38      // Preset.
  39      $name = 'theme_classic/preset';
  40      $title = get_string('preset', 'theme_classic');
  41      $description = get_string('preset_desc', 'theme_classic');
  42      $default = 'default.scss';
  43  
  44      $context = context_system::instance();
  45      $fs = get_file_storage();
  46      $files = $fs->get_area_files($context->id, 'theme_classic', 'preset', 0, 'itemid, filepath, filename', false);
  47  
  48      $choices = [];
  49      foreach ($files as $file) {
  50          $choices[$file->get_filename()] = $file->get_filename();
  51      }
  52  
  53      // These are the built in presets.
  54      $choices['default.scss'] = 'default.scss';
  55      $choices['plain.scss'] = 'plain.scss';
  56  
  57      $setting = new admin_setting_configthemepreset($name, $title, $description, $default, $choices, 'classic');
  58      $setting->set_updatedcallback('theme_reset_all_caches');
  59      $page->add($setting);
  60  
  61      // Preset files setting.
  62      $name = 'theme_classic/presetfiles';
  63      $title = get_string('presetfiles', 'theme_classic');
  64      $description = get_string('presetfiles_desc', 'theme_classic');
  65  
  66      $setting = new admin_setting_configstoredfile($name, $title, $description, 'preset', 0,
  67          array('maxfiles' => 20, 'accepted_types' => array('.scss')));
  68      $page->add($setting);
  69  
  70      // Background image setting.
  71      $name = 'theme_classic/backgroundimage';
  72      $title = get_string('backgroundimage', 'theme_boost');
  73      $description = get_string('backgroundimage_desc', 'theme_boost');
  74      $setting = new admin_setting_configstoredfile($name, $title, $description, 'backgroundimage');
  75      $setting->set_updatedcallback('theme_reset_all_caches');
  76      $page->add($setting);
  77  
  78      // Variable $body-color.
  79      // We use an empty default value because the default colour should come from the preset.
  80      $name = 'theme_classic/brandcolor';
  81      $title = get_string('brandcolor', 'theme_boost');
  82      $description = get_string('brandcolor_desc', 'theme_boost');
  83      $setting = new admin_setting_configcolourpicker($name, $title, $description, '');
  84      $setting->set_updatedcallback('theme_reset_all_caches');
  85      $page->add($setting);
  86  
  87      // Must add the page after definiting all the settings!
  88      $settings->add($page);
  89  
  90      // Advanced settings.
  91      $page = new admin_settingpage('theme_classic_advanced', get_string('advancedsettings', 'theme_boost'));
  92  
  93      // Raw SCSS to include before the content.
  94      $setting = new admin_setting_scsscode('theme_classic/scsspre',
  95          get_string('rawscsspre', 'theme_boost'), get_string('rawscsspre_desc', 'theme_boost'), '', PARAM_RAW);
  96      $setting->set_updatedcallback('theme_reset_all_caches');
  97      $page->add($setting);
  98  
  99      // Raw SCSS to include after the content.
 100      $setting = new admin_setting_scsscode('theme_classic/scss', get_string('rawscss', 'theme_boost'),
 101          get_string('rawscss_desc', 'theme_boost'), '', PARAM_RAW);
 102      $setting->set_updatedcallback('theme_reset_all_caches');
 103      $page->add($setting);
 104  
 105      $settings->add($page);
 106  }