Support export/import of logo site in web site templates

This commit is contained in:
Laurent Destailleur 2018-09-26 11:15:11 +02:00
parent f2d53e80e5
commit 0a4d80012a

View File

@ -783,7 +783,7 @@ class Website extends CommonObject
*/
function exportWebSite()
{
global $conf;
global $conf, $mysoc;
$website = $this;
@ -904,6 +904,9 @@ class Website extends CommonObject
$stringtoexport = str_replace('file=js/'.$website->ref.'/', "file=js/__WEBSITE_KEY__/", $stringtoexport);
$stringtoexport = str_replace('medias/image/'.$website->ref.'/', "medias/image/__WEBSITE_KEY__/", $stringtoexport);
$stringtoexport = str_replace('medias/js/'.$website->ref.'/', "medias/js/__WEBSITE_KEY__/", $stringtoexport);
$stringtoexport = str_replace('file=logos%2Fthumbs%2F'.$mysoc->logo_small, "file=logos%2Fthumbs%2F__LOGO_SMALL_KEY__", $stringtoexport);
$stringtoexport = str_replace('file=logos%2Fthumbs%2F'.$mysoc->logo_mini, "file=logos%2Fthumbs%2F__LOGO_MINI_KEY__", $stringtoexport);
$stringtoexport = str_replace('file=logos%2Fthumbs%2F'.$mysoc->logo, "file=logos%2Fthumbs%2F__LOGO_KEY__", $stringtoexport);
$line.= "'".$this->db->escape(str_replace(array("\r\n","\r","\n"), "__N__", $stringtoexport))."', "; // Replace \r \n to have record on 1 line
$stringtoexport = $objectpageold->content;
@ -912,6 +915,9 @@ class Website extends CommonObject
$stringtoexport = str_replace('file=js/'.$website->ref.'/', "file=js/__WEBSITE_KEY__/", $stringtoexport);
$stringtoexport = str_replace('medias/image/'.$website->ref.'/', "medias/image/__WEBSITE_KEY__/", $stringtoexport);
$stringtoexport = str_replace('medias/js/'.$website->ref.'/', "medias/js/__WEBSITE_KEY__/", $stringtoexport);
$stringtoexport = str_replace('file=logos%2Fthumbs%2F'.$mysoc->logo_small, "file=logos%2Fthumbs%2F__LOGO_SMALL_KEY__", $stringtoexport);
$stringtoexport = str_replace('file=logos%2Fthumbs%2F'.$mysoc->logo_mini, "file=logos%2Fthumbs%2F__LOGO_MINI_KEY__", $stringtoexport);
$stringtoexport = str_replace('file=logos%2Fthumbs%2F'.$mysoc->logo, "file=logos%2Fthumbs%2F__LOGO_KEY__", $stringtoexport);
$line.= "'".$this->db->escape($stringtoexport)."'"; // Replace \r \n to have record on 1 line
$line.= ");";
$line.= "\n";
@ -951,7 +957,7 @@ class Website extends CommonObject
*/
function importWebSite($pathtofile)
{
global $conf;
global $conf, $mysoc;
$error = 0;
@ -1000,6 +1006,9 @@ class Website extends CommonObject
$arrayreplacement['__WEBSITE_ID__'] = $object->id;
$arrayreplacement['__WEBSITE_KEY__'] = $object->ref;
$arrayreplacement['__N__'] = $this->db->escape("\n"); // Restore \n
$arrayreplacement['__LOGO_SMALL_KEY__'] = $this->db->escape($mysoc->logo_small);
$arrayreplacement['__LOGO_MINI_KEY__'] = $this->db->escape($mysoc->logo_mini);
$arrayreplacement['__LOGO_KEY__'] = $this->db->escape($mysoc->logo);
$result = dolReplaceInFile($sqlfile, $arrayreplacement);
$this->db->begin();