From 6e9cbe5b702cd430f7e7b0fc739fc017f554c3e1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 15 Apr 2020 03:32:49 +0200 Subject: [PATCH] Fix RSS for blogs --- htdocs/core/lib/xcal.lib.php | 5 +++-- htdocs/langs/en_US/other.lang | 2 +- htdocs/website/samples/wrapper.php | 11 ++++++++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/htdocs/core/lib/xcal.lib.php b/htdocs/core/lib/xcal.lib.php index 32c5c1a6bb6..3ad033b30bb 100644 --- a/htdocs/core/lib/xcal.lib.php +++ b/htdocs/core/lib/xcal.lib.php @@ -333,7 +333,7 @@ function build_calfile($format, $title, $desc, $events_array, $outputfile) * @param array $events_array Array of events ("uid","startdate","summary","url","desc","author","category") or Array of WebsitePage * @param string $outputfile Output file * @param string $filter (optional) Filter - * @param string $url Url + * @param string $url Url (If empty, forge URL for agenda RSS export) * @return int < 0 if ko, Nb of events in file if ok */ function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filter = '', $url = '') @@ -402,9 +402,10 @@ function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filt $tmpevent['uid'] = $event->id; $tmpevent['startdate'] = $event->date_creation; $tmpevent['summary'] = $event->title; - $tmpevent['url'] = $event->urlpage.'.php'; + $tmpevent['url'] = $event->fullpageurl ? $event->fullpageurl : $event->pageurl.'.php'; $tmpevent['author'] = $event->author_alias ? $event->author_alias : 'unknown'; //$tmpevent['category'] = ''; + $tmpevent['desc'] = $event->description; $event = $tmpevent; } diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index e13f763b1f7..ba85f51e739 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -34,7 +34,7 @@ GraphInBarsAreLimitedToNMeasures=Grapics are limited to %s measures in 'Bars' mo OnlyOneFieldForXAxisIsPossible=Only 1 field is currently possible as X-Axis. Only the first selected field has been selected. AtLeastOneMeasureIsRequired=At least 1 field for measure is required AtLeastOneXAxisIsRequired=At least 1 field for X-Axis is required - +LatestBlogPosts=Latest Blog Posts Notify_ORDER_VALIDATE=Sales order validated Notify_ORDER_SENTBYMAIL=Sales order sent by mail Notify_ORDER_SUPPLIER_SENTBYMAIL=Purchase order sent by email diff --git a/htdocs/website/samples/wrapper.php b/htdocs/website/samples/wrapper.php index 7b40619ee58..910b58f391f 100644 --- a/htdocs/website/samples/wrapper.php +++ b/htdocs/website/samples/wrapper.php @@ -101,7 +101,11 @@ if ($rss) { $MAXNEWS = 20; $arrayofblogs = $websitepage->fetchAll($website->id, 'DESC', 'date_creation', $MAXNEWS, 0, $filters); - $eventarray = $arrayofblogs; + $eventarray = array(); + foreach($arrayofblogs as $blog) { + $blog->fullpageurl = $website->virtualhost.'/'.$blog->pageurl.'.php'; + $eventarray[] = $blog; + } require_once DOL_DOCUMENT_ROOT."/core/lib/xcal.lib.php"; require_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"; @@ -137,14 +141,15 @@ if ($rss) { if ($buildfile) { - $title = $desc = $langs->transnoentities('LastBlogPosts'); + $langs->load("other"); + $title = $desc = $langs->transnoentities('LatestBlogPosts'); // Create temp file $outputfiletmp = tempnam($dir_temp, 'tmp'); // Temporary file (allow call of function by different threads @chmod($outputfiletmp, octdec($conf->global->MAIN_UMASK)); // Write file - $result = build_rssfile($format, $title, $desc, $eventarray, $outputfiletmp); + $result = build_rssfile($format, $title, $desc, $eventarray, $outputfiletmp, '', $website->virtualhost.'/wrapper.php?rss=1'); if ($result >= 0) {