[357] | 1 | <?php |
---|
| 2 | #-----------------------------------------------------# |
---|
| 3 | # Plugin : redCTA - Licence : GPL # |
---|
| 4 | # |
---|
| 5 | #-----------------------------------------------------# |
---|
| 6 | if (!defined("_ECRIRE_INC_VERSION")) return; |
---|
| 7 | |
---|
| 8 | // compatibilidad con spip 1.9 |
---|
| 9 | if(!function_exists(ajax_retour)) { |
---|
| 10 | function ajax_retour($corps) { |
---|
| 11 | $c = $GLOBALS['meta']["charset"]; |
---|
| 12 | header('Content-Type: text/html; charset='. $c); |
---|
| 13 | $c = '<' . "?xml version='1.0' encoding='" . $c . "'?" . ">\n"; |
---|
| 14 | echo $c, $corps; |
---|
| 15 | exit; |
---|
| 16 | } |
---|
| 17 | } |
---|
| 18 | |
---|
| 19 | function exec_redcta_boite_rss_dist() { |
---|
| 20 | cs_minipres(); |
---|
| 21 | include_spip('cout_define'); |
---|
| 22 | cout_define('distant'); |
---|
| 23 | $p = ''; |
---|
| 24 | // on cherche le flux rss toutes les _REDCTA_RSS_UPDATE minutes |
---|
| 25 | $force = _request('force')=='oui'; |
---|
| 26 | if(!$force) { |
---|
| 27 | $lastmodified = @file_exists(_DIR_RSS_TMP)?@filemtime(_DIR_RSS_TMP):0; |
---|
| 28 | if (time()-$lastmodified < _REDCTA_RSS_UPDATE) lire_fichier(_DIR_RSS_TMP, $p); |
---|
| 29 | } |
---|
| 30 | if(strlen($p)) { ajax_retour($p); return; } |
---|
| 31 | include_spip('inc/filtres'); |
---|
| 32 | include_spip('action/editer_site'); |
---|
| 33 | include_spip('inc/xml'); |
---|
| 34 | $r = spip_xml_load(_REDCTA_RSS_SOURCE); |
---|
| 35 | if (function_exists('spip_xml_match_nodes')) $c = spip_xml_match_nodes(',^item$,', $r, $r2); |
---|
| 36 | else { |
---|
| 37 | $r2 = !is_array($r)?array():array_shift(array_shift(array_shift(array_shift($r)))); |
---|
| 38 | $c = count($r2); |
---|
| 39 | } |
---|
| 40 | if($c) { |
---|
| 41 | $r3 = &$r2['item']; |
---|
| 42 | $c = count($r3); $p=''; |
---|
| 43 | for($i=0; $i<min($c, _REDCTA_RSS_COUNT); $i++) { |
---|
| 44 | $l = $r3[$i]['link'][0]; |
---|
| 45 | $d = affdate_court(date('Y-m-d', strtotime($r3[$i]['pubDate'][0]))); |
---|
| 46 | $t = str_replace('&', '&', htmlentities($r3[$i]['title'][0], ENT_NOQUOTES, "UTF-8")); |
---|
| 47 | $t = preg_replace(',\s*€(¦)?,', ' (…)', $t); |
---|
| 48 | $t = preg_replace(',^(.*?):,', "• <a href='$l' class='spip_out' target='_cout'>$1</a> <i>($d)</i><br/>", $t); |
---|
| 49 | $p .= "<li style='padding-top:0.6em;'>$t</li>"; |
---|
| 50 | } |
---|
| 51 | } else { |
---|
| 52 | // pour redcta_lien() |
---|
| 53 | include_spip('cout_fonctions'); |
---|
| 54 | $p = '<span style="color: red;">'._T('redcta:erreur:probleme', array('pb'=>cs_lien(_REDCTA_RSS_SOURCE,_T('redcta:erreur:distant')))).'</span>'; |
---|
| 55 | } |
---|
| 56 | $du = affdate_heure(date('Y-m-d H:i:s',time())); |
---|
| 57 | $p = '<ul style="list-style-type:none; padding:0; margin:0; ">'.$p |
---|
| 58 | .'</ul><p class="spip_xx-small" style="border-top:solid gray thin;"><b>' |
---|
| 59 | ._T('redcta:rss_edition')."</b><br/>$du</p>" |
---|
| 60 | .'<p style="text-align:right"><a href="' |
---|
| 61 | .generer_url_ecrire('admin_redcta','var_mode=calcul', true).'" onclick="' |
---|
| 62 | ."javascipt:jQuery('div.redcta_boite_rss').load('".generer_url_ecrire('redcta_boite_rss', 'force=oui', true).'\');return false;">' |
---|
| 63 | ._T('redctaprive:rss_actualiser').'</a> | <a href="' |
---|
| 64 | ._REDCTA_RSS_SOURCE.'">' |
---|
| 65 | ._T('redctaprive:rss_source').'</a></p>'; |
---|
| 66 | if($c) ecrire_fichier(_DIR_RSS_TMP, $p); |
---|
| 67 | |
---|
| 68 | ajax_retour($p); |
---|
| 69 | } |
---|
| 70 | |
---|
| 71 | ?> |
---|