mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-07 10:41:40 +09:00
Add option to set the site default image
This commit is contained in:
parent
3cf0e6017d
commit
e4453712b5
7 changed files with 128 additions and 1 deletions
|
|
@ -546,6 +546,12 @@ class adminAdminController extends admin
|
|||
$this->_saveFavicon('favicon.ico', $vars->is_delete_favicon);
|
||||
$this->_saveFavicon('mobicon.png', $vars->is_delete_mobicon);
|
||||
|
||||
// Site default image
|
||||
if ($vars->is_delete_site_default_image)
|
||||
{
|
||||
$this->_deleteSiteDefaultImage();
|
||||
}
|
||||
|
||||
// Save
|
||||
Rhymix\Framework\Config::save();
|
||||
|
||||
|
|
@ -970,6 +976,70 @@ class adminAdminController extends admin
|
|||
Rhymix\Framework\Storage::move($tmpicon_filepath, $icon_filepath);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload site default image.
|
||||
*/
|
||||
public function procAdminSiteDefaultImageUpload()
|
||||
{
|
||||
$site_info = Context::get('site_module_info');
|
||||
$virtual_site = '';
|
||||
if ($site_info->site_srl)
|
||||
{
|
||||
$virtual_site = $site_info->site_srl . '/';
|
||||
}
|
||||
|
||||
if ($image = Context::get('default_image'))
|
||||
{
|
||||
$image_type = strtolower(strrchr($image['name'], '.')) ?: '.png';
|
||||
list($width, $height) = @getimagesize($image['tmp_name']);
|
||||
if ($width && $height)
|
||||
{
|
||||
$target_filename = 'files/attach/xeicon/' . $virtual_site . 'default_image' . $image_type;
|
||||
if (Rhymix\Framework\Storage::copy($image['tmp_name'], \RX_BASEDIR . $target_filename, 0666 & ~umask()))
|
||||
{
|
||||
Rhymix\Framework\Storage::writePHPData(\RX_BASEDIR . 'files/attach/xeicon/' . $virtual_site . 'default_image.php', array(
|
||||
'filename' => $target_filename, 'width' => $width, 'height' => $height,
|
||||
));
|
||||
}
|
||||
|
||||
Context::set('site_default_image_url', $target_filename . '?' . date('YmdHis', filemtime(\RX_BASEDIR . $target_filename)));
|
||||
}
|
||||
else
|
||||
{
|
||||
Context::set('site_default_image_url', $url);
|
||||
Context::set('msg', lang('msg_invalid_format'));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Context::set('site_default_image_url', $url);
|
||||
Context::set('msg', lang('msg_invalid_format'));
|
||||
}
|
||||
|
||||
$this->setTemplatePath($this->module_path . 'tpl');
|
||||
$this->setTemplateFile("favicon_upload.html");
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete site default image.
|
||||
*/
|
||||
private function _deleteSiteDefaultImage()
|
||||
{
|
||||
$site_info = Context::get('site_module_info');
|
||||
$virtual_site = '';
|
||||
if ($site_info->site_srl)
|
||||
{
|
||||
$virtual_site = $site_info->site_srl . '/';
|
||||
}
|
||||
|
||||
$info = Rhymix\Framework\Storage::readPHPData(\RX_BASEDIR . 'files/attach/xeicon/' . $virtual_site . 'default_image.php');
|
||||
if ($info['filename'])
|
||||
{
|
||||
Rhymix\Framework\Storage::delete(\RX_BASEDIR . $info['filename']);
|
||||
}
|
||||
Rhymix\Framework\Storage::delete(\RX_BASEDIR . 'files/attach/xeicon/' . $virtual_site . 'default_image.php');
|
||||
}
|
||||
}
|
||||
/* End of file admin.admin.controller.php */
|
||||
/* Location: ./modules/admin/admin.admin.controller.php */
|
||||
|
|
|
|||
|
|
@ -940,6 +940,31 @@ class adminAdminModel extends admin
|
|||
{
|
||||
return $this->iconUrlCheck('mobicon.png', 'mobiconSample.png', $default);
|
||||
}
|
||||
|
||||
function getSiteDefaultImageUrl(&$width = 0, &$height = 0)
|
||||
{
|
||||
$site_info = Context::get('site_module_info');
|
||||
if ($site_info->site_srl)
|
||||
{
|
||||
$virtual_site = $site_info->site_srl . '/';
|
||||
}
|
||||
else
|
||||
{
|
||||
$virtual_site = '';
|
||||
}
|
||||
|
||||
$info = Rhymix\Framework\Storage::readPHPData(\RX_BASEDIR . 'files/attach/xeicon/' . $virtual_site . 'default_image.php');
|
||||
if ($info && Rhymix\Framework\Storage::exists(\RX_BASEDIR . $info['filename']))
|
||||
{
|
||||
$width = $info['width'];
|
||||
$height = $info['height'];
|
||||
return \RX_BASEURL . $info['filename'] . '?' . date('YmdHis', filemtime(\RX_BASEDIR . $info['filename']));
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function iconUrlCheck($iconname, $default_icon_name, $default)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -436,12 +436,14 @@ class adminAdminView extends admin
|
|||
// Mobile view
|
||||
Context::set('use_mobile_view', config('use_mobile_view') ? 'Y' : 'N');
|
||||
|
||||
// Favicon and mobicon
|
||||
// Favicon and mobicon and site default image
|
||||
$oAdminModel = getAdminModel('admin');
|
||||
$favicon_url = $oAdminModel->getFaviconUrl(false) ?: $oAdminModel->getFaviconUrl();
|
||||
$mobicon_url = $oAdminModel->getMobileIconUrl(false) ?: $oAdminModel->getMobileIconUrl();
|
||||
$site_default_image_url = $oAdminModel->getSiteDefaultImageUrl();
|
||||
Context::set('favicon_url', $favicon_url);
|
||||
Context::set('mobicon_url', $mobicon_url);
|
||||
Context::set('site_default_image_url', $site_default_image_url);
|
||||
|
||||
$this->setTemplateFile('config_general');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
<action name="procAdminUpdateFTPInfo" type="controller" />
|
||||
<action name="procAdminRemoveFTPInfo" type="controller" />
|
||||
<action name="procAdminFaviconUpload" type="controller" />
|
||||
<action name="procAdminSiteDefaultImageUpload" type="controller" />
|
||||
|
||||
<action name="getSiteAllList" type="model" />
|
||||
</actions>
|
||||
|
|
|
|||
|
|
@ -173,6 +173,9 @@ $lang->allow_use_favicon = '파비콘 지정';
|
|||
$lang->about_use_favicon = '16x16 또는 32x32 크기의 ico 또는 png 파일을 권장합니다.';
|
||||
$lang->allow_use_mobile_icon = '모바일 홈 화면 아이콘';
|
||||
$lang->detail_use_mobile_icon = '57x57 또는 114x114 크기의 png 파일을 권장합니다.';
|
||||
$lang->cmd_site_default_image = '사이트 대표 이미지';
|
||||
$lang->msg_no_site_default_image = '대표 이미지가 등록되지 않았습니다.';
|
||||
$lang->about_site_default_image = 'SNS 등에 이 사이트가 링크되었을 때 표시되는 이미지입니다. 200x200 크기의 jpg 또는 png 파일을 권장합니다.';
|
||||
$lang->use_sso = '<abbr title="Single Sign On">SSO</abbr> 사용';
|
||||
$lang->about_use_sso = '사용자가 한 번만 로그인하면 기본 사이트와 가상 사이트에 동시에 로그인이 됩니다. 가상 사이트를 사용할 때만 필요합니다.';
|
||||
$lang->about_arrange_session = '세션을 정리하시겠습니까?';
|
||||
|
|
|
|||
|
|
@ -132,6 +132,25 @@
|
|||
<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_image_preview">
|
||||
<img cond="$site_default_image_url" src="{$site_default_image_url}" alt="site default image" style="width:200px;height:auto" />
|
||||
<block cond="!$site_default_image_url">{$lang->msg_no_site_default_image}</block>
|
||||
</p>
|
||||
<label><input type="checkbox" name="is_delete_site_default_image" value="1" /> {$lang->cmd_delete}</label>
|
||||
<form action="./" enctype="multipart/form-data" method="post" target="hiddenIframe" class="imageUpload" style="margin:0">
|
||||
<input type="hidden" name="module" value="admin">
|
||||
<input type="hidden" name="act" value="procAdminSiteDefaultImageUpload">
|
||||
<p>
|
||||
<input type="file" name="default_image" id="default_image" title="Site default image"/>
|
||||
<input class="x_btn" type="submit" value="{$lang->cmd_upload}" style="vertical-align:top">
|
||||
</p>
|
||||
</form>
|
||||
<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" onclick="doSubmitConfig()">{$lang->cmd_save}</button>
|
||||
|
|
@ -148,6 +167,11 @@ function afterUploadConfigImage(name, fileName, tmpFileName)
|
|||
jQuery('#' + name).val('');
|
||||
}
|
||||
|
||||
function alertUploadSiteDefaultImage(url)
|
||||
{
|
||||
jQuery('#default_image_preview').empty().append(jQuery('<img />').attr('src', url).css('width', '200px').css('height', 'auto'));
|
||||
}
|
||||
|
||||
function alertUploadMessage(msg) {
|
||||
alert(msg);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
<script>
|
||||
<!--@if($msg)-->
|
||||
parent.alertUploadMessage('{$msg}');
|
||||
<!--@elseif($site_default_image_url)-->
|
||||
parent.alertUploadSiteDefaultImage('{$site_default_image_url}');
|
||||
<!--@else-->
|
||||
parent.afterUploadConfigImage('{$name}', '{$fileName}', '{$tmpFileName}');
|
||||
<!--@end-->
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue