Subversion Repositories Applications.bazar

Rev

Rev 186 | Rev 192 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 186 Rev 190
Line 17... Line 17...
17
// |                                                                                                      |
17
// |                                                                                                      |
18
// | You should have received a copy of the GNU Lesser General Public                                     |
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                                  |
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                            |
20
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
21
// +------------------------------------------------------------------------------------------------------+
21
// +------------------------------------------------------------------------------------------------------+
22
// CVS : $Id: bazar.fonct.rss.php,v 1.66 2007-02-15 17:38:46 jp_milcent Exp $
22
// CVS : $Id: bazar.fonct.rss.php,v 1.67 2007-02-28 10:18:56 alexandre_tb Exp $
23
/**
23
/**
24
* 
24
* 
25
*@package bazar
25
*@package bazar
26
//Auteur original :
26
//Auteur original :
27
*@author        Alexandre GRANIER <alexandre@tela-botanica.org>
27
*@author        Alexandre GRANIER <alexandre@tela-botanica.org>
28
*@author        Florian Schmitt <florian@ecole-et-nature.org>
28
*@author        Florian Schmitt <florian@ecole-et-nature.org>
29
//Autres auteurs :
29
//Autres auteurs :
30
*@copyright     Tela-Botanica 2000-2006
30
*@copyright     Tela-Botanica 2000-2006
31
*@version       $Revision: 1.66 $
31
*@version       $Revision: 1.67 $
32
// +------------------------------------------------------------------------------------------------------+
32
// +------------------------------------------------------------------------------------------------------+
33
*/
33
*/
Line 34... Line 34...
34
 
34
 
35
// +------------------------------------------------------------------------------------------------------+
35
// +------------------------------------------------------------------------------------------------------+
Line 549... Line 549...
549
		$req_where=1;
549
		$req_where=1;
550
	}
550
	}
551
	$nomflux=BAZ_DERNIERE_ACTU;
551
	$nomflux=BAZ_DERNIERE_ACTU;
552
	if (!is_array ($typeannonce) && $typeannonce!='' and $typeannonce!='toutes') {
552
	if (!is_array ($typeannonce) && $typeannonce!='' and $typeannonce!='toutes') {
553
		if ($req_where==1) {$requete .= ' AND ';}
553
		if ($req_where==1) {$requete .= ' AND ';}
554
		$requete .= 'bf_ce_nature='.$typeannonce;
554
		$requete .= 'bf_ce_nature='.$typeannonce.' and bf_ce_nature=bn_id_nature ';;
555
		$req_where=1;
555
		$req_where=1;
556
		//le nom du flux devient le type d'annonce
556
		//le nom du flux devient le type d'annonce
557
		$requete_nom_flux = 'select bn_label_nature from bazar_nature where bn_id_nature = '.$typeannonce;
557
		$requete_nom_flux = 'select bn_label_nature from bazar_nature where bn_id_nature='.$typeannonce ;
558
		$nomflux = $GLOBALS['_BAZAR_']['db']->getOne($requete_nom_flux) ;
558
		$nomflux = $GLOBALS['_BAZAR_']['db']->getOne($requete_nom_flux) ;
559
	}
559
	}
560
	// Cas où il y plusieurs type d annonce demande
560
	// Cas où il y plusieurs type d annonce demande
