Skip to content

Commit

Permalink
hotfix 2024-08-07
Browse files Browse the repository at this point in the history
Occurrence Cleaner
- Replace catalog numbers as the unique identifier for duplicate cluster with numeric key, thus avoiding interference of target form element due to existence of space or period within catalog number. Resolves issue: #1471
- Internationize first submit button
- Add header and footer to cleaning page
  • Loading branch information
egbot committed Aug 7, 2024
1 parent bd1efd2 commit b92df79
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
11 changes: 7 additions & 4 deletions classes/OccurrenceCleaner.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function getDuplicateCatalogNumber($type, $start, $limit = 500){
}
$rs->free();

$retArr = array();
$stagingArr = array();
if($dupArr){
$sqlFrag = '';
if($type=='cat'){
Expand All @@ -54,13 +54,15 @@ public function getDuplicateCatalogNumber($type, $start, $limit = 500){
else{
$sqlFrag = 'occid, otherCatalogNumbers, otherCatalogNumbers AS dupid FROM omoccurrences WHERE collid = '.$this->collid.' AND otherCatalogNumbers IN("'.implode('","', $dupArr).'") ORDER BY otherCatalogNumbers';
}
$retArr = $this->getDuplicates($sqlFrag);
$stagingArr = $this->getDuplicates($sqlFrag);
}

if($type=='other' && count($dupArr) < $limit){
$retArr = array_merge($retArr, $this->setAdditionalIdentifiers($cnt, ($limit - count($dupArr))));
$stagingArr = array_merge($stagingArr, $this->setAdditionalIdentifiers($cnt, ($limit - count($dupArr))));
}

//Replace catalog number keys with renumbered numeric keys, thus avoid unusual characters interferring with naming form target element
$retArr = array_values($stagingArr);
return $retArr;
}

Expand Down Expand Up @@ -152,7 +154,7 @@ private function getDuplicates($sqlFragment){
$sqlFragment;
$rs = $this->conn->query($sql);
while($row = $rs->fetch_assoc()){
$retArr[$row['dupid']][$row['occid']] = array_change_key_case($row);
$retArr[strtolower($row['dupid'])][$row['occid']] = array_change_key_case($row);
}
$rs->free();
return $retArr;
Expand All @@ -162,6 +164,7 @@ public function mergeDupeArr($occidArr){
$status = true;
$this->verboseMode = 2;
$editorManager = new OccurrenceEditorManager($this->conn);
$editorManager->setCollId($this->collid);
foreach($occidArr as $target => $occArr){
$mergeArr = array($target);
foreach($occArr as $source){
Expand Down
14 changes: 10 additions & 4 deletions collections/cleaning/duplicatesearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ function batchSwitchTargetSpecimens(cbElem){
</script>
</head>
<body style="margin-left:10px; width: 100%">
<?php
include($SERVER_ROOT . '/includes/header.php');
?>
<div class='navpath' style="margin:10px">
<a href="../../index.php"><?php echo $LANG['HOME']; ?></a> &gt;&gt;
<a href="../misc/collprofiles.php?collid=<?php echo $collid; ?>&emode=1"><?php echo $LANG['COL_MAN']; ?></a> &gt;&gt;
Expand All @@ -122,7 +125,7 @@ function batchSwitchTargetSpecimens(cbElem){
$href = 'duplicatesearch.php?collid='.$collid.'&action='.$action.'&start='.($start+$limit);
echo '<div style="float:right;"><a href="'.$href.'"><b>'.$LANG['NEXT'].' '.$limit.' '.$LANG['RECORDS'].' &gt;&gt;</b></a></div>';
}
echo '<div style="float:left;margin-bottom:4px;margin-left:15px;"><input name="action" type="submit" value="Merge Duplicate Records" /></div>';
echo '<div style="float:left;margin-bottom:4px;margin-left:15px;"><button name="action" type="submit" value="mergeDuplicates">' . $LANG['MERGE_DUPES'] . '</button></div>';
echo '<div style="float:left;margin-left:15px;"><b>'.($start+1).' '.$LANG['TO'].' '.($start+$recCnt).' '.$LANG['DUP_CLUSTERS'].' </b></div>';
?>
</div>
Expand Down Expand Up @@ -177,7 +180,7 @@ function batchSwitchTargetSpecimens(cbElem){
</table>
</div>
<div style="margin:15px;">
<button name="action" type="submit" value="Merge Duplicate Records"><?php echo $LANG['MERGE_DUPES']; ?></button>
<button name="action" type="submit" value="mergeDuplicates"><?php echo $LANG['MERGE_DUPES']; ?></button>
</div>
</form>
<?php
Expand All @@ -190,7 +193,7 @@ function batchSwitchTargetSpecimens(cbElem){
<?php
}
}
elseif($action == 'Merge Duplicate Records'){
elseif($action == 'mergeDuplicates'){
?>
<ul>
<li><?php echo $LANG['DUPE_MERGING_STARTED']; ?></li>
Expand All @@ -199,7 +202,7 @@ function batchSwitchTargetSpecimens(cbElem){
foreach($_POST['dupid'] as $v){
$vArr = explode('|',$v);
if(count($vArr) > 1){
$target = $_POST['dup'.str_replace(' ', '_', $vArr[0]).'target'];
$target = $_POST['dup' . $vArr[0] . 'target'];
if($target != $vArr[1]) $dupArr[$target][] = $vArr[1];
}
}
Expand Down Expand Up @@ -229,5 +232,8 @@ function batchSwitchTargetSpecimens(cbElem){
}
?>
</div>
<?php
include($SERVER_ROOT . '/includes/footer.php');
?>
</body>
</html>

0 comments on commit b92df79

Please sign in to comment.