";
$form = str_replace('!!ck_diarization!!', $checkbox, $form);
} else {
$form = str_replace("!!ck_diarization!!", "" , $form);
}
//Gestion du scanner
if (($pmb_scan_pmbws_client_url)&&($pmb_scan_pmbws_url)) {
$scan_addon="
";
$form = str_replace('',$scan_addon, $form);
}
// Ajout du bouton d'association s'il y a des segments en base
$associer = "";
$fct = "";
if ($this->explnum_id) {
$nb = 0;
$query = "select count(*) as nb from explnum_segments where explnum_segment_explnum_num = ".$this->explnum_id;
$result = mysql_query($query);
if ($result && mysql_num_rows($result)) {
$nb = mysql_fetch_object($result)->nb;
}
if ($nb > 0) {
$associer = "explnum_id."';\" />";
if ($pmb_diarization_docnum) {
// On ajoute une confirmation pour une deuxième segmentation => perte des associations
$fct = "";
}
}
}
$form = str_replace("!!associate_speakers!!", $associer, $form);
$form = str_replace("!!fct_conf_diarize_again!!", $fct, $form);
// Ajout du bouton supprimer si modification
if ($this->explnum_id && $suppr)
$supprimer = "
";
$form = str_replace('!!supprimer!!', $supprimer, $form);
//Gestion du statut de notice
if ($pmb_explnum_statut=='1') {
$explnum_statut_form = " explnum_statut=='1') $explnum_statut_form.="checked='checked' ";
$explnum_statut_form.= "/> ";
$form = str_replace('', $explnum_statut_form, $form);
}
//Conserver la vignette
if ($this->explnum_vignette)
$form = str_replace('!!vignette_existante!!', " ", $form);
else $form = str_replace('!!vignette_existante!!', '', $form);
global $_mimetypes_bymimetype_;
create_tableau_mimetype();
$selector_mimetype = " ";
$form = str_replace('!!mimetype_list!!', $selector_mimetype, $form);
//Intégration de la gestion de l'interface de l'upload
if ($pmb_docnum_in_directory_allow){
$div_up = "
";
if ($pmb_docnum_in_database_allow) $div_up .= " ";
$div_up .= "
";
$form = str_replace('!!div_upload!!',$div_up,$form);
$up = new upload_folder($this->explnum_repertoire);
//$nom_chemin = ($up->isHashing() ? $this->explnum_rep_nom : $this->explnum_rep_nom.$this->explnum_path);
$nom_chemin=$this->explnum_rep_nom;
if ($up->isHashing()) {
$nom_chemin.="/";
} else {
$nom_chemin.=($this->explnum_path==='' ? "/" : $this->explnum_path);
}
$form = str_replace('!!path!!', htmlentities($nom_chemin ,ENT_QUOTES, $charset), $form);
$form = str_replace('!!id_rep!!', htmlentities($this->explnum_repertoire ,ENT_QUOTES, $charset), $form);
if($this->explnum_rep_nom || $this->isEnUpload()){
$form = str_replace('!!check_base!!','', $form);
$form = str_replace('!!check_up!!','checked', $form);
} else {
$form = str_replace('!!check_base!!','', $form);
$form = str_replace('!!check_up!!','checked', $form);
}
} else {
$form = str_replace('!!div_upload!!','',$form);
}
//Ajout du selecteur de localisation
if ($explnum_id) {
if (!$this->explnum_location) {
$requete = "select idlocation from docs_location";
$res = mysql_query($requete);
$i=0;
while ($row = mysql_fetch_array($res)) {
$liste_id[$i] = $row["idlocation"];
$i++;
}
} else {
$liste_id = $this->explnum_location;
}
} else {
global $deflt_docs_location;
$liste_id[0] = $deflt_docs_location;
}
$docloc = new docs_location();
$selector_location = $docloc->gen_multiple_combo($liste_id);
$form = str_replace('!!location_explnum!!',"".$selector_location,$form);
}
/*
* Appel au constructeur du formulaire puis retourne le formulaire créé
*/
function explnum_form ($action, $annuler='', $suppr='') {
global $explnum_form;
//$action .= '&id='.$this->explnum_id;
$this->fill_form ($explnum_form, $action, $suppr);
// action du bouton annuler
if(!$annuler)
// default : retour à la liste des exemplaires
$annuler = './catalog.php?categ=expl&id='.$this->id_notice;
$explnum_form = str_replace('!!annuler_action!!', $annuler, $explnum_form);
// affichage
return $explnum_form;
}
/*
* Mise à jour des documents numériques
*/
function mise_a_jour($f_notice, $f_bulletin, $f_nom, $f_url, $retour, $conservervignette, $f_statut_chk){
global $multi_ck, $base_path;
$this->recuperer_explnum($f_notice, $f_bulletin, $f_nom, $f_url, $retour, $conservervignette, $f_statut_chk);
if($multi_ck){
//Gestion multifichier
$this->unzip($base_path."/temp/".$this->infos_docnum["userfile_moved"]);
if(!is_array($this->unzipped_files) || !count($this->unzipped_files)){//Si la décompression n'a pas fonctionnée on reprend le fonctionnement normal
$this->infos_docnum["nom"] = "-x-x-x-x-";
$this->analyser_docnum();
$this->update();
}else{
$this->analyse_multifile();
}
if(file_exists($base_path."/temp/".$this->infos_docnum["userfile_moved"]))
unlink($base_path."/temp/".$this->infos_docnum["userfile_moved"]);
} else {
//Gestion normale du fichier
$this->analyser_docnum();
$this->update();
}
if($f_notice){
// Mise a jour de la table notices_mots_global_index
notice::majNoticesMotsGlobalIndex($f_notice,"explnum");
}elseif($f_bulletin){
// Mise a jour de la table notices_mots_global_index pour toutes les notices en relation avec l'exemplaire
$req_maj="SELECT bulletin_notice,num_notice FROM bulletins WHERE bulletin_id='".$f_bulletin."'";
$res_maj=mysql_query($req_maj);
if($res_maj && mysql_num_rows($res_maj)){
if($tmp=mysql_result($res_maj,0,0)){//Périodique
notice::majNoticesMotsGlobalIndex($tmp,"explnum");
}
if($tmp=mysql_result($res_maj,0,1)){//Notice de bulletin
notice::majNoticesMotsGlobalIndex($tmp,"explnum");
}
}
}
}
/*
* Effacement de l'exemplaire numérique
*/
function delete() {
global $dbh;
if($this->isEnUpload()){
$up = new upload_folder($this->explnum_repertoire);
$chemin = str_replace("//","/",$this->explnum_rep_path.$this->explnum_path.$this->explnum_nomfichier);
$chemin = $up->encoder_chaine($chemin);
if(file_exists($chemin))
unlink($chemin);
}
$requete = "DELETE FROM explnum WHERE explnum_id=".$this->explnum_id;
mysql_query($requete, $dbh);
//on oublie pas la localisation associé
$requete = "delete from explnum_location where num_explnum = ".$this->explnum_id;
mysql_query($requete, $dbh);
// Suppression des segments et locuteurs
$requete = "delete from explnum_speakers where explnum_speaker_explnum_num = ".$this->explnum_id;
mysql_query($requete, $dbh);
$requete = "delete from explnum_segments where explnum_segment_explnum_num = ".$this->explnum_id;
mysql_query($requete, $dbh);
//On recalcule l'index global pour la notice
if($this->explnum_notice){
// Mise a jour de la table notices_mots_global_index
notice::majNoticesMotsGlobalIndex($this->explnum_notice,"explnum");
}elseif($this->explnum_bulletin){
// Mise a jour de la table notices_mots_global_index pour toutes les notices en relation avec l'exemplaire
$req_maj="SELECT bulletin_notice,num_notice FROM bulletins WHERE bulletin_id='".$this->explnum_bulletin."'";
$res_maj=mysql_query($req_maj);
if($res_maj && mysql_num_rows($res_maj)){
if($tmp=mysql_result($res_maj,0,0)){//Périodique
notice::majNoticesMotsGlobalIndex($tmp,"explnum");
}
if($tmp=mysql_result($res_maj,0,1)){//Notice de bulletin
notice::majNoticesMotsGlobalIndex($tmp,"explnum");
}
}
}
}
/*
* Mise à jour de l'exemplaire numérique
*/
function update($with_print = true){
global $dbh, $msg;
global $current_module, $pmb_explnum_statut;
global $id_rep, $up_place;
global $mime_vign;
$update = false;
if ($this->explnum_id) {
$requete = "UPDATE explnum SET ";
$limiter = " WHERE explnum_id='$this->explnum_id' ";
$update = true;
} else {
$requete = "INSERT INTO explnum SET ";
$limiter = "";
}
if($with_print){
print "
$msg[explnum_doc_associe]
";
}
if (!$this->params["erreur"]) {
$requete .= " explnum_notice='".$this->infos_docnum["notice"]."'";
$requete .= ", explnum_bulletin='".$this->infos_docnum["bull"]."'";
$requete .= ", explnum_nom='".$this->infos_docnum["nom"]."'";
$requete .= ", explnum_url='".$this->infos_docnum["url"]."'";
if ($this->params["maj_mimetype"])
$requete .= ", explnum_mimetype='".$this->infos_docnum["mime"]. "' ";
if ($this->params["maj_data"] ) {
if(!$this->params["is_upload"])
$requete .= ", explnum_data='".addslashes($this->infos_docnum["contenu"])."'";
$requete .= ", explnum_nomfichier='".addslashes($this->infos_docnum["userfile_name"])."'";
$requete .= ", explnum_extfichier='".addslashes($this->infos_docnum["userfile_ext"])."'";
}
if ($this->params["maj_vignette"] && !$this->params["conservervignette"]) {
$requete .= ", explnum_vignette='".addslashes($this->infos_docnum["contenu_vignette"])."'";
}
if ($pmb_explnum_statut=='1') {
$requete.= ", explnum_statut='".$this->params["statut"]."'";
}
$requete.= ", explnum_repertoire='".(($up_place)?$id_rep:0)."'";
$requete.= ", explnum_path='".$this->infos_docnum["path"]."'";
$requete .= $limiter;
mysql_query($requete, $dbh) ;
if(!$update)
$this->explnum_id = mysql_insert_id();
//Indexation du document
global $pmb_indexation_docnum;
if($pmb_indexation_docnum){
$vign_index = $this->indexer_docnum();
if(!$mime_vign && !$this->params["conservervignette"] && !$this->infos_docnum["vignette_name"]){
if($vign_index){
$req_mime = "update explnum set explnum_vignette='".addslashes($vign_index)."' where explnum_id='".$this->explnum_id."'";
mysql_query($req_mime,$dbh);
}else{
$contenu_vignette = construire_vignette("", "",$this->infos_docnum["url"]);
if($contenu_vignette){
$req_mime = "update explnum set explnum_vignette='".addslashes($contenu_vignette)."' where explnum_id='".$this->explnum_id."'";
mysql_query($req_mime,$dbh);
}
}
}
}elseif(!$mime_vign && !$this->params["conservervignette"] && !$this->infos_docnum["vignette_name"] && $this->infos_docnum["url"]){//Si pas d'indexation et que je ne force pas la vignette en fonction du mimetype et si j'ai une url
$contenu_vignette = construire_vignette("", "",$this->infos_docnum["url"]);
if($contenu_vignette){
$req_mime = "update explnum set explnum_vignette='".addslashes($contenu_vignette)."' where explnum_id='".$this->explnum_id."'";
mysql_query($req_mime,$dbh);
}
}
// Segmentation du document
global $pmb_diarization_docnum;
if ($pmb_diarization_docnum) {
$this->diarization_docnum();
}
//On enregistre la ou les localisations
global $loc_selector;
if($update){
$req = "delete from explnum_location where num_explnum='".$this->explnum_id."'";
mysql_query($req,$dbh);
}
if((count($loc_selector) == 1) && ($loc_selector[0] == -1)){
//Ne rien faire
//$req = "select idlocation from docs_location";
//$res = mysql_query($req,$dbh);
//while($loc=mysql_fetch_object($res)){
// $req = "replace into explnum_location set num_explnum='".$this->explnum_id."', num_location='".$loc->idlocation."'";
// mysql_query($req,$dbh);
//}
} else {
for($i=0;$i