561
	if (is_array ($typeannonce)) {
561
	if (is_array ($typeannonce)) {
562
		if ($req_where==1) {$requete .= ' AND ';}
562
		if ($req_where==1) {$requete .= ' AND ';}
Line 609... Line 609...
609
	if ($nbitem!='') {$requete .= ' LIMIT 0,'.$nbitem;}
609
	if ($nbitem!='') {$requete .= ' LIMIT 0,'.$nbitem;}
610
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
610
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
611
	if (DB::isError($resultat)) {
611
	if (DB::isError($resultat)) {
612
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
612
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
613
	}
613
	}
-
 
614
	
614
	// En-tete du flux RSS version 2.0
615
	function xmlEntities($s){
-
 
616
		//build first an assoc. array with the entities we want to match
-
 
617
		$table1 = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES);
-
 
618
		
-
 
619
		//now build another assoc. array with the entities we want to replace (numeric entities)
-
 
620
		foreach ($table1 as $k=>$v){
-
 
621
		  $table1[$k] = "/$v/";
-
 
622
		  $c = htmlentities($k,ENT_QUOTES,"UTF-8");
-
 
623
		  $table2[$c] = "&#".ord($k).";";
-
 
624
		}
-
 
625
		
-
 
626
		//now perform a replacement using preg_replace
-
 
627
		//each matched value in array 1 will be replaced with the corresponding value in array 2
-
 
628
		$s = preg_replace($table1,$table2,$s);
-
 
629
		return $s;
-
 
630
	}
-
 
631
	
-
 
632
	include_once 'XML/Util.php' ;
-
 
633
 
-
 
634
	$xml = XML_Util::getXMLDeclaration('1.0', 'ISO-8859-1', 'no') ; 
615
	$xml = '<?xml version="1.0" encoding="ISO-8859-1"?>'."\n".'<rss version="2.0">'."\n";
635
	$xml .= XML_Util::createStartElement ('rss', array('version' => '2.0')) ;
-
 
636
	$xml .= XML_Util::createStartElement ('channel');
-
 
637
	$xml .= XML_Util::createTag ('title', null, $nomflux, null, false);
616
	$xml .= '<channel>'."\n".'<title>'.$nomflux.'</title>'."\n".'<link>'.BAZ_RSS_ADRESSESITE.'</link>'."\n";
638
	$xml .= XML_Util::createTag ('link', null, BAZ_RSS_ADRESSESITE);
617
	$xml .= '<description>'.BAZ_RSS_DESCRIPTIONSITE.'</description>'."\n".'<language>fr-FR</language>'."\n".
639
	$xml .= XML_Util::createTag ('description', null, BAZ_RSS_DESCRIPTIONSITE);
-
 
640
	$xml .= XML_Util::createTag ('language', null, 'fr-FR');
618
	'<copyright>Copyright 2005 '.BAZ_RSS_NOMSITE.'</copyright>'."\n";
641
	$xml .= XML_Util::createTag ('copyright', null, 'Copyright 2005 '.BAZ_RSS_NOMSITE);
619
	// Ajout de la date actuelle de publication (suivant la DTD RSS)
642
	$xml .= XML_Util::createTag ('lastBuildDate', null, strftime('%d %b %Y %H:%M:%S GMT'));
620
	$xml .= '<lastBuildDate>'.strftime('%d %b %Y %H:%M:%S GMT').'</lastBuildDate>'."\n";
643
	$xml .= XML_Util::createTag ('docs', null, 'http://www.stervinou.com/projets/rss/');
621
	// En-tete suite et fin
644
	$xml .= XML_Util::createTag ('category', null, BAZ_RSS_CATEGORIE);
622
	$xml .= '<docs>http://www.stervinou.com/projets/rss/</docs>'."\n".'<category>'.BAZ_RSS_CATEGORIE.'</category>'."\n".
645
	$xml .= XML_Util::createTag ('managingEditor', null, BAZ_RSS_MANAGINGEDITOR);
623
	'<managingEditor>'.BAZ_RSS_MANAGINGEDITOR.'</managingEditor>'."\n".'<webMaster>'.BAZ_RSS_WEBMASTER.'</webMaster>'."\n";
646
	$xml .= XML_Util::createTag ('webMaster', null, BAZ_RSS_WEBMASTER);
-
 
647
	$xml .= XML_Util::createTag ('ttl', null, '60');
-
 
648
	$xml .= XML_Util::createStartElement ('image');
624
	$xml .= '<ttl>60</ttl>'."\n".'<image>'."\n".'<title>'.BAZ_RSS_NOMSITE.'</title>'."\n".'<url>'.BAZ_RSS_LOGOSITE.'</url>'."\n".
649
		$xml .= XML_Util::createTag ('title', null, BAZ_RSS_NOMSITE);
-
 
650
		$xml .= XML_Util::createTag ('url', null, BAZ_RSS_LOGOSITE);
-
 
651
		$xml .= XML_Util::createTag ('link', null, BAZ_RSS_ADRESSESITE);
625
	'<link>'.BAZ_RSS_ADRESSESITE.'</link>'."\n".'</image>'."\n";
652
	$xml .= XML_Util::createEndElement ('image');
626
	if ($resultat->numRows()>0) {
653
	if ($resultat->numRows()>0) {
627
		// Creation des items : titre + lien + description + date de publication
654
		// Creation des items : titre + lien + description + date de publication
628
		while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
655
		while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
629
			$xml .= '<item>'."\n";
656
			$xml .= XML_Util::createStartElement ('item');
-
 
657
			
630
			$xml .= '<title>'.$ligne['bf_titre'].'</title>'."\n";
658
			$xml .= XML_Util::createTag ('title', null, xmlEntities($ligne['bf_titre']));
-
 
659
			
631
			$lien=$GLOBALS['_BAZAR_']['url'];
660
			$lien=$GLOBALS['_BAZAR_']['url'];
632
			$lien->addQueryString('action', BAZ_VOIR_FICHE);
661
			$lien->addQueryString('action', BAZ_VOIR_FICHE);
633
			$lien->addQueryString('id_fiche', $ligne['bf_id_fiche']);
662
			$lien->addQueryString('id_fiche', $ligne['bf_id_fiche']);
-
 
663
			$xml .= XML_Util::createTag ('link', null, $lien->getURL());
634
			$xml .= '<link>'.str_replace ('&', '&amp;', $lien->getURL()).'</link>'."\n";
664
			$xml .= XML_Util::createTag ('guid', null, $lien->getURL());
635
			$xml .= '<description>'."\n".'<![CDATA[' ;
665
			$xml .= XML_Util::createStartElement ('description');
636
			if ($_GET['action'] != BAZ_VOIR_TOUTES_ANNONCES) {
666
			if ($_GET['action'] != BAZ_VOIR_TOUTES_ANNONCES) {
637
				//$xml .= baz_voir_fiche(0,$ligne['bf_id_fiche']) ;
-
 
638
				$xml .= $ligne['bf_description'] ;
667
				$xml .= XML_Util::createCDataSection ($ligne['bf_description']);
639
			}
668
			}
640
			$xml .= ']]>'."\n".'</description>'."\n";
669
			$xml .= XML_Util::createEndElement ('description');
641
			if ($ligne['bf_date_debut_validite_fiche'] == '0000-00-00') $date_pub = $ligne[' bf_date_creation_fiche'] ; else 
670
			if ($ligne['bf_date_debut_validite_fiche'] == '0000-00-00') $date_pub = $ligne[' bf_date_creation_fiche'] ; else 
642
					$date_pub =  $ligne['bf_date_debut_validite_fiche'];
671
					$date_pub =  $ligne['bf_date_debut_validite_fiche'];
643
			$xml .= '<pubDate>'.strftime('%d %b %Y %H:%M:%S GMT',strtotime($date_pub)).'</pubDate>'."\n";
672
			$xml .= XML_Util::createTag ('pubDate', null, strftime('%d %b %Y %H:%M:%S GMT',strtotime($date_pub)));
644
			$xml .= '</item>'."\n";
673
			$xml .= XML_Util::createEndElement ('item');
645
		}
674
		}
646
	}
