Subversion Repositories Applications.bazar

Rev

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

Rev 219 Rev 220
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.73 2007-03-28 10:01:47 florian Exp $
22
// CVS : $Id: bazar.fonct.rss.php,v 1.74 2007-03-28 15:54:32 florian 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.73 $
31
*@version       $Revision: 1.74 $
32
// +------------------------------------------------------------------------------------------------------+
32
// +------------------------------------------------------------------------------------------------------+
33
*/
33
*/
Line 34... Line 34...
34
 
34
 
35
// +------------------------------------------------------------------------------------------------------+
35
// +------------------------------------------------------------------------------------------------------+
Line 618... Line 618...
618
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
618
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
619
	if (DB::isError($resultat)) {
619
	if (DB::isError($resultat)) {
620
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
620
		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
621
	}
621
	}
Line 622... Line -...
622
	
-
 
623
	function xmlEntities($s){
-
 
624
		//build first an assoc. array with the entities we want to match
-
 
625
		$table1 = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES);
-
 
626
		
-
 
627
		//now build another assoc. array with the entities we want to replace (numeric entities)
-
 
628
		foreach ($table1 as $k=>$v){
-
 
629
		  $table1[$k] = "/$v/";
-
 
630
		  $c = htmlentities($k,ENT_QUOTES,"UTF-8");
-
 
631
		  $table2[$c] = "&#".ord($k).";";
-
 
632
		}
-
 
633
		
-
 
634
		//now perform a replacement using preg_replace
-
 
635
		//each matched value in array 1 will be replaced with the corresponding value in array 2
-
 
636
		$s = preg_replace($table1,$table2,$s);
-
 
637
		return $s;
-
 
638
	}
-
 
639
	
622
	
Line 640... Line 623...
640
	include_once PAP_CHEMIN_API_PEAR . 'XML/Util.php' ;
623
	include_once PAP_CHEMIN_API_PEAR . 'XML/Util.php' ;
641
	
624
	
Line 649... Line 632...
649
	$xml .= "\r\n  ";
632
	$xml .= "\r\n  ";
650
	$xml .= XML_Util::createStartElement ('rss', array('version' => '2.0')) ;
633
	$xml .= XML_Util::createStartElement ('rss', array('version' => '2.0')) ;
651
	$xml .= "\r\n    ";
634
	$xml .= "\r\n    ";
652
	$xml .= XML_Util::createStartElement ('channel');
635
	$xml .= XML_Util::createStartElement ('channel');
653
	$xml .= "\r\n      ";
636
	$xml .= "\r\n      ";
654
	$xml .= XML_Util::createTag ('title', null, utf8_encode($nomflux));
637
	$xml .= XML_Util::createTag ('title', null, utf8_encode(html_entity_decode($nomflux)));
655
	$xml .= "\r\n      ";
638
	$xml .= "\r\n      ";
656
	$xml .= XML_Util::createTag ('link', null, BAZ_RSS_ADRESSESITE);
639
	$xml .= XML_Util::createTag ('link', null, BAZ_RSS_ADRESSESITE);
657
	$xml .= "\r\n      ";
640
	$xml .= "\r\n      ";
658
	$xml .= XML_Util::createTag ('description', null, BAZ_RSS_DESCRIPTIONSITE);
641
	$xml .= XML_Util::createTag ('description', null, BAZ_RSS_DESCRIPTIONSITE);
659
	$xml .= "\r\n      ";
642
	$xml .= "\r\n      ";
Line 673... Line 656...
673
	$xml .= "\r\n      ";
656
	$xml .= "\r\n      ";
674
	$xml .= XML_Util::createTag ('ttl', null, '60');
657
	$xml .= XML_Util::createTag ('ttl', null, '60');
675
	$xml .= "\r\n      ";
658
	$xml .= "\r\n      ";
676
	$xml .= XML_Util::createStartElement ('image');
659
	$xml .= XML_Util::createStartElement ('image');
677
	$xml .= "\r\n        ";
660
	$xml .= "\r\n        ";
678
		$xml .= XML_Util::createTag ('title', null, utf8_encode(BAZ_RSS_NOMSITE));
661
		$xml .= XML_Util::createTag ('title', null, utf8_encode(html_entity_decode(BAZ_RSS_NOMSITE)));
679
		$xml .= "\r\n        ";
662
		$xml .= "\r\n        ";
680
		$xml .= XML_Util::createTag ('url', null, BAZ_RSS_LOGOSITE);
663
		$xml .= XML_Util::createTag ('url', null, BAZ_RSS_LOGOSITE);
681
		$xml .= "\r\n        ";
664
		$xml .= "\r\n        ";
682
		$xml .= XML_Util::createTag ('link', null, BAZ_RSS_ADRESSESITE);
665
		$xml .= XML_Util::createTag ('link', null, BAZ_RSS_ADRESSESITE);
683
		$xml .= "\r\n      ";
666
		$xml .= "\r\n      ";
Line 686... Line 669...
686
		// Creation des items : titre + lien + description + date de publication
669
		// Creation des items : titre + lien + description + date de publication
687
		while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
670
		while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
688
			$xml .= "\r\n      ";
671
			$xml .= "\r\n      ";
689
			$xml .= XML_Util::createStartElement ('item');
672
			$xml .= XML_Util::createStartElement ('item');
690
			$xml .= "\r\n        ";
673
			$xml .= "\r\n        ";
691
			$xml .= XML_Util::createTag ('title', null, utf8_encode($ligne['bf_titre']) );
674
			$xml .= XML_Util::createTag ('title', null, utf8_encode(html_entity_decode(($ligne['bf_titre']))));
692
			$xml .= "\r\n        ";
675
			$xml .= "\r\n        ";
693
			$lien=$GLOBALS['_BAZAR_']['url'];
676
			$lien=$GLOBALS['_BAZAR_']['url'];
694
			$lien->addQueryString('action', BAZ_VOIR_FICHE);
677
			$lien->addQueryString('action', BAZ_VOIR_FICHE);
695
			$lien->addQueryString('id_fiche', $ligne['bf_id_fiche']);
678
			$lien->addQueryString('id_fiche', $ligne['bf_id_fiche']);
696
			$xml .= XML_Util::createTag ('link', null, $lien->getURL());
679
			$xml .= XML_Util::createTag ('link', null, utf8_encode(html_entity_decode($lien->getURL())));
697
			$xml .= "\r\n        ";
680
			$xml .= "\r\n        ";
698
			$xml .= XML_Util::createTag ('guid', null, $lien->getURL());
681
			$xml .= XML_Util::createTag ('guid', null, utf8_encode(html_entity_decode($lien->getURL())));
699
			$xml .= "\r\n        ";
682
			$xml .= "\r\n        ";
700
			$xml .= XML_Util::createStartElement ('description');
683
			$xml .= XML_Util::createStartElement ('description');
701
			$xml .= "\r\n          ";
684
			$xml .= "\r\n          ";
702
			if ($_GET['action'] != BAZ_VOIR_TOUTES_ANNONCES) {
685
			if ($_GET['action'] != BAZ_VOIR_TOUTES_ANNONCES) {
703
				$xml .= XML_Util::createCDataSection ( utf8_encode($ligne['bf_description']) );
686
				$xml .= XML_Util::createCDataSection ( utf8_encode(html_entity_decode(($ligne['bf_description']))));
704
			}
687
			}
705
			$xml .= "\r\n        ";
688
			$xml .= "\r\n        ";
706
			$xml .= XML_Util::createEndElement ('description');
689
			$xml .= XML_Util::createEndElement ('description');
707
			$xml .= "\r\n        ";
690
			$xml .= "\r\n        ";
-
 
691
			if ($ligne['bf_date_debut_validite_fiche'] != '0000-00-00' && 
708
			if ($ligne['bf_date_debut_validite_fiche'] == '0000-00-00') $date_pub = $ligne[' bf_date_creation_fiche'] ; else 
692
			$ligne['bf_date_debut_validite_fiche']>$ligne['bf_date_creation_fiche']) {
709
					$date_pub =  $ligne['bf_date_debut_validite_fiche'];
693
				$date_pub =  $ligne['bf_date_debut_validite_fiche'];	
-
 
694
			} else $date_pub = $ligne['bf_date_creation_fiche'] ;
710
			$xml .= XML_Util::createTag ('pubDate', null, strftime('%a, %d %b %Y %H:%M:%S GMT',strtotime($date_pub)));
695
			$xml .= XML_Util::createTag ('pubDate', null, strftime('%a, %d %b %Y %H:%M:%S GMT',strtotime($date_pub)));
711
			$xml .= "\r\n      ";
696
			$xml .= "\r\n      ";
712
			$xml .= XML_Util::createEndElement ('item');
697
			$xml .= XML_Util::createEndElement ('item');
713
		}
698
		}
714
	}
699
	}
715
	else {//pas d'annonces
700
	else {//pas d'annonces
716
		$xml .= "\r\n      ";
701
		$xml .= "\r\n      ";
717
		$xml .= XML_Util::createStartElement ('item');
702
		$xml .= XML_Util::createStartElement ('item');
718
		$xml .= "\r\n          ";
703
		$xml .= "\r\n          ";
719
		$xml .= XML_Util::createTag ('title', null, BAZ_PAS_D_ANNONCES);
704
		$xml .= XML_Util::createTag ('title', null, utf8_encode(html_entity_decode(BAZ_PAS_D_ANNONCES)));
720
		$xml .= "\r\n          ";
705
		$xml .= "\r\n          ";
721
		$xml .= XML_Util::createTag ('link', null, $GLOBALS['_BAZAR_']['url']->getUrl());
706
		$xml .= XML_Util::createTag ('link', null, utf8_encode(html_entity_decode($GLOBALS['_BAZAR_']['url']->getUrl())));
722
		$xml .= "\r\n          ";
707
		$xml .= "\r\n          ";
723
		$xml .= XML_Util::createTag ('guid', null, $GLOBALS['_BAZAR_']['url']->getUrl());
708
		$xml .= XML_Util::createTag ('guid', null, utf8_encode(html_entity_decode($GLOBALS['_BAZAR_']['url']->getUrl())));
724
		$xml .= "\r\n          ";
709
		$xml .= "\r\n          ";
725
		$xml .= XML_Util::createTag ('description', null, BAZ_PAS_D_ANNONCES);
710
		$xml .= XML_Util::createTag ('description', null, utf8_encode(html_entity_decode(BAZ_PAS_D_ANNONCES)));
726
		$xml .= "\r\n          ";
711
		$xml .= "\r\n          ";
727
		$xml .= XML_Util::createTag ('pubDate', null, strftime('%a, %d %b %Y %H:%M:%S GMT',strtotime("01/01/%Y")));
712
		$xml .= XML_Util::createTag ('pubDate', null, strftime('%a, %d %b %Y %H:%M:%S GMT',strtotime("01/01/%Y")));
728
		$xml .= "\r\n      ";
713
		$xml .= "\r\n      ";
729
		$xml .= XML_Util::createEndElement ('item');
714
		$xml .= XML_Util::createEndElement ('item');
730
	}
715
	}
Line 972... Line 957...
972
		ob_end_clean() ;
957
		ob_end_clean() ;
973
	} else {
958
	} else {
974
    	$res .= $formtemplate->toHTML();
959
    	$res .= $formtemplate->toHTML();
975
    	if (!isset($_REQUEST['recherche_effectuee'])) {
960
    	if (!isset($_REQUEST['recherche_effectuee'])) {
976
        	$res .= '<p class="zone_info">'.BAZ_ENTRER_VOS_CRITERES_DE_RECHERCHE.'</p>'."\n";
961
        	$res .= '<p class="zone_info">'.BAZ_ENTRER_VOS_CRITERES_DE_RECHERCHE.'</p>'."\n";
-
 
962
        	$GLOBALS['_BAZAR_']['url']->addQueryString('action',BAZ_VOIR_FLUX_RSS);
-
 
963
        	$GLOBALS['_BAZAR_']['url']->addQueryString('annonce',$GLOBALS['_BAZAR_']['id_typeannonce']);
-
 
964
	        if ($GLOBALS['_BAZAR_']['categorie_nature']!=0) $GLOBALS['_BAZAR_']['url']->addQueryString('categorie_nature',$GLOBALS['_BAZAR_']['categorie_nature']);
977
        	$res .= '{{Syndication titre="Derni&egrave;res actualit&eacute;s" url="http://localhost/papyrus/papyrus.php?menu=13&action=18" nb=10 nouvellefenetre=0 formatdate="jma"}}';
965
        	$res .= '{{Syndication titre="Derni&egrave;res actualit&eacute;s" url="'.$GLOBALS['_BAZAR_']['url']->getURL().'" nb=10 nouvellefenetre=0 formatdate="'.BAZ_FORMAT_DATE_DEFAUT.'"}}';
978
    	}
966
    	}
979
	}
