forked from egbot/Symbiota
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 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
Showing
16 changed files
with
2,831 additions
and
231 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,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; | ||
} | ||
} |
Oops, something went wrong.