Initial commit
This commit is contained in:
commit
6b5a84dfa4
33 changed files with 1535 additions and 0 deletions
51
core/functions.php
Normal file
51
core/functions.php
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
function kcal2kj(int $kcal)
|
||||
{
|
||||
return $kcal * 4.1868;
|
||||
}
|
||||
|
||||
function is_https(){
|
||||
return !empty($_SERVER['HTTPS']) &&
|
||||
(strtolower($_SERVER['HTTPS']) == 'on' ||
|
||||
$_SERVER['HTTPS'] == '1');
|
||||
}
|
||||
|
||||
function base_url()
|
||||
{
|
||||
$protocol = is_https() ? 'https://' : 'http://';
|
||||
$server = $_SERVER['SERVER_NAME'];
|
||||
//$port = $_SERVER['SERVER_PORT'] ? ':'.$_SERVER['SERVER_PORT'] : '';
|
||||
return $protocol.$server;
|
||||
}
|
||||
|
||||
function resource_url()
|
||||
{
|
||||
return base_url() . dirname($_SERVER['PHP_SELF'])."/";;
|
||||
}
|
||||
|
||||
function current_url($lang, $parameters){
|
||||
return resource_url() . $lang . "/" . $parameters;
|
||||
}
|
||||
|
||||
{
|
||||
$protocol = is_https() ? 'https://' : 'http://';
|
||||
$server = $_SERVER['SERVER_NAME'];
|
||||
//$port = $_SERVER['SERVER_PORT'] ? ':'.$_SERVER['SERVER_PORT'] : '';
|
||||
return $protocol.$server;
|
||||
}
|
||||
|
||||
|
||||
function translate_and_format($translation, $ingredient)
|
||||
{
|
||||
$ingredient_id = $ingredient->id;
|
||||
$tranlated = $translation->$ingredient_id;
|
||||
|
||||
$is_allergen = isset($ingredient->allergen) ? $ingredient->allergen : false;
|
||||
if ($is_allergen) {
|
||||
$format = '<strong>%s</strong>';
|
||||
$tranlated = sprintf($format, $tranlated);
|
||||
}
|
||||
return $tranlated;
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue