mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-05 19:42:38 +02:00
This commit is contained in:
parent
e9c180457a
commit
865a7a4d91
14 changed files with 113 additions and 70 deletions
|
@ -320,7 +320,7 @@ class Layout extends PluginAbstract {
|
||||||
}else{
|
}else{
|
||||||
$selectedJsonIcon = '';
|
$selectedJsonIcon = '';
|
||||||
}
|
}
|
||||||
$code = "<script>function getLangSelectformatStateResult (state) {
|
$code = "<script>/*selected={$selected}*/function getLangSelectformatStateResult (state) {
|
||||||
if (!state.id) {
|
if (!state.id) {
|
||||||
return state.text;
|
return state.text;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,10 @@ class User_Location extends PluginAbstract {
|
||||||
public function getEmptyDataObject() {
|
public function getEmptyDataObject() {
|
||||||
$obj = new stdClass();
|
$obj = new stdClass();
|
||||||
$obj->autoChangeLanguage = true;
|
$obj->autoChangeLanguage = true;
|
||||||
|
$o = new stdClass();
|
||||||
|
$o->type = array('browser'=>__("Detect language from Browser"), 'ip'=>__("Detect language from IP"));
|
||||||
|
$o->value = 'browser';
|
||||||
|
$obj->useLanguageFrom = $o;
|
||||||
return $obj;
|
return $obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,25 +74,63 @@ class User_Location extends PluginAbstract {
|
||||||
|
|
||||||
static function getLocationFromIP($ip) {
|
static function getLocationFromIP($ip) {
|
||||||
return IP2Location::getLocation($ip);
|
return IP2Location::getLocation($ip);
|
||||||
|
}
|
||||||
|
|
||||||
|
static function getLanguageFromBrowser() {
|
||||||
|
if(empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$parts = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
||||||
|
return str_replace('-', '_', $parts[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static function setLanguage($lang) {
|
||||||
|
global $global;
|
||||||
|
$file = "{$global['systemRootPath']}locale/{$lang}.php";
|
||||||
|
_session_start();
|
||||||
|
if(file_exists($file)){
|
||||||
|
$_SESSION['language'] = $lang;
|
||||||
|
include_once $file;
|
||||||
|
return true;
|
||||||
|
}else{
|
||||||
|
$lang = strtolower($lang);
|
||||||
|
$file = "{$global['systemRootPath']}locale/{$lang}.php";
|
||||||
|
if(file_exists($file)){
|
||||||
|
$_SESSION['language'] = $lang;
|
||||||
|
include_once $file;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static function setLanguageFromBrowser() {
|
||||||
|
return self::setLanguage(self::getLanguageFromBrowser());
|
||||||
|
}
|
||||||
|
|
||||||
|
static function setLanguageFromIP() {
|
||||||
|
$User_Location = self::getThisUserLocation();
|
||||||
|
return self::setLanguage($User_Location['country_code']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStart() {
|
public function getStart() {
|
||||||
global $global, $config;
|
global $global, $config;
|
||||||
$obj = $this->getDataObject();
|
$obj = $this->getDataObject();
|
||||||
$User_Location = self::getThisUserLocation();
|
$User_Location = self::getThisUserLocation();
|
||||||
if (session_status() == PHP_SESSION_NONE) {
|
|
||||||
session_start();
|
|
||||||
}
|
|
||||||
if($obj->autoChangeLanguage){
|
if($obj->autoChangeLanguage){
|
||||||
$location = self::getSessionLocation();
|
if($obj->useLanguageFrom->value=='browser'){
|
||||||
if(empty($location) && !empty($User_Location['country_code'])){
|
$changed = self::setLanguageFromBrowser();
|
||||||
$_SESSION['language'] = strtolower($User_Location['country_code']);
|
if(!$changed){
|
||||||
$file = "{$global['systemRootPath']}locale/{$_SESSION['language']}.php";
|
$changed = self::setLanguageFromIP();
|
||||||
if(file_exists($file)){
|
|
||||||
include_once $file;
|
|
||||||
}else{
|
|
||||||
$_SESSION['language'] = $config->getLanguage();
|
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
$changed = self::setLanguageFromIP();
|
||||||
|
if(!$changed){
|
||||||
|
$changed = self::setLanguageFromBrowser();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!$changed){
|
||||||
|
$_SESSION['language'] = $config->getLanguage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$global['User_Location'] = $User_Location;
|
$global['User_Location'] = $User_Location;
|
||||||
|
|
18
vendor/composer/installed.json
vendored
18
vendor/composer/installed.json
vendored
|
@ -2298,7 +2298,7 @@
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=7.2.5"
|
"php": ">=7.3"
|
||||||
},
|
},
|
||||||
"time": "2021-03-05T17:36:06+00:00",
|
"time": "2021-03-05T17:36:06+00:00",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
|
@ -3490,7 +3490,7 @@
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=7.2.5",
|
"php": ">=7.3",
|
||||||
"psr/log": "^1|^2|^3",
|
"psr/log": "^1|^2|^3",
|
||||||
"symfony/deprecation-contracts": "^2.1",
|
"symfony/deprecation-contracts": "^2.1",
|
||||||
"symfony/http-client-contracts": "^2.4",
|
"symfony/http-client-contracts": "^2.4",
|
||||||
|
@ -3580,7 +3580,7 @@
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=7.2.5"
|
"php": ">=7.3"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"symfony/http-client-implementation": ""
|
"symfony/http-client-implementation": ""
|
||||||
|
@ -3661,7 +3661,7 @@
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=7.2.5",
|
"php": ">=7.3",
|
||||||
"symfony/deprecation-contracts": "^2.1",
|
"symfony/deprecation-contracts": "^2.1",
|
||||||
"symfony/polyfill-mbstring": "~1.1",
|
"symfony/polyfill-mbstring": "~1.1",
|
||||||
"symfony/polyfill-php80": "^1.16"
|
"symfony/polyfill-php80": "^1.16"
|
||||||
|
@ -3737,7 +3737,7 @@
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=7.2.5",
|
"php": ">=7.3",
|
||||||
"symfony/deprecation-contracts": "^2.1",
|
"symfony/deprecation-contracts": "^2.1",
|
||||||
"symfony/polyfill-php73": "~1.0",
|
"symfony/polyfill-php73": "~1.0",
|
||||||
"symfony/polyfill-php80": "^1.16"
|
"symfony/polyfill-php80": "^1.16"
|
||||||
|
@ -4316,7 +4316,7 @@
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=7.2.5",
|
"php": ">=7.3",
|
||||||
"symfony/deprecation-contracts": "^2.1",
|
"symfony/deprecation-contracts": "^2.1",
|
||||||
"symfony/polyfill-php80": "^1.16"
|
"symfony/polyfill-php80": "^1.16"
|
||||||
},
|
},
|
||||||
|
@ -4409,7 +4409,7 @@
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=7.2.5",
|
"php": ">=7.3",
|
||||||
"psr/container": "^1.1"
|
"psr/container": "^1.1"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
|
@ -4491,7 +4491,7 @@
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=7.2.5",
|
"php": ">=7.3",
|
||||||
"symfony/deprecation-contracts": "^2.1",
|
"symfony/deprecation-contracts": "^2.1",
|
||||||
"symfony/polyfill-mbstring": "~1.0",
|
"symfony/polyfill-mbstring": "~1.0",
|
||||||
"symfony/polyfill-php80": "^1.16",
|
"symfony/polyfill-php80": "^1.16",
|
||||||
|
@ -4589,7 +4589,7 @@
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=7.2.5"
|
"php": ">=7.3"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"symfony/translation-implementation": ""
|
"symfony/translation-implementation": ""
|
||||||
|
|
2
vendor/psr/container/composer.json
vendored
2
vendor/psr/container/composer.json
vendored
|
@ -12,7 +12,7 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=7.2.5"
|
"php": ">=7.3"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=7.2.5"
|
"php": ">=7.3"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"symfony/http-client-implementation": ""
|
"symfony/http-client-implementation": ""
|
||||||
|
|
2
vendor/symfony/http-client/composer.json
vendored
2
vendor/symfony/http-client/composer.json
vendored
|
@ -21,7 +21,7 @@
|
||||||
"symfony/http-client-implementation": "2.4"
|
"symfony/http-client-implementation": "2.4"
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=7.2.5",
|
"php": ">=7.3",
|
||||||
"psr/log": "^1|^2|^3",
|
"psr/log": "^1|^2|^3",
|
||||||
"symfony/deprecation-contracts": "^2.1",
|
"symfony/deprecation-contracts": "^2.1",
|
||||||
"symfony/http-client-contracts": "^2.4",
|
"symfony/http-client-contracts": "^2.4",
|
||||||
|
|
80
vendor/symfony/http-foundation/composer.json
vendored
80
vendor/symfony/http-foundation/composer.json
vendored
|
@ -1,40 +1,40 @@
|
||||||
{
|
{
|
||||||
"name": "symfony/http-foundation",
|
"name": "symfony/http-foundation",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"description": "Defines an object-oriented layer for the HTTP specification",
|
"description": "Defines an object-oriented layer for the HTTP specification",
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"homepage": "https://symfony.com",
|
"homepage": "https://symfony.com",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
"name": "Fabien Potencier",
|
"name": "Fabien Potencier",
|
||||||
"email": "fabien@symfony.com"
|
"email": "fabien@symfony.com"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Symfony Community",
|
"name": "Symfony Community",
|
||||||
"homepage": "https://symfony.com/contributors"
|
"homepage": "https://symfony.com/contributors"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=7.2.5",
|
"php": ">=7.3",
|
||||||
"symfony/deprecation-contracts": "^2.1",
|
"symfony/deprecation-contracts": "^2.1",
|
||||||
"symfony/polyfill-mbstring": "~1.1",
|
"symfony/polyfill-mbstring": "~1.1",
|
||||||
"symfony/polyfill-php80": "^1.16"
|
"symfony/polyfill-php80": "^1.16"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"predis/predis": "~1.0",
|
"predis/predis": "~1.0",
|
||||||
"symfony/cache": "^4.4|^5.0",
|
"symfony/cache": "^4.4|^5.0",
|
||||||
"symfony/mime": "^4.4|^5.0",
|
"symfony/mime": "^4.4|^5.0",
|
||||||
"symfony/expression-language": "^4.4|^5.0"
|
"symfony/expression-language": "^4.4|^5.0"
|
||||||
},
|
},
|
||||||
"suggest" : {
|
"suggest" : {
|
||||||
"symfony/mime": "To use the file extension guesser"
|
"symfony/mime": "To use the file extension guesser"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": { "Symfony\\Component\\HttpFoundation\\": "" },
|
"psr-4": { "Symfony\\Component\\HttpFoundation\\": "" },
|
||||||
"exclude-from-classmap": [
|
"exclude-from-classmap": [
|
||||||
"/Tests/"
|
"/Tests/"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"minimum-stability": "dev"
|
"minimum-stability": "dev"
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=7.2.5",
|
"php": ">=7.3",
|
||||||
"symfony/deprecation-contracts": "^2.1",
|
"symfony/deprecation-contracts": "^2.1",
|
||||||
"symfony/polyfill-php73": "~1.0",
|
"symfony/polyfill-php73": "~1.0",
|
||||||
"symfony/polyfill-php80": "^1.16"
|
"symfony/polyfill-php80": "^1.16"
|
||||||
|
|
2
vendor/symfony/routing/composer.json
vendored
2
vendor/symfony/routing/composer.json
vendored
|
@ -16,7 +16,7 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=7.2.5",
|
"php": ">=7.3",
|
||||||
"symfony/deprecation-contracts": "^2.1",
|
"symfony/deprecation-contracts": "^2.1",
|
||||||
"symfony/polyfill-php80": "^1.16"
|
"symfony/polyfill-php80": "^1.16"
|
||||||
},
|
},
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=7.2.5",
|
"php": ">=7.3",
|
||||||
"psr/container": "^1.1"
|
"psr/container": "^1.1"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=7.2.5"
|
"php": ">=7.3"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"symfony/translation-implementation": ""
|
"symfony/translation-implementation": ""
|
||||||
|
|
2
vendor/symfony/translation/composer.json
vendored
2
vendor/symfony/translation/composer.json
vendored
|
@ -16,7 +16,7 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=7.2.5",
|
"php": ">=7.3",
|
||||||
"symfony/deprecation-contracts": "^2.1",
|
"symfony/deprecation-contracts": "^2.1",
|
||||||
"symfony/polyfill-mbstring": "~1.0",
|
"symfony/polyfill-mbstring": "~1.0",
|
||||||
"symfony/polyfill-php80": "^1.16",
|
"symfony/polyfill-php80": "^1.16",
|
||||||
|
|
BIN
view/img/audio_wave_portrait.png
Normal file
BIN
view/img/audio_wave_portrait.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 42 KiB |
|
@ -545,7 +545,8 @@ if (!User::isLogged() && !empty($advancedCustomUser->userMustBeLoggedIn) && !emp
|
||||||
if ($lang == 'en') {
|
if ($lang == 'en') {
|
||||||
$lang = 'en_US';
|
$lang = 'en_US';
|
||||||
}
|
}
|
||||||
echo Layout::getLangsSelect('navBarFlag', $lang, 'navBarFlag', '', true);
|
echo Layout::getLangsSelect('navBarFlag', $lang, 'navBarFlag', '', true);
|
||||||
|
//var_dump($lang);exit;
|
||||||
?>
|
?>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue