diff --git a/htdocs/admin/external_rss.php b/htdocs/admin/external_rss.php index 578b3edb682..38c885f86d9 100644 --- a/htdocs/admin/external_rss.php +++ b/htdocs/admin/external_rss.php @@ -31,6 +31,8 @@ */ require("./pre.inc.php"); +include_once(MAGPIERSS_PATH."rss_fetch.inc"); + $langs->load("admin"); @@ -53,13 +55,26 @@ if ($_POST["action"] == 'add' || $_POST["modify"]) { $external_rss_urlrss = "external_rss_urlrss_" . $_POST["norss"]; - if(isset($_POST[$external_rss_urlrss])) { + if(isset($_POST[$external_rss_urlrss])) + { $boxlabel='(ExternalRSSInformations)'; $external_rss_title = "external_rss_title_" . $_POST["norss"]; //$external_rss_url = "external_rss_url_" . $_POST["norss"]; $db->begin(); + if ($_POST["modify"]) + { + // Supprime boite box_external_rss de définition des boites + $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes_def"; + $sql.= " WHERE file ='box_external_rss.php' AND note like '".$_POST["norss"]." %'"; + if (! $db->query($sql)) + { + dolibarr_print_error($db,"sql=$sql"); + exit; + } + } + // Ajoute boite box_external_rss dans définition des boites $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes_def (name, file, note) VALUES ('".$boxlabel."','box_external_rss.php','".addslashes($_POST["norss"].' ('.$_POST[$external_rss_title]).")')"; if (! $db->query($sql)) @@ -74,7 +89,8 @@ if ($_POST["action"] == 'add' || $_POST["modify"]) { $db->commit(); //$mesg='
'.$langs->trans("Success").'
'; - header("Location: external_rss.php"); + header("Location: ".$_SERVER["PHP_SELF"]); + exit; } else { @@ -86,7 +102,8 @@ if ($_POST["action"] == 'add' || $_POST["modify"]) if ($_POST["delete"]) { - if(isset($_POST["norss"])) { + if(isset($_POST["norss"])) + { $db->begin(); // Supprime boite box_external_rss de définition des boites @@ -134,13 +151,13 @@ print ''; print ''; print ''.$langs->trans("Title").''; print ''; -print 'April,
LinuxFR,
Lolix,
Parinux'; +print 'April,
LinuxFR,
Lolix'; print ''; ?> URL du RSS " size="64"> - http://wiki.april.org/RecentChanges?format=rss,
http://www.linuxfr.org/backend.rss,
http://back.fr.lolix.org/jobs.rss.php3,
http://parinux.org/backend.rss + http://wiki.april.org/RecentChanges?format=rss
http://linuxfr.org/backend/news/rss20.rss
http://back.fr.lolix.org/jobs.rss.php3 "> @@ -159,25 +176,68 @@ print ''; for($i = 0; $i < $nbexternalrss; $i++) { - print "
"; + $var=true; + + $rss = fetch_rss( @constant("EXTERNAL_RSS_URLRSS_".$i) ); + // fetch_rss initialise les objets suivant: + // print_r($rss->channel); + // print_r($rss->image); + // print_r($rss->items); + + print ""; + + print ""; print "Syndication du flux numéro " . ($i+1) . ""; print ""; - print ""; + + $var=!$var; + print ""; print "".$langs->trans("Title").""; print ""; print ""; - print ""; - print "URL du RSS"; + + $var=!$var; + print ""; + print "".$langs->trans("URL").""; print ""; print ""; + + $var=!$var; + print ""; + print "".$langs->trans("Status").""; + print ""; + if (! $rss->ERROR) + { + print ''.$langs->trans("Online").''; + } + else + { + print ''.$langs->trans("Offline").''; + } + print ""; + print ""; + + // Logo + if (! $rss->ERROR && $rss->image['url']) + { + $var=!$var; + print ""; + print "".$langs->trans("Logo").""; + print ''; + print ''; + print ''; + print ""; + } + print ""; print ""; print "trans("Modify")."\">  "; print "trans("Delete")."\">"; print ""; print ""; - print ""; print ""; + + print ""; } ?> diff --git a/htdocs/conf/conf.class.php b/htdocs/conf/conf.class.php index df667c22c34..77f37e6ed12 100644 --- a/htdocs/conf/conf.class.php +++ b/htdocs/conf/conf.class.php @@ -396,9 +396,12 @@ class Conf } // Format de la date - // \todo Mettre format dans fichier langue - $this->format_date_text_short="%d %b %Y"; + // \todo Mettre les 4 formats dans fichier langue $this->format_date_short="%d/%m/%Y"; + $this->format_date_text_short="%d %b %Y"; + $this->format_date_hour_short="%d/%m/%Y %H:%M"; + $this->format_date_hour_text_short="%d %b %Y %H:%M"; + $this->format_date_short_java="dd/MM/yyyy"; /* \todo Ajouter une option Gestion de la TVA dans le module compta qui permet de désactiver la fonction TVA diff --git a/htdocs/includes/boxes/box_external_rss.php b/htdocs/includes/boxes/box_external_rss.php index 7f06a5461cb..434c605aa0d 100644 --- a/htdocs/includes/boxes/box_external_rss.php +++ b/htdocs/includes/boxes/box_external_rss.php @@ -88,18 +88,37 @@ class box_external_rss extends ModeleBoxes { $this->info_box_head = array('text' => $title); } + // Titre du channel + $channel=$rss->channel['tagline']; + for($i = 0; $i < $max ; $i++) { $item = $rss->items[$i]; - $href = $item['link']; - $result = $this->utf8_check(urldecode($item['title'])); + + // Magpierss common fields + $href = $item['link']; + $title = urldecode($item['title']); + $date = $item['date_timestamp']; // date will be empty if conversion into timestamp failed + if ($rss->is_rss()) // If RSS + { + if (! $date && isset($item['pubdate'])) $date=$item['pubdate']; + if (! $date && isset($item['dc']['date'])) $date=$item['dc']['date']; + //$item['dc']['language'] + //$item['dc']['publisher'] + } + if ($rss->is_atom()) // If Atom + { + if (! $date && isset($item['issued'])) $date=$item['issued']; + if (! $date && isset($item['modified'])) $date=$item['modified']; + //$item['issued'] + //$item['modified'] + //$item['atom_content'] + } + if (is_numeric($date)) $date=dolibarr_print_date($date,"dayhour"); + $result = $this->utf8_check($title); if ($result) { - $title = utf8_decode(urldecode($item['title'])); - } - else - { - $title = (urldecode($item['title'])); + $title=utf8_decode($title); } $title=ereg_replace("([[:alnum:]])\?([[:alnum:]])","\\1'\\2",$title); // Gère problème des apostrophes mal codée/décodée par utf8 $title=ereg_replace("^\s+","",$title); // Supprime espaces de début @@ -108,7 +127,12 @@ class box_external_rss extends ModeleBoxes { 'logo' => $this->boximg, 'text' => $title, 'url' => $href, + 'maxlength' => 64, 'target' => 'newrss'); + $this->info_box_contents[$i][1] = array('align' => 'right', + 'text' => $date, + 'td' => 'nowrap="1"'); + } } diff --git a/htdocs/includes/boxes/modules_boxes.php b/htdocs/includes/boxes/modules_boxes.php index dcf2f23548d..7388510b728 100644 --- a/htdocs/includes/boxes/modules_boxes.php +++ b/htdocs/includes/boxes/modules_boxes.php @@ -99,6 +99,7 @@ class ModeleBoxes if (isset($contents[$i][$j]['width'])) $tdparam.=' width="'. $contents[$i][$j]['width'].'"'; if (isset($contents[$i][$j]['colspan'])) $tdparam.=' colspan="'. $contents[$i][$j]['colspan'].'"'; if (isset($contents[$i][$j]['class'])) $tdparam.=' class="'. $contents[$i][$j]['class'].'"'; + if (isset($contents[$i][$j]['td'])) $tdparam.=' '.$contents[$i][$j]['td']; if (!$contents[$i][$j]['text']) $contents[$i][$j]['text']=""; $texte=isset($contents[$i][$j]['text'])?$contents[$i][$j]['text']:''; diff --git a/htdocs/lib/functions.inc.php b/htdocs/lib/functions.inc.php index 0521a4ce26e..f52cbdf131c 100644 --- a/htdocs/lib/functions.inc.php +++ b/htdocs/lib/functions.inc.php @@ -413,7 +413,10 @@ function dolibarr_time_plus_duree($time,$duration_value,$duration_unit) /** \brief Formattage de la date en fonction de la langue $conf->langage \param time Date 'timestamp' ou format 'YYYY-MM-DD' ou 'YYYY-MM-DD HH:MM:SS' - \param format Format d'affichage de la date ("%d %b %Y", "%d/%m/%Y %h:%M:%s", ...) + \param format Format d'affichage de la date + "%d %b %Y", + "%d/%m/%Y %h:%M:%s", + "day", "daytext", "dayhour", "dayhourtext" \return string Date formatée ou '' si time null */ function dolibarr_print_date($time,$format='') @@ -423,6 +426,11 @@ function dolibarr_print_date($time,$format='') // Si format non défini, on prend $conf->format_date_text_short if (! $format) $format=$conf->format_date_text_short; + if ($format == 'day') $format=$conf->format_date_short; + if ($format == 'daytext') $format=$conf->format_date_text_short; + if ($format == 'dayhour') $format=$conf->format_date_hour_short; + if ($format == 'dayhourtext') $format=$conf->format_date_hour_text_short; + // Si date non définie, on renvoie '' if (! $time) return '';