From 1e3c913063ab68c71ad93e2feb0a1ff39fb3fcd4 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Tue, 22 Dec 2015 16:55:25 +0800 Subject: [PATCH] * fix bug #777. --- lib/dao/dao.class.php | 13 +++++++------ module/doc/control.php | 18 ++++++++++++++++-- module/doc/lang/en.php | 2 ++ module/doc/lang/zh-cn.php | 2 ++ module/story/model.php | 4 ++-- www/js/my.full.js | 2 +- 6 files changed, 30 insertions(+), 11 deletions(-) diff --git a/lib/dao/dao.class.php b/lib/dao/dao.class.php index c81772b6ae..d63b66d829 100755 --- a/lib/dao/dao.class.php +++ b/lib/dao/dao.class.php @@ -534,7 +534,7 @@ class dao * @access public * @return object the dao object self. */ - public function page($pager) + public function page($pager, $distinctField = '') { if(!is_object($pager)) return $this; @@ -542,11 +542,12 @@ class dao if($pager->recTotal == 0) { /* Get the SELECT, FROM position, thus get the fields, replace it by count(*). */ - $sql = $this->get(); - $selectPOS = strpos($sql, 'SELECT') + strlen('SELECT'); - $fromPOS = strpos($sql, 'FROM'); - $fields = substr($sql, $selectPOS, $fromPOS - $selectPOS ); - $sql = str_replace($fields, ' COUNT(*) AS recTotal ', $sql); + $sql = $this->get(); + $selectPOS = strpos($sql, 'SELECT') + strlen('SELECT'); + $fromPOS = strpos($sql, 'FROM'); + $fields = substr($sql, $selectPOS, $fromPOS - $selectPOS ); + $countField = $distinctField ? 'distinct ' . $distinctField : '*'; + $sql = str_replace($fields, " COUNT($countField) AS recTotal ", $sql); /* Remove the part after order and limit. */ $subLength = strlen($sql); diff --git a/module/doc/control.php b/module/doc/control.php index 98d4728065..48b8a36842 100644 --- a/module/doc/control.php +++ b/module/doc/control.php @@ -307,6 +307,20 @@ class doc extends control $moduleOptionMenu = $this->tree->getOptionMenu($libID, 'customdoc', $startModuleID = 0); } + $products = $projectID == 0 ? $this->product->getPairs() : $this->project->getProducts($projectID, false); + if($libID == 'product' and empty($products)) + { + echo js::alert($this->lang->doc->errorEmptyProduct); + die(js::locate('back')); + } + + $projects = $this->project->getPairs('all'); + if($libID == 'project' and ($projects)) + { + echo js::alert($this->lang->doc->errorEmptyProject); + die(js::locate('back')); + } + $this->view->title = $this->libs[$libID] . $this->lang->colon . $this->lang->doc->create; $this->view->position[] = html::a($this->createLink('doc', 'browse', "libID=$libID"), $this->libs[$libID]); $this->view->position[] = $this->lang->doc->create; @@ -316,8 +330,8 @@ class doc extends control $this->view->moduleID = $moduleID; $this->view->productID = $productID; $this->view->projectID = $projectID; - $this->view->products = $projectID == 0 ? $this->product->getPairs() : $this->project->getProducts($projectID, false); - $this->view->projects = $this->loadModel('project')->getPairs('all'); + $this->view->products = $products; + $this->view->projects = $projects; $this->display(); } diff --git a/module/doc/lang/en.php b/module/doc/lang/en.php index 9e5342e212..e44643999f 100644 --- a/module/doc/lang/en.php +++ b/module/doc/lang/en.php @@ -67,6 +67,8 @@ $lang->doc->types['text'] = 'Html'; $lang->doc->confirmDelete = "Are you sure to delete this doc?"; $lang->doc->confirmDeleteLib = " Are you sure to delete this doc library?"; $lang->doc->errorEditSystemDoc = "System doc library needn't edit"; +$lang->doc->errorEmptyProduct = "{$lang->productCommon} is empty, can not create doc."; +$lang->doc->errorEmptyProject = "{$lang->projectCommon} is empty, can not create doc."; $lang->doc->placeholder = new stdclass(); $lang->doc->placeholder->url = 'url'; diff --git a/module/doc/lang/zh-cn.php b/module/doc/lang/zh-cn.php index a4ac6cc81f..cbd8a2a871 100644 --- a/module/doc/lang/zh-cn.php +++ b/module/doc/lang/zh-cn.php @@ -67,6 +67,8 @@ $lang->doc->types['text'] = '网页'; $lang->doc->confirmDelete = "您确定删除该文档吗?"; $lang->doc->confirmDeleteLib = "您确定删除该文档库吗?"; $lang->doc->errorEditSystemDoc = "系统文档库无需修改。"; +$lang->doc->errorEmptyProduct = "没有{$lang->productCommon},无法创建文档"; +$lang->doc->errorEmptyProject = "没有{$lang->projectCommon},无法创建文档"; $lang->doc->placeholder = new stdclass(); $lang->doc->placeholder->url = '相应的链接地址'; diff --git a/module/story/model.php b/module/story/model.php index cad7e9187c..002a1202b4 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -1311,7 +1311,7 @@ class storyModel extends model public function getProjectStories($projectID = 0, $orderBy = 'pri_asc,id_desc', $type = 'byModule', $param = 0, $pager = null) { $modules = ($type == 'byModule' and $param) ? $this->dao->select('*')->from(TABLE_MODULE)->where('path')->like("%,$param,%")->andWhere('type')->eq('story')->fetchPairs('id', 'id') : array(); - $stories = $this->dao->select('t1.*, t2.*,t3.branch as productBranch,t4.type as productType, t2.version as version')->from(TABLE_PROJECTSTORY)->alias('t1') + $stories = $this->dao->select('distinct t1.*, t2.*,t3.branch as productBranch,t4.type as productType,t2.version as version')->from(TABLE_PROJECTSTORY)->alias('t1') ->leftJoin(TABLE_STORY)->alias('t2')->on('t1.story = t2.id') ->leftJoin(TABLE_PROJECTPRODUCT)->alias('t3')->on('t1.project = t3.project') ->leftJoin(TABLE_PRODUCT)->alias('t4')->on('t2.product = t4.id') @@ -1321,7 +1321,7 @@ class storyModel extends model ->beginIF($type == 'byModule' and $param)->andWhere('t2.module')->in($modules)->fi() ->andWhere('t2.deleted')->eq(0) ->orderBy($orderBy) - ->page($pager) + ->page($pager, 't2.id') ->fetchAll('id'); $query = $this->dao->get(); diff --git a/www/js/my.full.js b/www/js/my.full.js index aa060d24db..a051a3b0d9 100644 --- a/www/js/my.full.js +++ b/www/js/my.full.js @@ -1379,7 +1379,7 @@ function fixedTfootAction(formID) var tfootOffset = $tfoot.offset().top + 30; var windowH = $(window).height(); var tableWidth = $table.width(); - if(tfootOffset > windowH) + if(tfootOffset > windowH + $(window).scrollTop()) { $tfoot.addClass('fixedTfootAction'); $tfoot.width(tableWidth);