diff --git a/VERSIONS_HOTLINE/60547 b/VERSIONS_HOTLINE/60547 new file mode 100644 index 0000000000000000000000000000000000000000..c84f333cd69f9df59f09d5a783d5564ca9116695 --- /dev/null +++ b/VERSIONS_HOTLINE/60547 @@ -0,0 +1 @@ + - ticket #60547 : Cosmogramme : correction d'erreurs dans les écrans de configuration des intégrations, d'analyse de fichier unimarc et de modifications des codifications Dewey et PCDM4 \ No newline at end of file diff --git a/cosmogramme/php/classes/classe_dewey.php b/cosmogramme/php/classes/classe_dewey.php index 166f43b3218517159a81af4f92b2cd6fbe82f467..407d1301679969607c447f2d677aaa09557134bc 100644 --- a/cosmogramme/php/classes/classe_dewey.php +++ b/cosmogramme/php/classes/classe_dewey.php @@ -16,152 +16,143 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -//////////////////////////////////////////////////////////////////////////////////////// -// INDICES DEWEY -/////////////////////////////////////////////////////////////////////////////////////// - -class dewey -{ - -// ---------------------------------------------------------------- -// Dewey sans libelle -// ---------------------------------------------------------------- - public function getIndicesSanslibelle($indice, $limite) - { + +class dewey { + + public function getIndicesSanslibelle($indice, $limite) { global $sql; - $liste=array(); - if($indice) $where = "and id_dewey like '$indice%'"; - $handle=$sql->prepareListe("Select id_dewey from codif_dewey Where LENGTH(id_dewey)=$limite and libelle ='' ".$where." order by id_dewey"); - while( $indice=$sql->fetchNext($handle,true)) $liste[]=$this->formatIndice($indice); + $liste = []; + if ($indice) + $where = "and id_dewey like '$indice%'"; + + $handle = $sql->prepareListe("Select id_dewey from codif_dewey Where LENGTH(id_dewey)=$limite and libelle ='' ".$where." order by id_dewey"); + while ($indice = $sql->fetchNext($handle,true)) + $liste[] = $this->formatIndice($indice); + return $liste; } - -// ---------------------------------------------------------------- -// Rend une liste d'indices par niveau -// ---------------------------------------------------------------- + + static function getIndices($pere) { global $sql; - if ($pere == "root") - $liste=$sql->fetchAll("select * from codif_dewey where LENGTH(id_dewey)=1 order by id_dewey"); - else - { - $long=strlen($pere)+1; - $req="select * from codif_dewey where id_dewey like '$pere%' and LENGTH(id_dewey)=$long order by id_dewey"; - $liste =$sql->fetchAll($req); - } - return $liste; + if ($pere == "root") + return $sql->fetchAll("select * from codif_dewey where LENGTH(id_dewey)=1 order by id_dewey"); + + $long = strlen($pere)+1; + $req = "select * from codif_dewey where id_dewey like '$pere%' and LENGTH(id_dewey)=$long order by id_dewey"; + return $sql->fetchAll($req); } - -// ---------------------------------------------------------------- -// Ponctue un indice dewey -// ---------------------------------------------------------------- - static function formatIndice($indice) - { - if(strlen($indice)< 4) return $indice; - $new=""; - while(strlen($indice)>3) - { - $new.=substr($indice,0,3)."."; - $indice=substr($indice,3,strlen($indice)); + + + static function formatIndice($indice) { + if(strlen($indice)< 4) + return $indice; + + $new = ''; + while(strlen($indice) > 3) { + $new .= substr($indice,0,3) . "."; + $indice = substr($indice, 3, strlen($indice)); } - $new.=$indice; - return $new; + + return $new . $indice; } -// ---------------------------------------------------------------- -// Analyse et rend l'indice s'il est valide -// ---------------------------------------------------------------- - static function filtreIndice($indice) - { - $indice=trim($indice); - if(strlen($indice)>18) return false; - if(substr($indice,1,1) == ".") return ""; // si c'est de la pcdm4 on dégage - $new=""; - for($i=0; $i<strlen($indice); $i++) - { - $car=$indice[$i]; - if($car >="0" and $car<="9") $new.=$car; + + + static function filtreIndice($indice) { + $indice = trim($indice); + if(strlen($indice) > 18) + return false; + + if(substr($indice,1,1) == ".") + return ''; // si c'est de la pcdm4 on dégage + + $new = ''; + for($i=0; $i < strlen($indice); $i++) { + $car = $indice[$i]; + if ($car >= "0" and $car <= "9") + $new .= $car; } + return $new; } -// ---------------------------------------------------------------- -// Rend le libelle ou le code si le libelle est vide -// ---------------------------------------------------------------- - static function getLibelle($indice) - { + + + static function getLibelle($indice) { global $sql; - $libelle=$sql->fetchOne("select libelle from codif_dewey where id_dewey='$indice'"); - if(!$libelle) $libelle=dewey::formatIndice($indice)." - intitulé non renseigné"; + $libelle = $sql->fetchOne("select libelle from codif_dewey where id_dewey='$indice'"); + if(!$libelle) + $libelle = dewey::formatIndice($indice) . " - intitulé non renseigné"; + return $libelle; } - -// ---------------------------------------------------------------- -// Ecrit un indice dewey -// ---------------------------------------------------------------- - public function ecrire($indice, $libelle) - { + + + public function ecrire($indice, $libelle) { global $sql; - - $indice=trim($indice); - $indice=str_replace(".","",$indice); - $libelle=trim(str_replace("'","''",$libelle)); - if($indice=="") return false; - $controle=$sql->fetchOne("select count(*) from codif_dewey where id_dewey='$indice'"); - if($controle > 0) - { - // Maj du libelle - $sql->execute("Update codif_dewey set libelle='$libelle' Where id_dewey='$indice'"); - // Maj des mots-recherche pour le nouveau libelle - $this->majFulltext($indice); - } - else $sql->execute("insert into codif_dewey (id_dewey,libelle) Values('$indice','$libelle')"); + + $indice = trim($indice); + $indice = str_replace(".", "", $indice); + $libelle = trim(str_replace("'", "''", $libelle)); + if($indice == "") + return false; + + $controle = $sql->fetchOne("select count(*) from codif_dewey where id_dewey='$indice'"); + if (0 == $controle) { + $sql->execute("insert into codif_dewey (id_dewey,libelle) Values('$indice','$libelle')"); + return 1; + } + + // Maj du libelle + $sql->execute("Update codif_dewey set libelle='$libelle' Where id_dewey='$indice'"); + // Maj des mots-recherche pour le nouveau libelle + $this->majFulltext($indice); return 1; } - -// ---------------------------------------------------------------- -// Maj des mots facettes pour 1 indice -// ---------------------------------------------------------------- - public function majFulltext($indice) - { + + + public function majFulltext($indice) { global $sql; - require_once("classe_indexation.php"); + + require_once("classe_indexation.php"); $ix = new indexation(); - - // Verif parametres - $indice=trim($indice); - $indice=str_replace(".","",$indice); - $code="+D".$indice; - - // Get notices de cet indice - $liste=$sql->prepareListe("select id_notice,facettes from notices where match(facettes) against('".$code."' IN BOOLEAN MODE)"); - if(!$liste) return; - while($ligne=$sql->fetchNext($liste)) - { - $id_notice=$ligne["id_notice"]; - // recup id dewey et pcdm4 des facettes - $facette=explode(" ",$ligne["facettes"]); - for($i=0; $i < count($facette); $i++) - { - if(!$facette[$i]) continue; - if(substr($facette[$i],0,1) == "D") - { - $clef=substr($facette[$i],1); - $libelle=$sql->fetchOne("select libelle from codif_dewey where id_dewey='$clef'"); - $fulltext.=" ".$libelle; - } - elseif(substr($facette[$i],0,1) == "P") - { - $clef=substr($facette[$i],1); - $libelle=$sql->fetchOne("select libelle from codif_pcdm4 where id_pcdm4='$clef'"); - $fulltext.=" ".$libelle; - } - } - // Calcul nouveau fulltext et maj notice - $fulltext=$ix->getFulltext($fulltext); - $sql->execute("update notices set dewey='$fulltext' where id_notice=$id_notice"); - } + + $indice = trim($indice); + $indice = str_replace(".","",$indice); + $code = "+D".$indice; + + $liste = $sql->prepareListe("select id_notice,facettes from notices where match(facettes) against('".$code."' IN BOOLEAN MODE)"); + if(!$liste) + return; + + while($ligne = $sql->fetchNext($liste)) + $this->_updateRecord($ligne, $ix); } + + + protected function _updateRecord($ligne, $ix) { + global $sql; + + $id_notice = $ligne["id_notice"]; + $facets = explode(" ", $ligne["facettes"]); + foreach ($faces as $facet) { + if (!$facet) + continue; + + $code = substr($facet, 0, 1); + $map = ['D' => 'dewey', 'P' => 'pcdm4']; + if (!array_key_exists($code, $map)) + continue; + + $value = substr($facet, 1); + if ($libelle = $sql->fetchOne("select libelle from codif_". $map[$code] . " where id_" . $map[$code] . "='" . $value ."'")) + $fulltext .= ' ' . $libelle; + } + + $fulltext = $ix->getFulltext($fulltext); + $sql->execute("update notices set dewey='$fulltext' where id_notice=$id_notice"); + } } ?> \ No newline at end of file diff --git a/cosmogramme/php/classes/classe_log.php b/cosmogramme/php/classes/classe_log.php index a70e7bb30ade75360aa09712cf7cc16a53e40966..70f3b1052cf1a463f82e141c873f74d582ab4fff 100644 --- a/cosmogramme/php/classes/classe_log.php +++ b/cosmogramme/php/classes/classe_log.php @@ -18,9 +18,6 @@ * along with BOKEH; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -//////////////////////////////////////////////////////////////////////// -// LOGS -//////////////////////////////////////////////////////////////////////// class Class_log { use Trait_Translator; @@ -32,34 +29,33 @@ class Class_log { private $afficher; // Afficher à l'écran ou pas private $entete; // Entetes pour les logs de type tableau -// ---------------------------------------------------------------- -// Contructeur -// ---------------------------------------------------------------- - function __construct($typeLog,$afficher=true) - { + + public function __construct($typeLog,$afficher=true) { $this->typeLog = $typeLog; $this->afficher=$afficher; $this->path = getVariable("log_path"); - if(!$this->path) afficherErreur("La variable : log_path n'est pas définie."); - if( strRight($this->path,1) != "/" ) $this->path .="/"; - $this->maxLog=getVariable("log_max"); - if(!$this->maxLog) $this->maxLog=100; + if(!$this->path) + afficherErreur("La variable : log_path n'est pas définie."); + + if (strRight($this->path,1) != "/" ) + $this->path .="/"; + + $this->maxLog = getVariable("log_max"); + if(!$this->maxLog) + $this->maxLog=100; // Entetes - if($typeLog=="erreur") $this->entete=array("n°","Bibliothèque","Type d'opération","Erreur"); - elseif($typeLog=="warning") $this->entete=array("n°","Bibliothèque","Type d'opération","Alerte","Valeur"); + if($typeLog=="erreur") + $this->entete = ["n°", "Bibliothèque", "Type d'opération", "Erreur"]; + elseif($typeLog=="warning") + $this->entete = ["n°", "Bibliothèque", "Type d'opération", "Alerte", "Valeur"]; } -// ---------------------------------------------------------------- -// Ouverture fichier -// ---------------------------------------------------------------- + public function open($append=0) { - // Controle de l'historique - if($append==0) { + if($append==0) $this->_removeOldLogs(); - } - // Ouverture du nouveau log $nom = $this->path . $this->typeLog . "_" . dateDuJour(0) .".log"; $mode='a'; // test en mode append systematique umask(0002); @@ -69,61 +65,68 @@ class Class_log { protected function _removeOldLogs() { - @$dir = opendir( $this->path) or AfficherErreur("Impossible d'ouvrir le dossier des logs : " .$this->path); + @$dir = opendir($this->path) or afficherErreur("Impossible d'ouvrir le dossier des logs : " .$this->path); - while (($file = readdir($dir)) !== false) { - if(strLeft($file, strLen($this->typeLog))== $this->typeLog) $liste[]=$file; - } + while (($file = readdir($dir)) !== false) + if(strLeft($file, strLen($this->typeLog))== $this->typeLog) + $liste[]=$file; closedir( $dir); - if( count($liste) > $this->maxLog ) { - $nb_destroy=count($liste)-$this->maxLog; - sort($liste); - for($i=0; $i < $nb_destroy; $i++) { - unlink($this->path .$liste[$i]); - if($this->typeLog != "sql") @unlink($this->path.str_replace($this->typeLog,"notice",$liste[$i])); - } - } + if (count($liste) <= $this->maxLog) + return; + + $nb_destroy = count($liste)-$this->maxLog; + sort($liste); + for ($i=0; $i < $nb_destroy; $i++) + $this->_removeLog($liste[$i]); + } + + + protected function _removeLog($file) { + unlink($this->path . $file); + if($this->typeLog != "sql") + @unlink($this->path . str_replace($this->typeLog, "notice", $file)); } -// ---------------------------------------------------------------- -// Ecrire -// ---------------------------------------------------------------- + public function log($texte) { global $mode_cron; - fwrite($this->fic, $texte ."\n"); - if($this->afficher == false) return false; - if($mode_cron) { - $texte=strip_tags($texte); - if(trim($texte)) print($texte ."\n"); - } - else + fwrite($this->fic, $texte . "\n"); + if (!$this->afficher) + return false; + + if (!$mode_cron) { print($texte); + flush(); + return; + } + + $texte = strip_tags($texte); + if(trim($texte)) + print($texte ."\n"); flush(); } -// ---------------------------------------------------------------- -// Taille des logs -// ---------------------------------------------------------------- - public function getTailleLogs() - { - // Parse directory - @$dir = opendir( $this->path) or AfficherErreur("Impossible d'ouvrir le dossier des logs : " .$this->path); - $taille=0; - $nb_fic=0; - while (($file = readdir($dir)) !== false) - { - $fic=$this->path.$file; - if(!is_file($fic)) continue; - $nb_fic++; - $taille+=filesize($fic); - } - $ret["nb_fic"]=$nb_fic; - $ret["taille"]=(int)($taille / 1024); - $ret["taille"]=number_format($ret["taille"], 0, ',', ' ')." ko"; + + public function getTailleLogs() { + @$dir = opendir( $this->path) or afficherErreur("Impossible d'ouvrir le dossier des logs : " . $this->path); + $taille = 0; + $nb_fic = 0; + while (($file = readdir($dir)) !== false) { + $fic = $this->path . $file; + if(!is_file($fic)) + continue; + + $nb_fic++; + $taille += filesize($fic); + } + + $ret["nb_fic"] = $nb_fic; + $ret["taille"] = (int)($taille / 1024); + $ret["taille"] = number_format($ret["taille"], 0, ',', ' ')." ko"; return $ret; } diff --git a/cosmogramme/php/classes/classe_pcdm4.php b/cosmogramme/php/classes/classe_pcdm4.php index 6ab4724e9e1518dd29ef38aad21d6e75e3f2d195..7ea29b3e683ffb57d105777e7d2b1943132f7cea 100644 --- a/cosmogramme/php/classes/classe_pcdm4.php +++ b/cosmogramme/php/classes/classe_pcdm4.php @@ -16,143 +16,139 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -//////////////////////////////////////////////////////////////////////////////////////// -// INDICES PCDM4 -/////////////////////////////////////////////////////////////////////////////////////// - -class pcdm4 -{ - -// ---------------------------------------------------------------- -// Pcdm4 sans libelle -// ---------------------------------------------------------------- - public function getIndicesSanslibelle($indice, $limite) - { + +class pcdm4 { + public function getIndicesSanslibelle($indice, $limite) { global $sql; - $liste=array(); - if($indice) $where = "and id_pcdm4 like '$indice%'"; - $handle=$sql->prepareListe("Select distinct SUBSTRING(id_pcdm4, 1, $limite) from codif_pcdm4 Where libelle ='' ".$where." order by id_pcdm4"); - while( $indice=$sql->fetchNext($handle,true)) $liste[]=$this->formatIndice($indice); + + $liste=[]; + if($indice) + $where = "and id_pcdm4 like '$indice%'"; + + $handle = $sql->prepareListe("Select distinct SUBSTRING(id_pcdm4, 1, $limite) from codif_pcdm4 Where libelle ='' ".$where." order by id_pcdm4"); + while( $indice=$sql->fetchNext($handle,true)) + $liste[]=$this->formatIndice($indice); + return $liste; } -// ---------------------------------------------------------------- -// Rend une liste d'indices par niveau -// ---------------------------------------------------------------- - static function getIndices($pere) - { + + + static function getIndices($pere) { global $sql; - if($pere == "root") $liste=$sql->fetchAll("select * from codif_pcdm4 where LENGTH(id_pcdm4)=1 order by id_pcdm4"); - else - { - $long=strlen($pere)+1; - $req="select * from codif_pcdm4 where id_pcdm4 like '$pere%' and LENGTH(id_pcdm4)=$long order by id_pcdm4"; - $liste =$sql->fetchAll($req); - } - return $liste; + + if ($pere == "root") + return $sql->fetchAll("select * from codif_pcdm4 where LENGTH(id_pcdm4)=1 order by id_pcdm4"); + + $long = strlen($pere)+1; + $req = "select * from codif_pcdm4 where id_pcdm4 like '$pere%' and LENGTH(id_pcdm4)=$long order by id_pcdm4"; + return $sql->fetchAll($req); } -// ---------------------------------------------------------------- -// Ponctue un indice pcdm4 -// ---------------------------------------------------------------- - static function formatIndice($indice) - { - if(strlen($indice)< 2) return $indice; - $new=substr($indice,0,1).".".substr($indice,1); + + + static function formatIndice($indice) { + if(strlen($indice)< 2) + return $indice; + + $new = substr($indice,0,1).".".substr($indice,1); return $new; } -// ---------------------------------------------------------------- -// Analyse et rend l'indice s'il est valide -// ---------------------------------------------------------------- - static function filtreIndice($indice) - { - $indice=trim($indice); - if(!is_numeric(substr($indice,0,1))) return ""; - if(strlen($indice) > 1 and substr($indice,1,1) != ".") return ""; - $new=""; - for($i=0; $i<strlen($indice); $i++) - { + + + static function filtreIndice($indice) { + $indice = trim($indice); + if(!is_numeric(substr($indice,0,1))) + return ""; + + if(strlen($indice) > 1 and substr($indice,1,1) != ".") + return ""; + + $new = ""; + for($i=0; $i<strlen($indice); $i++) { $car=$indice[$i]; - if($car >="0" and $car<="9") $new.=$car; + if($car >="0" and $car<="9") + $new.=$car; } + return $new; } -// ---------------------------------------------------------------- -// Rend le libelle ou le code si le libelle est vide -// ---------------------------------------------------------------- - static function getLibelle($indice) - { + + + static function getLibelle($indice) { global $sql; - $libelle=$sql->fetchOne("select libelle from codif_pcdm4 where id_pcdm4='$indice'"); - if(!$libelle) $libelle=pcdm4::formatIndice($indice); + + if(!$libelle = $sql->fetchOne("select libelle from codif_pcdm4 where id_pcdm4='$indice'")) + $libelle = pcdm4::formatIndice($indice); + return $libelle; } -// ---------------------------------------------------------------- -// Ecrit un indice pcdm4 -// ---------------------------------------------------------------- - public function ecrire($indice, $libelle) - { + + + public function ecrire($indice, $libelle) { global $sql; - - $indice=trim($indice); - $indice=str_replace(".","",$indice); - $libelle=trim(str_replace("'","''",$libelle)); - if($indice=="") return false; - $controle=$sql->fetchOne("select count(*) from codif_pcdm4 where id_pcdm4='$indice'"); - if($controle > 0) - { - // Maj du libelle - $sql->execute("Update codif_pcdm4 set libelle='$libelle' Where id_pcdm4='$indice'"); - // Maj des mots-recherche pour le nouveau libelle - $this->majFulltext($indice); - } - else $sql->execute("insert into codif_pcdm4 (id_pcdm4,libelle) Values('$indice','$libelle')"); + + $indice = trim($indice); + $indice = str_replace(".","",$indice); + $libelle = trim(str_replace("'","''",$libelle)); + if($indice=="") + return false; + + $controle = $sql->fetchOne("select count(*) from codif_pcdm4 where id_pcdm4='$indice'"); + if (0 == $controle) { + $sql->execute("insert into codif_pcdm4 (id_pcdm4,libelle) Values('$indice','$libelle')"); + return 1; + } + + $sql->execute("Update codif_pcdm4 set libelle='$libelle' Where id_pcdm4='$indice'"); + $this->majFulltext($indice); + return 1; } - -// ---------------------------------------------------------------- -// Maj des mots facettes pour 1 indice -// ---------------------------------------------------------------- - public function majFulltext($indice) - { + + + public function majFulltext($indice) { global $sql; + require_once("classe_indexation.php"); $ix = new indexation(); - - // Verif parametres - $indice=trim($indice); - $indice=str_replace(".","",$indice); - $code="+P".$indice; - - // Get notices de cet indice - $liste=$sql->prepareListe("select id_notice,facettes from notices where match(facettes) against('".$code."' IN BOOLEAN MODE)"); - if(!$liste) return; - while($ligne=$sql->fetchNext($liste)) - { - $id_notice=$ligne["id_notice"]; - // recup id dewey et pcdm4 des facettes - $facette=explode(" ",$ligne["facettes"]); - for($i=0; $i < count($facette); $i++) - { - if(!$facette[$i]) continue; - if(substr($facette[$i],0,1) == "D") - { - $clef=substr($facette[$i],1); - $libelle=$sql->fetchOne("select libelle from codif_dewey where id_dewey='$clef'"); - $fulltext.=" ".$libelle; - } - elseif(substr($facette[$i],0,1) == "P") - { - $clef=substr($facette[$i],1); - $libelle=$sql->fetchOne("select libelle from codif_pcdm4 where id_pcdm4='$clef'"); - $fulltext.=" ".$libelle; - } - } - // Calcul nouveau fulltext et maj notice - $fulltext=$ix->getFulltext($fulltext); - $sql->execute("update notices set dewey='$fulltext' where id_notice=$id_notice"); - } + + // Verif parametres + $indice = trim($indice); + $indice = str_replace(".","",$indice); + $code = "+P" . $indice; + + $liste = $sql->prepareListe("select id_notice,facettes from notices where match(facettes) against('".$code."' IN BOOLEAN MODE)"); + if(!$liste) + return; + + while($ligne = $sql->fetchNext($liste)) + $this->_updateRecord($ligne, $ix); } + + + protected function _updateRecord($ligne, $ix) { + global $sql; + + $id_notice = $ligne["id_notice"]; + $facets = explode(" ", $ligne["facettes"]); + foreach ($faces as $facet) { + if (!$facet) + continue; + + $code = substr($facet, 0, 1); + $map = ['D' => 'dewey', 'P' => 'pcdm4']; + if (!array_key_exists($code, $map)) + continue; + + $value = substr($facet, 1); + if ($libelle = $sql->fetchOne("select libelle from codif_". $map[$code] . " where id_" . $map[$code] . "='" . $value ."'")) + $fulltext .= ' ' . $libelle; + } + + $fulltext = $ix->getFulltext($fulltext); + $sql->execute("update notices set dewey='$fulltext' where id_notice=$id_notice"); + } } ?> \ No newline at end of file diff --git a/cosmogramme/php/codif_dewey.php b/cosmogramme/php/codif_dewey.php index 647743cb3d0285c8c83d88ceb86f24d33d21a6a8..e2099430c4bce827af23775c7e016d0961c41b68 100644 --- a/cosmogramme/php/codif_dewey.php +++ b/cosmogramme/php/codif_dewey.php @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /////////////////////////////////////////////////////////////////// // @@ -26,7 +26,7 @@ include("_init_frame.php"); require_once("classe_dewey.php"); -$dewey=new dewey(); +$dewey = new dewey(); extract($_POST); ?> @@ -41,9 +41,9 @@ extract($_POST); { oChampRetour=document.getElementById("indice_a_ecrire"); chaine=""; - for (var i=0;i<document.getElementsByName("selection").length;i++) + for (var i=0;i<document.getElementsByName("selection").length;i++) { - if (document.getElementsByName("selection")[i].checked==true) + if (document.getElementsByName("selection")[i].checked==true) { if(chaine > '') chaine=chaine+";"; chaine=chaine+document.getElementsByName("selection")[i].id; @@ -77,7 +77,7 @@ if($_REQUEST["action"]=="") print('<td><input type ="text" name="nbdec" value="3" size="3" align="left"></td>'); print('</tr>'); print('</table></form>'.BR); - + $url="codif_dewey.php?action=MAJ"; print('<form id="suppression" method="post" action="'.$url.'">'); print('<table width="60%" cellspacing="0">'); @@ -93,7 +93,7 @@ if($_REQUEST["action"]=="") print('<td><input type ="text" name="commencepar" value="" size="7" align="left"></td>'); print('</tr>'); print('</table></form>'.BR); - + $url="codif_dewey.php?action=SUPPRESSION"; print('<form id="suppression" method="post" action="'.$url.'">'); print('<table width="60%" cellspacing="0">'); @@ -109,7 +109,7 @@ if($_REQUEST["action"]=="") print('<td><input type ="text" name="commencepar" value="" size="7" align="left"></td>'); print('</tr>'); print('</table></form>'.BR); - + $url="codif_dewey.php?action=CONSOLIDATION"; print('<form id="consolidation" method="post" action="'.$url.'">'); print('<table width="60%" cellspacing="0">'); @@ -131,7 +131,7 @@ if($_REQUEST["action"]=="") print('<td colspan="2">Cette fonction créee les niveaux intermédiaires pour un bon fonctionnement de la recherche guidée</td>'); print('</tr>'); print('</table></form>'.BR); - + } // ---------------------------------------------------------------- @@ -171,13 +171,13 @@ if($_REQUEST["action"]=="ECRIRE_LISTE") $controle=$sql->fetchOne("select count(*) from codif_dewey where id_dewey='$indice'"); if($controle) { - if($_REQUEST["remplacer"] == "on") + if($_REQUEST["remplacer"] == "on") { - $mode="Remplacement"; - $majs+=$dewey->log($indice,$libelle); + $mode="Remplacement"; + $majs+=$dewey->ecrire($indice,$libelle); } else {$mode="Pas de traitement car existe déjà "; $pas_traites++;} - } + } else {$mode="Création"; $creations++; $sql->insert("codif_dewey",array("id_dewey"=>$indice,"libelle"=>$libelle));} print('<span class="violet" style="margin-left:20px"><b>'.$indice.' : </b></span><span>'.$mode.'</span>'.BR); } @@ -198,7 +198,7 @@ if($_REQUEST["action"]=="MAJ") print('<form method="POST" action="'.$url.'">'); print('<input type="hidden" id="indice_a_ecrire" name="indice_a_ecrire">'); print('<table>'); - + $req="Select id_dewey,libelle from codif_dewey "; if($nbdec >0) $where=" Where LENGTH(id_dewey)<= $nbdec"; if($commencepar > "") @@ -209,7 +209,7 @@ if($_REQUEST["action"]=="MAJ") $req.= $where." order by id_dewey"; $result=$sql->prepareListe($req); if($result) - { + { While($ret=$sql->fetchNext($result)) { print('<tr><td>'.$dewey->formatIndice($ret["id_dewey"]).'</td><td><input type="text" size="70" onblur="give_libelle(\''.$ret["id_dewey"].'\',this.value)" value="'.$ret["libelle"].'"></td></tr>'); @@ -232,7 +232,7 @@ if($_REQUEST["action"]=="SUPPRESSION") print('<form method="POST" action="'.$url.'">'); print('<input type="hidden" id="indice_a_ecrire" name="indice_a_ecrire">'); print('<table>'); - + $req="Select id_dewey,libelle from codif_dewey"; if($nbdec >0) $where=" Where LENGTH(id_dewey)<= $nbdec"; if($commencepar > "") @@ -243,7 +243,7 @@ if($_REQUEST["action"]=="SUPPRESSION") $req.= $where; $result=$sql->prepareListe($req); if($result) - { + { While($ret=$sql->fetchNext($result)) { print('<tr>'); @@ -287,7 +287,7 @@ if($_REQUEST["action"]=="NOLIB") print('<form method="POST" action="'.$url.'">'); print('<input type="hidden" id="indice_a_ecrire" name="indice_a_ecrire">'); print('<table>'); - + $ret=$dewey->getIndicesSanslibelle("",$nbdec); for($i=0; $i<count($ret); $i++) { @@ -299,7 +299,7 @@ if($_REQUEST["action"]=="NOLIB") } // ---------------------------------------------------------------- -// ECRITURE DES LIBELLES +// ECRITURE DES LIBELLES // ---------------------------------------------------------------- if($_REQUEST["action"]=="ECRIRE") { @@ -316,7 +316,7 @@ if($_REQUEST["action"]=="ECRIRE") { $elem=explode("#",$liste[$i]); print($elem[0]." - " .$elem[1]."<br>"); - $nb+=$dewey->log($elem[0],$elem[1]); + $nb+=$dewey->ecrire($elem[0],$elem[1]); } print("<br><h3>".$nb. " indice(s) ont été mis à jour avec succès.</h3>"); } @@ -354,4 +354,3 @@ if($_REQUEST["action"]=="NIVEAUX") </center></div> </body> </html> - diff --git a/cosmogramme/php/codif_pcdm4.php b/cosmogramme/php/codif_pcdm4.php index 86fb173e8115881a2a93b541a005aac49daea128..ae148ad61b42959beb73c91db2c121d14cb9f092 100644 --- a/cosmogramme/php/codif_pcdm4.php +++ b/cosmogramme/php/codif_pcdm4.php @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /////////////////////////////////////////////////////////////////// // @@ -41,9 +41,9 @@ extract($_POST); { oChampRetour=document.getElementById("indice_a_ecrire"); chaine=""; - for (var i=0;i<document.getElementsByName("selection").length;i++) + for (var i=0;i<document.getElementsByName("selection").length;i++) { - if (document.getElementsByName("selection")[i].checked==true) + if (document.getElementsByName("selection")[i].checked==true) { if(chaine > '') chaine=chaine+";"; chaine=chaine+document.getElementsByName("selection")[i].id; @@ -64,7 +64,7 @@ if($_REQUEST["action"]=="") $nb1=$sql->fetchOne("Select count(*) from codif_pcdm4 where libelle=''" ); print('<span class="orange"><b>La base contient '.number_format($nb, 0, ',', ' ').' fiches pcdm4</b></span>'.BR); print('<span class="orange"><b>Libellés non renseignés : '.number_format($nb1, 0, ',', ' ').'</b></span>'.BR.BR); - + print('<div class="liste">'); $url="codif_pcdm4.php?action=NOLIB"; @@ -77,8 +77,8 @@ if($_REQUEST["action"]=="") print('<td align="right">Nombre de décimales: </td>'); print('<td><input type ="text" name="nbdec" value="3" size="3" align="left"></td>'); print('</tr>'); - print('</table></form>'); - + print('</table></form>'); + $url="codif_pcdm4.php?action=MAJ"; print('<tr><form id="suppression" method="post" action="'.$url.'">'); print('<table width="60%" cellspacing="0">'); @@ -93,8 +93,8 @@ if($_REQUEST["action"]=="") print('<td align="right">Indices commencent par: </td>'); print('<td><input type ="text" name="commencepar" value="" size="7" align="left"></td>'); print('</tr>'); - print('</table></form>'); - + print('</table></form>'); + $url="codif_pcdm4.php?action=SUPPRESSION"; print('<tr><form id="suppression" method="post" action="'.$url.'">'); print('<table width="60%" cellspacing="0">'); @@ -110,7 +110,7 @@ if($_REQUEST["action"]=="") print('<td><input type ="text" name="commencepar" value="" size="7" align="left"></td>'); print('</tr>'); print('</table></form>'); - + $url="codif_pcdm4.php?action=CONSOLIDATION"; print('<tr><form id="consolidation" method="post" action="'.$url.'">'); print('<table width="60%" cellspacing="0">'); @@ -121,7 +121,7 @@ if($_REQUEST["action"]=="") print('<td colspan="2" align="center"><input type ="checkbox" name="remplacer">Remplacer les libellés présents dans la base</td>'); print('</tr>'); print('</table></form>'); - + } // ---------------------------------------------------------------- @@ -161,13 +161,13 @@ if($_REQUEST["action"]=="ECRIRE_LISTE") $controle=$sql->fetchOne("select count(*) from codif_pcdm4 where id_pcdm4='$indice'"); if($controle) { - if($_REQUEST["remplacer"] == "on") + if($_REQUEST["remplacer"] == "on") { - $mode="Remplacement"; - $majs+=$pcdm4->log($indice,$libelle); + $mode="Remplacement"; + $majs+=$pcdm4->ecrire($indice,$libelle); } else {$mode="Pas de traitement car existe déjà "; $pas_traites++;} - } + } else {$mode="Création"; $creations++; $sql->insert("codif_pcdm4",array("id_pcdm4"=>$indice,"libelle"=>$libelle));} print('<span class="violet" style="margin-left:20px"><b>'.$indice.' : </b></span><span>'.$mode.'</span>'.BR); } @@ -188,7 +188,7 @@ if($_REQUEST["action"]=="MAJ") print('<form method="POST" action="'.$url.'">'); print('<input type="hidden" id="indice_a_ecrire" name="indice_a_ecrire">'); print('<table>'); - + $req="Select id_pcdm4,libelle from codif_pcdm4"; if($nbdec >0) $where=" Where LENGTH(id_pcdm4)<= $nbdec"; if($commencepar > "") @@ -199,7 +199,7 @@ if($_REQUEST["action"]=="MAJ") $req.= $where ." order by id_pcdm4"; $result=$sql->prepareListe($req); if($result) - { + { While($ret=$sql->fetchNext($result)) { print('<tr><td>'.$pcdm4->formatIndice($ret["id_pcdm4"]).'</td><td><input type="text" size="70" onblur="give_libelle(\''.$ret["id_pcdm4"].'\',this.value)" value="'.$ret["libelle"].'"></td></tr>'); @@ -222,7 +222,7 @@ if($_REQUEST["action"]=="SUPPRESSION") print('<form method="POST" action="'.$url.'">'); print('<input type="hidden" id="indice_a_ecrire" name="indice_a_ecrire">'); print('<table>'); - + $req="Select id_pcdm4,libelle from codif_pcdm4"; if($nbdec >0) $where=" Where LENGTH(id_pcdm4)<= $nbdec"; if($commencepar > "") @@ -233,7 +233,7 @@ if($_REQUEST["action"]=="SUPPRESSION") $req.= $where." order by id_pcdm4"; $result=$sql->prepareListe($req); if($result) - { + { While($ret=$sql->fetchNext($result)) { print('<tr>'); @@ -277,7 +277,7 @@ if($_REQUEST["action"]=="NOLIB") print('<form method="POST" action="'.$url.'">'); print('<input type="hidden" id="indice_a_ecrire" name="indice_a_ecrire">'); print('<table>'); - + $ret=$pcdm4->getIndicesSanslibelle("",$nbdec); for($i=0; $i<count($ret); $i++) { @@ -289,7 +289,7 @@ if($_REQUEST["action"]=="NOLIB") } // ---------------------------------------------------------------- -// ECRITURE DES LIBELLES +// ECRITURE DES LIBELLES // ---------------------------------------------------------------- if($_REQUEST["action"]=="ECRIRE") { @@ -306,7 +306,7 @@ if($_REQUEST["action"]=="ECRIRE") { $elem=explode("#",$liste[$i]); print($elem[0]." - " .$elem[1]."<br>"); - $nb+=$pcdm4->log($elem[0],$elem[1]); + $nb+=$pcdm4->ecrire($elem[0],$elem[1]); } print("<br><h3>".$nb. " indice(s) ont été mis à jour avec succès.</h3>"); } @@ -317,4 +317,3 @@ if($_REQUEST["action"]=="ECRIRE") </center></div> </body> </html> - diff --git a/cosmogramme/php/config_integrations.php b/cosmogramme/php/config_integrations.php index 270a4991705e19954c932308eee251802c574876..ba9ec0f99c545db5bad5647784bf734d25cad029 100644 --- a/cosmogramme/php/config_integrations.php +++ b/cosmogramme/php/config_integrations.php @@ -66,7 +66,7 @@ if($_REQUEST["action"]=="VALIDER") // ecriture require_once("classe_bib.php"); $ficheBib = new bibliotheque(); - $ficheBib->log($id_bib,$nom_court,$mail,$qualite,$ecart_ajouts,$sigb,$comm_sigb,$comm_params,$pas_exporter); + $ficheBib->ecrire($id_bib,$nom_court,$mail,$qualite,$ecart_ajouts,$sigb,$comm_sigb,$comm_params,$pas_exporter); $id_prog=0; } @@ -74,7 +74,7 @@ if($_REQUEST["action"]=="VALIDER") else { $id_prog=$_REQUEST["id"]; - $maj->log($id_prog,$id_bib,$libelle,$profil,$type_operation,$fichier,$rang,$type_doc,(int)$taille_min_import_total); + $maj->ecrire($id_prog,$id_bib,$libelle,$profil,$type_operation,$fichier,$rang,$type_doc,(int)$taille_min_import_total); if($id_prog == 0 ) { $ret=$maj->getDerniereCreation(); diff --git a/cosmogramme/php/integre_analyse_fichier_unimarc.php b/cosmogramme/php/integre_analyse_fichier_unimarc.php index 446c2a0ed4d65993b84dde6c354f7d23bc51095d..78278d93c84021d6df55f8773e2a3976b7b5ddf8 100644 --- a/cosmogramme/php/integre_analyse_fichier_unimarc.php +++ b/cosmogramme/php/integre_analyse_fichier_unimarc.php @@ -1,4 +1,4 @@ -<?PHP +<?php /** * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. * @@ -18,28 +18,26 @@ * along with BOKEH; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -///////////////////////////////////////////////////////////////////////// -// TEST D'UN FICHIER UNIMARC -///////////////////////////////////////////////////////////////////////// + include("_init_frame.php"); print('<h1>Analyse de fichier unimarc</h1>'); // Redirection pour le mode synthèse if($_POST["test_level"]==3) { - setVariable("test_level",3); - redirection(URL_BASE."php/integre_analyse_fichier_synthese.php?action=INIT&fichier=".$_POST["fichier"]."&profil=".$_POST["profil_unimarc"]); + setVariable("test_level",3); + redirection(URL_BASE."php/integre_analyse_fichier_synthese.php?action=INIT&fichier=".$_POST["fichier"]."&profil=".$_POST["profil_unimarc"]); } // Redirection pour le mode : valeurs distinctes if($_POST["test_level"]==4) { - setVariable("test_level",4); - if(controleChampsDistinct()==false) - { - afficherErreur('Les champs a analyser sont mal définis !',false); - $_REQUEST["action"]="PARAM"; - } - else redirection(URL_BASE."php/integre_analyse_fichier_valeurs_distinctes.php?action=INIT&fichier=".$_POST["fichier"]."&profil=".$_POST["profil_unimarc"]."&distinct=".$_POST["distinct"]); + setVariable("test_level",4); + if(controleChampsDistinct()==false) + { + afficherErreur('Les champs a analyser sont mal définis !',false); + $_REQUEST["action"]="PARAM"; + } + else redirection(URL_BASE."php/integre_analyse_fichier_valeurs_distinctes.php?action=INIT&fichier=".$_POST["fichier"]."&profil=".$_POST["profil_unimarc"]."&distinct=".$_POST["distinct"]); } // Includes @@ -59,33 +57,33 @@ $buffer = new buffer(); // ---------------------------------------------------------------- if($_REQUEST["action"]=="PARAM") { - require("fonctions/objets_saisie.php"); - //print(BR.'<div class="liste"><p>NB : Les fichiers à analyser doivent être téléchargés dans le sous-dossier "test" du dossier de transfert ftp des notices.</p></div>'.BR); - print('<div class="liste">'); - print('<form method="post" action="'.URL_BASE.'php/integre_analyse_fichier_unimarc.php">'); - print('<table class="form" width="100%" cellspacing="0" cellpadding="5">'); - print('<tr><th class="form" colspan="2" align="left">Fichier à analyser</th></tr>'); - print('<tr><td class="form_first" align="right" width="40%">Fichier</td><td class="form_first">'.getComboFichiers().'</td></tr>'); - print('<tr><td class="form" align="right" width="40%">Profil unimarc</td><td class="form_first">'.getComboTable("profil_unimarc","profil_donnees","id_profil",1,"where format in(0,6)").'</td></tr>'); - print('<tr><td class="form" align="right" width="40%">Mode d\'affichage</td><td class="form_first">'.getComboCodif("test_level","test_level",getVariable("test_level")).'</td></tr>'); - print('<tr><td class="form" align="right" width="40%">Valeurs distinctes (ex: 995$a;210$b)</td><td class="form_first">'.getChamp("distinct",$_REQUEST["distinct"],"60").'</td></tr>'); + require("fonctions/objets_saisie.php"); + //print(BR.'<div class="liste"><p>NB : Les fichiers à analyser doivent être téléchargés dans le sous-dossier "test" du dossier de transfert ftp des notices.</p></div>'.BR); + print('<div class="liste">'); + print('<form method="post" action="'.URL_BASE.'php/integre_analyse_fichier_unimarc.php">'); + print('<table class="form" width="100%" cellspacing="0" cellpadding="5">'); + print('<tr><th class="form" colspan="2" align="left">Fichier à analyser</th></tr>'); + print('<tr><td class="form_first" align="right" width="40%">Fichier</td><td class="form_first">'.getComboFichiers().'</td></tr>'); + print('<tr><td class="form" align="right" width="40%">Profil unimarc</td><td class="form_first">'.getComboTable("profil_unimarc","profil_donnees","id_profil",1,"where format in(0,6)").'</td></tr>'); + print('<tr><td class="form" align="right" width="40%">Mode d\'affichage</td><td class="form_first">'.getComboCodif("test_level","test_level",getVariable("test_level")).'</td></tr>'); + print('<tr><td class="form" align="right" width="40%">Valeurs distinctes (ex: 995$a;210$b)</td><td class="form_first">'.getChamp("distinct",$_REQUEST["distinct"],"60").'</td></tr>'); - print('<tr><th class="form" colspan="2" align="left">Piéger des notices</th></tr>'); + print('<tr><th class="form" colspan="2" align="left">Piéger des notices</th></tr>'); - $liste[""]=""; - $tdocs=getCodifsVariable("types_docs"); - foreach($tdocs as $td)$liste[$td["code"]]=$td["libelle"]; - unset($liste["0"]); - $liste["100"]="article de périodique"; - print('<tr><td class="form_first" align="right" width="40%">Type de document</td><td class="form_first">'.getComboSimple("piege_type_doc","",$liste,"").'</td></tr>'); - print('<tr><td class="form_first" align="right" width="40%">n° de notice</td><td class="form_first">'.getChamp("piege_numero","","5").'</td></tr>'); - print('<tr><td class="form_first" align="right" width="40%">Titre</td><td class="form_first">'.getChamp("piege_titre","","50").'</td></tr>'); - print('<tr><td class="form_first" align="right" width="40%">Code-barres</td><td class="form_first">'.getChamp("piege_code_barres","","30").'</td></tr>'); - print('<tr><td class="form_first" align="right" width="40%">Isbn</td><td class="form_first">'.getChamp("piege_isbn","","30").'</td></tr>'); - print('<tr><td class="form_first" align="right" width="40%">Mémoriser l\'unimarc</td><td class="form_first"><input type="checkbox" name="pave_unimarc" value="1"></td></tr></td></tr>'); - print('<tr><th class="form" colspan="2" align="center"><input type="submit" class="bouton" value="Lancer"></th></tr>'); - print('</table></form></div></div>'); - exit; + $liste[""]=""; + $tdocs=getCodifsVariable("types_docs"); + foreach($tdocs as $td)$liste[$td["code"]]=$td["libelle"]; + unset($liste["0"]); + $liste["100"]="article de périodique"; + print('<tr><td class="form_first" align="right" width="40%">Type de document</td><td class="form_first">'.getComboSimple("piege_type_doc","",$liste,"").'</td></tr>'); + print('<tr><td class="form_first" align="right" width="40%">n° de notice</td><td class="form_first">'.getChamp("piege_numero","","5").'</td></tr>'); + print('<tr><td class="form_first" align="right" width="40%">Titre</td><td class="form_first">'.getChamp("piege_titre","","50").'</td></tr>'); + print('<tr><td class="form_first" align="right" width="40%">Code-barres</td><td class="form_first">'.getChamp("piege_code_barres","","30").'</td></tr>'); + print('<tr><td class="form_first" align="right" width="40%">Isbn</td><td class="form_first">'.getChamp("piege_isbn","","30").'</td></tr>'); + print('<tr><td class="form_first" align="right" width="40%">Mémoriser l\'unimarc</td><td class="form_first"><input type="checkbox" name="pave_unimarc" value="1"></td></tr></td></tr>'); + print('<tr><th class="form" colspan="2" align="center"><input type="submit" class="bouton" value="Lancer"></th></tr>'); + print('</table></form></div></div>'); + exit; } // ---------------------------------------------------------------- @@ -93,9 +91,9 @@ if($_REQUEST["action"]=="PARAM") // ---------------------------------------------------------------- if($_REQUEST["action"]=="AFFICHER") { - $buffer->afficher($_REQUEST["page"]); - print('</body></html>'); - exit; + $buffer->afficher($_REQUEST["page"]); + print('</body></html>'); + exit; } // ---------------------------------------------------------------- // Initialisations @@ -124,19 +122,19 @@ $avance=-1; if($_REQUEST["reprise"]=="oui") restaureContext(); else { - $buffer->open(false); - $timeStart = time(); - $buffer->log('<h4>Début de l\'analyse</h4>'); - $buffer->log('Fichier : '.$fichier.BR); - $buffer->log('Profil unimarc : '.$sql->fetchOne("select libelle from profil_donnees where id_profil=$profil_unimarc").BR); - $buffer->log('Affichage : '.getLibCodifVariable("test_level",$test_level).BR); - $buffer->log('Heure : '.date("G:i:s").BR.BR); + $buffer->open(false); + $timeStart = time(); + $buffer->ecrire('<h4>Début de l\'analyse</h4>'); + $buffer->ecrire('Fichier : '.$fichier.BR); + $buffer->ecrire('Profil unimarc : '.$sql->fetchOne("select libelle from profil_donnees where id_profil=$profil_unimarc").BR); + $buffer->ecrire('Affichage : '.getLibCodifVariable("test_level",$test_level).BR); + $buffer->ecrire('Heure : '.date("G:i:s").BR.BR); } if( false == $parseur->open($fichier,0,$pointeur_reprise) ) { - afficherErreur('Impossible d\'ouvrir le fichier : '. $fichier); - exit; + afficherErreur('Impossible d\'ouvrir le fichier : '. $fichier); + exit; } // Jauge @@ -159,63 +157,63 @@ $notice->setParamsIntegration(0,0,$profil_unimarc); while(true) { - if($chrono->tempsPasse() > $timeout) sauveContexte(); - $ret=$parseur->nextEnreg(); - $pointeur_reprise=$ret["pointeur_reprise"]; - $adresse=$ret["adresse"]; - afficherAvance($ret["pct"]); - if($ret["statut"]=="ok") - { - if($test_level==1 and $nb_notices == 100) break; - $nb_notices++; - $ret_test=$notice->testNotice($ret["data"],$piege_numero,$piege_titre,$piege_code_barres,$piege_isbn,$piege_type_doc); - $nb_ex+=$ret_test["nb_ex"]; + if($chrono->tempsPasse() > $timeout) sauveContexte(); + $ret=$parseur->nextEnreg(); + $pointeur_reprise=$ret["pointeur_reprise"]; + $adresse=$ret["adresse"]; + afficherAvance($ret["pct"]); + if($ret["statut"]=="ok") + { + if($test_level==1 and $nb_notices == 100) break; + $nb_notices++; + $ret_test=$notice->testNotice($ret["data"],$piege_numero,$piege_titre,$piege_code_barres,$piege_isbn,$piege_type_doc); + $nb_ex+=$ret_test["nb_ex"]; - // Mode piege - if($mode_piege == true) - { - if($nb_notices == $piege_numero or $ret_test["statut"]==1) - { - $url_notice='<a class="notice" href="'.URL_BASE."php/analyse_afficher_notice.php?fichier=".$fichier."&adresse=".$adresse .'&profil_unimarc='.$profil_unimarc.'">'; - $buffer->log('<b>'.$url_notice.'Notice n° '.$nb_notices.' : '.$ret_test["titre"].'</a></b>'.BR); - if($pave_unimarc > 0) - { - if($pave_unimarc == 1) $mf="w"; else $mf="a"; - $pave_unimarc++; - $ficmemo="test/analyse_unimarc.txt"; - $handle=fopen(getVariable("ftp_path").$ficmemo,$mf); - fwrite($handle,$ret["data"]); - fclose($handle); - $buffer->log("La notice a été écrite dans le fichier : ".$ficmemo.BR); - } - // Si le piege est sur le n° on quitte - if($piege_numero) break; - } - continue; - } - // Mode analyse - $type_doc[$ret_test["type_doc"]]++; - if($test_level > 0 or $ret_test["statut"]>0) - { - if($ret_test["statut"]==1) $nb_warnings++; - if($ret_test["statut"]==2) $nb_rejets++; - if($ret_test["statut"]==3) $nb_suppr++; - $url_notice='<a class="notice" href="'.URL_BASE."php/analyse_afficher_notice.php?fichier=".$fichier."&adresse=".$adresse .'&profil_unimarc='.$profil_unimarc.'">'; - $buffer->log('<b>'.$url_notice.'Notice n° '.$nb_notices.' : '.$ret_test["titre"].'</a></b>'.BR); - $buffer->log('<table class="blank" cellspacing="0" cellpadding="5px" style="margin-left:15px;margin-bottom:10px;">'); - foreach($ret_test["lig"] as $item) - { - $item[1]=str_replace(" "," ",$item[1]); - if(! $item[2]) $item[2]=" "; - if(! $item[3]) $item[3]=" "; - $buffer->log('<tr><td class="blank"><span class="vert">'.$item[1].'</span></td>'); - if($item[0] > 0 and $item[0] < 3) $buffer->log('<td class="blank"><span class="rouge">'.$item[2].'</span></td>'); - else $buffer->log('<td class="blank">'.$item[2].'</td>'); - $buffer->log('<td class="blank">'.$item[3].'</td>'); - $buffer->log('</tr>'); - } - $buffer->log('</table>'); - } + // Mode piege + if($mode_piege == true) + { + if($nb_notices == $piege_numero or $ret_test["statut"]==1) + { + $url_notice='<a class="notice" href="'.URL_BASE."php/analyse_afficher_notice.php?fichier=".$fichier."&adresse=".$adresse .'&profil_unimarc='.$profil_unimarc.'">'; + $buffer->ecrire('<b>'.$url_notice.'Notice n° '.$nb_notices.' : '.$ret_test["titre"].'</a></b>'.BR); + if($pave_unimarc > 0) + { + if($pave_unimarc == 1) $mf="w"; else $mf="a"; + $pave_unimarc++; + $ficmemo="test/analyse_unimarc.txt"; + $handle=fopen(getVariable("ftp_path").$ficmemo,$mf); + fwrite($handle,$ret["data"]); + fclose($handle); + $buffer->ecrire("La notice a été écrite dans le fichier : ".$ficmemo.BR); + } + // Si le piege est sur le n° on quitte + if($piege_numero) break; + } + continue; + } + // Mode analyse + $type_doc[$ret_test["type_doc"]]++; + if($test_level > 0 or $ret_test["statut"]>0) + { + if($ret_test["statut"]==1) $nb_warnings++; + if($ret_test["statut"]==2) $nb_rejets++; + if($ret_test["statut"]==3) $nb_suppr++; + $url_notice='<a class="notice" href="'.URL_BASE."php/analyse_afficher_notice.php?fichier=".$fichier."&adresse=".$adresse .'&profil_unimarc='.$profil_unimarc.'">'; + $buffer->ecrire('<b>'.$url_notice.'Notice n° '.$nb_notices.' : '.$ret_test["titre"].'</a></b>'.BR); + $buffer->ecrire('<table class="blank" cellspacing="0" cellpadding="5px" style="margin-left:15px;margin-bottom:10px;">'); + foreach($ret_test["lig"] as $item) + { + $item[1]=str_replace(" "," ",$item[1]); + if(! $item[2]) $item[2]=" "; + if(! $item[3]) $item[3]=" "; + $buffer->ecrire('<tr><td class="blank"><span class="vert">'.$item[1].'</span></td>'); + if($item[0] > 0 and $item[0] < 3) $buffer->ecrire('<td class="blank"><span class="rouge">'.$item[2].'</span></td>'); + else $buffer->ecrire('<td class="blank">'.$item[2].'</td>'); + $buffer->ecrire('<td class="blank">'.$item[3].'</td>'); + $buffer->ecrire('</tr>'); + } + $buffer->ecrire('</table>'); + } } else break; } @@ -224,63 +222,63 @@ while(true) // ---------------------------------------------------------------- if($mode_piege == true) { - $page=$buffer->close(); - redirection("integre_analyse_fichier_unimarc.php?action=AFFICHER&page=1"); + $page=$buffer->close(); + redirection("integre_analyse_fichier_unimarc.php?action=AFFICHER&page=1"); } $chrono->timeStart=$timeStart; -$buffer->log("<h4>Fin de l'analyse</h4>",true); -$buffer->log("Heure : ".date("G:i:s").BR); -$buffer->log("temps de traitement ".$chrono->end().BR.BR); +$buffer->ecrire("<h4>Fin de l'analyse</h4>",true); +$buffer->ecrire("Heure : ".date("G:i:s").BR); +$buffer->ecrire("temps de traitement ".$chrono->end().BR.BR); if($ret["statut"]=="erreur") { - $buffer->log('<span class="rouge">Le fichier ne respecte pas la norme unimarc</span><br>'); - if($nb_notices > 0) - { - $buffer->log($nb_notices . " notices ont pu être analysées.".BR); - } - else - { - $buffer->log("aucune notice n'a pu être analysée.".BR); - } + $buffer->ecrire('<span class="rouge">Le fichier ne respecte pas la norme unimarc</span><br>'); + if($nb_notices > 0) + { + $buffer->ecrire($nb_notices . " notices ont pu être analysées.".BR); + } + else + { + $buffer->ecrire("aucune notice n'a pu être analysée.".BR); + } } else { - if($nb_notices == 0 ) $buffer->log('<span class="rouge">Le fichier ne contenait aucune notice</span><br>'); - else - { - $buffer->log('<b><span class="vert">Le fichier respecte la norme unimarc</span></b>'.BR); - $buffer->log($nb_notices.' notices on été analysées.'.BR); - } + if($nb_notices == 0 ) $buffer->ecrire('<span class="rouge">Le fichier ne contenait aucune notice</span><br>'); + else + { + $buffer->ecrire('<b><span class="vert">Le fichier respecte la norme unimarc</span></b>'.BR); + $buffer->ecrire($nb_notices.' notices on été analysées.'.BR); + } } if($nb_notices > 0 ) { - if(!$nb_suppr > 0) $nb_suppr="aucune"; - $buffer->log("Notices à supprimer : " . $nb_suppr.BR); - $buffer->log("Notices à mettre à jour : " . ($nb_notices - ($nb_rejets + $nb_suppr)).BR); - $buffer->log("Exemplaires à insérer : " . $nb_ex.BR); - $buffer->log('Anomalies non bloquantes : '. $nb_warnings.BR); - if($nb_rejets>0) $buffer->log('<span class="rouge">Notices non exploitables : '. $nb_rejets.'</span>'.BR); - else $buffer->log('Notices non exploitables : aucune'.BR); - $buffer->log("Moyenne : ".$chrono->moyenne($nb_notices,"notices").BR); + if(!$nb_suppr > 0) $nb_suppr="aucune"; + $buffer->ecrire("Notices à supprimer : " . $nb_suppr.BR); + $buffer->ecrire("Notices à mettre à jour : " . ($nb_notices - ($nb_rejets + $nb_suppr)).BR); + $buffer->ecrire("Exemplaires à insérer : " . $nb_ex.BR); + $buffer->ecrire('Anomalies non bloquantes : '. $nb_warnings.BR); + if($nb_rejets>0) $buffer->ecrire('<span class="rouge">Notices non exploitables : '. $nb_rejets.'</span>'.BR); + else $buffer->ecrire('Notices non exploitables : aucune'.BR); + $buffer->ecrire("Moyenne : ".$chrono->moyenne($nb_notices,"notices").BR); - // Types de docs - $buffer->log(BR."<b>Types de documents :</b>".BR); - $buffer->log('<table class="blank" cellpadding="5px" style="margin-left:15px;margin-top:5px;">'); - $td=$sql->fetchOne("select liste from variables where clef='types_docs'"); - $td=explode(chr(13).chr(10),$td); - $td[]="100:articles de périodiques"; - for($i=0; $i<count($td); $i++) - { - $elem=explode(":",$td[$i]); - if(!$type_doc[$elem[0]]) $type_doc[$elem[0]]=0; - $buffer->log('<tr>'); - $buffer->log('<td class="blank">'.$elem[1].'</td>'); - $buffer->log('<td class="blank" align="right">'.$type_doc[$elem[0]].'</td>'); - $buffer->log('</tr>'); - } - $buffer->log('</table>'.BR); + // Types de docs + $buffer->ecrire(BR."<b>Types de documents :</b>".BR); + $buffer->ecrire('<table class="blank" cellpadding="5px" style="margin-left:15px;margin-top:5px;">'); + $td=$sql->fetchOne("select liste from variables where clef='types_docs'"); + $td=explode(chr(13).chr(10),$td); + $td[]="100:articles de périodiques"; + for($i=0; $i<count($td); $i++) + { + $elem=explode(":",$td[$i]); + if(!$type_doc[$elem[0]]) $type_doc[$elem[0]]=0; + $buffer->ecrire('<tr>'); + $buffer->ecrire('<td class="blank">'.$elem[1].'</td>'); + $buffer->ecrire('<td class="blank" align="right">'.$type_doc[$elem[0]].'</td>'); + $buffer->ecrire('</tr>'); + } + $buffer->ecrire('</table>'.BR); } // Réafficher le debut si + d'1 page en buffer $page=$buffer->close(); @@ -292,126 +290,124 @@ print('</body></html>'); // ---------------------------------------------------------------- function sauveContexte() { - global $buffer; - global $fichier,$timeStart,$pointeur_reprise,$nb_notices,$nb_ex,$nb_warnings,$nb_rejets,$nb_suppr,$type_doc,$test_level,$profil_unimarc; - global $mode_piege,$piege_numero,$piege_titre,$piege_code_barres,$piege_isbn,$piege_type_doc,$pave_unimarc; - $page=$buffer->close(); - $data=compact("page","fichier","timeStart","pointeur_reprise","nb_notices","nb_ex","nb_warnings","nb_rejets" - ,"type_doc","test_level","profil_unimarc","mode_piege","piege_numero","piege_titre","piege_code_barres","piege_type_doc","piege_isbn","pave_unimarc"); - $_SESSION["reprise"]=$data; - redirection( "integre_analyse_fichier_unimarc.php?reprise=oui"); + global $buffer; + global $fichier,$timeStart,$pointeur_reprise,$nb_notices,$nb_ex,$nb_warnings,$nb_rejets,$nb_suppr,$type_doc,$test_level,$profil_unimarc; + global $mode_piege,$piege_numero,$piege_titre,$piege_code_barres,$piege_isbn,$piege_type_doc,$pave_unimarc; + $page=$buffer->close(); + $data=compact("page","fichier","timeStart","pointeur_reprise","nb_notices","nb_ex","nb_warnings","nb_rejets" + ,"type_doc","test_level","profil_unimarc","mode_piege","piege_numero","piege_titre","piege_code_barres","piege_type_doc","piege_isbn","pave_unimarc"); + $_SESSION["reprise"]=$data; + redirection( "integre_analyse_fichier_unimarc.php?reprise=oui"); } function restaureContext() { - global $buffer; - global $fichier,$timeStart,$pointeur_reprise,$nb_notices,$nb_ex,$nb_warnings,$nb_rejets,$nb_suppr,$type_doc,$fichier,$test_level,$profil_unimarc; - global $mode_piege,$piege_numero,$piege_titre,$piege_code_barres,$piege_isbn,$piege_type_doc,$pave_unimarc; - extract($_SESSION["reprise"]); - unset($_SESSION["reprise"]); - $buffer->open($page); + global $buffer; + global $fichier,$timeStart,$pointeur_reprise,$nb_notices,$nb_ex,$nb_warnings,$nb_rejets,$nb_suppr,$type_doc,$fichier,$test_level,$profil_unimarc; + global $mode_piege,$piege_numero,$piege_titre,$piege_code_barres,$piege_isbn,$piege_type_doc,$pave_unimarc; + extract($_SESSION["reprise"]); + unset($_SESSION["reprise"]); + $buffer->open($page); } function afficherAvance($pct) { - global $avance; - if($pct > $avance) - { - $avance=$pct; - print('<script>'); - print("document.getElementById('pct').innerHTML='".$pct."%';"); - $jauge="document.getElementById('jauge').style.width='".$pct."%';"; - print($jauge); - print('</script>'); - flush(); - } + global $avance; + if($pct > $avance) + { + $avance=$pct; + print('<script>'); + print("document.getElementById('pct').innerHTML='".$pct."%';"); + $jauge="document.getElementById('jauge').style.width='".$pct."%';"; + print($jauge); + print('</script>'); + flush(); + } } function getComboFichiers() { - // dossiers a parser - $paths[]=getVariable("integration_path"); - $paths[]=getVariable("ftp_path"); - if(!file_exists($paths[0])) afficherErreur("Impossible d'ouvrir le dossier : ".$paths[0]); + // dossiers a parser + $paths[]=getVariable("integration_path"); + $paths[]=getVariable("ftp_path"); + if(!file_exists($paths[0])) afficherErreur("Impossible d'ouvrir le dossier : ".$paths[0]); - // recup des dossiers - $dossiers = array(); - foreach($paths as $path) - { - $dossiers[]=$path; - $ret=parseDossiers($path); - $dossiers=array_merge($dossiers,$ret); - } + // recup des dossiers + $dossiers = array(); + foreach($paths as $path) + { + $dossiers[]=$path; + $ret=parseDossiers($path); + $dossiers=array_merge($dossiers,$ret); + } - // recup des fichiers - $files = []; - foreach($dossiers as $dossier) { - $ret=parseFichiers($dossier); - $files = array_merge($files, $ret); - } - sort($files); + // recup des fichiers + $files = []; + foreach($dossiers as $dossier) { + $ret=parseFichiers($dossier); + $files = array_merge($files, $ret); + } + sort($files); - $combo='<select name="fichier">'; - foreach($files as $file) { - $combo .= "<option value='$file'>$file</option>"; - } - $combo.='</select>'; - return $combo; + $combo='<select name="fichier">'; + foreach($files as $file) { + $combo .= "<option value='$file'>$file</option>"; + } + $combo.='</select>'; + return $combo; } function parseDossiers($racine) { - if(strRight($racine,1) != "/") $racine.="/"; - @$dir = opendir($racine); - if(!$dir) return array(); - $paths = array(); - while (($file = readdir($dir)) !== false) - { - if(is_dir($racine.$file) and substr($file,0,1) != "." and $file !="etalon") - { - $paths[]=$racine.$file; - $ret=parseDossiers($racine.$file); - $paths=array_merge($paths,$ret); - } - } - closedir($dir); - return $paths; + if(strRight($racine,1) != "/") $racine.="/"; + @$dir = opendir($racine); + if(!$dir) return array(); + $paths = array(); + while (($file = readdir($dir)) !== false) + { + if(is_dir($racine.$file) and substr($file,0,1) != "." and $file !="etalon") + { + $paths[]=$racine.$file; + $ret=parseDossiers($racine.$file); + $paths=array_merge($paths,$ret); + } + } + closedir($dir); + return $paths; } function parseFichiers($dossier) { - $rejet=array(".gitignore","test.txt"); - if(strRight($dossier,1) != "/") $dossier.="/"; - @$dir = opendir($dossier); - if(!$dir) return []; + $rejet=array(".gitignore","test.txt"); + if(strRight($dossier,1) != "/") $dossier.="/"; + @$dir = opendir($dossier); + if(!$dir) return []; - $combo_lignes = []; - while(($file = readdir($dir)) !== false) - { - if(in_array($file, $rejet)) continue; - if(is_file($dossier.$file)) - { - $combo_lignes []= $dossier.$file; - } - } + $combo_lignes = []; + while(($file = readdir($dir)) !== false) + { + if(in_array($file, $rejet)) continue; + if(is_file($dossier.$file)) + { + $combo_lignes []= $dossier.$file; + } + } - closedir( $dir); - return $combo_lignes; + closedir( $dir); + return $combo_lignes; } function controleChampsDistinct() { - $champs=trim($_POST["distinct"]); - if(!$champs) return false; - $champs=explode(";",$champs); - foreach($champs as $champ) - { - if(strlen($champ) !=5) return false; - if(!intVal(substr($champ,0,3))) return false; - if(substr($champ,3,1) != "\$") return false; - $car=substr($champ,-1); - if($car >="0" and $car <="9") continue; - if($car >="a" and $car <="z") continue; - return false; - } - return true; -} - -?> + $champs=trim($_POST["distinct"]); + if(!$champs) return false; + $champs=explode(";",$champs); + foreach($champs as $champ) + { + if(strlen($champ) !=5) return false; + if(!intVal(substr($champ,0,3))) return false; + if(substr($champ,3,1) != "\$") return false; + $car=substr($champ,-1); + if($car >="0" and $car <="9") continue; + if($car >="a" and $car <="z") continue; + return false; + } + return true; +} \ No newline at end of file