function choose_next_mode()
{
    global $session_data;
    if (@$_REQUEST['zoteroEntryPoint']) {
        $session_data['mode'] = 'zotero request parsing';
        return;
    }
    $session_data['prev-mode'] = @$session_data['mode'] ? $session_data['mode'] : '';
    // allow the user to keep re-visiting the entry insertion page as long as there are records to disambiguate
    if ($session_data['prev-mode'] == 'entry insertion' && (count(@$session_data['disambig-biblios']) > 0 || count(@$session_data['disambig-ancestor-biblios']) > 0)) {
        $session_data['mode'] = 'entry insertion';
        return;
    }
    /*
    if (@$_REQUEST['clear-session'] == 'Yes') {
    $session_data['mode'] = 'clear session';
    return;
    } else if (@$_REQUEST['clear-session'] == 'No') {
    $session_data['mode'] = 'file selection';
    return;
    }
    */
    if ($session_data['prev-mode'] == '' && @$_FILES['import_file']['name']) {
        $session_data['prev-mode'] = 'file selection';
    }
    switch ($session_data['prev-mode']) {
        case 'file selection':
            // might progress to file parsing, might stay at file selection
            postmode_file_selection();
            break;
        case 'file parsing':
        case 'zotero request parsing':
            // might skip over rectype selection if there are no unknown rectypes
            postmode_file_parsing();
            break;
        case 'print rectype selection':
            // user might have selected "set all to X", or "choose between X, Y, Z"
            postmode_print_rectype_selection();
            break;
        case 'apply rectype heuristic':
            // only one way forward
            $session_data['mode'] = 'crosswalking';
            break;
        case 'crosswalking':
            // only one way forward
            $session_data['mode'] = 'entry insertion';
            break;
        case '':
            $heurist_import_count = 0;
            if (is_array(@$_SESSION[HEURIST_SESSION_DB_PREFIX . 'heurist'])) {
                foreach ($_SESSION[HEURIST_SESSION_DB_PREFIX . 'heurist'] as $name => $val) {
                    if (strpos($name, 'heurist-import-') === 0) {
                        ++$heurist_import_count;
                    }
                }
            }
            if ($heurist_import_count > 0) {
                // get rid of old import data automatically
                clear_session();
            }
        case 'finished':
        case 'entry insertion':
        default:
            $session_data['mode'] = 'file selection';
    }
}
Esempio n. 2
0
}
//first step - load file into import table
if ($step == 1 && $imp_session == null) {
    ob_start();
    echo '<script>showProgressMsg("Please wait, file is processing on server")</script>';
    ob_flush();
    flush();
    if (@$_REQUEST["upload_file_name"]) {
        //load file into db
        $imp_session = postmode_file_load_to_db(HEURIST_FILESTORE_DIR . 'scratch/' . $_REQUEST["upload_file_name"], $_REQUEST["upload_file_name"], true);
    } else {
        if (@$_REQUEST["filename"]) {
            //after postprocessing - additional step load from temp file
            $imp_session = postmode_file_load_to_db($_REQUEST["filename"], $_REQUEST["original"], @$_REQUEST["preprocess"] == "1");
        } else {
            $imp_session = postmode_file_selection();
        }
    }
    ?>

            <script type="text/javascript">
                $(document).ready( function(){ 
                    $("#div-progress").hide(); 
                });

                //
                // reload
                //
                function doReload(){
                    $("#step").val(0);
                    doUpload2();