$v ) // Yii::info ( "KEY: " . $k . " -- " . $v ); $filters = array (); $filters ['unitID'] = $_REQUEST ['unitID']; if (isset ( $_REQUEST ['collectioncode'] )) $filters ['collectioncode'] = $_REQUEST ['collectioncode']; else $filters ['collectioncode'] = NULL; if (isset ( $_REQUEST ['institutioncode'] )) $filters ['institutioncode'] = $_REQUEST ['institutioncode']; else $filters ['institutioncode'] = NULL; $gbifIDs = [ ]; $colID = ""; $ncbiID = ""; $config = SOLRQueryManager::getConfigSearch (); $query = SOLRQueryManager::createSearchQuery ( $config ); $raw_response = SOLRQueryManager::fillAndExecuteQuery ( $query, "*:*", null, $filters, True ); $response = $raw_response; // Yii::info ( "nb res: " . $response->getNumFound () ); if ($response->getNumFound () == 0) { return [ ]; } $tripleidstoreid = ""; foreach ( $response as $doc ) { $tripleidstoreid = $doc->tripleidstoreid; // echo $tripleidstoreid; } $config = SOLRQueryManager::getConfigDetails (); $query = SOLRQueryManager::createSearchQuery ( $config ); $response = SOLRQueryManager::fillAndExecuteQuery ( $query, "tripleidstoreid:" . $tripleidstoreid, null, [ ], True ); if ($response->getNumFound () == 0) { return [ ]; } $multimedia = ""; $loan = [ ]; foreach ( $response as $doc ) { $upperTripleidstoreids = [ ]; $accesspoint = $doc->accesspoint; $unitID = $doc->unitID; $collectioncode = $doc->collectioncode; $institutioncode = $doc->institutioncode; $schemaurl = $doc->schemaurl; $digirresourcename = $doc->digirresourcename; $schemaname = $doc->schemaname; $basedirectory = $doc->basedirectory; $sampletype = $doc->sampletype; $tripleidstoreid = $doc->tripleidstoreid; $fullScientificName = $doc->originalName; $occurrenceFile = $doc->filename; $elementtype = $doc->elementtype; $collectors = $doc->collectors; $collectornb = $doc->collectornumbers_nc; try { $indexHerbarorium = $doc->indexHerbarorium; } catch ( Exception $e ) { $indexHerbarorium = null; } if (! empty ( $collectornb )) { $collectornb = array_unique ( $collectornb ); if (($key = array_search ( 's.n.', $collectornb )) !== false) { unset ( $collectornb [$key] ); } } try { $latitude = $doc->latitude; } catch ( Exception $e ) { $latitude [] = NULL; } try { $longitude = $doc->longitude; } catch ( Exception $e ) { $longitude [] = NULL; } try { $canonicalName = $doc->canonicalName; } catch ( Exception $e ) { $canonicalName = ""; } try { $citesStatus = $doc->citesStatus; } catch ( Exception $e ) { $citesStatus = NULL; } try { $gbifIDs [] = $doc->gbifKey; } catch ( Exception $e ) { } try { $colID = $doc->taxonIDcol; } catch ( Exception $e ) { } try { $ncbiID = $doc->taxonIDncbi; } catch ( Exception $e ) { } try { $upperTripleidstoreids = $doc->upperTripleidstoreids; } catch ( Exception $e ) { $upperTripleidstoreids = [ ]; } if ($upperTripleidstoreids == "") $upperTripleidstoreids = [ ]; try { $tmpids = $doc->lowerTripleidstoreids; if (isset ( $tmpids )) array_merge ( $upperTripleidstoreids, $tmpids ); } catch ( Exception $e ) { } try { if (isset ( $doc->multimediaurl )) foreach ( $doc->multimediaurl as $murl ) { if ($murl != "N/A") { if (! (strpos ( $multimedia, $murl ) === FALSE)) continue; else { if (strpos ( $murl, "http" ) === FALSE) { $murl = "http://" . $murl; } $multimedia = $multimedia . "  "; } } } } catch ( Exception $e ) { } $blocked = $doc->blocked; $blockedUntil = $doc->blockedUntil; $disposition = $doc->disposition; $disposition_clean = $doc->disposition_clean; $condition = $doc->condition; if (empty ( $blockedUntil )) { if ($sampletype == "tissue") $loan [$unitID] = [ " Tissue available ", "OK", "not blocked", $condition, $disposition_clean ]; if ($sampletype == "DNA") $loan [$unitID] = [ " DNA available ", "OK", "not blocked", $condition, $disposition_clean ]; } else { if (new \DateTime () > new \DateTime ( $blockedUntil )) { // $loan [] = "The unitID " . $unitID . " was blocked until " . $blockedUntil . " under the condition " . $condition . ". There is still " . $disposition_clean . " available."; if ($sampletype == "tissue") $loan [$unitID] = [ " Tissue available ", "OK", "was blocked until " . $blockedUntil, $condition, $disposition_clean ]; if ($sampletype == "DNA") $loan [$unitID] = [ " DNA available ", "OK", "was blocked until " . $blockedUntil, $condition, $disposition_clean ]; } else { if ($sampletype == "tissue") $loan [$unitID] = [ " Tissue available ", "BLOCKED", "is blocked until " . $blockedUntil, $condition, $disposition_clean ]; if ($sampletype == "DNA") $loan [$unitID] = [ " DNA available ", "BLOCKED", "is blocked until " . $blockedUntil, $condition, $disposition_clean ]; } } } if (isset ( $upperTripleidstoreids [0] )) { $tripleidstoreids = SingleRecordManager::getListOfTripleids ( $upperTripleidstoreids, $model ); // remove the tripleidstoreid from the unit already searched unset ( $tripleidstoreids [array_search ( $tripleidstoreid, $tripleidstoreids )] ); $tripleidstoreids = array_values ( $tripleidstoreids ); $SumSize = count ( $tripleidstoreids ); $config = SOLRQueryManager::getConfigDetails (); $query = SOLRQueryManager::createSearchQuery ( $config ); $fq = ""; for($i = 0; $i < $SumSize; $i ++) { $fq .= "tripleidstoreid:" . $tripleidstoreids [$i]; if (isset ( $tripleidstoreids [$i + 1] )) { $fq .= " OR "; } } // Yii::info ( "fq: " . $fq ); if ($fq == "") { $index = 0; // $accesspoint2 [$index] = "missing"; // $unitID2 [$index] = "missing"; // $tripleid2 [$index] = "missing"; // $collectioncode2 [$index] = "missing"; // $institutioncode2 [$index] = "missing"; // $schemaurl2 [$index] = "missing"; // $schemaname2 [$index] = "missing"; // $basedirectory2 [$index] = "missing"; // $sampletype2 [$index] = "missing"; // $recordBasis2 [$index] = "missing"; // $digirresourcename2 [$index] = "missing"; // $latitude2 [$index] = NULL; // $longitude2 [$index] = NULL; // $filters ['unitID2'] [$index] = "missing"; // $filters ['collectioncode2'] [$index] = "missing"; // $filters ['institutioncode2'] [$index] = "missing"; // $citesStatus2 [$index] = NULL; // $multimedia2 [$index] = ""; $accesspoint2 [$index] = NULL; $unitID2 [$index] = NULL; $tripleid2 [$index] = NULL; $collectioncode2 [$index] = NULL; $institutioncode2 [$index] = NULL; $schemaurl2 [$index] = NULL; $schemaname2 [$index] = NULL; $basedirectory2 [$index] = NULL; $sampletype2 [$index] = NULL; $recordBasis2 [$index] = NULL; $digirresourcename2 [$index] = NULL; $latitude2 [$index] = NULL; $longitude2 [$index] = NULL; $occurrenceFile2 [$index] = NULL; $elementtype2 [index] = NULL; $filters ['unitID2'] [$index] = NULL; $filters ['collectioncode2'] [$index] = NULL; $filters ['institutioncode2'] [$index] = NULL; $citesStatus2 [$index] = NULL; $multimedia2 [$index] = ""; $output = array ( 'response' => $response, 'filters' => $filters, 'accesspoint' => $accesspoint, 'unitID' => $unitID, 'collectioncode' => $collectioncode, 'institutioncode' => $institutioncode, 'schemaurl' => $schemaurl, 'digirresourcename' => $digirresourcename, 'schemaname' => $schemaname, 'basedirectory' => $basedirectory, 'sampletype' => $sampletype, 'multimedia' => $multimedia, 'canonicalName' => $canonicalName, 'tripleid' => $tripleidstoreid, 'latitude' => $latitude, 'longitude' => $longitude, 'loan' => $loan, 'collectors' => $collectors, 'collectornb' => $collectornb, 'indexHerbarorium' => $indexHerbarorium, 'occurrenceFile' => $occurrenceFile, 'elementtype' => $elementtype ); } else { $raw_response = SOLRQueryManager::fillAndExecuteQuery ( $query, "*:*", $fq, [ ], True ); $response = $raw_response; foreach ( $response as $index => $doc ) { $occurrenceFile2 [$index] = $doc->filename; try { $accesspoint2 [$index] = $doc->accesspoint; } catch ( Exception $e ) { $accesspoint2 [$index] = ""; } try { $unitID2 [$index] = $doc->unitID; } catch ( Exception $e ) { $unitID2 [$index] = ""; } try { $collectioncode2 [$index] = $doc->collectioncode; } catch ( Exception $e ) { $collectioncode2 [$index] = ""; } try { $tripleid2 [$index] = $doc->tripleidstoreid; } catch ( Exception $e ) { $tripleid2 [$index] = ""; } try { $institutioncode2 [$index] = $doc->institutioncode; } catch ( Exception $e ) { $institutioncode2 [$index] = ""; } try { $schemaurl2 [$index] = $doc->schemaurl; } catch ( Exception $e ) { $schemaurl2 [$index] = ""; } try { $ocurrenceFile2 [$index] = $doc->filename; } catch ( Exception $e ) { $ocurrenceFile2 [$index] = ""; } try { $schemaname2 [$index] = $doc->schemaname; } catch ( Exception $e ) { $schemaname2 [$index] = ""; } try { $basedirectory2 [$index] = $doc->basedirectory; } catch ( Exception $e ) { $basedirectory2 [$index] = ""; } try { $elementtype2 [$index] = $doc->elementtype; } catch ( Exception $e ) { $elementtype2 [$index] = ""; } try { $sampletype2 [$index] = $doc->sampletype; if (! isset ( $sampletype2 [$index] ) || $sampletype2 [$index] == "unknown") { try { $rb = $doc->recordbasis; // echo "recordbasis: " . $rb . "
"; if (stristr ( $rb, "specimen" ) != FALSE || stristr ( $rb, "occurrence" )) $sampletype2 [$index] = 'specimen'; } catch ( Exception $e ) { } } } catch ( Exception $e ) { $sampletype2 [$index] = "unkown"; try { $rb = $doc->recordbasis; // echo "recordbasis!"; if (stristr ( $rb, "specimen" ) != FALSE || stristr ( $rb, "occurrence" )) $sampletype2 [$index] = 'specimen'; } catch ( Exception $e ) { } } try { $digirresourcename2 [$index] = $doc->digirresourcename; } catch ( Exception $e ) { $digirresourcename2 [$index] = ""; } try { $latitude2 [$index] = $doc->latitude; } catch ( Exception $e ) { $latitude2 [$index] = NULL; } try { $longitude2 [$index] = $doc->longitude; } catch ( Exception $e ) { $longitude2 [$index] = NULL; } try { $citesStatus2 [$index] = $doc->citesStatus; } catch ( Exception $e ) { $citesStatus2 [$index] = NULL; } try { $gbifIDs [] = $doc->gbifKey; } catch ( Exception $e ) { } try { $colID = $doc->taxonIDcol; } catch ( Exception $e ) { } try { $ncbiID = $doc->taxonIDncbi; } catch ( Exception $e ) { } $filters ['unitID2'] [$index] = $doc->unitID; $filters ['collectioncode2'] [$index] = $doc->collectioncode; $filters ['institutioncode2'] [$index] = $doc->institutioncode; try { $multimedia2 [$index] = ""; try { if (is_array ( $doc->multimediaurl )) foreach ( $doc->multimediaurl as $murl ) if ($murl != "N/A") if (! strpos ( $multimedia2 [$index], $murl )) $multimedia2 [$index] = $multimedia2 [$index] . " "; else $multimedia2 [$index] == ""; } catch ( Exception $e ) { $multimedia2 [$index] == ""; } } catch ( Exception $e ) { $multimedia2 [$index] = ""; } $blocked = $doc->blocked; $blockedUntil = $doc->blockedUntil; $disposition = $doc->disposition; $disposition_clean = $doc->disposition_clean; $condition = $doc->condition; if ($sampletype != "tissue") { if (empty ( $blockedUntil )) { if ($sampletype2 [$index] == "tissue") $loan [$filters ['unitID2'] [$index]] = [ " Tissue available ", "OK", "not blocked", $condition, $disposition_clean ]; } else { if (new \DateTime () > new \DateTime ( $blockedUntil )) { // $loan [] = "The unitID " . $filters ['unitID2'] [$index] . " was blocked until " . $blockedUntil . " under the condition " . $condition . ". There is still " . $disposition_clean . " available."; if ($sampletype2 [$index] == "tissue") $loan [$filters ['unitID2'] [$index]] = [ " Tissue available ", "OK", "was blocked until " . $blockedUntil, $condition, $disposition_clean ]; } else { if ($sampletype2 [$index] == "tissue") $loan [$filters ['unitID2'] [$index]] = [ " Tissue available ", "BLOCKED", "is blocked until " . $blockedUntil, $condition, $disposition_clean ]; } } } } $output = array ( 'response' => $response, 'filters' => $filters, 'accesspoint' => $accesspoint, 'unitID' => $unitID, 'collectioncode' => $collectioncode, 'institutioncode' => $institutioncode, 'schemaurl' => $schemaurl, 'digirresourcename' => $digirresourcename, 'schemaname' => $schemaname, 'basedirectory' => $basedirectory, 'sampletype' => $sampletype, 'multimedia' => $multimedia, 'canonicalName' => $canonicalName, 'tripleid' => $tripleidstoreid, 'latitude' => $latitude, 'longitude' => $longitude, 'occurrenceFile' => $occurrenceFile, 'elementtype' => $elementtype, 'accesspoint2' => $accesspoint2, 'unitID2' => $unitID2, 'collectioncode2' => $collectioncode2, 'tripleid2' => $tripleid2, 'institutioncode2' => $institutioncode2, 'schemaurl2' => $schemaurl2, 'occurrenceFile2' => $occurrenceFile2, 'elementtype2' => $elementtype2, 'schemaname2' => $schemaname2, 'basedirectory2' => $basedirectory2, 'digirresourcename2' => $digirresourcename2, 'sampletype2' => $sampletype2, 'longitude2' => $longitude2, 'latitude2' => $latitude2, 'multimedia2' => $multimedia2, 'citesStatus2' => $citesStatus2, 'loan' => $loan, 'collectors' => $collectors, 'collectornb' => $collectornb, 'indexHerbarorium' => $indexHerbarorium ); } if (sizeof ( $gbifIDs ) > 0) { $output ['GBIFs'] = array_unique ( $gbifIDs ); // $GBIFs = ExploreManager::getGBIFRecords ( $gbifIDs ); // if (sizeof ( $GBIFs ) > 0) // $output ['GBIFs'] = $GBIFs; } else $output ['GBIFs'] = [ ]; if ($ncbiID != "") { $output ['NCBI'] = $ncbiID; // $NCBI = ExploreManager::getNCBIRecord ( $ncbiID ); // if (! empty ( $NCBI )) // $output ['NCBI'] = $NCBI; } else $output ['NCBI'] = [ ]; $GGBNs = ExploreManager::getGGBNRecords ( $fullScientificName, $tripleidstoreid ); if (! empty ( $GGBNs )) $output ['GGBNs'] = $GGBNs; else $output ['GGBNs'] = [ ]; return $output; } // if($upperTripleidstoreids != "") else { $output = array ( 'response' => $response, 'filters' => $filters, 'accesspoint' => $accesspoint, 'unitID' => $unitID, 'collectioncode' => $collectioncode, 'institutioncode' => $institutioncode, 'schemaurl' => $schemaurl, 'digirresourcename' => $digirresourcename, 'schemaname' => $schemaname, 'basedirectory' => $basedirectory, 'sampletype' => $sampletype, 'multimedia' => $multimedia, 'canonicalName' => $canonicalName, 'tripleid' => $tripleidstoreid, 'latitude' => $latitude, 'longitude' => $longitude, 'loan' => $loan, 'occurrenceFile' => $occurrenceFile, 'collectors' => $collectors, 'collectornb' => $collectornb, 'indexHerbarorium' => $indexHerbarorium, 'elementtype' => $elementtype ); if (sizeof ( $gbifIDs ) > 0) { $output ['GBIFs'] = array_unique ( $gbifIDs ); // $GBIFs = ExploreManager::getGBIFRecords ( $gbifIDs ); // if (sizeof ( $GBIFs ) > 0) // $output ['GBIFs'] = $GBIFs; } else $output ['GBIFs'] = [ ]; if ($ncbiID != "") { $output ['NCBI'] = $ncbiID; // $NCBI = ExploreManager::getNCBIRecord ( $ncbiID ); // if (! empty ( $NCBI )) // $output ['NCBI'] = $NCBI; } else $output ['NCBI'] = [ ]; $GGBNs = ExploreManager::getGGBNRecords ( $fullScientificName, $tripleidstoreid ); if (! empty ( $GGBNs )) $output ['GGBNs'] = $GGBNs; else $output ['GGBNs'] = [ ]; return $output; } } public static function getListOfTripleids($baseIds, $model) { static $cnt = 0; static $lowerAndUppers = [ ]; if (sizeof ( $lowerAndUppers ) == 0) { $lowerAndUppers = $baseIds; } $cnt ++; $sizeBefore = sizeof ( $lowerAndUppers ); if ($sizeBefore == 0) $sizeBefore = sizeof ( $baseIds ); foreach ( $baseIds as $id ) { $config = SOLRQueryManager::getConfigDetails (); $query = SOLRQueryManager::createSearchQuery ( $config ); $fq = "tripleidstoreid:" . $id; $raw_response = SOLRQueryManager::fillAndExecuteQuery ( $query, "*:*", $fq, [ ], True ); $response = $raw_response; foreach ( $response as $doc ) { $upperTripleidstoreids2 = $doc ['upperTripleidstoreids']; $lowerIDs = $doc ['lowerTripleidstoreids']; if (isset ( $upperTripleidstoreids2 )) { $lowerAndUppers = array_unique ( array_merge ( $lowerAndUppers, $upperTripleidstoreids2 ) ); } if (isset ( $lowerIDs )) { $lowerAndUppers = array_unique ( array_merge ( $lowerAndUppers, $lowerIDs ) ); } } } if (sizeof ( $lowerAndUppers ) > $sizeBefore) { if ($cnt < 5) return self::getListOfTripleids ( $lowerAndUppers, $model ); } return $lowerAndUppers; } public static function createRecordQuery($filters, $schemaurl) { if ($schemaurl == "http://www.tdwg.org/schemas/abcd/2.06") { $query = urlencode ( '
search
http://www.tdwg.org/schemas/abcd/2.06 http://www.tdwg.org/schemas/abcd/2.06 ' . $filters ['unitID'] . ' ' . $filters ['institutioncode'] . ' ' . $filters ['collectioncode'] . ' false
' ); } if ($schemaurl == "http://www.tdwg.org/schemas/abcd/2.1") { $query = urlencode ( '
search
http://www.tdwg.org/schemas/abcd/2.1 http://www.tdwg.org/schemas/abcd/2.1 ' . $filters ['unitID'] . ' ' . $filters ['institutioncode'] . ' ' . $filters ['collectioncode'] . ' false
' ); } if ($schemaurl == "http://rs.tdwg.org/dwc/") { $query = ""; } return $query; } public static function createAssociatedRecordQuery($associatedUnitID, $associatedCollectionCode, $associatedInstitutionCode, $associatedSchemaUrl, $associatedDigirResourcename, $associatedAccessPoint) { // echo ( "createAssociatedRecordQuery " . $associatedUnitID . " " . $associatedSchemaUrl ); $query2 = ""; if ($associatedSchemaUrl == "http://www.tdwg.org/schemas/abcd/2.06") { $query2 = urlencode ( '
search
http://www.tdwg.org/schemas/abcd/2.06 http://www.tdwg.org/schemas/abcd/2.06 ' . $associatedUnitID . ' ' . $associatedInstitutionCode . ' ' . $associatedCollectionCode . ' false
' ); } if ($associatedSchemaUrl == "http://www.tdwg.org/schemas/abcd/2.1") { $query2 = urlencode ( '
search
http://www.tdwg.org/schemas/abcd/2.1 http://www.tdwg.org/schemas/abcd/2.1 ' . $associatedUnitID . ' ' . $associatedInstitutionCode . ' ' . $associatedCollectionCode . ' false
' ); } if ($associatedSchemaUrl == "http://rs.tdwg.org/dwc/") { $query2 = ""; } if ($associatedSchemaUrl == "http://bnhm.berkeley.edu/DwC/bnhm_dc2_schema.xsd") { $q = '
1.0.02009-11-13 14:40:56.000 ' . $associatedAccessPoint . ' search
' . $associatedUnitID . ' ' . $associatedInstitutionCode . ' ' . $associatedCollectionCode . ' false
'; $query2 = urlencode ( $q ); } return $query2; } public static function getABCD($accesspoint, $query, $unitID) { // TODO test if url has parameter and set ? or &!!! $fullURL = $accesspoint . "&query=" . $query; // echo $fullURL; $options = [ 'http' => [ 'timeout' => '10' ] ]; $context = stream_context_create ( $options ); libxml_set_streams_context ( $context ); $xml = new DOMDocument ( '1.0', 'UTF-8' ); try { $xml->load ( $fullURL ); $handle = fopen ( Yii::$app->params ['tmpFolder'] . $unitID . '.xml', 'w' ); fwrite ( $handle, $xml->saveXML () ); fclose ( $handle ); } catch ( yii\base\ErrorException $e ) { $xml = NULL; } // Yii::info ( $xml->saveXML () ); return $xml; } public static function parseABCD($xsl, $xml, $tripleid) { $processor = new XSLTProcessor (); $processor->registerPHPFunctions (); $processor->importStyleSheet ( $xsl ); try { $html = $processor->transformToXML ( $xml ); } catch ( yii\base\ErrorException $e ) { Yii::error ( $e ); $html = SingleRecordManager::getFromCache ( $tripleid ); return [ $html, False ]; } // Yii::info("parse ABCD: ".$html); // echo $html; if (strpos ( $html, "hits found for" ) > 0 && $tripleid != NULL) { $out = SingleRecordManager::getFromCache ( $tripleid ); return [ $out, False ]; } else return [ $html, True ]; } public static function readDwC($xsl, $accesspoint, $digirresourcename, $query, $tripleid) { $processor = new XSLTProcessor (); $processor->importStyleSheet ( $xsl ); $fullURL = $accesspoint . "?request=" . $query; // echo $fullURL; $xml = new DOMDocument ( '1.0', 'UTF-8' ); $xml->load ( $fullURL ); $html = $processor->transformToXML ( $xml ); // print_r( $html); if (strpos ( $html, "hits found for" ) > 0) { $out = SingleRecordManager::getFromCache ( $tripleid ); return $out; } else return $html; } public static function getFromCache($tripleidstoreid) { Yii::info ( "getFromCache " . $tripleidstoreid ); $config = SOLRQueryManager::getConfigDetails (); $query = SOLRQueryManager::createSearchQuery ( $config ); $fq = "tripleidstoreid:" . $tripleidstoreid; $raw_response = SOLRQueryManager::fillAndExecuteQuery ( $query, "*:*", $fq, [ ], True ); $response = $raw_response; $out = ""; foreach ( $response as $doc ) { $out .= "The original unit could not be found - info displayed from the cache"; $out .= "

Identification(s):

"; $out .= $doc->fullScientificName . "
"; if (Yii::$app->params ['siteName'] != 'ggbn_portal') $out .= "

Gathering Event

"; else $out .= "

Collection Info:

"; $out .= "Collector(s): " . $doc->collectors . "
"; if ($doc->fieldnumber != "s.n.") $out .= "Field number: " . $doc->fieldnumber . "
"; $out .= "Locality: " . $doc->locality . "
" . "
"; // $out .= "Other info " . "
"; $out .= "Country: " . $doc->country . "
"; if (! empty ( $doc->continent )) $out .= "Continent: " . implode ( ", ", $doc->continent ) . "
"; if (! empty ( $doc->latitude )) $out .= "Coordinates (Lat|Lon): " . $doc->latitude [0] . "|" . $doc->longitude [0] . "
"; } return $out; } // type = specimen or tissue or dna public static function readDwCA($unitToFind, $folder, $dom, $sampleType, $occurrenceFile) { Yii::info ( "READ " . $unitToFind . " in file " . $occurrenceFile ); echo ""; $Cores = $dom->getElementsByTagName ( 'core' ); $Extensions = $dom->getElementsByTagName ( 'extension' ); $xml = simplexml_load_file ( $folder . "meta.xml" ); foreach ( $xml->attributes () as $a => $b ) { if ($a === 'metadata') $EML = $b; } $output = ''; $relation = ''; $sample = ''; $preservation = ''; $preparation = ''; $sequences = ''; $prepSex = ''; $locality = ""; $identification = ""; $gathering = ""; $ID_Record = null; $material = ""; $taxonomySet = false; $latitude = [ ]; $longitude = [ ]; $multimedia = ""; $preparationType = ""; // extract data from EML file $xml = simplexml_load_file ( $folder . $EML ); $datasetxml = $xml->dataset; $creator = $datasetxml->creator; try { $orga = $creator->organizationName; Yii::info ( "ORGA " . $orga ); } catch ( yii\base\ErrorException $e ) { } try { $addressxml = $creator->address; } catch ( yii\base\ErrorException $e ) { } $addressT = [ ]; try { $addressT [] = $addressxml->deliveryPoint; $addressT [] = $addressxml->city; $addressT [] = $addressxml->administrativeArea; $addressT [] = $addressxml->postalCode; $addressT [] = $addressxml->country; } catch ( yii\base\ErrorException $e ) { } try { $addressT = array_filter ( $addressT ); } catch ( yii\base\ErrorException $e ) { } $intellectualRightsxml = $datasetxml->intellectualRights; $irT = [ ]; try { $irT [] = $intellectualRightsxml->para; $paraXML = $intellectualRightsxml->para; $ulinkXML = $paraXML->ulink; $url = $ulinkXML->attributes () [0]; $irT [] = "" . $ulinkXML->citetitle . ""; } catch ( yii\base\ErrorException $e ) { Yii::info ( "oups " . $e ); } try { $irT = array_filter ( $irT ); } catch ( Exception $e ) { } try { $geocoveragexml = $datasetxml->coverage->geographicCoverage->geographicDescription; } catch ( yii\base\ErrorException $e ) { $geocoveragexml = ""; } try { $taxocoveragexml = $datasetxml->coverage->taxonomicCoverage->generalTaxonomicCoverage; } catch ( yii\base\ErrorException $e ) { $taxocoveragexml = ""; } try { $abstract = $datasetxml->abstract->para; } catch ( yii\base\ErrorException $e ) { $abstract = ""; } // Start Core foreach ( $Cores as $Core ) { $Files = $Core->getElementsByTagName ( 'files' ); foreach ( $Files as $File ) { $FileLocationCore = $File->getElementsByTagName ( 'location' )->item ( 0 )->nodeValue; } $ColumnIDs = $Core->getElementsByTagName ( 'id' ); foreach ( $ColumnIDs as $ColumnID ) { $field_columns_core [0] = $ColumnID->getAttribute ( 'index' ); $idElt = $ColumnID->getAttribute ( 'index' ); } $fields = $Core->getElementsByTagName ( 'field' ); $max = 0; $staticValues = [ ]; foreach ( $fields as $field ) { $idx = $field->getAttribute ( 'index' ); if (! empty ( $idx )) { $field_columns_core [$field->getAttribute ( 'index' )] = $field->getAttribute ( 'term' ); if ($field->getAttribute ( 'index' ) > $max) $max = $field->getAttribute ( 'index' ); } else { $staticValues [end ( explode ( "/", $field->getAttribute ( 'term' ) ) )] = $field->getAttribute ( 'default' ); } } if (sizeof ( $field_columns_core ) < $max) foreach ( range ( 0, $max ) as $i ) if (! isset ( $field_columns_core [$i] )) { $field_columns_core [$i] = ""; } // read header first to get column of catalogNumber -> if catalogNumber = required record -> get full row // Yii::info( "try top open " . $folder . " in " . $FileLocationCore . " and look for " . $unitToFind."
" ); // //does only parse this part if the current thing to display is the DNA part $handle = fopen ( $folder . $FileLocationCore, "r" ); if ($handle) { $separator = "\t"; $t1 = sizeof ( fgetcsv ( $handle, 0, $separator, $enclosure = '"' ) ); fclose ( $handle ); $handle = fopen ( $folder . $FileLocationCore, "r" ); $t2 = sizeof ( fgetcsv ( $handle, 0, ",", $enclosure = '"' ) ); fclose ( $handle ); $handle = fopen ( $folder . $FileLocationCore, "r" ); if ($t2 > $t1) $separator = ","; $header = fgetcsv ( $handle, 0, $separator, $enclosure = '"' ); foreach ( $header as $index => $term ) { if ($term == "catalogNumber") { $ColumnCatalogNumber = $index; } if ($term == "id") { $ColumnIndex = $index; } if ($term == "occurrenceID") { $ColumnOccurrenceID = $index; } } if (empty ( $ColumnCatalogNumber )) { $k = array_search ( "http://rs.tdwg.org/dwc/terms/catalogNumber", $field_columns_core ); if ($k) $ColumnCatalogNumber = $k; $k = array_search ( "http://rs.tdwg.org/dwc/terms/occurrenceID", $field_columns_core ); if ($k) $ColumnOccurrenceID = $k; if (isset ( $idElt )) $ColumnIndex = $idElt; else $ColumnIndex = 0; $header = [ ]; foreach ( $field_columns_core as $k => $v ) $header [$k] = end ( explode ( "/", $v ) ); } $row = 1; $idfound = false; $allIDs = [ ]; array_push ( $allIDs, $unitToFind ); if (is_array ( $unitToFind )) $allIDs = array_merge ( $unitToFind, $allIDs ); else array_push ( $allIDs, $unitToFind ); fclose ( $handle ); ini_set ( "auto_detect_line_endings", true ); $handle2 = fopen ( $folder . $occurrenceFile, "r" ); $separator = "\t"; $t1 = sizeof ( fgetcsv ( $handle2, 0, $separator, $enclosure = '"' ) ); fclose ( $handle2 ); $handle2 = fopen ( $folder . $occurrenceFile, "r" ); $t2 = sizeof ( fgetcsv ( $handle2, 0, ",", $enclosure = '"' ) ); fclose ( $handle2 ); $handle2 = fopen ( $folder . $occurrenceFile, "r" ); if ($t2 > $t1) $separator = ","; while ( ($data = fgetcsv ( $handle2, 0, $separator, $enclosure = '"' )) !== FALSE ) { $tmp = 1; $row ++; $idfound = false; if (sizeof ( $data ) > 1) { $currentID = $data [$ColumnCatalogNumber]; if (isset ( $ColumnOccurrenceID )) $currentOccurrenceID = $data [$ColumnOccurrenceID]; else $currentOccurrenceID = ""; if (in_array ( $currentID, $allIDs ) || in_array ( $currentOccurrenceID, $allIDs )) $idfound = true; if ($idfound) { $record_array = array_combine ( $header, $data ); $ID_Record = $data [$ColumnIndex]; if (Yii::$app->params ['catalogNumberClickable']) $output .= "Catalog Number: " . $record_array ['catalogNumber'] . " "; else $output .= "Catalog Number: " . $record_array ['catalogNumber'] . " "; if (isset ( $record_array ['collectionCode'] )) $output .= $record_array ['collectionCode']; if (isset ( $staticValues ['collectionCode'] )) { $output .= $staticValues ['collectionCode']; } if (isset ( $staticValues ['collectionID'] )) { $output .= " (" . $staticValues ['collectionID'] . ")"; } if (isset ( $record_array ['institutionCode'] )) $output .= " (" . $record_array ['institutionCode'] . ")"; if (isset ( $staticValues ['institutionCode'] )) $output .= " (" . $staticValues ['institutionCode'] . ")"; if (isset ( $staticValues ['datasetName'] )) $output .= " (" . $staticValues ['datasetName'] . ")"; $output .= "
"; if (isset ( $record_array ['basisOfRecord'] )) $output .= "Record Basis: " . $record_array ['basisOfRecord'] . "
"; if (isset ( $staticValues ['basisOfRecord'] )) $output .= "Record Basis: " . $staticValues ['basisOfRecord'] . "
"; if (isset ( $record_array ['id'] )) { if (! (stripos ( $record_array ['id'], "http" ) === FALSE)) $output .= "GUID/Occurrence ID: " . $record_array ['id'] . "
"; else $output .= "GUID/Occurrence ID: " . $record_array ['id'] . "
"; } if (isset ( $record_array ['scientificName'] )) $identification .= "

