From 7f1652b1b23bf4680b33599d984f9242b9b7e4ca Mon Sep 17 00:00:00 2001 From: wangyidong Date: Thu, 13 Dec 2012 08:07:07 +0000 Subject: [PATCH] * adjust for ajax get search form. --- module/bug/control.php | 2 +- module/bug/view/browse.html.php | 1 - module/company/control.php | 2 +- module/company/view/dynamic.html.php | 1 - module/doc/control.php | 2 +- module/doc/view/browse.html.php | 1 - module/product/control.php | 2 +- module/product/view/browse.html.php | 1 - module/project/control.php | 6 +++--- module/project/view/importbug.html.php | 1 - module/project/view/linkstory.html.php | 5 +---- module/project/view/task.html.php | 1 - module/search/control.php | 10 ++++++---- module/search/model.php | 19 ++++++++----------- module/testcase/control.php | 2 +- module/testcase/view/browse.html.php | 1 - module/testtask/control.php | 2 +- module/testtask/view/linkcase.html.php | 5 +---- www/index.php | 7 +++++++ www/js/my.full.js | 2 +- 20 files changed, 33 insertions(+), 40 deletions(-) diff --git a/module/bug/control.php b/module/bug/control.php index 92f7263d80..78cd1ed274 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -121,6 +121,7 @@ class bug extends control $this->config->bug->search['params']['project']['values'] = $this->product->getProjectPairs($productID); $this->config->bug->search['params']['openedBuild']['values'] = $this->loadModel('build')->getProductBuildPairs($productID); $this->config->bug->search['params']['resolvedBuild']['values'] = $this->build->getProductBuildPairs($productID); + $this->loadModel('search')->setSearchParams($this->config->bug->search); $users = $this->user->getPairs('noletter'); @@ -148,7 +149,6 @@ class bug extends control $this->view->productID = $productID; $this->view->productName = $this->products[$productID]; $this->view->moduleTree = $this->tree->getTreeMenu($productID, $viewType = 'bug', $startModuleID = 0, array('treeModel', 'createBugLink')); - $this->view->formUrl = $this->loadModel('search')->getFormUrl($this->config->bug->search); $this->view->browseType = $browseType; $this->view->bugs = $bugs; $this->view->users = $users; diff --git a/module/bug/view/browse.html.php b/module/bug/view/browse.html.php index 0f5ca0934b..c37a2ef47d 100644 --- a/module/bug/view/browse.html.php +++ b/module/bug/view/browse.html.php @@ -15,7 +15,6 @@ diff --git a/module/company/control.php b/module/company/control.php index 3f7e40e303..3a959332a1 100644 --- a/module/company/control.php +++ b/module/company/control.php @@ -258,10 +258,10 @@ class company extends control $this->config->company->dynamic->search['params']['project']['values'] = $projects; $this->config->company->dynamic->search['params']['product']['values'] = $products; $this->config->company->dynamic->search['params']['actor']['values'] = $users; + $this->loadModel('search')->setSearchParams($this->config->company->dynamic->search); /* Assign. */ $this->view->browseType = $browseType; - $this->view->formUrl = $this->loadModel('search')->getFormUrl($this->config->company->dynamic->search); $this->view->account = $account; $this->view->product = $product; $this->view->project = $project; diff --git a/module/company/view/dynamic.html.php b/module/company/view/dynamic.html.php index c917eb64e7..9375090dc3 100644 --- a/module/company/view/dynamic.html.php +++ b/module/company/view/dynamic.html.php @@ -14,7 +14,6 @@
config->doc->search['params']['project']['values'] = array(''=>'') + $this->project->getPairs() + array('all'=>$this->lang->doc->allProject); $this->config->doc->search['params']['lib']['values'] = array(''=>'') + $this->libs; $this->config->doc->search['params']['type']['values'] = array(''=>'') + $this->config->doc->search['params']['type']['values']; + $this->loadModel('search')->setSearchParams($this->config->doc->search); /* Get the modules. */ if($libID == 'product' or $libID == 'project') @@ -139,7 +140,6 @@ class doc extends control $this->config->doc->search['params']['module']['values'] = array(''=>'') + $moduleOptionMenu; $this->view->libID = $libID; - $this->view->formUrl = $this->loadModel('search')->getFormUrl($this->config->doc->search); $this->view->libName = $this->libs[$libID]; $this->view->moduleID = $moduleID; $this->view->moduleTree = $moduleTree; diff --git a/module/doc/view/browse.html.php b/module/doc/view/browse.html.php index cab8401065..950afeb723 100644 --- a/module/doc/view/browse.html.php +++ b/module/doc/view/browse.html.php @@ -16,7 +16,6 @@
diff --git a/module/product/control.php b/module/product/control.php index ba08ae5419..30446cee43 100644 --- a/module/product/control.php +++ b/module/product/control.php @@ -132,6 +132,7 @@ class product extends control $this->config->product->search['params']['plan']['values'] = $this->loadModel('productplan')->getPairs($productID); $this->config->product->search['params']['product']['values'] = array($productID => $this->products[$productID], 'all' => $this->lang->product->allProduct); $this->config->product->search['params']['module']['values'] = $this->tree->getOptionMenu($productID, $viewType = 'story', $startModuleID = 0); + $this->loadModel('search')->setSearchParams($this->config->product->search); $this->view->productID = $productID; $this->view->productName = $this->products[$productID]; @@ -144,7 +145,6 @@ class product extends control $this->view->orderBy = $orderBy; $this->view->browseType = $browseType; $this->view->moduleID = $moduleID; - $this->view->formUrl = $this->loadModel('search')->getFormUrl($this->config->product->search); $this->view->treeClass = $browseType == 'bymodule' ? '' : 'hidden'; $this->display(); } diff --git a/module/product/view/browse.html.php b/module/product/view/browse.html.php index 465fd81b3a..f31fcda1cb 100644 --- a/module/product/view/browse.html.php +++ b/module/product/view/browse.html.php @@ -15,7 +15,6 @@
diff --git a/module/project/control.php b/module/project/control.php index 399302f978..fbe5f9f531 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -178,6 +178,7 @@ class project extends control $this->config->project->search['queryID'] = $queryID; $this->config->project->search['params']['project']['values'] = array(''=>'', $projectID => $this->projects[$projectID], 'all' => $this->lang->project->allProject); $this->config->project->search['params']['module']['values'] = $this->tree->getOptionMenu($projectID, $viewType = 'task', $startModuleID = 0); + $this->loadModel('search')->setSearchParams($this->config->project->search); /* Assign. */ $this->view->tasks = $tasks; @@ -193,7 +194,6 @@ class project extends control $this->view->projectID = $projectID; $this->view->project = $project; $this->view->moduleID = $moduleID; - $this->view->formUrl = $this->loadModel('search')->getFormUrl($this->config->project->search); $this->view->moduleTree = $this->tree->getTreeMenu($projectID, $viewType = 'task', $startModuleID = 0, array('treeModel', 'createTaskLink')); $this->view->projectTree = $this->project->tree(); @@ -452,10 +452,10 @@ class project extends control unset($this->config->bug->search['params']['resolvedBuild']); unset($this->config->bug->search['params']['resolvedDate']); unset($this->config->bug->search['params']['closedDate']); + $this->loadModel('search')->setSearchParams($this->config->bug->search); /* Assign. */ $this->view->header = $header; - $this->view->formUrl = $this->loadModel('search')->getFormUrl($this->config->bug->search); $this->view->pager = $pager; $this->view->bugs = $bugs; $this->view->recTotal = $pager->recTotal; @@ -1171,6 +1171,7 @@ class project extends control $this->config->product->search['queryID'] = $queryID; $this->config->product->search['params']['product']['values'] = $products + array('all' => $this->lang->product->allProductsOfProject); $this->config->product->search['params']['plan']['values'] = $this->loadModel('productplan')->getForProducts($products); + $this->loadModel('search')->setSearchParams($this->config->product->search); $header['title'] = $project->name . $this->lang->colon . $this->lang->project->linkStory; $position[] = html::a($browseLink, $project->name); @@ -1193,7 +1194,6 @@ class project extends control $this->view->allStories = $allStories; $this->view->prjStories = $prjStories; $this->view->browseType = $browseType; - $this->view->formUrl = $this->loadModel('search')->getFormUrl($this->config->product->search); $this->view->users = $this->loadModel('user')->getPairs('noletter'); $this->display(); } diff --git a/module/project/view/importbug.html.php b/module/project/view/importbug.html.php index cd8c1bcbb2..ad1817ed77 100755 --- a/module/project/view/importbug.html.php +++ b/module/project/view/importbug.html.php @@ -18,7 +18,6 @@ $(function(){ $(".preview").colorbox({width:1000, height:700, iframe:true, transition:'elastic', speed:350, scrolling:true}); }) var browseType = ''; -var formUrl = '';
diff --git a/module/project/view/linkstory.html.php b/module/project/view/linkstory.html.php index e0f822e7f5..5f27f4b612 100644 --- a/module/project/view/linkstory.html.php +++ b/module/project/view/linkstory.html.php @@ -59,8 +59,5 @@ - + diff --git a/module/project/view/task.html.php b/module/project/view/task.html.php index edc26de589..aacd2c1074 100644 --- a/module/project/view/task.html.php +++ b/module/project/view/task.html.php @@ -17,7 +17,6 @@
'>
diff --git a/module/search/control.php b/module/search/control.php index 7075864d70..2e20fb5e32 100644 --- a/module/search/control.php +++ b/module/search/control.php @@ -22,11 +22,13 @@ class search extends control * @access public * @return void */ - public function buildForm($module, $searchFields, $fieldParams, $actionURL, $queryID = 0) + public function buildForm($module = '', $searchFields = '', $fieldParams = '', $actionURL = '', $queryID = 0) { - $searchFields = is_array($searchFields) ? $searchFields : json_decode(helper::safe64Decode($searchFields), true); - $fieldParams = is_array($fieldParams) ? $fieldParams : json_decode(helper::safe64Decode($fieldParams), true); - $actionURL = (strpos($actionURL, '/') !== false) ? $actionURL : helper::safe64Decode($actionURL); + $queryID = (empty($module) and empty($queryID)) ? $this->session->searchParams['queryID'] : $queryID; + $module = empty($module) ? $this->session->searchParams['module'] : $module; + $searchFields = empty($searchFields) ? json_decode($this->session->searchParams['searchFields'], true) : $searchFields; + $fieldParams = empty($fieldParams) ? json_decode($this->session->searchParams['fieldParams'], true) : $fieldParams; + $actionURL = empty($actionURL) ? $this->session->searchParams['actionURL'] : $actionURL; $this->search->initSession($module, $searchFields, $fieldParams); $this->view->module = $module; diff --git a/module/search/model.php b/module/search/model.php index 09f7374287..722a15d0ea 100644 --- a/module/search/model.php +++ b/module/search/model.php @@ -15,23 +15,20 @@ class searchModel extends model { /** - * Get search form URL. + * Set search params to session. * * @param array $searchConfig * @access public * @return void */ - public function getFormUrl($searchConfig) + public function setSearchParams($searchConfig) { - $module = $searchConfig['module']; - $searchFields = $searchConfig['fields']; - $fieldParams = $searchConfig['params']; - $actionURL = $searchConfig['actionURL']; - $queryID = isset($searchConfig['queryID']) ? $searchConfig['queryID'] : 0; - $searchFields = helper::safe64Encode(json_encode($searchFields)); - $fieldParams = helper::safe64Encode(json_encode($fieldParams)); - $actionURL = helper::safe64Encode($actionURL); - return helper::createLink('search', 'buildForm', "module=$module&searchFields=$searchFields&fieldParams=$fieldParams&actionURL=$actionURL&queryID=$queryID"); + $searchParams['module'] = $searchConfig['module']; + $searchParams['searchFields'] = json_encode($searchConfig['fields']); + $searchParams['fieldParams'] = json_encode($searchConfig['params']); + $searchParams['actionURL'] = $searchConfig['actionURL']; + $searchParams['queryID'] = isset($searchConfig['queryID']) ? $searchConfig['queryID'] : 0; + $this->session->set('searchParams', $searchParams); } /** diff --git a/module/testcase/control.php b/module/testcase/control.php index 9b3ef91e1e..b7b5629de6 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -127,6 +127,7 @@ class testcase extends control $this->config->testcase->search['params']['module']['values'] = $this->loadModel('tree')->getOptionMenu($productID, $viewType = 'case'); $this->config->testcase->search['actionURL'] = $this->createLink('testcase', 'browse', "productID=$productID&browseType=bySearch&queryID=myQueryID"); $this->config->testcase->search['queryID'] = $queryID; + $this->loadModel('search')->setSearchParams($this->config->testcase->search); /* Assign. */ $this->view->header->title = $this->products[$productID] . $this->lang->colon . $this->lang->testcase->common; @@ -141,7 +142,6 @@ class testcase extends control $this->view->orderBy = $orderBy; $this->view->browseType = $browseType; $this->view->param = $param; - $this->view->formUrl = $this->loadModel('search')->getFormUrl($this->config->testcase->search); $this->view->treeClass = $browseType == 'bymodule' ? '' : 'hidden'; $this->display(); diff --git a/module/testcase/view/browse.html.php b/module/testcase/view/browse.html.php index b52ddcbb93..f69d0050dc 100644 --- a/module/testcase/view/browse.html.php +++ b/module/testcase/view/browse.html.php @@ -17,7 +17,6 @@
diff --git a/module/testtask/control.php b/module/testtask/control.php index 0f21c0304c..6d1e366325 100644 --- a/module/testtask/control.php +++ b/module/testtask/control.php @@ -353,6 +353,7 @@ class testtask extends control $this->config->testcase->search['params']['product']['values']= array($productID => $this->products[$productID], 'all' => $this->lang->testcase->allProduct); $this->config->testcase->search['params']['module']['values'] = $this->loadModel('tree')->getOptionMenu($productID, $viewType = 'case'); $this->config->testcase->search['actionURL'] = inlink('linkcase', "taskID=$taskID"); + $this->loadModel('search')->setSearchParams($this->config->testcase->search); /* Save session. */ $this->testtask->setMenu($this->products, $productID); @@ -404,7 +405,6 @@ class testtask extends control $this->view->cases = $cases; $this->view->taskID = $taskID; $this->view->pager = $pager; - $this->view->formUrl = $this->loadModel('search')->getFormUrl($this->config->testcase->search); $this->display(); } diff --git a/module/testtask/view/linkcase.html.php b/module/testtask/view/linkcase.html.php index b0f4d44de7..99bb3e8e45 100644 --- a/module/testtask/view/linkcase.html.php +++ b/module/testtask/view/linkcase.html.php @@ -67,8 +67,5 @@
- + diff --git a/www/index.php b/www/index.php index 5ae2052bd8..f09e3ca1e6 100644 --- a/www/index.php +++ b/www/index.php @@ -12,6 +12,7 @@ * @link http://www.zentao.net */ /* Set the error reporting. */ + xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY); error_reporting(0); /* Start output buffer. */ ob_start(); @@ -40,3 +41,9 @@ $app->loadModule(); /* Flush the buffer. */ ob_end_flush(); +$data = xhprof_disable(); +include_once "xhprof_lib/utils/xhprof_lib.php"; +include_once "xhprof_lib/utils/xhprof_runs.php"; +$objXhprofRun = new XHProfRuns_Default(); +$run_id = $objXhprofRun->save_run($data, "xhprof"); +echo $run_id; diff --git a/www/js/my.full.js b/www/js/my.full.js index d9a2381c94..a6a46f3658 100644 --- a/www/js/my.full.js +++ b/www/js/my.full.js @@ -663,7 +663,7 @@ function ajaxGetSearchForm() { if($('#querybox').html() == '') { - $.get(formUrl, function(data){ + $.get(createLink('search', 'buildForm'), function(data){ $('#querybox').html(data); }); }