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.8 2007-11-30 14:17:30 jp_milcent Exp $
|
24 |
// CVS : $Id: syndication.php,v 1.9 2007-12-03 14:54:14 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.8 $ $Date: 2007-11-30 14:17:30 $
|
36 |
*@version $Revision: 1.9 $ $Date: 2007-12-03 14:54:14 $
|
37 |
// +------------------------------------------------------------------------------------------------------+
|
37 |
// +------------------------------------------------------------------------------------------------------+
|
38 |
*/
|
38 |
*/
|
Line 39... |
Line 39... |
39 |
|
39 |
|
40 |
// +------------------------------------------------------------------------------------------------------+
|
40 |
// +------------------------------------------------------------------------------------------------------+
|
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 |
// Liste des encodages acceptés pour les flux
|
- |
|
139 |
$encodages = 'UTF-8, ISO-8859-1, ISO-8859-15';
|
138 |
try {
|
140 |
try {
|
139 |
$feed = new XML_Feed_Parser(file_get_contents($url));
|
141 |
$feed = new XML_Feed_Parser(file_get_contents($url));
|
140 |
} catch (XML_Feed_Parser_Exception $e) {
|
142 |
} catch (XML_Feed_Parser_Exception $e) {
|
141 |
die('Le flux RSS est invalide : ' . $e->getMessage());
|
143 |
die('Le flux RSS est invalide : ' . $e->getMessage());
|
142 |
}
|
144 |
}
|
Line 152... |
Line 154... |
152 |
$all = true ;
|
154 |
$all = true ;
|
153 |
} else {
|
155 |
} else {
|
154 |
$all = false;
|
156 |
$all = false;
|
155 |
}
|
157 |
}
|
156 |
if (isset($item->summary)) {
|
158 |
if (isset($item->summary)) {
|
157 |
$item->description = $item->summary;
|
159 |
$item->description = mb_convert_encoding($item->summary, 'HTML-ENTITIES', $encodages);
|
158 |
} else {
|
160 |
} else {
|
159 |
if (strlen($item->description) > 200 && !$all) {
|
161 |
if (strlen($item->description) > 200 && !$all) {
|
160 |
$item->description = substr ($item->description , 0, 300).
|
162 |
$item->description = substr(mb_convert_encoding($item->description, 'HTML-ENTITIES', $encodages), 0, 300).
|
161 |
'... <a href="'.$item->link.'">Lire la suite</a>';
|
163 |
'... <a href="'.htmlentities($item->link).'">Lire la suite</a>';
|
162 |
}
|
164 |
}
|
163 |
}
|
165 |
}
|
164 |
if (!isset($item->pubdate)) {
|
166 |
if (!isset($item->pubdate)) {
|
165 |
$item->pubdate = date('dmY');
|
167 |
$item->pubdate = date('dmY');
|
166 |
}
|
168 |
}
|
Line 169... |
Line 171... |
169 |
if (preg_match('/^([0-3][0-9])([0-1][0-9])([0-9][0-9][0-9][0-9])$/', $item->pubdate, $match)) {
|
171 |
if (preg_match('/^([0-3][0-9])([0-1][0-9])([0-9][0-9][0-9][0-9])$/', $item->pubdate, $match)) {
|
170 |
$item->pubdate = $match[3].'-'.$match[2].'-'.$match[1];
|
172 |
$item->pubdate = $match[3].'-'.$match[2].'-'.$match[1];
|
171 |
//echo $item['pubdate'];
|
173 |
//echo $item['pubdate'];
|
172 |
}
|
174 |
}
|
173 |
$res .= str_replace ('{num}', ++$i,
|
175 |
$res .= str_replace ('{num}', ++$i,
|
174 |
str_replace ('{item}', '<a href="'.$item->link.'" target="_top">'.htmlentities($item->title).'</a>',
|
176 |
str_replace ('{item}', '<a href="'.htmlentities($item->link).'" target="_top">'.mb_convert_encoding($item->title, 'HTML-ENTITIES', $encodages).'</a>',
|
175 |
str_replace ('{date}', strftime('%d.%m.%Y',strtotime($item->pubdate)),
|
177 |
str_replace ('{date}', strftime('%d.%m.%Y',strtotime($item->pubdate)),
|
176 |
str_replace ('{description}', $item->description, $options['template'])))) ;
|
178 |
str_replace ('{description}', mb_convert_encoding($item->description, 'HTML-ENTITIES', $encodages), $options['template'])))) ;
|
177 |
$res .= "\n";
|
179 |
$res .= "\n";
|
178 |
if ($i > $options['nb']) {
|
180 |
if ($i > $options['nb']) {
|
179 |
break;
|
181 |
break;
|
180 |
}
|
182 |
}
|
181 |
}
|
183 |
}
|
182 |
return $res;
|
184 |
return $res;
|
183 |
}
|
185 |
}
|
184 |
// Gestion du titre
|
186 |
// Gestion du titre
|
185 |
if ( $options['titre'] == '' ) {
|
187 |
if ( $options['titre'] == '' ) {
|
186 |
$aso_site['titre'] = mb_convert_encoding($feed->title, 'HTML-ENTITIES', 'UTF-8');
|
188 |
$aso_site['titre'] = mb_convert_encoding($feed->title, 'HTML-ENTITIES', $encodages);
|
187 |
} else if ( $options['titre'] != '0' ) {
|
189 |
} else if ( $options['titre'] != '0' ) {
|
188 |
$aso_site['titre'] = $options['titre'];
|
190 |
$aso_site['titre'] = $options['titre'];
|
189 |
}
|
191 |
}
|
190 |
// Gestion de l'url du site
|
192 |
// Gestion de l'url du site
|
191 |
$aso_site['url'] = htmlentities($feed->link);
|
193 |
$aso_site['url'] = htmlentities($feed->link);
|
Line 204... |
Line 206... |
204 |
break;
|
206 |
break;
|
205 |
}
|
207 |
}
|
206 |
$i++;
|
208 |
$i++;
|
207 |
$aso_page = array();
|
209 |
$aso_page = array();
|
208 |
$aso_page['site'] = $aso_site;
|
210 |
$aso_page['site'] = $aso_site;
|
209 |
$aso_page['url'] = $item->link;
|
211 |
$aso_page['url'] = htmlentities($item->link);
|
210 |
$aso_page['titre'] = mb_convert_encoding($item->title, 'HTML-ENTITIES', 'UTF-8');
|
212 |
$aso_page['titre'] = mb_convert_encoding($item->title, 'HTML-ENTITIES', $encodages);
|
211 |
$aso_page['date'] = $item->pubDate;
|
213 |
$aso_page['date'] = $item->pubDate;
|
212 |
if ($options['formatdatepro']) {
|
214 |
if ($options['formatdatepro']) {
|
213 |
switch ($options['formatdatepro']) {
|
215 |
switch ($options['formatdatepro']) {
|
214 |
case 'jm' :
|
216 |
case 'jm' :
|
215 |
$aso_page['date'] = strftime('%d.%m', $aso_page['date']);
|
217 |
$aso_page['date'] = strftime('%d.%m', $aso_page['date']);
|
Line 274... |
Line 276... |
274 |
}
|
276 |
}
|
Line 275... |
Line 277... |
275 |
|
277 |
|
276 |
/* +--Fin du code ----------------------------------------------------------------------------------------+
|
278 |
/* +--Fin du code ----------------------------------------------------------------------------------------+
|
277 |
*
|
279 |
*
|
- |
|
280 |
* $Log: not supported by cvs2svn $
|
- |
|
281 |
* Revision 1.7.2.2 2007-12-03 14:52:21 jp_milcent
|
- |
|
282 |
* Correction bogue : & dans les urls.
|
- |
|
283 |
*
|
- |
|
284 |
* Revision 1.8 2007-11-30 14:17:30 jp_milcent
|
- |
|
285 |
* Fusion avec la livraison AHA : 30 novembre 2007
|
278 |
* $Log: not supported by cvs2svn $
|
286 |
*
|
279 |
* Revision 1.7.2.1 2007-11-30 14:15:02 jp_milcent
|
287 |
* Revision 1.7.2.1 2007-11-30 14:15:02 jp_milcent
|
280 |
* Amélioration du décodage utf8.
|
288 |
* Amélioration du décodage utf8.
|
281 |
*
|
289 |
*
|
282 |
* Revision 1.7 2007-07-25 15:09:44 jp_milcent
|
290 |
* Revision 1.7 2007-07-25 15:09:44 jp_milcent
|