<?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 Jeremy Hopkins (Coventry University)
 * @copyright 2015 Fernando Acedo (3-bits.com)
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 *
 */
defined('MOODLE_INTERNAL') || die;

// Settings for tools menus.
$temp = new admin_settingpage('theme_oficial_header_navbar_menu', get_string('navbarmenusettings', 'theme_oficial'));
if ($ADMIN->fulltree) {

    $temp->add(new admin_setting_heading('theme_oficial_toolsmenu', get_string('toolsmenu', 'theme_oficial'),
        format_text(get_string('toolsmenudesc', 'theme_oficial'), FORMAT_MARKDOWN)));

    $temp->add(new admin_setting_heading('theme_oficial_toolsmenu', get_string('toolsmenuheading', 'theme_oficial'),
        format_text(get_string('toolsmenuheadingdesc', 'theme_oficial'), FORMAT_MARKDOWN)));

    $name = 'theme_oficial/disablecustommenu';
    $title = get_string('disablecustommenu', 'theme_oficial');
    $description = get_string('disablecustommenudesc', 'theme_oficial');
    $setting = new admin_setting_configcheckbox($name, $title, $description, false, true, false);
    $temp->add($setting);

    $name = 'theme_oficial/enabletoolsmenus';
    $title = get_string('enabletoolsmenus', 'theme_oficial');
    $description = get_string('enabletoolsmenusdesc', 'theme_oficial');
    $setting = new admin_setting_configcheckbox($name, $title, $description, $default, true, false);
    $temp->add($setting);

    // Number of tools menus.
    $name = 'theme_oficial/toolsmenuscount';
    $title = get_string('toolsmenuscount', 'theme_oficial');
    $description = get_string('toolsmenuscountdesc', 'theme_oficial');
    $default = THEME_OFICIAL_DEFAULT_TOOLSMENUSCOUNT;
    $setting = new admin_setting_configselect($name, $title, $description, $default, $choices0to12);
    $temp->add($setting);

    // If we don't have a menuscount yet, default to the preset.
    $toolsmenuscount = get_config('theme_oficial', 'toolsmenuscount');

    if (!$toolsmenuscount) {
        $toolsmenuscount = THEME_OFICIAL_DEFAULT_TOOLSMENUSCOUNT;
    }

    for ($toolsmenusindex = 1; $toolsmenusindex <= $toolsmenuscount; $toolsmenusindex++) {
        $temp->add(new admin_setting_heading('theme_oficial_menus' . $toolsmenusindex,
            get_string('toolsmenuheading', 'theme_oficial') . $toolsmenusindex,
            format_text(get_string('toolsmenudesc', 'theme_oficial'), FORMAT_MARKDOWN)));

        $name = 'theme_oficial/toolsmenu' . $toolsmenusindex . 'title';
        $title = get_string('toolsmenutitle', 'theme_oficial') . ' ' . $toolsmenusindex;
        $description = get_string('toolsmenutitledesc', 'theme_oficial');
        $default = get_string('toolsmenutitledefault', 'theme_oficial');
        $setting = new admin_setting_configtext($name, $title, $description, $default, PARAM_RAW);
        $temp->add($setting);

        $name = 'theme_oficial/toolsmenu' . $toolsmenusindex;
        $title = get_string('toolsmenu', 'theme_oficial') . ' ' . $toolsmenusindex;
        $description = get_string('toolsmenudesc', 'theme_oficial');
        $setting = new admin_setting_configtextarea($name, $title, $description, '', PARAM_RAW, '50', '10');
        $temp->add($setting);

        $name = 'theme_oficial/toolsmenu' . $toolsmenusindex . 'field';
        $title = get_string('toolsmenufield', 'theme_oficial');
        $description = get_string('toolsmenufielddesc', 'theme_oficial');
        $setting = new admin_setting_configtext($name, $title, $description, '', PARAM_RAW);
        $temp->add($setting);
    }
}
$ADMIN->add('theme_oficial', $temp);
