30define(
'NOSCANPOSTFORINJECTION', array(
'PAGE_CONTENT',
'WEBSITE_CSS_INLINE',
'WEBSITE_JS_INLINE',
'WEBSITE_HTML_HEADER',
'htmlheader'));
32define(
'USEDOLIBARREDITOR', 1);
33define(
'FORCE_CKEDITOR', 1);
34if (!defined(
'DISABLE_JS_GRAHP')) {
35 define(
'DISABLE_JS_GRAPH', 1);
41require
'../main.inc.php';
51require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
52require_once DOL_DOCUMENT_ROOT.
'/website/lib/website.lib.php';
53require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
54require_once DOL_DOCUMENT_ROOT.
'/core/lib/website.lib.php';
55require_once DOL_DOCUMENT_ROOT.
'/core/lib/website2.lib.php';
56require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
57require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
58require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
59require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formwebsite.class.php';
60require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
61require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
62require_once DOL_DOCUMENT_ROOT.
'/website/class/website.class.php';
63require_once DOL_DOCUMENT_ROOT.
'/website/class/websitepage.class.php';
64require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
65require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
68$langs->loadLangs(array(
"admin",
"other",
"users",
"website"));
71if (!$user->hasRight(
'website',
'read')) {
75$conf->dol_hide_leftmenu = 1;
81$websitekey =
GETPOST(
'website',
'alpha');
82$page =
GETPOST(
'page',
'alpha');
84$pageref =
GETPOST(
'pageref',
'alphanohtml');
86$action =
GETPOST(
'action',
'aZ09');
87$massaction =
GETPOST(
'massaction',
'alpha');
88$confirm =
GETPOST(
'confirm',
'alpha');
89$cancel =
GETPOST(
'cancel',
'alpha');
90$toselect =
GETPOST(
'toselect',
'array:int');
91$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'websitelist';
92$backtopage =
GETPOST(
'backtopage',
'alpha');
93$optioncss =
GETPOST(
'optioncss',
'aZ');
94$dol_hide_topmenu =
GETPOSTINT(
'dol_hide_topmenu');
95$dol_hide_leftmenu =
GETPOSTINT(
'dol_hide_leftmenu');
96$dol_openinpopup =
GETPOST(
'dol_openinpopup',
'aZ09');
98$type_container =
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'alpha');
99$section_dir =
GETPOST(
'section_dir',
'alpha');
100$file_manager =
GETPOST(
'file_manager',
'alpha');
101$replacesite =
GETPOST(
'replacesite',
'alpha');
102$mode =
GETPOST(
'mode',
'alpha');
104if (
GETPOST(
'deletesite',
'alpha')) {
105 $action =
'deletesite';
107if (
GETPOST(
'delete',
'alpha')) {
110if (
GETPOST(
'preview',
'alpha')) {
113if (
GETPOST(
'createsite',
'alpha')) {
114 $action =
'createsite';
116if (
GETPOST(
'createcontainer',
'alpha')) {
117 $action =
'createcontainer';
119if (
GETPOST(
'editcss',
'alpha')) {
122if (
GETPOST(
'editmenu',
'alpha')) {
123 $action =
'editmenu';
125if (
GETPOST(
'setashome',
'alpha')) {
126 $action =
'setashome';
128if (
GETPOST(
'editmeta',
'alpha')) {
129 $action =
'editmeta';
131if (
GETPOST(
'editsource',
'alpha')) {
132 $action =
'editsource';
134if (
GETPOST(
'editcontent',
'alpha')) {
135 $action =
'editcontent';
137if (
GETPOST(
'exportsite',
'alpha')) {
138 $action =
'exportsite';
141 $action =
'importsite';
143if (
GETPOST(
'createfromclone',
'alpha')) {
144 $action =
'createfromclone';
146if (
GETPOST(
'createpagefromclone',
'alpha')) {
147 $action =
'createpagefromclone';
149if (empty($action) && $file_manager) {
150 $action =
'file_manager';
152if ($action ==
'replacesite' || (empty($action) && $replacesite)) {
153 $mode =
'replacesite';
162$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
164if (empty($page) || $page == -1) {
167$offset = $limit * $page;
168$pageprev = $page - 1;
169$pagenext = $page + 1;
176$objectpage =
new WebsitePage(
$db);
178$listofwebsites =
$object->fetchAll(
'ASC',
'position');
181if (!($websiteid > 0) && empty($websitekey) && $action !=
'createsite') {
182 foreach ($listofwebsites as $key => $valwebsite) {
183 $websitekey = $valwebsite->ref;
187if ($websiteid > 0 || $websitekey) {
188 $res =
$object->fetch($websiteid, $websitekey);
198if (($pageid > 0 || $pageref) && $action !=
'addcontainer') {
199 $res = $objectpage->fetch($pageid, (
$object->id > 0 ?
$object->id : null), $pageref);
202 $res = $objectpage->fetch($pageid, (
$object->id > 0 ?
$object->id : null), null, $pageref);
206 if ($res >= 0 &&
$object->id > 0) {
207 if ($objectpage->fk_website !=
$object->id) {
208 if (
$object->fk_default_home > 0) {
209 $res = $objectpage->fetch(
$object->fk_default_home, (
string)
$object->id,
'');
211 $pageid =
$object->fk_default_home;
214 $res = $objectpage->fetch(0, (
string)
$object->id,
'');
216 $objectpage =
new WebsitePage(
$db);
218 $pageid = $objectpage->id;
222 $pageid = $objectpage->id;
228$atleastonepage =
false;
229if (empty($pageid) && empty($pageref) &&
$object->id > 0 && $action !=
'createcontainer') {
230 $pageid =
$object->fk_default_home;
231 if (empty($pageid)) {
232 $array = $objectpage->fetchAll(
$object->id,
'ASC,ASC',
'type_container,pageurl');
233 if (!is_array($array) && $array < 0) {
236 $atleastonepage = (is_array($array) && count($array) > 0);
240 foreach ($array as $key => $valpage) {
241 if (empty($firstpageid)) {
242 $firstpageid = $valpage->id;
244 if (
$object->fk_default_home && $key ==
$object->fk_default_home) {
245 $homepageid = $valpage->id;
248 $pageid = ($homepageid ? $homepageid : $firstpageid);
253global $dolibarr_main_data_root;
254$pathofwebsite = $dolibarr_main_data_root.($conf->entity > 1 ?
'/'.$conf->entity :
'').
'/website/'.$websitekey;
255$filehtmlheader = $pathofwebsite.
'/htmlheader.html';
256$filecss = $pathofwebsite.
'/styles.css.php';
257$filejs = $pathofwebsite.
'/javascript.js.php';
258$filerobot = $pathofwebsite.
'/robots.txt';
259$filehtaccess = $pathofwebsite.
'/.htaccess';
260$filetpl = $pathofwebsite.
'/page'.$pageid.
'.tpl.php';
261$fileindex = $pathofwebsite.
'/index.php';
262$filewrapper = $pathofwebsite.
'/wrapper.php';
263$filemanifestjson = $pathofwebsite.
'/manifest.json.php';
264$filereadme = $pathofwebsite.
'/README.md';
265$filelicense = $pathofwebsite.
'/LICENSE';
266$filemaster = $pathofwebsite.
'/master.inc.php';
272$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
276$permtouploadfile = $user->hasRight(
'website',
'write');
277$diroutput =
$conf->medias->multidir_output[
$conf->entity];
279$relativepath = $section_dir;
280$upload_dir = preg_replace(
'/\/$/',
'', $diroutput).
'/'.preg_replace(
'/^\//',
'', $relativepath);
282$htmlheadercontentdefault =
'';
283$htmlheadercontentdefault .=
'<link rel="stylesheet" id="google-fonts-css" href="//fonts.googleapis.com/css?family=Open+Sans:300,400,700" />'.
"\n";
284$htmlheadercontentdefault .=
'<link rel="stylesheet" id="font-wasesome-css" href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />'.
"\n";
285$htmlheadercontentdefault .=
'<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>'.
"\n";
286$htmlheadercontentdefault .=
'<script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>'.
"\n";
287$htmlheadercontentdefault .=
'<!--'.
"\n";
288$htmlheadercontentdefault .=
'<script src="/document.php?modulepart=medias&file=css/myfile.css"></script>'.
"\n";
289$htmlheadercontentdefault .=
'<script src="/document.php?modulepart=medias&file=js/myfile.js"></script>'.
"\n";
290$htmlheadercontentdefault .=
'-->'.
"\n";
292$manifestjsoncontentdefault =
'';
293$manifestjsoncontentdefault .=
'{
295 "short_name": "MyWebsite",
298 "display": "standalone",
299 "background_color": "#fff",
300 "description": "A simple Web app.",
302 "src": "images/'.urlencode($website->ref).
'/homescreen48.png",
306 "src": "image/'.urlencode($website->ref).
'/homescreen72.png",
310 "src": "image/'.urlencode($website->ref).
'/homescreen96.png",
314 "src": "image/'.urlencode($website->ref).
'/homescreen144.png",
318 "src": "image/'.urlencode($website->ref).
'/homescreen168.png",
322 "src": "image/'.urlencode($website->ref).
'/homescreen192.png",
326 "related_applications": [{
328 "url": "https://play.google.com/store/apps/details?id=com.nltechno.dolidroidpro"
332$listofpages = array();
335if (
GETPOST(
'optionpagecontent')) {
341if (
GETPOST(
'optionsitefiles')) {
342 $algo .=
'sitefiles';
345$searchkey =
GETPOST(
'searchstring',
'restricthtmlallowunvalid');
347if ($sortfield ==
'') {
348 if ($action ==
'file_manager') {
352 $sortfield =
'pageurl';
356'@phan-var-force string $sortfield';
360$otherfilters = array();
362if ($action ==
'replacesite' || $mode ==
'replacesite') {
363 $containertype =
GETPOST(
'optioncontainertype',
'aZ09') !=
'-1' ?
GETPOST(
'optioncontainertype',
'aZ09') :
'';
364 $langcode =
GETPOST(
'optionlanguage',
'aZ09');
366 $otherfilters[
'category'] =
GETPOSTINT(
'optioncategory');
369 $listofpages = getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters, -1);
372$usercanedit = $user->hasRight(
'website',
'write');
373$permissiontoadd = $user->hasRight(
'website',
'write');
374$permissiontodelete = $user->hasRight(
'website',
'delete');
385if (
GETPOST(
'refreshsite',
'alpha') ||
GETPOST(
'refreshsite.x',
'alpha') ||
GETPOST(
'refreshsite_x',
'alpha')) {
386 if ($action ==
'addsite') {
389 if ($action ==
'updatesource') {
393 $pageid =
$object->fk_default_home;
394 if (empty($pageid)) {
395 $array = $objectpage->fetchAll(
$object->id,
'ASC,ASC',
'type_container,pageurl');
396 if (!is_array($array) && $array < 0) {
399 $atleastonepage = (is_array($array) && count($array) > 0);
403 foreach ($array as $key => $valpage) {
404 if (empty($firstpageid)) {
405 $firstpageid = $valpage->id;
407 if (
$object->fk_default_home && $key ==
$object->fk_default_home) {
408 $homepageid = $valpage->id;
411 $pageid = ($homepageid ? $homepageid : $firstpageid);
414if (
GETPOST(
'refreshpage',
'alpha') && !in_array($action, array(
'updatecss'))) {
418if ($cancel && $action ==
'renamefile') {
427 header(
"Location: ".$backtopage);
432$savbacktopage = $backtopage;
433$backtopage = $_SERVER[
"PHP_SELF"].
'?file_manager=1&website='.urlencode($websitekey).
'&pageid='.urlencode((
string) $pageid).(GETPOST(
'section_dir',
'alpha') ?
'§ion_dir='.urlencode(
GETPOST(
'section_dir',
'alpha')) :
'');
435 $backtopage .=
'&sortfield='.urlencode($sortfield);
438 $backtopage .=
'&sortorder='.urlencode($sortorder);
440include DOL_DOCUMENT_ROOT.
'/core/actions_linkedfiles.inc.php';
442$backtopage = $savbacktopage;
446if ($action ==
'renamefile') {
447 $action =
'file_manager';
450if ($action ==
'setwebsiteonline' && $usercanedit) {
451 $website->setStatut($website::STATUS_VALIDATED,
null,
'',
'WEBSITE_MODIFY',
'status');
453 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
GETPOST(
'website')).
'&pageid='.
GETPOSTINT(
'websitepage'));
456if ($action ==
'setwebsiteoffline' && $usercanedit) {
457 $result = $website->setStatut($website::STATUS_DRAFT,
null,
'',
'WEBSITE_MODIFY',
'status');
459 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
GETPOST(
'website')).
'&pageid='.
GETPOSTINT(
'websitepage'));
462if ($action ==
'seteditinline') {
465 setEventMessages($langs->trans(
"FeatureNotYetAvailable"),
null,
'warnings');
470 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
GETPOST(
'website')).
'&pageid='.
GETPOSTINT(
'pageid'));
473if ($action ==
'unseteditinline') {
475 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
GETPOST(
'website')).
'&pageid='.
GETPOSTINT(
'pageid'));
478if ($action ==
'setshowsubcontainers') {
481 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
GETPOST(
'website')).
'&pageid='.
GETPOSTINT(
'pageid'));
484if ($action ==
'unsetshowsubcontainers') {
486 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
GETPOST(
'website')).
'&pageid='.
GETPOSTINT(
'pageid'));
490if ($massaction ==
'replace' &&
GETPOST(
'confirmmassaction',
'alpha') && !$searchkey && $usercanedit) {
491 $mode =
'replacesite';
492 $action =
'replacesite';
496if ($action ==
'deletetemplate' && $usercanedit) {
497 $dirthemes = array(
'/doctemplates/websites');
498 if (!empty(
$conf->modules_parts[
'websitetemplates'])) {
499 foreach (
$conf->modules_parts[
'websitetemplates'] as $reldir) {
500 $dirthemes = array_merge($dirthemes, (array) ($reldir.
'doctemplates/websites'));
503 $dirthemes = array_unique($dirthemes);
507 $mode =
'importsite';
508 $action =
'importsite';
510 if (count($dirthemes)) {
512 foreach ($dirthemes as $dir) {
514 $dirtheme = DOL_DATA_ROOT.$dir;
515 if (is_dir($dirtheme)) {
516 $templateuserfile =
GETPOST(
'templateuserfile');
517 $imguserfile = preg_replace(
'/\.zip$/',
'', $templateuserfile).
'.jpg';
526if ($massaction ==
'setcategory' &&
GETPOST(
'confirmmassaction',
'alpha') && $usercanedit) {
533 if ($categoryid > 0) {
534 $tmpwebsitepage =
new WebsitePage(
$db);
536 $category->fetch($categoryid);
538 foreach ($toselect as $tmpid) {
539 $tmpwebsitepage->id = (int) $tmpid;
540 $result = $category->add_type($tmpwebsitepage,
'website_page');
541 if ($result < 0 && $result != -3) {
555 setEventMessages($langs->trans(
"RecordsModified", $nbupdate),
null,
'mesgs');
561 $listofpages = getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters, -1);
565if ($massaction ==
'delcategory' &&
GETPOST(
'confirmmassaction',
'alpha') && $usercanedit) {
572 if ($categoryid > 0) {
573 $tmpwebsitepage =
new WebsitePage(
$db);
575 $category->fetch($categoryid);
577 foreach ($toselect as $tmpid) {
578 $tmpwebsitepage->id = (int) $tmpid;
579 $result = $category->del_type($tmpwebsitepage,
'website_page');
580 if ($result < 0 && $result != -3) {
594 setEventMessages($langs->trans(
"RecordsModified", $nbupdate),
null,
'mesgs');
600 $listofpages = getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters, -1);
604if ($massaction ==
'replace' &&
GETPOST(
'confirmmassaction',
'alpha') && $usercanedit) {
605 $replacestring =
GETPOST(
'replacestring',
'restricthtmlallowunvalid');
607 $dolibarrdataroot = preg_replace(
'/([\\/]+)$/i',
'', DOL_DATA_ROOT);
608 $allowimportsite =
true;
609 if (
dol_is_file($dolibarrdataroot.
'/installmodules.lock')) {
610 $allowimportsite =
false;
613 if (!$allowimportsite) {
617 $message = $langs->trans(
'InstallModuleFromWebHasBeenDisabledContactUs');
620 $message = $langs->trans(
"InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.
'/installmodules.lock');
623 } elseif (!$user->hasRight(
'website',
'writephp')) {
625 } elseif (!$replacestring) {
630 foreach ($toselect as $keyselected) {
631 $objectpage = $listofpages[
'list'][$keyselected];
632 if ($objectpage->pageurl) {
633 dol_syslog(
"Replace string into page ".$objectpage->pageurl);
635 if (
GETPOST(
'optionpagecontent',
'aZ09')) {
636 $objectpage->content = str_replace($searchkey, $replacestring, $objectpage->content);
638 if (
GETPOST(
'optionmeta',
'aZ09')) {
639 $objectpage->title = str_replace($searchkey, $replacestring, $objectpage->title);
640 $objectpage->description = str_replace($searchkey, $replacestring, $objectpage->description);
641 $objectpage->keywords = str_replace($searchkey, $replacestring, $objectpage->keywords);
644 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
645 $filetpl = $pathofwebsite.
'/page'.$objectpage->id.
'.tpl.php';
650 setEventMessages(
'Failed to write file '.basename($filealias),
null,
'errors');
658 $objectpage->update($user);
662 $action =
'createcontainer';
668 if ($nbreplacement > 0) {
669 setEventMessages($langs->trans(
"ReplacementDoneInXPages", $nbreplacement),
null,
'mesgs');
672 $containertype =
GETPOST(
'optioncontainertype',
'aZ09') !=
'-1' ?
GETPOST(
'optioncontainertype',
'aZ09') :
'';
673 $langcode =
GETPOST(
'optionlanguage',
'aZ09');
674 $otherfilters = array();
676 $otherfilters[
'category'] =
GETPOSTINT(
'optioncategory');
680 $listofpages = getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters);
710if ($action ==
'addsite' && $usercanedit) {
713 if (
GETPOST(
'virtualhost',
'alpha') && !preg_match(
'/^http/',
GETPOST(
'virtualhost',
'alpha'))) {
715 setEventMessages($langs->trans(
'ErrorURLMustStartWithHttp', $langs->transnoentitiesnoconv(
"VirtualHost")),
null,
'errors');
718 if (!$error && !
GETPOST(
'WEBSITE_REF',
'alpha')) {
720 $langs->load(
"errors");
721 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->transnoentities(
"WebsiteName")),
null,
'errors');
723 if (!$error && !preg_match(
'/^[a-z0-9_\-\.]+$/i',
GETPOST(
'WEBSITE_REF',
'alpha'))) {
725 $langs->load(
"errors");
726 setEventMessages($langs->transnoentities(
"ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities(
"Ref")),
null,
'errors');
731 $arrayotherlang = explode(
',',
GETPOST(
'WEBSITE_OTHERLANG',
'alphanohtml'));
732 foreach ($arrayotherlang as $key => $val) {
734 if (empty(trim($val))) {
737 $arrayotherlang[$key] = substr(trim($val), 0, 2);
741 $tmpobject->ref =
GETPOST(
'WEBSITE_REF',
'alpha');
742 $tmpobject->description =
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml');
743 $tmpobject->lang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
744 $tmpobject->otherlang = implode(
',', $arrayotherlang);
745 $tmpobject->virtualhost =
GETPOST(
'virtualhost',
'alpha');
747 $result = $tmpobject->create($user);
751 } elseif ($result < 0) {
757 if (!$error && $tmpobject !==
null) {
762 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$tmpobject->ref);
766 $action =
'createsite';
775'@phan-var-force int $error';
778if ($action ==
'addcontainer' && $usercanedit) {
783 $objectpage->fk_website =
$object->id;
784 $objectpage->status = $objectpage::STATUS_DRAFT;
786 if (GETPOSTISSET(
'fetchexternalurl')) {
787 $urltograb =
GETPOST(
'externalurl',
'alpha');
788 $grabimages =
GETPOSTINT(
'grabimages') ? 1 : 0;
789 $grabimagesinto =
GETPOST(
'grabimagesinto',
'alpha');
791 include_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
794 if (empty($urltograb)) {
796 $langs->load(
"errors");
797 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"URL")),
null,
'errors');
798 $action =
'createcontainer';
799 } elseif (!preg_match(
'/^http/', $urltograb)) {
801 $langs->load(
"errors");
802 setEventMessages(
'Error URL must start with http:// or https://',
null,
'errors');
803 $action =
'createcontainer';
807 $urltograbdirwithoutslash =
'';
808 $urltograbdirrootwithoutslash =
'';
812 $urltograbwithoutdomainandparam = preg_replace(
'/^https?:\/\/[^\/]+\/?/i',
'', $urltograb);
814 $urltograbwithoutdomainandparam = preg_replace(
'/\?.*$/',
'', $urltograbwithoutdomainandparam);
815 if (empty($urltograbwithoutdomainandparam) && !preg_match(
'/\/$/', $urltograb)) {
818 $pageurl =
dol_sanitizeFileName(preg_replace(
'/[\/\.]/',
'-', preg_replace(
'/\/+$/',
'', $urltograbwithoutdomainandparam)));
820 $urltograbdirwithoutslash = dirname($urltograb.
'.');
828 $tmpwebsitepage =
new WebsitePage(
$db);
829 $result = $tmpwebsitepage->fetch(0, (
string)
$object->id, $pageurl);
831 setEventMessages($langs->trans(
"AliasPageAlreadyExists", $pageurl),
null,
'errors');
833 $action =
'createcontainer';
839 $tmp =
getURLContent($urltograb,
'GET',
'', 1, array(), array(
'http',
'https'), 0);
842 if (!empty($tmp[
'content_type']) && preg_match(
'/ISO-8859-1/', $tmp[
'content_type'])) {
843 if (function_exists(
'mb_check_encoding')) {
844 if (mb_check_encoding($tmp[
'content'],
'ISO-8859-1')) {
846 $tmp[
'content'] = mb_convert_encoding($tmp[
'content'],
'ISO-8859-1',
'UTF-8');
849 setEventMessages(
'Error getting '.$urltograb.
': content seems non valid ISO-8859-1',
null,
'errors');
850 $action =
'createcontainer';
854 setEventMessages(
'Error getting '.$urltograb.
': content seems ISO-8859-1 but functions to convert into UTF-8 are not available in your PHP',
null,
'errors');
855 $action =
'createcontainer';
858 if (empty($tmp[
'content_type']) || (!empty($tmp[
'content_type']) && preg_match(
'/UTF-8/', $tmp[
'content_type']))) {
859 if (function_exists(
'mb_check_encoding')) {
860 if (mb_check_encoding($tmp[
'content'],
'UTF-8')) {
864 setEventMessages(
'Error getting '.$urltograb.
': content seems not a valid UTF-8',
null,
'errors');
865 $action =
'createcontainer';
870 if (!empty($tmp[
'curl_error_no'])) {
872 setEventMessages(
'Error getting '.$urltograb.
': '.$tmp[
'curl_error_msg'],
null,
'errors');
873 $action =
'createcontainer';
874 } elseif ($tmp[
'http_code'] != 200) {
876 setEventMessages(
'Error getting '.$urltograb.
': '.$tmp[
'http_code'],
null,
'errors');
877 $action =
'createcontainer';
896 preg_match(
'/<head>(.*)<\/head>/ims', $tmp[
'content'], $regs);
899 $objectpage->type_container =
'page';
900 $objectpage->pageurl = $pageurl;
901 if (empty($objectpage->pageurl)) {
903 $objectpage->pageurl = $tmpdomain.
'-home';
906 $objectpage->aliasalt =
'';
908 if (preg_match(
'/^(\d+)\-/', basename($urltograb), $regs)) {
909 $objectpage->aliasalt = $regs[1];
913 if (preg_match(
'/<title>(.*)<\/title>/ims', $head, $regtmp)) {
914 $objectpage->title = $regtmp[1];
916 if (preg_match(
'/<meta name="title"[^"]+content="([^"]+)"/ims', $head, $regtmp)) {
917 if (empty($objectpage->title)) {
918 $objectpage->title = $regtmp[1];
921 if (preg_match(
'/<meta name="description"[^"]+content="([^"]+)"/ims', $head, $regtmp)) {
922 $objectpage->description = $regtmp[1];
924 if (preg_match(
'/<meta name="keywords"[^"]+content="([^"]+)"/ims', $head, $regtmp)) {
925 $objectpage->keywords = $regtmp[1];
927 if (preg_match(
'/<html\s+lang="([^"]+)"/ims', $tmp[
'content'], $regtmp)) {
928 $tmplang = explode(
'-', $regtmp[1]);
929 $objectpage->lang = $tmplang[0].(empty($tmplang[1]) ?
'' :
'_'.strtoupper($tmplang[1]));
932 $tmp[
'content'] = preg_replace(
'/\s*<meta name="generator"[^"]+content="([^"]+)"\s*\/?>/ims',
'', $tmp[
'content']);
934 $objectpage->content = $tmp[
'content'];
935 $objectpage->content = preg_replace(
'/^.*<body(\s[^>]*)*>/ims',
'', $objectpage->content);
936 $objectpage->content = preg_replace(
'/<\/body(\s[^>]*)*>.*$/ims',
'', $objectpage->content);
944 $objectpage->htmlheader = $tmp[
'content'];
945 $objectpage->htmlheader = preg_replace(
'/^.*<head(\s[^>]*)*>/ims',
'', $objectpage->htmlheader);
946 $objectpage->htmlheader = preg_replace(
'/<\/head(\s[^>]*)*>.*$/ims',
'', $objectpage->htmlheader);
947 $objectpage->htmlheader = preg_replace(
'/<base(\s[^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
948 $objectpage->htmlheader = preg_replace(
'/<meta http-equiv="content-type"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
949 $objectpage->htmlheader = preg_replace(
'/<meta name="robots"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
950 $objectpage->htmlheader = preg_replace(
'/<meta name="title"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
951 $objectpage->htmlheader = preg_replace(
'/<meta name="description"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
952 $objectpage->htmlheader = preg_replace(
'/<meta name="keywords"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
953 $objectpage->htmlheader = preg_replace(
'/<meta name="generator"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
956 $objectpage->htmlheader = preg_replace(
'/<title>[^<]*<\/title>\n*/ims',
'', $objectpage->htmlheader);
957 $objectpage->htmlheader = preg_replace(
'/<link[^>]*rel="shortcut[^>]*>\n/ims',
'', $objectpage->htmlheader);
958 $objectpage->htmlheader = preg_replace(
'/<link[^>]*rel="alternate[^>]*>\n/ims',
'', $objectpage->htmlheader);
959 $objectpage->htmlheader = preg_replace(
'/<link[^>]*rel="canonical[^>]*>\n/ims',
'', $objectpage->htmlheader);
962 $tmp = $objectpage->htmlheader;
965 preg_match_all(
'/<script([^\.>]+)src=["\']([^"\'>]+)["\']([^>]*)><\/script>/i', $objectpage->htmlheader, $regs);
966 $errorforsubresource = 0;
967 foreach ($regs[0] as $key => $val) {
968 dol_syslog(
"We will grab the script resource found into script tag ".$regs[2][$key]);
970 $linkwithoutdomain = $regs[2][$key];
971 if (preg_match(
'/^\//', $regs[2][$key])) {
972 $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key];
974 $urltograbbis = $urltograbdirwithoutslash.
'/'.$regs[2][$key];
978 if (preg_match(
'/^http/', $regs[2][$key])) {
979 $urltograbbis = $regs[2][$key];
980 $linkwithoutdomain = preg_replace(
'/^https?:\/\/[^\/]+\//i',
'', $regs[2][$key]);
990 if ($domaintograb != $domaintograbbis) {
1022 $tmp = preg_replace(
'/'.preg_quote($regs[0][$key],
'/').
'/i',
'', $tmp);
1024 $objectpage->htmlheader = trim($tmp).
"\n";
1028 $pagecsscontent =
"\n".
'<style>'.
"\n";
1030 preg_match_all(
'/<link([^\.>]+)href=["\']([^"\'>]+\.css[^"\'>]*)["\']([^>]*)>/i', $objectpage->htmlheader, $regs);
1031 $errorforsubresource = 0;
1032 foreach ($regs[0] as $key => $val) {
1033 dol_syslog(
"We will grab the css resources found into link tag ".$regs[2][$key]);
1035 $linkwithoutdomain = $regs[2][$key];
1036 if (preg_match(
'/^\//', $regs[2][$key])) {
1037 $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key];
1039 $urltograbbis = $urltograbdirwithoutslash.
'/'.$regs[2][$key];
1043 if (preg_match(
'/^http/', $regs[2][$key])) {
1044 $urltograbbis = $regs[2][$key];
1045 $linkwithoutdomain = preg_replace(
'/^https?:\/\/[^\/]+\//i',
'', $regs[2][$key]);
1055 if ($domaintograb != $domaintograbbis) {
1059 $tmpgeturl =
getURLContent($urltograbbis,
'GET',
'', 1, array(), array(
'http',
'https'), 0);
1060 if (!empty($tmpgeturl[
'curl_error_no'])) {
1061 $errorforsubresource++;
1062 setEventMessages(
'Error getting link tag url '.$urltograbbis.
': '.$tmpgeturl[
'curl_error_msg'],
null,
'errors');
1063 dol_syslog(
'Error getting '.$urltograbbis.
': '.$tmpgeturl[
'curl_error_msg']);
1064 $action =
'createcontainer';
1065 } elseif ($tmpgeturl[
'http_code'] != 200) {
1066 $errorforsubresource++;
1067 setEventMessages(
'Error getting link tag url '.$urltograbbis.
': '.$tmpgeturl[
'http_code'],
null,
'errors');
1068 dol_syslog(
'Error getting '.$urltograbbis.
': '.$tmpgeturl[
'curl_error_msg']);
1069 $action =
'createcontainer';
1078 $tmpgeturl[
'content'] = preg_replace(
'/\/\*\s+CSS content[a-z\s]*\s+\*\//',
'', $tmpgeturl[
'content']);
1088 $pagecsscontent .=
"\n".
'/* Content of file '.$urltograbbis.
' */'.
"\n";
1090 getAllImages($object, $objectpage, $urltograbbis, $tmpgeturl[
'content'], $action, 1, $grabimages, $grabimagesinto);
1093 include_once DOL_DOCUMENT_ROOT.
'/core/class/lessc.class.php';
1094 $lesscobj =
new Lessc();
1096 $contentforlessc =
".bodywebsite {\n".$tmpgeturl[
'content'].
"\n}\n";
1098 $contentforlessc = $lesscobj->compile($contentforlessc);
1101 $pagecsscontent .= $contentforlessc.
"\n";
1105 dol_syslog(
"Failed to compile the CSS from URL ".$urltograbbis.
" with lessc: ".$e->getMessage(), LOG_WARNING);
1106 $pagecsscontent .= $tmpgeturl[
'content'].
"\n";
1109 $objectpage->htmlheader = preg_replace(
'/'.preg_quote($regs[0][$key],
'/').
'\n*/ims',
'', $objectpage->htmlheader);
1113 $pagecsscontent .=
'</style>';
1117 $objectpage->htmlheader .= trim($pagecsscontent).
"\n";
1121 $tmp = $objectpage->content;
1123 getAllImages($object, $objectpage, $urltograb, $tmp, $action, 1, $grabimages, $grabimagesinto);
1126 $tmp = preg_replace(
'/a href="\/([^\/"]+)\/([^\/"]+)"/',
'a href="/\1-\2.php"', $tmp);
1127 $tmp = preg_replace(
'/a href="\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)"/',
'a href="/\1-\2-\3.php"', $tmp);
1128 $tmp = preg_replace(
'/a href="\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)"/',
'a href="/\1-\2-\3-\4.php"', $tmp);
1131 $objectpage->content = $tmp;
1133 $objectpage->grabbed_from = $urltograb;
1137 $newaliasnames =
'';
1138 if (!$error &&
GETPOST(
'WEBSITE_ALIASALT',
'alpha')) {
1139 $arrayofaliastotest = explode(
',', str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_ALIASALT',
'alpha')));
1140 $websitepagetemp =
new WebsitePage(
$db);
1141 foreach ($arrayofaliastotest as $aliastotest) {
1142 $aliastotest = trim(preg_replace(
'/\.php$/i',
'', $aliastotest));
1145 if (preg_match(
'/^page\d+/i', $aliastotest)) {
1147 $langs->load(
"errors");
1149 $action =
'createcontainer';
1152 $result = $websitepagetemp->fetch(0, (
string)
$object->id, $aliastotest);
1155 $langs->load(
"errors");
1156 setEventMessages($websitepagetemp->error, $websitepagetemp->errors,
'errors');
1157 $action =
'createcontainer';
1162 $langs->load(
"errors");
1163 setEventMessages($langs->trans(
"ErrorAPageWithThisNameOrAliasAlreadyExists", $websitepagetemp->pageurl),
null,
'errors');
1164 $action =
'createcontainer';
1167 $newaliasnames .= ($newaliasnames ?
', ' :
'').$aliastotest;
1172 $objectpage->title = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_TITLE',
'alphanohtml'));
1173 $objectpage->type_container =
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'aZ09');
1175 $objectpage->ref = $objectpage->pageurl;
1176 $objectpage->aliasalt = $newaliasnames;
1177 $objectpage->description = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml'));
1178 $objectpage->lang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
1179 $objectpage->otherlang =
GETPOST(
'WEBSITE_OTHERLANG',
'aZ09comma');
1180 $objectpage->image =
GETPOST(
'WEBSITE_IMAGE',
'alpha');
1181 $objectpage->keywords = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_KEYWORDS',
'alphanohtml'));
1182 $objectpage->allowed_in_frames =
GETPOST(
'WEBSITE_ALLOWED_IN_FRAMES',
'aZ09') ? 1 : 0;
1183 $objectpage->htmlheader =
GETPOST(
'htmlheader',
'restricthtmlallowlinkscript');
1185 $objectpage->author_alias =
GETPOST(
'WEBSITE_AUTHORALIAS',
'alphanohtml');
1186 $objectpage->object_type =
GETPOST(
'WEBSITE_OBJECTCLASS');
1187 $objectpage->fk_object =
GETPOST(
'WEBSITE_OBJECTID');
1188 $substitutionarray = array();
1189 $substitutionarray[
'__WEBSITE_CREATED_BY__'] = $user->getFullName($langs);
1202 $pageidfortranslation = (
GETPOSTINT(
'pageidfortranslation') > 0 ?
GETPOSTINT(
'pageidfortranslation') : 0);
1203 if ($pageidfortranslation > 0) {
1205 $objectpagetmp =
new WebsitePage(
$db);
1206 $objectpagetmp->fetch($pageidfortranslation);
1207 if ($objectpagetmp->fk_page > 0) {
1208 $pageidfortranslation = $objectpagetmp->fk_page;
1211 $objectpage->fk_page = $pageidfortranslation;
1215 if (GETPOSTISSET(
'content')) {
1217 $content =
GETPOST(
'content',
'none');
1234 if (empty($objectpage->pageurl)) {
1235 $langs->load(
"errors");
1236 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WEBSITE_PAGENAME")),
null,
'errors');
1238 $action =
'createcontainer';
1239 } elseif (!preg_match(
'/^[a-z0-9\-\_]+$/i', $objectpage->pageurl)) {
1240 $langs->load(
"errors");
1241 setEventMessages($langs->transnoentities(
"ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities(
'WEBSITE_PAGENAME')),
null,
'errors');
1243 $action =
'createcontainer';
1245 if (empty($objectpage->title)) {
1246 $langs->load(
"errors");
1247 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WEBSITE_TITLE")),
null,
'errors');
1249 $action =
'createcontainer';
1251 if ($objectpage->fk_page > 0 && empty($objectpage->lang)) {
1252 $langs->load(
"errors");
1253 setEventMessages($langs->trans(
"ErrorLanguageRequiredIfPageIsTranslationOfAnother"),
null,
'errors');
1255 $action =
'createcontainer';
1257 if ($objectpage->fk_page > 0 && !empty($objectpage->lang)) {
1258 if ($objectpage->lang == $website->lang) {
1259 $langs->load(
"errors");
1260 setEventMessages($langs->trans(
"ErrorLanguageMustNotBeSourceLanguageIfPageIsTranslationOfAnother"),
null,
'errors');
1262 $action =
'createcontainer';
1270 $pageid = $objectpage->create($user);
1274 $action =
'createcontainer';
1280 $categoriesarray =
GETPOST(
'categories',
'array:int');
1281 $result = $objectpage->setCategories($categoriesarray);
1290 if (empty(
$object->fk_default_home)) {
1291 $object->fk_default_home = $pageid;
1292 $res =
$object->update($user);
1297 $filetpl = $pathofwebsite.
'/page'.$pageid.
'.tpl.php';
1300 $result =
dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper, $object);
1311 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
1312 $filetpl = $pathofwebsite.
'/page'.$objectpage->id.
'.tpl.php';
1317 setEventMessages(
'Failed to write file '.basename($filealias),
null,
'errors');
1326 $action =
'createcontainer';
1333 setEventMessages($langs->trans(
"PageAdded", $objectpage->pageurl),
null,
'mesgs');
1340 $pageid = $objectpage->id;
1346 $pathtomedias = DOL_DATA_ROOT.
'/medias';
1347 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
1349 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
1350 dol_mkdir(dirname($pathtomediasinwebsite));
1351 $result = symlink($pathtomedias, $pathtomediasinwebsite);
1353 $langs->load(
"errors");
1354 setEventMessages($langs->trans(
"ErrorFailedToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias),
null,
'errors');
1368 $htmlheadercontent =
"<html>\n";
1369 $htmlheadercontent .= $htmlheadercontentdefault;
1370 $htmlheadercontent .=
"</html>";
1375 $csscontent =
"/* CSS content (all pages) */\nbody.bodywebsite { margin: 0; font-family: 'Open Sans', sans-serif; }\n.bodywebsite h1 { margin-top: 0; margin-bottom: 0; padding: 10px;}";
1380 $jscontent =
"/* JS content (all pages) */\n";
1385 $robotcontent =
"# Robot file. Generated with Dolibarr\nUser-agent: *\nAllow: /public/\nDisallow: /administrator/";
1390 $htaccesscontent =
"# Order allow,deny\n# Deny from all";
1395 $manifestjsoncontent =
"";
1400 $readmecontent =
"Website generated by Dolibarr ERP CRM";
1405 $licensecontent =
"LICENSE\n-------\nThis website template content (HTML and PHP code) is published under the license CC-BY-SA - https://creativecommons.org/licenses/by/4.0/";
1409 $action =
'preview';
1414if ($action ==
'confirm_deletesite' && $confirm ==
'yes' && $permissiontodelete) {
1423 $res =
$object->delete($user);
1430 if (
GETPOST(
'delete_also_js',
'alpha') ==
'on') {
1431 $pathofwebsitejs = DOL_DATA_ROOT.
'/medias/js/'.
$object->ref;
1435 if (
GETPOST(
'delete_also_medias',
'alpha') ==
'on') {
1436 $pathofwebsitemedias = DOL_DATA_ROOT.
'/medias/image/'.
$object->ref;
1446 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
1455if (GETPOSTISSET(
'pageid') && $action ==
'delete' && $permissiontodelete && !
GETPOST(
'file_manager')) {
1460 $res =
$object->fetch(0, $websitekey);
1463 $res = $objectpage->fetch($pageid, (
string)
$object->id);
1466 $res = $objectpage->delete($user);
1475 setEventMessages($langs->trans(
"PageDeleted", $objectpage->pageurl, $websitekey),
null,
'mesgs');
1477 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$websitekey);
1485if (!GETPOSTISSET(
'pageid')) {
1486 $objectclass =
'WebsitePage';
1490 if (!$error && ($massaction ==
'delete' || ($action ==
'delete' && $confirm ==
'yes')) && $permissiontodelete) {
1493 $objecttmp =
new $objectclass(
$db);
1495 foreach ($toselect as $toselectid) {
1496 $result = $objecttmp->fetch($toselectid);
1498 $result = $objecttmp->delete($user);
1527 if ($action ==
'delete') {
1528 $mode =
'replacesite';
1529 $action =
'replacesite';
1531 $containertype =
GETPOST(
'optioncontainertype',
'aZ09') !=
'-1' ?
GETPOST(
'optioncontainertype',
'aZ09') :
'';
1532 $langcode =
GETPOST(
'optionlanguage',
'aZ09');
1533 $otherfilters = array();
1535 $otherfilters[
'category'] =
GETPOSTINT(
'optioncategory');
1538 $listofpages = getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters);
1543if ($action ==
'updatecss' && $usercanedit) {
1546 $action =
'editcss';
1548 $res =
$object->fetch(0, $websitekey);
1551 if (GETPOSTISSET(
'virtualhost')) {
1552 $tmpvirtualhost = preg_replace(
'/\/$/',
'',
GETPOST(
'virtualhost',
'alpha'));
1553 if ($tmpvirtualhost && !preg_match(
'/^http/', $tmpvirtualhost)) {
1555 setEventMessages($langs->trans(
'ErrorURLMustStartWithHttp', $langs->transnoentitiesnoconv(
"VirtualHost")),
null,
'errors');
1556 $action =
'editcss';
1560 $arrayotherlang = explode(
',',
GETPOST(
'WEBSITE_OTHERLANG',
'alphanohtml'));
1561 foreach ($arrayotherlang as $key => $val) {
1563 if (empty(trim($val))) {
1566 $arrayotherlang[$key] = substr(trim($val), 0, 2);
1569 $object->virtualhost = $tmpvirtualhost;
1571 $object->otherlang = implode(
',', $arrayotherlang);
1574 $result =
$object->update($user);
1578 $action =
'editcss';
1584 if (($_FILES[
'addedfile'][
"name"] !=
'')) {
1585 $uploadfolder =
$conf->website->dir_output.
'/'.$websitekey;
1586 if ($_FILES[
'addedfile'][
'type'] !=
'image/png') {
1590 $filetoread = realpath(
dol_osencode($_FILES[
'addedfile'][
'tmp_name']));
1591 $filesize = getimagesize($filetoread);
1592 if ($filesize[0] != $filesize[1]) {
1594 setEventMessages($langs->trans(
'ErrorFaviconMustBeASquaredImage'), array(),
'errors');
1596 if (! $error && ($filesize[0] != 16 && $filesize[0] != 32 && $filesize[0] != 64)) {
1605 if (!GETPOSTISSET(
'updateandstay')) {
1606 $action =
'preview';
1608 $backtopage = preg_replace(
'/searchstring=[^&]*/',
'', $backtopage);
1609 header(
"Location: ".$backtopage);
1613 $action =
'editcss';
1632 $dataposted = trim(
GETPOST(
'WEBSITE_HTML_HEADER',
'restricthtmlallowlinkscript'));
1634 $dataposted = preg_replace(array(
'/<html>\n*/ims',
'/<\/html>\n*/ims'), array(
'',
''), $dataposted);
1635 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1638 $phpfullcodestringold =
'';
1642 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1644 if (!$errorphpcheck) {
1645 $htmlheadercontent =
'';
1657 $htmlheadercontent .= $dataposted.
"\n";
1672 $dataposted = trim(
GETPOST(
'WEBSITE_CSS_INLINE',
'none'));
1673 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1676 $phpfullcodestringold =
'';
1680 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1682 if (!$errorphpcheck) {
1685 $csscontent .=
"<?php // BEGIN PHP\n";
1686 $csscontent .=
'$websitekey=basename(__DIR__);'.
"\n";
1687 $csscontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded\n";
1688 $csscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
1689 $csscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
1690 $csscontent .=
"ob_start();\n";
1691 $csscontent .=
"if (! headers_sent()) { /* because file is included inline when in edit mode and we don't want warning */ \n";
1692 $csscontent .=
"header('Cache-Control: max-age=3600, public, must-revalidate');\n";
1693 $csscontent .=
"header('Content-type: text/css');\n";
1694 $csscontent .=
"}\n";
1695 $csscontent .=
"// END PHP ?>\n";
1697 $csscontent .= $dataposted.
"\n";
1699 $csscontent .=
'<?php // BEGIN PHP'.
"\n";
1700 $csscontent .=
'$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "css");'.
"\n";
1701 $csscontent .=
"// END PHP\n";
1703 dol_syslog(
"Save css content into ".$filecss);
1715 $dataposted = trim(
GETPOST(
'WEBSITE_JS_INLINE',
'none'));
1716 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1719 $phpfullcodestringold =
'';
1723 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1725 if (!$errorphpcheck) {
1728 $jscontent .=
"<?php // BEGIN PHP\n";
1729 $jscontent .=
'$websitekey=basename(__DIR__);'.
"\n";
1730 $jscontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded\n";
1731 $jscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
1732 $jscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
1733 $jscontent .=
"ob_start();\n";
1734 $jscontent .=
"header('Cache-Control: max-age=3600, public, must-revalidate');\n";
1735 $jscontent .=
"header('Content-type: application/javascript');\n";
1736 $jscontent .=
"// END PHP ?>\n";
1738 $jscontent .= $dataposted.
"\n";
1740 $jscontent .=
'<?php // BEGIN PHP'.
"\n";
1741 $jscontent .=
'$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "js");'.
"\n";
1742 $jscontent .=
"// END PHP\n";
1753 $dataposted = trim(
GETPOST(
'WEBSITE_ROBOT',
'nohtml'));
1754 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1757 $phpfullcodestringold =
'';
1761 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1763 if (!$errorphpcheck) {
1776 $robotcontent .= $dataposted.
"\n";
1791 $dataposted = trim(
GETPOST(
'WEBSITE_HTACCESS',
'nohtml'));
1792 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1795 $phpfullcodestringold =
'';
1799 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1801 if (!$errorphpcheck) {
1803 $htaccesscontent =
'';
1804 $htaccesscontent .= $dataposted.
"\n";
1819 $dataposted = trim(
GETPOST(
'WEBSITE_MANIFEST_JSON',
'restricthtmlallowunvalid'));
1820 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1823 $phpfullcodestringold =
'';
1827 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1829 if (!$errorphpcheck) {
1830 $manifestjsoncontent =
'';
1832 $manifestjsoncontent .=
"<?php // BEGIN PHP\n";
1833 $manifestjsoncontent .=
'$websitekey=basename(__DIR__);'.
"\n";
1834 $manifestjsoncontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded\n";
1835 $manifestjsoncontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
1836 $manifestjsoncontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
1837 $manifestjsoncontent .=
"ob_start();\n";
1838 $manifestjsoncontent .=
"header('Cache-Control: max-age=3600, public, must-revalidate');\n";
1839 $manifestjsoncontent .=
"header('Content-type: application/manifest+json');\n";
1840 $manifestjsoncontent .=
"// END PHP ?>\n";
1842 $manifestjsoncontent .= $dataposted.
"\n";
1844 $manifestjsoncontent .=
'<?php // BEGIN PHP'.
"\n";
1845 $manifestjsoncontent .=
'$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "manifest");'.
"\n";
1846 $manifestjsoncontent .=
"// END PHP\n";
1851 setEventMessages(
'Failed to write file '.$filemanifestjson,
null,
'errors');
1858 $dataposted = trim(
GETPOST(
'WEBSITE_README',
'nohtml'));
1859 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1862 $phpfullcodestringold =
'';
1866 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1868 if (!$errorphpcheck) {
1869 $readmecontent =
'';
1881 $readmecontent .= $dataposted.
"\n";
1897 $dataposted = trim(
GETPOST(
'WEBSITE_LICENSE',
'nohtml'));
1898 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1901 $phpfullcodestringold =
'';
1905 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1907 if (!$errorphpcheck) {
1908 $licensecontent =
'';
1920 $licensecontent .= $dataposted.
"\n";
1944 if (!GETPOSTISSET(
'updateandstay')) {
1945 $action =
'preview';
1947 $backtopage = preg_replace(
'/searchstring=[^&]*/',
'', $backtopage);
1948 header(
"Location: ".$backtopage);
1952 $action =
'editcss';
1959if ($action ==
"updatesecurity" && $usercanedit &&
GETPOST(
"btn_WEBSITE_SECURITY_FORCECSP")) {
1960 $directivecsp =
GETPOST(
"select_identifier_WEBSITE_SECURITY_FORCECSP");
1961 $sourcecsp =
GETPOST(
"select_source_WEBSITE_SECURITY_FORCECSP");
1962 $sourcedatacsp =
GETPOST(
"input_data_WEBSITE_SECURITY_FORCECSP");
1967 if (empty($directivecsp)) {
1970 if ($error || (!isset($sourcecsp) && $directivesarray[$directivecsp][
"data-directivetype"] !=
"none")) {
1974 $directivetype = $directivesarray[$directivecsp][
"data-directivetype"];
1975 if (isset($sourcecsp)) {
1976 $sourcetype = $sourcesarray[$directivetype][$sourcecsp][
"data-sourcetype"];
1978 $securityspstring =
"";
1979 if (isset($sourcetype) && $sourcetype ==
"data") {
1980 $forceCSPArr[$directivecsp][] =
"data:".$sourcedatacsp;
1981 } elseif (isset($sourcetype) && $sourcetype ==
"input") {
1982 if (empty($forceCSPArr[$directivecsp])) {
1983 $forceCSPArr[$directivecsp] = array();
1985 $forceCSPArr[$directivecsp] = array_merge(explode(
" ", $sourcedatacsp), $forceCSPArr[$directivecsp]);
1987 if (empty($forceCSPArr[$directivecsp])) {
1988 $forceCSPArr[$directivecsp] = array();
1990 if (!isset($sourcecsp)) {
1993 array_unshift($forceCSPArr[$directivecsp], $sourcecsp);
1995 foreach ($forceCSPArr as $directive => $sourcekeys) {
1996 if ($securityspstring !=
"") {
1997 $securityspstring .=
"; ";
2000 foreach ($sourcekeys as $key => $source) {
2001 $directivetype = $directivesarray[$directive][
"data-directivetype"];
2002 $sourcetype = $sourcesarray[$directivetype][$source][
"data-sourcetype"];
2003 if (isset($sourcetype) && $sourcetype ==
"quoted") {
2004 $sourcestring .=
" '".$source.
"'";
2005 } elseif ($directivetype !=
"none") {
2006 $sourcestring .=
" ".$source;
2009 $securityspstring .= $directive . $sourcestring;
2019 setEventMessages($langs->trans(
"SecurityPolicySucesfullyAdded"),
null,
'mesgs');
2022 setEventMessages($langs->trans(
"ErrorAddingSecurityPolicy"),
null,
'errors');
2024 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?websiteid='.$websiteid.
"&action=editsecurity");
2028if ($action ==
"updatesecurity" && $usercanedit) {
2030 $res1 = $res2 = $res3 = $res4 = 0;
2031 $securityrp =
GETPOST(
'WEBSITE_'.
$object->id.
'_SECURITY_FORCERP',
'alpha');
2032 $securitysts =
GETPOST(
'WEBSITE_'.
$object->id.
'_SECURITY_FORCESTS',
'alpha');
2033 $securitypp =
GETPOST(
'WEBSITE_'.
$object->id.
'_SECURITY_FORCEPP',
'alpha');
2034 $securitysp =
GETPOST(
'WEBSITE_'.
$object->id.
'_SECURITY_FORCECSP',
'alpha');
2035 $securitycspro =
GETPOST(
'WEBSITE_'.
$object->id.
'_SECURITY_FORCECSPRO',
'alpha');
2043 if ($res1 >= 0 && $res2 >= 0 && $res3 >= 0 && $res4 >= 0 && $res5 >= 0) {
2051 if (!GETPOSTISSET(
'updateandstay')) {
2052 $action =
'preview';
2054 $backtopage = preg_replace(
'/searchstring=[^&]*/',
'', $backtopage);
2055 header(
"Location: ".$backtopage);
2059 $action =
'editsecurity';
2065if ($action ==
'setashome' && $usercanedit) {
2067 $object->fetch(0, $websitekey);
2070 $object->fk_default_home = $pageid;
2071 $res =
$object->update($user);
2080 $filetpl = $pathofwebsite.
'/page'.$pageid.
'.tpl.php';
2083 $result =
dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper, $object);
2091 $action =
'preview';
2098if ($action ==
'updatemeta' && $usercanedit) {
2101 $result =
$object->fetch(0, $websitekey);
2104 $objectpage->fk_website =
$object->id;
2107 if (!preg_match(
'/^[a-z0-9\-\_]+$/i',
GETPOST(
'WEBSITE_PAGENAME',
'alpha'))) {
2109 $langs->load(
"errors");
2110 setEventMessages($langs->transnoentities(
"ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities(
'WEBSITE_PAGENAME')),
null,
'errors');
2111 $action =
'editmeta';
2114 $res = $objectpage->fetch($pageid, (
string)
$object->id);
2117 setEventMessages(
'Page not found '.$objectpage->error, $objectpage->errors,
'errors');
2121 if (!$error &&
GETPOST(
'WEBSITE_PAGENAME',
'alpha')) {
2122 $websitepagetemp =
new WebsitePage(
$db);
2123 $result = $websitepagetemp->fetch(-1 * $objectpage->id, (
string)
$object->id,
GETPOST(
'WEBSITE_PAGENAME',
'alpha'));
2126 $langs->load(
"errors");
2127 setEventMessages($websitepagetemp->error, $websitepagetemp->errors,
'errors');
2128 $action =
'editmeta';
2132 $langs->load(
"errors");
2133 setEventMessages($langs->trans(
"ErrorAPageWithThisNameOrAliasAlreadyExists", $websitepagetemp->pageurl),
null,
'errors');
2134 $action =
'editmeta';
2138 $newaliasnames =
'';
2139 if (!$error &&
GETPOST(
'WEBSITE_ALIASALT',
'alpha')) {
2140 $arrayofaliastotest = explode(
',', str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_ALIASALT',
'alpha')));
2142 $websitepagetemp =
new WebsitePage(
$db);
2143 foreach ($arrayofaliastotest as $aliastotest) {
2144 $aliastotest = trim(preg_replace(
'/\.php$/i',
'', $aliastotest));
2147 if (preg_match(
'/^page\d+/i', $aliastotest)) {
2149 $langs->load(
"errors");
2151 $action =
'editmeta';
2154 $result = $websitepagetemp->fetch(-1 * $objectpage->id, (
string)
$object->id, $aliastotest);
2157 $langs->load(
"errors");
2158 setEventMessages($websitepagetemp->error, $websitepagetemp->errors,
'errors');
2159 $action =
'editmeta';
2164 $langs->load(
"errors");
2165 setEventMessages($langs->trans(
"ErrorAPageWithThisNameOrAliasAlreadyExists", $websitepagetemp->pageurl),
null,
'errors');
2166 $action =
'editmeta';
2169 $newaliasnames .= ($newaliasnames ?
', ' :
'').$aliastotest;
2175 $objectpage->old_object = clone $objectpage;
2177 $objectpage->title = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_TITLE',
'alphanohtml'));
2178 $objectpage->type_container =
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'aZ09');
2180 $objectpage->aliasalt = $newaliasnames;
2181 $objectpage->lang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
2182 $objectpage->otherlang =
GETPOST(
'WEBSITE_OTHERLANG',
'aZ09comma');
2183 $objectpage->description = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml'));
2184 $objectpage->image =
GETPOST(
'WEBSITE_IMAGE',
'alpha');
2185 $objectpage->keywords = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_KEYWORDS',
'alphanohtml'));
2186 $objectpage->allowed_in_frames =
GETPOST(
'WEBSITE_ALLOWED_IN_FRAMES',
'aZ09') ? 1 : 0;
2187 $objectpage->htmlheader = trim(
GETPOST(
'htmlheader',
'restricthtmlallowlinkscript'));
2188 $objectpage->fk_page = (
GETPOSTINT(
'pageidfortranslation') > 0 ?
GETPOSTINT(
'pageidfortranslation') : 0);
2189 $objectpage->author_alias = trim(
GETPOST(
'WEBSITE_AUTHORALIAS',
'alphanohtml'));
2190 $objectpage->object_type =
GETPOST(
'WEBSITE_OBJECTCLASS',
'alpha');
2191 $objectpage->fk_object =
GETPOST(
'WEBSITE_OBJECTID',
'aZ09');
2194 if ($newdatecreation) {
2195 $objectpage->date_creation = $newdatecreation;
2198 $res = $objectpage->update($user);
2200 $langs->load(
"errors");
2201 if (
$db->lasterrno ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
2203 setEventMessages($langs->trans(
"ErrorAPageWithThisNameOrAliasAlreadyExists"),
null,
'errors');
2204 $action =
'editmeta';
2208 $action =
'editmeta';
2215 $categoriesarray =
GETPOST(
'categories',
'array:int');
2216 $result = $objectpage->setCategories($categoriesarray);
2230 $filemaster = $pathofwebsite.
'/master.inc.php';
2231 $fileoldalias = $pathofwebsite.
'/'.$objectpage->old_object->pageurl.
'.php';
2232 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
2243 if (!empty($fileoldalias)) {
2244 dol_syslog(
"We delete old alias page name=".$fileoldalias.
" to build a new alias page=".$filealias);
2248 if (empty($objectpage->lang) || !in_array($objectpage->lang, explode(
',',
$object->otherlang))) {
2249 $dirname = dirname($fileoldalias);
2250 $filename = basename($fileoldalias);
2251 $sublangs = explode(
',',
$object->otherlang);
2252 foreach ($sublangs as $sublang) {
2256 if (empty(trim($sublang))) {
2259 $fileoldaliassub = $dirname.
'/'.$sublang.
'/'.$filename;
2265 if (!empty($objectpage->old_object->aliasalt)) {
2266 $tmpaltaliases = explode(
',', $objectpage->old_object->aliasalt);
2267 if (is_array($tmpaltaliases)) {
2268 foreach ($tmpaltaliases as $tmpaliasalt) {
2269 dol_syslog(
"We delete old alt alias pages name=".trim($tmpaliasalt));
2273 if (empty($objectpage->lang) || !in_array($objectpage->lang, explode(
',',
$object->otherlang))) {
2274 $dirname = dirname($pathofwebsite.
'/'.trim($tmpaliasalt).
'.php');
2275 $filename = basename($pathofwebsite.
'/'.trim($tmpaliasalt).
'.php');
2276 $sublangs = explode(
',',
$object->otherlang);
2277 foreach ($sublangs as $sublang) {
2281 if (empty(trim($sublang))) {
2284 $fileoldaliassub = $dirname.
'/'.$sublang.
'/'.$filename;
2298 if (!empty($objectpage->aliasalt)) {
2299 $tmpaltaliases = explode(
',', $objectpage->aliasalt);
2300 if (is_array($tmpaltaliases)) {
2301 foreach ($tmpaltaliases as $tmpaliasalt) {
2302 if (trim($tmpaliasalt)) {
2303 $filealias = $pathofwebsite.
'/'.trim($tmpaliasalt).
'.php';
2306 setEventMessages(
'Failed to write file '.basename($filealias),
null,
'errors');
2319 if (!GETPOSTISSET(
'updateandstay')) {
2322 $action =
'preview';
2324 $action =
'editmeta';
2330 $action =
'preview';
2336if ((($action ==
'updatesource' || $action ==
'updatecontent' || $action ==
'confirm_createfromclone' || $action ==
'confirm_createpagefromclone') || ($action ==
'preview' && (
GETPOST(
'refreshsite') ||
GETPOST(
'refreshpage') ||
GETPOST(
'preview')))) && $usercanedit) {
2337 $object->fetch(0, $websitekey);
2340 if ($action ==
'confirm_createfromclone') {
2349 $action =
'preview';
2356 $pageid =
$object->fk_default_home;
2357 $websitekey =
GETPOST(
'siteref',
'aZ09');
2363 if ($action ==
'confirm_createpagefromclone') {
2364 $istranslation = (
GETPOST(
'is_a_translation',
'aZ09') ==
'on' ? 1 : 0);
2366 if ($istranslation) {
2367 if (
GETPOST(
'newlang',
'aZ09') == $objectpage->lang || !
GETPOST(
'newlang',
'aZ09')) {
2369 setEventMessages($langs->trans(
"LanguageMustNotBeSameThanClonedPage"),
null,
'errors');
2370 $action =
'preview';
2374 setEventMessages($langs->trans(
"WebsiteMustBeSameThanClonedPageIfTranslation"),
null,
'errors');
2375 $action =
'preview';
2383 $pathofwebsitenew = $pathofwebsite;
2386 if ($newwebsiteid > 0 && $newwebsiteid !=
$object->id) {
2387 $tmpwebsite->fetch($newwebsiteid);
2388 $pathofwebsitenew = $dolibarr_main_data_root.($conf->entity > 1 ?
'/'.$conf->entity :
'').
'/website/'.$tmpwebsite->ref;
2393 $objectpage =
new WebsitePage(
$db);
2394 $resultpage = $objectpage->createFromClone($user, $pageid,
GETPOST(
'newpageurl',
'aZ09'), (
GETPOST(
'newlang',
'aZ09') ?
GETPOST(
'newlang',
'aZ09') :
''), $istranslation, $newwebsiteid,
GETPOST(
'newtitle',
'alphanohtml'), $tmpwebsite);
2395 if ($resultpage < 0) {
2398 $action =
'createpagefromclone';
2402 $filetpl = $pathofwebsitenew.
'/page'.$resultpage->id.
'.tpl.php';
2403 $fileindex = $pathofwebsitenew.
'/index.php';
2404 $filewrapper = $pathofwebsitenew.
'/wrapper.php';
2413 if (empty($newwebsiteid) || $newwebsiteid ==
$object->id) {
2414 $pageid = $resultpage->id;
2427 $pathtomedias = DOL_DATA_ROOT.
'/medias';
2428 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
2430 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
2431 dol_mkdir(dirname($pathtomediasinwebsite));
2432 $result = symlink($pathtomedias, $pathtomediasinwebsite);
2434 $langs->load(
"errors");
2435 setEventMessages($langs->trans(
"ErrorFailedToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias),
null,
'errors');
2445 $objectpage->fk_website =
$object->id;
2448 $res = $objectpage->fetch($pageid);
2451 if (
$object->fk_default_home > 0) {
2452 $res = $objectpage->fetch(
$object->fk_default_home);
2455 $res = $objectpage->fetch(0, (
string)
$object->id);
2460 if (!$error && $res > 0) {
2461 if ($action ==
'updatesource' || $action ==
'updatecontent') {
2466 $objectpage->content =
GETPOST(
'PAGE_CONTENT',
'none');
2471 $error =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
2474 if ($action ==
'updatesource') {
2475 $action =
'editsource';
2477 if ($action ==
'updatecontent') {
2478 $action =
'editcontent';
2483 $objectpage->content = preg_replace(
'/<head>.*<\/head>/ims',
'', $objectpage->content);
2487 $res = $objectpage->update($user);
2491 if ($action ==
'updatesource') {
2492 $action =
'editsource';
2494 if ($action ==
'updatecontent') {
2495 $action =
'editcontent';
2502 $filemaster = $pathofwebsite.
'/master.inc.php';
2504 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
2512 setEventMessages(
'Failed to write the master file file '.$filemaster,
null,
'errors');
2536 setEventMessages(
'Failed to write the alias file '.basename($filealias),
null,
'errors');
2544 if (!GETPOSTISSET(
'updateandstay')) {
2546 header(
"Location: ".$backtopage);
2549 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$websitekey.
'&pageid='.$pageid);
2553 if ($action ==
'updatesource') {
2554 $action =
'editsource';
2556 if ($action ==
'updatecontent') {
2557 $action =
'editcontent';
2562 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$websitekey.
'&pageid='.$pageid);
2569 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$websitekey.
'&pageid='.$pageid);
2574 if (empty($websitekey) || $websitekey ==
'-1') {
2575 setEventMessages($langs->trans(
"NoWebSiteCreateOneFirst"),
null,
'warnings');
2578 setEventMessages($langs->trans(
"YouCanCreatePageOrImportTemplate"),
null,
'warnings');
2584if ($action ==
'deletelang' && $usercanedit) {
2585 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"website_page SET fk_page = NULL";
2586 $sql .=
" WHERE rowid = ".GETPOSTINT(
'deletelangforid');
2589 $resql =
$db->query($sql);
2593 $objectpage->fk_page =
null;
2596 $action =
'editmeta';
2601if ($action ==
'exportsite' && $user->hasRight(
'website',
'export')) {
2602 $fileofzip =
$object->exportWebSite();
2605 $file_name = basename($fileofzip);
2606 header(
"Content-Type: application/zip");
2607 header(
"Content-Disposition: attachment; filename=".$file_name);
2608 header(
"Content-Length: ".filesize($fileofzip));
2610 readfile($fileofzip);
2614 $action =
'preview';
2619if ($action ==
'overwritesite' && $user->hasRight(
'website',
'export')) {
2622 $fileofzip =
$object->exportWebSite();
2623 $pathToExport =
GETPOST(
'export_path');
2626 $result =
$object->overwriteTemplate($fileofzip, $pathToExport);
2628 $action =
'preview';
2632 $action =
'preview';
2637if ($action ==
'regeneratesite' && $usercanedit) {
2640 $pathtomedias = DOL_DATA_ROOT.
'/medias';
2641 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
2643 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
2644 dol_mkdir(dirname($pathtomediasinwebsite));
2645 $result = symlink($pathtomedias, $pathtomediasinwebsite);
2647 $langs->load(
"errors");
2648 setEventMessages($langs->trans(
"ErrorFailedToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias),
null,
'errors');
2649 $action =
'preview';
2653 $result =
$object->rebuildWebSiteFiles();
2655 setEventMessages($langs->trans(
"PagesRegenerated", $result),
null,
'mesgs');
2656 $action =
'preview';
2659 $action =
'preview';
2664if ($action ==
'importsiteconfirm' && $usercanedit) {
2665 $dolibarrdataroot = preg_replace(
'/([\\/]+)$/i',
'', DOL_DATA_ROOT);
2666 $allowimportsite =
true;
2667 if (
dol_is_file($dolibarrdataroot.
'/installmodules.lock')) {
2668 $allowimportsite =
false;
2671 if ($allowimportsite) {
2672 if (empty($_FILES) && !GETPOSTISSET(
'templateuserfile')) {
2673 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"File")),
null,
'errors');
2674 $action =
'importsite';
2676 if (!empty($_FILES) || GETPOSTISSET(
'templateuserfile')) {
2679 $pathtomedias = DOL_DATA_ROOT.
'/medias';
2680 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
2682 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
2683 dol_mkdir(dirname($pathtomediasinwebsite));
2684 $result = symlink($pathtomedias, $pathtomediasinwebsite);
2686 $langs->load(
"errors");
2687 setEventMessages($langs->trans(
"ErrorFailedToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias),
null,
'errors');
2688 $action =
'importsite';
2693 if (GETPOSTISSET(
'templateuserfile')) {
2695 $fileofzip = DOL_DATA_ROOT.
'/doctemplates/websites/'.
GETPOST(
'templateuserfile',
'alpha');
2696 } elseif (!empty($_FILES) && is_array($_FILES[
'userfile'])) {
2698 if (is_array($_FILES[
'userfile'][
'tmp_name'])) {
2699 $userfiles = $_FILES[
'userfile'][
'tmp_name'];
2701 $userfiles = array($_FILES[
'userfile'][
'tmp_name']);
2705 foreach ($userfiles as $key => $userfile) {
2706 if (empty($_FILES[
'userfile'][
'tmp_name'][$key])) {
2708 if ($_FILES[
'userfile'][
'error'][$key] == 1 || $_FILES[
'userfile'][
'error'][$key] == 2) {
2710 $action =
'importsite';
2712 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"File")),
null,
'errors');
2713 $action =
'importsite';
2720 $upload_dir = DOL_DATA_ROOT.
'/doctemplates/websites/';
2734 $action =
'importsite';
2737 if (!$error && GETPOSTISSET(
'templateuserfile')) {
2738 $templatewithoutzip = preg_replace(
'/\.zip$/i',
'',
GETPOST(
'templateuserfile'));
2739 $object->setTemplateName($templatewithoutzip);
2741 $result =
$object->importWebSite($fileofzip);
2745 $action =
'importsite';
2750 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.
$object->ref);
2759 $message = $langs->trans(
'InstallModuleFromWebHasBeenDisabledContactUs');
2762 $message = $langs->trans(
"InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.
'/installmodules.lock');
2768$domainname =
'0.0.0.0:8080';
2769$tempdir =
$conf->website->dir_output.
'/'.$websitekey.
'/';
2772if ($action ==
'generatesitemaps' && $usercanedit) {
2774 if ($website->virtualhost) {
2775 $domainname = $website->virtualhost;
2777 if (! preg_match(
'/^http/i', $domainname)) {
2778 $domainname =
'https://'.$domainname;
2781 $domtree =
new DOMDocument(
'1.0',
'UTF-8');
2783 $root = $domtree->createElementNS(
'http://www.sitemaps.org/schemas/sitemap/0.9',
'urlset');
2784 $root->setAttributeNS(
'http://www.w3.org/2000/xmlns/',
'xmlns:xhtml',
'http://www.w3.org/1999/xhtml');
2786 $domtree->formatOutput =
true;
2789 $xmlname =
'sitemap.xml';
2791 $sql =
"SELECT wp.rowid, wp.type_container , wp.pageurl, wp.lang, wp.fk_page, wp.tms as tms,";
2792 $sql .=
" w.virtualhost, w.fk_default_home";
2793 $sql .=
" FROM ".MAIN_DB_PREFIX.
"website_page as wp, ".MAIN_DB_PREFIX.
"website as w";
2794 $sql .=
" WHERE wp.type_container IN ('page', 'blogpost')";
2795 $sql .=
" AND wp.fk_website = w.rowid";
2796 $sql .=
" AND wp.status = ".WebsitePage::STATUS_VALIDATED;
2797 $sql .=
" AND wp.pageurl NOT IN ('404', '500', '501', '503')";
2798 $sql .=
" AND w.ref = '".dol_escape_json($websitekey).
"'";
2799 $sql .=
" ORDER BY wp.tms DESC, wp.rowid DESC";
2800 $resql =
$db->query($sql);
2802 $num_rows =
$db->num_rows($resql);
2803 if ($num_rows > 0) {
2805 while ($i < $num_rows) {
2806 $objp =
$db->fetch_object($resql);
2807 $url = $domtree->createElement(
'url');
2809 $shortlangcode =
'';
2811 $shortlangcode = substr($objp->lang, 0, 2);
2813 if (empty($shortlangcode)) {
2814 $shortlangcode = substr(
$object->lang, 0, 2);
2818 if ($objp->type_container ==
'blogpost') {
2823 $pageurl = $objp->pageurl.
'.php';
2824 if ($objp->fk_default_home == $objp->rowid) {
2827 if ($shortlangcode != substr(
$object->lang, 0, 2)) {
2828 $pageurl = $shortlangcode.
'/'.$pageurl;
2835 $loc = $domtree->createElement(
'loc', $domainname.
'/'.$pageurl);
2836 $lastmod = $domtree->createElement(
'lastmod',
dol_print_date(
$db->jdate($objp->tms),
'dayrfc',
'gmt'));
2837 $priority = $domtree->createElement(
'priority',
'1');
2839 $url->appendChild($loc);
2840 $url->appendChild($lastmod);
2843 $changefreq = $domtree->createElement(
'changefreq',
'weekly');
2844 $url->appendChild($changefreq);
2847 if ($objp->fk_default_home == $objp->rowid) {
2848 $url->appendChild($priority);
2853 $alternatefound = 0;
2856 $translationof = $objp->fk_page;
2857 if ($translationof) {
2858 $tmppage =
new WebsitePage(
$db);
2859 $tmppage->fetch($translationof);
2860 if ($tmppage->id > 0) {
2861 $tmpshortlangcode =
'';
2862 if ($tmppage->lang) {
2863 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'', $tmppage->lang);
2865 if (empty($tmpshortlangcode)) {
2866 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'',
$object->lang);
2868 if ($tmpshortlangcode != $shortlangcode) {
2869 $xhtmllink = $domtree->createElement(
'xhtml:link',
'');
2870 $xhtmllink->setAttribute(
"rel",
"alternate");
2871 $xhtmllink->setAttribute(
"hreflang", $tmpshortlangcode);
2872 $xhtmllink->setAttribute(
"href", $domainname.($objp->fk_default_home == $tmppage->id ?
'/' : (($tmpshortlangcode != substr(
$object->lang, 0, 2)) ?
'/'.$tmpshortlangcode :
'').
'/'.$tmppage->pageurl.
'.php'));
2873 $url->appendChild($xhtmllink);
2881 $sql =
'SELECT rowid as id, lang, pageurl from '.MAIN_DB_PREFIX.
'website_page';
2882 $sql .=
" WHERE status = ".((int) WebsitePage::STATUS_VALIDATED).
' AND fk_page IN ('.
$db->sanitize($objp->rowid.($translationof ?
", ".$translationof :
"")).
")";
2883 $resqlhastrans =
$db->query($sql);
2884 if ($resqlhastrans) {
2885 $num_rows_hastrans =
$db->num_rows($resqlhastrans);
2886 if ($num_rows_hastrans > 0) {
2887 while ($objhastrans =
$db->fetch_object($resqlhastrans)) {
2888 $tmpshortlangcode =
'';
2889 if ($objhastrans->lang) {
2890 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'', $objhastrans->lang);
2892 if ($tmpshortlangcode != $shortlangcode) {
2893 $xhtmllink = $domtree->createElement(
'xhtml:link',
'');
2894 $xhtmllink->setAttribute(
"rel",
"alternate");
2895 $xhtmllink->setAttribute(
"hreflang", $tmpshortlangcode);
2896 $xhtmllink->setAttribute(
"href", $domainname.($objp->fk_default_home == $objhastrans->id ?
'/' : (($tmpshortlangcode != substr(
$object->lang, 0, 2) ?
'/'.$tmpshortlangcode :
'')).
'/'.$objhastrans->pageurl.
'.php'));
2897 $url->appendChild($xhtmllink);
2907 if ($alternatefound) {
2909 $xhtmllink = $domtree->createElement(
'xhtml:link',
'');
2910 $xhtmllink->setAttribute(
"rel",
"alternate");
2911 $xhtmllink->setAttribute(
"hreflang", $shortlangcode);
2912 $xhtmllink->setAttribute(
"href", $domainname.
'/'.$pageurl);
2913 $url->appendChild($xhtmllink);
2929 $root->appendChild($url);
2935 if ($addrsswrapper &&
getDolGlobalInt(
'WEBSITE_ADD_RSS_FEED_INTO_SITEMAP')) {
2936 $url = $domtree->createElement(
'url');
2938 $pageurl =
'wrapper.php?rss=1';
2941 $loc = $domtree->createElement(
'loc', $domainname.
'/'.$pageurl);
2944 $url->appendChild($loc);
2945 $url->appendChild($lastmod);
2948 $changefreq = $domtree->createElement(
'changefreq',
'weekly');
2949 $url->appendChild($changefreq);
2952 $root->appendChild($url);
2955 $domtree->appendChild($root);
2957 if ($domtree->save($tempdir.$xmlname)) {
2959 setEventMessages($langs->trans(
"SitemapGenerated", $xmlname),
null,
'mesgs');
2969 $robotcontent = @file_get_contents($filerobot);
2970 $result = preg_replace(
'/<?php \/\/ BEGIN PHP[^?]END PHP ?>\n/ims',
'', $robotcontent);
2972 $robotcontent = $result;
2974 $robotsitemap =
"Sitemap: ".$domainname.
"/".$xmlname;
2975 $result = strpos($robotcontent,
'Sitemap: ');
2977 $result = preg_replace(
'/Sitemap:.*/', $robotsitemap, $robotcontent);
2978 $robotcontent = $result ? $result : $robotcontent;
2980 $robotcontent .= $robotsitemap.
"\n";
2987 $action =
'preview';
2990if ($action ==
'removecspsource' && $usercanedit) {
2993 $sourcecsp = explode(
"_",
GETPOST(
"sourcecsp"));
2994 $directive = $sourcecsp[0];
2995 $sourcekey = isset($sourcecsp[1]) ? $sourcecsp[1] :
null;
2996 $sourcedata = isset($sourcecsp[2]) ? $sourcecsp[2] :
null;
3000 if (empty($directive)) {
3004 if (!empty($directivesarray[$directive])) {
3005 $directivetype = (
string) $directivesarray[$directive][
"data-directivetype"];
3006 if (isset($sourcekey)) {
3007 $sourcetype = $sourcesarray[$directivetype][$sourcekey][
"data-sourcetype"];
3011 $securityspstring =
"";
3012 if (!$error && !empty($forceCSPArr)) {
3013 if (isset($sourcekey) && !empty($forceCSPArr[$directive][$sourcekey])) {
3014 unset($forceCSPArr[$directive][$sourcekey]);
3016 if (count($forceCSPArr[$directive]) == 0) {
3017 unset($forceCSPArr[$directive]);
3019 foreach ($forceCSPArr as $directive => $sourcekeys) {
3020 if ($securityspstring !=
"") {
3021 $securityspstring .=
"; ";
3024 foreach ($sourcekeys as $key => $source) {
3025 $directivetype = $directivesarray[$directive][
"data-directivetype"];
3026 $sourcetype = $sourcesarray[$directivetype][$source][
"data-sourcetype"];
3027 if ($sourcetype ==
"quoted") {
3028 $sourcestring .=
" '".$source.
"'";
3030 $sourcestring .=
" ".$source;
3033 $securityspstring .= $directive . $sourcestring;
3043 setEventMessages($langs->trans(
"SecurityPolicySucesfullyRemoved"),
null,
'mesgs');
3046 setEventMessages($langs->trans(
"ErrorRemovingSecurityPolicy"),
null,
'errors');
3049 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?websiteid='.$websiteid.
"&action=editsecurity");
3065if ($action ==
'confirmgeneratesitemaps') {
3066 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?website='.urlencode($website->ref), $langs->trans(
'ConfirmSitemapsCreation'), $langs->trans(
'ConfirmGenerateSitemaps',
$object->ref),
'generatesitemaps',
'',
"yes", 1);
3067 $action =
'preview';
3069$helpurl =
'EN:Module_Website|FR:Module_Website_FR|ES:Módulo_Website';
3072 '/includes/ace/src/ace.js',
3073 '/includes/ace/src/ext-statusbar.js',
3074 '/includes/ace/src/ext-language_tools.js',
3077$arrayofcss = array();
3080 $arrayofjs[] =
"public/includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js";
3083llxHeader(
'', $langs->trans(
"Website").(empty($website->ref) ?
'' :
' - '.$website->
ref), $helpurl,
'', 0, 0, $arrayofjs, $arrayofcss,
'',
'mod-website page-index',
'<!-- Begin div class="fiche" -->'.
"\n".
'<div class="fichebutwithotherclass">');
3086print
'<!-- Open form common to all pages generated by website/index.php -->'.
"\n";
3087print
'<form action="'.$_SERVER[
"PHP_SELF"].($action ==
'file_manager' ?
'?uploadform=1' :
'').
'" method="POST" enctype="multipart/form-data" class="websiteformtoolbar">'.
"\n";
3088print
'<input type="hidden" name="token" value="'.newToken().
'">';
3089print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
3090print
'<input type="hidden" name="dol_openinpopup" value="'.$dol_openinpopup.
'">';
3092if ($action ==
'createsite') {
3093 print
'<input type="hidden" name="action" value="addsite">';
3095if ($action ==
'createcontainer') {
3096 print
'<input type="hidden" name="action" value="addcontainer">';
3098if ($action ==
'editcss') {
3099 print
'<input type="hidden" name="action" value="updatecss">';
3101if ($action ==
'editmenu') {
3102 print
'<input type="hidden" name="action" value="updatemenu">';
3104if ($action ==
'setashome') {
3105 print
'<input type="hidden" name="action" value="updateashome">';
3107if ($action ==
'editmeta') {
3108 print
'<input type="hidden" name="action" value="updatemeta">';
3110if ($action ==
'editsource') {
3111 print
'<input type="hidden" name="action" value="updatesource">';
3113if ($action ==
'editcontent') {
3114 print
'<input type="hidden" name="action" value="updatecontent">';
3116if ($action ==
'edit') {
3117 print
'<input type="hidden" name="action" value="update">';
3119if ($action ==
'importsite') {
3120 print
'<input type="hidden" name="action" value="importsiteconfirm">';
3122if ($action ==
'file_manager') {
3123 print
'<input type="hidden" name="action" value="file_manager">';
3126 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
3128if ($action ==
'editsecurity') {
3129 print
'<input type="hidden" name="action" value="updatesecurity">';
3136if ($action !=
'preview' && $action !=
'editcontent' && $action !=
'editsource' && !
GETPOST(
'createpagefromclone',
'alphanohtml')) {
3137 $style =
' margin-bottom: 5px;';
3142if (!
GETPOST(
'hide_websitemenu')) {
3143 if (!$user->hasRight(
'website',
'write')) {
3144 $disabled =
' disabled="disabled"';
3146 $disabledexport =
'';
3147 if (!$user->hasRight(
'website',
'export')) {
3148 $disabledexport =
' disabled="disabled"';
3153 $dataroot = DOL_DATA_ROOT.($conf->entity > 1 ?
'/'.$conf->entity :
'').
'/website/'.$websitekey;
3154 if (!empty(
$object->virtualhost)) {
3155 $virtualurl =
$object->virtualhost;
3161 $array = $objectpage->fetchAll(
$object->id,
'ASC,ASC',
'type_container,pageurl');
3164 if (!is_array($array) && $array < 0) {
3167 $atleastonepage = (is_array($array) && count($array) > 0);
3169 $websitepage =
new WebsitePage(
$db);
3171 $websitepage->fetch($pageid);
3177 if (!$user->hasRight(
'website',
'write')) {
3178 $disabled =
' disabled="disabled"';
3179 $morecss =
'opacitymedium cursordefault';
3183 print
'<div class="centpercent websitebar'.(GETPOST(
'dol_openinpopup',
'aZ09') ?
' hiddenforpopup' :
'').
'">'.
"\n";
3189 print
'<!-- Toolbar for website -->';
3190 if ($action !=
'file_manager') {
3191 print
'<div class="websiteselection hideonsmartphoneimp minwidth75 tdoverflowmax100 inline-block">';
3192 print $langs->trans(
"Website").
': ';
3196 $urltocreatenewwebsite = $_SERVER[
"PHP_SELF"].
'?action=createsite';
3197 if ($user->hasRight(
'website',
'write')) {
3198 print
'<span class="websiteselection paddingrightonly">';
3199 print
'<a href="'.$urltocreatenewwebsite.
'" class=""'.$disabled.
' title="'.
dol_escape_htmltag($langs->trans(
"AddWebsite")).
'"><span class="fa fa-plus-circle valignmiddle btnTitle-icon"><span></a>';
3204 print
'<span class="websiteselection nopaddingrightimp">';
3207 $out .=
'<select name="website" class="minwidth100 width200 maxwidth150onsmartphone" id="website">';
3208 if (empty($listofwebsites)) {
3209 $out .=
'<option value="-1"> </option>';
3214 foreach ($listofwebsites as $key => $valwebsite) {
3215 if (empty($websitekey)) {
3216 if ($action !=
'createsite') {
3217 $websitekey = $valwebsite->ref;
3221 $out .=
'<option value="'.$valwebsite->ref.
'"';
3222 if ($websitekey == $valwebsite->ref) {
3223 $out .=
' selected';
3226 $outoption = (($valwebsite->status == $valwebsite::STATUS_DRAFT) ?
'<span class="opacitymedium">' :
'').$valwebsite->
ref.(($valwebsite->
status == $valwebsite::STATUS_DRAFT) ?
'</span>' :
'');
3227 $out .=
' data-html="'.dol_escape_htmltag($outoption).
'"';
3229 $out .= $valwebsite->ref;
3230 $out .=
'</option>';
3233 $out .=
'</select>';
3236 if (!empty(
$conf->use_javascript_ajax)) {
3237 $out .=
'<script type="text/javascript">';
3238 $out .=
'jQuery(document).ready(function () {';
3239 $out .=
' jQuery("#website").change(function () {';
3240 $out .=
' console.log("We select "+jQuery("#website option:selected").val());';
3241 $out .=
' if (jQuery("#website option:selected").val() == \'-2\') {';
3242 $out .=
' window.location.href = "'.dol_escape_js($urltocreatenewwebsite).
'";';
3243 $out .=
' } else {';
3244 $out .=
' window.location.href = "'.$_SERVER[
"PHP_SELF"].
'?website="+jQuery("#website option:selected").val();';
3248 $out .=
'</script>';
3255 if (!empty(
$conf->use_javascript_ajax)) {
3256 print
'<span class="websiteselection">';
3261 if ($website->status == $website::STATUS_DRAFT) {
3262 $text_off =
'Offline';
3263 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setwebsiteonline&token='.newToken().
'&website='.urlencode($website->ref).
'&websitepage='.((int) $websitepage->id).
'"'.$disabled.
'>'.
img_picto($langs->trans($text_off),
'switch_off',
'', 0, 0, 0,
'', $morecss).
'</a>';
3265 $text_off =
'Online';
3266 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setwebsiteoffline&token='.newToken().
'&website='.urlencode($website->ref).
'&websitepage='.((int) $websitepage->id).
'"'.$disabled.
'>'.
img_picto($langs->trans($text_off),
'switch_on',
'', 0, 0, 0,
'', $morecss).
'</a>';
3272 if (empty(
$conf->use_javascript_ajax)) {
3273 print
'<span class="websiteselection">';
3274 print
'<input type="image" class="valignmiddle" src="'.img_picto(
'',
'refresh',
'', 0, 1).
'" name="refreshsite" value="'.$langs->trans(
"Load").
'"'.$disabled.
'>';
3279 print
'<span class="websiteselection">';
3281 if ($websitekey && $websitekey !=
'-1' && ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite')) {
3283 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
$object->ref).
'&pageid='.((int) $pageid).
'&action=editcss&token='.newToken().
'" class="button bordertransp valignmiddle" title="'.
dol_escape_htmltag($langs->trans(
"EditCss")).
'"'.$disabled.
'>';
3285 print
'<span class="hideonsmartphone paddingleft">'.dol_escape_htmltag($langs->trans(
"EditCss")).
'</span>';
3289 $importlabel = $langs->trans(
"ImportSite");
3290 $exportlabel = $langs->trans(
"ExportSite");
3291 if (!empty(
$conf->dol_optimize_smallscreen)) {
3292 $importlabel = $langs->trans(
"Import");
3293 $exportlabel = $langs->trans(
"Export");
3296 if ($atleastonepage) {
3297 print
'<input type="submit" class="button bordertransp" disabled="disabled" value="'.dol_escape_htmltag($importlabel).
'" name="importsite">';
3299 print
'<input type="submit" class="button bordertransp"'.$disabled.
' value="'.
dol_escape_htmltag($importlabel).
'" name="importsite">';
3303 $extraCssClass =
getDolGlobalString(
'WEBSITE_ALLOW_OVERWRITE_GIT_SOURCE') ?
'hideobject' :
'';
3304 print
'<input type="submit" class="button bordertransp ' . $extraCssClass .
'" ' . $disabledexport .
' value="' .
dol_escape_htmltag($exportlabel) .
'" name="exportsite">';
3308 $overwriteGitUrl = $_SERVER[
"PHP_SELF"] .
'?action=overwritesite&website=' . urlencode($website->ref);
3309 print
dolButtonToOpenExportDialog(
'exportpopup', $langs->trans(
'ExportOptions'), $langs->trans(
'ExportSite'),
'exportsite', $overwriteGitUrl, $website);
3314 print
'<input type="submit" class="button bordertransp"'.$disabled.
' value="'.
dol_escape_htmltag($langs->trans(
"CloneSite")).
'" name="createfromclone">';
3317 if (!$permissiontodelete) {
3318 $disabled =
' disabled="disabled"';
3319 $title = $langs->trans(
"NotEnoughPermissions");
3322 if ($website->status == $website::STATUS_VALIDATED) {
3323 $disabled =
' disabled="disabled"';
3324 $title = $langs->trans(
"WebsiteMustBeDisabled", $langs->transnoentitiesnoconv($website->LibStatut(0, 0)));
3328 $title = $langs->trans(
"Delete");
3329 $url = $_SERVER[
"PHP_SELF"].
'?action=deletesite&token='.newToken().
'&website='.urlencode($website->ref);
3332 print
'<a href="'.$url.
'" class="button buttonDelete bordertransp'.($disabled ?
' disabled' :
'').
'"'.$disabled.
' title="'.
dol_escape_htmltag($title).
'">'.
img_picto(
'',
'delete',
'class=""').
'<span class="hideonsmartphone paddingleft">'.$langs->trans(
"Delete").
'</span></a>';
3335 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=regeneratesite&token='.newToken().
'&website='.urlencode($website->ref).
'" class="button bordertransp"'.$disabled.
' title="'.
dol_escape_htmltag($langs->trans(
"RegenerateWebsiteContent")).
'"><span class="far fa-hdd"></span></a>';
3338 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=confirmgeneratesitemaps&token='.newToken().
'&website='.urlencode($website->ref).
'" class="button bordertransp"'.$disabled.
' title="'.
dol_escape_htmltag($langs->trans(
"GenerateSitemaps")).
'"><span class="fa fa-sitemap"></span></a>';
3341 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=replacesite&token='.newToken().
'&website='.urlencode($website->ref).
'" class="button bordertransp"'.$disabled.
' title="'.
dol_escape_htmltag($langs->trans(
"ReplaceWebsiteContent")).
'"><span class="fa fa-search"></span></a>';
3346 if ($websitekey && $websitekey !=
'-1' && ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite')) {
3347 print
'<span class="websiteselection">';
3349 print
dolButtonToOpenUrlInDialogPopup(
'file_manager', $langs->transnoentitiesnoconv(
"MediaFiles"),
'<span class="fa fa-image"></span>',
'/website/index.php?action=file_manager&website='.urlencode($website->ref).
'§ion_dir='.urlencode(
'image/'.$website->ref.
'/'), $disabled);
3353 print
dolButtonToOpenUrlInDialogPopup(
'categories', $langs->transnoentitiesnoconv(
"Categories"),
'<span class="fa fa-tags"></span>',
'/categories/categorie_list.php?leftmenu=website&nosearch=1&type='.urlencode(Categorie::TYPE_WEBSITE_PAGE).
'&website='.urlencode($website->ref), $disabled);
3359 print
'<input type="hidden" name="website" id="website" value="'.$websitekey.
'">';
3363 print
'<span class="websitetools">';
3365 if ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite') {
3366 $urlext = $virtualurl;
3367 $urlint = $urlwithroot.
'/public/website/index.php?website='.$websitekey;
3369 print
'<span class="websiteinputurl valignmiddle" id="websiteinputurl">';
3370 $linktotestonwebserver =
'<a href="'.($virtualurl ? $virtualurl :
'#').
'" class="valignmiddle">';
3371 $linktotestonwebserver .=
'<span class="hideonsmartphone paddingrightonly">'.$langs->trans(
"TestDeployOnWeb", $virtualurl).
'</span>'.
img_picto(
'',
'globe');
3372 $linktotestonwebserver .=
'</a>';
3375 if (empty(
$object->fk_default_home)) {
3376 $htmltext .=
'<br><span class="error">'.$langs->trans(
"YouMustDefineTheHomePage").
'</span><br><br>';
3377 } elseif (empty($virtualurl)) {
3380 $htmltext .=
'<br><center>'.$langs->trans(
"GoTo").
' <a href="'.$virtualurl.
'" target="_website">'.$virtualurl.
' '.
img_picto(
'',
'url').
'</a></center><br>';
3383 $htmltext .=
'<!-- Message defined translate key set into WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER -->';
3384 $htmltext .=
'<br>'.$langs->trans(
getDolGlobalString(
'WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER'));
3386 $htmltext .= $langs->trans(
"ToDeployYourWebsiteOnLiveYouHave3Solutions").
'<br><br>';
3387 $htmltext .=
'<div class="titre inline-block">1</div> - '.$langs->trans(
"SetHereVirtualHost", $dataroot);
3388 $htmltext .=
'<br>';
3389 $htmltext .=
'<br>'.$langs->trans(
"CheckVirtualHostPerms", $langs->transnoentitiesnoconv(
"ReadPerm"), DOL_DOCUMENT_ROOT);
3390 $htmltext .=
'<br>'.$langs->trans(
"CheckVirtualHostPerms", $langs->transnoentitiesnoconv(
"WritePerm"),
'{s1}');
3391 $htmltext = str_replace(
'{s1}', DOL_DATA_ROOT.
'/website<br>'.DOL_DATA_ROOT.
'/medias', $htmltext);
3393 $examplewithapache =
"<VirtualHost *:80>\n";
3394 $examplewithapache .=
'#php_admin_value open_basedir /tmp/:'.DOL_DOCUMENT_ROOT.
':'.DOL_DATA_ROOT.
':/dev/urandom'.
"\n";
3396 $examplewithapache .=
"\n";
3397 $examplewithapache .=
'DocumentRoot "'.DOL_DOCUMENT_ROOT.
'"'.
"\n";
3398 $examplewithapache .=
"\n";
3399 $examplewithapache .=
'<Directory "'.DOL_DOCUMENT_ROOT.
'">'.
"\n";
3400 $examplewithapache .=
'AllowOverride FileInfo Options
3401 Options -Indexes -MultiViews -FollowSymLinks -ExecCGI
3403 </Directory>'.
"\n".
'
3404 <Directory "'.DOL_DATA_ROOT.
'/website">
3405 AllowOverride FileInfo Options
3406 Options -Indexes -MultiViews +FollowSymLinks -ExecCGI
3408 </Directory>'.
"\n".
'
3409 <Directory "'.DOL_DATA_ROOT.
'/medias">
3410 AllowOverride FileInfo Options
3411 Options -Indexes -MultiViews -FollowSymLinks -ExecCGI
3415 $examplewithapache .=
"\n";
3416 $examplewithapache .=
"#ErrorLog /var/log/apache2/".$websitekey.
"_error_log\n";
3417 $examplewithapache .=
"#TransferLog /var/log/apache2/".$websitekey.
"_access_log\n";
3419 $examplewithapache .=
"\n";
3420 $examplewithapache .=
"# If you need include the payment page into a frame of the website,\n";
3421 $examplewithapache .=
"# you need to make a proxy redirection of URLs required for the payment to your backoffice pages\n";
3422 $examplewithapache .=
"#SSLProxyEngine On\n";
3423 $examplewithapache .=
"#SSLProxyVerify none\n";
3424 $examplewithapache .=
"#SSLProxyCheckPeerCN off\n";
3425 $examplewithapache .=
"#SSLProxyCheckPeerName off\n";
3426 $examplewithapache .=
"#ProxyPreserveHost Off\n";
3427 $examplewithapache .=
'#ProxyPass "/public/payment/" "'.$urlwithroot.
'/public/payment/'.
"\n";
3428 $examplewithapache .=
'#ProxyPassReverse "/public/payment/" "'.$urlwithroot.
'/public/payment/'.
"\n";
3429 $examplewithapache .=
'#ProxyPass "/includes/" "'.$urlwithroot.
'/includes/'.
"\n";
3430 $examplewithapache .=
'#ProxyPassReverse "/includes/" "'.$urlwithroot.
'/includes/'.
"\n";
3431 $examplewithapache .=
'#ProxyPass "/theme/" "'.$urlwithroot.
'/theme/'.
"\n";
3432 $examplewithapache .=
'#ProxyPassReverse "/theme/" "'.$urlwithroot.
'/theme/'.
"\n";
3433 $examplewithapache .=
'#ProxyPass "/core/js/" "'.$urlwithroot.
'/core/js/'.
"\n";
3434 $examplewithapache .=
'#ProxyPassReverse "/core/js/" "'.$urlwithroot.
'/core/js/'.
"\n";
3435 $examplewithapache .=
"\n";
3437 $examplewithapache .=
"</VirtualHost>\n";
3439 $htmltext .=
'<br>'.$langs->trans(
"ExampleToUseInApacheVirtualHostConfig").
':<br>';
3440 $htmltext .=
'<div class="quatrevingtpercent exampleapachesetup wordbreak" spellcheck="false">'.dol_nl2br(
dol_escape_htmltag($examplewithapache, 1, 1)).
'</div>';
3442 $htmltext .=
'<br>';
3443 $htmltext .=
'<div class="titre inline-block">2</div> - '.$langs->trans(
"YouCanAlsoTestWithPHPS");
3444 $htmltext .=
'<br><div class="urllink"><input type="text" id="cliphpserver" spellcheck="false" class="quatrevingtpercent" value="php -S 0.0.0.0:8080 -t '.$dataroot.
'"></div>';
3445 $htmltext .= ajax_autoselect(
"cliphpserver");
3446 $htmltext .=
'<br>';
3447 $htmltext .=
'<div class="titre inline-block">3</div> - '.$langs->trans(
"YouCanAlsoDeployToAnotherWHP");
3449 print $form->textwithpicto($linktotestonwebserver, $htmltext, 1,
'none',
'valignmiddle', 0, 3,
'helpvirtualhost');
3453 if (in_array($action, array(
'editcss',
'editmenu',
'file_manager',
'replacesiteconfirm',
'editsecurity')) || in_array($mode, array(
'replacesite'))) {
3454 if (!$user->hasRight(
'website',
'write')) {
3455 $disabled =
' disabled';
3457 if ($action ==
'editcss' || $action ==
'editsecurity') {
3458 print
'<input type="submit" accesskey="s" title="'.dol_escape_htmltag(
$conf->browser->stringforfirstkey.
' s').
'" id="savefileandstay" class="button buttonforacesave hideonsmartphone small'.$disabled.
'" value="'.
dol_escape_htmltag($langs->trans(
"SaveAndStay")).
'" name="updateandstay">';
3460 if (preg_match(
'/^create/', $action) && $action !=
'file_manager' && $action !=
'replacesite' && $action !=
'replacesiteconfirm') {
3461 print
'<input type="submit" id="savefile" class="button buttonforacesave button-save small'.$disabled.
'" value="'.
dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
3463 if (preg_match(
'/^edit/', $action) && $action !=
'file_manager' && $action !=
'replacesite' && $action !=
'replacesiteconfirm') {
3464 print
'<input type="submit" id="savefile" class="button buttonforacesave button-save small'.$disabled.
'" value="'.
dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
3466 if ($action !=
'preview') {
3467 print
'<input type="submit" class="button button-cancel small" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'" name="cancel">';
3477 if ($websitekey && $websitekey !=
'-1' && (!in_array($action, array(
'editcss',
'editmenu',
'importsite',
'file_manager',
'replacesite',
'replacesiteconfirm',
'editsecurity'))) && (!in_array($mode, array(
'replacesite'))) && !$file_manager) {
3480 print
'<!-- Toolbar for websitepage -->';
3481 print
'<div class="centpercent websitebar"'.($style ?
' style="'.$style.
'"' :
'').
'>'.
"\n";
3483 print
'<div class="websiteselection hideonsmartphoneimp minwidth75 tdoverflowmax100 inline-block">';
3484 print $langs->trans(
"PageContainer").
': ';
3488 if ($user->hasRight(
'website',
'write')) {
3489 print
'<span class="websiteselection paddingrightonly">';
3490 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=createcontainer&token='.newToken().
'&website='.urlencode($website->ref).
'" class=""'.$disabled.
' title="'.
dol_escape_htmltag($langs->trans(
"AddPage")).
'"><span class="fa fa-plus-circle valignmiddle btnTitle-icon"></span></a>';
3496 $s = $formwebsite->selectContainer($website,
'pageid', $pageid, 0, $action,
'minwidth100 maxwidth200onsmartphone');
3498 $out .=
'<span class="websiteselection nopaddingrightimp">';
3502 $urltocreatenewpage = $_SERVER[
"PHP_SELF"].
'?action=createcontainer&token='.newToken().
'&website='.urlencode($website->ref);
3504 if (!empty(
$conf->use_javascript_ajax)) {
3505 $out .=
'<script type="text/javascript">';
3506 $out .=
'jQuery(document).ready(function () {';
3507 $out .=
' jQuery("#pageid").change(function () {';
3508 $out .=
' console.log("We select "+jQuery("#pageid option:selected").val());';
3509 $out .=
' if (jQuery("#pageid option:selected").val() == \'-2\') {';
3510 $out .=
' window.location.href = "'.$urltocreatenewpage.
'";';
3511 $out .=
' } else {';
3512 $out .=
' window.location.href = "'.$_SERVER[
"PHP_SELF"].
'?website='.urlencode($website->ref).
'&pageid="+jQuery("#pageid option:selected").val();';
3516 $out .=
'</script>';
3522 if (!empty(
$conf->use_javascript_ajax)) {
3523 print
'<span class="websiteselection">';
3525 if (
$object->status == $object::STATUS_DRAFT) {
3526 $text_off =
'SetWebsiteOnlineBefore';
3527 if ($websitepage->status == $websitepage::STATUS_DRAFT) {
3528 print
'<span class="valignmiddle disabled opacitymedium">'.img_picto($langs->trans($text_off),
'switch_off',
'', 0, 0, 0,
'', $morecss).
'</span>';
3530 print
'<span class="valignmiddle disabled opacitymedium">'.img_picto($langs->trans($text_off),
'switch_on',
'', 0, 0, 0,
'', $morecss).
'</span>';
3533 if ($objectpage->type_container !=
'setup') {
3534 print
ajax_object_onoff($websitepage,
'status',
'status',
'Online',
'Offline', array(),
'valignmiddle inline-block'.((empty($websitepage->id) || !$user->hasRight(
'website',
'write')) ?
' opacitymedium disabled' :
''),
'statuswebsitepage', 1,
'website='.urlencode($website->
ref).
'&pageid='.((int) $websitepage->id), $user->hasRight(
'website',
'write') ? 0 : 1);
3541 print
'<span class="websiteselection">';
3543 print
'<input type="image" class="valignmiddle buttonwebsite hideonsmartphone" src="'.img_picto(
'',
'refresh',
'', 0, 1).
'" name="refreshpage" value="'.$langs->trans(
"Load").
'"'.(($action !=
'editsource') ?
'' :
' disabled="disabled"').
'>';
3546 $pagepreviousid = 0;
3549 $sql =
"SELECT MAX(rowid) as pagepreviousid FROM ".MAIN_DB_PREFIX.
"website_page WHERE rowid < ".((int) $pageid).
" AND fk_website = ".((int)
$object->id);
3550 $resql =
$db->query($sql);
3552 $obj =
$db->fetch_object($resql);
3554 $pagepreviousid = $obj->pagepreviousid;
3559 $sql =
"SELECT MIN(rowid) as pagenextid FROM ".MAIN_DB_PREFIX.
"website_page WHERE rowid > ".((int) $pageid).
" AND fk_website = ".((int)
$object->id);
3560 $resql =
$db->query($sql);
3562 $obj =
$db->fetch_object($resql);
3564 $pagenextid = $obj->pagenextid;
3571 if ($pagepreviousid) {
3572 print
'<a class="valignmiddle" href="'.$_SERVER[
'PHP_SELF'].
'?website='.urlencode(
$object->ref).
'&pageid='.((int) $pagepreviousid).
'&action='.urlencode($action).
'&token='.newToken().
'">'.
img_previous($langs->trans(
"PreviousContainer")).
'</a>';
3574 print
'<span class="valignmiddle opacitymedium">'.img_previous($langs->trans(
"PreviousContainer")).
'</span>';
3577 print
'<a class="valignmiddle" href="'.$_SERVER[
'PHP_SELF'].
'?website='.urlencode(
$object->ref).
'&pageid='.((int) $pagenextid).
'&action='.urlencode($action).
'&token='.newToken().
'">'.
img_next($langs->trans(
"NextContainer")).
'</a>';
3579 print
'<span class="valignmiddle opacitymedium">'.img_next($langs->trans(
"NextContainer")).
'</span>';
3584 if ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite') {
3586 if (!$user->hasRight(
'website',
'write')) {
3587 $disabled =
' disabled="disabled"';
3591 if ($action ==
'deletesite') {
3593 $formquestion = array(
3594 array(
'type' =>
'checkbox',
'name' =>
'delete_also_js',
'label' => $langs->trans(
"DeleteAlsoJs"),
'value' => 0),
3595 array(
'type' =>
'checkbox',
'name' =>
'delete_also_medias',
'label' => $langs->trans(
"DeleteAlsoMedias"),
'value' => 0),
3600 if ($atleastonepage) {
3601 $langs->load(
"errors");
3602 $formquestion[] = array(
'type' =>
'onecolumn',
'value' =>
'<div class="warning">'.$langs->trans(
"WarningPagesWillBeDeleted").
'</div>');
3605 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteWebsite'),
'',
'confirm_deletesite', $formquestion, 0, 1, 210 + ($atleastonepage ? 70 : 0), 580);
3611 if ($action ==
'createfromclone') {
3613 $formquestion = array(
3614 array(
'type' =>
'text',
'name' =>
'siteref',
'label' => $langs->trans(
"WebSite"),
'value' =>
'copy_of_'.$object->ref)
3617 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'CloneSite'),
'',
'confirm_createfromclone', $formquestion, 0, 1, 200);
3622 if ($pageid > 0 && $atleastonepage) {
3624 if ($action ==
'createpagefromclone') {
3626 $preselectedlanguage =
GETPOST(
'newlang',
'aZ09') ?
GETPOST(
'newlang',
'aZ09') :
'';
3627 $onlylang = array();
3628 if ($website->otherlang) {
3629 if (!empty($website->lang)) {
3630 $onlylang[$website->lang] = $website->lang.
' ('.$langs->trans(
"Default").
')';
3632 foreach (explode(
',', $website->otherlang) as $langkey) {
3633 if (empty(trim($langkey))) {
3636 $onlylang[$langkey] = $langkey;
3638 $textifempty = $langs->trans(
"Default");
3640 $onlylang[
'none'] =
'none';
3641 $textifempty = $langs->trans(
"Default");
3646 $formquestion = array(
3647 array(
'type' =>
'hidden',
'name' =>
'sourcepageurl',
'value' => $objectpage->pageurl),
3648 array(
'type' =>
'other',
'tdclass' =>
'fieldrequired',
'name' =>
'newwebsite',
'label' => $langs->trans(
"WebSite"),
'value' => $formwebsite->selectWebsite((
string)
$object->id,
'newwebsite', 0)),
3649 array(
'type' =>
'text',
'tdclass' =>
'maxwidth200 fieldrequired',
'moreattr' =>
'autofocus="autofocus"',
'name' =>
'newtitle',
'label' => $langs->trans(
"WEBSITE_TITLE"),
'value' => $langs->trans(
"CopyOf").
' '.$objectpage->title),
3650 array(
'type' =>
'text',
'tdclass' =>
'maxwidth200',
'name' =>
'newpageurl',
'label' => $langs->trans(
"WEBSITE_PAGENAME"),
'value' =>
'')
3652 if (count($onlylang) > 1) {
3653 $formquestion[] = array(
'type' =>
'checkbox',
'tdclass' =>
'maxwidth200',
'name' =>
'is_a_translation',
'label' => $langs->trans(
"PageIsANewTranslation"),
'value' => 0,
'morecss' =>
'margintoponly');
3657 $value = $formadmin->select_language($preselectedlanguage,
'newlang', 0, array(), $textifempty, 0, 0,
'minwidth200', 1, 0, 0, $onlylang, 1);
3658 $formquestion[] = array(
'type' =>
'other',
'name' =>
'newlang',
'label' => $form->textwithpicto($langs->trans(
"Language"), $langs->trans(
"DefineListOfAltLanguagesInWebsiteProperties")),
'value' => $value);
3660 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?website='.
$object->ref.
'&pageid='.$pageid, $langs->trans(
'ClonePage'),
'',
'confirm_createpagefromclone', $formquestion, 0, 1, $formheight, 550);
3665 print
'<span class="websiteselection">';
3668 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?website='.
$object->ref.
'&pageid='.$pageid.
'&action=editmeta&token='.newToken().
'" class="button bordertransp valignmiddle" title="'.
dol_escape_htmltag($langs->trans(
"EditPageMeta")).
'"'.$disabled.
'>';
3670 print
'<span class="hideonsmartphone paddingleft">'.dol_escape_htmltag($langs->trans(
"EditPageMeta")).
'</span>';
3674 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?website='.
$object->ref.
'&pageid='.$pageid.
'&action=editsource&token='.newToken().
'" class="button bordertransp"'.$disabled.
'>';
3676 print
'<span class="hideonsmartphone paddingleft">'.dol_escape_htmltag($langs->trans(
$conf->dol_optimize_smallscreen ?
"HTML" :
"EditHTMLSource")).
'</span>';
3681 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?website='.
$object->ref.
'&pageid='.$pageid.
'&action=editcontent&token='.newToken().
'" class="button bordertransp"'.$disabled.
'>'.
dol_escape_htmltag(
"CKEditor").
'</a>';
3683 print
'<!-- Add option WEBSITE_ALLOW_CKEDITOR to allow ckeditor -->';
3690 print
'<!-- button EditInLine and ShowSubcontainers -->'.
"\n";
3691 print
'<div class="websiteselectionsection inline-block">';
3694 if ($objectpage->type_container ==
'setup') {
3698 if ($objectpage->type_container !=
'setup') {
3699 print
'<div class="inline-block marginrightonly">';
3700 print $langs->trans(
"ShowSubcontainers");
3702 print
'<a class="nobordertransp nohoverborder marginleftonlyshort valignmiddle"'.$disabled.
' href="'.$_SERVER[
"PHP_SELF"].
'?website='.
$object->ref.
'&pageid='.$websitepage->id.
'&action=setshowsubcontainers&token='.newToken().
'">'.
img_picto($langs->trans(
"ShowSubContainersOnOff", $langs->transnoentitiesnoconv(
"Off")),
'switch_off',
'', 0, 0, 0,
'',
'nomarginleft').
'</a>';
3704 print
'<a class="nobordertransp nohoverborder marginleftonlyshort valignmiddle"'.$disabled.
' href="'.$_SERVER[
"PHP_SELF"].
'?website='.
$object->ref.
'&pageid='.$websitepage->id.
'&action=unsetshowsubcontainers&token='.newToken().
'">'.
img_picto($langs->trans(
"ShowSubContainersOnOff", $langs->transnoentitiesnoconv(
"On")),
'switch_on',
'', 0, 0, 0,
'',
'nomarginleft').
'</a>';
3709 print
'<div class="inline-block marginrightonly">';
3711 print
'<span id="switchckeditorinline">'.
"\n";
3713 print
'<!-- Code to enabled edit inline ckeditor -->'.
"\n";
3714 print
'<script type="text/javascript">
3715 $(document).ready(function() {
3716 var isEditingEnabled = '.(getDolGlobalString(
"WEBSITE_EDITINLINE") ?
'true' :
'false').
';
3717 if (isEditingEnabled)
3719 switchEditorOnline(true);
3722 $( "#switchckeditorinline" ).click(function() {
3723 switchEditorOnline();
3726 function switchEditorOnline(forceenable)
3728 if (! isEditingEnabled || forceenable)
3730 console.log("Enable inline edit for some html tags with contenteditable=true attribute");
3732 jQuery(\'section[contenteditable="true"],div[contenteditable="true"],header[contenteditable="true"],main[contenteditable="true"],footer[contenteditable="true"]\').each(function(idx){
3733 var idtouse = $(this).attr(\'id\');
3734 console.log("Enable inline edit for "+idtouse);
3735 if (idtouse !== undefined) {
3736 var inlineditor = CKEDITOR.inline(idtouse, {
3737 // Allow some non-standard markup that we used in the introduction.
3738 // + a[target];div{float,display} ?
3739 extraAllowedContent: \'span(*);cite(*);q(*);dl(*);dt(*);dd(*);ul(*);li(*);header(*);main(*);footer(*);button(*);h1(*);h2(*);h3(*);\',
3740 //extraPlugins: \'sourcedialog\',
3741 removePlugins: \'flash,stylescombo,exportpdf,scayt,wsc,pagebreak,iframe,smiley\',
3742 // Show toolbar on startup (optional).
3743 // startupFocus: true
3747 // Note the Source tool does not work on inline
3748 inlineditor.config.toolbar = [
3749 [\'Templates\',\'NewPage\'],
3751 [\'Maximize\',\'Preview\'],
3753 [\'Undo\',\'Redo\',\'-\',\'Find\',\'Replace\',\'-\',\'SelectAll\',\'RemoveFormat\'],
3754 [\'CreateDiv\',\'ShowBlocks\'],
3755 [\'Form\', \'Checkbox\', \'Radio\', \'TextField\', \'Textarea\', \'Select\', \'Button\', \'ImageButton\', \'HiddenField\'],
3756 [\'Bold\',\'Italic\',\'Underline\',\'Strike\',\'Superscript\'],
3757 [\'NumberedList\',\'BulletedList\',\'-\',\'Outdent\',\'Indent\',\'Blockquote\'],
3758 [\'JustifyLeft\',\'JustifyCenter\',\'JustifyRight\',\'JustifyBlock\'],
3759 [\'Link\',\'Unlink\'],
3760 [\'Image\',\'Table\',\'HorizontalRule\'],
3761 [\'Styles\',\'Format\',\'Font\',\'FontSize\'],
3762 [\'TextColor\',\'BGColor\']
3766 //inlineditor.on(\'instanceReady\', function () {
3770 CKEDITOR.instances[idtouse].on(\'change\', function() {
3771 $(this.element.$).addClass(\'modified\');
3774 console.warn("A html section has the contenteditable=true attribute but has no id attribute");
3778 isEditingEnabled = true;
3780 // Trigger the function when clicking outside the elements with contenteditable=true attribute
3781 // so we can save the change.
3782 $(document).on(\'click\', function(e) {
3783 var target = $(e.target);
3785 // Check if the click is outside the elements with contenteditable=true attribute
3786 if (!target.closest(\'[contenteditable="true"]\').length) {
3787 // Repeat through the elements with contenteditable="true" attribute
3788 $(\'[contenteditable="true"]\').each(function() {
3789 var idToUse = $(this).attr(\'id\');
3790 var elementType = $(this).prop("tagName").toLowerCase(); // Get the tag name (div, section, footer...)
3791 var instance = CKEDITOR.instances[idToUse];
3793 // Check if the element has been modified
3794 if ($(this).hasClass(\'modified\')) {
3795 var content = instance.getData();
3796 content = "\\n" + content;
3798 // Retrieving the content and ID of the element
3799 var elementId = $(this).attr(\'id\');
3804 console.log("A change has been detected, we send new content for update with ajax");
3806 // Sending data via AJAX to update section
3809 url: \'' . DOL_URL_ROOT .
'/core/ajax/editinline.php\',
3811 website_ref: \''.dol_escape_js($website->ref).
'\',
3812 page_id: \
'' . ((int) $websitepage->id) .
'\',
3814 element_id: elementId,
3815 element_type: elementType,
3816 action: \
'updatedElementContent\',
3817 token: \'' . newToken() .
'\'
3819 success:
function(response) {
3820 console.log(response);
3821 var $lastWebsitebar = $(
".websitebar").last();
3822 var $span = $(
"<span></span>").html(
"'.$langs->trans("Saved
").'").css({
3823 \
'display\': \'block\',
3824 \'position\': \'absolute\',
3825 \'margin-top\': \'6px\',
3827 \'background-color\': \'#e3f0db\',
3828 \'color\': \'#446548\',
3829 \'font-size\': \'14px\',
3830 \'padding\': \'0px 5px\',
3833 $lastWebsitebar.after($span);
3835 // Close message after 2 seconds
3836 setTimeout(function() {
3837 $span.fadeOut(500, function() {
3845 print
'console.log("A change has been detected, but saving is not enabled by option WEBSITE_EDITINLINE_SAVE_CKEDITOR_EDIT, so no ajax update is done");';
3849 $(this).removeClass(\'modified\');
3856 console.log("Disable inline edit");
3857 for(name in CKEDITOR.instances) {
3858 CKEDITOR.instances[name].destroy(true);
3860 isEditingEnabled = false;
3865 print $langs->trans(
"EditInLine");
3869 $disableeditinline = 0;
3870 if ($disableeditinline) {
3872 print
'<a class="nobordertransp opacitymedium nohoverborder marginleftonlyshort"'.$disabled.
' href="#" disabled="disabled" title="'.
dol_escape_htmltag($langs->trans(
"OnlyEditionOfSourceForGrabbedContent")).
'">'.
img_picto($langs->trans(
"OnlyEditionOfSourceForGrabbedContent"),
'switch_off',
'', 0, 0, 0,
'',
'nomarginleft').
'</a>';
3876 print
'<a class="nobordertransp nohoverborder marginleftonlyshort valignmiddle"'.$disabled.
' href="'.$_SERVER[
"PHP_SELF"].
'?website='.
$object->ref.
'&pageid='.$websitepage->id.
'&action=seteditinline&token='.newToken().
'">'.
img_picto($langs->trans(
"EditInLineOnOff", $langs->transnoentitiesnoconv(
"Off")),
'switch_off',
'', 0, 0, 0,
'',
'nomarginleft').
'</a>';
3878 print
'<a class="nobordertransp nohoverborder marginleftonlyshort valignmiddle"'.$disabled.
' href="'.$_SERVER[
"PHP_SELF"].
'?website='.
$object->ref.
'&pageid='.$websitepage->id.
'&action=unseteditinline&token='.newToken().
'">'.
img_picto($langs->trans(
"EditInLineOnOff", $langs->transnoentitiesnoconv(
"On")),
'switch_on',
'', 0, 0, 0,
'',
'nomarginleft').
'</a>';
3887 print
'<span class="websiteselection">';
3888 if (
$object->fk_default_home > 0 && $pageid ==
$object->fk_default_home) {
3892 print
'<a href="#" class="button bordertransp disabled" disabled="disabled" title="'.dol_escape_htmltag($langs->trans(
"SetAsHomePage")).
'"><span class="fas fa-home valignmiddle btnTitle-icon"></span></a>';
3896 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setashome&token='.newToken().
'&website='.urlencode($website->ref).
'&pageid='.((int) $pageid).
'" class="button bordertransp"'.$disabled.
' title="'.
dol_escape_htmltag($langs->trans(
"SetAsHomePage")).
'"><span class="fas fa-home valignmiddle btnTitle-icon"></span></a>';
3898 print
'<input type="submit" class="button bordertransp"'.$disabled.
' value="'.
dol_escape_htmltag($langs->trans(
"ClonePage")).
'" name="createpagefromclone">';
3901 if ($websitepage->status != $websitepage::STATUS_DRAFT) {
3902 $disabled =
' disabled="disabled"';
3903 $title = $langs->trans(
"WebpageMustBeDisabled", $langs->transnoentitiesnoconv($websitepage->LibStatut(0, 0)));
3908 $url = $_SERVER[
"PHP_SELF"].
'?action=delete&token='.newToken().
'&pageid='.((int) $websitepage->id).
'&website='.urlencode($website->ref);
3910 print
'<a href="'.$url.
'" class="button buttonDelete bordertransp'.($disabled ?
' disabled' :
'').
'"'.$disabled.
' title="'.
dol_escape_htmltag($title).
'">'.
img_picto(
'',
'delete',
'class=""').
'<span class="hideonsmartphone paddingleft">'.$langs->trans(
"Delete").
'</span></a>';
3917 print
'<span class="websitetools">';
3919 if (($pageid > 0 && $atleastonepage) && ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite')) {
3920 $realpage = $urlwithroot.
'/public/website/index.php?website='.$websitekey.
'&pageref='.$websitepage->pageurl;
3921 $pagealias = $websitepage->pageurl;
3923 $htmltext = $langs->trans(
"PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv(
"Page"), $langs->transnoentitiesnoconv(
"Page"), $realpage, $langs->transnoentitiesnoconv(
"TestDeployOnWeb"));
3929 print
'<div class="websiteinputurl inline-block paddingright">';
3930 print
'<a class="websitebuttonsitepreview inline-block" id="previewpage" href="'.$realpage.
'&nocache='.
dol_now().
'" class="button" target="tab'.$websitekey.
'" alt="'.
dol_escape_htmltag($htmltext).
'">';
3931 print $form->textwithpicto(
'', $htmltext, 1,
'preview');
3955 if (!in_array($mode, array(
'replacesite')) && !in_array($action, array(
'editcss',
'editmenu',
'file_manager',
'replacesiteconfirm',
'createsite',
'createcontainer',
'createfromclone',
'createpagefromclone',
'deletesite',
'editsecurity'))) {
3956 if (!$user->hasRight(
'website',
'write')) {
3957 $disabled =
' disabled';
3959 if ($action ==
'editsource' || $action ==
'editmeta') {
3960 print
'<input type="submit" accesskey="s" title="'.dol_escape_htmltag(
$conf->browser->stringforfirstkey.
' s').
'" id="savefileandstay" class="button buttonforacesave hideonsmartphone small'.$disabled.
'" value="'.
dol_escape_htmltag($langs->trans(
"SaveAndStay")).
'" name="updateandstay">';
3962 if (preg_match(
'/^create/', $action)) {
3963 print
'<input type="submit" id="savefile" class="button buttonforacesave button-save small'.$disabled.
'" value="'.
dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
3965 if (preg_match(
'/^edit/', $action)) {
3966 print
'<input type="submit" id="savefile" class="button buttonforacesave button-save small'.$disabled.
'" value="'.
dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
3968 if ($action !=
'preview') {
3969 print
'<input type="submit" class="button button-cancel small" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'" name="cancel">';
3975 print
'<span class="websitehelp">';
3976 if ($action ==
'editsource' || $action ==
'editcontent' ||
GETPOST(
'editsource',
'alpha') ||
GETPOST(
'editcontent',
'alpha')) {
3977 $url =
'https://wiki.dolibarr.org/index.php/Module_Website';
3979 $htmltext =
'<small>';
3980 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource", $url);
3981 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSourceb", $url);
3982 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSourcec", $url);
3983 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSourced", $url);
3984 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource1", $url);
3985 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource2", $url);
3986 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource3", $url);
3987 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource4", $url);
3988 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSourceMore", $url);
3989 $htmltext .=
'<br>';
3990 $htmltext .=
'</small>';
3991 if (
$conf->browser->layout ==
'phone') {
3992 print $form->textwithpicto(
'', $htmltext, 1,
'help',
'inline-block', 1, 2,
'tooltipsubstitution');
3995 print $form->textwithpicto($langs->trans(
"SyntaxHelp").
' '.
img_help(2, $langs->trans(
"SyntaxHelp")), $htmltext, 1,
'none',
'inline-block', 1, 2,
'tooltipsubstitution');
4001 if ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone') {
4003 if (!empty(
$conf->use_javascript_ajax)) {
4004 print
'<script type="text/javascript">
4005 jQuery(document).ready(function() {
4006 jQuery("#websiteinputurl").keyup(function() {
4007 console.log("Website external url modified "+jQuery("#previewsiteurl").val());
4008 if (jQuery("#previewsiteurl").val() != "" && jQuery("#previewsiteurl").val().startsWith("http"))
4010 jQuery("a.websitebuttonsitepreviewdisabled img").css({ opacity: 1 });
4012 else jQuery("a.websitebuttonsitepreviewdisabled img").css({ opacity: 0.2 });
4016 jQuery("#previewsiteext,#previewpageext").click(function() {
4018 newurl=jQuery("#previewsiteurl").val();
4019 if (! newurl.startsWith("http"))
4021 alert(\''.dol_escape_js($langs->trans(
"ErrorURLMustStartWithHttp")).
'\');
4025 newpage=jQuery(
"#previewsiteurl").val() +
"/" + jQuery(
"#previewpageurl").val() +
".php";
4026 console.log(
"Open url "+newurl);
4030 url:
"'.DOL_URL_ROOT.'/core/ajax/saveinplace.php",
4032 field: \
'editval_virtualhost\',
4033 element: \'website\',
4034 table_element: \'website\',
4035 fk_element: '.((int)
$object->id).
',
4038 context: document.body
4041 jQuery("#previewsiteext").attr("href",newurl);
4042 jQuery("#previewpageext").attr("href",newpage);
4050 print
'</div>'.
"\n";
4061if ($action ==
'editcss') {
4062 print
'<div class="fiche">';
4066 if (!GETPOSTISSET(
'WEBSITE_CSS_INLINE')) {
4067 $csscontent = @file_get_contents($filecss);
4069 $csscontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $csscontent);
4071 $csscontent =
GETPOST(
'WEBSITE_CSS_INLINE',
'none');
4073 if (!trim($csscontent)) {
4074 $csscontent =
'/* CSS content (all pages) */'.
"\nbody.bodywebsite { margin: 0; font-family: 'Open Sans', sans-serif; }\n.bodywebsite h1 { margin-top: 0; margin-bottom: 0; padding: 10px;}";
4077 if (!GETPOSTISSET(
'WEBSITE_JS_INLINE')) {
4078 $jscontent = @file_get_contents($filejs);
4080 $jscontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $jscontent);
4082 $jscontent =
GETPOST(
'WEBSITE_JS_INLINE',
'none');
4084 if (!trim($jscontent)) {
4085 $jscontent =
'/* JS content (all pages) */'.
"\n";
4088 if (!GETPOSTISSET(
'WEBSITE_HTML_HEADER')) {
4089 $htmlheadercontent = @file_get_contents($filehtmlheader);
4091 $htmlheadercontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $htmlheadercontent);
4093 $htmlheadercontent =
GETPOST(
'WEBSITE_HTML_HEADER',
'none');
4095 if (!trim($htmlheadercontent)) {
4096 $htmlheadercontent =
"<html>\n";
4097 $htmlheadercontent .= $htmlheadercontentdefault;
4098 $htmlheadercontent .=
"</html>";
4100 $htmlheadercontent = preg_replace(
'/^\s*<html>/ims',
'', $htmlheadercontent);
4101 $htmlheadercontent = preg_replace(
'/<\/html>\s*$/ims',
'', $htmlheadercontent);
4102 $htmlheadercontent =
'<html>'.
"\n".trim($htmlheadercontent).
"\n".
'</html>';
4105 if (!GETPOSTISSET(
'WEBSITE_ROBOT')) {
4106 $robotcontent = @file_get_contents($filerobot);
4108 $robotcontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $robotcontent);
4110 $robotcontent =
GETPOST(
'WEBSITE_ROBOT',
'nohtml');
4112 if (!trim($robotcontent)) {
4113 $robotcontent .=
"# Robot file. Generated with ".DOL_APPLICATION_TITLE.
"\n";
4114 $robotcontent .=
"User-agent: *\n";
4115 $robotcontent .=
"Allow: /public/\n";
4116 $robotcontent .=
"Disallow: /administrator/\n";
4119 if (!GETPOSTISSET(
'WEBSITE_HTACCESS')) {
4120 $htaccesscontent = @file_get_contents($filehtaccess);
4122 $htaccesscontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $htaccesscontent);
4124 $htaccesscontent =
GETPOST(
'WEBSITE_HTACCESS',
'nohtml');
4127 if (!GETPOSTISSET(
'WEBSITE_MANIFEST_JSON')) {
4128 $manifestjsoncontent = @file_get_contents($filemanifestjson);
4130 $manifestjsoncontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $manifestjsoncontent);
4132 $manifestjsoncontent = trim(
GETPOST(
'WEBSITE_MANIFEST_JSON',
'restricthtmlallowunvalid'));
4133 $manifestjsoncontent = str_replace(
'<?=',
'<?php', $manifestjsoncontent);
4140 if (!GETPOSTISSET(
'WEBSITE_README')) {
4141 $readmecontent = @file_get_contents($filereadme);
4143 $readmecontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $readmecontent);
4145 $readmecontent =
GETPOST(
'WEBSITE_README',
'restricthtmlallowunvalid');
4151 if (!GETPOSTISSET(
'WEBSITE_LICENSE')) {
4152 $licensecontent = @file_get_contents($filelicense);
4154 $licensecontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $licensecontent);
4156 $licensecontent =
GETPOST(
'WEBSITE_LICENSE',
'restricthtmlallowunvalid');
4165 print
'<!-- Edit Website properties (CSS, Language, ...) -->'.
"\n";
4166 print
'<table class="border centpercent">';
4169 print
'<tr><td class="titlefieldcreate fieldrequired">';
4170 print $langs->trans(
'WebSite');
4176 if ($action !=
'createcontainer') {
4177 if (empty(
$conf->use_javascript_ajax)) {
4178 print
'<!-- Status of web site page -->'.
"\n";
4179 print
'<tr><td class="fieldrequired">';
4180 print $langs->trans(
'Status');
4182 print $form->selectyesno(
'status',
$object->status);
4188 print
'<tr><td class="tdtop fieldrequired">';
4190 print $form->textwithpicto($langs->trans(
'MainLanguage'), $htmltext, 1,
'help',
'', 0, 2,
'WEBSITE_LANG');
4192 print
img_picto(
'',
'language',
'class="pictofixedwidth"');
4193 print $formadmin->select_language((GETPOSTISSET(
'WEBSITE_LANG') ?
GETPOST(
'WEBSITE_LANG',
'aZ09comma') : (
$object->lang ?
$object->lang :
'0')),
'WEBSITE_LANG', 0, array(), 1, 0, 0,
'minwidth300', 2, 0, 0, array(), 1);
4198 print
'<tr><td class="tdtop">';
4199 $htmltext = $langs->trans(
"Example").
': fr,de,sv,it,pt';
4200 print $form->textwithpicto($langs->trans(
'OtherLanguages'), $htmltext, 1,
'help',
'', 0, 2);
4202 print
img_picto(
'',
'language',
'class="pictofixedwidth"');
4203 print
'<input type="text" class="flat maxwidth200" value="'.(GETPOSTISSET(
'WEBSITE_OTHERLANG') ?
GETPOST(
'WEBSITE_OTHERLANG',
'alpha') :
$object->otherlang).
'" name="WEBSITE_OTHERLANG">';
4208 print
'<tr><td class="tdtop">';
4210 $htmltext = $langs->trans(
"VirtualhostDesc");
4211 print $form->textwithpicto($langs->trans(
'Virtualhost'), $htmltext, 1,
'help',
'', 0, 2,
'virtualhosttooltip');
4213 print
'<input type="text" class="flat minwidth300" value="'.(GETPOSTISSET(
'virtualhost') ?
GETPOST(
'virtualhost',
'alpha') : $virtualurl).
'" name="virtualhost">';
4219 print $form->textwithpicto($langs->trans(
'ImportFavicon'), $langs->trans(
'FaviconTooltip'));
4222 $maxmin = $maxfilesizearray[
'maxmin'];
4224 print
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
4226 print
'<input type="file" class="flat minwidth300" name="addedfile" id="addedfile"/>';
4228 $uploadfolder =
$conf->website->dir_output.
'/'.$websitekey;
4230 print
'<div class="inline-block valignmiddle marginrightonly">';
4231 print
'<img style="max-height: 80px" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart=website&file='.$websitekey.
'/favicon.png">';
4237 print
'<tr><td class="tdtop">';
4238 $htmlhelp = $langs->trans(
"CSSContentTooltipHelp");
4239 print $form->textwithpicto($langs->trans(
'WEBSITE_CSS_INLINE'), $htmlhelp, 1,
'help',
'', 0, 2,
'csstooltip');
4242 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_CSS_INLINE_x'),
'y' =>
GETPOST(
'WEBSITE_CSS_INLINE_y'));
4243 $doleditor =
new DolEditor(
'WEBSITE_CSS_INLINE', $csscontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4244 print $doleditor->Create(1,
'',
true,
'CSS',
'css');
4249 print
'<tr><td class="tdtop">';
4250 $textwithhelp = $langs->trans(
'WEBSITE_JS_INLINE');
4251 $htmlhelp2 = $langs->trans(
"LinkAndScriptsHereAreNotLoadedInEditor").
'<br>';
4252 print $form->textwithpicto($textwithhelp, $htmlhelp2, 1,
'warning',
'', 0, 2,
'htmljstooltip2');
4256 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_JS_INLINE_x'),
'y' =>
GETPOST(
'WEBSITE_JS_INLINE_y'));
4257 $doleditor =
new DolEditor(
'WEBSITE_JS_INLINE', $jscontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4258 print $doleditor->Create(1,
'',
true,
'JS',
'javascript');
4263 print
'<tr><td class="tdtop">';
4264 print $langs->trans(
'WEBSITE_HTML_HEADER');
4265 $htmlhelp = $langs->trans(
"Example").
' :<br>';
4267 $textwithhelp = $form->textwithpicto(
'', $htmlhelp, 1,
'help',
'', 0, 2,
'htmlheadertooltip');
4268 $htmlhelp2 = $langs->trans(
"LinkAndScriptsHereAreNotLoadedInEditor").
'<br>';
4269 print $form->textwithpicto($textwithhelp, $htmlhelp2, 1,
'warning',
'', 0, 2,
'htmlheadertooltip2');
4272 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_HTML_HEADER_x'),
'y' =>
GETPOST(
'WEBSITE_HTML_HEADER_y'));
4273 $doleditor =
new DolEditor(
'WEBSITE_HTML_HEADER', $htmlheadercontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4274 print $doleditor->Create(1,
'',
true,
'HTML Header',
'html');
4279 print
'<tr><td class="tdtop">';
4280 print $langs->trans(
'WEBSITE_ROBOT');
4283 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_ROBOT_x'),
'y' =>
GETPOST(
'WEBSITE_ROBOT_y'));
4284 $doleditor =
new DolEditor(
'WEBSITE_ROBOT', $robotcontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4285 print $doleditor->Create(1,
'',
true,
'Robot file',
'text');
4290 print
'<tr><td class="tdtop">';
4292 $textwithhelp3 = $langs->trans(
"Example").
' :';
4293 $textwithhelp3 .=
"<br># Order allow,deny\n";
4294 $textwithhelp3 .=
"<br># Deny from all\n";
4295 $textwithhelp3 .=
"<br># Require all granted\n";
4297 print $form->textwithpicto($langs->trans(
'WEBSITE_HTACCESS'), $textwithhelp3, 1,
'help',
'', 0, 2,
'htmlheadertooltip3');
4300 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_HTACCESS_x'),
'y' =>
GETPOST(
'WEBSITE_HTACCESS_y'));
4301 $doleditor =
new DolEditor(
'WEBSITE_HTACCESS', $htaccesscontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4302 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' .htaccess',
'text');
4307 print
'<tr><td class="tdtop">';
4308 $htmlhelp = $langs->trans(
"Example").
' :<br>';
4309 $htmlhelp .=
'<small>'.dol_htmlentitiesbr($manifestjsoncontentdefault).
'</small>';
4310 print $form->textwithpicto($langs->trans(
'WEBSITE_MANIFEST_JSON'), $htmlhelp, 1,
'help',
'', 0, 2,
'manifestjsontooltip');
4312 print $langs->trans(
"UseManifest").
': '.$form->selectyesno(
'use_manifest', $website->use_manifest, 1).
'<br>';
4314 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_MANIFEST_JSON_x'),
'y' =>
GETPOST(
'WEBSITE_MANIFEST_JSON_y'));
4315 $doleditor =
new DolEditor(
'WEBSITE_MANIFEST_JSON', $manifestjsoncontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4316 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' manifest.json',
'text');
4320 print
'<tr><td class="tdtop">';
4321 $htmlhelp = $langs->trans(
"EnterHereReadmeInformation");
4322 print $form->textwithpicto($langs->trans(
"File").
' README.md', $htmlhelp, 1,
'help',
'', 0, 2,
'readmetooltip');
4325 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_README_x'),
'y' =>
GETPOST(
'WEBSITE_README_y'));
4326 $doleditor =
new DolEditor(
'WEBSITE_README', $readmecontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4327 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' README.md',
'text');
4332 print
'<tr><td class="tdtop">';
4333 $htmlhelp = $langs->trans(
"EnterHereLicenseInformation");
4334 print $form->textwithpicto($langs->trans(
"File").
' LICENSE', $htmlhelp, 1,
'help',
'', 0, 2,
'licensetooltip');
4337 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_LICENSE_x'),
'y' =>
GETPOST(
'WEBSITE_LICENSE_y'));
4338 $doleditor =
new DolEditor(
'WEBSITE_LICENSE', $licensecontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4339 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' LICENSE',
'text');
4344 print
'<tr><td class="tdtop">';
4345 $htmlhelp = $langs->trans(
'RSSFeedDesc');
4346 print $form->textwithpicto($langs->trans(
'RSSFeed'), $htmlhelp, 1,
'help',
'', 0, 2,
'');
4348 print
'/wrapper.php?rss=1[&l=XX][&limit=99][&cachedelay=99]';
4360if ($action ==
'editsecurity') {
4364 print
'<div class="fiche">';
4368 print
dol_get_fiche_head($head,
'security', $langs->trans(
"General"), -1,
'website');
4370 print
'<span class="opacitymedium">'.$langs->trans(
"HTTPHeaderEditor").
'. '.$langs->trans(
"ReservedToAdvancedUsers").
'.</span><br><br>';
4372 print
'<div class="div-table-responsive-no-min">';
4373 print
'<table class="noborder centpercent">';
4374 print
'<tr class="liste_titre">';
4375 print
'<td>'.$langs->trans(
"HTTPHeader").
'</td>';
4376 print
'<td></td>'.
"\n";
4380 print
'<tr class="oddeven">';
4381 print
'<td>'.$form->textwithpicto($langs->trans(
'WebsiteSecurityForceRP'),
'HTTP Header Referer-Policy<br><br>'.$langs->trans(
"Recommended").
':<br>strict-origin-when-cross-origin <span class="opacitymedium">'.$langs->trans(
"or").
'</span> same-origin"=more secured', 1,
'help',
'valignmiddle', 0, 3,
'WEBSITE_'.$object->id.
'_SECURITY_FORCERP').
'</td>';
4382 print
'<td><input class="minwidth500" name="WEBSITE_'.$object->id.
'_SECURITY_FORCERP" id="WEBSITE_'.
$object->id.
'_SECURITY_FORCERP" value="'.
getDolGlobalString(
"WEBSITE_".
$object->id.
"_SECURITY_FORCERP").
'"></td>';
4385 print
'<tr class="oddeven">';
4386 print
'<td>'.$form->textwithpicto($langs->trans(
'WebsiteSecurityForceSTS'),
'HTTP Header Strict-Transport-Security<br><br>'.$langs->trans(
"Example").
':<br>max-age=31536000; includeSubDomains', 1,
'help',
'valignmiddle', 0, 3,
'WEBSITE_'.$object->id.
'_SECURITY_FORCESTS').
'</td>';
4387 print
'<td><input class="minwidth500" name="WEBSITE_'.$object->id.
'_SECURITY_FORCESTS" id="WEBSITE_'.
$object->id.
'_SECURITY_FORCESTS" value="'.
getDolGlobalString(
"WEBSITE_".
$object->id.
"_SECURITY_FORCESTS").
'"></td>';
4390 print
'<tr class="oddeven">';
4391 print
'<td>'.$form->textwithpicto($langs->trans(
'WebsiteSecurityForcePP'),
'HTTP Header Permissions-Policy<br><br>'.$langs->trans(
"Example").
':<br>camera=*, microphone=(), geolocation=*', 1,
'help',
'valignmiddle', 0, 3,
'WEBSITE_'.$object->id.
'_SECURITY_FORCEPP').
'</td>';
4392 print
'<td><input class="minwidth500" name="WEBSITE_'.$object->id.
'_SECURITY_FORCEPP" id="WEBSITE_'.
$object->id.
'_SECURITY_FORCEPP" value="'.
getDolGlobalString(
"WEBSITE_".
$object->id.
"_SECURITY_FORCEPP").
'"></td>';
4395 $examplecsprule =
"frame-ancestors 'self'; img-src * data:; font-src *; default-src 'self' 'unsafe-inline' 'unsafe-eval' *.paypal.com *.stripe.com *.google.com *.googleapis.com *.google-analytics.com *.googletagmanager.com;";
4398 print
'<tr class="oddeven nohover">';
4399 print
'<td class="tdtop">'.$form->textwithpicto($langs->trans(
'ContentSecurityPolicy'),
'HTTP Header Content-Security-Policy<br><br>'.$langs->trans(
"Example").
":<br>".$examplecsprule, 1,
'help',
'valignmiddle', 0, 3,
'WEBSITE_'.$object->id.
'_SECURITY_FORCECSP').
'</td>';
4402 print
'<div class="div-table-responsive-no-min">';
4404 print
'<input class="minwidth500 quatrevingtpercent" name="WEBSITE_'.$object->id.
'_SECURITY_FORCECSP" id="WEBSITE_'.
$object->id.
'_SECURITY_FORCECSP" value="'.$forceCSP.
'"> <a href="#" id="btnaddcontentsecuritypolicy">'.
img_picto(
'',
'add').
'</a><br>';
4406 print
'<br class="selectaddcontentsecuritypolicy hidden">';
4408 print
'<div id="selectaddcontentsecuritypolicy" class="hidden selectaddcontentsecuritypolicy">';
4409 print $form->selectarray(
"select_identifier_WEBSITE_SECURITY_FORCECSP", $selectarrayCSPDirectives,
"select_identifier_WEBSITE_SECURITY_FORCECSP", $langs->trans(
"FillCSPDirective"), 0, 0,
'', 0, 0, 0,
'',
'minwidth200 maxwidth350 inline-block');
4411 print
'<input type="hidden" id="select_source_WEBSITE_SECURITY_FORCECSP" name="select_source_WEBSITE_SECURITY_FORCECSP">';
4412 foreach ($selectarrayCSPSources as $key => $values) {
4413 print
'<div class="div_WEBSITE_SECURITY_FORCECSP hidden inline-block maxwidth350" id="div_'.$key.
'_WEBSITE_SECURITY_FORCECSP">';
4414 print $form->selectarray(
"select_".$key.
"_WEBSITE_SECURITY_FORCECSP", $values,
"select_".$key.
"_WEBSITE_SECURITY_FORCECSP", $langs->trans(
"FillCSPSource"), 0, 0,
'', 0, 0, 0,
'',
'minwidth200 maxwidth300 inline-block select_WEBSITE_SECURITY_FORCECSP');
4418 print
'<div class="div_input_data_WEBSITE_SECURITY_FORCECSP hidden inline-block maxwidth200"><input id="input_data_WEBSITE_SECURITY_FORCECSP" name="input_data_WEBSITE_SECURITY_FORCECSP"></div>';
4420 print
'<div class="div_btn_class_WEBSITE_SECURITY_FORCECSP inline-block maxwidth200"><input type="submit" id="btn_WEBSITE_SECURITY_FORCECSP" name="btn_WEBSITE_SECURITY_FORCECSP" class="butAction small smallpaddingimp" value="'.$langs->trans(
"Add").
'" disabled></div>';
4424 if (!empty($forceCSP)) {
4427 print
'<div class="div-table-responsive-no-min">';
4428 print
img_picto(
'',
'graph',
'class="pictofixedwidth"').$langs->trans(
"HierarchicView").
'<br>';
4430 foreach ($forceCSPArr as $directive => $sources) {
4432 if (in_array($directive, array_keys($selectarrayCSPDirectives))) {
4433 print
'<span>'.$directive.
'</span>';
4435 print $form->textwithpicto($directive, $langs->trans(
"UnknowContentSecurityPolicyDirective"), 1,
'warning');
4437 if (!empty($sources)) {
4439 foreach ($sources as $key => $source) {
4440 print
'<li><span>'.$source.
'</span> <a href="'.$_SERVER[
"PHP_SELF"].
'?websiteid='.$websiteid.
'&action=removecspsource&sourcecsp='.$directive.
'_'.$key.
'&token='.newToken().
'">'.
img_delete().
'</a></li>';
4444 print
' <a href="'.$_SERVER[
"PHP_SELF"].
'?websiteid='.$websiteid.
'&action=removecspsource&sourcecsp='.$directive.
'&token='.newToken().
'">'.
img_delete().
'</a>';
4458 print
'<tr class="oddeven">';
4459 print
'<td>'.$form->textwithpicto($langs->trans(
'WebsiteSecurityForceCSPRO'),
'HTTP Header Content-Security-Policy-Report-Only<br><br>'.$langs->trans(
"Example").
":<br>".$examplecsprule, 1,
'help',
'valignmiddle', 0, 3,
'WEBSITE_'.$object->id.
'_SECURITY_FORCECSPRO').
'</td>';
4460 print
'<td><input class="minwidth500" name="WEBSITE_'.$object->id.
'_SECURITY_FORCECSPRO" id="WEBSITE_'.
$object->id.
'_SECURITY_FORCECSPRO" value="'.
getDolGlobalString(
"WEBSITE_".
$object->id.
"_SECURITY_FORCECSPRO").
'"></td>';
4468 print
'<div class="center">';
4470 print
'<input type="submit" class="button small" name="updateandstay" value="'.$langs->trans(
"Save").
'">';
4471 print
'<input class="button button-cancel small" type="submit" name="preview" value="'.$langs->trans(
"Cancel").
'">';
4477 $(document).ready(function() {
4478 $("#btnaddcontentsecuritypolicy").on("click", function(){
4479 if($("#selectaddcontentsecuritypolicy").is(":visible")){
4480 console.log("We hide select to add Content Security Policy");
4481 $(".selectaddcontentsecuritypolicy").hide();
4483 console.log("We show select to add Content Security Policy");
4484 $(".selectaddcontentsecuritypolicy").show();
4488 $("#select_identifier_WEBSITE_SECURITY_FORCECSP").on("change", function() {
4489 key = $(this).find(":selected").data("directivetype");
4490 console.log("We hide all select div");
4491 $(".div_WEBSITE_SECURITY_FORCECSP").hide();
4492 $(".select_WEBSITE_SECURITY_FORCECSP").val(null).trigger("change");
4493 $(".div_input_data_WEBSITE_SECURITY_FORCECSP").hide();
4494 $("#btn_WEBSITE_SECURITY_FORCECSP").prop("disabled",true);
4496 $("#btn_WEBSITE_SECURITY_FORCECSP").prop("disabled",false);
4498 console.log("We show div select with key "+key);
4499 $("#div_"+key+"_WEBSITE_SECURITY_FORCECSP").css("display", "inline-block");
4503 $(".select_WEBSITE_SECURITY_FORCECSP").on("change", function() {
4504 keysource = $(this).find(":selected").data("sourcetype");
4505 $("#select_source_WEBSITE_SECURITY_FORCECSP").val($(this).val());
4506 console.log("We hide and show fields");
4507 if (keysource == "data" || keysource == "input") {
4508 $(".div_input_data_WEBSITE_SECURITY_FORCECSP").css("display", "inline-block");
4509 $("#btn_WEBSITE_SECURITY_FORCECSP").prop("disabled",true);
4511 $("#input_data_WEBSITE_SECURITY_FORCECSP").val("");
4512 $(".div_input_data_WEBSITE_SECURITY_FORCECSP").hide();
4513 if (keysource != undefined) {
4514 $("#btn_WEBSITE_SECURITY_FORCECSP").prop("disabled",false);
4516 $("#btn_WEBSITE_SECURITY_FORCECSP").prop("disabled",true);
4521 $("#input_data_WEBSITE_SECURITY_FORCECSP").on("change keyup", function(){
4522 if ($(this).val() != "") {
4523 console.log("We show add button");
4524 $("#btn_WEBSITE_SECURITY_FORCECSP").prop("disabled",false);
4526 console.log("We hide add button");
4527 $("#btn_WEBSITE_SECURITY_FORCECSP").prop("disabled",true);
4538if ($action ==
'createsite') {
4539 print
'<div class="fiche">';
4553 if ($action ==
'createcontainer') {
4557 print
'<!-- Add site -->'.
"\n";
4558 print
'<div class="tabBar tabBarWithBottom">';
4560 print
'<table class="border centpercent">';
4562 $siteref = $sitedesc = $sitelang = $siteotherlang =
'';
4564 $siteref =
GETPOST(
'WEBSITE_REF',
'aZ09');
4566 if (
GETPOST(
'WEBSITE_DESCRIPTION')) {
4567 $sitedesc =
GETPOST(
'WEBSITE_DESCRIPTION',
'alpha');
4569 if (
GETPOST(
'WEBSITE_LANG')) {
4570 $sitelang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
4572 if (
GETPOST(
'WEBSITE_OTHERLANG')) {
4573 $siteotherlang =
GETPOST(
'WEBSITE_OTHERLANG',
'aZ09comma');
4576 print
'<tr><td class="titlefieldcreate fieldrequired">';
4577 print $form->textwithpicto($langs->trans(
'WebsiteName'), $langs->trans(
"Example").
': MyPortal, www.mywebsite.com, ...');
4579 print
'<input type="text" class="flat maxwidth300" name="WEBSITE_REF" value="'.dol_escape_htmltag($siteref).
'" autofocus>';
4582 print
'<tr><td class="fieldrequired">';
4583 print $langs->trans(
'MainLanguage');
4585 $shortlangcode = preg_replace(
'/[_-].*$/',
'', trim($langs->defaultlang));
4586 print
img_picto(
'',
'language',
'class="pictofixedwidth"');
4587 print $formadmin->select_language((GETPOSTISSET(
'WEBSITE_LANG') ?
GETPOST(
'WEBSITE_LANG',
'aZ09comma') : $shortlangcode),
'WEBSITE_LANG', 0, array(), 1, 0, 0,
'minwidth300', 2, 0, 0, array(), 1);
4591 $htmltext = $langs->trans(
"Example").
': fr,de,sv,it,pt';
4592 print $form->textwithpicto($langs->trans(
'OtherLanguages'), $htmltext, 1,
'help',
'', 0, 2);
4594 print
img_picto(
'',
'language',
'class="pictofixedwidth"');
4595 print
'<input type="text" class="flat minwidth300" name="WEBSITE_OTHERLANG" value="'.dol_escape_htmltag($siteotherlang).
'">';
4599 print $langs->trans(
'Description');
4601 print
'<input type="text" class="flat minwidth500" name="WEBSITE_DESCRIPTION" value="'.dol_escape_htmltag($sitedesc).
'">';
4606 $htmltext = $langs->trans(
"VirtualhostDesc");
4614 print $form->textwithpicto($langs->trans(
'Virtualhost'), $htmltext, 1,
'help',
'', 0, 2,
'');
4616 print
'<input type="text" class="flat minwidth300" name="virtualhost" value="'.dol_escape_htmltag(
GETPOST(
'virtualhost',
'alpha')).
'">';
4622 if ($action ==
'createsite') {
4623 print
'<div class="center">';
4625 print
'<input type="submit" class="button small" name="addcontainer" value="'.$langs->trans(
"Create").
'">';
4626 print
'<input class="button button-cancel small" type="submit" name="preview" value="'.$langs->trans(
"Cancel").
'">';
4642if ($action ==
'importsite') {
4643 print
'<!-- action=importsite -->';
4644 print
'<div class="fiche">';
4652 print
'<span class="opacitymedium">'.$langs->trans(
"ZipOfWebsitePackageToImport").
'</span><br><br>';
4655 $dolibarrdataroot = preg_replace(
'/([\\/]+)$/i',
'', DOL_DATA_ROOT);
4656 $allowimportsite =
true;
4657 if (
dol_is_file($dolibarrdataroot.
'/installmodules.lock')) {
4658 $allowimportsite =
false;
4661 if ($allowimportsite) {
4663 $maxmin = $maxfilesizearray[
'maxmin'];
4665 print
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
4667 print
'<input class="flat minwidth400" type="file" name="userfile[]" accept=".zip">';
4668 print
'<input type="submit" class="button small" name="buttonsubmitimportfile" value="'.dol_escape_htmltag($langs->trans(
"Upload")).
'">';
4669 print
'<input type="submit" class="button button-cancel small" name="preview" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
4670 print
'<br><br><br>';
4674 $message = $langs->trans(
'InstallModuleFromWebHasBeenDisabledContactUs');
4677 $message = $langs->trans(
"InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.
'/installmodules.lock');
4683 print
'<span class="opacitymedium">'.$langs->trans(
"ZipOfWebsitePackageToLoad").
'</span><br><br>';
4695if ($action ==
'editmeta' || $action ==
'createcontainer') {
4696 print
'<div class="fiche">';
4710 if ($action ==
'createcontainer') {
4714 print
'<!-- Edit or create page/container -->'.
"\n";
4717 $hiddenfromfetchingafterload =
' hideobject';
4718 $hiddenmanuallyafterload =
' hideobject';
4719 if (
GETPOST(
'radiocreatefrom') ==
'checkboxcreatefromfetching') {
4720 $hiddenfromfetchingafterload =
'';
4722 if (
GETPOST(
'radiocreatefrom') ==
'checkboxcreatemanually') {
4723 $hiddenmanuallyafterload =
'';
4726 if ($action ==
'editmeta' || empty(
$conf->use_javascript_ajax)) {
4727 $hiddenfromfetchingafterload =
'';
4728 $hiddenmanuallyafterload =
'';
4731 if ($action ==
'createcontainer') {
4734 if (!empty(
$conf->use_javascript_ajax)) {
4735 print
'<input type="radio" name="radiocreatefrom" id="checkboxcreatemanually" value="checkboxcreatemanually"'.(GETPOST(
'radiocreatefrom') ==
'checkboxcreatemanually' ?
' checked' :
'').
'> ';
4737 print
'<label for="checkboxcreatemanually"><span class="opacitymediumxx">'.$langs->trans(
"OrEnterPageInfoManually").
'</span></label><br>';
4738 print
'<hr class="tablecheckboxcreatemanually'.$hiddenmanuallyafterload.
'">';
4743 print
'<table class="border tableforfield nobackground centpercent tablecheckboxcreatemanually'.$hiddenmanuallyafterload.
'">';
4745 if ($action !=
'createcontainer') {
4746 print
'<tr><td class="titlefield fieldrequired">';
4747 print $langs->trans(
'IDOfPage').
' - '.$langs->trans(
'InternalURLOfPage');
4755 print
' - ';
4756 print
'/public/website/index.php?website='.urlencode($websitekey).
'&pageid='.urlencode((
string) $pageid);
4760 $type_container = $objectpage->type_container;
4761 $pageurl = $objectpage->pageurl;
4762 $pagealiasalt = $objectpage->aliasalt;
4763 $pagetitle = $objectpage->title;
4764 $pagedescription = $objectpage->description;
4765 $pageimage = $objectpage->image;
4766 $pagekeywords = $objectpage->keywords;
4767 $pagelang = $objectpage->lang;
4768 $pageallowedinframes = $objectpage->allowed_in_frames;
4769 $pagehtmlheader = $objectpage->htmlheader;
4770 $pagedatecreation = (
string) $objectpage->date_creation;
4771 $pagedatemodification = $objectpage->date_modification;
4772 $pageauthorid = $objectpage->fk_user_creat;
4773 $pageusermodifid = $objectpage->fk_user_modif;
4774 $pageauthoralias = $objectpage->author_alias;
4775 $pagestatus = $objectpage->status;
4777 $type_container =
'page';
4781 $pagedescription =
'';
4785 $pageallowedinframes = 0;
4786 $pagehtmlheader =
'';
4787 $pagedatecreation =
dol_now();
4788 $pagedatemodification =
'';
4789 $pageauthorid = $user->id;
4790 $pageusermodifid = 0;
4791 $pageauthoralias =
'';
4794 if (
GETPOST(
'WEBSITE_TITLE',
'alpha')) {
4795 $pagetitle = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_TITLE',
'alphanohtml'));
4797 if (
GETPOST(
'WEBSITE_PAGENAME',
'alpha')) {
4798 $pageurl =
GETPOST(
'WEBSITE_PAGENAME',
'alpha');
4800 if (
GETPOST(
'WEBSITE_ALIASALT',
'alpha')) {
4801 $pagealiasalt = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_ALIASALT',
'alphanohtml'));
4803 if (
GETPOST(
'WEBSITE_DESCRIPTION',
'alpha')) {
4804 $pagedescription = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml'));
4806 if (
GETPOST(
'WEBSITE_IMAGE',
'alpha')) {
4807 $pageimage =
GETPOST(
'WEBSITE_IMAGE',
'alpha');
4809 if (
GETPOST(
'WEBSITE_KEYWORDS',
'alpha')) {
4810 $pagekeywords = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_KEYWORDS',
'alphanohtml'));
4812 if (
GETPOST(
'WEBSITE_LANG',
'aZ09')) {
4813 $pagelang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
4815 if (
GETPOST(
'WEBSITE_ALLOWED_IN_FRAMES',
'aZ09')) {
4816 $pageallowedinframes = 1;
4818 if (
GETPOST(
'htmlheader',
'restricthtmlallowlinkscript')) {
4819 $pagehtmlheader =
GETPOST(
'htmlheader',
'none');
4822 if ($action !=
'createcontainer') {
4823 if (empty(
$conf->use_javascript_ajax)) {
4824 print
'<!-- Status of web site page -->'.
"\n";
4825 print
'<tr><td class="fieldrequired">';
4826 print $langs->trans(
'Status');
4828 print $form->selectyesno(
'status', $objectpage->status);
4834 print
'<tr><td class="titlefield fieldrequired">';
4835 print $langs->trans(
'WEBSITE_TYPE_CONTAINER');
4837 print
img_picto(
'',
'object_technic',
'class="paddingrightonly"').
' ';
4838 print $formwebsite->selectTypeOfContainer(
'WEBSITE_TYPE_CONTAINER', (
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'alpha') ?
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'alpha') : $type_container), 0,
'', 1,
'minwidth300');
4841 print
'<script type="text/javascript">
4842 jQuery(document).ready(function() {
4843 jQuery("#selectWEBSITE_TYPE_CONTAINER").change(function() {
4844 console.log("We change type of page : "+jQuery("#selectWEBSITE_TYPE_CONTAINER").val());
4845 if (jQuery("#selectWEBSITE_TYPE_CONTAINER").val() == \'blogpost\') {
4846 jQuery(".trpublicauthor").show();
4848 jQuery(".trpublicauthor").hide();
4850 if (jQuery("#selectWEBSITE_TYPE_CONTAINER").val() == \'service\' || jQuery("#selectWEBSITE_TYPE_CONTAINER").val() == \'library\') {
4851 $(".spanprefix").html("_" + $("#selectWEBSITE_TYPE_CONTAINER").val() + "_");
4852 jQuery(".spanprefix").show();
4854 jQuery(".spanprefix").hide();
4858 // Force at init execution a first time of the handler change
4859 jQuery("#selectWEBSITE_TYPE_CONTAINER").trigger(\'change\');
4865 print
'<tr><td class="fieldrequired">';
4866 print $langs->trans(
'WEBSITE_TITLE');
4868 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_TITLE" id="WEBSITE_TITLE" value="'.dol_escape_htmltag($pagetitle).
'" autofocus>';
4872 print
'<tr><td class="titlefieldcreate fieldrequired">';
4873 print $langs->trans(
'WEBSITE_PAGENAME');
4875 print
'<span class="opacitymedium spanprefix hidden"></span> ';
4876 print
'<input type="text" class="flat minwidth300" name="WEBSITE_PAGENAME" id="WEBSITE_PAGENAME" value="'.dol_escape_htmltag((
string) preg_replace(
'/^_[a-z]+_/',
'', (
string) $pageurl)).
'">';
4879 print
'<script type="text/javascript">
4880 $(document).ready(function() {
4881 console.log("Manage prefix for service or library");
4882 if ($("#selectWEBSITE_TYPE_CONTAINER").val() == "service" || $("#selectWEBSITE_TYPE_CONTAINER").val() == "library") {
4883 $(".spanprefix").html("_" + $("#selectWEBSITE_TYPE_CONTAINER").val() + "_");
4884 $(".spanprefix").show();
4886 $(".websiteformtoolbar").on("submit", function(event) {
4887 if ($("#selectWEBSITE_TYPE_CONTAINER").val() == "service" || $("#selectWEBSITE_TYPE_CONTAINER").val() == "library") {
4888 var prefix = "_" + $("#selectWEBSITE_TYPE_CONTAINER").val() + "_";
4889 var userInput = $("#WEBSITE_PAGENAME").val();
4890 var $inputField = $("#WEBSITE_PAGENAME");
4891 if (userInput.indexOf(prefix) !== 0) {
4892 $inputField.val(prefix + userInput);
4900 print
'<tr><td class="titlefieldcreate">';
4901 $htmlhelp = $langs->trans(
"WEBSITE_ALIASALTDesc");
4902 print $form->textwithpicto($langs->trans(
'WEBSITE_ALIASALT'), $htmlhelp, 1,
'help',
'', 0, 2,
'aliastooltip');
4904 print
'<input type="text" class="flat minwidth500" name="WEBSITE_ALIASALT" value="'.dol_escape_htmltag($pagealiasalt).
'">';
4908 print $langs->trans(
'WEBSITE_DESCRIPTION');
4910 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_DESCRIPTION" value="'.dol_escape_htmltag($pagedescription).
'">';
4915 print
'<tr class="trimageforpage hidden"><td>';
4916 $htmlhelp = $langs->trans(
"WEBSITE_IMAGEDesc");
4917 print $form->textwithpicto($langs->trans(
'WEBSITE_IMAGE'), $htmlhelp, 1,
'help',
'', 0, 2,
'imagetooltip');
4919 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_IMAGE" value="'.dol_escape_htmltag($pageimage).
'">';
4922 print
'<script type="text/javascript">
4923 jQuery(document).ready(function() {
4924 jQuery("#selectWEBSITE_TYPE_CONTAINER").change(function() {
4925 console.log("We change type of page : "+jQuery("#selectWEBSITE_TYPE_CONTAINER").val());
4926 if (jQuery("#selectWEBSITE_TYPE_CONTAINER").val() == \'blogpost\') {
4927 jQuery(".trimageforpage").show();
4929 jQuery(".trimageforpage").hide();
4939 $htmlhelp = $langs->trans(
"WEBSITE_KEYWORDSDesc");
4940 print $form->textwithpicto($langs->trans(
'WEBSITE_KEYWORDS'), $htmlhelp, 1,
'help',
'', 0, 2,
'keywordtooltip');
4942 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_KEYWORDS" value="'.dol_escape_htmltag($pagekeywords).
'">';
4946 print $langs->trans(
'Language');
4948 $onlykeys = array();
4952 $onlykeys[$langs->defaultlang] = $langs->defaultlang;
4955 $tmparray = explode(
',',
$object->otherlang);
4956 foreach ($tmparray as $key) {
4957 $tmpkey = trim($key);
4958 if (strlen($key) == 2) {
4959 $tmpkey = strtolower($key);
4961 $onlykeys[$tmpkey] = $tmpkey;
4965 $onlykeys = array();
4967 print
img_picto(
'',
'language',
'class="pictofixedwidth"').$formadmin->select_language($pagelang ? $pagelang :
'',
'WEBSITE_LANG', 0, array(),
'1', 0, 0,
'minwidth200', 0, 0, 0, $onlykeys, 1);
4968 $htmltext = $langs->trans(
"AvailableLanguagesAreDefinedIntoWebsiteProperties");
4969 print $form->textwithpicto(
'', $htmltext);
4975 print
'<!-- Translation of --><tr><td>';
4976 print $langs->trans(
'TranslationLinks');
4978 if ($action !=
'createcontainer') {
4980 $sql =
"SELECT rowid, lang from ".MAIN_DB_PREFIX.
"website_page where fk_page = ".((int) $objectpage->id);
4981 $resql =
$db->query($sql);
4983 $num_rows =
$db->num_rows($resql);
4984 if ($num_rows > 0) {
4985 print
'<span class="opacitymedium">'.$langs->trans(
'ThisPageHasTranslationPages').
':</span>';
4987 $tmppage =
new WebsitePage(
$db);
4989 while ($obj =
$db->fetch_object($resql)) {
4990 $result = $tmppage->fetch($obj->rowid);
4993 $tmpstring .=
'<br>';
4995 $tmpstring .= $tmppage->getNomUrl(1).
' '.
picto_from_langcode($tmppage->lang).
' '.$tmppage->lang;
4997 $tmpstring .=
' <a class="paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
$object->ref).
'&pageid='.((int) $objectpage->id).
'&action=deletelang&token='.newToken().
'&deletelangforid='.((int) $tmppage->id).
'">'.
img_picto($langs->trans(
"Remove"),
'unlink').
'</a>';
5013 if ((empty($translatedby) || ($objectpage->lang !=
$object->lang)) && ($action ==
'editmeta' || $action ==
'createcontainer' || $objectpage->fk_page > 0)) {
5014 $sourcepage =
new WebsitePage(
$db);
5016 if ($objectpage->fk_page > 0) {
5017 $result = $sourcepage->fetch($objectpage->fk_page);
5024 if ($translatedby) {
5027 $translationof = $objectpage->fk_page;
5028 print
'<span class="opacitymedium">'.$langs->trans(
'ThisPageIsTranslationOf').
'</span> ';
5029 print $sourcepage->getNomUrl(2).
' '.$formwebsite->selectContainer($website,
'pageidfortranslation', ($translationof ? $translationof : -1), 1, $action,
'minwidth300', array($objectpage->id));
5030 if ($translationof > 0 && $sourcepage->lang) {
5033 print
' <a class="paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
$object->ref).
'&pageid='.((int) $objectpage->id).
'&action=deletelang&token='.newToken().
'&deletelangforid='.((int) $objectpage->id).
'">'.
img_picto($langs->trans(
"Remove"),
'unlink').
'</a>';
5040 if (
isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire')) {
5042 $langs->load(
'categories');
5044 print
'<tr><td class="toptd">'.$form->editfieldkey(
'Categories',
'categories',
'', $objectpage, 0).
'</td><td>';
5045 print $form->selectCategories(Categorie::TYPE_WEBSITE_PAGE,
'categories', $objectpage);
5051 print
'<tr><td class="titlefieldcreate">';
5052 print
'ObjectClass';
5054 print
'<input type="text" class="flat minwidth300" name="WEBSITE_OBJECTCLASS" placeholder="ClassName::/path/class/ObjectClass.class.php" >';
5057 print
'<tr><td class="titlefieldcreate">';
5060 print
'<input type="text" class="flat minwidth300" name="WEBSITE_OBJECTID" >';
5067 if ($action !=
'createcontainer') {
5069 print $langs->trans(
'DateLastModification');
5071 print
dol_print_date($pagedatemodification,
'dayhour',
'tzuser');
5075 print $langs->trans(
'UserModification');
5077 if ($pageusermodifid > 0) {
5078 $fuser->fetch($pageusermodifid);
5079 print $fuser->getNomUrl(-1);
5081 print
'<span class="opacitymedium">'.$langs->trans(
"Unknown").
'</span>';
5087 $url =
'https://wiki.dolibarr.org/index.php/Module_Website';
5088 $htmltext =
'<small>';
5089 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource", $url);
5090 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource1", $url);
5091 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource2", $url);
5092 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource3", $url);
5093 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource4", $url);
5094 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSourceMore", $url);
5095 $htmltext .=
'<br>';
5096 $htmltext .=
'</small>';
5099 $formmail->withaiprompt =
'html';
5100 $formmail->withlayout =
'websitepage';
5101 $showlinktolayout = $formmail->withlayout;
5102 $showlinktoai = ($formmail->withaiprompt &&
isModEnabled(
'ai')) ?
'textgenerationwebpage' :
'';
5103 if (($action ==
'createcontainer' && $showlinktolayout) || ($action ==
'createcontainer' && $showlinktoai)) {
5104 print
'<tr><td class="titlefield tdtop">';
5105 if (
$conf->browser->layout ==
'phone') {
5106 print $form->textwithpicto(
'', $htmltext, 1,
'help',
'inline-block', 1, 2,
'tooltipsubstitution');
5109 print $form->textwithpicto($langs->trans(
"PreviewPageContent").
' '.
img_help(2, $langs->trans(
"PreviewPageContent")), $htmltext, 1,
'none',
'inline-block', 1, 2,
'tooltipsubstitution');
5111 print
'</td><td class="tdtop">';
5115 $showlinktolayoutlabel = $langs->trans(
"FillPageWithALayout");
5116 $showlinktoailabel = $langs->trans(
"FillPageWithAIContent");
5117 $htmlname =
'content';
5119 include DOL_DOCUMENT_ROOT.
'/core/tpl/formlayoutai.tpl.php';
5125 if ($action ==
'createcontainer') {
5126 print
'<tr id="pageContent"><td class="tdtop">';
5127 if (!$showlinktolayout || !$showlinktoai) {
5128 if (
$conf->browser->layout ==
'phone') {
5129 print $form->textwithpicto(
'', $htmltext, 1,
'help',
'inline-block', 1, 2,
'tooltipsubstitution');
5132 print $form->textwithpicto($showlinktolayout ?
'' : ($langs->trans(
"PreviewPageContent").
' '.
img_help(2, $langs->trans(
"PreviewPageContent"))), $htmltext, 1,
'none',
'inline-block', 1, 2,
'tooltipsubstitution');
5137 $doleditor =
new DolEditor(
'content',
GETPOST(
'content',
'none'),
'', 200,
'dolibarr_mailings',
'In',
true,
true,
true, 40,
'90%');
5138 $doleditor->Create();
5145 print $langs->trans(
'DateCreation');
5147 print $form->selectDate($pagedatecreation,
'datecreation', 1, 1, 0,
'', 1, 1);
5153 print $langs->trans(
'Author');
5155 if ($pageauthorid > 0) {
5156 $fuser->fetch($pageauthorid);
5157 print $fuser->getNomUrl(-1);
5159 print
'<span class="opacitymedium">'.$langs->trans(
"Unknown").
'</span>';
5164 print
'<tr class="trpublicauthor hidden"><td>';
5165 print $langs->trans(
'PublicAuthorAlias');
5167 print
'<input type="text" class="flat minwidth300" name="WEBSITE_AUTHORALIAS" value="'.dol_escape_htmltag($pageauthoralias).
'" placeholder="'.
dol_escape_htmltag($langs->trans(
"Anonymous")).
'">';
5171 print
'<tr><td class="tdhtmlheader tdtop">';
5172 $htmlhelp = $langs->trans(
"EditTheWebSiteForACommonHeader").
'<br><br>';
5173 $htmlhelp .= $langs->trans(
"Examples").
' :<br>';
5174 $htmlhelp .=
'<span class="small">';
5176 $htmlhelp .=
'</span>';
5177 print $form->textwithpicto($langs->transnoentitiesnoconv(
'HtmlHeaderPage'), $htmlhelp, 1,
'help',
'', 0, 2,
'htmlheadertooltip');
5179 $poscursor = array(
'x' =>
GETPOST(
'htmlheader_x'),
'y' =>
GETPOST(
'htmlheader_y'));
5180 $doleditor =
new DolEditor(
'htmlheader', $pagehtmlheader,
'', 160,
'ace',
'In',
true,
false,
'ace', ROWS_4,
'100%', 0, $poscursor);
5181 print $doleditor->Create(1,
'',
true,
'HTML Header',
'html');
5186 print $langs->trans(
'AllowedInFrames');
5190 print
'<input type="checkbox" class="flat" name="WEBSITE_ALLOWED_IN_FRAMES" value="1"'.($pageallowedinframes ?
'checked="checked"' :
'').
'>';
5196 if ($action ==
'createcontainer') {
5197 $langs->load(
"website");
5199 print
'<div class="center tablecheckboxcreatemanually'.$hiddenmanuallyafterload.
'">';
5201 print
'<input type="submit" class="button small buttonforacesave" name="addcontainer" value="'.$langs->trans(
"Create").
'">';
5202 print
'<input class="button button-cancel small" type="submit" name="preview" value="'.$langs->trans(
"Cancel").
'">';
5208 if (!empty(
$conf->use_javascript_ajax)) {
5209 print
'<input type="radio" name="radiocreatefrom" id="checkboxcreatefromfetching" value="checkboxcreatefromfetching"'.(GETPOST(
'radiocreatefrom') ==
'checkboxcreatefromfetching' ?
' checked' :
'').
'> ';
5211 print
'<label for="checkboxcreatefromfetching"><span class="opacitymediumxx">'.$langs->trans(
"CreateByFetchingExternalPage").
'</span> <span class="small opacitymedium">('.$langs->trans(
"ForAdvancedWebmastersOnly").
')</small></label><br>';
5212 print
'<hr class="tablecheckboxcreatefromfetching'.$hiddenfromfetchingafterload.
'">';
5214 print
info_admin($langs->trans(
"OnlyEditionOfSourceForGrabbedContentFuture"), 0, 0,
'warning tablecheckboxcreatefromfetching'.$hiddenfromfetchingafterload);
5217 print
'<table class="tableforfield centpercent tablecheckboxcreatefromfetching'.$hiddenfromfetchingafterload.
'">';
5218 print
'<tr><td class="titlefield tdtop">';
5219 print $langs->trans(
"URL");
5221 print
'<input class="flat minwidth500 marginbottomonly" type="text" name="externalurl" value="'.dol_escape_htmltag(
GETPOST(
'externalurl',
'alpha')).
'" placeholder="https://externalsite/pagetofetch"> ';
5223 print
'<div class="paddingtop">';
5224 print
'<input class="flat paddingtop paddingright" type="checkbox" name="grabimages" value="1" checked="checked">';
5225 print
'<span class="valignmiddle">'.$langs->trans(
"GrabImagesInto");
5227 print $langs->trans(
"ImagesShouldBeSavedInto").
' ';
5229 $arraygrabimagesinto = array(
'root' => $langs->trans(
"WebsiteRootOfImages"),
'subpage' => $langs->trans(
"SubdirOfPage"));
5230 print $form->selectarray(
'grabimagesinto', $arraygrabimagesinto, GETPOSTISSET(
'grabimagesinto') ?
GETPOST(
'grabimagesinto') :
'root', 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth75 valignmiddle', 1);
5233 print
'<input class="button small" style="margin-top: 5px" type="submit" name="fetchexternalurl" value="'.dol_escape_htmltag($langs->trans(
"FetchAndCreate")).
'">';
5234 print
'<input class="button button-cancel small" type="submit" name="preview" value="'.$langs->trans(
"Cancel").
'">';
5240 if ($action ==
'createcontainer') {
5241 print
'<script type="text/javascript">
5242 jQuery(document).ready(function() {
5243 var disableautofillofalias = 0;
5244 var selectedm = \'\';
5245 var selectedf = \'\';
5247 jQuery("#WEBSITE_TITLE").keyup(function() {
5248 if (disableautofillofalias == 0) {
5249 var valnospecial = jQuery("#WEBSITE_TITLE").val();
5250 valnospecial = valnospecial.replace(/[éèê]/g, \'e\').replace(/[à]/g, \'a\').replace(/[ù]/g, \'u\').replace(/[î]/g, \'i\');
5251 valnospecial = valnospecial.replace(/[ç]/g, \'c\').replace(/[ö]/g, \'o\');
5252 valnospecial = valnospecial.replace(/[^\w]/gi, \'-\').toLowerCase();
5253 valnospecial = valnospecial.replace(/\-+/g, \'-\').replace(/\-$/, \'\');
5254 console.log("disableautofillofalias=0 so we replace WEBSITE_TITLE with "+valnospecial);
5255 jQuery("#WEBSITE_PAGENAME").val(valnospecial);
5258 jQuery("#WEBSITE_PAGENAME").keyup(function() {
5259 if (jQuery("#WEBSITE_PAGENAME").val() == \'\') {
5260 disableautofillofalias = 0;
5262 disableautofillofalias = 1;
5265 jQuery("#WEBSITE_PAGENAME").blur(function() {
5266 if (jQuery("#WEBSITE_PAGENAME").val() == \'\') {
5267 disableautofillofalias = 0;
5268 jQuery("#WEBSITE_TITLE").trigger(\'keyup\');
5272 jQuery("#checkboxcreatefromfetching,#checkboxcreatemanually").click(function() {
5273 console.log("we select a method to create a new container "+jQuery("#checkboxcreatefromfetching:checked").val())
5274 jQuery(".tablecheckboxcreatefromfetching").hide();
5275 jQuery(".tablecheckboxcreatemanually").hide();
5276 if (typeof(jQuery("#checkboxcreatefromfetching:checked").val()) != \'undefined\') {
5277 console.log("show create from spider form");
5278 if (selectedf != \'createfromfetching\') {
5279 jQuery(".tablecheckboxcreatefromfetching").show();
5280 selectedf = \'createfromfetching\';
5283 jQuery(".tablecheckboxcreatefromfetching").hide();
5287 if (typeof(jQuery("#checkboxcreatemanually:checked").val()) != \'undefined\') {
5288 console.log("show create from scratch or template form");
5289 if (selectedm != \'createmanually\') {
5290 jQuery(".tablecheckboxcreatemanually").show();
5291 selectedm = \'createmanually\';
5294 jQuery(".tablecheckboxcreatemanually").hide();
5310if ($action ==
'preview') {
5314if ($action ==
'editfile' || $action ==
'file_manager' || $action ==
'convertimgwebp' || $action ==
'confirmconvertimgwebp') {
5315 print
'<!-- Edit Media -->'.
"\n";
5316 print
'<div class="fichenopadding" style="padding-right: 20px"><br>';
5319 $formalreadyopen = 2;
5321 $url = DOL_URL_ROOT.
'/website/index.php';
5323 include DOL_DOCUMENT_ROOT.
'/core/tpl/filemanager.tpl.php';
5328if ($action ==
'editmenu') {
5329 print
'<!-- Edit Menu -->'.
"\n";
5330 print
'<div class="center">'.$langs->trans(
"FeatureNotYetAvailable").
'</center>';
5333if ($action ==
'editsource') {
5336 $contentforedit =
'';
5340 $contentforedit .= $objectpage->content;
5343 $maxheightwin = 480;
5344 if (isset($_SESSION[
"dol_screenheight"])) {
5345 if ($_SESSION[
"dol_screenheight"] > 680) {
5346 $maxheightwin = (int) $_SESSION[
"dol_screenheight"] - 300;
5348 if ($_SESSION[
"dol_screenheight"] > 800) {
5349 $maxheightwin = (int) $_SESSION[
"dol_screenheight"] - 250;
5353 $poscursor = array(
'x' =>
GETPOST(
'PAGE_CONTENT_x'),
'y' =>
GETPOST(
'PAGE_CONTENT_y'));
5354 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
5355 $doleditor =
new DolEditor(
'PAGE_CONTENT', $contentforedit,
'', $maxheightwin,
'Full',
'',
true,
true,
'ace', ROWS_5,
'40%', 0, $poscursor);
5356 $doleditor->Create(0,
'',
false,
'HTML Source',
'php');
5359if ($action ==
'editcontent') {
5362 $contentforedit =
'';
5366 $contentforedit .= $objectpage->content;
5371 $contentforedit = preg_replace(
'/(<img.*\ssrc=")(?!http|\/viewimage\.php|'.preg_quote(DOL_URL_ROOT,
'/').
'\/viewimage\.php)/',
'\1'.DOL_URL_ROOT.
'/viewimage.php?modulepart=medias&file=', $contentforedit, -1, $nbrep);
5373 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
5374 $poscursor = array(
'x' =>
GETPOST(
'PAGE_CONTENT_x'),
'y' =>
GETPOST(
'PAGE_CONTENT_y'));
5375 $doleditor =
new DolEditor(
'PAGE_CONTENT', $contentforedit,
'', 500,
'Full',
'',
true,
true,
true, ROWS_5,
'90%', 0, $poscursor);
5376 $doleditor->Create(0,
'',
false);
5383if ($mode ==
'replacesite' || $massaction ==
'replace') {
5384 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5385 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5386 print
'<input type="hidden" name="action" value="replacesiteconfirm">';
5387 print
'<input type="hidden" name="mode" value="replacesite">';
5388 print
'<input type="hidden" name="website" value="'.$website->ref.
'">';
5391 print
'<!-- Search page and replace string -->'.
"\n";
5392 print
'<div class="fiche"><br>';
5394 print
load_fiche_titre($langs->trans(
"ReplaceWebsiteContent"),
'',
'search');
5396 print
'<div class="neutral">';
5398 print
'<div class="display-flex"><div class="flex-item">';
5400 print
'<div class="tagtable">';
5402 print
'<div class="tagtr">';
5403 print
'<div class="tagtd paddingrightonly opacitymedium">';
5404 print $langs->trans(
"SearchReplaceInto");
5406 print
'<div class="tagtd">';
5407 print
'<input type="checkbox" class="marginleftonly" id="checkboxoptionpagecontent" name="optionpagecontent" value="content"'.((!GETPOSTISSET(
'buttonreplacesitesearch') ||
GETPOST(
'optionpagecontent',
'aZ09')) ?
' checked' :
'').
'> <label for="checkboxoptionpagecontent" class="tdoverflowmax150onsmartphone inline-block valignmiddle">'.$langs->trans(
"Content").
'</label><br>';
5408 print
'<input type="checkbox" class="marginleftonly" id="checkboxoptionmeta" name="optionmeta" value="meta"'.(GETPOST(
'optionmeta',
'aZ09') ?
' checked' :
'').
'> <label for="checkboxoptionmeta" class="tdoverflowmax150onsmartphone inline-block valignmiddle">'.$langs->trans(
"WEBSITE_PAGENAME").
' | '.$langs->trans(
"Title").
' | '.$langs->trans(
"Description").
' | '.$langs->trans(
"Keywords").
'</label><br>';
5409 print
'<input type="checkbox" class="marginleftonly" id="checkboxoptionsitefiles" name="optionsitefiles" value="sitefiles"'.(GETPOST(
'optionsitefiles',
'aZ09') ?
' checked' :
'').
'> <label for="checkboxoptionsitefiles" class="tdoverflowmax150onsmartphone inline-block valignmiddle">'.$langs->trans(
"GlobalCSSorJS").
'</label><br>';
5413 print
'<div class="tagtr">';
5414 print
'<div class="tagtd paddingrightonly opacitymedium" style="padding-right: 10px !important">';
5415 print $langs->trans(
"SearchString");
5417 print
'<div class="tagtd">';
5418 print
'<input type="text" name="searchstring" value="'.dol_escape_htmltag($searchkey, 0, 0,
'', 1).
'" autofocus>';
5424 print
'</div><div class="flex-item">';
5426 print
'<div class="tagtable">';
5428 print
'<div class="tagtr">';
5429 print
'<div class="tagtd paddingrightonly opacitymedium tdoverflowmax100onsmartphone" style="padding-right: 10px !important">';
5430 print $langs->trans(
"WEBSITE_TYPE_CONTAINER");
5432 print
'<div class="tagtd">';
5433 print
img_picto(
'',
'object_technic',
'class="pictofixedwidth"').
' ';
5434 print $formwebsite->selectTypeOfContainer(
'optioncontainertype', (
GETPOST(
'optioncontainertype',
'alpha') ?
GETPOST(
'optioncontainertype',
'alpha') :
''), 1,
'', 1,
'minwidth125 maxwidth400 widthcentpercentminusx');
5438 print
'<div class="tagtr">';
5439 print
'<div class="tagtd paddingrightonly opacitymedium tdoverflowmax100onsmartphone" style="padding-right: 10px !important">';
5440 print $langs->trans(
"Language");
5442 print
'<div class="tagtd">';
5443 print
img_picto(
'',
'language',
'class="pictofixedwidth"').
' '.$formadmin->select_language(GETPOSTISSET(
'optionlanguage') ?
GETPOST(
'optionlanguage') :
'',
'optionlanguage', 0, array(),
'1', 0, 0,
'minwidth125 maxwidth400 widthcentpercentminusx', 2, 0, 0, array(), 1);
5448 if (
isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire')) {
5449 print
'<div class="tagtr">';
5450 print
'<div class="tagtd paddingrightonly marginrightonly opacitymedium tdoverflowmax100onsmartphone" style="padding-right: 10px !important">';
5451 print $langs->trans(
"Category");
5453 print
'<div class="tagtd">';
5455 print
img_picto(
'',
'category',
'class="pictofixedwidth"').
' '.$form->select_all_categories(Categorie::TYPE_WEBSITE_PAGE, GETPOSTISSET(
'optioncategory') ?
GETPOST(
'optioncategory') :
'',
'optioncategory', 0, 0, 0, 0,
'minwidth125 maxwidth400 widthcentpercentminusx');
5456 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
5464 print
'</div></div>';
5467 print
'<input type="submit" class="button margintoponly" name="buttonreplacesitesearch" value="'.dol_escape_htmltag($langs->trans(
"Search")).
'">';
5473 if ($mode ==
'replacesite') {
5474 print
'<!-- List of search result -->'.
"\n";
5475 print
'<div class="rowsearchresult clearboth">';
5480 if ($listofpages[
'code'] ==
'OK') {
5481 $arrayofselected = is_array($toselect) ? $toselect : array();
5483 $nbtotalofrecords = count($listofpages[
'list']);
5485 $permissiontodelete = $user->hasRight(
'website',
'delete');
5488 $arrayofmassactions = array();
5489 if ($user->hasRight(
'website',
'writephp') && $searchkey) {
5490 $arrayofmassactions[
'replace'] =
img_picto(
'',
'replacement',
'class="pictofixedwidth"').$langs->trans(
"Replace");
5492 if ($user->hasRight(
'website',
'write')) {
5493 $langs->load(
"categories");
5494 $arrayofmassactions[
'setcategory'] =
img_picto(
'',
'category',
'class="pictofixedwidth"').$langs->trans(
"ClassifyInCategory");
5496 if ($user->hasRight(
'website',
'write')) {
5497 $langs->load(
"categories");
5498 $arrayofmassactions[
'delcategory'] =
img_picto(
'',
'category',
'class="pictofixedwidth"').$langs->trans(
"RemoveCategory");
5500 if ($permissiontodelete) {
5501 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
5503 if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete'))) {
5504 $arrayofmassactions = array();
5507 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
5508 $massactionbutton .=
'<div class="massactionother massactionreplace hidden">';
5509 $massactionbutton .= $langs->trans(
"ReplaceString");
5510 $massactionbutton .=
' <input type="text" name="replacestring" value="'.dol_escape_htmltag(
GETPOST(
'replacestring',
'none')).
'">';
5511 $massactionbutton .=
'</div>';
5512 $massactionbutton .=
'<div class="massactionother massactionsetcategory massactiondelcategory hidden">';
5513 $massactionbutton .=
img_picto(
'',
'category',
'class="pictofixedwidth"');
5514 $massactionbutton .= $form->select_all_categories(Categorie::TYPE_WEBSITE_PAGE, GETPOSTISSET(
'setcategory') ?
GETPOST(
'setcategory') :
'',
'setcategory', 64, 0, 0, 0,
'minwidth300 alignstart');
5515 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
5517 $massactionbutton .=
'</div>';
5519 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
5522 $selectedfields =
'';
5523 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
5525 print_barre_liste($langs->trans(
"Results"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'generic', 0,
'',
'', $limit, 1, 1, 1);
5527 $topicmail =
"WebsitePageRef";
5528 $modelmail =
"websitepage_send";
5529 $objecttmp =
new WebsitePage(
$db);
5530 $trackid =
'wsp'.$object->id;
5531 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
5533 $param =
'mode=replacesite&website='.urlencode($website->ref);
5534 $param .=
'&searchstring='.urlencode($searchkey);
5535 if (
GETPOST(
'optionpagecontent')) {
5536 $param .=
'&optionpagecontent=content';
5539 $param .=
'&optionmeta=meta';
5541 if (
GETPOST(
'optionsitefiles')) {
5542 $param .=
'&optionsitefiles=optionsitefiles';
5544 if (
GETPOST(
'optioncontainertype')) {
5545 $param .=
'&optioncontainertype='.GETPOST(
'optioncontainertype',
'aZ09');
5547 if (
GETPOST(
'optionlanguage')) {
5548 $param .=
'&optionlanguage='.GETPOST(
'optionlanguage',
'aZ09');
5550 if (
GETPOST(
'optioncategory')) {
5551 $param .=
'&optioncategory='.GETPOST(
'optioncategory',
'aZ09');
5554 print
'<div class="div-table-responsive-no-min">';
5555 print
'<table class="noborder centpercent">';
5556 print
'<tr class="liste_titre">';
5558 if (
$conf->main_checkbox_left_column) {
5559 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
5561 print
getTitleFieldOfList(
"Type", 0, $_SERVER[
'PHP_SELF'],
'type_container',
'', $param,
'', $sortfield, $sortorder,
'').
"\n";
5562 print
getTitleFieldOfList(
"Page", 0, $_SERVER[
'PHP_SELF'],
'pageurl',
'', $param,
'', $sortfield, $sortorder,
'').
"\n";
5563 print
getTitleFieldOfList(
"Language", 0, $_SERVER[
'PHP_SELF'],
'lang',
'', $param,
'', $sortfield, $sortorder,
'center ').
"\n";
5564 print
getTitleFieldOfList(
"Categories", 0, $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'center ').
"\n";
5566 print
getTitleFieldOfList(
"UserCreation", 0, $_SERVER[
'PHP_SELF'],
'fk_user_creat',
'', $param,
'', $sortfield, $sortorder,
'').
"\n";
5567 print
getTitleFieldOfList(
"DateCreation", 0, $_SERVER[
'PHP_SELF'],
'date_creation',
'', $param,
'', $sortfield, $sortorder,
'center ').
"\n";
5568 print
getTitleFieldOfList(
"DateLastModification", 0, $_SERVER[
'PHP_SELF'],
'tms',
'', $param,
'', $sortfield, $sortorder,
'center ').
"\n";
5571 if (!
$conf->main_checkbox_left_column) {
5572 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
5576 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
5581 foreach ($listofpages[
'list'] as $answerrecord) {
5582 if (is_object($answerrecord) && get_class($answerrecord) ==
'WebsitePage') {
5583 $param =
'?mode=replacesite';
5584 $param .=
'&websiteid='.$website->id;
5585 $param .=
'&optionpagecontent='.GETPOST(
'optionpagecontent',
'aZ09');
5586 $param .=
'&optionmeta='.GETPOST(
'optionmeta',
'aZ09');
5587 $param .=
'&optionsitefiles='.GETPOST(
'optionsitefiles',
'aZ09');
5588 $param .=
'&optioncontainertype='.GETPOST(
'optioncontainertype',
'aZ09');
5589 $param .=
'&optionlanguage='.GETPOST(
'optionlanguage',
'aZ09');
5590 $param .=
'&optioncategory='.GETPOST(
'optioncategory',
'aZ09');
5591 $param .=
'&searchstring='.urlencode($searchkey);
5596 if (
$conf->main_checkbox_left_column) {
5597 print
'<td class="nowrap center">';
5599 print
'<!-- Status of page -->'.
"\n";
5600 if ($massactionbutton || $massaction) {
5602 if (in_array($answerrecord->id, $arrayofselected)) {
5605 print
'<input id="'.$answerrecord->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$answerrecord->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
5611 print
'<td class="nowraponall">';
5613 if (!empty(
$conf->cache[
'type_of_container'][$answerrecord->type_container])) {
5614 print $langs->trans(
$conf->cache[
'type_of_container'][$answerrecord->type_container]);
5616 print $langs->trans($answerrecord->type_container);
5621 $titleofpage = ($answerrecord->title ? $answerrecord->title : $langs->trans(
"NoTitle"));
5622 print
'<td class="tdoverflowmax300" title="'.dol_escape_htmltag($titleofpage).
'">';
5623 print $answerrecord->getNomUrl(1);
5624 print
' <span class="opacitymedium">('.dol_escape_htmltag($titleofpage).
')</span>';
5628 print
'<span class="opacitymedium">'.dol_escape_htmltag($answerrecord->description ? $answerrecord->description : $langs->trans(
"NoDescription")).
'</span>';
5632 print
'<td class="center">';
5637 print
'<td class="center">';
5638 if (
isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire')) {
5640 $existing =
$c->containing($answerrecord->id, Categorie::TYPE_WEBSITE_PAGE,
'object');
5641 if (is_array($existing)) {
5642 foreach ($existing as $tmpcategory) {
5644 print
img_object($langs->trans(
"Category").
' : '.$tmpcategory->label,
'category',
'style="padding-left: 2px; padding-right: 2px; color: #'.($tmpcategory->color !=
'' ? $tmpcategory->color :
'888').
'"');
5652 print
'<td class="center nowraponall">';
5654 $characterMap =
'áàéèëíóúüñùç0123456789';
5655 $nbofwords = str_word_count($textwithouthtml, 0, $characterMap);
5657 print $nbofwords.
' '.$langs->trans(
"words");
5658 $totalnbwords += $nbofwords;
5663 print
'<td class="tdoverflowmax125">';
5664 if (!empty($answerrecord->fk_user_creat)) {
5665 if (empty(
$conf->cache[
'user'][$answerrecord->fk_user_creat])) {
5667 $tmpuser->fetch($answerrecord->fk_user_creat);
5668 $conf->cache[
'user'][$answerrecord->fk_user_creat] = $tmpuser;
5670 $tmpuser =
$conf->cache[
'user'][$answerrecord->fk_user_creat];
5672 print $tmpuser->getNomUrl(-1,
'', 0, 0, 0, 0,
'login');
5677 print
'<td class="center nowraponall">';
5682 print
'<td class="center nowraponall">';
5683 print
dol_print_date($answerrecord->date_modification,
'dayhour');
5687 print
'<td class="tdwebsitesearchresult right nowraponall">';
5689 $urltoedithtmlsource = $_SERVER[
"PHP_SELF"].
'?action=editmeta&token='.newToken().
'&websiteid='.$website->id.
'&pageid='.$answerrecord->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].$param);
5690 if (!$user->hasRight(
'website',
'write')) {
5691 $disabled =
' disabled';
5692 $urltoedithtmlsource =
'';
5694 print
'<a class="editfielda marginleftonly marginrightonly '.$disabled.
'" href="'.$urltoedithtmlsource.
'" title="'.$langs->trans(
"EditPageMeta").
'">'.
img_picto($langs->trans(
"EditPageMeta"),
'pencil-ruler').
'</a>';
5697 $urltoedithtmlsource = $_SERVER[
"PHP_SELF"].
'?action=editsource&token='.newToken().
'&websiteid='.$website->id.
'&pageid='.$answerrecord->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].$param);
5698 if (!$user->hasRight(
'website',
'write')) {
5699 $disabled =
' disabled';
5700 $urltoedithtmlsource =
'';
5702 print
'<a class="editfielda marginleftonly marginrightonly '.$disabled.
'" href="'.$urltoedithtmlsource.
'" title="'.$langs->trans(
"EditHTMLSource").
'">'.
img_picto($langs->trans(
"EditHTMLSource"),
'edit').
'</a>';
5704 print
'<span class="marginleftonly marginrightonly"></span>';
5705 print
ajax_object_onoff($answerrecord,
'status',
'status',
'Enabled',
'Disabled', array(),
'valignmiddle inline-block');
5710 if (!
$conf->main_checkbox_left_column) {
5711 print
'<td class="nowrap center">';
5713 print
'<!-- Status of page -->'.
"\n";
5714 if ($massactionbutton || $massaction) {
5716 if (in_array($answerrecord->id, $arrayofselected)) {
5719 print
'<input id="'.$answerrecord->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$answerrecord->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
5727 '@phan-var-force array{type:string} $answerrecord';
5728 $param =
'?mode=replacesite';
5729 $param .=
'&websiteid='.$website->id;
5730 $param .=
'&optionpagecontent='.GETPOST(
'optionpagecontent',
'aZ09');
5731 $param .=
'&optionmeta='.GETPOST(
'optionmeta',
'aZ09');
5732 $param .=
'&optionsitefiles='.GETPOST(
'optionsitefiles',
'aZ09');
5733 $param .=
'&optioncontainertype='.GETPOST(
'optioncontainertype',
'aZ09');
5734 $param .=
'&optionlanguage='.GETPOST(
'optionlanguage',
'aZ09');
5735 $param .=
'&optioncategory='.GETPOST(
'optioncategory',
'aZ09');
5736 $param .=
'&searchstring='.urlencode($searchkey);
5741 if (
$conf->main_checkbox_left_column) {
5742 print
'<td class="nowrap center">';
5748 $translateofrecordtype = array(
5749 'website_csscontent' =>
'WEBSITE_CSS_INLINE',
5750 'website_jscontent' =>
'WEBSITE_JS_INLINE',
5751 'website_robotcontent' =>
'WEBSITE_ROBOT',
5752 'website_htmlheadercontent' =>
'WEBSITE_HTML_HEADER',
5753 'website_htaccess' =>
'WEBSITE_HTACCESS',
5754 'website_readme' =>
'WEBSITE_README',
5755 'website_manifestjson' =>
'WEBSITE_MANIFEST_JSON'
5757 print
'<span class="opacitymedium">';
5758 if (!empty($translateofrecordtype[$answerrecord[
'type']])) {
5759 print $langs->trans($translateofrecordtype[$answerrecord[
'type']]);
5761 print $answerrecord[
'type'];
5768 $backtopageurl = $_SERVER[
"PHP_SELF"].$param;
5769 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=editcss&token='.newToken().
'&website='.urlencode($website->ref).
'&backtopage='.urlencode($backtopageurl).
'">'.$langs->trans(
"EditCss").
'</a>';
5791 print
'<td class="center nowraponall">';
5800 if (!
$conf->main_checkbox_left_column) {
5801 print
'<td class="nowrap center">';
5809 if (count($listofpages[
'list']) >= 2) {
5811 print
'<tr class="lite_titre">';
5814 if (
$conf->main_checkbox_left_column) {
5815 print
'<td class="nowrap center">';
5821 print $langs->trans(
"Total");
5837 print
'<td class="center nowraponall">';
5838 print $totalnbwords.
' '.$langs->trans(
"words");
5856 if (!
$conf->main_checkbox_left_column) {
5857 print
'<td class="nowrap center">';
5868 print
'<div class="warning">'.$listofpages[
'message'].
'</div>';
5877if ((empty($action) || $action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone') && !in_array($mode, array(
'replacesite'))) {
5878 if ($pageid > 0 && $atleastonepage) {
5884 $objectpage->fetch($pageid);
5886 $jscontent = @file_get_contents($filejs);
5888 $out =
'<!-- Page content '.$filetpl.
' : Div with (Htmlheader/Style of page from database + CSS Of website from file + Page content from database or by include if WEBSITE_SUBCONTAINERSINLINE is on) -->'.
"\n";
5897 $out .=
"\n<html><head>\n";
5898 $out .=
"<!-- htmlheader/style of page from database -->\n";
5901 $out .=
"<!-- htmlheader/style of website from files -->\n";
5919 $out .=
"</head>\n";
5924 $out .=
'<div id="websitecontentundertopmenu" class="websitecontentundertopmenu boostrap-iso">'.
"\n";
5928 $out .=
'<!-- style of website from file -->'.
"\n";
5929 $out .=
'<style scoped>'.
"\n";
5931 $tmpout .=
'/* Include website CSS file */'.
"\n";
5936 $csscontent = ob_get_contents();
5942 $tmpout .=
'/* Include style from the HTML header of page */'.
"\n";
5944 $tmp = preg_split(
'(<style[^>]*>|</style>)', $objectpage->htmlheader);
5945 $tmpstyleinheader =
'';
5947 foreach ($tmp as $valtmp) {
5950 $tmpstyleinheader .= $valtmp.
"\n";
5953 $tmpout .= $tmpstyleinheader.
"\n";
5955 $tmpout = preg_replace(
'/}[\s\n]*body\s*{[^}]+}/ims',
'}', $tmpout);
5957 $out .=
'</style>'.
"\n";
5964 $out .=
'<div id="divbodywebsite" class="bodywebsite bodywebpage-'.$objectpage->ref.
'">'.
"\n";
5966 $newcontent = $objectpage->content;
5973 $filephp = $filetpl;
5976 $savsessionname = session_name();
5977 $savsessionid = $_COOKIE[$savsessionname];
5978 $_COOKIE[$savsessionname] =
'obfuscatedcookie';
5982 $res = include $filephp;
5984 print
"ERROR: Failed to include file '".$filephp.
"'. Try to edit and re-save page with this ID.";
5987 print $e->getMessage();
5989 $newcontent = ob_get_contents();
5993 $_COOKIE[$savsessionname] = $savsessionid;
5999 $newcontent = preg_replace(
'/(div|section|header|main|footer)(\s[^>]*)contenteditable="true"/',
'\1\2', $newcontent);
6006 $out .=
'</div>'.
"\n";
6008 $out .=
'</div> <!-- End div id=websitecontentundertopmenu -->'.
"\n";
6014 $out .=
"\n</body></html>\n";
6016 $out .=
"\n".
'<!-- End page content '.$filetpl.
' -->'.
"\n\n";
6041 if (empty($websitekey) || $websitekey ==
'-1') {
6042 print
'<br><br><div class="center previewnotyetavailable"><span class="">'.$langs->trans(
"NoWebSiteCreateOneFirst").
'</span></div><br><br><br>';
6043 print
'<div class="center"><div class="logo_setup"></div></div>';
6045 print
'<br><br><div class="center previewnotyetavailable"><span class="">'.$langs->trans(
"PreviewOfSiteNotYetAvailable",
$object->ref).
'</span></div><br><br><br>';
6046 print
'<div class="center"><div class="logo_setup"></div></div>';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
global $dolibarr_main_url_root
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input=array(), $morecss='', $htmlname='', $forcenojs=0, $moreparam='', $readonly=0)
On/off button to change a property status of an object This uses the ajax service objectonoff....
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage categories.
Class to manage a WYSIWYG editor.
The LESS compiler and parser.
Class to manage Dolibarr users.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modifylinks=0, $grabimages=1, $grabimagesinto='subpage')
Download all images found into an external URL.
dolStripPhpCode($str, $replacewith='')
Remove PHP code part from a string.
dolWebsiteReplacementOfLinks($website, $content, $removephppart=0, $contenttype='html', $containerid=0)
Convert a page content to have correct links (based on DOL_URL_ROOT) into an html content.
dolKeepOnlyPhpCode($str)
Keep only PHP code part from a HTML string page.
dol_add_file_process($upload_dir, $allowoverwrite=0, $updatesessionordb=0, $keyforsourcefile='addedfile', $savingdocmask='', $link=null, $trackid='', $generatethumbs=1, $object=null, $forceFullTextIndexation='', $mode=0)
Get and save an upload file (for example after submitting a new file in a mail form).
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0, $level=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories)
dol_is_file($pathoffile)
Return if path is a file.
dol_now($mode='gmt')
Return date for now.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_help($usehelpcursor=1, $usealttitle=1)
Show help logo with cursor "?".
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='')
Show information in HTML for admin users or standard users.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled='', $morecss='classlink button bordertransp', $jsonopen='', $jsonclose='', $accesskey='')
Return HTML code to output a button to open a dialog popup box.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
dolButtonToOpenExportDialog($name, $label, $buttonstring, $exportSiteName, $overwriteGitUrl, $website)
Create a dialog with two buttons for export and overwrite of a website.
dolChmod($filepath, $newmask='')
Change mod of a file.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
img_previous($titlealt='default', $moreatt='')
Show previous logo.
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
dol_sanitizeUrl($stringtoclean, $type=1)
Clean a string to use it as an URL (into a href or src attribute)
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_next($titlealt='default', $moreatt='')
Show next logo.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
getDomainFromURL($url, $mode=0)
Function get second level domain name.
getRootURLFromURL($url)
Function root url from a long url For example: https://www.abc.mydomain.com/dir/page....
removeHtmlComment($content)
Function to remove comments into HTML content.
getURLContent($url, $postorget='GET', $param='', $followlocation=1, $addheaders=array(), $allowedschemes=array('http', 'https'), $localurl=0, $ssl_verifypeer=-1, $timeoutconnect=0, $timeoutresponse=0, $otherCurlOptions=array(), $morelogsuffix='')
Function to get a content from an URL (use proxy if proxy defined).
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
getMaxFileSizeArray()
Return the max allowed for file upload.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
dolSaveMasterFile($filemaster)
Save content of a page on disk.
dolSaveLicense($file, $content)
Save content of a page on disk.
checkPHPCode(&$phpfullcodestringold, &$phpfullcodestring)
Check that the new string $phpfullcodestring contains only php code (including <php tag)
dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent)
Save content of a page on disk.
dolSaveReadme($file, $content)
Save content of a page on disk.
dolSaveManifestJson($file, $content)
Save content of a page on disk.
dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper, $object=null)
Save content of the index.php and/or the wrapper.php page.
dolSavePageAlias($filealias, $object, $objectpage)
Save an alias page on disk (A page that include the reference page).
dolSaveHtaccessFile($filehtaccess, $htaccess)
Save content of a page on disk.
dolSaveJsFile($filejs, $jscontent)
Save content of a page on disk.
dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage, $backupold=0)
Save content of a page on disk (page name is generally ID_of_page.php).
showWebsiteTemplates(Website $website, int $refresh)
Show list of themes.
dolSaveCssFile($filecss, $csscontent)
Save content of a page on disk.
dolSaveRobotFile($filerobot, $robotcontent)
Save content of a page on disk.
websiteGetContentPolicyDirectives()
Prepare array of directives for Website.
websiteGetContentPolicySources()
Prepare array of sources for Website.
websiteGetContentPolicyToArray($forceCSP)
Transform a Content Security Policy to an array.
websiteconfigPrepareHead($object)
Prepare array of tabs for Website.