'); /** * Compare feeds by date order (newer on top) */ function dateCmp($a, $b) { return strcmp($b['DATE'], $a['DATE']); } /* * Retourne la date sous le bon format pour l'affichage * Pas de seconde, pas d'annee * @param $date Format: 2005-01-01 12:00:00 -> 01 a 12h00 */ function myFormatDate($date) { $l = strlen($date); // enleve les secondes if ( 19 == $l ) { $date = substr($date, 0, $l-3); } // enlve le mois et l'annee // ATTENTION: presentement le serveur est sur l'heure de greenwitch $date = substr($date, 8, 2) . agregatorTr(' at ') . substr($date,11,2).'h'.substr($date,14,2); return $date; } /** * Retourne une chaine de caractere epurer, prete a l'écriture dans un fichier de sortie * Sert aux nouvelles sans DATE */ function clean($str) { return str_replace(array('<', '>',"\n"), array('','',''), $str); } /** * fill array value with constant */ function getArrayConstant($anArray) { foreach($anArray as $key=>$value) { if (defined($key)) { $anArray[$key] = constant($key); } } return $anArray; } /** * Strips html tags * @param string $htmlTags * @return mixed FALSE or xml encoded with
* @since 20090222 */ function agregator_strip_tags($htmlTags) { $htmlString = str_replace(' />', '/>', $htmlTags); $htmlString = strip_tags($htmlString, '

' . "\n"); } $moisan = substr($fil['DATE'],0,7); fwrite($fp, '

'.$moisan.'

'); fwrite($fp, '
    ' . "\n"); } $line = toHTMLItem($fil); fwrite($fp, $line); if ( (++$iFil) >= $max ) break; } fwrite ( $fp, '
'."\n"); fclose($fp); } else { echo "[rsstransform.php:toHTML()] Unable to open $filename for writing"; } } function toRSS(&$tabFil,$filename, $max) { if ($filename === '') return; if ( ($fp = fopen($filename,'w')) ) { $header = ' '.htmlspecialchars(HTML_TITLE).' '.htmlspecialchars(HTML_DESCRIPTION).' '.htmlspecialchars(HTML_LINK).' '; $footer = ''; $iFil = 0; // header fwrite($fp, $header); // each ... foreach ($tabFil as $fil ) { $line = toRSSItem($fil); fwrite($fp, $line); if ( (++$iFil) >= $max ) break; } // footer fwrite($fp, $footer); fclose($fp); } } function toHTMLTable(&$tabFil,$filename, $max) { if ($filename === '') return; if ( ($fp = fopen($filename,'w')) ) { $header = ''; $footer = '
'.agregatorTr('Title').''.agregatorTr('Description').'
'; $iFil = 0; // header fwrite($fp, $header); // each ... foreach ($tabFil as $fil ) { $line = toHTMLTableItem($fil); fwrite($fp, $line); if ( (++$iFil) >= $max ) break; } // footer fwrite($fp, $footer); fclose($fp); } else { echo "[rsstransform.php:toHTMLTable()] Unable to open $filename for writing"; } } function toHTMLTableItem(&$fil) { $date = datetime2dcdate($fil['DATE']); $line = ''."\n"; $line .= '

'.htmlspecialchars($fil['TITLE']).'

'."\n"; $line .= '

'.htmlspecialchars($fil['CREATOR']).'

'."\n"; $line .= '

'.htmlspecialchars($date).'

'."\n"; if ($fil['DESCRIPTION'] != '') { $line .= ' '.nl2br(htmlspecialchars(strip_tags($fil['DESCRIPTION']))).''."\n"; } else { $line .= ' '."\n"; } $line .= ''."\n"; return $line; } ?>