Example #1
0
 function handleVideoForm($form_values)
 {
     global $base_url;
     module_load_include('php', 'Fedora_Repository', 'api/fedora_item');
     $dom = new DomDocument("1.0", "UTF-8");
     $dom->formatOutput = true;
     $pid = $form_values['pid'];
     $title = $form_values['vid_nomenclature'];
     $rootElement = $dom->createElement("foxml:digitalObject");
     $rootElement->setAttribute('VERSION', '1.1');
     $rootElement->setAttribute('PID', "{$pid}");
     $rootElement->setAttribute('xmlns:foxml', "info:fedora/fedora-system:def/foxml#");
     $rootElement->setAttribute('xmlns:xsi', "http://www.w3.org/2001/XMLSchema-instance");
     $rootElement->setAttribute('xsi:schemaLocation', "info:fedora/fedora-system:def/foxml# http://www.fedora.info/definitions/1/0/foxml1-1.xsd");
     $dom->appendChild($rootElement);
     //create standard fedora stuff
     $this->createStandardFedoraStuff($form_values, $dom, $rootElement);
     //create relationships
     $this->createRelationShips($form_values, $dom, $rootElement);
     //create dublin core
     $myForm = array();
     $myForm['dc:title'] = $title;
     $this->createQDCStream($myForm, $dom, $rootElement);
     //create mag metadata
     module_load_include('php', 'Fedora_Repository', 'epistemetec/plugins/FileManipulation');
     $audio = new FileManipulation();
     $audio->getVideoMetadata($form_values);
     $ccks = array();
     module_load_include('php', 'Fedora_Repository', 'epistemetec/plugins/Node');
     $node = new EpistemetecNode();
     $ccks = $node->hashCCK($form_values, VIDEO_DL);
     $nid = $node->createNode($ccks, ITEM_DL);
     $form_values['dru_nurl'] = $base_url . '/node/' . $nid;
     $form_values['dru_nid'] = $nid;
     //$form_values['dru_nid'] = $base_url . '/node/' . $node->createNode($ccks, ITEM_DL);
     $this->createMAGStream($form_values, $dom, $rootElement, 'video');
     if (!empty($form_values['ingest-file-location'])) {
         $this->createFedoraDataStreams($form_values, $dom, $rootElement);
     }
     $collectionPid = $form_values['collection_pid'];
     $this->createPolicy($collectionPid, &$dom, &$rootElement);
     try {
         $object = Fedora_Item::ingest_from_FOXML($dom);
         $path = drupal_get_path('module', 'Fedora_Repository');
         $file = $path . "/epistemetec/files/cover-video.png";
         $object->add_datastream_from_file($file, "TN", "Thumbnail");
         if (!empty($object->pid)) {
             drupal_set_message("Item " . l($object->pid, 'fedora/repository/' . $object->pid) . " created successfully.", "status");
             //TODO: creare qui il nuovo nodo drupal e caricare il valore del pid in un campo CCK
         }
         if (!empty($_SESSION['fedora_ingest_files'])) {
             foreach ($_SESSION['fedora_ingest_files'] as $dsid => $createdFile) {
                 file_delete($createdFile);
             }
         }
         file_delete($form_values['ingest-file-location']);
         $node->addNodeReference($ccks);
     } catch (exception $e) {
         node_delete($nid);
         drupal_set_message(t('Error Ingesting Object! ') . $e->getMessage(), 'error');
         watchdog(t("Fedora_Repository"), t("Error Ingesting Object!") . $e->getMessage(), NULL, WATCHDOG_ERROR);
         return;
     }
 }
 function handleBookForm($form_values)
 {
     global $base_url;
     //		print_r($form_values);
     //		exit;
     module_load_include('php', 'Fedora_Repository', 'api/fedora_item');
     module_load_include('php', 'Fedora_Repository', 'epistemetec/plugins/FileManipulation');
     $dom = new DomDocument("1.0", "UTF-8");
     $dom->formatOutput = true;
     $pid = $form_values['pid'];
     $title = $form_values['gen_collection'];
     $rootElement = $dom->createElement("foxml:digitalObject");
     $rootElement->setAttribute('VERSION', '1.1');
     $rootElement->setAttribute('PID', "{$pid}");
     $rootElement->setAttribute('xmlns:foxml', "info:fedora/fedora-system:def/foxml#");
     $rootElement->setAttribute('xmlns:xsi', "http://www.w3.org/2001/XMLSchema-instance");
     $rootElement->setAttribute('xsi:schemaLocation', "info:fedora/fedora-system:def/foxml# http://www.fedora.info/definitions/1/0/foxml1-1.xsd");
     $dom->appendChild($rootElement);
     //create standard fedora stuff
     $this->createStandardFedoraStuff($form_values, $dom, $rootElement);
     //create relationships
     $this->createRelationShips($form_values, $dom, $rootElement);
     //create dublin core
     $myForm = array();
     $myForm['dc:title'] = $title;
     $this->createQDCStream($myForm, $dom, $rootElement);
     //create mag metadata
     //module_load_include('php', 'Fedora_Repository', 'plugins/EpistemetecImageManipulation');
     //		$image = new EpistemetecImageManipulation();
     //		$image->getMetadata($form_values);
     //		//$form_values['dru_nid'] = $base_url . '/node/' . $this->createNode($pid, $title);
     $file = new FileManipulation();
     $list = $file->manipulateZip($form_values['ingest-file-location']);
     $ccks = array();
     module_load_include('php', 'Fedora_Repository', 'epistemetec/plugins/Node');
     $node = new EpistemetecNode();
     $ccks = $node->hashCCK($form_values);
     $form_values['dru_nid'] = $base_url . '/node/' . $node->createNode($ccks, ITEM_DL);
     $this->createBookStream($form_values, $dom, $rootElement);
     //drupal_set_message($form_values['ingest-file-location']);
     if (!empty($form_values['ingest-file-location'])) {
         $this->createFedoraDataStreams($form_values, $dom, $rootElement);
     }
     $collectionPid = $form_values['collection_pid'];
     $this->createPolicy($collectionPid, &$dom, &$rootElement);
     try {
         $object = Fedora_Item::ingest_from_FOXML($dom);
         if (!empty($object->pid)) {
             drupal_set_message("Item " . l($object->pid, 'fedora/repository/' . $object->pid) . " created successfully.", "status");
             //TODO: creare qui il nuovo nodo drupal e caricare il valore del pid in un campo CCK
         }
         if (!empty($_SESSION['fedora_ingest_files'])) {
             foreach ($_SESSION['fedora_ingest_files'] as $dsid => $createdFile) {
                 file_delete($createdFile);
             }
         }
         file_delete($form_values['ingest-file-location']);
     } catch (exception $e) {
         node_delete($nid);
         drupal_set_message(t('Error Ingesting Object! ') . $e->getMessage(), 'error');
         watchdog(t("Fedora_Repository"), t("Error Ingesting Object!") . $e->getMessage(), NULL, WATCHDOG_ERROR);
         return;
     }
     $object = new Fedora_Item($pid);
     $path = drupal_get_path('module', 'Fedora_Repository');
     $stream = file_get_contents($path . "/epistemetec/xml/BOOK_COLLECTION_VIEW.xml");
     $object->add_datastream_from_string($stream, "COLLECTION_VIEW", "Collection View");
     $temp = explode(" ", $list[0]);
     $file = $temp[sizeof($temp) - 1];
     $image = new EpistemetecImageManipulation();
     $image = imageapi_image_open($file);
     imageapi_image_scale($image, 120, 120);
     $file = $file . "_TN";
     imageapi_image_close($image, $file);
     $object->add_datastream_from_file($file, "TN", "Thumbnail");
     $stream = $this->ingestPage($list, $form_values);
     $object->add_datastream_from_string($stream, "STRU", "Struttura Libro");
 }
