/** * * @internal revisions: * **/ function initEnv(&$dbHandler, &$argsObj, &$tprojectMgr, $userID) { $my = array(); $doc = new stdClass(); $my['options'] = array('recursive' => true, 'prepareNode' => null, 'order_cfg' => array("type" => 'spec_order')); $my['filters'] = array('exclude_node_types' => array('testplan' => 'exclude me', 'requirement_spec' => 'exclude me', 'requirement' => 'exclude me'), 'exclude_children_of' => array('testcase' => 'exclude my children', 'requirement_spec' => 'exclude my children')); $lblKey = array(DOC_TEST_SPEC => 'title_test_spec', DOC_TEST_PLAN_DESIGN => 'report_test_plan_design', DOC_TEST_PLAN_EXECUTION => 'report_test_plan_execution', DOC_TEST_PLAN_EXECUTION_ON_BUILD => 'report_test_plan_execution_on_build', DOC_REQ_SPEC => 'req_spec'); $doc->content_range = $argsObj->level; $doc->type = $argsObj->doc_type; $doc->type_name = lang_get($lblKey[$doc->type]); $doc->author = ''; $doc->title = ''; switch ($doc->type) { case DOC_TEST_PLAN_DESIGN: $my['options']['order_cfg'] = array("type" => 'exec_order', "tplan_id" => $argsObj->tplan_id); break; case DOC_TEST_PLAN_EXECUTION: case DOC_TEST_PLAN_EXECUTION_ON_BUILD: $my['options']['order_cfg'] = array("type" => 'exec_order', "tplan_id" => $argsObj->tplan_id); $my['options']['prepareNode'] = array('viewType' => 'executionTree'); break; case DOC_REQ_SPEC: $my['filters'] = array('exclude_node_types' => array('testplan' => 'exclude me', 'testsuite' => 'exclude me', 'testcase' => 'exclude me'), 'exclude_children_of' => array('testcase' => 'exclude my children', 'testsuite' => 'exclude my children', 'requirement' => 'exclude my children')); break; } $user = tlUser::getById($dbHandler, $userID); if ($user) { $doc->author = htmlspecialchars($user->getDisplayName()); } unset($user); $dummy = $tprojectMgr->get_by_id($argsObj->tproject_id); $doc->tproject_name = htmlspecialchars($dummy['name']); $doc->tproject_scope = $dummy['notes']; $doc->test_priority_enabled = $dummy['opt']->testPriorityEnabled; return array($doc, $my); }
} switch ($doc_info->type) { case DOC_REQ_SPEC: $my['options'] = array('recursive' => true, 'order_cfg' => $order_cfg); $my['filters'] = array('exclude_node_types' => array('testplan' => 'exclude me', 'testsuite' => 'exclude me', 'testcase' => 'exclude me'), 'exclude_children_of' => array('testcase' => 'exclude my children', 'requirement' => 'exclude my children', 'testsuite' => 'exclude my children')); break; default: $my['options'] = array('recursive' => true, 'order_cfg' => $order_cfg); $my['filters'] = array('exclude_node_types' => array('testplan' => 'exclude me', 'requirement_spec' => 'exclude me', 'requirement' => 'exclude me'), 'exclude_children_of' => array('testcase' => 'exclude my children', 'requirement_spec' => 'exclude my children')); break; } $subtree = $tree_manager->get_subtree($args->itemID, $my['filters'], $my['options']); $tproject_info = $tproject->get_by_id($args->tproject_id); $doc_info->tproject_name = htmlspecialchars($tproject_info['name']); $doc_info->tproject_scope = $tproject_info['notes']; $user = tlUser::getById($db, $_SESSION['userID']); if ($user) { $doc_info->author = htmlspecialchars($user->getDisplayName()); } $treeForPlatform = null; switch ($doc_info->type) { case DOC_REQ_SPEC: switch ($doc_info->content_range) { case 'testproject': $tree =& $subtree; $doc_info->title = $doc_info->tproject_name; break; case 'reqspec': $spec_mgr = new requirement_spec_mgr($db); $spec = $spec_mgr->get_by_id($args->itemID); $spec['childNodes'] = isset($subtree['childNodes']) ? $subtree['childNodes'] : null;
/** * render a requirement specification node as HTML code for printing * * @author Andreas Simon * * @param resource $db * @param array $node the node to be printed * @param array $options * @param string $tocPrefix Prefix to be printed in TOC before title of node * @param int $level * @param int $tprojectID * * @return string $output HTML Code */ function renderReqSpecNodeForPrinting(&$db, &$node, &$options, $tocPrefix, $level, $tprojectID) { static $tableColspan; static $firstColWidth; static $labels; static $title_separator; static $req_spec_mgr; static $tplan_mgr; static $req_spec_cfg; static $reqSpecTypeLabels; static $nodeTypes; $output = ''; $level = $level > 0 ? $level : 1; if (!$req_spec_mgr) { $req_spec_cfg = config_get('req_spec_cfg'); $firstColWidth = '20%'; $tableColspan = 2; $labels = array('requirements_spec' => 'requirements_spec', 'scope' => 'scope', 'type' => 'type', 'author' => 'author', 'relations' => 'relations', 'overwritten_count' => 'req_total', 'coverage' => 'coverage', 'revision' => 'revision', 'undefined_req_spec_type' => 'undefined_req_spec_type', 'custom_field' => 'custom_field', 'not_aplicable' => 'not_aplicable'); $labels = init_labels($labels); $reqSpecTypeLabels = init_labels($req_spec_cfg->type_labels); $title_separator = config_get('gui_title_separator_1'); $req_spec_mgr = new requirement_spec_mgr($db); $tplan_mgr = new testplan($db); $nodeTypes = array_flip($tplan_mgr->tree_manager->get_available_node_types()); } switch ($nodeTypes[$node['node_type_id']]) { case 'requirement_spec_revision': $spec = $req_spec_mgr->getRevisionByID($node['id']); $spec_id = $spec['parent_id']; $who = array('parent_id' => $spec['parent_id'], 'item_id' => $spec['id'], 'tproject_id' => $spec['testproject_id']); break; case 'requirement_spec': $spec = $req_spec_mgr->get_by_id($node['id']); $spec_id = $spec['id']; $who = array('parent_id' => $spec['id'], 'item_id' => $spec['revision_id'], 'tproject_id' => $spec['testproject_id']); break; } $name = htmlspecialchars($spec['doc_id'] . $title_separator . $spec['title']); $docHeadingNumbering = $options['headerNumbering'] ? "{$tocPrefix}. " : ''; if ($options['docType'] != SINGLE_REQSPEC) { $output = '<p style="page-break-before: always"></p>'; } $output .= "<table class=\"req_spec\"><tr><th colspan=\"{$tableColspan}\">" . "<h{$level} class=\"doclevel\"> <span class=\"label\">{$docHeadingNumbering}{$labels['requirements_spec']}:</span> " . $name . "</th></tr></h{$level}>\n"; if ($options['toc']) { $spacing = $level == 2 ? "<br>" : ""; $options['tocCode'] .= $spacing . '<b><p style="padding-left: ' . 10 * $level . 'px;">' . '<a href="#' . prefixToHTMLID($tocPrefix) . '">' . $docHeadingNumbering . $name . "</a></p></b>\n"; $output .= "<a name='" . prefixToHTMLID($tocPrefix) . "'></a>\n"; } $output .= '<tr><td width="' . $firstColWidth . '"><span class="label">' . $labels['revision'] . "</span></td><td> " . $spec['revision'] . "</td></tr>\n"; if ($options['req_spec_author']) { // get author name for node $author = tlUser::getById($db, $spec['author_id']); $whois = is_null($author) ? lang_get('undefined') : $author->getDisplayName(); $output .= '<tr><td width="' . $firstColWidth . '"><span class="label">' . $labels['author'] . "</span></td><td> " . htmlspecialchars($whois) . "</td></tr>\n"; } if ($options['req_spec_type']) { $output .= '<tr><td width="' . $firstColWidth . '"><span class="label">' . $labels['type'] . "</span></td>" . "<td>"; if (isset($reqSpecTypeLabels[$spec['type']])) { $output .= $reqSpecTypeLabels[$spec['type']]; } else { $output .= sprintf($labels['undefined_req_spec_type'], $spec['type']); } $output .= "</td></tr>"; } if ($options['req_spec_overwritten_count_reqs']) { $current = $req_spec_mgr->get_requirements_count($spec['id']); $expected = $spec['total_req']; $coverage = $labels['not_aplicable'] . " ({$current}/0)"; if ($expected) { $percentage = round(100 / $expected * $current, 2); $coverage = "{$percentage}% ({$current}/{$expected})"; } $output .= '<tr><td width="' . $firstColWidth . '"><span class="label">' . $labels['overwritten_count'] . " (" . $labels['coverage'] . ")</span></td>" . "<td>" . $coverage . "</td></tr>"; } if ($options['req_spec_scope']) { $output .= "<tr><td colspan=\"{$tableColspan}\">" . $spec['scope'] . "</td></tr>"; } if ($options['req_spec_cf']) { $linked_cf = $req_spec_mgr->get_linked_cfields($who); if ($linked_cf) { foreach ($linked_cf as $key => $cf) { $cflabel = htmlspecialchars($cf['label']); $value = htmlspecialchars($cf['value']); $output .= "<tr><td width=\"{$firstColWidth}\"><span class=\"label\">" . $cflabel . "</span></td>" . "<td>{$value}</td></tr>"; } } } $output .= "</table><br/>\n"; return $output; }
/** * render a requirement specification node as HTML code for printing * * @author Andreas Simon * * @param resource $db * @param array $node the node to be printed * @param array $printingOptions * @param string $tocPrefix Prefix to be printed in TOC before title of node * @param int $level * @param int $tprojectID * * @return string $output HTML Code */ function renderReqSpecNodeForPrinting(&$db, &$node, &$printingOptions, $tocPrefix, $level, $tprojectID) { static $tableColspan; static $firstColWidth; static $labels; static $title_separator; static $req_spec_mgr; static $tplan_mgr; static $req_spec_cfg; static $reqSpecTypeLabels; if (!$req_spec_mgr) { $req_spec_cfg = config_get('req_spec_cfg'); $firstColWidth = '20%'; $tableColspan = 2; $labels = array('requirements_spec' => 'requirements_spec', 'scope' => 'scope', 'type' => 'type', 'author' => 'author', 'relations' => 'relations', 'overwritten_count' => 'req_total', 'coverage' => 'coverage', 'custom_field' => 'custom_field', 'not_aplicable' => 'not_aplicable'); $labels = init_labels($labels); $reqSpecTypeLabels = init_labels($req_spec_cfg->type_labels); $title_separator = config_get('gui_title_separator_1'); $req_spec_mgr = new requirement_spec_mgr($db); $tplan_mgr = new testplan($db); } $spec = $req_spec_mgr->get_by_id($node['id']); $name = htmlspecialchars($spec['doc_id'] . $title_separator . $spec['title']); $docHeadingNumbering = ''; if ($printingOptions['headerNumbering']) { $docHeadingNumbering = "{$tocPrefix}. "; } $output = "<table class=\"req_spec\"><tr><th colspan=\"{$tableColspan}\">" . "<span class=\"label\">{$docHeadingNumbering}{$labels['requirements_spec']}:</span> " . $name . "</th></tr>\n"; if ($printingOptions['toc']) { $spacing = $level == 2 ? "<br>" : ""; $printingOptions['tocCode'] .= $spacing . '<b><p style="padding-left: ' . 10 * $level . 'px;">' . '<a href="#' . prefixToHTMLID($tocPrefix) . '">' . $docHeadingNumbering . $name . "</a></p></b>\n"; $output .= "<a name='" . prefixToHTMLID($tocPrefix) . "'></a>\n"; } if ($printingOptions['req_spec_author']) { // get author name for node $author = tlUser::getById($db, $spec['author_id']); $output .= '<tr><td width="' . $firstColWidth . '"><span class="label">' . $labels['author'] . "</span></td><td> " . htmlspecialchars($author->getDisplayName()) . "</td></tr>\n"; } if ($printingOptions['req_spec_type']) { $output .= '<tr><td width="' . $firstColWidth . '"><span class="label">' . $labels['type'] . "</span></td>" . "<td>" . $reqSpecTypeLabels[$spec['type']] . "</td></tr>"; } if ($printingOptions['req_spec_overwritten_count_reqs']) { $current = $req_spec_mgr->get_requirements_count($spec['id']); $expected = $spec['total_req']; $coverage = $labels['not_aplicable'] . " ({$current}/0)"; if ($expected) { $percentage = round(100 / $expected * $current, 2); $coverage = "{$percentage}% ({$current}/{$expected})"; } $output .= '<tr><td width="' . $firstColWidth . '"><span class="label">' . $labels['overwritten_count'] . " (" . $labels['coverage'] . ")</span></td>" . "<td>" . $coverage . "</td></tr>"; } if ($printingOptions['req_spec_scope']) { $output .= "<tr><td colspan=\"{$tableColspan}\"><span class=\"label\">" . $labels['scope'] . "</span><br/>" . $spec['scope'] . "</td></tr>"; } if ($printingOptions['req_spec_cf']) { $linked_cf = $req_spec_mgr->get_linked_cfields($spec['id']); if ($linked_cf) { foreach ($linked_cf as $key => $cf) { $cflabel = htmlspecialchars($cf['label']); $value = htmlspecialchars($cf['value']); $output .= "<tr><td width=\"{$firstColWidth}\"><span class=\"label\">" . $cflabel . "</span></td>" . "<td>{$value}</td></tr>"; } } } $output .= "</table><br/>\n"; return $output; }