示例#1
0
 function addStreamFormSubmit($form_id, $form_values)
 {
     module_load_include('inc', 'Fedora_Repository', 'api/fedora_utils');
     module_load_include('inc', 'Fedora_Repository', 'api/fedora_item');
     module_load_include('php', 'Fedora_Repository', 'ObjectHelper');
     $types = array('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.wordperfect', 'application/wordperfect', 'application/vnd.oasis.opendocument.text', 'text/rtf', 'application/rtf', 'application/msword', 'application/vnd.ms-powerpoint', 'application/pdf');
     global $user;
     /* TODO Modify the validators array to suit your needs.
        This array is used in the revised file_save_upload */
     $fileObject = file_save_upload('file_uploaded');
     if (!in_array($fileObject->filemime, $types)) {
         drupal_set_message(t('The detected mimetype %s is not supported', array('%s' => $fileObject->filemime)), 'error');
         return false;
     }
     file_move($fileObject->filepath, 0, 'FILE_EXISTS_RENAME');
     $objectHelper = new ObjectHelper();
     $pid = $form_values['pid'];
     $fedora_item = new Fedora_Item($pid);
     $test = NULL;
     $test = $fedora_item->add_datastream_from_file($fileObject->filepath, 'OBJ');
     if ($test) {
         $this->updateMODSStream($form_values['pid'], $form_values['version'], $form_values['usage']);
     }
     file_delete($fileObject->filepath);
     return true;
 }
 function handleVideoCollectionForm($form_values)
 {
     $this->handleQDCForm($form_values);
     $pid = $form_values["pid"];
     $object = new Fedora_Item($pid);
     $path = drupal_get_path('module', 'Fedora_Repository');
     $stream = file_get_contents($path . "/epistemetec/xml/VIDEO_COLLECTION_POLICY.xml");
     $object->add_datastream_from_string($stream, "COLLECTION_POLICY", "Collection Policy");
     $file = $path . "/epistemetec/files/cover-video.png";
     $object->add_datastream_from_file($file, "TN", "Thumbnail");
     $this->createNode($form_values);
 }