Subversion Repositories Applications.referentiel

Rev

Rev 56 | Rev 65 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 56 Rev 58
Line 191... Line 191...
191
					$e = "Le champ '$champ' n'a pas été pris en compte dans l'attribution de l'ordre des champs.";
191
					$e = "Le champ '$champ' n'a pas été pris en compte dans l'attribution de l'ordre des champs.";
192
					$this->ajouterMessage($e);
192
					$this->ajouterMessage($e);
193
				}
193
				}
194
			}
194
			}
195
			ksort($infos);
195
			ksort($infos);
-
 
196
			$infos = $this->remplacerTabulation($infos);
-
 
197
			$infos = $this->remplacerSautsDeLigne($infos);
196
			$donnees['noms'][] = $infos;
198
			$donnees['noms'][] = $infos;
197
		}
199
		}
198
		Debug::printr("Dernier element du tableau des noms [trié] : ".print_r($infos,true));
200
		Debug::printr("Dernier element du tableau des noms [trié] : ".print_r($infos,true));
199
		$bdnt_tsv = $this->getVue('versionnage/squelettes/bdnt', $donnees, '.tpl.tsv');
201
		$bdnt_tsv =& $this->getVue('versionnage/squelettes/bdnt', $donnees, '.tpl.tsv');
200
		$this->ecrireFichierBdnt($bdnt_tsv);
202
		$this->ecrireFichierBdnt($bdnt_tsv);
201
	}
203
	}
Line 202... Line 204...
202
	
204
	
