Skip to content

armgit / Vvveb

Public Imported from GitHub
0

Powerful and easy to use cms to build websites, blogs or ecommerce stores.

Href lang urls changed to absolute url

givanz3f72491b80af
diff --git a/app/component/language.php b/app/component/language.php
index e1e815a..dd5ceed 100755
--- a/app/component/language.php
+++ b/app/component/language.php
@@ -24,6 +24,7 @@ namespace Vvveb\Component;
use function Vvveb\availableLanguages;
use function Vvveb\getCurrentUrl;
+use function Vvveb\isSecure;
use Vvveb\Sql\LanguageSQL;
use Vvveb\System\Cache;
use Vvveb\System\Component\ComponentBase;
@@ -85,6 +86,8 @@ class Language extends ComponentBase {
$hreflang = [];
+ $scheme = isSecure() ? 'https' : 'http';
+
foreach ($results['language'] as $code => &$language) {
$shortcode = \Vvveb\filter('/[a-z]+/',$code);
$content = [];
@@ -105,8 +108,9 @@ class Language extends ComponentBase {
//$url = getCurrentUrl();
if (true/* && $options['default'] != $code*/) {
- $url = url($request->get['route'] ?? '', $lang + $content + $get, false); //"/$shortcode" . getCurrentUrl();
- $hreflang[$code] = $url;
+ $params = $lang + $content + $get + ['host' => $_SERVER['HTTP_HOST'] ?? '', 'scheme' => $scheme];
+ $url = url($request->get['route'] ?? '', $params, false); //"/$shortcode" . getCurrentUrl();
+ $hreflang[$shortcode] = $url;
}
$language['url'] = $url;
diff --git a/system/functions.php b/system/functions.php
index 6fe1232..72d31ec 100755
--- a/system/functions.php
+++ b/system/functions.php
@@ -1483,3 +1483,9 @@ function globBrace($path, $glob, $filename = '') {
return $files;
}
+
+function isSecure() {
+ return
+ (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off')
+ || $_SERVER['SERVER_PORT'] == 443;
+}