Skip to content

Commit

Permalink
Merge pull request #30 from BioKIC/master
Browse files Browse the repository at this point in the history
code update
  • Loading branch information
mandrewj authored Jul 29, 2022
2 parents 9332ccb + 8a53685 commit 8e1a495
Show file tree
Hide file tree
Showing 100 changed files with 2,452 additions and 25,476 deletions.
44 changes: 43 additions & 1 deletion api/app/Http/Controllers/OccurrenceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,42 @@ public function __construct(){
* required=false,
* @OA\Schema(type="string")
* ),
* ),
* @OA\Parameter(
* name="collid",
* in="query",
* description="collid - collection identifier in portal",
* required=false,
* @OA\Schema(type="string")
* ),
* @OA\Parameter(
* name="datasetID",
* in="query",
* description="dataset ID within portal",
* required=false,
* @OA\Schema(type="string")
* ),
* @OA\Parameter(
* name="family",
* in="query",
* description="family",
* required=false,
* @OA\Schema(type="string")
* ),
* @OA\Parameter(
* name="sciname",
* in="query",
* description="Scientific Name - binomen only without authorship",
* required=false,
* @OA\Schema(type="string")
* ),
* @OA\Parameter(
* name="eventDate",
* in="query",
* description="Date as YYYY, YYYY-MM or YYYY-MM-DD",
* required=false,
* @OA\Schema(type="string")
* ),
* @OA\Parameter(
* name="limit",
* in="query",
Expand Down Expand Up @@ -94,6 +130,12 @@ public function showAllOccurrences(Request $request){
if($request->has('country')) $conditions[] = ['country',$request->country];
if($request->has('stateProvince')) $conditions[] = ['stateProvince',$request->stateProvince];
if($request->has('county')) $conditions[] = ['county','LIKE',$request->county.'%'];
if($request->has('collid')) $conditions[] = ['collid',$request->collid];
if($request->has('family')) $conditions[] = ['family',$request->family];
if($request->has('sciname')) $conditions[] = ['sciname','LIKE',$request->sciname.'%'];
if($request->has('datasetID')) $conditions[] = ['datasetID',$request->datasetID];
if($request->has('eventDate')) $conditions[] = ['eventDate','LIKE',$request->eventDate.'%'];


$fullCnt = Occurrence::where($conditions)->count();
$result = Occurrence::where($conditions)->skip($offset)->take($limit)->get();
Expand Down Expand Up @@ -171,4 +213,4 @@ public function delete($id){
//Occurrence::findOrFail($id)->delete();
//return response('Occurrence Deleted Successfully', 200);
}
}
}
47 changes: 46 additions & 1 deletion api/storage/api-docs/api-docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,15 @@
"type": "string"
}
},
{
"name": "collid",
"in": "query",
"description": "collid - collection identifier within portal",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "country",
"in": "query",
Expand Down Expand Up @@ -348,6 +357,42 @@
"type": "string"
}
},
{
"name": "family",
"in": "query",
"description": "family - higher level classification",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "sciname",
"in": "query",
"description": "Scientific Name - as binomen without authorship",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "eventDate",
"in": "query",
"description": "Date as YYYY, YYYY-MM or YYYY-MM-DD",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "datasetID",
"in": "query",
"description": "Dataset ID within portal",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "limit",
"in": "query",
Expand Down Expand Up @@ -426,4 +471,4 @@
}
}
}
}
}
4 changes: 4 additions & 0 deletions checklists/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

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

//Sanitation
if(!is_numeric($pid)) $pid = 0;
$pid = filter_var($pid, FILTER_SANITIZE_STRING);

$clManager = new ChecklistManager();
$clManager->setProj($pid);
?>
Expand Down
41 changes: 29 additions & 12 deletions checklists/tools/mappolyaid.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@
header('Content-Type: text/html; charset='.$CHARSET);

$clid = array_key_exists('clid',$_REQUEST)?$_REQUEST['clid']:0;
$formSubmit = array_key_exists('formsubmit',$_POST)?$_POST['formsubmit']:0;
$formSubmit = array_key_exists('formsubmit',$_POST)?$_POST['formsubmit']:'';
$latDef = array_key_exists('latdef',$_REQUEST)?$_REQUEST['latdef']:'';
$lngDef = array_key_exists('lngdef',$_REQUEST)?$_REQUEST['lngdef']:'';
$zoom = array_key_exists('zoom',$_REQUEST)&&$_REQUEST['zoom']?$_REQUEST['zoom']:5;

//Sanitation
if(!is_numeric($clid)) $clid = 0;
if(!is_numeric($latDef)) $latDef = 0;
if(!is_numeric($lngDef)) $lngDef = 0;
if(!is_numeric($zoom)) $zoom = 0;

$clManager = new ChecklistAdmin();
$clManager->setClid($clid);

