24if (!defined(
'NOTOKENRENEWAL')) {
25 define(
'NOTOKENRENEWAL',
'1');
27if (!defined(
'NOREQUIREMENU')) {
28 define(
'NOREQUIREMENU',
'1');
30if (!defined(
'NOREQUIREAJAX')) {
31 define(
'NOREQUIREAJAX',
'1');
33if (!defined(
'NOREQUIRESOC')) {
34 define(
'NOREQUIRESOC',
'1');
38require
'../../main.inc.php';
39require_once DOL_DOCUMENT_ROOT.
'/website/class/website.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/website/class/websitepage.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/lib/website2.lib.php';
44$action =
GETPOST(
'action',
'alpha');
45$website_ref =
GETPOST(
'website_ref');
47$content =
GETPOST(
'content',
'restricthtml');
48$element_id =
GETPOST(
'element_id');
49$element_type =
GETPOST(
'element_type');
51$usercanmodify = $user->hasRight(
'website',
'write');
53 print
"You don't have permission for this action.";
64if (!empty($action) && $action ===
'updatedElementContent' && $usercanmodify && !empty($content) && !empty($element_id) && !empty($website_ref) && !empty($page_id)) {
67 $res = $objectpage->fetch($page_id);
69 print
"Cannot find page with ID = " . $page_id .
".";
74 $objectwebsite =
new Website($db);
75 $res = $objectwebsite->fetch($objectpage->fk_website);
77 print
"Cannot find website with REF " . $objectpage->fk_website .
".";
85 $objectpage->content = preg_replace(
'/<' . $element_type .
'[^>]*id="' . $element_id .
'"[^>]*>\K(.*?)(?=<\/' . $element_type .
'>)/s', $content, $objectpage->content, 1);
86 $res = $objectpage->update($user);
88 global $dolibarr_main_data_root;
89 $pathofwebsite = $dolibarr_main_data_root.($conf->entity > 1 ?
'/'.$conf->entity :
'').
'/website/'.$website_ref;
90 $filetpl = $pathofwebsite.
'/page'.$objectpage->id.
'.tpl.php';
94 print
"Failed to write file " . $filetpl .
".";
98 print
"Failed to save changes error " . $objectpage->error .
".";
104 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).