31define(
'NOSCANPOSTFORINJECTION', array(
'PAGE_CONTENT',
'WEBSITE_CSS_INLINE',
'WEBSITE_JS_INLINE',
'WEBSITE_HTML_HEADER',
'htmlheader'));
33define(
'USEDOLIBARREDITOR', 1);
34define(
'FORCE_CKEDITOR', 1);
35if (!defined(
'DISABLE_JS_GRAHP')) {
36 define(
'DISABLE_JS_GRAPH', 1);
42require
'../main.inc.php';
52require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
53require_once DOL_DOCUMENT_ROOT.
'/website/lib/website.lib.php';
54require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
55require_once DOL_DOCUMENT_ROOT.
'/core/lib/website.lib.php';
56require_once DOL_DOCUMENT_ROOT.
'/core/lib/website2.lib.php';
57require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
58require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
59require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
60require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formwebsite.class.php';
61require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
62require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
63require_once DOL_DOCUMENT_ROOT.
'/website/class/website.class.php';
64require_once DOL_DOCUMENT_ROOT.
'/website/class/websitepage.class.php';
65require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
66require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
69$langs->loadLangs(array(
"admin",
"other",
"users",
"website"));
72if (!$user->hasRight(
'website',
'read')) {
76$conf->dol_hide_leftmenu = 1;
82$websitekey =
GETPOST(
'website',
'alpha');
83$page =
GETPOST(
'page',
'alpha');
85$pageref =
GETPOST(
'pageref',
'alphanohtml');
87$action =
GETPOST(
'action',
'aZ09');
88$massaction =
GETPOST(
'massaction',
'alpha');
89$confirm =
GETPOST(
'confirm',
'alpha');
90$cancel =
GETPOST(
'cancel',
'alpha');
91$toselect =
GETPOST(
'toselect',
'array:int');
92$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'websitelist';
93$backtopage =
GETPOST(
'backtopage',
'alpha');
94$optioncss =
GETPOST(
'optioncss',
'aZ');
95$dol_hide_topmenu =
GETPOSTINT(
'dol_hide_topmenu');
96$dol_hide_leftmenu =
GETPOSTINT(
'dol_hide_leftmenu');
97$dol_openinpopup =
GETPOST(
'dol_openinpopup',
'aZ09');
99$type_container =
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'alpha');
100$section_dir =
GETPOST(
'section_dir',
'alpha');
101$file_manager =
GETPOST(
'file_manager',
'alpha');
102$replacesite =
GETPOST(
'replacesite',
'alpha');
103$mode =
GETPOST(
'mode',
'alpha');
105if (
GETPOST(
'deletesite',
'alpha')) {
106 $action =
'deletesite';
108if (
GETPOST(
'delete',
'alpha')) {
111if (
GETPOST(
'preview',
'alpha')) {
114if (
GETPOST(
'createsite',
'alpha')) {
115 $action =
'createsite';
117if (
GETPOST(
'createcontainer',
'alpha')) {
118 $action =
'createcontainer';
120if (
GETPOST(
'editcss',
'alpha')) {
123if (
GETPOST(
'editmenu',
'alpha')) {
124 $action =
'editmenu';
126if (
GETPOST(
'setashome',
'alpha')) {
127 $action =
'setashome';
129if (
GETPOST(
'editmeta',
'alpha')) {
130 $action =
'editmeta';
132if (
GETPOST(
'editsource',
'alpha')) {
133 $action =
'editsource';
135if (
GETPOST(
'editcontent',
'alpha')) {
136 $action =
'editcontent';
138if (
GETPOST(
'exportsite',
'alpha')) {
139 $action =
'exportsite';
142 $action =
'importsite';
144if (
GETPOST(
'createfromclone',
'alpha')) {
145 $action =
'createfromclone';
147if (
GETPOST(
'createpagefromclone',
'alpha')) {
148 $action =
'createpagefromclone';
150if (empty($action) && $file_manager) {
151 $action =
'file_manager';
153if ($action ==
'replacesite' || (empty($action) && $replacesite)) {
154 $mode =
'replacesite';
162$sortfield = (string)
GETPOST(
'sortfield',
'aZ09comma');
163$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
165if (empty($page) || $page == -1) {
168$offset = $limit * $page;
169$pageprev = $page - 1;
170$pagenext = $page + 1;
177$objectpage =
new WebsitePage($db);
179$listofwebsites =
$object->fetchAll(
'ASC',
'position');
182if (!($websiteid > 0) && empty($websitekey) && $action !=
'createsite') {
183 foreach ($listofwebsites as $key => $valwebsite) {
184 $websitekey = $valwebsite->ref;
188if ($websiteid > 0 || $websitekey) {
189 $res =
$object->fetch($websiteid, $websitekey);
199if (($pageid > 0 || $pageref) && $action !=
'addcontainer') {
200 $res = $objectpage->fetch($pageid, (
$object->id > 0 ?
$object->id : null), $pageref);
203 $res = $objectpage->fetch($pageid, (
$object->id > 0 ?
$object->id : null), null, $pageref);
207 if ($res >= 0 &&
$object->id > 0) {
208 if ($objectpage->fk_website !=
$object->id) {
209 if (
$object->fk_default_home > 0) {
210 $res = $objectpage->fetch(
$object->fk_default_home, (
string)
$object->id,
'');
212 $pageid =
$object->fk_default_home;
215 $res = $objectpage->fetch(0, (
string)
$object->id,
'');
217 $objectpage =
new WebsitePage($db);
219 $pageid = $objectpage->id;
223 $pageid = $objectpage->id;
229$atleastonepage =
false;
230if (empty($pageid) && empty($pageref) &&
$object->id > 0 && $action !=
'createcontainer') {
231 $pageid =
$object->fk_default_home;
232 if (empty($pageid)) {
233 $array = $objectpage->fetchAll(
$object->id,
'ASC,ASC',
'type_container,pageurl');
234 if (!is_array($array) && $array < 0) {
235 dol_print_error(
null, $objectpage->error, $objectpage->errors);
237 $atleastonepage = (is_array($array) && count($array) > 0);
241 foreach ($array as $key => $valpage) {
242 if (empty($firstpageid)) {
243 $firstpageid = $valpage->id;
245 if (
$object->fk_default_home && $key ==
$object->fk_default_home) {
246 $homepageid = $valpage->id;
249 $pageid = ($homepageid ? $homepageid : $firstpageid);
254global $dolibarr_main_data_root;
255$pathofwebsite = $dolibarr_main_data_root.($conf->entity > 1 ?
'/'.$conf->entity :
'').
'/website/'.$websitekey;
256$filehtmlheader = $pathofwebsite.
'/htmlheader.html';
257$filecss = $pathofwebsite.
'/styles.css.php';
258$filejs = $pathofwebsite.
'/javascript.js.php';
259$filerobot = $pathofwebsite.
'/robots.txt';
260$filehtaccess = $pathofwebsite.
'/.htaccess';
261$filetpl = $pathofwebsite.
'/page'.$pageid.
'.tpl.php';
262$fileindex = $pathofwebsite.
'/index.php';
263$filewrapper = $pathofwebsite.
'/wrapper.php';
264$filemanifestjson = $pathofwebsite.
'/manifest.json.php';
265$filereadme = $pathofwebsite.
'/README.md';
266$filelicense = $pathofwebsite.
'/LICENSE';
267$filemaster = $pathofwebsite.
'/master.inc.php';
273if ($pageid > 0 && $pageversion > 0) {
274 $filetplversion = $pathofwebsite.
'/page'.((int) $pageid).
'.tpl.php.v'.((int) $pageversion);
276 $filetplversion =
'';
285$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
289$permtouploadfile = $user->hasRight(
'website',
'write');
290$diroutput =
$conf->medias->multidir_output[
$conf->entity];
292$relativepath = $section_dir;
293$upload_dir = preg_replace(
'/\/$/',
'', $diroutput).
'/'.preg_replace(
'/^\//',
'', $relativepath);
295$htmlheadercontentdefault =
'';
296$htmlheadercontentdefault .=
'<link rel="stylesheet" id="google-fonts-css" href="//fonts.googleapis.com/css?family=Open+Sans:300,400,700" />'.
"\n";
297$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";
298$htmlheadercontentdefault .=
'<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>'.
"\n";
299$htmlheadercontentdefault .=
'<script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>'.
"\n";
300$htmlheadercontentdefault .=
'<!--'.
"\n";
301$htmlheadercontentdefault .=
'<script src="/document.php?modulepart=medias&file=css/myfile.css"></script>'.
"\n";
302$htmlheadercontentdefault .=
'<script src="/document.php?modulepart=medias&file=js/myfile.js"></script>'.
"\n";
303$htmlheadercontentdefault .=
'-->'.
"\n";
305$manifestjsoncontentdefault =
'';
306$manifestjsoncontentdefault .=
'{
308 "short_name": "MyWebsite",
311 "display": "standalone",
312 "background_color": "#fff",
313 "description": "A simple Web app.",
315 "src": "images/'.urlencode($website->ref).
'/homescreen48.png",
319 "src": "image/'.urlencode($website->ref).
'/homescreen72.png",
323 "src": "image/'.urlencode($website->ref).
'/homescreen96.png",
327 "src": "image/'.urlencode($website->ref).
'/homescreen144.png",
331 "src": "image/'.urlencode($website->ref).
'/homescreen168.png",
335 "src": "image/'.urlencode($website->ref).
'/homescreen192.png",
339 "related_applications": [{
341 "url": "https://play.google.com/store/apps/details?id=com.nltechno.dolidroidpro"
345$listofpages = array();
348if (
GETPOST(
'optionpcontent')) {
354if (
GETPOST(
'optionsitefiles')) {
355 $algo .=
'sitefiles';
358$searchkey =
GETPOST(
'searchstring',
'restricthtmlallowunvalid');
360if ($sortfield ==
'') {
361 if ($action ==
'file_manager') {
365 $sortfield =
'pageurl';
369'@phan-var-force string $sortfield';
373$otherfilters = array();
375if ($action ==
'replacesite' || $mode ==
'replacesite') {
376 $containertype =
GETPOST(
'optioncontainertype',
'aZ09') !=
'-1' ?
GETPOST(
'optioncontainertype',
'aZ09') :
'';
377 $langcode =
GETPOST(
'optionlanguage',
'aZ09');
379 $otherfilters[
'category'] =
GETPOSTINT(
'optioncategory');
382 $listofpages = getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters, -1);
385$usercanedit = $user->hasRight(
'website',
'write');
386$permissiontoadd = $user->hasRight(
'website',
'write');
387$permissiontodelete = $user->hasRight(
'website',
'delete');
398if (
GETPOST(
'refreshsite',
'alpha') ||
GETPOST(
'refreshsite.x',
'alpha') ||
GETPOST(
'refreshsite_x',
'alpha')) {
399 if ($action ==
'addsite') {
402 if ($action ==
'updatesource') {
406 $pageid =
$object->fk_default_home;
407 if (empty($pageid)) {
408 $array = $objectpage->fetchAll(
$object->id,
'ASC,ASC',
'type_container,pageurl');
409 if (!is_array($array) && $array < 0) {
410 dol_print_error(
null, $objectpage->error, $objectpage->errors);
412 $atleastonepage = (is_array($array) && count($array) > 0);
416 foreach ($array as $key => $valpage) {
417 if (empty($firstpageid)) {
418 $firstpageid = $valpage->id;
420 if (
$object->fk_default_home && $key ==
$object->fk_default_home) {
421 $homepageid = $valpage->id;
424 $pageid = ($homepageid ? $homepageid : $firstpageid);
427if (
GETPOST(
'refreshpage',
'alpha') && !in_array($action, array(
'updatecss'))) {
431if ($cancel && $action ==
'renamefile') {
440 header(
"Location: ".$backtopage);
445$savbacktopage = $backtopage;
446$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')) :
'');
448 $backtopage .=
'&sortfield='.urlencode($sortfield);
451 $backtopage .=
'&sortorder='.urlencode($sortorder);
453if ($dol_hide_topmenu) {
454 $backtopage .=
'&dol_hide_topmenu='.((int) $dol_hide_topmenu);
456if ($dol_hide_leftmenu) {
457 $backtopage .=
'&dol_hide_leftmenu='.((int) $dol_hide_leftmenu);
459if ($dol_openinpopup) {
460 $backtopage .=
'&dol_openinpopup='.urlencode($dol_openinpopup);
462include DOL_DOCUMENT_ROOT.
'/core/actions_linkedfiles.inc.php';
464$backtopage = $savbacktopage;
468if ($action ==
'renamefile') {
469 $action =
'file_manager';
472if ($action ==
'setwebsiteonline' && $usercanedit) {
473 $website->setStatut($website::STATUS_VALIDATED,
null,
'',
'WEBSITE_MODIFY',
'status');
475 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
GETPOST(
'website')).
'&pageid='.
GETPOSTINT(
'websitepage'));
478if ($action ==
'setwebsiteoffline' && $usercanedit) {
479 $result = $website->setStatut($website::STATUS_DRAFT,
null,
'',
'WEBSITE_MODIFY',
'status');
481 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
GETPOST(
'website')).
'&pageid='.
GETPOSTINT(
'websitepage'));
484if ($action ==
'seteditinline') {
487 setEventMessages(
'<span class="editinlineallowedareas">'.$langs->trans(
"EditInLineAllowedAreas").
'</span>',
null,
'warnings');
491 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
GETPOST(
'website')).
'&pageid='.
GETPOSTINT(
'pageid'));
494if ($action ==
'unseteditinline') {
496 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
GETPOST(
'website')).
'&pageid='.
GETPOSTINT(
'pageid'));
499if ($action ==
'setshowsubcontainers') {
502 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
GETPOST(
'website')).
'&pageid='.
GETPOSTINT(
'pageid'));
505if ($action ==
'unsetshowsubcontainers') {
507 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
GETPOST(
'website')).
'&pageid='.
GETPOSTINT(
'pageid'));
511if ($massaction ==
'replace' &&
GETPOST(
'confirmmassaction',
'alpha') && !$searchkey && $usercanedit) {
512 $mode =
'replacesite';
513 $action =
'replacesite';
517if ($action ==
'deletetemplate' && $usercanedit) {
518 $dirthemes = array(
'/doctemplates/websites');
519 if (!empty(
$conf->modules_parts[
'websitetemplates'])) {
520 foreach (
$conf->modules_parts[
'websitetemplates'] as $reldir) {
521 $dirthemes = array_merge($dirthemes, (array) ($reldir.
'doctemplates/websites'));
524 $dirthemes = array_unique($dirthemes);
528 $mode =
'importsite';
529 $action =
'importsite';
531 if (count($dirthemes)) {
533 foreach ($dirthemes as $dir) {
535 $dirtheme = DOL_DATA_ROOT.$dir;
536 if (is_dir($dirtheme)) {
537 $templateuserfile =
GETPOST(
'templateuserfile');
538 $imguserfile = preg_replace(
'/\.zip$/',
'', $templateuserfile).
'.jpg';
547if ($massaction ==
'setcategory' &&
GETPOST(
'confirmmassaction',
'alpha') && $usercanedit) {
554 if ($categoryid > 0) {
555 $tmpwebsitepage =
new WebsitePage($db);
557 $category->fetch($categoryid);
559 foreach ($toselect as $tmpid) {
560 $tmpwebsitepage->id = (int) $tmpid;
561 $result = $category->add_type($tmpwebsitepage,
'website_page');
562 if ($result < 0 && $result != -3) {
564 setEventMessages($category->error, $category->errors,
'errors');
576 setEventMessages($langs->trans(
"RecordsModified", $nbupdate),
null,
'mesgs');
582 $listofpages = getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters, -1);
586if ($massaction ==
'delcategory' &&
GETPOST(
'confirmmassaction',
'alpha') && $usercanedit) {
593 if ($categoryid > 0) {
594 $tmpwebsitepage =
new WebsitePage($db);
596 $category->fetch($categoryid);
598 foreach ($toselect as $tmpid) {
599 $tmpwebsitepage->id = (int) $tmpid;
600 $result = $category->del_type($tmpwebsitepage,
'website_page');
601 if ($result < 0 && $result != -3) {
603 setEventMessages($category->error, $category->errors,
'errors');
615 setEventMessages($langs->trans(
"RecordsModified", $nbupdate),
null,
'mesgs');
621 $listofpages = getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters, -1);
625if ($massaction ==
'replace' &&
GETPOST(
'confirmmassaction',
'alpha') && $usercanedit) {
626 $replacestring =
GETPOST(
'replacestring',
'restricthtmlallowunvalid');
628 $dolibarrdataroot = preg_replace(
'/([\\/]+)$/i',
'', DOL_DATA_ROOT);
629 $allowimportsite =
true;
630 if (
dol_is_file($dolibarrdataroot.
'/installmodules.lock')) {
631 $allowimportsite =
false;
634 if (!$allowimportsite) {
638 $message = $langs->trans(
'InstallModuleFromWebHasBeenDisabledContactUs');
641 $message = $langs->trans(
"InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.
'/installmodules.lock');
643 setEventMessages($message,
null,
'errors');
644 } elseif (!$user->hasRight(
'website',
'writephp')) {
645 setEventMessages(
"NotAllowedToAddDynamicContent",
null,
'errors');
646 } elseif (!$replacestring) {
647 setEventMessages(
"ErrorReplaceStringEmpty",
null,
'errors');
651 foreach ($toselect as $keyselected) {
652 $objectpage = $listofpages[
'list'][$keyselected];
653 if ($objectpage->pageurl) {
654 dol_syslog(
"Replace string into page ".$objectpage->pageurl);
656 if (
GETPOST(
'optionpcontent',
'aZ09')) {
657 $objectpage->content = str_replace($searchkey, $replacestring, $objectpage->content);
659 if (
GETPOST(
'optionmeta',
'aZ09')) {
660 $objectpage->title = str_replace($searchkey, $replacestring, $objectpage->title);
661 $objectpage->description = str_replace($searchkey, $replacestring, $objectpage->description);
662 $objectpage->keywords = str_replace($searchkey, $replacestring, $objectpage->keywords);
665 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
666 $filetpl = $pathofwebsite.
'/page'.$objectpage->id.
'.tpl.php';
671 setEventMessages(
'Failed to write file '.basename($filealias),
null,
'errors');
679 $objectpage->update($user);
682 setEventMessages(
'Failed to write file '.$filetpl,
null,
'errors');
683 $action =
'createcontainer';
689 if ($nbreplacement > 0) {
690 setEventMessages($langs->trans(
"ReplacementDoneInXPages", $nbreplacement),
null,
'mesgs');
693 $containertype =
GETPOST(
'optioncontainertype',
'aZ09') !=
'-1' ?
GETPOST(
'optioncontainertype',
'aZ09') :
'';
694 $langcode =
GETPOST(
'optionlanguage',
'aZ09');
695 $otherfilters = array();
697 $otherfilters[
'category'] =
GETPOSTINT(
'optioncategory');
701 $listofpages = getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters);
731if ($action ==
'addsite' && $usercanedit) {
734 if (
GETPOST(
'virtualhost',
'alpha') && !preg_match(
'/^http/',
GETPOST(
'virtualhost',
'alpha'))) {
736 setEventMessages($langs->trans(
'ErrorURLMustStartWithHttp', $langs->transnoentitiesnoconv(
"VirtualHost")),
null,
'errors');
739 if (!$error && !
GETPOST(
'WEBSITE_REF',
'alpha')) {
741 $langs->load(
"errors");
742 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->transnoentities(
"WebsiteName")),
null,
'errors');
744 if (!$error && !preg_match(
'/^[a-z0-9_\-\.]+$/i',
GETPOST(
'WEBSITE_REF',
'alpha'))) {
746 $langs->load(
"errors");
747 setEventMessages($langs->transnoentities(
"ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities(
"Ref")),
null,
'errors');
752 $arrayotherlang = explode(
',',
GETPOST(
'WEBSITE_OTHERLANG',
'alphanohtml'));
753 foreach ($arrayotherlang as $key => $val) {
755 if (empty(trim($val))) {
758 $arrayotherlang[$key] = substr(trim($val), 0, 2);
762 $tmpobject->ref =
GETPOST(
'WEBSITE_REF',
'alpha');
763 $tmpobject->description =
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml');
764 $tmpobject->lang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
765 $tmpobject->otherlang = implode(
',', $arrayotherlang);
766 $tmpobject->virtualhost =
GETPOST(
'virtualhost',
'alpha');
768 $result = $tmpobject->create($user);
771 setEventMessages($langs->trans(
"ErrorLabelAlreadyExists"),
null,
'errors');
772 } elseif ($result < 0) {
774 setEventMessages($tmpobject->error, $tmpobject->errors,
'errors');
778 if (!$error && $tmpobject !==
null) {
780 setEventMessages($langs->trans(
"SiteAdded",
$object->ref),
null,
'mesgs');
783 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$tmpobject->ref);
787 $action =
'createsite';
796'@phan-var-force int $error';
799if ($action ==
'addcontainer' && $usercanedit) {
804 $objectpage->fk_website =
$object->id;
805 $objectpage->status = $objectpage::STATUS_DRAFT;
808 $urltograb =
GETPOST(
'externalurl',
'alpha');
809 $grabimages =
GETPOSTINT(
'grabimages') ? 1 : 0;
810 $grabimagesinto =
GETPOST(
'grabimagesinto',
'alpha');
812 include_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
815 if (empty($urltograb)) {
817 $langs->load(
"errors");
818 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"URL")),
null,
'errors');
819 $action =
'createcontainer';
820 } elseif (!preg_match(
'/^http/', $urltograb)) {
822 $langs->load(
"errors");
823 setEventMessages(
'Error URL must start with http:// or https://',
null,
'errors');
824 $action =
'createcontainer';
828 $urltograbdirwithoutslash =
'';
829 $urltograbdirrootwithoutslash =
'';
833 $urltograbwithoutdomainandparam = preg_replace(
'/^https?:\/\/[^\/]+\/?/i',
'', $urltograb);
835 $urltograbwithoutdomainandparam = preg_replace(
'/\?.*$/',
'', $urltograbwithoutdomainandparam);
836 if (empty($urltograbwithoutdomainandparam) && !preg_match(
'/\/$/', $urltograb)) {
839 $pageurl =
dol_sanitizeFileName(preg_replace(
'/[\/\.]/',
'-', preg_replace(
'/\/+$/',
'', $urltograbwithoutdomainandparam)));
841 $urltograbdirwithoutslash = dirname($urltograb.
'.');
849 $tmpwebsitepage =
new WebsitePage($db);
850 $result = $tmpwebsitepage->fetch(0, (
string)
$object->id, $pageurl);
852 setEventMessages($langs->trans(
"AliasPageAlreadyExists", $pageurl),
null,
'errors');
854 $action =
'createcontainer';
860 $tmp =
getURLContent($urltograb,
'GET',
'', 1, array(), array(
'http',
'https'), 0);
863 if (!empty($tmp[
'content_type']) && preg_match(
'/ISO-8859-1/', $tmp[
'content_type'])) {
864 if (function_exists(
'mb_check_encoding')) {
865 if (mb_check_encoding($tmp[
'content'],
'ISO-8859-1')) {
867 $tmp[
'content'] = mb_convert_encoding($tmp[
'content'],
'ISO-8859-1',
'UTF-8');
870 setEventMessages(
'Error getting '.$urltograb.
': content seems non valid ISO-8859-1',
null,
'errors');
871 $action =
'createcontainer';
875 setEventMessages(
'Error getting '.$urltograb.
': content seems ISO-8859-1 but functions to convert into UTF-8 are not available in your PHP',
null,
'errors');
876 $action =
'createcontainer';
879 if (empty($tmp[
'content_type']) || (!empty($tmp[
'content_type']) && preg_match(
'/UTF-8/', $tmp[
'content_type']))) {
880 if (function_exists(
'mb_check_encoding')) {
881 if (mb_check_encoding($tmp[
'content'],
'UTF-8')) {
885 setEventMessages(
'Error getting '.$urltograb.
': content seems not a valid UTF-8',
null,
'errors');
886 $action =
'createcontainer';
891 if (!empty($tmp[
'curl_error_no'])) {
893 setEventMessages(
'Error getting '.$urltograb.
': '.$tmp[
'curl_error_msg'],
null,
'errors');
894 $action =
'createcontainer';
895 } elseif ($tmp[
'http_code'] != 200) {
897 setEventMessages(
'Error getting '.$urltograb.
': '.$tmp[
'http_code'],
null,
'errors');
898 $action =
'createcontainer';
917 preg_match(
'/<head>(.*)<\/head>/ims', $tmp[
'content'], $regs);
920 $objectpage->type_container =
'page';
921 $objectpage->pageurl = $pageurl;
922 if (empty($objectpage->pageurl)) {
924 $objectpage->pageurl = $tmpdomain.
'-home';
927 $objectpage->aliasalt =
'';
929 if (preg_match(
'/^(\d+)\-/', basename($urltograb), $regs)) {
930 $objectpage->aliasalt = $regs[1];
934 if (preg_match(
'/<title>(.*)<\/title>/ims', $head, $regtmp)) {
935 $objectpage->title = $regtmp[1];
937 if (preg_match(
'/<meta name="title"[^"]+content="([^"]+)"/ims', $head, $regtmp)) {
938 if (empty($objectpage->title)) {
939 $objectpage->title = $regtmp[1];
942 if (preg_match(
'/<meta name="description"[^"]+content="([^"]+)"/ims', $head, $regtmp)) {
943 $objectpage->description = $regtmp[1];
945 if (preg_match(
'/<meta name="keywords"[^"]+content="([^"]+)"/ims', $head, $regtmp)) {
946 $objectpage->keywords = $regtmp[1];
948 if (preg_match(
'/<html\s+lang="([^"]+)"/ims', $tmp[
'content'], $regtmp)) {
949 $tmplang = explode(
'-', $regtmp[1]);
950 $objectpage->lang = $tmplang[0].(empty($tmplang[1]) ?
'' :
'_'.strtoupper($tmplang[1]));
953 $tmp[
'content'] = preg_replace(
'/\s*<meta name="generator"[^"]+content="([^"]+)"\s*\/?>/ims',
'', $tmp[
'content']);
955 $objectpage->content = $tmp[
'content'];
956 $objectpage->content = preg_replace(
'/^.*<body(\s[^>]*)*>/ims',
'', $objectpage->content);
957 $objectpage->content = preg_replace(
'/<\/body(\s[^>]*)*>.*$/ims',
'', $objectpage->content);
965 $objectpage->htmlheader = $tmp[
'content'];
966 $objectpage->htmlheader = preg_replace(
'/^.*<head(\s[^>]*)*>/ims',
'', $objectpage->htmlheader);
967 $objectpage->htmlheader = preg_replace(
'/<\/head(\s[^>]*)*>.*$/ims',
'', $objectpage->htmlheader);
968 $objectpage->htmlheader = preg_replace(
'/<base(\s[^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
969 $objectpage->htmlheader = preg_replace(
'/<meta http-equiv="content-type"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
970 $objectpage->htmlheader = preg_replace(
'/<meta name="robots"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
971 $objectpage->htmlheader = preg_replace(
'/<meta name="title"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
972 $objectpage->htmlheader = preg_replace(
'/<meta name="description"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
973 $objectpage->htmlheader = preg_replace(
'/<meta name="keywords"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
974 $objectpage->htmlheader = preg_replace(
'/<meta name="generator"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
977 $objectpage->htmlheader = preg_replace(
'/<title>[^<]*<\/title>\n*/ims',
'', $objectpage->htmlheader);
978 $objectpage->htmlheader = preg_replace(
'/<link[^>]*rel="shortcut[^>]*>\n/ims',
'', $objectpage->htmlheader);
979 $objectpage->htmlheader = preg_replace(
'/<link[^>]*rel="alternate[^>]*>\n/ims',
'', $objectpage->htmlheader);
980 $objectpage->htmlheader = preg_replace(
'/<link[^>]*rel="canonical[^>]*>\n/ims',
'', $objectpage->htmlheader);
983 $tmp = $objectpage->htmlheader;
986 preg_match_all(
'/<script([^\.>]+)src=["\']([^"\'>]+)["\']([^>]*)><\/script>/i', $objectpage->htmlheader, $regs);
987 $errorforsubresource = 0;
988 foreach ($regs[0] as $key => $val) {
989 dol_syslog(
"We will grab the script resource found into script tag ".$regs[2][$key]);
991 $linkwithoutdomain = $regs[2][$key];
992 if (preg_match(
'/^\//', $regs[2][$key])) {
993 $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key];
995 $urltograbbis = $urltograbdirwithoutslash.
'/'.$regs[2][$key];
999 if (preg_match(
'/^http/', $regs[2][$key])) {
1000 $urltograbbis = $regs[2][$key];
1001 $linkwithoutdomain = preg_replace(
'/^https?:\/\/[^\/]+\//i',
'', $regs[2][$key]);
1011 if ($domaintograb != $domaintograbbis) {
1043 $tmp = preg_replace(
'/'.preg_quote($regs[0][$key],
'/').
'/i',
'', $tmp);
1045 $objectpage->htmlheader = trim($tmp).
"\n";
1049 $pagecsscontent =
"\n".
'<style>'.
"\n";
1051 preg_match_all(
'/<link([^\.>]+)href=["\']([^"\'>]+\.css[^"\'>]*)["\']([^>]*)>/i', $objectpage->htmlheader, $regs);
1052 $errorforsubresource = 0;
1053 foreach ($regs[0] as $key => $val) {
1054 dol_syslog(
"We will grab the css resources found into link tag ".$regs[2][$key]);
1056 $linkwithoutdomain = $regs[2][$key];
1057 if (preg_match(
'/^\//', $regs[2][$key])) {
1058 $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key];
1060 $urltograbbis = $urltograbdirwithoutslash.
'/'.$regs[2][$key];
1064 if (preg_match(
'/^http/', $regs[2][$key])) {
1065 $urltograbbis = $regs[2][$key];
1066 $linkwithoutdomain = preg_replace(
'/^https?:\/\/[^\/]+\//i',
'', $regs[2][$key]);
1076 if ($domaintograb != $domaintograbbis) {
1080 $tmpgeturl =
getURLContent($urltograbbis,
'GET',
'', 1, array(), array(
'http',
'https'), 0);
1081 if (!empty($tmpgeturl[
'curl_error_no'])) {
1082 $errorforsubresource++;
1083 setEventMessages(
'Error getting link tag url '.$urltograbbis.
': '.$tmpgeturl[
'curl_error_msg'],
null,
'errors');
1084 dol_syslog(
'Error getting '.$urltograbbis.
': '.$tmpgeturl[
'curl_error_msg']);
1085 $action =
'createcontainer';
1086 } elseif ($tmpgeturl[
'http_code'] != 200) {
1087 $errorforsubresource++;
1088 setEventMessages(
'Error getting link tag url '.$urltograbbis.
': '.$tmpgeturl[
'http_code'],
null,
'errors');
1089 dol_syslog(
'Error getting '.$urltograbbis.
': '.$tmpgeturl[
'curl_error_msg']);
1090 $action =
'createcontainer';
1099 $tmpgeturl[
'content'] = preg_replace(
'/\/\*\s+CSS content[a-z\s]*\s+\*\//',
'', $tmpgeturl[
'content']);
1109 $pagecsscontent .=
"\n".
'/* Content of file '.$urltograbbis.
' */'.
"\n";
1111 getAllImages($object, $objectpage, $urltograbbis, $tmpgeturl[
'content'], $action, 1, $grabimages, $grabimagesinto);
1114 include_once DOL_DOCUMENT_ROOT.
'/core/class/lessc.class.php';
1115 $lesscobj =
new Lessc();
1117 $contentforlessc =
".bodywebsite {\n".$tmpgeturl[
'content'].
"\n}\n";
1119 $contentforlessc = $lesscobj->compile($contentforlessc);
1122 $pagecsscontent .= $contentforlessc.
"\n";
1126 dol_syslog(
"Failed to compile the CSS from URL ".$urltograbbis.
" with lessc: ".$e->getMessage(), LOG_WARNING);
1127 $pagecsscontent .= $tmpgeturl[
'content'].
"\n";
1130 $objectpage->htmlheader = preg_replace(
'/'.preg_quote($regs[0][$key],
'/').
'\n*/ims',
'', $objectpage->htmlheader);
1134 $pagecsscontent .=
'</style>';
1138 $objectpage->htmlheader .= trim($pagecsscontent).
"\n";
1142 $tmp = $objectpage->content;
1144 getAllImages($object, $objectpage, $urltograb, $tmp, $action, 1, $grabimages, $grabimagesinto);
1147 $tmp = preg_replace(
'/a href="\/([^\/"]+)\/([^\/"]+)"/',
'a href="/\1-\2.php"', $tmp);
1148 $tmp = preg_replace(
'/a href="\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)"/',
'a href="/\1-\2-\3.php"', $tmp);
1149 $tmp = preg_replace(
'/a href="\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)"/',
'a href="/\1-\2-\3-\4.php"', $tmp);
1152 $objectpage->content = $tmp;
1154 $objectpage->grabbed_from = $urltograb;
1158 $newaliasnames =
'';
1159 if (!$error &&
GETPOST(
'WEBSITE_ALIASALT',
'alpha')) {
1160 $arrayofaliastotest = explode(
',', str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_ALIASALT',
'alpha')));
1161 $websitepagetemp =
new WebsitePage($db);
1162 foreach ($arrayofaliastotest as $aliastotest) {
1163 $aliastotest = trim(preg_replace(
'/\.php$/i',
'', $aliastotest));
1166 if (preg_match(
'/^page\d+/i', $aliastotest)) {
1168 $langs->load(
"errors");
1169 setEventMessages(
"Alias name 'pageX' is not allowed",
null,
'errors');
1170 $action =
'createcontainer';
1173 $result = $websitepagetemp->fetch(0, (
string)
$object->id, $aliastotest);
1176 $langs->load(
"errors");
1177 setEventMessages($websitepagetemp->error, $websitepagetemp->errors,
'errors');
1178 $action =
'createcontainer';
1183 $langs->load(
"errors");
1184 setEventMessages($langs->trans(
"ErrorAPageWithThisNameOrAliasAlreadyExists", $websitepagetemp->pageurl),
null,
'errors');
1185 $action =
'createcontainer';
1188 $newaliasnames .= ($newaliasnames ?
', ' :
'').$aliastotest;
1193 $objectpage->title = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_TITLE',
'alphanohtml'));
1194 $objectpage->type_container =
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'aZ09');
1196 $objectpage->ref = $objectpage->pageurl;
1197 $objectpage->aliasalt = $newaliasnames;
1198 $objectpage->description = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml'));
1199 $objectpage->lang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
1200 $objectpage->otherlang =
GETPOST(
'WEBSITE_OTHERLANG',
'aZ09comma');
1201 $objectpage->image =
GETPOST(
'WEBSITE_IMAGE',
'alpha');
1202 $objectpage->keywords = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_KEYWORDS',
'alphanohtml'));
1203 $objectpage->allowed_in_frames =
GETPOST(
'WEBSITE_ALLOWED_IN_FRAMES',
'aZ09') ? 1 : 0;
1204 $objectpage->htmlheader =
GETPOST(
'htmlheader',
'restricthtmlallowlinkscript');
1206 $objectpage->author_alias =
GETPOST(
'WEBSITE_AUTHORALIAS',
'alphanohtml');
1207 $objectpage->object_type =
GETPOST(
'WEBSITE_OBJECTCLASS');
1208 $objectpage->fk_object =
GETPOST(
'WEBSITE_OBJECTID');
1209 $substitutionarray = array();
1210 $substitutionarray[
'__WEBSITE_CREATED_BY__'] = $user->getFullName($langs);
1223 $pageidfortranslation = (
GETPOSTINT(
'pageidfortranslation') > 0 ?
GETPOSTINT(
'pageidfortranslation') : 0);
1224 if ($pageidfortranslation > 0) {
1226 $objectpagetmp =
new WebsitePage($db);
1227 $objectpagetmp->fetch($pageidfortranslation);
1228 if ($objectpagetmp->fk_page > 0) {
1229 $pageidfortranslation = $objectpagetmp->fk_page;
1232 $objectpage->fk_page = $pageidfortranslation;
1238 $content =
GETPOST(
'content',
'none');
1255 if (empty($objectpage->pageurl)) {
1256 $langs->load(
"errors");
1257 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WEBSITE_PAGENAME")),
null,
'errors');
1259 $action =
'createcontainer';
1260 } elseif (!preg_match(
'/^[a-z0-9\-\_]+$/i', $objectpage->pageurl)) {
1261 $langs->load(
"errors");
1262 setEventMessages($langs->transnoentities(
"ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities(
'WEBSITE_PAGENAME')),
null,
'errors');
1264 $action =
'createcontainer';
1266 if (empty($objectpage->title)) {
1267 $langs->load(
"errors");
1268 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WEBSITE_TITLE")),
null,
'errors');
1270 $action =
'createcontainer';
1272 if ($objectpage->fk_page > 0 && empty($objectpage->lang)) {
1273 $langs->load(
"errors");
1274 setEventMessages($langs->trans(
"ErrorLanguageRequiredIfPageIsTranslationOfAnother"),
null,
'errors');
1276 $action =
'createcontainer';
1278 if ($objectpage->fk_page > 0 && !empty($objectpage->lang)) {
1279 if ($objectpage->lang == $website->lang) {
1280 $langs->load(
"errors");
1281 setEventMessages($langs->trans(
"ErrorLanguageMustNotBeSourceLanguageIfPageIsTranslationOfAnother"),
null,
'errors');
1283 $action =
'createcontainer';
1291 $pageid = $objectpage->create($user);
1294 setEventMessages($objectpage->error, $objectpage->errors,
'errors');
1295 $action =
'createcontainer';
1301 $categoriesarray =
GETPOST(
'categories',
'array:int');
1302 $result = $objectpage->setCategories($categoriesarray);
1311 if (empty(
$object->fk_default_home)) {
1312 $object->fk_default_home = $pageid;
1313 $res =
$object->update($user);
1318 $filetpl = $pathofwebsite.
'/page'.$pageid.
'.tpl.php';
1321 $result =
dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper, $object);
1324 setEventMessages(
'Failed to write file '.$fileindex,
null,
'errors');
1332 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
1333 $filetpl = $pathofwebsite.
'/page'.$objectpage->id.
'.tpl.php';
1338 setEventMessages(
'Failed to write file '.basename($filealias),
null,
'errors');
1344 setEventMessages($langs->trans(
"Saved"),
null,
'mesgs');
1346 setEventMessages(
'Failed to write file '.$filetpl,
null,
'errors');
1347 $action =
'createcontainer';
1354 setEventMessages($langs->trans(
"PageAdded", $objectpage->pageurl),
null,
'mesgs');
1361 $pageid = $objectpage->id;
1367 $pathtomedias = DOL_DATA_ROOT.
'/medias';
1368 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
1370 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
1371 dol_mkdir(dirname($pathtomediasinwebsite));
1372 $result = symlink($pathtomedias, $pathtomediasinwebsite);
1374 $langs->load(
"errors");
1375 setEventMessages($langs->trans(
"ErrorFailedToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias),
null,
'errors');
1384 setEventMessages(
'Failed to write file '.$filemaster,
null,
'errors');
1389 $htmlheadercontent =
"<html>\n";
1390 $htmlheadercontent .= $htmlheadercontentdefault;
1391 $htmlheadercontent .=
"</html>";
1396 $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;}";
1401 $jscontent =
"/* JS content (all pages) */\n";
1406 $robotcontent =
"# Robot file. Generated with Dolibarr\nUser-agent: *\nAllow: /public/\nDisallow: /administrator/";
1411 $htaccesscontent =
"# Order allow,deny\n# Deny from all";
1416 $manifestjsoncontent =
"";
1421 $readmecontent =
"Website generated by Dolibarr ERP CRM";
1426 $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/";
1430 $action =
'preview';
1435if ($action ==
'confirm_deletesite' && $confirm ==
'yes' && $permissiontodelete) {
1445 $res =
$object->delete($user);
1452 if (
GETPOST(
'delete_also_js',
'alpha') ==
'on') {
1453 $pathofwebsitejs = DOL_DATA_ROOT.
'/medias/js/'.
$object->ref;
1457 if (
GETPOST(
'delete_also_medias',
'alpha') ==
'on') {
1458 $pathofwebsitemedias = DOL_DATA_ROOT.
'/medias/image/'.
$object->ref;
1466 setEventMessages($langs->trans(
"SiteDeleted",
$object->ref),
null,
'mesgs');
1468 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
1477if (
GETPOSTISSET(
'pageid') && $action ==
'delete' && $permissiontodelete && !
GETPOST(
'file_manager')) {
1482 $res =
$object->fetch(0, $websitekey);
1485 $res = $objectpage->fetch($pageid, (
string)
$object->id);
1488 $res = $objectpage->delete($user);
1491 setEventMessages($objectpage->error, $objectpage->errors,
'errors');
1497 setEventMessages($langs->trans(
"PageDeleted", $objectpage->pageurl, $websitekey),
null,
'mesgs');
1499 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$websitekey);
1503 dol_print_error($db);
1508 $objectclass =
'WebsitePage';
1512 if (!$error && ($massaction ==
'delete' || ($action ==
'delete' && $confirm ==
'yes')) && $permissiontodelete) {
1515 $objecttmp =
new $objectclass($db);
1517 foreach ($toselect as $toselectid) {
1518 $result = $objecttmp->fetch($toselectid);
1520 $result = $objecttmp->delete($user);
1523 setEventMessages($objecttmp->error, $objecttmp->errors,
'errors');
1530 setEventMessages($objecttmp->error, $objecttmp->errors,
'errors');
1538 setEventMessages($langs->trans(
"RecordsDeleted", $nbok),
null,
'mesgs');
1540 setEventMessages($langs->trans(
"RecordDeleted", $nbok),
null,
'mesgs');
1549 if ($action ==
'delete') {
1550 $mode =
'replacesite';
1551 $action =
'replacesite';
1553 $containertype =
GETPOST(
'optioncontainertype',
'aZ09') !=
'-1' ?
GETPOST(
'optioncontainertype',
'aZ09') :
'';
1554 $langcode =
GETPOST(
'optionlanguage',
'aZ09');
1555 $otherfilters = array();
1557 $otherfilters[
'category'] =
GETPOSTINT(
'optioncategory');
1560 $listofpages = getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters);
1565if ($action ==
'updatecss' && $usercanedit) {
1568 $action =
'editcss';
1570 $res =
$object->fetch(0, $websitekey);
1574 $tmpvirtualhost = preg_replace(
'/\/$/',
'',
GETPOST(
'virtualhost',
'alpha'));
1575 if ($tmpvirtualhost && !preg_match(
'/^http/', $tmpvirtualhost)) {
1577 setEventMessages($langs->trans(
'ErrorURLMustStartWithHttp', $langs->transnoentitiesnoconv(
"VirtualHost")),
null,
'errors');
1578 $action =
'editcss';
1582 $arrayotherlang = explode(
',',
GETPOST(
'WEBSITE_OTHERLANG',
'alphanohtml'));
1583 foreach ($arrayotherlang as $key => $val) {
1585 if (empty(trim($val))) {
1588 $arrayotherlang[$key] = substr(trim($val), 0, 2);
1591 $object->virtualhost = $tmpvirtualhost;
1593 $object->otherlang = implode(
',', $arrayotherlang);
1596 $result =
$object->update($user);
1600 $action =
'editcss';
1606 if (($_FILES[
'addedfile'][
"name"] !=
'')) {
1607 $uploadfolder =
$conf->website->dir_output.
'/'.$websitekey;
1608 if ($_FILES[
'addedfile'][
'type'] !=
'image/png') {
1610 setEventMessages($langs->trans(
'ErrorFaviconType'), array(),
'errors');
1612 $filetoread = realpath(
dol_osencode($_FILES[
'addedfile'][
'tmp_name']));
1613 $filesize = getimagesize($filetoread);
1614 if ($filesize[0] != $filesize[1]) {
1616 setEventMessages($langs->trans(
'ErrorFaviconMustBeASquaredImage'), array(),
'errors');
1618 if (! $error && ($filesize[0] != 16 && $filesize[0] != 32 && $filesize[0] != 64)) {
1620 setEventMessages($langs->trans(
'ErrorFaviconSize'), array(),
'errors');
1628 $action =
'preview';
1630 $backtopage = preg_replace(
'/searchstring=[^&]*/',
'', $backtopage);
1631 header(
"Location: ".$backtopage);
1635 $action =
'editcss';
1650 setEventMessages(
'Failed to write file '.$filemaster,
null,
'errors');
1654 $dataposted = trim(
GETPOST(
'WEBSITE_HTML_HEADER',
'restricthtmlallowlinkscript'));
1656 $dataposted = preg_replace(array(
'/<html>\n*/ims',
'/<\/html>\n*/ims'), array(
'',
''), $dataposted);
1657 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1660 $phpfullcodestringold =
'';
1664 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1666 if (!$errorphpcheck) {
1667 $htmlheadercontent =
'';
1679 $htmlheadercontent .= $dataposted.
"\n";
1688 setEventMessages(
'Failed to write file '.$filehtmlheader,
null,
'errors');
1694 $dataposted = trim(
GETPOST(
'WEBSITE_CSS_INLINE',
'none'));
1695 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1698 $phpfullcodestringold =
'';
1702 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1704 if (!$errorphpcheck) {
1707 $csscontent .=
"<?php // BEGIN PHP\n";
1708 $csscontent .=
'$websitekey=basename(__DIR__);'.
"\n";
1709 $csscontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded\n";
1710 $csscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
1711 $csscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
1712 $csscontent .=
"ob_start();\n";
1713 $csscontent .=
"if (! headers_sent()) { /* because file is included inline when in edit mode and we don't want warning */ \n";
1714 $csscontent .=
"header('Cache-Control: max-age=3600, public, must-revalidate');\n";
1715 $csscontent .=
"header('Content-type: text/css');\n";
1716 $csscontent .=
"}\n";
1717 $csscontent .=
"// END PHP ?>\n";
1719 $csscontent .= $dataposted.
"\n";
1721 $csscontent .=
'<?php // BEGIN PHP'.
"\n";
1722 $csscontent .=
'$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "css");'.
"\n";
1723 $csscontent .=
"// END PHP\n";
1725 dol_syslog(
"Save css content into ".$filecss);
1730 setEventMessages(
'Failed to write file '.$filecss,
null,
'errors');
1737 $dataposted = trim(
GETPOST(
'WEBSITE_JS_INLINE',
'none'));
1738 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1741 $phpfullcodestringold =
'';
1745 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1747 if (!$errorphpcheck) {
1750 $jscontent .=
"<?php // BEGIN PHP\n";
1751 $jscontent .=
'$websitekey=basename(__DIR__);'.
"\n";
1752 $jscontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded\n";
1753 $jscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
1754 $jscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
1755 $jscontent .=
"ob_start();\n";
1756 $jscontent .=
"header('Cache-Control: max-age=3600, public, must-revalidate');\n";
1757 $jscontent .=
"header('Content-type: application/javascript');\n";
1758 $jscontent .=
"// END PHP ?>\n";
1760 $jscontent .= $dataposted.
"\n";
1762 $jscontent .=
'<?php // BEGIN PHP'.
"\n";
1763 $jscontent .=
'$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "js");'.
"\n";
1764 $jscontent .=
"// END PHP\n";
1769 setEventMessages(
'Failed to write file '.$filejs,
null,
'errors');
1775 $dataposted = trim(
GETPOST(
'WEBSITE_ROBOT',
'nohtml'));
1776 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1779 $phpfullcodestringold =
'';
1783 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1785 if (!$errorphpcheck) {
1798 $robotcontent .= $dataposted.
"\n";
1807 setEventMessages(
'Failed to write file '.$filerobot,
null,
'errors');
1813 $dataposted = trim(
GETPOST(
'WEBSITE_HTACCESS',
'nohtml'));
1814 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1817 $phpfullcodestringold =
'';
1821 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1823 if (!$errorphpcheck) {
1825 $htaccesscontent =
'';
1826 $htaccesscontent .= $dataposted.
"\n";
1831 setEventMessages(
'Failed to write file '.$filehtaccess,
null,
'errors');
1841 $dataposted = trim(
GETPOST(
'WEBSITE_MANIFEST_JSON',
'restricthtmlallowunvalid'));
1842 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1845 $phpfullcodestringold =
'';
1849 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1851 if (!$errorphpcheck) {
1852 $manifestjsoncontent =
'';
1854 $manifestjsoncontent .=
"<?php // BEGIN PHP\n";
1855 $manifestjsoncontent .=
'$websitekey=basename(__DIR__);'.
"\n";
1856 $manifestjsoncontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded\n";
1857 $manifestjsoncontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
1858 $manifestjsoncontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
1859 $manifestjsoncontent .=
"ob_start();\n";
1860 $manifestjsoncontent .=
"header('Cache-Control: max-age=3600, public, must-revalidate');\n";
1861 $manifestjsoncontent .=
"header('Content-type: application/manifest+json');\n";
1862 $manifestjsoncontent .=
"// END PHP ?>\n";
1864 $manifestjsoncontent .= $dataposted.
"\n";
1866 $manifestjsoncontent .=
'<?php // BEGIN PHP'.
"\n";
1867 $manifestjsoncontent .=
'$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "manifest");'.
"\n";
1868 $manifestjsoncontent .=
"// END PHP\n";
1873 setEventMessages(
'Failed to write file '.$filemanifestjson,
null,
'errors');
1880 $dataposted = trim(
GETPOST(
'WEBSITE_README',
'nohtml'));
1881 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1884 $phpfullcodestringold =
'';
1888 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1890 if (!$errorphpcheck) {
1891 $readmecontent =
'';
1903 $readmecontent .= $dataposted.
"\n";
1912 setEventMessages(
'Failed to write file '.$filereadme,
null,
'errors');
1919 $dataposted = trim(
GETPOST(
'WEBSITE_LICENSE',
'nohtml'));
1920 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1923 $phpfullcodestringold =
'';
1927 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1929 if (!$errorphpcheck) {
1930 $licensecontent =
'';
1942 $licensecontent .= $dataposted.
"\n";
1951 setEventMessages(
'Failed to write file '.$filelicense,
null,
'errors');
1963 setEventMessages($langs->trans(
"Saved"),
null,
'mesgs');
1967 $action =
'preview';
1969 $backtopage = preg_replace(
'/searchstring=[^&]*/',
'', $backtopage);
1970 header(
"Location: ".$backtopage);
1974 $action =
'editcss';
1981if ($action ==
"updatesecurity" && $usercanedit &&
GETPOST(
"btn_WEBSITE_SECURITY_FORCECSP")) {
1982 $directivecsp =
GETPOST(
"select_identifier_WEBSITE_SECURITY_FORCECSP");
1983 $sourcecsp =
GETPOST(
"select_source_WEBSITE_SECURITY_FORCECSP");
1984 $sourcedatacsp =
GETPOST(
"input_data_WEBSITE_SECURITY_FORCECSP");
1989 if (empty($directivecsp)) {
1992 if ($error || (!isset($sourcecsp) && $directivesarray[$directivecsp][
"data-directivetype"] !=
"none")) {
1996 $directivetype = $directivesarray[$directivecsp][
"data-directivetype"];
1997 if (isset($sourcecsp)) {
1998 $sourcetype = $sourcesarray[$directivetype][$sourcecsp][
"data-sourcetype"];
2000 $securityspstring =
"";
2001 if (isset($sourcetype) && $sourcetype ==
"data") {
2002 $forceCSPArr[$directivecsp][] =
"data:".$sourcedatacsp;
2003 } elseif (isset($sourcetype) && $sourcetype ==
"input") {
2004 if (empty($forceCSPArr[$directivecsp])) {
2005 $forceCSPArr[$directivecsp] = array();
2007 $forceCSPArr[$directivecsp] = array_merge(explode(
" ", $sourcedatacsp), $forceCSPArr[$directivecsp]);
2009 if (empty($forceCSPArr[$directivecsp])) {
2010 $forceCSPArr[$directivecsp] = array();
2012 if (!isset($sourcecsp)) {
2015 array_unshift($forceCSPArr[$directivecsp], $sourcecsp);
2017 foreach ($forceCSPArr as $directive => $sourcekeys) {
2018 if ($securityspstring !=
"") {
2019 $securityspstring .=
"; ";
2022 foreach ($sourcekeys as $key => $source) {
2023 $directivetype = $directivesarray[$directive][
"data-directivetype"];
2024 $sourcetype = $sourcesarray[$directivetype][$source][
"data-sourcetype"];
2025 if (isset($sourcetype) && $sourcetype ==
"quoted") {
2026 $sourcestring .=
" '".$source.
"'";
2027 } elseif ($directivetype !=
"none") {
2028 $sourcestring .=
" ".$source;
2031 $securityspstring .= $directive . $sourcestring;
2041 setEventMessages($langs->trans(
"SecurityPolicySucesfullyAdded"),
null,
'mesgs');
2044 setEventMessages($langs->trans(
"ErrorAddingSecurityPolicy"),
null,
'errors');
2046 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?websiteid='.$websiteid.
"&action=editsecurity");
2050if ($action ==
"updatesecurity" && $usercanedit) {
2052 $res1 = $res2 = $res3 = $res4 = 0;
2053 $securityrp =
GETPOST(
'WEBSITE_'.
$object->id.
'_SECURITY_FORCERP',
'alpha');
2054 $securitysts =
GETPOST(
'WEBSITE_'.
$object->id.
'_SECURITY_FORCESTS',
'alpha');
2055 $securitypp =
GETPOST(
'WEBSITE_'.
$object->id.
'_SECURITY_FORCEPP',
'alpha');
2056 $securitysp =
GETPOST(
'WEBSITE_'.
$object->id.
'_SECURITY_FORCECSP',
'alpha');
2057 $securitycspro =
GETPOST(
'WEBSITE_'.
$object->id.
'_SECURITY_FORCECSPRO',
'alpha');
2065 if ($res1 >= 0 && $res2 >= 0 && $res3 >= 0 && $res4 >= 0 && $res5 >= 0) {
2067 setEventMessages($langs->trans(
"Saved"),
null,
'mesgs');
2070 setEventMessages($langs->trans(
"ErrorSavingChanges"),
null,
'errors');
2074 $action =
'preview';
2076 $backtopage = preg_replace(
'/searchstring=[^&]*/',
'', $backtopage);
2077 header(
"Location: ".$backtopage);
2081 $action =
'editsecurity';
2087if ($action ==
'setashome' && $confirm ==
'yes' && $usercanedit) {
2089 $object->fetch(0, $websitekey);
2092 $object->fk_default_home = $pageid;
2093 $res =
$object->update($user);
2102 $filetpl = $pathofwebsite.
'/page'.$pageid.
'.tpl.php';
2105 $result =
dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper, $object);
2108 setEventMessages($langs->trans(
"Saved"),
null,
'mesgs');
2110 setEventMessages(
'Failed to write file '.$fileindex,
null,
'errors');
2113 $action =
'preview';
2120if ($action ==
'updatemeta' && $usercanedit) {
2123 $result =
$object->fetch(0, $websitekey);
2126 $objectpage->fk_website =
$object->id;
2129 if (!preg_match(
'/^[a-z0-9\-\_]+$/i',
GETPOST(
'WEBSITE_PAGENAME',
'alpha'))) {
2131 $langs->load(
"errors");
2132 setEventMessages($langs->transnoentities(
"ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities(
'WEBSITE_PAGENAME')),
null,
'errors');
2133 $action =
'editmeta';
2136 $res = $objectpage->fetch($pageid, (
string)
$object->id);
2139 setEventMessages(
'Page not found '.$objectpage->error, $objectpage->errors,
'errors');
2143 if (!$error &&
GETPOST(
'WEBSITE_PAGENAME',
'alpha')) {
2144 $websitepagetemp =
new WebsitePage($db);
2145 $result = $websitepagetemp->fetch(-1 * $objectpage->id, (
string)
$object->id,
GETPOST(
'WEBSITE_PAGENAME',
'alpha'));
2148 $langs->load(
"errors");
2149 setEventMessages($websitepagetemp->error, $websitepagetemp->errors,
'errors');
2150 $action =
'editmeta';
2154 $langs->load(
"errors");
2155 setEventMessages($langs->trans(
"ErrorAPageWithThisNameOrAliasAlreadyExists", $websitepagetemp->pageurl),
null,
'errors');
2156 $action =
'editmeta';
2160 $newaliasnames =
'';
2161 if (!$error &&
GETPOST(
'WEBSITE_ALIASALT',
'alpha')) {
2162 $arrayofaliastotest = explode(
',', str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_ALIASALT',
'alpha')));
2164 $websitepagetemp =
new WebsitePage($db);
2165 foreach ($arrayofaliastotest as $aliastotest) {
2166 $aliastotest = trim(preg_replace(
'/\.php$/i',
'', $aliastotest));
2169 if (preg_match(
'/^page\d+/i', $aliastotest)) {
2171 $langs->load(
"errors");
2172 setEventMessages(
"Alias name 'pageX' is not allowed",
null,
'errors');
2173 $action =
'editmeta';
2176 $result = $websitepagetemp->fetch(-1 * $objectpage->id, (
string)
$object->id, $aliastotest);
2179 $langs->load(
"errors");
2180 setEventMessages($websitepagetemp->error, $websitepagetemp->errors,
'errors');
2181 $action =
'editmeta';
2186 $langs->load(
"errors");
2187 setEventMessages($langs->trans(
"ErrorAPageWithThisNameOrAliasAlreadyExists", $websitepagetemp->pageurl),
null,
'errors');
2188 $action =
'editmeta';
2191 $newaliasnames .= ($newaliasnames ?
', ' :
'').$aliastotest;
2197 $objectpage->old_object = clone $objectpage;
2199 $objectpage->title = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_TITLE',
'alphanohtml'));
2200 $objectpage->type_container =
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'aZ09');
2202 $objectpage->aliasalt = $newaliasnames;
2203 $objectpage->lang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
2204 $objectpage->otherlang =
GETPOST(
'WEBSITE_OTHERLANG',
'aZ09comma');
2205 $objectpage->description = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml'));
2206 $objectpage->image =
GETPOST(
'WEBSITE_IMAGE',
'alpha');
2207 $objectpage->keywords = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_KEYWORDS',
'alphanohtml'));
2208 $objectpage->allowed_in_frames =
GETPOST(
'WEBSITE_ALLOWED_IN_FRAMES',
'aZ09') ? 1 : 0;
2209 $objectpage->keep_history =
GETPOSTINT(
'WEBSITE_KEEP_HISTORY');
2210 $objectpage->htmlheader = trim(
GETPOST(
'htmlheader',
'restricthtmlallowlinkscript'));
2211 $objectpage->fk_page = (
GETPOSTINT(
'pageidfortranslation') > 0 ?
GETPOSTINT(
'pageidfortranslation') : 0);
2212 $objectpage->author_alias = trim(
GETPOST(
'WEBSITE_AUTHORALIAS',
'alphanohtml'));
2213 $objectpage->object_type =
GETPOST(
'WEBSITE_OBJECTCLASS',
'alpha');
2214 $objectpage->fk_object =
GETPOST(
'WEBSITE_OBJECTID',
'aZ09');
2217 if ($newdatecreation) {
2218 $objectpage->date_creation = $newdatecreation;
2221 $res = $objectpage->update($user);
2223 $langs->load(
"errors");
2224 if ($db->lasterrno ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
2226 setEventMessages($langs->trans(
"ErrorAPageWithThisNameOrAliasAlreadyExists"),
null,
'errors');
2227 $action =
'editmeta';
2230 setEventMessages($objectpage->error, $objectpage->errors,
'errors');
2231 $action =
'editmeta';
2238 $categoriesarray =
GETPOST(
'categories',
'array:int');
2239 $result = $objectpage->setCategories($categoriesarray);
2253 $filemaster = $pathofwebsite.
'/master.inc.php';
2254 $fileoldalias = $pathofwebsite.
'/'.$objectpage->old_object->pageurl.
'.php';
2255 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
2262 setEventMessages(
'Failed to write file '.$filemaster,
null,
'errors');
2266 if (!empty($fileoldalias)) {
2267 dol_syslog(
"We delete old alias page name=".$fileoldalias.
" to build a new alias page=".$filealias);
2271 if (empty($objectpage->lang) || !in_array($objectpage->lang, explode(
',',
$object->otherlang))) {
2272 $dirname = dirname($fileoldalias);
2273 $filename = basename($fileoldalias);
2274 $sublangs = explode(
',',
$object->otherlang);
2275 foreach ($sublangs as $sublang) {
2279 if (empty(trim($sublang))) {
2282 $fileoldaliassub = $dirname.
'/'.$sublang.
'/'.$filename;
2288 if (!empty($objectpage->old_object->aliasalt)) {
2289 $tmpaltaliases = explode(
',', $objectpage->old_object->aliasalt);
2290 if (is_array($tmpaltaliases)) {
2291 foreach ($tmpaltaliases as $tmpaliasalt) {
2292 dol_syslog(
"We delete old alt alias pages name=".trim($tmpaliasalt));
2296 if (empty($objectpage->lang) || !in_array($objectpage->lang, explode(
',',
$object->otherlang))) {
2297 $dirname = dirname($pathofwebsite.
'/'.trim($tmpaliasalt).
'.php');
2298 $filename = basename($pathofwebsite.
'/'.trim($tmpaliasalt).
'.php');
2299 $sublangs = explode(
',',
$object->otherlang);
2300 foreach ($sublangs as $sublang) {
2304 if (empty(trim($sublang))) {
2307 $fileoldaliassub = $dirname.
'/'.$sublang.
'/'.$filename;
2318 setEventMessages(
'Failed to write file '.$filealias,
null,
'errors');
2321 if (!empty($objectpage->aliasalt)) {
2322 $tmpaltaliases = explode(
',', $objectpage->aliasalt);
2323 if (is_array($tmpaltaliases)) {
2324 foreach ($tmpaltaliases as $tmpaliasalt) {
2325 if (trim($tmpaliasalt)) {
2326 $filealias = $pathofwebsite.
'/'.trim($tmpaliasalt).
'.php';
2329 setEventMessages(
'Failed to write file '.basename($filealias),
null,
'errors');
2340 setEventMessages($langs->trans(
"Saved"),
null,
'mesgs');
2345 $action =
'preview';
2347 $action =
'editmeta';
2350 setEventMessages(
'Failed to write file '.$filetpl,
null,
'errors');
2353 $action =
'preview';
2359if ((($action ==
'updatesource' || $action ==
'updatecontent' || $action ==
'confirm_createfromclone' || $action ==
'confirm_createpagefromclone') || ($action ==
'preview' && (
GETPOST(
'refreshsite') ||
GETPOST(
'refreshpage') ||
GETPOST(
'preview')))) && $usercanedit) {
2360 $object->fetch(0, $websitekey);
2363 if ($action ==
'confirm_createfromclone') {
2366 $objectnew =
new Website($db);
2371 setEventMessages($objectnew->error, $objectnew->errors,
'errors');
2372 $action =
'preview';
2376 setEventMessages(
"ObjectClonedSuccessfuly",
null,
'mesgs');
2379 $pageid =
$object->fk_default_home;
2380 $websitekey =
GETPOST(
'siteref',
'aZ09');
2386 if ($action ==
'confirm_createpagefromclone') {
2387 $istranslation = (
GETPOST(
'is_a_translation',
'aZ09') ==
'on' ? 1 : 0);
2389 if ($istranslation) {
2390 if (
GETPOST(
'newlang',
'aZ09') == $objectpage->lang || !
GETPOST(
'newlang',
'aZ09')) {
2392 setEventMessages($langs->trans(
"LanguageMustNotBeSameThanClonedPage"),
null,
'errors');
2393 $action =
'preview';
2397 setEventMessages($langs->trans(
"WebsiteMustBeSameThanClonedPageIfTranslation"),
null,
'errors');
2398 $action =
'preview';
2406 $pathofwebsitenew = $pathofwebsite;
2408 $tmpwebsite =
new Website($db);
2409 if ($newwebsiteid > 0 && $newwebsiteid !=
$object->id) {
2410 $tmpwebsite->fetch($newwebsiteid);
2411 $pathofwebsitenew = $dolibarr_main_data_root.($conf->entity > 1 ?
'/'.$conf->entity :
'').
'/website/'.$tmpwebsite->ref;
2416 $objectpage =
new WebsitePage($db);
2417 $resultpage = $objectpage->createFromClone($user, $pageid,
GETPOST(
'newpageurl',
'aZ09'), (
GETPOST(
'newlang',
'aZ09') ?
GETPOST(
'newlang',
'aZ09') :
''), $istranslation, $newwebsiteid,
GETPOST(
'newtitle',
'alphanohtml'), $tmpwebsite);
2418 if ($resultpage < 0) {
2420 setEventMessages($objectpage->error, $objectpage->errors,
'errors');
2421 $action =
'createpagefromclone';
2425 $filetpl = $pathofwebsitenew.
'/page'.$resultpage->id.
'.tpl.php';
2426 $fileindex = $pathofwebsitenew.
'/index.php';
2427 $filewrapper = $pathofwebsitenew.
'/wrapper.php';
2436 if (empty($newwebsiteid) || $newwebsiteid ==
$object->id) {
2437 $pageid = $resultpage->id;
2450 $pathtomedias = DOL_DATA_ROOT.
'/medias';
2451 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
2453 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
2454 dol_mkdir(dirname($pathtomediasinwebsite));
2455 $result = symlink($pathtomedias, $pathtomediasinwebsite);
2457 $langs->load(
"errors");
2458 setEventMessages($langs->trans(
"ErrorFailedToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias),
null,
'errors');
2468 $objectpage->fk_website =
$object->id;
2471 $res = $objectpage->fetch($pageid);
2474 if (
$object->fk_default_home > 0) {
2475 $res = $objectpage->fetch(
$object->fk_default_home);
2478 $res = $objectpage->fetch(0, (
string)
$object->id);
2483 if (!$error && $res > 0) {
2484 if ($action ==
'updatesource' || $action ==
'updatecontent') {
2489 $objectpage->content =
GETPOST(
'PAGE_CONTENT',
'none');
2494 $error =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
2497 if ($action ==
'updatesource') {
2498 $action =
'editsource';
2500 if ($action ==
'updatecontent') {
2501 $action =
'editcontent';
2506 $objectpage->content = preg_replace(
'/<head>.*<\/head>/ims',
'', $objectpage->content);
2510 $res = $objectpage->update($user);
2513 setEventMessages($objectpage->error, $objectpage->errors,
'errors');
2514 if ($action ==
'updatesource') {
2515 $action =
'editsource';
2517 if ($action ==
'updatecontent') {
2518 $action =
'editcontent';
2525 $filemaster = $pathofwebsite.
'/master.inc.php';
2527 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
2535 setEventMessages(
'Failed to write the master file file '.$filemaster,
null,
'errors');
2559 setEventMessages(
'Failed to write the alias file '.basename($filealias),
null,
'errors');
2565 setEventMessages($langs->trans(
"Saved"),
null,
'mesgs');
2569 header(
"Location: ".$backtopage);
2572 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$websitekey.
'&pageid='.$pageid);
2576 if ($action ==
'updatesource') {
2577 $action =
'editsource';
2579 if ($action ==
'updatecontent') {
2580 $action =
'editcontent';
2584 setEventMessages(
'Failed to write file '.$filetpl,
null,
'errors');
2585 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$websitekey.
'&pageid='.$pageid);
2592 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$websitekey.
'&pageid='.$pageid);
2597 if (empty($websitekey) || $websitekey ==
'-1') {
2598 setEventMessages($langs->trans(
"NoWebSiteCreateOneFirst"),
null,
'warnings');
2600 setEventMessages($langs->trans(
"NoPageYet"),
null,
'warnings');
2601 setEventMessages($langs->trans(
"YouCanCreatePageOrImportTemplate"),
null,
'warnings');
2607if ($action ==
'deletelang' && $usercanedit) {
2608 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"website_page SET fk_page = NULL";
2609 $sql .=
" WHERE rowid = ".GETPOSTINT(
'deletelangforid');
2612 $resql = $db->query($sql);
2614 setEventMessages($db->lasterror(),
null,
'errors');
2616 $objectpage->fk_page =
null;
2619 $action =
'editmeta';
2624if ($action ==
'exportsite' && $user->hasRight(
'website',
'export')) {
2625 $fileofzip =
$object->exportWebSite();
2628 $file_name = basename($fileofzip);
2629 header(
"Content-Type: application/zip");
2630 header(
"Content-Disposition: attachment; filename=".$file_name);
2631 header(
"Content-Length: ".filesize($fileofzip));
2633 readfile($fileofzip);
2637 $action =
'preview';
2642if ($action ==
'overwritesite' && $user->hasRight(
'website',
'export')) {
2645 $fileofzip =
$object->exportWebSite();
2646 $pathToExport =
GETPOST(
'export_path');
2649 $result =
$object->overwriteTemplate($fileofzip, $pathToExport);
2652 $action =
'preview';
2656 $action =
'preview';
2661if ($action ==
'regeneratesite' && $usercanedit) {
2664 $pathtomedias = DOL_DATA_ROOT.
'/medias';
2665 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
2667 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
2668 dol_mkdir(dirname($pathtomediasinwebsite));
2669 $result = symlink($pathtomedias, $pathtomediasinwebsite);
2671 $langs->load(
"errors");
2672 setEventMessages($langs->trans(
"ErrorFailedToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias),
null,
'errors');
2673 $action =
'preview';
2677 $result =
$object->rebuildWebSiteFiles();
2679 setEventMessages($langs->trans(
"PagesRegenerated", $result),
null,
'mesgs');
2680 $action =
'preview';
2683 $action =
'preview';
2688if ($action ==
'importsiteconfirm' && $usercanedit) {
2689 $dolibarrdataroot = preg_replace(
'/([\\/]+)$/i',
'', DOL_DATA_ROOT);
2690 $allowimportsite =
true;
2691 if (
dol_is_file($dolibarrdataroot.
'/installmodules.lock')) {
2692 $allowimportsite =
false;
2695 if ($allowimportsite) {
2696 if (empty($_FILES) && !
GETPOSTISSET(
'templateuserfile')) {
2697 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"File")),
null,
'errors');
2698 $action =
'importsite';
2700 if (!empty($_FILES) ||
GETPOSTISSET(
'templateuserfile')) {
2703 $pathtomedias = DOL_DATA_ROOT.
'/medias';
2704 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
2706 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
2707 dol_mkdir(dirname($pathtomediasinwebsite));
2708 $result = symlink($pathtomedias, $pathtomediasinwebsite);
2710 $langs->load(
"errors");
2711 setEventMessages($langs->trans(
"ErrorFailedToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias),
null,
'errors');
2712 $action =
'importsite';
2719 $fileofzip = DOL_DATA_ROOT.
'/doctemplates/websites/'.
GETPOST(
'templateuserfile',
'alpha');
2720 } elseif (!empty($_FILES) && is_array($_FILES[
'userfile'])) {
2722 if (is_array($_FILES[
'userfile'][
'tmp_name'])) {
2723 $userfiles = $_FILES[
'userfile'][
'tmp_name'];
2725 $userfiles = array($_FILES[
'userfile'][
'tmp_name']);
2729 foreach ($userfiles as $key => $userfile) {
2730 if (empty($_FILES[
'userfile'][
'tmp_name'][$key])) {
2732 if ($_FILES[
'userfile'][
'error'][$key] == 1 || $_FILES[
'userfile'][
'error'][$key] == 2) {
2733 setEventMessages($langs->trans(
'ErrorFileSizeTooLarge'),
null,
'errors');
2734 $action =
'importsite';
2736 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"File")),
null,
'errors');
2737 $action =
'importsite';
2744 $upload_dir = DOL_DATA_ROOT.
'/doctemplates/websites/';
2758 $action =
'importsite';
2762 $templatewithoutzip = preg_replace(
'/\.zip$/i',
'',
GETPOST(
'templateuserfile'));
2763 $object->setTemplateName($templatewithoutzip);
2765 $result =
$object->importWebSite($fileofzip);
2769 $action =
'importsite';
2774 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.
$object->ref);
2783 $message = $langs->trans(
'InstallModuleFromWebHasBeenDisabledContactUs');
2786 $message = $langs->trans(
"InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.
'/installmodules.lock');
2788 setEventMessages($message,
null,
'errors');
2792$domainname =
'0.0.0.0:8080';
2793$tempdir =
$conf->website->dir_output.
'/'.$websitekey.
'/';
2796if ($action ==
'generatesitemaps' && $usercanedit) {
2798 if ($website->virtualhost) {
2799 $domainname = $website->virtualhost;
2801 if (! preg_match(
'/^http/i', $domainname)) {
2802 $domainname =
'https://'.$domainname;
2805 $domtree =
new DOMDocument(
'1.0',
'UTF-8');
2807 $root = $domtree->createElementNS(
'http://www.sitemaps.org/schemas/sitemap/0.9',
'urlset');
2808 $root->setAttributeNS(
'http://www.w3.org/2000/xmlns/',
'xmlns:xhtml',
'http://www.w3.org/1999/xhtml');
2810 $domtree->formatOutput =
true;
2813 $xmlname =
'sitemap.xml';
2815 $sql =
"SELECT wp.rowid, wp.type_container , wp.pageurl, wp.lang, wp.fk_page, wp.tms as tms,";
2816 $sql .=
" w.virtualhost, w.fk_default_home";
2817 $sql .=
" FROM ".MAIN_DB_PREFIX.
"website_page as wp, ".MAIN_DB_PREFIX.
"website as w";
2818 $sql .=
" WHERE wp.type_container IN ('page', 'blogpost')";
2819 $sql .=
" AND wp.fk_website = w.rowid";
2820 $sql .=
" AND wp.status = ".WebsitePage::STATUS_VALIDATED;
2821 $sql .=
" AND wp.pageurl NOT IN ('404', '500', '501', '503')";
2822 $sql .=
" AND w.ref = '".dol_escape_json($websitekey).
"'";
2823 $sql .=
" ORDER BY wp.tms DESC, wp.rowid DESC";
2824 $resql = $db->query($sql);
2826 $num_rows = $db->num_rows($resql);
2827 if ($num_rows > 0) {
2829 while ($i < $num_rows) {
2830 $objp = $db->fetch_object($resql);
2831 $url = $domtree->createElement(
'url');
2833 $shortlangcode =
'';
2835 $shortlangcode = substr($objp->lang, 0, 2);
2837 if (empty($shortlangcode)) {
2838 $shortlangcode = substr(
$object->lang, 0, 2);
2842 if ($objp->type_container ==
'blogpost') {
2847 $pageurl = $objp->pageurl.
'.php';
2848 if ($objp->fk_default_home == $objp->rowid) {
2851 if ($shortlangcode != substr(
$object->lang, 0, 2)) {
2852 $pageurl = $shortlangcode.
'/'.$pageurl;
2859 $loc = $domtree->createElement(
'loc', $domainname.
'/'.$pageurl);
2860 $lastmod = $domtree->createElement(
'lastmod',
dol_print_date($db->jdate($objp->tms),
'dayrfc',
'gmt'));
2861 $priority = $domtree->createElement(
'priority',
'1');
2863 $url->appendChild($loc);
2864 $url->appendChild($lastmod);
2867 $changefreq = $domtree->createElement(
'changefreq',
'weekly');
2868 $url->appendChild($changefreq);
2871 if ($objp->fk_default_home == $objp->rowid) {
2872 $url->appendChild($priority);
2877 $alternatefound = 0;
2880 $translationof = $objp->fk_page;
2881 if ($translationof) {
2882 $tmppage =
new WebsitePage($db);
2883 $tmppage->fetch($translationof);
2884 if ($tmppage->id > 0) {
2885 $tmpshortlangcode =
'';
2886 if ($tmppage->lang) {
2887 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'', $tmppage->lang);
2889 if (empty($tmpshortlangcode)) {
2890 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'',
$object->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 == $tmppage->id ?
'/' : (($tmpshortlangcode != substr(
$object->lang, 0, 2)) ?
'/'.$tmpshortlangcode :
'').
'/'.$tmppage->pageurl.
'.php'));
2897 $url->appendChild($xhtmllink);
2905 $sql =
'SELECT rowid as id, lang, pageurl from '.MAIN_DB_PREFIX.
'website_page';
2906 $sql .=
" WHERE status = ".((int) WebsitePage::STATUS_VALIDATED).
' AND fk_page IN ('.$db->sanitize($objp->rowid.($translationof ?
", ".$translationof :
"")).
")";
2907 $resqlhastrans = $db->query($sql);
2908 if ($resqlhastrans) {
2909 $num_rows_hastrans = $db->num_rows($resqlhastrans);
2910 if ($num_rows_hastrans > 0) {
2911 while ($objhastrans = $db->fetch_object($resqlhastrans)) {
2912 $tmpshortlangcode =
'';
2913 if ($objhastrans->lang) {
2914 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'', $objhastrans->lang);
2916 if ($tmpshortlangcode != $shortlangcode) {
2917 $xhtmllink = $domtree->createElement(
'xhtml:link',
'');
2918 $xhtmllink->setAttribute(
"rel",
"alternate");
2919 $xhtmllink->setAttribute(
"hreflang", $tmpshortlangcode);
2920 $xhtmllink->setAttribute(
"href", $domainname.($objp->fk_default_home == $objhastrans->id ?
'/' : (($tmpshortlangcode != substr(
$object->lang, 0, 2) ?
'/'.$tmpshortlangcode :
'')).
'/'.$objhastrans->pageurl.
'.php'));
2921 $url->appendChild($xhtmllink);
2928 dol_print_error($db);
2931 if ($alternatefound) {
2933 $xhtmllink = $domtree->createElement(
'xhtml:link',
'');
2934 $xhtmllink->setAttribute(
"rel",
"alternate");
2935 $xhtmllink->setAttribute(
"hreflang", $shortlangcode);
2936 $xhtmllink->setAttribute(
"href", $domainname.
'/'.$pageurl);
2937 $url->appendChild($xhtmllink);
2953 $root->appendChild($url);
2959 if ($addrsswrapper &&
getDolGlobalInt(
'WEBSITE_ADD_RSS_FEED_INTO_SITEMAP')) {
2960 $url = $domtree->createElement(
'url');
2962 $pageurl =
'wrapper.php?rss=1';
2965 $loc = $domtree->createElement(
'loc', $domainname.
'/'.$pageurl);
2968 $url->appendChild($loc);
2969 $url->appendChild($lastmod);
2972 $changefreq = $domtree->createElement(
'changefreq',
'weekly');
2973 $url->appendChild($changefreq);
2976 $root->appendChild($url);
2979 $domtree->appendChild($root);
2981 if ($domtree->save($tempdir.$xmlname)) {
2983 setEventMessages($langs->trans(
"SitemapGenerated", $xmlname),
null,
'mesgs');
2989 dol_print_error($db);
2993 $robotcontent = @file_get_contents($filerobot);
2994 $result = preg_replace(
'/<?php \/\/ BEGIN PHP[^?]END PHP ?>\n/ims',
'', $robotcontent);
2996 $robotcontent = $result;
2998 $robotsitemap =
"Sitemap: ".$domainname.
"/".$xmlname;
2999 $result = strpos($robotcontent,
'Sitemap: ');
3001 $result = preg_replace(
'/Sitemap:.*/', $robotsitemap, $robotcontent);
3002 $robotcontent = $result ? $result : $robotcontent;
3004 $robotcontent .= $robotsitemap.
"\n";
3009 setEventMessages(
'Failed to write file '.$filerobot,
null,
'errors');
3011 $action =
'preview';
3014if ($action ==
'removecspsource' && $usercanedit) {
3017 $sourcecsp = explode(
"_",
GETPOST(
"sourcecsp"));
3018 $directive = $sourcecsp[0];
3019 $sourcekey = isset($sourcecsp[1]) ? $sourcecsp[1] :
null;
3020 $sourcedata = isset($sourcecsp[2]) ? $sourcecsp[2] :
null;
3024 if (empty($directive)) {
3028 if (!empty($directivesarray[$directive])) {
3029 $directivetype = (string) $directivesarray[$directive][
"data-directivetype"];
3030 if (isset($sourcekey)) {
3031 $sourcetype = $sourcesarray[$directivetype][$sourcekey][
"data-sourcetype"];
3035 $securityspstring =
"";
3036 if (!$error && !empty($forceCSPArr)) {
3037 if (isset($sourcekey) && !empty($forceCSPArr[$directive][$sourcekey])) {
3038 unset($forceCSPArr[$directive][$sourcekey]);
3040 if (count($forceCSPArr[$directive]) == 0) {
3041 unset($forceCSPArr[$directive]);
3043 foreach ($forceCSPArr as $directive => $sourcekeys) {
3044 if ($securityspstring !=
"") {
3045 $securityspstring .=
"; ";
3048 foreach ($sourcekeys as $key => $source) {
3049 $directivetype = $directivesarray[$directive][
"data-directivetype"];
3050 $sourcetype = $sourcesarray[$directivetype][$source][
"data-sourcetype"];
3051 if ($sourcetype ==
"quoted") {
3052 $sourcestring .=
" '".$source.
"'";
3054 $sourcestring .=
" ".$source;
3057 $securityspstring .= $directive . $sourcestring;
3067 setEventMessages($langs->trans(
"SecurityPolicySucesfullyRemoved"),
null,
'mesgs');
3070 setEventMessages($langs->trans(
"ErrorRemovingSecurityPolicy"),
null,
'errors');
3073 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?websiteid='.$websiteid.
"&action=editsecurity");
3082$form =
new Form($db);
3089if ($action ==
'confirmgeneratesitemaps') {
3090 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?website='.urlencode($website->ref), $langs->trans(
'ConfirmSitemapsCreation'), $langs->trans(
'ConfirmGenerateSitemaps',
$object->ref),
'generatesitemaps',
'',
"yes", 1);
3091 $action =
'preview';
3094if ($action ==
'confirmsetashome') {
3095 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?website='.urlencode($website->ref).
'&pageid='.((
int) $pageid), $langs->trans(
'SetAsHomePage'), $langs->trans(
'ConfirmSetAsHomePage', $objectpage->pageurl),
'setashome',
'',
"yes", 1);
3096 $action =
'preview';
3098$helpurl =
'EN:Module_Website|FR:Module_Website_FR|ES:Módulo_Website';
3101 '/includes/ace/src/ace.js',
3102 '/includes/ace/src/ext-statusbar.js',
3103 '/includes/ace/src/ext-language_tools.js',
3106$arrayofcss = array();
3109 $arrayofjs[] =
"public/includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js";
3112llxHeader(
'', $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" spellcheck="false">');
3115print
'<!-- Open form common to all pages generated by website/index.php -->'.
"\n";
3116print
'<form action="'.$_SERVER[
"PHP_SELF"].($action ==
'file_manager' ?
'?uploadform=1' :
'').
'" method="POST" enctype="multipart/form-data" class="websiteformtoolbar">'.
"\n";
3117print
'<input type="hidden" name="token" value="'.newToken().
'">';
3118print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
3119print
'<input type="hidden" name="dol_openinpopup" value="'.$dol_openinpopup.
'">';
3121if ($action ==
'createsite') {
3122 print
'<input type="hidden" name="action" value="addsite">';
3124if ($action ==
'createcontainer') {
3125 print
'<input type="hidden" name="action" value="addcontainer">';
3127if ($action ==
'editcss') {
3128 print
'<input type="hidden" name="action" value="updatecss">';
3130if ($action ==
'editmenu') {
3131 print
'<input type="hidden" name="action" value="updatemenu">';
3133if ($action ==
'setashome') {
3134 print
'<input type="hidden" name="action" value="updateashome">';
3136if ($action ==
'editmeta') {
3137 print
'<input type="hidden" name="action" value="updatemeta">';
3139if ($action ==
'editsource') {
3140 print
'<input type="hidden" name="action" value="updatesource">';
3142if ($action ==
'editcontent') {
3143 print
'<input type="hidden" name="action" value="updatecontent">';
3145if ($action ==
'edit') {
3146 print
'<input type="hidden" name="action" value="update">';
3148if ($action ==
'importsite') {
3149 print
'<input type="hidden" name="action" value="importsiteconfirm">';
3151if ($action ==
'file_manager') {
3152 print
'<input type="hidden" name="action" value="file_manager">';
3155 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
3157if ($action ==
'editsecurity') {
3158 print
'<input type="hidden" name="action" value="updatesecurity">';
3165if ($action !=
'preview' && $action !=
'editcontent' && $action !=
'editsource' && !
GETPOST(
'createpagefromclone',
'alphanohtml')) {
3166 $style =
' margin-bottom: 5px;';
3172if (!
GETPOST(
'hide_websitemenu')) {
3173 if (!$user->hasRight(
'website',
'write')) {
3174 $disabled =
' disabled="disabled"';
3176 $disabledexport =
'';
3177 if (!$user->hasRight(
'website',
'export')) {
3178 $disabledexport =
' disabled="disabled"';
3183 $dataroot = DOL_DATA_ROOT.($conf->entity > 1 ?
'/'.$conf->entity :
'').
'/website/'.$websitekey;
3184 if (!empty(
$object->virtualhost)) {
3185 $virtualurl =
$object->virtualhost;
3191 $array = $objectpage->fetchAll(
$object->id,
'ASC,ASC',
'type_container,pageurl');
3194 if (!is_array($array) && $array < 0) {
3195 dol_print_error(
null, $objectpage->error, $objectpage->errors);
3197 $atleastonepage = (is_array($array) && count($array) > 0);
3199 $websitepage =
new WebsitePage($db);
3201 $websitepage->fetch($pageid);
3207 if (!$user->hasRight(
'website',
'write')) {
3208 $disabled =
' disabled="disabled"';
3209 $morecss =
'opacitymedium cursordefault';
3213 print
'<div class="centpercent websitebar'.(GETPOST(
'dol_openinpopup',
'aZ09') ?
' hiddenforpopup' :
'').
'">'.
"\n";
3219 print
'<!-- Toolbar for website -->';
3220 if ($action !=
'file_manager' && $action !=
'editfile') {
3221 print
'<div class="websiteselection hideonsmartphoneimp minwidth75 tdoverflowmax100 inline-block">';
3222 print $langs->trans(
"Website").
': ';
3226 $urltocreatenewwebsite = $_SERVER[
"PHP_SELF"].
'?action=createsite';
3227 if ($user->hasRight(
'website',
'write')) {
3228 print
'<span class="websiteselection paddingrightonly">';
3229 print
'<a href="'.$urltocreatenewwebsite.
'" class=""'.$disabled.
' title="'.
dol_escape_htmltag($langs->trans(
"AddWebsite")).
'"><span class="fa fa-plus-circle valignmiddle btnTitle-icon"><span></a>';
3234 print
'<span class="websiteselection nopaddingrightimp">';
3237 $out .=
'<select name="website" class="minwidth100 width200 maxwidth150onsmartphone" id="website">';
3238 if (empty($listofwebsites)) {
3239 $out .=
'<option value="-1"> </option>';
3244 foreach ($listofwebsites as $key => $valwebsite) {
3245 if (empty($websitekey)) {
3246 if ($action !=
'createsite') {
3247 $websitekey = $valwebsite->ref;
3251 $out .=
'<option value="'.$valwebsite->ref.
'"';
3252 if ($websitekey == $valwebsite->ref) {
3253 $out .=
' selected';
3256 $outoption = (($valwebsite->status == $valwebsite::STATUS_DRAFT) ?
'<span class="opacitymedium">' :
'').$valwebsite->
ref.(($valwebsite->
status == $valwebsite::STATUS_DRAFT) ?
'</span>' :
'');
3257 $out .=
' data-html="'.dol_escape_htmltag($outoption).
'"';
3259 $out .= $valwebsite->ref;
3260 $out .=
'</option>';
3263 $out .=
'</select>';
3266 if (!empty(
$conf->use_javascript_ajax)) {
3267 $out .=
'<script type="text/javascript">';
3268 $out .=
'jQuery(document).ready(function () {';
3269 $out .=
' jQuery("#website").change(function () {';
3270 $out .=
' console.log("We select "+jQuery("#website option:selected").val());';
3271 $out .=
' if (jQuery("#website option:selected").val() == \'-2\') {';
3272 $out .=
' window.location.href = \''.dol_escape_js($urltocreatenewwebsite).
'\';
';
3273 $out .= ' }
else {
';
3274 $out .= ' window.location.href =
"'.$_SERVER["PHP_SELF
"].'?website="+jQuery(
"#website option:selected").val();
';
3278 $out .= '</script>
';
3284 // Switch offline/onine
3285 if (!empty($conf->use_javascript_ajax)) {
3286 print '<span
class=
"websiteselection">
';
3287 // Do not use ajax, we need a refresh of full page when we change status of a website
3288 //print '<div
class=
"inline-block marginrightonly">
';
3289 //print ajax_object_onoff($object, 'status', 'status', 'Online
', 'Offline
', array(), 'valignmiddle
inline-block
', 'statuswebsite
');
3291 if ($website->status == $website::STATUS_DRAFT) {
3292 $text_off = 'Offline
';
3293 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>
';
3295 $text_off = 'Online
';
3296 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>
';
3301 // Refresh / Reload web site (for non javascript browsers)
3302 if (empty($conf->use_javascript_ajax)) {
3303 print '<span
class=
"websiteselection">
';
3304 print '<input
type=
"image" class=
"valignmiddle" src=
"'.img_picto('', 'refresh', '', 0, 1).'" name=
"refreshsite" value=
"'.$langs->trans("Load
").'"'.$disabled.'>
';
3309 print '<span
class=
"websiteselection">
';
3311 if ($websitekey && $websitekey != '-1
' && ($action == 'preview
' || $action == 'createfromclone
' || $action == 'createpagefromclone
' || $action == 'deletesite
')) {
3312 // Edit website properties
3313 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.'>
';
3314 print img_picto('', 'setup
');
3315 print '<span
class=
"hideonsmartphone paddingleft">
'.dol_escape_htmltag($langs->trans("EditCss")).'</span>
';
3319 $importlabel = $langs->trans("ImportSite");
3320 $exportlabel = $langs->trans("ExportSite");
3321 if (!empty($conf->dol_optimize_smallscreen)) {
3322 $importlabel = $langs->trans("Import");
3323 $exportlabel = $langs->trans("Export");
3326 if ($atleastonepage) {
3327 print '<input
type=
"submit" class=
"button bordertransp" disabled=
"disabled" value=
"'.dol_escape_htmltag($importlabel).'" name=
"importsite">
';
3329 print '<input
type=
"submit" class=
"button bordertransp"'.$disabled.' value=
"'.dol_escape_htmltag($importlabel).'" name=
"importsite">
';
3332 // // Export web site
3333 $extraCssClass = getDolGlobalString('WEBSITE_ALLOW_OVERWRITE_GIT_SOURCE
') ? 'hideobject
' : '';
3334 print '<input
type=
"submit" class=
"button bordertransp ' . $extraCssClass . '" ' . $disabledexport . ' value=
"' . dol_escape_htmltag($exportlabel) . '" name=
"exportsite">
';
3336 if (getDolGlobalString('WEBSITE_ALLOW_OVERWRITE_GIT_SOURCE
')) {
3337 // Overwrite template in sources
3338 $overwriteGitUrl = $_SERVER["PHP_SELF"] . '?action=overwritesite&website=
' . urlencode($website->ref);
3339 print dolButtonToOpenExportDialog('exportpopup
', $langs->trans('ExportOptions
'), $langs->trans('ExportSite
'), 'exportsite
', $overwriteGitUrl, $website);
3340 //print '<a href=
"'.$_SERVER["PHP_SELF
"].'?action=overwritesite&website='.urlencode($website->ref).'" class=
"button bordertransp hideobject" title=
"'.dol_escape_htmltag($langs->trans("ExportIntoGIT
").". Directory
".getDolGlobalString('WEBSITE_ALLOW_OVERWRITE_GIT_SOURCE')).'">
'.dol_escape_htmltag($langs->trans("ExportIntoGIT")).'</a>
';
3344 print '<
button type=
"submit" class=
"button bordertransp buttonpictoonly"'.$disabled.' value=
"1" name=
"createfromclone" title=
"'.dol_escape_htmltag($langs->trans("CloneSite
")).'">
'.img_picto('', 'clone_nocolor
', 'class=
"fa-rotate-90"').'</
button>
';
3347 if (!$permissiontodelete) {
3348 $disabled = ' disabled=
"disabled"';
3349 $title = $langs->trans("NotEnoughPermissions");
3352 if ($website->status == $website::STATUS_VALIDATED) {
3353 $disabled = ' disabled=
"disabled"';
3354 $title = $langs->trans("WebsiteMustBeDisabled", $langs->transnoentitiesnoconv($website->LibStatut(0, 0)));
3358 $title = $langs->trans("Delete");
3359 $url = $_SERVER["PHP_SELF"].'?action=deletesite&token=
'.newToken().'&website=
'.urlencode($website->ref);
3362 print '<a href=
"'.$url.'" class=
"button buttonpictoonly buttonDelete bordertransp'.($disabled ? ' disabled' : '').'"'.$disabled.' title=
"'.dol_escape_htmltag($title).'">
'.img_picto('', 'delete', 'class=
""').'</a>
';
3364 // Regenerate all pages
3365 print '<a href=
"'.$_SERVER["PHP_SELF
"].'?action=regeneratesite&token='.newToken().'&website='.urlencode($website->ref).'" class=
"button buttonpictoonly bordertransp"'.$disabled.' title=
"'.dol_escape_htmltag($langs->trans("RegenerateWebsiteContent
")).'"><span
class=
"far fa-hdd"></span></a>
';
3367 // Generate site map
3368 print '<a href=
"'.$_SERVER["PHP_SELF
"].'?action=confirmgeneratesitemaps&token='.newToken().'&website='.urlencode($website->ref).'" class=
"button buttonpictoonly bordertransp"'.$disabled.' title=
"'.dol_escape_htmltag($langs->trans("GenerateSitemaps
")).'"><span
class=
"fa fa-sitemap"></span></a>
';
3370 // Find / replace tool
3371 print '<a href=
"'.$_SERVER["PHP_SELF
"].'?action=replacesite&token='.newToken().'&website='.urlencode($website->ref).'" class=
"button buttonpictoonly bordertransp"'.$disabled.' title=
"'.dol_escape_htmltag($langs->trans("ReplaceWebsiteContent
")).'"><span
class=
"fa fa-search"></span></a>
';
3376 if ($websitekey && $websitekey != '-1
' && ($action == 'preview
' || $action == 'createfromclone
' || $action == 'createpagefromclone
' || $action == 'deletesite
')) {
3377 print '<span
class=
"websiteselection">
';
3379 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, 'classlink
button bordertransp buttonpictoonly
');
3381 if (isModEnabled('category
')) {
3382 //print '<a href=
"'.DOL_URL_ROOT.'/categories/categorie_list.php?leftmenu=website&dol_hide_leftmenu=1&nosearch=1&type=website_page&website='.$website->ref.'" class=
"button bordertransp"'.$disabled.' title=
"'.dol_escape_htmltag($langs->trans("Categories")).'"><span
class=
"fa fa-tags"></span></a>
';
3383 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, 'classlink
button bordertransp buttonpictoonly
');
3389 print '<input
type=
"hidden" name=
"website" id=
"website" value=
"'.$websitekey.'">
';
3393 print '<span
class=
"websitetools">
';
3395 if ($action == 'preview
' || $action == 'createfromclone
' || $action == 'createpagefromclone
' || $action == 'deletesite
') {
3396 $urlext = $virtualurl;
3397 $urlint = $urlwithroot.'/
public/website/index.php?website=
'.$websitekey;
3399 print '<span
class=
"websiteinputurl valignmiddle" id=
"websiteinputurl">
';
3400 $linktotestonwebserver = '<a href=
"'.($virtualurl ? $virtualurl : '#').'" class=
"valignmiddle">
';
3401 $linktotestonwebserver .= '<span
class=
"hideonsmartphone paddingrightonly">
'.$langs->trans("TestDeployOnWeb", $virtualurl).'</span>
'.img_picto('', 'globe
');
3402 $linktotestonwebserver .= '</a>
';
3405 if (empty($object->fk_default_home)) {
3406 $htmltext .= '<br><span
class=
"error">
'.$langs->trans("YouMustDefineTheHomePage").'</span><br><br>
';
3407 } elseif (empty($virtualurl)) {
3408 //$htmltext .= '<br><span
class=
"error">
'.$langs->trans("VirtualHostUrlNotDefined").'</span><br><br>
';
3410 $htmltext .= '<br><center>
'.$langs->trans("GoTo").' <a href=
"'.$virtualurl.'" target=
"_website">
'.$virtualurl.' '.img_picto('', 'url
').'</a></center><br>
';
3412 if (getDolGlobalString('WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER
')) {
3413 $htmltext .= '<!-- Message defined translate key
set into WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER -->
';
3414 $htmltext .= '<br>
'.$langs->trans(getDolGlobalString('WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER
'));
3416 $htmltext .= $langs->trans("ToDeployYourWebsiteOnLiveYouHave3Solutions").'<br><br>
';
3417 $htmltext .= '<div
class=
"titre inline-block">1</div> -
'.$langs->trans("SetHereVirtualHost", $dataroot);
3418 $htmltext .= '<br>
';
3419 $htmltext .= '<br>
'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT);
3420 $htmltext .= '<br>
'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), '{s1}
');
3421 $htmltext = str_replace('{s1}
', DOL_DATA_ROOT.'/website<br>
'.DOL_DATA_ROOT.'/medias
', $htmltext);
3423 $examplewithapache = "<VirtualHost *:80>\n";
3424 $examplewithapache .= '#php_admin_value open_basedir /tmp/:
'.DOL_DOCUMENT_ROOT.':
'.DOL_DATA_ROOT.':/dev/urandom
'."\n";
3425 //$examplewithapache .= '#php_admin_value disable_functions
"exec,passthru,shell_exec,system,popen,proc_open"'."\n"; This is not effective if not in php.ini
3426 $examplewithapache .= "\n";
3427 $examplewithapache .= 'DocumentRoot
"'.DOL_DOCUMENT_ROOT.'"'."\n";
3428 $examplewithapache .= "\n";
3429 $examplewithapache .= '<Directory
"'.DOL_DOCUMENT_ROOT.'">
'."\n";
3430 $examplewithapache .= 'AllowOverride FileInfo Options
3431 Options -Indexes -MultiViews -FollowSymLinks -ExecCGI
3433 </Directory>
'."\n".'
3434 <Directory
"'.DOL_DATA_ROOT.'/website">
3435 AllowOverride FileInfo Options
3436 Options -Indexes -MultiViews +FollowSymLinks -ExecCGI
3438 </Directory>
'."\n".'
3439 <Directory
"'.DOL_DATA_ROOT.'/medias">
3440 AllowOverride FileInfo Options
3441 Options -Indexes -MultiViews -FollowSymLinks -ExecCGI
3445 $examplewithapache .= "\n";
3446 $examplewithapache .= "#ErrorLog /var/log/apache2/".$websitekey."_error_log\n";
3447 $examplewithapache .= "#TransferLog /var/log/apache2/".$websitekey."_access_log\n";
3449 $examplewithapache .= "\n";
3450 $examplewithapache .= "# If you need include the payment page into a frame of the website,\n";
3451 $examplewithapache .= "# you need to make a proxy redirection of URLs required for the payment to your backoffice pages\n";
3452 $examplewithapache .= "#SSLProxyEngine On\n";
3453 $examplewithapache .= "#SSLProxyVerify none\n";
3454 $examplewithapache .= "#SSLProxyCheckPeerCN off\n";
3455 $examplewithapache .= "#SSLProxyCheckPeerName off\n";
3456 $examplewithapache .= "#ProxyPreserveHost Off\n";
3457 $examplewithapache .= '#ProxyPass
"/public/payment/" "'.$urlwithroot.'/public/payment/'."\n
";
3458 $examplewithapache .= '#ProxyPassReverse "/
public/payment/
" "'.$urlwithroot.'/
public/payment/
'."\n";
3459 $examplewithapache .= '#ProxyPass
"/includes/" "'.$urlwithroot.'/includes/'."\n
";
3460 $examplewithapache .= '#ProxyPassReverse "/includes/
" "'.$urlwithroot.'/includes/
'."\n";
3461 $examplewithapache .= '#ProxyPass
"/theme/" "'.$urlwithroot.'/theme/'."\n
";
3462 $examplewithapache .= '#ProxyPassReverse "/theme/
" "'.$urlwithroot.'/theme/
'."\n";
3463 $examplewithapache .= '#ProxyPass
"/core/js/" "'.$urlwithroot.'/core/js/'."\n
";
3464 $examplewithapache .= '#ProxyPassReverse "/core/js/
" "'.$urlwithroot.'/core/js/
'."\n";
3465 $examplewithapache .= "\n";
3467 $examplewithapache .= "</VirtualHost>\n";
3469 $htmltext .= '<br>
'.$langs->trans("ExampleToUseInApacheVirtualHostConfig").':<br>
';
3470 $htmltext .= '<div
class=
"quatrevingtpercent exampleapachesetup wordbreak" spellcheck=
"false">
'.dol_nl2br(dol_escape_htmltag($examplewithapache, 1, 1)).'</div>
';
3472 $htmltext .= '<br>
';
3473 $htmltext .= '<div
class=
"titre inline-block">2</div> -
'.$langs->trans("YouCanAlsoTestWithPHPS");
3474 $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>
';
3475 $htmltext .= ajax_autoselect("cliphpserver");
3476 $htmltext .= '<br>
';
3477 $htmltext .= '<div
class=
"titre inline-block">3</div> -
'.$langs->trans("YouCanAlsoDeployToAnotherWHP");
3479 print $form->textwithpicto($linktotestonwebserver, $htmltext, 1, 'none
', 'valignmiddle
', 0, 3, 'helpvirtualhost
');
3483 if (in_array($action, array('editcss
', 'editmenu
', 'file_manager
', 'editfile
', 'replacesiteconfirm
', 'editsecurity
')) || in_array($mode, array('replacesite
'))) {
3484 if (!$user->hasRight('website
', 'write')) {
3487 if ($action == 'editcss
' || $action == 'editsecurity
') {
3488 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">
';
3490 if (preg_match('/^create/
', $action) && $action != 'file_manager
' && $action != 'replacesite
' && $action != 'replacesiteconfirm
') {
3491 print '<input
type=
"submit" id=
"savefile" class=
"button buttonforacesave button-save small'.$disabled.'" value=
"'.dol_escape_htmltag($langs->trans("Save
")).'" name=
"update">
';
3493 if (preg_match('/^edit/
', $action) && $action != 'file_manager
' && $action != 'editfile
' && $action != 'replacesite
' && $action != 'replacesiteconfirm
') {
3494 print '<input
type=
"submit" id=
"savefile" class=
"button buttonforacesave button-save small'.$disabled.'" value=
"'.dol_escape_htmltag($langs->trans("Save
")).'" name=
"update">
';
3496 if ($action != 'preview
') {
3497 print '<input
type=
"submit" class=
"button button-cancel small" value=
"'.dol_escape_htmltag($langs->trans("Cancel
")).'" name=
"cancel">
';
3504 // Toolbar for pages
3507 if ($websitekey && $websitekey != '-1
' && (!in_array($action, array('editcss
', 'editmenu
', 'importsite
', 'file_manager
', 'editfile
', 'replacesite
', 'replacesiteconfirm
', 'editsecurity
'))) && (!in_array($mode, array('replacesite
'))) && !$file_manager) {
3508 print '</div>
'; // Close current websitebar to open a new one
3510 print '<!-- Toolbar
for websitepage -->
';
3511 print '<div
class=
"centpercent websitebar"'.($style ? ' style=
"'.$style.'"' : '').'>
'."\n";
3513 print '<div
class=
"websiteselection hideonsmartphoneimp minwidth75 tdoverflowmax100 inline-block">
';
3514 print $langs->trans("PageContainer").':
';
3517 // Button Add new web page
3518 if ($user->hasRight('website
', 'write')) {
3519 print '<span
class=
"websiteselection paddingrightonly">
';
3520 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>
';
3526 $s = $formwebsite->selectContainer($website, 'pageid
', $pageid, 0, $action, 'minwidth100 maxwidth200onsmartphone
');
3528 $out .= '<span
class=
"websiteselection nopaddingrightimp">
';
3532 $urltocreatenewpage = $_SERVER["PHP_SELF"].'?action=createcontainer&token=
'.newToken().'&website=
'.urlencode($website->ref);
3534 if (!empty($conf->use_javascript_ajax)) {
3535 $out .= '<script
type=
"text/javascript">
';
3536 $out .= 'jQuery(document).ready(
function () {
';
3537 $out .= ' jQuery(
"#pageid").change(
function () {
';
3538 $out .= ' console.log(
"We select "+jQuery(
"#pageid option:selected").val());
';
3539 $out .= ' if (jQuery(
"#pageid option:selected").val() == \
'-2\') {';
3540 $out .=
' window.location.href = "'.$urltocreatenewpage.
'";';
3541 $out .=
' } else {';
3542 $out .=
' window.location.href = "'.$_SERVER[
"PHP_SELF"].
'?website='.urlencode($website->ref).
'&pageid="+jQuery("#pageid option:selected").val();';
3546 $out .=
'</script>';
3552 if ($pageid > 0 && $websitekey && $websitekey !=
'-1') {
3553 $listofpageversions =
dol_dir_list($pathofwebsite,
'files', 0,
'^page'.((
int) $pageid).
'\.tpl\.php\.v[0-9]+$',
'',
'name', SORT_DESC);
3557 $out .=
'<span class="websiteselection nopaddingrightimp">';
3558 $out .=
'<select name="pageversion" id="pageversion" class="minwidth100 maxwidth200onsmartphone" title="'.dol_escape_htmltag($langs->trans(
"ListOfPageVersions")).
'">';
3559 $out .=
'<option value="0"'.(empty($pageversion) ?
' selected' :
'').
' class="opacitymedium">';
3560 $out .= $langs->trans(
"CurrentPageVersion");
3561 $out .=
'</option>';
3562 foreach ($listofpageversions as $key => $fileversion) {
3563 $versiontimestamp = (int) preg_replace(
'/^page'.((
int) $pageid).
'\.tpl\.php\.v/',
'', $fileversion[
'name']);
3564 if (empty($versiontimestamp)) {
3567 $out .=
'<option value="'.((int) $versiontimestamp).
'"'.($pageversion == $versiontimestamp ?
' selected' :
'').
'>';
3569 $out .=
'</option>';
3571 $out .=
'</select>';
3574 if (!empty(
$conf->use_javascript_ajax)) {
3575 $out .=
'<script type="text/javascript">';
3576 $out .=
'jQuery(document).ready(function () {';
3577 $out .=
' jQuery("#pageversion").change(function () {';
3578 $out .=
' console.log("We select version "+jQuery("#pageversion option:selected").val());';
3579 $out .=
' window.location.href = "'.$_SERVER[
"PHP_SELF"].
'?website='.urlencode($website->ref).
'&pageid='.((int) $pageid).
'&pageversion="+jQuery("#pageversion option:selected").val();';
3582 $out .=
'</script>';
3591 if (!empty(
$conf->use_javascript_ajax)) {
3592 print
'<span class="websiteselection">';
3594 if (
$object->status == $object::STATUS_DRAFT) {
3595 $text_off =
'SetWebsiteOnlineBefore';
3596 if ($websitepage->status == $websitepage::STATUS_DRAFT) {
3597 print
'<span class="valignmiddle disabled opacitymedium">'.img_picto($langs->trans($text_off),
'switch_off',
'', 0, 0, 0,
'', $morecss).
'</span>';
3599 print
'<span class="valignmiddle disabled opacitymedium">'.img_picto($langs->trans($text_off),
'switch_on',
'', 0, 0, 0,
'', $morecss).
'</span>';
3602 if ($objectpage->type_container !=
'setup') {
3603 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);
3610 print
'<span class="websiteselection">';
3612 print
'<input type="image" class="valignmiddle buttonwebsite hideonsmartphone" src="'.img_picto(
'',
'refresh',
'', 0, 1).
'" name="refreshpage" value="'.$langs->trans(
"Load").
'"'.(($action !=
'editsource') ?
'' :
' disabled="disabled"').
'>';
3615 $pagepreviousid = 0;
3618 $sql =
"SELECT MAX(rowid) as pagepreviousid FROM ".MAIN_DB_PREFIX.
"website_page WHERE rowid < ".((int) $pageid).
" AND fk_website = ".((int)
$object->id);
3619 $resql = $db->query($sql);
3621 $obj = $db->fetch_object($resql);
3623 $pagepreviousid = $obj->pagepreviousid;
3626 dol_print_error($db);
3628 $sql =
"SELECT MIN(rowid) as pagenextid FROM ".MAIN_DB_PREFIX.
"website_page WHERE rowid > ".((int) $pageid).
" AND fk_website = ".((int)
$object->id);
3629 $resql = $db->query($sql);
3631 $obj = $db->fetch_object($resql);
3633 $pagenextid = $obj->pagenextid;
3636 dol_print_error($db);
3640 if ($pagepreviousid) {
3641 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>';
3643 print
'<span class="valignmiddle opacitymedium">'.img_previous($langs->trans(
"PreviousContainer")).
'</span>';
3646 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>';
3648 print
'<span class="valignmiddle opacitymedium">'.img_next($langs->trans(
"NextContainer")).
'</span>';
3653 if ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite') {
3655 if (!$user->hasRight(
'website',
'write')) {
3656 $disabled =
' disabled="disabled"';
3660 if ($action ==
'deletesite') {
3662 $formquestion = array(
3663 array(
'type' =>
'checkbox',
'name' =>
'delete_also_js',
'label' => $langs->trans(
"DeleteAlsoJs"),
'value' => 0),
3664 array(
'type' =>
'checkbox',
'name' =>
'delete_also_medias',
'label' => $langs->trans(
"DeleteAlsoMedias"),
'value' => 0),
3669 if ($atleastonepage) {
3670 $langs->load(
"errors");
3671 $formquestion[] = array(
'type' =>
'onecolumn',
'value' =>
'<div class="warning">'.$langs->trans(
"WarningPagesWillBeDeleted").
'</div>');
3674 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteWebsite'),
'',
'confirm_deletesite', $formquestion, 0, 1,
'auto', 580);
3680 if ($action ==
'createfromclone') {
3682 $formquestion = array(
3683 array(
'type' =>
'text',
'name' =>
'siteref',
'label' => $langs->trans(
"WebSite"),
'value' =>
'copy_of_'.$object->ref)
3686 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'CloneSite'),
'',
'confirm_createfromclone', $formquestion, 0, 1, 0);
3691 if ($pageid > 0 && $atleastonepage) {
3693 if ($action ==
'createpagefromclone') {
3695 $preselectedlanguage =
GETPOST(
'newlang',
'aZ09') ?
GETPOST(
'newlang',
'aZ09') : ($objectpage->lang ?:
'');
3696 $onlylang = array();
3697 if ($website->otherlang) {
3698 if (!empty($website->lang)) {
3699 $onlylang[$website->lang] = $website->lang.
' ('.$langs->trans(
"Default").
')';
3701 foreach (explode(
',', $website->otherlang) as $langkey) {
3702 if (empty(trim($langkey))) {
3705 $onlylang[$langkey] = $langkey;
3707 $textifempty = $langs->trans(
"Default");
3709 $onlylang[
'none'] =
'none';
3710 $textifempty = $langs->trans(
"Default");
3713 $formquestion = array(
3714 array(
'type' =>
'hidden',
'name' =>
'sourcepageurl',
'value' => $objectpage->pageurl),
3715 array(
'type' =>
'other',
'tdclass' =>
'fieldrequired',
'name' =>
'newwebsite',
'label' => $langs->trans(
"WebSite"),
'value' => $formwebsite->selectWebsite((
string)
$object->id,
'newwebsite', 0)),
3716 array(
'type' =>
'text',
'tdclass' =>
'maxwidth200 fieldrequired',
'moreattr' =>
'autofocus="autofocus"',
'name' =>
'newtitle',
'label' => $langs->trans(
"WEBSITE_TITLE"),
'value' => $langs->trans(
"CopyOf").
' '.$objectpage->title),
3717 array(
'type' =>
'text',
'tdclass' =>
'maxwidth200',
'name' =>
'newpageurl',
'label' => $langs->trans(
"WEBSITE_PAGENAME"),
'value' =>
'')
3719 if (count($onlylang) > 1) {
3720 $formquestion[] = array(
'type' =>
'checkbox',
'tdclass' =>
'maxwidth200',
'name' =>
'is_a_translation',
'label' => $langs->trans(
"PageIsANewTranslation"),
'value' => 0,
3721 'morecss' =>
'margintoponly',
3722 'moreattr' =>
'onclick="console.log(\'Click on is_a_translation\'); jQuery(\'#newlang\').val(-1).trigger(\'change\');"'
3726 $value = $formadmin->select_language($preselectedlanguage,
'newlang', 0, array(), $textifempty, 0, 0,
'minwidth200', 1, 0, 0, $onlylang, 1);
3727 $formquestion[] = array(
'type' =>
'other',
'name' =>
'newlang',
'label' => $form->textwithpicto($langs->trans(
"Language"), $langs->trans(
"DefineListOfAltLanguagesInWebsiteProperties")),
'value' => $value);
3729 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?website='.
$object->ref.
'&pageid='.$pageid, $langs->trans(
'ClonePage'),
'',
'confirm_createpagefromclone', $formquestion, 0, 1, 0, 550);
3734 print
'<span class="websiteselection">';
3737 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.
'>';
3738 print img_picto(
'',
'setup');
3739 print
'<span class="hideonsmartphone paddingleft">'.dol_escape_htmltag($langs->trans(
"EditPageMeta")).
'</span>';
3743 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?website='.
$object->ref.
'&pageid='.$pageid.($pageversion > 0 ?
'&pageversion='.((int) $pageversion) :
'').
'&action=editsource&token='.
newToken().
'" class="button bordertransp"'.$disabled.
'>';
3744 print img_picto(
'',
'code');
3745 print
'<span class="hideonsmartphone paddingleft">'.dol_escape_htmltag($langs->trans(
$conf->dol_optimize_smallscreen ?
"HTML" :
"EditHTMLSource")).
'</span>';
3750 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?website='.
$object->ref.
'&pageid='.$pageid.
'&action=editcontent&token='.
newToken().
'" class="button bordertransp"'.$disabled.
'>'.
dol_escape_htmltag(
"CKEditor").
'</a>';
3752 print
'<!-- Add option WEBSITE_ALLOW_CKEDITOR to allow ckeditor -->';
3759 print
'<!-- button EditInLine and ShowSubcontainers -->'.
"\n";
3760 print
'<div class="websiteselectionsection inline-block">';
3763 if ($objectpage->type_container ==
'setup') {
3767 if ($objectpage->type_container !=
'setup') {
3768 print
'<div class="inline-block marginrightonly">';
3769 print $langs->trans(
"ShowSubcontainers");
3771 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>';
3773 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>';
3778 print
'<div class="inline-block marginrightonly">';
3780 print
'<span id="switchckeditorinline">';
3781 print $langs->trans(
"EditInLine");
3788 if (
getDolGlobalString(
'WEBSITE_EDITINLINE') && empty($filetplversion) && $usercanedit) {
3789 $editinlineelements = array();
3791 $editinlineelements[
$id] = array(
3792 'mode' => $element[
'mode'],
3793 'blocks' => $element[
'blocks'],
3794 'error' => ($element[
'error'] ? $langs->transnoentitiesnoconv($element[
'error'],
$id) :
'')
3800 $(document).ready(function() {
3801 setTimeout(function() {
3802 $(".jnotify-notification").has(".editinlineallowedareas").fadeOut(500, function() { $(this).remove(); });
3807 print
'<!-- Code to enable edit inline of elements with contenteditable="true" -->'.
"\n";
3809 .bodywebsite .dol-edit-text, .bodywebsite .dol-edit-html { outline: 1px dashed #888; outline-offset: 2px; cursor: text; }
3810 .bodywebsite .dol-edit-text:focus, .bodywebsite .dol-edit-html:focus { outline: 2px solid #4a90d9; }
3811 .bodywebsite .dol-edit-refused { outline: 1px dashed #c66; outline-offset: 2px; cursor: not-allowed; }
3814 $(document).ready(function() {
3815 var editInlineElements = '.json_encode($editinlineelements, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT).
';
3817 // Save the new content of an element with ajax
3818 function saveEditInline(element, data, callback) {
3819 console.log("Element "+element.id+" was modified, we send new content for update with ajax");
3820 data.page_id = '.((int) $websitepage->id).
';
3821 data.element_id = element.id;
3825 url: \
''.dol_escape_js(DOL_URL_ROOT.
'/core/ajax/editinline.php').
'\',
3828 }).done(function(response) {
3830 $.jnotify(response.message,
"ok");
3831 }).
fail(
function(xhr) {
3832 $.jnotify((xhr.responseJSON && xhr.responseJSON.error) ? xhr.responseJSON.error : \
''.
dol_escape_js($langs->trans(
"Error")).
' \'+xhr.status, "error", true);
3836 function refuseEditInline(element, message) {
3837 console.warn(message);
3838 element.contentEditable = "false";
3839 $(element).addClass("dol-edit-refused").attr("title", message);
3842 $("#websitecontentundertopmenu [contenteditable=\"true\"]").each(function() {
3844 var tag = element.tagName.toLowerCase();
3846 refuseEditInline(element, \''.
dol_escape_js($langs->transnoentitiesnoconv(
"ErrorEditInlineElementNoId")).
'\');
3849 if (!Object.prototype.hasOwnProperty.call(editInlineElements, element.id)) {
3850 // Element not found into the source of the page (it may come from an included container)
3851 refuseEditInline(element, \''.
dol_escape_js($langs->transnoentitiesnoconv(
"ErrorEditInlineElementNotFound",
"__ID__")).
'\'.replace("__ID__", element.id));
3854 var info = editInlineElements[element.id];
3856 refuseEditInline(element, info.error);
3860 if (typeof CKEDITOR !== "undefined" && CKEDITOR.dtd.$editable[tag]) {
3861 // Edit with CKEditor. Allow only the tags accepted when saving, see dolWebsiteCheckEditInlineHtml().
3862 var allowedcontent = "a[!href,target,rel,title]{*}(*); b i u s em strong sub sup span[title]{*}(*); br";
3865 ["Bold", "Italic", "Underline", "Strike", "Subscript", "Superscript", "-", "RemoveFormat"],
3867 ["Font", "FontSize"],
3868 ["TextColor", "BGColor"]
3871 allowedcontent += "; p h1 h2 h3 h4 h5 h6 ul ol li blockquote div[title]{*}(*)";
3872 toolbar.splice(2, 0, ["NumberedList", "BulletedList", "-", "Blockquote"], ["JustifyLeft", "JustifyCenter", "JustifyRight", "JustifyBlock"]);
3873 toolbar.splice(5, 1, ["Format", "Font", "FontSize"]);
3875 var editor = CKEDITOR.inline(element, {
3876 allowedContent: allowedcontent,
3878 format_tags: "p;h1;h2;h3;h4;h5;h6",
3879 removePlugins: "flash,stylescombo,exportpdf,scayt,wsc,pagebreak,iframe,smiley",
3882 $(element).addClass("dol-edit-html");
3883 editor.on("blur", function() {
3884 if (!editor.checkDirty()) {
3887 saveEditInline(element, {action: "updateElementHtml", content: editor.getData()}, function() {
3888 editor.resetDirty();
3891 } else if (info.mode == "text") {
3892 // Edit as plain text. Replace the content with the text as it is rendered, because the line feeds
3893 // and spaces of the source are no more collapsed once the element is editable as plain text.
3894 element.innerText = element.innerText;
3896 element.contentEditable = "plaintext-only";
3898 // Browser without support of plaintext-only: keep "true", paste is converted into text below
3900 $(element).addClass("dol-edit-text").data("dolEditText", element.innerText);
3902 refuseEditInline(element, \''.
dol_escape_js($langs->transnoentitiesnoconv(
"ErrorEditInlineElementNotPlainText",
"__ID__")).
'\'.replace("__ID__", element.id));
3906 $("#websitecontentundertopmenu").on("paste", ".dol-edit-text", function(e) {
3908 document.execCommand("insertText", false, e.originalEvent.clipboardData.getData("text/plain"));
3911 $("#websitecontentundertopmenu").on("keydown", ".dol-edit-text", function(e) {
3912 if (e.key === "Escape") { // Cancel the changes
3913 this.innerText = $(this).data("dolEditText");
3918 $("#websitecontentundertopmenu").on("blur", ".dol-edit-text", function() {
3920 var text = element.innerText;
3921 if (text === $(element).data("dolEditText")) {
3924 saveEditInline(element, {action: "updateElementText", text: text}, function(response) {
3925 $(element).data("dolEditText", response.text);
3926 if (response.text !== text && document.activeElement !== element) {
3927 element.innerText = response.text;
3936 $disableeditinline = 0;
3937 if ($disableeditinline) {
3939 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>';
3943 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>';
3945 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>';
3954 print
'<span class="websiteselection">';
3955 if (
$object->fk_default_home > 0 && $pageid ==
$object->fk_default_home) {
3959 print
'<a href="#" class="button buttonpictoonly bordertransp disabled" disabled="disabled" title="'.dol_escape_htmltag($langs->trans(
"SetAsHomePage")).
'"><span class="fas fa-home valignmiddle btnTitle-icon"></span></a>';
3963 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=confirmsetashome&token='.
newToken().
'&website='.urlencode($website->ref).
'&pageid='.((int) $pageid).
'" class="button buttonpictoonly bordertransp"'.$disabled.
' title="'.
dol_escape_htmltag($langs->trans(
"SetAsHomePage")).
'"><span class="fas fa-home valignmiddle btnTitle-icon"></span></a>';
3965 print
'<button type="submit" class="button bordertransp buttonpictoonly"'.$disabled.
' value="1" name="createpagefromclone" title="'.
dol_escape_htmltag($langs->trans(
"ClonePage")).
'">'.img_picto(
'',
'clone_nocolor',
'class="fa-rotate-90"').
'</button>';
3968 if (!$permissiontodelete) {
3969 $disabled =
' disabled="disabled"';
3970 $title = $langs->trans(
"NotEnoughPermissions");
3972 } elseif ($websitepage->status != $websitepage::STATUS_DRAFT) {
3973 $disabled =
' disabled="disabled"';
3974 $title = $langs->trans(
"WebpageMustBeDisabled", $langs->transnoentitiesnoconv($websitepage->LibStatut(0, 0)));
3978 $title = $langs->trans(
"Delete");
3979 $url = $_SERVER[
"PHP_SELF"].
'?action=delete&token='.
newToken().
'&pageid='.((int) $websitepage->id).
'&website='.urlencode($website->ref);
3981 print
'<a href="'.$url.
'" class="button buttonpictoonly buttonDelete bordertransp'.($disabled ?
' disabled' :
'').
'"'.$disabled.
' title="'.
dol_escape_htmltag($title).
'">'.img_picto(
'',
'delete',
'class=""').
'</a>';
3988 print
'<span class="websitetools">';
3990 if (($pageid > 0 && $atleastonepage) && ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite')) {
3991 $realpage = $urlwithroot.
'/public/website/index.php?website='.$websitekey.
'&pageref='.$websitepage->pageurl;
3992 $pagealias = $websitepage->pageurl;
3994 $htmltext = $langs->trans(
"PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv(
"Page"), $langs->transnoentitiesnoconv(
"Page"), $realpage, $langs->transnoentitiesnoconv(
"TestDeployOnWeb"));
4000 print
'<div class="websiteinputurl inline-block paddingright">';
4001 print
'<a class="websitebuttonsitepreview inline-block" id="previewpage" href="'.$realpage.
'&nocache='.
dol_now().
'" class="button" target="tab'.$websitekey.
'" alt="'.
dol_escape_htmltag($htmltext).
'">';
4002 print $form->textwithpicto(
'', $htmltext, 1,
'preview');
4026 if (!in_array($mode, array(
'replacesite')) && !in_array($action, array(
'editcss',
'editmenu',
'file_manager',
'editfile',
'replacesiteconfirm',
'createsite',
'createcontainer',
'createfromclone',
'createpagefromclone',
'deletesite',
'editsecurity'))) {
4027 if (!$user->hasRight(
'website',
'write')) {
4028 $disabled =
' disabled';
4030 if ($action ==
'editsource' || $action ==
'editmeta') {
4031 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">';
4033 if (preg_match(
'/^create/', $action)) {
4034 print
'<input type="submit" id="savefile" class="button buttonforacesave button-save small'.$disabled.
'" value="'.
dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
4036 if (preg_match(
'/^edit/', $action)) {
4037 print
'<input type="submit" id="savefile" class="button buttonforacesave button-save small'.$disabled.
'" value="'.
dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
4039 if ($action !=
'preview') {
4040 print
'<input type="submit" class="button button-cancel small" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'" name="cancel">';
4046 print
'<span class="websitehelp">';
4047 if ($action ==
'editsource' || $action ==
'editcontent' ||
GETPOST(
'editsource',
'alpha') ||
GETPOST(
'editcontent',
'alpha')) {
4048 $url =
'https://wiki.dolibarr.org/index.php/Module_Website';
4050 $htmltext =
'<small>';
4051 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource", $url);
4052 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSourceb", $url);
4053 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSourcec", $url);
4054 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSourced", $url);
4055 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource1", $url);
4056 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource2", $url);
4057 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource3", $url);
4058 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource4", $url);
4059 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource5", $url);
4060 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSourceMore", $url);
4061 $htmltext .=
'<br>';
4062 $htmltext .=
'</small>';
4063 if (
$conf->browser->layout ==
'phone') {
4064 print $form->textwithpicto(
'', $htmltext, 1,
'help',
'inline-block', 1, 2,
'tooltipsubstitution');
4067 print $form->textwithpicto($langs->trans(
"SyntaxHelp").
' '.img_help(2, $langs->trans(
"SyntaxHelp")), $htmltext, 1,
'none',
'inline-block', 1, 2,
'tooltipsubstitution');
4073 if ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone') {
4075 if (!empty(
$conf->use_javascript_ajax)) {
4076 print
'<script type="text/javascript">
4077 jQuery(document).ready(function() {
4078 jQuery("#websiteinputurl").keyup(function() {
4079 console.log("Website external url modified "+jQuery("#previewsiteurl").val());
4080 if (jQuery("#previewsiteurl").val() != "" && jQuery("#previewsiteurl").val().startsWith("http"))
4082 jQuery("a.websitebuttonsitepreviewdisabled img").css({ opacity: 1 });
4084 else jQuery("a.websitebuttonsitepreviewdisabled img").css({ opacity: 0.2 });
4088 jQuery("#previewsiteext,#previewpageext").click(function() {
4090 newurl=jQuery("#previewsiteurl").val();
4091 if (! newurl.startsWith("http"))
4093 alert(\''.dol_escape_js($langs->trans(
"ErrorURLMustStartWithHttp")).
'\');
4097 newpage=jQuery(
"#previewsiteurl").val() +
"/" + jQuery(
"#previewpageurl").val() +
".php";
4098 console.log(
"Open url "+newurl);
4102 url:
"'.DOL_URL_ROOT.'/core/ajax/saveinplace.php",
4104 token: \
''.currentToken().
'\',
4105 field: \
'editval_virtualhost\',
4106 element: \'website\',
4107 table_element: \'website\',
4108 fk_element: '.((int)
$object->id).
',
4111 context: document.body
4114 jQuery("#previewsiteext").attr("href",newurl);
4115 jQuery("#previewpageext").attr("href",newpage);
4123 print
'</div>'.
"\n";
4134if ($action ==
'editcss') {
4135 print
'<div class="fiche">';
4140 $csscontent = @file_get_contents($filecss);
4142 $csscontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $csscontent);
4144 $csscontent =
GETPOST(
'WEBSITE_CSS_INLINE',
'none');
4146 if (!trim($csscontent)) {
4147 $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;}";
4151 $jscontent = @file_get_contents($filejs);
4153 $jscontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $jscontent);
4155 $jscontent =
GETPOST(
'WEBSITE_JS_INLINE',
'none');
4157 if (!trim($jscontent)) {
4158 $jscontent =
'/* JS content (all pages) */'.
"\n";
4162 $htmlheadercontent = @file_get_contents($filehtmlheader);
4164 $htmlheadercontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $htmlheadercontent);
4166 $htmlheadercontent =
GETPOST(
'WEBSITE_HTML_HEADER',
'none');
4168 if (!trim($htmlheadercontent)) {
4169 $htmlheadercontent =
"<html>\n";
4170 $htmlheadercontent .= $htmlheadercontentdefault;
4171 $htmlheadercontent .=
"</html>";
4173 $htmlheadercontent = preg_replace(
'/^\s*<html>/ims',
'', $htmlheadercontent);
4174 $htmlheadercontent = preg_replace(
'/<\/html>\s*$/ims',
'', $htmlheadercontent);
4175 $htmlheadercontent =
'<html>'.
"\n".trim($htmlheadercontent).
"\n".
'</html>';
4179 $robotcontent = @file_get_contents($filerobot);
4181 $robotcontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $robotcontent);
4183 $robotcontent =
GETPOST(
'WEBSITE_ROBOT',
'nohtml');
4185 if (!trim($robotcontent)) {
4186 $robotcontent .=
"# Robot file. Generated with ".DOL_APPLICATION_TITLE.
"\n";
4187 $robotcontent .=
"User-agent: *\n";
4188 $robotcontent .=
"Allow: /public/\n";
4189 $robotcontent .=
"Disallow: /administrator/\n";
4193 $htaccesscontent = @file_get_contents($filehtaccess);
4195 $htaccesscontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $htaccesscontent);
4197 $htaccesscontent =
GETPOST(
'WEBSITE_HTACCESS',
'nohtml');
4201 $manifestjsoncontent = @file_get_contents($filemanifestjson);
4203 $manifestjsoncontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $manifestjsoncontent);
4205 $manifestjsoncontent = trim(
GETPOST(
'WEBSITE_MANIFEST_JSON',
'restricthtmlallowunvalid'));
4206 $manifestjsoncontent = str_replace(
'<?=',
'<?php', $manifestjsoncontent);
4214 $readmecontent = @file_get_contents($filereadme);
4216 $readmecontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $readmecontent);
4218 $readmecontent =
GETPOST(
'WEBSITE_README',
'restricthtmlallowunvalid');
4225 $licensecontent = @file_get_contents($filelicense);
4227 $licensecontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $licensecontent);
4229 $licensecontent =
GETPOST(
'WEBSITE_LICENSE',
'restricthtmlallowunvalid');
4238 print
'<!-- Edit Website properties (CSS, Language, ...) -->'.
"\n";
4239 print
'<table class="border centpercent">';
4242 print
'<tr><td class="titlefieldcreate fieldrequired">';
4243 print $langs->trans(
'WebSite');
4249 if ($action !=
'createcontainer') {
4250 if (empty(
$conf->use_javascript_ajax)) {
4251 print
'<!-- Status of web site page -->'.
"\n";
4252 print
'<tr><td class="fieldrequired">';
4253 print $langs->trans(
'Status');
4255 print $form->selectyesno(
'status',
$object->status);
4261 print
'<tr><td class="tdtop fieldrequired">';
4263 print $form->textwithpicto($langs->trans(
'MainLanguage'), $htmltext, 1,
'help',
'', 0, 2,
'WEBSITE_LANG');
4265 print img_picto(
'',
'language',
'class="pictofixedwidth"');
4266 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);
4271 print
'<tr><td class="tdtop">';
4272 $htmltext = $langs->trans(
"Example").
': fr,de,sv,it,pt';
4273 print $form->textwithpicto($langs->trans(
'OtherLanguages'), $htmltext, 1,
'help',
'', 0, 2);
4275 print img_picto(
'',
'language',
'class="pictofixedwidth"');
4276 print
'<input type="text" class="flat maxwidth200" value="'.(GETPOSTISSET(
'WEBSITE_OTHERLANG') ?
GETPOST(
'WEBSITE_OTHERLANG',
'alpha') :
$object->otherlang).
'" name="WEBSITE_OTHERLANG">';
4281 print
'<tr><td class="tdtop">';
4283 $htmltext = $langs->trans(
"VirtualhostDesc");
4284 print $form->textwithpicto($langs->trans(
'Virtualhost'), $htmltext, 1,
'help',
'', 0, 2,
'virtualhosttooltip');
4286 print
'<input type="text" class="flat minwidth300" value="'.(GETPOSTISSET(
'virtualhost') ?
GETPOST(
'virtualhost',
'alpha') : $virtualurl).
'" name="virtualhost">';
4292 print $form->textwithpicto($langs->trans(
'ImportFavicon'), $langs->trans(
'FaviconTooltip'));
4295 $maxmin = $maxfilesizearray[
'maxmin'];
4297 print
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
4299 print
'<input type="file" class="flat minwidth300" name="addedfile" id="addedfile"/>';
4301 $uploadfolder =
$conf->website->dir_output.
'/'.$websitekey;
4303 print
'<div class="inline-block valignmiddle marginrightonly">';
4304 print
'<img style="max-height: 80px" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart=website&file='.$websitekey.
'/favicon.png">';
4310 print
'<tr><td class="tdtop">';
4311 $htmlhelp = $langs->trans(
"CSSContentTooltipHelp");
4312 print $form->textwithpicto($langs->trans(
'WEBSITE_CSS_INLINE'), $htmlhelp, 1,
'help',
'', 0, 2,
'csstooltip');
4315 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_CSS_INLINE_x'),
'y' =>
GETPOST(
'WEBSITE_CSS_INLINE_y'));
4316 $doleditor =
new DolEditor(
'WEBSITE_CSS_INLINE', $csscontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4317 print $doleditor->Create(1,
'',
true,
'CSS',
'css');
4322 print
'<tr><td class="tdtop">';
4323 $textwithhelp = $langs->trans(
'WEBSITE_JS_INLINE');
4324 $htmlhelp2 = $langs->trans(
"LinkAndScriptsHereAreNotLoadedInEditor").
'<br>';
4325 print $form->textwithpicto($textwithhelp, $htmlhelp2, 1,
'warning',
'', 0, 2,
'htmljstooltip2');
4329 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_JS_INLINE_x'),
'y' =>
GETPOST(
'WEBSITE_JS_INLINE_y'));
4330 $doleditor =
new DolEditor(
'WEBSITE_JS_INLINE', $jscontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4331 print $doleditor->Create(1,
'',
true,
'JS',
'javascript');
4336 print
'<tr><td class="tdtop">';
4337 print $langs->trans(
'WEBSITE_HTML_HEADER');
4338 $htmlhelp = $langs->trans(
"Example").
' :<br>';
4340 $textwithhelp = $form->textwithpicto(
'', $htmlhelp, 1,
'help',
'', 0, 2,
'htmlheadertooltip');
4341 $htmlhelp2 = $langs->trans(
"LinkAndScriptsHereAreNotLoadedInEditor").
'<br>';
4342 print $form->textwithpicto($textwithhelp, $htmlhelp2, 1,
'warning',
'', 0, 2,
'htmlheadertooltip2');
4345 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_HTML_HEADER_x'),
'y' =>
GETPOST(
'WEBSITE_HTML_HEADER_y'));
4346 $doleditor =
new DolEditor(
'WEBSITE_HTML_HEADER', $htmlheadercontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4347 print $doleditor->Create(1,
'',
true,
'HTML Header',
'html');
4352 print
'<tr><td class="tdtop">';
4353 print $langs->trans(
'WEBSITE_ROBOT');
4356 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_ROBOT_x'),
'y' =>
GETPOST(
'WEBSITE_ROBOT_y'));
4357 $doleditor =
new DolEditor(
'WEBSITE_ROBOT', $robotcontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4358 print $doleditor->Create(1,
'',
true,
'Robot file',
'text');
4363 print
'<tr><td class="tdtop">';
4365 $textwithhelp3 = $langs->trans(
"Example").
' :';
4366 $textwithhelp3 .=
"<br># Order allow,deny\n";
4367 $textwithhelp3 .=
"<br># Deny from all\n";
4368 $textwithhelp3 .=
"<br># Require all granted\n";
4370 print $form->textwithpicto($langs->trans(
'WEBSITE_HTACCESS'), $textwithhelp3, 1,
'help',
'', 0, 2,
'htmlheadertooltip3');
4373 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_HTACCESS_x'),
'y' =>
GETPOST(
'WEBSITE_HTACCESS_y'));
4374 $doleditor =
new DolEditor(
'WEBSITE_HTACCESS', $htaccesscontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4375 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' .htaccess',
'text');
4380 print
'<tr><td class="tdtop">';
4381 $htmlhelp = $langs->trans(
"Example").
' :<br>';
4382 $htmlhelp .=
'<small>'.dol_htmlentitiesbr($manifestjsoncontentdefault).
'</small>';
4383 print $form->textwithpicto($langs->trans(
'WEBSITE_MANIFEST_JSON'), $htmlhelp, 1,
'help',
'', 0, 2,
'manifestjsontooltip');
4385 print $langs->trans(
"UseManifest").
': '.$form->selectyesno(
'use_manifest', $website->use_manifest, 1).
'<br>';
4387 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_MANIFEST_JSON_x'),
'y' =>
GETPOST(
'WEBSITE_MANIFEST_JSON_y'));
4388 $doleditor =
new DolEditor(
'WEBSITE_MANIFEST_JSON', $manifestjsoncontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4389 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' manifest.json',
'text');
4393 print
'<tr><td class="tdtop">';
4394 $htmlhelp = $langs->trans(
"EnterHereReadmeInformation");
4395 print $form->textwithpicto($langs->trans(
"File").
' README.md', $htmlhelp, 1,
'help',
'', 0, 2,
'readmetooltip');
4398 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_README_x'),
'y' =>
GETPOST(
'WEBSITE_README_y'));
4399 $doleditor =
new DolEditor(
'WEBSITE_README', $readmecontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4400 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' README.md',
'text');
4405 print
'<tr><td class="tdtop">';
4406 $htmlhelp = $langs->trans(
"EnterHereLicenseInformation");
4407 print $form->textwithpicto($langs->trans(
"File").
' LICENSE', $htmlhelp, 1,
'help',
'', 0, 2,
'licensetooltip');
4410 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_LICENSE_x'),
'y' =>
GETPOST(
'WEBSITE_LICENSE_y'));
4411 $doleditor =
new DolEditor(
'WEBSITE_LICENSE', $licensecontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4412 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' LICENSE',
'text');
4417 print
'<tr><td class="tdtop">';
4418 $htmlhelp = $langs->trans(
'RSSFeedDesc');
4419 print $form->textwithpicto($langs->trans(
'RSSFeed'), $htmlhelp, 1,
'help',
'', 0, 2,
'');
4421 print
'/wrapper.php?rss=1[&l=XX][&limit=99][&cachedelay=99]';
4433if ($action ==
'editsecurity') {
4437 print
'<div class="fiche">';
4441 print
dol_get_fiche_head($head,
'security', $langs->trans(
"General"), -1,
'website');
4443 print
'<span class="opacitymedium">'.$langs->trans(
"HTTPHeaderEditor").
'. '.$langs->trans(
"ReservedToAdvancedUsers").
'.</span><br><br>';
4445 print
'<div class="div-table-responsive-no-min">';
4446 print
'<table class="noborder centpercent">';
4447 print
'<tr class="liste_titre">';
4448 print
'<td>'.$langs->trans(
"HTTPHeader").
'</td>';
4449 print
'<td></td>'.
"\n";
4453 print
'<tr class="oddeven">';
4454 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>';
4455 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>';
4458 print
'<tr class="oddeven">';
4459 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>';
4460 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>';
4463 print
'<tr class="oddeven">';
4464 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>';
4465 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>';
4468 $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;";
4471 print
'<tr class="oddeven nohover">';
4472 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>';
4475 print
'<div class="div-table-responsive-no-min">';
4477 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>';
4479 print
'<br class="selectaddcontentsecuritypolicy hidden">';
4481 print
'<div id="selectaddcontentsecuritypolicy" class="hidden selectaddcontentsecuritypolicy">';
4482 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');
4484 print
'<input type="hidden" id="select_source_WEBSITE_SECURITY_FORCECSP" name="select_source_WEBSITE_SECURITY_FORCECSP">';
4485 foreach ($selectarrayCSPSources as $key => $values) {
4486 print
'<div class="div_WEBSITE_SECURITY_FORCECSP hidden inline-block maxwidth350" id="div_'.$key.
'_WEBSITE_SECURITY_FORCECSP">';
4487 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');
4491 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>';
4493 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>';
4497 if (!empty($forceCSP)) {
4500 print
'<div class="div-table-responsive-no-min">';
4501 print img_picto(
'',
'graph',
'class="pictofixedwidth"').$langs->trans(
"HierarchicView").
'<br>';
4503 foreach ($forceCSPArr as $directive => $sources) {
4505 if (in_array($directive, array_keys($selectarrayCSPDirectives))) {
4506 print
'<span>'.$directive.
'</span>';
4508 print $form->textwithpicto($directive, $langs->trans(
"UnknowContentSecurityPolicyDirective"), 1,
'warning');
4510 if (!empty($sources)) {
4512 foreach ($sources as $key => $source) {
4513 print
'<li><span>'.$source.
'</span> <a href="'.$_SERVER[
"PHP_SELF"].
'?websiteid='.$websiteid.
'&action=removecspsource&sourcecsp='.$directive.
'_'.$key.
'&token='.
newToken().
'">'.img_delete().
'</a></li>';
4517 print
' <a href="'.$_SERVER[
"PHP_SELF"].
'?websiteid='.$websiteid.
'&action=removecspsource&sourcecsp='.$directive.
'&token='.
newToken().
'">'.img_delete().
'</a>';
4531 print
'<tr class="oddeven">';
4532 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>';
4533 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>';
4541 print
'<div class="center">';
4543 print
'<input type="submit" class="button small" name="updateandstay" value="'.$langs->trans(
"Save").
'">';
4544 print
'<input class="button button-cancel small" type="submit" name="preview" value="'.$langs->trans(
"Cancel").
'">';
4550 $(document).ready(function() {
4551 $("#btnaddcontentsecuritypolicy").on("click", function(){
4552 if($("#selectaddcontentsecuritypolicy").is(":visible")){
4553 console.log("We hide select to add Content Security Policy");
4554 $(".selectaddcontentsecuritypolicy").hide();
4556 console.log("We show select to add Content Security Policy");
4557 $(".selectaddcontentsecuritypolicy").show();
4561 $("#select_identifier_WEBSITE_SECURITY_FORCECSP").on("change", function() {
4562 key = $(this).find(":selected").data("directivetype");
4563 console.log("We hide all select div");
4564 $(".div_WEBSITE_SECURITY_FORCECSP").hide();
4565 $(".select_WEBSITE_SECURITY_FORCECSP").val(null).trigger("change");
4566 $(".div_input_data_WEBSITE_SECURITY_FORCECSP").hide();
4567 $("#btn_WEBSITE_SECURITY_FORCECSP").prop("disabled",true);
4569 $("#btn_WEBSITE_SECURITY_FORCECSP").prop("disabled",false);
4571 console.log("We show div select with key "+key);
4572 $("#div_"+key+"_WEBSITE_SECURITY_FORCECSP").css("display", "inline-block");
4576 $(".select_WEBSITE_SECURITY_FORCECSP").on("change", function() {
4577 keysource = $(this).find(":selected").data("sourcetype");
4578 $("#select_source_WEBSITE_SECURITY_FORCECSP").val($(this).val());
4579 console.log("We hide and show fields");
4580 if (keysource == "data" || keysource == "input") {
4581 $(".div_input_data_WEBSITE_SECURITY_FORCECSP").css("display", "inline-block");
4582 $("#btn_WEBSITE_SECURITY_FORCECSP").prop("disabled",true);
4584 $("#input_data_WEBSITE_SECURITY_FORCECSP").val("");
4585 $(".div_input_data_WEBSITE_SECURITY_FORCECSP").hide();
4586 if (keysource != undefined) {
4587 $("#btn_WEBSITE_SECURITY_FORCECSP").prop("disabled",false);
4589 $("#btn_WEBSITE_SECURITY_FORCECSP").prop("disabled",true);
4594 $("#input_data_WEBSITE_SECURITY_FORCECSP").on("change keyup", function(){
4595 if ($(this).val() != "") {
4596 console.log("We show add button");
4597 $("#btn_WEBSITE_SECURITY_FORCECSP").prop("disabled",false);
4599 console.log("We hide add button");
4600 $("#btn_WEBSITE_SECURITY_FORCECSP").prop("disabled",true);
4611if ($action ==
'createsite') {
4612 print
'<div class="fiche">';
4626 if ($action ==
'createcontainer') {
4630 print
'<!-- Add site -->'.
"\n";
4631 print
'<div class="tabBar tabBarWithBottom">';
4633 print
'<table class="border centpercent">';
4635 $siteref = $sitedesc = $sitelang = $siteotherlang =
'';
4637 $siteref =
GETPOST(
'WEBSITE_REF',
'aZ09');
4639 if (
GETPOST(
'WEBSITE_DESCRIPTION')) {
4640 $sitedesc =
GETPOST(
'WEBSITE_DESCRIPTION',
'alpha');
4642 if (
GETPOST(
'WEBSITE_LANG')) {
4643 $sitelang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
4645 if (
GETPOST(
'WEBSITE_OTHERLANG')) {
4646 $siteotherlang =
GETPOST(
'WEBSITE_OTHERLANG',
'aZ09comma');
4649 print
'<tr><td class="titlefieldcreate fieldrequired">';
4650 print $form->textwithpicto($langs->trans(
'WebsiteName'), $langs->trans(
"Example").
': MyPortal, www.mywebsite.com, ...');
4652 print
'<input type="text" class="flat maxwidth300" name="WEBSITE_REF" value="'.dol_escape_htmltag($siteref).
'" autofocus>';
4655 print
'<tr><td class="fieldrequired">';
4656 print $langs->trans(
'MainLanguage');
4658 $shortlangcode = preg_replace(
'/[_-].*$/',
'', trim($langs->defaultlang));
4659 print img_picto(
'',
'language',
'class="pictofixedwidth"');
4660 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);
4664 $htmltext = $langs->trans(
"Example").
': fr,de,sv,it,pt';
4665 print $form->textwithpicto($langs->trans(
'OtherLanguages'), $htmltext, 1,
'help',
'', 0, 2);
4667 print img_picto(
'',
'language',
'class="pictofixedwidth"');
4668 print
'<input type="text" class="flat minwidth300" name="WEBSITE_OTHERLANG" value="'.dol_escape_htmltag($siteotherlang).
'">';
4672 print $langs->trans(
'Description');
4674 print
'<input type="text" class="flat minwidth500" name="WEBSITE_DESCRIPTION" value="'.dol_escape_htmltag($sitedesc).
'">';
4679 $htmltext = $langs->trans(
"VirtualhostDesc");
4687 print $form->textwithpicto($langs->trans(
'Virtualhost'), $htmltext, 1,
'help',
'', 0, 2,
'');
4689 print
'<input type="text" class="flat minwidth300" name="virtualhost" value="'.dol_escape_htmltag(
GETPOST(
'virtualhost',
'alpha')).
'">';
4695 if ($action ==
'createsite') {
4696 print
'<div class="center">';
4698 print
'<input type="submit" class="button small" name="addcontainer" value="'.$langs->trans(
"Create").
'">';
4699 print
'<input class="button button-cancel small" type="submit" name="preview" value="'.$langs->trans(
"Cancel").
'">';
4715if ($action ==
'importsite') {
4716 print
'<!-- action=importsite -->';
4717 print
'<div class="fiche">';
4725 print
'<span class="opacitymedium">'.$langs->trans(
"ZipOfWebsitePackageToImport").
'</span><br><br>';
4728 $dolibarrdataroot = preg_replace(
'/([\\/]+)$/i',
'', DOL_DATA_ROOT);
4729 $allowimportsite =
true;
4730 if (
dol_is_file($dolibarrdataroot.
'/installmodules.lock')) {
4731 $allowimportsite =
false;
4734 if ($allowimportsite) {
4736 $maxmin = $maxfilesizearray[
'maxmin'];
4738 print
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
4740 print
'<input class="flat minwidth400" type="file" name="userfile[]" accept=".zip">';
4741 print
'<input type="submit" class="button small" name="buttonsubmitimportfile" value="'.dol_escape_htmltag($langs->trans(
"Upload")).
'">';
4742 print
'<input type="submit" class="button button-cancel small" name="preview" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
4743 print
'<br><br><br>';
4747 $message = $langs->trans(
'InstallModuleFromWebHasBeenDisabledContactUs');
4750 $message = $langs->trans(
"InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.
'/installmodules.lock');
4756 print
'<span class="opacitymedium">'.$langs->trans(
"ZipOfWebsitePackageToLoad").
'</span><br><br>';
4768if ($action ==
'editmeta' || $action ==
'createcontainer') {
4769 print
'<div class="fiche">';
4783 if ($action ==
'createcontainer') {
4787 print
'<!-- Edit or create page/container -->'.
"\n";
4790 $hiddenfromfetchingafterload =
' hideobject';
4791 $hiddenmanuallyafterload =
' hideobject';
4792 if (
GETPOST(
'radiocreatefrom') ==
'checkboxcreatefromfetching') {
4793 $hiddenfromfetchingafterload =
'';
4795 if (
GETPOST(
'radiocreatefrom') ==
'checkboxcreatemanually') {
4796 $hiddenmanuallyafterload =
'';
4799 if ($action ==
'editmeta' || empty(
$conf->use_javascript_ajax)) {
4800 $hiddenfromfetchingafterload =
'';
4801 $hiddenmanuallyafterload =
'';
4804 if ($action ==
'createcontainer') {
4807 if (!empty(
$conf->use_javascript_ajax)) {
4808 print
'<input type="radio" name="radiocreatefrom" id="checkboxcreatemanually" value="checkboxcreatemanually"'.(GETPOST(
'radiocreatefrom') ==
'checkboxcreatemanually' ?
' checked' :
'').
'> ';
4810 print
'<label for="checkboxcreatemanually"><span class="opacitymediumxx">'.$langs->trans(
"OrEnterPageInfoManually").
'</span></label><br>';
4811 print
'<hr class="tablecheckboxcreatemanually'.$hiddenmanuallyafterload.
'">';
4816 print
'<table class="border tableforfield nobackground centpercent tablecheckboxcreatemanually'.$hiddenmanuallyafterload.
'">';
4818 if ($action !=
'createcontainer') {
4819 print
'<tr><td class="titlefield fieldrequired">';
4820 print $langs->trans(
'IDOfPage').
' - '.$langs->trans(
'InternalURLOfPage');
4828 print
' - ';
4829 print
'/public/website/index.php?website='.urlencode((
string) $websitekey).
'&pageid='.urlencode((
string) $pageid);
4833 $type_container = $objectpage->type_container;
4834 $pageurl = $objectpage->pageurl;
4835 $pagealiasalt = $objectpage->aliasalt;
4836 $pagetitle = $objectpage->title;
4837 $pagedescription = $objectpage->description;
4838 $pageimage = $objectpage->image;
4839 $pagekeywords = $objectpage->keywords;
4840 $pagelang = $objectpage->lang;
4841 $pageallowedinframes = $objectpage->allowed_in_frames;
4842 $pagehtmlheader = $objectpage->htmlheader;
4843 $pagedatecreation = (string) $objectpage->date_creation;
4844 $pagedatemodification = $objectpage->date_modification;
4845 $pageauthorid = $objectpage->fk_user_creat;
4846 $pageusermodifid = $objectpage->fk_user_modif;
4847 $pageauthoralias = $objectpage->author_alias;
4848 $pagestatus = $objectpage->status;
4849 $pagekeephistory = (strlen((
string) $objectpage->keep_history) ? $objectpage->keep_history : 5);
4851 $type_container =
'page';
4855 $pagedescription =
'';
4859 $pageallowedinframes = 0;
4860 $pagehtmlheader =
'';
4861 $pagedatecreation =
dol_now();
4862 $pagedatemodification =
'';
4863 $pageauthorid = $user->id;
4864 $pageusermodifid = 0;
4865 $pageauthoralias =
'';
4867 $pagekeephistory = 5;
4869 if (
GETPOST(
'WEBSITE_TITLE',
'alpha')) {
4870 $pagetitle = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_TITLE',
'alphanohtml'));
4872 if (
GETPOST(
'WEBSITE_PAGENAME',
'alpha')) {
4873 $pageurl =
GETPOST(
'WEBSITE_PAGENAME',
'alpha');
4875 if (
GETPOST(
'WEBSITE_ALIASALT',
'alpha')) {
4876 $pagealiasalt = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_ALIASALT',
'alphanohtml'));
4878 if (
GETPOST(
'WEBSITE_DESCRIPTION',
'alpha')) {
4879 $pagedescription = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml'));
4881 if (
GETPOST(
'WEBSITE_IMAGE',
'alpha')) {
4882 $pageimage =
GETPOST(
'WEBSITE_IMAGE',
'alpha');
4884 if (
GETPOST(
'WEBSITE_KEYWORDS',
'alpha')) {
4885 $pagekeywords = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_KEYWORDS',
'alphanohtml'));
4887 if (
GETPOST(
'WEBSITE_LANG',
'aZ09')) {
4888 $pagelang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
4890 if (
GETPOST(
'WEBSITE_ALLOWED_IN_FRAMES',
'aZ09')) {
4891 $pageallowedinframes = 1;
4894 $pagekeephistory =
GETPOSTINT(
'WEBSITE_KEEP_HISTORY');
4896 if (
GETPOST(
'htmlheader',
'restricthtmlallowlinkscript')) {
4897 $pagehtmlheader =
GETPOST(
'htmlheader',
'restricthtmlallowlinkscript');
4900 if ($action !=
'createcontainer') {
4901 if (empty(
$conf->use_javascript_ajax)) {
4902 print
'<!-- Status of web site page -->'.
"\n";
4903 print
'<tr><td class="fieldrequired">';
4904 print $langs->trans(
'Status');
4906 print $form->selectyesno(
'status', $objectpage->status);
4912 print
'<tr><td class="titlefield fieldrequired">';
4913 print $langs->trans(
'WEBSITE_TYPE_CONTAINER');
4915 print img_picto(
'',
'object_technic',
'class="paddingrightonly"').
' ';
4916 print $formwebsite->selectTypeOfContainer(
'WEBSITE_TYPE_CONTAINER', (
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'alpha') ?
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'alpha') : $type_container), 0,
'', 1,
'minwidth300');
4919 print
'<script type="text/javascript">
4920 jQuery(document).ready(function() {
4921 jQuery("#selectWEBSITE_TYPE_CONTAINER").change(function() {
4922 console.log("We change type of page : "+jQuery("#selectWEBSITE_TYPE_CONTAINER").val());
4923 if (jQuery("#selectWEBSITE_TYPE_CONTAINER").val() == \'blogpost\') {
4924 jQuery(".trpublicauthor").show();
4926 jQuery(".trpublicauthor").hide();
4928 if (jQuery("#selectWEBSITE_TYPE_CONTAINER").val() == \'service\' || jQuery("#selectWEBSITE_TYPE_CONTAINER").val() == \'library\') {
4929 $(".spanprefix").html("_" + $("#selectWEBSITE_TYPE_CONTAINER").val() + "_");
4930 jQuery(".spanprefix").show();
4932 jQuery(".spanprefix").hide();
4936 // Force at init execution a first time of the handler change
4937 jQuery("#selectWEBSITE_TYPE_CONTAINER").trigger(\'change\');
4943 print
'<tr><td class="fieldrequired">';
4944 print $langs->trans(
'WEBSITE_TITLE');
4946 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_TITLE" id="WEBSITE_TITLE" value="'.dol_escape_htmltag($pagetitle).
'" autofocus>';
4950 print
'<tr><td class="titlefieldcreate fieldrequired">';
4951 print $langs->trans(
'WEBSITE_PAGENAME');
4953 print
'<span class="opacitymedium spanprefix hidden"></span> ';
4954 print
'<input type="text" class="flat minwidth300" name="WEBSITE_PAGENAME" id="WEBSITE_PAGENAME" value="'.dol_escape_htmltag((
string) preg_replace(
'/^_[a-z]+_/',
'', (
string) $pageurl)).
'">';
4957 print
'<script type="text/javascript">
4958 $(document).ready(function() {
4959 console.log("Manage prefix for service or library");
4960 if ($("#selectWEBSITE_TYPE_CONTAINER").val() == "service" || $("#selectWEBSITE_TYPE_CONTAINER").val() == "library") {
4961 $(".spanprefix").html("_" + $("#selectWEBSITE_TYPE_CONTAINER").val() + "_");
4962 $(".spanprefix").show();
4964 $(".websiteformtoolbar").on("submit", function(event) {
4965 if ($("#selectWEBSITE_TYPE_CONTAINER").val() == "service" || $("#selectWEBSITE_TYPE_CONTAINER").val() == "library") {
4966 var prefix = "_" + $("#selectWEBSITE_TYPE_CONTAINER").val() + "_";
4967 var userInput = $("#WEBSITE_PAGENAME").val();
4968 var $inputField = $("#WEBSITE_PAGENAME");
4969 if (userInput.indexOf(prefix) !== 0) {
4970 $inputField.val(prefix + userInput);
4978 print
'<tr><td class="titlefieldcreate">';
4979 $htmlhelp = $langs->trans(
"WEBSITE_ALIASALTDesc");
4980 print $form->textwithpicto($langs->trans(
'WEBSITE_ALIASALT'), $htmlhelp, 1,
'help',
'', 0, 2,
'aliastooltip');
4982 print
'<input type="text" class="flat minwidth500" name="WEBSITE_ALIASALT" value="'.dol_escape_htmltag($pagealiasalt).
'">';
4986 print $langs->trans(
'WEBSITE_DESCRIPTION');
4988 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_DESCRIPTION" value="'.dol_escape_htmltag($pagedescription).
'">';
4993 print
'<tr class="trimageforpage hidden"><td>';
4994 $htmlhelp = $langs->trans(
"WEBSITE_IMAGEDesc");
4995 print $form->textwithpicto($langs->trans(
'WEBSITE_IMAGE'), $htmlhelp, 1,
'help',
'', 0, 2,
'imagetooltip');
4997 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_IMAGE" value="'.dol_escape_htmltag($pageimage).
'">';
5000 print
'<script type="text/javascript">
5001 jQuery(document).ready(function() {
5002 jQuery("#selectWEBSITE_TYPE_CONTAINER").change(function() {
5003 console.log("We change type of page : "+jQuery("#selectWEBSITE_TYPE_CONTAINER").val());
5004 if (jQuery("#selectWEBSITE_TYPE_CONTAINER").val() == \'blogpost\') {
5005 jQuery(".trimageforpage").show();
5007 jQuery(".trimageforpage").hide();
5017 $htmlhelp = $langs->trans(
"WEBSITE_KEYWORDSDesc");
5018 print $form->textwithpicto($langs->trans(
'WEBSITE_KEYWORDS'), $htmlhelp, 1,
'help',
'', 0, 2,
'keywordtooltip');
5020 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_KEYWORDS" value="'.dol_escape_htmltag($pagekeywords).
'">';
5024 print $langs->trans(
'Language');
5026 $onlykeys = array();
5030 $onlykeys[$langs->defaultlang] = $langs->defaultlang;
5033 $tmparray = explode(
',',
$object->otherlang);
5034 foreach ($tmparray as $key) {
5035 $tmpkey = trim($key);
5036 if (strlen($key) == 2) {
5037 $tmpkey = strtolower($key);
5039 $onlykeys[$tmpkey] = $tmpkey;
5043 $onlykeys = array();
5045 print img_picto(
'',
'language',
'class="pictofixedwidth"').$formadmin->select_language($pagelang ? $pagelang :
'',
'WEBSITE_LANG', 0, array(),
'1', 0, 0,
'minwidth200', 0, 0, 0, $onlykeys, 1);
5046 $htmltext = $langs->trans(
"AvailableLanguagesAreDefinedIntoWebsiteProperties");
5047 print $form->textwithpicto(
'', $htmltext);
5053 print
'<!-- Translation of --><tr><td>';
5054 print $langs->trans(
'TranslationLinks');
5056 if ($action !=
'createcontainer') {
5058 $sql =
"SELECT rowid, lang from ".MAIN_DB_PREFIX.
"website_page where fk_page = ".((int) $objectpage->id);
5059 $resql = $db->query($sql);
5061 $num_rows = $db->num_rows($resql);
5062 if ($num_rows > 0) {
5063 print
'<span class="opacitymedium">'.$langs->trans(
'ThisPageHasTranslationPages').
':</span>';
5065 $tmppage =
new WebsitePage($db);
5067 while ($obj = $db->fetch_object($resql)) {
5068 $result = $tmppage->fetch($obj->rowid);
5071 $tmpstring .=
'<br>';
5073 $tmpstring .= $tmppage->getNomUrl(1).
' '.
picto_from_langcode($tmppage->lang).
' '.$tmppage->lang;
5075 $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>';
5088 dol_print_error($db);
5091 if ((empty($translatedby) || ($objectpage->lang !=
$object->lang)) && ($action ==
'editmeta' || $action ==
'createcontainer' || $objectpage->fk_page > 0)) {
5092 $sourcepage =
new WebsitePage($db);
5094 if ($objectpage->fk_page > 0) {
5095 $result = $sourcepage->fetch($objectpage->fk_page);
5102 if ($translatedby) {
5105 $translationof = $objectpage->fk_page;
5106 print
'<span class="opacitymedium">'.$langs->trans(
'ThisPageIsTranslationOf').
'</span> ';
5107 print $sourcepage->getNomUrl(2).
' '.$formwebsite->selectContainer($website,
'pageidfortranslation', ($translationof ? $translationof : -1), 1, $action,
'minwidth300', array($objectpage->id));
5108 if ($translationof > 0 && $sourcepage->lang) {
5111 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>';
5118 if (
isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire')) {
5120 $langs->load(
'categories');
5122 print
'<tr><td class="toptd">'.$form->editfieldkey(
'Categories',
'categories',
'', $objectpage, 0).
'</td><td>';
5123 print $form->selectCategories(Categorie::TYPE_WEBSITE_PAGE,
'categories', $objectpage);
5129 print
'<tr><td class="titlefieldcreate">';
5130 print
'ObjectClass';
5132 print
'<input type="text" class="flat minwidth300" name="WEBSITE_OBJECTCLASS" placeholder="ClassName::/path/class/ObjectClass.class.php" >';
5135 print
'<tr><td class="titlefieldcreate">';
5138 print
'<input type="text" class="flat minwidth300" name="WEBSITE_OBJECTID" >';
5142 $fuser =
new User($db);
5145 if ($action !=
'createcontainer') {
5147 print $langs->trans(
'DateLastModification');
5149 print
dol_print_date($pagedatemodification,
'dayhour',
'tzuser');
5153 print $langs->trans(
'UserModification');
5155 if ($pageusermodifid > 0) {
5156 $fuser->fetch($pageusermodifid);
5157 print $fuser->getNomUrl(-1);
5159 print
'<span class="opacitymedium">'.$langs->trans(
"Unknown").
'</span>';
5165 $url =
'https://wiki.dolibarr.org/index.php/Module_Website';
5166 $htmltext =
'<small>';
5167 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource", $url);
5168 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource1", $url);
5169 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource2", $url);
5170 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource3", $url);
5171 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource4", $url);
5172 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource5", $url);
5173 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSourceMore", $url);
5174 $htmltext .=
'<br>';
5175 $htmltext .=
'</small>';
5178 $formmail->withaiprompt =
'html';
5179 $formmail->withlayout =
'websitepage';
5180 $showlinktolayout = $formmail->withlayout;
5181 $showlinktoai = ($formmail->withaiprompt &&
isModEnabled(
'ai')) ?
'textgenerationwebpage' :
'';
5182 if (($action ==
'createcontainer' && $showlinktolayout) || ($action ==
'createcontainer' && $showlinktoai)) {
5183 print
'<tr><td class="titlefield tdtop">';
5184 if (
$conf->browser->layout ==
'phone') {
5185 print $form->textwithpicto(
'', $htmltext, 1,
'help',
'inline-block', 1, 2,
'tooltipsubstitution');
5188 print $form->textwithpicto($langs->trans(
"PreviewPageContent").
' '.img_help(2, $langs->trans(
"PreviewPageContent")), $htmltext, 1,
'none',
'inline-block', 1, 2,
'tooltipsubstitution');
5190 print
'</td><td class="tdtop">';
5194 $showlinktolayoutlabel = $langs->trans(
"FillPageWithALayout");
5195 $showlinktoailabel = $langs->trans(
"FillPageWithAIContent");
5196 $htmlname =
'content';
5198 include DOL_DOCUMENT_ROOT.
'/core/tpl/formlayoutai.tpl.php';
5204 if ($action ==
'createcontainer') {
5205 print
'<tr id="pageContent"><td class="tdtop">';
5206 if (!$showlinktolayout || !$showlinktoai) {
5207 if (
$conf->browser->layout ==
'phone') {
5208 print $form->textwithpicto(
'', $htmltext, 1,
'help',
'inline-block', 1, 2,
'tooltipsubstitution');
5211 print $form->textwithpicto($showlinktolayout ?
'' : ($langs->trans(
"PreviewPageContent").
' '.img_help(2, $langs->trans(
"PreviewPageContent"))), $htmltext, 1,
'none',
'inline-block', 1, 2,
'tooltipsubstitution');
5216 $doleditor =
new DolEditor(
'content',
GETPOST(
'content',
'none'),
'', 200,
'dolibarr_mailings',
'In',
true,
true,
true, 40,
'90%');
5217 $doleditor->Create();
5224 print $langs->trans(
'DateCreation');
5226 print $form->selectDate($pagedatecreation,
'datecreation', 1, 1, 0,
'', 1, 1);
5232 print $langs->trans(
'Author');
5234 if ($pageauthorid > 0) {
5235 $fuser->fetch($pageauthorid);
5236 print $fuser->getNomUrl(-1);
5238 print
'<span class="opacitymedium">'.$langs->trans(
"Unknown").
'</span>';
5243 print
'<tr class="trpublicauthor hidden"><td>';
5244 print $langs->trans(
'PublicAuthorAlias');
5246 print
'<input type="text" class="flat minwidth300" name="WEBSITE_AUTHORALIAS" value="'.dol_escape_htmltag($pageauthoralias).
'" placeholder="'.
dol_escape_htmltag($langs->trans(
"Anonymous")).
'">';
5250 print
'<tr><td class="tdhtmlheader tdtop">';
5251 $htmlhelp = $langs->trans(
"EditTheWebSiteForACommonHeader").
'<br><br>';
5252 $htmlhelp .= $langs->trans(
"Examples").
' :<br>';
5253 $htmlhelp .=
'<span class="small">';
5255 $htmlhelp .=
'</span>';
5256 print $form->textwithpicto($langs->transnoentitiesnoconv(
'HtmlHeaderPage'), $htmlhelp, 1,
'help',
'', 0, 2,
'htmlheadertooltip');
5258 $poscursor = array(
'x' =>
GETPOST(
'htmlheader_x'),
'y' =>
GETPOST(
'htmlheader_y'));
5259 $doleditor =
new DolEditor(
'htmlheader', $pagehtmlheader,
'', 160,
'ace',
'In',
true,
false,
'ace', ROWS_4,
'100%', 0, $poscursor);
5260 print $doleditor->Create(1,
'',
true,
'HTML Header',
'html');
5265 print $langs->trans(
'AllowedInFrames');
5269 print
'<input type="checkbox" class="flat" name="WEBSITE_ALLOWED_IN_FRAMES" value="1"'.($pageallowedinframes ?
'checked="checked"' :
'').
'>';
5273 if ($action !=
'createcontainer') {
5275 $htmlhelp = $langs->trans(
"NumberOfVersionsToKeepInHistoryHelp");
5276 print $form->textwithpicto($langs->trans(
'NumberOfVersionsToKeepInHistory'), $htmlhelp, 1,
'help',
'', 0, 2,
'keephistorytooltip');
5278 print
'<input type="text" class="flat maxwidth50" name="WEBSITE_KEEP_HISTORY" value="'.dol_escape_htmltag((
string) $pagekeephistory).
'">';
5285 if ($action ==
'createcontainer') {
5286 $langs->load(
"website");
5288 print
'<div class="center tablecheckboxcreatemanually'.$hiddenmanuallyafterload.
'">';
5290 print
'<input type="submit" class="button small buttonforacesave" name="addcontainer" value="'.$langs->trans(
"Create").
'">';
5291 print
'<input class="button button-cancel small" type="submit" name="preview" value="'.$langs->trans(
"Cancel").
'">';
5297 if (!empty(
$conf->use_javascript_ajax)) {
5298 print
'<input type="radio" name="radiocreatefrom" id="checkboxcreatefromfetching" value="checkboxcreatefromfetching"'.(GETPOST(
'radiocreatefrom') ==
'checkboxcreatefromfetching' ?
' checked' :
'').
'> ';
5300 print
'<label for="checkboxcreatefromfetching"><span class="opacitymediumxx">'.$langs->trans(
"CreateByFetchingExternalPage").
'</span> <span class="small opacitymedium">('.$langs->trans(
"ForAdvancedWebmastersOnly").
')</small></label><br>';
5301 print
'<hr class="tablecheckboxcreatefromfetching'.$hiddenfromfetchingafterload.
'">';
5303 print
info_admin($langs->trans(
"OnlyEditionOfSourceForGrabbedContentFuture"), 0, 0,
'warning tablecheckboxcreatefromfetching'.$hiddenfromfetchingafterload);
5306 print
'<table class="tableforfield centpercent tablecheckboxcreatefromfetching'.$hiddenfromfetchingafterload.
'">';
5307 print
'<tr><td class="titlefield tdtop">';
5308 print $langs->trans(
"URL");
5310 print
'<input class="flat minwidth500 marginbottomonly" type="text" name="externalurl" value="'.dol_escape_htmltag(
GETPOST(
'externalurl',
'alpha')).
'" placeholder="https://externalsite/pagetofetch"> ';
5312 print
'<div class="paddingtop">';
5313 print
'<input class="flat paddingtop paddingright" type="checkbox" name="grabimages" value="1" checked="checked">';
5314 print
'<span class="valignmiddle">'.$langs->trans(
"GrabImagesInto");
5316 print $langs->trans(
"ImagesShouldBeSavedInto").
' ';
5318 $arraygrabimagesinto = array(
'root' => $langs->trans(
"WebsiteRootOfImages"),
'subpage' => $langs->trans(
"SubdirOfPage"));
5319 print $form->selectarray(
'grabimagesinto', $arraygrabimagesinto,
GETPOSTISSET(
'grabimagesinto') ?
GETPOST(
'grabimagesinto') :
'root', 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth75 valignmiddle', 1);
5322 print
'<input class="button small" style="margin-top: 5px" type="submit" name="fetchexternalurl" value="'.dol_escape_htmltag($langs->trans(
"FetchAndCreate")).
'">';
5323 print
'<input class="button button-cancel small" type="submit" name="preview" value="'.$langs->trans(
"Cancel").
'">';
5329 if ($action ==
'createcontainer') {
5330 print
'<script type="text/javascript">
5331 jQuery(document).ready(function() {
5332 var disableautofillofalias = 0;
5333 var selectedm = \'\';
5334 var selectedf = \'\';
5336 jQuery("#WEBSITE_TITLE").keyup(function() {
5337 if (disableautofillofalias == 0) {
5338 var valnospecial = jQuery("#WEBSITE_TITLE").val();
5339 valnospecial = valnospecial.replace(/[éèê]/g, \'e\').replace(/[à]/g, \'a\').replace(/[ù]/g, \'u\').replace(/[î]/g, \'i\');
5340 valnospecial = valnospecial.replace(/[ç]/g, \'c\').replace(/[ö]/g, \'o\');
5341 valnospecial = valnospecial.replace(/[^\w]/gi, \'-\').toLowerCase();
5342 valnospecial = valnospecial.replace(/\-+/g, \'-\').replace(/\-$/, \'\');
5343 console.log("disableautofillofalias=0 so we replace WEBSITE_TITLE with "+valnospecial);
5344 jQuery("#WEBSITE_PAGENAME").val(valnospecial);
5347 jQuery("#WEBSITE_PAGENAME").keyup(function() {
5348 if (jQuery("#WEBSITE_PAGENAME").val() == \'\') {
5349 disableautofillofalias = 0;
5351 disableautofillofalias = 1;
5354 jQuery("#WEBSITE_PAGENAME").blur(function() {
5355 if (jQuery("#WEBSITE_PAGENAME").val() == \'\') {
5356 disableautofillofalias = 0;
5357 jQuery("#WEBSITE_TITLE").trigger(\'keyup\');
5361 jQuery("#checkboxcreatefromfetching,#checkboxcreatemanually").click(function() {
5362 console.log("we select a method to create a new container "+jQuery("#checkboxcreatefromfetching:checked").val())
5363 jQuery(".tablecheckboxcreatefromfetching").hide();
5364 jQuery(".tablecheckboxcreatemanually").hide();
5365 if (typeof(jQuery("#checkboxcreatefromfetching:checked").val()) != \'undefined\') {
5366 console.log("show create from spider form");
5367 if (selectedf != \'createfromfetching\') {
5368 jQuery(".tablecheckboxcreatefromfetching").show();
5369 selectedf = \'createfromfetching\';
5372 jQuery(".tablecheckboxcreatefromfetching").hide();
5376 if (typeof(jQuery("#checkboxcreatemanually:checked").val()) != \'undefined\') {
5377 console.log("show create from scratch or template form");
5378 if (selectedm != \'createmanually\') {
5379 jQuery(".tablecheckboxcreatemanually").show();
5380 selectedm = \'createmanually\';
5383 jQuery(".tablecheckboxcreatemanually").hide();
5399if ($action ==
'preview') {
5403if ($action ==
'editfile' || $action ==
'file_manager' || $action ==
'convertimgwebp' || $action ==
'confirmconvertimgwebp') {
5404 print
'<!-- Edit Media -->'.
"\n";
5405 print
'<div class="fichenopadding" style="padding-right: 20px">'.($dol_openinpopup ?
'' :
'<br>');
5408 $formalreadyopen = 2;
5410 $url = DOL_URL_ROOT.
'/website/index.php';
5412 include DOL_DOCUMENT_ROOT.
'/core/tpl/filemanager.tpl.php';
5417if ($action ==
'editmenu') {
5418 print
'<!-- Edit Menu -->'.
"\n";
5419 print
'<div class="center">'.$langs->trans(
"FeatureNotYetAvailable").
'</center>';
5422if ($action ==
'editsource') {
5425 $contentforedit =
'';
5429 $contentforedit .= $objectpage->content;
5433 if (!empty($filetplversion)) {
5434 $contentoffile = @file_get_contents($filetplversion);
5435 if ($contentoffile) {
5437 if (preg_match(
'/<body[^>]*>(.*)<\/body>/ims', $contentoffile, $reg)) {
5438 $contentforedit = $reg[1];
5444 $maxheightwin = 480;
5445 if (isset($_SESSION[
"dol_screenheight"])) {
5446 if ($_SESSION[
"dol_screenheight"] > 680) {
5447 $maxheightwin = (int) $_SESSION[
"dol_screenheight"] - 300;
5449 if ($_SESSION[
"dol_screenheight"] > 800) {
5450 $maxheightwin = (int) $_SESSION[
"dol_screenheight"] - 250;
5454 $poscursor = array(
'x' =>
GETPOST(
'PAGE_CONTENT_x'),
'y' =>
GETPOST(
'PAGE_CONTENT_y'));
5455 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
5456 $titlecontent =
'HTML Source';
5460 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
5462 $formmail->withaiprompt =
'html';
5463 $showlinktolayout =
'';
5464 $showlinktoai =
'textgenerationwebpage';
5465 $showlinktoailabel = $langs->trans(
"FillPageWithAIContent");
5466 $htmlname =
'PAGE_CONTENT';
5469 include DOL_DOCUMENT_ROOT.
'/core/tpl/formlayoutai.tpl.php';
5471 $titlecontent .=
' '.$out;
5474 $doleditor =
new DolEditor(
'PAGE_CONTENT', $contentforedit,
'', $maxheightwin,
'Full',
'',
true,
true,
'ace', ROWS_5,
'40%', 0, $poscursor);
5475 $doleditor->Create(0,
'',
false, $titlecontent,
'php');
5478if ($action ==
'editcontent') {
5481 $contentforedit =
'';
5485 $contentforedit .= $objectpage->content;
5490 $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);
5492 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
5493 $poscursor = array(
'x' =>
GETPOST(
'PAGE_CONTENT_x'),
'y' =>
GETPOST(
'PAGE_CONTENT_y'));
5494 $doleditor =
new DolEditor(
'PAGE_CONTENT', $contentforedit,
'', 500,
'Full',
'',
true,
true,
true, ROWS_5,
'90%', 0, $poscursor);
5495 $doleditor->Create(0,
'',
false);
5500print
'<!-- Now, output content of page ID='.($websitepage->id??
'NULL').
', mode= '.$mode.
' WEBSITE_SUBCONTAINERSINLINE='.
getDolGlobalString(
'WEBSITE_SUBCONTAINERSINLINE').
' WEBSITE_EDITINLINE='.
getDolGlobalString(
'WEBSITE_EDITINLINE').
' -->'.
"\n";
5503if ($mode ==
'replacesite' || $massaction ==
'replace') {
5504 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5505 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5506 print
'<input type="hidden" name="action" value="replacesiteconfirm">';
5507 print
'<input type="hidden" name="mode" value="replacesite">';
5508 print
'<input type="hidden" name="website" value="'.$website->ref.
'">';
5511 print
'<!-- Search page and replace string -->'.
"\n";
5512 print
'<div class="fiche"><br>';
5514 print
load_fiche_titre($langs->trans(
"ReplaceWebsiteContent"),
'',
'search');
5516 print
'<div class="neutral">';
5518 print
'<div class="display-flex"><div class="flex-item">';
5520 print
'<div class="tagtable">';
5522 print
'<div class="tagtr">';
5523 print
'<div class="tagtd paddingrightonly opacitymedium">';
5524 print $langs->trans(
"SearchReplaceInto");
5526 print
'<div class="tagtd">';
5527 print
'<input type="checkbox" class="marginleftonly" id="checkboxoptionpcontent" name="optionpcontent" value="content"'.((!
GETPOSTISSET(
'buttonreplacesitesearch') ||
GETPOST(
'optionpcontent',
'aZ09')) ?
' checked' :
'').
'> <label for="checkboxoptionpcontent" class="tdoverflowmax150onsmartphone inline-block valignmiddle">'.$langs->trans(
"Content").
'</label><br>';
5528 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>';
5529 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>';
5533 print
'<div class="tagtr">';
5534 print
'<div class="tagtd paddingrightonly opacitymedium" style="padding-right: 10px !important">';
5535 print $langs->trans(
"SearchString");
5537 print
'<div class="tagtd">';
5538 print
'<input type="text" name="searchstring" value="'.dol_escape_htmltag($searchkey, 0, 0,
'', 1).
'" autofocus>';
5544 print
'</div><div class="flex-item">';
5546 print
'<div class="tagtable">';
5548 print
'<div class="tagtr">';
5549 print
'<div class="tagtd paddingrightonly opacitymedium tdoverflowmax100onsmartphone" style="padding-right: 10px !important">';
5550 print $langs->trans(
"WEBSITE_TYPE_CONTAINER");
5552 print
'<div class="tagtd">';
5553 print img_picto(
'',
'object_technic',
'class="pictofixedwidth"').
' ';
5554 print $formwebsite->selectTypeOfContainer(
'optioncontainertype', (
GETPOST(
'optioncontainertype',
'alpha') ?
GETPOST(
'optioncontainertype',
'alpha') :
''), 1,
'', 1,
'minwidth125 maxwidth400 widthcentpercentminusx');
5558 print
'<div class="tagtr">';
5559 print
'<div class="tagtd paddingrightonly opacitymedium tdoverflowmax100onsmartphone" style="padding-right: 10px !important">';
5560 print $langs->trans(
"Language");
5562 print
'<div class="tagtd">';
5563 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);
5568 if (
isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire')) {
5569 print
'<div class="tagtr">';
5570 print
'<div class="tagtd paddingrightonly marginrightonly opacitymedium tdoverflowmax100onsmartphone" style="padding-right: 10px !important">';
5571 print $langs->trans(
"Category");
5573 print
'<div class="tagtd">';
5575 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');
5576 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
5584 print
'</div></div>';
5587 print
'<input type="submit" class="button margintoponly" name="buttonreplacesitesearch" value="'.dol_escape_htmltag($langs->trans(
"Search")).
'">';
5593 if ($mode ==
'replacesite') {
5594 print
'<!-- List of search result -->'.
"\n";
5595 print
'<div class="rowsearchresult clearboth">';
5600 if ($listofpages[
'code'] ==
'OK') {
5601 $arrayofselected = is_array($toselect) ? $toselect : array();
5603 $nbtotalofrecords = count($listofpages[
'list']);
5605 $permissiontodelete = $user->hasRight(
'website',
'delete');
5608 $arrayofmassactions = array();
5609 if ($user->hasRight(
'website',
'writephp') && $searchkey) {
5610 $arrayofmassactions[
'replace'] = img_picto(
'',
'replacement',
'class="pictofixedwidth"').$langs->trans(
"Replace");
5612 if ($user->hasRight(
'website',
'write')) {
5613 $langs->load(
"categories");
5614 $arrayofmassactions[
'setcategory'] = img_picto(
'',
'category',
'class="pictofixedwidth"').$langs->trans(
"ClassifyInCategory");
5616 if ($user->hasRight(
'website',
'write')) {
5617 $langs->load(
"categories");
5618 $arrayofmassactions[
'delcategory'] = img_picto(
'',
'category',
'class="pictofixedwidth"').$langs->trans(
"RemoveCategory");
5620 if ($permissiontodelete) {
5621 $arrayofmassactions[
'predelete'] = img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
5623 if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete'))) {
5624 $arrayofmassactions = array();
5627 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
5628 $massactionbutton .=
'<div class="massactionother massactionreplace hidden">';
5629 $massactionbutton .= $langs->trans(
"ReplaceString");
5630 $massactionbutton .=
' <input type="text" name="replacestring" value="'.dol_escape_htmltag(
GETPOST(
'replacestring',
'none')).
'">';
5631 $massactionbutton .=
'</div>';
5632 $massactionbutton .=
'<div class="massactionother massactionsetcategory massactiondelcategory hidden">';
5633 $massactionbutton .= img_picto(
'',
'category',
'class="pictofixedwidth"');
5634 $massactionbutton .= $form->select_all_categories(Categorie::TYPE_WEBSITE_PAGE,
GETPOSTISSET(
'setcategory') ?
GETPOST(
'setcategory') :
'',
'setcategory', 64, 0, 0, 0,
'minwidth300 alignstart');
5635 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
5637 $massactionbutton .=
'</div>';
5639 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
5642 $selectedfields =
'';
5643 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
5645 print_barre_liste($langs->trans(
"Results"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'generic', 0,
'',
'', $limit, 1, 1, 1);
5647 $topicmail =
"WebsitePageRef";
5648 $modelmail =
"websitepage_send";
5649 $objecttmp =
new WebsitePage($db);
5650 $trackid =
'wsp'.$object->id;
5651 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
5653 $param =
'mode=replacesite&website='.urlencode($website->ref);
5654 $param .=
'&searchstring='.urlencode($searchkey);
5655 if (
GETPOST(
'optionpcontent')) {
5656 $param .=
'&optionpcontent=content';
5659 $param .=
'&optionmeta=meta';
5661 if (
GETPOST(
'optionsitefiles')) {
5662 $param .=
'&optionsitefiles=optionsitefiles';
5664 if (
GETPOST(
'optioncontainertype')) {
5665 $param .=
'&optioncontainertype='.GETPOST(
'optioncontainertype',
'aZ09');
5667 if (
GETPOST(
'optionlanguage')) {
5668 $param .=
'&optionlanguage='.GETPOST(
'optionlanguage',
'aZ09');
5670 if (
GETPOST(
'optioncategory')) {
5671 $param .=
'&optioncategory='.GETPOST(
'optioncategory',
'aZ09');
5674 print
'<div class="div-table-responsive-no-min">';
5675 print
'<table class="noborder centpercent">';
5676 print
'<tr class="liste_titre">';
5678 if (
$conf->main_checkbox_left_column) {
5679 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
5681 print
getTitleFieldOfList(
"Type", 0, $_SERVER[
'PHP_SELF'],
'type_container',
'', $param,
'', $sortfield, $sortorder,
'').
"\n";
5682 print
getTitleFieldOfList(
"Page", 0, $_SERVER[
'PHP_SELF'],
'pageurl',
'', $param,
'', $sortfield, $sortorder,
'').
"\n";
5683 print
getTitleFieldOfList(
"Language", 0, $_SERVER[
'PHP_SELF'],
'lang',
'', $param,
'', $sortfield, $sortorder,
'center ').
"\n";
5684 print
getTitleFieldOfList(
"Categories", 0, $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'center ').
"\n";
5686 print
getTitleFieldOfList(
"UserCreation", 0, $_SERVER[
'PHP_SELF'],
'fk_user_creat',
'', $param,
'', $sortfield, $sortorder,
'').
"\n";
5687 print
getTitleFieldOfList(
"DateCreation", 0, $_SERVER[
'PHP_SELF'],
'date_creation',
'', $param,
'', $sortfield, $sortorder,
'center ').
"\n";
5688 print
getTitleFieldOfList(
"DateLastModification", 0, $_SERVER[
'PHP_SELF'],
'tms',
'', $param,
'', $sortfield, $sortorder,
'center ').
"\n";
5691 if (!
$conf->main_checkbox_left_column) {
5692 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
5696 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
5701 foreach ($listofpages[
'list'] as $answerrecord) {
5702 if (is_object($answerrecord) && get_class($answerrecord) ==
'WebsitePage') {
5703 $param =
'?mode=replacesite';
5704 $param .=
'&websiteid='.$website->id;
5705 $param .=
'&optionpcontent='.GETPOST(
'optionpcontent',
'aZ09');
5706 $param .=
'&optionmeta='.GETPOST(
'optionmeta',
'aZ09');
5707 $param .=
'&optionsitefiles='.GETPOST(
'optionsitefiles',
'aZ09');
5708 $param .=
'&optioncontainertype='.GETPOST(
'optioncontainertype',
'aZ09');
5709 $param .=
'&optionlanguage='.GETPOST(
'optionlanguage',
'aZ09');
5710 $param .=
'&optioncategory='.GETPOST(
'optioncategory',
'aZ09');
5711 $param .=
'&searchstring='.urlencode($searchkey);
5716 if (
$conf->main_checkbox_left_column) {
5717 print
'<td class="nowrap center">';
5719 print
'<!-- Status of page -->'.
"\n";
5720 if ($massactionbutton || $massaction) {
5722 if (in_array($answerrecord->id, $arrayofselected)) {
5725 print
'<input id="'.$answerrecord->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$answerrecord->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
5731 print
'<td class="nowraponall">';
5733 if (!empty(
$conf->cache[
'type_of_container'][$answerrecord->type_container])) {
5734 print $langs->trans(
$conf->cache[
'type_of_container'][$answerrecord->type_container]);
5736 print $langs->trans($answerrecord->type_container);
5741 $titleofpage = ($answerrecord->title ? $answerrecord->title : $langs->trans(
"NoTitle"));
5742 print
'<td class="tdoverflowmax300" title="'.dol_escape_htmltag($titleofpage).
'">';
5743 print $answerrecord->getNomUrl(1);
5744 print
' <span class="opacitymedium">('.dol_escape_htmltag($titleofpage).
')</span>';
5748 print
'<span class="opacitymedium">'.dol_escape_htmltag($answerrecord->description ? $answerrecord->description : $langs->trans(
"NoDescription")).
'</span>';
5752 print
'<td class="center">';
5757 print
'<td class="center">';
5758 if (
isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire')) {
5760 $existing =
$c->containing($answerrecord->id, Categorie::TYPE_WEBSITE_PAGE,
'object');
5761 if (is_array($existing)) {
5762 foreach ($existing as $tmpcategory) {
5764 print img_object($langs->trans(
"Category").
' : '.$tmpcategory->label,
'category',
'style="padding-left: 2px; padding-right: 2px; color: #'.($tmpcategory->color !=
'' ? $tmpcategory->color :
'888').
'"');
5772 print
'<td class="center nowraponall">';
5774 $characterMap =
'áàéèëíóúüñùç0123456789';
5775 $nbofwords = str_word_count($textwithouthtml, 0, $characterMap);
5777 print $nbofwords.
' '.$langs->trans(
"words");
5778 $totalnbwords += $nbofwords;
5783 print
'<td class="tdoverflowmax125">';
5784 if (!empty($answerrecord->fk_user_creat)) {
5785 if (empty(
$conf->cache[
'user'][$answerrecord->fk_user_creat])) {
5786 $tmpuser =
new User($db);
5787 $tmpuser->fetch($answerrecord->fk_user_creat);
5788 $conf->cache[
'user'][$answerrecord->fk_user_creat] = $tmpuser;
5790 $tmpuser =
$conf->cache[
'user'][$answerrecord->fk_user_creat];
5792 print $tmpuser->getNomUrl(-1,
'', 0, 0, 0, 0,
'login');
5797 print
'<td class="center nowraponall">';
5802 print
'<td class="center nowraponall">';
5803 print
dol_print_date($answerrecord->date_modification,
'dayhour');
5807 print
'<td class="tdwebsitesearchresult right nowraponall">';
5809 $urltoedithtmlsource = $_SERVER[
"PHP_SELF"].
'?action=editmeta&token='.
newToken().
'&websiteid='.$website->id.
'&pageid='.$answerrecord->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].$param);
5810 if (!$user->hasRight(
'website',
'write')) {
5811 $disabled =
' disabled';
5812 $urltoedithtmlsource =
'';
5814 print
'<a class="editfielda marginleftonly marginrightonly '.$disabled.
'" href="'.$urltoedithtmlsource.
'" title="'.$langs->trans(
"EditPageMeta").
'">'.img_picto($langs->trans(
"EditPageMeta"),
'pencil-ruler').
'</a>';
5817 $urltoedithtmlsource = $_SERVER[
"PHP_SELF"].
'?action=editsource&token='.
newToken().
'&websiteid='.$website->id.
'&pageid='.$answerrecord->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].$param);
5818 if (!$user->hasRight(
'website',
'write')) {
5819 $disabled =
' disabled';
5820 $urltoedithtmlsource =
'';
5822 print
'<a class="editfielda marginleftonly marginrightonly '.$disabled.
'" href="'.$urltoedithtmlsource.
'" title="'.$langs->trans(
"EditHTMLSource").
'">'.img_picto($langs->trans(
"EditHTMLSource"),
'edit').
'</a>';
5824 print
'<span class="marginleftonly marginrightonly"></span>';
5825 print
ajax_object_onoff($answerrecord,
'status',
'status',
'Enabled',
'Disabled', array(),
'valignmiddle inline-block');
5830 if (!
$conf->main_checkbox_left_column) {
5831 print
'<td class="nowrap center">';
5833 print
'<!-- Status of page -->'.
"\n";
5834 if ($massactionbutton || $massaction) {
5836 if (in_array($answerrecord->id, $arrayofselected)) {
5839 print
'<input id="'.$answerrecord->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$answerrecord->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
5847 '@phan-var-force array{type:string} $answerrecord';
5848 $param =
'?mode=replacesite';
5849 $param .=
'&websiteid='.$website->id;
5850 $param .=
'&optionpcontent='.GETPOST(
'optionpcontent',
'aZ09');
5851 $param .=
'&optionmeta='.GETPOST(
'optionmeta',
'aZ09');
5852 $param .=
'&optionsitefiles='.GETPOST(
'optionsitefiles',
'aZ09');
5853 $param .=
'&optioncontainertype='.GETPOST(
'optioncontainertype',
'aZ09');
5854 $param .=
'&optionlanguage='.GETPOST(
'optionlanguage',
'aZ09');
5855 $param .=
'&optioncategory='.GETPOST(
'optioncategory',
'aZ09');
5856 $param .=
'&searchstring='.urlencode($searchkey);
5861 if (
$conf->main_checkbox_left_column) {
5862 print
'<td class="nowrap center">';
5868 $translateofrecordtype = array(
5869 'website_csscontent' =>
'WEBSITE_CSS_INLINE',
5870 'website_jscontent' =>
'WEBSITE_JS_INLINE',
5871 'website_robotcontent' =>
'WEBSITE_ROBOT',
5872 'website_htmlheadercontent' =>
'WEBSITE_HTML_HEADER',
5873 'website_htaccess' =>
'WEBSITE_HTACCESS',
5874 'website_readme' =>
'WEBSITE_README',
5875 'website_manifestjson' =>
'WEBSITE_MANIFEST_JSON'
5877 print
'<span class="opacitymedium">';
5878 if (!empty($translateofrecordtype[$answerrecord[
'type']])) {
5879 print $langs->trans($translateofrecordtype[$answerrecord[
'type']]);
5881 print $answerrecord[
'type'];
5888 $backtopageurl = $_SERVER[
"PHP_SELF"].$param;
5889 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=editcss&token='.
newToken().
'&website='.urlencode($website->ref).
'&backtopage='.urlencode($backtopageurl).
'">'.$langs->trans(
"EditCss").
'</a>';
5911 print
'<td class="center nowraponall">';
5920 if (!
$conf->main_checkbox_left_column) {
5921 print
'<td class="nowrap center">';
5929 if (count($listofpages[
'list']) >= 2) {
5931 print
'<tr class="lite_titre">';
5934 if (
$conf->main_checkbox_left_column) {
5935 print
'<td class="nowrap center">';
5941 print $langs->trans(
"Total");
5957 print
'<td class="center nowraponall">';
5958 print $totalnbwords.
' '.$langs->trans(
"words");
5976 if (!
$conf->main_checkbox_left_column) {
5977 print
'<td class="nowrap center">';
5988 print
'<div class="warning">'.$listofpages[
'message'].
'</div>';
5997if ((empty($action) || $action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone') && !in_array($mode, array(
'replacesite'))) {
5998 if ($pageid > 0 && $atleastonepage) {
6004 $objectpage->fetch($pageid);
6006 $jscontent = @file_get_contents($filejs);
6008 $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";
6017 $out .=
"\n<html><head>\n";
6018 $out .=
"<!-- htmlheader/style of page from database -->\n";
6021 $out .=
"<!-- htmlheader/style of website from files -->\n";
6039 $out .=
"</head>\n";
6044 $out .=
'<div id="websitecontentundertopmenu" class="websitecontentundertopmenu boostrap-iso">'.
"\n";
6048 $out .=
'<!-- style of website from file -->'.
"\n";
6049 $out .=
'<style scoped>'.
"\n";
6051 $tmpout .=
'/* Include website CSS file */'.
"\n";
6056 $csscontent = ob_get_contents();
6062 $tmpout .=
'/* Include style from the HTML header of page */'.
"\n";
6064 $tmp = preg_split(
'(<style[^>]*>|</style>)', $objectpage->htmlheader);
6065 $tmpstyleinheader =
'';
6067 foreach ($tmp as $valtmp) {
6070 $tmpstyleinheader .= $valtmp.
"\n";
6073 $tmpout .= $tmpstyleinheader.
"\n";
6075 $tmpout = preg_replace(
'/}[\s\n]*body\s*{[^}]+}/ims',
'}', $tmpout);
6077 $out .=
'</style>'.
"\n";
6084 $out .=
'<div id="divbodywebsite" class="bodywebsite bodywebpage-'.$objectpage->ref.
'">'.
"\n";
6086 $newcontent = $objectpage->content;
6093 $filephp = $filetpl;
6094 if (!empty($filetplversion)) {
6095 $filephp = $filetplversion;
6099 $savsessionname = session_name();
6100 $savsessionid = $_COOKIE[$savsessionname];
6101 $_COOKIE[$savsessionname] =
'obfuscatedcookie';
6105 $res = include $filephp;
6107 print
"ERROR: Failed to include file '".$filephp.
"'. Try to edit and re-save page with this ID.";
6110 print $e->getMessage();
6112 $newcontent = ob_get_contents();
6117 $_COOKIE[$savsessionname] = $savsessionid;
6125 $newcontent = preg_replace(
'/(<[a-z][a-z0-9]*\s[^>]*)contenteditable="true"/i',
'\1', $newcontent);
6132 $out .=
'</div>'.
"\n";
6134 $out .=
'</div> <!-- End div id=websitecontentundertopmenu -->'.
"\n";
6140 $out .=
"\n</body></html>\n";
6142 $out .=
"\n".
'<!-- End page content '.$filetpl.
' -->'.
"\n\n";
6167 if (empty($websitekey) || $websitekey ==
'-1') {
6168 print
'<br><br><div class="center previewnotyetavailable"><span class="">'.$langs->trans(
"NoWebSiteCreateOneFirst").
'</span></div><br><br><br>';
6169 print
'<div class="center"><div class="logo_setup"></div></div>';
6171 print
'<br><br><div class="center previewnotyetavailable"><span class="">'.$langs->trans(
"PreviewOfSiteNotYetAvailable",
$object->ref).
'</span></div><br><br><br>';
6172 print
'<div class="center"><div class="logo_setup"></div></div>';
write(string $newInnerBlock)
Replace the whole permissions block, markers included, in a single write.
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
global $dolibarr_main_url_root
$propal type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
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='', $placeholder='')
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.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
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...
if(! $sortfield) if(! $sortorder) $module
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.
dolWebsiteGetEditInlineElements($content)
Return the elements with contenteditable="true" and an id found into the source of a page,...
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_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
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...
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
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.
dolChmod($filepath, $newmask='')
Change mod of a file.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into JavaScript code.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
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, or into a js string that is a locat...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
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).
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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)
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).
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
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_get_fiche_end($notab=0)
Return tab footer of a card.
img_previous($titlealt='default', $moreatt='')
Show previous logo.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
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.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='', $cssfordropdown='info_admin')
Show information in HTML for admin users or standard users.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
$conf db name
Only used if Module[ID]Name translation string is not found.
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.
if(empty( $takeposterminal)) fail($message)
Abort invoice creation with a given error message.
multi select button
0 = Do not include form tag and submit button -1 = Do not include form tag but include submit button
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.