/** * manage GUI rendering * */ function renderGui(&$argsObj, $guiObj, $opObj, $templateCfg, $cfgObj, $edit_steps) { $smartyObj = new TLSmarty(); // need by webeditor loading logic present on inc_head.tpl $smartyObj->assign('editorType', $guiObj->editorType); $renderType = 'none'; // // key: operation requested (normally received from GUI on doAction) // value: operation value to set on doAction HTML INPUT // This is useful when you use same template (example xxEdit.tpl), for create and edit. // When template is used for create -> operation: doCreate. // When template is used for edit -> operation: doUpdate. // // used to set value of: $guiObj->operation // $actionOperation = array('create' => 'doCreate', 'doCreate' => 'doCreate', 'edit' => 'doUpdate', 'delete' => 'doDelete', 'doDelete' => '', 'createStep' => 'doCreateStep', 'doCreateStep' => 'doCreateStep', 'doCopyStep' => 'doUpdateStep', 'editStep' => 'doUpdateStep', 'doUpdateStep' => 'doUpdateStep', 'doDeleteStep' => '', 'doReorderSteps' => '', 'doInsertStep' => 'doUpdateStep'); $key2work = 'initWebEditorFromTemplate'; $initWebEditorFromTemplate = property_exists($opObj, $key2work) ? $opObj->{$key2work} : false; $key2work = 'cleanUpWebEditor'; $cleanUpWebEditor = property_exists($opObj, $key2work) ? $opObj->{$key2work} : false; $oWebEditor = createWebEditors($argsObj->basehref, $cfgObj->webEditorCfg, null, $edit_steps); foreach ($oWebEditor->cfg as $key => $value) { $of =& $oWebEditor->editor[$key]; $rows = $oWebEditor->cfg[$key]['rows']; $cols = $oWebEditor->cfg[$key]['cols']; switch ($argsObj->doAction) { case "edit": case "delete": case "editStep": $initWebEditorFromTemplate = false; $of->Value = $argsObj->{$key}; break; case "doCreate": case "doDelete": case "doCopyStep": case "doUpdateStep": $initWebEditorFromTemplate = false; $of->Value = $argsObj->{$key}; break; case "create": case "doCreateStep": case "doInsertStep": default: $initWebEditorFromTemplate = true; break; } $guiObj->operation = $actionOperation[$argsObj->doAction]; if ($initWebEditorFromTemplate) { $of->Value = getItemTemplateContents('testcase_template', $of->InstanceName, ''); } else { if ($cleanUpWebEditor) { $of->Value = ''; } } $smartyObj->assign($key, $of->CreateHTML($rows, $cols)); } // manage tree refresh switch ($argsObj->doAction) { case "doDelete": $guiObj->refreshTree = $argsObj->refreshTree; break; } switch ($argsObj->doAction) { case "edit": case "create": case "delete": case "createStep": case "editStep": case "doCreate": case "doDelete": case "doCreateStep": case "doUpdateStep": case "doDeleteStep": case "doReorderSteps": case "doCopyStep": case "doInsertStep": $renderType = 'template'; // Document !!!! $key2loop = get_object_vars($opObj); foreach ($key2loop as $key => $value) { $guiObj->{$key} = $value; } $guiObj->operation = $actionOperation[$argsObj->doAction]; new dBug($opObj); $tplDir = !isset($opObj->template_dir) || is_null($opObj->template_dir) ? $templateCfg->template_dir : $opObj->template_dir; $tpl = is_null($opObj->template) ? $templateCfg->default_template : $opObj->template; $pos = strpos($tpl, '.php'); if ($pos === false) { $tpl = $tplDir . $tpl; } else { $renderType = 'redirect'; } break; } switch ($renderType) { case 'template': new dBug($tpl); $smartyObj->assign('gui', $guiObj); $smartyObj->display($tpl); break; case 'redirect': header("Location: {$tpl}"); exit; break; default: break; } }
$labels = init_labels(array('active_integration' => null, 'inactive_integration' => null)); for ($idx = 0; $idx < $loop2do; $idx++) { $gui->tprojects[$idx]['rmsstatusImg'] = ''; if ($gui->tprojects[$idx]['rmsname'] != '') { $ak = $gui->tprojects[$idx]['reqmgr_integration_enabled'] ? 'active' : 'inactive'; $gui->tprojects[$idx]['rmsstatusImg'] = ' <img title="' . $labels[$ak . '_integration'] . '" ' . ' alt="' . $labels[$ak . '_integration'] . '" ' . ' src="' . $imgSet[$ak] . '"/>'; } } } $smarty->assign('gui', $gui); $smarty->display($templateCfg->template_dir . $template); break; case "ErrorOnAction": default: if ($args->doAction != "edit" && $args->doAction != "ErrorOnAction") { $of->Value = getItemTemplateContents('project_template', $of->InstanceName, $args->notes); } else { $of->Value = $args->notes; } foreach ($ui as $prop => $value) { $smarty->assign($prop, $value); } $smarty->assign('gui', $args); $smarty->assign('notes', $of->CreateHTML()); $smarty->assign('user_feedback', $user_feedback); $smarty->assign('feedback_type', $feedback_type); $smarty->display($templateCfg->template_dir . $template); break; } /** * INITialize page ARGuments, using the $_REQUEST and $_SESSION
$templateCfg = templateConfiguration(); $tplan_mgr = new testplan($db); $tproject_mgr = new testproject($db); $smarty = new TLSmarty(); $do_display = false; $template = null; $args = init_args($_REQUEST); if (!$args->tproject_id) { $smarty->assign('title', lang_get('fatal_page_title')); $smarty->assign('content', lang_get('error_no_testprojects_present')); $smarty->display('workAreaSimple.tpl'); exit; } $gui = initializeGui($db, $args, $editorCfg, $tproject_mgr); $of = web_editor('notes', $_SESSION['basehref'], $editorCfg); $of->Value = getItemTemplateContents('testplan_template', $of->InstanceName, $args->notes); // Checks on testplan name, and testplan name<=>testplan id if ($args->do_action == "do_create" || $args->do_action == "do_update") { $gui->testplan_name = $args->testplan_name; $name_exists = $tproject_mgr->check_tplan_name_existence($args->tproject_id, $args->testplan_name); $name_id_rel_ok = isset($gui->tplans[$args->tplan_id]) && $gui->tplans[$args->tplan_id]['name'] == $args->testplan_name; } // interface changes to be able to do not loose CF values if some problem arise on User Interface $gui->cfields = $tplan_mgr->html_table_of_custom_field_inputs($args->tplan_id, $args->tproject_id, 'design', '', $_REQUEST); switch ($args->do_action) { case 'fileUpload': fileUploadManagement($db, $args->tplan_id, $args->fileTitle, $tplan_mgr->getAttachmentTableName()); getItemData($tplan_mgr, $gui, $of, $args->tplan_id, true); break; case 'deleteFile': deleteAttachment($db, $args->file_id);
private function _initializeWebEditors($WebEditors, $itemTemplateCfgKey) { $wdata = array(); foreach ($WebEditors as $key => $html_name) { $wdata[$html_name] = getItemTemplateContents($itemTemplateCfgKey, $html_name, ''); } return $wdata; }
function createExecNotesWebEditor(&$tcversions, $basehref, $editorCfg) { if (is_null($tcversions) || count($tcversions) == 0) { return null; // nothing todo >>>------> bye! } // Important Notice: // // When using tinymce or none as web editor, we need to set rows and cols // to appropriate values, to avoid an ugly ui. // null => use default values defined on editor class file // // Rows and Cols values are useless for FCKeditor. // $itemTemplateValue = getItemTemplateContents('execution_template', 'notes', null); foreach ($tcversions as $key => $tcv) { $tcversion_id = $tcv['id']; $tcase_id = $tcv['testcase_id']; $of = web_editor("notes[{$tcversion_id}]", $basehref, $editorCfg); $of->Value = $itemTemplateValue; // Magic numbers that can be determined by trial and error $editors[$tcase_id] = $of->CreateHTML(10, 60); unset($of); } return $editors; }
/** * renderGui * */ function renderGui(&$argsObj, $guiObj, $opObj, $templateCfg, $editorCfg) { $smartyObj = new TLSmarty(); $renderType = 'none'; $tpl = $tpd = null; $actionOperation = array('create' => 'doCreate', 'edit' => 'doUpdate', 'doDelete' => '', 'doReorder' => '', 'reorder' => '', 'doCreate' => 'doCreate', 'doUpdate' => 'doUpdate', 'createChild' => 'doCreate', 'copy' => 'doCopy', 'doCopy' => 'doCopy', 'copyRequirements' => 'doCopyRequirements', 'doCopyRequirements' => 'doCopyRequirements'); $owebEditor = web_editor('scope', $argsObj->basehref, $editorCfg); switch ($argsObj->doAction) { case "edit": case "doCreate": $owebEditor->Value = $argsObj->scope; break; default: $owebEditor->Value = getItemTemplateContents('req_spec_template', $owebEditor->InstanceName, $argsObj->scope); break; } $guiObj->scope = $owebEditor->CreateHTML(); $guiObj->editorType = $editorCfg['type']; // 20100808 - aismon - added logic to refresh filtered tree on action switch ($argsObj->doAction) { case "doCreate": case "doUpdate": case "doCopyRequirements": case "doCopy": case "doDelete": $guiObj->refreshTree = $argsObj->refreshTree; break; } switch ($argsObj->doAction) { case "edit": case "create": case "createChild": case "reorder": case "doDelete": case "doReorder": case "doCreate": case "doUpdate": case "copyRequirements": case "doCopyRequirements": case "copy": case "doCopy": $renderType = 'template'; $key2loop = get_object_vars($opObj); foreach ($key2loop as $key => $value) { $guiObj->{$key} = $value; } $guiObj->operation = $actionOperation[$argsObj->doAction]; $tpl = is_null($opObj->template) ? $templateCfg->default_template : $opObj->template; $tpd = isset($key2loop['template_dir']) ? $opObj->template_dir : $templateCfg->template_dir; break; } switch ($argsObj->doAction) { case "edit": case "create": case "createChild": case "reorder": case "doDelete": case "doReorder": case "copyRequirements": case "copy": $tpl = $tpd . $tpl; break; case "doCreate": case "doUpdate": case "doCopyRequirements": case "doCopy": $pos = strpos($tpl, '.php'); if ($pos === false) { $tpl = $templateCfg->template_dir . $tpl; } else { $renderType = 'redirect'; } break; } switch ($renderType) { case 'template': $smartyObj->assign('mgt_view_events', has_rights($db, "mgt_view_events")); $smartyObj->assign('gui', $guiObj); $smartyObj->display($tpl); break; case 'redirect': header("Location: {$tpl}"); exit; break; default: break; } }
/** * * */ function initWebEditors(&$guiObj, $cfgObj, $baseHREF) { if ($guiObj->can_use_bulk_op) { //$guiObj->execStatusValues=createResultsMenu(); //if( isset($guiObj->execStatusValues[$cfgObj->tc_status['all']]) ) //{ // unset($guiObj->execStatusValues[$cfgObj->tc_status['all']]); //} $of = web_editor("bulk_exec_notes", $baseHREF, $cfgObj->editorCfg); $of->Value = getItemTemplateContents('execution_template', $of->InstanceName, null); // Magic numbers that can be determined by trial and error $guiObj->bulk_exec_notes_editor = $of->CreateHTML(10, 60); unset($of); } else { $guiObj->exec_notes_editors = createExecNotesWebEditor($guiObj->map_last_exec, $baseHREF, $cfgObj->editorCfg); } }
function setUpForBulkExec($guiObj) { $guiObj->execStatusValues = testcase::createExecutionResultsMenu(); if (isset($guiObj->execStatusValues[$guiObj->cfg->tc_status['all']])) { unset($guiObj->execStatusValues[$guiObj->cfg->tc_status['all']]); } $of = web_editor("bulk_exec_notes", $_SESSION['basehref'], $guiObj->cfg->editorCfg); $of->Value = getItemTemplateContents('execution_template', $of->InstanceName, null); // Magic numbers that can be determined by trial and error $guiObj->bulk_exec_notes_editor = $of->CreateHTML(10, 60); unset($of); }
* **/ require_once "../../config.inc.php"; require_once "common.php"; require_once "users.inc.php"; require_once "web_editor.php"; $editorCfg = getWebEditorCfg('role'); require_once require_web_editor($editorCfg['type']); testlinkInitPage($db, false, false, "checkRights"); init_global_rights_maps(); $templateCfg = templateConfiguration(); $args = init_args(); $gui = initialize_gui($args, $editorCfg['type']); $op = initialize_op(); $owebeditor = web_editor('notes', $args->basehref, $editorCfg); $owebeditor->Value = getItemTemplateContents('role_template', $owebeditor->InstanceName, null); $canManage = $args->user->hasRight($db, "role_management") ? true : false; switch ($args->doAction) { case 'create': break; case 'edit': $op->role = tlRole::getByID($db, $args->roleid); break; case 'doCreate': case 'doUpdate': case 'duplicate': if ($canManage) { $op = doOperation($db, $args, $args->doAction); $templateCfg->template = $op->template; } break;
/** * * */ function renderGui(&$argsObj, $guiObj, $opObj, $templateCfg, $editorCfg, &$dbHandler) { $smartyObj = new TLSmarty(); $renderType = 'none'; // @TODO document $actionOperation = array('create' => 'doCreate', 'edit' => 'doUpdate', 'doDelete' => '', 'doReorder' => '', 'reorder' => '', 'createTestCases' => 'doCreateTestCases', 'doCreateTestCases' => 'doCreateTestCases', 'doCreate' => 'doCreate', 'doUpdate' => 'doUpdate', 'copy' => 'doCopy', 'doCopy' => 'doCopy', 'doCreateVersion' => 'doCreateVersion', 'doCreateRevision' => 'doCreateRevision', 'doDeleteVersion' => '', 'doFreezeVersion' => 'doFreezeVersion', 'doAddRelation' => 'doAddRelation', 'doDeleteRelation' => 'doDeleteRelation'); $owebEditor = web_editor('scope', $argsObj->basehref, $editorCfg); switch ($argsObj->doAction) { case "edit": case "doCreate": $owebEditor->Value = $argsObj->scope; break; default: if ($opObj->suggest_revision || $opObj->prompt_for_log) { $owebEditor->Value = $argsObj->scope; } else { $owebEditor->Value = getItemTemplateContents('requirement_template', $owebEditor->InstanceName, $argsObj->scope); } break; } $guiObj->askForRevision = $opObj->suggest_revision ? 1 : 0; $guiObj->askForLog = $opObj->prompt_for_log ? 1 : 0; $guiObj->scope = $owebEditor->CreateHTML(); $guiObj->editorType = $editorCfg['type']; switch ($argsObj->doAction) { case "doDelete": $guiObj->refreshTree = 1; // has to be forced break; case "doCreate": $guiObj->refreshTree = $argsObj->refreshTree; break; case "doUpdate": // IMPORTANT NOTICE // we do not set tree refresh here, because on this situation // tree update has to be done when reqView page is called. // If we ask for tree refresh here we are going to do double refresh (useless and time consuming) break; } switch ($argsObj->doAction) { case "edit": case "create": case "reorder": case "doDelete": case "doReorder": case "createTestCases": case "doCreateTestCases": case "doCreate": case "doFreezeVersion": case "doUpdate": case "copy": case "doCopy": case "doCreateVersion": case "doDeleteVersion": case "doAddRelation": case "doDeleteRelation": case "doCreateRevision": $renderType = 'template'; $key2loop = get_object_vars($opObj); foreach ($key2loop as $key => $value) { $guiObj->{$key} = $value; } // exceptions $guiObj->askForRevision = $opObj->suggest_revision ? 1 : 0; $guiObj->askForLog = $opObj->prompt_for_log ? 1 : 0; $guiObj->operation = $actionOperation[$argsObj->doAction]; $tplDir = !isset($opObj->template_dir) || is_null($opObj->template_dir) ? $templateCfg->template_dir : $opObj->template_dir; $tpl = is_null($opObj->template) ? $templateCfg->default_template : $opObj->template; $pos = strpos($tpl, '.php'); if ($pos === false) { $tpl = $tplDir . $tpl; } else { $renderType = 'redirect'; } break; } $req_mgr = new requirement_mgr($dbHandler); $guiObj->last_doc_id = $req_mgr->get_last_doc_id_for_testproject($argsObj->tproject_id); $guiObj->doAction = $argsObj->doAction; switch ($renderType) { case 'template': $smartyObj->assign('gui', $guiObj); $smartyObj->display($tpl); break; case 'redirect': header("Location: {$tpl}"); exit; break; default: break; } }
/** * * */ function renderGui(&$argsObj, $guiObj, $opObj, $templateCfg, $editorCfg, &$dbHandler) { $smartyObj = new TLSmarty(); $renderType = 'none'; // @TODO document $actionOperation = array('create' => 'doCreate', 'edit' => 'doUpdate', 'doDelete' => '', 'doReorder' => '', 'reorder' => '', 'createTestCases' => 'doCreateTestCases', 'doCreateTestCases' => 'doCreateTestCases', 'doCreate' => 'doCreate', 'doUpdate' => 'doUpdate', 'copy' => 'doCopy', 'doCopy' => 'doCopy', 'doCreateVersion' => 'doCreateVersion', 'doDeleteVersion' => '', 'doFreezeVersion' => 'doFreezeVersion', 'doAddRelation' => 'doAddRelation', 'doDeleteRelation' => 'doDeleteRelation'); $owebEditor = web_editor('scope', $argsObj->basehref, $editorCfg); switch ($argsObj->doAction) { case "edit": case "doCreate": $owebEditor->Value = $argsObj->scope; break; default: $owebEditor->Value = getItemTemplateContents('requirement_template', $owebEditor->InstanceName, $argsObj->scope); break; } $guiObj->scope = $owebEditor->CreateHTML(); $guiObj->editorType = $editorCfg['type']; // 20100808 - aismon - added logic to refresh filtered tree on action switch ($argsObj->doAction) { case "doDelete": case "doCreate": $guiObj->refreshTree = $argsObj->refreshTree; break; } switch ($argsObj->doAction) { case "edit": case "create": case "reorder": case "doDelete": case "doReorder": case "createTestCases": case "doCreateTestCases": case "doCreate": case "doFreezeVersion": case "doUpdate": case "copy": case "doCopy": case "doCreateVersion": case "doDeleteVersion": // BUGID 1748 // BUGID 1748 case "doAddRelation": case "doDeleteRelation": $renderType = 'template'; $key2loop = get_object_vars($opObj); foreach ($key2loop as $key => $value) { $guiObj->{$key} = $value; } $guiObj->operation = $actionOperation[$argsObj->doAction]; $tplDir = !isset($opObj->template_dir) || is_null($opObj->template_dir) ? $templateCfg->template_dir : $opObj->template_dir; $tpl = is_null($opObj->template) ? $templateCfg->default_template : $opObj->template; $pos = strpos($tpl, '.php'); if ($pos === false) { $tpl = $tplDir . $tpl; } else { $renderType = 'redirect'; } break; } $req_mgr = new requirement_mgr($dbHandler); $guiObj->last_doc_id = $req_mgr->get_last_doc_id_for_testproject($argsObj->tproject_id); $guiObj->doAction = $argsObj->doAction; switch ($renderType) { case 'template': $smartyObj->assign('gui', $guiObj); $smartyObj->display($tpl); break; case 'redirect': header("Location: {$tpl}"); exit; break; default: break; } }
/** * renderGui * */ function renderGui(&$argsObj, $guiObj, $opObj, $templateCfg, $editorCfg) { $smartyObj = new TLSmarty(); $renderType = 'none'; $tpl = $tpd = null; $actionOperation = array('create' => 'doCreate', 'edit' => 'doUpdate', 'doDelete' => '', 'doReorder' => '', 'reorder' => '', 'doCreate' => 'doCreate', 'doUpdate' => 'doUpdate', 'createChild' => 'doCreate', 'copy' => 'doCopy', 'doCopy' => 'doCopy', 'doFreeze' => 'doFreeze', 'copyRequirements' => 'doCopyRequirements', 'doCopyRequirements' => 'doCopyRequirements', 'doCreateRevision' => 'doCreateRevision'); // ------------------------------------------------------------------------------------------------ // Web Editor Processing $owebEditor = web_editor('scope', $argsObj->basehref, $editorCfg); switch ($argsObj->doAction) { case "edit": case "doCreate": $owebEditor->Value = $argsObj->scope; break; default: // TICKET 4661 if ($opObj->askForRevision || $opObj->askForLog || !$opObj->action_status_ok) { $owebEditor->Value = $argsObj->scope; } else { $owebEditor->Value = getItemTemplateContents('req_spec_template', $owebEditor->InstanceName, $argsObj->scope); } break; } $guiObj->scope = $owebEditor->CreateHTML(); $guiObj->editorType = $editorCfg['type']; // Tree refresh Processing switch ($argsObj->doAction) { case "doCreate": case "doUpdate": case "doCopyRequirements": case "doCopy": case "doFreeze": case "doDelete": $guiObj->refreshTree = $argsObj->refreshTree; break; } // GUI rendering Processing switch ($argsObj->doAction) { case "edit": case "create": case "createChild": case "reorder": case "doDelete": case "doReorder": case "doCreate": case "doUpdate": case "copyRequirements": case "doCopyRequirements": case "copy": case "doCopy": case "doFreeze": case "doCreateRevision": $renderType = 'template'; $key2loop = get_object_vars($opObj); if ($opObj->action_status_ok == false) { // Remember that scope normally is a WebRichEditor, and that // we have already processed WebRichEditor // Need to understand if remove of scope key can be done always // no matter action_status_ok unset($key2loop['scope']); } foreach ($key2loop as $key => $value) { $guiObj->{$key} = $value; } $guiObj->operation = $actionOperation[$argsObj->doAction]; $tpl = is_null($opObj->template) ? $templateCfg->default_template : $opObj->template; $tpd = isset($key2loop['template_dir']) ? $opObj->template_dir : $templateCfg->template_dir; $pos = strpos($tpl, '.php'); if ($pos === false) { $tpl = $tpd . $tpl; } else { $renderType = 'redirect'; } break; } switch ($renderType) { case 'template': $smartyObj->assign('mgt_view_events', $argsObj->user->hasRights($db, "mgt_view_events")); $smartyObj->assign('gui', $guiObj); $smartyObj->display($tpl); break; case 'redirect': header("Location: {$tpl}"); exit; break; default: echo '$argsObj->doAction:' . $argsObj->doAction . ' Can not process RENDERING!!!'; break; } }
/** * * */ function initWebEditors(&$guiObj, $cfgObj, $baseHREF) { if ($guiObj->can_use_bulk_op) { $of = web_editor("bulk_exec_notes", $baseHREF, $cfgObj->editorCfg); $of->Value = getItemTemplateContents('execution_template', $of->InstanceName, null); // Magic numbers that can be determined by trial and error $cols = intval(isset($editorCfg['cols']) ? $cfgObj->editorCfg['cols'] : 60); $rows = intval(isset($editorCfg['rows']) ? $cfgObj->editorCfg['rows'] : 10); $guiObj->bulk_exec_notes_editor = $of->CreateHTML($rows, $cols); unset($of); } else { $guiObj->exec_notes_editors = createExecNotesWebEditor($guiObj->map_last_exec, $baseHREF, $cfgObj->editorCfg); } }