tethys/app/Helpers/utils.php

29 lines
804 B
PHP
Raw Normal View History

2018-11-21 12:40:34 +00:00
<?php
/**
* Get an associative array with localeCodes as keys and translated URLs of current page as value
*/
2018-11-21 12:40:34 +00:00
function getLocalizedURLArray()
{
$localesOrdered = LaravelLocalization::getLocalesOrder();
$localizedURLs = array();
foreach ($localesOrdered as $localeCode => $properties) {
$localizedURLs[$localeCode] = LaravelLocalization::getLocalizedURL($localeCode, null, [], true);
}
return $localizedURLs;
}
function get_domain($host)
{
$myhost = strtolower(trim($host));
$count = substr_count($myhost, '.');
if ($count === 2) {
if (strlen(explode('.', $myhost)[1]) > 3) {
$myhost = explode('.', $myhost, 2)[1];
}
} else if ($count > 2) {
$myhost = get_domain(explode('.', $myhost, 2)[1]);
}
return $myhost;
}