diff --git a/module/bug/model.php b/module/bug/model.php
index 9c8ddc3e04..b1ff8a2fac 100644
--- a/module/bug/model.php
+++ b/module/bug/model.php
@@ -2184,7 +2184,6 @@ class bugModel extends model
if(!empty($stepResults))
{
- $i = 1;
$bugStep = '';
$bugResult = '';
$bugExpect = '';
@@ -2193,13 +2192,17 @@ class bugModel extends model
if(!isset($caseSteps[$stepId])) continue;
$step = $caseSteps[$stepId];
- $stepResult = (!isset($stepResults[$stepId]) or empty($stepResults[$stepId]['real'])) ? '' : $stepResults[$stepId]['real'];
- $bugStep .= $i . '. ' . $step->desc . "
";
- $bugResult .= $i . '. ' . $stepResult . "
";
- $bugExpect .= $i . '. ' . $step->expect . "
";
+ $i = $this->getCaseStepIndex($step);
- $i++;
+ $stepDesc = str_replace("\n", "
", $step->desc);
+ $stepExpect = str_replace("\n", "
", $step->expect);
+ $stepResult = (!isset($stepResults[$stepId]) or empty($stepResults[$stepId]['real'])) ? '' : $stepResults[$stepId]['real'];
+
+ $bugStep .= $i . '. ' . $stepDesc . "
";
+ $bugResult .= $i . '. ' . $stepResult . "
";
+ $bugExpect .= $i . '. ' . $stepExpect . "
";
}
+
$bugSteps .= $bugStep ? str_replace('
', '', $this->lang->bug->tplStep) . $bugStep : $this->lang->bug->tplStep;
$bugSteps .= $bugResult ? str_replace('
', '', $this->lang->bug->tplResult) . $bugResult : $this->lang->bug->tplResult;
$bugSteps .= $bugExpect ? str_replace('
', '', $this->lang->bug->tplExpect) . $bugExpect : $this->lang->bug->tplExpect;
@@ -3661,4 +3664,42 @@ class bugModel extends model
if(in_array($object, array('build','resolvedBuild'))) $relatedObjects= array('trunk' => $this->lang->trunk) + $relatedObjects;
return array('' => '', 0 => '') + $relatedObjects;
}
+
+ /**
+ * Return index of a case's step.
+ *
+ * @param object $caseStep
+ * @access public
+ * @return int
+ */
+ public function getCaseStepIndex($caseStep)
+ {
+ static $index = 0;
+ static $stepIndex = 0;
+ static $itemIndex = 0;
+ static $groupID = 0;
+
+ if($caseStep->type == 'item')
+ {
+ if($groupID and $caseStep->parent == $groupID)
+ {
+ $itemIndex ++;
+ $index = $stepIndex . '. ' . $itemIndex;
+ }
+ else
+ {
+ $stepIndex ++;
+ $index = $stepIndex;
+ }
+ }
+ else
+ {
+ if($caseStep->type == 'group') $groupID = $caseStep->id;
+ $stepIndex ++;
+ $itemIndex = 0;
+ $index = $stepIndex;
+ }
+
+ return $index;
+ }
}