Refactoring the class displaying the form of the editor

This commit is contained in:
Valentin Popov 2017-10-26 17:41:16 +04:00
parent a7e41f77d2
commit 4f34a6db0f

View File

@ -63,46 +63,34 @@ class service_edit_form extends moodleform {
$mform =& $this->_form;
/* Form heading */
$mform->addElement("header", "editserviceheader",
new lang_string("service", "webservice"));
$mform->addElement("header", "editserviceheader", new lang_string("service", "webservice"));
/* Name of the service */
$mform->addElement("text", "title",
new lang_string("name", "moodle"),
array("size" => 60));
$mform->setType("title", PARAM_NOTAGS);
$mform->addElement("text", "title", new lang_string("name", "moodle"), array("size" => 60));
$mform->addRule("title", null, "required");
$mform->setType("title", PARAM_NOTAGS);
/* Callback address */
$mform->addElement("text", "url",
new lang_string("url", "moodle"),
array("size" => 60));
$mform->setType("url", PARAM_URL);
$mform->addElement("text", "url", new lang_string("url", "moodle"), array("size" => 60));
$mform->addRule("url", null, "required");
$mform->setType("url", PARAM_URL);
/* Enabling the service */
$mform->addElement("advcheckbox", "enable",
new lang_string("enable", "moodle"));
$mform->addElement("advcheckbox", "enable", new lang_string("enable", "moodle"));
$mform->setType("enable", PARAM_BOOL);
$mform->setDefault("enable", 1);
$mform->setAdvanced("enable");
/* Token */
$mform->addElement("text", "token",
new lang_string("token", "webservice"),
array("size" => 60));
$mform->addElement("text", "token", new lang_string("token", "webservice"), array("size" => 60));
$mform->setType("token", PARAM_NOTAGS);
/* Content type */
$mform->addElement("select", "type", "Content type",
array(
"json" => "application/json",
"x-www-form-urlencoded" => "application/x-www-form-urlencoded"));
$mform->addElement("select", "type", "Content type", array("json" => "application/json", "x-www-form-urlencoded" => "application/x-www-form-urlencoded"));
$mform->setAdvanced("type");
/* Form heading */
$mform->addElement("header", "editserviceheaderevent",
new lang_string("edulevel", "moodle"));
$mform->addElement("header", "editserviceheaderevent", new lang_string("edulevel", "moodle"));
/* List of events */
$eventlist = report_eventlist_list_generator::get_all_events_list(true);
@ -110,8 +98,7 @@ class service_edit_form extends moodleform {
/* Formation of the list of elements */
foreach ($eventlist as $event) {
$events[$event["component"]][] =&
$mform->createElement("checkbox", $event["eventname"], $event["eventname"]);
$events[$event["component"]][] =& $mform->createElement("checkbox", $event["eventname"], $event["eventname"]);
}
/* Displays groups of items */