51 lines
1.2 KiB
PHP
51 lines
1.2 KiB
PHP
<?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;
|
|
}
|
|
|
|
?>
|