Improve backward compatibility with AXUpload5 and other third-party AJAX apps

This commit is contained in:
Kijin Sung 2016-01-26 10:32:59 +09:00
parent 8ee5e8c4b0
commit 3a419d586d
5 changed files with 33 additions and 15 deletions

View file

@ -232,6 +232,7 @@ class Context
$this->setRequestMethod('');
$this->_setXmlRpcArgument();
$this->_setJSONRequestArgument();
$this->_setRequestArgument();
$this->_setUploadedArgument();
@ -1386,7 +1387,16 @@ class Context
*/
private function _setJSONRequestArgument()
{
if(count($_POST) || self::getRequestMethod() != 'JSON')
{
return;
}
$params = array();
parse_str($GLOBALS['HTTP_RAW_POST_DATA'], $params);
foreach($params as $key => $val)
{
self::set($key, $this->_filterRequestVar($key, $val, 1), TRUE);
}
}
/**

View file

@ -91,7 +91,10 @@ class DisplayHandler extends Handler
{
if(Context::getResponseMethod() == 'JSON' || Context::getResponseMethod() == 'JS_CALLBACK')
{
self::_printJSONHeader();
if(strpos($_SERVER['HTTP_ACCEPT'], 'json') !== false)
{
self::_printJSONHeader();
}
}
else if(Context::getResponseMethod() != 'HTML')
{

View file

@ -299,7 +299,9 @@
$.exec_json('file.getFileList', obj, function(res){
data.uploadTargetSrl = res.upload_target_srl;
editorRelKeys[data.editorSequence].primary.value = res.upload_target_srl;
if(editorRelKeys[data.editorSequence]) {
editorRelKeys[data.editorSequence].primary.value = res.upload_target_srl;
}
data.uploadTargetSrl = res.uploadTargetSrl;
// @TODO 정리

View file

@ -239,21 +239,23 @@ function xml2json(xml, tab, ignoreAttrib) {
// 전송 성공시
function onsuccess(data, textStatus, xhr) {
waiting_obj.css('display', 'none').trigger('cancel_confirm');
var ret = [];
var tags = {};
var ret = {};
$.each(response_tags, function(key, val){ tags[val] = true; });
tags.redirect_url = true;
tags.act = true;
$.each(data, function(key, val){ if(tags[key]) ret[key] = val; });
if(ret.error != '0') {
if ($.isFunction($.exec_xml.onerror)) {
return $.exec_xml.onerror(module, act, ret, callback_func, response_tags, callback_func_arg, fo_obj);
$.each(data, function(key, val) {
if(key == "act" || key == "redirect_url" || $.inArray(key, response_tags)) {
if($.isArray(val)) {
ret[key] = { item: val };
} else {
ret[key] = val;
}
}
});
alert( (ret.message || 'An unknown error occured while loading ['+module+'.'+act+']').replace(/\\n/g, '\n') );
if(data.error != 0) {
if ($.isFunction($.exec_xml.onerror)) {
return $.exec_xml.onerror(module, act, data, callback_func, response_tags, callback_func_arg, fo_obj);
}
alert( (data.message || 'An unknown error occured while loading ['+module+'.'+act+']').replace(/\\n/g, '\n') );
return null;
}

View file

@ -35,6 +35,7 @@ class fileModel extends file
{
$tmp_files = $this->getFiles($upload_target_srl);
$file_count = count($tmp_files);
$files = array();
for($i=0;$i<$file_count;$i++)
{