* finish task#1670.

* finish task#1671.
 * finish task#1672.
 * finish task#1674.
 * finish task#1675.
 * finish task#1676.
 * finish task#1668.
This commit is contained in:
azhi
2013-08-07 10:40:10 +08:00
parent 4358fd24b3
commit 145c55b447
10 changed files with 214 additions and 96 deletions

View File

@@ -1472,6 +1472,7 @@ class router
if($moduleName == $record->module)
{
if(!$record->key) continue;
unset($lang->{$record->module}->{$record->section}[$record->key]);
$lang->{$record->module}->{$record->section}[$record->key] = $record->value;
}
}

View File

@@ -283,7 +283,7 @@ $lang->convert = new stdclass();
$lang->upgrade = new stdclass();
$lang->action = new stdclass();
$lang->extension = new stdclass();
$lang->customlang = new stdclass();
$lang->custom = new stdclass();
$lang->editor = new stdclass();
$lang->mail = new stdclass();
$lang->sso = new stdclass();

View File

@@ -6,13 +6,47 @@ $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->fields['statusList'] = '状态';
$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 = '';
$config->custom->task = new stdClass();
$config->custom->task->fields['priList'] = '优先级';
$config->custom->task->fields['typeList'] = '类型';
$config->custom->task->fields['reasonList'] = '关闭原因';
$config->custom->task->fields['statusList'] = '状态';
$config->custom->task->canAdd = 'priList,typeList';
$config->custom->bug = new stdClass();
$config->custom->bug->fields['priList'] = '优先级';
$config->custom->bug->fields['severityList'] = '严重程度';
$config->custom->bug->fields['osList'] = '操作系统';
$config->custom->bug->fields['browserList'] = '浏览器';
$config->custom->bug->fields['typeList'] = '类型';
$config->custom->bug->fields['resolutionList'] = '解决方案';
$config->custom->bug->fields['statusList'] = '状态';
$config->custom->bug->canAdd = 'priList,severityList,osList,browserList,typeList,resolutionList';
$config->custom->testcase = new stdClass();
$config->custom->testcase->fields['priList'] = '优先级';
$config->custom->testcase->fields['typeList'] = '类型';
$config->custom->testcase->fields['stageList'] = '阶段';
$config->custom->testcase->fields['resultList'] = '执行结果';
$config->custom->testcase->fields['statusList'] = '状态';
$config->custom->testcase->canAdd = 'priList,typeList,stageList';
$config->custom->testtask = new stdClass();
$config->custom->testtask->fields['priList'] = '优先级';
$config->custom->testtask->fields['statusList'] = '状态';
$config->custom->testtask->canAdd = 'priList';
$config->custom->todo = new stdClass();
$config->custom->todo->fields['priList'] = '优先级';
$config->custom->todo->fields['typeList'] = '类型';
$config->custom->todo->fields['statusList'] = '状态';
$config->custom->todo->canAdd = 'priList,typeList';
$config->custom->user = new stdClass();
$config->custom->user->fields['roleList'] = '角色';
$config->custom->user->fields['statusList'] = '状态';
$config->custom->user->canAdd = 'roleList';

View File

