Subversion Repositories Applications.referentiel

Rev

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

Rev 46 Rev 48
Line 14... Line 14...
14
 */
14
 */
15
class Versionnage extends AppliControleur {
15
class Versionnage extends AppliControleur {
Line 16... Line 16...
16
	
16
	
Line -... Line 17...
-
 
17
	const SCRIPT_A_LANCER = 'versionnage';
-
 
18
	
-
 
19
	private $version = array('titre', 'acronyme', 'version', 'date_prod', 
-
 
20
		'auteur_principal', 'coordinateur', 'editeur', 'contact', 
-
 
21
		'contributeur', 
17
	const SCRIPT_A_LANCER = 'versionnage';
22
		'dom_tax', 'dom_geo', 'dom_code', 
18
	
23
		'source', 'copyright', 'licence', 'referencement');
Line 19... Line 24...
19
	private $referentiel = null;
24
	private $referentiel = null;
20
	private $traitementDao = null;
25
	private $traitementDao = null;
Line 51... Line 56...
51
		$this->url->unsetVariablesRequete(array('module', 'action', 'ref'));
56
		$this->url->unsetVariablesRequete(array('module', 'action', 'ref'));
52
		$donnees['url_form'] = $this->obtenirUrlDemandeVersionnage($this->referentiel);
57
		$donnees['url_form'] = $this->obtenirUrlDemandeVersionnage($this->referentiel);
53
		$donnees['url_module'] = 'Versionnage';
58
		$donnees['url_module'] = 'Versionnage';
54
		$donnees['url_action_rafraichir'] = 'afficherInterface';
59
		$donnees['url_action_rafraichir'] = 'afficherInterface';
Line 55... Line -...
55
		
-
 
56
		// Date de production de la version
60
		
57
		$donnees['date_prod'] = date('Y-m-d');
61
		$donnees['version'] = $this->instancierChampsVersionnage();
58
		 
62
		
59
		// Récupération des paramètres de configuration du manuel des référentiels
63
		// Récupération des paramètres de configuration du manuel des référentiels
60
		$donnees['domaine_geo'] = explode(';', $this->manuel['domaine_geo']);
64
		$donnees['domaine_geo'] = explode(';', $this->manuel['domaine_geo']);
61
		$donnees['domaine_taxo'] = explode(';', $this->manuel['domaine_taxo']);
65
		$donnees['domaine_taxo'] = explode(';', $this->manuel['domaine_taxo']);
62
		$donnees['domaine_code'] = explode(';', $this->manuel['domaine_code']);
-
 
63
		$licences = explode(';', $this->manuel['licences']);
-
 
64
		foreach ($licences as $licence) {
-
 
65
			if (preg_match('/^([^<]+)<([^>]+)>/', $licence, $match)) {
-
 
66
				$info_licence = array();
-
 
67
				$info_licence['nom'] = $match[1];
-
 
68
				$info_licence['url'] = $match[2];
-
 
69
				$donnees['licences'][] = $info_licence;
-
 
70
			}
-
 
Line 71... Line 66...
71
		}
66
		$donnees['domaine_code'] = explode(';', $this->manuel['domaine_code']);
72
		
67
		
73
		// Traitement de l'info sur le code du référentiel
68
		// Traitement de l'info sur le code du référentiel
74
		if (isset($this->referentiel)) {
69
		if (isset($this->referentiel)) {
Line 98... Line 93...
98
		$this->setSortie(self::RENDU_CORPS, $this->getVue('form_version', $donnees), false);
93
		$this->setSortie(self::RENDU_CORPS, $this->getVue('form_version', $donnees), false);
99
		$this->construireMenu($this->referentiel);
94
		$this->construireMenu($this->referentiel);
100
		$this->construireFilAriane($this->referentiel);
95
		$this->construireFilAriane($this->referentiel);
101
	}
96
	}
Line -... Line 97...
-
 
97
	
-
 
98
	public function instancierChampsVersionnage() {
-
 
99
		$version = array();
-
 
100
		foreach ($this->version as $champ) {
-
 
101
			if (isset($_POST[$champ])) {
-
 
102
				$version[$champ] = strip_tags(stripslashes($_POST[$champ]));
-
 
103
			} else {
-
 
104
				$version[$champ] = $this->getValeurParDefaut($champ);
-
 
105
				
-
 
106
			}
-
 
107
		}
-
 
108
		return $version;
-
 
109
	}
-
 
110
	
-
 
111
	public function getValeurParDefaut($champ) {
-
 
112
		$valeur = '';
-
 
113
		if ('date_prod' == $champ) {
-
 
114
			$valeur = date('Y-m-d');
-
 
115
		}
-
 
116
		return $valeur;
-
 
117
	}
102
	
118
	
103
	/**
119
	/**
104
	 * Lance l'ajout d'un traitement
120
	 * Lance l'ajout d'un traitement
105
	 */
121
	 */
-
 
122
	public function demanderTraitement() {
106
	public function demanderTraitement() {
123
		if ($this->verifierMetadonnees()) {
-
 
124
			$this->ajouterTraitement($this->referentiel, self::SCRIPT_A_LANCER);
107
		$this->ajouterTraitement($this->referentiel, self::SCRIPT_A_LANCER);
125
		}
108
		$this->afficherInterface();
126
		$this->afficherInterface();
-
 
127
	}
-
 
128
	
-
 
129
	/**
-
 
130
	 * Vérifie les données du formulaire
-
 
131
	 */
-
 
132
	public function verifierMetadonnees() {
-
 
133
		$ok = true;
-
 
134
		$ok = ($this->verifierChampsObligatoires()) ? true : false;
-
 
135
		return $ok;
-
 
136
	}
-
 
137
	
-
 
138
	public function verifierChampsObligatoires() {
-
 
139
		$ok = true;
-
 
140
		$champs_obligatoires = array('titre' => 'Titre',
-
 
141
			'acronyme' => 'Acronyme',
-
 
142
			'version' => 'Version',
-
 
143
			'auteur_principal' => 'Auteur Principal',
-
 
144
			'coordinateur' => 'coordinateur',
-
 
145
			'contact' => 'Courriel de contact',
-
 
146
			'dom_tax' => 'Domaine taxonomique',
-
 
147
			'dom_geo' => 'Domaine géographique',
-
 
148
			'dom_code' => 'Codes botaniques utilisés',
-
 
149
			'referencement' => 'Comment citer ce référentiel?');
-
 
150
		foreach ($champs_obligatoires as $champ_id => $champ_nom) {
-
 
151
			if (!isset($_POST[$champ_id]) || empty($_POST[$champ_id])) {
-
 
152
				$this->addMessage("Le champ '$champ_nom' doit être obligatoirement rempli.");
-
 
153
				$ok = false;
-
 
154
			}
-
 
155
		}
-
 
156
		return $ok;
109
	}
157
	}
110
}
158
}
111
?>
159
?>