function definition() { global $CFG, $DB; $mform =& $this->_form; // this hack is needed for different settings of each subtype if (!empty($this->_instance)) { if ($res = $DB->get_record('resource', array('id' => $this->_instance))) { $type = $res->type; } else { print_error('invalidassignment', 'resource'); } } else { $type = required_param('type', PARAM_ALPHA); } $mform->addElement('hidden', 'type', $type); $mform->setDefault('type', $type); require $CFG->dirroot . '/mod/resource/type/' . $type . '/resource.class.php'; $resclass = 'resource_' . $type; $this->_resinstance = new $resclass(); //------------------------------------------------------------------------------- $mform->addElement('header', 'general', get_string('general', 'form')); $mform->addElement('text', 'name', get_string('name'), array('size' => '48')); if (!empty($CFG->formatstringstriptags)) { $mform->setType('name', PARAM_TEXT); } else { $mform->setType('name', PARAM_CLEAN); } $mform->addRule('name', null, 'required', null, 'client'); $this->add_intro_editor(false); $mform->addElement('header', 'typedesc', resource_get_name($type)); $this->_resinstance->setup_elements($mform); $this->standard_coursemodule_elements(); $this->add_action_buttons(); }
function definition() { global $CFG; $mform =& $this->_form; // this hack is needed for different settings of each subtype if (!empty($this->_instance)) { if ($res = get_record('resource', 'id', (int) $this->_instance)) { $type = $res->type; } else { error('incorrect assignment'); } } else { $type = required_param('type', PARAM_ALPHA); } $mform->addElement('hidden', 'type', $type); $mform->setDefault('type', $type); require $CFG->dirroot . '/mod/resource/type/' . $type . '/resource.class.php'; $resclass = 'resource_' . $type; $this->_resinstance = new $resclass(); //------------------------------------------------------------------------------- $mform->addElement('header', 'general', get_string('general', 'form')); // $mform->addElement('static', 'statictype', get_string('assignmenttype', 'assignment'), get_string('type'.$type,'assignment')); $mform->addElement('text', 'name', get_string('name'), array('size' => '48')); $mform->setType('name', PARAM_TEXT); $mform->addRule('name', null, 'required', null, 'client'); $mform->addElement('htmleditor', 'summary', get_string('summary')); $mform->setType('summary', PARAM_RAW); $mform->setHelpButton('summary', array('summary', get_string('summary'), 'resource')); // summary should be optional again MDL-9485 //$mform->addRule('summary', get_string('required'), 'required', null, 'client'); $mform->addElement('header', 'typedesc', resource_get_name($type)); $this->_resinstance->setup_elements($mform); $this->standard_coursemodule_elements(false); $this->add_action_buttons(); }
function resource_get_types() { global $CFG; $types = array(); $standardresources = array('text', 'html', 'file', 'directory'); foreach ($standardresources as $resourcetype) { $type = new object(); $type->modclass = MOD_CLASS_RESOURCE; $type->name = $resourcetype; $type->type = "resource&type={$resourcetype}"; $type->typestr = resource_get_name($resourcetype); $types[] = $type; } /// Drop-in extra resource types $resourcetypes = get_list_of_plugins('mod/resource/type'); foreach ($resourcetypes as $resourcetype) { if (!empty($CFG->{'resource_hide_' . $resourcetype})) { // Not wanted continue; } if (!in_array($resourcetype, $standardresources)) { $type = new object(); $type->modclass = MOD_CLASS_RESOURCE; $type->name = $resourcetype; $type->type = "resource&type={$resourcetype}"; $type->typestr = resource_get_name($resourcetype); $types[] = $type; } } return $types; }