Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 628 Rev 871
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
* Retourne un RDF des images pour eflore
7
* Retourne un RDF des images pour eflore
6
*
8
*
Line 10... Line 12...
10
* @copyright 2010 Tela-Botanica
12
* @copyright 2010 Tela-Botanica
11
* @license   http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
13
* @license   http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
12
* @version   SVN: <svn_id>
14
* @version   SVN: <svn_id>
13
* @link      /doc/jrest/
15
* @link      /doc/jrest/
14
*/
16
*/
15
Class ImageRDF extends DBAccessor {
17
class ImageRDF extends Cel {
16
 
-
 
17
	var $config;
-
 
18
 
-
 
19
    function ImageRDF($config) {
-
 
20
 
-
 
21
    	$this->config=$config;
-
 
22
    }
-
 
Line 23... Line -...
23
 
-
 
24
    
-
 
25
    
18
 
26
	/**
19
	/**
27
	 * Recherche des images associee au numero nomenclatural
20
	 * Recherche des images associee au numero nomenclatural
28
	 * @param numeric $uid [0] : numero nomenclatural obligatoire , $uid[1] (optionnel) : taille image : S , M,  L (default)
21
	 * @param numeric $uid [0] : numero nomenclatural obligatoire , $uid[1] (optionnel) : taille image : S , M,  L (default)
29
	 */
-
 
30
    
-
 
31
    
-
 
32
    // TODO : recherche taxon ?
-
 
33
    
22
	 */    
Line 34... Line -...
34
	function getElement($uid){
-
 
-
 
23
	function getElement($uid){
35
 
24
 
36
		
25
		// TODO : recherche taxon ?
37
		// Taille 
26
		// Taille 
38
		if (isset($uid[1])) {
27
		if (isset($uid[1])) {
39
			$taille = $uid[1]; // S , M ou L
28
			$taille = $uid[1]; // S , M ou L
40
		}
29
		}
41
		else {
30
		else {
42
			$taille = 'L';
-
 
43
		} 
-
 
44
		
-
 
45
		
-
 
46
        $DB=$this->connectDB($this->config,'cel_db');
-
 
47
        
-
 
48
        // Recherche de toutes les observations transmises du taxon pour lesquelles une photo est associee. 
-
 
49
                
-
 
50
        $query = 'SELECT * FROM cel_inventory, cel_obs_images, cel_images '.
-
 
51
        		' WHERE cel_inventory.num_nom_sel = "'.mysql_escape_string($uid[0]).'"'.
-
 
52
        		' AND cel_obs_images.coi_ce_utilisateur = cel_inventory.identifiant '.
-
 
53
        		' AND cel_obs_images.coi_ce_observation = cel_inventory.ordre '.
-
 
54
				' AND cel_inventory.transmission =  1 '.
-
 
55
				' AND cel_images.ci_ce_utilisateur = cel_obs_images.coi_ce_utilisateur '. 
-
 
Line -... Line 31...
-
 
31
			$taille = 'L';
-
 
32
		} 
56
				' AND  ci_id_image = cel_obs_images.coi_ce_image';
33
        
57
 
-
 
58
        
34
        // Recherche de toutes les observations transmises du taxon pour lesquelles une photo est associee.        
59
        $result =& $DB->query($query);
35
        $requete_obs_publiques_images_taxon = 'SELECT * FROM cel_obs, cel_obs_images, cel_images '.
60
 
36
        		' WHERE cel_obs.nom_sel_nn = '.$this->proteger($uid[0]).
61
        if (DB::isError($result)) {
-
 
-
 
37
        		' AND cel_obs_images.id_utilisateur = cel_obs.ce_utilisateur '.
-
 
38
        		' AND cel_obs_images.id_observation = cel_obs.id_observation '.
Line -... Line 39...
-
 
39
				' AND cel_obs.transmission =  0 '.
62
            die($result->getMessage());
40
				' AND cel_images.ce_utilisateur = cel_obs_images.id_utilisateur '. 
63
        }
-
 
64
 
41
				' AND cel_images.id_image = cel_obs_images.id_image';
65
 
42
 
66
        $picture_path = $this->config['cel_db']['url_images'];           
43
        $resultat_requete_obs_images_taxon = $this->requeter($requete_obs_publiques_images_taxon);
67
           	
44
        $picture_path = $this->config['cel_db']['url_images'];           
68
	    
45
           	    
69
		// Formatage du xml
46
		// Formatage du xml
70
		$xml = '<?xml version="1.0" encoding="utf-8"?>'."\n";
47
		$xml = '<?xml version="1.0" encoding="utf-8"?>'."\n";
71
		$xml .= '<rdf:RDF'."\n";
48
		$xml .= '<rdf:RDF'."\n";
-
 
49
		$xml .= '	xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"'."\n";
-
 
50
		$xml .= '	xmlns:dc="http://purl.org/dc/elements/1.1/"'."\n";
-
 
51
		$xml .= '	xmlns:dcterms="http://purl.org/dc/terms">'."\n";
-
 
52
		
Line 72... Line 53...
72
		$xml .= '	xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"'."\n";
53
		$images_obs_taxon = array();
73
		$xml .= '	xmlns:dc="http://purl.org/dc/elements/1.1/"'."\n";
-
 
Line -... Line 54...
-
 
54
		if (is_array($resultat_requete_obs_images_taxon)) {
74
		$xml .= '	xmlns:dcterms="http://purl.org/dc/terms">'."\n";
55
			$images_obs_taxon = $resultat_requete_obs_images_taxon;
75
			
56
		}
76
 
57
 
Line 77... Line 58...
77
        while ($picture =& $result->fetchrow(DB_FETCHMODE_ASSOC)) {
58
        foreach ($images_obs_taxon as $picture) {
Line 87... Line 68...
87
 
68
 
88
            $dossierNiveau1 = $niveauDossier[0] ;
69
            $dossierNiveau1 = $niveauDossier[0] ;
Line 89... Line 70...
89
            $dossierNiveau2 = $niveauDossier[1] ;
70
            $dossierNiveau2 = $niveauDossier[1] ;
90
 
-
 
91
            $picture_path_with_level = $picture_path.'/'.$dossierNiveau1.'/'.$dossierNiveau2 ;
71
 
92
 
-
 
-
 
72
            $picture_path_with_level = $picture_path.'/'.$dossierNiveau1.'/'.$dossierNiveau2 ;
93
         
73
       
94
             
74
       		// TODO: mettre nom prénom dans créateur ? ou mail ?
95
			$xml .= '	<rdf:Description about="'.$picture_path_with_level.'/'.$taille.'/'.$id.'_'.$taille.'.jpg'.'"'."\n";
75
			$xml .= '	<rdf:Description about="'.$picture_path_with_level.'/'.$taille.'/'.$id.'_'.$taille.'.jpg'.'"'."\n";
96
			$xml .= '		dc:identifier="'.'urn:lsid:tela-botanica.org:celpic:'.$picture['ci_id_image'].'"'."\n";
76
			$xml .= '		dc:identifier="'.'urn:lsid:tela-botanica.org:celpic:'.$picture['id_image'].'"'."\n";
97
			$xml .= '		dc:title="'.$picture['nom_sel'].'"'."\n";
77
			$xml .= '		dc:title="'.$picture['nom_sel'].'"'."\n";
98
			$xml .= '		dc:description="'.$picture['nom_sel']." - [fichier_origine:".$picture['ci_nom_original'].'][image_identifiant:'.$picture['ci_id_image'].']';
78
			$xml .= '		dc:description="'.$picture['nom_sel']." - [fichier_origine:".$picture['nom_original'].'][image_identifiant:'.$picture['id_image'].']';
99
			$xml .= '[image_ordre:'.$picture['ci_ordre'].']';
79
			$xml .= '[image_ordre:'.$picture['ordre'].']';
100
			$xml .= '[observation_identifiant:'.$picture['id'].']';
80
			$xml .= '[observation_identifiant:'.$picture['id_observation'].']';
101
			$xml .= '[observation_ordre:'.$picture['ordre'].']'.'"'."\n";
81
			$xml .= '[observation_ordre:'.$picture['ordre'].']'.'"'."\n";
102
			$xml .= '		dc:creator="'.$picture['identifiant'].'"'."\n";
82
			$xml .= '		dc:creator="'.$picture['ce_utilisateur'].'"'."\n";
Line 103... Line 83...
103
			$xml .= '		dc:publisher="CEL"'."\n";
83
			$xml .= '		dc:publisher="CEL"'."\n";
104
			$xml .= '		dcterms:spatial="'.utf8_decode($picture['location'])." (".$picture['id_location'].")".'"'."\n";
84
			$xml .= '		dcterms:spatial="'.utf8_decode($picture['zone_geo'])." (".$picture['ce_zone_geo'].")".'"'."\n";
105
			
85
			
106
	        if ($picture['date_observation'] != '0000-00-00 00:00:00') {
86
	        if ($picture['date_observation'] != '0000-00-00 00:00:00') {
Line 114... Line 94...
114
		
94
		
Line 115... Line 95...
115
		$xml .= '</rdf:RDF>'."\n";
95
		$xml .= '</rdf:RDF>'."\n";
116
		
96
		
117
		// Envoi du xml au navigateur
97
		// Envoi du xml au navigateur
118
		header("Content-Type: text/xml");
-
 
Line 119... Line 98...
119
		echo utf8_encode(str_replace(' & ', ' &#38; ', $xml));
98
		header("Content-Type: text/xml");
Line 120... Line 99...
120
		
99
		echo utf8_encode(str_replace(' & ', ' &#38; ', $xml));		
121
 
100