Implement title, subtitle, and other information for domains

This commit is contained in:
Kijin Sung 2017-03-11 22:48:53 +09:00
parent 2e5ffa7dea
commit 190e9f039e
6 changed files with 153 additions and 30 deletions

View file

@ -958,13 +958,21 @@ class adminAdminController extends admin
$domain_info = null;
if ($domain_srl !== '')
{
$output = executeQuery('module.getDomainInfo', (object)array('domain_srl' => $domain_srl));
if ($output->toBool() && $output->data)
$domain_info = getModel('module')->getSiteInfo($domain_srl);
if ($domain_info->domain_srl != $domain_srl)
{
$domain_info = $output->data;
$domain_info = null;
}
}
// Validate the title and subtitle.
$vars->title = utf8_trim($vars->title);
$vars->subtitle = utf8_trim($vars->subtitle);
if ($vars->title === '')
{
return new Object(-1, 'msg_site_title_is_empty');
}
// Validate the domain.
if (!preg_match('@^https?://@', $vars->domain))
{
@ -1041,6 +1049,25 @@ class adminAdminController extends admin
return new Object(-1, 'msg_lang_is_not_enabled');
}
// Validate the default time zone.
$timezone_list = Rhymix\Framework\DateTime::getTimezoneList();
if (!isset($timezone_list[$vars->default_timezone]))
{
return new Object(-1, 'msg_invalid_timezone');
}
// Clean up the footer script.
$vars->html_footer = utf8_trim($vars->html_footer);
// Merge all settings into an array.
$settings = array(
'title' => $vars->title,
'subtitle' => $vars->subtitle,
'language' => $vars->default_lang,
'timezone' => $vars->default_timezone,
'html_footer' => $vars->html_footer,
);
// Insert or update the domain.
if (!$domain_info)
{
@ -1053,7 +1080,7 @@ class adminAdminController extends admin
$args->https_port = $vars->https_port;
$args->security = $vars->domain_security;
$args->description = '';
$args->settings = json_encode(array('language' => $vars->default_lang, 'timezone' => null));
$args->settings = json_encode($settings);
$output = executeQuery('module.insertDomain', $args);
if (!$output->toBool())
{
@ -1070,7 +1097,7 @@ class adminAdminController extends admin
$args->http_port = $vars->http_port;
$args->https_port = $vars->https_port;
$args->security = $vars->domain_security;
$args->settings = json_encode(array_merge($domain_info->settings, array('language' => $vars->default_lang)));
$args->settings = json_encode(array_merge(get_object_vars($domain_info->settings), $settings));
$output = executeQuery('module.updateDomain', $args);
if (!$output->toBool())
{

View file

@ -811,22 +811,26 @@ class adminAdminModel extends admin
return $output->data->count;
}
function getFaviconUrl($default = true)
function getFaviconUrl($domain_srl = 0)
{
return $this->iconUrlCheck('favicon.ico', 'faviconSample.png', $default);
return $this->iconUrlCheck('favicon.ico', 'faviconSample.png', $domain_srl);
}
function getMobileIconUrl($default = true)
function getMobileIconUrl($domain_srl = 0)
{
return $this->iconUrlCheck('mobicon.png', 'mobiconSample.png', $default);
return $this->iconUrlCheck('mobicon.png', 'mobiconSample.png', $domain_srl);
}
function getSiteDefaultImageUrl(&$width = 0, &$height = 0)
function getSiteDefaultImageUrl($domain_srl = 0, &$width = 0, &$height = 0)
{
$site_info = Context::get('site_module_info');
if ($site_info->site_srl)
$domain_srl = intval($domain_srl);
if (!$domain_srl)
{
$virtual_site = $site_info->site_srl . '/';
$domain_srl = intval(Context::get('site_module_info')->domain_srl);
}
if ($domain_srl)
{
$virtual_site = $domain_srl . '/';
}
else
{
@ -846,17 +850,16 @@ class adminAdminModel extends admin
}
}
function iconUrlCheck($iconname, $default_icon_name, $default)
function iconUrlCheck($iconname, $default_icon_name, $domain_srl)
{
if ($default)
$domain_srl = intval($domain_srl);
if (!$domain_srl)
{
return \RX_BASEURL . 'modules/admin/tpl/img/' . $default_icon_name;
$domain_srl = intval(Context::get('site_module_info')->domain_srl);
}
$site_info = Context::get('site_module_info');
if ($site_info->site_srl)
if ($domain_srl)
{
$virtual_site = $site_info->site_srl . '/';
$virtual_site = $domain_srl . '/';
}
else
{

View file

@ -689,10 +689,10 @@ class adminAdminView extends admin
$domain_info = null;
if ($domain_srl !== '')
{
$output = executeQuery('module.getDomainInfo', (object)array('domain_srl' => $domain_srl));
if ($output->toBool() && $output->data)
$domain_info = getModel('module')->getSiteInfo($domain_srl);
if ($domain_info->domain_srl != $domain_srl)
{
$domain_info = $output->data;
$domain_info = null;
}
}
Context::set('domain_info', $domain_info);
@ -723,6 +723,24 @@ class adminAdminView extends admin
}
Context::set('domain_lang', $domain_lang);
// Get timezone list.
Context::set('timezones', Rhymix\Framework\DateTime::getTimezoneList());
if ($domain_info && $domain_info->settings->timezone)
{
$domain_timezone = $domain_info->settings->timezone;
}
else
{
$domain_timezone = Rhymix\Framework\Config::get('locale.default_timezone');
}
Context::set('domain_timezone', $domain_timezone);
// Get favicon and images.
$oAdminAdminModel = getAdminModel('admin');
Context::set('favicon_url', $oAdminAdminModel->getFaviconUrl($domain_info->domain_srl));
Context::set('mobicon_url', $oAdminAdminModel->getMobileIconUrl($domain_info->domain_srl));
Context::set('default_image_url', $oAdminAdminModel->getSiteDefaultImageUrl($domain_info->domain_srl));
$this->setTemplateFile('config_domains_edit');
}

View file

@ -119,6 +119,7 @@ $lang->cmd_edit_domain = 'Edit Domain';
$lang->about_use_ssl = 'Selecting \'Optional\' is to use SSL for the specified actions such as signing up and changing information.<br />Selecting \'Always\' is to use SSL for the entire pages, generated by Rhymix.<br>Please be careful! You may not be able to access to the site, before installing SSL certificate.';
$lang->server_ports = 'Server Port';
$lang->about_server_ports = 'If your web server does not use 80 for HTTP or 443 for HTTPS port, you should specify server ports.';
$lang->msg_site_title_is_empty = 'Please enter a title for the domain.';
$lang->msg_invalid_domain = 'Invalid domain.';
$lang->msg_domain_already_exists = 'The domain already exists.';
$lang->msg_invalid_http_port = 'Invalid HTTP port.';
@ -126,6 +127,7 @@ $lang->msg_invalid_https_port = 'Invalid HTTPS port.';
$lang->msg_invalid_index_module_srl = 'The main module does not exist.';
$lang->msg_invalid_index_document_srl = 'The main document number does not exist.';
$lang->msg_lang_is_not_enabled = 'The language you selected is not enabled in this site.';
$lang->msg_invalid_timezone = 'The selected time zone is not usable on this server.';
$lang->use_db_session = 'Store Session in DB';
$lang->about_db_session = 'Store PHP sessions in the database. This setting must be turned on if you want to see current users or get detailed statistics.<br>Unnecessary use may decrease server performance.';
$lang->qmail_compatibility = 'Enable Qmail';
@ -235,7 +237,7 @@ $lang->about_use_mobile_view = 'Show mobile page when visitors access with mobil
$lang->tablets_as_mobile = 'Treat Tablets as Mobile';
$lang->thumbnail_type = 'Select thumbnail type.';
$lang->input_footer_script = 'Footer script';
$lang->detail_input_footer_script = 'The script is inserted into the bottom of body. It does not work at admin page.';
$lang->detail_input_footer_script = 'Any content added here will be printed at the bottom of the page, except the admin module.';
$lang->thumbnail_crop = 'Crop';
$lang->thumbnail_ratio = 'Keep aspect ratio (may result in spaces)';
$lang->thumbnail_none = 'Do not create thumbnails';

View file

@ -119,6 +119,7 @@ $lang->cmd_edit_domain = '도메인 정보 수정';
$lang->about_use_ssl = '\'선택적으로 사용\'은 회원가입, 정보수정 등의 지정된 동작(action)에서만 보안접속(HTTPS)을 사용합니다.<br>\'항상 사용\'은 사이트 전체에 HTTPS를 사용합니다.<br>SSL 인증서가 설치되지 않은 상태에서 HTTPS 사용을 시도하면 접속이 되지 않을 수 있으니 주의하시기 바랍니다.';
$lang->server_ports = '포트';
$lang->about_server_ports = 'HTTP는 80, HTTPS는 443 이 아닌, 다른 포트를 사용할 경우에 포트를 지정해 주어야 합니다.';
$lang->msg_site_title_is_empty = '사이트 이름을 입력해 주십시오.';
$lang->msg_invalid_domain = '올바르지 않은 도메인입니다.';
$lang->msg_domain_already_exists = '이미 등록된 도메인입니다.';
$lang->msg_invalid_http_port = '올바르지 않은 HTTP 포트입니다.';
@ -126,6 +127,7 @@ $lang->msg_invalid_https_port = '올바르지 않은 HTTPS 포트입니다.';
$lang->msg_invalid_index_module_srl = '선택하신 메인 모듈이 존재하지 않습니다.';
$lang->msg_invalid_index_document_srl = '선택하신 메인 문서 번호가 존재하지 않습니다.';
$lang->msg_lang_is_not_enabled = '선택하신 언어가 활성화되어 있지 않습니다.';
$lang->msg_invalid_timezone = '사용할 수 없는 표준 시간대입니다.';
$lang->use_db_session = '인증 세션 DB 사용';
$lang->about_db_session = '세션을 DB에 저장합니다. 현재 접속자를 파악하려면 이 기능을 켜야 합니다.<br>불필요하게 사용하면 서버 성능에 악영향을 줄 수 있으니 주의하십시오.';
$lang->qmail_compatibility = '큐메일(Qmail) 사용';
@ -230,7 +232,7 @@ $lang->about_use_mobile_view = '모바일 기기로 접속시 모바일 페이
$lang->tablets_as_mobile = '태블릿도 모바일 취급';
$lang->thumbnail_type = '썸네일 생성 방식';
$lang->input_footer_script = '하단(footer) 스크립트';
$lang->detail_input_footer_script = '최하단에 코드를 삽입합니다. 관리자 페이지에서는 수행되지 않습니다.';
$lang->detail_input_footer_script = '최하단에 코드를 삽입합니다. 관리자 화면에는 적용되지 않습니다.';
$lang->thumbnail_crop = '크기에 맞추어 잘라내기';
$lang->thumbnail_ratio = '비율 유지 (여백이 생길 수 있음)';
$lang->thumbnail_none = '썸네일 생성하지 않음';

View file

@ -9,6 +9,20 @@
<input type="hidden" name="xe_validator_id" value="modules/admin/tpl/config_domains_edit/1" />
<input type="hidden" name="domain_srl" value="{$domain_info ? $domain_info->domain_srl : ''}" />
<div class="x_control-group">
<label class="x_control-label">{$lang->site_title}</label>
<div class="x_controls">
<input type="text" name="title" value="{$domain_info ? escape($domain_info->settings->title) : ''}" class="lang_code" />
</div>
</div>
<div class="x_control-group">
<label class="x_control-label">{$lang->site_subtitle}</label>
<div class="x_controls">
<input type="text" name="subtitle" value="{$domain_info ? escape($domain_info->settings->subtitle) : ''}" class="lang_code" />
</div>
</div>
<div class="x_control-group">
<label class="x_control-label" for="domain">{$lang->domain}</label>
<div class="x_controls">
@ -45,11 +59,7 @@
<div class="x_control-group">
<label class="x_control-label" for="index_module_srl">{$lang->cmd_index_module_srl}</label>
<div class="x_controls">
<select id="index_module_srl" name="index_module_srl">
<!--@foreach($module_list as $module_info)-->
<option value="{$module_info->module_srl}" selected="selected"|cond="$module_info->module_srl == $index_module_srl">{escape($module_info->browser_title)}</option>
<!--@endforeach-->
</select>
<input class="module_search" type="text" id="index_module_srl" name="index_module_srl" value="{$index_module_srl}" />
</div>
</div>
@ -69,6 +79,67 @@
</div>
</div>
<div class="x_control-group">
<label class="x_control-label" for="default_timezone">{$lang->timezone}</label>
<div class="x_controls">
<select name="default_timezone">
<option loop="$timezones => $key,$val" value="{$key}" selected="selected"|cond="$key == $domain_timezone">{$val}</option>
</select>
</div>
</div>
<div class="x_control-group">
<label class="x_control-label" for="html_footer">{$lang->input_footer_script}</label>
<div class="x_controls" style="margin-right:14px">
<textarea name="html_footer" id="html_footer" rows="6" style="width:100%">{$domain_info ? $domain_info->settings->html_footer : ''}</textarea>
<div class="x_help-block">{$lang->detail_input_footer_script}</div>
</div>
</div>
<div class="x_control-group">
<label class="x_control-label">{$lang->allow_use_favicon}</label>
<div class="x_controls">
<p id="faviconPreview">
<img src="{$favicon_url ?: (\RX_BASEURL . 'modules/admin/tpl/img/faviconSample.png')}" alt="Favicon" class="fn1" style="width:16px;height:16px">
<img src="{$favicon_url ?: (\RX_BASEURL . 'modules/admin/tpl/img/faviconSample.png')}" alt="Favicon" class="fn2" style="width:16px;height:16px">
</p>
<label cond="$favicon_url">
<input type="checkbox" name="delete_favicon" value="1" /> {$lang->cmd_delete}
</label>
<input type="file" name="favicon" id="favicon" title="Favicon"/>
<span class="x_help-block">{$lang->about_use_favicon}</span>
</div>
</div>
<div class="x_control-group">
<label class="x_control-label">{$lang->allow_use_mobile_icon}</label>
<div class="x_controls">
<p id="mobiconPreview">
<img src="{$mobicon_url ?: (\RX_BASEURL . 'modules/admin/tpl/img/mobiconSample.png')}" alt="Mobile Home Icon" width="32" height="32" />
<span>Rhymix</span>
</p>
<label cond="$mobicon_url">
<input type="checkbox" name="delete_mobicon" value="1" /> {$lang->cmd_delete}
</label>
<input type="file" name="mobicon" id="mobicon" title="Mobile Home Icon"/>
<span class="x_help-block">{$lang->detail_use_mobile_icon}</span>
</div>
</div>
<div class="x_control-group">
<label class="x_control-label">{$lang->cmd_site_default_image}</label>
<div class="x_controls">
<p id="default_imagePreview" cond="$default_image_url">
<img src="{$default_image_url}" alt="Default Image" style="width:200px;height:auto" />
</p>
<label cond="$default_image_url">
<input type="checkbox" name="delete_default_image" value="1" /> {$lang->cmd_delete}
</label>
<input type="file" name="default_image" id="default_image" title="Default Image"/>
<span class="x_help-block">{$lang->about_site_default_image}</span>
</div>
</div>
<div class="x_clearfix btnArea">
<div class="x_pull-right">
<button type="submit" class="x_btn x_btn-primary">{$lang->cmd_save}</button>