Expand Down Expand Up @@ -46,15 +52,15 @@
<title><?php echo $DEFAULT_TITLE; ?> - Coordinate Aid</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<script src="//maps.googleapis.com/maps/api/js?<?php echo (isset($GOOGLE_MAP_KEY) && $GOOGLE_MAP_KEY?'key='.$GOOGLE_MAP_KEY:''); ?>&libraries=drawing&v=weekly"></script>
<script src="<?php echo $CLIENT_ROOT; ?>/js/symb/wktpolygontools.js?ver=3d" type="text/javascript"></script>
<script src="<?php echo $CLIENT_ROOT; ?>/js/symb/wktpolygontools.js?ver=4" type="text/javascript"></script>
<script type="text/javascript">
var map;
var polygons = [];
var polyBounds = null;
var selectedPolygon = null;
var drawingManager = null;
<?php
if($formSubmit && $formSubmit == 'exit') echo 'window.close();';
if($formSubmit == 'exit') echo 'window.close();';
?>
function initialize(){
if(opener.document.getElementById("footprintwkt") && opener.document.getElementById("footprintwkt").value != ""){
Expand Down Expand Up @@ -168,14 +174,20 @@ function addPolyListeners(poly){

function reformatPolygons(f){
let footprintWkt = f.footprintwkt.value.trim();
if(f.trimCoord.checked) trimCoord = true;
else trimCoord = false;
if(f.switchCoord.checked) switchCoord = true;
else switchCoord = false;
f.footprintwkt.value = validatePolygon(footprintWkt);
clearSelection();
for(var h=0;h<polygons.length;h++){
polygons[h].setMap(null);
}
polyBounds = null;
polyBounds = new google.maps.LatLngBounds();
drawPolygons();
drawingManager.setDrawingMode(null);
f.formatButton.disabled = true;
f.redrawButton.disabled = true;
}

function clearSelection() {
Expand Down Expand Up @@ -216,7 +228,7 @@ function setPolygonStr() {
}
document.getElementById("footprintwkt").value = "MULTIPOLYGON ("+outStr.substring(1)+")";
}
document.getElementById("formatButton").disabled = true;
document.getElementById("redrawButton").disabled = true;
}

function deleteSelectedPolygon() {
Expand Down Expand Up @@ -252,7 +264,7 @@ function submitPolygonForm(f){
}

function polygonModified(f){
f.formatButton.disabled = false;
f.redrawButton.disabled = false;
}

function toggle(target){
Expand All @@ -275,18 +287,23 @@ function toggle(target){
Use Switch Coordinate Order button to convert Long-Lat coordinate pairs to Lat-Long format.
</div>
<form name="polygonSubmitForm" method="post" action="mappolyaid.php" onsubmit="return submitPolygonForm(this)">
<div style="float:left;width:800px">
<div style="">
<textarea id="footprintwkt" name="footprintwkt" style="width:98%;height:90px;" oninput="polygonModified(this.form)"><?php echo $clManager->getFootprintWkt(); ?></textarea>
<input name="clid" type="hidden" value="<?php echo $clid; ?>" />
<input name="latdef" type="hidden" value="<?php echo $latDef; ?>" />
<input name="lngdef" type="hidden" value="<?php echo $lngDef; ?>" />
<input name="zoom" type="hidden" value="<?php echo $zoom; ?>" />
</div>
<div style="float:left">
<button name="formsubmit" type="submit" value="save">Save Polygons</button>
<a href="#" onclick="toggle('helptext')"><img alt="Display Help Text" src="../../images/qmark_big.png" style="width:15px;" /></a><br/>
<button name="deleteButton" type="button" onclick="deleteSelectedPolygon()">Delete Selected Shape</button><br/>
<button id="formatButton" name="formatButton" type="button" onclick="reformatPolygons(this.form);" disabled>Reformat Polygons</button><br/>
<div style="">
<button name="formsubmit" type="submit" value="save" style="margin-right: 10px">Save Polygons</button>
<button name="deleteButton" type="button" onclick="deleteSelectedPolygon()">Delete Selected Shape</button>
<a href="#" onclick="toggle('helptext')"><img alt="Display Help Text" src="../../images/qmark_big.png" style="width:15px;" /></a>
<fieldset id="reformatFieldset" style="width:300px;">
<legend>Redraw / Reformat Polygons</legend>
<button id="redrawButton" name="redrawButton" type="button" onclick="reformatPolygons(this.form);" disabled>Redraw</button><br />
<input type="checkbox" name="trimCoord" value="1" onclick="polygonModified(this.form)" checked /> Trim to 6 significant digits<br />
<input type="checkbox" name="switchCoord" value="1" onclick="polygonModified(this.form)" /> Switch lat/long coordinates
</fieldset>
</div>
</form>
</div>
Expand Down
3 changes: 2 additions & 1 deletion classes/OccurrenceCollectionProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class OccurrenceCollectionProfile extends OmCollections{

private $collMeta;
private $collMeta = array();
private $organizationKey;
private $installationKey;
private $datasetKey;
Expand Down Expand Up @@ -928,6 +928,7 @@ public function materialSampleIsActive(){

//Misc functions
public function cleanOutArr(&$arr){
if(!is_array($arr)) return;
foreach($arr as $k => $v){
$arr[$k] = $this->cleanOutStr($v);
}
Expand Down
6 changes: 5 additions & 1 deletion classes/OccurrenceManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,10 @@ public function getLocalSearchStr(){
return implode("; ", $this->displaySearchArr);
}

protected function setSearchTerm($termKey, $termValue){
$this->searchTermArr[$termKey] = $this->cleanInputStr($termValue);
}

public function getSearchTerm($k){
if($k && isset($this->searchTermArr[$k])){
return trim($this->searchTermArr[$k],' ;');
Expand Down Expand Up @@ -805,7 +809,7 @@ protected function readRequestVariables(){
if($eventDate = $this->cleanInputStr($_REQUEST['eventdate1'])){
$this->searchTermArr['eventdate1'] = $eventDate;
if(array_key_exists('eventdate2',$_REQUEST)){
if($eventDate2 = filter_var($_REQUEST['eventdate2'], FILTER_SANITIZE_STRING)){
if($eventDate2 = $this->cleanInputStr($_REQUEST['eventdate2'])){
if($eventDate2 != $eventDate){
$this->searchTermArr['eventdate2'] = $eventDate2;
}
Expand Down
Loading

0 comments on commit 8e1a495

Please sign in to comment.