mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-08 19:21:40 +09:00
Refactor default image code to reuse favicon code as much as possible
This commit is contained in:
parent
e4453712b5
commit
ffa90345d0
6 changed files with 67 additions and 104 deletions
|
|
@ -545,12 +545,7 @@ class adminAdminController extends admin
|
|||
// Favicon and mobicon
|
||||
$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();
|
||||
}
|
||||
$this->_saveDefaultImage($vars->is_delete_site_default_image);
|
||||
|
||||
// Save
|
||||
Rhymix\Framework\Config::save();
|
||||
|
|
@ -916,6 +911,11 @@ class adminAdminController extends admin
|
|||
$name = 'mobicon';
|
||||
$tmpFileName = $this->_saveFaviconTemp($mobicon, 'mobicon.png');
|
||||
}
|
||||
elseif ($default_image = Context::get('default_image'))
|
||||
{
|
||||
$name = 'default_image';
|
||||
$tmpFileName = $this->_saveFaviconTemp($default_image, 'default_image.png');
|
||||
}
|
||||
else
|
||||
{
|
||||
$name = $tmpFileName = '';
|
||||
|
|
@ -928,7 +928,7 @@ class adminAdminController extends admin
|
|||
$this->setTemplateFile("favicon_upload.html");
|
||||
}
|
||||
|
||||
private function _saveFaviconTemp($icon, $iconname)
|
||||
protected function _saveFaviconTemp($icon, $iconname)
|
||||
{
|
||||
$site_info = Context::get('site_module_info');
|
||||
$virtual_site = '';
|
||||
|
|
@ -940,9 +940,9 @@ class adminAdminController extends admin
|
|||
$original_filename = $icon['tmp_name'];
|
||||
$type = $icon['type'];
|
||||
$relative_filename = 'files/attach/xeicon/'.$virtual_site.'tmp/'.$iconname;
|
||||
$target_filename = RX_BASEDIR . $relative_filename;
|
||||
$target_filename = \RX_BASEDIR . $relative_filename;
|
||||
|
||||
if ($iconname !== 'favicon.ico' && $iconname !== 'mobicon.png')
|
||||
if (!preg_match('/^(favicon|mobicon|default_image)\.(ico|png|jpe?g)$/', $iconname))
|
||||
{
|
||||
Context::set('msg', lang('msg_invalid_format'));
|
||||
return;
|
||||
|
|
@ -952,93 +952,64 @@ class adminAdminController extends admin
|
|||
return $relative_filename;
|
||||
}
|
||||
|
||||
private function _saveFavicon($iconname, $deleteIcon = false)
|
||||
protected function _saveFavicon($iconname, $deleteIcon = false)
|
||||
{
|
||||
$image_filepath = 'files/attach/xeicon/';
|
||||
$site_info = Context::get('site_module_info');
|
||||
$virtual_site = '';
|
||||
if ($site_info->site_srl)
|
||||
{
|
||||
$virtual_site = $site_info->site_srl . '/';
|
||||
$image_filepath .= $site_info->site_srl . '/';
|
||||
}
|
||||
|
||||
$image_filepath = RX_BASEDIR . 'files/attach/xeicon/' . $virtual_site;
|
||||
|
||||
if ($deleteIcon)
|
||||
{
|
||||
Rhymix\Framework\Storage::delete($image_filepath.$iconname);
|
||||
Rhymix\Framework\Storage::delete(\RX_BASEDIR . $image_filepath . $iconname);
|
||||
return;
|
||||
}
|
||||
|
||||
$tmpicon_filepath = $image_filepath . 'tmp/' . $iconname;
|
||||
$icon_filepath = $image_filepath . $iconname;
|
||||
if (file_exists($tmpicon_filepath))
|
||||
if (file_exists(\RX_BASEDIR . $tmpicon_filepath))
|
||||
{
|
||||
Rhymix\Framework\Storage::move($tmpicon_filepath, $icon_filepath);
|
||||
Rhymix\Framework\Storage::move(\RX_BASEDIR . $tmpicon_filepath, \RX_BASEDIR . $icon_filepath);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload site default image.
|
||||
*/
|
||||
public function procAdminSiteDefaultImageUpload()
|
||||
protected function _saveDefaultImage($deleteIcon = false)
|
||||
{
|
||||
$image_filepath = 'files/attach/xeicon/';
|
||||
$site_info = Context::get('site_module_info');
|
||||
$virtual_site = '';
|
||||
if ($site_info->site_srl)
|
||||
{
|
||||
$virtual_site = $site_info->site_srl . '/';
|
||||
$image_filepath .= $site_info->site_srl . '/';
|
||||
}
|
||||
|
||||
if ($image = Context::get('default_image'))
|
||||
if ($deleteIcon)
|
||||
{
|
||||
$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');
|
||||
$info = Rhymix\Framework\Storage::readPHPData($image_filepath . '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');
|
||||
Rhymix\Framework\Storage::delete($image_filepath . 'default_image.php');
|
||||
return;
|
||||
}
|
||||
|
||||
$tmpicon_filepath = \RX_BASEDIR . $image_filepath . 'tmp/default_image.png';
|
||||
if (file_exists($tmpicon_filepath))
|
||||
{
|
||||
list($width, $height, $type) = @getimagesize($tmpicon_filepath);
|
||||
switch ($type)
|
||||
{
|
||||
case 'image/gif': $target_filename = $image_filepath . 'default_image.gif'; break;
|
||||
case 'image/jpeg': $target_filename = $image_filepath . 'default_image.jpg'; break;
|
||||
case 'image/png': default: $target_filename = $image_filepath . 'default_image.png';
|
||||
}
|
||||
Rhymix\Framework\Storage::move($tmpicon_filepath, \RX_BASEDIR . $target_filename);
|
||||
Rhymix\Framework\Storage::writePHPData(\RX_BASEDIR . 'files/attach/xeicon/' . $virtual_site . 'default_image.php', array(
|
||||
'filename' => $target_filename, 'width' => $width, 'height' => $height,
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
/* End of file admin.admin.controller.php */
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@
|
|||
<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>
|
||||
|
|
|
|||
|
|
@ -166,10 +166,12 @@ $lang->about_admin_ip_allow = 'If this list is not empty, the administrator will
|
|||
$lang->about_admin_ip_deny = 'This list can be used to designate IP addresses that are not allowed to log in as administrator.';
|
||||
$lang->msg_current_ip_will_be_denied = 'The given IP list cannot be applied, as they would block your own IP address.';
|
||||
$lang->detail_about_ftp_info = 'FTP information is needed for easyinstall when save_mode = on.';
|
||||
$lang->allow_use_favicon = 'Do you want to use favicon?';
|
||||
$lang->allow_use_favicon = 'Favicon';
|
||||
$lang->about_use_favicon = 'The favicon should be 16x16 or 32x32, either ico or png format.';
|
||||
$lang->allow_use_mobile_icon = 'Do you want to use the mobile home screen icon?';
|
||||
$lang->allow_use_mobile_icon = 'Home Screen Icon';
|
||||
$lang->detail_use_mobile_icon = 'The mobile icon should be 57x57 or 114x114, only png format.';
|
||||
$lang->cmd_site_default_image = 'Default Image';
|
||||
$lang->about_site_default_image = 'This image will be shown when your site is linked to in various social networks. It should be 200x200, either jpg or png format.';
|
||||
$lang->use_sso = 'Use <abbr title="Single Sign On">SSO</abbr>?';
|
||||
$lang->about_use_sso = 'SSO will enable users to sign in just once for both default and virtual site. You will need this only if you are using virtual sites.';
|
||||
$lang->about_arrange_session = 'Do you want to clean up session?';
|
||||
|
|
|
|||
|
|
@ -169,12 +169,11 @@ $lang->about_admin_ip_allow = '여기에 IP 주소를 나열하면 해당 IP에
|
|||
$lang->about_admin_ip_deny = '여기에 나열된 IP 주소에서는 관리자 로그인이 금지됩니다.';
|
||||
$lang->msg_current_ip_will_be_denied = '주어진 설정에 따르면 현재 로그인하신 관리자의 IP 주소도 차단됩니다. 다시 확인해 주십시오.';
|
||||
$lang->detail_about_ftp_info = 'safe_mode = on 상태에서 쉬운설치를 사용하려면 FTP 정보를 입력해야 합니다.';
|
||||
$lang->allow_use_favicon = '파비콘 지정';
|
||||
$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 = '사용자가 한 번만 로그인하면 기본 사이트와 가상 사이트에 동시에 로그인이 됩니다. 가상 사이트를 사용할 때만 필요합니다.';
|
||||
|
|
|
|||
|
|
@ -98,8 +98,8 @@
|
|||
<label class="x_control-label">{$lang->allow_use_favicon}</label>
|
||||
<div class="x_controls">
|
||||
<p id="faviconPreview">
|
||||
<img src="{$favicon_url}" alt="favicon" class="fn1" style="width:16px;height:16px">
|
||||
<img src="{$favicon_url}" alt="favicon Image" class="fn2" style="width:16px;height:16px">
|
||||
<img src="{$favicon_url}" alt="Favicon" class="fn1" style="width:16px;height:16px">
|
||||
<img src="{$favicon_url}" alt="Favicon" class="fn2" style="width:16px;height:16px">
|
||||
</p>
|
||||
<label><input type="checkbox" name="is_delete_favicon" value="1" /> {$lang->cmd_delete}</label>
|
||||
<form action="./" enctype="multipart/form-data" method="post" target="hiddenIframe" class="imageUpload" style="margin:0">
|
||||
|
|
@ -135,14 +135,13 @@
|
|||
<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 id="default_imagePreview">
|
||||
<img src="{$site_default_image_url}" alt="Default Image" style="width:200px;height:auto" />
|
||||
</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">
|
||||
<input type="hidden" name="act" value="procAdminFaviconUpload">
|
||||
<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">
|
||||
|
|
@ -161,15 +160,10 @@
|
|||
|
||||
<iframe name="hiddenIframe" src="about:blank" hidden></iframe>
|
||||
<script>
|
||||
function afterUploadConfigImage(name, fileName, tmpFileName)
|
||||
{
|
||||
function afterUploadConfigImage(name, tmpFileName) {
|
||||
jQuery('#' + name + 'Preview img').attr('src', tmpFileName);
|
||||
jQuery('#' + name).val('');
|
||||
}
|
||||
|
||||
function alertUploadSiteDefaultImage(url)
|
||||
{
|
||||
jQuery('#default_image_preview').empty().append(jQuery('<img />').attr('src', url).css('width', '200px').css('height', 'auto'));
|
||||
jQuery("input[name='is_delete_'" + name + "']").prop('checked', false);
|
||||
}
|
||||
|
||||
function alertUploadMessage(msg) {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
<script>
|
||||
<!--@if($msg)-->
|
||||
parent.alertUploadMessage('{$msg}');
|
||||
<!--@elseif($site_default_image_url)-->
|
||||
parent.alertUploadSiteDefaultImage('{$site_default_image_url}');
|
||||
<!--@else-->
|
||||
parent.afterUploadConfigImage('{$name}', '{$fileName}', '{$tmpFileName}');
|
||||
parent.afterUploadConfigImage('{$name}', '{$tmpFileName}');
|
||||
<!--@end-->
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue