=') && extension_loaded('xsl')) {
require_once($include_path.'/xslt-php4-to-php5.inc.php');
}
//Voici un array_unique qui marche aussi avec des objects et des arrays.
function array_unique_more($array, $keep_key_assoc = false){
$duplicate_keys = array();
$tmp = array();
foreach ($array as $key=>$val){
// convert objects to arrays, in_array() does not support objects
if (is_object($val))
$val = (array)$val;
if (!in_array($val, $tmp))
$tmp[] = $val;
else
$duplicate_keys[] = $key;
}
foreach ($duplicate_keys as $key)
unset($array[$key]);
return $keep_key_assoc ? $array : array_values($array);
}
class aligastore 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 $blank_image;
public $image_thumb_url;
public $image_front;
public $image_back;
public $image_folder;
public $image_folder_url;
public $fetchimages;
public function __construct($connector_path="") {
parent::__construct($connector_path);
}
public function get_id() {
return "aligastore";
}
//Est-ce un entrepot ?
public function is_repository() {
return 3;
}
public function source_get_property_form($source_id) {
global $charset;
$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;
}
}
//URL
if (!isset($url))
$url = "http://www.aligastore.com/partenaires/xmldetaillivre.php";
$form="
";
//Username
if (!isset($username))
$username="";
$form.="
";
//Password
if (!isset($password))
$password="";
$form.="
";
//Image Thumb URL
if (!isset($image_thumb_url))
$image_thumb_url="http://www.aligastore.com/query.dll/img?gcdFab=!!isbn!!&type=0";
$form.="
";
//Image Front
if (!isset($image_front))
$image_front="http://www.aligastore.com/query.dll/img?gcdFab=!!isbn!!&type=1";
$form.="
";
//Image Back
if (!isset($image_back))
$image_back="http://www.aligastore.com/query.dll/img?gcdFab=!!isbn!!&type=4";
$form.="
";
//Image Fetch?
if (!isset($fetch_images))
$fetch_images=0;
$form.="
";
//Image Folder
if (!isset($image_folder))
$image_folder="";
$form.="
";
//Image Folder Public URL
if (!isset($image_folder_public))
$image_folder_public="";
$form.="
";
$form.="
";
return $form;
}
public function make_serialized_source_properties($source_id) {
global $url,$username, $password, $fetch_images, $image_folder, $image_thumb_url, $image_front, $image_back, $image_folder_public;
$t["url"]=stripslashes($url);
$t["username"]=stripslashes($username);
$t["password"]=stripslashes($password);
$t["fetch_images"]=stripslashes($fetch_images);
$t["image_folder"]=stripslashes($image_folder);
$t["image_folder_public"]=stripslashes($image_folder_public);
$t["image_thumb_url"]=stripslashes($image_thumb_url);
$t["image_front"]=stripslashes($image_front);
$t["image_back"]=stripslashes($image_back);
$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;
if (!trim($record))
return;
//On a un enregistrement unimarc, on l'enregistre
$rec_uni_dom=new xml_dom_aligastore($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; $iget_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) {
$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);
}
$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
$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);
}
if ($fs)
for ($i=0; $iget_nodes("s",$fs[$i]);
if (is_array($ss)) {
for ($j=0; $jget_datas($ss[$j]);
$subfield_order=$j;
$this->insert_content_into_entrepot($source_id, $ref, $date_import, $ufield, $usubfield, $field_order, $subfield_order, $value, $recid, $search_id);
}
} else {
$value=$rec_uni_dom->get_datas($fs[$i]);
$this->insert_content_into_entrepot($source_id, $ref, $date_import, $ufield, $usubfield, $field_order, 0, $value, $recid, $search_id);
}
}
$this->rec_isbd_record($source_id, $ref, $recid);
}
$this->n_recu++;
}
}
}
public function form_pour_maj_entrepot($source_id,$sync_form="sync_form") {
global $quoi_synchro;
$form = "";
$form .= "";
$form .= $this->msg["aliga_syncbase"];
$form .= '