MDL-66979 behat: Whitespace fix
[moodle.git] / user / editor_form.php
blobc1f5ba5c83cbe3d43750ee99de14f6aa6b0d7ab7
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.
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/>.
17 /**
18 * Form to edit a users editor preferences.
20 * @copyright 1999 Martin Dougiamas http://dougiamas.com
21 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
22 * @package core_user
25 if (!defined('MOODLE_INTERNAL')) {
26 die('Direct access to this script is forbidden.'); // It must be included from a Moodle page.
29 require_once($CFG->dirroot.'/lib/formslib.php');
31 /**
32 * Class user_edit_editor_form.
34 * @copyright 1999 Martin Dougiamas http://dougiamas.com
35 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
37 class user_edit_editor_form extends moodleform {
39 /**
40 * Define the form.
42 public function definition () {
43 global $CFG, $COURSE;
45 $mform = $this->_form;
47 $editors = editors_get_enabled();
49 $mform->addElement('hidden', 'id');
50 $mform->setType('id', PARAM_INT);
52 if (count($editors) > 1) {
53 $choices = array('' => get_string('defaulteditor'));
54 $firsteditor = '';
55 foreach (array_keys($editors) as $editor) {
56 if (!$firsteditor) {
57 $firsteditor = $editor;
59 $choices[$editor] = get_string('pluginname', 'editor_' . $editor);
61 $mform->addElement('select', 'preference_htmleditor', get_string('textediting'), $choices);
62 $mform->addHelpButton('preference_htmleditor', 'textediting');
63 $mform->setDefault('preference_htmleditor', '');
64 } else {
65 // Empty string means use the first chosen text editor.
66 $mform->addElement('hidden', 'preference_htmleditor');
67 $mform->setDefault('preference_htmleditor', '');
68 $mform->setType('preference_htmleditor', PARAM_PLUGIN);
71 $this->add_action_buttons(true, get_string('savechanges'));