Skip to content

Commit

Permalink
Merge pull request #48 from bryo-lichen/master
Browse files Browse the repository at this point in the history
Merging Symbiota-light developments into Bryo-lichen code repository
  • Loading branch information
egbot authored Mar 12, 2021
2 parents d9cd8c7 + bea7e64 commit cb32316
Show file tree
Hide file tree
Showing 19 changed files with 165 additions and 94 deletions.
36 changes: 18 additions & 18 deletions checklists/dynamicmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,32 @@
$tid = array_key_exists('tid',$_REQUEST)?$_REQUEST['tid']:0;
$taxa = array_key_exists('taxa',$_REQUEST)?$_REQUEST['taxa']:'';
$interface = array_key_exists('interface',$_REQUEST)&&$_REQUEST['interface']?$_REQUEST['interface']:'checklist';
$latCen = array_key_exists('lat',$_REQUEST)?$_REQUEST['lat']:'';
$longCen = array_key_exists('long',$_REQUEST)?$_REQUEST['long']:'';
$zoomInt = array_key_exists('zoom',$_REQUEST)?$_REQUEST['zoom']:'';

//Sanitation
if(!is_numeric($tid)) $tid = 0;
$taxa = filter_var($taxa,FILTER_SANITIZE_STRING);
if($interface && $interface != 'key') $interface = 'checklist';

//$dynClManager = new DynamicChecklistManager();

