Line 19... |
Line 19... |
19 |
// | |
|
19 |
// | |
|
20 |
// | You should have received a copy of the GNU General Public License |
|
20 |
// | You should have received a copy of the GNU General Public License |
|
21 |
// | along with Foobar; if not, write to the Free Software |
|
21 |
// | along with Foobar; if not, write to the Free Software |
|
22 |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
22 |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
23 |
// +------------------------------------------------------------------------------------------------------+
|
23 |
// +------------------------------------------------------------------------------------------------------+
|
24 |
// CVS : $Id: syndication.php,v 1.5.2.1 2007-06-06 15:24:37 jp_milcent Exp $
|
24 |
// CVS : $Id: syndication.php,v 1.5.2.2 2007-07-25 09:45:07 jp_milcent Exp $
|
25 |
/**
|
25 |
/**
|
26 |
* papyrus_bp - syndication.php
|
26 |
* papyrus_bp - syndication.php
|
27 |
*
|
27 |
*
|
28 |
* Description :
|
28 |
* Description :
|
29 |
*
|
29 |
*
|
Line 31... |
Line 31... |
31 |
//Auteur original :
|
31 |
//Auteur original :
|
32 |
*@author Jean-Pascal MILCENT <jpm@tela-botanica.org>
|
32 |
*@author Jean-Pascal MILCENT <jpm@tela-botanica.org>
|
33 |
//Autres auteurs :
|
33 |
//Autres auteurs :
|
34 |
*@author Aucun
|
34 |
*@author Aucun
|
35 |
*@copyright Tela-Botanica 1999-2006
|
35 |
*@copyright Tela-Botanica 1999-2006
|
36 |
*@version $Revision: 1.5.2.1 $ $Date: 2007-06-06 15:24:37 $
|
36 |
*@version $Revision: 1.5.2.2 $ $Date: 2007-07-25 09:45:07 $
|
37 |
// +------------------------------------------------------------------------------------------------------+
|
37 |
// +------------------------------------------------------------------------------------------------------+
|
38 |
*/
|
38 |
*/
|
Line 39... |
Line 39... |
39 |
|
39 |
|
40 |
// +------------------------------------------------------------------------------------------------------+
|
40 |
// +------------------------------------------------------------------------------------------------------+
|
Line 66... |
Line 66... |
66 |
/** Inclusion du fichier de traduction par défaut.*/
|
66 |
/** Inclusion du fichier de traduction par défaut.*/
|
67 |
require_once SYND_CHEMIN_LANGUE.'synd_langue_'.SYND_I18N_DEFAUT.'.inc.php';
|
67 |
require_once SYND_CHEMIN_LANGUE.'synd_langue_'.SYND_I18N_DEFAUT.'.inc.php';
|
68 |
}
|
68 |
}
|
69 |
/** Inclusion du fichier de la bibliotheque permettant de manipuler les flux RSS.*/
|
69 |
/** Inclusion du fichier de la bibliotheque permettant de manipuler les flux RSS.*/
|
70 |
//require_once(MAGPIE_DIR.'rss_fetch.inc');
|
70 |
//require_once(MAGPIE_DIR.'rss_fetch.inc');
|
71 |
require_once PAP_CHEMIN_API_PEAR.'XML/RSS.php';
|
71 |
require_once PAP_CHEMIN_API_PEAR.'XML/Feed/Parser.php';
|
72 |
// +------------------------------------------------------------------------------------------------------+
|
72 |
// +------------------------------------------------------------------------------------------------------+
|
73 |
// | CORPS du PROGRAMME |
|
73 |
// | CORPS du PROGRAMME |
|
74 |
// +------------------------------------------------------------------------------------------------------+
|
74 |
// +------------------------------------------------------------------------------------------------------+
|
75 |
/** Fonction afficherSyndication() - Retourne la liste des pages des sites syndiqués.
|
75 |
/** Fonction afficherSyndication() - Retourne la liste des pages des sites syndiqués.
|
76 |
*
|
76 |
*
|
Line 133... |
Line 133... |
133 |
if (count($GLOBALS['_SYNDICATION_']['erreurs']) == 0) {
|
133 |
if (count($GLOBALS['_SYNDICATION_']['erreurs']) == 0) {
|
134 |
$tab_url = array_map('trim', explode(',', $options['url']));
|
134 |
$tab_url = array_map('trim', explode(',', $options['url']));
|
135 |
foreach ($tab_url as $cle => $url) {
|
135 |
foreach ($tab_url as $cle => $url) {
|
136 |
if ($url != '') {
|
136 |
if ($url != '') {
|
137 |
$aso_site = array();
|
137 |
$aso_site = array();
|
- |
|
138 |
try {
|
138 |
$rss =& new XML_RSS(str_replace('&', '&', $url));
|
139 |
$feed = new XML_Feed_Parser(file_get_contents($url));
|
- |
|
140 |
} catch (XML_Feed_Parser_Exception $e) {
|
- |
|
141 |
die('Le flux RSS est invalide : ' . $e->getMessage());
|
139 |
$rss->parse();
|
142 |
}
|
140 |
if ($options['template'] != '' && !file_exists($options['template'])) {
|
143 |
if ($options['template'] != '' && !file_exists($options['template'])) {
|
141 |
$i = 0 ;
|
144 |
$i = 0 ;
|
142 |
$res= '';
|
145 |
$res= '';
|
143 |
foreach ($rss->getItems() as $item) {
|
146 |
foreach ($feed as $item) {
|
144 |
// Le test suivant pour savoir s il faut reduire l excendent de description
|
147 |
// Le test suivant pour savoir s il faut reduire l excendent de description
|
145 |
// Si {all} est present dans le template on ne reduit pas
|
148 |
// Si {all} est present dans le template on ne reduit pas
|
146 |
if (preg_match ('/{all}/', $options['template'])) {
|
149 |
if (preg_match ('/{all}/', $options['template'])) {
|
147 |
$template = str_replace('{all}', '', $options['template']);
|
150 |
$template = str_replace('{all}', '', $options['template']);
|
148 |
$all = true ;
|
151 |
$all = true ;
|
149 |
} else {
|
152 |
} else {
|
150 |
$all = false;
|
153 |
$all = false;
|
151 |
}
|
154 |
}
|
152 |
if (isset($item['summary'])) {
|
155 |
if (isset($item->summary)) {
|
153 |
$item['description'] = $item['summary'];
|
156 |
$item->description = $item->summary;
|
154 |
} else {
|
157 |
} else {
|
155 |
if (strlen($item['description']) > 200 && !$all) {
|
158 |
if (strlen($item->description) > 200 && !$all) {
|
156 |
$item['description'] = substr ($item['description'] , 0, 300).
|
159 |
$item->description = substr ($item->description , 0, 300).
|
157 |
'... <a href="'.$item['link'].'">Lire la suite</a>';
|
160 |
'... <a href="'.$item->link.'">Lire la suite</a>';
|
158 |
}
|
161 |
}
|
159 |
}
|
162 |
}
|
160 |
if (!isset($item['pubdate'])) {
|
163 |
if (!isset($item->pubdate)) {
|
161 |
$item['pubdate'] = date('dmY');
|
164 |
$item->pubdate = date('dmY');
|
162 |
}
|
165 |
}
|
163 |
// Le code ci-apres est pour rattraper les dates du type 01012005 parsees par magpie
|
166 |
// Le code ci-apres est pour rattraper les dates du type 01012005 parsees par magpie
|
164 |
// lorsque les flux donne des dates au format iso
|
167 |
// lorsque les flux donne des dates au format iso
|
165 |
if (preg_match('/^([0-3][0-9])([0-1][0-9])([0-9][0-9][0-9][0-9])$/', $item['pubdate'], $match)) {
|
168 |
if (preg_match('/^([0-3][0-9])([0-1][0-9])([0-9][0-9][0-9][0-9])$/', $item->pubdate, $match)) {
|
166 |
$item['pubdate'] = $match[3].'-'.$match[2].'-'.$match[1];
|
169 |
$item->pubdate = $match[3].'-'.$match[2].'-'.$match[1];
|
167 |
//echo $item['pubdate'];
|
170 |
//echo $item['pubdate'];
|
168 |
}
|
171 |
}
|
169 |
$res .= str_replace ('{num}', ++$i,
|
172 |
$res .= str_replace ('{num}', ++$i,
|
170 |
str_replace ('{item}', '<a href="'.$item['link'].'" target="_top">'.htmlentities($item['title']).'</a>',
|
173 |
str_replace ('{item}', '<a href="'.$item->link.'" target="_top">'.htmlentities($item->title).'</a>',
|
171 |
str_replace ('{date}', strftime('%d.%m.%Y',strtotime($item['pubdate'])),
|
174 |
str_replace ('{date}', strftime('%d.%m.%Y',strtotime($item->pubdate)),
|
172 |
str_replace ('{description}', $item['description'], $options['template'])))) ;
|
175 |
str_replace ('{description}', $item->description, $options['template'])))) ;
|
173 |
$res .= "\n";
|
176 |
$res .= "\n";
|
174 |
if ($i > $options['nb']) {
|
177 |
if ($i > $options['nb']) {
|
175 |
break;
|
178 |
break;
|
176 |
}
|
179 |
}
|
177 |
}
|
180 |
}
|
178 |
return $res;
|
181 |
return $res;
|
179 |
}
|
182 |
}
|
180 |
$channel=$rss->getChannelInfo();
|
- |
|
181 |
//var_dump($channel);
|
- |
|
182 |
// Gestion du titre
|
183 |
// Gestion du titre
|
183 |
if ( $options['titre'] == '' ) {
|
184 |
if ( $options['titre'] == '' ) {
|
184 |
$aso_site['titre'] = utf8_decode($channel['title']);
|
185 |
$aso_site['titre'] = utf8_decode($feed->title);
|
185 |
} else if ( $options['titre'] != '0' ) {
|
186 |
} else if ( $options['titre'] != '0' ) {
|
186 |
$aso_site['titre'] = utf8_decode($options['titre']);
|
187 |
$aso_site['titre'] = utf8_decode($options['titre']);
|
187 |
}
|
188 |
}
|
188 |
// Gestion de l'url du site
|
189 |
// Gestion de l'url du site
|
189 |
if (isset($channel['link'])) {
|
190 |
if (isset($feed->link)) {
|
190 |
$aso_site['url'] = htmlentities($channel['link']);
|
191 |
$aso_site['url'] = htmlentities($feed->link);
|
191 |
}
|
192 |
}
|
192 |
// Ouverture du lien dans une nouvelle fenetre
|
193 |
// Ouverture du lien dans une nouvelle fenetre
|
193 |
$aso_site['ext'] = false;
|
194 |
$aso_site['ext'] = false;
|
194 |
if ($options['nouvellefenetre'] == 1) {
|
195 |
if ($options['nouvellefenetre'] == 1) {
|
195 |
$aso_site['ext'] = true;
|
196 |
$aso_site['ext'] = true;
|
196 |
}
|
197 |
}
|
197 |
// Gestion des pages syndiquees
|
198 |
// Gestion des pages syndiquees
|
198 |
$i = 0;
|
199 |
$i = 0;
|
199 |
$nb_item = count($rss->getItems());
|
200 |
$nb_item = count($feed);
|
200 |
foreach ($rss->getItems() as $item) {
|
201 |
foreach ($feed as $item) {
|
201 |
if ($options['nb'] != 0 && $nb_item >= $options['nb'] && $i >= $options['nb']) {
|
202 |
if ($options['nb'] != 0 && $nb_item >= $options['nb'] && $i >= $options['nb']) {
|
202 |
break;
|
203 |
break;
|
203 |
}
|
204 |
}
|
204 |
$i++;
|
205 |
$i++;
|
205 |
$aso_page = array();
|
206 |
$aso_page = array();
|
206 |
$aso_page['site'] = $aso_site;
|
207 |
$aso_page['site'] = $aso_site;
|
207 |
$aso_page['url'] = $item['link'];
|
208 |
$aso_page['url'] = $item->link;
|
208 |
$aso_page['titre'] = utf8_decode($item['title']);
|
209 |
$aso_page['titre'] = utf8_decode($item->title);
|
209 |
if (isset($item['pubdate'])) {
|
210 |
if (isset($item->pubdate)) {
|
210 |
$aso_page['date'] = $item['pubdate'];
|
211 |
$aso_page['date'] = $item->pubdate;
|
211 |
} elseif (isset($item['date'])) {
|
212 |
} elseif (isset($item->date)) {
|
212 |
$aso_page['date'] = $item['date'];
|
213 |
$aso_page['date'] = $item->date;
|
213 |
} elseif (isset($item['date_timestamp'])) {
|
214 |
} elseif (isset($item->date_timestamp)) {
|
214 |
$aso_page['date'] = $item['date_timestamp'];
|
215 |
$aso_page['date'] = $item->date_timestamp;
|
215 |
} else {
|
216 |
} else {
|
216 |
$aso_page['date'] = '';
|
217 |
$aso_page['date'] = '';
|
217 |
}
|
218 |
}
|
218 |
if ($options['formatdatepro']) {
|
219 |
if ($options['formatdatepro']) {
|
219 |
switch ($options['formatdatepro']) {
|
220 |
switch ($options['formatdatepro']) {
|
Line 280... |
Line 281... |
280 |
}
|
281 |
}
|
Line 281... |
Line 282... |
281 |
|
282 |
|
282 |
/* +--Fin du code ----------------------------------------------------------------------------------------+
|
283 |
/* +--Fin du code ----------------------------------------------------------------------------------------+
|
283 |
*
|
284 |
*
|
- |
|
285 |
* $Log: not supported by cvs2svn $
|
- |
|
286 |
* Revision 1.5.2.1 2007-06-06 15:24:37 jp_milcent
|
- |
|
287 |
* Amélioration de la compatibilité avec les anciennes version des balises de l'applette syndication.
|
284 |
* $Log: not supported by cvs2svn $
|
288 |
*
|
285 |
* Revision 1.5 2007-04-20 12:50:18 florian
|
289 |
* Revision 1.5 2007-04-20 12:50:18 florian
|
286 |
* correction bugs suite au merge
|
290 |
* correction bugs suite au merge
|
287 |
*
|
291 |
*
|
288 |
* Revision 1.4 2007/03/28 15:53:27 florian
|
292 |
* Revision 1.4 2007/03/28 15:53:27 florian
|