Identification

Name: " . $record_array ['scientificName'] . "
"; if ((isset ( $record_array ['family'] ) && ! empty ( $record_array ['family'] )) || (isset ( $record_array ['order'] ) && ! empty ( $record_array ['order'] )) || (isset ( $record_array ['class'] ) && ! empty ( $record_array ['class'] )) || (isset ( $record_array ['phylum'] ) && ! empty ( $record_array ['phylum'] )) || (isset ( $record_array ['kingdom'] ) && ! empty ( $record_array ['kingdom'] ))) { $identification .= "Taxonomy (Occurrence): "; if (isset ( $record_array ['family'] ) && ! empty ( $record_array ['family'] )) $identification .= "" . $record_array ['family'] . " (family); "; if (isset ( $record_array ['order'] ) && ! empty ( $record_array ['order'] )) $identification .= "" . $record_array ['order'] . " (order); "; if (isset ( $record_array ['class'] ) && ! empty ( $record_array ['class'] )) $identification .= "" . $record_array ['class'] . " (class); "; if (isset ( $record_array ['phylum'] ) && ! empty ( $record_array ['phylum'] )) $identification .= "" . $record_array ['phylum'] . " (phylum); "; if (isset ( $record_array ['kingdom'] ) && ! empty ( $record_array ['kingdom'] )) $identification .= "" . $record_array ['kingdom'] . " (kingdom); "; $taxonomySet = true; $identification .= "