675
	}
647
	else {//pas d'annonces
676
	else {//pas d'annonces
648
		$xml .= '<item>'."\n";
677
		$xml .= XML_Util::createStartElement ('item');
649
		$xml .= '<title>'.BAZ_PAS_D_ANNONCES.'</title>'."\n";
678
		$xml .= XML_Util::createTag ('title', null, BAZ_PAS_D_ANNONCES);
650
		$xml .= '<link>#</link>'."\n";
679
		$xml .= XML_Util::createTag ('link', null, '#');
651
		$xml .= '<description>'.BAZ_PAS_D_ANNONCES.'</description>'."\n";
680
		$xml .= XML_Util::createTag ('description', null, BAZ_PAS_D_ANNONCES);
652
		$xml .= '<pubDate>'.strftime('%d %b %Y %H:%M:%S GMT',strtotime('12/12/2004')).'</pubDate>'."\n";
681
		$xml .= XML_Util::createTag ('pubDate', null, strftime('%d %b %Y %H:%M:%S GMT',strtotime('12/12/2004')));
653
		$xml .= '</item>'."\n";
682
		$xml .= XML_Util::createEndElement ('item');
-
 
683
 
654
	}
684
	}
-
 
685
	$xml .= XML_Util::createEndElement ('channel');
655
	$xml .= '</channel>'."\n".'</rss>'."\n";
686
	$xml .= XML_Util::createEndElement('rss') ;
656
	return $xml;
687
	return $xml;
657
}
688
}
Line 658... Line 689...
658
 
689
 
Line 907... Line 938...
907
		$res .= '<br /><p class="zone_info">'."\n".BAZ_ENTRER_VOS_CRITERES_DE_RECHERCHE.'</p>'."\n";
938
		$res .= '<br /><p class="zone_info">'."\n".BAZ_ENTRER_VOS_CRITERES_DE_RECHERCHE.'</p>'."\n";
