forked from egbot/Symbiota
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from BioKIC/master
Merge BioKIC/Symbiota developments
- Loading branch information
Showing
1,422 changed files
with
25,498 additions
and
9,539 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
<?php | ||
require_once('../config/symbini.php'); | ||
require_once($SERVER_ROOT.'/classes/PortalIndex.php'); | ||
//include_once($SERVER_ROOT.'/content/lang/admin/portalindex.'.$LANG_TAG.'.php'); | ||
header("Content-Type: text/html; charset=".$CHARSET); | ||
|
||
if(!$SYMB_UID) header('Location: '.$CLIENT_ROOT.'/profile/index.php?refurl=../admin/portalindex.php?'.htmlspecialchars($_SERVER['QUERY_STRING'], ENT_QUOTES)); | ||
|
||
$portalID = array_key_exists('portalid',$_REQUEST)?$_REQUEST['portalid']:0; | ||
$remoteID = array_key_exists('remoteid',$_REQUEST)?$_REQUEST['remoteid']:0; | ||
$formSubmit = array_key_exists('formsubmit',$_POST)?$_POST['formsubmit']:''; | ||
|
||
//Sanitation | ||
if(!is_numeric($portalID)) $portalID = 0; | ||
if(!is_numeric($remoteID)) $remoteID = 0; | ||
|
||
$portalManager = new PortalIndex(); | ||
|
||
$isEditor = 0; | ||
if($IS_ADMIN) $isEditor = 1; | ||
?> | ||
<html> | ||
<head> | ||
<title><?php echo $DEFAULT_TITLE; ?> Portal Index Control Panel</title> | ||
<?php | ||
$activateJQuery = true; | ||
include_once($SERVER_ROOT.'/includes/head.php'); | ||
?> | ||
<script src="<?php echo $CLIENT_ROOT; ?>/js/jquery.js" type="text/javascript"></script> | ||
<script src="<?php echo $CLIENT_ROOT; ?>/js/jquery-ui.js" type="text/javascript"></script> | ||
<script type="text/javascript"> | ||
</script> | ||
<style type="text/css"> | ||
fieldset{ margin:20px; padding:15px; } | ||
legend{ font-weight: bold; } | ||
label{ font-weight: bold; } | ||
hr{ margin-top: 15px; margin-bottom: 15px; } | ||
</style> | ||
</head> | ||
<body> | ||
<?php | ||
$displayLeftMenu = true; | ||
include($SERVER_ROOT.'/includes/header.php'); | ||
?> | ||
<div class="navpath"> | ||
<a href="../../index.php">Home</a> >> | ||
<b>Portal Index Control Panel</b> | ||
</div> | ||
<div id="innertext"> | ||
<?php | ||
if($isEditor){ | ||
if($formSubmit == 'importProfile'){ | ||
if($collid = $portalManager->importProfile($portalID, $remoteID)) | ||
echo '<div><a href="../collections/misc/collprofiles.php?collid='.$collid.'" target="_blank">New snapshot collection created</a></div>'; | ||
else echo '<div>failed to insert new collections: '.$portalManager->getErrorMessage().'</div>'; | ||
} | ||
$indexArr = $portalManager->getPortalIndexArr($portalID); | ||
?> | ||
<fieldset> | ||
<legend>Portal Index</legend> | ||
<?php | ||
foreach($indexArr as $portalID => $portalArr){ | ||
foreach($portalArr as $fieldName => $fieldValue){ | ||
if($fieldValue){ | ||
echo '<div><label>'.$fieldName.'</label>: '; | ||
$href = ''; | ||
if($fieldName=='urlRoot') $href = $fieldValue; | ||
elseif($fieldName=='guid') $href = $portalArr['urlRoot'].'/api/v2/installation/ping'; | ||
if($href) echo '<a href="'.$href.'" target="_blank">'; | ||
echo $fieldValue; | ||
if($href) echo '</a>'; | ||
echo '</div>'; | ||
} | ||
} | ||
echo '<hr/>'; | ||
if($remoteID){ | ||
$collectArr = $portalManager->getCollectionList($portalArr['urlRoot'], $remoteID); | ||
$collTitle = $collectArr['collectionName'].' ('.$collectArr['institutionCode'].($collectArr['collectionCode']?':'.$collectArr['collectionCode']:'').')'; | ||
echo '<div style="font-weight:bold">#'.$remoteID.': '.$collTitle.'</div>'; | ||
$collectArr['remoteID'] = $collectArr['collID']; | ||
unset($collectArr['collID']); | ||
echo '<div style="margin:15px 30px;">'; | ||
foreach($collectArr as $fName => $fValue){ | ||
if($fValue){ | ||
if($fName == 'fullDescription') $fValue = htmlentities($fValue); | ||
elseif($fName == 'internalCollid') $fValue = '<a href="'.$CLIENT_ROOT.'/collections/misc/collprofiles.php?collid='.$fValue.'" target="_blank">Mapped Internally</a>'; | ||
echo '<div><label>'.$fName.'</label>: '.$fValue.'</div>'; | ||
} | ||
} | ||
echo '</div>'; | ||
if(!$collectArr['internalCollid']){ | ||
?> | ||
<div style="margin: 0px 30px"> | ||
<form name="collPubForm" method="post" action="portalindex.php"> | ||
<input name="portalid" type="hidden" value="<?php echo $portalID; ?>" /> | ||
<input name="remoteid" type="hidden" value="<?php echo $remoteID; ?>" /> | ||
<input name="collid" type="hidden" value="<?php echo $collectArr['internalCollid']; ?>" /> | ||
<button name="formsubmit" type="submit" value="importProfile">Import Profile</button> | ||
</form> | ||
</div> | ||
<?php | ||
} | ||
} | ||
elseif($formSubmit == 'listCollections'){ | ||
if($collList = $portalManager->getCollectionList($portalArr['urlRoot'])){ | ||
echo '<div><label>Collection Count</label>: '.count($collList).'</div>'; | ||
echo '<table class="styledtable">'; | ||
echo '<tr><th>ID</th><th>Institution Code</th><th>Collection Code</th><th>Collection Name</th><th>Dataset Type</th><th>Management</th><th>Mapped Internally</th></tr>'; | ||
foreach($collList as $collArr){ | ||
echo '<tr>'; | ||
echo '<td><a href="portalindex.php?portalid='.$portalID.'&remoteid='.$collArr['collID'].'">'.$collArr['collID'].'</a></td>'; | ||
echo '<td>'.$collArr['institutionCode'].'</td>'; | ||
echo '<td>'.$collArr['collectionCode'].'</td>'; | ||
echo '<td>'.$collArr['collectionName'].'</td>'; | ||
echo '<td>'.$collArr['collType'].'</td>'; | ||
echo '<td>'.$collArr['managementType'].'</td>'; | ||
if($collArr['internalCollid']) $internal = '<a href="'.$CLIENT_ROOT.'/collections/misc/collprofiles.php?collid='.$collArr['internalCollid'].'" target="_blank">Yes</a>'; | ||
else $internal = 'No'; | ||
echo '<td>'.$internal.'</td>'; | ||
echo '</tr>'; | ||
} | ||
echo '</table>'; | ||
} | ||
} | ||
else{ | ||
?> | ||
<div> | ||
<form name="portalActionForm" method="post" action="portalindex.php"> | ||
<input name="portalid" type="hidden" value="<?php echo $portalID; ?>" /> | ||
<button name="formsubmit" type="submit" value="listCollections">List Collections</button> | ||
</form> | ||
</div> | ||
<?php | ||
} | ||
echo '<hr/>'; | ||
} | ||
?> | ||
</fieldset> | ||
<?php | ||
} | ||
else echo '<h2>ERROR: access denied</h2>'; | ||
?> | ||
</div> | ||
<?php | ||
include($SERVER_ROOT.'/includes/footer.php'); | ||
?> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
APP_NAME=Lumen | ||
APP_ENV=local | ||
APP_KEY= | ||
APP_DEBUG=true | ||
APP_DEBUG=false | ||
APP_URL= | ||
APP_TIMEZONE=UTC | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
namespace App; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Collection extends Model{ | ||
|
||
protected $table = 'omcollections'; | ||
protected $primaryKey = 'collid'; | ||
public $timestamps = false; | ||
|
||
protected $fillable = [ | ||
'institutionCode', 'collectionCode', 'collectionName', 'collectionID', 'datasetID', 'datasetName', 'fullDescription', 'resourceJson', 'IndividualUrl', 'contactJson', | ||
'latitudeDecimal', 'longitudeDecimal', 'icon', 'collType', 'managementType', 'publicEdits', 'collectionGuid', 'rightsHolder', 'rights', 'usageTerm', 'dwcaUrl', | ||
'bibliographicCitation', 'accessRights', 'sortSeq' | ||
]; | ||
|
||
protected $hidden = ['securityKey', 'guidTarget', 'aggKeysStr', 'dwcTermJson', 'publishToGbif', 'publishToIdigbio', 'dynamicProperties']; | ||
|
||
public function occurrence(){ | ||
return $this->hasMany(Occurrence::class, 'collid', 'collid'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Collection; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\DB; | ||
|
||
class CollectionController extends Controller{ | ||
/** | ||
* Collection controller instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct(){ | ||
} | ||
|
||
/** | ||
* @OA\Get( | ||
* path="/api/v2/collection", | ||
* operationId="/api/v2/collection", | ||
* tags={""}, | ||
* @OA\Parameter( | ||
* name="managementType", | ||
* in="query", | ||
* description="live, snapshot, aggregate", | ||
* required=false, | ||
* @OA\Schema(type="string") | ||
* ), | ||
* @OA\Parameter( | ||
* name="collectionType", | ||
* in="query", | ||
* description="preservedSpecimens, observations, researchObservation", | ||
* required=false, | ||
* @OA\Schema(type="string") | ||
* ), | ||
* @OA\Parameter( | ||
* name="limit", | ||
* in="query", | ||
* description="Pagination parameter: maximum number of records per page", | ||
* required=false, | ||
* @OA\Schema(type="integer", default=1000) | ||
* ), | ||
* @OA\Parameter( | ||
* name="offset", | ||
* in="query", | ||
* description="Pagination parameter: page number", | ||
* required=false, | ||
* @OA\Schema(type="integer", default=0) | ||
* ), | ||
* @OA\Response( | ||
* response="200", | ||
* description="Returns list of collections", | ||
* @OA\JsonContent() | ||
* ), | ||
* @OA\Response( | ||
* response="400", | ||
* description="Error: Bad request. ", | ||
* ), | ||
* ) | ||
*/ | ||
public function showAllCollections(Request $request){ | ||
$this->validate($request, [ | ||
'limit' => ['integer', 'max:1000'], | ||
'offset' => 'integer' | ||
]); | ||
$limit = $request->input('limit',1000); | ||
$offset = $request->input('offset',0); | ||
|
||
$conditions = []; | ||
if($request->has('managementType')){ | ||
if($request->managementType == 'live') $conditions[] = ['managementType','Live Data']; | ||
elseif($request->managementType == 'snapshot') $conditions[] = ['managementType','Snapshot']; | ||
elseif($request->managementType == 'aggregate') $conditions[] = ['managementType','Aggregate']; | ||
} | ||
if($request->has('collectionType')){ | ||
if($request->collectionType == 'specimens') $conditions[] = ['collType','Preserved Specimens']; | ||
elseif($request->collectionType == 'observations') $conditions[] = ['collType','Observations']; | ||
elseif($request->collectionType == 'researchObservations') $conditions[] = ['collType','General Observations']; | ||
} | ||
|
||
$fullCnt = Collection::where($conditions)->count(); | ||
$result = Collection::where($conditions)->skip($offset)->take($limit)->get(); | ||
|
||
$eor = false; | ||
$retObj = [ | ||
"offset" => (int)$offset, | ||
"limit" => (int)$limit, | ||
"endOfRecords" => $eor, | ||
"count" => $fullCnt, | ||
"results" => $result | ||
]; | ||
return response()->json($retObj); | ||
} | ||
|
||
/** | ||
* @OA\Get( | ||
* path="/api/v2/collection/{identifier}", | ||
* operationId="/api/v2/collection/identifier", | ||
* tags={""}, | ||
* @OA\Parameter( | ||
* name="identifier", | ||
* in="path", | ||
* description="Installation ID or GUID associated with target collection", | ||
* required=true, | ||
* @OA\Schema(type="string") | ||
* ), | ||
* @OA\Response( | ||
* response="200", | ||
* description="Returns collection data", | ||
* @OA\JsonContent() | ||
* ), | ||
* @OA\Response( | ||
* response="400", | ||
* description="Error: Bad request. Collection identifier is required.", | ||
* ), | ||
* ) | ||
*/ | ||
public function showOneCollection($id, Request $request){ | ||
$collectionObj = null; | ||
if(is_numeric($id)) $collectionObj = Collection::find($id); | ||
else $collectionObj = Collection::where('collectionGuid',$id)->first(); | ||
if(!$collectionObj->count()) $collectionObj = ["status"=>false,"error"=>"Unable to locate collection based on identifier"]; | ||
return response()->json($collectionObj); | ||
} | ||
|
||
public function create(Request $request){ | ||
//$collection = Collection::create($request->all()); | ||
//return response()->json($collection, 201); | ||
} | ||
|
||
public function update($id, Request $request){ | ||
//$collection = Collection::findOrFail($id); | ||
//$collection->update($request->all()); | ||
//return response()->json($collection, 200); | ||
} | ||
|
||
public function delete($id){ | ||
//Collection::findOrFail($id)->delete(); | ||
//return response('Collection Deleted Successfully', 200); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.