* build tutorial data and add wizard function.

This commit is contained in:
wangyidong
2016-04-26 09:22:46 +08:00
parent fbccbf45b7
commit 03a8e3a2d6
11 changed files with 222 additions and 9 deletions
+1 -1
View File
@@ -188,7 +188,7 @@ class block extends control
$inited = empty($this->config->$module->common->blockInited) ? '' : $this->config->$module->common->blockInited;
/* Init block when vist index first. */
if(empty($blocks) and !$inited)
if(empty($blocks) and !$inited and !defined('KIZARD'))
{
if($this->block->initBlock($module)) die(js::reload());
}
+2 -2
View File
@@ -19,9 +19,9 @@ class bug extends control
* @access public
* @return void
*/
public function __construct()
public function __construct($moduleName = '', $methodName = '')
{
parent::__construct();
parent::__construct($moduleName, $methodName);
$this->loadModel('product');
$this->loadModel('tree');
$this->loadModel('user');
+1 -1
View File
@@ -10,4 +10,4 @@ $config->custom->canAdd['user'] = 'roleList';
$config->menu = new stdclass();
$config->menu->main = array();
$config->menu->main['novice'] = 'my,product,project,qa,doc,report,company,admin';
$config->menu->main['novice'] = 'my,company,product,project,qa,doc,report,admin';
+2 -2
View File
@@ -19,9 +19,9 @@ class product extends control
* @access public
* @return void
*/
public function __construct()
public function __construct($moduleName = '', $methodName = '')
{
parent::__construct();
parent::__construct($moduleName, $methodName);
/* Load need modules. */
$this->loadModel('story');
+5
View File
@@ -141,6 +141,7 @@ class productModel extends model
*/
public function getById($productID)
{
if(defined('WIZARD')) return $this->loadModel('tutorial')->getProduct();
return $this->dao->findById($productID)->from(TABLE_PRODUCT)->fetch();
}
@@ -183,6 +184,8 @@ class productModel extends model
*/
public function getPairs($mode = '')
{
if(defined('WIZARD')) return $this->loadModel('tutorial')->getProductPairs();
$orderBy = !empty($this->config->product->orderBy) ? $this->config->product->orderBy : 'isClosed';
$mode .= $this->cookie->productMode;
$products = $this->dao->select('*, IF(INSTR(" closed", status) < 2, 0, 1) AS isClosed')
@@ -363,6 +366,8 @@ class productModel extends model
*/
public function getStories($productID, $branch, $browseType, $queryID, $moduleID, $sort, $pager)
{
if(defined('WIZARD')) return $this->loadModel('tutorial')->getStories();
$this->loadModel('story');
/* Set modules and browse type. */
+9
View File
@@ -520,6 +520,8 @@ class projectModel extends model
*/
public function getPairs($mode = '')
{
if(defined('KIZARD')) return $this->loadModel('tutorial')->getProjectPairs();
$orderBy = !empty($this->config->project->orderBy) ? $this->config->project->orderBy : 'isDone, status';
$mode .= $this->cookie->projectMode;
/* Order by status's content whether or not done */
@@ -840,6 +842,8 @@ class projectModel extends model
*/
public function getById($projectID, $setImgSize = false)
{
if(defined('WIZARD')) return $this->loadModel('tutorial')->getProject();
$project = $this->dao->findById((int)$projectID)->from(TABLE_PROJECT)->fetch();
if(!$project) return false;
@@ -901,6 +905,11 @@ class projectModel extends model
*/
public function getProducts($projectID, $withBranch = true)
{
if(defined('WIZARD'))
{
if(!$withBranch) return $this->loadModel('tutorial')->getProductPairs();
return $this->loadModel('tutorial')->getProjectProducts();
}
$query = $this->dao->select('t2.id, t2.name, t2.type, t1.branch')->from(TABLE_PROJECTPRODUCT)->alias('t1')
->leftJoin(TABLE_PRODUCT)->alias('t2')
->on('t1.product = t2.id')
+2 -2
View File
@@ -27,14 +27,14 @@ js::set('browseType', $browseType);
if($productID)
{
$product = $this->product->getById($productID);
$removeLink = $browseType == 'byproduct' ? inlink('task', "projectID=$projectID&browseType=$status&param=0&orderBy=$orderBy&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}") : 'javascript:removeCookieByKey("browseParam")';
$removeLink = $browseType == 'byproduct' ? inlink('task', "projectID=$projectID&browseType=$status&param=0&orderBy=$orderBy&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}") : 'javascript:removeCookieByKey("productBrowseParam")';
echo $product->name;
echo '&nbsp;' . html::a($removeLink, "<i class='icon icon-remove'></i>") . '&nbsp;';
}
elseif($moduleID)
{
$module = $this->tree->getById($moduleID);
$removeLink = $browseType == 'bymodule' ? inlink('task', "projectID=$projectID&browseType=$status&param=0&orderBy=$orderBy&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}") : 'javascript:removeCookieByKey("browseParam")';
$removeLink = $browseType == 'bymodule' ? inlink('task', "projectID=$projectID&browseType=$status&param=0&orderBy=$orderBy&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}") : 'javascript:removeCookieByKey("moduleBrowseParam")';
echo $module->name;
echo '&nbsp;' . html::a($removeLink, "<i class='icon icon-remove'></i>") . '&nbsp;';
}
+1 -1
View File
@@ -431,6 +431,6 @@ foreach($fieldParams as $fieldName => $param)
</div>
</form>
<script language='Javascript'>
$("#shortcutModal").modalTrigger({width:650, type:'iframe'});
if($('#shortcutModal').size() > 0) $("#shortcutModal").modalTrigger({width:650, type:'iframe'});
<?php if(isset($formSession['formType'])) echo "show{$formSession['formType']}('#{$module}-search')";?>
</script>
+5
View File
@@ -1218,6 +1218,8 @@ class storyModel extends model
*/
public function getProductStories($productID = 0, $branch = 0, $moduleIds = 0, $status = 'all', $orderBy = 'id_desc', $pager = null)
{
if(defined('WIZARD')) return $this->loadModel('tutorial')->getStories();
if(is_array($branch))
{
unset($branch[0]);
@@ -1498,6 +1500,8 @@ class storyModel extends model
*/
public function getProjectStories($projectID = 0, $orderBy = 'pri_asc,id_desc', $type = 'byModule', $param = 0, $pager = null)
{
if(defined('WIZARD')) return $this->loadModel('tutorial')->getProjectStories();
$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('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')
@@ -1540,6 +1544,7 @@ class storyModel extends model
*/
public function getProjectStoryPairs($projectID = 0, $productID = 0, $branch = 0, $moduleIds = 0, $type = 'full')
{
if(defined('WIZARD')) return $this->loadModel('tutorial')->getProjectStoryPairs();
$stories = $this->dao->select('t2.id, t2.title, t2.module, t2.pri, t2.estimate, t3.name AS product')
->from(TABLE_PROJECTSTORY)->alias('t1')
->leftJoin(TABLE_STORY)->alias('t2')->on('t1.story = t2.id')
+19
View File
@@ -51,4 +51,23 @@ class tutorial extends control
$this->view->referer = base64_decode($referer);
$this->display();
}
/**
* Wizard.
*
* @param string $module
* @param string $method
* @param string $params
* @access public
* @return void
*/
public function wizard($module, $method, $params = '')
{
define('WIZARD', true);
if($_POST)
{
die();
}
die($this->fetch($module, $method, $params));
}
}
+175
View File
@@ -0,0 +1,175 @@
<?php
/**
* The model file of tutorial module of ZenTaoCMS.
*
* @copyright Copyright 2009-2015 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
* @license ZPL (http://zpl.pub/page/zplv12.html)
* @author Yidong Wang <yidong@cnezsoft.com>
* @package tutorial
* @version $Id$
* @link http://www.zentao.net
*/
class tutorialModel extends model
{
/**
* Get tutorial product pairs.
*
* @access public
* @return array
*/
public function getProductPairs()
{
return array(1 => 'Test product');
}
/**
* Get tutorial product.
*
* @access public
* @return object
*/
public function getProduct()
{
$product = new stdclass();
$product->id = 1;
$product->name = 'Test product';
$product->code = 'test';
$product->type = 'normal';
$product->status = 'normal';
$product->desc = '';
$product->PO = $this->app->user->account;
$product->QD = '';
$product->RD = '';
$product->acl = 'open';
$product->createdBy = $this->app->user->account;
$product->createdDate = helper::now();
$product->createdVersion = '8.1.3';
$product->order = 10;
$product->deleted = '0';
return $product;
}
/**
* Get tutorial stories.
*
* @access public
* @return array
*/
public function getStories()
{
$story = new stdclass();
$story->id = 1;
$story->product = 1;
$story->branch = 0;
$story->module = 0;
$story->plan = '';
$story->planTitle = '';
$story->color = '';
$story->source = 'po';
$story->fromBug = 0;
$story->title = 'Test story';
$story->keywords = '';
$story->type = '';
$story->pri = 3;
$story->estimate = 1;
$story->status = 'active';
$story->stage = 'wait';
$story->openedBy = $this->app->user->account;
$story->openedDate = helper::now();
$story->assignedTo = '';
$story->assignedDate = '';
$story->reviewedBy = $this->app->user->account;
$story->reviewedDate = helper::now();
$story->closedBy = '';
$story->closedDate = '';
$story->closedReason = '';
$story->toBug = 0;
$story->childStories = '';
$story->linkStories = '';
$story->duplicateStory = 0;
$story->version = 1;
$story->deleted = '0';
$stories = array();
$stories[] = $story;
$story = json_decode(json_encode($stories[0]));
$story->id = 2;
$story->title = 'Test story 2';
$stories[] = $story;
return $stories;
}
/**
* Get tutorial project pairs.
*
* @access public
* @return array
*/
public function getProjectPairs()
{
return array(1 => 'Test project');
}
/**
* Get tutorial project.
*
* @access public
* @return object
*/
public function getProject()
{
$project = new stdclass();
$project->id = 1;
$project->type = 'sprint';
$project->name = 'Test project';
$project->code = 'test';
$project->begin = date('Y-m-d', strtotime('-7 days'));
$project->end = date('Y-m-d', strtotime('+7 days'));
$project->days = 10;
$project->status = 'wait';
$project->pri = '1';
$project->desc = '';
$project->goal = '';
$project->acl = 'open';
return $project;
}
/**
* Get tutorial project products.
*
* @access public
* @return array
*/
public function getProjectProducts()
{
$product = $this->getProduct();
return array($product->id => $product);
}
/**
* Get tutorial project stories.
*
* @access public
* @return array
*/
public function getProjectStories()
{
$stories = $this->getStories();
$story = $stories[0];
return array($story->id => $story);
}
/**
* Get tutorial project story pairs.
*
* @access public
* @return array
*/
public function getProjectStoryPairs()
{
$stories = $this->getStories();
$story = $stories[0];
return array($story->id => $story->title);
}
}