| 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 tool_usertours;
|
|
|
18 |
|
|
|
19 |
/**
|
|
|
20 |
* Step configuration detail class.
|
|
|
21 |
*
|
|
|
22 |
* @package tool_usertours
|
|
|
23 |
* @copyright 2024 Andrew Nicols <andrew@nicols.co.uk>
|
|
|
24 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
25 |
*/
|
|
|
26 |
class configuration {
|
|
|
27 |
/**
|
|
|
28 |
* @var TOURDEFAULT
|
|
|
29 |
*/
|
|
|
30 |
const TOURDEFAULT = 'usetourdefault';
|
|
|
31 |
|
|
|
32 |
/**
|
|
|
33 |
* Get the list of keys which can be defaulted in the tour.
|
|
|
34 |
*
|
|
|
35 |
* @return array
|
|
|
36 |
*/
|
|
|
37 |
public static function get_defaultable_keys() {
|
|
|
38 |
return [
|
|
|
39 |
'placement',
|
|
|
40 |
'orphan',
|
|
|
41 |
'backdrop',
|
|
|
42 |
'reflex',
|
|
|
43 |
];
|
|
|
44 |
}
|
|
|
45 |
|
|
|
46 |
/**
|
|
|
47 |
* Get the default value for the specified key.
|
|
|
48 |
*
|
|
|
49 |
* @param string $key The key for the specified value
|
|
|
50 |
* @return mixed
|
|
|
51 |
*/
|
|
|
52 |
public static function get_default_value($key) {
|
|
|
53 |
switch ($key) {
|
|
|
54 |
case 'placement':
|
|
|
55 |
return 'bottom';
|
|
|
56 |
case 'orphan':
|
|
|
57 |
case 'backdrop':
|
|
|
58 |
case 'reflex':
|
|
|
59 |
return false;
|
|
|
60 |
}
|
|
|
61 |
}
|
|
|
62 |
|
|
|
63 |
/**
|
|
|
64 |
* Get the default value for the specified key for the step form.
|
|
|
65 |
*
|
|
|
66 |
* @param string $key The key for the specified value
|
|
|
67 |
* @return mixed
|
|
|
68 |
*/
|
|
|
69 |
public static function get_step_default_value($key) {
|
|
|
70 |
switch ($key) {
|
|
|
71 |
case 'placement':
|
|
|
72 |
case 'orphan':
|
|
|
73 |
case 'backdrop':
|
|
|
74 |
case 'reflex':
|
|
|
75 |
return self::TOURDEFAULT;
|
|
|
76 |
}
|
|
|
77 |
}
|
|
|
78 |
|
|
|
79 |
/**
|
|
|
80 |
* Get the list of possible placement options.
|
|
|
81 |
*
|
|
|
82 |
* @param string $default The default option.
|
|
|
83 |
* @return array
|
|
|
84 |
*/
|
|
|
85 |
public static function get_placement_options($default = null) {
|
|
|
86 |
$values = [
|
|
|
87 |
'top' => get_string('above', 'tool_usertours'),
|
|
|
88 |
'bottom' => get_string('below', 'tool_usertours'),
|
|
|
89 |
'left' => get_string('left', 'tool_usertours'),
|
|
|
90 |
'right' => get_string('right', 'tool_usertours'),
|
|
|
91 |
];
|
|
|
92 |
|
|
|
93 |
if ($default === null) {
|
|
|
94 |
return $values;
|
|
|
95 |
}
|
|
|
96 |
|
|
|
97 |
if (!isset($values[$default])) {
|
|
|
98 |
$default = self::get_default_value('placement');
|
|
|
99 |
}
|
|
|
100 |
|
|
|
101 |
$values = array_reverse($values, true);
|
|
|
102 |
$values[self::TOURDEFAULT] = get_string('defaultvalue', 'tool_usertours', $values[$default]);
|
|
|
103 |
$values = array_reverse($values, true);
|
|
|
104 |
|
|
|
105 |
return $values;
|
|
|
106 |
}
|
|
|
107 |
}
|