function entrepot_to_unimarc($recid)
 {
     global $dbh;
     $requete = "SELECT source_id FROM external_count WHERE rid=" . addslashes($recid) . ";";
     $myQuery = pmb_mysql_query($requete, $dbh);
     $source_id = pmb_mysql_result($myQuery, 0, 0);
     $requete = "select * from entrepot_source_{$source_id} where recid='" . addslashes($recid) . "' group by ufield,usubfield,field_order,subfield_order,value order by field_order,subfield_order";
     $resultat = pmb_mysql_query($requete, $dbh);
     $unimarc = new iso2709_record("", USER_UPDATE);
     $field_order = -1;
     $field = $r->ufield;
     $sfields = array();
     while ($r = pmb_mysql_fetch_object($resultat)) {
         switch ($r->ufield) {
             case "rs":
                 $unimarc->set_rs($r->value);
                 break;
             case "dt":
                 $unimarc->set_dt($r->value);
                 break;
             case "bl":
                 $unimarc->set_bl($r->value);
                 break;
             case "hl":
                 $unimarc->set_hl($r->value);
                 break;
             case "el":
                 $unimarc->set_el($r->value);
                 break;
             case "ru":
                 $unimarc->set_ru($r->value);
                 break;
             case "001":
                 $unimarc->add_field("001", '  ', $r->value);
             default:
                 if ($field_order != $r->field_order) {
                     if (count($sfields)) {
                         $unimarc->add_field($field, '  ', $sfields);
                     }
                     $field = $r->ufield;
                     $sfields = array();
                     $field_order = $r->field_order;
                 }
                 if (!$r->usubfield) {
                     $unimarc->add_field($r->ufield, '', $r->value);
                 } else {
                     $sfields[][0] = $r->usubfield;
                     $sfields[count($sfields) - 1][1] = $r->value;
                 }
                 break;
         }
     }
     if (count($sfields)) {
         $unimarc->add_field($field, '  ', $sfields);
     }
     $unimarc->update();
     $this->sugg_uni_notice = $unimarc->full_record;
 }
Пример #2
0
function entrepot_to_unimarc($recid)
{
    global $dbh, $charset;
    $requete = "SELECT source_id FROM external_count WHERE rid=" . addslashes($recid) . ";";
    $myQuery = mysql_query($requete, $dbh);
    $source_id = mysql_result($myQuery, 0, 0);
    $requete = "select * from entrepot_source_{$source_id} where recid='" . addslashes($recid) . "' group by ufield,usubfield,field_order,subfield_order,value order by field_order,subfield_order";
    $resultat = mysql_query($requete, $dbh);
    $unimarc = new iso2709_record("", USER_UPDATE);
    if ($charset == "utf-8") {
        //Si on est en UTF-8 alors ce qui sort de la base est en UTF-8 et donc la notice sera en utf-8
        $unimarc->is_utf8 = true;
    }
    $field_order = -1;
    $field = $r->ufield;
    $field_ind = $r->field_ind;
    while (strlen($field_ind) < 2) {
        $field_ind .= ' ';
    }
    $sfields = array();
    while ($r = mysql_fetch_object($resultat)) {
        switch ($r->ufield) {
            case "rs":
                $unimarc->set_rs($r->value);
                break;
            case "dt":
                $unimarc->set_dt($r->value);
                break;
            case "bl":
                $unimarc->set_bl($r->value);
                break;
            case "hl":
                $unimarc->set_hl($r->value);
                break;
            case "el":
                $unimarc->set_el($r->value);
                break;
            case "ru":
                $unimarc->set_ru($r->value);
                break;
            case "001":
                $unimarc->add_field("001", '  ', $r->value);
            default:
                if ($field_order != $r->field_order) {
                    if (count($sfields)) {
                        $unimarc->add_field($field, $field_ind, $sfields);
                    }
                    $field = $r->ufield;
                    $field_ind = $r->field_ind;
                    while (strlen($field_ind) < 2) {
                        $field_ind .= ' ';
                    }
                    $sfields = array();
                    $field_order = $r->field_order;
                }
                if (!$r->usubfield) {
                    $unimarc->add_field($r->ufield, '', $r->value);
                } else {
                    $sfields[][0] = $r->usubfield;
                    $sfields[count($sfields) - 1][1] = $r->value;
                }
                break;
        }
    }
    if (count($sfields)) {
        $unimarc->add_field($field, $field_ind, $sfields);
    }
    $unimarc->update();
    return array('notice' => $unimarc->full_record, 'source_id' => $source_id);
}