Work on website module

This commit is contained in:
Laurent Destailleur 2017-04-07 16:44:43 +02:00
parent be439f6252
commit 1ab3086fca

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2016-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -143,6 +143,8 @@ $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain
*/ */
if (GETPOST('refreshsite')) $pageid=0; // If we change the site, we reset the pageid. if (GETPOST('refreshsite')) $pageid=0; // If we change the site, we reset the pageid.
if (GETPOST('refreshpage')) $action='preview';
// Add page // Add page
if ($action == 'add') if ($action == 'add')
@ -434,7 +436,7 @@ if ($action == 'updatemeta')
} }
// Update page // Update page
if ($action == 'updatecontent') if ($action == 'updatecontent' || GETPOST('refreshsite') || GETPOST('refreshpage') || GETPOST('preview'))
{ {
$db->begin(); $db->begin();
$object->fetch(0, $website); $object->fetch(0, $website);
@ -443,6 +445,8 @@ if ($action == 'updatecontent')
$res = $objectpage->fetch($pageid, $object->fk_website); $res = $objectpage->fetch($pageid, $object->fk_website);
if ($res > 0) if ($res > 0)
{
if ($action == 'updatecontent')
{ {
$objectpage->content = GETPOST('PAGE_CONTENT'); $objectpage->content = GETPOST('PAGE_CONTENT');
@ -542,7 +546,12 @@ if ($action == 'updatecontent')
header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website.'&pageid='.$pageid); header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website.'&pageid='.$pageid);
exit; exit;
} }
else setEventMessages('Failed to write file '.$filetpl, null, 'errors'); else
{
setEventMessages('Failed to write file '.$filetpl, null, 'errors');
header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website.'&pageid='.$pageid);
exit;
}
} }
else else
{ {
@ -550,6 +559,12 @@ if ($action == 'updatecontent')
} }
} }
else else
{
header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website.'&pageid='.$pageid);
exit;
}
}
else
{ {
dol_print_error($db, 'Page not found'); dol_print_error($db, 'Page not found');
} }
@ -603,7 +618,7 @@ if ($action == 'edit')
$style=''; $style='';
if ($action != 'preview' && $action != 'editcontent') $style=' margin-bottom: 5px;'; if ($action != 'preview' && $action != 'editcontent') $style=' margin-bottom: 5px;';
//var_dump($objectpage);exit;
print '<div class="centpercent websitebar">'; print '<div class="centpercent websitebar">';
if (count($object->records) > 0) if (count($object->records) > 0)