コード例 #1
0
 function setIdentifier($form_values)
 {
     require_once drupal_get_path('module', 'Fedora_Repository') . '/ObjectHelper.php';
     require_once drupal_get_path('module', 'Fedora_Repository') . '/CollectionClass.php';
     $collectionHelper = new CollectionClass();
     $ppid = $_SESSION['pid'];
     $itqlquery = 'select $object from <#ri> where $object <fedora-rels-ext:isPartOf><info:fedora/' . $ppid . '> and $object <fedora-rels-ext:isMemberOfCollection><info:fedora/vre:mnpl-compounds>and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>';
     $relatedItems = $collectionHelper->getRelatedItems($this->pid, $itqlquery);
     $sxe = new SimpleXMLElement($relatedItems);
     $nmspace = $sxe->getNamespaces(true);
     $regspace = $sxe->registerXPathNamespace('ri', implode($nmspace));
     $link = $sxe->xpath('//@uri');
     $labid = $_SESSION['labid'];
     if (empty($link)) {
         $ident = $labid . '-C-0';
     } else {
         //loop through returns , trim to create identifier and increment highest value
         $xia = array();
         foreach ($link as $path) {
             $path1 = substr($path, '30');
             $path2 = strrchr($path1, "-");
             $path = str_replace($path2, '', $path1);
             $xi = ltrim($path2, "-");
             $xnew = array_push($xia, $xi);
         }
         $num = max($xia);
         $numinc = $num + 1;
         $ident = $labid . '-C-' . $numinc;
     }
     return $ident;
 }
コード例 #2
0
function get_RIQueryResults($pid, $query)
{
    module_load_include('php', 'Fedora_Repository', 'CollectionClass');
    $collectionClass = new CollectionClass();
    $results = $collectionClass->getRelatedItems($pid, $query);
    return $results;
}
コード例 #3
0
ファイル: EditStreams.php プロジェクト: ratzeni/islandora
 function handleSpecimenEditForm($form_id, $form_values, $soap_client)
 {
     // ======================================
     // = begin creation of foxml dom object for critter/specimen stream=
     // ======================================
     module_load_include('php', 'Fedora_Repository', 'ObjectHelper');
     $objectHelper = new ObjectHelper();
     $critterStream = $objectHelper->getStream($form_values['pid'], 'CRITTER', true);
     $sxec = new SimpleXMLElement($critterStream);
     $dom = new DomDocument("1.0", "UTF-8");
     $dom->formatOutput = true;
     ///begin writing critter datastream
     $spec = $dom->createElement("critters:sample");
     $spec->setAttribute('xmlns:critters', "http://vre.upei.ca/critters/");
     $spec->setAttribute('name', implode($sxec->xpath('//@name')));
     // critter sample (root) elements
     $date = $dom->createElement("critters:date_collected", $form_values['date']);
     $size = $dom->createElement("critters:samplesize", implode($sxec->xpath('//critters:samplesize')));
     $lab_id = $dom->createElement("critters:lab_id", implode($sxec->xpath('//critters:lab_id')));
     $type = $dom->createElement("critters:type", $form_values['type']);
     $desc = $dom->createElement("critters:description", implode($sxec->xpath('//critters:description')));
     $spec->appendChild($lab_id);
     $spec->appendChild($type);
     $spec->appendChild($date);
     $spec->appendChild($size);
     $spec->appendChild($desc);
     //critter taxonomy elements
     $taxon = $dom->createElement("critters:taxonomy");
     $phylum = $dom->createElement("critters:phylum", $form_values['phylum']);
     $subphylum = $dom->createElement("critters:subPhylum", $form_values['subphylum']);
     $class = $dom->createElement("critters:class", $form_values['class']);
     $order = $dom->createElement("critters:order", $form_values['order']);
     $family = $dom->createElement("critters:family", $form_values['family']);
     $genus = $dom->createElement("critters:genus", $form_values['genus']);
     $species = $dom->createElement("critters:species", $form_values['species']);
     $taxon->appendChild($phylum);
     $taxon->appendChild($subphylum);
     $taxon->appendChild($class);
     $taxon->appendChild($order);
     $taxon->appendChild($family);
     $taxon->appendChild($genus);
     $taxon->appendChild($species);
     // critter photos
     $photos = $dom->createElement("critters:photos");
     $photos->setAttribute('quantity', implode($sxec->xpath('//@quantity')));
     foreach ($sxec->xpath('//@id') as $idkey => $photo) {
         $image = $dom->createElement("critters:photo");
         $image->setAttribute('id', $photo);
         foreach ($sxec->xpath('//critters:location') as $key => $value) {
             if ($key == $idkey) {
                 $location = $dom->createElement("critters:location", $value);
                 $image->appendChild($location);
             }
         }
         $photos->appendChild($image);
     }
     // critter site elements
     $site = $dom->createElement("critters:site");
     $sitename = $dom->createElement("critters:sitename", $form_values['sitename']);
     $country = $dom->createElement("critters:country", $form_values['country']);
     $region = $dom->createElement("critters:region", $form_values['region']);
     $latitude = $dom->createElement("critters:latitude", $form_values['latitude']);
     $longitude = $dom->createElement("critters:longitude", $form_values['longitude']);
     $depth = $dom->createElement("critters:depth", $form_values['depth']);
     $site->appendChild($sitename);
     $site->appendChild($country);
     $site->appendChild($region);
     $site->appendChild($latitude);
     $site->appendChild($longitude);
     $site->appendChild($depth);
     // critter collectors
     $collectors = $dom->createElement("critters:collectors");
     foreach ($sxec->xpath('//critters:collector') as $individual) {
         $collector = $dom->createElement("critters:collector", $individual);
         $collectors->appendChild($collector);
     }
     // append nested elements
     $spec->appendChild($taxon);
     $spec->appendChild($photos);
     $spec->appendChild($site);
     $spec->appendChild($collectors);
     $dom->appendChild($spec);
     $newxml = $dom->saveXML();
     // map critter form elements to DC stream
     // loop through taxonomy to create label pulled from dctitle
     if ($form_values['species'] != '' and $form_values['genus'] != '') {
         $label = " <i>" . $form_values['genus'] . " " . $form_values['species'] . "</i>";
     } elseif ($form_values['species'] != '' and $form_values['genus'] == '') {
         $label = " <i>" . $form_values['species'] . "</i>";
     } elseif ($form_values['species'] == '' and $form_values['genus'] != '') {
         $label = " <i>" . $form_values['genus'] . "</i>";
     } elseif ($form_values['species'] == '' and $form_values['genus'] == '' and $form_values['family'] != '') {
         $label = " " . $form_values['family'];
     } elseif ($form_values['species'] == '' and $form_values['genus'] == '' and $form_values['family'] == '' and $form_values['order'] != '') {
         $label = " " . $form_values['order'];
     } elseif ($form_values['species'] == '' and $form_values['genus'] == '' and $form_values['family'] == '' and $form_values['order'] == '' and $form_values['class'] != '') {
         $label = " " . $form_values['class'];
     } elseif ($form_values['species'] == '' and $form_values['genus'] == '' and $form_values['family'] == '' and $form_values['order'] == '' and $form_values['class'] == '' and $form_values['subphylum'] != '') {
         $label = " " . $form_values['subphylum'];
     } elseif ($form_values['species'] == '' and $form_values['genus'] == '' and $form_values['family'] == '' and $form_values['order'] == '' and $form_values['class'] == '' and $form_values['subphylum'] == '' and $form_values['phylum'] != '') {
         $label = " " . $form_values['phylum'];
     }
     $dom2 = new DomDocument("1.0", "UTF-8");
     $dom2->formatOutput = true;
     ///begin writing dc datastream
     $oai = $dom2->createElement("oai_dc:dc");
     $oai->setAttribute('xmlns:oai_dc', "http://www.openarchives.org/OAI/2.0/oai_dc/");
     $oai->setAttribute('xmlns:dc', "http://purl.org/dc/elements/1.1/");
     $oai->setAttribute('xmlns:dcterms', "http://purl.org/dc/terms/");
     $oai->setAttribute('xmlns:xsi', "http://www.w3.org/2001/XMLSchema-instance");
     $dctitle = $dom2->createElement("dc:title", implode($sxec->xpath('//critters:lab_id')) . $label);
     $dccreator = $dom2->createElement("dc:creator", 'Marine Natural Products Lab, University of Prince Edward Island');
     // list specimen taxonomy as dc:subject
     $dcphylum = $dom2->createElement("dc:subject", $form_values['phylum']);
     $dcsubphylum = $dom2->createElement("dc:subject", $form_values['subphylum']);
     $dcclass = $dom2->createElement("dc:subject", $form_values['class']);
     $dcorder = $dom2->createElement("dc:subject", $form_values['order']);
     $dcfamily = $dom2->createElement("dc:subject", $form_values['family']);
     $dcgenus = $dom2->createElement("dc:subject", $form_values['genus']);
     $dcspecies = $dom2->createElement("dc:subject", $form_values['species']);
     // end taxonomy
     $dcdesc = $dom2->createElement("dc:description", implode($sxec->xpath('//critters:description')));
     $dcpublisher = $dom2->createElement("dc:publisher", 'Marine Natural Products Lab, University of Prince Edward Island');
     $dcpid = $dom2->createElement("dc:identifier", $form_values['pid']);
     $dcident = $dom2->createElement("dc:identifier", implode($sxec->xpath('//critters:lab_id')));
     $dcid = $dom2->createElement("dc:identifier", implode($sxec->xpath('//@name')));
     $dcdate = $dom2->createElement("dc:date", implode($sxec->xpath('//critters:date_collected')));
     $dctype = $dom2->createElement("dc:type", implode($sxec->xpath('//critters:type')));
     $dcformat = $dom2->createElement("dc:format", 'text/html');
     $dclang = $dom2->createElement("dc:language", 'eng');
     $dcsource = $dom2->createElement("dc:source", '');
     $dcrelation = $dom2->createElement("dc:relation", 'vre:mnpl-specimens');
     $dcrights = $dom2->createElement("dc:rights", 'All Rights Reserved - Marine Natural Products Lab. For permission to use this material please contact MNPL at rkerr@upei.ca.');
     // append elements
     $oai->appendChild($dctitle);
     $oai->appendChild($dccreator);
     $oai->appendChild($dcphylum);
     $oai->appendChild($dcsubphylum);
     $oai->appendChild($dcclass);
     $oai->appendChild($dcorder);
     $oai->appendChild($dcfamily);
     $oai->appendChild($dcgenus);
     $oai->appendChild($dcspecies);
     $oai->appendChild($dcdesc);
     $oai->appendChild($dcpublisher);
     //loop for contributors
     foreach ($sxec->xpath('//critters:collector') as $individual) {
         $dccontrib = $dom2->createElement("dc:contributor", $individual);
         $oai->appendChild($dccontrib);
     }
     $oai->appendChild($dcdate);
     $oai->appendChild($dctype);
     $oai->appendChild($dcformat);
     $oai->appendChild($dcpid);
     $oai->appendChild($dcident);
     $oai->appendChild($dcid);
     $oai->appendChild($dcsource);
     $oai->appendChild($dcrelation);
     $oai->appendChild($dcrights);
     $dom2->appendChild($oai);
     $dcxml = $dom2->saveXML();
     $params = array("pid" => $form_values['pid'], "dsID" => 'DC', "altIDs" => "", "dsLabel" => "Dublin Core Record", "MIMEType" => "text/xml", "formatURI" => "URL", "dsContent" => $dcxml, "checksumType" => "DISABLED", "checksum" => "none", "logMessage" => "datastream_modified", "force" => "true");
     $soapHelper = new ConnectionHelper();
     $client = $soapHelper->getSoapClient(variable_get('fedora_soap_manage_url', 'http://*****:*****@uri') as $link) {
         $partpid = ltrim($link, 'info:fedora/');
         $params = array("pid" => $partpid, "dsID" => $dsId, "altIDs" => "", "dsLabel" => "Parent Critter Record", "MIMEType" => "text/xml", "formatURI" => "URL", "dsContent" => $newxml, "checksumType" => "DISABLED", "checksum" => "none", "logMessage" => "datastream_modified", "force" => "true");
         $soapHelper = new ConnectionHelper();
         $client = $soapHelper->getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl'));
         $object = $client->__soapCall('ModifyDatastreamByValue', array($params));
     }
     // end of update other datastreams   - begin soap call for main critter record
     $params = array("pid" => $pid, "dsID" => $dsId, "altIDs" => "", "dsLabel" => "CRITTER", "MIMEType" => "text/xml", "formatURI" => "URL", "dsContent" => $newxml, "checksumType" => "DISABLED", "checksum" => "none", "logMessage" => "datastream_modified", "force" => "true");
     try {
         $soapHelper = new ConnectionHelper();
         $client = $soapHelper->getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl'));
         if ($client == null) {
             drupal_set_message(t('Error Getting Soap Client.'), 'error');
             return;
         }
         $object = $client->__soapCall('ModifyDatastreamByValue', array($params));
         return true;
     } catch (exception $e) {
         drupal_set_message(t('Error Editing Specimen! ') . $e->getMessage(), 'error');
         watchdog(t("Fedora_Repository"), t("Error Editing Specimen!") . $e->getMessage(), WATCHDOG_ERROR);
         return;
     }
 }
コード例 #4
0
 function showCompound()
 {
     $dsid = 'COMPOUND';
     $path = drupal_get_path('module', 'Fedora_Repository');
     require_once drupal_get_path('module', 'Fedora_Repository') . '/ObjectHelper.php';
     require_once drupal_get_path('module', 'Fedora_Repository') . '/CollectionClass.php';
     $collectionHelper = new CollectionClass();
     $xmlstr = $collectionHelper->getStream($this->pid, "COMPOUND");
     html_entity_decode($xmlstr);
     if ($xmlstr == null || strlen($xmlstr) < 5) {
         return " ";
     }
     try {
         $proc = new XsltProcessor();
     } catch (Exception $e) {
         drupal_set_message(t($e->getMessage()), 'error');
         return " ";
     }
     $xsl = new DomDocument();
     $xsl->load($path . '/mnpl/xsl/compound.xsl');
     $input = new DomDocument();
     $input->loadXML(trim($xmlstr));
     $xsl = $proc->importStylesheet($xsl);
     $newdom = $proc->transformToDoc($input);
     $content = $newdom->saveXML();
     // get parent pid and build link
     $pid = $this->pid;
     $itqlquery = 'select $object from <#ri> where <info:fedora/' . $pid . '><fedora-rels-ext:isPartOf> $object ';
     $relatedItems = $collectionHelper->getRelatedItems($this->pid, $itqlquery);
     $sxe = new SimpleXMLElement($relatedItems);
     $nmspace = $sxe->getNamespaces(true);
     $regspace = $sxe->registerXPathNamespace('ri', implode($nmspace));
     // begin fractions
     $flabel = '<h4>Parent Specimen Record for This Compound</h4><p>';
     $link = implode($sxe->xpath('//@uri'));
     $link = substr($link, 12);
     global $base_url;
     $plink .= '<a href =' . $base_url . '/fedora/repository/' . $link . '>Parent Specimen</a><br>';
     if (user_access('edit fedora meta data')) {
         $editcomp = '<a href =' . $base_url . '/fedora/repository/editmetadata/' . $pid . '/' . $dsid . '>Edit This Compound</a><br>';
     } else {
         $editcomp = '';
     }
     // display other compounds for this parent
     $itqlQuery = 'select $object $title  from <#ri> where $object <fedora-model:label> $title  and $object <fedora-rels-ext:isPartOf> <info:fedora/' . $link . '> and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active> order by $title';
     $relatedItems = $collectionHelper->getRelatedItems($this->pid, $itqlQuery);
     $sxe = new SimpleXMLElement($relatedItems);
     $nmspace = $sxe->getNamespaces(true);
     $regspace = $sxe->registerXPathNamespace('ri', implode($nmspace));
     // begin display compounds
     global $base_url;
     $altcomp = '<h4> Other Compounds For Parent Sepcimen</h4><div>';
     if (stristr(implode($sxe->xpath('//ri:title')), 'compound')) {
         foreach ($sxe->xpath('//@uri') as $link2) {
             if (strstr($link2, 'compound')) {
                 $pidlink = substr($link2, 12);
                 if ($pidlink != $pid) {
                     $compound .= '<a href = "' . $base_url . '/fedora/repository/' . $pidlink . '">' . substr($link2, 30) . '</a><br>';
                 }
             }
         }
     }
     if ($compound == NULL) {
         $compound = "<div>No other Compounds present for this Specimen</div>";
     }
     $collection_fieldset = array('#title' => t('MNPL Compound Record'), '#collapsible' => TRUE, '#collapsed' => FALSE, '#value' => $content . $editcomp . $flabel . $plink . $altcomp . $compound);
     return theme('fieldset', $collection_fieldset);
 }
コード例 #5
0
    function showCritter()
    {
        $path = drupal_get_path('module', 'Fedora_Repository');
        module_load_include('php', 'Fedora_Repository', 'ObjectHelper');
        module_load_include('php', 'Fedora_Repository', 'CollectionClass');
        $collectionHelper = new CollectionClass();
        $xmlstr = $collectionHelper->getStream($this->pid, "CRITTER");
        html_entity_decode($xmlstr);
        if ($xmlstr == null || strlen($xmlstr) < 5) {
            return " ";
        }
        try {
            $proc = new XsltProcessor();
        } catch (Exception $e) {
            drupal_set_message(t($e->getMessage()), 'error');
            return " ";
        }
        $xsl = new DomDocument();
        $xsl->load($path . '/xsl/critter.xsl');
        $input = new DomDocument();
        $input->loadXML(trim($xmlstr));
        $xsl = $proc->importStylesheet($xsl);
        $newdom = $proc->transformToDoc($input);
        $content = $newdom->saveXML();
        $collection_fieldset = array('#title' => t('MNPL Critter Record'), '#collapsible' => TRUE, '#collapsed' => FALSE, '#value' => $content);
        $pid = $this->pid;
        $itqlQuery = 'select $object $title $content from <#ri>
														where $object <rdf:type> <fedora-model:FedoraObject>
														and $object <fedora-model:label> $title
														and $object <fedora-model:contentModel> $content
			 											and $object <fedora-rels-ext:isMemberOf> <info:fedora/' . $pid . '>
			 											and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active> order by $title';
        $relatedItems = $collectionHelper->getRelatedItems($this->pid, $itqlQuery);
        return theme('fieldset', $collection_fieldset);
    }
コード例 #6
0
ファイル: ObjectHelper.php プロジェクト: ratzeni/islandora
 function get_content_models_list($pid, $include_fedora_system_content_models = FALSE)
 {
     module_load_include('php', 'Fedora_Repository', 'CollectionClass');
     $collectionHelper = new CollectionClass();
     $pids = array();
     $query = 'select $object from <#ri>
         where <info:fedora/' . $pid . '> <fedora-model:hasModel> $object
         and $object <fedora-model:state> <info:fedora/fedora-system:def/model#Active>';
     $content_models = $collectionHelper->getRelatedItems($pid, $query);
     if (empty($content_models)) {
         return $pids;
     }
     try {
         $sxml = new SimpleXMLElement($content_models);
     } catch (exception $e) {
         watchdog(t("Fedora_Repository"), t("Could not find a parent object for %s", $pid), NULL, WATCHDOG_ERROR);
         return $pids;
     }
     if (!isset($sxml)) {
         return $pids;
     }
     foreach ($sxml->xpath('//@uri') as $uri) {
         if (strpos($uri, 'fedora-system') != FALSE && $include_fedora_system_content_models == FALSE) {
             continue;
         }
         $pids[] = substr(strstr($uri, '/'), 1);
     }
     return $pids;
 }