=') && extension_loaded('xsl')) { require_once($include_path.'/xslt-php4-to-php5.inc.php'); } function cfile_file_item_($param) { global $catalogs; if (($param['VISIBLE'] != 'no') && ($param['IMPORT'] == 'yes') || ($param['OUTPUT_PMBXML'] == 'yes')) { $catalogs[]= array( "name" => $param['NAME'], "path" => $param['PATH'] ); } } class cfile extends connector { //Variables internes pour la progression de la récupération des notices public $current_set; //Set en cours de synchronisation public $total_sets; //Nombre total de sets sélectionnés public $metadata_prefix; //Préfixe du format de données courant public $search_id; public $xslt_transform; //Feuille xslt transmise public $sets_names; //Nom des sets pour faire plus joli !! public $url; public $username; public $password; public function __construct($connector_path="") { parent::__construct($connector_path); } public function get_id() { return "cfile"; } //Est-ce un entrepot ? public function is_repository() { return 1; } public function source_get_property_form($source_id) { global $charset, $basepath; $params=$this->get_source_params($source_id); if ($params["PARAMETERS"]) { //Affichage du formulaire avec $params["PARAMETERS"] $vars=unserialize($params["PARAMETERS"]); foreach ($vars as $key=>$val) { global ${$key}; ${$key}=$val; } } if (!isset($convert_type)) $convert_type = ""; //Lecture des différents imports possibles if (file_exists($basepath."admin/convert/imports/catalog_subst.xml")) $fic_catal = $basepath."admin/convert/imports/catalog_subst.xml"; else $fic_catal = $basepath."admin/convert/imports/catalog.xml"; global $catalogs; $catalogs=array(); _parser_($fic_catal,array("ITEM"=>"cfile_file_item_"),"CATALOG"); $convert_select = ''; $form = ""; $form .= "
".$convert_select."
"; $xsl_exemplaire_input = ""; if (isset($xslt_exemplaire)) { $xsl_exemplaire_input .= ''; } $xsl_exemplaire_input .= ' '; $form.="
".$xsl_exemplaire_input."
"; return $form; } public function make_serialized_source_properties($source_id) { global $convert_type, $action_xsl_expl; $t = array(); $t["convert_type"] = $convert_type; if($action_xsl_expl == "keep") { $oldparams=$this->get_source_params($source_id); if ($oldparams["PARAMETERS"]) { //Affichage du formulaire avec $params["PARAMETERS"] $oldvars=unserialize($oldparams["PARAMETERS"]); } $t["xslt_exemplaire"] = $oldvars["xslt_exemplaire"]; } else { if (($_FILES["xsl_exemplaire"])&&(!$_FILES["xsl_exemplaire"]["error"])) { $axslt_info["name"] = $_FILES["xsl_exemplaire"]["name"]; $axslt_info["content"] = file_get_contents($_FILES["xsl_exemplaire"]["tmp_name"]); $t["xslt_exemplaire"] = $axslt_info; } } $this->sources[$source_id]["PARAMETERS"]=serialize($t); } //Récupération des proriétés globales par défaut du connecteur (timeout, retry, repository, parameters) public function fetch_default_global_values() { parent::fetch_default_global_values(); $this->repository=1; } public function rec_record($record,$source_id,$search_id) { global $charset,$base_path; $date_import=date("Y-m-d H:i:s",time()); $r=array(); //Inversion du tableau $r["rs"]=($record["RS"][0]["value"]?$record["RS"][0]["value"]:"*"); $r["ru"]=($record["RU"][0]["value"]?$record["RU"][0]["value"]:"*"); $r["el"]=($record["EL"][0]["value"]?$record["EL"][0]["value"]:"*"); $r["bl"]=($record["BL"][0]["value"]?$record["BL"][0]["value"]:"*"); $r["hl"]=($record["HL"][0]["value"]?$record["HL"][0]["value"]:"*"); $r["dt"]=($record["DT"][0]["value"]?$record["DT"][0]["value"]:"*"); $exemplaires = array(); for ($i=0; $idel_old) { $ref_exists = $this->has_ref($source_id, $ref); } //Si pas de conservation des anciennes notices, on supprime if ($this->del_old) { $this->delete_from_entrepot($source_id, $ref); $this->delete_from_external_count($source_id, $ref); } //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"]=$record["rs"]; $n_header["ru"]=$record["ru"]; $n_header["el"]=$record["el"]; $n_header["bl"]=$record["bl"]; $n_header["hl"]=$record["hl"]; $n_header["dt"]=$record["dt"]; //Récupération d'un ID $recid = $this->insert_into_external_count($source_id, $ref); foreach($n_header as $hc=>$code) { $this->insert_header_into_entrepot($source_id, $ref, $date_import, $hc, $code, $recid, $search_id); } $field_order=0; foreach($exemplaires as $exemplaire) { $sub_field_order = 0; foreach($exemplaire as $exkey => $exvalue) { $this->insert_content_into_entrepot($source_id, $ref, $date_import, '996', $exkey, $field_order, $sub_field_order, $exvalue, $recid, $search_id); $sub_field_order++; } $field_order++; } foreach ($record as $field=>$val) { for ($i=0; $i$vals) { for ($j=0; $jinsert_content_into_entrepot($source_id, $ref, $date_import, $field, $sfield, $field_order, $j, $vals[$j], $recid, $search_id); } } } else { $this->insert_content_into_entrepot($source_id, $ref, $date_import, $field, '', $field_order, 0, $val[$i], $recid, $search_id); } $field_order++; } } $this->rec_isbd_record($source_id, $ref, $recid); } } } public function form_pour_maj_entrepot($source_id) { global $base_path, $id; //Allons chercher plein d'informations utiles et amusantes $params=$this->get_source_params($source_id); $this->fetch_global_properties(); if ($params["PARAMETERS"]) { $vars=unserialize($params["PARAMETERS"]); foreach ($vars as $key=>$val) { global ${$key}; ${$key}=$val; } } if (!isset($convert_type)) $convert_type = "none_unimarc"; $form = ""; switch ($convert_type) { case "none_unimarc": //On importe de l'unimarc direct $form .= '
'; $form .= ''; $form .= ''; // $form .= ""; break; case "none_xml": //On importe du pmb-XML unimarc direct $form .= '
'; $form .= ''; $form .= ''; // $form .= ""; break; default: //Une conversion est nécéssaire $form .= '
'; $form .= ''; $form .= ''; $form .= ""; break; } $form .= "

