New file |
0,0 → 1,105 |
<?php |
/*vim: set expandtab tabstop=4 shiftwidth=4: */ |
// +------------------------------------------------------------------------------------------------------+ |
// | PHP version 4.1 | |
// +------------------------------------------------------------------------------------------------------+ |
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) | |
// +------------------------------------------------------------------------------------------------------+ |
// | This library is free software; you can redistribute it and/or | |
// | modify it under the terms of the GNU Lesser General Public | |
// | License as published by the Free Software Foundation; either | |
// | version 2.1 of the License, or (at your option) any later version. | |
// | | |
// | This library is distributed in the hope that it will be useful, | |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
// | Lesser General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU Lesser General Public | |
// | License along with this library; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
// +------------------------------------------------------------------------------------------------------+ |
// CVS : $Id: projet.fonct.rss.php,v 1.1 2005-10-25 13:50:54 alexandre_tb Exp $ |
/** |
* Générateur de flux RSS à partir de l'application projet |
* |
*@package projet |
//Auteur original : |
*@author Alexandre Granier <alexandre@tela-botanica.org> |
* |
*@copyright Tela-Botanica 2000-2004 |
*@version $$ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
|
// +------------------------------------------------------------------------------------------------------+ |
// | ENTETE du PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
|
// +------------------------------------------------------------------------------------------------------+ |
// | CORPS DU PROGRAMME | |
// +------------------------------------------------------------------------------------------------------+ |
|
|
/** gen_RSS() - générer un fichier de flux RSS par type liste |
* |
* @param string Le type de l'annonce (laisser vide pour tout type d'annonce) |
* @param integer Le nombre d'annonces a regrouper dans le fichier XML (laisser vide pour toutes) |
* @param integer L'identifiant de l'emetteur (laisser vide pour tous) |
* @param integer L'état de validation de l'annonce (laisser 1 pour les annonces validées, 0 pour les non-validées) |
* @param string La requête SQL personnalisée |
* |
* @return string Le code du flux RSS |
*/ |
function gen_RSS($domaine='', $nbitem='', $liste='') { |
|
// En-tête du flux RSS version 2.0 |
$xml = '<?xml version="1.0" encoding="ISO-8859-1"?>'."\n".'<rss version="2.0">'."\n"; |
$xml .= '<channel>'."\n".'<title>'.$nomflux.'</title>'."\n".'<link>'.BAZ_RSS_ADRESSESITE.'</link>'."\n"; |
$xml .= '<description>'.BAZ_RSS_DESCRIPTIONSITE.'</description>'."\n".'<language>fr-FR</language>'."\n". |
'<copyright>Copyright 2005 '.BAZ_RSS_NOMSITE.'</copyright>'."\n"; |
// Ajout de la date actuelle de publication (suivant la DTD RSS) |
$xml .= '<lastBuildDate>'.strftime('%d %b %Y %H:%M:%S GMT').'</lastBuildDate>'."\n"; |
// En-tête suite et fin |
$xml .= '<docs>http://www.stervinou.com/projets/rss/</docs>'."\n".'<category>'.BAZ_RSS_CATEGORIE.'</category>'."\n". |
'<managingEditor>'.BAZ_RSS_MANAGINGEDITOR.'</managingEditor>'."\n".'<webMaster>'.BAZ_RSS_WEBMASTER.'</webMaster>'."\n"; |
$xml .= '<ttl>60</ttl>'."\n".'<image>'."\n".'<title>'.BAZ_RSS_NOMSITE.'</title>'."\n".'<url>'.BAZ_RSS_LOGOSITE.'</url>'."\n". |
'<link>'.BAZ_RSS_ADRESSESITE.'</link>'."\n".'</image>'."\n"; |
if ($resultat->numRows()>0) { |
// Creation des items : titre + lien + description + date de publication |
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) { |
$xml .= '<item>'."\n"; |
$xml .= '<title>'.$ligne['bf_titre'].'</title>'."\n"; |
$lien=$GLOBALS['_BAZAR_']['url']; |
$lien->addQueryString('action', BAZ_VOIR_FICHE); |
$lien->addQueryString('id_fiche', $ligne['bf_id_fiche']); |
$xml .= '<link>'.str_replace ('&', '&', $lien->getURL()).'</link>'."\n"; |
$xml .= '<description>'."\n".'<![CDATA['.baz_voir_fiche(0,$ligne['bf_id_fiche']).']]>'."\n".'</description>'."\n"; |
$xml .= '<pubDate>'.strftime('%d %b %Y %H:%M:%S GMT',strtotime($ligne['bf_date_debut_validite_fiche'])).'</pubDate>'."\n"; |
$xml .= '</item>'."\n"; |
} |
} |
else {//pas d'annonces |
$xml .= '<item>'."\n"; |
$xml .= '<title>'.BAZ_PAS_D_ANNONCES.'</title>'."\n"; |
$xml .= '<link></link>'."\n"; |
$xml .= '<description>'.BAZ_PAS_D_ANNONCES.'</description>'."\n"; |
$xml .= '<pubDate>'.strftime('%d %b %Y %H:%M:%S GMT',strtotime('12/12/2004')).'</pubDate>'."\n"; |
$xml .= '</item>'."\n"; |
} |
$xml .= '</channel>'."\n".'</rss>'."\n"; |
return $xml; |
} |
|
|
/** baz_liste() Formate la liste de toutes les annonces actuelles |
* |
* @return string le code HTML à afficher |
*/ |
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* $Log: not supported by cvs2svn $ |
|
* +-- Fin du code ----------------------------------------------------------------------------------------+ |
*/ |
?> |