967
	}
Line 1075... Line 1063...
1075
	$res .= '<ul>' ;
1063
	$res .= '<ul>' ;
1076
	$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_VOIR_FICHE);
1064
	$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_VOIR_FICHE);
Line 1077... Line 1065...
1077
	
1065
	
1078
	$donnees = array();
1066
	$donnees = array();
1079
	while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
1067
	while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
1080
		$GLOBALS['_BAZAR_']['url']->addQueryString('id_fiche', $ligne->bf_id_fiche) ;
1068
		$GLOBALS['_BAZAR_']['url']->addQueryString('id_fiche', $ligne['bf_id_fiche']) ;
1081
		array_push ($donnees, $ligne);		
1069
		array_push ($donnees, $ligne);		
1082
	}
1070
	}
1083
	// Mise en place du Pager
1071
	// Mise en place du Pager
1084
	include_once PAP_CHEMIN_API_PEAR.'Pager/Pager.php';
1072
	include_once PAP_CHEMIN_API_PEAR.'Pager/Pager.php';
Line 1123... Line 1111...
1123
	            $GLOBALS['_BAZAR_']['url']->removeQueryString('action');
1111
	            $GLOBALS['_BAZAR_']['url']->removeQueryString('action');
1124
	            $GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_ACTION_SUPPRESSION);
1112
	            $GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_ACTION_SUPPRESSION);
1125
	            $res .='<a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'" onclick="javascript:return confirm(\''.BAZ_SUPPRIMER.'\');">('.BAZ_SUPPRIMER.')</a>';
1113
	            $res .='<a href="'.$GLOBALS['_BAZAR_']['url']->getURL().'" onclick="javascript:return confirm(\''.BAZ_SUPPRIMER.'\');">('.BAZ_SUPPRIMER.')</a>';
1126
	            $GLOBALS['_BAZAR_']['url']->removeQueryString('action');
1114
	            $GLOBALS['_BAZAR_']['url']->removeQueryString('action');
1127
	        }
1115
	        }
1128
	        $res .= '<ul><li>'.$valeur['bf_etablissement'].'</li></ul>'."\n".'</li>';
-
 
1129
	    }
1116
	    }
1130
	    $res .= '</ul>'."\n".'<div class="bazar_numero">'.$pager->links.'</div>'."\n";
1117
	    $res .= '</ul>'."\n".'<div class="bazar_numero">'.$pager->links.'</div>'."\n";
1131
    }
1118
    }
Line 1141... Line 1128...
1141
}
1128
}
Line 1142... Line 1129...
1142
 
1129
 
1143
/* +--Fin du code ----------------------------------------------------------------------------------------+
1130
/* +--Fin du code ----------------------------------------------------------------------------------------+
1144
*
1131
*
-
 
1132
* $Log: not supported by cvs2svn $
-
 
1133
* Revision 1.73  2007/03/28 10:01:47  florian
-
 
1134
* ajout de la constante BAZ_UTILISE_TEMPLATE, pour utiliser ou non les templates pour l'affichage du moteur de recherche
1145
* $Log: not supported by cvs2svn $
1135
*
1146
* Revision 1.72  2007/03/28 08:51:22  neiluj
1136
* Revision 1.72  2007/03/28 08:51:22  neiluj
1147
* passage des flux RSS en UTF-8
1137
* passage des flux RSS en UTF-8
1148
* ajout de l'indentation du code
1138
* ajout de l'indentation du code
1149
* Vérification validation w3c = OK
1139
* Vérification validation w3c = OK