unset($biblio['origin']); // fot debugging purpose // var_dump($biblio); // die(); // insert biblio data $sql_op->insert('biblio', $biblio); echo '<p>' . $sql_op->error . '</p><p> </p>'; $biblio_id = $sql_op->insert_id; if ($biblio_id < 1) { continue; } // insert authors if ($authors) { $author_id = 0; foreach ($authors as $author) { $author_id = getAuthorID($author['name'], strtolower(substr($author['author_type'], 0, 1)), $author_cache); @$dbs->query("INSERT IGNORE INTO biblio_author (biblio_id, author_id, level) VALUES ({$biblio_id}, {$author_id}, " . $author['level'] . ")"); } } // insert subject/topical terms if ($subjects) { foreach ($subjects as $subject) { if ($subject['term_type'] == 'Temporal') { $subject_type = 'tm'; } else { if ($subject['term_type'] == 'Genre') { $subject_type = 'gr'; } else { if ($subject['term_type'] == 'Occupation') { $subject_type = 'oc'; } else {
// echo 'Author: '; foreach ($author_flds as $tag => $auth_fld) { if ($tag == '710') { $author_type = 'o'; } else { if ($tag == '711') { $author_type = 'c'; } else { $author_type = 'p'; } } if ($auth_fld) { $author = $auth_fld->getSubfields('a'); if (isset($author[0])) { // echo $author[0]->getData(); $author_id = getAuthorID($dbs->escape_string(trim($author[0]->getData())), $author_type, $author_cache); @$dbs->query("INSERT IGNORE INTO biblio_author (biblio_id, author_id, level) VALUES ({$biblio_id}, {$author_id}, 1)"); } } } } // create biblio index if ($sysconf['index']['type'] == 'index') { $indexer->makeIndex($biblio_id); } } $end_time = time(); $import_time_sec = $end_time - $start_time; utility::writeLogs($dbs, 'staff', $_SESSION['uid'], 'bibliography', 'Importing ' . $updated_row . ' MARC records from file : ' . $_FILES['importFile']['name']); echo '<script type="text/javascript">' . "\n"; echo 'top.jQuery(\'#importInfo\').html(\'<strong>' . $updated_row . '</strong> records updated successfully to item database, from record <strong>' . $_POST['recordOffset'] . ' in ' . $import_time_sec . ' second(s)</strong>\');' . "\n";
} // insert corporate body authors if ($authors_corp) { $author_id = 0; $author_type = 'o'; foreach ($authors_corp as $author_corp) { $author_id = getAuthorID($author_corp, $author_type, $author_cache); @$dbs->query("INSERT IGNORE INTO biblio_author (biblio_id, author_id, level) VALUES ({$biblio_id}, {$author_id}, 1)"); } } // insert conference/meeting authors if ($authors_conf) { $author_id = 0; $author_type = 'c'; foreach ($authors_conf as $author_conf) { $author_id = getAuthorID($author_conf, $author_type, $author_cache); @$dbs->query("INSERT IGNORE INTO biblio_author (biblio_id, author_id, level) VALUES ({$biblio_id}, {$author_id}, 1)"); } } // insert subject/topical terms if ($subjects) { foreach ($subjects as $subject) { $subject_type = 't'; $subject_id = getSubjectID($subject, $subject_type, $subject_cache); @$dbs->query("INSERT IGNORE INTO biblio_topic (biblio_id, topic_id, level) VALUES ({$biblio_id}, {$subject_id}, 1)"); } } if ($biblio_id) { $r++; } }
// echo 'Author: '; foreach ($author_flds as $tag => $auth_fld) { if ($tag == '710') { $author_type = 'o'; } else { if ($tag == '711') { $author_type = 'c'; } else { $author_type = 'p'; } } if ($auth_fld) { $author = $auth_fld->getSubfields('a'); if (isset($author[0])) { // echo $author[0]->getData(); $author_id = getAuthorID($author[0]->getData(), $author_type, $author_cache); @$dbs->query("INSERT IGNORE INTO biblio_author (biblio_id, author_id, level) VALUES ({$biblio_id}, {$author_id}, 1)"); } } } } echo '</pre>'; } $end_time = time(); $import_time_sec = $end_time - $start_time; utility::writeLogs($dbs, 'staff', $_SESSION['uid'], 'bibliography', 'Importing ' . $updated_row . ' MARC records from file : ' . $_FILES['importFile']['name']); echo '<script type="text/javascript">' . "\n"; echo 'parent.$(\'#importInfo\').html(\'<strong>' . $updated_row . '</strong> records updated successfully to item database, from record <strong>' . $_POST['recordOffset'] . ' in ' . $import_time_sec . ' second(s)</strong>\');' . "\n"; echo 'parent.$(\'#importInfo\').css( {\'display\': \'block\'} );' . "\n"; echo '</script>'; exit;