908
		$GLOBALS['_BAZAR_']['url']->removeQueryString('action');
939
		$GLOBALS['_BAZAR_']['url']->removeQueryString('action');
909
		$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_VOIR_FLUX_RSS);
940
		$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_VOIR_FLUX_RSS);
910
		$GLOBALS['_BAZAR_']['url']->addQueryString('annonce', $typeannonce);
941
		$GLOBALS['_BAZAR_']['url']->addQueryString('annonce', $typeannonce);
911
		$GLOBALS['_BAZAR_']['url']->addQueryString('categorie_nature', $GLOBALS['_BAZAR_']['categorie_nature']);
942
		$GLOBALS['_BAZAR_']['url']->addQueryString('categorie_nature', $GLOBALS['_BAZAR_']['categorie_nature']);
912
		/*$res .= '{{Syndication titre="'.BAZ_DERNIERES_FICHES.'" url="'.preg_replace ('/&amp;/', '&', $GLOBALS['_BAZAR_']['url']->getURL()).
943
		/*$res .= '{{Syndication titre="Les derni&egrave;res fiches enregistrées" url="'.preg_replace ('/&amp;/', '&', $GLOBALS['_BAZAR_']['url']->getURL()).
913
                '" nb=10 nouvellefenetre=0 formatdate="'.BAZ_TYPE_AFFICHAGE_LISTE.'"}}';*/
944
                '" nb=10 nouvellefenetre=0 formatdate="'.BAZ_TYPE_AFFICHAGE_LISTE.'"}}';*/
914
	}
945
	}
Line 915... Line 946...
915
	
946
	
916
	// Appel du template n 1
947
	// Appel du template n 1
Line 1030... Line 1061...
1030
}
1061
}
Line 1031... Line 1062...
1031
 
1062
 
1032
/* +--Fin du code ----------------------------------------------------------------------------------------+
1063
/* +--Fin du code ----------------------------------------------------------------------------------------+
1033
*
1064
*
1034
* $Log: not supported by cvs2svn $
-
 
1035
* Revision 1.65  2007/02/15 14:18:38  jp_milcent
-
 
1036
* Fusion avec la livraison Menes : 15 février 2007
-
 
1037
*
1065
* $Log: not supported by cvs2svn $
1038
* Revision 1.64  2007/02/02 14:00:41  alexandre_tb
1066
* Revision 1.64  2007/02/02 14:00:41  alexandre_tb
1039
* mise en place d'un template pour l'affichage du moteur de recherche
1067
* mise en place d'un template pour l'affichage du moteur de recherche
1040
*
1068
*
1041
* Revision 1.63  2007/01/18 14:37:34  alexandre_tb
1069
* Revision 1.63  2007/01/18 14:37:34  alexandre_tb
1042
* backport
1070
* backport
1043
* les dates ne s'affichent pas si elles sont vides.
1071
* les dates ne s'affichent pas si elles sont vides.
1044
* les champs dates propose 4 années avant l'année actuelle
-
 
1045
*
-
 
1046
* Revision 1.60.2.6  2007/02/15 13:42:16  jp_milcent
-
 
1047
* Utilisation de IN à la place du = dans les requêtes traitant les catégories de fiches.
-
 
1048
* Permet d'utiliser la syntaxe 1,2,3 dans la configuration de categorie_nature.
-
 
1049
*
-
 
1050
* Revision 1.60.2.5  2007/02/02 13:46:54  alexandre_tb
-
 
1051
* correction bug sur une date
-
 
1052
*
-
 
1053
* Revision 1.60.2.4  2007/01/30 15:45:01  alexandre_tb
-
 
1054
* affichage de la date de création e la fiche lorsque la date de début de validité n'est plus bonne
-
 
1055
*
-
 
1056
* Revision 1.60.2.3  2007/01/29 10:53:46  alexandre_tb
-
 
1057
* Mise en place de la constante BAZ_DERNIERES_FICHES pour remplacer le label en francais dans baz_liste
1072
* les champs dates propose 4 années avant l'année actuelle
1058
*
1073
*
1059
* Revision 1.60.2.2  2007/01/17 16:01:27  alexandre_tb
1074
* Revision 1.60.2.2  2007/01/17 16:01:27  alexandre_tb
1060
* les dates ne s'affichent pas si elles sont vides.
1075
* les dates ne s'affichent pas si elles sont vides.
1061
* les champs dates propose 4 années avant l'année actuelle
1076
* les champs dates propose 4 années avant l'année actuelle