[SPIP][PLUGINS] v3.0-->v3.2
[lhc/web/www.git] / www / prive / rss / a_suivre_fonctions.php
1 <?php
2
3 if (!defined('_ECRIRE_INC_VERSION')) {
4 return;
5 }
6
7 function trier_rss($texte) {
8 if (preg_match_all(',<item.*</item>\s*?,Uims', $texte, $matches, PREG_SET_ORDER)) {
9 $placeholder = '<!--REINSERT-->';
10 $items = array();
11 foreach ($matches as $match) {
12 if (preg_match(',<dc:date>(.*)</dc:date>,Uims', $match[0], $r)) {
13 $items[strtotime($r[1])] = trim($match[0]);
14 $texte = str_replace($match[0], unique($placeholder), $texte);
15 }
16 }
17 krsort($items);
18 $texte = str_replace($placeholder, implode("\n\t", $items) . "\n", $texte);
19 }
20
21 return $texte;
22 }