<?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/>.

/**
 * Version details
 *
 * @package   theme_oficial
 * @copyright 2015-2016 Jeremy Hopkins (Coventry University)
 * @copyright 2015-2016 Fernando Acedo (3-bits.com)
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 *
 */

defined('MOODLE_INTERNAL') || die;

// Alert Section.
$temp = new admin_settingpage('theme_oficial_frontpage_alert', get_string('frontpagealertsettings', 'theme_oficial'));
if ($ADMIN->fulltree) {
    $temp->add(new admin_setting_heading('theme_oficial_alert', get_string('alertsettingsheading', 'theme_oficial'),
        format_text(get_string('alertdesc', 'theme_oficial'), FORMAT_MARKDOWN)));

    // Alert General Settings Heading.
    $name = 'theme_oficial/settingsalertgeneral';
    $heading = get_string('alertsettingsgeneral', 'theme_oficial');
    $setting = new admin_setting_heading($name, $heading, '');
    $temp->add($setting);

    // Enable or disable alerts.
    $name = 'theme_oficial/enablealerts';
    $title = get_string('enablealerts', 'theme_oficial');
    $description = get_string('enablealertsdesc', 'theme_oficial');
    $default = false;
    $setting = new admin_setting_configcheckbox($name, $title, $description, $default, true, false);
    $temp->add($setting);

    // Disable alert in course pages.  TODO -> Used anymore??
    $name = 'theme_oficial/enablealertcoursepages';
    $title = get_string('enablealertcoursepages', 'theme_oficial');
    $description = get_string('enablealertcoursepagesdesc', 'theme_oficial');
    $default = false;
    $setting = new admin_setting_configcheckbox($name, $title, $description, $default, true, false);
    $temp->add($setting);

    // Alert hidden course.
    $name = 'theme_oficial/alerthiddencourse';
    $title = get_string('alerthiddencourse', 'theme_oficial');
    $description = get_string('alerthiddencoursedesc', 'theme_oficial');
    $default = 'warning';
    $choices = array(
        'disabled' => get_string('alertdisabled', 'theme_oficial'),
        'info' => get_string('alertinfo', 'theme_oficial'),
        'warning' => get_string('alertwarning', 'theme_oficial'),
        'success' => get_string('alertannounce', 'theme_oficial'));
    $setting = new admin_setting_configselect($name, $title, $description, $default, $choices);
    $temp->add($setting);

    // Strip Tags.
    $name = 'theme_oficial/enablealertstriptags';
    $title = get_string('enablealertstriptags', 'theme_oficial');
    $description = get_string('enablealertstriptagsdesc', 'theme_oficial');
    $default = true;
    $setting = new admin_setting_configcheckbox($name, $title, $description, $default, true, false);
    $temp->add($setting);

    // Number of Alerts.
    $name = 'theme_oficial/alertcount';
    $title = get_string('alertcount', 'theme_oficial');
    $description = get_string('alertcountdesc', 'theme_oficial');
    $default = THEME_OFICIAL_DEFAULT_ALERTCOUNT;
    $setting = new admin_setting_configselect($name, $title, $description, $default, $choices0to12);
    $temp->add($setting);

    $alertcount = get_config('theme_oficial', 'alertcount');
    // If we don't have an an alertcount yet, default to the preset.
    if (!$alertcount) {
        $alertcount = THEME_OFICIAL_DEFAULT_ALERTCOUNT;
    }

    for ($alertindex = 1; $alertindex <= $alertcount; $alertindex++) {
        // Alert Box Heading.
        $name = 'theme_oficial/settingsalertbox'.$alertindex;
        $heading = get_string('alertsettings', 'theme_oficial', $alertindex);
        $setting = new admin_setting_heading($name, $heading, '');
        $temp->add($setting);

        // Enable Alert.
        $name = 'theme_oficial/enablealert'.$alertindex;
        $title = get_string('enablealert', 'theme_oficial', $alertindex);
        $description = get_string('enablealertdesc', 'theme_oficial', $alertindex);
        $default = false;
        $setting = new admin_setting_configcheckbox($name, $title, $description, $default, true, false);
        $temp->add($setting);

        // Alert Key.
        $name = 'theme_oficial/alertkey'.$alertindex;
        $title = get_string('alertkeyvalue', 'theme_oficial');
        $description = get_string('alertkeyvalue_details', 'theme_oficial');
        $setting = new admin_setting_configtext($name, $title, $description, '', PARAM_RAW);
        $temp->add($setting);

        // Alert Text.
        $name = 'theme_oficial/alerttext'.$alertindex;
        $title = get_string('alerttext', 'theme_oficial');
        $description = get_string('alerttextdesc', 'theme_oficial');
        $default = '';
        $setting = new oficial_setting_confightmleditor($name, $title, $description, $default);
        $temp->add($setting);

        // Alert Type.
        $name = 'theme_oficial/alerttype'.$alertindex;
        $title = get_string('alerttype', 'theme_oficial');
        $description = get_string('alerttypedesc', 'theme_oficial');
        $default = 'info';
        $choices = array(
            'info' => get_string('alertinfo', 'theme_oficial'),
            'warning' => get_string('alertwarning', 'theme_oficial'),
            'success' => get_string('alertannounce', 'theme_oficial'));
            $setting = new admin_setting_configselect($name, $title, $description, $default, $choices);
        $temp->add($setting);

        // Alert Access.
        $name = 'theme_oficial/alertaccess' . $alertindex;
        $title = get_string('alertaccess', 'theme_oficial');
        $description = get_string('alertaccessdesc', 'theme_oficial');
        $default = 'global';
        $choices = array(
            'global' => get_string('alertaccessglobal', 'theme_oficial'),
            'user' => get_string('alertaccessusers', 'theme_oficial'),
            'admin' => get_string('alertaccessadmins', 'theme_oficial'),
            'profile' => get_string('alertaccessprofile', 'theme_oficial'));
        $setting = new admin_setting_configselect($name, $title, $description, $default, $choices);
        $temp->add($setting);

        $name = 'theme_oficial/alertprofilefield' . $alertindex;
        $title = get_string('alertprofilefield', 'theme_oficial');
        $description = get_string('alertprofilefielddesc', 'theme_oficial');
        $setting = new admin_setting_configtext($name, $title, $description, '', PARAM_RAW);
        $temp->add($setting);
    }

    // Colours.
    // Alert Course Settings Heading.
    $name = 'theme_oficial/settingsalertcolors';
    $heading = get_string('settingscolors', 'theme_oficial');
    $setting = new admin_setting_heading($name, $heading, '');
    $temp->add($setting);

    // Alert info colours.
    $name = 'theme_oficial/alertcolorinfo';
    $title = get_string('alertcolorinfo', 'theme_oficial');
    $description = get_string('alertcolorinfodesc', 'theme_oficial');
    $previewconfig = null;
    $setting = new admin_setting_configcolourpicker($name, $title, $description, '#3a87ad', $previewconfig);
    $setting->set_updatedcallback('theme_reset_all_caches');
    $temp->add($setting);

    $name = 'theme_oficial/alertbackgroundcolorinfo';
    $title = get_string('alertbackgroundcolorinfo', 'theme_oficial');
    $description = get_string('alertbackgroundcolorinfodesc', 'theme_oficial');
    $previewconfig = null;
    $setting = new admin_setting_configcolourpicker($name, $title, $description, '#d9edf7', $previewconfig);
    $setting->set_updatedcallback('theme_reset_all_caches');
    $temp->add($setting);

    $name = 'theme_oficial/alertbordercolorinfo';
    $title = get_string('alertbordercolorinfo', 'theme_oficial');
    $description = get_string('alertbordercolorinfodesc', 'theme_oficial');
    $previewconfig = null;
    $setting = new admin_setting_configcolourpicker($name, $title, $description, '#bce8f1', $previewconfig);
    $setting->set_updatedcallback('theme_reset_all_caches');
    $temp->add($setting);

    $name = 'theme_oficial/alerticoninfo';
    $title = get_string('alerticoninfo', 'theme_oficial');
    $description = get_string('alerticoninfodesc', 'theme_oficial');
    $setting = new admin_setting_configtext($name, $title, $description, 'info-circle');
    $temp->add($setting);

    // Alert success colours.
    $name = 'theme_oficial/alertcolorsuccess';
    $title = get_string('alertcolorsuccess', 'theme_oficial');
    $description = get_string('alertcolorsuccessdesc', 'theme_oficial');
    $previewconfig = null;
    $setting = new admin_setting_configcolourpicker($name, $title, $description, '#468847', $previewconfig);
    $setting->set_updatedcallback('theme_reset_all_caches');
    $temp->add($setting);

    $name = 'theme_oficial/alertbackgroundcolorsuccess';
    $title = get_string('alertbackgroundcolorsuccess', 'theme_oficial');
    $description = get_string('alertbackgroundcolorsuccessdesc', 'theme_oficial');
    $previewconfig = null;
    $setting = new admin_setting_configcolourpicker($name, $title, $description, '#dff0d8', $previewconfig);
    $setting->set_updatedcallback('theme_reset_all_caches');
    $temp->add($setting);

    $name = 'theme_oficial/alertbordercolorsuccess';
    $title = get_string('alertbordercolorsuccess', 'theme_oficial');
    $description = get_string('alertbordercolorsuccessdesc', 'theme_oficial');
    $previewconfig = null;
    $setting = new admin_setting_configcolourpicker($name, $title, $description, '#d6e9c6', $previewconfig);
    $setting->set_updatedcallback('theme_reset_all_caches');
    $temp->add($setting);

    $name = 'theme_oficial/alerticonsuccess';
    $title = get_string('alerticonsuccess', 'theme_oficial');
    $description = get_string('alerticonsuccessdesc', 'theme_oficial');
    $setting = new admin_setting_configtext($name, $title, $description, 'bullhorn');
    $temp->add($setting);

    // Alert warning colours.
    $name = 'theme_oficial/alertcolorwarning';
    $title = get_string('alertcolorwarning', 'theme_oficial');
    $description = get_string('alertcolorwarningdesc', 'theme_oficial');
    $previewconfig = null;
    $setting = new admin_setting_configcolourpicker($name, $title, $description, '#8a6d3b', $previewconfig);
    $setting->set_updatedcallback('theme_reset_all_caches');
    $temp->add($setting);

    $name = 'theme_oficial/alertbackgroundcolorwarning';
    $title = get_string('alertbackgroundcolorwarning', 'theme_oficial');
    $description = get_string('alertbackgroundcolorwarningdesc', 'theme_oficial');
    $previewconfig = null;
    $setting = new admin_setting_configcolourpicker($name, $title, $description, '#fcf8e3', $previewconfig);
    $setting->set_updatedcallback('theme_reset_all_caches');
    $temp->add($setting);

    $name = 'theme_oficial/alertbordercolorwarning';
    $title = get_string('alertbordercolorwarning', 'theme_oficial');
    $description = get_string('alertbordercolorwarningdesc', 'theme_oficial');
    $previewconfig = null;
    $setting = new admin_setting_configcolourpicker($name, $title, $description, '#fbeed5', $previewconfig);
    $setting->set_updatedcallback('theme_reset_all_caches');
    $temp->add($setting);

    $name = 'theme_oficial/alerticonwarning';
    $title = get_string('alerticonwarning', 'theme_oficial');
    $description = get_string('alerticonwarningdesc', 'theme_oficial');
    $setting = new admin_setting_configtext($name, $title, $description, 'exclamation-triangle');
    $temp->add($setting);
}
$ADMIN->add('theme_oficial', $temp);
