예제 #1
0
function convert_endnote($notice, $s, $islast, $isfirst, $param_path)
{
    global $cols;
    global $ty;
    global $intitules;
    global $base_path, $origine;
    global $tab_functions;
    global $lot;
    //global $charset;
    if (!$tab_functions) {
        $tab_functions = new marc_list('function');
    }
    $fields = explode("\n", $notice);
    $error = "";
    if ($fields) {
        $data = "<notice>\n";
    }
    $lignes = organize_line($fields);
    foreach ($lignes as $champ => $value) {
        switch ($champ) {
            case '%T':
                //Titre principal
                $titre = $value;
                break;
            case '%B':
                //Autre info sur titre
                $titre_other = $value;
                break;
            case '%Q':
                //Autre info sur titre
                $titre_parallel = $value;
                break;
            case '%C':
                //Editeur
                $editeur_ville = $value;
                break;
            case '%Y':
            case '%A':
                //Autres auteurs
                $autres_auteurs = $value;
                break;
            case '%E':
                //Auteur secondaire
                $auteur_secondaire = $value;
                break;
            case '%@':
                //ISBN/ISSN
                $code = $value;
                if (isISBN($code)) {
                    $infos_isbn = $code;
                } elseif (isISSN($code)) {
                    $infos_issn = $code;
                } else {
                    $error = "wrong ISBN/ISSN \n";
                }
                break;
            case '%U':
                //URL
                $url = $value;
                break;
            case '%D':
                //Date de publication (YYYY/MM/DD)
                $dates = explode("/", $value);
                if ($dates[0]) {
                    $year = $dates[0];
                }
                if ($dates[1]) {
                    $month = $dates[1];
                }
                if ($dates[2]) {
                    $day = $dates[2];
                }
                $publication_date = $year;
                if ($year && $month && $day) {
                    $date_sql = str_replace("/", "-", $value);
                    $mention_date = $value;
                } else {
                    if ($year && $month && !$day) {
                        $date_sql = $year . "-" . $month . "-01";
                        $mention_date = $year . "/" . $month;
                    } else {
                        if ($year && !$month && !$day) {
                            $date_sql = $year . "-01-01";
                            $mention_date = $year;
                        }
                    }
                }
                break;
            case '%0':
                /*switch($value){
                			case 'Book':
                			case 'Edited Book':
                			case 'Electronic Book':
                				$subtype='Book';
                			break;
                			case 'Computer Program':
                				$subtype='Computing Program';
                			break;
                			case 'Conference Proceedings':
                			case 'Conference Paper':	
                				$subtype='Conference Proceedings';
                			break;
                			case 'Unpublished Work':
                				$subtype='Preprint';
                			break;
                			case 'Online Multimedia':
                				$subtype='Interactive Multimedia';
                			break;
                			case 'Journal Article':
                			case 'Magazine Article':	
                			case 'Electronic Article':
                			case 'Newspaper Article':
                				$subtype='Article';
                			break;
                			case 'Map':
                				$subtype='Map';
                			break;
                			case 'Report':
                				$subtype='Report';
                			break;
                			case 'Online Database':
                				$subtype='Database';
                			break;
                			case 'Thesis':
                				$subtype='Thesis';
                			break;
                			default :
                				$subtype='Article';
                			break;
                		}	*/
                //Document type
                $subtype = $value;
                break;
            case '%Z':
                //Notes
                $notes = $value;
                break;
            case '%P':
                //End page
                $page = $value;
                break;
            case '%K':
                //Mots cles
                $keywords = $value;
                break;
            case '%+':
                //Collectivite
                $collectivite = $value;
                break;
            case '%N':
                //Numéro de bulletin
                $bull_num = $value;
                break;
            case '%V':
                //Volume
                $bull_vol = $value;
                break;
            case '%X':
                //Résumé
                $resume = $value;
                break;
            case '%J':
                //Titre du pério
                $perio_title = $value;
                break;
            case '%G':
                $langue = $value;
                break;
            case '%M':
                $id_endnote = $value;
                break;
            case '%I':
                $publisher = $value;
                break;
            default:
                $data .= '';
                break;
        }
    }
    //Construction du fichier
    $data .= "<rs>n</rs>\n\t\t  <dt>a</dt>\n\t\t  <bl>a</bl>\n\t\t  <hl>2</hl>\n\t\t  <el>1</el>\n\t\t  <ru>i</ru>\n";
    $data .= "<f c='001' ind='  '>\n";
    $data .= htmlspecialchars($id_endnote, ENT_QUOTES, $charset);
    $data .= "</f>\n";
    if ($infos_isbn) {
        $data .= "<f c='010' ind='  '>\n";
        $data .= "\t<s c='a'>" . htmlspecialchars($infos_isbn, ENT_QUOTES, $charset) . "</s>\n";
        $data .= "</f>\n";
    }
    if ($infos_issn) {
        $data .= "<f c='011' ind='  '>\n";
        $data .= "\t<s c='a'>" . htmlspecialchars($infos_issn, ENT_QUOTES, $charset) . "</s>\n";
        $data .= "</f>\n";
    }
    if ($langue) {
        $data .= "<f c='101' ind='  '>\n";
        $data .= "\t<s c='a'>" . htmlspecialchars($langue, ENT_QUOTES, $charset) . "</s>\n";
        $data .= "</f>\n";
    }
    if ($titre) {
        $data .= "<f c='200' ind='  '>\n";
        $data .= "\t<s c='a'>" . htmlspecialchars($titre, ENT_QUOTES, $charset) . "</s>";
        if ($titre_other) {
            $data .= "\t<s c='e'>" . htmlspecialchars($titre_other, ENT_QUOTES, $charset) . "</s>";
        }
        if ($titre_parallel) {
            $data .= "\t<s c='d'>" . htmlspecialchars($titre_parallel, ENT_QUOTES, $charset) . "</s>";
        }
        $data .= "</f>\n";
    }
    if ($publisher) {
        $data .= "<f c='210' ind='  '>\n";
        $data .= "\t<s c='c'>" . htmlspecialchars($publisher, ENT_QUOTES, $charset) . "</s>\n";
        $data .= "</f>\n";
    }
    if ($page) {
        $data .= "<f c='215' ind='  '>\n";
        if ($page) {
            $data .= "\t<s c='a'>" . htmlspecialchars($page, ENT_QUOTES, $charset) . "</s>\n";
        }
        $data .= "</f>\n";
    }
    if ($notes) {
        $note = explode('###', $notes);
        $doi = "";
        $pubmedid = "";
        for ($i = 0; $i < count($note); $i++) {
            if (strpos($note[$i], "doi:") !== false) {
                $doi = $note[$i];
            } else {
                if (strpos($note[$i], "PubMed ID:") !== false) {
                    $pubmedid = $note[$i];
                } else {
                    if (strlen($note[$i]) > 9000) {
                        $word = wordwrap($note[$i], 9000, "####");
                        $words = explode("####", $word);
                        for ($j = 0; $j < count($words); $j++) {
                            $data .= "<f c='300' ind='  '>\n";
                            $data .= "\t<s c='a'>" . htmlspecialchars($words[$j], ENT_QUOTES, $charset) . "</s>\n";
                            $data .= "</f>\n";
                        }
                    } else {
                        $data .= "<f c='300' ind='  '>\n";
                        $data .= "\t<s c='a'>" . htmlspecialchars($note[$i], ENT_QUOTES, $charset) . "</s>\n";
                        $data .= "</f>\n";
                    }
                }
            }
        }
    }
    if ($resume) {
        $data .= "<f c='330' ind='  '>\n";
        $data .= "\t<s c='a'>" . htmlspecialchars($resume, ENT_QUOTES, $charset) . "</s>\n";
        $data .= "</f>\n";
    }
    if ($perio_title) {
        $data .= "<f c='461' ind='  '>\n";
        $data .= "\t<s c='t'>" . htmlspecialchars($perio_title, ENT_QUOTES, $charset) . "</s>\n";
        if ($infos_issn) {
            $data .= "\t<s c='x'>" . htmlspecialchars($infos_issn, ENT_QUOTES, $charset) . "</s>\n";
        }
        $data .= "\t<s c='9'>lnk:perio</s>\n";
        $data .= "</f>\n";
    }
    if ($bull_num || $bull_vol) {
        $data .= "<f c='463' ind='  '>\n";
        if ($bull_num && $bull_vol) {
            $data .= "\t<s c='v'>" . "vol. " . htmlspecialchars($bull_vol, ENT_QUOTES, $charset) . ", no. " . htmlspecialchars($bull_num, ENT_QUOTES, $charset) . "</s>\n";
        } else {
            if ($bull_num && !$bull_vol) {
                $data .= "\t<s c='v'>no. " . htmlspecialchars($bull_num, ENT_QUOTES, $charset) . "</s>\n";
            } else {
                if (!$bull_num && $bull_vol) {
                    $data .= "\t<s c='v'>vol. " . htmlspecialchars($bull_vol, ENT_QUOTES, $charset) . "</s>\n";
                }
            }
        }
        if ($date_sql) {
            $data .= "\t<s c='d'>" . htmlspecialchars($date_sql, ENT_QUOTES, $charset) . "</s>\n";
        }
        if ($mention_date) {
            $data .= "\t<s c='e'>" . htmlspecialchars($mention_date, ENT_QUOTES, $charset) . "</s>\n";
        }
        $data .= "\t<s c='9'>lnk:bull</s>\n";
        $data .= "</f>\n";
    }
    if ($keywords) {
        $mots = explode('###', $keywords);
        for ($i = 0; $i < count($mots); $i++) {
            $data .= "<f c='610' ind='0 '>\n";
            $data .= "\t<s c='a'>" . htmlspecialchars($mots[$i], ENT_QUOTES, $charset) . "</s>\n";
            $data .= "</f>\n";
        }
    }
    if ($collectivite) {
        $collectivites = explode("###", $collectivite);
        if (count($collectivites) == 1) {
            $coll_elt = explode(", ", $collectivites[0], 3);
            $coll_infos = explode(", ", $coll_elt[2], 2);
            $coll_nom = $coll_infos[0];
            $coll_pays = trim(substr($coll_infos[1], strrpos($coll_infos[1], ", ") + 1));
            $coll_lieu = trim(substr($coll_infos[1], 0, -(strlen($coll_pays) + 2)));
            $data .= "<f c='710' ind='0 '>\n";
            $data .= "\t<s c='a'>" . htmlspecialchars($coll_nom, ENT_QUOTES, $charset) . "</s>\n";
            $data .= "\t<s c='e'>" . htmlspecialchars($coll_lieu, ENT_QUOTES, $charset) . "</s>\n";
            $data .= "\t<s c='m'>" . htmlspecialchars($coll_pays, ENT_QUOTES, $charset) . "</s>\n";
            $data .= "</f>\n";
        } else {
            for ($i = 0; $i < count($collectivites); $i++) {
                $coll_elt = explode(", ", $collectivites[$i], 3);
                $coll_infos = explode(", ", $coll_elt[2], 2);
                $coll_nom = $coll_infos[0];
                $coll_pays = trim(substr($coll_infos[1], strrpos($coll_infos[1], ", ") + 1));
                $coll_lieu = trim(substr($coll_infos[1], 0, -(strlen($coll_pays) + 2)));
                $data .= "<f c='710' ind='0 '>\n";
                $data .= "\t<s c='a'>" . htmlspecialchars($coll_nom, ENT_QUOTES, $charset) . "</s>\n";
                $data .= "\t<s c='e'>" . htmlspecialchars($coll_lieu, ENT_QUOTES, $charset) . "</s>\n";
                $data .= "\t<s c='m'>" . htmlspecialchars($coll_pays, ENT_QUOTES, $charset) . "</s>\n";
                $data .= "</f>\n";
            }
        }
    }
    if ($autres_auteurs) {
        $others = explode("###", $autres_auteurs);
        for ($i = 0; $i < count($others); $i++) {
            $aut = explode(", ", $others[$i]);
            $data .= "<f c='701' ind='  '>\n";
            $data .= "\t<s c='a'>" . htmlspecialchars($aut[0], ENT_QUOTES, $charset) . "</s>\n";
            $data .= "\t<s c='b'>" . htmlspecialchars($aut[1], ENT_QUOTES, $charset) . "</s>\n";
            if ($aut[2]) {
                $data .= "\t<s c='c'>" . htmlspecialchars($aut[2], ENT_QUOTES, $charset) . "</s>\n";
            }
            $data .= "</f>\n";
        }
    }
    if ($auteur_secondaire) {
        $secs = explode("###", $auteur_secondaire);
        for ($i = 0; $i < count($secs); $i++) {
            $aut = explode(", ", $secs);
            $data .= "<f c='702' ind='  '>\n";
            $data .= "\t<s c='a'>" . htmlspecialchars($aut[0], ENT_QUOTES, $charset) . "</s>\n";
            $data .= "\t<s c='b'>" . htmlspecialchars($aut[1], ENT_QUOTES, $charset) . "</s>\n";
            if ($aut[2]) {
                $data .= "\t<s c='c'>" . htmlspecialchars($aut[2], ENT_QUOTES, $charset) . "</s>\n";
            }
            $data .= "</f>\n";
        }
    }
    if ($url) {
        $data .= "<f c='856' ind='  '>\n";
        $data .= "\t<s c='u'>" . htmlspecialchars($url, ENT_QUOTES, $charset) . "</s>";
        $data .= "</f>\n";
    }
    if ($subtype) {
        $data .= "<f c='900' ind='  '>\n";
        $data .= "\t<s c='a'>" . htmlspecialchars($subtype, ENT_QUOTES, $charset) . "</s>\n";
        $data .= "\t<s c='l'>Sub-Type</s>\n";
        $data .= "\t<s c='n'>subtype</s>\n";
        $data .= "</f>\n";
    }
    $data .= "</notice>\n";
    if (!$error) {
        $r['VALID'] = true;
    } else {
        $r['VALID'] = false;
    }
    $r['ERROR'] = $error;
    $r['DATA'] = $data;
    return $r;
}
예제 #2
0
function convert_ris($notice, $s, $islast, $isfirst, $param_path)
{
    global $cols;
    global $ty;
    global $intitules;
    global $base_path, $origine;
    global $tab_functions;
    global $lot;
    global $charset;
    if (mb_detect_encoding($notice) == 'UTF-8' && $charset == "iso-8859-1") {
        $notice = utf8_decode($notice);
    }
    if (!$tab_functions) {
        $tab_functions = new marc_list('function');
    }
    $fields = explode("\n", $notice);
    $error = "";
    if ($fields) {
        $data = "<notice>\n";
    }
    $lignes = organize_line($fields);
    foreach ($lignes as $champ => $value) {
        switch ($champ) {
            case 'CT':
            case 'TI':
            case 'T1':
                //Titre principal
                $titre = $value;
                break;
            case 'T2':
                //Autre info sur titre
                $titre_other = $value;
                break;
            case 'PB':
                //Editeur
                $editeur_nom = $value;
                break;
            case 'CY':
                //Editeur
                $editeur_ville = $value;
                break;
            case 'AU':
                //Autres auteurs
                $autres_auteurs = $value;
                break;
            case 'A1':
                //Auteur principal
                $auteur_principal = $value;
                break;
            case 'A2':
                //Auteur secondaire
                $auteur_secondaire = $value;
                break;
            case 'SN':
                //ISBN/ISSN
                $code = trim($value);
                $pos = strpos($code, "(");
                if ($pos !== false) {
                    $code = substr($code, 0, $pos);
                }
                if (isISBN($code)) {
                    $infos_isbn = $code;
                } elseif (isISSN($code)) {
                    $infos_issn = $code;
                } else {
                    $error = "wrong ISBN/ISSN \n";
                }
                break;
            case 'UR':
                //URL
                $url = $value;
                break;
            case 'PY':
                //Date de publication (YYYY/MM/DD)
                $dates = explode("/", $value);
                if ($dates[0]) {
                    $year = $dates[0];
                }
                if ($dates[1]) {
                    $month = $dates[1];
                }
                if ($dates[2]) {
                    $day = $dates[2];
                }
                $publication_date = $year;
                if ($year && $month && $day) {
                    $date_sql = str_replace("/", "-", $value);
                    $mention_date = $value;
                } else {
                    if ($year && $month && !$day) {
                        $date_sql = $year . "-" . $month . "-01";
                        $mention_date = $year . "/" . $month;
                    } else {
                        if ($year && !$month && !$day) {
                            $date_sql = $year . "-01-01";
                            $mention_date = $year;
                        }
                    }
                }
                break;
            case 'TY':
                //Document type
                switch ($value) {
                    case 'ABST':
                        $subtype = 'Abstract';
                        break;
                    case 'BOOK':
                        $subtype = 'Book';
                        break;
                    case 'CHAP':
                        $subtype = 'Chapter';
                        break;
                    case 'COMP':
                        $subtype = 'Computing Program';
                        break;
                    case 'CONF':
                        $subtype = 'Conference Proceedings';
                        break;
                    case 'INPR':
                        $subtype = 'Preprint';
                        break;
                    case 'NEWS':
                    case 'JFULL':
                        $subtype = 'Journal';
                        break;
                    case 'MGZN':
                    case 'JOUR':
                        $subtype = 'Article';
                        break;
                    case 'MAP':
                        $subtype = 'Map';
                        break;
                    case 'UNPB':
                    case 'RPRT':
                        $subtype = 'Report';
                        break;
                    case 'SLIDE':
                        $subtype = 'Presentation';
                        break;
                    case 'THES':
                        $subtype = 'Thesis';
                        break;
                    default:
                        $subtype = 'Article';
                        break;
                }
                break;
            case 'N1':
                //Notes
                $notes = $value;
                break;
            case 'SP':
                //Start page
                $start_page = $value;
                break;
            case 'EP':
                //End page
                $end_page = $value;
                break;
            case 'KW':
                //Mots cles
                $keywords = $value;
                break;
            case 'AD':
                //Collectivite
                $collectivite = $value;
                break;
            case 'IS':
                //Numéro de bulletin
                $bull_num = $value;
                break;
            case 'VL':
                //Volume
                $bull_vol = $value;
                break;
            case 'AB':
                //Résumé
                $resume = $value;
                break;
            case 'JF':
                //Titre du pério
                $perio_title = $value;
                break;
            default:
                $data .= '';
                break;
        }
    }
    //Construction du fichier
    $data .= "<rs>n</rs>\n\t\t  <dt>a</dt>\n\t\t  <bl>a</bl>\n\t\t  <hl>2</hl>\n\t\t  <el>1</el>\n\t\t  <ru>i</ru>\n";
    //Soyons sûr que le microtime ne sera plus le même..
    usleep(1);
    $data .= "<f c='001' ind='  '>\n";
    $data .= htmlspecialchars(microtime(), ENT_QUOTES, $charset);
    $data .= "</f>\n";
    if ($titre) {
        $data .= "<f c='200' ind='  '>\n";
        $data .= "\t<s c='a'>" . htmlspecialchars($titre, ENT_QUOTES, $charset) . "</s>";
        if ($titre_other) {
            $data .= "\t<s c='e'>" . htmlspecialchars($titre_other, ENT_QUOTES, $charset) . "</s>";
        }
        $data .= "</f>\n";
    }
    if ($editeur_nom || $publication_date || $editeur_ville) {
        $data .= "<f c='210' ind='  '>\n";
        if ($editeur_ville) {
            $data .= "\t<s c='a'>" . htmlspecialchars($editeur_ville, ENT_QUOTES, $charset) . "</s>\n";
        }
        if ($editeur_nom) {
            $data .= "\t<s c='c'>" . htmlspecialchars($editeur_nom, ENT_QUOTES, $charset) . "</s>\n";
        }
        if ($publication_date) {
            $data .= "\t<s c='d'>" . htmlspecialchars($publication_date, ENT_QUOTES, $charset) . "</s>";
        }
        $data .= "</f>\n";
    }
    if ($start_page || $end_page) {
        $data .= "<f c='215' ind='  '>\n";
        if ($start_page && $end_page) {
            $data .= "\t<s c='a'>" . htmlspecialchars($start_page . "-" . $end_page, ENT_QUOTES, $charset) . "</s>\n";
        }
        if (!$start_page && $end_page) {
            $data .= "\t<s c='a'>" . htmlspecialchars($end_page, ENT_QUOTES, $charset) . "</s>\n";
        }
        if ($start_page && !$end_page) {
            $data .= "\t<s c='a'>" . htmlspecialchars($start_page, ENT_QUOTES, $charset) . "</s>\n";
        }
        $data .= "</f>\n";
    }
    if ($notes) {
        $note = explode('###', $notes);
        $doi = "";
        $pubmedid = "";
        for ($i = 0; $i < count($note); $i++) {
            if (strpos($note[$i], "doi:") !== false) {
                $doi = $note[$i];
            } else {
                if (strpos($note[$i], "PubMed ID:") !== false) {
                    $pubmedid = $note[$i];
                } else {
                    if (strlen($note[$i]) > 9000) {
                        $word = wordwrap($note[$i], 9000, "####");
                        $words = explode("####", $word);
                        for ($j = 0; $j < count($words); $j++) {
                            $data .= "<f c='300' ind='  '>\n";
                            $data .= "\t<s c='a'>" . htmlspecialchars($words[$j], ENT_QUOTES, $charset) . "</s>\n";
                            $data .= "</f>\n";
                        }
                    } else {
                        $data .= "<f c='300' ind='  '>\n";
                        $data .= "\t<s c='a'>" . htmlspecialchars($note[$i], ENT_QUOTES, $charset) . "</s>\n";
                        $data .= "</f>\n";
                    }
                }
            }
        }
    }
    if ($resume) {
        $data .= "<f c='330' ind='  '>\n";
        $data .= "\t<s c='a'>" . htmlspecialchars($resume, ENT_QUOTES, $charset) . "</s>\n";
        $data .= "</f>\n";
    }
    if ($perio_title) {
        $data .= "<f c='461' ind='  '>\n";
        $data .= "\t<s c='t'>" . htmlspecialchars($perio_title, ENT_QUOTES, $charset) . "</s>\n";
        if ($infos_issn) {
            $data .= "\t<s c='x'>" . htmlspecialchars($infos_issn, ENT_QUOTES, $charset) . "</s>\n";
        }
        $data .= "\t<s c='9'>lnk:perio</s>\n";
        $data .= "</f>\n";
    }
    if ($bull_num || $bull_vol) {
        $data .= "<f c='463' ind='  '>\n";
        if ($bull_num && $bull_vol) {
            $data .= "\t<s c='v'>" . "vol. " . htmlspecialchars($bull_vol, ENT_QUOTES, $charset) . ", no. " . htmlspecialchars($bull_num, ENT_QUOTES, $charset) . "</s>\n";
        } else {
            if ($bull_num && !$bull_vol) {
                $data .= "\t<s c='v'>no. " . htmlspecialchars($bull_num, ENT_QUOTES, $charset) . "</s>\n";
            } else {
                if (!$bull_num && $bull_vol) {
                    $data .= "\t<s c='v'>vol. " . htmlspecialchars($bull_vol, ENT_QUOTES, $charset) . "</s>\n";
                }
            }
        }
        if ($date_sql) {
            $data .= "\t<s c='d'>" . htmlspecialchars($date_sql, ENT_QUOTES, $charset) . "</s>\n";
        }
        if ($mention_date) {
            $data .= "\t<s c='e'>" . htmlspecialchars($mention_date, ENT_QUOTES, $charset) . "</s>\n";
        }
        $data .= "\t<s c='9'>lnk:bull</s>\n";
        $data .= "</f>\n";
    }
    if ($keywords) {
        $mots = explode('###', $keywords);
        for ($i = 0; $i < count($mots); $i++) {
            $data .= "<f c='610' ind='0 '>\n";
            $data .= "\t<s c='a'>" . htmlspecialchars($mots[$i], ENT_QUOTES, $charset) . "</s>\n";
            $data .= "</f>\n";
        }
    }
    if ($auteur_principal) {
        $aut = explode(", ", $auteur_principal);
        $data .= "<f c='700' ind='  '>\n";
        $data .= "\t<s c='a'>" . htmlspecialchars($aut[0], ENT_QUOTES, $charset) . "</s>\n";
        $data .= "\t<s c='b'>" . htmlspecialchars($aut[1], ENT_QUOTES, $charset) . "</s>\n";
        if ($aut[2]) {
            $data .= "\t<s c='c'>" . htmlspecialchars($aut[2], ENT_QUOTES, $charset) . "</s>\n";
        }
        $data .= "</f>\n";
    }
    if ($collectivite) {
        $collectivites = explode("###", $collectivite);
        if (count($collectivites) == 1 && !$auteur_principal) {
            $coll_elt = explode(", ", $collectivites[0], 2);
            $coll_nom = $coll_elt[0];
            $coll_pays = trim(substr($coll_elt[1], strrpos($coll_elt[1], ", ") + 1));
            $coll_lieu = trim(substr($coll_elt[1], 0, -(strlen($coll_pays) + 2)));
            $data .= "<f c='710' ind='0 '>\n";
            $data .= "\t<s c='a'>" . htmlspecialchars($coll_nom, ENT_QUOTES, $charset) . "</s>\n";
            $data .= "\t<s c='e'>" . htmlspecialchars($coll_lieu, ENT_QUOTES, $charset) . "</s>\n";
            $data .= "\t<s c='m'>" . htmlspecialchars($coll_pays, ENT_QUOTES, $charset) . "</s>\n";
            $data .= "</f>\n";
        } else {
            for ($i = 0; $i < count($collectivites); $i++) {
                $coll_elt = explode(", ", $collectivites[$i], 2);
                $coll_nom = $coll_elt[0];
                $coll_pays = trim(substr($coll_elt[1], strrpos($coll_elt[1], ", ") + 1));
                $coll_lieu = trim(substr($coll_elt[1], 0, -(strlen($coll_pays) + 2)));
                $data .= "<f c='711' ind='0 '>\n";
                $data .= "\t<s c='a'>" . htmlspecialchars($coll_nom, ENT_QUOTES, $charset) . "</s>\n";
                $data .= "\t<s c='e'>" . htmlspecialchars($coll_lieu, ENT_QUOTES, $charset) . "</s>\n";
                $data .= "\t<s c='m'>" . htmlspecialchars($coll_pays, ENT_QUOTES, $charset) . "</s>\n";
                $data .= "</f>\n";
            }
        }
    }
    if ($autres_auteurs) {
        $others = explode("###", $autres_auteurs);
        for ($i = 0; $i < count($others); $i++) {
            $aut = explode(", ", $others[$i]);
            $data .= "<f c='701' ind='  '>\n";
            $data .= "\t<s c='a'>" . htmlspecialchars($aut[0], ENT_QUOTES, $charset) . "</s>\n";
            $data .= "\t<s c='b'>" . htmlspecialchars($aut[1], ENT_QUOTES, $charset) . "</s>\n";
            if ($aut[2]) {
                $data .= "\t<s c='c'>" . htmlspecialchars($aut[2], ENT_QUOTES, $charset) . "</s>\n";
            }
            $data .= "</f>\n";
        }
    }
    if ($auteur_secondaire) {
        $secs = explode("###", $auteur_secondaire);
        for ($i = 0; $i < count($secs); $i++) {
            $aut = explode(", ", $secs);
            $data .= "<f c='702' ind='  '>\n";
            $data .= "\t<s c='a'>" . htmlspecialchars($aut[0], ENT_QUOTES, $charset) . "</s>\n";
            $data .= "\t<s c='b'>" . htmlspecialchars($aut[1], ENT_QUOTES, $charset) . "</s>\n";
            if ($aut[2]) {
                $data .= "\t<s c='c'>" . htmlspecialchars($aut[2], ENT_QUOTES, $charset) . "</s>\n";
            }
            $data .= "</f>\n";
        }
    }
    if ($url) {
        $data .= "<f c='856' ind='  '>\n";
        $data .= "\t<s c='u'>" . htmlspecialchars($url, ENT_QUOTES, $charset) . "</s>";
        $data .= "</f>\n";
    }
    if ($subtype) {
        $data .= "<f c='900' ind='  '>\n";
        $data .= "\t<s c='a'>" . htmlspecialchars($subtype, ENT_QUOTES, $charset) . "</s>\n";
        $data .= "\t<s c='l'>Sub-Type</s>\n";
        $data .= "\t<s c='n'>subtype</s>\n";
        $data .= "</f>\n";
    }
    if ($doi) {
        $doi = trim(str_replace("doi:", "", $doi));
        if ($doi) {
            $data .= "<f c='900' ind='  '>\n";
            $data .= "\t<s c='a'>" . htmlspecialchars($doi, ENT_QUOTES, $charset) . "</s>\n";
            $data .= "\t<s c='l'>DOI id</s>\n";
            $data .= "\t<s c='n'>pmi_doi_identifier</s>\n";
            $data .= "</f>\n";
        }
    }
    if ($pubmedid) {
        $pubmedid = trim(str_replace("PubMed ID:", "", $pubmedid));
        if ($pubmedid) {
            $data .= "<f c='900' ind='  '>\n";
            $data .= "\t<s c='a'>" . htmlspecialchars($pubmedid, ENT_QUOTES, $charset) . "</s>\n";
            $data .= "\t<s c='l'>Numéro PUBMED</s>\n";
            $data .= "\t<s c='n'>pmi_xref_dbase_id</s>\n";
            $data .= "</f>\n";
        }
    }
    $data .= "</notice>\n";
    if (!$error) {
        $r['VALID'] = true;
    } else {
        $r['VALID'] = false;
    }
    $r['ERROR'] = $error;
    $r['DATA'] = $data;
    return $r;
}
예제 #3
0
function convert_medline($notice, $s, $islast, $isfirst, $param_path)
{
    global $cols;
    global $ty;
    global $intitules;
    global $base_path, $origine;
    global $tab_functions;
    global $lot;
    global $charset;
    if (!$tab_functions) {
        $tab_functions = new marc_list('function');
    }
    $fields = explode("\n", $notice);
    $error = "";
    if ($fields) {
        $data = "<notice>\n";
    }
    $lignes = organize_line($fields);
    foreach ($lignes as $champ => $value) {
        switch ($champ) {
            case 'TI':
                //Titre principal
                $titre = $value;
                break;
            case 'PL':
                //Editeur
                $editeur = $value;
                break;
            case 'AU':
                //Auteur principal
                $auteur = explode(", ", $value);
                break;
            case 'IS':
                //ISBN/ISSN
                $code = $value;
                $pos = strpos($code, "(");
                $endcode = substr($code, $pos);
                $code = trim(substr($code, 0, $pos));
                if (isISBN($code)) {
                    $infos_isbn = $code . " " . $endcode;
                } elseif (isISSN($code)) {
                    $infos_issn = $code . " " . $endcode;
                } else {
                    $error = "wrong ISBN/ISSN \n";
                }
                break;
            case 'DP':
                //Date de publication
                $date = $value;
                if ($date) {
                    $date_elt = explode(' ', $date);
                    if ($date_elt[0]) {
                        $year = $date_elt[0];
                    }
                    if ($date_elt[2]) {
                        $day = $date_elt[2];
                    }
                    if ($date_elt[1]) {
                        $mois = $date_elt[1];
                        switch ($mois) {
                            case 'Jan':
                                $month = "01";
                                break;
                            case 'Feb':
                                $month = "02";
                                break;
                            case 'Mar':
                                $month = "03";
                                break;
                            case 'Apr':
                                $month = "04";
                                break;
                            case 'May':
                                $month = "05";
                                break;
                            case 'Jun':
                                $month = "06";
                                break;
                            case 'Jul':
                                $month = "07";
                                break;
                            case 'Aug':
                                $month = "08";
                                break;
                            case 'Sep':
                                $month = "09";
                                break;
                            case 'Oct':
                                $month = "10";
                                break;
                            case 'Nov':
                                $month = "11";
                                break;
                            case 'Dec':
                                $month = "12";
                                break;
                        }
                    }
                    if ($year && $month && $day) {
                        $date_sql = $year . "-" . $month . "-" . $day;
                    } else {
                        if ($year && $month) {
                            $date_sql = $year . "-" . $month . "-01";
                        } else {
                            if ($year) {
                                $date_sql = $year . "-01-01";
                            }
                        }
                    }
                }
                break;
            case 'IP':
                //Numéro de bulletin
                $bull_num = $value;
                break;
            case 'VI':
                //Volume
                $bull_vol = $value;
                break;
            case 'AB':
                //Résumé
                $resume = $value;
                break;
            case 'JT':
                //Titre du pério
                $perio_title = $value;
                break;
            case 'LA':
                //Langue
                $langue = $value;
                break;
            case 'TT':
                //Titre parallele
                $titre_parallele = $value;
                break;
            case 'PG':
                //Pagination
                $pagination = $value;
                break;
            case 'PMID':
                //Pubmed ID
                $pubmed_id = $value;
                break;
            case 'PT':
                //Document Type
                $doc_type = $value;
                break;
            case 'AID':
                //DOI
                $ids = explode(",", $value);
                if (is_array($ids)) {
                    for ($i = 0; $i < count($ids); $i++) {
                        if (strpos($ids[$i], "[doi]") !== false) {
                            $doi = trim(substr($ids[$i], 0, strpos($ids[$i], "[doi]")));
                        }
                    }
                }
                break;
            case 'AD':
                $collectivite = $value;
                break;
            default:
                $data .= '';
                break;
        }
    }
    //Construction du fichier
    $data .= "<rs>n</rs>\n\t\t  <dt>a</dt>\n\t\t  <bl>a</bl>\n\t\t  <hl>2</hl>\n\t\t  <el>1</el>\n\t\t  <ru>i</ru>\n";
    if ($pubmed_id) {
        $data .= "<f c='001' ind='  '>\n";
        $data .= htmlspecialchars($pubmed_id, ENT_QUOTES, $charset);
        $data .= "</f>\n";
    }
    if ($infos_isbn || $pubmed_id) {
        $data .= " <f c='010' ind='  '>\n";
        $data .= "\t<s c='a'>" . htmlspecialchars($pubmed_id ? $pubmed_id : $infos_isbn, ENT_QUOTES, $charset) . "</s>";
        $data .= "</f>\n";
    }
    if ($langue) {
        $data .= "<f c='101' ind='  '>\n";
        $data .= "\t<s c='a'>" . htmlspecialchars($langue, ENT_QUOTES, $charset) . "</s>\n";
        $data .= "</f>\n";
    }
    if ($titre) {
        $data .= "<f c='200' ind='  '>\n";
        $data .= "\t<s c='a'>" . htmlspecialchars($titre, ENT_QUOTES, $charset) . "</s>\n";
        if ($titre_parallele) {
            $data .= "\t<s c='d'>" . htmlspecialchars($titre_parallele, ENT_QUOTES, $charset) . "</s>\n";
        }
        $data .= "</f>\n";
    }
    if ($editeur) {
        $data .= "<f c='210' ind='  '>\n";
        if ($editeur) {
            $data .= "\t<s c='c'>" . htmlspecialchars($editeur, ENT_QUOTES, $charset) . "</s>\n";
        }
        $data .= "</f>\n";
    }
    if ($pagination) {
        $data .= "<f c='215' ind='  '>\n";
        $data .= "\t<s c='a'>" . htmlspecialchars($pagination, ENT_QUOTES, $charset) . "</s>\n";
        $data .= "</f>\n";
    }
    if ($resume) {
        $data .= "<f c='330' ind='  '>\n";
        $data .= "\t<s c='a'>" . htmlspecialchars($resume, ENT_QUOTES, $charset) . "</s>\n";
        $data .= "</f>\n";
    }
    if ($perio_title) {
        $data .= "<f c='461' ind='  '>\n";
        $data .= "\t<s c='t'>" . htmlspecialchars($perio_title, ENT_QUOTES, $charset) . "</s>\n";
        if ($infos_issn) {
            $data .= "\t<s c='x'>" . htmlspecialchars($infos_issn, ENT_QUOTES, $charset) . "</s>\n";
        }
        $data .= "\t<s c='9'>lnk:perio</s>\n";
        $data .= "</f>\n";
    }
    if ($bull_num || $bull_vol || $date || $date_sql) {
        $data .= "<f c='463' ind='  '>\n";
        if ($bull_num && $bull_vol) {
            $data .= "\t<s c='v'>" . "vol. " . htmlspecialchars($bull_vol, ENT_QUOTES, $charset) . ", no. " . htmlspecialchars($bull_num, ENT_QUOTES, $charset) . "</s>\n";
        } else {
            if ($bull_num && !$bull_vol) {
                $data .= "\t<s c='v'>no. " . htmlspecialchars($bull_num, ENT_QUOTES, $charset) . "</s>\n";
            } else {
                if (!$bull_num && $bull_vol) {
                    $data .= "\t<s c='v'>vol. " . htmlspecialchars($bull_vol, ENT_QUOTES, $charset) . "</s>\n";
                }
            }
        }
        if ($date) {
            $data .= "\t<s c='e'>" . htmlspecialchars($date, ENT_QUOTES, $charset) . "</s>\n";
        }
        if ($date_sql) {
            $data .= "\t<s c='d'>" . htmlspecialchars($date_sql, ENT_QUOTES, $charset) . "</s>\n";
        }
        $data .= "\t<s c='9'>lnk:bull</s>\n";
        $data .= "</f>\n";
    }
    if ($collectivite) {
        if ($auteur) {
            for ($i = 0; $i < count($auteur); $i++) {
                $data .= "<f c='701' ind='  '>\n";
                $data .= "\t<s c='a'>" . htmlspecialchars($auteur[$i], ENT_QUOTES, $charset) . "</s>\n";
                $data .= "</f>\n";
            }
        }
        $coll = explode(",", $collectivite, 2);
        $data .= "<f c='710' ind='0 '>\n";
        $data .= "\t<s c='a'>" . htmlspecialchars($coll[0], ENT_QUOTES, $charset) . "</s>\n";
        $data .= "\t<s c='e'>" . htmlspecialchars($coll[1], ENT_QUOTES, $charset) . "</s>\n";
        $data .= "</f>\n";
    } else {
        if ($auteur) {
            $data .= "<f c='700' ind='  '>\n";
            $data .= "\t<s c='a'>" . htmlspecialchars($auteur[0], ENT_QUOTES, $charset) . "</s>\n";
            $data .= "</f>\n";
            if ($auteur) {
                for ($i = 1; $i < count($auteur); $i++) {
                    $data .= "<f c='701' ind='  '>\n";
                    $data .= "\t<s c='a'>" . htmlspecialchars($auteur[$i], ENT_QUOTES, $charset) . "</s>\n";
                    $data .= "</f>\n";
                }
            }
        }
    }
    if ($doc_type) {
        switch ($doc_type) {
            case 'Abstracts':
            case 'Meeting Abstracts':
                $doctype = "Abstract";
                break;
            case 'Academic Dissertations':
                $doctype = "Thesis";
                break;
            case 'Annual Reports':
            case 'Technical Report':
                $doctype = "Report";
                break;
            case 'Book Reviews':
            case 'Review':
                $doctype = "Review";
                break;
            case 'Classical Article':
            case 'Corrected and Republished Article':
            case 'Journal Article':
            case 'Newspaper Article':
                $doctype = "Article";
                break;
            case 'Comment':
            case 'Published Erratum':
                $doctype = "Erratum";
                break;
            case 'Congresses':
                $doctype = "Conference Proceedings";
                break;
            case 'Database':
                $doctype = "Database";
                break;
            case 'Dictionary':
                $doctype = "Dictionary";
                break;
            case 'Directory':
                $doctype = "Directory";
                break;
            case 'Editorial':
                $doctype = "Editorial";
                break;
            case 'Encyclopedias':
                $doctype = "Encyclopedia";
                break;
            case 'Letter':
                $doctype = "Letter";
                break;
            case 'Unpublished Works':
                $doctype = "Preprint";
                break;
            default:
                $doctype = "Article";
                break;
        }
        if ($doctype) {
            $data .= "<f c='900' ind='  '>\n";
            $data .= "\t<s c='a'>" . htmlspecialchars($doctype, ENT_QUOTES, $charset) . "</s>\n";
            $data .= "\t<s c='l'>Sub-Type</s>\n";
            $data .= "\t<s c='n'>subtype</s>\n";
            $data .= "</f>\n";
        }
    }
    if ($doi) {
        $data .= "<f c='900' ind='  '>\n";
        $data .= "\t<s c='a'>" . htmlspecialchars($doi, ENT_QUOTES, $charset) . "</s>\n";
        $data .= "\t<s c='l'>DOI id</s>\n";
        $data .= "\t<s c='n'>pmi_doi_identifier</s>\n";
        $data .= "</f>\n";
    }
    if ($pubmed_id) {
        $data .= "<f c='856' ind='  '>\n";
        $data .= "\t<s c='u'>http://www.ncbi.nlm.nih.gov/pubmed/{$pubmed_id}</s>\n";
        $data .= "</f>\n";
        $data .= "<f c='900' ind='  '>\n";
        $data .= "\t<s c='a'>" . htmlspecialchars($pubmed_id, ENT_QUOTES, $charset) . "</s>\n";
        $data .= "\t<s c='l'>Numéro PUBMED</s>\n";
        $data .= "\t<s c='n'>pmi_xref_dbase_id</s>\n";
        $data .= "</f>\n";
    }
    $data .= "</notice>\n";
    if (!$error) {
        $r['VALID'] = true;
    } else {
        $r['VALID'] = false;
    }
    $r['ERROR'] = $error;
    $r['DATA'] = $data;
    return $r;
}