Example #3
0
 function handleVideoEditForm($form_id, $form_values, $soap_client)
 {
     //echo "FORM_ID: ".$form_id;
     $pid = $form_values['pid'];
     module_load_include('php', 'Fedora_Repository', 'ObjectHelper');
     $object = new ObjectHelper($pid);
     $spec = $object->getStream($pid, 'MAG', TRUE);
     $xml = new SimpleXMLElement($spec);
     $dom = new DomDocument("1.0", "UTF-8");
     $dom->formatOutput = true;
     $mag = $dom->createElement("mag");
     //		$dom->appendChild($mag);
     $vid = $dom->createElement("video");
     $proxies = $dom->createElement("proxies");
     $metrics = $dom->createElement("video_metrics");
     $dimensions = $dom->createElement("video_dimensions");
     $format = $dom->createElement("format");
     $dis = $dom->createElement("dis");
     $gen = $dom->createElement("gen");
     $bib = $dom->createElement("bib");
     $drup = $dom->createElement("dru");
     $vid->appendChild($dom->createElement('sequence_number', implode($xml->xpath('//sequence_number'))));
     $proxies->appendChild($dom->createElement('size', implode($xml->xpath('//size'))));
     $proxies->appendChild($dom->createElement('md5', implode($xml->xpath('//md5'))));
     $proxies->appendChild($dom->createElement('file', implode($xml->xpath('//file'))));
     $metrics->appendChild($dom->createElement('framerate', implode($xml->xpath('//framerate'))));
     $dimensions->appendChild($dom->createElement('framewidth', implode($xml->xpath('//framewidth'))));
     $dimensions->appendChild($dom->createElement('frameheight', implode($xml->xpath('//frameheight'))));
     $metrics->appendChild($dom->createElement('bitrate', implode($xml->xpath('//bitrate'))));
     $format->appendChild($dom->createElement('mime', implode($xml->xpath('//mime'))));
     //		$vid->appendChild($dom->createElement('samplingfrequencyunit', implode($xml->xpath('//samplingfrequencyunit'))));
     //		$vid->appendChild($dom->createElement('samplingfrequencyplane', implode($xml->xpath('//samplingfrequencyplane'))));
     $dis->appendChild($dom->createElement('item', implode($xml->xpath('//item'))));
     $drup->appendChild($dom->createElement('nid', implode($xml->xpath('//nid'))));
     $drup->appendChild($dom->createElement('nurl', implode($xml->xpath('//nurl'))));
     $previousElement = null;
     //used in case we have to nest elements for qualified dublin core
     foreach ($form_values as $key => $value) {
         $index = strrpos($key, '-');
         if ($index > 01) {
             $key = substr($key, 0, $index);
         }
         $value = trim($value);
         $test = substr($key, 0, 3);
         $element = substr($key, 4);
         if ($test == 'vid') {
             //don't try to process other form values
             try {
                 $previousElement = $dom->createElement($element, $value);
                 if (in_array($element, array('file', 'md5', 'size', 'note'))) {
                     $proxies->appendChild($previousElement);
                 } elseif (in_array($element, array('bitrate', 'framerate'))) {
                     $metrics->appendChild($previousElement);
                 } elseif (in_array($element, array('framewidth', 'frameheight'))) {
                     $dimensions->appendChild($previousElement);
                 } elseif (in_array($element, array('mime'))) {
                     $format->appendChild($previousElement);
                 } else {
                     $vid->appendChild($previousElement);
                 }
             } catch (exception $e) {
                 drupal_set_message(t($e->getMessage()), 'error');
                 continue;
             }
         }
         if ($test == 'dis') {
             //don't try to process other form values
             try {
                 $previousElement = $dom->createElement(substr($key, 4), $value);
                 $dis->appendChild($previousElement);
             } catch (exception $e) {
                 drupal_set_message(t($e->getMessage()), 'error');
                 continue;
             }
         }
         if ($test == 'gen') {
             //don't try to process other form values
             try {
                 $previousElement = $dom->createElement(substr($key, 4), $value);
                 $gen->appendChild($previousElement);
             } catch (exception $e) {
                 drupal_set_message(t($e->getMessage()), 'error');
                 continue;
             }
         }
         if ($test == 'bib') {
             //don't try to process other form values
             try {
                 $previousElement = $dom->createElement(substr($key, 4), $value);
                 $bib->appendChild($previousElement);
             } catch (exception $e) {
                 drupal_set_message(t($e->getMessage()), 'error');
                 continue;
             }
         }
         if ($test == 'dru') {
             //don't try to process other form values
             try {
                 $previousElement = $dom->createElement(substr($key, 4), $value);
                 $drup->appendChild($previousElement);
             } catch (exception $e) {
                 drupal_set_message(t($e->getMessage()), 'error');
                 continue;
             }
         }
         //$rootElement->appendChild($datastream);
     }
     $proxies->appendChild($metrics);
     $proxies->appendChild($dimensions);
     $proxies->appendChild($format);
     $vid->appendChild($proxies);
     $mag->appendChild($vid);
     $mag->appendChild($gen);
     $mag->appendChild($bib);
     $mag->appendChild($dis);
     $mag->appendChild($drup);
     $dom->appendChild($mag);
     $params = array("pid" => "{$pid}", "dsID" => "MAG", "altIDs" => "", "dsLabel" => "Mag Metadata", "MIMEType" => "text/xml", "formatURI" => "", "dsContent" => $dom->saveXML(), "checksumType" => "DISABLED", "checksum" => "none", "logMessage" => "datastream_modified", "force" => "true");
     //drupal_set_message($mag);
     $ccks = array();
     module_load_include('php', 'Fedora_Repository', 'epistemetec/plugins/Node');
     $node = new EpistemetecNode();
     $ccks = $node->hashCCK($form_values);
     try {
         //$soapHelper = new ConnectionHelper();
         //$client = $soapHelper->getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl'));
         $object = $soap_client->__soapCall('ModifyDatastreamByValue', array($params));
         $node->editNode($ccks);
         return $form_id;
     } catch (exception $e) {
         drupal_set_message(t("Error updating  MAG metadata ") . $e->getMessage(), 'error');
     }
 }