25if (!defined(
'NOTOKENRENEWAL')) {
26 define(
'NOTOKENRENEWAL',
'1');
28if (!defined(
'NOREQUIREMENU')) {
29 define(
'NOREQUIREMENU',
'1');
31if (!defined(
'NOREQUIREAJAX')) {
32 define(
'NOREQUIREAJAX',
'1');
34if (!defined(
'NOREQUIRESOC')) {
35 define(
'NOREQUIRESOC',
'1');
39require
'../../main.inc.php';
40require_once DOL_DOCUMENT_ROOT.
'/website/class/website.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/website/class/websitepage.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/lib/website2.lib.php';
52$action =
GETPOST(
'action',
'alpha');
53$website_ref =
GETPOST(
'website_ref');
55$content =
GETPOST(
'content',
'restricthtml');
56$element_id =
GETPOST(
'element_id');
57$element_type =
GETPOST(
'element_type');
59$usercanmodify = $user->hasRight(
'website',
'write');
61 print
"You don't have permission for this action.";
72if (!empty($action) && $action ===
'updatedElementContent' && $usercanmodify && !empty($content) && !empty($element_id) && !empty($website_ref) && !empty($page_id)) {
75 $res = $objectpage->fetch($page_id);
77 print
"Cannot find page with ID = " . $page_id .
".";
82 $objectwebsite =
new Website($db);
83 $res = $objectwebsite->fetch($objectpage->fk_website);
85 print
"Cannot find website with REF " . $objectpage->fk_website .
".";
93 $objectpage->content = preg_replace(
'/<' . $element_type .
'[^>]*id="' . $element_id .
'"[^>]*>\K(.*?)(?=<\/' . $element_type .
'>)/s', $content, $objectpage->content, 1);
94 $res = $objectpage->update($user);
96 global $dolibarr_main_data_root;
97 $pathofwebsite = $dolibarr_main_data_root.($conf->entity > 1 ?
'/'.$conf->entity :
'').
'/website/'.$website_ref;
98 $filetpl = $pathofwebsite.
'/page'.$objectpage->id.
'.tpl.php';
102 print
"Failed to write file " . $filetpl .
".";
106 print
"Failed to save changes error " . $objectpage->error .
".";
112 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).