From a015353dea0cbfe85b53d0fa73c30da82ad8af63 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Wed, 23 Mar 2016 10:35:39 +0800 Subject: [PATCH 1/3] * fix for http://www.zentao.net/thread/86375.html. --- framework/base/helper.class.php | 4 +++- framework/base/router.class.php | 1 + www/js/jquery/form/zentao.js | 23 +++++++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/framework/base/helper.class.php b/framework/base/helper.class.php index d2df07d63a..be1f0ba93e 100644 --- a/framework/base/helper.class.php +++ b/framework/base/helper.class.php @@ -595,7 +595,9 @@ class baseHelper */ public static function isAjaxRequest() { - return isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'; + $isAjax = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'; + if(!$isAjax) $isAjax = (isset($_GET['HTTP_X_REQUESTED_WITH']) && $_GET['HTTP_X_REQUESTED_WITH'] == 'true'); + return $isAjax; } /** diff --git a/framework/base/router.class.php b/framework/base/router.class.php index 9b4680fc2f..1594c1b58e 100644 --- a/framework/base/router.class.php +++ b/framework/base/router.class.php @@ -1535,6 +1535,7 @@ class baseRouter } unset($passedParams['onlybody']); + unset($passedParams['HTTP_X_REQUESTED_WITH']); $passedParams = array_values($passedParams); $i = 0; foreach($defaultParams as $key => $defaultValue) diff --git a/www/js/jquery/form/zentao.js b/www/js/jquery/form/zentao.js index 92d1adbc9a..084da23c92 100644 --- a/www/js/jquery/form/zentao.js +++ b/www/js/jquery/form/zentao.js @@ -1,3 +1,4 @@ +var ajaxFormUrl = ''; $.extend( { ajaxForm: function(formID, callback) @@ -9,6 +10,28 @@ $.extend( timeout : config.timeout, dataType:'json', + beforeSubmit:function(arr, $form, options) + { + /* Check should use frame. */ + var feature = {}; + feature.fileapi = $("").get(0).files !== undefined; + feature.formdata = window.FormData !== undefined; + var fileInputs = $('input[type=file]:enabled', this).filter(function() { return $(this).val() !== ''; }); + var hasFileInputs = fileInputs.length > 0; + var mp = 'multipart/form-data'; + var multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp); + + var fileAPI = feature.fileapi && feature.formdata; + var shouldUseFrame = (hasFileInputs || multipart) && !fileAPI; + /* Append HTTP_X_REQUESTED_WITH on url when shouldUseFrame is true. */ + if(shouldUseFrame) + { + if(ajaxFormUrl == '')ajaxFormUrl = options.url; + if(options.url != ajaxFormUrl) options.url = ajaxFormUrl; + options.url = options.url.indexOf('&') >= 0 ? options.url + '&HTTP_X_REQUESTED_WITH=true' : options.url + '?HTTP_X_REQUESTED_WITH=true'; + } + }, + success:function(response) { $.enableForm(formID); From 63010c78863b14b45469ccf59058a75897c9926b Mon Sep 17 00:00:00 2001 From: wangyidong Date: Wed, 23 Mar 2016 10:44:22 +0800 Subject: [PATCH 2/3] * fix for load siteCode config. --- framework/base/control.class.php | 1 - framework/base/router.class.php | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/framework/base/control.class.php b/framework/base/control.class.php index 26562c9e8f..662a01cff4 100644 --- a/framework/base/control.class.php +++ b/framework/base/control.class.php @@ -591,7 +591,6 @@ class baseControl $this->output = json_encode($output); } - /** /** * 默认渲染方法,适用于viewType = html的时候。 * Default parse method when viewType != json, like html. diff --git a/framework/base/router.class.php b/framework/base/router.class.php index 1594c1b58e..0ebc0ace3f 100644 --- a/framework/base/router.class.php +++ b/framework/base/router.class.php @@ -1709,7 +1709,7 @@ class baseRouter if(is_file($multiConfigFile)) include $multiConfigFile; } - if(empty($this->siteCode)) + if(!empty($this->siteCode)) { $siteConfigFile = $this->configRoot . "sites/{$this->siteCode}.php"; if(is_file($siteConfigFile)) include $siteConfigFile; From 313e0c82e7569019d810cb7905a05c66db7e943d Mon Sep 17 00:00:00 2001 From: Catouse Date: Wed, 23 Mar 2016 11:39:26 +0800 Subject: [PATCH 3/3] * fix caption border in table of testtask result. --- module/testtask/view/results.html.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/module/testtask/view/results.html.php b/module/testtask/view/results.html.php index a789517aa4..6fc12a9a23 100644 --- a/module/testtask/view/results.html.php +++ b/module/testtask/view/results.html.php @@ -28,7 +28,7 @@
- @@ -81,7 +81,7 @@
+ testcase->result?>   testtask->showResult, $count)?>
0) echo $failCount > 0 ? "" . sprintf($lang->testtask->showFail, $failCount) . "":"{$lang->testtask->passAll}";?>
- +