"; } if (isset ( $record_array ['typeStatus'] )) { $identification . "Type Status: " . $record_array ['typeStatus'] . ""; } if (isset ( $record_array ['country'] ) || isset ( $record_array ['locality'] ) || isset ( $record_array ['stateProvince'] )) if (Yii::$app->params ['siteName'] != 'ggbn_portal') $gathering .= "

Gathering Event

"; else $gathering .= "

Collection Info

"; if (isset ( $record_array ['country'] )) $gathering .= "Country: " . $record_array ['country'] . "
"; if (isset ( $record_array ['stateProvince'] )) $gathering .= "State/Province: " . $record_array ['stateProvince'] . "
"; if (isset ( $record_array ['locality'] )) $gathering .= "Locality: " . $record_array ['locality'] . "
"; if (isset ( $record_array ['decimalLatitude'] ) || isset ( $record_array ['decimalLongitude'] )) { if (! empty ( $record_array ['decimalLatitude'] ) && ! empty ( $record_array ['decimalLongitude'] )) { $gathering .= "Coordinates (lat|lon): "; if (isset ( $record_array ['decimalLatitude'] )) { $gathering .= $record_array ['decimalLatitude']; $latitude [] = $record_array ['decimalLatitude']; } $gathering .= "|"; if (isset ( $record_array ['decimalLongitude'] )) { $gathering .= $record_array ['decimalLongitude']; $longitude [] = $record_array ['decimalLongitude']; } $gathering .= "

