Exemple #1
0
 function rec_record($record, $source_id, $search_id)
 {
     global $charset, $base_path;
     //On a un enregistrement unimarc, on l'enregistre
     $rec_uni_dom = new xml_dom_sru($record, $charset, false);
     if (!$rec_uni_dom->error) {
         //Initialisation
         $ref = "";
         $ufield = "";
         $usubfield = "";
         $field_order = 0;
         $subfield_order = 0;
         $value = "";
         $date_import = date("Y-m-d H:i:s", time());
         $fs = $rec_uni_dom->get_nodes("unimarc/notice/f");
         //Recherche du 001
         if ($fs) {
             for ($i = 0; $i < count($fs); $i++) {
                 if ($fs[$i]["ATTRIBS"]["c"] == "001") {
                     $ref = $rec_uni_dom->get_datas($fs[$i]);
                     break;
                 }
             }
         }
         if (!$ref) {
             $ref = md5($record);
         }
         //Mise � jour
         if ($ref) {
             //Si conservation des anciennes notices, on regarde si elle existe
             if (!$this->del_old) {
                 $requete = "select count(*) from entrepot_source_" . $source_id . " where ref='" . addslashes($ref) . "'";
                 $rref = mysql_query($requete);
                 if ($rref) {
                     $ref_exists = mysql_result($rref, 0, 0);
                 }
             }
             //Si pas de conservation des anciennes notices, on supprime
             if ($this->del_old) {
                 //					$requete="delete from entrepot_source_".$source_id." where ref='".addslashes($ref)."'";
                 //					mysql_query($requete);
             }
             $ref_exists = false;
             //Si pas de conservation ou ref�rence inexistante
             if ($this->del_old || !$this->del_old && !$ref_exists) {
                 //Insertion de l'ent�te
                 $n_header["rs"] = $rec_uni_dom->get_value("unimarc/notice/rs");
                 $n_header["ru"] = $rec_uni_dom->get_value("unimarc/notice/ru");
                 $n_header["el"] = $rec_uni_dom->get_value("unimarc/notice/el");
                 $n_header["bl"] = $rec_uni_dom->get_value("unimarc/notice/bl");
                 $n_header["hl"] = $rec_uni_dom->get_value("unimarc/notice/hl");
                 $n_header["dt"] = $rec_uni_dom->get_value("unimarc/notice/dt");
                 //R�cup�ration d'un ID
                 $requete = "insert into external_count (recid, source_id) values('" . addslashes($this->get_id() . " " . $source_id . " " . $ref) . "', " . $source_id . ")";
                 $rid = mysql_query($requete);
                 if ($rid) {
                     $recid = mysql_insert_id();
                 }
                 foreach ($n_header as $hc => $code) {
                     $requete = "insert into entrepot_source_" . $source_id . " (connector_id,source_id,ref,date_import,ufield,usubfield,field_order,subfield_order,value,i_value,recid, search_id) values(\n\t\t\t\t\t\t'" . addslashes($this->get_id()) . "'," . $source_id . ",'" . addslashes($ref) . "','" . addslashes($date_import) . "',\n\t\t\t\t\t\t'" . $hc . "','',-1,0,'" . addslashes($code) . "','',{$recid}, '{$search_id}')";
                     mysql_query($requete);
                 }
                 if ($fs) {
                     for ($i = 0; $i < count($fs); $i++) {
                         $ufield = $fs[$i]["ATTRIBS"]["c"];
                         $field_order = $i;
                         $ss = $rec_uni_dom->get_nodes("s", $fs[$i]);
                         if (is_array($ss)) {
                             for ($j = 0; $j < count($ss); $j++) {
                                 $usubfield = $ss[$j]["ATTRIBS"]["c"];
                                 $value = $rec_uni_dom->get_datas($ss[$j]);
                                 $subfield_order = $j;
                                 $requete = "insert into entrepot_source_" . $source_id . " (connector_id,source_id,ref,date_import,ufield,usubfield,field_order,subfield_order,value,i_value,recid, search_id) values(\n\t\t\t\t\t\t\t\t'" . addslashes($this->get_id()) . "'," . $source_id . ",'" . addslashes($ref) . "','" . addslashes($date_import) . "',\n\t\t\t\t\t\t\t\t'" . addslashes($ufield) . "','" . addslashes($usubfield) . "'," . $field_order . "," . $subfield_order . ",'" . addslashes($value) . "',\n\t\t\t\t\t\t\t\t' " . addslashes(strip_empty_words($value)) . " ',{$recid}, '{$search_id}')";
                                 mysql_query($requete);
                             }
                         } else {
                             $value = $rec_uni_dom->get_datas($fs[$i]);
                             $requete = "insert into entrepot_source_" . $source_id . " (connector_id,source_id,ref,date_import,ufield,usubfield,field_order,subfield_order,value,i_value,recid, search_id) values(\n\t\t\t\t\t\t\t'" . addslashes($this->get_id()) . "'," . $source_id . ",'" . addslashes($ref) . "','" . addslashes($date_import) . "',\n\t\t\t\t\t\t\t'" . addslashes($ufield) . "','" . addslashes($usubfield) . "'," . $field_order . "," . $subfield_order . ",'" . addslashes($value) . "',\n\t\t\t\t\t\t\t' " . addslashes(strip_empty_words($value)) . " ',{$recid}, '{$search_id}')";
                             mysql_query($requete);
                         }
                     }
                 }
             }
             $this->n_recu++;
         }
     }
 }
Exemple #2
0
 function endElement($parser, $name)
 {
     if ($this->tag_and_attribs_name_lowercase) {
         $name = strtolower($name);
     }
     if (preg_match('/^:?recorddata$/', substr($name, strpos($name, ':') + 1)) && $this->depth <= 4) {
         $this->in_record_data = false;
     }
     parent::endElement($parser, $name);
 }