Subversion Repositories eFlore/Archives.herbiers

Compare Revisions

Ignore whitespace Rev 8 → Rev 9

/trunk/applications/hb_rss/hb_rss.php
19,7 → 19,7
// | 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: hb_rss.php,v 1.1 2006-10-30 18:57:17 jp_milcent Exp $
// CVS : $Id: hb_rss.php,v 1.2 2006-10-31 12:38:12 jp_milcent Exp $
/**
* Générateur de flux RSS pour les Herbiers
*
29,7 → 29,7
*@author Jean-Pascal MILCENT <jpm@tela-botanica.org>
*
*@copyright Tela-Botanica 2000-2006
*@version $Revision: 1.1 $
*@version $Revision: 1.2 $ $Date: 2006-10-31 12:38:12 $
// +------------------------------------------------------------------------------------------------------+
*/
 
59,11 → 59,73
$nbitem = '';
}
 
// Generation de la requete MySQL personnalisee
switch ('type') {
case 'herbier' :
$requete = 'SELECT DISTINCT ID_ORG AS id, INSTITUTION_NAME AS titre, DATE_DERNIERE_MODIF AS date_derniere_modif, U_NAME AS nom, U_SURNAME AS prenom '.
'FROM HERBIERS_ORGANISATION, '.HB_BDD_NOM_ANNUAIRE.'.annuaire_tela '.
'WHERE CE_MODIFIER_PAR = U_ID '.
'ORDER BY DATE_DERNIERE_MODIF DESC';
$url = HB_URL_COURANTE_CONSULTATION_FICHE_HERBIER_ID;
$aso_meta['titre'] = 'Flux des Organisations';
break;
case 'collection' :
$requete = 'SELECT DISTINCT ID AS id, NOM_COLLECTION AS titre, DATE_DERNIERE_MODIF AS date_derniere_modif, U_NAME AS nom, U_SURNAME AS prenom '.
'FROM HERBIERS_COLLECTION, '.HB_BDD_NOM_ANNUAIRE.'.annuaire_tela '.
'WHERE CE_MODIFIER_PAR = U_ID '.
'ORDER BY DATE_DERNIERE_MODIF DESC';
$url = HB_URL_COURANTE_CONSULTATION_FICHE_COLECTION_ID;
$aso_meta['titre'] = 'Flux des Collections';
break;
default :
$requete = '';
}
$tab_infos = array();
if ($requete != '') {
if ($nbitem != '') {
$requete .= ' LIMIT 0,'.$nbitem;
}
$resultat = $GLOBALS['_HERBIER_']['bdd']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
$aso_infos = array();
$aso_infos['title'] = $ligne['titre'];
$aso_infos['link'] = str_replace('&', '&amp;', sprintf($url, $ligne['id']));
$aso_infos['description'] = 'Modifié par '.$ligne['prenom'].' '.$ligne['nom'].' le '.$ligne['date_derniere_modif'];
$aso_infos['pubdate'] = strftime('%d %b %Y %H:%M:%S GMT', strtotime($ligne['date_derniere_modif']));
$tab_infos[] = $aso_infos;
}
} else {
$aso_flux = array('herbier', 'collection');
foreach ($aso_flux as $flux) {
$aso_infos = array();
$aso_infos['title'] = 'Flux RSS : '.$flux;
$GLOBALS['_HERBIER_']['url_rss']->addQueryString('type', $flux);
$aso_infos['link'] = str_replace('&', '&amp;', $GLOBALS['_HERBIER_']['url_rss']->getURL());
$aso_infos['description'] = 'Modifié par '.$ligne['prenom'].' '.$ligne['nom'].' le '.$ligne['date_derniere_modif'];
$aso_infos['pubdate'] = strftime('%d %b %Y %H:%M:%S GMT', strtotime(str_replace('$', str_replace('$Date: 2006-10-31 12:38:12 $Date$'))));
$tab_infos[] = $aso_infos;
}
}
$aso_meta['description'] = HBR_RSS_DESCRIPTIONSITE;
$aso_meta['link'] = HBR_RSS_ADRESSESITE;
$aso_meta['language'] = 'fr-FR';
$aso_meta['copyright'] = 'Copyright 2005 '.HBR_RSS_NOMSITE;
$aso_meta['lastBuildDate'] = strftime('%d %b %Y %H:%M:%S GMT');
$aso_meta['docs'] = 'http://www.stervinou.com/projets/rss/';
$aso_meta['category'] = HBR_RSS_CATEGORIE;
$aso_meta['managingEditor'] = HBR_RSS_MANAGINGEDITOR;
$aso_meta['webMaster'] = HBR_RSS_WEBMASTER;
$aso_meta['ttl'] = 60;
$aso_meta['image']['title'] = HBR_RSS_NOMSITE;
$aso_meta['image']['url'] = HBR_RSS_LOGOSITE;
$aso_meta['image']['link'] = HBR_RSS_ADRESSESITE;
 
echo html_entity_decode(gen_RSS($aso_meta, $tab_infos, $nbitem));
 
echo html_entity_decode(gen_RSS($annonce, $nbitem));
 
 
/** gen_RSS() - generer un fichier de flux RSS par type d'annonce
*
* @param string Le type de l'annonce (laisser vide pour tout type d'annonce)
75,61 → 137,60
*
* @return string Le code du flux RSS
*/
function gen_RSS($typeannonce='', $nbitem='') {
// Generation de la requete MySQL personnalisee
$requete = 'SELECT DISTINCT * '.
'FROM HERBIERS_ORGANISATION '.
'ORDER BY DATE_DERNIERE_MODIF DESC';
if ($nbitem!='') {
$requete .= ' LIMIT 0,'.$nbitem;
}
$resultat = $GLOBALS['_HERBIER_']['bdd']->query($requete) ;
if (DB::isError($resultat)) {
die ($resultat->getMessage().$resultat->getDebugInfo()) ;
}
// Initialisation des variables
$nomflux = 'Flux des '.$typeannonce;
function gen_RSS($meta = '', $infos = '', $nbitem = '') {
// En-tete 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>'.HBR_RSS_ADRESSESITE.'</link>'."\n";
$xml .= '<description>'.HBR_RSS_DESCRIPTIONSITE.'</description>'."\n".'<language>fr-FR</language>'."\n".
'<copyright>Copyright 2005 '.HBR_RSS_NOMSITE.'</copyright>'."\n";
$xml = '<?xml version="1.0" encoding="ISO-8859-1"?>'."\n";
$xml .= '<rss version="2.0">'."\n";
$xml .= '<channel>'."\n";
$xml .= "\t\t".'<title>'.$meta['titre'].'</title>'."\n";
$xml .= "\t\t".'<link>'.$meta['link'].'</link>'."\n";
$xml .= "\t\t".'<description>'.$meta['description'].'</description>'."\n";
$xml .= "\t\t".'<language>'.$meta['language'].'</language>'."\n";
$xml .= "\t\t".'<copyright>'.$meta['copyright'].'</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";
$xml .= "\t\t".'<lastBuildDate>'.$meta['lastBuildDate'].'</lastBuildDate>'."\n";
// En-tete suite et fin
$xml .= '<docs>http://www.stervinou.com/projets/rss/</docs>'."\n".'<category>'.HBR_RSS_CATEGORIE.'</category>'."\n".
'<managingEditor>'.HBR_RSS_MANAGINGEDITOR.'</managingEditor>'."\n".'<webMaster>'.HBR_RSS_WEBMASTER.'</webMaster>'."\n";
$xml .= '<ttl>60</ttl>'."\n".'<image>'."\n".'<title>'.HBR_RSS_NOMSITE.'</title>'."\n".'<url>'.HBR_RSS_LOGOSITE.'</url>'."\n".
'<link>'.HBR_RSS_ADRESSESITE.'</link>'."\n".'</image>'."\n";
if ($resultat->numRows() > 0) {
$xml .= "\t\t".'<docs>'.$meta['docs'].'</docs>'."\n";
$xml .= "\t\t".'<category>'.$meta['category'].'</category>'."\n";
$xml .= "\t\t".'<managingEditor>'.$meta['managingEditor'].'</managingEditor>'."\n";
$xml .= "\t\t".'<webMaster>'.$meta['webMaster'].'</webMaster>'."\n";
$xml .= "\t\t".'<ttl>'.$meta['ttl'].'</ttl>'."\n";
$xml .= "\t\t".'<image>'."\n";
$xml .= "\t\t\t".'<title>'.$meta['image']['title'].'</title>'."\n";
$xml .= "\t\t\t".'<url>'.$meta['image']['url'].'</url>'."\n";
$xml .= "\t\t\t".'<link>'.$meta['image']['link'].'</link>'."\n";
$xml .= "\t\t".'</image>'."\n";
if (count($infos) > 0) {
// Creation des items : titre + lien + description + date de publication
while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
$xml .= '<item>'."\n";
$xml .= '<title>'.$ligne['INSTITUTION_NAME'].'</title>'."\n";
$lien = sprintf(HB_URL_COURANTE_CONSULTATION_FICHE_HERBIER_ID, $ligne['ID_ORG']);
$xml .= '<link>'.str_replace('&', '&amp;', $lien).'</link>'."\n";
$xml .= '<description>'."\n".'<![CDATA[' ;
$xml .= $ligne['ZIP'] ;
$xml .= ']]>'."\n".'</description>'."\n";
$xml .= '<pubDate>'.strftime('%d %b %Y %H:%M:%S GMT',strtotime($ligne['DATE_DERNIERE_MODIF'])).'</pubDate>'."\n";
$xml .= '</item>'."\n";
foreach ($infos as $info) {
$xml .= "\t\t".'<item>'."\n";
$xml .= "\t\t\t".'<title>'.$info['title'].'</title>'."\n";
$xml .= "\t\t\t".'<link>'.$info['link'].'</link>'."\n";
$xml .= "\t\t\t".'<description><![CDATA['."\n";
$xml .= $info['description']."\n";
$xml .= "\t\t\t".']]></description>'."\n";
$xml .= "\t\t\t".'<pubDate>'.$info['pubdate'].'</pubDate>'."\n";
$xml .= "\t\t".'</item>'."\n";
}
} else {//pas d'annonces
$xml .= '<item>'."\n";
$xml .= '<title>'.HBR_PAS_D_ANNONCES.'</title>'."\n";
$xml .= '<link>#</link>'."\n";
$xml .= '<description>'.HBR_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 .= "\t\t".'<item>'."\n";
$xml .= "\t\t\t".'<title>'.HBR_PAS_D_ANNONCES.'</title>'."\n";
$xml .= "\t\t\t".'<link>#</link>'."\n";
$xml .= "\t\t\t".'<description>'.HBR_PAS_D_ANNONCES.'</description>'."\n";
$xml .= "\t\t\t".'<pubDate>'.strftime('%d %b %Y %H:%M:%S GMT',strtotime('12/12/2004')).'</pubDate>'."\n";
$xml .= "\t\t".'</item>'."\n";
}
$xml .= '</channel>'."\n".'</rss>'."\n";
$xml .= "\t".'</channel>'."\n";
$xml .= '</rss>'."\n";
return $xml;
}
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* Revision 1.1 2006/10/30 18:57:17 jp_milcent
* Début gestion des flux rss.
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/