Proyectos de Subversion Moodle

Rev

Rev 1 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 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
namespace core\aws;
18
 
19
defined('MOODLE_INTERNAL') || die();
20
 
21
require_once($CFG->dirroot . '/lib/adminlib.php');
22
 
23
/**
24
 * Admin setting for a list of AWS regions.
25
 *
26
 * @package    core
27
 * @copyright  2020 Catalyst IT
28
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
1441 ariadna 29
 * @deprecated Since Moodle 4.5
30
 * @todo       MDL-82459 Final deprecation in Moodle 5.0.
1 efrain 31
 */
32
class admin_settings_aws_region extends \admin_setting_configtext {
33
 
34
    /**
35
     * Return part of form with setting.
36
     *
37
     * @param mixed $data array or string depending on setting
38
     * @param string $query
39
     * @return string
1441 ariadna 40
     * @deprecated Since Moodle 4.5
1 efrain 41
     */
1441 ariadna 42
    #[\core\attribute\deprecated(
43
        'admin_settings_aws_region::output_html()',
44
        since: '4.5',
45
        mdl: 'MDL-80962',
46
    )]
1 efrain 47
    public function output_html($data, $query='') {
1441 ariadna 48
        \core\deprecation::emit_deprecation([$this, __FUNCTION__]);
1 efrain 49
        global $CFG, $OUTPUT;
50
 
51
        $default = $this->get_defaultsetting();
52
        $options = [];
53
        // We do require() not require_once() here, as the file returns a value and we may need to get
54
        // this value more than once.
55
        $all = require($CFG->dirroot . '/lib/aws-sdk/src/data/endpoints.json.php');
56
        $ends = $all['partitions'][0]['regions'];
57
        if ($ends) {
58
            foreach ($ends as $key => $value) {
59
                $options[] = [
60
                    'value' => $key,
61
                    'label' => $key . ' - ' . $value['description'],
62
                ];
63
            }
64
        }
65
 
66
        $context = [
67
            'list' => $this->get_full_name(),
68
            'name' => $this->get_full_name(),
69
            'id' => $this->get_id(),
70
            'value' => $data,
71
            'size' => $this->size,
72
            'options' => $options,
73
        ];
74
        $element = $OUTPUT->render_from_template('core/aws/setting_aws_region', $context);
75
        return format_admin_setting($this, $this->visiblename, $element, $this->description, true, '', $default, $query);
76
    }
77
}