forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
editcategory_form.php
50 lines (43 loc) · 1.98 KB
/
editcategory_form.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
}
require_once ($CFG->dirroot.'/course/moodleform_mod.php');
class editcategory_form extends moodleform {
// form definition
function definition() {
global $CFG;
$mform =& $this->_form;
$category = $this->_customdata['category'];
$editoroptions = $this->_customdata['editoroptions'];
// get list of categories to use as parents, with site as the first one
$options = array(get_string('top'));
$parents = array();
if ($category->id) {
// Editing an existing category.
make_categories_list($options, $parents, 'moodle/category:manage', $category->id);
$strsubmit = get_string('savechanges');
} else {
// Making a new category
make_categories_list($options, $parents, 'moodle/category:manage');
$strsubmit = get_string('createcategory');
}
$mform->addElement('select', 'parent', get_string('parentcategory'), $options);
$mform->addElement('text', 'name', get_string('categoryname'), array('size'=>'30'));
$mform->addRule('name', get_string('required'), 'required', null);
$mform->addElement('editor', 'description_editor', get_string('description'), null, $editoroptions);
$mform->setType('description_editor', PARAM_RAW);
if (!empty($CFG->allowcategorythemes)) {
$themes = array(''=>get_string('forceno'));
$allthemes = get_list_of_themes();
foreach ($allthemes as $key=>$theme) {
$themes[$key] = $theme->name;
}
$mform->addElement('select', 'theme', get_string('forcetheme'), $themes);
}
$mform->addElement('hidden', 'id', 0);
$mform->setType('id', PARAM_INT);
$mform->setDefault('id', $category->id);
$this->add_action_buttons(true, $strsubmit);
}
}