* Remove useless codes.

This commit is contained in:
daitingting
2023-09-14 06:43:07 +00:00
parent 92d7465805
commit 99b1909a37
-324
View File
@@ -1303,220 +1303,6 @@ class testcaseModel extends model
return $module->id;
}
/**
* Print cell data
*
* @param object $col
* @param object $case
* @param array $users
* @param array $branches
* @access public
* @return void
*/
public function printCell($col, $case, $users, $branches, $modulePairs = array(), $browseType = '', $mode = 'datatable', $isCase = 1)
{
/* Check the product is closed. */
$canBeChanged = common::canBeChanged('case', $case);
$canBatchRun = common::hasPriv('testtask', 'batchRun');
$canBatchEdit = common::hasPriv('testcase', 'batchEdit');
$canBatchDelete = common::hasPriv('testcase', 'batchDelete');
$canBatchChangeType = common::hasPriv('testcase', 'batchChangeType');
$canBatchConfirmStoryChange = common::hasPriv('testcase', 'batchConfirmStoryChange');
$canBatchChangeModule = common::hasPriv('testcase', 'batchChangeModule');
$canBatchAction = ($canBatchRun or $canBatchEdit or $canBatchDelete or $canBatchChangeType or $canBatchConfirmStoryChange or $canBatchChangeModule);
$canView = common::hasPriv('testcase', 'view');
$caseLink = helper::createLink('testcase', 'view', "caseID=$case->id&version=$case->version");
$account = $this->app->user->account;
$fromCaseID = $case->fromCaseID;
$id = $col->id;
if($col->show)
{
$class = $id == 'title' ? 'c-name' : 'c-' . $id;
$title = '';
if($id == 'title')
{
$class .= ' text-left';
$title = "title='{$case->title}'";
}
if($id == 'status')
{
$class .= $case->status;
$title = "title='" . $this->processStatus('testcase', $case) . "'";
}
if(strpos(',bugs,results,stepNumber,', ",$id,") !== false) $title = "title='{$case->$id}'";
if($id == 'actions') $class .= ' c-actions';
if($id == 'lastRunResult') $class .= " {$case->lastRunResult}";
if(strpos(',stage,precondition,keywords,story,', ",{$id},") !== false) $class .= ' text-ellipsis';
if($id == 'title')
{
if($isCase == 2)
{
echo "<td class='c-name table-nest-title text-left sort-handler has-prefix has-suffix' {$title}><span class='table-nest-icon icon '></span>";
}
else
{
echo "<td class='c-name table-nest-title text-left sort-handler has-prefix has-suffix' {$title}><span class='table-nest-icon icon icon-test'></span>";
}
}
else
{
echo "<td class='{$class}' {$title}>";
}
if($this->config->edition != 'open') $this->loadModel('flow')->printFlowCell('testcase', $case, $id);
switch($id)
{
case 'id':
$showid = "";
if($isCase == 2)
{
$showid = substr($case->id,1);
$showid = preg_replace('/^0+/', '', $showid);
}
else
{
$showid = $case->id;
}
if($canBatchAction)
{
$disabled = $canBeChanged ? '' : 'disabled';
if($isCase == 1){
echo html::checkbox('caseIDList', array($case->id => ''), '', $disabled) . html::a(helper::createLink('testcase', 'view', "caseID=$case->id"), sprintf('%03d', $showid), '', "data-app='{$this->app->tab}'");
}
else
{
echo html::checkbox('caseIDList', array($case->id => ''), '', $disabled) . sprintf('%03d', $showid);
}
}
else
{
printf('%03d', $showid);
}
break;
case 'pri':
if($isCase != 2)
{
echo "<span class='label-pri label-pri-" . $case->pri . "' title='" . zget($this->lang->testcase->priList, $case->pri, $case->pri) . "'>";
echo zget($this->lang->testcase->priList, $case->pri, $case->pri);
echo "</span>";
}
break;
case 'title':
if($isCase == 1)
{
$autoIcon = $case->auto == 'auto' ? " <i class='icon icon-draft-edit'></i>" : '';
if($modulePairs and $case->module and isset($modulePairs[$case->module])) echo "<span class='label label-gray label-badge'>{$modulePairs[$case->module]}</span> ";
echo $canView ? html::a($caseLink, $case->title, null, "style='color: $case->color' data-app='{$this->app->tab}'")
: "<span style='color: $case->color'>$case->title</span>";
$fromLink = ($fromCaseID and $canView) ? helper::createLink('testcase', 'view', "caseID=$fromCaseID") : '#';
$title = $fromCaseID ? "[<i class='icon icon-share' title='{$this->lang->testcase->fromCaselib}'></i>#$fromCaseID]$autoIcon" : $autoIcon;
if($case->auto == 'auto') echo html::a($fromLink, $title, '', "data-app='{$this->app->tab}'");
}
else
{
echo $case->title;
}
break;
case 'branch':
echo $branches[$case->branch];
break;
case 'type':
echo $this->lang->testcase->typeList[$case->type];
break;
case 'stage':
$stages = '';
foreach(explode(',', trim($case->stage, ',')) as $stage) $stages .= $this->lang->testcase->stageList[$stage] . ',';
$stages = trim($stages, ',');
echo "<span title='$stages'>$stages</span>";
break;
case 'status':
if($case->needconfirm)
{
print("<span class='status-story status-changed' title='{$this->lang->story->changed}'>{$this->lang->story->changed}</span>");
}
elseif(isset($case->fromCaseVersion) and $case->fromCaseVersion > $case->version and !$case->needconfirm)
{
print("<span class='status-story status-changed' title='{$this->lang->testcase->changed}'>{$this->lang->testcase->changed}</span>");
}
else
{
print("<span class='status-testcase status-{$case->status}'>" . $this->processStatus('testcase', $case) . "</span>");
}
break;
case 'story':
static $stories = array();
if(empty($stories)) $stories = $this->dao->select('id,title')->from(TABLE_STORY)->where('deleted')->eq('0')->andWhere('product')->eq($case->product)->fetchPairs('id', 'title');
if($case->story and isset($stories[$case->story])) echo html::a(helper::createLink('story', 'view', "storyID=$case->story"), $stories[$case->story]);
break;
case 'precondition':
echo $case->precondition;
break;
case 'keywords':
echo $case->keywords;
break;
case 'version':
if($isCase == 1) echo $case->version;
break;
case 'openedBy':
echo zget($users, $case->openedBy);
break;
case 'openedDate':
echo substr($case->openedDate, 5, 11);
break;
case 'reviewedBy':
echo zget($users, $case->reviewedBy);
break;
case 'reviewedDate':
echo helper::isZeroDate($case->reviewedDate) ? '' : substr($case->reviewedDate, 5, 11);
break;
case 'lastEditedBy':
echo zget($users, $case->lastEditedBy);
break;
case 'lastEditedDate':
echo helper::isZeroDate($case->lastEditedDate) ? '' : substr($case->lastEditedDate, 5, 11);
break;
case 'lastRunner':
echo zget($users, $case->lastRunner);
break;
case 'lastRunDate':
if(!helper::isZeroDate($case->lastRunDate)) echo substr($case->lastRunDate, 5, 11);
break;
case 'lastRunResult':
if ($isCase == 1) {
$class = 'result-' . $case->lastRunResult;
$lastRunResultText = $case->lastRunResult ? zget($this->lang->testcase->resultList, $case->lastRunResult, $case->lastRunResult) : $this->lang->testcase->unexecuted;
echo "<span class='$class'>" . $lastRunResultText . "</span>";
}
break;
case 'bugs':
if ($isCase == 1) echo (common::hasPriv('testcase', 'bugs') and $case->bugs) ? html::a(helper::createLink('testcase', 'bugs', "runID=0&caseID={$case->id}"), $case->bugs, '', "class='iframe'") : $case->bugs;
break;
case 'results':
if ($isCase == 1) echo (common::hasPriv('testtask', 'results') and $case->results) ? html::a(helper::createLink('testtask', 'results', "runID=0&caseID={$case->id}"), $case->results, '', "class='iframe'") : $case->results;
break;
case 'stepNumber':
if ($isCase == 1) echo $case->stepNumber;
break;
case 'actions':
if ($isCase == 1)
{
$case->browseType = $browseType;
echo $this->buildOperateMenu($case, 'browse');
break;
}
else
{
echo $this->buildOperateBrowseSceneMenu($case);
}
}
echo '</td>';
}
}
/**
* 追加 bug 和用例执行结果信息
* Append bugs and results.
@@ -1844,31 +1630,6 @@ class testcaseModel extends model
->get();
}
/**
* Build operate browse scene menu.
*
* @param object $scene
* @access public
* @return string
*/
public function buildOperateBrowseSceneMenu($scene)
{
$canBeChanged = common::canBeChanged('case', $scene);
if(!$canBeChanged) return '';
$params = "sceneID=$scene->id";
/* Generate params for editing scene. */
$editParams = $params;
if($this->app->tab == 'project') $editParams .= "&projectID={$this->session->project}";
if($this->app->tab == 'execution') $editParams .= "&executionID={$this->session->execution}";
$menu = $this->buildMenu('testcase', 'editScene', $editParams, $scene, 'browse', 'edit', '', '', '', '', $this->lang->testcase->editScene);
$menu .= $this->buildMenu('testcase', 'deleteScene', $params, $scene, 'browse', 'trash', 'hiddenwin', '', '', '', $this->lang->testcase->deleteScene);
return $menu;
}
/**
* 构建树数组。
* Build tree array.
@@ -2227,91 +1988,6 @@ class testcaseModel extends model
return $scenePairs;
}
/**
* Substr string.
*
* @param string $text
* @param int $length
* @access public
* @return string
*/
public function istrcut($text, $length)
{
return (mb_strlen($text, 'utf8') > $length) ? mb_substr($text, 0, $length, 'utf8').'...' : $text;
}
/**
* Print table head.
*
* @param object $col
* @param string $orderBy
* @param string $vars
* @param bool $checkBox
* @access public
* @return string
*/
public function printHead($col, $orderBy, $vars, $checkBox = true)
{
$id = $col->id;
if($col->show)
{
$fixed = $col->fixed == 'no' ? 'true' : 'false';
$width = is_numeric($col->width) ? "{$col->width}px" : $col->width;
$title = isset($col->title) ? "title='$col->title'" : '';
$title = (isset($col->name) and $col->name) ? "title='$col->name'" : $title;
if($id == 'id' and (int)$width < 90) $width = '120px';
$align = $id == 'actions' ? 'text-center' : '';
$align = in_array($id, array('budget', 'teamCount', 'estimate', 'consume', 'consumed', 'left')) ? 'text-right' : $align;
$style = '';
$data = '';
$data .= "data-width='$width'";
$style .= "width:$width;";
if(isset($col->minWidth))
{
$data .= "data-minWidth='{$col->minWidth}px'";
$style .= "min-width:{$col->minWidth}px;";
}
if(isset($col->maxWidth))
{
$data .= "data-maxWidth='{$col->maxWidth}px'";
$style .= "max-width:{$col->maxWidth}px;";
}
if(isset($col->pri)) $data .= "data-pri='{$col->pri}'";
if($col->title == $this->lang->testcase->title)
{
echo "<th data-flex='$fixed' $data style='$style' class='c-$id $align' title='".$this->lang->testcase->generalTitle."'>";
}
else
{
echo "<th data-flex='$fixed' $data style='$style' class='c-$id $align' $title>";
}
if($id == 'actions')
{
echo $this->lang->actions;
}
else
{
if($id == 'id' && $checkBox) echo "<div class='checkbox-primary check-all' title='".$this->lang->selectAll."'><label></label></div>";
if($col->title == $this->lang->testcase->title)
{
echo $this->lang->testcase->generalTitle;
}
else
{
echo $col->title;
}
}
echo '</th>';
}
}
/**
* 编辑一个场景和它的子场景。
* Update a scene and its children.