1441 |
ariadna |
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_cache\form;
|
|
|
18 |
|
|
|
19 |
use core_cache\store;
|
|
|
20 |
use moodleform;
|
|
|
21 |
|
|
|
22 |
/**
|
|
|
23 |
* Form to set the mappings for a mode.
|
|
|
24 |
*
|
|
|
25 |
* @package core_cache
|
|
|
26 |
* @category cache
|
|
|
27 |
* @copyright 2012 Sam Hemelryk
|
|
|
28 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
29 |
*/
|
|
|
30 |
class cache_mode_mappings_form extends moodleform {
|
|
|
31 |
/**
|
|
|
32 |
* The definition of the form
|
|
|
33 |
*/
|
|
|
34 |
protected function definition() {
|
|
|
35 |
$form = $this->_form;
|
|
|
36 |
$stores = $this->_customdata;
|
|
|
37 |
|
|
|
38 |
$options = [
|
|
|
39 |
store::MODE_APPLICATION => [],
|
|
|
40 |
store::MODE_SESSION => [],
|
|
|
41 |
store::MODE_REQUEST => [],
|
|
|
42 |
];
|
|
|
43 |
foreach ($stores as $storename => $store) {
|
|
|
44 |
foreach ($store['modes'] as $mode => $enabled) {
|
|
|
45 |
if ($enabled && ($mode !== store::MODE_SESSION || $store['supports']['searchable'])) {
|
|
|
46 |
if (empty($store['default'])) {
|
|
|
47 |
$options[$mode][$storename] = $store['name'];
|
|
|
48 |
} else {
|
|
|
49 |
$options[$mode][$storename] = get_string('store_' . $store['name'], 'cache');
|
|
|
50 |
}
|
|
|
51 |
}
|
|
|
52 |
}
|
|
|
53 |
}
|
|
|
54 |
|
|
|
55 |
$form->addElement('hidden', 'action', 'editmodemappings');
|
|
|
56 |
$form->setType('action', PARAM_ALPHA);
|
|
|
57 |
foreach ($options as $mode => $optionset) {
|
|
|
58 |
$form->addElement('select', 'mode_' . $mode, get_string('mode_' . $mode, 'cache'), $optionset);
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
$this->add_action_buttons();
|
|
|
62 |
}
|
|
|
63 |
}
|
|
|
64 |
|
|
|
65 |
// Alias this class to the old name.
|
|
|
66 |
// This file will be autoloaded by the legacyclasses autoload system.
|
|
|
67 |
// In future all uses of this class will be corrected and the legacy references will be removed.
|
|
|
68 |
class_alias(cache_mode_mappings_form::class, \cache_mode_mappings_form::class);
|