Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 416 Rev 869
Line 1... Line 1...
1
<?php
1
<?php
-
 
2
// ATTENTION ! Classe compatible uniquement avec nouveau format de bdd du cel //
-
 
3
 
2
/**
4
/**
3
* PHP Version 5
5
* PHP Version 5
4
*
6
*
5
* @category  PHP
7
* @category  PHP
6
* @package   jrest
8
* @package   jrest
Line 9... Line 11...
9
* @license   http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
11
* @license   http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
10
* @version   SVN: <svn_id>
12
* @version   SVN: <svn_id>
11
* @link      /doc/jrest/
13
* @link      /doc/jrest/
12
*/
14
*/
Line -... Line 15...
-
 
15
 
13
 
16
/**
14
Class ImageContribution extends DBAccessor {
17
 * Classe renvoyant une liste très succinte des observations liées à une image de l'utilisateur 
15
 
-
 
16
	var $config;
18
 * 
17
 
19
 */
18
    function ImageContribution($config) {
20
class ImageContribution extends Cel {
-
 
21
 
-
 
22
	/**
19
 
23
	 * Renvoi un petit bout de html contenant les dernières obs liées à 
20
        $this->config=$config;
24
	 * une image d'un utilisateur
-
 
25
	 * 
-
 
26
	 * @param string $uid[0] le type de requête (à venir)
21
    }
27
	 * @param string $uid[1] identifiant numérique de l'utilisateur
22
 
28
	 */
Line 23... Line -...
23
	function getElement($uid){
-
 
24
 
-
 
25
        $DB=$this->connectDB($this->config,'cel_db');
-
 
26
 
-
 
27
       /* $query='SELECT * FROM cel_images';
-
 
28
        $query .= ' WHERE ci_ce_utilisateur ="'.$uid[0].'"' ;
-
 
29
        $query .= ' ORDER BY ci_meta_date_ajout DESC LIMIT 0,5' ;*/
29
	function getElement($uid){
30
 
30
 
31
        $query = 'SELECT * FROM cel_inventory'.
31
        $requete_obs_liee_images = 'SELECT * FROM cel_obs'.
32
        		' WHERE identifiant = "'.$uid[1].'"'.
32
        		' WHERE ce_utilisateur = '.$this->proteger($uid[1]).
33
        		' AND ordre IN (SELECT coi_ce_observation
33
        		' AND id_observation IN (SELECT id_observation
34
								FROM cel_obs_images
34
								FROM cel_obs_images
35
								WHERE coi_ce_utilisateur ="'.$uid[1].'" )'.
35
								WHERE id_utilisateur = '.$this->proteger($uid[1]).' )'.
Line 36... Line -...
36
				' AND transmission =  1'.
-
 
37
				' ORDER BY date_modification DESC LIMIT 0,5';
-
 
38
 
-
 
39
        $res =& $DB->query($query);
-
 
40
 
-
 
41
        if (DB::isError($res)) {
-
 
42
            die($res->getMessage());
36
				' AND transmission =  0'.
-
 
37
				' ORDER BY date_modification DESC LIMIT 0,5';
-
 
38
 
-
 
39
        $html = '<div id="resume_cel">';
-
 
40
        
-
 
41
        $obs_liees_images = array();
-
 
42
        
-
 
43
        $resultat_obs_liees_images = $this->requeter($requete_obs_liee_images);
-
 
44
        
Line 43... Line -...
43
        }
-
 
44
 
-
 
45
        $html = '<div id="resume_cel">';
-
 
46
 
-
 
47
        while ($obs =& $res->fetchrow(DB_FETCHMODE_ASSOC)) {
-
 
48
 
-
 
49
            $chemin_sur_serveur = $this->config['cel_db']['url_images'];
-
 
50
 
-
 
51
            $req_liaison = 'SELECT * FROM cel_images WHERE ci_id_image IN (SELECT coi_ce_image FROM cel_obs_images WHERE coi_ce_observation = "'.$obs['ordre'].'") AND ci_ce_utilisateur = "'.$obs['identifiant'].'"' ;
45
        if(is_array($resultat_obs_liees_images)) {
52
            $res_liaison =& $DB->query($req_liaison);
-
 
53
 
-
 
54
            if (DB::isError($res_liaison)) {
-
 
55
                die($res_liaison->getMessage());
-
 
56
            }
-
 
57
 
-
 
58
           while ($img =& $res_liaison->fetchrow(DB_FETCHMODE_ASSOC)) {
-
 
59
				$row = $img;
-
 
60
           }
-
 
61
 
-
 
62
           $row['ci_nom_original'] = htmlspecialchars($row['ci_nom_original']);
-
 
63
           $row['ci_id_image'] = htmlspecialchars($row['ci_id_image']);
-
 
64
           $id = $row['ci_id_image'];
-
 
65
 
-
 
66
           $tailleXY = $this->calculerDimensions(array($row['ci_meta_width'], $row['ci_meta_height']));
-
 
67
 
-
 
68
            $id = sprintf('%09s', $id) ;
-
 
69
            $id = wordwrap($id, 3 , '_', true) ;
-
 
70
 
-
 
71
            $id_fichier = $id.".jpg" ;
-
 
72
 
-
 
73
            $niveauDossier = split("_", $id) ;
-
 
74
 
-
 
75
            $dossierNiveau1 = $niveauDossier[0] ;
-
 
76
            $dossierNiveau2 = $niveauDossier[1] ;
-
 
77
 
-
 
78
            $chemin_sur_serveur_final = $chemin_sur_serveur.'/'.$dossierNiveau1.'/'.$dossierNiveau2 ;
-
 
79
 
-
 
Line 80... Line 46...
80
            $chemin_fichier = $chemin_sur_serveur_final.'/L/'.$id."_L.jpg" ;
46
        	$obs_liees_images = $resultat_obs_liees_images;
81
            $chemin_fichier_s = $chemin_sur_serveur_final.'/M/'.$id."_M.jpg" ;
-
 
82
 
-
 
83
            $html .= '<div class="item_resume_cel">';
-
 
84
 
-
 
Line -... Line 47...
-
 
47
        }
-
 
48
 
-
 
49
        foreach ($obs_liees_images as $obs) {
-
 
50
 
-
 
51
			$chemin_sur_serveur = $this->config['cel_db']['url_images'];
-
 
52
 
-
 
53
            $requete_img_liees = 'SELECT * FROM cel_images WHERE id_image '.
-
 
54
						   'IN (SELECT id_image FROM cel_obs_images '.
-
 
55
						   'WHERE id_observation = "'.$obs['id_observation'].'") '.
-
 
56
						   'AND ce_utilisateur = "'.$obs['ce_utilisateur'].'"' ;
-
 
57
 
-
 
58
			$resultat_requete_img_liees = $this->requeter($requete_img_liees);
-
 
59
 
-
 
60
			if (is_array($resultat_requete_img_liees) && count($resultat_requete_img_liees) > 0) {
-
 
61
				
-
 
62
				$premiere_image_liee = $resultat_requete_img_liees[0];
-
 
63
 
-
 
64
	           	$premiere_image_liee['nom_original'] = htmlspecialchars($premiere_image_liee['nom_original']);
-
 
65
	           	$premiere_image_liee['id_image'] = htmlspecialchars($premiere_image_liee['id_image']);
-
 
66
	           	$id = $premiere_image_liee['id_image'];
-
 
67
	
-
 
68
	           	$tailleXY = $this->calculerDimensions(array($premiere_image_liee['largeur'], $premiere_image_liee['hauteur']));
-
 
69
	
-
 
70
	            $id = sprintf('%09s', $id) ;
-
 
71
	            $id = wordwrap($id, 3 , '_', true) ;
-
 
72
	
-
 
73
	            $id_fichier = $id.".jpg" ;
-
 
74
	
-
 
75
	            $niveauDossier = split("_", $id) ;
-
 
76
	
-
 
77
	            $dossierNiveau1 = $niveauDossier[0] ;
-
 
78
	            $dossierNiveau2 = $niveauDossier[1] ;
-
 
79
	
-
 
80
	            $chemin_sur_serveur_final = $chemin_sur_serveur.'/'.$dossierNiveau1.'/'.$dossierNiveau2 ;
-
 
81
	
-
 
82
	            $chemin_fichier = $chemin_sur_serveur_final.'/L/'.$id."_L.jpg" ;
-
 
83
	            $chemin_fichier_s = $chemin_sur_serveur_final.'/M/'.$id."_M.jpg" ;
-
 
84
	
-
 
85
	            $html .= '<div class="item_resume_cel">';
-
 
86
	
85
           	$html .= '<h4><a href="'.$chemin_fichier.'">'.$obs['nom_ret'].'</a></h4>'.
87
	           	$html .= '<h4><a href="'.$chemin_fichier.'">'.$obs['nom_ret'].'</a></h4>'.
-
 
88
	          	'<img src="'.$chemin_fichier_s.'" alt="'.$premiere_image_liee['nom_original'].'" height="'.$tailleXY[1].'px" width="'.$tailleXY[0].'px"></img><br/>';
86
          	'<img src="'.$chemin_fichier_s.'" alt="'.$row['ci_nom_original'].'" height="'.$tailleXY[1].'px" width="'.$tailleXY[0].'px"></img><br/>';
89
	            $html .= '<span>Datée du '.$obs['date_modification'].'<br/>'  ;
Line 87... Line 90...
87
            $html .= '<span>Datée du '.$obs['date_modification'].'<br/>'  ;
90
	            $html .= 'Lieu : '.trim($obs['zone_geo'],'000null').' ('.trim($obs['ce_zone_geo'],'000null').') '.trim($obs['station'],'000null').' '.trim($obs['lieudit'],'000null').'<br/></p>'  ;
Line 88... Line -...
88
            $html .= 'Lieu : '.trim($obs['location'],'000null').' ('.trim($obs['id_location'],'000null').') '.trim($obs['station'],'000null').' '.trim($obs['lieudit'],'000null').'<br/></p>'  ;
-
 
89
			$html .= '</span>';
91
				$html .= '</span>';
90
 
92
	
91
         	 $html .= '</div>';
93
	         	$html .= '</div>';
92
        }
94
			}
Line 93... Line 95...
93
 
95
        }
Line 94... Line 96...
94
        $html.= '</div>';
96
 
Line 95... Line 97...
95
 
97
        $html.= '</div>';
96
 
98
 
Line 127... Line 129...
127
 
129
 
128
        return $tailleXY ;
130
        return $tailleXY ;
Line 129... Line 131...
129
    }
131
    }
130
 
132
 
131
}
133
}