Proyectos de Subversion Moodle

Rev

| 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 tool_usertours\local\target;
18
 
19
/**
20
 * A step designed to be orphaned.
21
 *
22
 * @package    tool_usertours
23
 * @copyright  2016 Andrew Nicols <andrew@nicols.co.uk>
24
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25
 */
26
class unattached extends base {
27
    /**
28
     * @var     array       $forcedsettings The settings forced by this type.
29
     */
30
    protected static $forcedsettings = [
31
            'placement'     => 'top',
32
            'orphan'        => true,
33
            'reflex'        => false,
34
        ];
35
 
36
    /**
37
     * Convert the target value to a valid CSS selector for use in the
38
     * output configuration.
39
     *
40
     * @return string
41
     */
42
    public function convert_to_css() {
43
        return '';
44
    }
45
 
46
    /**
47
     * Convert the step target to a friendly name for use in the UI.
48
     *
49
     * @return string
50
     */
51
    public function get_displayname() {
52
        return get_string('target_unattached', 'tool_usertours');
53
    }
54
 
55
    /**
56
     * Add the target type configuration to the form.
57
     *
58
     * @param   MoodleQuickForm $mform      The form to add configuration to.
59
     * @return  $this
60
     */
61
    public static function add_config_to_form(\MoodleQuickForm $mform) {
62
        // There is no relevant value here.
63
        $mform->addElement('hidden', 'targetvalue_unattached', '');
64
        $mform->setType('targetvalue_unattached', PARAM_TEXT);
65
    }
66
 
67
    /**
68
     * Add the disabledIf values.
69
     *
70
     * @param   MoodleQuickForm $mform      The form to add configuration to.
71
     */
72
    public static function add_disabled_constraints_to_form(\MoodleQuickForm $mform) {
73
        $myvalue = \tool_usertours\target::get_target_constant_for_class(self::class);
74
 
75
        foreach (array_keys(self::$forcedsettings) as $settingname) {
76
            $mform->hideIf($settingname, 'targettype', 'eq', $myvalue);
77
        }
78
    }
79
 
80
    /**
81
     * Prepare data to submit to the form.
82
     *
83
     * @param   object          $data       The data being passed to the form
84
     */
85
    public function prepare_data_for_form($data) {
86
        $data->targetvalue_unattached = '';
87
    }
88
 
89
    /**
90
     * Fetch the targetvalue from the form for this target type.
91
     *
92
     * @param   stdClass        $data       The data submitted in the form
93
     * @return  string
94
     */
95
    public function get_value_from_form($data) {
96
        return '';
97
    }
98
}