/** * * * @param integer $level * @param array &$node reference to recursive map * @param array &$tcases_map reference to map that contains info about testcase exec status * when node is of testcase type. * * @return datatype description * */ function renderExecTreeNode($level, &$node, &$tcase_node, $hash_id_descr, $linkto, $testCasePrefix, $opt) { static $resultsCfg; static $l18n; static $pf; static $doColouringOn; static $cssClasses; $node_type = $hash_id_descr[$node['node_type_id']]; $menustring = ''; if (!$resultsCfg) { $doColouringOn['testcase'] = 1; $doColouringOn['counters'] = 1; if (!is_null($opt['useColors'])) { $doColouringOn['testcase'] = $opt['useColors']->testcases; $doColouringOn['counters'] = $opt['useColors']->counters; } $resultsCfg = config_get('results'); $status_descr_code = $resultsCfg['status_code']; foreach ($resultsCfg['status_label'] as $key => $value) { $l18n[$status_descr_code[$key]] = lang_get($value); // here we use ONLY key $cssClasses[$status_descr_code[$key]] = $doColouringOn['testcase'] ? 'class="light_' . $key . '"' : ''; } // Very BAD CHOICE => SIDE EFFECT $pf['testsuite'] = $opt['hideTestCases'] ? 'TPLAN_PTS' : ($opt['showTestSuiteContents'] ? 'STS' : null); $pf['testproject'] = $opt['hideTestCases'] ? 'TPLAN_PTP' : 'SP'; if (isset($opt['actionJS'])) { if (isset($opt['actionJS']['testproject'])) { $pf['testproject'] = $opt['actionJS']['testproject']; } if (isset($opt['actionJS']['testsuite'])) { $pf['testsuite'] = $opt['actionJS']['testsuite']; } } // manage defaults $opt['showTestCaseExecStatus'] = isset($opt['showTestCaseExecStatus']) ? $opt['showTestCaseExecStatus'] : true; $opt['nodeHelpText'] = isset($opt['nodeHelpText']) ? $opt['nodeHelpText'] : array(); } $name = filterString($node['name']); // custom Property that will be accessed by EXT-JS using node.attributes $node['testlink_node_name'] = $name; $node['testlink_node_type'] = $node_type; switch ($node_type) { case 'testproject': case 'testsuite': $node['leaf'] = false; // $versionID = 0; $pfn = !is_null($pf[$node_type]) ? $pf[$node_type] . "({$node['id']})" : null; $testcase_count = isset($node['testcase_count']) ? $node['testcase_count'] : 0; $node['text'] = $name . " (" . $testcase_count . ")"; if ($opt['useCounters']) { $node['text'] .= create_counters_info($node, $doColouringOn['counters']); } if (isset($opt['nodeHelpText'][$node_type])) { $node['text'] = '<span title="' . $opt['nodeHelpText'][$node_type] . '">' . $node['text'] . '</span>'; } break; case 'testcase': $node['leaf'] = true; // $versionID = $node['tcversion_id']; $pfn = $opt['tc_action_enabled'] ? "ST({$node['id']},{$node['tcversion_id']})" : null; $node['text'] = "<span "; if (isset($tcase_node[$node['id']])) { if ($opt['showTestCaseExecStatus']) { $status_code = $tcase_node[$node['id']]['exec_status']; $node['text'] .= "{$cssClasses[$status_code]} " . ' title="' . $l18n[$status_code] . '" alt="' . $l18n[$status_code] . '">'; } } if ($opt['showTestCaseID']) { $node['text'] .= "<b>" . htmlspecialchars($testCasePrefix . $node['external_id']) . "</b>:"; } $node['text'] .= "{$name}</span>"; break; default: $pfn = "ST({$node['id']})"; break; } $node['position'] = isset($node['node_order']) ? $node['node_order'] : 0; $node['href'] = is_null($pfn) ? '' : "javascript:{$pfn}"; // ---------------------------------------------------------------------------------------------- if (isset($tcase_node[$node['id']])) { unset($tcase_node[$node['id']]); // dam it NO COMMENT! } if (isset($node['childNodes']) && $node['childNodes']) { // need to work always original object in order to change it's values using reference . // Can not assign anymore to intermediate variables. $nodes_qty = sizeof($node['childNodes']); for ($idx = 0; $idx < $nodes_qty; $idx++) { if (is_null($node['childNodes'][$idx])) { continue; } $menustring .= renderExecTreeNode($level + 1, $node['childNodes'][$idx], $tcase_node, $hash_id_descr, $linkto, $testCasePrefix, $opt); } } return $menustring; }
/** * VERY IMPORTANT: node must be passed BY REFERENCE * * @internal Revisions: * 20080629 - franciscom - fixed bug missing argument for call to ST */ function extjs_renderExecTreeNodeOnOpen(&$node, $node_type, $tcase_node, $tc_action_enabled, $bForPrinting, $useCounters = 1, $useColors = null, $showTestCaseID = 1, $testCasePrefix, $showTestSuiteContents = 1) { static $resultsCfg; static $status_descr_code; static $status_code_descr; static $status_verbose; if (!$resultsCfg) { $resultsCfg = config_get('results'); $status_descr_code = $resultsCfg['status_code']; $status_code_descr = $resultsCfg['code_status']; $status_verbose = $resultsCfg['status_label']; } $name = filterString($node['name']); $buildLinkTo = 1; $pfn = "ST"; $testcase_count = isset($node['testcase_count']) ? $node['testcase_count'] : 0; $create_counters = 0; $versionID = 0; $node['leaf'] = false; $testcaseColouring = 1; $countersColouring = 1; if (!is_null($useColors)) { $testcaseColouring = $useColors->testcases; $countersColouring = $useColors->counters; } // $doIt=true; // custom Property that will be accessed by EXT-JS using node.attributes // 20100908 - tlNodeType -> 'testlink_node_type' $node['testlink_node_type'] = $node_type; switch ($node_type) { case 'testproject': $create_counters = 1; $pfn = $bForPrinting ? 'TPLAN_PTP' : 'SP'; $label = $name . " (" . $testcase_count . ")"; break; case 'testsuite': $create_counters = 1; $label = $name . " (" . $testcase_count . ")"; if ($bForPrinting) { $pfn = 'TPLAN_PTS'; } else { $pfn = $showTestSuiteContents ? 'STS' : null; } break; case 'testcase': $node['leaf'] = true; $buildLinkTo = $tc_action_enabled; if (!$buildLinkTo) { $pfn = null; } //echo "DEBUG - Test Case rendering: \$node['id']:{$node['id']}<br>"; $status_code = $tcase_node[$node['id']]['exec_status']; $status_descr = $status_code_descr[$status_code]; $status_text = lang_get($status_verbose[$status_descr]); $css_class = $testcaseColouring ? " class=\"light_{$status_descr}\" " : ''; $label = "<span {$css_class} " . ' title="' . $status_text . '" alt="' . $status_text . '">'; if ($showTestCaseID) { $label .= "<b>" . htmlspecialchars($testCasePrefix . $node['external_id']) . "</b>:"; } $label .= "{$name}</span>"; $versionID = $node['tcversion_id']; break; } if ($create_counters) { $label = $name . " (" . $testcase_count . ")"; if ($useCounters) { $add_html = create_counters_info($node, $countersColouring); $label .= $add_html; } } $node['text'] = $label; $node['position'] = isset($node['node_order']) ? $node['node_order'] : 0; $node['href'] = is_null($pfn) ? '' : "javascript:{$pfn}({$node['id']},{$versionID})"; // Remove useless keys foreach ($status_descr_code as $key => $code) { if (isset($node[$key])) { unset($node[$key]); } } $key2del = array('node_type_id', 'parent_id', 'node_order', 'node_table', 'tcversion_id', 'external_id', 'version', 'testcase_count'); foreach ($key2del as $key) { if (isset($node[$key])) { unset($node[$key]); } } }