コード例 #1
0
 function insert_authority_infos($authority_number, $type, $id_origin_authority, $authority_infos = array())
 {
     global $opac_enrichment_bnf_sparql;
     //on a un numéro d'autorité, on regarde si on l'a déjà rencontré
     $num_authority = $authority_infos['id'];
     $query = "select id_authority_source,num_authority from authorities_sources where authority_number = '" . $authority_number . "' and num_origin_authority='" . $id_origin_authority . "' and authority_type = '" . $type . "'";
     $result = pmb_mysql_query($query) or die("can't select authorities_sources :" . $query);
     if (pmb_mysql_num_rows($result)) {
         $row = pmb_mysql_fetch_object($result);
         $num_authority = $row->num_authority;
         $num_authority_source = $row->id_authority_source;
         // on cherche la préférence... dès fois que...
         $query = "select id_authority_source, num_authority from authorities_sources where authority_number = '" . $authority_number . "' and authority_type = '" . $type . "' and authority_favorite = 1";
         $result = pmb_mysql_query($query) or die("can't select authorities_sources :" . $query);
         if (pmb_mysql_num_rows($result)) {
             $row = pmb_mysql_fetch_object($result);
             $num_authority = $row->num_authority;
             $num_authority_source = $row->id_authority_source;
         }
     } else {
         // on importe l'autorité dans la base si elle n'a pas d'id
         if ($num_authority == 0) {
             switch ($type) {
                 case "author":
                     $num_authority = auteur::import($authority_infos);
                     break;
                 case "uniform_title":
                     $num_authority = titre_uniforme::import($authority_infos);
                     break;
                 case "category":
                     $num_authority = category::import($authority_infos);
                     break;
                 case "collection":
                     $num_authority = collection::import($authority_infos);
                     break;
                 case "subcollection":
                     $num_authority = subcollection::import($authority_infos);
                     break;
                 case "serie":
                     break;
             }
         }
         // on intègre la source de l'autorité
         $query = "insert into authorities_sources set\n\t\t\tnum_authority = '{$num_authority}',\n\t\t\tauthority_number = '" . $authority_number . "',\n\t\t\tauthority_type = '{$type}',\n\t\t\tnum_origin_authority = " . $id_origin_authority . ",\n\t\t\timport_date = now()";
         pmb_mysql_query($query) or die("can't insert authorities_sources :" . $query);
         $num_authority_source = pmb_mysql_insert_id();
         ////////////////////////////////////////////////////////////////
         if ($opac_enrichment_bnf_sparql && $type == 'author') {
             auteur::author_enrichment($num_authority);
         }
     }
     return $num_authority;
 }
コード例 #2
0
ファイル: import_func.inc.php プロジェクト: bouchra012/PMB
function keep_authority_infos($authority_number, $type, $origin_authority, $notice_id, $authority_infos = array())
{
    //on a un numéro d'autorité, on regarde si on l'a déjà rencontré
    $query = "select id_authority_source,num_authority from authorities_sources where authority_number = '" . $authority_number . "' and num_origin_authority='" . $origin_authority . "' and authority_type = '" . $type . "'";
    $result = mysql_query($query);
    if (mysql_num_rows($result)) {
        $row = mysql_fetch_object($result);
        $num_authority = $row->num_authority;
        $num_authority_source = $row->id_authority_source;
        // on cherche la préférence... dès fois que...
        $query = "select id_authority_source, num_authority from authorities_sources where authority_number = '" . $authority_number . "' and authority_type = '" . $type . "' and authority_favorite = 1";
        $result = mysql_query($query);
        if (mysql_num_rows($result)) {
            $row = mysql_fetch_object($result);
            $num_authority = $row->num_authority;
            $num_authority_source = $row->id_authority_source;
        }
    } else {
        // c'est un petit nouveau
        switch ($type) {
            case "author":
                $num_authority = auteur::import($authority_infos);
                break;
            case "uniform_title":
                $num_authority = titre_uniforme::import($authority_infos);
                break;
            case "category":
                $num_authority = category::import($authority_infos);
                break;
            case "collection":
                $num_authority = collection::import($authority_infos);
                break;
            case "subcollection":
                $num_authority = subcollection::import($authority_infos);
                break;
            case "serie":
                break;
        }
        $query = "insert into authorities_sources set \n\t\t\tnum_authority = '{$num_authority}',\n\t\t\tauthority_number = '" . $authority_number . "',\n\t\t\tauthority_type = '{$type}',\n\t\t\tnum_origin_authority = " . $origin_authority . ",\n\t\t\timport_date = now()";
        mysql_query($query);
        $num_authority_source = mysql_insert_id();
    }
    //certaines autorités sont créés avant la notice...
    if ($notice_id != 0) {
        $query = "insert into notices_authorities_sources set \n\t\tnum_authority_source = " . $num_authority_source . ",\n\t\tnum_notice = " . $notice_id;
        mysql_query($query);
    }
    return $num_authority;
}
コード例 #3
0
 static function getAutomaticTu($notice)
 {
     global $dbh, $charset, $opac_enrichment_bnf_sparql;
     if (!$opac_enrichment_bnf_sparql) {
         return 0;
     }
     $requete = "select code, responsability_author from notices left join responsability on (responsability_notice={$notice} and responsability_type=0)\n\t\t\tleft join notices_titres_uniformes on notice_id=ntu_num_notice where notice_id={$notice} and ntu_num_notice is null";
     $resultat = pmb_mysql_query($requete, $dbh);
     if (pmb_mysql_num_rows($resultat, $dbh)) {
         $code = pmb_mysql_result($resultat, 0, 0, $dbh);
         $id_author = pmb_mysql_result($resultat, 0, 1, $dbh);
     } else {
         $code = "";
     }
     $id_tu = 0;
     if (isISBN($code)) {
         $uri = titre_uniforme::get_data_bnf_uri($code);
         if ($uri) {
             //Recherche du titre uniforme déjà existant ?
             $requete = "select tu_id from titres_uniformes where tu_databnf_uri='" . addslashes($uri) . "'";
             $resultat = pmb_mysql_query($requete, $dbh);
             if (pmb_mysql_num_rows($resultat, $dbh)) {
                 $id_tu = pmb_mysql_result($resultat, 0, 0, $dbh);
             } else {
                 //Interrogation de data.bnf pour obtenir les infos !
                 $configbnf = array('remote_store_endpoint' => 'http://data.bnf.fr/sparql');
                 $storebnf = ARC2::getRemoteStore($configbnf);
                 $sparql = "\n\t\t\t\t\t\tPREFIX dc: <http://purl.org/dc/terms/>\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\tSELECT ?title ?date ?description WHERE {\n\t\t\t\t\t\t  <" . $uri . "> dc:title ?title.\n\t\t\t\t\t\t  OPTIONAL { <" . $uri . "> dc:date ?date. }\n\t\t\t\t\t\t  OPTIONAL { <" . $uri . "> dc:description ?description. }\n\t\t\t\t\t\t}";
                 $rows = $storebnf->query($sparql, 'rows');
                 // On vérifie qu'il n'y a pas d'erreur sinon on stoppe le programme et on renvoi une chaine vide
                 $err = $storebnf->getErrors();
                 if (!$err) {
                     $value = array("name" => encoding_normalize::charset_normalize($rows[0]['title'], "utf-8"), "num_author" => $id_author, "date" => encoding_normalize::charset_normalize($rows[0]['date'], "utf-8"), "comment" => encoding_normalize::charset_normalize($rows[0]['description'], "utf-8"), "databnf_uri" => $uri);
                     $id_tu = titre_uniforme::import($value);
                 }
             }
         }
     }
     if ($id_tu) {
         $titres_uniformes = array(array("num_tu" => $id_tu));
         $ntu = new tu_notice($notice);
         $ntu->update($titres_uniformes);
     }
     return $id_tu;
 }
