mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-02 01:52:10 +09:00
IE에서 첨부파일 미리 보기 안되는 기능 및 Context에서 request arguments에 대해 filtering을 하는 기능 보완
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@4702 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
aaff38633c
commit
b59ac03deb
5 changed files with 97 additions and 93 deletions
|
|
@ -550,18 +550,7 @@
|
|||
|
||||
foreach($_REQUEST as $key => $val) {
|
||||
if($val === "") continue;
|
||||
if($key == "page" || $key == "cpage" || substr($key,-3)=="srl") $val = (int)$val;
|
||||
else if(is_array($val) && count($val) ) {
|
||||
foreach($val as $k => $v) {
|
||||
if(version_compare(PHP_VERSION, "5.9.0", "<") && get_magic_quotes_gpc()) $v = stripslashes($v);
|
||||
$v = trim($v);
|
||||
$val[$k] = $v;
|
||||
}
|
||||
} else {
|
||||
if(version_compare(PHP_VERSION, "5.9.0", "<") && get_magic_quotes_gpc()) $val = stripslashes($val);
|
||||
$val = trim($val);
|
||||
}
|
||||
|
||||
$val = $this->_filterRequestVar($key, $val);
|
||||
if($this->_getRequestMethod()=='GET'&&$_GET[$key]) $set_to_vars = true;
|
||||
elseif($this->_getRequestMethod()=='POST'&&$_POST[$key]) $set_to_vars = true;
|
||||
else $set_to_vars = false;
|
||||
|
|
@ -584,11 +573,30 @@
|
|||
if(!count($params)) return;
|
||||
|
||||
foreach($params as $key => $obj) {
|
||||
$val = trim($obj->body);
|
||||
$val = $this->_filterRequestVar($key, $obj->body);
|
||||
$this->_set($key, $val, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 변수명에 따라서 필터링 처리
|
||||
* _srl, page, cpage등의 변수는 integer로 형변환
|
||||
**/
|
||||
function _filterRequestVar($key, $val) {
|
||||
if($key == "page" || $key == "cpage" || substr($key,-3)=="srl") return (int)$val;
|
||||
if(is_array($val) && count($val) ) {
|
||||
foreach($val as $k => $v) {
|
||||
if(version_compare(PHP_VERSION, "5.9.0", "<") && get_magic_quotes_gpc()) $v = stripslashes($v);
|
||||
$v = trim($v);
|
||||
$val[$k] = $v;
|
||||
}
|
||||
} else {
|
||||
if(version_compare(PHP_VERSION, "5.9.0", "<") && get_magic_quotes_gpc()) $val = stripslashes($val);
|
||||
$val = trim($val);
|
||||
}
|
||||
return $val;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 업로드 되었을 경우 return true
|
||||
**/
|
||||
|
|
|
|||
|
|
@ -9,10 +9,12 @@ var show_waiting_message = true;
|
|||
function exec_xml(module, act, params, callback_func, response_tags, callback_func_arg, fo_obj) {
|
||||
var oXml = new xml_handler();
|
||||
oXml.reset();
|
||||
for(var key in params) {
|
||||
if(!params.hasOwnProperty(key)) continue;
|
||||
var val = params[key];
|
||||
oXml.addParam(key, val);
|
||||
if(typeof(params)!='undefined') {
|
||||
for(var key in params) {
|
||||
if(!params.hasOwnProperty(key)) continue;
|
||||
var val = params[key];
|
||||
oXml.addParam(key, val);
|
||||
}
|
||||
}
|
||||
oXml.addParam("module", module);
|
||||
oXml.addParam("act", act);
|
||||
|
|
|
|||
|
|
@ -236,7 +236,7 @@ function completeReloadFileList(ret_obj, response_tags, settings) {
|
|||
var previewObj = xGetElementById(settings["previewAreaID"]);
|
||||
if(previewObj) xInnerHtml(previewObj,"");
|
||||
|
||||
if(files) {
|
||||
if(files && typeof(files['item'])!='undefined') {
|
||||
var item = files['item'];
|
||||
if(item.length<1) item = new Array(item);
|
||||
if(item.length) {
|
||||
|
|
@ -249,14 +249,20 @@ function completeReloadFileList(ret_obj, response_tags, settings) {
|
|||
}
|
||||
}
|
||||
}
|
||||
listObj.selectedIndex = listObj.options.length-1;
|
||||
//listObj.selectedIndex = listObj.options.length-1;
|
||||
xAddEventListener(listObj,'click',previewFiles);
|
||||
}
|
||||
|
||||
function previewFiles(evt) {
|
||||
var e = new xEvent(evt);
|
||||
var obj = e.target;
|
||||
if(obj.nodeName!="OPTION") return;
|
||||
var selObj = null;
|
||||
if(obj.nodeName=="OPTION") selObj = obj.parentNode;
|
||||
else selObj = obj;
|
||||
if(selObj.nodeName != "SELECT") return;
|
||||
if(selObj.selectedIndex<0) return;
|
||||
obj = selObj.options[selObj.selectedIndex];
|
||||
|
||||
var file_srl = obj.value;
|
||||
if(!file_srl || typeof(uploadedFiles[file_srl])=="undefined") return;
|
||||
var file_info = uploadedFiles[file_srl];
|
||||
|
|
@ -297,12 +303,18 @@ function removeUploadedFile(editorSequence) {
|
|||
|
||||
if(fileListObj.selectedIndex<0) return;
|
||||
|
||||
var file_srl = fileListObj.options[fileListObj.selectedIndex].value;
|
||||
var file_srls = new Array();
|
||||
for(var i=0;i<fileListObj.options.length;i++) {
|
||||
if(!fileListObj.options[i].selected) continue;
|
||||
var file_srl = fileListObj.options[i].value;
|
||||
if(!file_srl) continue;
|
||||
file_srls[file_srls.length] = file_srl;
|
||||
}
|
||||
|
||||
if(!file_srl) return;
|
||||
if(file_srls.length<1) return;
|
||||
|
||||
var params = new Array();
|
||||
params["file_srl"] = file_srl;
|
||||
params["file_srl"] = file_srls.join(',');
|
||||
params["editor_sequence"] = editorSequence;
|
||||
var response_tags = new Array("error","message");
|
||||
exec_xml("file","procFileDelete", params, function() { reloadFileList(settings); } );
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@
|
|||
if($upload_target_srl && $file_srl) $output = $this->deleteFile($file_srl);
|
||||
|
||||
// 첨부파일의 목록을 java script로 출력
|
||||
$this->printUploadedFileList($editor_sequence, $upload_target_srl);
|
||||
// $this->printUploadedFileList($editor_sequence, $upload_target_srl);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -333,31 +333,40 @@
|
|||
function deleteFile($file_srl) {
|
||||
if(!$file_srl) return;
|
||||
|
||||
// 파일 정보를 가져옴
|
||||
$args->file_srl = $file_srl;
|
||||
$output = executeQuery('file.getFile', $args);
|
||||
if(!$output->toBool()) return $output;
|
||||
$file_info = $output->data;
|
||||
if(!$file_info) return new Object(-1, 'file_not_founded');
|
||||
$srls = explode(',',$file_srl);
|
||||
if(!count($srls)) return;
|
||||
|
||||
$source_filename = $output->data->source_filename;
|
||||
$uploaded_filename = $output->data->uploaded_filename;
|
||||
for($i=0;$i<count($srls);$i++) {
|
||||
$srl = (int)$srls[$i];
|
||||
if(!$srl) continue;
|
||||
|
||||
// trigger 호출 (before)
|
||||
$trigger_obj = $output->data;
|
||||
$output = ModuleHandler::triggerCall('file.deleteFile', 'before', $trigger_obj);
|
||||
if(!$output->toBool()) return $output;
|
||||
$args = null;
|
||||
$args->file_srl = $srl;
|
||||
$output = executeQuery('file.getFile', $args);
|
||||
if(!$output->toBool()) continue;
|
||||
|
||||
// DB에서 삭제
|
||||
$output = executeQuery('file.deleteFile', $args);
|
||||
if(!$output->toBool()) return $output;
|
||||
$file_info = $output->data;
|
||||
if(!$file_info) continue;
|
||||
|
||||
// trigger 호출 (after)
|
||||
$trigger_output = ModuleHandler::triggerCall('file.deleteFile', 'after', $trigger_obj);
|
||||
if(!$trigger_output->toBool()) return $trigger_output;
|
||||
$source_filename = $output->data->source_filename;
|
||||
$uploaded_filename = $output->data->uploaded_filename;
|
||||
|
||||
// 삭제 성공하면 파일 삭제
|
||||
FileHandler::removeFile($uploaded_filename);
|
||||
// trigger 호출 (before)
|
||||
$trigger_obj = $output->data;
|
||||
$output = ModuleHandler::triggerCall('file.deleteFile', 'before', $trigger_obj);
|
||||
if(!$output->toBool()) return $output;
|
||||
|
||||
// DB에서 삭제
|
||||
$output = executeQuery('file.deleteFile', $args);
|
||||
if(!$output->toBool()) return $output;
|
||||
|
||||
// trigger 호출 (after)
|
||||
$trigger_output = ModuleHandler::triggerCall('file.deleteFile', 'after', $trigger_obj);
|
||||
if(!$trigger_output->toBool()) return $trigger_output;
|
||||
|
||||
// 삭제 성공하면 파일 삭제
|
||||
FileHandler::removeFile($uploaded_filename);
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
|
@ -446,38 +455,7 @@
|
|||
* @brief upload_target_srl을 키로 하는 첨부파일을 찾아서 java script 코드로 return
|
||||
**/
|
||||
function printUploadedFileList($editor_sequence, $upload_target_srl) {
|
||||
$oFileModel = &getModel('file');
|
||||
|
||||
if($upload_target_srl) {
|
||||
// file의 Model객체 생성
|
||||
|
||||
// 첨부파일 목록을 구함
|
||||
$tmp_file_list = $oFileModel->getFiles($upload_target_srl);
|
||||
$file_count = count($tmp_file_list);
|
||||
|
||||
// 루프를 돌면서 $buff 변수에 java script 코드를 생성
|
||||
$buff = "";
|
||||
for($i=0;$i<$file_count;$i++) {
|
||||
$file_info = $tmp_file_list[$i];
|
||||
if(!$file_info->file_srl) continue;
|
||||
if($file_info->direct_download == 'Y') $file_info->uploaded_filename = sprintf('%s%s', Context::getRequestUri(), str_replace('./', '', $file_info->uploaded_filename));
|
||||
$file_list[] = $file_info;
|
||||
$attached_size += $file_info->file_size;
|
||||
}
|
||||
}
|
||||
|
||||
// 업로드 상태 표시 작성
|
||||
$upload_status = $oFileModel->getUploadStatus($attached_size);
|
||||
|
||||
// 필요한 정보들 세팅
|
||||
Context::set('upload_target_srl', $upload_target_srl);
|
||||
Context::set('file_list', $file_list);
|
||||
Context::set('upload_status', $upload_status);
|
||||
|
||||
// 업로드 현황을 브라우저로 알리기 위한 javascript 코드 출력하는 템플릿 호출
|
||||
Context::set('layout','none');
|
||||
$this->setTemplatePath($this->module_path.'tpl');
|
||||
$this->setTemplateFile('print_uploaded_file_list');
|
||||
return;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -19,25 +19,29 @@
|
|||
function getFileList() {
|
||||
$editor_sequence = Context::get("editor_sequence");
|
||||
$upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
|
||||
if(!$upload_target_srl) exit();
|
||||
if($upload_target_srl) {
|
||||
$tmp_files = $this->getFiles($upload_target_srl);
|
||||
$file_count = count($tmp_files);
|
||||
|
||||
$tmp_files = $this->getFiles($upload_target_srl);
|
||||
$file_count = count($tmp_files);
|
||||
for($i=0;$i<$file_count;$i++) {
|
||||
$file_info = $tmp_files[$i];
|
||||
if(!$file_info->file_srl) continue;
|
||||
|
||||
for($i=0;$i<$file_count;$i++) {
|
||||
$file_info = $tmp_files[$i];
|
||||
if(!$file_info->file_srl) continue;
|
||||
|
||||
$obj = null;
|
||||
$obj->file_srl = $file_info->file_srl;
|
||||
$obj->source_filename = $file_info->source_filename;
|
||||
$obj->file_size = $file_info->file_size;
|
||||
$obj->disp_file_size = FileHandler::filesize($file_info->file_size);
|
||||
if($file_info->direct_download=='N') $obj->download_url = $this->getDownloadUrl($file_info->file_srl, $file_info->sid);
|
||||
else $obj->download_url = str_replace('./', '', $file_info->uploaded_filename);
|
||||
$obj->direct_download = $file_info->direct_download;
|
||||
$files[] = $obj;
|
||||
$attached_size += $file_info->file_size;
|
||||
$obj = null;
|
||||
$obj->file_srl = $file_info->file_srl;
|
||||
$obj->source_filename = $file_info->source_filename;
|
||||
$obj->file_size = $file_info->file_size;
|
||||
$obj->disp_file_size = FileHandler::filesize($file_info->file_size);
|
||||
if($file_info->direct_download=='N') $obj->download_url = $this->getDownloadUrl($file_info->file_srl, $file_info->sid);
|
||||
else $obj->download_url = str_replace('./', '', $file_info->uploaded_filename);
|
||||
$obj->direct_download = $file_info->direct_download;
|
||||
$files[] = $obj;
|
||||
$attached_size += $file_info->file_size;
|
||||
}
|
||||
} else {
|
||||
$upload_target_srl = 0;
|
||||
$attached_size = 0;
|
||||
$files = array();
|
||||
}
|
||||
|
||||
// 업로드 상태 표시 작성
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue