Line 45... |
Line 45... |
45 |
'(?:\s*'.
|
45 |
'(?:\s*'.
|
46 |
'(?:'.
|
46 |
'(?:'.
|
47 |
'(url="[^"]*")|'.
|
47 |
'(url="[^"]*")|'.
|
48 |
'(titre="[^"]*")|'.
|
48 |
'(titre="[^"]*")|'.
|
49 |
'(nb="?\d+"?)|'.
|
49 |
'(nb="?\d+"?)|'.
|
- |
|
50 |
'(nbmax="?\d+"?)|'.
|
50 |
'(nouvellefenetre="?(?:0|1)"?)|'.
|
51 |
'(nouvellefenetre="?(?:0|1)"?)|'.
|
51 |
'(formatdate="[^"]*")|'.
|
52 |
'(formatdate="[^"]*")|'.
|
52 |
'(formatdatepro="[^"]*")|'.
|
53 |
'(formatdatepro="[^"]*")|'.
|
53 |
'(template=".*")|'.
|
54 |
'(template=".*")|'.
|
54 |
')'.
|
55 |
')'.
|
Line 56... |
Line 57... |
56 |
'\s*\}\}';
|
57 |
'\s*\}\}';
|
57 |
// +------------------------------------------------------------------------------------------------------+
|
58 |
// +------------------------------------------------------------------------------------------------------+
|
58 |
/** Inclusion du fichier de configuration de cette application.*/
|
59 |
/** Inclusion du fichier de configuration de cette application.*/
|
59 |
require_once GEN_CHEMIN_APPLETTE.'syndication'.GEN_SEP.'configuration'.GEN_SEP.'synd_configuration.inc.php';
|
60 |
require_once GEN_CHEMIN_APPLETTE.'syndication'.GEN_SEP.'configuration'.GEN_SEP.'synd_configuration.inc.php';
|
Line -... |
Line 61... |
- |
|
61 |
|
- |
|
62 |
/** Inclusion du fichier de fonctions de cette application.*/
|
- |
|
63 |
require_once GEN_CHEMIN_APPLETTE.'syndication'.GEN_SEP.'bibliotheque'.GEN_SEP.'syndication.fonct.php';
|
60 |
|
64 |
|
61 |
// Inclusion des fichiers de traduction de l'applette SYND de Papyrus
|
65 |
// Inclusion des fichiers de traduction de l'applette SYND de Papyrus
|
62 |
if (file_exists(SYND_CHEMIN_LANGUE.'synd_langue_'.$GLOBALS['_GEN_commun']['i18n'].'.inc.php')) {
|
66 |
if (file_exists(SYND_CHEMIN_LANGUE.'synd_langue_'.$GLOBALS['_GEN_commun']['i18n'].'.inc.php')) {
|
63 |
/** Inclusion du fichier de traduction suite à la transaction avec le navigateur.*/
|
67 |
/** Inclusion du fichier de traduction suite à la transaction avec le navigateur.*/
|
64 |
require_once SYND_CHEMIN_LANGUE.'synd_langue_'.$GLOBALS['_GEN_commun']['i18n'].'.inc.php';
|
68 |
require_once SYND_CHEMIN_LANGUE.'synd_langue_'.$GLOBALS['_GEN_commun']['i18n'].'.inc.php';
|
65 |
} else {
|
69 |
} else {
|
66 |
/** Inclusion du fichier de traduction par défaut.*/
|
70 |
/** Inclusion du fichier de traduction par défaut.*/
|
67 |
require_once SYND_CHEMIN_LANGUE.'synd_langue_'.SYND_I18N_DEFAUT.'.inc.php';
|
71 |
require_once SYND_CHEMIN_LANGUE.'synd_langue_'.SYND_I18N_DEFAUT.'.inc.php';
|
- |
|
72 |
}
|
68 |
}
|
73 |
|
69 |
/** Inclusion du fichier de la bibliotheque permettant de manipuler les flux RSS.*/
|
74 |
/** Inclusion du fichier de la bibliotheque permettant de manipuler les flux RSS.*/
|
70 |
//require_once(MAGPIE_DIR.'rss_fetch.inc');
|
75 |
//require_once(MAGPIE_DIR.'rss_fetch.inc');
|
71 |
require_once PAP_CHEMIN_API_PEAR.'XML/Feed/Parser.php';
|
76 |
require_once PAP_CHEMIN_API_PEAR.'XML/Feed/Parser.php';
|
72 |
// +------------------------------------------------------------------------------------------------------+
|
77 |
// +------------------------------------------------------------------------------------------------------+
|
Line 85... |
Line 90... |
85 |
// Initialisation des variables
|
90 |
// Initialisation des variables
|
86 |
$sortie = '';
|
91 |
$sortie = '';
|
87 |
$GLOBALS['_SYNDICATION_']['erreurs'] = array();
|
92 |
$GLOBALS['_SYNDICATION_']['erreurs'] = array();
|
88 |
$GLOBALS['_SYNDICATION_']['informations'] = array();
|
93 |
$GLOBALS['_SYNDICATION_']['informations'] = array();
|
89 |
$GLOBALS['_SYNDICATION_']['sites'] = array();
|
94 |
$GLOBALS['_SYNDICATION_']['sites'] = array();
|
- |
|
95 |
|
90 |
|
96 |
|
- |
|
97 |
$string_arguments = "";
|
91 |
//+----------------------------------------------------------------------------------------------------------------+
|
98 |
//+----------------------------------------------------------------------------------------------------------------+
|
92 |
// Gestion des arguments
|
99 |
// Gestion des arguments
|
93 |
$balise = $tab_applette_arguments[0];
|
100 |
$balise = $tab_applette_arguments[0];
|
94 |
$tab_arguments = $tab_applette_arguments;
|
101 |
$tab_arguments = $tab_applette_arguments;
|
95 |
unset($tab_arguments[0]);
|
102 |
unset($tab_arguments[0]);
|
96 |
foreach($tab_arguments as $argument) {
|
103 |
foreach($tab_arguments as $argument) {
|
97 |
if ($argument != '') {
|
104 |
if ($argument != '') {
|
- |
|
105 |
$string_arguments .= $argument;
|
98 |
$tab_parametres = explode('=', $argument, 2);
|
106 |
$tab_parametres = explode('=', $argument, 2);
|
99 |
$options[$tab_parametres[0]] = trim($tab_parametres[1], '"');
|
107 |
$options[$tab_parametres[0]] = trim($tab_parametres[1], '"');
|
100 |
}
|
108 |
}
|
101 |
}
|
109 |
}
|
- |
|
110 |
|
- |
|
111 |
$id_cache = md5($string_arguments);
|
- |
|
112 |
|
- |
|
113 |
if($contenu_cache = verifierCache($id_cache)) {
|
- |
|
114 |
return $contenu_cache;
|
- |
|
115 |
}
|
102 |
//
|
116 |
//
|
103 |
//+----------------------------------------------------------------------------------------------------------------+
|
117 |
//+----------------------------------------------------------------------------------------------------------------+
|
104 |
// Gestion des erreurs de paramétrage
|
118 |
// Gestion des erreurs de paramétrage
|
105 |
if (!isset($options['url'])) {
|
119 |
if (!isset($options['url'])) {
|
106 |
$GLOBALS['_SYNDICATION_']['erreurs'][] = sprintf(SYND_LG_ERREUR_URL, $balise);
|
120 |
$GLOBALS['_SYNDICATION_']['erreurs'][] = sprintf(SYND_LG_ERREUR_URL, $balise);
|
Line 109... |
Line 123... |
109 |
$options['titre'] = '';
|
123 |
$options['titre'] = '';
|
110 |
}
|
124 |
}
|
111 |
if (!isset($options['nb'])) {
|
125 |
if (!isset($options['nb'])) {
|
112 |
$options['nb'] = SYND_NOMBRE;
|
126 |
$options['nb'] = SYND_NOMBRE;
|
113 |
}
|
127 |
}
|
- |
|
128 |
if (!isset($options['nbmax'])) {
|
- |
|
129 |
$options['nbmax'] = SYND_NOMBRE_MAX;
|
- |
|
130 |
}
|
114 |
if (!isset($options['nouvellefenetre'])) {
|
131 |
if (!isset($options['nouvellefenetre'])) {
|
115 |
$options['nouvellefenetre'] = SYND_OUVRIR_LIEN_RSS_NOUVELLE_FENETRE;
|
132 |
$options['nouvellefenetre'] = SYND_OUVRIR_LIEN_RSS_NOUVELLE_FENETRE;
|
116 |
}
|
133 |
}
|
117 |
if (!isset($options['formatdate'])) {
|
134 |
if (!isset($options['formatdate'])) {
|
118 |
$options['formatdate'] = SYND_FORMAT_DATE;
|
135 |
$options['formatdate'] = SYND_FORMAT_DATE;
|
Line 125... |
Line 142... |
125 |
} else {
|
142 |
} else {
|
126 |
if (file_exists(SYND_CHEMIN_SQUELETTE.$options['template'])) {
|
143 |
if (file_exists(SYND_CHEMIN_SQUELETTE.$options['template'])) {
|
127 |
$options['template'] = SYND_CHEMIN_SQUELETTE.$options['template'];
|
144 |
$options['template'] = SYND_CHEMIN_SQUELETTE.$options['template'];
|
128 |
}
|
145 |
}
|
129 |
}
|
146 |
}
|
130 |
|
147 |
|
131 |
//+----------------------------------------------------------------------------------------------------------------+
|
148 |
//+----------------------------------------------------------------------------------------------------------------+
|
132 |
// Recuperation des donnees
|
149 |
// Recuperation des donnees
|
133 |
if (count($GLOBALS['_SYNDICATION_']['erreurs']) == 0) {
|
150 |
if (count($GLOBALS['_SYNDICATION_']['erreurs']) == 0) {
|
134 |
$tab_url = array_map('trim', explode(',', $options['url']));
|
151 |
$tab_url = array_map('trim', explode(',', $options['url']));
|
135 |
foreach ($tab_url as $cle => $url) {
|
152 |
foreach ($tab_url as $cle => $url) {
|
Line 140... |
Line 157... |
140 |
try {
|
157 |
try {
|
141 |
$feed = new XML_Feed_Parser(file_get_contents($url));
|
158 |
$feed = new XML_Feed_Parser(file_get_contents($url));
|
142 |
} catch (XML_Feed_Parser_Exception $e) {
|
159 |
} catch (XML_Feed_Parser_Exception $e) {
|
143 |
return('Le flux RSS est invalide : ' . $e->getMessage());
|
160 |
return('Le flux RSS est invalide : ' . $e->getMessage());
|
144 |
}
|
161 |
}
|
145 |
|
162 |
|
146 |
if ($options['template'] != '' && !file_exists($options['template'])) {
|
163 |
if ($options['template'] != '' && !file_exists($options['template'])) {
|
147 |
$i = 0 ;
|
164 |
$i = 0 ;
|
148 |
$res= '';
|
165 |
$res= '';
|
149 |
foreach ($feed as $item) {
|
166 |
foreach ($feed as $item) {
|
150 |
// Le test suivant pour savoir s il faut reduire l excendent de description
|
167 |
// Le test suivant pour savoir s il faut reduire l excendent de description
|
Line 154... |
Line 171... |
154 |
$all = true ;
|
171 |
$all = true ;
|
155 |
} else {
|
172 |
} else {
|
156 |
$all = false;
|
173 |
$all = false;
|
157 |
}
|
174 |
}
|
158 |
if (isset($item->summary)) {
|
175 |
if (isset($item->summary)) {
|
159 |
$item->description = mb_convert_encoding($item->summary, 'HTML-ENTITIES', $encodages);
|
176 |
$item->description = mb_convert_encoding($item->summary, 'HTML-ENTITIES', $encodages);
|
160 |
} else {
|
177 |
} else {
|
161 |
if (strlen($item->description) > 200 && !$all) {
|
178 |
if (strlen($item->description) > 200 && !$all) {
|
162 |
$item->description = substr(mb_convert_encoding($item->description, 'HTML-ENTITIES', $encodages), 0, 300).
|
179 |
$item->description = substr(mb_convert_encoding($item->description, 'HTML-ENTITIES', $encodages), 0, 300).
|
163 |
'... <a href="'.htmlentities($item->link).'">Lire la suite</a>';
|
180 |
'... <a href="'.htmlentities($item->link).'">Lire la suite</a>';
|
164 |
}
|
181 |
}
|
Line 170... |
Line 187... |
170 |
// lorsque les flux donne des dates au format iso
|
187 |
// lorsque les flux donne des dates au format iso
|
171 |
if (preg_match('/^([0-3][0-9])([0-1][0-9])([0-9][0-9][0-9][0-9])$/', $item->pubdate, $match)) {
|
188 |
if (preg_match('/^([0-3][0-9])([0-1][0-9])([0-9][0-9][0-9][0-9])$/', $item->pubdate, $match)) {
|
172 |
$item->pubdate = $match[3].'-'.$match[2].'-'.$match[1];
|
189 |
$item->pubdate = $match[3].'-'.$match[2].'-'.$match[1];
|
173 |
//echo $item['pubdate'];
|
190 |
//echo $item['pubdate'];
|
174 |
}
|
191 |
}
|
175 |
$res .= str_replace ('{num}', ++$i,
|
192 |
$res .= str_replace ('{num}', ++$i,
|
176 |
str_replace ('{item}', '<a href="'.htmlentities($item->link).'" target="_top">'.mb_convert_encoding($item->title, 'HTML-ENTITIES', $encodages).'</a>',
|
193 |
str_replace ('{item}', '<a href="'.htmlentities($item->link).'" target="_top">'.mb_convert_encoding($item->title, 'HTML-ENTITIES', $encodages).'</a>',
|
177 |
str_replace ('{date}', strftime('%d.%m.%Y',strtotime($item->pubdate)),
|
194 |
str_replace ('{date}', strftime('%d.%m.%Y',strtotime($item->pubdate)),
|
178 |
str_replace ('{description}', mb_convert_encoding($item->description, 'HTML-ENTITIES', $encodages), $options['template'])))) ;
|
195 |
str_replace ('{description}', mb_convert_encoding($item->description, 'HTML-ENTITIES', $encodages), $options['template'])))) ;
|
179 |
$res .= "\n";
|
196 |
$res .= "\n";
|
180 |
if ($i > $options['nb']) {
|
197 |
if ($i > $options['nb']) {
|
181 |
break;
|
198 |
break;
|
Line 200... |
Line 217... |
200 |
// Gestion des pages syndiquees
|
217 |
// Gestion des pages syndiquees
|
201 |
$i = 0;
|
218 |
$i = 0;
|
202 |
$nb_item = $feed->numberEntries;
|
219 |
$nb_item = $feed->numberEntries;
|
Line 203... |
Line 220... |
203 |
|
220 |
|
204 |
foreach ($feed as $item) {
|
221 |
foreach ($feed as $item) {
|
205 |
|
222 |
|
206 |
if ($options['nb'] != 0 && $nb_item >= $options['nb'] && $i >= $options['nb']) {
|
223 |
if ($options['nb'] != 0 && $nb_item >= $options['nb'] && $i >= $options['nb']) {
|
207 |
break;
|
224 |
break;
|
208 |
}
|
225 |
}
|
209 |
$i++;
|
226 |
$i++;
|
210 |
|
227 |
|
211 |
$aso_page = array();
|
228 |
$aso_page = array();
|
212 |
$aso_page['site'] = $aso_site;
|
229 |
$aso_page['site'] = $aso_site;
|
213 |
$aso_page['url'] = htmlentities($item->link);
|
230 |
$aso_page['url'] = htmlentities($item->link);
|
214 |
$aso_page['titre'] = mb_convert_encoding($item->title, 'HTML-ENTITIES', $encodages);
|
231 |
$aso_page['titre'] = mb_convert_encoding($item->title, 'HTML-ENTITIES', $encodages);
|
215 |
$aso_page['description'] = mb_convert_encoding($item->description, 'HTML-ENTITIES', $encodages);
|
232 |
$aso_page['description'] = mb_convert_encoding($item->description, 'HTML-ENTITIES', $encodages);
|
216 |
$aso_page['category'] = mb_convert_encoding($item->model->getElementsByTagName('category')->item(0)->nodeValue, 'HTML-ENTITIES', $encodages);
|
233 |
$aso_page['category'] = mb_convert_encoding($item->model->getElementsByTagName('category')->item(0)->nodeValue, 'HTML-ENTITIES', $encodages);
|
217 |
$aso_page['author'] = mb_convert_encoding($item->author, 'HTML-ENTITIES', $encodages);
|
234 |
$aso_page['author'] = mb_convert_encoding($item->author, 'HTML-ENTITIES', $encodages);
|
218 |
$aso_page['date'] = $item->pubDate;
|
235 |
$aso_page['date'] = $item->pubDate;
|
219 |
if ($options['formatdatepro']) {
|
236 |
if ($options['formatdatepro']) {
|
220 |
switch ($options['formatdatepro']) {
|
237 |
switch ($options['formatdatepro']) {
|
221 |
case 'jm' :
|
238 |
case 'jm' :
|
222 |
$aso_page['date'] = strftime('%d.%m', $aso_page['date']);
|
239 |
$aso_page['date'] = strftime('%d.%m', $aso_page['date']);
|
Line 257... |
Line 274... |
257 |
$GLOBALS['_SYNDICATION_']['sites'][] = $aso_site;
|
274 |
$GLOBALS['_SYNDICATION_']['sites'][] = $aso_site;
|
258 |
}
|
275 |
}
|
259 |
}
|
276 |
}
|
260 |
}
|
277 |
}
|
261 |
// Trie des pages par date
|
278 |
// Trie des pages par date
|
262 |
//var_dump($GLOBALS['_SYNDICATION_']['pages']);
|
- |
|
263 |
krsort($GLOBALS['_SYNDICATION_']['pages']);
|
279 |
krsort($GLOBALS['_SYNDICATION_']['pages']);
|
264 |
|
280 |
|
- |
|
281 |
$GLOBALS['_SYNDICATION_']['sites'] = array_slice($GLOBALS['_SYNDICATION_']['sites'],0,$options['nbmax'],true) ;
|
- |
|
282 |
$GLOBALS['_SYNDICATION_']['pages'] = array_slice($GLOBALS['_SYNDICATION_']['pages'],0,$options['nbmax'],true) ;
|
- |
|
283 |
|
265 |
//+----------------------------------------------------------------------------------------------------------------+
|
284 |
//+----------------------------------------------------------------------------------------------------------------+
|
266 |
// Extrait les variables et les ajoutes a l'espace de noms local
|
285 |
// Extrait les variables et les ajoutes a l'espace de noms local
|
267 |
// Gestion des squelettes
|
286 |
// Gestion des squelettes
|
268 |
extract($GLOBALS['_SYNDICATION_']);
|
287 |
extract($GLOBALS['_SYNDICATION_']);
|
269 |
// Demarre le buffer
|
288 |
// Demarre le buffer
|
270 |
ob_start();
|
289 |
ob_start();
|
271 |
// Inclusion du fichier
|
290 |
// Inclusion du fichier
|
272 |
include($options['template']);
|
291 |
include($options['template']);
|
273 |
// Recuperer le contenu du buffer
|
292 |
// Recuperer le contenu du buffer
|
274 |
$sortie = ob_get_contents();
|
293 |
$sortie = ob_get_contents();
|
- |
|
294 |
creer_cache($id_cache,$sortie);
|
275 |
// Arrete et detruit le buffer
|
295 |
// Arrete et detruit le buffer
|
276 |
ob_end_clean();
|
296 |
ob_end_clean();
|
277 |
|
297 |
|
278 |
//+----------------------------------------------------------------------------------------------------------------+
|
298 |
//+----------------------------------------------------------------------------------------------------------------+
|
279 |
// Sortie
|
299 |
// Sortie
|
280 |
return $sortie;
|
300 |
return $sortie;
|
281 |
}
|
301 |
}
|