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