Fix export of website
This commit is contained in:
parent
661bf6a131
commit
3108cd12fb
@ -164,6 +164,8 @@ class modWebsite extends DolibarrModules
|
|||||||
{
|
{
|
||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
|
|
||||||
|
$error = 0;
|
||||||
|
|
||||||
$result = $this->_load_tables('/install/mysql/', 'website');
|
$result = $this->_load_tables('/install/mysql/', 'website');
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')
|
return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')
|
||||||
@ -185,10 +187,15 @@ class modWebsite extends DolibarrModules
|
|||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
$this->error = $langs->trans('ErrorFailToCopyDir', $src, $dest);
|
$this->error = $langs->trans('ErrorFailToCopyDir', $src, $dest);
|
||||||
|
$this->errors[] = $langs->trans('ErrorFailToCopyDir', $src, $dest);
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($error) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Website templates
|
// Website templates
|
||||||
$srcroot = DOL_DOCUMENT_ROOT.'/install/doctemplates/websites';
|
$srcroot = DOL_DOCUMENT_ROOT.'/install/doctemplates/websites';
|
||||||
@ -205,9 +212,15 @@ class modWebsite extends DolibarrModules
|
|||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
$this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
|
$this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
|
||||||
|
$this->errors[] = $langs->trans('ErrorFailToCopyFile', $src, $dest);
|
||||||
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($error) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = array();
|
$sql = array();
|
||||||
|
|
||||||
return $this->_init($sql, $options);
|
return $this->_init($sql, $options);
|
||||||
|
|||||||
@ -1059,29 +1059,35 @@ class Website extends CommonObject
|
|||||||
$line .= "'".$this->db->escape($objectpageold->grabbed_from)."', ";
|
$line .= "'".$this->db->escape($objectpageold->grabbed_from)."', ";
|
||||||
$line .= "'".$this->db->escape($objectpageold->type_container)."', ";
|
$line .= "'".$this->db->escape($objectpageold->type_container)."', ";
|
||||||
|
|
||||||
|
// Make substitution with a generic path into htmlheader content
|
||||||
$stringtoexport = $objectpageold->htmlheader;
|
$stringtoexport = $objectpageold->htmlheader;
|
||||||
$stringtoexport = str_replace(array("\r\n", "\r", "\n"), "__N__", $stringtoexport);
|
$stringtoexport = str_replace(array("\r\n", "\r", "\n"), "__N__", $stringtoexport);
|
||||||
$stringtoexport = str_replace('file=image/'.$website->ref.'/', "file=image/__WEBSITE_KEY__/", $stringtoexport);
|
$stringtoexport = str_replace('file=image/'.$website->ref.'/', "file=image/__WEBSITE_KEY__/", $stringtoexport);
|
||||||
$stringtoexport = str_replace('file=js/'.$website->ref.'/', "file=js/__WEBSITE_KEY__/", $stringtoexport);
|
$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/image/'.$website->ref.'/', "medias/image/__WEBSITE_KEY__/", $stringtoexport);
|
||||||
$stringtoexport = str_replace('medias/js/'.$website->ref.'/', "medias/js/__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_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_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);
|
$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
|
$line .= "'".$this->db->escape(str_replace(array("\r\n", "\r", "\n"), "__N__", $stringtoexport))."', "; // Replace \r \n to have record on 1 line
|
||||||
|
|
||||||
|
// Make substitution with a generic path into page content
|
||||||
$stringtoexport = $objectpageold->content;
|
$stringtoexport = $objectpageold->content;
|
||||||
$stringtoexport = str_replace(array("\r\n", "\r", "\n"), "__N__", $stringtoexport);
|
$stringtoexport = str_replace(array("\r\n", "\r", "\n"), "__N__", $stringtoexport);
|
||||||
$stringtoexport = str_replace('file=image/'.$website->ref.'/', "file=image/__WEBSITE_KEY__/", $stringtoexport);
|
$stringtoexport = str_replace('file=image/'.$website->ref.'/', "file=image/__WEBSITE_KEY__/", $stringtoexport);
|
||||||
$stringtoexport = str_replace('file=js/'.$website->ref.'/', "file=js/__WEBSITE_KEY__/", $stringtoexport);
|
$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/image/'.$website->ref.'/', "medias/image/__WEBSITE_KEY__/", $stringtoexport);
|
||||||
$stringtoexport = str_replace('medias/js/'.$website->ref.'/', "medias/js/__WEBSITE_KEY__/", $stringtoexport);
|
$stringtoexport = str_replace('medias/js/'.$website->ref.'/', "medias/js/__WEBSITE_KEY__/", $stringtoexport);
|
||||||
|
$stringtoexport = str_replace('"image/'.$website->ref.'/', '"image/__WEBSITE_KEY__/', $stringtoexport); // When we have a link src="image/websiteref/file.png" into html content
|
||||||
|
$stringtoexport = str_replace('"/image/'.$website->ref.'/', '"/image/__WEBSITE_KEY__/', $stringtoexport); // When we have a link src="/image/websiteref/file.png" into html content
|
||||||
|
$stringtoexport = str_replace('"js/'.$website->ref.'/', '"js/__WEBSITE_KEY__/', $stringtoexport);
|
||||||
|
$stringtoexport = str_replace('"/js/'.$website->ref.'/', '"/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_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_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);
|
$stringtoexport = str_replace('file=logos%2Fthumbs%2F'.$mysoc->logo, "file=logos%2Fthumbs%2F__LOGO_KEY__", $stringtoexport);
|
||||||
|
|
||||||
// When we have a link src="image/websiteref/file.png" into html content
|
|
||||||
$stringtoexport = str_replace('="image/'.$website->ref.'/', '="image/__WEBSITE_KEY__/', $stringtoexport);
|
|
||||||
|
|
||||||
$line .= "'".$this->db->escape($stringtoexport)."', "; // Replace \r \n to have record on 1 line
|
$line .= "'".$this->db->escape($stringtoexport)."', "; // Replace \r \n to have record on 1 line
|
||||||
$line .= "'".$this->db->escape($objectpageold->author_alias)."', ";
|
$line .= "'".$this->db->escape($objectpageold->author_alias)."', ";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user