Fix RSS for blogs

This commit is contained in:
Laurent Destailleur 2020-04-15 03:32:49 +02:00
parent 3be426be5b
commit 6e9cbe5b70
3 changed files with 12 additions and 6 deletions

View File

@ -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 array $events_array Array of events ("uid","startdate","summary","url","desc","author","category") or Array of WebsitePage
* @param string $outputfile Output file * @param string $outputfile Output file
* @param string $filter (optional) Filter * @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 * @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 = '')
@ -402,9 +402,10 @@ function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filt
$tmpevent['uid'] = $event->id; $tmpevent['uid'] = $event->id;
$tmpevent['startdate'] = $event->date_creation; $tmpevent['startdate'] = $event->date_creation;
$tmpevent['summary'] = $event->title; $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['author'] = $event->author_alias ? $event->author_alias : 'unknown';
//$tmpevent['category'] = ''; //$tmpevent['category'] = '';
$tmpevent['desc'] = $event->description;
$event = $tmpevent; $event = $tmpevent;
} }

View File

@ -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. 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 AtLeastOneMeasureIsRequired=At least 1 field for measure is required
AtLeastOneXAxisIsRequired=At least 1 field for X-Axis is required AtLeastOneXAxisIsRequired=At least 1 field for X-Axis is required
LatestBlogPosts=Latest Blog Posts
Notify_ORDER_VALIDATE=Sales order validated Notify_ORDER_VALIDATE=Sales order validated
Notify_ORDER_SENTBYMAIL=Sales order sent by mail Notify_ORDER_SENTBYMAIL=Sales order sent by mail
Notify_ORDER_SUPPLIER_SENTBYMAIL=Purchase order sent by email Notify_ORDER_SUPPLIER_SENTBYMAIL=Purchase order sent by email

View File

@ -101,7 +101,11 @@ if ($rss) {
$MAXNEWS = 20; $MAXNEWS = 20;
$arrayofblogs = $websitepage->fetchAll($website->id, 'DESC', 'date_creation', $MAXNEWS, 0, $filters); $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/xcal.lib.php";
require_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"; require_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php";
@ -137,14 +141,15 @@ if ($rss) {
if ($buildfile) if ($buildfile)
{ {
$title = $desc = $langs->transnoentities('LastBlogPosts'); $langs->load("other");
$title = $desc = $langs->transnoentities('LatestBlogPosts');
// Create temp file // Create temp file
$outputfiletmp = tempnam($dir_temp, 'tmp'); // Temporary file (allow call of function by different threads $outputfiletmp = tempnam($dir_temp, 'tmp'); // Temporary file (allow call of function by different threads
@chmod($outputfiletmp, octdec($conf->global->MAIN_UMASK)); @chmod($outputfiletmp, octdec($conf->global->MAIN_UMASK));
// Write file // 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) if ($result >= 0)
{ {