203
	private function determinerOrdreDesChamps() {
205
	private function determinerOrdreDesChamps() {
Line 226... Line 228...
226
	private function ajouterMessage($message) {
228
	private function ajouterMessage($message) {
227
		$titre = self::SCRIPT_NOM.' #'.$this->traitement['id_traitement'];
229
		$titre = self::SCRIPT_NOM.' #'.$this->traitement['id_traitement'];
228
		$this->messages[] = array('message' => $message, 'resultat' => true);
230
		$this->messages[] = array('message' => $message, 'resultat' => true);
229
	}
231
	}
Line 230... Line 232...
230
	
232
	
231
	private function ecrireFichierBdnt($contenu) {
233
	private function ecrireFichierBdnt(&$contenu) {
232
		$fichier_nom = $this->getBaseNomFichier().$this->manuel['ext_fichier_bdnt'];
234
		$fichier_nom = $this->getBaseNomFichier().$this->manuel['ext_fichier_bdnt'];
Line 233... Line 235...
233
		$fichier_chemin = $this->zip_chemin_dossier.$fichier_nom;
235
		$fichier_chemin = $this->zip_chemin_dossier.$fichier_nom;
234
		
236
		
Line 242... Line 244...
242
	
244
	
243
	private function getBaseNomFichier() {
245
	private function getBaseNomFichier() {
244
		return strtolower($this->meta['acronyme'].'_v'.$this->meta['version']);
246
		return strtolower($this->meta['acronyme'].'_v'.$this->meta['version']);
Line 245... Line 247...
245
	}
247
	}
246
	
248
	
247
	private function ecrireFichier($fichier_chemin, $contenu) {
249
	private function ecrireFichier($fichier_chemin, &$contenu) {
248
		$retour = true;
250
		$retour = true;
249
		if (file_put_contents($fichier_chemin, $contenu) == false) {
251
		if (file_put_contents($fichier_chemin, $contenu) == false) {
250
			$e = "Une erreur est survenu lors de l'écriture du fichier : $fichier_chemin";
252
			$e = "Une erreur est survenu lors de l'écriture du fichier : $fichier_chemin";
Line 267... Line 269...
267
					"de la demande actuel ({$this->version_courante}) pour ce projet, aucun fichier différentiel ne sera créé.";
269
					"de la demande actuel ({$this->version_courante}) pour ce projet, aucun fichier différentiel ne sera créé.";
268
				$this->ajouterMessage($e);
270
				$this->ajouterMessage($e);
269
			} else {
271
			} else {
270
				$this->noms_precedents = $this->referentielDao->getTout($code_projet_precedent);
272
				$this->noms_precedents = $this->referentielDao->getTout($code_projet_precedent);
271
				$donnees = array();
273
				$donnees = array();
272
				$donnees['diff'] = $this->realiserDiff();
274
				$donnees['diff'] =& $this->realiserDiff();
273
				$donnees['champs'] = $this->champs_nom;
275
				$donnees['champs'] = $this->champs_nom;
274
				$diff_tsv = $this->getVue('versionnage/squelettes/diff', $donnees, '.tpl.tsv');
276
				$diff_tsv = $this->getVue('versionnage/squelettes/diff', &$donnees, '.tpl.tsv');
275
				$this->ecrireFichierDiff($diff_tsv);
277
				$this->ecrireFichierDiff($diff_tsv);
276
			}
278
			}
277
		}
279
		}
278
	}
280
	}
Line 279... Line 281...
279
	
281
	
280
	private function realiserDiff() {
282
	private function realiserDiff() {
281
		$diff = array();
283
		$diff = array();
-
 
284
		$this->noms_stat['modification'] = 0;
282
		$this->noms_stat['modification'] = 0;
285
		$i = 0;
-
 
286
		foreach ($this->noms as $id => &$nom) {
283
		foreach ($this->noms as $id => &$nom) {
287
			$infos = array();
284
			if (!isset($this->noms_precedents[$id])) {
288
			if (!isset($this->noms_precedents[$id])) {
285
				$diff[$id] = $nom;
289
				$infos = $nom;
286
				$diff[$id]['modification_type'] = 'A';
290
				$infos['modification_type'] = 'A';
287
				$diff[$id]['modification_type_1'] = '0';
291
				$infos['modification_type_1'] = '0';
288
				$diff[$id]['modification_type_2'] = '0';
292
				$infos['modification_type_2'] = '0';
289
				$diff[$id]['modification_type_3'] = '0';
293
				$infos['modification_type_3'] = '0';
290
				$this->noms_stat['modification']++;
294
				$this->noms_stat['modification']++;
291
			} else {
295
			} else {
292
				$nom_precedent =& $this->noms_precedents[$id];
296
				$nom_precedent =& $this->noms_precedents[$id];
-
 
297
				$nom_diff = array_diff_assoc($nom, $nom_precedent);
293
				$nom_diff = array_diff_assoc($nom, $nom_precedent);
298
				Debug::printr($nom_diff);
294
				if (count($nom_diff) > 0) {
299
				if (count($nom_diff) > 0) {
295
					$this->noms_stat['modification']++;
300
					$this->noms_stat['modification']++;
296
					$modif['modification_type'] = 'M';
301
					$modif['modification_type'] = 'M';
297
					$modif['modification_type_1'] = '0';
302
					$modif['modification_type_1'] = '0';
298
					$modif['modification_type_2'] = '0';
303
					$modif['modification_type_2'] = '0';
299
					$modif['modification_type_3'] = '0';
304
					$modif['modification_type_3'] = '0';
300
					$this->chargerTableauChampsModifTypes();
305
					$this->chargerTableauChampsModifTypes();
301
					foreach ($this->champs_nom as $champ) {
306
					foreach ($this->champs_nom as $champ) {
302
						if (isset($nom_diff[$champ])) {
307
						if (isset($nom_diff[$champ])) {
303
							$diff[$id][$champ] = $nom_diff[$champ];
308
							$infos[$champ] = $nom_diff[$champ];
304
							$type = $this->getDiffType($champ);
309
							$type = $this->getDiffType($champ);
305
							$modif['modification_type_'.$type] = '1';
310
							$modif['modification_type_'.$type] = '1';
306
						} else {
311
						} else {
307
							$diff[$id][$champ] = '';
312
							$infos[$champ] = '';
308
						}
313
						}
309
					}
314
					}
310
					foreach ($modif as $cle => $val) {
315
					foreach ($modif as $cle => $val) {
311
						$diff[$id][$cle] = $val;
316
						$infos[$cle] = $val;
312
					}
317
					}
313
				}
318
				}
-
 
319
			}
-
 
320
			$infos = $this->remplacerTabulation($infos);
-
 
321
			$infos = $this->remplacerSautsDeLigne($infos);
-
 
322
			Debug::printr($infos);
-
 
323
			Debug::printr("-------------------------------------------------");
-
 
324
			$diff[$id][] = $infos;
314
			}
325
			if ($i == 100) break;
315
		}
326
		}
316
		return $diff;
327
		return $diff;
Line 317... Line 328...
317
	}
328
	}
318
	
329
	
319
	private function chargerTableauChampsModifTypes() {
330
	private function chargerTableauChampsModifTypes() {
320
		$champs = explode(',', $this->manuel['champs_diff_type']);
331
		$champs = explode(',', $this->manuel['champs_diff_type']);
321
		foreach ($champs as $champ) {
332
		foreach ($champs as $champ) {
322
			list($champ_nom, $type) = explode('=', $champ);
333
			list($champ_nom, $type) = explode('=', trim($champ));
323
			$this->diff_modif_types[$champ_nom] = $type;
334
			$this->diff_modif_types[$champ_nom] = $type;
Line 324... Line 335...
324
		}
335
		}
Line 341... Line 352...
341
	private function creerFichierMeta() {
352
	private function creerFichierMeta() {
342
		$donnees = array();
353
		$donnees = array();
343
		$donnees = $this->meta;
354
		$donnees = $this->meta;
344
		$donnees['stats'] = $this->noms_stat;
355
		$donnees['stats'] = $this->noms_stat;
345
		$donnees['signature'] = $this->signature_md5;
356
		$donnees['signature'] = $this->signature_md5;
-
 
357
		
-
 
358
		$donnees = $this->remplacerTabulation($donnees);
-
 
359
		$donnees = $this->remplacerSautsDeLigne($donnees);
-
 
360
		
346
		$meta_tsv = $this->getVue('versionnage/squelettes/meta', $donnees, '.tpl.tsv');
361
		$meta_tsv = $this->getVue('versionnage/squelettes/meta', $donnees, '.tpl.tsv');
347
		$this->ecrireFichierMeta($meta_tsv);
362
		$this->ecrireFichierMeta($meta_tsv);
348
	}
363
	}
Line -... Line 364...
-
 
364
	
-
 
365
	private function remplacerTabulation($doc) {
-
 
366
		if (is_string($doc)) {
-
 
367
			$doc = str_replace("\t", ' ', $doc);
-
 
368
		} else if (is_array($doc) && count($doc) > 0) {
-
 
369
			foreach ($doc as $cle => $valeur) {
-
 
370
				$doc[$cle] = $this->remplacerTabulation($valeur);
-
 
371
			}
-
 
372
		}
-
 
373
		return $doc;
-
 
374
	}
-
 
375
	
-
 
376
	private function remplacerSautsDeLigne($doc) {
-
 
377
		if (is_string($doc)) {
-
 
378
			$a_remplacer = array("\r", "\n");
-
 
379
			$doc = str_replace($a_remplacer, ' ', $doc);
-
 
380
		} else if (is_array($doc) && count($doc) > 0) {
-
 
381
			foreach ($doc as $cle => $valeur) {
-
 
382
				$doc[$cle] = $this->remplacerSautsDeLigne($valeur);
-
 
383
			}
-
 
384
		}
-
 
385
		return $doc;
-
 
386
	}
349
	
387
	
350
	private function ecrireFichierMeta($contenu) {
388
	private function ecrireFichierMeta($contenu) {
351
		$fichier_nom = $this->getBaseNomFichier().$this->manuel['ext_fichier_meta'];
389
		$fichier_nom = $this->getBaseNomFichier().$this->manuel['ext_fichier_meta'];
Line 352... Line 390...
352
		$fichier_chemin = $this->zip_chemin_dossier.$fichier_nom;
390
		$fichier_chemin = $this->zip_chemin_dossier.$fichier_nom;