'.__('You are not authorized to view this section').''); } /* RECORD OPERATION */ if (isset($_POST['saveResults']) && isset($_POST['p2precord']) && isset($_POST['p2pserver_save'])) { require MDLBS.'bibliography/biblio_utils.inc.php'; $p2pserver = trim($_POST['p2pserver_save']); $gmd_cache = array(); $publ_cache = array(); $place_cache = array(); $lang_cache = array(); $author_cache = array(); $subject_cache = array(); $input_date = date('Y-m-d H:i:s'); // record counter $r = 0; foreach ($_POST['p2precord'] as $id) { // construct full XML URI $detail_uri = $p2pserver."/index.php?p=show_detail&inXML=true&id=".$id; // parse XML $data = modsXMLsenayan($detail_uri, 'uri'); // get record detail $record = $data['records'][0]; // insert record to database if ($record) { // create dbop object $sql_op = new simbio_dbop($dbs); // escape all string value foreach ($record as $field => $content) { if (is_string($content)) { $biblio[$field] = $dbs->escape_string(trim($content)); } } // gmd $biblio['gmd_id'] = utility::getID($dbs, 'mst_gmd', 'gmd_id', 'gmd_name', $record['gmd'], $gmd_cache); unset($biblio['gmd']); // publisher $biblio['publisher_id'] = utility::getID($dbs, 'mst_publisher', 'publisher_id', 'publisher_name', $record['publisher'], $publ_cache); unset($biblio['publisher']); // publish place $biblio['publish_place_id'] = utility::getID($dbs, 'mst_place', 'place_id', 'place_name', $record['publish_place'], $place_cache); unset($biblio['publish_place']); // language $biblio['language_id'] = utility::getID($dbs, 'mst_language', 'language_id', 'language_name', $record['language']['name'], $lang_cache); unset($biblio['language']); // authors $authors = array(); if (isset($record['authors'])) { $authors = $record['authors']; unset($biblio['authors']); } // subject $subjects = array(); if (isset($record['subjects'])) { $subjects = $record['subjects']; unset($biblio['subjects']); } $biblio['input_date'] = $biblio['create_date']; $biblio['last_update'] = $biblio['modified_date']; // remove unneeded elements unset($biblio['manuscript']); unset($biblio['collection']); unset($biblio['resource_type']); unset($biblio['genre_authority']); unset($biblio['genre']); unset($biblio['issuance']); unset($biblio['location']); unset($biblio['id']); unset($biblio['create_date']); unset($biblio['modified_date']); unset($biblio['origin']); // fot debugging purpose // var_dump($biblio); // die(); // insert biblio data $sql_op->insert('biblio', $biblio); echo '

'.$sql_op->error.'

 

'; $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 { $subject_type = strtolower(substr($subject['term_type'], 0, 1)); } $subject_id = getSubjectID($subject['term'], $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) { // write to logs utility::writeLogs($dbs, 'staff', $_SESSION['uid'], 'bibliography', $_SESSION['realname'].' insert bibliographic data from P2P service (server:'.$p2pserver.') with ('.$biblio['title'].') and biblio_id ('.$biblio_id.')'); $r++; } } } utility::jsAlert($r.' records inserted to database.'); echo ''; exit(); } /* RECORD OPERATION END */ /* SEARCH OPERATION */ if (isset($_GET['keywords']) && $can_read && isset($_GET['p2pserver'])) { $max_fetch = 20; # get server information $serverid = (integer)$_GET['p2pserver']; $p2pserver = $sysconf['p2pserver'][$serverid]['uri']; $p2pserver_name = $sysconf['p2pserver'][$serverid]['name']; # get keywords $keywords = urlencode($_GET['keywords']); # $p2pquery = $p2pserver.'index.php?resultXML=true&keywords='.$_GET['keywords']; $data = modsXMLsenayan($p2pserver."/index.php?resultXML=true&search=Search&keywords=".$keywords, 'uri'); # debugging tools # echo $p2pserver."/index.php?resultXML=true&keywords=".$keywords; # echo '
'; if ($data['records']) { echo '
Found '.$data['result_num'].' records from '.$p2pserver_name.' Server
'; echo '
'; echo ''; echo ''; $row = 1; foreach($data['records'] as $record) { if ($row > $max_fetch) { break; } $row_class = ($row%2 == 0)?'alterCell':'alterCell2'; echo ''; echo ''; echo ''; echo ''; $row++; } echo '
'.$record['title'].''; echo '
'; // concat authors name $buffer_authors = ''; foreach ($record['authors'] as $author) { $buffer_authors .= $author['name'].' - '; } echo substr_replace($buffer_authors, '', -3); echo '
'; echo '
'."\n"; echo ''; echo '
'; } else { echo '
'.sprintf(__('Sorry, no result found from %s OR maybe XML result and detail disabled.'), $p2pserver).'
'; } exit(); } /* SEARCH OPERATION END */ /* search form */ ?>