require_once "common.php";
require_once "csv.inc.php";
require_once "xml.inc.php";
testlinkInitPage($db);
$templateCfg = templateConfiguration();
$args = init_args($db);
checkRights($db, $_SESSION['currentUser'], $args);
switch ($args->doAction) {
    case "do_export":
        $op = do_export($db, $smarty, $args);
        break;
}
$keyword = new tlKeyword();
$gui = new stdClass();
$gui->tproject_id = $args->tproject_id;
$gui->exportTypes = $keyword->getSupportedSerializationInterfaces();
$gui->action_descr = lang_get('export_keywords');
$gui->main_descr = lang_get('testproject') . TITLE_SEP . $args->tproject_name;
$gui->export_filename = is_null($args->export_filename) ? $args->tproject_name . '-keywords.xml' : $args->export_filename;
$smarty = new TLSmarty();
$smarty->assign('gui', $gui);
$smarty->display($templateCfg->template_dir . $templateCfg->default_template);
function init_args(&$dbHandler)
{
    $_REQUEST = strings_stripSlashes($_REQUEST);
    $args = new stdClass();
    $iParams = array("doAction" => array(tlInputParameter::STRING_N, 0, 50), "export_filename" => array(tlInputParameter::STRING_N, 0, 255), "exportType" => array(tlInputParameter::STRING_N, 0, 255), "tproject_id" => array(tlInputParameter::INT_N));
    R_PARAMS($iParams, $args);
    $args->tproject_name = '';
    if ($args->tproject_id > 0) {
        $treeMgr = new tree($dbHandler);
                $result = $tproject->{$pfn}($args->testproject_id, $dest);
                if ($result != tl::OK) {
                    $msg = lang_get('wrong_keywords_file');
                } else {
                    header("Location: keywordsView.php");
                    exit;
                }
            }
            @unlink($dest);
        }
    } else {
        $msg = lang_get('please_choose_keywords_file');
    }
}
$tlKeyword = new tlKeyword();
$importTypes = $tlKeyword->getSupportedSerializationInterfaces();
$formatStrings = $tlKeyword->getSupportedSerializationFormatDescriptions();
$file_size_limit = config_get('import_file_max_size_bytes');
$smarty = new TLSmarty();
$smarty->assign('import_type_selected', $args->importType);
$smarty->assign('msg', $msg);
$smarty->assign('keywordFormatStrings', $formatStrings);
$smarty->assign('importTypes', $importTypes);
$smarty->assign('tproject_name', $args->testproject_name);
$smarty->assign('tproject_id', $args->testproject_id);
$smarty->assign('fileSizeLimitMsg', sprintf(lang_get('max_file_size_is'), $file_size_limit / 1024 . ' KB '));
$smarty->assign('importLimit', $file_size_limit);
$smarty->display($templateCfg->template_dir . $templateCfg->default_template);
/**
 * @return object returns the arguments for the page
 */