"; } } if (isset ( $record_array ['recordedBy'] )) if (strcasecmp ( $record_array ['recordedBy'], "" ) != 0) $gathering .= "Collector(s): " . $record_array ['recordedBy'] . "
"; if (isset ( $record_array ['recordNumber'] )) if (strcasecmp ( $record_array ['recordNumber'], "" ) != 0) $gathering .= "Collector's number: " . $record_array ['recordNumber'] . "
"; if (isset ( $record_array ['verbatimEventDate'] )) if (strcasecmp ( $record_array ['verbatimEventDate'], "" ) != 0) $gathering .= "Collection Date: " . $record_array ['verbatimEventDate'] . "
"; // PREPARATION SPECIMEN && SEX if (isset ( $record_array ['sex'] )) if (strcasecmp ( $record_array ['sex'], "" ) != 0) $prepSex .= "
Sex: " . $record_array ['sex'] . "
"; if (isset ( $record_array ['preparations'] )) if (strcasecmp ( $record_array ['preparations'], "" ) != 0) $prepSex .= "Preparations: " . $record_array ['preparations'] . "
"; } } } fclose ( $handle2 ); // } } // foreach ($Cores as $Core) else echo ("Could not read the file ?
"); } // Start Extensions foreach ( $Extensions as $Extension ) { $Files = $Extension->getElementsByTagName ( 'files' ); foreach ( $Files as $File ) { $FileLocationExtension = $File->getElementsByTagName ( 'location' )->item ( 0 )->nodeValue; } $ColumnIDs = $Extension->getElementsByTagName ( 'coreid' ); foreach ( $ColumnIDs as $ColumnID ) { $field_columns_extension [0] = $ColumnID->getAttribute ( 'index' ); } $fields = $Extension->getElementsByTagName ( 'field' ); foreach ( $fields as $field ) { $field_columns_extension [$field->getAttribute ( 'index' )] = $field->getAttribute ( 'term' ); } // help for debugging foreach($field_columns_core as $field_column_core) { echo $field_column_core."
"; } // read header first to get column of catalogNumber -> if catalogNumber = required record -> get full row if (($handle = fopen ( $folder . $FileLocationExtension, "r" )) !== FALSE) { Yii::info ( "FileLocationExtension: " . $FileLocationExtension ); $separator = "\t"; $t1 = sizeof ( fgetcsv ( $handle, 1000, $separator, $enclosure = '"' ) ); fclose ( $handle ); $handle = fopen ( $folder . $FileLocationExtension, "r" ); $t2 = sizeof ( fgetcsv ( $handle, 1000, ",", $enclosure = '"' ) ); fclose ( $handle ); if ($t2 > $t1) $separator = ","; // Yii::info ( "USE SEPARATOR " . $separator ); $handle = fopen ( $folder . $FileLocationExtension, "r" ); $header = fgetcsv ( $handle, 1000, $separator, $enclosure = '"' ); foreach ( $header as $index => $term ) { // YII::info ( "TERMS " . $term ); if ($term == "id") { $ColumnID = $index; } } // Yii::info ( "COLUMNID " . $ColumnID ); // Yii::info ( "IDRECORD " . $ID_Record ); $row = 1; $lines = file ( $folder . $FileLocationExtension ); $data = SingleRecordManager::getLineOnly ( $lines, $separator, $ID_Record, $ColumnID ); if (! empty ( $data )) { // foreach ( $lines as $dataL ) { // if (strpos ( $line, $ID_Record ) !== false) { // Yii::info ( "line: " . $dataL ); // Yii::info ( "alive: " . $row ); // $data = explode ( $separator, $dataL ); // // while ( ($data = fgetcsv ( $handle, 1000, "\t" )) !== FALSE ) { // $row ++; // if ($data [$ColumnID] == $ID_Record) { // help for debugging foreach ($data as $value) { echo $value. "
"; } $record_array = array_combine ( $header, $data ); if ($FileLocationExtension == "resourcerelationship.txt") { if (isset ( $record_array ['resourceRelationshipID'] )) $relationshipFull = "&" . $record_array ['resourceRelationshipID']; if (! isset ( $relationshipFull )) $relationshipFull = "&" . $record_array ['relatedResourceID']; if (isset ( $relationshipFull )) { $collcode = explode ( "&", explode ( "&collectionCode=", $relationshipFull ) [1] ) [0]; $instcode = explode ( "&", explode ( "&institutionCode=", $relationshipFull ) [1] ) [0]; $catcode = explode ( "&", explode ( "&catalogNumber=", $relationshipFull ) [1] ) [0]; // $relation .= $relationshipFull; $relation .= "

