Work on website module
This commit is contained in:
parent
621ba7b76f
commit
8a32391171
@ -376,14 +376,11 @@ class WebsitePage extends CommonObject
|
||||
$this->status = trim($this->status);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Check parameters
|
||||
// Put here code to add a control on parameters values
|
||||
|
||||
// Update request
|
||||
$sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET';
|
||||
|
||||
$sql .= ' fk_website = '.(isset($this->fk_website)?$this->fk_website:"null").',';
|
||||
$sql .= ' pageurl = '.(isset($this->pageurl)?"'".$this->db->escape($this->pageurl)."'":"null").',';
|
||||
$sql .= ' title = '.(isset($this->title)?"'".$this->db->escape($this->title)."'":"null").',';
|
||||
@ -394,8 +391,6 @@ class WebsitePage extends CommonObject
|
||||
$sql .= ' date_creation = '.(! isset($this->date_creation) || dol_strlen($this->date_creation) != 0 ? "'".$this->db->idate($this->date_creation)."'" : 'null').',';
|
||||
$sql .= ' date_modification = '.(! isset($this->date_modification) || dol_strlen($this->date_modification) != 0 ? "'".$this->db->idate($this->date_modification)."'" : 'null').',';
|
||||
$sql .= ' tms = '.(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : "'".$this->db->idate(dol_now())."'");
|
||||
|
||||
|
||||
$sql .= ' WHERE rowid=' . $this->id;
|
||||
|
||||
$this->db->begin();
|
||||
@ -407,6 +402,12 @@ class WebsitePage extends CommonObject
|
||||
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
|
||||
}
|
||||
|
||||
if ($this->old_object->pageurl != $this->pageurl)
|
||||
{
|
||||
dol_syslog("The alias was changed, we must rename/recreate the page file into document");
|
||||
|
||||
}
|
||||
|
||||
if (!$error && !$notrigger) {
|
||||
// Uncomment this and change MYOBJECT to your own tag if you
|
||||
// want this action calls a trigger.
|
||||
|
||||
@ -182,48 +182,6 @@ if ($action == 'add')
|
||||
$id = $objectpage->id;
|
||||
}
|
||||
|
||||
// Update page
|
||||
if ($action == 'update')
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
$res = $object->fetch(0, $website);
|
||||
|
||||
$objectpage->fk_website = $object->id;
|
||||
$objectpage->pageurl = GETPOST('WEBSITE_PAGENAME');
|
||||
|
||||
$res = $objectpage->fetch(0, $object->fk_website, $objectpage->pageurl);
|
||||
|
||||
if ($res > 0)
|
||||
{
|
||||
$objectpage->title = GETPOST('WEBSITE_TITLE');
|
||||
$objectpage->description = GETPOST('WEBSITE_DESCRIPTION');
|
||||
$objectpage->keyword = GETPOST('WEBSITE_KEYWORD');
|
||||
|
||||
$res = $objectpage->update($user);
|
||||
if (! $res > 0)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages($objectpage->error, $objectpage->errors, 'errors');
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$db->commit();
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
$action='';
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
// Update page
|
||||
if ($action == 'delete')
|
||||
{
|
||||
@ -338,7 +296,7 @@ if ($action == 'setashome')
|
||||
}
|
||||
}
|
||||
|
||||
// Update page
|
||||
// Update page (meta)
|
||||
if ($action == 'updatemeta')
|
||||
{
|
||||
$db->begin();
|
||||
@ -349,7 +307,7 @@ if ($action == 'updatemeta')
|
||||
$res = $objectpage->fetch($pageid, $object->fk_website);
|
||||
if ($res > 0)
|
||||
{
|
||||
$oldobjectpage = clone $objectpage;
|
||||
$objectpage->old_object = clone $objectpage;
|
||||
|
||||
$objectpage->pageurl = GETPOST('WEBSITE_PAGENAME');
|
||||
$objectpage->title = GETPOST('WEBSITE_TITLE');
|
||||
@ -367,11 +325,13 @@ if ($action == 'updatemeta')
|
||||
{
|
||||
$db->commit();
|
||||
|
||||
$fileoldalias=$pathofwebsite.'/'.$oldobjectpage->pageurl.'.php';
|
||||
$fileoldalias=$pathofwebsite.'/'.$objectpage->old_object->pageurl.'.php';
|
||||
$filealias=$pathofwebsite.'/'.$objectpage->pageurl.'.php';
|
||||
|
||||
// Generate the alias.php page
|
||||
//-----------------------------
|
||||
dol_syslog("We regenerate alias page new name=".$filealias.", old name=".$fileoldalias);
|
||||
|
||||
dol_mkdir($pathofwebsite);
|
||||
dol_delete_file($fileoldalias);
|
||||
|
||||
@ -386,9 +346,10 @@ if ($action == 'updatemeta')
|
||||
if ($result) setEventMessages($langs->trans("Saved"), null, 'mesgs');
|
||||
else setEventMessages('Failed to write file '.$filealias, null, 'errors');
|
||||
|
||||
|
||||
|
||||
// Now create the .tpl file (duplicate code with actions updatecontent but we need this to save new header)
|
||||
dol_syslog("We regenerate the tpl page filetpl=".$filetpl);
|
||||
|
||||
dol_mkdir($pathofwebsite);
|
||||
dol_delete_file($filetpl);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user