Last active
August 29, 2018 15:42
-
-
Save stranger777/b3ffa367d310ee8307adeb709c61bf54 to your computer and use it in GitHub Desktop.
PHP code example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
interface iUserLocaleInstallerSettings | |
{ | |
public function getInstallationSiteURL(); | |
} | |
class RussianInstallation implements iUserLocaleInstallerSettings | |
{ | |
public function getInstallationSiteURL() | |
{ | |
return "https://www.1c-bitrix.ru/"; | |
} | |
} | |
class NonRussianInstallation implements iUserLocaleInstallerSettings | |
{ | |
public function getInstallationSiteURL() | |
{ | |
return "http://www.bitrixsoft.com/"; | |
} | |
} | |
class Installer | |
{ | |
public function getLang() | |
{ | |
$tmp = explode("_", Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE'])); | |
return $tmp[0]; | |
} | |
} | |
// | |
$Inst = new Installer(); | |
if (in_array($Inst->getLang(), array( | |
"by", | |
"ru", | |
"ua" | |
))) | |
{ | |
$Installation = new RussianInstallation(); | |
echo "No, we are russians... " . $Installation->getInstallationSiteURL(); | |
} | |
else if (in_array($Inst->getLang(), array( | |
"en", | |
"de" | |
))) | |
{ | |
$Installation = new NonRussianInstallation(); | |
echo "Detect English Installation Server: " . $Installation->getInstallationSiteURL(); | |
} | |
else | |
{ | |
$Installation = new NonRussianInstallation(); | |
echo "Other countries Installation Server: " . $Installation->getInstallationSiteURL(); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment