26if (!defined(
'NOTOKENRENEWAL')) {
27 define(
'NOTOKENRENEWAL',
'1');
29if (!defined(
'NOREQUIREMENU')) {
30 define(
'NOREQUIREMENU',
'1');
32if (!defined(
'NOREQUIREAJAX')) {
33 define(
'NOREQUIREAJAX',
'1');
35if (!defined(
'NOREQUIRESOC')) {
36 define(
'NOREQUIRESOC',
'1');
40require
'../../main.inc.php';
41require_once DOL_DOCUMENT_ROOT.
'/website/class/website.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/website/class/websitepage.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/lib/website2.lib.php';
53$action =
GETPOST(
'action',
'alpha');
54$website_ref =
GETPOST(
'website_ref');
56$content =
GETPOST(
'content',
'restricthtml');
57$element_id =
GETPOST(
'element_id');
58$element_type =
GETPOST(
'element_type');
60$usercanmodify = $user->hasRight(
'website',
'write');
62 print
"You don't have permission for this action.";
73if (!empty($action) && $action ===
'updatedElementContent' && $usercanmodify && !empty($content) && !empty($element_id) && !empty($website_ref) && !empty($page_id)) {
75 $objectpage =
new WebsitePage(
$db);
76 $res = $objectpage->fetch((
int) $page_id);
78 print
"Cannot find page with ID = " . $page_id .
".";
84 $res = $objectwebsite->fetch($objectpage->fk_website);
86 print
"Cannot find website with REF " . $objectpage->fk_website .
".";
94 $objectpage->content = preg_replace(
'/<' . $element_type .
'[^>]*id="' . $element_id .
'"[^>]*>\K(.*?)(?=<\/' . $element_type .
'>)/s', $content, $objectpage->content, 1);
95 $res = $objectpage->update($user);
97 global $dolibarr_main_data_root;
98 $pathofwebsite = $dolibarr_main_data_root.($conf->entity > 1 ?
'/'.$conf->entity :
'').
'/website/'.$website_ref;
99 $filetpl = $pathofwebsite.
'/page'.$objectpage->id.
'.tpl.php';
103 print
"Failed to write file " . $filetpl .
".";
107 print
"Failed to save changes error " . $objectpage->error .
".";
113 print
"Changes are saved for " . $element_type .
" with id " . $element_id;
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage, $backupold=0)
Save content of a page on disk (page name is generally ID_of_page.php).