Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401]

   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   * @package   theme_boost
  19   * @copyright 2016 Ryan Wyllie
  20   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  21   */
  22  
  23  defined('MOODLE_INTERNAL') || die();
  24  
  25  if ($ADMIN->fulltree) {
  26      $settings = new theme_boost_admin_settingspage_tabs('themesettingboost', get_string('configtitle', 'theme_boost'));
  27      $page = new admin_settingpage('theme_boost_general', get_string('generalsettings', 'theme_boost'));
  28  
  29      // Unaddable blocks.
  30      // Blocks to be excluded when this theme is enabled in the "Add a block" list: Administration, Navigation, Courses and
  31      // Section links.
  32      $default = 'navigation,settings,course_list,section_links';
  33      $setting = new admin_setting_configtext('theme_boost/unaddableblocks',
  34          get_string('unaddableblocks', 'theme_boost'), get_string('unaddableblocks_desc', 'theme_boost'), $default, PARAM_TEXT);
  35      $page->add($setting);
  36  
  37      // Preset.
  38      $name = 'theme_boost/preset';
  39      $title = get_string('preset', 'theme_boost');
  40      $description = get_string('preset_desc', 'theme_boost');
  41      $default = 'default.scss';
  42  
  43      $context = context_system::instance();
  44      $fs = get_file_storage();
  45      $files = $fs->get_area_files($context->id, 'theme_boost', 'preset', 0, 'itemid, filepath, filename', false);
  46  
  47      $choices = [];
  48      foreach ($files as $file) {
  49          $choices[$file->get_filename()] = $file->get_filename();
  50      }
  51      // These are the built in presets.
  52      $choices['default.scss'] = 'default.scss';
  53      $choices['plain.scss'] = 'plain.scss';
  54  
  55      $setting = new admin_setting_configthemepreset($name, $title, $description, $default, $choices, 'boost');
  56      $setting->set_updatedcallback('theme_reset_all_caches');
  57      $page->add($setting);
  58  
  59      // Preset files setting.
  60      $name = 'theme_boost/presetfiles';
  61      $title = get_string('presetfiles','theme_boost');
  62      $description = get_string('presetfiles_desc', 'theme_boost');
  63  
  64      $setting = new admin_setting_configstoredfile($name, $title, $description, 'preset', 0,
  65          array('maxfiles' => 20, 'accepted_types' => array('.scss')));
  66      $page->add($setting);
  67  
  68      // Background image setting.
  69      $name = 'theme_boost/backgroundimage';
  70      $title = get_string('backgroundimage', 'theme_boost');
  71      $description = get_string('backgroundimage_desc', 'theme_boost');
  72      $setting = new admin_setting_configstoredfile($name, $title, $description, 'backgroundimage');
  73      $setting->set_updatedcallback('theme_reset_all_caches');
  74      $page->add($setting);
  75  
  76      // Login Background image setting.
  77      $name = 'theme_boost/loginbackgroundimage';
  78      $title = get_string('loginbackgroundimage', 'theme_boost');
  79      $description = get_string('loginbackgroundimage_desc', 'theme_boost');
  80      $setting = new admin_setting_configstoredfile($name, $title, $description, 'loginbackgroundimage');
  81      $setting->set_updatedcallback('theme_reset_all_caches');
  82      $page->add($setting);
  83  
  84      // We use an empty default value because the default colour should come from the preset.
  85      $name = 'theme_boost/brandcolor';
  86      $title = get_string('brandcolor', 'theme_boost');
  87      $description = get_string('brandcolor_desc', 'theme_boost');
  88      $setting = new admin_setting_configcolourpicker($name, $title, $description, '');
  89      $setting->set_updatedcallback('theme_reset_all_caches');
  90      $page->add($setting);
  91  
  92      // Must add the page after definiting all the settings!
  93      $settings->add($page);
  94  
  95      // Advanced settings.
  96      $page = new admin_settingpage('theme_boost_advanced', get_string('advancedsettings', 'theme_boost'));
  97  
  98      // Raw SCSS to include before the content.
  99      $setting = new admin_setting_scsscode('theme_boost/scsspre',
 100          get_string('rawscsspre', 'theme_boost'), get_string('rawscsspre_desc', 'theme_boost'), '', PARAM_RAW);
 101      $setting->set_updatedcallback('theme_reset_all_caches');
 102      $page->add($setting);
 103  
 104      // Raw SCSS to include after the content.
 105      $setting = new admin_setting_scsscode('theme_boost/scss', get_string('rawscss', 'theme_boost'),
 106          get_string('rawscss_desc', 'theme_boost'), '', PARAM_RAW);
 107      $setting->set_updatedcallback('theme_reset_all_caches');
 108      $page->add($setting);
 109  
 110      $settings->add($page);
 111  }