forked from yireo-joomla/plg_system_languagedomains
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
2,177 additions
and
12 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
build/tmp | ||
source/.idea | ||
.idea |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
<?php | ||
/** | ||
* Joomla! System plugin - Language 2 Domain | ||
* Originally developed by Jisse Reitsma, https://yireo.com | ||
* Modified by Peter Martin, https://db8.nl | ||
* | ||
* @author Yireo <[email protected]> | ||
* @author Peter Martin <[email protected]> | ||
* @copyright Copyright 2016 Yireo.com. All rights reserved | ||
* @license GNU Public License | ||
* @link https://db8.nl | ||
*/ | ||
|
||
use Joomla\CMS\Factory; | ||
use Joomla\CMS\Uri\Uri; | ||
use Joomla\CMS\Version; | ||
|
||
defined('_JEXEC') or die; | ||
|
||
/** | ||
* Class PlgSystemLanguage2DomainHelper | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
class PlgSystemLanguage2DomainHelper | ||
{ | ||
/** | ||
* Method to detect whether Falang is active or not | ||
* | ||
* @return boolean | ||
* @since 1.0.0 | ||
*/ | ||
public function isFalangDatabaseDriver() | ||
{ | ||
$db = Factory::getDbo(); | ||
|
||
if ($db instanceof JFalangDatabase) | ||
{ | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
/** | ||
* Helper-method to get a proper URL from the domain | ||
* | ||
* @param string $url URL to obtain the domain from | ||
* | ||
* @return string | ||
* @since 1.0.0 | ||
*/ | ||
public function getDomainFromUrl($url) | ||
{ | ||
// Add URL-elements to the domain | ||
if (preg_match('/^(http|https):\/\/([a-zA-Z0-9\.\-\_]+)/', $url, $match)) | ||
{ | ||
$domain = $match[2]; | ||
|
||
return $domain; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
/** | ||
* Helper-method to get a proper URL from the domain | ||
* | ||
* @param string $domain Domain to obtain the URL from | ||
* | ||
* @return string | ||
* @since 1.0.0 | ||
*/ | ||
public function getUrlFromDomain($domain) | ||
{ | ||
// Add URL-elements to the domain | ||
if (preg_match('/^(http|https):\/\//', $domain) == false) | ||
{ | ||
$domain = ($this->isSSL()) ? 'https://' . $domain : 'http://' . $domain; | ||
} | ||
|
||
if (preg_match('/\/$/', $domain) == false) | ||
{ | ||
$domain = $domain . '/'; | ||
} | ||
|
||
$config = Factory::getConfig(); | ||
|
||
if ($config->get('sef_rewrite', 0) == 0 && preg_match('/index\.php/', $domain) == false) | ||
{ | ||
$domain = $domain . 'index.php/'; | ||
} | ||
|
||
return $domain; | ||
} | ||
|
||
/** | ||
* Method to override certain Joomla classes | ||
* | ||
* @return void | ||
* @since 1.0.0 | ||
*/ | ||
public function overrideClasses() | ||
{ | ||
JLoader::import('joomla.version'); | ||
$version = new Version; | ||
$majorVersion = $version->getShortVersion(); | ||
|
||
if (version_compare($majorVersion, '3.2', 'ge')) | ||
{ | ||
require_once JPATH_SITE . '/plugins/system/language2domain/rewrite-32/associations.php'; | ||
require_once JPATH_SITE . '/plugins/system/language2domain/rewrite-32/multilang.php'; | ||
} | ||
} | ||
|
||
/** | ||
* Reset the current language (with $%& VirtueMart support) | ||
* | ||
* @return void | ||
* @since 1.0.0 | ||
*/ | ||
public function resetDefaultLanguage() | ||
{ | ||
if (!class_exists('VmConfig')) | ||
{ | ||
$vmConfigFile = JPATH_ROOT . '/administrator/components/com_virtuemart/helpers/config.php'; | ||
|
||
if (file_exists($vmConfigFile)) | ||
{ | ||
defined('DS') or define('DS', DIRECTORY_SEPARATOR); | ||
|
||
include_once $vmConfigFile; | ||
} | ||
} | ||
|
||
if (class_exists('VmConfig')) | ||
{ | ||
VmConfig::loadConfig(); | ||
VmConfig::$vmlang = false; | ||
VmConfig::setdbLanguageTag(); | ||
} | ||
} | ||
|
||
/** | ||
* Helper-method to check whether SSL is active or not | ||
* | ||
* @return boolean | ||
* @since 1.0.0 | ||
*/ | ||
protected function isSSL() | ||
{ | ||
// Support for proxy headers | ||
if (isset($_SERVER['X-FORWARDED-PROTO'])) | ||
{ | ||
if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') | ||
{ | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
$uri = Uri::getInstance(); | ||
|
||
return (bool) $uri->isSSL(); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/plugins/system/language2domain/language/en-GB/en-GB.plg_system_language2domain.ini
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
; Language2Domain - System Plugin | ||
; License GNU General Public License version 2 or later; see LICENSE.txt | ||
; Note : All ini files need to be saved as UTF-8 | ||
|
||
PLG_SYSTEM_LANGUAGE2DOMAIN="System - Language2Domain" | ||
PLG_SYSTEM_LANGUAGE2DOMAIN_DESC="For multilingual Joomla Websites to associate Languages with Domains" | ||
|
||
PLG_SYSTEM_LANGUAGE2DOMAIN_FIELD_BINDINGS_LABEL="Bindings" | ||
PLG_SYSTEM_LANGUAGE2DOMAIN_FIELD_BINDINGS_DESC="List of language-code versus domain. Each record on a new line. Language and domain separated by equal-sign. e.g.: en-GB=example.co.uk and nl-NL=example.nl" | ||
PLG_SYSTEM_LANGUAGE2DOMAIN_FIELD_ENFORCE_DOMAINS_LABEL="Enforce domains" | ||
PLG_SYSTEM_LANGUAGE2DOMAIN_FIELD_ENFORCE_DOMAINS_DESC="Make sure current domain matches one of the domains configured here" | ||
PLG_SYSTEM_LANGUAGE2DOMAIN_FIELD_EXCLUDE_COMPONENTS_LABEL="Exclude Components" | ||
PLG_SYSTEM_LANGUAGE2DOMAIN_FIELD_EXCLUDE_COMPONENTS_DESC="Comma-separated list of components that should be just served from current domain" | ||
PLG_SYSTEM_LANGUAGE2DOMAIN_FIELD_EXCLUDE_URLS_LABEL="Exclude URLS" | ||
PLG_SYSTEM_LANGUAGE2DOMAIN_FIELD_EXCLUDE_URLS_DESC="Comma-separated list of URLs that should be just served from current domain" | ||
PLG_SYSTEM_LANGUAGE2DOMAIN_FIELD_LOAD_BUILDRULE_LABEL="Load Build Rule" | ||
PLG_SYSTEM_LANGUAGE2DOMAIN_FIELD_LOAD_BUILDRULE_DESC="Only enable this, if you are using Falang and you want to see whether this works or not" | ||
PLG_SYSTEM_LANGUAGE2DOMAIN_FIELD_DEBUG_LABEL="Debug" | ||
PLG_SYSTEM_LANGUAGE2DOMAIN_FIELD_DEBUG_DESC="Add debugging messages to JS console" | ||
|
||
PLG_SYSTEM_LANGUAGEFILTER_FIELD_ITEM_ASSOCIATIONS_LABEL="Item associations" | ||
PLG_SYSTEM_LANGUAGEFILTER_FIELD_ITEM_ASSOCIATIONS_DESC="This option will allow item associations when switching from one language to another" | ||
PLG_SYSTEM_LANGUAGEFILTER_FIELD_ALTERNATE_META_LABEL="Add alternate meta tags" | ||
PLG_SYSTEM_LANGUAGEFILTER_FIELD_ALTERNATE_META_DESC="Add alternate meta tags for items with associated items in other languages." | ||
|
||
JIGNORE="Ignore" |
6 changes: 6 additions & 0 deletions
6
src/plugins/system/language2domain/language/en-GB/en-GB.plg_system_language2domain.sys.ini
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
; Language2Domain - System Plugin | ||
; License GNU General Public License version 2 or later; see LICENSE.txt | ||
; Note : All ini files need to be saved as UTF-8 | ||
|
||
PLG_SYSTEM_LANGUAGE2DOMAIN="System - Language2Domain" | ||
PLG_SYSTEM_LANGUAGE2DOMAIN_DESC="For multilingual Joomla Websites to associate Languages with Domains" |
Oops, something went wrong.