* code for task#1670.
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
$config->custom = new stdClass();
|
||||
|
||||
$config->custom->story = new stdClass();
|
||||
$config->custom->story->fields['priList'] = '优先级';
|
||||
$config->custom->story->fields['sourceList'] = '来源';
|
||||
$config->custom->story->fields['reasonList'] = '关闭原因';
|
||||
$config->custom->story->fields['reviewResultList'] = '评审结果';
|
||||
$config->custom->story->fields['statusList'] = '状态';
|
||||
$config->custom->story->fields['stageList'] = '阶段';
|
||||
$config->custom->story->canAdd = 'reasonList,reviewResultList,sourceList,priList';
|
||||
|
||||
$config->custom->task = '';
|
||||
$config->custom->bug = '';
|
||||
$config->custom->testcase = '';
|
||||
$config->custom->testtask = '';
|
||||
$config->custom->todo = '';
|
||||
$config->custom->user = '';
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* The control file of custom of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2010 QingDao Nature Easy Soft Network Technology Co,LTD (www.cnezsoft.com)
|
||||
* @license LGPL (http://www.gnu.org/licenses/lgpl.html)
|
||||
* @author Chunsheng Wang <chunsheng@cnezsoft.com>
|
||||
* @package custom
|
||||
* @version $Id$
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
class custom extends control
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index($module = 'story', $field = 'priList')
|
||||
{
|
||||
$lang = $this->app->getClientLang();
|
||||
|
||||
$this->app->loadLang($module);
|
||||
$fieldList = $this->lang->$module->$field;
|
||||
if(!empty($_POST))
|
||||
{
|
||||
foreach($_POST['keys'] as $index => $key)
|
||||
{
|
||||
// $value = $_POST['values'][$index];
|
||||
// if(isset($fieldList[$key]) and $fieldList[$key] == $value) continue;
|
||||
$this->custom->setItem("{$lang}.{$module}.{$field}.{$key}", $value);
|
||||
}
|
||||
if(!dao::getError()) die(js::reload('parent'));
|
||||
}
|
||||
|
||||
$this->view->standardList = $this->custom->getStandardList($module, $field);
|
||||
$this->view->title = $this->lang->custom->common . $this->lang->colon . $this->lang->custom->story;
|
||||
$this->view->position[] = $this->lang->custom->common;
|
||||
$this->view->position[] = $this->lang->custom->$module;
|
||||
$this->view->fieldList = $fieldList;
|
||||
$this->view->field = $field;
|
||||
$this->view->module = $module;
|
||||
$this->view->canAdd = strpos($this->config->custom->$module->canAdd, $field) !== false;
|
||||
|
||||
$this->display();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
$lang->custom->common = 'Custom';
|
||||
$lang->custom->key = 'Key';
|
||||
$lang->custom->value = 'Value';
|
||||
|
||||
$lang->custom->story = 'Story';
|
||||
$lang->custom->task = 'Task';
|
||||
$lang->custom->bug = 'Bug';
|
||||
$lang->custom->testcase = 'Test case';
|
||||
$lang->custom->testtask = 'Test task';
|
||||
$lang->custom->todo = 'Todo';
|
||||
$lang->custom->user = 'User';
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
$lang->custom->common = '自定义配置';
|
||||
$lang->custom->key = '键';
|
||||
$lang->custom->value = '值';
|
||||
|
||||
$lang->custom->story = '需求';
|
||||
$lang->custom->task = '任务';
|
||||
$lang->custom->bug = 'Bug';
|
||||
$lang->custom->testcase = '测试用例';
|
||||
$lang->custom->testtask = '测试任务';
|
||||
$lang->custom->todo = '待办';
|
||||
$lang->custom->user = '用户';
|
||||
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
/**
|
||||
* The model file of xxx module of ZenTaoCMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2010 QingDao Nature Easy Soft Network Technology Co,LTD (www.cnezsoft.com)
|
||||
* @license LGPL (http://www.gnu.org/licenses/lgpl.html)
|
||||
* @author Chunsheng Wang <chunsheng@cnezsoft.com>
|
||||
* @package xxx
|
||||
* @version $Id$
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
class customModel extends model
|
||||
{
|
||||
/**
|
||||
* Get config of system and one user.
|
||||
*
|
||||
* @param string $account
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getAll()
|
||||
{
|
||||
return $this->dao->select('*')->from(TABLE_CUSTOM)->orderBy('id')->fetchAll('id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set value of an item.
|
||||
*
|
||||
* @param string $path system.common.global.sn or system.common.sn
|
||||
* @param string $value
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function setItem($path, $value = '')
|
||||
{
|
||||
$level = substr_count($path, '.');
|
||||
$section = '';
|
||||
|
||||
if($level <= 1) return false;
|
||||
if($level == 2) list($lang, $module, $key) = explode('.', $path);
|
||||
if($level == 3) list($lang, $module, $section, $key) = explode('.', $path);
|
||||
|
||||
$item = new stdclass();
|
||||
$item->lang = $lang;
|
||||
$item->module = $module;
|
||||
$item->section = $section;
|
||||
$item->key = $key;
|
||||
$item->value = $value;
|
||||
|
||||
$this->dao->replace(TABLE_CUSTOM)->data($item)->exec();
|
||||
}
|
||||
|
||||
public function getStandardList($module, $field)
|
||||
{
|
||||
$this->loadModel($module);
|
||||
$lang = $this->app->getClientLang();
|
||||
$currentList = $this->lang->$module->$field;
|
||||
$dbList = $this->getItems("{$lang}.{$module}.{$field}");
|
||||
}
|
||||
|
||||
public function getItems($paramString)
|
||||
{
|
||||
return $this->createDAO($this->parseItemParam($paramString), 'select')->fetchAll('id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete items.
|
||||
*
|
||||
* @param string $paramString see parseItemParam();
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function deleteItems($paramString)
|
||||
{
|
||||
$this->createDAO($this->parseItemParam($paramString), 'delete')->exec();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the param string for select or delete items.
|
||||
*
|
||||
* @param string $paramString owner=xxx&key=sn and so on.
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function parseItemParam($paramString)
|
||||
{
|
||||
/* Parse the param string into array. */
|
||||
parse_str($paramString, $params);
|
||||
|
||||
/* Init fields not set in the param string. */
|
||||
$fields = 'lang,module,section,key';
|
||||
$fields = explode(',', $fields);
|
||||
foreach($fields as $field) if(!isset($params[$field])) $params[$field] = '';
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a DAO object to select or delete one or more records.
|
||||
*
|
||||
* @param array $params the params parsed by parseItemParam() method.
|
||||
* @param string $method select|delete.
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function createDAO($params, $method = 'select')
|
||||
{
|
||||
return $this->dao->$method('*')->from(TABLE_CUSTOM)->where('1 = 1')
|
||||
->beginIF($params['lang'])->andWhere('lang')->in($params['lang'])->fi()
|
||||
->beginIF($params['module'])->andWhere('module')->in($params['module'])->fi()
|
||||
->beginIF($params['section'])->andWhere('section')->in($params['section'])->fi()
|
||||
->beginIF($params['key'])->andWhere('`key`')->in($params['key'])->fi();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
<?php include '../../common/view/header.html.php';?>
|
||||
<div id='featurebar'>
|
||||
<div class='f-left'>
|
||||
<?php
|
||||
echo "<span id='storyTab'>"; common::printLink('custom', 'index', "module=story", $lang->custom->story); echo '</span>';
|
||||
echo "<span id='taskTab'>"; common::printLink('custom', 'index', "module=task", $lang->custom->task); echo '</span>';
|
||||
echo "<span id='bugTab'>"; common::printLink('custom', 'index', "module=bug", $lang->custom->bug); echo '</span>';
|
||||
echo "<span id='testcaseTab'>"; common::printLink('custom', 'index', "module=testcase", $lang->custom->testcase); echo '</span>';
|
||||
echo "<span id='testtaskTab'>"; common::printLink('custom', 'index', "module=testtask", $lang->custom->testtask); echo '</span>';
|
||||
echo "<span id='todoTab'>"; common::printLink('custom', 'index', "module=todo", $lang->custom->todo); echo '</span>' ;
|
||||
echo "<span id='userTab'>"; common::printLink('custom', 'index', "module=user", $lang->custom->user); echo '</span>';
|
||||
echo "<script>$('#{$module}Tab').addClass('active')</script>";
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* The xxx view file of xxx module of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2010 QingDao Nature Easy Soft Network Technology Co,LTD (www.cnezsoft.com)
|
||||
* @license LGPL (http://www.gnu.org/licenses/lgpl.html)
|
||||
* @author Chunsheng Wang <chunsheng@cnezsoft.com>
|
||||
* @package xxx
|
||||
* @version $Id$
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
?>
|
||||
<?php include './header.html.php';?>
|
||||
<?php
|
||||
$itemRow = <<<EOT
|
||||
<tr class='a-center'>
|
||||
<td><input type='text' class="text-1" type="text" value="" name="keys[]"></td>
|
||||
<td>
|
||||
<input type='text' class="text-1" type="text" value="" name="values[]">
|
||||
<input type='button' onclick='addItem(this)' class='icon-add' value=' '></input>
|
||||
<input type='button' onclick='delItem(this)' class='icon-delete' value=' '></input>
|
||||
</td>
|
||||
</tr>
|
||||
EOT;
|
||||
?>
|
||||
<script>
|
||||
function addItem(clickedButton)
|
||||
{
|
||||
$(clickedButton).parent().parent().after(<?php echo json_encode($itemRow);?>);
|
||||
}
|
||||
function delItem(clickedButton)
|
||||
{
|
||||
$(clickedButton).parent().parent().remove();
|
||||
}
|
||||
</script>
|
||||
<div id='featurebar'>
|
||||
<div class='f-left'>
|
||||
<?php
|
||||
foreach($this->config->custom->story->fields as $key => $value)
|
||||
{
|
||||
echo "<span id='{$key}Tab'>" . html::a(inlink('index', "module=$module&field=$key"), $value) . "</span>";
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<form method='post'>
|
||||
<table align='center' class='table-5'>
|
||||
<tr>
|
||||
<th class='w-100px'><?php echo $lang->custom->key;?></th>
|
||||
<th><?php echo $lang->custom->value;?></th>
|
||||
</tr>
|
||||
<?php foreach($fieldList as $key => $value):?>
|
||||
<tr class='a-center'>
|
||||
<td><?php echo $key; echo html::hidden('keys[]', $key);?></td>
|
||||
<td>
|
||||
<?php echo html::input("values[]", $value, "class='text-1'");?>
|
||||
<?php if($canAdd):?><input type='button' onclick='addItem(this)' class='icon-add' value=' '></input><?php endif;?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
<tfoot><tr><td colspan='2' class='a-center'><?php echo html::submitButton()?></td></tr><tfoot>
|
||||
</table>
|
||||
</form>
|
||||
<script>$('#<?php echo $field;?>Tab').addClass('active')</script>
|
||||
<?php include '../../common/view/footer.html.php';?>
|
||||
Reference in New Issue
Block a user