Can clone a page
This commit is contained in:
parent
0d15bf5de1
commit
aacef21cb8
@ -28,4 +28,6 @@
|
|||||||
ALTER TABLE llx_facture_fourn ADD COLUMN date_pointoftax date DEFAULT NULL;
|
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_facture_fourn ADD COLUMN date_valid date;
|
||||||
|
|
||||||
|
ALTER TABLE llx_website_page MODIFY COLUMN pageurl varchar(255);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -21,7 +21,7 @@ CREATE TABLE llx_website_page
|
|||||||
(
|
(
|
||||||
rowid integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
|
rowid integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
|
||||||
fk_website integer NOT NULL,
|
fk_website integer NOT NULL,
|
||||||
pageurl varchar(16) NOT NULL,
|
pageurl varchar(255) NOT NULL,
|
||||||
title varchar(255),
|
title varchar(255),
|
||||||
description varchar(255),
|
description varchar(255),
|
||||||
keywords varchar(255),
|
keywords varchar(255),
|
||||||
|
|||||||
@ -9,7 +9,7 @@ WEBSITE_CSS_URL=URL of external CSS file
|
|||||||
WEBSITE_CSS_INLINE=CSS content
|
WEBSITE_CSS_INLINE=CSS content
|
||||||
PageNameAliasHelp=Name or alias of the page.<br>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 "<strong>%s</strong>" to edit this alias.
|
PageNameAliasHelp=Name or alias of the page.<br>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 "<strong>%s</strong>" to edit this alias.
|
||||||
MediaFiles=Media library
|
MediaFiles=Media library
|
||||||
EditCss=Edit Style/CSS
|
EditCss=Edit Style/CSS or HTML header
|
||||||
EditMenu=Edit menu
|
EditMenu=Edit menu
|
||||||
EditPageMeta=Edit Meta
|
EditPageMeta=Edit Meta
|
||||||
EditPageContent=Edit Content
|
EditPageContent=Edit Content
|
||||||
|
|||||||
@ -482,17 +482,17 @@ class WebsitePage extends CommonObject
|
|||||||
/**
|
/**
|
||||||
* Load an object from its id and create a new one in database
|
* Load an object from its id and create a new one in database
|
||||||
*
|
*
|
||||||
* @param int $fromid Id of object to clone
|
* @param int $fromid Id of object to clone
|
||||||
*
|
* @return int New id of clone
|
||||||
* @return int New id of clone
|
|
||||||
*/
|
*/
|
||||||
public function createFromClone($fromid)
|
public function createFromClone($fromid)
|
||||||
{
|
{
|
||||||
|
global $user, $langs;
|
||||||
|
|
||||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||||
|
|
||||||
global $user;
|
|
||||||
$error = 0;
|
$error = 0;
|
||||||
$object = new Websitepage($this->db);
|
$object = new self($this->db);
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
@ -502,14 +502,17 @@ class WebsitePage extends CommonObject
|
|||||||
$object->id = 0;
|
$object->id = 0;
|
||||||
|
|
||||||
// Clear fields
|
// Clear fields
|
||||||
// ...
|
$object->ref = 'copy_of_'.$object->ref;
|
||||||
|
$object->pageurl = 'copy_of_'.$object->pageurl;
|
||||||
|
$object->title = $langs->trans("CopyOf").' '.$object->title;
|
||||||
|
|
||||||
// Create clone
|
// Create clone
|
||||||
$result = $object->create($user);
|
$result = $object->create($user);
|
||||||
|
|
||||||
// Other options
|
// Other options
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
$error ++;
|
$error++;
|
||||||
|
$this->error = $object->error;
|
||||||
$this->errors = $object->errors;
|
$this->errors = $object->errors;
|
||||||
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
|
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
|
||||||
}
|
}
|
||||||
@ -522,7 +525,7 @@ class WebsitePage extends CommonObject
|
|||||||
} else {
|
} else {
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
|
|
||||||
return - 1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -101,6 +101,8 @@ if (GETPOST('editmenu')) { $action='editmenu'; }
|
|||||||
if (GETPOST('setashome')) { $action='setashome'; }
|
if (GETPOST('setashome')) { $action='setashome'; }
|
||||||
if (GETPOST('editmeta')) { $action='editmeta'; }
|
if (GETPOST('editmeta')) { $action='editmeta'; }
|
||||||
if (GETPOST('editcontent')) { $action='editcontent'; }
|
if (GETPOST('editcontent')) { $action='editcontent'; }
|
||||||
|
if (GETPOST('createfromclone')) { $action='createfromclone'; }
|
||||||
|
if (GETPOST('createpagefromclone')) { $action='createpagefromclone'; }
|
||||||
|
|
||||||
if (empty($action)) $action='preview';
|
if (empty($action)) $action='preview';
|
||||||
|
|
||||||
@ -505,10 +507,22 @@ if ($action == 'updatemeta')
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update page
|
// 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);
|
$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
|
// Check symlink to medias and restore it if ko
|
||||||
$pathtomedias=DOL_DATA_ROOT.'/medias';
|
$pathtomedias=DOL_DATA_ROOT.'/medias';
|
||||||
$pathtomediasinwebsite=$pathofwebsite.'/medias';
|
$pathtomediasinwebsite=$pathofwebsite.'/medias';
|
||||||
@ -785,7 +799,7 @@ if (count($object->records) > 0)
|
|||||||
//print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("MediaFiles")).'" name="editmedia">';
|
//print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("MediaFiles")).'" name="editmedia">';
|
||||||
print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditCss")).'" name="editcss">';
|
print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditCss")).'" name="editcss">';
|
||||||
print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditMenu")).'" name="editmenu">';
|
print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditMenu")).'" name="editmenu">';
|
||||||
print '<input type="submit"'.$disabled.' class="button" value="'.dol_escape_htmltag($langs->trans("AddPage")).'" name="create">';
|
//print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("CloneSite")).'" name="createfromclone">';
|
||||||
}
|
}
|
||||||
|
|
||||||
print '</div>';
|
print '</div>';
|
||||||
@ -834,6 +848,11 @@ if (count($object->records) > 0)
|
|||||||
$atleastonepage=(is_array($array) && count($array) > 0);
|
$atleastonepage=(is_array($array) && count($array) > 0);
|
||||||
|
|
||||||
print '<div class="centpercent websitebar"'.($style?' style="'.$style.'"':'').'">';
|
print '<div class="centpercent websitebar"'.($style?' style="'.$style.'"':'').'">';
|
||||||
|
|
||||||
|
print '<div class="websiteselection hideonsmartphoneimp">';
|
||||||
|
print '<input type="submit"'.$disabled.' class="button" value="'.dol_escape_htmltag($langs->trans("AddPage")).'" name="create">';
|
||||||
|
print '</div>';
|
||||||
|
|
||||||
print '<div class="websiteselection hideonsmartphoneimp">';
|
print '<div class="websiteselection hideonsmartphoneimp">';
|
||||||
print $langs->trans("Page").': ';
|
print $langs->trans("Page").': ';
|
||||||
print '</div>';
|
print '</div>';
|
||||||
@ -891,6 +910,7 @@ if (count($object->records) > 0)
|
|||||||
print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditPageMeta")).'" name="editmeta">';
|
print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditPageMeta")).'" name="editmeta">';
|
||||||
if ($object->fk_default_home > 0 && $pageid == $object->fk_default_home) print '<input type="submit" class="button" disabled="disabled" value="'.dol_escape_htmltag($langs->trans("SetAsHomePage")).'" name="setashome">';
|
if ($object->fk_default_home > 0 && $pageid == $object->fk_default_home) print '<input type="submit" class="button" disabled="disabled" value="'.dol_escape_htmltag($langs->trans("SetAsHomePage")).'" name="setashome">';
|
||||||
else print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("SetAsHomePage")).'" name="setashome">';
|
else print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("SetAsHomePage")).'" name="setashome">';
|
||||||
|
print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("ClonePage")).'" name="createpagefromclone">';
|
||||||
print '<input type="submit" class="buttonDelete" name="delete" value="'.$langs->trans("Delete").'"'.($atleastonepage?'':' disabled="disabled"').'>';
|
print '<input type="submit" class="buttonDelete" name="delete" value="'.$langs->trans("Delete").'"'.($atleastonepage?'':' disabled="disabled"').'>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user