/**
 * Initialize gui (stdClass) object that will be used as argument
 * in call to Template Engine.
 *
 * @param class pointer args: object containing User Input and some session values
 *    TBD structure
 * 
 * ?     tprojectMgr: test project manager object.
 * ?     treeDragDropEnabled: true/false. Controls Tree drag and drop behaivor.
 * 
 * @return stdClass TBD structure
 */
function initializeGui(&$db, $args)
{
    $tcaseCfg = config_get('testcase_cfg');
    $reqCfg = config_get('req_cfg');
    $gui = new stdClass();
    $gui->showOptionsCheckBoxes = $gui->showOptions = $args->showOptions;
    $gui->showHelpIcon = $args->showHelpIcon;
    $gui->mainTitle = '';
    $gui->outputFormat = array(FORMAT_HTML => lang_get('format_html'), FORMAT_MSWORD => lang_get('format_pseudo_msword'));
    $gui->outputOptions = init_checkboxes($args);
    if ($gui->showOptions == false) {
        $loop2do = count($gui->outputOptions);
        for ($idx = 0; $idx < $loop2do; $idx++) {
            $gui->outputOptions[$idx]['checked'] = 'y';
        }
    }
    $tprojectMgr = new testproject($db);
    $tcasePrefix = $tprojectMgr->getTestCasePrefix($args->tproject_id);
    $gui->tree_title = '';
    $gui->ajaxTree = new stdClass();
    $gui->ajaxTree->root_node = new stdClass();
    $gui->ajaxTree->dragDrop = new stdClass();
    $gui->ajaxTree->dragDrop->enabled = false;
    $gui->ajaxTree->dragDrop->BackEndUrl = null;
    $gui->ajaxTree->children = '';
    // improved cookie prefix for test spec doc and req spec doc
    $gui->ajaxTree->cookiePrefix = $args->doc_type . '_doc_';
    $gui->doc_type = $args->doc_type;
    $addTestPlanID = false;
    switch ($args->doc_type) {
        case DOC_REQ_SPEC:
            $gui->showOptions = true;
            $gui->showOptionsCheckBoxes = false;
            $gui->tree_title = lang_get('title_req_print_navigator');
            $gui->ajaxTree->loader = $args->basehref . 'lib/ajax/getrequirementnodes.php?' . "root_node={$args->tproject_id}&show_children=0&operation=print";
            $gui->ajaxTree->loadFromChildren = 0;
            $gui->ajaxTree->root_node->href = "javascript:TPROJECT_PTP_RS({$args->tproject_id})";
            $gui->ajaxTree->root_node->id = $args->tproject_id;
            $req_qty = $tprojectMgr->count_all_requirements($args->tproject_id);
            $gui->ajaxTree->root_node->name = htmlspecialchars($args->tproject_name) . " ({$req_qty})";
            $gui->ajaxTree->cookiePrefix .= "tproject_id_" . $gui->ajaxTree->root_node->id . "_";
            $gui->mainTitle = lang_get('requirement_specification_report');
            break;
        case DOC_TEST_SPEC:
            $gui->tree_title = lang_get('title_tc_print_navigator');
            $gui->ajaxTree->loader = $args->basehref . 'lib/ajax/gettprojectnodes.php?' . "root_node={$args->tproject_id}&" . "show_tcases=0&operation=print&" . "tcprefix=" . urlencode($tcasePrefix . $tcaseCfg->glue_character) . "}";
            $gui->ajaxTree->loadFromChildren = 0;
            $gui->ajaxTree->root_node->href = "javascript:TPROJECT_PTP({$args->tproject_id})";
            $gui->ajaxTree->root_node->id = $args->tproject_id;
            $tcase_qty = $tprojectMgr->count_testcases($args->tproject_id);
            $gui->ajaxTree->root_node->name = htmlspecialchars($args->tproject_name) . " ({$tcase_qty})";
            $gui->ajaxTree->cookiePrefix .= "tproject_id_" . $gui->ajaxTree->root_node->id . "_";
            $gui->mainTitle = lang_get('testspecification_report');
            break;
        case DOC_TEST_PLAN_EXECUTION:
            $addTestPlanID = true;
            $gui->mainTitle = lang_get('test_report');
            break;
        case DOC_TEST_PLAN_DESIGN:
            $addTestPlanID = true;
            $gui->tree_title = lang_get('title_tp_print_navigator');
            $gui->ajaxTree->loadFromChildren = 1;
            $gui->ajaxTree->loader = '';
            $gui->mainTitle = lang_get('test_plan');
            break;
        case DOC_TEST_PLAN_EXECUTION_ON_BUILD:
            $addTestPlanID = true;
            $gui->mainTitle = lang_get('test_report_on_build');
            break;
    }
    // Do not move
    if ($args->mainTitle == '') {
        $gui->mainTitle .= ' - ' . lang_get('doc_opt_title');
    } else {
        $gui->mainTitle = $args->mainTitle;
    }
    $gui->getArguments = "&type=" . $args->doc_type;
    if ($addTestPlanID) {
        $gui->getArguments .= '&docTestPlanId=' . $args->tplan_id;
    }
    return $gui;
}
Пример #2
0
 *		20100723 - BUGID 3451 and related
 *  	20100326 - asimon - refactored to include requirement documents
 *                          added init_checkboxes()
 *		20090322 - amkhullar - added new option custom fields while printing Test plan/report
 * 		20090222 - havlatm - added new options 
 *
 */
require_once "../../config.inc.php";
require_once "../../cfg/reports.cfg.php";
require_once "common.php";
require_once "treeMenu.inc.php";
testlinkInitPage($db);
$templateCfg = templateConfiguration();
$args = init_args();
$gui = initializeGui($db, $args);
$arrCheckboxes = init_checkboxes($args);
$workPath = 'lib/results/printDocument.php';
switch ($args->doc_type) {
    case 'testplan':
    case 'testreport':
        $addTestPlanID = true;
        break;
    default:
        $addTestPlanID = false;
        break;
}
$getArguments = "&type=" . $args->doc_type;
if ($addTestPlanID) {
    $getArguments .= '&docTestPlanId=' . $args->tplan_id;
}
// generate tree
Пример #3
0
        $tree = $treeContents->menustring;
        $gui->ajaxTree = new stdClass();
        $gui->ajaxTree->root_node = $treeContents->rootnode;
        $gui->ajaxTree->children = $treeContents->menustring;
        $gui->ajaxTree->loadFromChildren = true;
        $report = $args->doc_type == "testplan" ? "test_plan_report" : "test_report";
        $gui->ajaxTree->cookiePrefix .= "{$report}_tplan_id_{$args->tplan_id}_";
        break;
    default:
        tLog("Argument _REQUEST['type'] has invalid value", 'ERROR');
        exit;
        break;
}
$smarty = new TLSmarty();
$smarty->assign('gui', $gui);
$smarty->assign('arrCheckboxes', init_checkboxes($args));
$smarty->assign('selFormat', $args->format);
$smarty->assign('docType', $args->doc_type);
$smarty->assign('docTestPlanId', $args->tplan_id);
$smarty->assign('tree', $tree);
$smarty->assign('menuUrl', $workPath);
$smarty->assign('args', $getArguments);
$smarty->assign('additionalArgs', $additionalArgs);
$smarty->display($templateCfg->template_dir . $templateCfg->default_template);
/**
 * get user input and create an object with properties representing this inputs.
 * @return stdClass object 
 */
function init_args(&$dbHandler)
{
    $args = new stdClass();