From f2c02f5559b931b2288929f4bd1686114c791aed Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 23 May 2020 12:41:06 +0200 Subject: [PATCH] FIX Language for RSS --- htdocs/core/lib/xcal.lib.php | 7 +++++-- htdocs/website/samples/wrapper.php | 8 ++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/xcal.lib.php b/htdocs/core/lib/xcal.lib.php index 440f1147cbf..3d8120a6d29 100644 --- a/htdocs/core/lib/xcal.lib.php +++ b/htdocs/core/lib/xcal.lib.php @@ -334,9 +334,10 @@ function build_calfile($format, $title, $desc, $events_array, $outputfile) * @param string $outputfile Output file * @param string $filter (optional) Filter * @param string $url Url (If empty, forge URL for agenda RSS export) + * @param string $langcode Language code to show in header * @return int < 0 if ko, Nb of events in file if ok */ -function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filter = '', $url = '') +function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filter = '', $url = '', $langcode = '') { global $user, $conf, $langs; global $dolibarr_main_url_root; @@ -362,7 +363,9 @@ function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filt fwrite($fichier, ''); fwrite($fichier, "\n"); - fwrite($fichier, "\n".$title."\n"); + fwrite($fichier, "\n"); + fwrite($fichier, "".$title."\n"); + if ($langcode) fwrite($fichier, "".$langcode."\n"); /* fwrite($fichier, ""."\n". diff --git a/htdocs/website/samples/wrapper.php b/htdocs/website/samples/wrapper.php index 25483a36f53..bb761c5f894 100644 --- a/htdocs/website/samples/wrapper.php +++ b/htdocs/website/samples/wrapper.php @@ -12,6 +12,7 @@ $hashp = GETPOST('hashp', 'aZ09'); $modulepart = GETPOST('modulepart', 'aZ09'); $entity = GETPOST('entity', 'int') ?GETPOST('entity', 'int') : $conf->entity; $original_file = GETPOST("file", "alpha"); +$l = GETPOST('l', 'aZ09'); // Parameters for RSS $rss = GETPOST('rss', 'aZ09'); @@ -90,8 +91,8 @@ if ($rss) { $type = ''; $cachedelay = 0; $filename = $original_file; - $filters = array('type_container'=>'blogpost', 'lang'=>'en_US'); $dir_temp = $conf->website->dir_temp; + include_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php'; include_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php'; $website = new Website($db); @@ -99,6 +100,9 @@ if ($rss) { $website->fetch('', $websitekey); + $filters = array('type_container'=>'blogpost'); + if ($l) $filters['lang'] = $l; + $MAXNEWS = 20; $arrayofblogs = $websitepage->fetchAll($website->id, 'DESC', 'date_creation', $MAXNEWS, 0, $filters); $eventarray = array(); @@ -151,7 +155,7 @@ if ($rss) { @chmod($outputfiletmp, octdec($conf->global->MAIN_UMASK)); // Write file - $result = build_rssfile($format, $title, $desc, $eventarray, $outputfiletmp, '', $website->virtualhost.'/wrapper.php?rss=1'); + $result = build_rssfile($format, $title, $desc, $eventarray, $outputfiletmp, '', $website->virtualhost.'/wrapper.php?rss=1'.($l ? '&l='.$l : ''), $l); if ($result >= 0) {