Skip to content

Commit

Permalink
Api occurrence 2024 08 (#1688)
Browse files Browse the repository at this point in the history
- Occurrence API endpoint development
-- Add collector, collector last name, and collector number as searchable functions
-- Develop write functions (insert, update, delete), but not yet activated for public use 
-- Add new endpoint for loading and processing skeletal occurrence data
-- Add swagger documentation for skeletal record processing 
- Taxonomy API endpoint development
-- Refactor to use query builder for defining search terms (bring code in sync NEON taxonomy developments)  
- Mics
-- Add helper functions to Lumen API
  • Loading branch information
egbot authored Sep 3, 2024
1 parent 9b951c7 commit 532fbf1
Show file tree
Hide file tree
Showing 16 changed files with 2,831 additions and 231 deletions.
560 changes: 560 additions & 0 deletions api/app/Helpers/GPoint.php

Large diffs are not rendered by default.

53 changes: 53 additions & 0 deletions api/app/Helpers/Helper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php
namespace App\Helpers;

/**
* Base static fucntions that are regularly used across all code.
*/

class Helper {

public static function getDomain(){
$domain = 'http://';
if((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443) $domain = 'https://';
if(!empty($GLOBALS['SERVER_HOST'])){
if(substr($GLOBALS['SERVER_HOST'], 0, 4) == 'http') $domain = $GLOBALS['SERVER_HOST'];
else $domain .= $GLOBALS['SERVER_HOST'];
}
else $domain .= $_SERVER['SERVER_NAME'];
if($_SERVER['SERVER_PORT'] && $_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443 && !strpos($domain, ':'.$_SERVER['SERVER_PORT'])){
$domain .= ':'.$_SERVER['SERVER_PORT'];
}
$domain = filter_var($domain, FILTER_SANITIZE_URL);
return $domain;
}

public static function getRightsHtml($inputStr){
$rightsOutput = '';
if($inputStr){
$inputStr = htmlspecialchars($inputStr, ENT_COMPAT | ENT_HTML401 | ENT_SUBSTITUTE);
//Use input as default value
$rightsOutput = $inputStr;
//Replace with badget if input as a creative commons URL
$path = 'https://mirrors.creativecommons.org/presskit/buttons/88x31/png/';
$ccBadgeArr = array(
'/by-nc/' => 'by-nd.png',
'/by-sa/' => 'by-sa.png',
'/by-nc-sa/' => 'by-nc-sa.png',
'/by/' => 'by.png',
'/zero/' => 'cc-zero.png'
);
foreach($ccBadgeArr as $fragment => $fileName){
if(strpos($inputStr, $fragment)){
$rightsOutput = '<img src="' . $path . $fileName . '">';
}
}
//If input is a URL, make output a clickable link
if(substr($inputStr, 0, 4) == 'http'){
$rightsOutput = '<a href="' . $inputStr . '" target="_blank">' . $rightsOutput . '</a>';
}
}
$rightsOutput = '<span class="rights-span">' . $rightsOutput . '</span>';
return $rightsOutput;
}
}
Loading

0 comments on commit 532fbf1

Please sign in to comment.