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: bazar.fonct.rss.php,v 1.66 2007-02-15 17:38:46 jp_milcent Exp $ |
// CVS : $Id: bazar.fonct.rss.php,v 1.67 2007-02-28 10:18:56 alexandre_tb Exp $ |
/** |
* |
*@package bazar |
28,7 → 28,7 |
*@author Florian Schmitt <florian@ecole-et-nature.org> |
//Autres auteurs : |
*@copyright Tela-Botanica 2000-2006 |
*@version $Revision: 1.66 $ |
*@version $Revision: 1.67 $ |
// +------------------------------------------------------------------------------------------------------+ |
*/ |
|
551,10 → 551,10 |
$nomflux=BAZ_DERNIERE_ACTU; |
if (!is_array ($typeannonce) && $typeannonce!='' and $typeannonce!='toutes') { |
if ($req_where==1) {$requete .= ' AND ';} |
$requete .= 'bf_ce_nature='.$typeannonce; |
$requete .= 'bf_ce_nature='.$typeannonce.' and bf_ce_nature=bn_id_nature ';; |
$req_where=1; |
//le nom du flux devient le type d'annonce |
$requete_nom_flux = 'select bn_label_nature from bazar_nature where bn_id_nature = '.$typeannonce; |
$requete_nom_flux = 'select bn_label_nature from bazar_nature where bn_id_nature='.$typeannonce ; |
$nomflux = $GLOBALS['_BAZAR_']['db']->getOne($requete_nom_flux) ; |
} |
// Cas où il y plusieurs type d annonce demande |
611,48 → 611,79 |
if (DB::isError($resultat)) { |
die ($resultat->getMessage().$resultat->getDebugInfo()) ; |
} |
// 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>'.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-tete 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"; |
|
function xmlEntities($s){ |
//build first an assoc. array with the entities we want to match |
$table1 = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES); |
|
//now build another assoc. array with the entities we want to replace (numeric entities) |
foreach ($table1 as $k=>$v){ |
$table1[$k] = "/$v/"; |
$c = htmlentities($k,ENT_QUOTES,"UTF-8"); |
$table2[$c] = "&#".ord($k).";"; |
} |
|
//now perform a replacement using preg_replace |
//each matched value in array 1 will be replaced with the corresponding value in array 2 |
$s = preg_replace($table1,$table2,$s); |
return $s; |
} |
|
include_once 'XML/Util.php' ; |
|
$xml = XML_Util::getXMLDeclaration('1.0', 'ISO-8859-1', 'no') ; |
$xml .= XML_Util::createStartElement ('rss', array('version' => '2.0')) ; |
$xml .= XML_Util::createStartElement ('channel'); |
$xml .= XML_Util::createTag ('title', null, $nomflux, null, false); |
$xml .= XML_Util::createTag ('link', null, BAZ_RSS_ADRESSESITE); |
$xml .= XML_Util::createTag ('description', null, BAZ_RSS_DESCRIPTIONSITE); |
$xml .= XML_Util::createTag ('language', null, 'fr-FR'); |
$xml .= XML_Util::createTag ('copyright', null, 'Copyright 2005 '.BAZ_RSS_NOMSITE); |
$xml .= XML_Util::createTag ('lastBuildDate', null, strftime('%d %b %Y %H:%M:%S GMT')); |
$xml .= XML_Util::createTag ('docs', null, 'http://www.stervinou.com/projets/rss/'); |
$xml .= XML_Util::createTag ('category', null, BAZ_RSS_CATEGORIE); |
$xml .= XML_Util::createTag ('managingEditor', null, BAZ_RSS_MANAGINGEDITOR); |
$xml .= XML_Util::createTag ('webMaster', null, BAZ_RSS_WEBMASTER); |
$xml .= XML_Util::createTag ('ttl', null, '60'); |
$xml .= XML_Util::createStartElement ('image'); |
$xml .= XML_Util::createTag ('title', null, BAZ_RSS_NOMSITE); |
$xml .= XML_Util::createTag ('url', null, BAZ_RSS_LOGOSITE); |
$xml .= XML_Util::createTag ('link', null, BAZ_RSS_ADRESSESITE); |
$xml .= XML_Util::createEndElement ('image'); |
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"; |
$xml .= XML_Util::createStartElement ('item'); |
|
$xml .= XML_Util::createTag ('title', null, xmlEntities($ligne['bf_titre'])); |
|
$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[' ; |
$xml .= XML_Util::createTag ('link', null, $lien->getURL()); |
$xml .= XML_Util::createTag ('guid', null, $lien->getURL()); |
$xml .= XML_Util::createStartElement ('description'); |
if ($_GET['action'] != BAZ_VOIR_TOUTES_ANNONCES) { |
//$xml .= baz_voir_fiche(0,$ligne['bf_id_fiche']) ; |
$xml .= $ligne['bf_description'] ; |
$xml .= XML_Util::createCDataSection ($ligne['bf_description']); |
} |
$xml .= ']]>'."\n".'</description>'."\n"; |
$xml .= XML_Util::createEndElement ('description'); |
if ($ligne['bf_date_debut_validite_fiche'] == '0000-00-00') $date_pub = $ligne[' bf_date_creation_fiche'] ; else |
$date_pub = $ligne['bf_date_debut_validite_fiche']; |
$xml .= '<pubDate>'.strftime('%d %b %Y %H:%M:%S GMT',strtotime($date_pub)).'</pubDate>'."\n"; |
$xml .= '</item>'."\n"; |
$xml .= XML_Util::createTag ('pubDate', null, strftime('%d %b %Y %H:%M:%S GMT',strtotime($date_pub))); |
$xml .= XML_Util::createEndElement ('item'); |
} |
} |
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 .= XML_Util::createStartElement ('item'); |
$xml .= XML_Util::createTag ('title', null, BAZ_PAS_D_ANNONCES); |
$xml .= XML_Util::createTag ('link', null, '#'); |
$xml .= XML_Util::createTag ('description', null, BAZ_PAS_D_ANNONCES); |
$xml .= XML_Util::createTag ('pubDate', null, strftime('%d %b %Y %H:%M:%S GMT',strtotime('12/12/2004'))); |
$xml .= XML_Util::createEndElement ('item'); |
|
} |
$xml .= '</channel>'."\n".'</rss>'."\n"; |
$xml .= XML_Util::createEndElement ('channel'); |
$xml .= XML_Util::createEndElement('rss') ; |
return $xml; |
} |
|
909,7 → 940,7 |
$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_VOIR_FLUX_RSS); |
$GLOBALS['_BAZAR_']['url']->addQueryString('annonce', $typeannonce); |
$GLOBALS['_BAZAR_']['url']->addQueryString('categorie_nature', $GLOBALS['_BAZAR_']['categorie_nature']); |
/*$res .= '{{Syndication titre="'.BAZ_DERNIERES_FICHES.'" url="'.preg_replace ('/&/', '&', $GLOBALS['_BAZAR_']['url']->getURL()). |
/*$res .= '{{Syndication titre="Les dernières fiches enregistrées" url="'.preg_replace ('/&/', '&', $GLOBALS['_BAZAR_']['url']->getURL()). |
'" nb=10 nouvellefenetre=0 formatdate="'.BAZ_TYPE_AFFICHAGE_LISTE.'"}}';*/ |
} |
|
1032,9 → 1063,6 |
/* +--Fin du code ----------------------------------------------------------------------------------------+ |
* |
* $Log: not supported by cvs2svn $ |
* Revision 1.65 2007/02/15 14:18:38 jp_milcent |
* Fusion avec la livraison Menes : 15 février 2007 |
* |
* Revision 1.64 2007/02/02 14:00:41 alexandre_tb |
* mise en place d'un template pour l'affichage du moteur de recherche |
* |
1042,19 → 1070,6 |
* backport |
* les dates ne s'affichent pas si elles sont vides. |
* les champs dates propose 4 années avant l'année actuelle |
* |
* Revision 1.60.2.6 2007/02/15 13:42:16 jp_milcent |
* Utilisation de IN à la place du = dans les requêtes traitant les catégories de fiches. |
* Permet d'utiliser la syntaxe 1,2,3 dans la configuration de categorie_nature. |
* |
* Revision 1.60.2.5 2007/02/02 13:46:54 alexandre_tb |
* correction bug sur une date |
* |
* Revision 1.60.2.4 2007/01/30 15:45:01 alexandre_tb |
* affichage de la date de création e la fiche lorsque la date de début de validité n'est plus bonne |
* |
* Revision 1.60.2.3 2007/01/29 10:53:46 alexandre_tb |
* Mise en place de la constante BAZ_DERNIERES_FICHES pour remplacer le label en francais dans baz_liste |
* |
* Revision 1.60.2.2 2007/01/17 16:01:27 alexandre_tb |
* les dates ne s'affichent pas si elles sont vides. |