Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync tyrrell-dev with tyrrell-master (local) #8

Merged
merged 13 commits into from
Aug 14, 2023
6 changes: 1 addition & 5 deletions checklists/checklist.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,14 @@
if($clid) echo 'var clid = '.$clid.';'."\n";
echo 'var taxaCount = '.count($taxaArray).';'."\n";
?>
$( function() {
$( document ).tooltip();
} );

function changeImageSource(elem){
let f = document.optionform;
if(elem.id == "vi_voucher") f.voucherimages.value = "1";
else f.voucherimages.value = "0";
f.submit();
}
</script>
<script type="text/javascript" src="../js/symb/checklists.checklist.js?ver=3"></script>
<script type="text/javascript" src="../js/symb/checklists.checklist.js?ver=4"></script>
<style type="text/css">
<?php
if($printMode){
Expand Down
19 changes: 16 additions & 3 deletions checklists/checklistadminmeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,19 @@ function openMappingPolyAid() {
mapWindow=open("<?php echo $CLIENT_ROOT; ?>/checklists/tools/mappolyaid.php?clid=<?php echo $clid; ?>&formname=editclmatadata&latname=latcentroid&longname=longcentroid&latdef="+latDec+"&lngdef="+lngDec,"mapaid","resizable=0,width=1000,height=800,left=20,top=20");
if(mapWindow.opener == null) mapWindow.opener = self;
}

function enableDisableExtServiceFields() {
let xsrv = document.getElementById('externalservice');
let xsid = document.getElementById('externalserviceid');
let xstaxonfilter = document.getElementById('externalserviceiconictaxon');
if(xsrv.value == '') {
xsid.setAttribute("disabled","");
xstaxonfilter.setAttribute("disabled","");
} else {
xsid.removeAttribute("disabled");
xstaxonfilter.removeAttribute("disabled");
}
}
</script>
<?php
if(!$clid){
Expand Down Expand Up @@ -180,7 +193,7 @@ function openMappingPolyAid() {
</div>
<div>
<b><?php echo (isset($LANG['EXTSERVICE'])?$LANG['EXTSERVICE']:'External Service (e.g., iNaturalist) to associate with this checklist [optional]');?></b><br/>
<select name="externalservice">
<select name="externalservice" id="externalservice" onchange="enableDisableExtServiceFields()">
<option value=""></option>
<option value="">-------------------------------</option>
<option value="inaturalist" <?php echo (($dynamPropsArr['externalservice']=='inaturalist')?'selected':''); ?>>iNaturalist</option>
Expand All @@ -189,10 +202,10 @@ function openMappingPolyAid() {
<div style="width:100%;margin-top:5px">
<div style="float:left;width:25%">
<b><?php echo (isset($LANG['EXTSERVICEID'])?$LANG['EXTSERVICEID']:'Project ID from External Service');?></b><br/>
<input type="text" name="externalserviceid" style="width:100%" value="<?php echo ($dynamPropsArr?$dynamPropsArr['externalserviceid']:''); ?>" />
<input type="text" name="externalserviceid" id="externalserviceid" style="width:100%" value="<?php echo ($dynamPropsArr?$dynamPropsArr['externalserviceid']:''); ?>" />
</div><div style="float:left;margin-left:15px;">
<b><?php echo (isset($LANG['EXTSERVICETAXON'])?$LANG['EXTSERVICETAXON']:'External Service Taxon Filter [optional]');?></b><br/>
<input type="text" name="externalserviceiconictaxon" style="width:100%" value="<?php echo ($dynamPropsArr?$dynamPropsArr['externalserviceiconictaxon']:''); ?>" />
<input type="text" name="externalserviceiconictaxon" id="externalserviceiconictaxon" style="width:100%" value="<?php echo ($dynamPropsArr?$dynamPropsArr['externalserviceiconictaxon']:''); ?>" />
</div>
</div>
<div id="locDiv" style="clear:both;margin-top:5px;">
Expand Down
2 changes: 1 addition & 1 deletion checklists/checklistmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function initialize(){
}
$clMeta = $clManager->getClMetaData();
//Check for and add checklist polygon
$clMeta = $clManager->getClMetaData();

if($clMeta['footprintwkt']){
//Add checklist polygon
$wkt = $clMeta['footprintwkt'];
Expand Down
132 changes: 132 additions & 0 deletions checklists/externalvouchers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
<?php
include_once('../config/symbini.php');
include_once($SERVER_ROOT.'/classes/ChecklistVoucherReport.php');
include_once($SERVER_ROOT.'/classes/ChecklistManager.php');
include_once($SERVER_ROOT.'/content/lang/checklists/voucheradmin.'.$LANG_TAG.'.php');

$clid = array_key_exists('clid', $_REQUEST) ? filter_var($_REQUEST['clid'], FILTER_SANITIZE_NUMBER_INT) : 0;
$pid = array_key_exists('pid', $_REQUEST) ? filter_var($_REQUEST['pid'], FILTER_SANITIZE_NUMBER_INT) : '';
$startPos = (array_key_exists('start', $_REQUEST) ? filter_var($_REQUEST['start'], FILTER_SANITIZE_NUMBER_INT) : 0);
$displayMode = (array_key_exists('displaymode', $_REQUEST) ? filter_var($_REQUEST['displaymode'], FILTER_SANITIZE_NUMBER_INT) : 0);

$clManager = new ChecklistManager();
$clVoucherManager = new ChecklistVoucherReport();
if($clid) {
$clManager->setClid($clid);
$clVoucherManager->setClid($clid);
//$clVoucherManager->setCollectionVariables();
}

$isEditor = 0;
if($IS_ADMIN || (array_key_exists('ClAdmin', $USER_RIGHTS) && in_array($clid, $USER_RIGHTS['ClAdmin']))){
$isEditor = 1;
}
if($isEditor){
$taxaArray = $clManager->getTaxaList();
?>
<div id="externalServiceVoucherDiv">
<div style="margin:10px;">
<div style="clear:both;">
<div style="margin:10px;">
<?php echo $LANG['LISTEDBELOWEXTERNAL'];?>
</div>
<div style="margin:20px;">
<style>
#taxalist-div {
margin-bottom: 10px;
}
label {
display: inline-block;
width: 250px;
text-align: right;
}
</style>
<?php
echo '<div id="taxalist-div">';
$prevGroup = '';
foreach($taxaArray as $tid => $sppArr){
$group = $sppArr['taxongroup'];
if($group != $prevGroup){
$famUrl = '../taxa/index.php?taxauthid=1&taxon='.strip_tags($group).'&clid='.$clid;
//Edit family name display style here
?>
<div class="family-div" id="<?php echo strip_tags($group);?>">
<a href="<?php echo $famUrl; ?>" target="_blank" style="color:black;"><?php echo $group;?></a>
</div>
<?php
$prevGroup = $group;
}
$taxonWithDashes = str_replace(' ', '-', $sppArr['sciname']);
echo '<div class="taxon-container">';
echo '<a href="#" target="_blank" id="a-' . $taxonWithDashes . '" style="pointer-events:none;">';
echo '<label>'.$sppArr['sciname'].' '.$sppArr["author"].'</label></a>&nbsp;';
//class="taxon-span"
?>
<input type="text" name="<?php echo $tid; ?>" id="i-<?php echo $taxonWithDashes; ?>">
<span class="view-specimen-span printoff">
<a href="#" target="_blank" style="text-decoration: none;">
<img src="../images/link.png" style="width:12px;" title="<?php echo (isset($LANG['LINKEXT'])?$LANG['LINKEXT']:'Link external vouchers'); ?>" />
</a>
</span>
<?php
echo "</div>\n";
$scinameasid = str_replace(" ", "-", $sppArr['sciname']);
if($arrforexternalserviceapi == '') {
$arrforexternalserviceapi .= "'" . $scinameasid . "'";
} else {
$arrforexternalserviceapi .= ",'" . $scinameasid . "'";
}
}
echo '</div>';
//if(isset($dynamPropsArr) && $dynamPropsArr['externalservice'] == 'inaturalist') {
echo '<script src="../js/symb/checklists.externalserviceapi.js"></script>';
?>
<script>
<?php
echo 'const checklisttaxa = [' . $arrforexternalserviceapi . '];';
//echo 'const externalProjID = "' . ($dynamPropsArr['externalserviceid']?$dynamPropsArr['externalserviceid']:'') . '";';
echo 'const externalProjID = "biodiversity-of-puerto-rico";'; //DEBUG ONLY!!!!!!!!!!!!!
echo 'const iconictaxon = "' . ($dynamPropsArr['externalserviceiconictaxon']?$dynamPropsArr['externalserviceiconictaxon']:'') . '";';
?>

// iNaturalist Integration
// Note: the two part request (...Page1 vs ...AdditionalPages) is performed
// to allow for a variable number of total results. There will always be a
// first page, but there may be 0 or more additional pages. The answer is
// extracted from the response to the first ("Page1") fetch request.
fetchiNatPage1(externalProjID, iconictaxon)
.then(pageone => {
const totalresults = pageone.total_results;
const perpage = pageone.per_page;
const loopnum = Math.ceil(totalresults / perpage);
const taxalist1 = extractiNatTaxaIdAndName(pageone.results);
fetchiNatAdditionalPages(loopnum, externalProjID, iconictaxon)
.then(pagestwoplus => {
const taxalist2 = pagestwoplus.map(page => extractiNatTaxaIdAndName(page.results))
taxalist = taxalist1.concat(taxalist2.flat());
checklisttaxa.forEach( taxon => {
let anchortag = document.getElementById('a-'+taxon);
let imgtag = document.getElementById('i-'+taxon);
let taxonwithspaces = taxon.replaceAll('-', ' ');
const idx = taxalist.findIndex( elem => elem.name === taxonwithspaces);
if(idx >= 0) {
console.log('yep');
anchortag.setAttribute("style", "pointer-events:auto;");
imgtag.setAttribute("style", "background-color: #f1e740;");
anchortag.setAttribute("href", `https://www.inaturalist.org/observations?project_id=${externalProjID}&taxon_id=${taxalist[idx].id}`);
}
})
})
.catch(error => {
error.message;
})
})
</script>
<?php //} ?>
</div>
</div>
</div>
</div>
<?php
}
?>
4 changes: 2 additions & 2 deletions checklists/rpc/searchsuggest.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php
include_once('../../config/symbini.php');
include_once($SERVER_ROOT.'/classes/ChecklistManager.php');
header("Content-Type: text/html; charset=".$CHARSET);
header('Content-Type: text/html; charset='.$CHARSET);

$clid = $_REQUEST['clid'];
$term = $_REQUEST['term'];
$deep = (isset($_REQUEST['deep'])?$_REQUEST['deep']:0);

$clManager = new ChecklistManager();
$retArr = $clManager->getTaxonSearch($term,$clid,$deep);
$retArr = $clManager->getTaxonSearch($term, $clid, $deep);
echo json_encode($retArr);
?>
3 changes: 2 additions & 1 deletion checklists/voucheradmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@
<li><a href="nonvoucheredtab.php?clid=<?php echo $clid.'&pid='.$pid.'&start='.$startPos.'&displaymode='.$displayMode; ?>"><span><?php echo $LANG['NON_VOUCHERED'];?></span></a></li>
<li><a href="vamissingtaxa.php?clid=<?php echo $clid.'&pid='.$pid.'&start='.$startPos.'&displaymode='.($tabIndex==1?$displayMode:0).'&excludevouchers='.(isset($_POST['excludevouchers'])?$_POST['excludevouchers']:''); ?>"><span><?php echo $LANG['MISSINGTAXA'];?></span></a></li>
<li><a href="vaconflicts.php?clid=<?php echo $clid.'&pid='.$pid.'&start='.$startPos; ?>"><span><?php echo $LANG['VOUCHCONF'];?></span></a></li>
<?php
<?php
if($clManager->getAssociatedExternalService()) echo '<li><a href="externalvouchers.php?clid='.$clid.'&pid='.$pid.'&start='.$startPos.'"><span>' . $LANG['EXTVOUCH'] . '</span></a></li>';
if($clManager->hasVoucherProjects()) echo '<li><a href="imgvouchertab.php?clid='.$clid.'">'.(isset($LANG['ADDIMGV'])?$LANG['ADDIMGV']:'Add Image Voucher').'</a></li>';
?>
<li><a href="#reportDiv"><span><?php echo $LANG['REPORTS'];?></span></a></li>
Expand Down
10 changes: 7 additions & 3 deletions classes/ChecklistManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,11 +330,16 @@ private function setImages(){
if($this->taxaList){
$matchedArr = array();
if($this->limitImagesToVouchers){
$clidStr = $this->clid;
if($this->childClidArr){
$clidStr .= ','.implode(',',array_keys($this->childClidArr));
}
$sql = 'SELECT i.tid, i.url, i.thumbnailurl, i.originalurl
FROM images i INNER JOIN omoccurrences o ON i.occid = o.occid
INNER JOIN fmvouchers v ON o.occid = v.occid
INNER JOIN fmchklsttaxalink cl ON v.clTaxaID = cl.clTaxaID
WHERE (cl.clid = 2) AND (i.tid IN('.implode(',',array_keys($this->taxaList)).'))';
WHERE (cl.clid = '.$clidStr.') AND (i.tid IN('.implode(',',array_keys($this->taxaList)).'))
ORDER BY i.sortOccurrence, i.sortSequence';
$matchedArr = $this->setImageSubset($sql);
}
if($missingArr = array_diff(array_keys($this->taxaList),$matchedArr)){
Expand All @@ -347,7 +352,7 @@ private function setImages(){
$matchedArr = $this->setImageSubset($sql);
if($missingArr = array_diff(array_keys($this->taxaList),$matchedArr)){
//Get children images
$sql = 'SELECT i2.tid, i.url, i.thumbnailurl FROM images i INNER JOIN '.
$sql = 'SELECT DISTINCT i2.tid, i.url, i.thumbnailurl FROM images i INNER JOIN '.
'(SELECT ts1.parenttid AS tid, SUBSTR(MIN(CONCAT(LPAD(i.sortsequence,6,"0"),i.imgid)),7) AS imgid '.
'FROM taxstatus ts1 INNER JOIN taxstatus ts2 ON ts1.tidaccepted = ts2.tidaccepted '.
'INNER JOIN images i ON ts2.tid = i.tid '.
Expand All @@ -362,7 +367,6 @@ private function setImages(){
private function setImageSubset($sql){
$matchTidArr = array();
if($this->taxaList){
//echo $sql;
$rs = $this->conn->query($sql);
while($r = $rs->fetch_object()){
if(!in_array($r->tid,$matchTidArr)){
Expand Down
14 changes: 13 additions & 1 deletion classes/ChecklistVoucherAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function setClid($clid){
private function setMetaData(){
if($this->clid){
$sql = 'SELECT clid, name, locality, publication, abstract, authors, parentclid, notes, latcentroid, longcentroid, pointradiusmeters, '.
'footprintwkt, access, defaultSettings, dynamicsql, datelastmodified, uid, type, initialtimestamp '.
'footprintwkt, access, defaultSettings, dynamicsql, datelastmodified, dynamicProperties, uid, type, initialtimestamp '.
'FROM fmchecklists WHERE (clid = '.$this->clid.')';
$rs = $this->conn->query($sql);
if($rs){
Expand All @@ -66,6 +66,7 @@ private function setMetaData(){
$this->clMetadata["defaultSettings"] = $row->defaultSettings;
$this->clMetadata["dynamicsql"] = $row->dynamicsql;
$this->clMetadata["datelastmodified"] = $row->datelastmodified;
$this->clMetadata['dynamicProperties'] = $row->dynamicProperties;
}
$rs->free();
}
Expand Down Expand Up @@ -108,6 +109,17 @@ public function getPolygonCoordinates(){
return $retArr;
}

public function getAssociatedExternalService(){
$resp = 'FALSE';
if($this->clMetadata['dynamicProperties']){
$dynpropArr = json_decode($this->clMetadata['dynamicProperties'], TRUE);
if(array_key_exists('externalservice', $dynpropArr)) {
$resp = $dynpropArr['externalservice'];
}
}
return $resp;
}

//Dynamic query variable functions
public function setCollectionVariables(){
if($this->clid){
Expand Down
19 changes: 9 additions & 10 deletions classes/DwcArchiverCore.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class DwcArchiverCore extends Manager{
private $includeDets = 1;
private $includeImgs = 1;
private $includeAttributes = 0;
private $includeMaterialSample = 0; // 0 = off, 1 = on, 2 = active (activated within at least one collection)
private $includeMaterialSample = 0;
private $hasPaleo = false;
private $redactLocalities = 1;
private $rareReaderArr = array();
Expand Down Expand Up @@ -191,7 +191,6 @@ public function setCollArr($collTarget, $collType = ''){
if (isset($modArr['paleo']['status'])) $this->hasPaleo = true;
elseif (isset($modArr['matSample']['status'])){
$this->collArr[$r->collid]['matSample'] = 1;
$this->includeMaterialSample = 2;
}
}
}
Expand Down Expand Up @@ -1055,7 +1054,7 @@ private function writeMetaFile(){
}

//MaterialSample extension
if ($this->includeMaterialSample == 2 && isset($this->fieldArrMap['materialSample'])) {
if ($this->includeMaterialSample && isset($this->fieldArrMap['materialSample'])) {
$extElem3 = $newDoc->createElement('extension');
$extElem3->setAttribute('encoding', $this->charSetOut);
$extElem3->setAttribute('fieldsTerminatedBy', $this->delimiter);
Expand Down Expand Up @@ -1765,7 +1764,7 @@ private function writeOccurrenceFile(){

$batchOccidArr[] = $r['occid'];
if (count($batchOccidArr) > 1000) {
if ($this->includeMaterialSample == 2) $this->writeMaterialSampleData($materialSampleHandler, $batchOccidArr);
if ($this->includeMaterialSample) $this->writeMaterialSampleData($materialSampleHandler, $batchOccidArr);
if ($pubID && $portalManager) $portalManager->insertPortalOccurrences($pubID, $batchOccidArr);
unset($batchOccidArr);
$batchOccidArr = array();
Expand All @@ -1782,7 +1781,7 @@ private function writeOccurrenceFile(){
if ($batchOccidArr) {
if ($pubID && $portalManager) $portalManager->insertPortalOccurrences($pubID, $batchOccidArr);
}
if ($this->includeMaterialSample == 2){
if ($this->includeMaterialSample){
$this->writeMaterialSampleData($materialSampleHandler, $batchOccidArr);
$materialSampleHandler->__destruct();
}
Expand All @@ -1801,7 +1800,7 @@ private function writeOccurrenceFile(){
$this->logOrEcho($this->errorMessage);
}
$this->logOrEcho('Done! (' . date('h:i:s A') . ")\n");
if ($this->includeMaterialSample == 2) $this->logOrEcho('Material Sample extension file created (' . date('h:i:s A') . ')... ');
if ($this->includeMaterialSample) $this->logOrEcho('Material Sample extension file created (' . date('h:i:s A') . ')... ');
return $filePath;
}

Expand Down Expand Up @@ -2161,19 +2160,19 @@ public function setDelimiter($d){
}

public function setIncludeDets($includeDets){
$this->includeDets = $includeDets;
if($includeDets) $this->includeDets = true;
}

public function setIncludeImgs($includeImgs){
$this->includeImgs = $includeImgs;
if($includeImgs) $this->includeImgs = true;
}

public function setIncludeAttributes($include){
$this->includeAttributes = $include;
if($include) $this->includeAttributes = true;
}

public function setIncludeMaterialSample($include){
$this->includeMaterialSample = $include;
if($include) $this->includeMaterialSample = true;
}

public function hasAttributes(){
Expand Down
Loading