"; return $form; } //Nécessaire pour passer les valeurs obtenues dans form_pour_maj_entrepot au javascript asynchrone public function get_maj_environnement($source_id) { global $outputtype, $import_type; global $base_path; $envt=array(); //Copie du fichier dans le répertoire temporaire $origine=str_replace(" ","",microtime()); $origine=str_replace("0.","",$origine); if ($_FILES['import_file']['name']) { if (!@copy($_FILES['import_file']['tmp_name'], "$base_path/temp/".$origine.$_FILES['import_file']['name'])) { error_message_history($msg["ie_tranfert_error"], $msg["ie_transfert_error_detail"], 1); exit; } else $file_in = $origine.$_FILES['import_file']['name']; } $envt["file_in"] = $file_in; if (!$import_type) $envt["outputtype"] = $outputtype; $envt["import_type"] = $import_type; $envt["origine"] = $origine; return $envt; } public function sync_custom_page($source_id) { global $base_path, $id, $file_in, $origine; //Allons chercher plein d'informations utiles et amusantes $params=$this->get_source_params($source_id); $this->fetch_global_properties(); if ($params["PARAMETERS"]) { $vars=unserialize($params["PARAMETERS"]); foreach ($vars as $key=>$val) { global ${$key}; ${$key}=$val; } } if (!isset($convert_type)) $convert_type = ""; //Convertissons le $convert_type en un nombre, vu que c'est ce que mange le script d'import $convert_type; $env = $this->get_maj_environnement($source_id); $file_in = $env["file_in"]; $redirect_url = "../../admin.php?categ=connecteurs&sub=in&act=sync&source_id=".$source_id."&go=1&id=$id&env=".urlencode(serialize($env)); $content = ""; $content .= '' . '