diff --git a/config/filter.php b/config/filter.php index 5c651142b1..c1d66224d4 100755 --- a/config/filter.php +++ b/config/filter.php @@ -21,6 +21,7 @@ $filter->default->paramValue = 'reg::paramValue'; $filter->default->get['onlybody'] = 'equal::yes'; $filter->default->get['_single'] = 'equal::1'; +$filter->default->get['_nocache'] = 'equal::1'; $filter->default->get['tid'] = 'reg::word'; $filter->default->get['HTTP_X_REQUESTED_WITH'] = 'equal::XMLHttpRequest'; diff --git a/framework/base/control.class.php b/framework/base/control.class.php index 55ff21c026..ef66f235bc 100644 --- a/framework/base/control.class.php +++ b/framework/base/control.class.php @@ -955,6 +955,7 @@ class baseControl for($i = 0; $i < $obLevel; $i++) ob_end_clean(); $response = helper::removeUTF8Bom(urldecode(json_encode($data))); + $this->app->outputXhprof(); die($response); } diff --git a/framework/base/router.class.php b/framework/base/router.class.php index 5799fba03f..f79c1a63a0 100644 --- a/framework/base/router.class.php +++ b/framework/base/router.class.php @@ -718,7 +718,7 @@ class baseRouter * * @return bool */ - protected function outputXhprof() + public function outputXhprof() { if(empty($this->config->debug) || $this->config->debug < 4 || !extension_loaded('xhprof')) return false; @@ -2266,7 +2266,7 @@ class baseRouter { $cacheEnable = $this->config->cache->enableFullPage; /* If caching is not turned on, pages that do not need to be cached, or when searching, they are not cached. */ - if(!$cacheEnable || !in_array("{$this->moduleName}|{$this->methodName}", $this->config->cache->fullPages) || stripos($this->server->request_uri, 'search') !== false) + if(!$cacheEnable || !in_array("{$this->moduleName}|{$this->methodName}", $this->config->cache->fullPages) || stripos($this->server->request_uri, 'search') !== false || isset($_GET['_nocache']) || $this->server->http_x_zt_refresh) { $this->loadModule(); return helper::removeUTF8Bom(ob_get_clean()); diff --git a/framework/helper.class.php b/framework/helper.class.php index 6ed7d08873..737b31b5e9 100644 --- a/framework/helper.class.php +++ b/framework/helper.class.php @@ -350,12 +350,28 @@ class helper extends baseHelper } /** + * 是否是内网。 + * Check is intranet. + * * @return bool */ public static function isIntranet() { return !defined('USE_INTRANET') ? false : USE_INTRANET; } + + /** + * 检查是否启用缓存。 + * Check is enable cache. + * + * @return bool + */ + public static function isCacheEnabled() + { + if(isset($_GET['_nocace']) || isset($_SERVER['HTTP_X_ZT_REFRESH'])) return false; + global $config; + return $config->cache->enable; + } } /** diff --git a/lib/base/front/front.class.php b/lib/base/front/front.class.php index 0c00d47a97..4dee58782e 100644 --- a/lib/base/front/front.class.php +++ b/lib/base/front/front.class.php @@ -1259,7 +1259,7 @@ EOT; * Set js value. * * @param string $key - * @param mix $value + * @param mixed $value * @static * @access public * @return string diff --git a/lib/dbh/dbh.class.php b/lib/dbh/dbh.class.php index 910d68cc50..6ebb979fd1 100644 --- a/lib/dbh/dbh.class.php +++ b/lib/dbh/dbh.class.php @@ -255,7 +255,8 @@ class dbh public function formatDmSQL($sql) { $sql = trim($sql); - $sql = str_replace(array('\r', '\n'), ' ', $sql); + /* '\\\\n' try to compatible screen json like \u0232\\nBug. */ + $sql = str_replace(array('\\\\n', '\r', '\n'), ' ', $sql); $sql = $this->formatFunction($sql); $actionPos = strpos($sql, ' '); diff --git a/module/admin/control.php b/module/admin/control.php index 3cea1d7d4a..7705fca59f 100755 --- a/module/admin/control.php +++ b/module/admin/control.php @@ -81,7 +81,7 @@ class admin extends control */ public function ajaxSetZentaoData() { - if(helper::isIntranet()) return $this->send(array('result' => 'fail')); + if(helper::isIntranet()) return $this->send(array('result' => 'ignore')); $hasInternet = $this->admin->checkInternet(); diff --git a/module/block/control.php b/module/block/control.php index f831400eef..46d2d24136 100755 --- a/module/block/control.php +++ b/module/block/control.php @@ -381,7 +381,7 @@ class block extends control $this->view->tutorialed = $this->loadModel('tutorial')->getTutorialed(); $cacheKey = 'welcomeBlockData'; - if($this->config->cache->enable and $this->cache->has($cacheKey)) + if(helper::isCacheEnabled() && $this->cache->has($cacheKey)) { $data = $this->cache->get($cacheKey); } @@ -418,7 +418,7 @@ class block extends control */ public function contribute() { - if($this->config->cache->enable && $this->cache->has('contributeBlockData')) + if(helper::isCacheEnabled() && $this->cache->has('contributeBlockData')) { $data = $this->cache->get('contributeBlockData'); } @@ -984,7 +984,7 @@ class block extends control } $cacheKey = __FUNCTION__ . $status . $count . $excludedModel; - if($this->config->cache->enable and $this->cache->has($cacheKey)) + if(helper::isCacheEnabled() && $this->cache->has($cacheKey)) { $projects = $this->cache->get($cacheKey); } @@ -2037,7 +2037,7 @@ class block extends control $this->app->loadClass('pager', $static = true); $pager = new pager(0, 3, 1); $cacheKey = __FUNCTION__; - if($this->config->cache->enable and $this->cache->has($cacheKey)) + if(helper::isCacheEnabled() && $this->cache->has($cacheKey)) { $this->app->loadLang('project'); $projects = $this->cache->get($cacheKey); diff --git a/module/block/js/dashboard.js b/module/block/js/dashboard.js index 63f476ff44..4cea7405c6 100644 --- a/module/block/js/dashboard.js +++ b/module/block/js/dashboard.js @@ -58,14 +58,17 @@ function resizeBlock(blockID, width, callback) * * @param object $panel * @param function afterRefresh + * @param number forceRefresh * @access public * @return void */ -function refreshBlock($panel, afterRefresh) +function refreshBlock($panel, afterRefresh, forceRefresh = 0) { var url = $panel.data('url'); + var headers = {}; + if(forceRefresh) headers['X-Zt-Refresh'] = forceRefresh; $panel.addClass('load-indicator loading'); - $.ajax({url: url, dataType: 'html'}).done(function(data) + $.ajax({url: url, dataType: 'html', headers: headers}).done(function(data) { var $data = $(data); if($data.hasClass('panel')) $panel.empty().append($data.children()); @@ -284,7 +287,7 @@ $(function() always: function(){sortMessager.isShow && sortMessager.hide();} }).on('click', '.refresh-panel', function() { - refreshBlock($(this).closest('.panel')); + refreshBlock($(this).closest('.panel'), null, 1); }); }); diff --git a/module/bug/control.php b/module/bug/control.php index 0041c667f4..bd318c6270 100755 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -166,7 +166,7 @@ class bug extends control /* Get executions. */ $cacheKey = "bugBrowse{$this->projectID}"; - if($this->config->cache->enable && $this->cache->has($cacheKey)) + if(helper::isCacheEnabled() && $this->cache->has($cacheKey)) { $executions = $this->cache->get($cacheKey); } diff --git a/module/execution/control.php b/module/execution/control.php index 7874a3750b..aefc876ced 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -3819,13 +3819,34 @@ class execution extends control * @param int $executionID * @param string $module * @param string $method - * @param mix $extra + * @param mixed $extra * @access public * @return void */ public function ajaxGetDropMenu($executionID, $module, $method, $extra) { - $orderedExecutions = array(); + $this->view->link = $this->execution->getLink($module, $method, $extra); + $this->view->module = $module; + $this->view->method = $method; + $this->view->executionID = $executionID; + $this->view->extra = $extra; + + $cacheProjectsKey = 'execution|dropmenu|project'; + $cacheExecutionsKey = 'execution|dropmenu|executions'; + + if(helper::isCacheEnabled()) + { + $projects = $this->cache->get($cacheProjectsKey); + $projectExecutions = $this->cache->get($cacheExecutionsKey); + + if(!empty($projects) && !empty($projectExecutions)) + { + $this->view->projects = $projects; + $this->view->projectExecutions = $projectExecutions; + $this->display(); + return; + } + } $projects = $this->loadModel('program')->getProjectList(0, 'all', 0, 'order_asc', null, 0, 0, true); $executionGroups = $this->dao->select('*')->from(TABLE_EXECUTION) @@ -3842,7 +3863,8 @@ class execution extends control ->andWhere('type')->eq('execution') ->fetchGroup('root', 'account'); - $projectPairs = array(); + $projectPairs = array(); + $orderedExecutions = array(); foreach($projects as $project) { $executions = zget($executionGroups, $project->id, array()); @@ -3878,13 +3900,14 @@ class execution extends control $projectExecutions[$execution->project][] = $execution; } - $this->view->link = $this->execution->getLink($module, $method, $extra); - $this->view->module = $module; - $this->view->method = $method; - $this->view->executionID = $executionID; - $this->view->extra = $extra; - $this->view->projects = $projectPairs; - $this->view->projectExecutions = $projectExecutions; + if($this->config->cache->enable) + { + $this->cache->set($cacheProjectsKey, $projectPairs); + $this->cache->set($cacheExecutionsKey, $projectExecutions); + } + + $this->view->projects = $projectPairs; + $this->view->projectExecutions = $projectExecutions; $this->display(); } diff --git a/module/execution/model.php b/module/execution/model.php index bc7e4ca317..70a0548461 100755 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -2297,7 +2297,7 @@ class executionModel extends model } /** - * Get full name of executons. + * Get full name of executions. * @param array $executions * @access public * @return array diff --git a/module/index/control.php b/module/index/control.php index b4f6cef1e2..1d89e23cd5 100644 --- a/module/index/control.php +++ b/module/index/control.php @@ -37,7 +37,7 @@ class index extends control if($this->get->open) $open = $this->get->open; $latestVersionList = array(); - if(isset($this->config->global->latestVersionList)) $latestVersionList = json_decode($this->config->global->latestVersionList); + if(isset($this->config->global->latestVersionList)) $latestVersionList = json_decode($this->config->global->latestVersionList, true); $this->view->title = $this->lang->index->common; $this->view->open = helper::safe64Decode($open); diff --git a/module/index/view/index.html.php b/module/index/view/index.html.php index e67c0e8787..b1239b9066 100644 --- a/module/index/view/index.html.php +++ b/module/index/view/index.html.php @@ -133,15 +133,15 @@ js::set('isIntranet', helper::isIntranet());
-

name;?>

+

-
explain;?>
+
- name != $lastVersion->name):?> +