Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 11
Línea 66... Línea 66...
66
     */
66
     */
67
    public function instance_form_definition(\MoodleQuickForm $mform) {
67
    public function instance_form_definition(\MoodleQuickForm $mform) {
68
        $field = $this->get_field();
68
        $field = $this->get_field();
69
        $config = $field->get('configdata');
69
        $config = $field->get('configdata');
70
        $options = $field->get_options();
70
        $options = $field->get_options();
71
        $formattedoptions = array();
-
 
72
        $context = $this->get_field()->get_handler()->get_configuration_context();
-
 
73
        foreach ($options as $key => $option) {
-
 
74
            // Multilang formatting with filters.
-
 
75
            $formattedoptions[$key] = format_string($option, true, ['context' => $context]);
-
 
76
        }
-
 
Línea 77... Línea 71...
77
 
71
 
78
        $elementname = $this->get_form_element_name();
72
        $elementname = $this->get_form_element_name();
Línea 79... Línea 73...
79
        $mform->addElement('select', $elementname, $this->get_field()->get_formatted_name(), $formattedoptions);
73
        $mform->addElement('select', $elementname, $this->get_field()->get_formatted_name(), $options);
80
 
74
 
81
        if (($defaultkey = array_search($config['defaultvalue'], $options)) !== false) {
75
        if (($defaultkey = array_search($config['defaultvalue'], $options)) !== false) {
82
            $mform->setDefault($elementname, $defaultkey);
76
            $mform->setDefault($elementname, $defaultkey);
Línea 117... Línea 111...
117
            return null;
111
            return null;
118
        }
112
        }
Línea 119... Línea 113...
119
 
113
 
120
        $options = $this->get_field()->get_options();
114
        $options = $this->get_field()->get_options();
121
        if (array_key_exists($value, $options)) {
115
        if (array_key_exists($value, $options)) {
122
            return format_string($options[$value], true,
-
 
123
                ['context' => $this->get_field()->get_handler()->get_configuration_context()]);
116
            return $options[$value];
Línea 124... Línea 117...
124
        }
117
        }
125
 
118
 
126
        return null;
119
        return null;