From d2fb9520095d0cbae3a73b30ffcf0cc0ccd41a31 Mon Sep 17 00:00:00 2001 From: wangchunsheng Date: Thu, 14 Jan 2010 06:18:55 +0000 Subject: [PATCH] + add build module. --- module/build/control.php | 99 +++++++++++++++++++++++++++++++ module/build/lang/zh-cn.php | 40 +++++++++++++ module/build/model.php | 79 ++++++++++++++++++++++++ module/build/view/create.html.php | 65 ++++++++++++++++++++ module/build/view/edit.html.php | 64 ++++++++++++++++++++ 5 files changed, 347 insertions(+) create mode 100644 module/build/control.php create mode 100644 module/build/lang/zh-cn.php create mode 100644 module/build/model.php create mode 100644 module/build/view/create.html.php create mode 100644 module/build/view/edit.html.php diff --git a/module/build/control.php b/module/build/control.php new file mode 100644 index 0000000000..cb128065c0 --- /dev/null +++ b/module/build/control.php @@ -0,0 +1,99 @@ +. + * + * @copyright Copyright: 2009 Chunsheng Wang + * @author Chunsheng Wang + * @package build + * @version $$ + * @link http://www.zentao.cn + */ +class build extends control +{ + /* 添加build。*/ + public function create($projectID) + { + if(!empty($_POST)) + { + $this->build->create($projectID); + if(dao::isError()) die(js::error(dao::getError())); + die(js::locate($this->createLink('project', 'build', "project=$projectID"), 'parent')); + } + + /* 设置菜单。*/ + $this->loadModel('project')->setMenu($this->project->getPairs(), $projectID); + + /* 赋值。*/ + $this->view->header->title = $this->lang->build->create; + $this->view->products = $this->project->getProducts($projectID); + $this->view->users = $this->loadModel('user')->getPairs(); + $this->display(); + } + + /* 编辑build。*/ + public function edit($buildID) + { + if(!empty($_POST)) + { + $this->build->update($buildID); + if(dao::isError()) die(js::error(dao::getError())); + die(js::locate($this->createLink('project', 'build', "projectID={$this->post->project}"), 'parent')); + } + + /* 设置菜单。*/ + $build = $this->build->getById((int)$buildID); + $this->loadModel('project')->setMenu($this->project->getPairs(), $build->project); + + /* 赋值。*/ + $this->view->header->title = $this->lang->build->edit; + $this->view->position[] = $this->lang->build->edit; + $this->view->products = $this->project->getProducts($build->project); + $this->view->users = $this->loadModel('user')->getPairs(); + $this->view->build = $build; + $this->display(); + } + + /* 查看build。*/ + public function view($buildID) + { + /* 设置菜单。*/ + $build = $this->build->getById((int)$buildID); + $this->loadModel('project')->setMenu($this->project->getPairs(), $build->project); + + /* 赋值。*/ + $this->view->header->title = $this->lang->build->view; + $this->view->position[] = $this->lang->build->view; + $this->view->products = $this->project->getProducts($build->project); + $this->view->users = $this->loadModel('user')->getPairs(); + $this->view->build = $build; + $this->display(); + } + + /* 删除build。*/ + public function delete($buildID, $confirm = 'no') + { + if($confirm == 'no') + { + die(js::confirm($this->lang->build->confirmDelete, $this->createLink('build', 'delete', "buildID=$buildID&confirm=yes"))); + } + else + { + $build = $this->build->getById($buildID); + $this->build->delete($buildID); + die(js::locate($this->createLink('project', 'build', "projectID=$build->project"), 'parent')); + } + } +} diff --git a/module/build/lang/zh-cn.php b/module/build/lang/zh-cn.php new file mode 100644 index 0000000000..4dfb25b609 --- /dev/null +++ b/module/build/lang/zh-cn.php @@ -0,0 +1,40 @@ +. + * + * @copyright Copyright: 2009 Chunsheng Wang + * @author Chunsheng Wang + * @package build + * @version $Id$ + * @link http://www.zentao.cn + */ +$lang->build->common = 'Build'; +$lang->build->create = "创建Build"; +$lang->build->edit = "编辑Build"; +$lang->build->delete = "删除Build"; +$lang->build->view = "Build详情"; + +$lang->build->confirmDelete = "您确认删除该build吗?"; + +$lang->build->id = 'ID'; +$lang->build->product = '产品'; +$lang->build->project = '项目'; +$lang->build->name = '名称编号'; +$lang->build->date = 'Build日期'; +$lang->build->builder = '构建者'; +$lang->build->scmPath = '源代码地址'; +$lang->build->filePath = '存储地址'; +$lang->build->desc = '描述'; diff --git a/module/build/model.php b/module/build/model.php new file mode 100644 index 0000000000..502c346594 --- /dev/null +++ b/module/build/model.php @@ -0,0 +1,79 @@ +. + * + * @copyright Copyright: 2009 Chunsheng Wang + * @author Chunsheng Wang + * @package build + * @version $Id$ + * @link http://www.zentao.cn + */ +?> +dao->select('t1.*, t2.name as projectName, t3.name as productName') + ->from(TABLE_BUILD)->alias('t1') + ->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project = t2.id') + ->leftJoin(TABLE_PRODUCT)->alias('t3')->on('t1.product = t3.id') + ->where('t1.id')->eq((int)$buildID) + ->orderBy('t1.id DESC') + ->fetch(); + } + + /* 查找项目中的build列表。*/ + public function getProjectBuilds($projectID) + { + return $this->dao->select('t1.*, t2.name as projectName, t3.name as productName') + ->from(TABLE_BUILD)->alias('t1') + ->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project = t2.id') + ->leftJoin(TABLE_PRODUCT)->alias('t3')->on('t1.product = t3.id') + ->where('t1.project')->eq((int)$projectID) + ->orderBy('t1.id DESC') + ->fetchAll(); + } + + /* 创建。*/ + public function create($projectID) + { + $build = fixer::input('post') + ->stripTags('name') + ->specialChars('desc') + ->add('project', (int)$projectID) + ->get(); + $this->dao->insert(TABLE_BUILD)->data($build)->autoCheck()->batchCheck('name,date,builder', 'notempty')->exec(); + if(!dao::isError()) return $this->dao->lastInsertID(); + } + + /* 编辑。*/ + public function update($buildID) + { + $build = fixer::input('post') + ->stripTags('name') + ->specialChars('desc') + ->get(); + $this->dao->update(TABLE_BUILD)->data($build)->autoCheck()->batchCheck('name,date,builder', 'notempty')->where('id')->eq((int)$buildID)->exec(); + } + + /* 删除build。*/ + public function delete($buildID) + { + return $this->dao->delete()->from(TABLE_BUILD)->where('id')->eq((int)$buildID)->exec(); + } +} diff --git a/module/build/view/create.html.php b/module/build/view/create.html.php new file mode 100644 index 0000000000..7a16ef4ae7 --- /dev/null +++ b/module/build/view/create.html.php @@ -0,0 +1,65 @@ +. + * + * @copyright Copyright: 2009 Chunsheng Wang + * @author Chunsheng Wang + * @package build + * @version $Id$ + * @link http://www.zentao.cn + */ +?> + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
build->create;?>
build->product;?>
build->name;?>
build->builder;?>user->account, 'class="select-3"');?>
build->date;?>' />
build->scmPath;?>
build->filePath;?>
build->desc;?>
+
+
+ diff --git a/module/build/view/edit.html.php b/module/build/view/edit.html.php new file mode 100644 index 0000000000..83a2318821 --- /dev/null +++ b/module/build/view/edit.html.php @@ -0,0 +1,64 @@ +. + * + * @copyright Copyright: 2009 Chunsheng Wang + * @author Chunsheng Wang + * @package build + * @version $Id$ + * @link http://www.zentao.cn + */ +?> + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
build->edit;?>
build->product;?>product);?>
build->name;?>
build->builder;?>builder, 'class="select-3"');?>
build->date;?>
build->scmPath;?>
build->filePath;?>
build->desc;?>
project);?>
+
+
+