diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql
index 43c2b813536..8e87f3e6bba 100644
--- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql
+++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql
@@ -28,4 +28,6 @@
ALTER TABLE llx_facture_fourn ADD COLUMN date_pointoftax date DEFAULT NULL;
ALTER TABLE llx_facture_fourn ADD COLUMN date_valid date;
+ALTER TABLE llx_website_page MODIFY COLUMN pageurl varchar(255);
+
diff --git a/htdocs/install/mysql/tables/llx_website_page.sql b/htdocs/install/mysql/tables/llx_website_page.sql
index 69b6c417528..ff7cbb47a16 100644
--- a/htdocs/install/mysql/tables/llx_website_page.sql
+++ b/htdocs/install/mysql/tables/llx_website_page.sql
@@ -21,7 +21,7 @@ CREATE TABLE llx_website_page
(
rowid integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
fk_website integer NOT NULL,
- pageurl varchar(16) NOT NULL,
+ pageurl varchar(255) NOT NULL,
title varchar(255),
description varchar(255),
keywords varchar(255),
diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang
index aeff9078d0f..41418ab5eae 100644
--- a/htdocs/langs/en_US/website.lang
+++ b/htdocs/langs/en_US/website.lang
@@ -9,7 +9,7 @@ WEBSITE_CSS_URL=URL of external CSS file
WEBSITE_CSS_INLINE=CSS content
PageNameAliasHelp=Name or alias of the page.
This alias is also used to forge a SEO URL when website is ran from a Virtual host of a Web server (like Apacke, Nginx, ...). Use the button "%s" to edit this alias.
MediaFiles=Media library
-EditCss=Edit Style/CSS
+EditCss=Edit Style/CSS or HTML header
EditMenu=Edit menu
EditPageMeta=Edit Meta
EditPageContent=Edit Content
diff --git a/htdocs/websites/class/websitepage.class.php b/htdocs/websites/class/websitepage.class.php
index 60661a1af02..d313905a3bc 100644
--- a/htdocs/websites/class/websitepage.class.php
+++ b/htdocs/websites/class/websitepage.class.php
@@ -482,17 +482,17 @@ class WebsitePage extends CommonObject
/**
* Load an object from its id and create a new one in database
*
- * @param int $fromid Id of object to clone
- *
- * @return int New id of clone
+ * @param int $fromid Id of object to clone
+ * @return int New id of clone
*/
public function createFromClone($fromid)
{
+ global $user, $langs;
+
dol_syslog(__METHOD__, LOG_DEBUG);
- global $user;
$error = 0;
- $object = new Websitepage($this->db);
+ $object = new self($this->db);
$this->db->begin();
@@ -502,14 +502,17 @@ class WebsitePage extends CommonObject
$object->id = 0;
// Clear fields
- // ...
+ $object->ref = 'copy_of_'.$object->ref;
+ $object->pageurl = 'copy_of_'.$object->pageurl;
+ $object->title = $langs->trans("CopyOf").' '.$object->title;
// Create clone
$result = $object->create($user);
// Other options
if ($result < 0) {
- $error ++;
+ $error++;
+ $this->error = $object->error;
$this->errors = $object->errors;
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
}
@@ -522,7 +525,7 @@ class WebsitePage extends CommonObject
} else {
$this->db->rollback();
- return - 1;
+ return -1;
}
}
diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php
index 437f91f2203..e723f9312c0 100644
--- a/htdocs/websites/index.php
+++ b/htdocs/websites/index.php
@@ -101,6 +101,8 @@ if (GETPOST('editmenu')) { $action='editmenu'; }
if (GETPOST('setashome')) { $action='setashome'; }
if (GETPOST('editmeta')) { $action='editmeta'; }
if (GETPOST('editcontent')) { $action='editcontent'; }
+if (GETPOST('createfromclone')) { $action='createfromclone'; }
+if (GETPOST('createpagefromclone')) { $action='createpagefromclone'; }
if (empty($action)) $action='preview';
@@ -505,10 +507,22 @@ if ($action == 'updatemeta')
}
// Update page
-if ($action == 'updatecontent' || ($action == 'preview' && (GETPOST('refreshsite') || GETPOST('refreshpage') || GETPOST('preview'))))
+if (($action == 'updatecontent' || $action == 'createpagefromclone')
+ || ($action == 'preview' && (GETPOST('refreshsite') || GETPOST('refreshpage') || GETPOST('preview'))))
{
$object->fetch(0, $website);
+ if ($action == 'createpagefromclone')
+ {
+ $objectpage = new WebsitePage($db);
+ $result = $objectpage->createFromClone($pageid);
+ if ($result < 0)
+ {
+ setEventMessages($objectpage->error, $objectpage->errors, 'errors');
+ $action='preview';
+ }
+ }
+
// Check symlink to medias and restore it if ko
$pathtomedias=DOL_DATA_ROOT.'/medias';
$pathtomediasinwebsite=$pathofwebsite.'/medias';
@@ -785,7 +799,7 @@ if (count($object->records) > 0)
//print '';
print '';
print '';
- print '';
+ //print '';
}
print '';
@@ -834,6 +848,11 @@ if (count($object->records) > 0)
$atleastonepage=(is_array($array) && count($array) > 0);
print '