Ejemplo n.º 1
0
 function definition()
 {
     global $CFG, $USER;
     $mform =& $this->_form;
     $this->set_upload_manager(new upload_manager('taoresourcefile', false, false, null, false, 0, true, true, false));
     $mform->addElement('header', 'resourceheader', get_string('resource'));
     $mform->addElement('text', 'title', get_string('name'), array('size' => '48'));
     if (!empty($CFG->formatstringstriptags)) {
         $mform->setType('title', PARAM_TEXT);
     } else {
         $mform->setType('title', PARAM_CLEAN);
     }
     $mform->addRule('title', null, 'required', null, 'client');
     $mform->setHelpButton('title', array('name', get_string('name'), 'taoresource'));
     $mform->addElement('htmleditor', 'description', get_string('description'));
     $mform->setType('description', PARAM_RAW);
     $mform->setHelpButton('description', array('description', get_string('description'), 'taoresource'));
     $mform->addElement('text', 'keywords', get_string('keywords', 'taoresource'), array('size' => '48'));
     $mform->setHelpButton('keywords', array('keywords', get_string('keywords', 'taoresource'), 'taoresource'));
     if ($this->taoresource_entry_mode == 'update') {
         $mform->addElement('static', 'url_display', get_string('url', 'taoresource') . ': ', '');
         $mform->addElement('static', 'taoresourcefile', get_string('file') . ': ', '');
     } else {
         $mform->addElement('text', 'url', get_string('url', 'taoresource'), array('size' => '48'));
         $mform->setHelpButton('url', array('url', get_string('url', 'taoresource'), 'taoresource'));
         $mform->addElement('file', 'taoresourcefile', get_string('file'), 'size="40"');
         $mform->setHelpButton('taoresourcefile', array('taoresourcefile', get_string('file'), 'taoresource'));
     }
     $mform->addElement('text', 'Contributor', get_string('contributor', 'taoresource'), array('size' => '48'));
     $mform->setHelpButton('Contributor', array('contributor', get_string('contributor', 'taoresource'), 'taoresource'));
     $mform->addElement('date_selector', 'IssueDate', get_string('issuedate', 'taoresource'), array('optional' => true));
     $mform->setHelpButton('IssueDate', array('issuedate', get_string('issuedate', 'taoresource'), 'taoresource'));
     $mform->addElement('text', 'TypicalAgeRange', get_string('typicalagerange', 'taoresource'), array('size' => '48'));
     $mform->setHelpButton('TypicalAgeRange', array('typicalagerange', get_string('typicalagerange', 'taoresource'), 'taoresource'));
     $mform->addElement('text', 'LearningResourceType', get_string('learningresourcetype', 'taoresource'), array('size' => '48'));
     $mform->setHelpButton('LearningResourceType', array('learningresourcetype', get_string('learningresourcetype', 'taoresource'), 'taoresource'));
     $mform->addElement('text', 'Rights', get_string('rights', 'taoresource'), array('size' => '48'));
     $mform->setHelpButton('Rights', array('rights', get_string('rights', 'taoresource'), 'taoresource'));
     $mform->setAdvanced('Rights');
     $mform->addElement('text', 'RightsDescription', get_string('rightsdescription', 'taoresource'), array('size' => '48'));
     $mform->setHelpButton('RightsDescription', array('rightsdescription', get_string('rightsdescription', 'taoresource'), 'taoresource'));
     $mform->setAdvanced('RightsDescription');
     $mform->addElement('text', 'ClassificationPurpose', get_string('classificationpurpose', 'taoresource'), array('size' => '48'));
     $mform->setHelpButton('ClassificationPurpose', array('classificationpurpose', get_string('classificationpurpose', 'taoresource'), 'taoresource'));
     $mform->setAdvanced('ClassificationPurpose');
     $mform->addElement('text', 'ClassificationTaxonPath', get_string('classificationtaxonpath', 'taoresource'), array('size' => '48'));
     $mform->setHelpButton('ClassificationTaxonPath', array('classificationtaxonpath', get_string('classificationtaxonpath', 'taoresource'), 'taoresource'));
     $mform->setAdvanced('ClassificationTaxonPath');
     // let the plugins see the form definition
     $plugins = taoresource_get_plugins();
     foreach ($plugins as $plugin) {
         $rc = $plugin->taoresource_entry_definition($mform);
         if (!$rc) {
             break;
         }
     }
     $btext = '';
     if (taoresource_extra_resource_screen()) {
         $btext = get_string('step2', 'taoresource');
     } else {
         $btext = get_string($this->taoresource_entry_mode . 'taoresource', 'taoresource');
     }
     $this->add_action_buttons(true, $btext);
     // mark this as the first step page
     $mform->addElement('hidden', 'pagestep', 1);
     //        }
 }
Ejemplo n.º 2
0
             $taoresource_entry->file = $formdata->file;
             $taoresource_entry->tempfilename = $CFG->dataroot . TAORESOURCE_TEMPPATH . $taoresource_entry->file;
         }
     }
 }
 // common update or add tasks
 // now that we know what the identifier will be - add the elements
 foreach ($formdata as $key => $value) {
     if (!in_array($key, $ignore_list) && !empty($value)) {
         $taoresource_entry->update_element($key, clean_param($value, PARAM_CLEAN));
     }
 }
 // if we need to do step 2 - defer the add/update, and load up the extra form
 // hide all values retrieved so far in hidden
 // put the file into temp for later
 if ($pagestep == 1 && taoresource_extra_resource_screen()) {
     // setup the new form, and hide away all the values we have so far
     $mform = new mod_taoresource_taoresource_entry_extra_form($mode);
     $mform->set_data($taoresource_entry);
     $hidden = array();
     foreach ($formdata as $key => $value) {
         if (!in_array($key, $ignore_list) && !empty($value)) {
             $mform->_form->addElement('hidden', $key, $value);
             $hidden[] = $key;
         }
     }
     $mform->_form->addElement('hidden', 'taoresource_hidden', join('|', $hidden));
 } else {
     if ($mode == 'add' && !$taoresource_entry->add_instance()) {
         error('Resource failed to save (add) to the DB');
     } else {