function unixref_endElement($parser, $name)
 {
     switch ($name) {
         case 'doi_record':
             $this->node['biblio_contributors'] += $this->contributors;
             array_walk_recursive($this->node, array($this, 'unixref_decode'));
             $this->node['biblio_crossref_id'] = $this->getDOI();
             $this->node['biblio_crossref_md5'] = md5(serialize($this->node));
             $this->nodes[] = $this->node;
             //biblio_save_node($node, $batch, $session_id, $save_node);
             break;
         case 'person_name':
             $this->contributors[$this->contrib_count]['auth_type'] = _biblio_get_auth_type($this->auth_category, $this->node['biblio_type']);
             $this->contributors[$this->contrib_count]['auth_category'] = $this->auth_category;
             $this->contributors[$this->contrib_count]['name'] = $this->contributors[$this->contrib_count]['lastname'];
             if (isset($this->contributors[$this->contrib_count]['firstname'])) {
                 $this->contributors[$this->contrib_count]['name'] .= ', ' . $this->contributors[$this->contrib_count]['firstname'];
             }
             $this->auth_category = '';
             $this->contrib_count++;
             break;
         case 'organization':
             $this->contributors[$this->contrib_count]['auth_type'] = _biblio_get_auth_type(5, $this->node['biblio_type']);
             $this->contributors[$this->contrib_count]['auth_category'] = 5;
             $this->contrib_count++;
             break;
         case 'pages':
             if (isset($this->node['biblio_first_page'])) {
                 $this->node['biblio_pages'] = $this->node['biblio_first_page'];
             }
             if (isset($this->node['biblio_last_page'])) {
                 $this->node['biblio_pages'] .= ' - ' . $this->node['biblio_last_page'];
             }
             break;
         case 'publication_date':
             break;
         case 'journal_issue':
         case 'journal_article':
             if (!isset($this->node['biblio_date']) || empty($this->node['biblio_date'])) {
                 $day = !empty($this->node['day']) ? $this->node['day'] : 1;
                 $month = !empty($this->node['month']) ? $this->node['month'] : 1;
                 $year = !empty($this->node['year']) ? $this->node['year'] : 0;
                 if ($year) {
                     $this->node['biblio_date'] = date("M-d-Y", mktime(0, 0, 0, $day, $month, $year));
                 }
             }
             if ((!isset($this->node['biblio_year']) || empty($this->node['biblio_year'])) && isset($this->node['year'])) {
                 $this->node['biblio_year'] = $this->node['year'];
             }
             break;
         case 'conference_paper':
         case 'content_item':
         case 'report-paper_metadata':
         case 'standard_metadata':
         case 'database_date':
         case 'component':
             if ((!isset($this->node['biblio_year']) || empty($this->node['biblio_year'])) && isset($this->node['year'])) {
                 $this->node['biblio_year'] = $this->node['year'];
                 unset($this->node['year']);
             }
             //        $this->node['biblio_doi']  = $this->node['doi'];
             break;
         case 'issn':
         case 'isbn':
             $this->attribute = '';
             break;
         case 'i':
             // HTML font style tags
         // HTML font style tags
         case 'b':
         case 'u':
         case 'sub':
         case 'sup':
             $this->unixref_characterData(NULL, '</' . $name . '> ');
             break;
         case 'doi_data':
             $this->doi_data = FALSE;
             break;
         default:
     }
 }
예제 #2
0
 function bib2node($terms = array(), $batch = FALSE, $session_id = NULL, $save = TRUE, $start = 0, $limit = 0)
 {
     //list($preamble, $strings, $entries, $undefinedStrings) = $this->returnArrays();
     $limit = $limit ? $limit : count($this->entries);
     if ($start + $limit > count($this->entries)) {
         $limit = count($this->entries) - $start;
     }
     for ($i = $start; $i < $limit; $i++) {
         $node = array();
         $entry = $this->entries[$i];
         if ($this->removeDelimit || $this->expandMacro && $this->fieldExtract) {
             foreach ($entry as $key => $value) {
                 if ($key != 'bibtexCitation' && $key != 'bibtexEntryType') {
                     $entry[$key] = trim($this->removeDelimitersAndExpand($entry[$key]));
                 }
             }
         }
         // hook_biblio_bibtex_import_pre. Allows to define new or change
         // types, e.g. split @incollection from @book and put in a custom type.
         // We don't use module_invoke_all to enable passing by reference.
         foreach (module_implements('biblio_bibtex_import_pre') as $module) {
             $function = $module . '_biblio_bibtex_import_pre';
             $function($entry, $node);
         }
         //foreach($entries as $entry){
         $node['biblio_contributors'] = array();
         $node['biblio_type'] = $this->bibtex_type_map($entry['bibtexEntryType']);
         switch ($entry['bibtexEntryType']) {
             case 'mastersthesis':
                 $node['biblio_type_of_work'] = 'masters';
                 break;
             case 'phdthesis':
                 $node['biblio_type_of_work'] = 'phd';
                 break;
         }
         if (!empty($entry['author'])) {
             // split on ' and '
             $authorArray = preg_split("/\\s(and|&)\\s/i", trim($entry['author']));
             foreach ($authorArray as $key => $author) {
                 $node['biblio_contributors'][1][] = array('name' => $author, 'auth_type' => _biblio_get_auth_type(1, $node['biblio_type']));
             }
         }
         $node['biblio_citekey'] = !empty($entry['bibtexCitation']) ? $entry['bibtexCitation'] : NULL;
         if (!empty($entry['editor'])) {
             $authorArray = preg_split("/\\s(and|&)\\s/i", trim($entry['editor']));
             foreach ($authorArray as $key => $author) {
                 $node['biblio_contributors'][2][] = array('name' => $author, 'auth_type' => _biblio_get_auth_type(2, $node['biblio_type']));
             }
         }
         $node['biblio_secondary_title'] = !empty($entry['journal']) ? $entry['journal'] : NULL;
         if (!empty($entry['booktitle'])) {
             $node['biblio_secondary_title'] = $entry['booktitle'];
         }
         if (!empty($entry['series'])) {
             $node['biblio_tertiary_title'] = $entry['series'];
         }
         $node['biblio_volume'] = !empty($entry['volume']) ? $entry['volume'] : NULL;
         $node['biblio_number'] = !empty($entry['number']) ? $entry['number'] : NULL;
         $node['biblio_year'] = !empty($entry['year']) ? $entry['year'] : NULL;
         $node['biblio_notes'] = !empty($entry['note']) ? $entry['note'] : NULL;
         $node['biblio_date'] = !empty($entry['month']) ? $entry['month'] : NULL;
         $node['biblio_pages'] = !empty($entry['pages']) ? $entry['pages'] : NULL;
         $node['biblio_publisher'] = !empty($entry['publisher']) ? $entry['publisher'] : NULL;
         if (!empty($entry['organization'])) {
             $node['biblio_publisher'] = $entry['organization'];
         }
         if (!empty($entry['school'])) {
             $node['biblio_publisher'] = $entry['school'];
         }
         if (!empty($entry['institution'])) {
             $node['biblio_publisher'] = $entry['institution'];
         }
         $node['title'] = !empty($entry['title']) ? $entry['title'] : NULL;
         $node['biblio_type_of_work'] .= !empty($entry['type']) ? $entry['type'] : NULL;
         $node['biblio_edition'] = !empty($entry['edition']) ? $entry['edition'] : NULL;
         $node['biblio_section'] = !empty($entry['chapter']) ? $entry['chapter'] : NULL;
         $node['biblio_place_published'] = !empty($entry['address']) ? $entry['address'] : NULL;
         $node['biblio_abst_e'] = !empty($entry['abstract']) ? $entry['abstract'] : NULL;
         if (!empty($entry['keywords'])) {
             if (strpos($entry['keywords'], ';')) {
                 $entry['keywords'] = str_replace(';', ',', $entry['keywords']);
             }
             $node['biblio_keywords'] = explode(',', $entry['keywords']);
         }
         $node['biblio_isbn'] = !empty($entry['isbn']) ? $entry['isbn'] : NULL;
         $node['biblio_issn'] = !empty($entry['issn']) ? $entry['issn'] : NULL;
         $node['biblio_url'] = !empty($entry['url']) ? $entry['url'] : NULL;
         $node['biblio_doi'] = !empty($entry['doi']) ? $entry['doi'] : NULL;
         if (!empty($terms)) {
             if (!isset($node['taxonomy'])) {
                 $node['taxonomy'] = array();
             }
             $node['taxonomy'] = array_merge($terms, $node['taxonomy']);
         }
         // Allow other modules to adjust the bibtex entries. Functions must
         // be named modulename_biblio_bibtex_import.
         foreach (module_implements('biblio_bibtex_import') as $module) {
             $function = $module . '_biblio_bibtex_import';
             $function($entry, $node);
         }
         $nid = biblio_save_node($node, $batch, $session_id, $save);
         if (isset($nid)) {
             $nids[] = $nid;
         }
     }
     return !empty($nids) ? $nids : NULL;
 }
예제 #3
0
파일: PARSEENTRIES.php 프로젝트: scf/scf
 function bib2node($terms = array(), $batch = FALSE, $session_id = NULL, $save = TRUE, $start = 0, $limit = 0)
 {
     //list($preamble, $strings, $entries, $undefinedStrings) = $this->returnArrays();
     $limit = $limit ? $limit : count($this->entries);
     if ($start + $limit > count($this->entries)) {
         $limit = count($this->entries) - $start;
     }
     for ($i = $start; $i < $limit; $i++) {
         $node = array();
         $entry = $this->entries[$i];
         if ($this->removeDelimit || $this->expandMacro && $this->fieldExtract) {
             foreach ($entry as $key => $value) {
                 if ($key != 'bibtexCitation' && $key != 'bibtexEntryType') {
                     $entry[$key] = trim($this->removeDelimitersAndExpand($entry[$key]));
                 }
             }
         }
         //foreach($entries as $entry){
         $node['biblio_contributors'] = array();
         $node['biblio_type'] = $this->bibtex_type_map($entry['bibtexEntryType']);
         switch ($entry['bibtexEntryType']) {
             case mastersthesis:
                 $node['biblio_type_of_work'] = 'masters';
                 break;
             case phdthesis:
                 $node['biblio_type_of_work'] = 'phd';
                 break;
         }
         if (!empty($entry['author'])) {
             // split on ' and '
             $authorArray = preg_split("/\\s(and|&)\\s/i", trim($entry['author']));
             foreach ($authorArray as $key => $author) {
                 $node['biblio_contributors'][1][] = array('name' => $author, 'auth_type' => _biblio_get_auth_type(1, $node['biblio_type']));
             }
         }
         $node['biblio_citekey'] = !empty($entry['bibtexCitation']) ? $entry['bibtexCitation'] : NULL;
         if (!empty($entry['editor'])) {
             $authorArray = preg_split("/\\s(and|&)\\s/i", trim($entry['editor']));
             foreach ($authorArray as $key => $author) {
                 $node['biblio_contributors'][2][] = array('name' => $author, 'auth_type' => _biblio_get_auth_type(2, $node['biblio_type']));
             }
         }
         $node['biblio_secondary_title'] = !empty($entry['journal']) ? $entry['journal'] : NULL;
         if (!empty($entry['booktitle'])) {
             $node['biblio_secondary_title'] = $entry['booktitle'];
         }
         if (!empty($entry['series'])) {
             $node['biblio_tertiary_title'] = $entry['series'];
         }
         $node['biblio_volume'] = !empty($entry['volume']) ? $entry['volume'] : NULL;
         $node['biblio_number'] = !empty($entry['number']) ? $entry['number'] : NULL;
         $node['biblio_year'] = !empty($entry['year']) ? $entry['year'] : NULL;
         $node['biblio_notes'] = !empty($entry['note']) ? $entry['note'] : NULL;
         $node['biblio_date'] = !empty($entry['month']) ? $entry['month'] : NULL;
         $node['biblio_pages'] = !empty($entry['pages']) ? $entry['pages'] : NULL;
         $node['biblio_publisher'] = !empty($entry['publisher']) ? $entry['publisher'] : NULL;
         if (!empty($entry['organization'])) {
             $node['biblio_publisher'] = $entry['organization'];
         }
         if (!empty($entry['school'])) {
             $node['biblio_publisher'] = $entry['school'];
         }
         if (!empty($entry['institution'])) {
             $node['biblio_publisher'] = $entry['institution'];
         }
         $node['title'] = !empty($entry['title']) ? $entry['title'] : NULL;
         $node['biblio_type_of_work'] .= !empty($entry['type']) ? $entry['type'] : NULL;
         $node['biblio_edition'] = !empty($entry['edition']) ? $entry['edition'] : NULL;
         $node['biblio_section'] = !empty($entry['chapter']) ? $entry['chapter'] : NULL;
         $node['biblio_place_published'] = !empty($entry['address']) ? $entry['address'] : NULL;
         $node['biblio_abst_e'] = !empty($entry['abstract']) ? $entry['abstract'] : NULL;
         if (!empty($entry['keywords'])) {
             if (strpos($entry['keywords'], ';')) {
                 $entry['keywords'] = str_replace(';', ',', $entry['keywords']);
             }
             $node['biblio_keywords'] = explode(',', $entry['keywords']);
         }
         $node['biblio_isbn'] = !empty($entry['isbn']) ? $entry['isbn'] : NULL;
         $node['biblio_issn'] = !empty($entry['issn']) ? $entry['issn'] : NULL;
         $node['biblio_url'] = !empty($entry['url']) ? $entry['url'] : NULL;
         $node['biblio_doi'] = !empty($entry['doi']) ? $entry['doi'] : NULL;
         if (!empty($terms)) {
             if (!isset($node['taxonomy'])) {
                 $node['taxonomy'] = array();
             }
             $node['taxonomy'] = array_merge($terms, $node['taxonomy']);
         }
         $nids[] = biblio_save_node($node, $batch, $session_id, $save);
     }
     return !empty($nids) ? $nids : NULL;
 }