mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-08 03:01:43 +09:00
Update domains schema and improve default domain handling
This commit is contained in:
parent
4257edf7fa
commit
03087aa7ba
6 changed files with 90 additions and 14 deletions
|
|
@ -19,12 +19,13 @@ class module extends ModuleObject
|
||||||
$oDB->addIndex("modules","idx_site_mid", array("site_srl","mid"), true);
|
$oDB->addIndex("modules","idx_site_mid", array("site_srl","mid"), true);
|
||||||
|
|
||||||
// Insert new domain
|
// Insert new domain
|
||||||
if(!getModel('module')->getSiteInfo(0))
|
if(!getModel('module')->getDefaultDomainInfo())
|
||||||
{
|
{
|
||||||
$current_url = Rhymix\Framework\Url::getCurrentUrl();
|
$current_url = Rhymix\Framework\Url::getCurrentUrl();
|
||||||
$domain = new stdClass();
|
$domain = new stdClass();
|
||||||
$domain->domain_srl = 0;
|
$domain->domain_srl = 0;
|
||||||
$domain->domain = Rhymix\Framework\URL::getDomainFromURL($current_url);
|
$domain->domain = Rhymix\Framework\URL::getDomainFromURL($current_url);
|
||||||
|
$domain->is_default_domain = 'Y';
|
||||||
$domain->index_module_srl = 0;
|
$domain->index_module_srl = 0;
|
||||||
$domain->index_document_srl = 0;
|
$domain->index_document_srl = 0;
|
||||||
$domain->http_port = null;
|
$domain->http_port = null;
|
||||||
|
|
@ -92,7 +93,7 @@ class module extends ModuleObject
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check domains
|
// Check domains
|
||||||
if (!$oDB->isTableExists('domains') || !getModel('module')->getSiteInfo(0))
|
if (!$oDB->isTableExists('domains') || !getModel('module')->getDefaultDomainInfo())
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -308,7 +309,7 @@ class module extends ModuleObject
|
||||||
}
|
}
|
||||||
|
|
||||||
// Migrate domains
|
// Migrate domains
|
||||||
if (!getModel('module')->getSiteInfo(0))
|
if (!getModel('module')->getDefaultDomainInfo())
|
||||||
{
|
{
|
||||||
$this->migrateDomains();
|
$this->migrateDomains();
|
||||||
}
|
}
|
||||||
|
|
@ -393,8 +394,13 @@ class module extends ModuleObject
|
||||||
$oDB->createTableByXmlFile($this->module_path . 'schemas/domains.xml');
|
$oDB->createTableByXmlFile($this->module_path . 'schemas/domains.xml');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get current site configuration.
|
||||||
|
$oModuleModel = getModel('module');
|
||||||
|
$config = $oModuleModel->getModuleConfig('module');
|
||||||
|
|
||||||
// Initialize domains data.
|
// Initialize domains data.
|
||||||
$domains = array();
|
$domains = array();
|
||||||
|
$default_domain = new stdClass;
|
||||||
|
|
||||||
// Check XE sites.
|
// Check XE sites.
|
||||||
$output = executeQueryArray('module.getSites');
|
$output = executeQueryArray('module.getSites');
|
||||||
|
|
@ -411,15 +417,26 @@ class module extends ModuleObject
|
||||||
$domain = new stdClass();
|
$domain = new stdClass();
|
||||||
$domain->domain_srl = $site_info->site_srl;
|
$domain->domain_srl = $site_info->site_srl;
|
||||||
$domain->domain = Rhymix\Framework\URL::getDomainFromURL(strtolower($site_domain));
|
$domain->domain = Rhymix\Framework\URL::getDomainFromURL(strtolower($site_domain));
|
||||||
|
$domain->is_default_domain = $site_info->site_srl == 0 ? 'Y' : 'N';
|
||||||
$domain->index_module_srl = $site_info->index_module_srl;
|
$domain->index_module_srl = $site_info->index_module_srl;
|
||||||
$domain->index_document_srl = 0;
|
$domain->index_document_srl = 0;
|
||||||
$domain->http_port = config('url.http_port') ?: null;
|
$domain->http_port = config('url.http_port') ?: null;
|
||||||
$domain->https_port = config('url.https_port') ?: null;
|
$domain->https_port = config('url.https_port') ?: null;
|
||||||
$domain->security = config('url.ssl') ?: 'none';
|
$domain->security = config('url.ssl') ?: 'none';
|
||||||
$domain->description = '';
|
$domain->description = '';
|
||||||
$domain->settings = json_encode(array('language' => $site_info->default_language, 'timezone' => null));
|
$domain->settings = json_encode(array(
|
||||||
|
'title' => $config->siteTitle,
|
||||||
|
'subtitle' => $config->siteSubtitle,
|
||||||
|
'language' => $site_info->default_language,
|
||||||
|
'timezone' => config('locale.default_timezone'),
|
||||||
|
'html_footer' => $config->htmlFooter,
|
||||||
|
));
|
||||||
$domain->regdate = $site_info->regdate;
|
$domain->regdate = $site_info->regdate;
|
||||||
$domains[$domain->domain] = $domain;
|
$domains[$domain->domain] = $domain;
|
||||||
|
if ($domain->is_default_domain === 'Y')
|
||||||
|
{
|
||||||
|
$default_domain = $domain;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -430,14 +447,22 @@ class module extends ModuleObject
|
||||||
$domain = new stdClass();
|
$domain = new stdClass();
|
||||||
$domain->domain_srl = 0;
|
$domain->domain_srl = 0;
|
||||||
$domain->domain = Rhymix\Framework\URL::decodeIdna(strtolower($default_hostinfo['host']));
|
$domain->domain = Rhymix\Framework\URL::decodeIdna(strtolower($default_hostinfo['host']));
|
||||||
|
$domain->is_default_domain = 'Y';
|
||||||
$domain->index_module_srl = $output->data ? $output->data->module_srl : 0;
|
$domain->index_module_srl = $output->data ? $output->data->module_srl : 0;
|
||||||
$domain->index_document_srl = 0;
|
$domain->index_document_srl = 0;
|
||||||
$domain->http_port = isset($default_hostinfo['port']) ? intval($default_hostinfo['port']) : null;
|
$domain->http_port = isset($default_hostinfo['port']) ? intval($default_hostinfo['port']) : null;
|
||||||
$domain->https_port = null;
|
$domain->https_port = null;
|
||||||
$domain->security = config('url.ssl') ?: 'none';
|
$domain->security = config('url.ssl') ?: 'none';
|
||||||
$domain->description = '';
|
$domain->description = '';
|
||||||
$domain->settings = json_encode(array('language' => null, 'timezone' => null));
|
$domain->settings = json_encode(array(
|
||||||
|
'title' => $config->siteTitle,
|
||||||
|
'subtitle' => $config->siteSubtitle,
|
||||||
|
'language' => $site_info->default_language,
|
||||||
|
'timezone' => config('locale.default_timezone'),
|
||||||
|
'html_footer' => $config->htmlFooter,
|
||||||
|
));
|
||||||
$domains[$domain->domain] = $domain;
|
$domains[$domain->domain] = $domain;
|
||||||
|
$default_domain = $domain;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check multidomain module.
|
// Check multidomain module.
|
||||||
|
|
@ -457,15 +482,26 @@ class module extends ModuleObject
|
||||||
$domain = new stdClass();
|
$domain = new stdClass();
|
||||||
$domain->domain_srl = $site_info->multidomain_srl;
|
$domain->domain_srl = $site_info->multidomain_srl;
|
||||||
$domain->domain = Rhymix\Framework\URL::getDomainFromURL(strtolower($site_domain));
|
$domain->domain = Rhymix\Framework\URL::getDomainFromURL(strtolower($site_domain));
|
||||||
|
$domain->is_default_domain = isset($domains[$domain->domain]) ? $domains[$domain->domain]->is_default_domain : 'N';
|
||||||
$domain->index_module_srl = intval($site_info->module_srl);
|
$domain->index_module_srl = intval($site_info->module_srl);
|
||||||
$domain->index_document_srl = intval($site_info->document_srl);
|
$domain->index_document_srl = intval($site_info->document_srl);
|
||||||
$domain->http_port = config('url.http_port') ?: null;
|
$domain->http_port = config('url.http_port') ?: null;
|
||||||
$domain->https_port = config('url.https_port') ?: null;
|
$domain->https_port = config('url.https_port') ?: null;
|
||||||
$domain->security = config('url.ssl') ?: 'none';
|
$domain->security = config('url.ssl') ?: 'none';
|
||||||
$domain->description = '';
|
$domain->description = '';
|
||||||
$domain->settings = json_encode(array('language' => null, 'timezone' => null));
|
$domain->settings = json_encode(array(
|
||||||
|
'title' => $config->siteTitle,
|
||||||
|
'subtitle' => $config->siteSubtitle,
|
||||||
|
'language' => $site_info->default_language,
|
||||||
|
'timezone' => config('locale.default_timezone'),
|
||||||
|
'html_footer' => $config->htmlFooter,
|
||||||
|
));
|
||||||
$domain->regdate = $site_info->regdate;
|
$domain->regdate = $site_info->regdate;
|
||||||
$domains[$domain->domain] = $domain;
|
$domains[$domain->domain] = $domain;
|
||||||
|
if ($domain->is_default_domain === 'Y')
|
||||||
|
{
|
||||||
|
$default_domain = $domain;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -479,6 +515,12 @@ class module extends ModuleObject
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clear cache.
|
||||||
|
Rhymix\Framework\Cache::clearGroup('site_and_module');
|
||||||
|
|
||||||
|
// Return the default domain info.
|
||||||
|
return $default_domain;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -62,12 +62,40 @@ class moduleModel extends module
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get site information
|
* @brief Get default domain information
|
||||||
|
*/
|
||||||
|
function getDefaultDomainInfo()
|
||||||
|
{
|
||||||
|
$domain_info = Rhymix\Framework\Cache::get('site_and_module:domain_info:default');
|
||||||
|
if ($domain_info === null)
|
||||||
|
{
|
||||||
|
$args = new stdClass();
|
||||||
|
$args->is_default_domain = 'Y';
|
||||||
|
$output = executeQuery('module.getDomainInfo', $args);
|
||||||
|
if ($output->data)
|
||||||
|
{
|
||||||
|
$domain_info = $output->data;
|
||||||
|
$domain_info->site_srl = 0;
|
||||||
|
$domain_info->settings = $domain_info->settings ? json_decode($domain_info->settings) : new stdClass;
|
||||||
|
$domain_info->default_language = $domain_info->settings->language ?: config('locale.default_lang');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$domain_info = false;
|
||||||
|
}
|
||||||
|
Rhymix\Framework\Cache::set('site_and_module:domain_info:default', $domain_info, 0, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $domain_info;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get site information by domain_srl
|
||||||
*/
|
*/
|
||||||
function getSiteInfo($domain_srl)
|
function getSiteInfo($domain_srl)
|
||||||
{
|
{
|
||||||
$domain_srl = intval($domain_srl);
|
$domain_srl = intval($domain_srl);
|
||||||
$domain_info = Rhymix\Framework\Cache::get('site_and_module:domain_info:srl_' . $domain_srl);
|
$domain_info = Rhymix\Framework\Cache::get('site_and_module:domain_info:srl:' . $domain_srl);
|
||||||
if ($domain_info === null)
|
if ($domain_info === null)
|
||||||
{
|
{
|
||||||
$args = new stdClass();
|
$args = new stdClass();
|
||||||
|
|
@ -84,12 +112,15 @@ class moduleModel extends module
|
||||||
{
|
{
|
||||||
$domain_info = false;
|
$domain_info = false;
|
||||||
}
|
}
|
||||||
Rhymix\Framework\Cache::set('site_and_module:domain_info:srl_' . $domain_srl, $domain_info, 0, true);
|
Rhymix\Framework\Cache::set('site_and_module:domain_info:srl:' . $domain_srl, $domain_info, 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $domain_info;
|
return $domain_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get site information by domain name
|
||||||
|
*/
|
||||||
function getSiteInfoByDomain($domain)
|
function getSiteInfoByDomain($domain)
|
||||||
{
|
{
|
||||||
if (strpos($domain, '/') !== false)
|
if (strpos($domain, '/') !== false)
|
||||||
|
|
@ -106,7 +137,7 @@ class moduleModel extends module
|
||||||
}
|
}
|
||||||
|
|
||||||
$domain = strtolower($domain);
|
$domain = strtolower($domain);
|
||||||
$domain_info = Rhymix\Framework\Cache::get('site_and_module:domain_info:' . $domain);
|
$domain_info = Rhymix\Framework\Cache::get('site_and_module:domain_info:domain:' . $domain);
|
||||||
if ($domain_info === null)
|
if ($domain_info === null)
|
||||||
{
|
{
|
||||||
$args = new stdClass();
|
$args = new stdClass();
|
||||||
|
|
@ -123,7 +154,7 @@ class moduleModel extends module
|
||||||
{
|
{
|
||||||
$domain_info = false;
|
$domain_info = false;
|
||||||
}
|
}
|
||||||
Rhymix\Framework\Cache::set('site_and_module:domain_info:' . $domain, $domain_info, 0, true);
|
Rhymix\Framework\Cache::set('site_and_module:domain_info:domain:' . $domain, $domain_info, 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $domain_info;
|
return $domain_info;
|
||||||
|
|
@ -154,11 +185,10 @@ class moduleModel extends module
|
||||||
$domain_info = $this->getSiteInfoByDomain($domain);
|
$domain_info = $this->getSiteInfoByDomain($domain);
|
||||||
if (!$domain_info)
|
if (!$domain_info)
|
||||||
{
|
{
|
||||||
$domain_info = $this->getSiteInfo(0);
|
$domain_info = $this->getDefaultDomainInfo();
|
||||||
if (!$domain_info)
|
if (!$domain_info)
|
||||||
{
|
{
|
||||||
$this->migrateDomains();
|
$domain_info = $this->migrateDomains();
|
||||||
return $this->getDefaultMid();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,5 +11,6 @@
|
||||||
<condition operation="equal" column="modules.module_srl" default="domains.index_module_srl" notnull="notnull" />
|
<condition operation="equal" column="modules.module_srl" default="domains.index_module_srl" notnull="notnull" />
|
||||||
<condition operation="equal" column="domain_srl" var="domain_srl" pipe="and" />
|
<condition operation="equal" column="domain_srl" var="domain_srl" pipe="and" />
|
||||||
<condition operation="equal" column="domain" var="domain" pipe="and" />
|
<condition operation="equal" column="domain" var="domain" pipe="and" />
|
||||||
|
<condition operation="equal" column="is_default_domain" var="is_default_domain" pipe="and" />
|
||||||
</conditions>
|
</conditions>
|
||||||
</query>
|
</query>
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
<columns>
|
<columns>
|
||||||
<column name="domain_srl" var="domain_srl" notnull="notnull" filter="number" />
|
<column name="domain_srl" var="domain_srl" notnull="notnull" filter="number" />
|
||||||
<column name="domain" var="domain" notnull="notnull" />
|
<column name="domain" var="domain" notnull="notnull" />
|
||||||
|
<column name="is_default_domain" var="is_default_domain" notnull="notnull" default="N" />
|
||||||
<column name="index_module_srl" var="index_module_srl" notnull="notnull" />
|
<column name="index_module_srl" var="index_module_srl" notnull="notnull" />
|
||||||
<column name="index_document_srl" var="index_document_srl" notnull="notnull" />
|
<column name="index_document_srl" var="index_document_srl" notnull="notnull" />
|
||||||
<column name="default_layout_srl" var="default_layout_srl" notnull="notnull" default="0" />
|
<column name="default_layout_srl" var="default_layout_srl" notnull="notnull" default="0" />
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
</tables>
|
</tables>
|
||||||
<columns>
|
<columns>
|
||||||
<column name="domain" var="domain" />
|
<column name="domain" var="domain" />
|
||||||
|
<column name="is_default_domain" var="is_default_domain" />
|
||||||
<column name="index_module_srl" var="index_module_srl" />
|
<column name="index_module_srl" var="index_module_srl" />
|
||||||
<column name="index_document_srl" var="index_document_srl" />
|
<column name="index_document_srl" var="index_document_srl" />
|
||||||
<column name="default_layout_srl" var="default_layout_srl" />
|
<column name="default_layout_srl" var="default_layout_srl" />
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
<table name="domains">
|
<table name="domains">
|
||||||
<column name="domain_srl" type="number" notnull="notnull" primary_key="primary_key" />
|
<column name="domain_srl" type="number" notnull="notnull" primary_key="primary_key" />
|
||||||
<column name="domain" type="varchar" size="80" notnull="notnull" index="idx_domain" />
|
<column name="domain" type="varchar" size="80" notnull="notnull" index="idx_domain" />
|
||||||
|
<column name="is_default_domain" type="char" size="1" notnull="notnull" default="N" index="idx_is_default_domain" />
|
||||||
<column name="index_module_srl" type="number" notnull="notnull" index="idx_index_module_srl" />
|
<column name="index_module_srl" type="number" notnull="notnull" index="idx_index_module_srl" />
|
||||||
<column name="index_document_srl" type="number" notnull="notnull" index="idx_index_document_srl" />
|
<column name="index_document_srl" type="number" notnull="notnull" index="idx_index_document_srl" />
|
||||||
<column name="default_layout_srl" type="number" notnull="notnull" default="0" />
|
<column name="default_layout_srl" type="number" notnull="notnull" default="0" />
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue