function _biblio_import in Bibliography Module 5
1 call to _biblio_import()
File
- ./
biblio.module, line 2907
Code
function _biblio_import($userid = 1, $filename = null, $type = 'tagged', $terms = null) {
global $user;
$node = array();
$node_ids = "";
if (file_exists($filename)) {
if (($file_content = @file_get_contents($filename)) === false) {
return false;
}
else {
$options = variable_get('node_options_biblio', array(
'status',
));
if (module_exists('i18n') && variable_get('i18n_node_biblio', 0)) {
$node['language'] = module_invoke('i18n', 'default_language');
}
$node['type'] = "biblio";
$node['created'] = time();
$node['changed'] = time();
$node['comment'] = variable_get('comment_biblio', 0);
$node['promote'] = in_array('promote', $options);
$node['moderate'] = in_array('moderate', $options);
$node['sticky'] = in_array('sticky', $options);
$node['format'] = 0;
$node['status'] = in_array('status', $options);
$node['uid'] = $userid;
switch ($type) {
case 'tagged':
// EndNote Tagged
require_once drupal_get_path('module', 'biblio') . '/tagged_parser.inc';
$node_ids = _endnote_tagged_import($file_content, $node);
break;
case 'xml':
// EndNote 7 XML
$node_ids = _endnote_XML_import($file_content, $node, 7);
break;
case 'xml8':
// EndNote 8+ XML
$node_ids = _endnote_XML_import($file_content, $node, 8);
break;
case 'bib':
// BibTex
$node_ids = _bibtex_import($file_content, $node);
break;
case 'ris':
// RIS
require_once drupal_get_path('module', 'biblio') . '/ris_parser.inc';
$node_ids = _ris_tagged_import($file_content, $node);
break;
}
if ($terms && count($node_ids)) {
// set the vocabulary for the returned nodes
foreach ($node_ids as $node_id) {
module_invoke('taxonomy', 'node_save', $node_id, $terms);
}
}
if (count($node_ids)) {
db_query('UPDATE {node} SET uid = %d WHERE nid IN(%s)', $userid, implode(',', $node_ids));
db_query('UPDATE {node_revisions} SET uid = %d WHERE nid IN(%s)', $userid, implode(',', $node_ids));
}
return $node_ids;
}
}
else {
return false;
}
}