Пример #1
0
}
if ($action == "importPreview") {
    $returnJSON = array();
    // prepare the temp import file name
    $rnrTempFileName = $pageObject->getImportTempFileName();
    if (postvalue("importType") == "text") {
        $importText = postvalue("importText");
        $returnJSON["previewData"] = $pageObject->getPreviewDataFromText($importText);
        // prepare the temp file path
        $rnrTempImportFilePath = getabspath("templates_c/" . $rnrTempFileName . ".csv");
        // save file in a temporary directory
        runner_save_textfile($rnrTempImportFilePath, $importText);
    } else {
        $ext = getImportFileExtension("importFile" . $id);
        $importTempFileName = getTempImportFileName("importFile" . $id);
        $returnJSON["previewData"] = $pageObject->getPreviewDataFromFile($importTempFileName, $ext);
        // save file in a temporary directory
        $importFileData = getImportFileData("importFile" . $id);
        // prepare the temp file path
        $rnrTempImportFilePath = getabspath("templates_c/" . $rnrTempFileName . "." . $ext);
        upload_File($importFileData, $rnrTempImportFilePath);
    }
    // keep the temporary path in the SESSION variable
    $_SESSION[$pageObject->sessionPrefix . "_tempImportFilePath"] = $rnrTempImportFilePath;
    echo printJSON($returnJSON, postvalue("useXHR"));
    exit;
}
if ($action == "importData") {
    if ($eventObj->exists('BeforeImport')) {
        if ($eventObj->BeforeImport($pageObject) === false) {
            echo printJSON(array());