mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-08 03:01:43 +09:00
issue 2163, some change
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.3.1@10976 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
2f08f0c273
commit
f3a6fc5573
4 changed files with 40 additions and 39 deletions
|
|
@ -143,14 +143,36 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
$tmpDir = sprintf('./files/attach/images/%s/tmp', $args->layout_srl);
|
||||
// Separately handle if a type of extra_vars is an image
|
||||
if($layout_info->extra_var) {
|
||||
foreach($layout_info->extra_var as $name => $vars) {
|
||||
if($vars->type!='image') continue;
|
||||
|
||||
$extra_vars->{$name} = $vars->value;
|
||||
$fileName = $extra_vars->{$name};
|
||||
if($vars->value == $fileName)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
FileHandler::removeFile($vars->value);
|
||||
|
||||
if(!$fileName)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$pathInfo = pathinfo($fileName);
|
||||
$tmpFileName = sprintf('%s/tmp/%s', $pathInfo['dirname'], $pathInfo['basename']);
|
||||
|
||||
if(!FileHandler::moveFile($tmpFileName, $fileName))
|
||||
{
|
||||
unset($extra_vars->{$name});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Save header script into "config" of layout module
|
||||
$oModuleModel = &getModel('module');
|
||||
$oModuleController = &getController('module');
|
||||
|
|
@ -164,6 +186,8 @@
|
|||
$output = $this->updateLayout($args);
|
||||
if(!$output->toBool()) return $output;
|
||||
|
||||
FileHandler::removeDir($tmpDir);
|
||||
|
||||
return $this->setRedirectUrl(Context::get('error_return_url'), $output);
|
||||
}
|
||||
|
||||
|
|
@ -762,7 +786,8 @@
|
|||
}
|
||||
|
||||
$path = sprintf('./files/attach/images/%s/', $layoutSrl);
|
||||
if(!FileHandler::makeDir($path))
|
||||
$tmpPath = $path . 'tmp/';
|
||||
if(!FileHandler::makeDir($tmpPath))
|
||||
{
|
||||
Context::set('msg', Context::getLang('make directory failed'));
|
||||
return;
|
||||
|
|
@ -771,38 +796,17 @@
|
|||
$ext = substr(strrchr($img['name'],'.'),1);
|
||||
$_fileName = md5(crypt(rand(1000000,900000), rand(0,100))).'.'.$ext;
|
||||
$fileName = $path . $_fileName;
|
||||
$tmpFileName = $tmpPath . $_fileName;
|
||||
|
||||
if(!move_uploaded_file($img['tmp_name'], $fileName))
|
||||
if(!move_uploaded_file($img['tmp_name'], $tmpFileName))
|
||||
{
|
||||
Context::set('msg', Context::getLang('move file failed'));
|
||||
return;
|
||||
}
|
||||
|
||||
$oModel = &getModel('layout');
|
||||
$layoutInfo = $oModel->getLayout($layoutSrl);
|
||||
|
||||
if($layoutInfo->extra_var_count)
|
||||
{
|
||||
foreach($layoutInfo->extra_var as $varId => $val)
|
||||
{
|
||||
$newLayoutInfo->{$varId} = $val->value;
|
||||
}
|
||||
}
|
||||
|
||||
$newLayoutInfo->{$name} = $fileName;
|
||||
|
||||
$args->layout_srl = $layoutSrl;
|
||||
$args->extra_vars = serialize($newLayoutInfo);
|
||||
$output = $this->updateLayout($args);
|
||||
if(!$output->toBool())
|
||||
{
|
||||
FileHandler::removeFile($fileName);
|
||||
Context::set('msg', Context::getLang($output->getMessage()));
|
||||
return;
|
||||
}
|
||||
|
||||
Context::set('name', $name);
|
||||
Context::set('fileName', $fileName);
|
||||
Context::set('tmpFileName', $tmpFileName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -2,6 +2,6 @@
|
|||
<!--@if($msg)-->
|
||||
alert('{$msg}');
|
||||
<!--@else-->
|
||||
parent.afterUploadConfigImage('{$name}', '{$fileName}');
|
||||
parent.afterUploadConfigImage('{$name}', '{$fileName}', '{$tmpFileName}');
|
||||
<!--@end-->
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -18,15 +18,17 @@ function doSubmitConfig()
|
|||
$configForm.submit();
|
||||
}
|
||||
|
||||
function afterUploadConfigImage(name, fileName)
|
||||
function afterUploadConfigImage(name, fileName, tmpFileName)
|
||||
{
|
||||
jQuery('#preview_' + name + ' img').attr('src', fileName);
|
||||
jQuery('#preview_' + name + ' img').attr('src', tmpFileName);
|
||||
jQuery('#preview_' + name).show();
|
||||
jQuery('#file_' + name).val('');
|
||||
jQuery('#file_select' + name).val('');
|
||||
jQuery('#file_' + name).val(fileName);
|
||||
}
|
||||
|
||||
function afterDeleteConfigImage(name)
|
||||
function deleteImage(name)
|
||||
{
|
||||
jQuery('#preview_' + name + ' img').removeAttr('src');
|
||||
jQuery('#preview_' + name).hide();
|
||||
jQuery('#file_' + name).val('');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,15 +76,10 @@
|
|||
</div>
|
||||
|
||||
<block cond="$var->type == 'image'">
|
||||
<input type="hidden" name="{$name}" id="file_{$name}" value="{$var->value}" />
|
||||
<div id="preview_{$name}" style="display:none;"|cond="!$var->value">
|
||||
<img src="../../../{$var->value}"|cond="$var->value" alt="" style="max-width: 250px"/>
|
||||
<form action="./" method="post" target="hiddenIframe" class="imageUpload" style="display:inline;">
|
||||
<input type="hidden" name="module" value="layout" />
|
||||
<input type="hidden" name="act" value="procLayoutAdminConfigImageDelete" />
|
||||
<input type="hidden" name="layout_srl" value="{$layout_srl}" />
|
||||
<input type="hidden" name="name" value="{$name}" />
|
||||
<input type="submit" value="{$lang->cmd_delete}" />
|
||||
</form>
|
||||
<input type="button" value="{$lang->cmd_delete}" onclick="deleteImage('{$name}')" />
|
||||
</div>
|
||||
<form action="./" enctype="multipart/form-data" method="post" target="hiddenIframe" class="imageUpload">
|
||||
<input type="hidden" name="module" value="layout" />
|
||||
|
|
@ -92,7 +87,7 @@
|
|||
<input type="hidden" name="layout_srl" value="{$layout_srl}" />
|
||||
<input type="hidden" name="name" value="{$name}" />
|
||||
<p>
|
||||
<input type="file" name="img" id="file_{$name}" value="" />
|
||||
<input type="file" name="img" id="file_select_{$name}" value="" />
|
||||
<input type="submit" value="{$lang->cmd_submit}" />
|
||||
</p>
|
||||
</form>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue