From 13f1fd6bf7c759abd509e4eab17e51bb3453da2e Mon Sep 17 00:00:00 2001 From: wangyidong Date: Mon, 11 Apr 2016 15:48:58 +0800 Subject: [PATCH] * change for print blok. --- module/block/control.php | 123 +++++++++++++++++++---- module/block/js/admin.js | 14 +-- module/block/model.php | 4 +- module/block/view/bugblock.html.php | 11 +- module/block/view/buildblock.html.php | 37 +++++++ module/block/view/caseblock.html.php | 11 +- module/block/view/listblock.html.php | 13 +++ module/block/view/planblock.html.php | 39 +++++++ module/block/view/productblock.html.php | 11 +- module/block/view/projectblock.html.php | 11 +- module/block/view/releaseblock.html.php | 41 ++++++++ module/block/view/set.html.php | 4 +- module/block/view/setmodule.html.php | 2 +- module/block/view/storyblock.html.php | 4 +- module/block/view/taskblock.html.php | 11 +- module/block/view/testtaskblock.html.php | 41 ++++++++ module/block/view/todoblock.html.php | 11 +- 17 files changed, 321 insertions(+), 67 deletions(-) create mode 100644 module/block/view/buildblock.html.php create mode 100644 module/block/view/listblock.html.php create mode 100644 module/block/view/planblock.html.php create mode 100644 module/block/view/releaseblock.html.php create mode 100644 module/block/view/testtaskblock.html.php diff --git a/module/block/control.php b/module/block/control.php index e671a24f6d..ae1c57c4ab 100644 --- a/module/block/control.php +++ b/module/block/control.php @@ -75,33 +75,32 @@ class block extends control * * @param int $index * @param string $type - * @param int $blockID * @access public * @return void */ - public function set($index, $type, $blockID = 0) + public function set($index, $type, $source = '') { if($_POST) { - $source = isset($this->lang->block->moduleList[$type]) ? $type : ''; - $this->block->save($index, $source, $this->session->blockModule, $blockID); + $source = isset($this->lang->block->moduleList[$source]) ? $source : ''; + $this->block->save($index, $source, $type, $this->session->blockModule); if(dao::isError()) die(js::error(dao::geterror())); die(js::reload('parent')); } - $block = $blockID ? $this->block->getByID($blockID) : $this->block->getBlock($index); + $block = $this->block->getBlock($index); if($block) $type = $block->block; - if(isset($this->lang->block->moduleList[$type])) + if(isset($this->lang->block->moduleList[$source])) { - $func = 'get' . ucfirst($blockID) . 'Params'; - $params = $this->block->$func($type); + $func = 'get' . ucfirst($type) . 'Params'; + $params = $this->block->$func($source); $this->view->params = json_decode($params, true); } - $this->view->type = $type; - $this->view->index = $index; - $this->view->blockID = $blockID; + $this->view->source = $source; + $this->view->type = $type; + $this->view->index = $index; $this->view->block = ($block) ? $block : array(); $this->display(); } @@ -231,7 +230,7 @@ class block extends control $this->get->set('source', $block->source); $this->get->set('blockid', $block->block); $this->get->set('param',base64_encode(json_encode($block->params))); - $html = $this->fetch('block', 'main'); + $html = $this->fetch('block', 'main', "module={$block->source}&index=$index"); } elseif($block->block == 'dynamic') { @@ -306,6 +305,13 @@ class block extends control $func = 'print' . ucfirst($code) . 'Block'; $this->$func($module); + $this->view->moreLink = ''; + if(isset($this->lang->block->modules[$module]->moreLinkList->{$code})) + { + list($moduleName, $method, $vars) = explode('|', sprintf($this->lang->block->modules[$module]->moreLinkList->{$code}, $params->type)); + $this->view->moreLink = $this->createLink($moduleName, $method, $vars); + } + if($this->viewType == 'json') { unset($this->view->app); @@ -325,6 +331,20 @@ class block extends control } } + /** + * Print List block. + * + * @access public + * @return void + */ + public function printListBlock($module = 'product') + { + $func = 'print' . ucfirst($module) . 'Block'; + $this->view->module = $module; + $this->$func(); + + } + /** * Print todo block. * @@ -334,7 +354,6 @@ class block extends control public function printTodoBlock() { $this->view->todos = $this->loadModel('todo')->getList('all', $this->app->user->account, 'wait, doing', $this->viewType == 'json' ? 0 : $this->params->num); - $this->view->listLink = $this->view->sso . $this->view->sign . 'referer=' . base64_encode($this->createLink('my', 'todo', "type=all")); } /** @@ -346,7 +365,6 @@ class block extends control public function printTaskBlock() { $this->view->tasks = $this->loadModel('task')->getUserTasks($this->app->user->account, $this->params->type, $this->viewType == 'json' ? 0 : $this->params->num, null, $this->params->orderBy); - $this->view->listLink = $this->view->sso . $this->view->sign . 'referer=' . base64_encode($this->createLink('my', 'task', "type={$this->params->type}")); } /** @@ -358,7 +376,6 @@ class block extends control public function printBugBlock() { $this->view->bugs = $this->loadModel('bug')->getUserBugs($this->app->user->account, $this->params->type, $this->params->orderBy, $this->viewType == 'json' ? 0 : $this->params->num); - $this->view->listLink = $this->view->sso . $this->view->sign . 'referer=' . base64_encode($this->createLink('my', 'bug', "type={$this->params->type}")); } /** @@ -396,7 +413,26 @@ class block extends control ->fetchAll(); } $this->view->cases = $cases; - $this->view->listLink = $this->view->sso . $this->view->sign . 'referer=' . base64_encode($this->createLink('my', 'testcase', "type={$this->params->type}")); + } + + /** + * Print testtask block. + * + * @access public + * @return void + */ + public function printTesttaskBlock() + { + $this->app->loadLang('testtask'); + $this->view->testtasks = $this->dao->select('t1.*,t2.name as productName,t3.name as buildName,t4.name as projectName')->from(TABLE_TESTTASK)->alias('t1') + ->leftJoin(TABLE_PRODUCT)->alias('t2')->on('t1.product=t2.id') + ->leftJoin(TABLE_BUILD)->alias('t3')->on('t1.build=t3.id') + ->leftJoin(TABLE_PROJECT)->alias('t4')->on('t1.build=t4.id') + ->where('t1.deleted')->eq('0') + ->beginIF($this->params->type != 'all')->andWhere('t1.status')->eq($this->params->type)->fi() + ->orderBy('t1.id desc') + ->beginIF($this->viewType != 'json')->limit($this->params->num)->fi() + ->fetchAll(); } /** @@ -410,9 +446,58 @@ class block extends control $this->app->loadClass('pager', $static = true); $pager = pager::init(0, $this->params->num, 1); $this->view->stories = $this->loadModel('story')->getUserStories($this->app->user->account, $this->params->type, $this->params->orderBy, $this->viewType != 'json' ? $pager : ''); + } - $listLink = $this->createLink('my', 'story', "type={$this->params->type}"); - $this->view->listLink = !isset($this->view->sso) ? $listLink : $this->view->sso . $this->view->sign . 'referer=' . base64_encode($listLink); + /** + * Print plan block. + * + * @access public + * @return void + */ + public function printPlanBlock() + { + $this->app->loadLang('productplan'); + $this->view->plans = $this->dao->select('t1.*,t2.name as productName')->from(TABLE_PRODUCTPLAN)->alias('t1') + ->leftJoin(TABLE_PRODUCT)->alias('t2')->on('t1.product=t2.id') + ->where('t1.deleted')->eq('0') + ->orderBy('t1.begin desc') + ->beginIF($this->viewType != 'json')->limit($this->params->num)->fi() + ->fetchAll(); + } + + /** + * Print releases block. + * + * @access public + * @return void + */ + public function printReleaseBlock() + { + $this->app->loadLang('release'); + $this->view->releases = $this->dao->select('t1.*,t2.name as productName,t3.name as buildName')->from(TABLE_RELEASE)->alias('t1') + ->leftJoin(TABLE_PRODUCT)->alias('t2')->on('t1.product=t2.id') + ->leftJoin(TABLE_BUILD)->alias('t3')->on('t1.build=t3.id') + ->where('t1.deleted')->eq('0') + ->orderBy('t1.id desc') + ->beginIF($this->viewType != 'json')->limit($this->params->num)->fi() + ->fetchAll(); + } + + /** + * Print Build block. + * + * @access public + * @return void + */ + public function printBuildBlock() + { + $this->app->loadLang('build'); + $this->view->builds = $this->dao->select('t1.*,t2.productName')->from(TABLE_BUILD)->alias('t1') + ->leftJoin(TABLE_PRODUCT)->alias('t2')->on('t1.product=t2.id') + ->where('t1.deleted')->eq('0') + ->orderBy('t1.id desc') + ->beginIF($this->viewType != 'json')->limit($this->params->num)->fi() + ->fetchAll(); } /** @@ -426,7 +511,6 @@ class block extends control $this->app->loadClass('pager', $static = true); $pager = pager::init(0, $this->params->num, 1); $this->view->productStats = $this->loadModel('product')->getStats('order_desc', $this->viewType != 'json' ? $pager : ''); - $this->view->listLink = $this->view->sso . $this->view->sign . 'referer=' . base64_encode($this->createLink('product', 'index', "locate=no&productID=" . current($this->view->productStats)->id)); } /** @@ -440,6 +524,5 @@ class block extends control $this->app->loadClass('pager', $static = true); $pager = pager::init(0, $this->params->num, 1); $this->view->projectStats = $this->loadModel('project')->getProjectStats($status = 'undone', $productID = 0, $branch = 0, $itemCounts = 30, $orderBy = 'order_desc', $this->viewType != 'json' ? $pager : ''); - $this->view->listLink = $this->view->sso . $this->view->sign . 'referer=' . base64_encode($this->createLink('my', 'project')); } } diff --git a/module/block/js/admin.js b/module/block/js/admin.js index 1b47f04926..6bb2560f77 100644 --- a/module/block/js/admin.js +++ b/module/block/js/admin.js @@ -35,14 +35,12 @@ function getBlocks(moduleID) * Get rss and html params. * * @param string $type - * @param int $blockID * @access public * @return void */ -function getRssAndHtmlParams(type, blockID) +function getRssAndHtmlParams(type) { - blockID = typeof(blockID) == 'undefined' ? 0 : blockID; - $.get(createLink('block', 'set', 'index=' + index + '&type=' + type + '&blockID=' + blockID), function(data) + $.get(createLink('block', 'set', 'index=' + index + '&type=' + type), function(data) { $('#blockParam').html(data); }); @@ -51,17 +49,15 @@ function getRssAndHtmlParams(type, blockID) /** * Get block params. * - * @param string $blockID + * @param string $type * @param int $moduleID * @access public * @return void */ -function getBlockParams(blockID, moduleID) +function getBlockParams(type, moduleID) { $('#blockParam').empty(); - if(blockID == '') return false; - - $.get(createLink('block', 'set', 'index=' + index + '&type=' + moduleID + '&blockID=' + blockID), function(data) + $.get(createLink('block', 'set', 'index=' + index + '&type=' + type + '&source=' + moduleID), function(data) { $('#blockParam').html(data); }); diff --git a/module/block/model.php b/module/block/model.php index 4626c82b53..13f62e3a73 100644 --- a/module/block/model.php +++ b/module/block/model.php @@ -21,16 +21,16 @@ class blockModel extends model * @access public * @return void */ - public function save($index, $source, $module = 'my', $blockID = 0) + public function save($index, $source, $type, $module = 'my') { $data = fixer::input('post') ->add('account', $this->app->user->account) ->add('order', $index) ->add('module', $module) ->add('hidden', 0) - ->setIF($blockID, 'id', $blockID) ->setDefault('grid', '4') ->setDefault('source', $source) + ->setDefault('block', $type) ->setDefault('params', array()) ->get(); diff --git a/module/block/view/bugblock.html.php b/module/block/view/bugblock.html.php index cd9085ab4b..0d7ee6fb1b 100644 --- a/module/block/view/bugblock.html.php +++ b/module/block/view/bugblock.html.php @@ -20,8 +20,11 @@ - get->entry}'" : ''?> - id}")); ?>' > + get->entry}'" : ''; + $viewLink = $this->createLink('bug', 'view', "bugID={$bug->id}"); + ?> + > id;?> bug->severityList, $bug->severity, $bug->severity)?> bug->priList, $bug->pri, $bug->pri)?> @@ -29,8 +32,6 @@ - diff --git a/module/block/view/buildblock.html.php b/module/block/view/buildblock.html.php new file mode 100644 index 0000000000..9e390ffe61 --- /dev/null +++ b/module/block/view/buildblock.html.php @@ -0,0 +1,37 @@ + + * @package block + * @version $Id$ + * @link http://www.ranzhi.org + */ +?> + + + + + + + + + + + get->entry}'" : ''; + $viewLink = $this->createLink('build', 'view', "buildID={$build->id}"); + ?> + > + + + + + + +
idAB?> build->product;?> build->name;?>build->date;?>
id;?>productName?>name?>date?>
+ diff --git a/module/block/view/caseblock.html.php b/module/block/view/caseblock.html.php index 931b6c926b..359f490159 100644 --- a/module/block/view/caseblock.html.php +++ b/module/block/view/caseblock.html.php @@ -22,8 +22,11 @@ - get->entry}'" : ''?> - id}")); ?>' > + get->entry}'" : ''; + $viewLink = $this->createLink('testcase', 'view', "caseID={$case->id}"); + ?> + > id;?> case->priList, $case->pri, $case->pri)?> title?> @@ -33,8 +36,6 @@ - diff --git a/module/block/view/listblock.html.php b/module/block/view/listblock.html.php new file mode 100644 index 0000000000..6b24331725 --- /dev/null +++ b/module/block/view/listblock.html.php @@ -0,0 +1,13 @@ + + * @package block + * @version $Id$ + * @link http://www.ranzhi.org + */ +?> + diff --git a/module/block/view/planblock.html.php b/module/block/view/planblock.html.php new file mode 100644 index 0000000000..44073f523a --- /dev/null +++ b/module/block/view/planblock.html.php @@ -0,0 +1,39 @@ + + * @package block + * @version $Id$ + * @link http://www.ranzhi.org + */ +?> + + + + + + + + + + + + get->entry}'" : ''; + $viewLink = $this->createLink('productplan', 'view', "planID={$plan->id}"); + ?> + > + + + + + + + +
idAB?> productplan->product;?> productplan->title;?>productplan->begin;?>productplan->end;?>
id;?>productName?>title?>begin?>end?>
+ diff --git a/module/block/view/productblock.html.php b/module/block/view/productblock.html.php index 35228a5280..00b04d262a 100644 --- a/module/block/view/productblock.html.php +++ b/module/block/view/productblock.html.php @@ -25,8 +25,11 @@ - get->entry}'" : "class='text-center'"?> - > + get->entry}'" : "class='text-center'"; + $viewLink = $this->createLink('product', 'browse', 'productID=' . $product->id); + ?> + > name?> stories['active']?> stories['changed']?> @@ -39,8 +42,6 @@ - diff --git a/module/block/view/projectblock.html.php b/module/block/view/projectblock.html.php index ced4690ed6..924eeb9423 100644 --- a/module/block/view/projectblock.html.php +++ b/module/block/view/projectblock.html.php @@ -25,8 +25,11 @@ - get->entry}'" : "class='text-center'"?> - > + get->entry}'" : "class='text-center'"; + $viewLink = $this->createLink('project', 'task', 'project=' . $project->id); + ?> + > name;?> end;?> delay)):?> @@ -42,8 +45,6 @@ - diff --git a/module/block/view/releaseblock.html.php b/module/block/view/releaseblock.html.php new file mode 100644 index 0000000000..8d0f606017 --- /dev/null +++ b/module/block/view/releaseblock.html.php @@ -0,0 +1,41 @@ + + * @package block + * @version $Id$ + * @link http://www.ranzhi.org + */ +?> + + + + + + + + + + + + + get->entry}'" : ''; + $viewLink = $this->createLink('release', 'view', "releaseID={$release->id}"); + ?> + > + + + + + + + + +
idAB?> release->product;?> release->name;?> release->build;?>release->date;?>release->status;?>
id;?>productName?>name?>buildName?>date?>release->statusList[$release->status]?>
+ diff --git a/module/block/view/set.html.php b/module/block/view/set.html.php index 09bfc87aa9..a99a171a77 100644 --- a/module/block/view/set.html.php +++ b/module/block/view/set.html.php @@ -11,7 +11,7 @@ */ ?> block->moduleList[$type])) +if(isset($lang->block->moduleList[$source])) { include 'setmodule.html.php'; die(); @@ -24,7 +24,7 @@ if($type == 'html') include '../../common/view/kindeditor.html.php'; } ?> -
'> +'> diff --git a/module/block/view/setmodule.html.php b/module/block/view/setmodule.html.php index 4ec21026d9..0098a29217 100644 --- a/module/block/view/setmodule.html.php +++ b/module/block/view/setmodule.html.php @@ -16,7 +16,7 @@ $jsRoot = $webRoot . "js/"; $themeRoot = $webRoot . "theme/"; include "../../common/view/chosen.html.php"; ?> -'> +'>
diff --git a/module/block/view/storyblock.html.php b/module/block/view/storyblock.html.php index 114c4b27ac..ba5499a14c 100644 --- a/module/block/view/storyblock.html.php +++ b/module/block/view/storyblock.html.php @@ -36,8 +36,6 @@
-

diff --git a/module/block/view/taskblock.html.php b/module/block/view/taskblock.html.php index 79c5ed2df0..21d499e2fe 100644 --- a/module/block/view/taskblock.html.php +++ b/module/block/view/taskblock.html.php @@ -25,8 +25,11 @@ td.delayed{background: #e84e0f!important; color: white;} - get->entry}'" : ''?> - id}")); ?>' > + get->entry}'" : ''; + $viewLink = $this->createLink('task', 'view', "taskID={$task->id}"); + ?> + > id;?> task->priList, $task->pri, $task->pri)?> name?> @@ -36,8 +39,6 @@ td.delayed{background: #e84e0f!important; color: white;} - diff --git a/module/block/view/testtaskblock.html.php b/module/block/view/testtaskblock.html.php new file mode 100644 index 0000000000..f08e7a78e0 --- /dev/null +++ b/module/block/view/testtaskblock.html.php @@ -0,0 +1,41 @@ + + * @package block + * @version $Id$ + * @link http://www.ranzhi.org + */ +?> + + + + + + + + + + + + + get->entry}'" : ''; + $viewLink = $this->createLink('testtask', 'view', "testtaskID={$testtask->id}"); + ?> + > + + + + + + + + +
idAB?> testtask->product;?> testtask->name;?> testtask->project . '/' . $lang->testtask->project;?>testtask->begin;?>testtask->end;?>
id;?>productName?>name?>buildName?>'>projectName . '/' . $testtask->buildName?>begin?>end?>
+ diff --git a/module/block/view/todoblock.html.php b/module/block/view/todoblock.html.php index 2651a580aa..ba9548544c 100644 --- a/module/block/view/todoblock.html.php +++ b/module/block/view/todoblock.html.php @@ -21,8 +21,11 @@ $todo):?> - get->entry}'" : ''?> - id}")); ?>' > + get->entry}'" : ''; + $viewLink = $this->createLink('todo', 'view', "todoID={$todo->id}"); + ?> + > date == '2030-01-01' ? $lang->todo->periods['future'] : $todo->date;?> todo->priList, $todo->pri, $todo->pri)?> name?> @@ -31,8 +34,6 @@ -