FIX Language for RSS

This commit is contained in:
Laurent Destailleur 2020-05-23 12:41:06 +02:00
parent c460cff01c
commit f2c02f5559
2 changed files with 11 additions and 4 deletions

View File

@ -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, '<rss version="2.0">');
fwrite($fichier, "\n");
fwrite($fichier, "<channel>\n<title>".$title."</title>\n");
fwrite($fichier, "<channel>\n");
fwrite($fichier, "<title>".$title."</title>\n");
if ($langcode) fwrite($fichier, "<language>".$langcode."</language>\n");
/*
fwrite($fichier, "<description><![CDATA[".$desc.".]]></description>"."\n".

View File

@ -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)
{