@@ -11,38 +11,86 @@
*/
class custom extends control
{
/**
* __construct
*
* @access public
* @return void
*/
public function __construct()
{
parent::__construct();
}
public function index($module = 'story', $field = 'priList')
/**
* Index
*
* @access public
* @return void
*/
public function index()
{
die(js::locate(inlink('setCustom')));
}
/**
* Custom
*
* @param string $module
* @param string $field
* @access public
* @return void
*/
public function setCustom($module = 'story', $field = 'priList')
{
if($module == 'user' and $field == 'priList') $field = 'roleList';
$lang = $this->app->getClientLang();
$this->app->loadLang($module);
$fieldList = $this->lang->$module->$field;
if(!empty($_POST))
{
$this->custom->deleteItems("{$lang}.{$module}.{$field}");
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);
$value = $_POST['values'][$index];
$system = $_POST['systems'][$index];
$this->custom->setItem("{$lang}.{$module}.{$field}.{$key}.{$system}", $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->dbFields = $this->custom->getItems("{$lang}.{$module}.{$field}");
$this->view->field = $field;
$this->view->module = $module;
$this->view->canAdd = strpos($this->config->custom->$module->canAdd, $field) !== false;
$this->display();
}
/**
* Restore the default lang. Delete the related items.
*
* @param string $module
* @param string $field
* @param string $confirm
* @access public
* @return void
*/
public function restore($module, $field, $confirm = 'no')
{
if($confirm == 'no')
{
die(js::confirm($this->lang->custom->confirmRestore, inlink('restore', "module=$module&field=$field&confirm=yes")));
}
$lang = $this->app->getClientLang();
$this->custom->deleteItems("{$lang}.{$module}.{$field}");
die(js::reload('parent'));
}
}

View File

@@ -0,0 +1 @@
input[type='text'] {border:1px solid #ccc; padding:3px 0px}

View File

@@ -1,5 +1,6 @@
<?php
$lang->custom->common = 'Custom';
$lang->custom->custom = 'Custom';
$lang->custom->key = 'Key';
$lang->custom->value = 'Value';
@@ -10,3 +11,6 @@ $lang->custom->testcase = 'Test case';
$lang->custom->testtask = 'Test task';
$lang->custom->todo = 'Todo';
$lang->custom->user = 'User';
$lang->custom->restore = 'restore';
$lang->custom->confirmRestore = 'Are you sure to restore the default lang setting?';

View File

@@ -1,5 +1,6 @@
<?php
$lang->custom->common = '自定义配置';
$lang->custom->custom = '自定义配置';
$lang->custom->key = '键';
$lang->custom->value = '值';
@@ -10,3 +11,6 @@ $lang->custom->testcase = '测试用例';
$lang->custom->testtask = '测试任务';
$lang->custom->todo = '待办';
$lang->custom->user = '用户';
$lang->custom->restore = '恢复默认';
$lang->custom->confirmRestore = '是否要恢复默认语言配置?';

View File

@@ -1,20 +1,19 @@
<?php
/**
* The model file of xxx module of ZenTaoCMS.
* The model file of custom 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
* @author Congzhi Chen <congzhi@cnezsoft.com>
* @package custom
* @version $Id$
* @link http://www.zentao.net
*/
class customModel extends model
{
/**
* Get config of system and one user.
* Get all custom lang.
*
* @param string $account
* @access public
* @return array
*/
@@ -26,7 +25,7 @@ class customModel extends model
/**
* Set value of an item.
*
* @param string $path system.common.global.sn or system.common.sn
* @param string $path zh-cn.story.soucreList.customer.1
* @param string $value
* @access public
* @return void
@@ -34,11 +33,13 @@ class customModel extends model
public function setItem($path, $value = '')
{
$level = substr_count($path, '.');
$section = '';
$section = '';
$system = 1;
if($level <= 1) return false;
if($level == 2) list($lang, $module, $key) = explode('.', $path);
if($level == 3) list($lang, $module, $section, $key) = explode('.', $path);
if($level == 4) list($lang, $module, $section, $key, $system) = explode('.', $path);
$item = new stdclass();
$item->lang = $lang;
@@ -46,21 +47,21 @@ class customModel extends model
$item->section = $section;
$item->key = $key;
$item->value = $value;
$item->system = $system;
$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}");
}
/**
* Get some items
*
* @param string $paramString see parseItemParam();
* @access public
* @return void
*/
public function getItems($paramString)
{
return $this->createDAO($this->parseItemParam($paramString), 'select')->fetchAll('id');
return $this->createDAO($this->parseItemParam($paramString), 'select')->fetchAll('key');
}
/**
@@ -78,7 +79,7 @@ class customModel extends model
/**
* Parse the param string for select or delete items.
*
* @param string $paramString owner=xxx&key=sn and so on.
* @param string $paramString lang=xxx&module=story&section=sourceList&key=customer and so on.
* @access public
* @return array
*/
@@ -111,6 +112,5 @@ class customModel extends model
->beginIF($params['section'])->andWhere('section')->in($params['section'])->fi()
->beginIF($params['key'])->andWhere('`key`')->in($params['key'])->fi();
}
}

View File

@@ -1,65 +0,0 @@
<?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='&nbsp;'></input>
<input type='button' onclick='delItem(this)' class='icon-delete' value='&nbsp;'></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='&nbsp;'></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';?>

View File

@@ -0,0 +1,91 @@
<?php
/**
* The setCustom view file of custom 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 Congzhi Chen <congzhi@cnezsoft.com>
* @package custom
* @version $Id$
* @link http://www.zentao.net
*/
?>
<?php include '../../common/view/header.html.php';?>
<div id='featurebar'>
<div class='f-left'>
<?php
echo "<span id='storyTab'>"; common::printLink('custom', 'setCustom', "module=story", $lang->custom->story); echo '</span>';
echo "<span id='taskTab'>"; common::printLink('custom', 'setCustom', "module=task", $lang->custom->task); echo '</span>';
echo "<span id='bugTab'>"; common::printLink('custom', 'setCustom', "module=bug", $lang->custom->bug); echo '</span>';
echo "<span id='testcaseTab'>"; common::printLink('custom', 'setCustom', "module=testcase", $lang->custom->testcase); echo '</span>';
echo "<span id='testtaskTab'>"; common::printLink('custom', 'setCustom', "module=testtask", $lang->custom->testtask); echo '</span>';
echo "<span id='todoTab'>"; common::printLink('custom', 'setCustom', "module=todo", $lang->custom->todo); echo '</span>' ;
echo "<span id='userTab'>"; common::printLink('custom', 'setCustom', "module=user", $lang->custom->user); echo '</span>';
echo "<script>$('#{$module}Tab').addClass('active')</script>";
?>
</div>
</div>
<?php
$itemRow = <<<EOT
<tr class='a-center'>
<td>
<input type='text' class="text-1" value="" name="keys[]">
<input type='hidden' value="0" name="systems[]">
</td>
<td>
<input type='text' class="w-p98" value="" name="values[]">
</td>
<td class='a-left'>
<input type='button' onclick='addItem(this)' class='icon-add' value='&nbsp;'></input>
<input type='button' onclick='delItem(this)' class='icon-delete' value='&nbsp;'></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($config->custom->{$module}->fields as $key => $value)
{
echo "<span id='{$key}Tab'>" . html::a(inlink('setCustom', "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>
<?php if($canAdd):?><th class='w-40px'></th><?php endif;?>
</tr>
<?php foreach($fieldList as $key => $value):?>
<tr class='a-center'>
<?php $system = isset($dbFields[$key]) ? $dbFields[$key]->system : 1;?>
<td><?php echo $key; echo html::hidden('keys[]', $key) . html::hidden('systems[]', $system);?></td>
<td>
<?php echo html::input("values[]", $value, "class='w-p98'");?>
</td>
<?php if($canAdd):?>
<td class='a-left'>
<input type='button' onclick='addItem(this)' class='icon-add' value='&nbsp;'></input>
<?php if(!$system):?><input type='button' onclick='delItem(this)' class='icon-delete' value='&nbsp;'></input><?php endif;?>
</td>
<?php endif;?>
</tr>
<?php endforeach;?>
<tfoot><tr><td colspan='<?php $canAdd ? print(3) : print(2);?>' class='a-center'><?php echo html::submitButton() . html::linkButton($lang->custom->restore, inlink('restore', "modult=$modult&field=$field"), 'hiddenwin')?></td></tr><tfoot>
</table>
</form>
<script>$('#<?php echo $field;?>Tab').addClass('active')</script>
<?php include '../../common/view/footer.html.php';?>