$latCen = 41.0;
$longCen = -95.0;
$coorArr = explode(";",$MAPPING_BOUNDARIES);
if($coorArr && count($coorArr) == 4){
$latCen = ($coorArr[0] + $coorArr[2])/2;
$longCen = ($coorArr[1] + $coorArr[3])/2;
}
$coordRange = 50;
if($coorArr && count($coorArr) == 4) $coordRange = ($coorArr[0] - $coorArr[2]);
$zoomInt = 5;
if($coordRange < 20){
$zoomInt = 6;
}
elseif($coordRange > 35 && $coordRange < 40){
$zoomInt = 4;
if(!$latCen || !$longCen){
$latCen = 41.0;
$longCen = -95.0;
$coorArr = explode(";",$MAPPING_BOUNDARIES);
if($coorArr && count($coorArr) == 4){
$latCen = ($coorArr[0] + $coorArr[2])/2;
$longCen = ($coorArr[1] + $coorArr[3])/2;
}
}
elseif($coordRange > 40){
$zoomInt = 3;
if(!$zoomInt){
$zoomInt = 5;
$coordRange = 50;
if($coorArr && count($coorArr) == 4) $coordRange = ($coorArr[0] - $coorArr[2]);
if($coordRange < 20) $zoomInt = 6;
elseif($coordRange > 35 && $coordRange < 40) $zoomInt = 4;
elseif($coordRange > 40) $zoomInt = 3;
}
?>
<html>
Expand Down
64 changes: 30 additions & 34 deletions checklists/index.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php
include_once('../config/symbini.php');
include_once($SERVER_ROOT.'/classes/ChecklistManager.php');
include_once($SERVER_ROOT.'/content/lang/checklists/index.'.$LANG_TAG.'.php');
header("Content-Type: text/html; charset=".$CHARSET);

$pid = array_key_exists("pid",$_REQUEST)?$_REQUEST["pid"]:0;
$pid = array_key_exists('pid',$_REQUEST)?$_REQUEST['pid']:0;

$clManager = new ChecklistManager();
$clManager->setProj($pid);
Expand All @@ -21,57 +22,52 @@
echo '<link href="'.$CLIENT_ROOT.'/css/base.css?ver=1" type="text/css" rel="stylesheet" />';
echo '<link href="'.$CLIENT_ROOT.'/css/main.css?ver=1" type="text/css" rel="stylesheet" />';
}
include_once($SERVER_ROOT.'/includes/googleanalytics.php');
?>
<script type="text/javascript">
<?php include_once($SERVER_ROOT.'/includes/googleanalytics.php'); ?>
</script>
</head>
<body>
<?php
$displayLeftMenu = (isset($checklists_indexMenu)?$checklists_indexMenu:"true");
include($SERVER_ROOT."/includes/header.php");
echo "<div class='navpath'>";
echo "<a href='../index.php'>Home</a> &gt;&gt; ";
if(isset($checklists_indexCrumbs) && $checklists_indexCrumbs) echo $checklists_indexCrumbs.' &gt;&gt;';
echo " <b>Species Checklists</b>";
echo "</div>";
$displayLeftMenu = (isset($checklists_indexMenu)?$checklists_indexMenu:'true');
include($SERVER_ROOT.'/includes/header.php');
?>
<!-- This is inner text! -->
<div class="navpath">
<a href="../index.php"><?php echo (isset($LANG['NAV_HOME'])?$LANG['NAV_HOME']:'Home'); ?></a> &gt;&gt;
<b><?php echo (isset($LANG['SPECIES_INVENTORIES'])?$LANG['SPECIES_INVENTORIES']:'Species Inventories'); ?></b>
</div>
<div id="innertext">
<h1>Species Checklists</h1>
<div style='margin:20px;'>
<h1><?php echo (isset($LANG['SPECIES_INVENTORIES'])?$LANG['SPECIES_INVENTORIES']:'Species Inventories'); ?></h1>
<div style="margin:20px;">
<?php
$researchArr = $clManager->getChecklists();
if($researchArr){
foreach($researchArr as $pid => $projArr){
?>
<div style='margin:3px 0px 0px 15px;'>
<h3><?php echo $projArr['name']; ?>
<a href="<?php echo "clgmap.php?pid=".$pid; ?>" title='Show checklists on map'>
<img src='../images/world.png' style='width:10px;border:0' />
</a>
</h3>
<div>
<ul>
<?php
foreach($projArr['clid'] as $clid => $clName){
echo "<li><a href='checklist.php?clid=".$clid."&pid=".$pid."'>".$clName."</a></li>\n";
}
?>
</ul>
</div>
</div>
<h3>
<?php
$projName = $projArr['name'];
if($projName == 'Miscellaneous Inventories') $projName = (isset($LANG['MISC_INVENTORIES'])?$LANG['MISC_INVENTORIES']:'Miscellaneous Inventories');
echo $projName;
?>
<a href="<?php echo "clgmap.php?pid=".$pid; ?>" title='<?php echo (isset($LANG['SHOW_MAP'])?$LANG['SHOW_MAP']:'Show inventories on map'); ?>'>
<img src='../images/world.png' style='width:10px;border:0' />
</a>
</h3>
<ul>
<?php
foreach($projArr['clid'] as $clid => $clName){
echo '<li><a href="checklist.php?clid='.$clid.'&pid='.$pid.'">'.$clName.'</a></li>';
}
?>
</ul>
<?php
}
}
else{
echo '<div><b>No Checklists returned</b></div>';
}
else echo '<div><b>'.(isset($LANG['NO_INVENTORIES'])?$LANG['NO_INVENTORIES']:'No inventories returned').'</b></div>';
?>
</div>
</div>
<?php
include($SERVER_ROOT."/includes/footer.php");
include($SERVER_ROOT.'/includes/footer.php');
?>
</body>
</html>
3 changes: 2 additions & 1 deletion classes/DwcArchiverCore.php
Original file line number Diff line number Diff line change
Expand Up @@ -1662,7 +1662,8 @@ private function writeOccurrenceFile(){
elseif($this->schemaType == 'backup') unset($r['collid']);

if($ocnStr = $dwcOccurManager->getAdditionalCatalogNumberStr($r['occid'])) $r['otherCatalogNumbers'] = $ocnStr;
if($assocStr = $dwcOccurManager->getAssociationStr($r['occid'])) $r['t_associatedOccurrences'] = $assocStr;
if($assocOccurStr = $dwcOccurManager->getAssociationStr($r['occid'])) $r['t_associatedOccurrences'] = $assocOccurStr;
if($assocTaxa = $dwcOccurManager->getAssocTaxa($r['occid'])) $r['associatedTaxa'] = $assocTaxa;
//$dwcOccurManager->appendUpperTaxonomy($r);
$dwcOccurManager->appendUpperTaxonomy2($r);
if($rankStr = $dwcOccurManager->getTaxonRank($r['rankid'])) $r['t_taxonRank'] = $rankStr;
Expand Down
15 changes: 15 additions & 0 deletions classes/DwcArchiverOccurrence.php
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,21 @@ public function getAssociationStr($occid){
return trim($retStr,' |');
}

public function getAssocTaxa($occid){
$retStr = '';
if($occid){
$sql = 'SELECT assocID, relationship, subType, verbatimSciname FROM omoccurassociations WHERE occid = '.$occid.' AND verbatimSciname IS NOT NULL ';
$rs = $this->conn->query($sql);
if($rs){
while($r = $rs->fetch_object()){
$retStr .= '|'.$r->relationship.($r->subType?' ('.$r->subType.')':'').': '.$r->verbatimSciname;
}
$rs->free();
}
}
return trim($retStr,' |');
}

private function getInverseRelationship($relationship){
if(!$this->relationshipArr) $this->setRelationshipArr();
if(array_key_exists($relationship, $this->relationshipArr)) return $this->relationshipArr[$relationship];
Expand Down
19 changes: 14 additions & 5 deletions classes/ImageCleaner.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,12 @@ public function buildThumbnailImages(){

private function setCollectionCode(){
if($this->collid && !$this->collMetaArr){
$sql = 'SELECT collid, CONCAT_WS("_",institutioncode, collectioncode) AS code, collectionname FROM omcollections WHERE collid = '.$this->collid;
$sql = 'SELECT collid, CONCAT_WS("_",institutioncode, collectioncode) AS code, collectionname, managementType FROM omcollections WHERE collid = '.$this->collid;
$rs = $this->conn->query($sql);
while($r = $rs->fetch_object()){
$this->collMetaArr[$r->collid]['code'] = $r->code;
$this->collMetaArr[$r->collid]['name'] = $r->collectionname;
$this->collMetaArr[$r->collid]['managementType'] = $r->managementType;
}
$rs->free();
}
Expand Down Expand Up @@ -278,9 +279,8 @@ private function getTropicosWebUrl2($url){
$imageID = $m[1];
$imgDisplayUrl = 'http://www.tropicos.org/Image/'.$imageID;
$ip = $_SERVER['HTTP_HOST'];

$header[0] = "Accept: text/xml,application/xml,application/xhtml+xml,";
$header[0] .= "text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
$header = array();
$header[] = "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
$header[] = "Cache-Control: max-age=0";
$header[] = "Connection: keep-alive";
$header[] = "Keep-Alive: 300";
Expand Down Expand Up @@ -520,7 +520,7 @@ public function recycleImagesFromFile($filePath){
$this->setRecycleBin();
if(!$filePath) exit('Image identifier file path IS NULL');
if(!file_exists($filePath)) exit('Image identifier file Not Found');
if(($imgidHandler = fopen($imgidFile, 'r')) !== FALSE){
if(($imgidHandler = fopen($filePath, 'r')) !== FALSE){
while(($data = fgets($imgidHandler)) !== FALSE){
$this->recycleImage($data[0]);
}
Expand Down Expand Up @@ -660,6 +660,15 @@ public function getCollectionName(){
return $retStr;
}

public function getManagementType(){
$retStr = '';
if($this->collid){
if(!$this->collMetaArr) $this->setCollectionCode();
$retStr = $this->collMetaArr[$this->collid]['managementType'];
}
return $retStr;
}

public function setBuildMediumDerivative($bool){
if($bool) $this->buildMediumDerivative = true;
else $this->buildMediumDerivative = false;
Expand Down
11 changes: 7 additions & 4 deletions classes/ImageShared.php
Original file line number Diff line number Diff line change
Expand Up @@ -401,14 +401,13 @@ public function processImage(){
if(!$this->imgWebUrl && $this->createWebDerivative){
if($this->sourceWidth < ($this->webPixWidth*1.2) && $this->sourceFileSize < $this->webFileSizeLimit){
//Source image width and file size is small enough to serve as web image
if(strtolower(substr($this->sourcePath,0,7)) == 'http://' || strtolower(substr($this->sourcePath,0,8)) == 'https://'){
if(strtolower(substr($this->sourcePath,0,4)) == 'http'){
if(copy($this->sourcePath, $this->targetPath.$this->imgName.$this->imgExt, $this->context)){
$this->imgWebUrl = $this->imgName.$this->imgExt;
}
}
else{
$this->imgWebUrl = $this->imgName.$this->imgExt;
}
elseif($this->imgLgUrl) $this->imgWebUrl = $this->imgLgUrl;
else $this->imgWebUrl = basename($this->sourcePath);
}
else{
//Image width or file size is too large
Expand Down Expand Up @@ -910,6 +909,10 @@ public function setSourceUrl($v){
$this->sourceUrl = $this->cleanInStr($v);
}

public function setImgLgUrl($v){
$this->imgLgUrl = $this->cleanInStr($v);
}

public function setImgWebUrl($v){
$this->imgWebUrl = $this->cleanInStr($v);
}
Expand Down
5 changes: 2 additions & 3 deletions classes/OccurrenceEditorImages.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,11 @@ public function addImage($postArr){
if(array_key_exists('copytoserver',$postArr) && $postArr['copytoserver']){
if(!$imgManager->copyImageFromUrl()) $status = false;
}
else $imgManager->setImgLgUrl($sourceImgUri);
}
else{
//Image is a file upload
if(!$imgManager->uploadImage()){
$status = false;
}
if(!$imgManager->uploadImage()) $status = false;
}
$imgManager->setOccid($this->occid);
if(isset($this->occurrenceMap[$this->occid]['tidinterpreted'])) $imgManager->setTid($this->occurrenceMap[$this->occid]['tidinterpreted']);
Expand Down
14 changes: 10 additions & 4 deletions classes/OccurrenceSesar.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function getSesarProfile(){
}

private function setDynamicPropertiesArr(){
if($this->dynPropArr === false){
if($this->dynPropArr === false && $this->collid){
$this->dynPropArr = array();
$sql = 'SELECT dynamicProperties FROM omcollections WHERE collid = '.$this->collid;
$rs = $this->conn->query($sql);
Expand Down Expand Up @@ -619,6 +619,10 @@ private function setMissingSesarMeta(&$sesarResultArr){
$catNum = $m[1];
$occid = $m[2];
$sesarResultArr['missing'][$lostIGSN] = array('catNum'=>$catNum,'occid'=>$occid);
$sql1 = 'UPDATE igsnverification SET occid = '.$occid.' WHERE igsn = "'.$lostIGSN.'"';
$this->conn->query($sql1);
$sql2 = 'UPDATE igsnverification SET catalogNumber = "'.$catNum.'" WHERE igsn = "'.$lostIGSN.'"';
$this->conn->query($sql2);
}
}
$cnt++;
Expand All @@ -644,17 +648,19 @@ public function syncIGSN($occid,$catalogNumber,$igsn){
$ok = true;
$retArr = array('status'=>0);
if(is_numeric($occid) && preg_match('/^[A-Z0-9]+$/', $igsn)){
$sql = 'SELECT catalogNumber, occurrenceID FROM omoccurrences WHERE occid = '.$occid;
$sql = 'SELECT catalogNumber, otherCatalogNumbers, occurrenceID FROM omoccurrences WHERE occid = '.$occid;
$rs = $this->conn->query($sql);
if($r = $rs->fetch_object()){
if($r->occurrenceID){
$retArr['errCode'] = 1;
$retArr['guid'] = $r->occurrenceID;
$ok = false;
}
elseif($r->catalogNumber != $catalogNumber){
elseif($r->catalogNumber != $catalogNumber && $r->otherCatalogNumbers != $catalogNumber){
$retArr['errCode'] = 2;
$retArr['catNum'] = $r->catalogNumber;
$catNum = $r->catalogNumber;
if($r->otherCatalogNumbers) $catNum .= ', '.$r->otherCatalogNumbers;
$retArr['catNum'] = trim($catNum,', ');
$ok = false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion collections/admin/igsnmanagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ function verifyProfileForm(f){
if($missingCnt){
echo '<div id="missingGuidList" style="margin-left:40px;display:none">';
foreach($sesarArr['missing'] as $igsn => $missingArr){
echo '<li><a href="https://sesardev.geosamples.org/sample/igsn/'.$igsn.'" target="_blank" title="Open IGSN in SESAR Systems">'.$igsn.'</a> ';
echo '<li><a href="https://app.geosamples.org/sample/igsn/'.$igsn.'" target="_blank" title="Open IGSN in SESAR Systems">'.$igsn.'</a> ';
if(isset($missingArr['occid'])){
echo '=> <a href="../editor/occurrenceeditor.php?occid='.$missingArr['occid'].'" target="_blank" title="Open occurrence in editor">'.$missingArr['catNum'].'</a> ';
echo '<a href="#" onclick="syncIGSN('.$missingArr['occid'].',\''.$missingArr['catNum'].'\',\''.$igsn.'\');return false" title="Add IGSN to target occurrence"><img src="../../images/link.png" style="width:13px"/></a>';
Expand Down
9 changes: 7 additions & 2 deletions collections/individual/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -865,8 +865,13 @@ function initializeMap(){
<?php
foreach($iArr as $imgId => $imgArr){
$thumbUrl = $imgArr['tnurl'];
if(!$thumbUrl || substr($thumbUrl,0,7)=='process') $thumbUrl = $imgArr['url'];
if(!$thumbUrl || substr($thumbUrl,0,7)=='process') $thumbUrl = $imgArr['lgurl'];
if(!$thumbUrl || substr($thumbUrl,0,7)=='process'){
if($image = exif_thumbnail($imgArr['lgurl'])){
$thumbUrl = 'data:image/jpeg;base64,'.base64_encode($image);
}
elseif($imgArr['url'] && substr($imgArr['url'],0,7)!='process') $thumbUrl = $imgArr['url'];
else $thumbUrl = $imgArr['lgurl'];
}
?>
<div class="imgDiv">
<a href='<?php echo $imgArr['url']; ?>' target="_blank">
Expand Down
2 changes: 2 additions & 0 deletions config/schema-1.0/dev/db_schema_patch_pending.sql
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,8 @@ CREATE TABLE `igsnverification` (
INDEX `INDEX_igsn` (`igsn` ASC),
CONSTRAINT `FK_igsn_occid` FOREIGN KEY (`occid`) REFERENCES `omoccurrences` (`occid`) ON DELETE CASCADE ON UPDATE CASCADE);

ALTER TABLE `igsnverification`
ADD COLUMN `catalogNumber` VARCHAR(45) NULL AFTER `occid`;

CREATE TABLE `omoccurloanuser` (
`loanid` INT UNSIGNED NOT NULL,
Expand Down
13 changes: 13 additions & 0 deletions content/lang/checklists/index.en.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
/*
------------------
Language: English
------------------
*/

$LANG['NAV_HOME'] = 'Home';
$LANG['SPECIES_INVENTORIES'] = 'Species Inventories';
$LANG['SHOW_MAP'] = 'Show inventories on map';
$LANG['NO_INVENTORIES'] = 'No inventories returned';
$LANG['MISC_INVENTORIES'] = 'Miscellaneous Inventories';
?>
13 changes: 13 additions & 0 deletions content/lang/checklists/index.es.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
/*
------------------
Language: Español (Spanish)
------------------
*/

$LANG['NAV_HOME'] = 'Inicio';
$LANG['SPECIES_INVENTORIES'] = 'Inventarios de Especies';
$LANG['SHOW_MAP'] = 'Mostrar inventarios en el mapa';
$LANG['NO_INVENTORIES'] = 'Sin inventories';
$LANG['MISC_INVENTORIES'] = 'Inventarios Varios';
?>
3 changes: 2 additions & 1 deletion content/lang/sitemap.en.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
$LANG['GLOSSARY'] = 'Glossary';
$LANG['PROTECTED_SPECIES'] = 'Protected Species';
$LANG['LISTOFTAXA'] = 'list of taxa where locality and/or taxonomic information is protected due to rare/threatened/endangered status';
$LANG['BIOINV'] = 'Biotic Inventory Projects';
$LANG['BIOTIC_INVENTORIES'] = 'Biotic Inventory Projects';
$LANG['ALL_CHECKLISTS'] = 'All Public Checklists';
$LANG['DYNAMIC'] = 'Dynamic Species Lists';
$LANG['CHECKLIST'] = 'Checklist';
$LANG['BUILDCHECK'] = 'dynamically build a checklist using georeferenced specimen records';
Expand Down
Loading

0 comments on commit cb32316

Please sign in to comment.