MDL-10234
[moodle-linuxchix.git] / mod / resource / mod_form.php
blob1948c22130f2f60aecb53292385ca95a4a6157c2
1 <?php
2 require_once ($CFG->dirroot.'/course/moodleform_mod.php');
4 class mod_resource_mod_form extends moodleform_mod {
5 var $_resinstance;
7 function definition() {
8 global $CFG;
9 $mform =& $this->_form;
11 // this hack is needed for different settings of each subtype
12 if (!empty($this->_instance)) {
13 if($res = get_record('resource', 'id', (int)$this->_instance)) {
14 $type = $res->type;
15 } else {
16 error('incorrect assignment');
18 } else {
19 $type = required_param('type', PARAM_ALPHA);
21 $mform->addElement('hidden', 'type', $type);
22 $mform->setDefault('type', $type);
24 require($CFG->dirroot.'/mod/resource/type/'.$type.'/resource.class.php');
25 $resclass = 'resource_'.$type;
26 $this->_resinstance = new $resclass();
28 //-------------------------------------------------------------------------------
29 $mform->addElement('header', 'general', get_string('general', 'form'));
31 // $mform->addElement('static', 'statictype', get_string('assignmenttype', 'assignment'), get_string('type'.$type,'assignment'));
33 $mform->addElement('text', 'name', get_string('name'), array('size'=>'48'));
34 $mform->setType('name', PARAM_TEXT);
35 $mform->addRule('name', null, 'required', null, 'client');
37 $mform->addElement('htmleditor', 'summary', get_string('summary'));
38 $mform->setType('summary', PARAM_RAW);
39 $mform->setHelpButton('summary', array('summary', get_string('summary'), 'resource'));
40 // summary should be optional again MDL-9485
41 //$mform->addRule('summary', get_string('required'), 'required', null, 'client');
43 $mform->addElement('header', 'typedesc', get_string('resourcetype'.$type,'resource'));
44 $this->_resinstance->setup_elements($mform);
46 $this->standard_coursemodule_elements(false);
48 $this->add_action_buttons();
51 function data_preprocessing(&$default_values){
52 $this->_resinstance->setup_preprocessing($default_values);