Relation to " . $catcode . " ($collcode, $instcode) :

"; if (isset ( $record_array ['relationshipOfResource'] )) $relation .= $record_array ['relationshipOfResource']; } } if ($FileLocationExtension == "preparation.txt") { if ((isset ( $record_array ['preparationMaterials'] ) && (strcasecmp ( $record_array ['preparationMaterials'], "" ) != 0)) || (isset ( $record_array ['preparationDate'] ) && (strcasecmp ( $record_array ['preparationDate'], "" ) != 0)) || (isset ( $record_array ['preparedBy'] ) && (strcasecmp ( $record_array ['preparedBy'], "" ) != 0)) || (isset ( $record_array ['preparationType'] ) && (strcasecmp ( $record_array ['preparationType'], "" ) != 0))) { if ($sampleType == "DNA") $label = "Extraction"; else $label = "Preparation"; $preparation .= "

" . $label . "

"; $preparation .= isset ( $record_array ['preparationDate'] ) && (strcasecmp ( $record_array ['preparationDate'], "" ) != 0) ? "" . $label . " Date:" . $record_array ['preparationDate'] . "
" : ""; $preparation .= isset ( $record_array ['preparationMaterials'] ) && (strcasecmp ( $record_array ['preparationMaterials'], "" ) != 0) ? "" . $label . " Method:" . $record_array ['preparationMaterials'] . "
" : ""; $preparation .= isset ( $record_array ['preparedBy'] ) && (strcasecmp ( $record_array ['preparedBy'], "" ) != 0) ? "" . $label . " Staff: " . $record_array ['preparedBy'] . "
" : ""; $preparation .= isset ( $record_array ['preparationType'] ) && (strcasecmp ( $record_array ['preparationType'], "" ) != 0) ? "" . $label . " Type: " . $record_array ['preparationType'] . "
" : ""; $preparationType = $record_array ['preparationType']; } else { $preparation = NULL; if (isset ( $record_array ['preparationType'] )) $material .= "
Preparation Type: " . $record_array ['preparationType'] . ""; } } if ($FileLocationExtension == "materialsample2.txt") { if ((isset ( $record_array ['concentration'] ) && (strcasecmp ( $record_array ['concentration'], "" ) != 0)) || (isset ( $record_array ['ratioOfAbsorbance260_230'] ) && (strcasecmp ( $record_array ['ratioOfAbsorbance260_230'], "" ) != 0))) { $sample .= "

