function renderTestSuiteNodeForPrinting(&$db, &$node, $env, &$options, $context, $tocPrefix, $indentLevel)
{
    static $tsuite_mgr;
    static $l10n;
    static $title_separator;
    static $cfieldFormatting;
    static $getOpt;
    if (is_null($l10n)) {
        $tsuite_mgr = new testsuite($db);
        $l10n = array('test_suite' => 'test_suite', 'details' => 'details', 'attached_files' => 'attached_files');
        $l10n = init_labels($l10n);
        $title_separator = config_get('gui_title_separator_1');
        $cfieldFormatting = array('table_css_style' => 'class="cf"');
        $getOpt['getByID'] = array('fields' => ' TS.id,TS.details ', 'renderImageInline' => true);
    }
    $code = null;
    $name = isset($node['name']) ? htmlspecialchars($node['name']) : '';
    $cfields = array('design' => '');
    $docHeadingNumbering = $options['headerNumbering'] ? $tocPrefix . "." : '';
    if ($options['toc']) {
        $spacing = $indentLevel == 2 && $tocPrefix != 1 ? "<br>" : "";
        $options['tocCode'] .= $spacing . '<b><p style="padding-left: ' . 10 * $indentLevel . 'px;">' . '<a href="#' . prefixToHTMLID($tocPrefix) . '">' . $docHeadingNumbering . $name . "</a></p></b>\n";
        $code .= "<a name='" . prefixToHTMLID($context['prefix']) . "'></a>\n";
    }
    // we would like to have html top heading H1 - H6
    $docHeadingLevel = $indentLevel - 1;
    // Remember that only H1 to H6 exists
    $docHeadingLevel = $docHeadingLevel > 6 ? 6 : $docHeadingLevel;
    $docHeadingLevel = $docHeadingLevel < 1 ? 1 : $docHeadingLevel;
    $code .= "<h{$docHeadingLevel} class='doclevel'>" . $docHeadingNumbering . $l10n['test_suite'] . $title_separator . $name . "</h{$docHeadingLevel}>\n";
    // ----- get Test Suite text -----------------
    if ($options['header']) {
        $tInfo = $tsuite_mgr->get_by_id($node['id'], $getOpt['getByID']);
        if ($tInfo['details'] != '') {
            $code .= '<div>' . $tInfo['details'] . '</div>';
        }
        $tInfo = null;
        $attachSet = (array) $tsuite_mgr->getAttachmentInfos($node['id']);
        if (count($attachSet) > 0) {
            $code .= '<table><caption style="text-align:left;">' . $l10n['attached_files'] . '</caption>';
            $code .= '<tr><td>&nbsp</td>';
            $code .= '<td><ul>';
            foreach ($attachSet as $item) {
                $fname = "";
                if ($item['title']) {
                    $fname .= htmlspecialchars($item['title']) . " : ";
                }
                $fname .= htmlspecialchars($item['file_name']);
                $code .= "<li>{$fname}</li>";
                if ($item['is_image']) {
                    $code .= '<li>' . '<img src="' . $env->base_href . 'lib/attachments/attachmentdownload.php?skipCheck=1&id=' . $item['id'] . '"> </li>';
                } else {
                    $code .= '<li>' . '<a href="' . $env->base_href . 'lib/attachments/attachmentdownload.php?skipCheck=1&id=' . $item['id'] . '" ' . ' target="#blank" > ' . htmlspecialchars($item['file_name']) . '</a></li>';
                }
            }
            $code .= "</ul></td></tr>";
            $code .= "</table>";
        }
        $attachSet = null;
        // get Custom fields
        // Attention: for test suites custom fields can not be edited during execution,
        //            then we need to get just custom fields with scope  'design'
        foreach ($cfields as $key => $value) {
            $cfields[$key] = $tsuite_mgr->html_table_of_custom_field_values($node['id'], $key, null, $context['tproject_id'], $cfieldFormatting);
            if ($cfields[$key] != "") {
                $add_br = true;
                $code .= '<p>' . $cfields[$key] . '</p>';
            }
        }
        $cfields = null;
    }
    return $code;
}
예제 #2
0
function renderTestSuiteNodeForPrinting(&$db, &$node, $env, &$options, $context)
{
    static $tsuite_mgr;
    static $labels;
    static $title_separator;
    static $cfieldFormatting;
    if (!is_null($labels)) {
        $labels = array('test_suite' => lang_get('test_suite'), 'details' => lang_get('details'));
        $title_separator = config_get('gui_title_separator_1');
        $cfieldFormatting = array('table_css_style' => 'class="cf"');
    }
    $code = null;
    $name = isset($node['name']) ? htmlspecialchars($node['name']) : '';
    $cfields = array('design' => '');
    $docHeadingNumbering = $options['headerNumbering'] ? $env->tocPrefix . "." : '';
    if ($options['toc']) {
        $spacing = $context['level'] == 2 && $env->tocPrefix != 1 ? "<br>" : "";
        $options['tocCode'] .= $spacing . '<b><p style="padding-left: ' . 10 * $context['level'] . 'px;">' . '<a href="#' . prefixToHTMLID($env->tocPrefix) . '">' . $docHeadingNumbering . $name . "</a></p></b>\n";
        $code .= "<a name='" . prefixToHTMLID($context['prefix']) . "'></a>\n";
    }
    $docHeadingLevel = $context['level'] - 1;
    //we would like to have html top heading H1 - H6
    $docHeadingLevel = $docHeadingLevel > 6 ? 6 : $docHeadingLevel;
    $code .= "<h{$docHeadingLevel} class='doclevel'>" . $docHeadingNumbering . $labels['test_suite'] . $title_separator . $name . "</h{$docHeadingLevel}>\n";
    // ----- get Test Suite text -----------------
    if ($options['header']) {
        if (!$tsuite_mgr) {
            $tsuite_mgr = new testsuite($db);
        }
        $tInfo = $tsuite_mgr->get_by_id($node['id']);
        if ($tInfo['details'] != '') {
            $code .= '<div>' . $tInfo['details'] . '</div>';
        }
        $attachSet = (array) $tsuite_mgr->getAttachmentInfos($node['id']);
        if (count($attachSet) > 0) {
            $code .= "<table>";
            $code .= "<tr><td><span class=\"label\">" . $labels['attached_files'] . "</span></td><td><ul>";
            foreach ($attachSet as $item) {
                $fname = "";
                if ($item['title']) {
                    $fname .= htmlspecialchars($item['title']) . " : ";
                }
                $fname .= htmlspecialchars($item['file_name']);
                $code .= "<li>{$fname}</li>";
                if ($item['is_image']) {
                    $code .= '<li>' . '<img src="' . $env->base_href . 'lib/attachments/attachmentdownload.php?skipCheck=1&id=' . $item['id'] . '"> </li>';
                }
            }
            $code .= "</ul></td></tr>";
            $code .= "</table>";
        }
        // get Custom fields
        // Attention: for test suites custom fields can not be edited during execution,
        //            then we need to get just custom fields with scope  'design'
        foreach ($cfields as $key => $value) {
            $cfields[$key] = $tsuite_mgr->html_table_of_custom_field_values($node['id'], $key, null, $context['tproject_id'], $cfieldFormatting);
            if ($cfields[$key] != "") {
                $add_br = true;
                $code .= '<p>' . $cfields[$key] . '</p>';
            }
        }
    }
    return $code;
}