Пример #1
0
 function manipulateImage($parameterArray = null, $dsid, $file, $file_ext, $folder)
 {
     $height = $parameterArray['height'];
     $width = $parameterArray['width'];
     $file_suffix = '_' . $dsid . '.' . $file_ext;
     $returnValue = TRUE;
     $image = imageapi_image_open($file);
     if (!$image) {
         drupal_set_message(t("Error opening image"));
         return false;
     }
     if (!empty($height) || !empty($width)) {
         $returnValue = imageapi_image_scale($image, $height, $width);
     }
     if (!$returnValue) {
         drupal_set_message(t("Error scaling image"));
         return $returnValue;
     }
     $filename = substr(strrchr($file, '/'), 1);
     $output_path = $_SERVER['DOCUMENT_ROOT'] . base_path() . file_directory_path() . '/' . $folder . '/' . $filename . $file_suffix;
     $returnValue = imageapi_image_close($image, $output_path);
     if ($returnValue) {
         $_SESSION['fedora_ingest_files']["{$dsid}"] = $file . $file_suffix;
         return TRUE;
     } else {
         return $returnValue;
     }
 }
Пример #2
0
 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");
 }