Skip to content

Commit

Permalink
Merge pull request #5 from BioKIC/master
Browse files Browse the repository at this point in the history
Updates from main core
  • Loading branch information
arbolitoloco committed Sep 27, 2019
2 parents c1550ac + 4fe1ea3 commit a6f072c
Show file tree
Hide file tree
Showing 42 changed files with 968 additions and 822 deletions.
26 changes: 15 additions & 11 deletions checklists/checklist.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,12 @@
#sddm div{position: absolute;visibility:hidden;margin:0;padding:0;background:#EAEBD8;border:1px solid #5970B2}
#sddm div a {position: relative;display:block;margin:0;padding:5px 10px;width:auto;white-space:nowrap;text-align:left;text-decoration:none;background:#EAEBD8;color:#2875DE;font-weight:bold;}
#sddm div a:hover{background:#49A3FF;color:#FFF}

<?php
if($printMode){
?>
body{ background-color:#ffffff; }
#innertext{ background-color:#ffffff; }
#taxaDiv{ line-height: 1em; }
.printoff{ display:none; }
a{ color: currentColor; cursor: none; pointer-events: none; text-decoration: none; }
<?php
Expand Down Expand Up @@ -689,35 +689,37 @@
}
else{
//Display taxa
echo '<div id="taxaDiv">';
echo '<div id="taxalist-div">';
$voucherArr = array();
if($showVouchers) $voucherArr = $clManager->getVoucherArr();
$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="familydiv" id="<?php echo strip_tags($group);?>" style="margin:12px 0px 3px 0px;font-weight:bold;">
<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;
}
echo "<div id='tid-$tid' style='margin:0px 0px 3px 10px;'>";
echo '<div style="clear:left">';
echo '<div id="tid-'.$tid.'" class="taxon-container">';
//Edit species name display style here
echo '<div class="taxon-div">';
if(!preg_match('/\ssp\d/',$sppArr["sciname"])) echo '<a href="../taxa/index.php?taxauthid=1&taxon='.$tid.'&clid='.$clid.'" target="_blank">';
echo "<b><i>".$sppArr["sciname"]."</b></i> ";
echo '<span class="taxon-span">'.$sppArr['sciname'].'</span> ';
if(array_key_exists("author",$sppArr)) echo $sppArr["author"];
if(!preg_match('/\ssp\d/',$sppArr["sciname"])) echo "</a>";
if(array_key_exists('vern',$sppArr)){
echo " - <span style='font-weight:bold;'>".$sppArr["vern"]."</span>";
echo ' - <span class="vern-span">'.$sppArr['vern'].'</span>';
}
$clidArr = array();
if(isset($sppArr['clid'])) $clidArr = explode(',',$sppArr['clid']);
if($clArray["dynamicsql"]){
?>
<span class="printoff" style="margin:0px 10px">
<span class="view-specimen-span printoff">
<a href="../collections/list.php?usethes=1&taxontype=2&taxa=<?php echo $tid."&targetclid=".$clid."&targettid=".$tid;?>" target="_blank">
<img src="../images/list.png" style="width:12px;" title="<?php echo (isset($LANG['VIEW_RELATED'])?$LANG['VIEW_RELATED']:'View Related Specimens'); ?>" />
</a>
Expand Down Expand Up @@ -747,7 +749,7 @@
}
echo "</div>\n";
if($showSynonyms && isset($sppArr['syn'])){
echo '<div style="margin-left:15px">['.$sppArr['syn'].']</div>';
echo '<div class="syn-div">['.$sppArr['syn'].']</div>';
}
if($showVouchers){
$voucStr = '';
Expand All @@ -770,7 +772,8 @@
$noteStr = $sppArr['notes'];
}
if($noteStr || $voucStr){
echo "<div style='margin-left:15px;'>".$noteStr.($noteStr && $voucStr?'; ':'').$voucStr."</div>";
//Edit notes and voucher display style here
echo '<div class="note-div">'.$noteStr.($noteStr && $voucStr?'; ':'').$voucStr.'</div>';
}
}
echo "</div>\n";
Expand All @@ -780,7 +783,8 @@
$taxaLimit = ($showImages?$clManager->getImageLimit():$clManager->getTaxaLimit());
if($clManager->getTaxaCount() > (($pageNumber)*$taxaLimit)){
echo '<div class="printoff" style="margin:20px;clear:both;">';
echo '<a href="checklist.php?pagenumber='.($pageNumber+1).$argStr.'"> '.$LANG['DISPLAYNEXT'].' '.$taxaLimit.' '.$LANG['TAXA'].'...</a></div>';
echo '<a href="checklist.php?pagenumber='.($pageNumber+1).$argStr.'"> '.$LANG['DISPLAYNEXT'].' '.$taxaLimit.' '.$LANG['TAXA'].'...</a>';
echo '</div>';
}
if(!$taxaArray) echo "<h1 style='margin:40px;'>".$LANG['NOTAXA']."</h1>";
?>
Expand Down
18 changes: 13 additions & 5 deletions classes/ImageLibraryManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -498,12 +498,20 @@ public function getTaxaSuggest($queryString, $type = 'sciname'){

public function getPhotographerUidArr(){
$retArr = array();
$sql = 'SELECT DISTINCT u.uid, CONCAT_WS(", ",u.lastname, u.firstname) AS fullname FROM images i INNER JOIN users u ON i.photographeruid = u.uid ';
$rs = $this->conn->query($sql);
while ($r = $rs->fetch_object()) {
$retArr[$r->uid] = $r->fullname;
$sql1 = 'SELECT DISTINCT photographeruid FROM images WHERE photographeruid IS NOT NULL';
$rs1 = $this->conn->query($sql1);
while ($r1 = $rs1->fetch_object()) {
$retArr[$r1->photographeruid] = '';
}
$rs1->free();
if($retArr){
$sql2 = 'SELECT uid, CONCAT_WS(", ", lastname, firstname) AS fullname FROM users WHERE uid IN('.implode(',',array_keys($retArr)).')';
$rs2 = $this->conn->query($sql2);
while ($r2 = $rs2->fetch_object()) {
$retArr[$r2->uid] = $r2->fullname;
}
$rs2->free();
}
$rs->free();
asort($retArr,SORT_NATURAL | SORT_FLAG_CASE);
return $retArr;
}
Expand Down
9 changes: 7 additions & 2 deletions classes/ImageProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function processIPlantImages($pmTerm, $postArr){
return false;
}
//Get start date
if(!$lastRunDate || !preg_match('/^\d{4}-\d{2}-\d{2}$/',$lastRunDate)) $lastRunDate = '2015-04-01';
if(!$lastRunDate || !preg_match('/^\d{4}-\d{2}-\d{2}$/',$lastRunDate)) $lastRunDate = '2019-05-01';
while(strtotime($lastRunDate) < strtotime('now')){
$url = $iPlantDataUrl.'image?value=*'.$iPlantSourcePath.'*&tag_query=upload_datetime:'.$lastRunDate.'*';
$contents = @file_get_contents($url);
Expand Down Expand Up @@ -374,7 +374,12 @@ public function loadFileData($postArr){
while($r1 = $rs1->fetch_object()){
$uFileName = substr(strrchr($r1->url, "/"), 1);
$oFileName = substr(strrchr($r1->originalurl, "/"), 1);
if($oFileName == $origFileName || $uFileName == $urlFileName || $oFileName == $urlFileName || $uFileName == $origFileName){
$replaceImg = false;
if($oFileName && $oFileName == $origFileName) $replaceImg = true;
elseif($uFileName && $uFileName == $urlFileName) $replaceImg = true;
elseif($oFileName && $oFileName == $urlFileName) $replaceImg = true;
elseif($uFileName && $uFileName == $origFileName) $replaceImg = true;
if($replaceImg){
$sql2 = 'UPDATE images '.
'SET url = "'.$url.'", originalurl = "'.$originalUrl.'", thumbnailurl = '.($thumbnailUrl?'"'.$thumbnailUrl.'"':'NULL').', '.
'sourceurl = '.($sourceUrl?'"'.$sourceUrl.'"':'NULL').' '.
Expand Down
17 changes: 11 additions & 6 deletions classes/ImageShared.php
Original file line number Diff line number Diff line change
Expand Up @@ -1237,11 +1237,11 @@ public static function getImgDim($imgUrl){
// Retrieve JPEG width and height without downloading/reading entire image.
private static function getImgDim1($imgUrl) {
$opts = array(
'http'=>array(
'user_agent' => $GLOBALS['DEFAULT_TITLE'],
'method'=>"GET",
'header'=> implode("\r\n", array('Content-type: text/plain;'))
)
'http'=>array(
'user_agent' => $GLOBALS['DEFAULT_TITLE'],
'method'=>"GET",
'header'=> implode("\r\n", array('Content-type: text/plain;'))
)
);
$context = stream_context_create($opts);
if($handle = fopen($imgUrl, "rb", false, $context)){
Expand All @@ -1263,9 +1263,14 @@ private static function getImgDim1($imgUrl) {
$sof_marker = array("\xC0", "\xC1", "\xC2", "\xC3", "\xC5", "\xC6", "\xC7", "\xC8", "\xC9", "\xCA", "\xCB", "\xCD", "\xCE", "\xCF");
if(in_array($new_block[$i+1], $sof_marker)) {
// SOF marker detected. Width and height information is contained in bytes 4-7 after this byte.
$size_data = $new_block[$i+2] . $new_block[$i+3] . $new_block[$i+4] . $new_block[$i+5] . $new_block[$i+6] . $new_block[$i+7] . $new_block[$i+8];
//$size_data = $new_block[$i+2] . $new_block[$i+3] . $new_block[$i+4] . $new_block[$i+5] . $new_block[$i+6] . $new_block[$i+7] . $new_block[$i+8];
$size_data = null;
for($x = 2; $x < 9; $x++){
if(isset($new_block[$i+$x])) $size_data .= $new_block[$i+$x];
}
$unpacked = unpack("H*", $size_data);
$unpacked = $unpacked[1];
if(!is_array($unpacked) || count($unpacked) < 13) return false;
$height = hexdec($unpacked[6] . $unpacked[7] . $unpacked[8] . $unpacked[9]);
$width = hexdec($unpacked[10] . $unpacked[11] . $unpacked[12] . $unpacked[13]);
return array($width, $height);
Expand Down
61 changes: 37 additions & 24 deletions classes/OccurrenceAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function addAttributes($postArr,$uid){
$status = true;
$stateArr = array();
foreach($postArr as $postKey => $postValue){
if(substr($postKey,0,8) == 'stateid-'){
if(substr($postKey,0,8) == 'traitid-'){
if(is_array($postValue)){
$stateArr = array_merge($stateArr,$postValue);
}
Expand All @@ -36,23 +36,35 @@ public function addAttributes($postArr,$uid){
}
}
}
$sourceStr = 'viewingSpecimenImage';
if(isset($postArr['source']) && $postArr['source']) $sourceStr = $postArr['source'];
foreach($stateArr as $stateId){
if(is_numeric($stateId)){
$sql = 'INSERT INTO tmattributes(stateid,occid,source,notes,createduid) '.
'VALUES('.$stateId.','.$this->occid.','.($sourceStr?'"'.$this->cleanInStr($sourceStr).'"':'NULL').','.
($postArr['notes']?'"'.$this->cleanInStr($postArr['notes']).'"':'NULL').','.$uid.') ';
//echo $sql.'<br/>';
if(!$this->conn->query($sql)){
$this->errorMessage .= 'ERROR saving occurrence attribute: '.$this->conn->error.'; ';
if($stateArr){
//Get trait types
$traitArr = array();
$sql = 'SELECT s.stateid, t.traittype FROM tmtraits t INNER JOIN tmstates s ON t.traitid = s.traitid WHERE s.stateid IN('.implode(',',$stateArr).')';
$rs = $this->conn->query($sql);
while($r = $rs->fetch_object()){
$traitArr[$r->stateid] = $r->traittype;
}
$rs->free();

//Insert attributes
$sourceStr = 'viewingSpecimenImage';
if(isset($postArr['source']) && $postArr['source']) $sourceStr = $postArr['source'];
foreach($stateArr as $stateId){
if(is_numeric($stateId)){
$sql = 'INSERT INTO tmattributes(stateid,xvalue,occid,source,notes,createduid) '.
'VALUES('.$stateId.',,'.$this->occid.','.($sourceStr?'"'.$this->cleanInStr($sourceStr).'"':'NULL').','.
($postArr['notes']?'"'.$this->cleanInStr($postArr['notes']).'"':'NULL').','.$uid.') ';
//echo $sql.'<br/>';
if(!$this->conn->query($sql)){
$this->errorMessage .= 'ERROR saving occurrence attribute: '.$this->conn->error.'; ';
$status = false;
}
}
else{
$this->errorMessage .= 'ERROR saving occurrence attribute: bad input values ('.$stateId.'); ';
$status = false;
}
}
else{
$this->errorMessage .= 'ERROR saving occurrence attribute: bad input values ('.$stateId.'); ';
$status = false;
}
}
return $status;
}
Expand All @@ -62,7 +74,7 @@ public function editAttributes($postArr){
$stateArr = array();

foreach($postArr as $postKey => $postValue){
if(substr($postKey,0,8) == 'stateid-'){
if(substr($postKey,0,8) == 'traitid-'){
if(is_array($postValue)){
$stateArr = array_merge($stateArr,$postValue);
}
Expand All @@ -89,7 +101,7 @@ public function editAttributes($postArr){
$status = true;
}
else{
$this->errorMessage = 'ERROR addin occurrence attribute: '.$this->conn->error;
$this->errorMessage = 'ERROR adding occurrence attribute: '.$this->conn->error;
$status = false;
}
}
Expand Down Expand Up @@ -253,8 +265,8 @@ public function getTraitArr($traitID = null, $setAttributes = true){
}

private function setTraitArr($traitID){
$sql = 'SELECT traitid, traitname, traittype, units, description, refurl, notes, dynamicproperties FROM tmtraits ';
if($traitID) $sql .= 'WHERE (traitid = '.$traitID.')';
$sql = 'SELECT traitid, traitname, traittype, units, description, refurl, notes, dynamicproperties FROM tmtraits WHERE traittype IN("UM","OM","NU") ';
if($traitID) $sql .= 'AND (traitid = '.$traitID.')';
//echo $sql.'<br/>';
$rs = $this->conn->query($sql);
while($r = $rs->fetch_object()){
Expand Down Expand Up @@ -305,14 +317,14 @@ private function setTraitStates(){

private function setCodedAttribute(){
$retArr = array();
$sql = 'SELECT s.traitid, a.stateid, a.source, a.notes, a.statuscode, a.modifieduid, a.datelastmodified, a.createduid, a.initialtimestamp '.
$sql = 'SELECT s.traitid, a.stateid, a.xvalue, a.source, a.notes, a.statuscode, a.modifieduid, a.datelastmodified, a.createduid, a.initialtimestamp '.
'FROM tmattributes a INNER JOIN tmstates s ON a.stateid = s.stateid '.
'WHERE (a.occid = '.$this->occid.') ';
if($this->traitArr) $sql .= 'AND (s.traitid IN('.implode(',',array_keys($this->traitArr)).'))';
//echo $sql; exit;
$rs = $this->conn->query($sql);
while($r = $rs->fetch_object()){
$this->traitArr[$r->traitid]['states'][$r->stateid]['coded'] = '';
$this->traitArr[$r->traitid]['states'][$r->stateid]['coded'] = $r->xvalue;
$this->traitArr[$r->traitid]['states'][$r->stateid]['source'] = $r->source;
$this->traitArr[$r->traitid]['states'][$r->stateid]['notes'] = $r->notes;
$this->traitArr[$r->traitid]['states'][$r->stateid]['statuscode'] = $r->statuscode;
Expand Down Expand Up @@ -342,19 +354,20 @@ private function getTraitUnitString($traitID,$display,$classStr=''){
foreach($attrStateArr as $sid => $sArr){
$isCoded = false;
if(array_key_exists('coded',$sArr)){
$isCoded = true;
if($sArr['coded'] === '') $isCoded = true;
else $isCoded = $sArr['coded'];
$this->stateCodedArr[$sid] = $sid;
}
$depTraitId = false;
if(isset($sArr['dependTraitID']) && $sArr['dependTraitID']) $depTraitId = $sArr['dependTraitID'];
if($controlType == 'checkbox' || $controlType == 'radio'){
$innerStr .= '<div title="'.$sArr['description'].'"><input name="stateid-'.$traitID.'[]" class="'.$classStr.'" type="'.$controlType.'" value="'.$sid.'" '.($isCoded?'checked':'').' onchange="traitChanged(this)" /> '.$sArr['name'];
$innerStr .= '<div title="'.$sArr['description'].'"><input name="traitid-'.$traitID.'[]" class="'.$classStr.'" type="'.$controlType.'" value="'.$sid.'" '.($isCoded?'checked':'').' onchange="traitChanged(this)" /> '.$sArr['name'];
}
elseif($controlType == 'select'){
$innerStr .= '<option value="'.$sid.'" '.($isCoded?'selected':'').'>'.$sArr['name'].'</option>';
}
elseif($controlType == 'numeric'){
$innerStr .= '<div title="'.$sArr['description'].'">'.$sArr['name'].': <input name="stateid-'.$traitID.'[]" class="'.$classStr.'" type="input" value="'.$sid.'" onchange="traitChanged(this)" style="width:50px" /> ';
$innerStr .= '<div title="'.$sArr['description'].'">'.$sArr['name'].': <input name="traitid-'.$traitID.'[]" class="'.$classStr.'" type="input" value="'.($isCoded!==false?$isCoded:'').'" onchange="traitChanged(this)" style="width:50px" /> ';
}
if($depTraitId){
$innerStr .= $this->getTraitUnitString($depTraitId,$isCoded,trim($classStr.' child-'.$sid));
Expand Down
13 changes: 5 additions & 8 deletions classes/OccurrenceCollectionProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,14 @@ public function getMetadataHtml($collArr, $LANG){
$outStr .= '<div style="margin-top:5px;">';
$outStr .= '<b>'.$LANG['MANAGEMENT'].':</b> ';
if($collArr['managementtype'] == 'Live Data'){
$outStr .= 'Live Data managed directly within data portal';
$outStr .= (isset($LANG['LIVE_DATA'])?$LANG['LIVE_DATA']:'Live Data managed directly within data portal');
}
else{
if($collArr['managementtype'] == 'Aggregate'){
$outStr .= 'Data harvested from a data aggregator';
$outStr .= (isset($LANG['DATA_AGGREGATE'])?$LANG['DATA_AGGREGATE']:'Data harvested from a data aggregator');
}
else{
$outStr .= 'Data snapshot of local collection database ';
$outStr .= (isset($LANG['DATA_SNAPSHOT'])?$LANG['DATA_SNAPSHOT']:'Data snapshot of local collection database ');
}
$outStr .= '<div style="margin-top:5px;"><b>'.$LANG['LAST_UPDATE'].':</b> '.$collArr['uploaddate'].'</div>';
}
Expand All @@ -161,13 +161,10 @@ public function getMetadataHtml($collArr, $LANG){
}
$outStr .= '<div style="margin-top:5px;">';
if($collArr['managementtype'] == 'Live Data'){
$outStr .= '<b>'.(isset($LANG['LIVE_DOWNLOAD'])?$LANG['LIVE_DOWNLOAD']:'Live Data Download').':</b> ';
if($GLOBALS['SYMB_UID']){
$outStr .= '<b>'.(isset($LANG['LIVE_DOWNLOAD'])?$LANG['LIVE_DOWNLOAD']:'Live Data Download').':</b> ';
$outStr .= '<a href="../../webservices/dwc/dwcapubhandler.php?collid='.$collArr['collid'].'">'.(isset($LANG['FULL_DATA'])?$LANG['FULL_DATA']:'DwC-Archive File').'</a>';
}
else{
$outStr .= '<a href="../../profile/index.php?refurl=../collections/misc/collprofiles.php?collid='.$collArr['collid'].'">'.(isset($LANG['LOGIN_TO_ACCESS'])?$LANG['LOGIN_TO_ACCESS']:'Login for access').'</a>';
}
}
elseif($collArr['managementtype'] == 'Snapshot'){
$pathArr = $this->getDwcaPath($collArr['collid']);
Expand Down Expand Up @@ -201,7 +198,7 @@ public function getMetadataHtml($collArr, $LANG){
if($rightsUrl) $outStr .= '</a>';
}
elseif(file_exists('../../misc/usagepolicy.php')){
$outStr .= '<a href="../../misc/usagepolicy.php" target="_blank">Usage policy</a>';
$outStr .= '<a href="../../misc/usagepolicy.php" target="_blank">'.(isset($LANG['USAGE_POLICY'])?$LANG['USAGE_POLICY']:'Usage policy').'</a>';
}
$outStr .= '</div>';
if($collArr['rightsholder']){
Expand Down
6 changes: 3 additions & 3 deletions classes/OccurrenceDuplicate.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function getClusterArr($occid){
$retArr[$r1->duplicateid]['description'] = $r1->description;
$retArr[$r1->duplicateid]['notes'] = $r1->notes;
}
$rs1->close();
$rs1->free();
}
else{
$this->errorStr = 'ERROR getting list of duplicate records [1]: '.$this->conn->error;
Expand All @@ -39,7 +39,7 @@ public function getClusterArr($occid){

if($retArr){
$sql = 'SELECT d.duplicateid, d.occid, c.institutioncode, c.collectioncode, c.collectionname, o.catalognumber, '.
'o.occurrenceid, o.sciname, o.identifiedby, o.dateidentified, '.
'o.occurrenceid, o.sciname, o.scientificnameauthorship, o.identifiedby, o.dateidentified, '.
'o.recordedby, o.recordnumber, o.eventdate, d.notes, i.url, i.thumbnailurl '.
'FROM omoccurduplicatelink d INNER JOIN omoccurrences o ON d.occid = o.occid '.
'INNER JOIN omcollections c ON o.collid = c.collid '.
Expand All @@ -48,7 +48,7 @@ public function getClusterArr($occid){
if($rs = $this->conn->query($sql)){
while($r = $rs->fetch_object()){
$retArr[$r->duplicateid]['o'][$r->occid] = array('instcode' => $r->institutioncode, 'collcode' => $r->collectioncode,
'collname' => $r->collectionname, 'catnum' => $r->catalognumber, 'occurrenceid' => $r->occurrenceid, 'sciname' => $r->sciname,
'collname' => $r->collectionname, 'catnum' => $r->catalognumber, 'occurrenceid' => $r->occurrenceid, 'sciname' => $r->sciname, 'author' => $r->scientificnameauthorship,
'identifiedby' => $r->identifiedby, 'dateidentified' => $r->dateidentified, 'recordedby' => $r->recordedby,
'recordnumber' => $r->recordnumber, 'eventdate' => $r->eventdate, 'notes' => $r->notes, 'tnurl' => $r->thumbnailurl,
'url' => $r->url);
Expand Down
Loading

0 comments on commit a6f072c

Please sign in to comment.