$v )
// Yii::info ( "KEY: " . $k . " -- " . $v );
if (isset ( $_REQUEST ['name'] ))
{throw new NotFoundHttpException('You try to access a page not available for your user group. Go back to search.');
/*return $this->render ( '/site/error', [
"name" => "Oooops",
"message" => "Something went wrong.",
"exception" => $e
] ); */}
else {
$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;
if (isset ( $_REQUEST ['guid'] ))
$filters ['guid'] = $_REQUEST ['guid'];
$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;
$guid = $doc->guid;
$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 {
$guid = $doc->guid;
} catch ( Exception $e ) {
$guid = null;
}
try {
$indexHerbarorium = $doc->indexHerbarorium;
} catch ( Exception $e ) {
$indexHerbarorium = null;
}
try {
$fullScientificName = $doc->originalName;
} catch ( Exception $e ) {
$fullScientificName = null;
}
try {
$preparationtype = $doc->preparationType;
} catch ( Exception $e ) {
$preparationtype = null;
}
try {
$citesStatus = $doc->citesStatus;
} catch ( Exception $e ) {
$citesStatus = NULL;
}
if (! empty ( $collectornb )) {
$collectornb = array_unique ( $collectornb );
if (($key = array_search ( 's.n.', $collectornb )) !== false) {
unset ( $collectornb [$key] );
}
}
try {
$latitude = $doc->latitude;
//Yii::info($latitude);
} catch ( Exception $e ) {
$latitude [] = NULL;
}
try {
$longitude = $doc->longitude;
} catch ( Exception $e ) {
$longitude [] = NULL;
}
try {
$canonicalName = $doc->canonicalName;
} catch ( Exception $e ) {
$canonicalName = NULL;
}
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) || !empty($doc->multimediaurl) ) {
if (is_array ( $doc->multimediaurl ) && $doc->multimediaurl[0] != "N/A") {
$multimedia = '';
$multimedia .= '
';
foreach ( $doc->multimediaurl as $index => $murl) {
if ($murl != "N/A" && strpos($murl, 'SpecimenPK') == "") {
if (! (strpos ( $multimedia, $murl ) === FALSE))
continue;
else {
if (strpos ( $murl, "http" ) === FALSE) {
$murl = "http://" . $murl;
}
$License = "";
$Copyright = "";
$TermsOfUse = "";
$CreatedWhen = "";
$CreatedBy = "";
if(isset($doc->licenses[$index]) && $doc->licenses[$index] != "N/A") { $License = "
License: ". $doc->licenses[$index]."
";}
if(isset($doc->copyrights[$index]) && $doc->copyrights[$index] != "N/A") { $Copyright = "
Copyright: ". $doc->copyrights[$index]."
";}
if(isset($doc->termsofuse[$index]) && $doc->termsofuse[$index] != "N/A") { $TermsOfUse = "
Terms of Use: ". $doc->termsofuse[$index]."
";}
if(isset($doc->createdwhen[$index]) && $doc->createdwhen[$index] != "N/A" ) { $CreatedWhen = "
Created: ". $doc->createdwhen[$index]."
";}
if(isset($doc->createdby[$index]) && $doc->createdby[$index] != "N/A") { $CreatedBy = "
Photographer: ". $doc->createdby[$index]."
";}
$multimedia = $multimedia . "
".$CreatedWhen.$CreatedBy.$Copyright.$TermsOfUse.$License."
";
}
}
}
$multimedia .= "
";
}
} catch ( Exception $e ) {
}
$blocked = $doc->blocked;
$blockedUntil = $doc->blockedUntil;
$disposition = $doc->disposition;
$disposition_clean = $doc->disposition_clean;
$condition = $doc->condition;
$DNALabel = "";
if (empty ( $blockedUntil ) and $blocked != 'yes' and $blocked != 'Yes' and $blocked != '1') {
if ($sampletype == "tissue")
$loan [$unitID] = [
" Tissue available ",
"OK",
"not blocked",
$condition,
$disposition_clean
];
if ($sampletype == "specimen")
$loan [$unitID] = [
" Specimen available ",
"OK",
"not blocked",
$condition,
$disposition_clean
];
if ($sampletype == "culture")
$loan [$unitID] = [
" Culture available ",
"OK",
"not blocked",
$condition,
$disposition_clean
];
if ($sampletype == "DNA")
{
if($preparationtype == "eDNA")
{ $DNALabel = "environmental"; }
else if($preparationtype == "aDNA")
{ $DNALabel = "ancient"; }
$loan [$unitID] = [
$DNALabel." 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")
if($preparationtype == "eDNA")
{ $DNALabel = "environmental"; }
else if($preparationtype == "aDNA")
{ $DNALabel = "ancient"; }
$loan [$unitID] = [
$DNALabel." DNA available ",
"OK",
"was blocked until " . $blockedUntil,
$condition,
$disposition_clean
];
}
if ( $blocked == 'yes' or $blocked == 'Yes' or $blocked == '1') {
if ($sampletype == "tissue")
$loan [$unitID] = [
" Tissue available ",
"BLOCKED",
"Blocked for loaning",
$condition,
$disposition_clean
];
if ($sampletype == "DNA")
if($preparationtype == "eDNA")
{ $DNALabel .= "environmental"; }
else if($preparationtype == "aDNA")
{ $DNALabel .= "ancient"; }
$loan [$unitID] = [
$DNALabel." DNA available ",
"BLOCKED",
"Blocked for loaning",
$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] = NULL;
$unitID2 [$index] = NULL;
$tripleid2 [$index] = NULL;
$collectioncode2 [$index] = NULL;
$institutioncode2 [$index] = NULL;
$guid2 [$index] = NULL;
$schemaurl2 [$index] = NULL;
$schemaname2 [$index] = NULL;
$basedirectory2 [$index] = NULL;
$sampletype2 [$index] = NULL;
$preparationtype2 [$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;
$filters ['guid2'] [$index] = NULL;
$citesStatus2 [$index] = NULL;
$multimedia2 [$index] = "";
$output = array (
'response' => $response,
'filters' => $filters,
'accesspoint' => $accesspoint,
'unitID' => $unitID,
'citesStatus' => $citesStatus,
'collectioncode' => $collectioncode,
'institutioncode' => $institutioncode,
'guid' => $guid,
'schemaurl' => $schemaurl,
'digirresourcename' => $digirresourcename,
'schemaname' => $schemaname,
'basedirectory' => $basedirectory,
'sampletype' => $sampletype,
'preparationtype' => $preparationtype,
'fullScientificName' => $fullScientificName,
'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 {
$guid2 [$index] = $doc->guid;
} catch ( Exception $e ) {
$guid2 [$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] = "unknown";
try {
$rb = $doc->recordbasis;
// echo "recordbasis!";
if (stristr ( $rb, "specimen" ) != FALSE || stristr ( $rb, "occurrence" ))
$sampletype2 [$index] = 'specimen';
} catch ( Exception $e ) {
}
}
try {
$preparationtype2 [$index] = $doc->preparationType;
} catch ( Exception $e ) {
$preparationtype2 [$index] = "";
}
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;
$filters ['guid2'] [$index] = $doc->institutioncode;
try {
$multimedia2 [$index] = "";
try {
if (is_array ( $doc->multimediaurl ) && $doc->multimediaurl[0] != "N/A") {
$multimedia2 [$index] = '';
foreach ( $doc->multimediaurl as $ind => $murl )
if ($murl != "N/A" && strpos($murl, 'manifest.json') == "")
if (! strpos ( $multimedia2 [$index], $murl )){
$License = "";
$Copyright = "";
$TermsOfUse = "";
$CreatedWhen = "";
$CreatedBy = "";
if (isset($doc->licenses[$ind]) && $doc->licenses[$ind] != "N/A") {
$License = "
License: " . $doc->licenses[$ind] . "
";
}
if (isset($doc->copyrights[$ind]) && $doc->copyrights[$ind] != "N/A") {
$Copyright = "
Copyright: " . $doc->copyrights[$ind] . "
";
}
if (isset($doc->termsofuse[$ind]) && $doc->termsofuse[$ind] != "N/A") {
$TermsOfUse = "
Terms of Use: " . $doc->termsofuse[$ind] . "
";
}
if (isset($doc->createdwhen[$ind]) && $doc->createdwhen[$ind] != "N/A") {
$CreatedWhen = "
Created: " . $doc->createdwhen[$ind] . "
";
}
if (isset($doc->createdby[$ind]) && $doc->createdby[$ind] != "N/A") {
$CreatedBy = "
Photographer: " . $doc->createdby[$ind] . "
";
}
$multimedia2 [$index] = $multimedia2 [$index] . "
" . $CreatedWhen . $CreatedBy . $Copyright . $TermsOfUse . $License . "
";
//$multimedia2 [$index] = $multimedia2 [$index] . "
";
}else
{ $multimedia2 [$index] == ""; }
$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;
$DNALabel = "";
if ($sampletype != "tissue") {
if (empty ( $blockedUntil )) {
if ($sampletype2 [$index] == "tissue")
$loan [$filters ['unitID2'] [$index]] = [
" Tissue available ",
"OK",
"not blocked",
$condition,
$disposition_clean
];
if ($sampletype2 [$index] == "environmental sample")
$loan [$filters ['unitID2'] [$index]] = [
" from ".$preparationtype2 [$index],
"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
];
if ($sampletype2 [$index] == "environmental sample")
$loan [$filters ['unitID2'] [$index]] = [
" from ".$preparationtype2 [$index],
"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
];
if ($sampletype2 [$index] == "environmental sample")
$loan [$filters ['unitID2'] [$index]] = [
" from ".$preparationtype2 [$index],
"BLOCKED",
"is blocked until " . $blockedUntil,
$condition,
$disposition_clean
];
}
}
}
}
$output = array (
'response' => $response,
'filters' => $filters,
'accesspoint' => $accesspoint,
'unitID' => $unitID,
'collectioncode' => $collectioncode,
'institutioncode' => $institutioncode,
'guid' => $guid,
'schemaurl' => $schemaurl,
'digirresourcename' => $digirresourcename,
'schemaname' => $schemaname,
'basedirectory' => $basedirectory,
'sampletype' => $sampletype,
'preparationtype' => $preparationtype,
'multimedia' => $multimedia,
'canonicalName' => $canonicalName,
'tripleid' => $tripleidstoreid,
'latitude' => $latitude,
'longitude' => $longitude,
'occurrenceFile' => $occurrenceFile,
'elementtype' => $elementtype,
'accesspoint2' => $accesspoint2,
'unitID2' => $unitID2,
'collectioncode2' => $collectioncode2,
'tripleid2' => $tripleid2,
'institutioncode2' => $institutioncode2,
'guid2' => $guid2,
'schemaurl2' => $schemaurl2,
'occurrenceFile2' => $occurrenceFile2,
'elementtype2' => $elementtype2,
'schemaname2' => $schemaname2,
'basedirectory2' => $basedirectory2,
'digirresourcename2' => $digirresourcename2,
'sampletype2' => $sampletype2,
'preparationtype2' => $preparationtype2,
'longitude2' => $longitude2,
'latitude2' => $latitude2,
'multimedia2' => $multimedia2,
'citesStatus2' => $citesStatus2,
'loan' => $loan,
'fullScientificName' => $fullScientificName,
'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 ( $canonicalName, $tripleidstoreid );
if (! empty ( $GGBNs ))
{ $output ['GGBNs'] = $GGBNs; }
else
{ $output ['GGBNs'] = [ ]; }
return $output;
} // if($upperTripleidstoreids != "")
else {
$output = array (
'response' => $response,
'filters' => $filters,
'accesspoint' => $accesspoint,
'citesStatus' => $citesStatus,
'unitID' => $unitID,
'collectioncode' => $collectioncode,
'institutioncode' => $institutioncode,
'guid' => $guid,
'schemaurl' => $schemaurl,
'digirresourcename' => $digirresourcename,
'schemaname' => $schemaname,
'basedirectory' => $basedirectory,
'sampletype' => $sampletype,
'preparationtype' => $preparationtype,
'multimedia' => $multimedia,
'canonicalName' => $canonicalName,
'tripleid' => $tripleidstoreid,
'latitude' => $latitude,
'longitude' => $longitude,
'loan' => $loan,
'occurrenceFile' => $occurrenceFile,
'fullScientificName' => $fullScientificName,
'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 ( $canonicalName, $tripleidstoreid );
if (! empty ( $GGBNs ))
{ $output ['GGBNs'] = $GGBNs; }
else
{ $output ['GGBNs'] = [ ]; } */
return $output;
}
}
}
public static function createOutputTaxonBased($name) {
/* $config = SOLRQueryManager::getConfigDetails ();
$query = SOLRQueryManager::createSearchQuery ( $config );
$raw_response = SOLRQueryManager::fillAndExecuteQuery ( $query, 'fullScientificName:"'. $name . '"', "", [], true );*/
$config = SOLRQueryManager::getConfigSearch ();
$query = SOLRQueryManager::createSearchQuery ( $config );
$q = [
'originalCanonicalName:"'.$name.'" AND accessionStatus:C'
];
$CustomizedFacets = SOLRQueryManager::CustomizedFacetsListView($query, $config, $q, "");
$multimedia = "";
$longitude = [];
$latitude = [];
//var_dump ($raw_response);
/* foreach ( $raw_response as $doc ) {
if (is_array ( $doc->multimediaurl ) && $doc->multimediaurl[0] != "N/A") {
$multimedia = '';
foreach ( $doc->multimediaurl as $index => $murl) {
if ($murl != "N/A") {
if (! (strpos ( $multimedia, $murl ) === FALSE))
continue;
else {
if (strpos ( $murl, "http" ) === FALSE) {
$murl = "http://" . $murl;
}
$License = "";
$Copyright = "";
$TermsOfUse = "";
$CreatedWhen = "";
$CreatedBy = "";
if($doc->licenses[$index] != "N/A" && isset($doc->licenses[$index])) { $License = "
License: ". $doc->licenses[$index]."
";}
if($doc->copyrights[$index] != "N/A" && isset($doc->copyrights[$index])) { $Copyright = "
Copyright: ". $doc->copyrights[$index]."
";}
if($doc->termsofuse[$index] != "N/A" && isset($doc->termsofuse[$index])) { $TermsOfUse = "
Terms of Use: ". $doc->termsofuse[$index]."
";}
if($doc->createdwhen[$index] != "N/A" && isset($doc->createdwhen[$index])) { $CreatedWhen = "
Created: ". $doc->createdwhen[$index]."
";}
if($doc->createdby[$index] != "N/A" && isset($doc->createdby[$index])) { $CreatedBy = "
Photographer: ". $doc->createdby[$index]."
";}
$multimedia = $multimedia . "
".$CreatedWhen.$CreatedBy.$Copyright.$TermsOfUse.$License."
";
}
}
}
$multimedia .= "
"; }
if(isset($doc->longitude) or $doc->longitude != "") $longitude = array_merge($longitude, $doc->longitude);
if(isset($doc->latitude) or $doc->latitude != "") $latitude = array_merge($latitude, $doc->latitude);
} */
$output = array ('fullScientificName' => $name,
'multimedia' => $multimedia,
'longitude' => $longitude,
'latitude' => $latitude,
'facetNumbers' => $CustomizedFacets
);
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 ( '
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 ( '
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, $associatedGuid) {
// echo ( "createAssociatedRecordQuery " . $associatedUnitID . " " . $associatedSchemaUrl );
$query2 = "";
// TODO
// add guid to ABCD Queries
if ($associatedSchemaUrl == "http://www.tdwg.org/schemas/abcd/2.06") {
$query2 = urlencode ( '
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 ( '
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, $guid) {
// 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, $guid) {
$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 );
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): " . strval(round(floatval($doc->latitude[0]), 1)) . "|" . $doc->longitude [0] . "
";
}
return $out;
}
// type = specimen or tissue or dna
public static function readDwCA($unitToFind, $folder, $basedirectory, $dom, $sampleType, $occurrenceFile, $guidToFind) {
//Yii::info ( "READ " . $unitToFind . " in file " . $occurrenceFile );
echo "";
$Cores = $dom->getElementsByTagName ( 'core' );
$Extensions = $dom->getElementsByTagName ( 'extension' );
$xml = simplexml_load_file ( $folder . "meta.xml" );
// $xml = simplexml_load_file ("http://bgbm-import/ggbntestunits/8937452-fishes__associated_only_/nmnh_occurrence_archive/associated/smallArchive/" . "meta.xml" );
foreach ( $xml->attributes () as $a => $b ) {
if ($a === 'metadata')
{ $EML = $b; }
}
foreach ($Cores as $Core) {
$encoding = $Core->getAttribute ( 'encoding' );
$fieldTerminatedBy = $Core->getAttribute ( 'fieldsTerminatedBy' );
if($fieldTerminatedBy == ","){ $fieldsTerminatedBy = $fieldTerminatedBy; }
else { $fieldsTerminatedBy = "%09"; }
$linesTerminatedBy = $Core->getAttribute ( 'linesTerminatedBy' );
$fieldsEnclosedBy = $Core->getAttribute ( 'fieldsEnclosedBy' );
$ignoreHeaderLines = $Core->getAttribute ( 'ignoreHeaderLines' );
$fields = $Core->getElementsByTagName ( 'field');
foreach ($fields as $index => $field)
{ if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/catalogNumber')
{ $CatalogNoID = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/occurrenceID')
{ $OccurrenceID = $field->getAttribute('index'); }
}
}
$output = '';
$relation = '';
$sample = '';
$preservation = '';
$preparation = '';
$sequences = '';
$gelimage = '';
$permit = '';
$prepSex = '';
$locality = "";
$identification = "";
$gathering = "";
$ID_Record = null;
$material = "";
$taxonlist = "";
$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 {
$creatorxml = $creator->individualName;
} catch ( yii\base\ErrorException $e ) {
}
try {
$addressxml = $creator->address;
} catch ( yii\base\ErrorException $e ) {
}
$addressT = [ ];
try {
$addressT [] = $creatorxml->surName;
$addressT [] .= $creatorxml->givenName;
$addressT [] .= $creator->electronicMailAddress;
$addressT [] .= $orga;
$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 ) {
}
$metaprovider = $datasetxml->metadataProvider;
try {
$orgameta = $metaprovider->organizationName;
//Yii::info ( "ORGA Metada " . $orgameta );
} catch ( yii\base\ErrorException $e ) {
}
try {
$metaproviderxml = $metaprovider->individualName;
} catch ( yii\base\ErrorException $e ) {
}
try {
$addressmetaxml = $metaprovider->address;
} catch ( yii\base\ErrorException $e ) {
}
$addressMP = [ ];
try {
$addressMP [] = $metaproviderxml->surName;
$addressMP [] .= $metaproviderxml->givenName;
$addressMP [] .= $metaprovider->electronicMailAddress;
$addressMP [] .= "(".$metaprovider->positionName.")";
$addressMP [] .= $orgameta;
$addressMP [] .= $addressmetaxml->deliveryPoint;
$addressMP [] .= $addressmetaxml->city;
$addressMP [] .= $addressmetaxml->administrativeArea;
$addressMP [] .= $addressmetaxml->postalCode;
$addressMP [] .= $addressmetaxml->country;
} catch ( yii\base\ErrorException $e ) {
}
try {
$addressMP = array_filter ( $addressMP );
} catch ( yii\base\ErrorException $e ) {
}
$intellectualRightsxml = $datasetxml->intellectualRights;
$irT = [ ];
if($intellectualRightsxml) {
try {
$irT [] = $intellectualRightsxml->para;
$paraXML = $intellectualRightsxml->para;
$ulinkXML = $paraXML->ulink;
/* if(isset ($ulinkXML)) {$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 ) {
$catalogNumber = "";
$collectionCode = "";
$collectionID = "";
$institutionCode = "";
$datasetName = "";
$basisOfRecord = "";
$guid = "";
$scientificName = "";
$identifiedBy = "";
$identificationReferences = "";
$identificationRemarks = "";
$dateIdentified = "";
$family = "";
$order = "";
$class = "";
$phylum = "";
$kingdom = "";
$typeStatus = "";
$country = "";
$locality = "";
$locationID = "";
$stateProvince = "";
$islandGroup = "";
$decimalLatitude = "";
$decimalLongitude = "";
$verbatimElevation = "";
$minimumElevationInMeters = "";
$maximumElevationInMeters = "";
$verbatimDepth = "";
$minimumDepthInMeters = "";
$maximumDepthInMeters = "";
$recordedBy = "";
$recordNumber = "";
$fieldNumber = "";
$verbatimEventDate = "";
$eventDate = "";
$sex = "";
$preparations = "";
$individualCount = "";
$lifeStage = "";
$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;
foreach ( $fields as $field ) {
$idx = $field->getAttribute ( 'index' );
$field_columns_core [$field->getAttribute ( 'index' )] = $field->getAttribute ( 'term' );
if ($field->getAttribute ( 'index' ) > $max)
$max = $field->getAttribute ( 'index' );
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/catalogNumber')
{ $catalogNumber = $field->getAttribute('index');
}
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/collectionCode')
{ $collectionCode = $field->getAttribute('index');
if($collectionCode == "") { $staticValues_collectionCode = $field->getAttribute('default');}
}
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/collectionID')
{ $collectionID = $field->getAttribute('index');
if($collectionID == "") { $staticValues_collectionID = $field->getAttribute('default'); } }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/institutionCode')
{ $institutionCode = $field->getAttribute('index');
if($institutionCode == "") { $staticValues_institutionCode = $field->getAttribute('default'); } }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/datasetName')
{ $datasetName = $field->getAttribute('index');
if($datasetName == "") { $staticValues_datasetName = $field->getAttribute('default'); } }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/basisOfRecord')
{ $basisOfRecord = $field->getAttribute('index');
if($basisOfRecord == "") { $staticValues_basisOfRecord = $field->getAttribute('default'); } }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/occurrenceID')
{ $guid = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/scientificName')
{ $scientificName = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/identifiedBy')
{ $identifiedBy = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/identificationRemarks')
{ $identificationRemarks = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/identificationReferences')
{ $identificationReferences = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/dateIdentified')
{ $dateIdentified = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/family')
{ $family = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/order')
{ $order = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/class')
{ $class = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/phylum')
{ $phylum = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/kingdom')
{ $kingdom = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/typeStatus')
{ $typeStatus = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/country')
{ $country = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/locality')
{ $locality = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/locationID')
{ $locationID = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/islandGroup')
{ $islandGroup = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/stateProvince')
{ $stateProvince = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/verbatimElevation')
{ $verbatimElevation = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/minimumElevationInMeters')
{ $minimumElevationInMeters = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/maximumElevationInMeters')
{ $maximumElevationInMeters = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/verbatimDepth')
{ $verbatimDepth = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/minimumDepthInMeters')
{ $minimumDepthInMeters = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/maximumDepthInMeters')
{ $maximumDepthInMeters = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/decimalLatitude')
{ $decimalLatitude = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/decimalLongitude')
{ $decimalLongitude = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/recordedBy')
{ $recordedBy = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/recordNumber')
{ $recordNumber = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/fieldNumber')
{ $fieldNumber = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/verbatimEventDate')
{ $verbatimEventDate = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/eventDate')
{ $eventDate = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/sex')
{ $sex = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/preparations')
{ $preparations = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/individualCount')
{ $individualCount = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/lifeStage')
{ $lifeStage = $field->getAttribute('index'); }
}
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."
" );
$feed_core = 'http://bgbm-import/feed/dwca.cgi' .
'?fileStore='. rawurlencode(Yii::$app->params['fileStore']) .
'&baseDirectory='. rawurlencode($basedirectory) .
'&fileName=' . rawurlencode($occurrenceFile);
//Trick17 f�r NHM Pollinators
if($_REQUEST ['collectioncode'] == "BMNH(E)") {
$feed_core .= '&idIndex=55';
}
else {
if($guidToFind != "" and $_REQUEST ['collectioncode'] != "BMNH(E)") $idIndex = $OccurrenceID;
else $idIndex = $CatalogNoID;
$feed_core .= '&idIndex=' . $idIndex;
}
$feed_core .= '&fieldsTerminatedBy=' . $fieldsTerminatedBy;
if($fieldsEnclosedBy != "" && $_REQUEST ['collectioncode'] != "E" && $_REQUEST ['collectioncode'] != "BMNH(E)") {
$feed_core .= '&fieldsEnclosedBy=' . rawurlencode($fieldsEnclosedBy); }
if($guidToFind != "" and $_REQUEST ['collectioncode'] != "BMNH(E)") $recordToFind = $guidToFind;
else $recordToFind = $unitToFind;
$feed_core .= '&id=' . rawurlencode($recordToFind) .
'&linesTerminatedBy=' .$linesTerminatedBy .
'&ignoreHeader=' . $ignoreHeaderLines .
'&encoding=' . $encoding;
// echo $feed_core;
// //does only parse this part if the current thing to display is the DNA part
$handle = fopen ( $feed_core, "r" );
if ($handle) {
if($fieldsTerminatedBy == ",") { $separator = ","; }
else { $separator = "\t"; }
$header = fgetcsv ( $handle, 0, $separator);
//fopen("aslkdhf==||".implode($header,"@")." - '".""."'"." - '".""."'", "r" );
foreach ( $header as $index => $term ) {
if ($term == "catalogNumber") {
$ColumnCatalogNumber = $index;
}
if ($term == "id") {
$ColumnIndex = $index;
}
if ($term == "occurrenceID") {
$ColumnOccurrenceID = $index;
}
//trick17 für Norwegen, Oslo
if(!isset($ColumnIndex)) { $ColumnIndex = 0; }
if(!isset($ColumnOccurrenceID)) { $ColumnOccurrenceID = 0; }
//trick17 für Norwegen, Oslo
}
if (empty ( $ColumnCatalogNumber )) {
//fopen("aslkdhf==||".implode($field_columns_core,"@")." - '", "r" );
$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;
#fopen("aslkdhf==||".$idElt." - '", "r" );
if (isset ( $idElt ))
$ColumnIndex = $idElt;
else
$ColumnIndex = 0;
$header = [ ];
foreach ( $field_columns_core as $k => $v )
$tmp = explode ( "/", $v );
$header [$k] = end ( $tmp );
/*
* from a forum: The problem is, that end requires a reference, because it modifies the internal representation of the array
* (i.e. it makes the current element pointer point to the last element).
* The result of explode('/', $ve) cannot be turned into a reference.
* This is a restriction in the PHP language, that probably exists for simplicity reasons.
*/ }
$row = 0;
$idfound = false;
$allIDs = [ ];
//array_push ( $allIDs, $unitToFind );
if (is_array ( $unitToFind ))
$allIDs = array_merge ( $unitToFind, $allIDs );
else
array_push ( $allIDs, $unitToFind );
$handle2 = fopen ( $feed_core, "r" );
if($fieldsTerminatedBy == ",") { $separator = ","; }
else { $separator = "\t"; }
while ( ($data = fgetcsv ( $handle2, 0, $separator )) !== FALSE ) {
$tmp = 1;
$row ++;
$idfound = false;
if (count ( $data ) > 1) {
$currentID = $data [$ColumnCatalogNumber];
if (isset ( $ColumnOccurrenceID ))
$currentOccurrenceID = $data [$ColumnOccurrenceID];
else
$currentOccurrenceID = "";
if (in_array ( $currentID, $allIDs ) || in_array ( $currentOccurrenceID, $allIDs ) || in_array ( '"'.$currentID.'"', $allIDs) || in_array ('"'.$currentOccurrenceID.'"', $allIDs))
$idfound = true;
//fopen("aslkdhf==||".implode($allIDs,"@")." - '".$currentID."'"." - '".$currentOccurrenceID."'", "r" );
if ($idfound) {
$ID_Record = $data [$ColumnIndex];
#fopen("aslkdhf==||".implode($field_columns_core,"@")." - '", "r" );
if (Yii::$app->params ['catalogNumberClickable'])
$output .= "Catalog Number: " . $data [$catalogNumber] . " ";
else
$output .= "Catalog Number: " . $data [$catalogNumber] . " ";
if (isset ( $data [$collectionCode] ))
$output .= $data [$collectionCode];
if (isset ( $staticValues_collectionCode )) {
$output .= $staticValues_collectionCode;
}
if (isset ( $staticValues_collectionID )) {
$output .= " (" . $staticValues_collectionID . ")";
}
if (isset ( $data [$institutionCode] ))
$output .= " (" . $data [$institutionCode] . ")";
if (isset ( $staticValues_institutionCode ))
$output .= " (" . $staticValues_institutionCode . ")";
if (isset ( $staticValues_datasetName ))
$output .= " (" . $staticValues_datasetName . ")";
$output .= "
";
if (isset ( $data [$basisOfRecord] ))
$output .= "Record Basis: " . $data [$basisOfRecord] . "
";
if (isset ( $staticValues_basisOfRecord ))
$output .= "Record Basis: " . $staticValues_basisOfRecord . "
";
if (isset ( $data [$guid] )) {
if (! (stripos ( $data [$guid], "http" ) === FALSE))
$output .= "GUID/Occurrence ID: " . $data [$guid] . "
";
else
$output .= "GUID/Occurrence ID: " . $data [$guid] . "
";
}
if (isset ( $data [$scientificName] ) && ! empty ( $data [$scientificName] ))
$identification .= "Identification
Name:
" . $data [$scientificName] . "
";
if ((isset ( $data [$family] ) && ! empty ( $data [$family] )) || (isset ( $data [$order] ) && ! empty ( $data [$order] )) || (isset ( $data [$class] ) && ! empty ( $data [$class] )) || (isset ( $data [$phylum] ) && ! empty ( $data [$phylum] )) || (isset ( $data [$kingdom] ) && ! empty ( $data [$kingdom] ))) {
$identification .= "Taxonomy (Occurrence): ";
if (isset ( $data [$family] ) && ! empty ( $data [$family] ))
$identification .= "" . $data [$family] . " (family); ";
if (isset ( $data [$order] ) && ! empty ( $data [$order] ))
$identification .= "" . $data [$order] . " (order); ";
if (isset ( $data [$class] ) && ! empty ( $data [$class] ))
$identification .= "" . $data [$class] . " (class); ";
if (isset ( $data [$phylum] ) && ! empty ( $data [$phylum] ))
$identification .= "" . $data [$phylum] . " (phylum); ";
if (isset ( $data [$kingdom] ) && ! empty ( $data [$kingdom] ))
$identification .= "" . $data [$kingdom] . " (kingdom); ";
$taxonomySet = true;
$identification .= "
";
}
if ((isset ( $data [$identifiedBy] ) && (strcasecmp ( $data [$identifiedBy], "" ) != 0)) || (isset ( $data [$identificationReferences] ) && (strcasecmp ( $data [$identificationReferences], "" ) != 0)) || (isset ( $data [$identificationRemarks] ) && (strcasecmp ( $data [$identificationRemarks], "" ) != 0))) {
// $identification .= "Identification details
";
if (isset ( $data [$identifiedBy] ) && (strcasecmp ( $data [$identifiedBy], "" ) != 0)) {
$identification .= "Identified by: " . $data [$identifiedBy] . "
";
}
if (isset ( $data [$dateIdentified] ) && (strcasecmp ( $data [$dateIdentified], "" ) != 0)) {
$identification .= "Identified (date): " . $data [$dateIdentified] . "
";
}
if (isset ( $data [$identificationReferences] ) && (strcasecmp ( $data [$identificationReferences], "" ) != 0)) {
$identification .= "References: " . $data [$identificationReferences] . "
";
}
if (isset ( $data [$identificationRemarks] ) && (strcasecmp ( $data [$identificationRemarks], "" ) != 0)) {
$identification .= "Remarks: " . $data [$identificationRemarks] . "
";
}
if (isset ( $data [$typeStatus] ) && (strcasecmp ( $data [$typeStatus], "" ) != 0)) {
$identification .= "Type Status: " . $data [$typeStatus] . "
";
}
}
$identification .= "
";
if (isset ( $data [$typeStatus] )) {
$identification . "Type Status: " . $data [$typeStatus] . "";
}
if (isset ( $data [$country] ) || isset ( $data [$locality] ) || isset ( $data [$stateProvince] ))
$gathering .= "Gathering Event
";
if (isset ( $data [$country] ) && $data [$country] != "" )
$gathering .= "Country: " . $data [$country] . "
";
if (isset ( $data [$stateProvince] ) && ! empty ( $data [$stateProvince]))
$gathering .= "State/Province: " . $data [$stateProvince] . "
";
if (isset ( $data [$islandGroup] ) && ! empty ( $data [$islandGroup]))
$gathering .= "Island Group: " . $data [$islandGroup] . "
";
if (isset ( $data [$locality] )&& ! empty ( $data [$locality]))
$gathering .= "Locality: " . $data [$locality] . "
";
if ((isset ($data [$verbatimElevation] )&& ! empty ( $data [$verbatimElevation]))
|| (isset ($data [$minimumElevationInMeters] )&& ! empty ( $data [$minimumElevationInMeters]))
|| (isset ($data [$maximumElevationInMeters] )&& ! empty ( $data [$maximumElevationInMeters])))
$gathering .= "Elevation: ";
if(isset ($data [$minimumElevationInMeters] )&& ! empty ( $data [$minimumElevationInMeters]))
$gathering .= $data [$minimumElevationInMeters] . " m";
if(isset ($data [$maximumElevationInMeters] )&& ! empty ( $data [$maximumElevationInMeters]))
$gathering .= " - ". $data [$maximumElevationInMeters] . " m";
if(isset ($data [$verbatimElevation] )&& ! empty ( $data [$verbatimElevation]))
$gathering .= " [" . $data[$verbatimElevation] . "]";
$gathering .= "
";
if ((isset ($data [$verbatimDepth] )&& ! empty ( $data [$verbatimDepth]))
|| (isset ($data [$minimumDepthInMeters] )&& ! empty ( $data [$minimumDepthInMeters]))
|| (isset ($data [$maximumDepthInMeters] )&& ! empty ( $data [$maximumDepthInMeters])))
$gathering .= "Depth: ";
if(isset ($data [$minimumDepthInMeters] )&& ! empty ( $data [$minimumDepthInMeters]))
$gathering .= $data [$minimumDepthInMeters] . " m";
if(isset ($data [$maximumDepthInMeters] )&& ! empty ( $data [$maximumDepthInMeters]))
$gathering .= " - ". $data [$maximumDepthInMeters] . " m";
if(isset ($data [$verbatimDepth] )&& ! empty ( $data [$verbatimDepth]))
$gathering .= " [" . $data [$verbatimDepth] . "]";
$gathering .= "
";
if (isset ( $data [$decimalLatitude] ) || isset ( $data [$decimalLongitude] )) {
if (! empty ( $data [$decimalLatitude] ) && ! empty ( $data [$decimalLongitude] )) {
$gathering .= "Coordinates (lat|lon): ";
if (isset ( $data [$decimalLatitude] )) {
Yii::info($data);
$gathering .= strval(round(floatval($data [$decimalLatitude]), Yii::$app->params ['coordinatesPrecision'])); // Latitude in Gathering Event section
$latitude [] = strval(round(floatval($data [$decimalLatitude]), Yii::$app->params ['coordinatesPrecision'])); // Latitude in Map
}
$gathering .= " | ";
if (isset ( $data [$decimalLongitude] )) {
$gathering .= strval(round(floatval($data [$decimalLongitude]), Yii::$app->params ['coordinatesPrecision'])); // Longitude in Gathering Event section
$longitude [] = strval(round(floatval($data [$decimalLongitude]), Yii::$app->params ['coordinatesPrecision'])); // Longitude in Map
}
$gathering .= "
";
}
}
if (isset ( $data [$fieldNumber] ))
if (strcasecmp ( $data [$fieldNumber], "" ) != 0)
$gathering .= "Field number: " . $data [$fieldNumber] . "
";
if (isset ( $data [$locationID] ))
if (strcasecmp ( $data [$locationID], "" ) != 0)
$gathering .= "Location ID: " . $data [$locationID] . "
";
if (isset ( $data [$recordedBy] ))
if (strcasecmp ( $data [$recordedBy], "" ) != 0)
$gathering .= "Collector(s): " . $data [$recordedBy] . "
";
if (isset ( $data [$recordNumber] ))
if (strcasecmp ( $data [$recordNumber], "" ) != 0)
$gathering .= "Collector's number: " . $data [$recordNumber] . "
";
if (isset ( $data [$verbatimEventDate] ))
if (strcasecmp ( $data [$verbatimEventDate], "" ) != 0)
$gathering .= "Collection Date: " . $data [$verbatimEventDate] . "
";
if (isset ( $data [$eventDate] ))
if (strcasecmp ( $data [$eventDate], "" ) != 0)
$gathering .= "Collection Date: " . $data [$eventDate] . "
";
// PREPARATION SPECIMEN && SEX
if (isset ( $data [$sex] ))
if (strcasecmp ( $data [$sex], "" ) != 0)
$prepSex .= "
Sex: " . $data [$sex] . "
";
if (isset ( $data [$individualCount] ))
if (strcasecmp ( $data [$individualCount], "" ) != 0)
$prepSex .= "
Individual Count: " . $data [$individualCount] . "
";
if (isset ( $data [$lifeStage] ))
if (strcasecmp ( $data [$lifeStage], "" ) != 0)
$prepSex .= "
Individual Count: " . $data [$lifeStage] . "
";
if (isset ( $data [$preparations] ))
if (strcasecmp ( $data [$preparations], "" ) != 0)
$prepSex .= "Preparations: " . $data [$preparations] . "
";
}
}
}
#$ID_Record = "";
fclose ( $handle2 );
// }
} // foreach ($Cores as $Core)
else
echo ("Could not read the file ?
");
}
// Start Extensions
foreach ( $Extensions as $Extension ) {
$encoding = $Core->getAttribute ( 'encoding' );
$fieldTerminatedBy = $Core->getAttribute ( 'fieldsTerminatedBy' );
if($fieldTerminatedBy == ","){ $fieldsTerminatedBy = $fieldTerminatedBy; }
else { $fieldsTerminatedBy = "%09"; }
$linesTerminatedBy = $Core->getAttribute ( 'linesTerminatedBy' );
$fieldsEnclosedBy = $Core->getAttribute ( 'fieldsEnclosedBy' );
$ignoreHeaderLines = $Core->getAttribute ( 'ignoreHeaderLines' );
$resourceRelationshipID = "";
$relatedResourceID = "";
$relationshipOfResource = "";
$preparationMaterials = "";
$preparationDate = "";
$preparedBy = "";
$preparationType = "";
$concentration = "";
$concentrationUnit = "";
$ratioOfAbsorbance260_230 = "";
$ratioOfAbsorbance260_280 = "";
$qualityCheckDate = "";
$materialSampleType = "";
$preservationType = "";
$preservationDateBegin = "";
$identifier = "";
$DNAThreshold = "";
$percentAboveThreshold = "";
$gelBuffer = "";
$gelConcentration = "";
$gelLadder = "";
$gelStain = "";
$gelStainConcentration = "";
$stainingMethod = "";
$gelRemarks = "";
$permitType = "";
$permitStatus = "";
$permitStatusQualifier = "";
$permitText = "";
$marker = "";
$geneticAccessionNumber = "";
$accessURI = "";
$scientificName = "";
$family = "";
$order = "";
$class = "";
$phylum = "";
$kingdom = "";
$identifiedBy = "";
$identificationReferences = "";
$identificationRemarks = "";
$dateIdentified = "";
$typeStatus = "";
$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' );
$OccurrenceID_extension = $ColumnID->getAttribute ( 'index' );
}
$fields = $Extension->getElementsByTagName ( 'field' );
foreach ( $fields as $field ) {
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/resourceRelationshipID')
{ $resourceRelationshipID = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/relatedResourceID')
{ $relatedResourceID = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/relationshipOfResource')
{ $relationshipOfResource = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://data.ggbn.org/schemas/ggbn/terms/preparationMaterials')
{ $preparationMaterials = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://data.ggbn.org/schemas/ggbn/terms/preparationDate')
{ $preparationDate = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://data.ggbn.org/schemas/ggbn/terms/preparationBy')
{ $preparationBy = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://data.ggbn.org/schemas/ggbn/terms/preparationType')
{ $preparationType = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://data.ggbn.org/schemas/ggbn/terms/concentration')
{ $concentration = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://data.ggbn.org/schemas/ggbn/terms/concentrationUnit')
{ $concentrationUnit = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://data.ggbn.org/schemas/ggbn/terms/ratioOfAbsorbance260_230')
{ $ratioOfAbsorbance260_230 = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://data.ggbn.org/schemas/ggbn/terms/ratioOfAbsorbance260_280')
{ $ratioOfAbsorbance260_280 = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://data.ggbn.org/schemas/ggbn/terms/qualityCheckDate')
{ $qualityCheckDate = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://data.ggbn.org/schemas/ggbn/terms/materialSampleType')
{ $materialSampleType = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://data.ggbn.org/schemas/ggbn/terms/preservationType')
{ $preservationType = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://data.ggbn.org/schemas/ggbn/terms/preservationDateBegin')
{ $preservationDateBegin = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/identifier')
{ $identifier = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/accessURI')
{ $accessURI = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://data.ggbn.org/schemas/ggbn/terms/DNAThreshold')
{ $DNAThreshold = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://data.ggbn.org/schemas/ggbn/terms/percentAboveThreshold')
{ $percentAboveThreshold = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://data.ggbn.org/schemas/ggbn/terms/gelBuffer')
{ $gelBuffer = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://data.ggbn.org/schemas/ggbn/terms/gelConcentration')
{ $gelConcentration = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://data.ggbn.org/schemas/ggbn/terms/gelLadder')
{ $gelLadder = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://data.ggbn.org/schemas/ggbn/terms/gelStain')
{ $gelStain = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://data.ggbn.org/schemas/ggbn/terms/gelStainConcentration')
{ $gelStainConcentration = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://data.ggbn.org/schemas/ggbn/terms/stainingMethod')
{ $stainingMethod = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://data.ggbn.org/schemas/ggbn/terms/gelRemarks')
{ $gelRemarks = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://data.ggbn.org/schemas/ggbn/terms/permitType')
{ $permitType = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://data.ggbn.org/schemas/ggbn/terms/permitStatus')
{ $permitStatus = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://data.ggbn.org/schemas/ggbn/terms/permitStatusQualifier')
{ $permitStatusQualifier = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://data.ggbn.org/schemas/ggbn/terms/permitText')
{ $permitText = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://data.ggbn.org/schemas/ggbn/terms/marker')
{ $marker = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://data.ggbn.org/schemas/ggbn/terms/geneticAccessionNumber')
{ $geneticAccessionNumber = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://data.ggbn.org/schemas/ggbn/terms/amplificationDate')
{ $amplificationDate = $field->getAttribute('index'); }
else $amplificationDate = "";
if($field->getAttribute('term') == 'http://data.ggbn.org/schemas/ggbn/terms/BOLDProcessID')
{ $BOLDProcessID = $field->getAttribute('index'); }
else $BOLDProcessID = "";
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/scientificName')
{ $scientificName = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/family')
{ $family = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/order')
{ $order = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/class')
{ $class = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/phylum')
{ $phylum = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/kingdom')
{ $kingdom = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/identifiedBy')
{ $identifiedBy = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/identificationReferences')
{ $identificationReferences = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/identificationRemarks')
{ $identificationRemarks = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/dateIdentified')
{ $dateIdentified = $field->getAttribute('index'); }
if($field->getAttribute('term') == 'http://rs.tdwg.org/dwc/terms/typeStatus')
{ $typeStatus = $field->getAttribute('index'); }
$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
$feed_extension = 'http://bgbm-import/feed/dwca.cgi' .
'?fileStore='. rawurlencode(Yii::$app->params['fileStore']) .
'&baseDirectory='. rawurlencode($basedirectory) .
'&fileName=' . rawurlencode($FileLocationExtension) .
//'&idIndex=' .$field_columns_extension [0] . // $ColumnID .
'&idIndex=' . $OccurrenceID_extension .
'&fieldsTerminatedBy=' . $fieldsTerminatedBy;
if($fieldsEnclosedBy != "" && $_REQUEST ['collectioncode'] != "E") {
$feed_extension .= '&fieldsEnclosedBy=' . rawurlencode($fieldsEnclosedBy); }
$feed_extension .= '&id=' . rawurlencode($ID_Record) .
'&linesTerminatedBy=' . $linesTerminatedBy .
'&ignoreHeader=' . $ignoreHeaderLines .
'&encoding=' . $encoding;
// echo "
".$feed_extension."
";
if ((fopen ( $feed_extension, "r" )) !== FALSE) {
//Yii::info ( "FileLocationExtension: " . $FileLocationExtension );
if($fieldsTerminatedBy == ",") { $separator = ","; }
else { $separator = "\t"; }
$handle = fopen ( $feed_extension, "r" );
Yii::info ( $feed_extension );
Yii::info ( $handle );
// Yii::info ( "COLUMNID " . $ColumnID );
// Yii::info ( "IDRECORD " . $ID_Record );
$row = 0;
while ( ($data = fgetcsv ( $handle, 1000, $separator )) !== FALSE ) {
$tmp = 1;
$row ++;
if (sizeof ( $data ) > 1) {
// 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. "
"; }
if ($FileLocationExtension == "resourcerelationship.txt" || $FileLocationExtension == "resourcerelationship.csv") {
#fopen("aslkdhf==||".implode($data,"@")." - '", "r" );
Yii::info($resourceRelationshipID);
Yii::info($relatedResourceID);
Yii::info($data);
/*
$relationshipFull = "";
if (isset ( $data [$resourceRelationshipID] ))
$relationshipFull = "&" . $data [$resourceRelationshipID];
if (! isset ( $relationshipFull ))
$relationshipFull = "&" . $data [$relatedResourceID];
*/
$relationshipFull = "&";
if (isset ( $data [$resourceRelationshipID] ))
$relationshipFull .= $data [$resourceRelationshipID] . "&" ;
if (isset ( $data [$relatedResourceID] ))
$relationshipFull .= $data [$relatedResourceID] . "&";
if (isset ( $relationshipFull )) {
#fopen("aslkdhf==||".$relationshipFull." - '", "r" );
#$instcode = "123";
$instcode = "";
$collcode = "";
$guidcode = "";
if (strpos($relationshipFull, "&institutionCode=") !== false) {
$instcode = explode ( "&", explode ( "&institutionCode=", $relationshipFull ) [1] ) [0];
}
if (strpos($relationshipFull, "&collectionCode=") !== false) {
$collcode = explode ( "&", explode ( "&collectionCode=", $relationshipFull ) [1] ) [0];
}
if (strpos($relationshipFull, "&guid=") !== false) {
$guidcode = explode ( "&", explode ( "&guid=", $relationshipFull ) [1] ) [0];
}
// $collcode = explode ( "&", explode ( "&collectionCode=", $relationshipFull ) [1] ) [0];
// $guidcode = explode ( "&", explode ( "&guid=", $relationshipFull ) [1] ) [0];
# Problem: There's no catalognumber in relationshipfull.
# Question: Is this possible?
# Answer 1: If yes, then catch this case here.
# Answer 2: If no, the catalognumber doesn't seem to be added in the code above. Need to find its cause above.
Yii::info($relationshipFull);
if(strpos($relationshipFull, '&catalogNumber=') !== false) {
// explodable
$catcode = explode ( "&", explode ( "&catalogNumber=", $relationshipFull ) [1] ) [0];
$relation .= "Relation to " . $catcode . " ($collcode, $instcode)";
if($guidcode != "") {
if (strpos($guidcode, "http") !== false && strpos($guidcode, "http") == 0) {
$relation .= " [" . $guidcode . "]";
}
else {
$relation .= " [GUID: " . $guidcode . "]";
}
}
} else {
// not explodable
if($guidcode != "") {
if (strpos($guidcode, "http") == 0) {
$relation .= "Relation to " . $guidcode . " ($collcode, $instcode)";
}
else {
$relation .= "Relation to GUID:" . $guidcode . " ($collcode, $instcode)";
}
}
}
$relation .= " :
";
if (isset ( $data [$relationshipOfResource] ))
$relation .= $data [$relationshipOfResource];
}
}
if ($FileLocationExtension == "preparation.txt" || $FileLocationExtension == "preparation.csv") {
if ((isset ( $data [$preparationMaterials] ) && (strcasecmp ( $data [$preparationMaterials], "" ) != 0)) || (isset ( $data [$preparationDate] ) && (strcasecmp ( $data [$preparationDate], "" ) != 0)) || (isset ( $data [$preparedBy] ) && (strcasecmp ( $data [$preparedBy], "" ) != 0)) || (isset ( $data [$preparationType] ) && (strcasecmp ( $data [$preparationType], "" ) != 0))) {
if ($sampleType == "DNA")
$label = "Extraction";
else
$label = "Preparation";
$preparation .= "" . $label . "
";
$preparation .= isset ( $data [$preparationDate] ) && (strcasecmp ( $data [$preparationDate], "" ) != 0) ? "" . $label . " Date: " . $data [$preparationDate] . "
" : "";
$preparation .= isset ( $data [$preparationMaterials] ) && (strcasecmp ( $data [$preparationMaterials], "" ) != 0) ? "" . $label . " Method: " . $data [$preparationMaterials] . "
" : "";
$preparation .= isset ( $data [$preparedBy] ) && (strcasecmp ( $data [$preparedBy], "" ) != 0) ? "" . $label . " Staff: " . $data [$preparedBy] . "
" : "";
$preparation .= isset ( $data [$preparationType] ) && (strcasecmp ( $data [$preparationType], "" ) != 0) ? "" . $label . " Type: " . $data [$preparationType] . "
" : "";
$preparationType = $data [$preparationType];
} else {
$preparation = NULL;
if (isset ( $data [$preparationType] ))
$material .= "
Preparation Type: " . $data [$preparationType] . "";
}
}
if ($FileLocationExtension == "materialsample2.txt" || $FileLocationExtension == "materialsample.txt" || $FileLocationExtension == "materialsample.csv") {
if ((isset ( $data [$concentration] ) && (strcasecmp ( $data [$concentration], "" ) != 0)) || (isset ( $data [$ratioOfAbsorbance260_230] ) && (strcasecmp ( $data [$ratioOfAbsorbance260_280], "" ) != 0))) {
$sample .= "Quality
";
$sample .= isset ( $data [$concentration] ) && (strcasecmp ( $data [$concentration], "" ) != 0) ? "Concentration: " . $data [$concentration] . " " . $data [$concentrationUnit] . "
" : "";
$sample .= isset ( $data [$ratioOfAbsorbance260_230] ) && (strcasecmp ( $data [$ratioOfAbsorbance260_230], "" ) != 0) ? "Ratio of Absorbance:" . $data [$ratioOfAbsorbance260_230] . "
" : "";
$sample .= isset ( $data [$ratioOfAbsorbance260_280] ) && (strcasecmp ( $data [$ratioOfAbsorbance260_280], "" ) != 0) ? "Ratio of Absorbance:" . $data [$ratioOfAbsorbance260_280] . "
" : "";
$sample .= isset ( $data [$qualityCheckDate] ) && (strcasecmp ( $data [$qualityCheckDate], "" ) != 0) ? "Quality Check Date: " . $data [$qualityCheckDate] . "
" : "";
} else
$sample = NULL;
if (isset ( $data [$materialSampleType] ))
$material .= "
Sample Type / Kind of Unit: " . $data [$materialSampleType] . "
";
}
if ($FileLocationExtension == "preservation.txt" || $FileLocationExtension == "preservation.csv") {
if ((isset ( $data [$preservationType] ) && (strcasecmp ( $data [$preservationType], "" ) != 0)) || (isset ( $data [$preservationDateBegin] ) && (strcasecmp ( $data [$preservationDateBegin], "" ) != 0))) {
$preservation .= "Sample Preservation(s)
";
$preservation .= isset ( $data [$preservationType] ) && (strcasecmp ( $data [$preservationType], "" ) != 0) ? "Preservation:" . $data [$preservationType] . "
" : "";
$preservation .= isset ( $data [$preservationDateBegin] ) && (strcasecmp ( $data [$preservationDateBegin], "" ) != 0) ? "since:" . $data [$preservationDateBegin] . "
" : "";
} else
$preservation = NULL;
}
if ($FileLocationExtension == "gelimage.txt" || $FileLocationExtension == "gelimage.csv") {
if (isset ( $data [$identifier] ) ) {
if ($sampleType == "DNA")
$label = "Gel image";
$gelimage .= "" . $label . "
";
$gelimage .= "
";
$gelimage .= isset ( $data [$identifier] ) ? " " : "";
$gelimage .= " | ";
$gelimage .= isset ( $data [$DNAThreshold] ) ? "DNA Threshold:" . $data [$DNAThreshold] . " " : "";
$gelimage .= isset ( $data [$percentAboveThreshold] ) ? "Percent Above Threshold:" . $data [$percentAboveThreshold] . " " : "";
$gelimage .= isset ( $data [$gelBuffer] ) ? "Gel Buffer:" . $data [$gelBuffer] . " " : "";
$gelimage .= isset ( $data [$gelConcentration] ) ? "Gel Concentration:" . $data [$gelConcentration] . " " : "";
$gelimage .= isset ( $data [$gelLadder] ) ? "Gel Ladder:" . $data [$gelLadder] . " " : "";
$gelimage .= isset ( $data [$gelStain] ) ? "Gel Stain:" . $data [$gelStain] . " " : "";
$gelimage .= isset ( $data [$gelStainConcentration] ) ? "Gel Stain Concentration:" . $data [$gelStainConcentration] . " " : "";
$gelimage .= isset ( $data [$stainingMethod] ) ? "Staining Method:" . $data [$stainingMethod] . " " : "";
$gelimage .= isset ( $data [$gelRemarks] ) ? "Gel Remarks:" . $data [$gelRemarks] . " " : "";
$gelimage .= " |
";
} else {
$gelimage = NULL;
}
}
if ($FileLocationExtension == "permit.txt" || $FileLocationExtension == "permit.csv") {
if (isset ( $data [$permitType] ) ) {
$permit .= "Permit(s)
";
$permit .= isset ( $data [$permitType] ) ? "Permit Type:" . $data [$permitType] . "
" : "";
$permit .= isset ( $data [$permitStatus] ) ? "Permit Status:" . $data [$permitStatus] . "
" : "";
$permit .= isset ( $data [$permitStatusQualifier] ) ? "Permit Status Remarks:" . $data [$permitStatusQualifier] . "
" : "";
$permit .= isset ( $data [$permitText] ) ? "Permit Remarks:" . $data [$permitText] . "
" : "";
} else {
$permit = NULL;
}
}
if ($FileLocationExtension == "amplification.txt" || $FileLocationExtension == "amplification.csv") {
if ((isset ( $data [$marker] ) && (strcasecmp ( $data [$marker], "" ) != 0)) || (isset ( $data [$geneticAccessionNumber] ) && (strcasecmp ( $data [$geneticAccessionNumber], "" ) != 0))) {
$sequences = "Amplifications(s)
";
$sequences .= isset ( $data [$amplificationDate] ) && (strcasecmp ( $data [$amplificationDate], "" ) != 0) ? "Amplification date: " . $data [$amplificationDate] . "
" : "";
$sequences .= isset ( $data [$marker] ) && (strcasecmp ( $data [$marker], "" ) != 0) ? "Marker: " . $data [$marker] . "
" : "";
$sequences .= isset ( $data [$geneticAccessionNumber] ) && (strcasecmp ( $data [$geneticAccessionNumber], "" ) != 0) ? "Genetic Accession Number: ". $data [$geneticAccessionNumber]. "
" : "";
$sequences .= isset ( $data [$BOLDProcessID] ) && (strcasecmp ( $data [$BOLDProcessID], "" ) != 0) ? "BOLD Process ID: ". $data [$BOLDProcessID] . "
" : "";
} else
$sequences = NULL;
}
$multimedia = "";
if ($FileLocationExtension == "multimedia.txt" || $FileLocationExtension == "multimedia.csv") {
if ((isset ( $data [$accessURI] ) && (strcasecmp ( $data [$accessURI], "" ) != 0))) {
$murl = $data [$accessURI];
if ($murl != "N/A") {
if (strpos ( $multimedia, $murl ) === FALSE) {
if (strpos ( $murl, "http" ) === FALSE) {
$murl = "http://" . $murl;
}
$multimedia = $multimedia . " ";
}
}
} else {
if ((isset ( $data [$identifier] ) && (strcasecmp ( $data [$identifier], "" ) != 0))) {
$murl = $data [$identifier];
if ($murl != "N/A") {
if (strpos ( $multimedia, $murl ) === FALSE) {
if (strpos ( $murl, "http" ) === FALSE) {
$murl = "http://" . $murl;
}
$multimedia = $multimedia . " ";
}
}
}
}
}
if ($FileLocationExtension == "identification.txt" || $FileLocationExtension == "identification.csv") {
// foreach ($data as $k=>$v)
// echo "k and v: ".$k." -- ".$v."
";
if (! empty ( $identification ) && stripos ( $identification, "supplemental information" ) == 0)
$identification .= "Other identification / supplemental information
";
if (isset ( $data [$scientificName] ) && ! empty ( $data [$scientificName] ))
$identification .= "Name: " . $data [$scientificName] . "
";
if (! $taxonomySet)
if ((isset ( $data [$family] ) && ! empty ( $data [$family] )) || (isset ( $data [$order] ) && ! empty ( $data [$order] )) || (isset ( $data [$class] ) && ! empty ( $data [$class] )) || (isset ( $data [$phylum] ) && ! empty ( $data [$phylum] )) || (isset ( $data [$kingdom] ) && ! empty ( $data [$kingdom] ))) {
$identification .= "Taxonomy: ";
if (isset ( $data [$family] ) && ! empty ( $data [$family] ))
$identification .= "" . $data [$family] . " (family); ";
if (isset ( $data [$order] ) && ! empty ( $data [$order] ))
$identification .= "" . $data [$order] . " (order); ";
if (isset ( $data [$class] ) && ! empty ( $data [$class] ))
$identification .= "" . $data [$class] . " (class); ";
if (isset ( $data [$phylum] ) && ! empty ( $data [$phylum] ))
$identification .= "" . $data [$phylum] . " (phylum); ";
if (isset ( $data [$kingdom] ) && ! empty ( $data [$kingdom] ))
$identification .= "" . $data [$kingdom] . " (kingdom); ";
$identification .= "
";
}
if ((isset ( $data [$identifiedBy] ) && (strcasecmp ( $data [$identifiedBy], "" ) != 0)) || (isset ( $data [$identificationReferences] ) && (strcasecmp ( $data [$identificationReferences], "" ) != 0)) || (isset ( $data [$identificationRemarks] ) && (strcasecmp ( $data [$identificationRemarks], "" ) != 0))) {
// $identification .= "Identification details
";
if (isset ( $data [$identifiedBy] ) && (strcasecmp ( $data [$identifiedBy], "" ) != 0)) {
$identification .= "Identified by: " . $data [$identifiedBy] . "
";
}
if (isset ( $data [$dateIdentified] ) && (strcasecmp ( $data [$dateIdentified], "" ) != 0)) {
$identification .= "Identified (date): " . $data [$dateIdentified] . "
";
}
if (isset ( $data [$identificationReferences] ) && (strcasecmp ( $data [$identificationReferences], "" ) != 0)) {
$identification .= "References: " . $data [$identificationReferences] . "
";
}
if (isset ( $data [$identificationRemarks] ) && (strcasecmp ( $data [$identificationRemarks], "" ) != 0)) {
$identification .= "Remarks: " . $data [$identificationRemarks] . "
";
}
if (isset ( $data [$typeStatus] ) && (strcasecmp ( $data [$typeStatus], "" ) != 0)) {
$identification .= "Type Status: " . $data [$typeStatus] . "
";
}
}
$identification .= "
";
}
} }
fclose ( $handle );
}
}
// $output = $relation . $preparation . $sample . $preservation . $sequences;
// $dna = "";
$dataset = "";
if (! empty ( $orga ) || ! empty ( $irT ) || ! empty ( $addressT ) || ! empty ( $addressMP ) || ! empty ( $taxocoveragexml ) || ! empty ( $geocoveragexml )) {
$dataset .= "
";
if (! empty ( $orga ))
$dataset .= $orga . "
";
if (! empty ( $abstract ))
$dataset .= "Description: " . $abstract . "
";
if (! empty ( $addressT ))
$dataset .= "Creator of dataset: " . implode ( ", ", $addressT ) . "
";
if (! empty ( $addressMP ))
$dataset .= "Metadata Provider: " . implode ( ", ", $addressMP ) . "
";
if (! empty ( $irT ))
$dataset .= "Rights: " . implode ( " ", $irT ) . "
";
if (! empty ( $taxocoveragexml ))
$dataset .= "Taxonomic coverage: " . $taxocoveragexml . "
";
if (! empty ( $geocoveragexml ))
$dataset .= "Geographic coverage: " . $geocoveragexml . "
";
$dataset .= "
";
}
if ($sampleType == "DNA") {
$dna = "
";
$dna .= $output;
$dna .= $relation . "
";
$dna .= $preparation . "
";
$dna .= $preservation . "
";
$dna .= $gelimage . "
";
$dna .= $sample . "
";
$dna .= $permit . "
";
if (! empty ( $dataset ))
$dna .= $dataset;
$dna .= "
";
if ($preparationType != "" && ! stripos ( " " . $preparationType, "dna" ))
$dna = NULL;
echo ""; }
else $dna = null;
if ($sampleType == "specimen" or $sampleType == "unknown") {
// $specimen = "
";
$specimen = "
";
$specimen .= $output;
$specimen .= $relation;
if ($sampleType == "specimen" or $sampleType == "unknown") {
$specimen .= $material;
$specimen .= $preparation . "
";
$specimen .= $prepSex;
$specimen .= $preservation . "
";
} else
$specimen .= $prepSex;
$specimen .= $permit . "
";
if (! empty ( $dataset ))
$specimen .= $dataset;
$specimen .= "
"; }
else $specimen = null;
$header = "
";
$header .= $output;
$header .= "
";
if ($sampleType == "culture") {
$culture = "
";
$culture .= $output;
$culture .= $relation;
if ($sampleType == "culture") {
$culture .= $material;
$culture .= $preparation . "
";
$culture .= $prepSex;
$culture .= $preservation . "
";
} else
$culture .= $prepSex;
$culture .= $permit . "
";
if (! empty ( $dataset ))
$culture .= $dataset;
$culture .= "
"; }
else $culture = null;
if ($sampleType == "environmental sample") {
$enviro = "
";
$enviro .= $output;
$enviro .= $relation;
$enviro .= $material;
$enviro .= $preparation . "
";
$enviro .= $prepSex;
$enviro .= $preservation . "
";
$enviro .= $permit . "
";
if (! empty ( $dataset ))
$enviro .= $dataset;
$enviro .= "
";
}
else {
$enviro = null;
$taxonlist = null;
}
//$culture = "";
//$enviro = $specimen;
// $tissue = "
";
if ($sampleType == "tissue") {
$tissue = "
";
$tissue .= $output;
$tissue .= $material;
$tissue .= $relation;
$tissue .= $preparation . "
";
$tissue .= $preservation . "
";
$tissue .= $permit . "
";
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,
"gelimage" => $gelimage,
"permit" => $permit,
"specimen" => $specimen,
"tissue" => $tissue,
"header" => $header,
"locality" => $identification . $gathering,
"culture" => $culture,
"enviro" => $enviro,
"taxonlist" => $taxonlist,
"latitude" => $latitude, //for mapview
"longitude" => $longitude, //for mapview
"identification" => $identification,
"gathering" => $gathering,
"multimedia" => $multimedia,
"dataset" => $dataset
];
return $out;
}
}
?>