MDL-44221 editor_atto: convert plugins to use insert_html_at_focus_point
[moodle.git] / mod / data / mod_form.php
blobeb7ab7c9b13988b5119b9839c7136c540ba68295
1 <?php
2 if (!defined('MOODLE_INTERNAL')) {
3 die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
6 require_once ($CFG->dirroot.'/course/moodleform_mod.php');
8 class mod_data_mod_form extends moodleform_mod {
10 function definition() {
11 global $CFG, $DB;
13 $mform =& $this->_form;
15 //-------------------------------------------------------------------------------
16 $mform->addElement('header', 'general', get_string('general', 'form'));
18 $mform->addElement('text', 'name', get_string('name'), array('size'=>'64'));
19 if (!empty($CFG->formatstringstriptags)) {
20 $mform->setType('name', PARAM_TEXT);
21 } else {
22 $mform->setType('name', PARAM_CLEANHTML);
24 $mform->addRule('name', null, 'required', null, 'client');
25 $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
27 $this->add_intro_editor(true, get_string('intro', 'data'));
29 // ----------------------------------------------------------------------
30 $mform->addElement('header', 'entrieshdr', get_string('entries', 'data'));
32 $mform->addElement('selectyesno', 'approval', get_string('requireapproval', 'data'));
33 $mform->addHelpButton('approval', 'requireapproval', 'data');
35 $mform->addElement('selectyesno', 'comments', get_string('allowcomments', 'data'));
37 $countoptions = array(0=>get_string('none'))+
38 (array_combine(range(1, DATA_MAX_ENTRIES), // Keys.
39 range(1, DATA_MAX_ENTRIES))); // Values.
40 $mform->addElement('select', 'requiredentries', get_string('requiredentries', 'data'), $countoptions);
41 $mform->addHelpButton('requiredentries', 'requiredentries', 'data');
43 $mform->addElement('select', 'requiredentriestoview', get_string('requiredentriestoview', 'data'), $countoptions);
44 $mform->addHelpButton('requiredentriestoview', 'requiredentriestoview', 'data');
46 $mform->addElement('select', 'maxentries', get_string('maxentries', 'data'), $countoptions);
47 $mform->addHelpButton('maxentries', 'maxentries', 'data');
49 // ----------------------------------------------------------------------
50 $mform->addElement('header', 'availibilityhdr', get_string('availability'));
52 $mform->addElement('date_time_selector', 'timeavailablefrom', get_string('availablefromdate', 'data'),
53 array('optional' => true));
55 $mform->addElement('date_time_selector', 'timeavailableto', get_string('availabletodate', 'data'),
56 array('optional' => true));
58 $mform->addElement('date_time_selector', 'timeviewfrom', get_string('viewfromdate', 'data'),
59 array('optional' => true));
61 $mform->addElement('date_time_selector', 'timeviewto', get_string('viewtodate', 'data'),
62 array('optional' => true));
64 // ----------------------------------------------------------------------
65 if ($CFG->enablerssfeeds && $CFG->data_enablerssfeeds) {
66 $mform->addElement('header', 'rsshdr', get_string('rss'));
67 $mform->addElement('select', 'rssarticles', get_string('numberrssarticles', 'data') , $countoptions);
70 $this->standard_grading_coursemodule_elements();
72 $this->standard_coursemodule_elements();
74 //-------------------------------------------------------------------------------
75 // buttons
76 $this->add_action_buttons();
79 function data_preprocessing(&$default_values){
80 parent::data_preprocessing($default_values);