<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.

/**
 * IILMP theme settings.
 *
 * @package   theme_iilmp
 * @copyright 2026 RUFORUM
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */

defined('MOODLE_INTERNAL') || die();

if ($ADMIN->fulltree) {
    $settings = new theme_boost_admin_settingspage_tabs('themesettingiilmp', get_string('configtitle', 'theme_iilmp'));

    // -- General tab --------------------------------------------------------
    $page = new admin_settingpage('theme_iilmp_general', get_string('generalsettings', 'theme_iilmp'));

    // Preset (Boost preset to build on).
    $name = 'theme_iilmp/preset';
    $title = get_string('preset', 'theme_iilmp');
    $description = get_string('preset_desc', 'theme_iilmp');
    $default = 'default.scss';
    $choices = ['default.scss' => 'default.scss', 'plain.scss' => 'plain.scss'];
    $setting = new admin_setting_configselect($name, $title, $description, $default, $choices);
    $setting->set_updatedcallback('theme_reset_all_caches');
    $page->add($setting);

    // Brand colour (maps to Bootstrap $primary via pre-scss).
    $name = 'theme_iilmp/brandcolor';
    $title = get_string('brandcolor', 'theme_iilmp');
    $description = get_string('brandcolor_desc', 'theme_iilmp');
    $setting = new admin_setting_configcolourpicker($name, $title, $description, '#6b5317');
    $setting->set_updatedcallback('theme_reset_all_caches');
    $page->add($setting);

    // Custom logo (falls back to the bundled pix/logo when empty).
    $name = 'theme_iilmp/logo';
    $title = get_string('logo', 'theme_iilmp');
    $description = get_string('logo_desc', 'theme_iilmp');
    $setting = new admin_setting_configstoredfile($name, $title, $description, 'logo', 0,
        ['maxfiles' => 1, 'accepted_types' => ['.png', '.jpg', '.svg', '.webp']]);
    $setting->set_updatedcallback('theme_reset_all_caches');
    $page->add($setting);

    $settings->add($page);

    // -- Advanced tab -------------------------------------------------------
    $page = new admin_settingpage('theme_iilmp_advanced', get_string('advancedsettings', 'theme_iilmp'));

    // Raw SCSS injected before the preset.
    $name = 'theme_iilmp/scsspre';
    $title = get_string('rawscsspre', 'theme_iilmp');
    $description = get_string('rawscsspre_desc', 'theme_iilmp');
    $setting = new admin_setting_scsscode($name, $title, $description, '', PARAM_RAW);
    $setting->set_updatedcallback('theme_reset_all_caches');
    $page->add($setting);

    // Raw SCSS injected after the preset.
    $name = 'theme_iilmp/scss';
    $title = get_string('rawscss', 'theme_iilmp');
    $description = get_string('rawscss_desc', 'theme_iilmp');
    $setting = new admin_setting_scsscode($name, $title, $description, '', PARAM_RAW);
    $setting->set_updatedcallback('theme_reset_all_caches');
    $page->add($setting);

    $settings->add($page);
}
