Subversion Repositories eFlore/Applications.cel

Rev

Rev 1477 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1477 Rev 1609
1
<?php
1
<?php
2
//TODO migrer cette classe lorsqu'elle deviendra utile à nouveau
2
//TODO migrer cette classe lorsqu'elle deviendra utile à nouveau
3
/****
3
/****
4
 * 
4
 * 
5
 * Attention classe non migrée !!!!
5
 * Attention classe non migrée !!!!
6
 */
6
 */
7
Class InventoryImageExport extends DBAccessor {
7
Class InventoryImageExport extends DBAccessor {
8
 
8
 
9
	private $extendSpreadsheetProductor;
9
	private $extendSpreadsheetProductor;
10
 
10
 
11
	private $archive;
11
	private $archive;
12
	private $workbook;
12
	private $workbook;
13
	private $worksheet;
13
	private $worksheet;
14
	private $chemin_export_liste;
14
	private $chemin_export_liste;
15
 
15
 
16
    function InventoryImageExport($config) {
16
    function InventoryImageExport($config) {
17
 
17
 
18
    	parent::__construct($config);
18
    	parent::__construct($config);
19
 
19
 
20
        $this->config=$config;
20
        $this->config=$config;
21
        $this->extendSpreadsheetProductor = new SpreadsheetProductor();
21
        $this->extendSpreadsheetProductor = new SpreadsheetProductor();
22
		$this->extendSpreadsheetProductor->initSpreadsheet();
22
		$this->extendSpreadsheetProductor->initSpreadsheet();
23
    }
23
    }
24
 
24
 
25
    function getElement($uid){
25
    function getElement($uid){
26
    	
26
    	
27
      	$this->authentifier();
27
      	$this->authentifier();
28
 
28
 
29
      	$tableau = array();
29
      	$tableau = array();
30
        $tag = $uid[0];
30
        $tag = $uid[0];
31
 
31
 
32
        $limite = 0;
32
        $limite = 0;
33
        $pas = 0;
33
        $pas = 0;
34
 
34
 
35
        //ini_set('max_execution_time',120);
35
        //ini_set('max_execution_time',120);
36
 
36
 
37
        /*if(isset($uid[1]) && isset($uid[2])) {
37
        /*if(isset($uid[1]) && isset($uid[2])) {
38
			$limite = $uid[]
38
			$limite = $uid[]
39
        }*/
39
        }*/
40
 
40
 
41
       	$taille_archive_courante = 0;
41
       	$taille_archive_courante = 0;
42
		$index_archive_courante = 0;
42
		$index_archive_courante = 0;
43
		$taille_max_archive = $this->config['cel']['taille_max_archive'];
43
		$taille_max_archive = $this->config['cel']['taille_max_archive'];
44
		$liens_archives = array();
44
		$liens_archives = array();
45
 
45
 
46
        $DB=$this->connectDB($this->config,'cel');
46
        $DB=$this->connectDB($this->config,'cel');
47
 
47
 
48
        $query_id_id_img = 'SELECT cmc_id_mot_cle_utilisateur, cmc_id_proprietaire FROM cel_mots_cles_images WHERE cmc_id_mot_cle_general = md5("'.$DB->escapeSimple($tag).'")' ;
48
        $query_id_id_img = 'SELECT cmc_id_mot_cle_utilisateur, cmc_id_proprietaire FROM cel_mots_cles_images WHERE cmc_id_mot_cle_general = md5("'.$DB->escapeSimple($tag).'")' ;
49
 
49
 
50
        $res =& $DB->query($query_id_id_img);
50
        $res =& $DB->query($query_id_id_img);
51
 
51
 
52
        if (DB::isError($res)) {
52
        if (DB::isError($res)) {
53
			$this->logger("InventoryImageExport",'Erreur de requete '.$query_id_id_img);
53
			$this->logger("InventoryImageExport",'Erreur de requete '.$query_id_id_img);
54
            die($res->getMessage());
54
            die($res->getMessage());
55
        }
55
        }
56
 
56
 
57
 
57
 
58
        $query='SELECT * FROM cel_images';
58
        $query='SELECT * FROM cel_images';
59
 
59
 
60
        $premier_item = true ;
60
        $premier_item = true ;
61
        while ($row =& $res->fetchrow(DB_FETCHMODE_ASSOC)) {
61
        while ($row =& $res->fetchrow(DB_FETCHMODE_ASSOC)) {
62
 
62
 
63
        	$tableau['mots cles'] = array('utilisateur' => $row['cmc_id_proprietaire'], 'mot cle' => $row['cmc_id_mot_cle_utilisateur']);
63
        	$tableau['mots cles'] = array('utilisateur' => $row['cmc_id_proprietaire'], 'mot cle' => $row['cmc_id_mot_cle_utilisateur']);
64
 
64
 
65
            if($premier_item) {
65
            if($premier_item) {
66
                $query .= ' WHERE ';
66
                $query .= ' WHERE ';
67
                $premier_item = false ;
67
                $premier_item = false ;
68
            }
68
            }
69
            else{
69
            else{
70
                $query .= ' OR ';
70
                $query .= ' OR ';
71
            }
71
            }
72
 
72
 
73
            $query .= '(ci_meta_mots_cles LIKE "%'.$row['cmc_id_mot_cle_utilisateur'].'%" AND ci_ce_utilisateur ="'.$row['cmc_id_proprietaire'].'")' ;
73
            $query .= '(ci_meta_mots_cles LIKE "%'.$row['cmc_id_mot_cle_utilisateur'].'%" AND ci_ce_utilisateur ="'.$row['cmc_id_proprietaire'].'")' ;
74
        }
74
        }
75
 
75
 
76
        $query .= ' ORDER BY ci_meta_date_ajout' ;
76
        $query .= ' ORDER BY ci_meta_date_ajout' ;
77
 
77
 
78
        $res =& $DB->query($query);
78
        $res =& $DB->query($query);
79
 
79
 
80
        if (DB::isError($res)) {
80
        if (DB::isError($res)) {
81
            die($res->getMessage());
81
            die($res->getMessage());
82
        }
82
        }
83
 
83
 
84
        $this->logger('Requetes',$query);
84
        $this->logger('Requetes',$query);
85
 
85
 
86
        // création d'un objet 'zipfile'
86
        // création d'un objet 'zipfile'
87
		$this->archive = new zipfile();
87
		$this->archive = new zipfile();
88
 
88
 
89
		$i = 1;
89
		$i = 1;
90
 
90
 
91
		$this->initialiserWorkBook($index_archive_courante);
91
		$this->initialiserWorkBook($index_archive_courante);
92
 
92
 
93
        while ($image =& $res->fetchrow(DB_FETCHMODE_ASSOC)) {
93
        while ($image =& $res->fetchrow(DB_FETCHMODE_ASSOC)) {
94
 
94
 
95
           $image['ci_nom_original'] = htmlspecialchars($image['ci_nom_original']);
95
           $image['ci_nom_original'] = htmlspecialchars($image['ci_nom_original']);
96
           $image['ci_id_image'] = htmlspecialchars($image['ci_id_image']);
96
           $image['ci_id_image'] = htmlspecialchars($image['ci_id_image']);
97
           $image['ci_meta_date_ajout'] = htmlspecialchars($image['ci_meta_date_ajout']);
97
           $image['ci_meta_date_ajout'] = htmlspecialchars($image['ci_meta_date_ajout']);
98
           $image['ci_ce_utilisateur'] = htmlspecialchars($image['ci_ce_utilisateur']);
98
           $image['ci_ce_utilisateur'] = htmlspecialchars($image['ci_ce_utilisateur']);
99
           $image['ci_meta_user_comment'] = htmlspecialchars($image['ci_meta_user_comment']);
99
           $image['ci_meta_user_comment'] = htmlspecialchars($image['ci_meta_user_comment']);
100
           $image['ci_note_image'] = htmlspecialchars($image['ci_note_image']);
100
           $image['ci_note_image'] = htmlspecialchars($image['ci_note_image']);
101
 
101
 
102
           $id = $image['ci_id_image'];
102
           $id = $image['ci_id_image'];
103
 
103
 
104
           $tableau[$id]['image'] = $image;
104
           $tableau[$id]['image'] = $image;
105
                   
105
                   
106
           if($filename = $this->renvoyerCheminSurServeur($id,false)) {
106
           if($filename = $this->renvoyerCheminSurServeur($id,false)) {
107
 
107
 
108
				// appel de la classe
108
				// appel de la classe
109
			    // nom du fichier à ajouter dans l'archive
109
			    // nom du fichier à ajouter dans l'archive
110
			    // contenu du fichier
110
			    // contenu du fichier
111
			    $fp = fopen ($filename, 'r');
111
			    $fp = fopen ($filename, 'r');
112
			    $content = fread($fp, filesize($filename));
112
			    $content = fread($fp, filesize($filename));
113
			    fclose ($fp);
113
			    fclose ($fp);
114
 
114
 
115
			    // ajout du fichier dans cet objet
115
			    // ajout du fichier dans cet objet
116
			    if(preg_match('/\.(?:jpg|jpeg)$/i',$image['ci_nom_original'])) {
116
			    if(preg_match('/\.(?:jpg|jpeg)$/i',$image['ci_nom_original'])) {
117
			    	$nom_fichier_image = preg_replace('/\.(?:jpg|jpeg)$/i','_'.$id.'.jpg', $image['ci_nom_original']);
117
			    	$nom_fichier_image = preg_replace('/\.(?:jpg|jpeg)$/i','_'.$id.'.jpg', $image['ci_nom_original']);
118
			    } else {
118
			    } else {
119
			    	$nom_fichier_image = $image['ci_nom_original'].'_'.$id.'.jpg';
119
			    	$nom_fichier_image = $image['ci_nom_original'].'_'.$id.'.jpg';
120
			    }
120
			    }
121
			    
121
			    
122
			    $chemin_sur_serveur = $this->config['cel']['url_images'];
122
			    $chemin_sur_serveur = $this->config['cel']['url_images'];
123
			    
123
			    
124
			    $id = sprintf('%09s', $id) ;
124
			    $id = sprintf('%09s', $id) ;
125
            	$id = wordwrap($id, 3 , '_', true) ;
125
            	$id = wordwrap($id, 3 , '_', true) ;
126
			    $niveauDossier = explode("_", $id) ;
126
			    $niveauDossier = explode("_", $id) ;
127
 
127
 
128
	            $dossierNiveau1 = $niveauDossier[0] ;
128
	            $dossierNiveau1 = $niveauDossier[0] ;
129
	            $dossierNiveau2 = $niveauDossier[1] ;
129
	            $dossierNiveau2 = $niveauDossier[1] ;
130
	
130
	
131
	            $chemin_sur_serveur_final = $chemin_sur_serveur.'/'.$dossierNiveau1.'/'.$dossierNiveau2 ;
131
	            $chemin_sur_serveur_final = $chemin_sur_serveur.'/'.$dossierNiveau1.'/'.$dossierNiveau2 ;
132
	
132
	
133
	            $chemin_fichier = $chemin_sur_serveur_final.'/O/'.$id."_O.jpg" ;
133
	            $chemin_fichier = $chemin_sur_serveur_final.'/O/'.$id."_O.jpg" ;
134
			    
134
			    
135
			    $obs_liee['url_image_liee'] = $chemin_fichier;
135
			    $obs_liee['url_image_liee'] = $chemin_fichier;
136
 
136
 
137
			    $taille_fichier = filesize($filename);
137
			    $taille_fichier = filesize($filename);
138
 
138
 
139
            	$req_liaison = 'SELECT * FROM cel_inventory WHERE ordre IN (SELECT coi_ce_observation FROM cel_obs_images WHERE coi_ce_image = "'.$image['ci_id_image'].'") AND identifiant = "'.$image['ci_ce_utilisateur'].'"' ;
139
            	$req_liaison = 'SELECT * FROM cel_inventory WHERE ordre IN (SELECT coi_ce_observation FROM cel_obs_images WHERE coi_ce_image = "'.$image['ci_id_image'].'") AND identifiant = "'.$image['ci_ce_utilisateur'].'"' ;
140
            	$res_liaison =& $DB->query($req_liaison);
140
            	$res_liaison =& $DB->query($req_liaison);
141
 
141
 
142
	            if (DB::isError($res_liaison)) {
142
	            if (DB::isError($res_liaison)) {
143
	                die($res_liaison->getMessage());
143
	                die($res_liaison->getMessage());
144
	            }
144
	            }
145
 
145
 
146
	            if (DB::isError($res_liaison)) {
146
	            if (DB::isError($res_liaison)) {
147
	                die($res_liaison->getMessage());
147
	                die($res_liaison->getMessage());
148
	            }
148
	            }
149
 
149
 
150
	          while($obs_liee = & $res_liaison->fetchrow(DB_FETCHMODE_ASSOC)) {
150
	          while($obs_liee = & $res_liaison->fetchrow(DB_FETCHMODE_ASSOC)) {
151
 
151
 
152
          	  	$tableau[$id]['obs'] = $obs_liee;
152
          	  	$tableau[$id]['obs'] = $obs_liee;
153
          	  	$obs_liee['nom_image_liee'] = $nom_fichier_image;
153
          	  	$obs_liee['nom_image_liee'] = $nom_fichier_image;
154
          	  	$obs_liee['url_image_liee'] = $chemin_fichier;
154
          	  	$obs_liee['url_image_liee'] = $chemin_fichier;
155
 
155
 
156
			  	$this->ecrireLigneWorkBook($i,$obs_liee);
156
			  	$this->ecrireLigneWorkBook($i,$obs_liee);
157
 
157
 
158
		  		$i++;
158
		  		$i++;
159
	          }
159
	          }
160
 
160
 
161
	          //$this->archive->addfile($content, $nom_fichier_image);
161
	          //$this->archive->addfile($content, $nom_fichier_image);
162
			  //$taille_archive_courante += $taille_fichier;
162
			  //$taille_archive_courante += $taille_fichier;
163
 
163
 
164
	          if($taille_archive_courante <= $taille_max_archive) {
164
	          if($taille_archive_courante <= $taille_max_archive) {
165
 
165
 
166
 
166
 
167
				} else {
167
				} else {
168
 
168
 
169
					// fermeture du workbook
169
					// fermeture du workbook
170
					$this->workbook->close();
170
					$this->workbook->close();
171
					$i = 1;
171
					$i = 1;
172
 
172
 
173
					// ajout du fichier liste dans cet objet
173
					// ajout du fichier liste dans cet objet
174
					// contenu du fichier
174
					// contenu du fichier
175
				    $fp = fopen($this->chemin_export_liste, 'r');
175
				    $fp = fopen($this->chemin_export_liste, 'r');
176
				    $contenu = fread($fp, filesize($this->chemin_export_liste));
176
				    $contenu = fread($fp, filesize($this->chemin_export_liste));
177
				    fclose ($fp);
177
				    fclose ($fp);
178
 
178
 
179
					$this->archive->addfile($contenu,'liste.'.md5($tag).'_'.$index_archive_courante.'.xls');
179
					$this->archive->addfile($contenu,'liste.'.md5($tag).'_'.$index_archive_courante.'.xls');
180
					
180
					
181
					$liens_archives[] = $this->enregistrerArchive($this->archive,$index_archive_courante,$tag);
181
					$liens_archives[] = $this->enregistrerArchive($this->archive,$index_archive_courante,$tag);
182
					$index_archive_courante++;
182
					$index_archive_courante++;
183
					$taille_archive_courante = 0;
183
					$taille_archive_courante = 0;
184
 
184
 
185
					$this->archive = new zipfile();
185
					$this->archive = new zipfile();
186
					$this->initialiserWorkBook($index_archive_courante);
186
					$this->initialiserWorkBook($index_archive_courante);
187
				}
187
				}
188
	       }
188
	       }
189
 
189
 
190
      		//$this->verifierOuRelancerExecution();
190
      		//$this->verifierOuRelancerExecution();
191
      		//$this->logger('InventoryImageExport'," Temps d'éxécution à l'image ".$id." : ".$this->getTempsEcoule());
191
      		//$this->logger('InventoryImageExport'," Temps d'éxécution à l'image ".$id." : ".$this->getTempsEcoule());
192
        }
192
        }
193
        
193
        
194
        // fermeture du workbook
194
        // fermeture du workbook
195
		$this->workbook->close();
195
		$this->workbook->close();
196
		$i = 1;
196
		$i = 1;
197
 
197
 
198
		// ajout du fichier liste dans cet objet
198
		// ajout du fichier liste dans cet objet
199
		// contenu du fichier
199
		// contenu du fichier
200
	    $fp = fopen($this->chemin_export_liste, 'r');
200
	    $fp = fopen($this->chemin_export_liste, 'r');
201
	    $contenu = fread($fp, filesize($this->chemin_export_liste));
201
	    $contenu = fread($fp, filesize($this->chemin_export_liste));
202
	    fclose ($fp);
202
	    fclose ($fp);
203
 
203
 
204
		$this->archive->addfile($contenu,'liste.'.md5($tag).'_'.$index_archive_courante.'.xls');
204
		$this->archive->addfile($contenu,'liste.'.md5($tag).'_'.$index_archive_courante.'.xls');
205
		
205
		
206
		$liens_archives[] = $this->enregistrerArchive($this->archive,$index_archive_courante,$tag);
206
		$liens_archives[] = $this->enregistrerArchive($this->archive,$index_archive_courante,$tag);
207
		$index_archive_courante++;
207
		$index_archive_courante++;
208
 
208
 
209
		$j = 1;
209
		$j = 1;
210
		$sortie = '<div><ul>';
210
		$sortie = '<div><ul>';
211
		foreach($liens_archives as $lien) {
211
		foreach($liens_archives as $lien) {
212
			$sortie .= '<li> <a href = "'.$lien.'"> Partie '.$j.'</a></li>';
212
			$sortie .= '<li> <a href = "'.$lien.'"> Partie '.$j.'</a></li>';
213
			$j++;
213
			$j++;
214
		}
214
		}
215
 
215
 
216
		$sortie .= '</div></ul>';
216
		$sortie .= '</div></ul>';
217
 
217
 
218
		//$this->logger('InventoryImageExport',count($tableau));
218
		//$this->logger('InventoryImageExport',count($tableau));
219
 
219
 
220
		//$this->logger('InventoryImageExport',print_r($tableau,true));
220
		//$this->logger('InventoryImageExport',print_r($tableau,true));
221
 
221
 
222
		header('Content-Type: text/html');
222
		header('Content-Type: text/html');
223
		echo $sortie;
223
		echo $sortie;
224
 
224
 
225
    }
225
    }
226
 
226
 
227
 
227
 
228
    function getRessource(){
228
    function getRessource(){
229
		//$this->getElement();
229
		//$this->getElement();
230
    }
230
    }
231
 
231
 
232
    public function authentifier() {
232
    public function authentifier() {
233
        if (!isset($_SERVER['PHP_AUTH_USER'])) {
233
        if (!isset($_SERVER['PHP_AUTH_USER'])) {
234
        header('WWW-Authenticate: Basic realm="www.tela-botanica.org"');
234
        header('WWW-Authenticate: Basic realm="www.tela-botanica.org"');
235
        header('HTTP/1.0 401 Unauthorized');
235
        header('HTTP/1.0 401 Unauthorized');
236
        header('Content-type: text/html; charset=UTF-8');
236
        header('Content-type: text/html; charset=UTF-8');
237
        echo 'Accès interdit';
237
        echo 'Accès interdit';
238
        exit;
238
        exit;
239
        } else {
239
        } else {
240
            if($this->verifierAcces($_SERVER['PHP_AUTH_USER'])) {
240
            if($this->verifierAcces($_SERVER['PHP_AUTH_USER'])) {
241
                return ;
241
                return ;
242
            }
242
            }
243
            else
243
            else
244
            {
244
            {
245
                header('WWW-Authenticate: Basic realm="www.tela-botanica.org"');
245
                header('WWW-Authenticate: Basic realm="www.tela-botanica.org"');
246
                header('HTTP/1.0 401 Unauthorized');
246
                header('HTTP/1.0 401 Unauthorized');
247
                header('Content-type: text/html; charset=UTF-8');
247
                header('Content-type: text/html; charset=UTF-8');
248
                echo 'Accès interdit';
248
                echo 'Accès interdit';
249
                exit ;
249
                exit ;
250
            }
250
            }
251
        }
251
        }
252
    }
252
    }
253
 
253
 
254
    public function verifierAcces($id) {
254
    public function verifierAcces($id) {
255
 
255
 
256
        $DB=$this->connectDB($this->config,'database_ident');
256
        $DB=$this->connectDB($this->config,'database_ident');
257
        $query="SELECT ".$this->config['database_ident']['ann_id']." as name FROM ".$this->config['database_ident']['annuaire']." WHERE ".$this->config['database_ident']['ann_id']." ='".$DB->escapeSimple($id)
257
        $query="SELECT ".$this->config['database_ident']['ann_id']." as name FROM ".$this->config['database_ident']['annuaire']." WHERE ".$this->config['database_ident']['ann_id']." ='".$DB->escapeSimple($id)
258
        ."' AND ".$this->config['database_ident']['ann_pwd']." = ".$this->config['database_ident']['pass_crypt_funct']."('".$DB->escapeSimple($_SERVER['PHP_AUTH_PW'])."')" ;
258
        ."' AND ".$this->config['database_ident']['ann_pwd']." = ".$this->config['database_ident']['pass_crypt_funct']."('".$DB->escapeSimple($_SERVER['PHP_AUTH_PW'])."')" ;
259
 
259
 
260
        $res =& $DB->getOne($query);
260
        $res =& $DB->getOne($query);
261
 
261
 
262
        if($res == "") {
262
        if($res == "") {
263
            return false ;
263
            return false ;
264
        }
264
        }
265
 
265
 
266
        if (DB::isError($res)) {
266
        if (DB::isError($res)) {
267
            die($res->getMessage());
267
            die($res->getMessage());
268
        }
268
        }
269
 
269
 
270
        return $this->isAdmin($id) ;
270
        return $this->isAdmin($id) ;
271
 
271
 
272
    }
272
    }
273
 
273
 
274
    private function renvoyerCheminSurServeur($id,$url = true) {
274
    private function renvoyerCheminSurServeur($id,$url = true) {
275
 
275
 
276
		if($url) {
276
		if($url) {
277
			$chemin_sur_serveur = $this->config['cel']['url_images'];
277
			$chemin_sur_serveur = $this->config['cel']['url_images'];
278
		} else {
278
		} else {
279
			$chemin_sur_serveur = $this->config['cel']['chemin_images'];
279
			$chemin_sur_serveur = $this->config['cel']['chemin_images'];
280
		}
280
		}
281
 
281
 
282
		$id = sprintf('%09s', $id) ;
282
		$id = sprintf('%09s', $id) ;
283
        $id = wordwrap($id, 3 , '_', true) ;
283
        $id = wordwrap($id, 3 , '_', true) ;
284
 
284
 
285
        $id_fichier = $id.".jpg" ;
285
        $id_fichier = $id.".jpg" ;
286
 
286
 
287
        $niveauDossier = explode("_", $id) ;
287
        $niveauDossier = explode("_", $id) ;
288
 
288
 
289
        $dossierNiveau1 = $niveauDossier[0] ;
289
        $dossierNiveau1 = $niveauDossier[0] ;
290
        $dossierNiveau2 = $niveauDossier[1] ;
290
        $dossierNiveau2 = $niveauDossier[1] ;
291
 
291
 
292
        $chemin_sur_serveur_final = $chemin_sur_serveur.'/'.$dossierNiveau1.'/'.$dossierNiveau2 ;
292
        $chemin_sur_serveur_final = $chemin_sur_serveur.'/'.$dossierNiveau1.'/'.$dossierNiveau2 ;
293
 
293
 
294
        $chemin_fichier = $chemin_sur_serveur_final.'/L/'.$id."_L.jpg" ;
294
        $chemin_fichier = $chemin_sur_serveur_final.'/L/'.$id."_L.jpg" ;
295
 
295
 
296
        return $chemin_fichier;
296
        return $chemin_fichier;
297
    }
297
    }
298
 
298
 
299
    private function renvoyerCheminExport($url = true) {
299
    private function renvoyerCheminExport($url = true) {
300
    	if($url) {
300
    	if($url) {
301
    		return $this->config['cel']['url_export'];
301
    		return $this->config['cel']['url_export'];
302
    	} else {
302
    	} else {
303
			return $this->config['cel']['chemin_export'];
303
			return $this->config['cel']['chemin_export'];
304
    	}
304
    	}
305
    }
305
    }
306
 
306
 
307
    private function enregistrerArchive($zip,$index,$tag) {
307
    private function enregistrerArchive($zip,$index,$tag) {
308
 
308
 
309
		// production de l'archive' Zip
309
		// production de l'archive' Zip
310
	    $this->archive = $zip->file();
310
	    $this->archive = $zip->file();
311
		$chemin_export = $this->renvoyerCheminExport(false);
311
		$chemin_export = $this->renvoyerCheminExport(false);
312
		$url_export = $this->renvoyerCheminExport(true);
312
		$url_export = $this->renvoyerCheminExport(true);
313
 
313
 
314
		$chemin_archive = $chemin_export.'/'.md5($tag).'_'.$index.'.zip';
314
		$chemin_archive = $chemin_export.'/'.md5($tag).'_'.$index.'.zip';
315
		$url_archive = $url_export.'/'.md5($tag).'_'.$index.'.zip';
315
		$url_archive = $url_export.'/'.md5($tag).'_'.$index.'.zip';
316
 
316
 
317
		$fp = fopen($chemin_archive,'w+');
317
		$fp = fopen($chemin_archive,'w+');
318
	    $ecriture = fwrite($fp,$this->archive);
318
	    $ecriture = fwrite($fp,$this->archive);
319
	    fclose($fp);
319
	    fclose($fp);
320
 
320
 
321
	    if($ecriture) {
321
	    if($ecriture) {
322
			return $url_archive;
322
			return $url_archive;
323
	    } else {
323
	    } else {
324
	    	return false;
324
	    	return false;
325
	    }
325
	    }
326
 
326
 
327
    }
327
    }
328
 
328
 
329
    private function initialiserWorkBook($index) {
329
    private function initialiserWorkBook($index) {
330
 
330
 
331
    	// Creating a workbook
331
    	// Creating a workbook
332
        $this->chemin_export_liste = $this->renvoyerCheminExport(false).'/liste'.$index.'.xls';
332
        $this->chemin_export_liste = $this->renvoyerCheminExport(false).'/liste'.$index.'.xls';
333
		$this->workbook = new Spreadsheet_Excel_Writer($this->chemin_export_liste);
333
		$this->workbook = new Spreadsheet_Excel_Writer($this->chemin_export_liste);
-
 
334
		$workbook->setVersion(8);
334
 
335
 
335
		// Creating a worksheet
336
		// Creating a worksheet
336
		$this->worksheet = $this->workbook->addWorksheet('Liste');
337
		$this->worksheet = $this->workbook->addWorksheet('Liste');
-
 
338
		$worksheet->setInputEncoding('utf-8');
337
 
339
 
338
		$this->worksheet->write(0,0,'url de l\'image');
340
		$this->worksheet->write(0,0,'url de l\'image');
339
		$this->worksheet->write(0,1,'Nom original de l\'image');
341
		$this->worksheet->write(0,1,'Nom original de l\'image');
340
        //$this->worksheet->write(0,1,'Nom saisi');
342
        //$this->worksheet->write(0,1,'Nom saisi');
341
        //$this->worksheet->write(0,2,'Numero nomenclatural');
343
        //$this->worksheet->write(0,2,'Numero nomenclatural');
342
        $this->worksheet->write(0,2,'Nom retenu');
344
        $this->worksheet->write(0,2,'Nom retenu');
343
        $this->worksheet->write(0,3,'Numero nomenclatural nom retenu');
345
        $this->worksheet->write(0,3,'Numero nomenclatural nom retenu');
344
        $this->worksheet->write(0,4,'Numero taxonomique');
346
        $this->worksheet->write(0,4,'Numero taxonomique');
345
        $this->worksheet->write(0,5,'Famille');
347
        $this->worksheet->write(0,5,'Famille');
346
        //$this->worksheet->write(0,7,'Commune');
348
        //$this->worksheet->write(0,7,'Commune');
347
        //$this->worksheet->write(0,8,'Identifiant Commune');
349
        //$this->worksheet->write(0,8,'Identifiant Commune');
348
        $this->worksheet->write(0,6,'Date Observation');
350
        $this->worksheet->write(0,6,'Date Observation');
349
       // $this->worksheet->write(0,10,'Lieu dit');
351
       // $this->worksheet->write(0,10,'Lieu dit');
350
        //$this->worksheet->write(0,11,'Station');
352
        //$this->worksheet->write(0,11,'Station');
351
        //$this->worksheet->write(0,12,'Milieu');
353
        //$this->worksheet->write(0,12,'Milieu');
352
        $this->worksheet->write(0,7,'Contributeur');
354
        $this->worksheet->write(0,7,'Contributeur');
353
        $this->worksheet->write(0,8,'Commentaire');
355
        $this->worksheet->write(0,8,'Commentaire');
354
    }
356
    }
355
 
357
 
356
    private function ecrireLigneWorkBook($index, $observation) {
358
    private function ecrireLigneWorkBook($index, $observation) {
357
 
359
 
358
    	$this->worksheet->write($index,0,$observation['url_image_liee']);
360
    	$this->worksheet->write($index,0,$observation['url_image_liee']);
359
    	$this->worksheet->write($index,1,$observation['nom_image_liee']);
361
    	$this->worksheet->write($index,1,$observation['nom_image_liee']);
360
	  	//$this->worksheet->write($index,1,$observation['nom_sel']);
362
	  	//$this->worksheet->write($index,1,$observation['nom_sel']);
361
		//$this->worksheet->write($index,2,$observation['num_nom_sel']);
363
		//$this->worksheet->write($index,2,$observation['num_nom_sel']);
362
		$this->worksheet->write($index,2,$observation['nom_ret']);
364
		$this->worksheet->write($index,2,$observation['nom_ret']);
363
		$this->worksheet->write($index,3,$observation['num_nom_ret']);
365
		$this->worksheet->write($index,3,$observation['num_nom_ret']);
364
		$this->worksheet->write($index,4,$observation['num_taxon']);
366
		$this->worksheet->write($index,4,$observation['num_taxon']);
365
		$this->worksheet->write($index,5,$observation['famille']);
367
		$this->worksheet->write($index,5,$observation['famille']);
366
		//$this->worksheet->write($index,7,$observation['location']);
368
		//$this->worksheet->write($index,7,$observation['location']);
367
		//$this->worksheet->write($index,8,$observation['id_location']);
369
		//$this->worksheet->write($index,8,$observation['id_location']);
368
		$this->worksheet->write($index,6,$observation['date_observation']);
370
		$this->worksheet->write($index,6,$observation['date_observation']);
369
		//$this->worksheet->write($index,10,$observation['lieudit']);
371
		//$this->worksheet->write($index,10,$observation['lieudit']);
370
		//$this->worksheet->write($index,11,$observation['station']);
372
		//$this->worksheet->write($index,11,$observation['station']);
371
	 	//$this->worksheet->write($index,12,$observation['milieu']);
373
	 	//$this->worksheet->write($index,12,$observation['milieu']);
372
	 	$this->worksheet->write($index,7,$observation['identifiant']);
374
	 	$this->worksheet->write($index,7,$observation['identifiant']);
373
		$this->worksheet->write($index,8,$observation['commentaire']);
375
		$this->worksheet->write($index,8,$observation['commentaire']);
374
    }
376
    }
375
}
377
}
376
 
378
 
377
 
379
 
378
/* +--Fin du code ---------------------------------------------------------------------------------------+
380
/* +--Fin du code ---------------------------------------------------------------------------------------+
379
* $Log$
381
* $Log$
380
* Revision 1.5  2008-11-13 11:29:12  ddelon
382
* Revision 1.5  2008-11-13 11:29:12  ddelon
381
* Reecriture gwt-ext
383
* Reecriture gwt-ext
382
*
384
*
383
* Revision 1.4  2007-06-06 13:31:16  ddelon
385
* Revision 1.4  2007-06-06 13:31:16  ddelon
384
* v0.09
386
* v0.09
385
*
387
*
386
* Revision 1.3  2007-05-22 12:54:09  ddelon
388
* Revision 1.3  2007-05-22 12:54:09  ddelon
387
* Securisation acces utilisateur
389
* Securisation acces utilisateur
388
*
390
*
389
*
391
*
390
*
392
*
391
*/
393
*/
392
 
394
 
393
?>
395
?>