diff --git a/db/zentao.sql b/db/zentao.sql index 9457583bc7..a441950b55 100644 --- a/db/zentao.sql +++ b/db/zentao.sql @@ -858,7 +858,7 @@ CREATE TABLE IF NOT EXISTS `zt_searchdict` ( ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- DROP TABLE IF EXISTS `zt_searchindex`; CREATE TABLE IF NOT EXISTS `zt_searchindex` ( - `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `objectType` char(20) NOT NULL, `objectID` mediumint(9) NOT NULL, `title` text NOT NULL, diff --git a/module/bug/control.php b/module/bug/control.php index 0d64822484..ca709ddd2c 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -1298,9 +1298,6 @@ class bug extends control $this->qa->setMenu($this->products, $productID, $bug->branch); $this->view->title = $this->products[$productID] . $this->lang->colon . $this->lang->bug->resolve; - $this->view->position[] = html::a($this->createLink('bug', 'browse', "productID=$productID"), $this->products[$productID]); - $this->view->position[] = $this->lang->bug->resolve; - $this->view->bug = $bug; $this->view->users = $users; $this->view->assignedTo = $assignedTo; diff --git a/module/search/control.php b/module/search/control.php index f4d6e5e5ab..e0baa17683 100644 --- a/module/search/control.php +++ b/module/search/control.php @@ -166,7 +166,8 @@ class search extends control } else { - return $this->send(array('result' => 'unfinished', 'message' => sprintf($this->lang->search->buildResult, zget($this->lang->searchObjects, ($result['type'] == 'case' ? 'testcase' : $result['type']), $result['type']), $result['count']),'next' => inlink('buildIndex', "type={$result['type']}&lastID={$result['lastID']}") )); + $type = zget($this->lang->searchObjects, ($result['type'] == 'case' ? 'testcase' : $result['type']), $result['type']); + return $this->send(array('result' => 'unfinished', 'message' => sprintf($this->lang->search->buildResult, $type, $type, $result['count']), 'type' => $type, 'count' => $result['count'], 'next' => inlink('buildIndex', "type={$result['type']}&lastID={$result['lastID']}") )); } } diff --git a/module/search/js/buildindex.js b/module/search/js/buildindex.js index 74df862ea4..7f9fdc4f60 100644 --- a/module/search/js/buildindex.js +++ b/module/search/js/buildindex.js @@ -13,8 +13,19 @@ $(document).ready(function() } else { + className = response.type + 'count'; + $typeCount = $('#resultBox .' + className) + if($typeCount.length == 0) + { + $('#resultBox').append("
  • " + response.message + "
  • "); + } + else + { + count = parseInt($typeCount.html()) + parseInt(response.count); + $typeCount.html(count); + } + $('#execButton').attr('href', response.next); - $('#resultBox').append("
  • " + response.message + "
  • "); return $('#execButton').click(); } }); diff --git a/module/search/lang/de.php b/module/search/lang/de.php index d37d7d28bc..6097774685 100644 --- a/module/search/lang/de.php +++ b/module/search/lang/de.php @@ -68,7 +68,7 @@ $lang->search->preview = 'Preview'; $lang->search->result = 'Search Results'; $lang->search->buildSuccessfully = 'Search index initialized.'; $lang->search->executeInfo = '%s search results for you in %s seconds.'; -$lang->search->buildResult = 'Created index %s and added %s records.'; +$lang->search->buildResult = "Create index %s and created %s records."; $lang->search->modules['all'] = 'All'; $lang->search->modules['task'] = 'Task'; diff --git a/module/search/lang/en.php b/module/search/lang/en.php index b35e74c92b..0ee2b29838 100644 --- a/module/search/lang/en.php +++ b/module/search/lang/en.php @@ -68,7 +68,7 @@ $lang->search->preview = 'Preview'; $lang->search->result = 'Search Results'; $lang->search->buildSuccessfully = 'Search index initialized.'; $lang->search->executeInfo = '%s search results for you in %s seconds.'; -$lang->search->buildResult = 'Created index %s and added %s records.'; +$lang->search->buildResult = "Create index %s and created %s records."; $lang->search->modules['all'] = 'All'; $lang->search->modules['task'] = 'Task'; diff --git a/module/search/lang/fr.php b/module/search/lang/fr.php index c385e47934..47970e082f 100644 --- a/module/search/lang/fr.php +++ b/module/search/lang/fr.php @@ -68,7 +68,7 @@ $lang->search->preview = 'Preview'; $lang->search->result = 'Search Results'; $lang->search->buildSuccessfully = 'Search index initialized.'; $lang->search->executeInfo = '%s search results for you in %s seconds.'; -$lang->search->buildResult = 'Created index %s and added %s records.'; +$lang->search->buildResult = "Create index %s and created %s records."; $lang->search->modules['all'] = 'All'; $lang->search->modules['task'] = 'Task'; diff --git a/module/search/lang/vi.php b/module/search/lang/vi.php index 4d8a3132eb..a2cb4d565b 100644 --- a/module/search/lang/vi.php +++ b/module/search/lang/vi.php @@ -68,7 +68,7 @@ $lang->search->preview = 'Preview'; $lang->search->result = 'Kết quả tìm kiếm'; $lang->search->buildSuccessfully = 'Tìm kiếm khởi tạo chỉ mục.'; $lang->search->executeInfo = '%s kết quả tìm kiếm trong %s giây'; -$lang->search->buildResult = 'Chỉ mục được tao %s và được thêm %s mục'; +$lang->search->buildResult = "Create index %s and created %s records."; $lang->search->modules['all'] = 'Tất cả'; $lang->search->modules['task'] = 'Nhiệm vụ'; diff --git a/module/search/lang/zh-cn.php b/module/search/lang/zh-cn.php index 9ec02c18d1..180076618f 100644 --- a/module/search/lang/zh-cn.php +++ b/module/search/lang/zh-cn.php @@ -68,7 +68,7 @@ $lang->search->preview = '预览'; $lang->search->result = '搜索结果'; $lang->search->buildSuccessfully = '初始化搜索索引成功'; $lang->search->executeInfo = '为您找到相关结果%s个,耗时%s秒'; -$lang->search->buildResult = '创建 %s 索引, 新增 %s 条记录;'; +$lang->search->buildResult = "创建 %s 索引, 已创建 %s 条记录;"; $lang->search->modules['all'] = '全部'; $lang->search->modules['task'] = '任务'; diff --git a/module/search/model.php b/module/search/model.php index a11b3ded2a..3d6ab911fd 100644 --- a/module/search/model.php +++ b/module/search/model.php @@ -684,7 +684,7 @@ class searchModel extends model $index->content = $contentSplited['words']; $this->saveDict($titleSplited['dict'] + $contentSplited['dict']); - $this->dao->replace(TABLE_SEARCHINDEX)->data($index)->exec(); + $this->dao->insert(TABLE_SEARCHINDEX)->data($index)->exec(); return true; } @@ -697,10 +697,15 @@ class searchModel extends model */ public function saveDict($dict) { + static $savedDict; + if(empty($savedDict)) $savedDict = $this->dao->select("`key`")->from(TABLE_SEARCHDICT)->fetchPairs('key', 'key'); foreach($dict as $key => $value) { if(!is_numeric($key) or empty($value) or strlen($key) != 5) continue; - $this->dao->replace(TABLE_SEARCHDICT)->data(array('key' => $key, 'value' => $value))->exec(); + if(isset($savedDict[$key])) continue; + + $this->dao->insert(TABLE_SEARCHDICT)->data(array('key' => $key, 'value' => $value))->exec(); + $savedDict[$key] = $key; } } @@ -1112,7 +1117,14 @@ class searchModel extends model } } - foreach($dataList as $data) $this->saveIndex($module, $data); + $savedIndex = $this->dao->select('*')->from(TABLE_SEARCHINDEX)->where('objectType')->eq($module)->andWhere('objectID')->in(array_keys($dataList))->fetchPairs('objectID', 'objectID'); + $fields = $this->config->search->fields->{$module}; + foreach($dataList as $data) + { + if(empty($fields)) continue; + if(isset($savedIndex[$data->{$fields->id}])) continue; + $this->saveIndex($module, $data); + } return array('type' => $module, 'count' => count($dataList), 'lastID' => max(array_keys($dataList))); } }