Subversion Repositories Applications.projet

Rev

Rev 389 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 389 Rev 431
Line 1... Line 1...
1
<?php
1
<?php
2
/**
2
/**
3
* PHP Version 5
3
* PHP Version 5
4
*
4
*
5
* @category  PHP
5
* @category  PHP
6
* @package   papyrus_bp
6
* @package   papyrus_bp
7
* @author    aurelien <aurelien@tela-botanica.org>
7
* @author    aurelien <aurelien@tela-botanica.org>
8
* @copyright 2010 Tela-Botanica
8
* @copyright 2010 Tela-Botanica
9
* @license   http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
9
* @license   http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
10
* @version   SVN: <svn_id>
10
* @version   SVN: <svn_id>
11
* @link      /doc/papyrus_bp/
11
* @link      /doc/papyrus_bp/
12
*/
12
*/
13
 
13
 
14
Class DocumentsRss extends ProjetService {
14
Class DocumentsRss extends ProjetService {
15
	
15
	
16
	public function __construct($config, $demarrer_session= true) {
16
	public function __construct($config, $demarrer_session= true) {
17
		parent::__construct($config, $demarrer_session);
17
		parent::__construct($config, $demarrer_session);
18
	}
18
	}
19
	
19
	
20
	// TODO: gérer plusieurs format et utiliser les mêmes classes communes que 
20
	// TODO: gérer plusieurs format et utiliser les mêmes classes communes que 
21
	// celles du cel
21
	// celles du cel
22
	public function getElement($uid){
22
	public function getElement($uid){
23
	    
23
	    
24
	    $format = 'rss2';
24
	    $format = 'rss2';
25
 
25
 
26
		// on selectionne les projets les plus actifs
26
		// on selectionne les projets les plus actifs
27
		$requete_docs_projets = 'SELECT * FROM projet_documents '.
27
		$requete_docs_projets = 'SELECT * FROM projet_documents '.
28
 								'WHERE pd_ce_type != 0 AND pd_visibilite = "public" '.
28
 								'WHERE pd_ce_type != 0 AND pd_visibilite = "public" '.
29
 								'ORDER BY pd_date_de_mise_a_jour DESC '.
29
 								'ORDER BY pd_date_de_mise_a_jour DESC '.
30
 								'LIMIT 0,5';
30
 								'LIMIT 0,5';
31
		
31
		
32
		$resume = array();
32
		$resume = array();
33
 
33
 
34
		$titre = htmlspecialchars('Derniers documents publics ');
34
		$titre = htmlspecialchars('Derniers documents publics ');
35
		$lien = 'http://www.tela-botanica.org/page:liste_projets';
35
		$lien = 'http://www.tela-botanica.org/page:liste_projets';
36
 
36
 
37
		$docs = $this->bdd->query($requete_docs_projets)->fetchAll();
37
		$docs = $this->bdd->query($requete_docs_projets)->fetchAll();
38
	    
38
	    
39
	    $rss = '<?xml version="1.0" encoding="UTF-8"?>'.
39
	    $rss = '<?xml version="1.0" encoding="UTF-8"?>'.
40
		'<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
40
		'<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
41
			<channel>
41
			<channel>
42
				<title>'.$titre.'</title>
42
				<title>'.$titre.'</title>
43
				<link>'.$lien.'</link>
43
				<link>'.$lien.'</link>
44
				<atom:link href="" rel="self" type="application/rss+xml" />
44
				<atom:link href="" rel="self" type="application/rss+xml" />
45
				<description>'.$titre.'</description>';
45
				<description>'.$titre.'</description>';
46
	    
46
	    
47
		foreach($docs as $doc) {
47
		foreach($docs as $doc) {
48
			
48
			
49
			$infos_projet = $this->obtenirInformationsProjet($doc['pd_ce_projet']);
49
			$infos_projet = $this->obtenirInformationsProjet($doc['pd_ce_projet']);
50
			
50
			
51
			$date_modification_timestamp = strtotime($doc['pd_date_de_mise_a_jour']);
51
			$date_modification_timestamp = strtotime($doc['pd_date_de_mise_a_jour']);
52
			$date_maj_doc = date(DATE_RSS, $date_modification_timestamp);
52
			$date_maj_doc = date(DATE_RSS, $date_modification_timestamp);
53
	    		    			    	
53
	    		    			    	
54
	    	$nom_projet = 'Dans le projet '.$infos_projet[0]['p_titre'];
54
	    	$nom_projet = 'Dans le projet '.$infos_projet[0]['p_titre'];
55
	    	
55
	    	
56
	    	$id_doc = $doc['pd_id'];
56
	    	$id_doc = $doc['pd_id'];
57
	    	$nom_doc = $doc['pd_nom'];
57
	    	$nom_doc = $doc['pd_nom'];
58
			
58
			
59
			$description = preg_replace('/&(?!(a-z+|#0-9+|#x0-9a-f+);)/i', '&amp;', $nom_projet);
59
			$description = preg_replace('/&(?!(a-z+|#0-9+|#x0-9a-f+);)/i', '&amp;', $nom_projet);
60
			$description = preg_replace('/000null/i', '', $nom_projet);
60
			$description = preg_replace('/000null/i', '', $nom_projet);
61
			$description = htmlspecialchars($description);
61
			$description = htmlspecialchars($description);
62
			
62
			
63
			$lien_doc = 'http://www.tela-botanica.org/projets/'.$doc['pd_ce_projet'].'/telechargement/'.$doc['pd_id'];
63
			$lien_doc = 'http://www.tela-botanica.org/projets/'.$doc['pd_ce_projet'].'/telechargement/'.$doc['pd_id'];
64
				
64
				
65
			$rss .='<item>
65
			$rss .='<item>
66
				  <guid>'.$id_doc.'</guid>
66
				  <guid>'.$id_doc.'</guid>
67
				  <title>'.$nom_doc.'</title>
67
				  <title>'.$nom_doc.'</title>
68
				  <link>'.$lien_doc.'</link>
68
				  <link>'.$lien_doc.'</link>
69
				  <description>'.$description.'</description>
69
				  <description>'.$description.'</description>
70
				  <category>Document</category>
70
				  <category>Document</category>
71
				  <pubDate>'.$date_maj_doc.'</pubDate>
71
				  <pubDate>'.$date_maj_doc.'</pubDate>
72
				</item>';
72
				</item>';
73
		}
73
		}
74
				
74
				
75
		$rss .=	'</channel>'.
75
		$rss .=	'</channel>'.
76
		'</rss>';
76
		'</rss>';
77
 
77
 
78
		echo $rss;
78
		echo $rss;
79
	}
79
	}
80
}
80
}
81
?>
81
?>
82
82