Quality

"; $sample .= isset ( $record_array ['concentration'] ) && (strcasecmp ( $record_array ['concentration'], "" ) != 0) ? "Concentration: " . $record_array ['concentration'] . " " . $record_array ['concentrationUnit'] . "
" : ""; $sample .= isset ( $record_array ['ratioOfAbsorbance260_230'] ) && (strcasecmp ( $record_array ['ratioOfAbsorbance260_230'], "" ) != 0) ? "Ratio of Absorbance:" . $record_array ['ratioOfAbsorbance260_230'] . "
" : ""; $sample .= isset ( $record_array ['ratioOfAbsorbance260_230'] ) && (strcasecmp ( $record_array ['ratioOfAbsorbance260_230'], "" ) != 0) ? "Ratio of Absorbance:" . $record_array ['ratioOfAbsorbance260_280'] . "
" : ""; $sample .= isset ( $record_array ['qualityCheckDate'] ) && (strcasecmp ( $record_array ['qualityCheckDate'], "" ) != 0) ? "Quality Check Date: " . $record_array ['qualityCheckDate'] . "
" : ""; } else $sample = NULL; if (isset ( $record_array ['materialSampleType'] )) $material .= "
Sample Type / Kind of Unit: " . $record_array ['materialSampleType'] . "
"; } if ($FileLocationExtension == "preservation.txt") { if ((isset ( $record_array ['preservationType'] ) && (strcasecmp ( $record_array ['preservationType'], "" ) != 0)) || (isset ( $record_array ['preservationDateBegin'] ) && (strcasecmp ( $record_array ['preservationDateBegin'], "" ) != 0))) { $preservation .= "

Sample Preservation(s)

"; $preservation .= isset ( $record_array ['preservationType'] ) && (strcasecmp ( $record_array ['preservationType'], "" ) != 0) ? "Preservation:" . $record_array ['preservationType'] . "
" : ""; $preservation .= isset ( $record_array ['preservationDateBegin'] ) && (strcasecmp ( $record_array ['preservationDateBegin'], "" ) != 0) ? "since:" . $record_array ['preservationDateBegin'] . "
" : ""; } else $preservation = NULL; } if ($FileLocationExtension == "amplification.txt") { if ((isset ( $record_array ['marker'] ) && (strcasecmp ( $record_array ['marker'], "" ) != 0)) || (isset ( $record_array ['geneticAccessionNumber'] ) && (strcasecmp ( $record_array ['geneticAccessionNumber'], "" ) != 0))) { $sequences = "

Amplifications(s)

"; $sequences .= isset ( $record_array ['marker'] ) && (strcasecmp ( $record_array ['marker'], "" ) != 0) ? "Marker:" . $record_array ['marker'] . "
" : ""; $sequences .= isset ( $record_array ['geneticAccessionNumber'] ) && (strcasecmp ( $record_array ['geneticAccessionNumber'], "" ) != 0) ? "Genetic Accession Number" . $record_array ['geneticAccessionNumber'] . "
" : ""; } else $sequences = NULL; } $multimedia = ""; if ($FileLocationExtension == "multimedia.txt") { if ((isset ( $record_array ['accessURI'] ) && (strcasecmp ( $record_array ['accessURI'], "" ) != 0))) { $murl = $record_array ['accessURI']; if ($murl != "N/A") { if (strpos ( $multimedia, $murl ) === FALSE) { if (strpos ( $murl, "http" ) === FALSE) { $murl = "http://" . $murl; } $multimedia = $multimedia . "  "; } } } else { if ((isset ( $record_array ['identifier'] ) && (strcasecmp ( $record_array ['identifier'], "" ) != 0))) { $murl = $record_array ['identifier']; if ($murl != "N/A") { if (strpos ( $multimedia, $murl ) === FALSE) { if (strpos ( $murl, "http" ) === FALSE) { $murl = "http://" . $murl; } $multimedia = $multimedia . "  "; } } } } } if ($FileLocationExtension == "identification.txt") { // foreach ($record_array as $k=>$v) // echo "k and v: ".$k." -- ".$v."
"; if (! empty ( $identification ) && stripos ( $identification, "supplemental information" ) == 0) $identification .= "

Other identification / supplemental information

"; if (isset ( $record_array ['scientificName'] ) && ! empty ( $record_array ['scientificName'] )) $identification .= "Name: " . $record_array ['scientificName'] . "
"; if (! $taxonomySet) if ((isset ( $record_array ['family'] ) && ! empty ( $record_array ['family'] )) || (isset ( $record_array ['order'] ) && ! empty ( $record_array ['order'] )) || (isset ( $record_array ['class'] ) && ! empty ( $record_array ['class'] )) || (isset ( $record_array ['phylum'] ) && ! empty ( $record_array ['phylum'] )) || (isset ( $record_array ['kingdom'] ) && ! empty ( $record_array ['kingdom'] ))) { $identification .= "Taxonomy: "; if (isset ( $record_array ['family'] ) && ! empty ( $record_array ['family'] )) $identification .= "" . $record_array ['family'] . " (family); "; if (isset ( $record_array ['order'] ) && ! empty ( $record_array ['order'] )) $identification .= "" . $record_array ['order'] . " (order); "; if (isset ( $record_array ['class'] ) && ! empty ( $record_array ['class'] )) $identification .= "" . $record_array ['class'] . " (class); "; if (isset ( $record_array ['phylum'] ) && ! empty ( $record_array ['phylum'] )) $identification .= "" . $record_array ['phylum'] . " (phylum); "; if (isset ( $record_array ['kingdom'] ) && ! empty ( $record_array ['kingdom'] )) $identification .= "" . $record_array ['kingdom'] . " (kingdom); "; $identification .= "
"; } if ((isset ( $record_array ['identifiedBy'] ) && (strcasecmp ( $record_array ['identifiedBy'], "" ) != 0)) || (isset ( $record_array ['identificationReferences'] ) && (strcasecmp ( $record_array ['identificationReferences'], "" ) != 0)) || (isset ( $record_array ['identificationRemarks'] ) && (strcasecmp ( $record_array ['identificationRemarks'], "" ) != 0))) { // $identification .= "

Identification details

"; if (isset ( $record_array ['identifiedBy'] ) && (strcasecmp ( $record_array ['identifiedBy'], "" ) != 0)) { $identification .= "Identified by: " . $record_array ['identifiedBy'] . "
"; } if (isset ( $record_array ['dateIdentified'] ) && (strcasecmp ( $record_array ['dateIdentified'], "" ) != 0)) { $identification .= "Identified in: " . $record_array ['dateIdentified'] . "
"; } if (isset ( $record_array ['identificationReferences'] ) && (strcasecmp ( $record_array ['identificationReferences'], "" ) != 0)) { $identification .= "References: " . $record_array ['identificationReferences'] . "
"; } if (isset ( $record_array ['identificationRemarks'] ) && (strcasecmp ( $record_array ['identificationRemarks'], "" ) != 0)) { $identification .= "Remarks: " . $record_array ['identificationRemarks'] . "
"; } if (isset ( $record_array ['typeStatus'] ) && (strcasecmp ( $record_array ['typeStatus'], "" ) != 0)) { $identification .= "Type Status: " . $record_array ['typeStatus'] . "
"; } } $identification .= "
"; } /* * echo ""; * echo "
Extension file:".$FileLocationExtension.""; * foreach($record_array as $headrow => $record) { echo "
".$headrow."".$record.""; } * echo "
"; */ // } // } // } } fclose ( $handle ); } } // $output = $relation . $preparation . $sample . $preservation . $sequences; // $dna = "
"; $dataset = ""; if (! empty ( $orga ) || ! empty ( $irT ) || ! empty ( $addressT ) || ! empty ( $taxocoveragexml ) || ! empty ( $geocoveragexml )) { $dataset .= "
"; if (! empty ( $orga )) $dataset .= $orga . "
"; if (! empty ( $abstract )) $dataset .= "Description: " . $abstract . "
"; if (! empty ( $addressT )) $dataset .= "Address: " . implode ( ", ", $addressT ) . "
"; if (! empty ( $irT )) $dataset .= "Rights: " . implode ( " ", $irT ) . "
"; if (! empty ( $taxocoveragexml )) $dataset .= "Taxonomic coverage: " . $taxocoveragexml . "
"; if (! empty ( $geocoveragexml )) $dataset .= "Geographic coverage: " . $geocoveragexml . "
"; $dataset .= "
"; } $dna = "
"; $dna .= $output; $dna .= $relation . "
"; $dna .= $preparation . "
"; $dna .= $preservation . "
"; $dna .= $sample . "
"; if (! empty ( $dataset )) $dna .= $dataset; $dna .= "
"; if ($preparationType != "" && ! stripos ( " " . $preparationType, "dna" )) $dna = NULL; echo ""; // $specimen = "
"; $specimen = "
"; $specimen .= $output; $specimen .= $relation; if ($sampleType != "DNA") { $specimen .= $material; $specimen .= $preparation . "
"; $specimen .= $prepSex; $specimen .= $preservation . "
"; } else $specimen .= $prepSex; if (! empty ( $dataset )) $specimen .= $dataset; $specimen .= "
"; $header = "
"; $header .= $output; $header .= "
"; $culture = ""; $enviro = $specimen; // $tissue = "
"; $tissue = "
"; $tissue .= $output; $tissue .= $material; $tissue .= $relation; $tissue .= $preparation . "
"; $tissue .= $preservation . "
"; if (! empty ( $dataset )) $tissue .= $dataset; $tissue .= "
"; // if($preparationType!="" && !stripos(" ".$preparationType,"tissue") && !stripos(" ".$preparationType,"muscle")){ // if( !stripos(" ".$preparationType,"tissue") && !stripos(" ".$preparationType,"muscle") && !stripos(" ".$preparationType,"leaf")){ echo ""; if ($sampleType != "tissue") { $tissue = null; } else { $specimen = null; } if ($sampleType == "environmental sample") $specimen = null; else $enviro = null; if ($sequences != "") $sequences = "
" . $sequences . "
"; $output = "
" . $output . "
"; // echo "HEADER FROM HERE ".$header."

"; // if (is_array ( $unitToFind )) { // Yii::info ( "header part for unit: " . implode ( $unitToFind, " ---- " ) . ": " . $header ); // Yii::info ( "tissue part for unit: " . implode ( $unitToFind, " ---- " ) . ": " . $tissue ); // Yii::info ( "dna part for unit: " . implode ( $unitToFind, " ---- " ) . ": " . $dna ); // Yii::info ( "specimen part for unit: " . implode ( $unitToFind, " ---- " ) . ": " . $specimen ); // } else { // Yii::info ( "header part for unit: " . $unitToFind . ": " . $header ); // Yii::info ( "tissue part for unit: " . $unitToFind . ": " . $tissue ); // Yii::info ( "dna part for unit: " . $unitToFind . ": " . $dna ); // Yii::info ( "specimen part for unit: " . $unitToFind . ": " . $specimen ); // } $out = [ "dna" => $dna, "output" => $output, "relation" => $relation, "sample" => $sample, "sequences" => $sequences, "preservation" => $preservation, "preparation" => $preparation, "specimen" => $specimen, "tissue" => $tissue, "header" => $header, "locality" => $identification . $gathering, "culture" => $culture, "enviro" => $enviro, "latitude" => $latitude, "longitude" => $longitude, "identification" => $identification, "gathering" => $gathering, "multimedia" => $multimedia, "dataset" => $dataset ]; return $out; } static function getLineOnly($lines, $separator, $ID_Record, $ColumnID) { // Yii::info ( "getlineonly" ); $chuncks = array_chunk ( $lines, 50000 ); foreach ( $chuncks as $chunck ) { $searchword = str_ireplace ( "/", "\/", $ID_Record ); $matches = array_filter ( $chunck, function ($var) use($searchword) { return preg_match ( "/\b$searchword\b/i", $var ); } ); foreach ( $matches as $m ) { // Yii::info ( "found it :)" ); $data = explode ( $separator, $m ); if ($data [$ColumnID] == $ID_Record) return $data; } } return null; } } ?>