From 83b8497d28eff24455a6eb7c1d041c8a84451f5e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 21 Mar 2020 17:58:03 +0100 Subject: [PATCH] Rename sample file so we can use color editor --- htdocs/core/lib/website2.lib.php | 2 +- htdocs/core/lib/xcal.lib.php | 16 +++++++------ htdocs/website/samples/wrapper.php | 37 ++++++++++++++++++++++++++---- 3 files changed, 42 insertions(+), 13 deletions(-) diff --git a/htdocs/core/lib/website2.lib.php b/htdocs/core/lib/website2.lib.php index 2a599aa3fc3..ab2ef8c7396 100644 --- a/htdocs/core/lib/website2.lib.php +++ b/htdocs/core/lib/website2.lib.php @@ -253,7 +253,7 @@ function dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper) dol_delete_file($filewrapper); - $wrappercontent = file_get_contents(DOL_DOCUMENT_ROOT.'/website/samples/wrapper.html'); + $wrappercontent = file_get_contents(DOL_DOCUMENT_ROOT.'/website/samples/wrapper.php'); $result2 = file_put_contents($filewrapper, $wrappercontent); if (!empty($conf->global->MAIN_UMASK)) diff --git a/htdocs/core/lib/xcal.lib.php b/htdocs/core/lib/xcal.lib.php index e3f53b7588d..4aba32007bf 100644 --- a/htdocs/core/lib/xcal.lib.php +++ b/htdocs/core/lib/xcal.lib.php @@ -333,9 +333,10 @@ 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 * @return int < 0 if ko, Nb of events in file if ok */ -function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filter = "") +function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filter = "", $url="") { global $user, $conf, $langs; global $dolibarr_main_url_root; @@ -371,13 +372,14 @@ function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filt "Dolibarr"."\n"); */ - // Define $urlwithroot - $urlwithouturlroot = preg_replace("/".preg_quote(DOL_URL_ROOT, "/")."$/i", "", trim($dolibarr_main_url_root)); + if (empty($url)) { + // Define $urlwithroot + $urlwithouturlroot = preg_replace("/".preg_quote(DOL_URL_ROOT, "/")."$/i", "", trim($dolibarr_main_url_root)); + $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current - $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file - //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current - - $url=$urlwithroot."/public/agenda/agendaexport.php?format=rss&exportkey=".urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY); + $url = $urlwithroot."/public/agenda/agendaexport.php?format=rss&exportkey=".urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY); + } fwrite($fichier, ""."\n"); diff --git a/htdocs/website/samples/wrapper.php b/htdocs/website/samples/wrapper.php index 8f38c0b2043..8615d2db803 100644 --- a/htdocs/website/samples/wrapper.php +++ b/htdocs/website/samples/wrapper.php @@ -1,6 +1,7 @@ global->MAIN_UMASK)); // Write file - if ($format == 'vcal') $result=build_calfile($format, $title, $desc, $eventarray, $outputfiletmp); - elseif ($format == 'ical') $result=build_calfile($format, $title, $desc, $eventarray, $outputfiletmp); - elseif ($format == 'rss') $result=build_rssfile($format, $title, $desc, $eventarray, $outputfiletmp); + //if ($format == 'vcal') $result=build_calfile($format, $title, $desc, $eventarray, $outputfiletmp); + //elseif ($format == 'ical') $result=build_calfile($format, $title, $desc, $eventarray, $outputfiletmp); + if ($format == 'rss') $result=build_rssfile($format, $title, $desc, $eventarray, $outputfiletmp); if ($result >= 0) { @@ -173,7 +174,33 @@ if ($rss) { } } - return $result; + if ($result >= 0) + { + $attachment = false; + if (isset($_GET["attachment"])) $attachment=$_GET["attachment"]; + //$attachment = false; + $contenttype='application/rss+xml'; + if (isset($_GET["contenttype"])) $contenttype=$_GET["contenttype"]; + //$contenttype='text/plain'; + $outputencoding='UTF-8'; + + if ($contenttype) header('Content-Type: '.$contenttype.($outputencoding?'; charset='.$outputencoding:'')); + if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"'); + + // Ajout directives pour resoudre bug IE + //header('Cache-Control: Public, must-revalidate'); + //header('Pragma: public'); + if ($cachedelay) header('Cache-Control: max-age='.$cachedelay.', private, must-revalidate'); + else header('Cache-Control: private, must-revalidate'); + + // Clean parameters + $outputfile=$dir_temp.'/'.$filename; + $result=readfile($outputfile); + if (! $result) print 'File '.$outputfile.' was empty.'; + + // header("Location: ".DOL_URL_ROOT.'/document.php?modulepart=agenda&file='.urlencode($filename)); + exit; + } } // Get logos elseif ($modulepart == "mycompany" && preg_match('/^\/?logos\//', $original_file))