Subversion Repositories Applications.projet

Rev

Rev 56 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
56 alexandre_ 1
<?php
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */
3
// +------------------------------------------------------------------------------------------------------+
4
// | PHP version 4.1                                                                                      |
5
// +------------------------------------------------------------------------------------------------------+
6
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
7
// +------------------------------------------------------------------------------------------------------+
8
// | This library is free software; you can redistribute it and/or                                        |
9
// | modify it under the terms of the GNU Lesser General Public                                           |
10
// | License as published by the Free Software Foundation; either                                         |
11
// | version 2.1 of the License, or (at your option) any later version.                                   |
12
// |                                                                                                      |
13
// | This library is distributed in the hope that it will be useful,                                      |
14
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
15
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
16
// | Lesser General Public License for more details.                                                      |
17
// |                                                                                                      |
18
// | You should have received a copy of the GNU Lesser General Public                                     |
19
// | License along with this library; if not, write to the Free Software                                  |
20
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
21
// +------------------------------------------------------------------------------------------------------+
180 neiluj 22
// CVS : $Id: projet.fonct.rss.php,v 1.2 2007-03-28 08:51:22 neiluj Exp $
56 alexandre_ 23
/**
24
* Générateur de flux RSS à partir de l'application projet
25
*
26
*@package projet
27
//Auteur original :
28
*@author        Alexandre Granier <alexandre@tela-botanica.org>
29
*
30
*@copyright     Tela-Botanica 2000-2004
31
*@version       $$
32
// +------------------------------------------------------------------------------------------------------+
33
*/
34
 
35
// +------------------------------------------------------------------------------------------------------+
36
// |                                            ENTETE du PROGRAMME                                       |
37
// +------------------------------------------------------------------------------------------------------+
38
 
39
// +------------------------------------------------------------------------------------------------------+
40
// |                                            CORPS DU PROGRAMME                                        |
41
// +------------------------------------------------------------------------------------------------------+
42
 
43
 
44
/** gen_RSS() - générer un fichier de flux RSS par type liste
45
*
46
* @param   string Le type de l'annonce (laisser vide pour tout type d'annonce)
47
* @param   integer Le nombre d'annonces a regrouper dans le fichier XML (laisser vide pour toutes)
48
* @param   integer L'identifiant de l'emetteur (laisser vide pour tous)
49
* @param   integer L'état de validation de l'annonce (laisser 1 pour les annonces validées, 0 pour les non-validées)
50
* @param   string La requête SQL personnalisée
51
*
52
* @return  string Le code du flux RSS
53
*/
54
function gen_RSS($domaine='', $nbitem='', $liste='') {
55
 
56
	// En-tête du flux RSS version 2.0
57
	$xml = '<?xml version="1.0" encoding="ISO-8859-1"?>'."\n".'<rss version="2.0">'."\n";
58
	$xml .= '<channel>'."\n".'<title>'.$nomflux.'</title>'."\n".'<link>'.BAZ_RSS_ADRESSESITE.'</link>'."\n";
59
	$xml .= '<description>'.BAZ_RSS_DESCRIPTIONSITE.'</description>'."\n".'<language>fr-FR</language>'."\n".
60
	'<copyright>Copyright 2005 '.BAZ_RSS_NOMSITE.'</copyright>'."\n";
61
	// Ajout de la date actuelle de publication (suivant la DTD RSS)
62
	$xml .= '<lastBuildDate>'.strftime('%d %b %Y %H:%M:%S GMT').'</lastBuildDate>'."\n";
63
	// En-tête suite et fin
64
	$xml .= '<docs>http://www.stervinou.com/projets/rss/</docs>'."\n".'<category>'.BAZ_RSS_CATEGORIE.'</category>'."\n".
65
	'<managingEditor>'.BAZ_RSS_MANAGINGEDITOR.'</managingEditor>'."\n".'<webMaster>'.BAZ_RSS_WEBMASTER.'</webMaster>'."\n";
66
	$xml .= '<ttl>60</ttl>'."\n".'<image>'."\n".'<title>'.BAZ_RSS_NOMSITE.'</title>'."\n".'<url>'.BAZ_RSS_LOGOSITE.'</url>'."\n".
67
	'<link>'.BAZ_RSS_ADRESSESITE.'</link>'."\n".'</image>'."\n";
68
	if ($resultat->numRows()>0) {
69
		// Creation des items : titre + lien + description + date de publication
70
		while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
71
			$xml .= '<item>'."\n";
72
			$xml .= '<title>'.$ligne['bf_titre'].'</title>'."\n";
73
			$lien=$GLOBALS['_BAZAR_']['url'];
74
			$lien->addQueryString('action', BAZ_VOIR_FICHE);
75
			$lien->addQueryString('id_fiche', $ligne['bf_id_fiche']);
76
			$xml .= '<link>'.str_replace ('&', '&amp;', $lien->getURL()).'</link>'."\n";
77
			$xml .= '<description>'."\n".'<![CDATA['.baz_voir_fiche(0,$ligne['bf_id_fiche']).']]>'."\n".'</description>'."\n";
78
			$xml .= '<pubDate>'.strftime('%d %b %Y %H:%M:%S GMT',strtotime($ligne['bf_date_debut_validite_fiche'])).'</pubDate>'."\n";
79
			$xml .= '</item>'."\n";
80
		}
81
	}
82
	else {//pas d'annonces
83
		$xml .= '<item>'."\n";
84
		$xml .= '<title>'.BAZ_PAS_D_ANNONCES.'</title>'."\n";
85
		$xml .= '<link></link>'."\n";
86
		$xml .= '<description>'.BAZ_PAS_D_ANNONCES.'</description>'."\n";
87
		$xml .= '<pubDate>'.strftime('%d %b %Y %H:%M:%S GMT',strtotime('12/12/2004')).'</pubDate>'."\n";
88
		$xml .= '</item>'."\n";
89
	}
90
	$xml .= '</channel>'."\n".'</rss>'."\n";
91
	return $xml;
92
}
93
 
94
 
95
/** baz_liste() Formate la liste de toutes les annonces actuelles
96
*
97
*   @return  string    le code HTML à afficher
98
*/
99
/* +--Fin du code ----------------------------------------------------------------------------------------+
100
*
101
* $Log: not supported by cvs2svn $
180 neiluj 102
* Revision 1.1  2005/10/25 13:50:54  alexandre_tb
103
* version initiale
104
*
56 alexandre_ 105
 
106
* +-- Fin du code ----------------------------------------------------------------------------------------+
107
*/
108
?>