コード例 #4
0
 public function create_authority()
 {
     switch ($this->notice->type) {
         case "author":
             $this->authority_id = auteur::import($this->notice->specifics_data);
             break;
         case "uniform_title":
             $this->authority_id = titre_uniforme::import($this->notice->specifics_data);
             break;
         case "collection":
             $this->authority_id = collection::import($this->notice->specifics_data);
             if ($this->authority_id != 0 && $this->notice->specifics_data['subcollections']) {
                 for ($i = 0; $i < count($this->notice->specifics_data['subcollections']); $i++) {
                     $this->notice->specifics_data['subcollections'][$i]['coll_parent'] = $this->authority_id;
                     $subcoll_id = subcollection::check_if_exists($this->notice->specifics_data['subcollections'][$i]);
                     if ($subcoll_id != 0 && $this->notice->specifics_data['subcollections'][$i]['authority_number']) {
                         $query = "insert into authorities_sources set \n\t\t\t\t\t\t\t\t\tnum_authority = " . $subcoll_id . ",\n\t\t\t\t\t\t\t\t\tauthority_number = '" . $this->notice->specifics_data['subcollections'][$i]['authority_number'] . "',\t\n\t\t\t\t\t\t\t\t\tauthority_type = 'subcollection',\n\t\t\t\t\t\t\t\t\tnum_origin_authority = " . $this->num_origin . ",\n\t\t\t\t\t\t\t\t\tauthority_favorite = 0,\n\t\t\t\t\t\t\t\t\timport_date = now()";
                         mysql_query($query);
                     }
                 }
             }
             break;
         case "subcollection":
             $this->authority_id = subcollection::import($this->notice->specifics_data);
             if ($this->authority_id != 0 && $this->notice->specifics_data['collection'] && $this->notice->specifics_data['collection']['authority_number']) {
                 $coll_id = collection::check_if_exists($this->notice->specifics_data['collection']);
                 $query = "insert into authorities_sources set \n\t\t\t\t\t\t\tnum_authority = " . $coll_id . ",\n\t\t\t\t\t\t\tauthority_number = '" . $this->notice->specifics_data['collection']['authority_number'] . "',\t\n\t\t\t\t\t\t\tauthority_type = 'collection',\n\t\t\t\t\t\t\tnum_origin_authority = " . $this->num_origin . ",\n\t\t\t\t\t\t\tauthority_favorite = 0,\n\t\t\t\t\t\t\timport_date = now()";
                 mysql_query($query);
             }
             break;
         case "category":
             $this->authority_id = category::import($this->notice->specifics_data, $this->id_thesaurus, $this->get_parent_category(), $this->notice->common_data['lang']);
             break;
         default:
             //	on fait rien...
             break;
     }
     if ($this->authority_id) {
         $query = "insert into authorities_sources set \n\t\t\t\tnum_authority = " . $this->authority_id . ",\n\t\t\t\tauthority_number = '" . $this->notice->common_data['authority_number'] . "',\t\n\t\t\t\tauthority_type = '" . $this->notice->type . "',\n\t\t\t\tnum_origin_authority = " . $this->num_origin . ",\n\t\t\t\tauthority_favorite = 1,\n\t\t\t\timport_date = now(),\n\t\t\t\tupdate_date = now()";
         mysql_query($query);
     } else {
         return false;
     }
 }