25 define(
'NOSCANPOSTFORINJECTION', 1);
26 define(
'NOSTYLECHECK', 1);
27 define(
'USEDOLIBARREDITOR', 1);
28 define(
'FORCE_CKEDITOR', 1);
29 if (!defined(
'DISABLE_JS_GRAHP')) define(
'DISABLE_JS_GRAPH', 1);
33 require
'../main.inc.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/website.lib.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/website2.lib.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formwebsite.class.php';
42 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
43 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
44 require_once DOL_DOCUMENT_ROOT.
'/website/class/website.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/website/class/websitepage.class.php';
46 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
48 $langs->loadLangs(array(
"admin",
"other",
"website",
"errors"));
50 if (!$user->rights->website->read) {
54 $conf->dol_hide_leftmenu = 1;
57 $websiteid =
GETPOST(
'websiteid',
'int');
58 $websitekey =
GETPOST(
'website',
'alpha');
59 $page =
GETPOST(
'page',
'alpha');
60 $pageid =
GETPOST(
'pageid',
'int');
61 $pageref =
GETPOST(
'pageref',
'alphanohtml');
63 $action =
GETPOST(
'action',
'aZ09');
64 $massaction =
GETPOST(
'massaction',
'alpha');
65 $confirm =
GETPOST(
'confirm',
'alpha');
66 $cancel =
GETPOST(
'cancel',
'alpha');
67 $toselect =
GETPOST(
'toselect',
'array');
68 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'websitelist';
69 $backtopage =
GETPOST(
'backtopage',
'alpha');
70 $optioncss =
GETPOST(
'optioncss',
'aZ');
71 $dol_hide_topmenu =
GETPOST(
'dol_hide_topmenu',
'int');
72 $dol_hide_leftmenu =
GETPOST(
'dol_hide_leftmenu',
'int');
73 $dol_openinpopup =
GETPOST(
'dol_openinpopup',
'aZ09');
75 $type_container =
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'alpha');
77 $section_dir =
GETPOST(
'section_dir',
'alpha');
78 $file_manager =
GETPOST(
'file_manager',
'alpha');
79 $replacesite =
GETPOST(
'replacesite',
'alpha');
81 if (
GETPOST(
'deletesite',
'alpha')) {
82 $action =
'deletesite';
84 if (
GETPOST(
'delete',
'alpha')) {
87 if (
GETPOST(
'preview',
'alpha')) {
90 if (
GETPOST(
'createsite',
'alpha')) {
91 $action =
'createsite';
93 if (
GETPOST(
'createcontainer',
'alpha')) {
94 $action =
'createcontainer';
96 if (
GETPOST(
'editcss',
'alpha')) {
99 if (
GETPOST(
'editmenu',
'alpha')) {
100 $action =
'editmenu';
102 if (
GETPOST(
'setashome',
'alpha')) {
103 $action =
'setashome';
105 if (
GETPOST(
'editmeta',
'alpha')) {
106 $action =
'editmeta';
108 if (
GETPOST(
'editsource',
'alpha')) {
109 $action =
'editsource';
111 if (
GETPOST(
'editcontent',
'alpha')) {
112 $action =
'editcontent';
114 if (
GETPOST(
'exportsite',
'alpha')) {
115 $action =
'exportsite';
117 if (
GETPOST(
'importsite',
'alpha')) {
118 $action =
'importsite';
120 if (
GETPOST(
'createfromclone',
'alpha')) {
121 $action =
'createfromclone';
123 if (
GETPOST(
'createpagefromclone',
'alpha')) {
124 $action =
'createpagefromclone';
126 if (empty($action) && $file_manager) {
127 $action =
'file_manager';
129 if (empty($action) && $replacesite) {
130 $action =
'replacesite';
137 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
138 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
139 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
141 if (empty($page) || $page == -1) {
144 $offset = $limit * $page;
145 $pageprev = $page - 1;
146 $pagenext = $page + 1;
150 if (empty($action)) {
157 $object->fetchAll(
'ASC',
'position');
160 if (!($websiteid > 0) && empty($websitekey) && $action !=
'createsite') {
161 foreach ($object->records as $key => $valwebsite) {
162 $websitekey = $valwebsite->ref;
166 if ($websiteid > 0 || $websitekey) {
167 $res = $object->fetch($websiteid, $websitekey);
168 $websitekey = $object->ref;
177 if (($pageid > 0 || $pageref) && $action !=
'addcontainer') {
178 $res = $objectpage->fetch($pageid, ($object->id > 0 ? $object->id :
null), $pageref);
180 $res = $objectpage->fetch($pageid, ($object->id > 0 ? $object->id :
null),
null, $pageref);
184 if ($res >= 0 && $object->id > 0) {
185 if ($objectpage->fk_website != $object->id) {
186 if ($object->fk_default_home > 0) {
187 $res = $objectpage->fetch($object->fk_default_home, $object->id,
'');
189 $pageid = $object->fk_default_home;
192 $res = $objectpage->fetch(0, $object->id,
'');
197 $pageid = $objectpage->id;
202 $pageid = $objectpage->id;
208 if (empty($pageid) && empty($pageref) && $object->id > 0 && $action !=
'createcontainer') {
209 $pageid = $object->fk_default_home;
210 if (empty($pageid)) {
211 $array = $objectpage->fetchAll($object->id,
'ASC,ASC',
'type_container,pageurl');
212 if (!is_array($array) && $array < 0) {
215 $atleastonepage = (is_array($array) && count($array) > 0);
217 $firstpageid = 0; $homepageid = 0;
218 foreach ($array as $key => $valpage) {
219 if (empty($firstpageid)) {
220 $firstpageid = $valpage->id;
222 if ($object->fk_default_home && $key == $object->fk_default_home) {
223 $homepageid = $valpage->id;
226 $pageid = ($homepageid ? $homepageid : $firstpageid);
231 global $dolibarr_main_data_root;
232 $pathofwebsite = $dolibarr_main_data_root.($conf->entity > 1 ?
'/'.$conf->entity :
'').
'/website/'.$websitekey;
233 $filehtmlheader = $pathofwebsite.
'/htmlheader.html';
234 $filecss = $pathofwebsite.
'/styles.css.php';
235 $filejs = $pathofwebsite.
'/javascript.js.php';
236 $filerobot = $pathofwebsite.
'/robots.txt';
237 $filehtaccess = $pathofwebsite.
'/.htaccess';
238 $filetpl = $pathofwebsite.
'/page'.$pageid.
'.tpl.php';
239 $fileindex = $pathofwebsite.
'/index.php';
240 $filewrapper = $pathofwebsite.
'/wrapper.php';
241 $filemanifestjson = $pathofwebsite.
'/manifest.json.php';
242 $filereadme = $pathofwebsite.
'/README.md';
243 $filemaster = $pathofwebsite.
'/master.inc.php';
246 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
247 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
251 $permtouploadfile = $user->rights->website->write;
252 $diroutput = $conf->medias->multidir_output[$conf->entity];
254 $relativepath = $section_dir;
255 $upload_dir = preg_replace(
'/\/$/',
'', $diroutput).
'/'.preg_replace(
'/^\//',
'', $relativepath);
257 $htmlheadercontentdefault =
'';
258 $htmlheadercontentdefault .=
'<link rel="stylesheet" id="google-fonts-css" href="//fonts.googleapis.com/css?family=Open+Sans:300,400,700" />'.
"\n";
259 $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";
260 $htmlheadercontentdefault .=
'<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>'.
"\n";
261 $htmlheadercontentdefault .=
'<script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>'.
"\n";
262 $htmlheadercontentdefault .=
'<script src="//cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js"></script>'.
"\n";
263 $htmlheadercontentdefault .=
'<script src="//cdnjs.cloudflare.com/ajax/libs/popper.js/1.13.0/umd/popper.min.js"></script>'.
"\n";
264 $htmlheadercontentdefault .=
'<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>'.
"\n";
265 $htmlheadercontentdefault .=
'<!--'.
"\n";
266 $htmlheadercontentdefault .=
'<script src="/document.php?modulepart=medias&file=css/myfile.css"></script>'.
"\n";
267 $htmlheadercontentdefault .=
'<script src="/document.php?modulepart=medias&file=js/myfile.js"></script>'.
"\n";
268 $htmlheadercontentdefault .=
'-->'.
"\n";
270 $manifestjsoncontentdefault =
'';
271 $manifestjsoncontentdefault .=
'{
273 "short_name": "MyWebsite",
276 "display": "standalone",
277 "background_color": "#fff",
278 "description": "A simple Web app.",
280 "src": "images/'.urlencode($website->ref).
'/homescreen48.png",
284 "src": "image/'.urlencode($website->ref).
'/homescreen72.png",
288 "src": "image/'.urlencode($website->ref).
'/homescreen96.png",
292 "src": "image/'.urlencode($website->ref).
'/homescreen144.png",
296 "src": "image/'.urlencode($website->ref).
'/homescreen168.png",
300 "src": "image/'.urlencode($website->ref).
'/homescreen192.png",
304 "related_applications": [{
306 "url": "https://play.google.com/store/apps/details?id=com.nltechno.dolidroidpro"
310 $listofpages = array();
316 if (
GETPOST(
'optioncontent')) {
319 if (
GETPOST(
'optionsitefiles')) {
320 $algo .=
'sitefiles';
323 if (empty($sortfield)) {
324 if ($action ==
'file_manager') {
325 $sortfield =
'name'; $sortorder =
'ASC';
327 $sortfield =
'pageurl'; $sortorder =
'ASC';
331 $searchkey =
GETPOST(
'searchstring',
'restricthtml');
333 if ($action ==
'replacesiteconfirm') {
334 $containertype =
GETPOST(
'optioncontainertype',
'aZ09') !=
'-1' ?
GETPOST(
'optioncontainertype',
'aZ09') :
'';
335 $langcode =
GETPOST(
'optionlanguage',
'aZ09');
336 $otherfilters = array();
337 if (
GETPOST(
'optioncategory',
'int') > 0) {
338 $otherfilters[
'category'] =
GETPOST(
'optioncategory',
'int');
341 $listofpages =
getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters, -1);
344 $usercanedit = $user->rights->website->write;
345 $permissiontoadd = $user->rights->website->write;
346 $permissiontodelete = $user->rights->website->delete;
357 if (
GETPOST(
'refreshsite',
'alpha') ||
GETPOST(
'refreshsite.x',
'alpha') ||
GETPOST(
'refreshsite_x',
'alpha')) {
358 if ($action ==
'addsite') {
361 if ($action ==
'updatesource') {
365 $pageid = $object->fk_default_home;
366 if (empty($pageid)) {
367 $array = $objectpage->fetchAll($object->id,
'ASC,ASC',
'type_container,pageurl');
368 if (!is_array($array) && $array < 0) {
371 $atleastonepage = (is_array($array) && count($array) > 0);
373 $firstpageid = 0; $homepageid = 0;
374 foreach ($array as $key => $valpage) {
375 if (empty($firstpageid)) {
376 $firstpageid = $valpage->id;
378 if ($object->fk_default_home && $key == $object->fk_default_home) {
379 $homepageid = $valpage->id;
382 $pageid = ($homepageid ? $homepageid : $firstpageid);
385 if (
GETPOST(
'refreshpage',
'alpha') && !in_array($action, array(
'updatecss'))) {
389 if ($cancel && $action ==
'renamefile') {
397 header(
"Location: ".$backtopage);
402 $savbacktopage = $backtopage;
403 $backtopage = $_SERVER[
"PHP_SELF"].
'?file_manager=1&website='.urlencode($websitekey).
'&pageid='.urlencode($pageid).(GETPOST(
'section_dir',
'alpha') ?
'§ion_dir='.urlencode(
GETPOST(
'section_dir',
'alpha')) :
'');
405 $backtopage .=
'&sortfield='.urlencode($sortfield);
408 $backtopage .=
'&sortorder='.urlencode($sortorder);
410 include DOL_DOCUMENT_ROOT.
'/core/actions_linkedfiles.inc.php';
412 $backtopage = $savbacktopage;
416 if ($action ==
'renamefile') {
417 $action =
'file_manager';
420 if ($action ==
'seteditinline') {
422 setEventMessages($langs->trans(
"FeatureNotYetAvailable"),
null,
'warnings');
424 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.
GETPOST(
'website',
'alphanohtml').
'&pageid='.
GETPOST(
'pageid',
'int'));
427 if ($action ==
'unseteditinline') {
429 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.
GETPOST(
'website',
'alphanohtml').
'&pageid='.
GETPOST(
'pageid',
'int'));
432 if ($action ==
'setshowsubcontainers') {
435 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.
GETPOST(
'website',
'alphanohtml').
'&pageid='.
GETPOST(
'pageid',
'int'));
438 if ($action ==
'unsetshowsubcontainers') {
440 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.
GETPOST(
'website',
'alphanohtml').
'&pageid='.
GETPOST(
'pageid',
'int'));
444 if ($massaction ==
'replace' &&
GETPOST(
'confirmmassaction',
'alpha') && !$searchkey) {
445 $action =
'replacesite';
450 if ($massaction ==
'setcategory' &&
GETPOST(
'confirmmassaction',
'alpha') && $usercanedit) {
456 $categoryid =
GETPOST(
'setcategory',
'restricthtml');
457 if ($categoryid > 0) {
460 $category->fetch($categoryid);
462 foreach ($toselect as $tmpid) {
463 $tmpwebsitepage->id = $tmpid;
464 $result = $category->add_type($tmpwebsitepage,
'website_page');
465 if ($result < 0 && $result != -3) {
479 setEventMessages($langs->trans(
"RecordsModified", $nbupdate),
null,
'mesgs');
485 $listofpages =
getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters, -1);
489 if ($massaction ==
'replace' &&
GETPOST(
'confirmmassaction',
'alpha') && $usercanedit) {
490 $replacestring =
GETPOST(
'replacestring',
'none');
492 if (empty($user->rights->website->writephp)) {
494 } elseif (!$replacestring) {
499 foreach ($toselect as $keyselected) {
500 $objectpage = $listofpages[
'list'][$keyselected];
501 if ($objectpage->pageurl) {
502 dol_syslog(
"Replace string into page ".$objectpage->pageurl);
504 if (
GETPOST(
'optioncontent',
'aZ09')) {
505 $objectpage->content = str_replace($searchkey, $replacestring, $objectpage->content);
507 if (
GETPOST(
'optionmeta',
'aZ09')) {
508 $objectpage->title = str_replace($searchkey, $replacestring, $objectpage->title);
509 $objectpage->description = str_replace($searchkey, $replacestring, $objectpage->description);
510 $objectpage->keywords = str_replace($searchkey, $replacestring, $objectpage->keywords);
513 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
514 $filetpl = $pathofwebsite.
'/page'.$objectpage->id.
'.tpl.php';
519 setEventMessages(
'Failed to write file '.basename($filealias),
null,
'errors');
527 $objectpage->update($user);
531 $action =
'createcontainer';
537 if ($nbreplacement > 0) {
538 setEventMessages($langs->trans(
"ReplacementDoneInXPages", $nbreplacement),
null,
'mesgs');
541 $containertype =
GETPOST(
'optioncontainertype',
'aZ09') !=
'-1' ?
GETPOST(
'optioncontainertype',
'aZ09') :
'';
542 $langcode =
GETPOST(
'optionlanguage',
'aZ09');
543 $otherfilters = array();
544 if (
GETPOST(
'optioncategory',
'int') > 0) {
545 $otherfilters[
'category'] =
GETPOST(
'optioncategory',
'int');
549 $listofpages =
getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters);
579 if ($action ==
'addsite' && $usercanedit) {
582 if (
GETPOST(
'virtualhost',
'alpha') && !preg_match(
'/^http/',
GETPOST(
'virtualhost',
'alpha'))) {
584 setEventMessages($langs->trans(
'ErrorURLMustStartWithHttp', $langs->transnoentitiesnoconv(
"VirtualHost")),
null,
'errors');
587 if (!$error && !
GETPOST(
'WEBSITE_REF',
'alpha')) {
589 $langs->load(
"errors");
590 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->transnoentities(
"Ref")),
null,
'errors');
592 if (!$error && !preg_match(
'/^[a-z0-9_\-\.]+$/i',
GETPOST(
'WEBSITE_REF',
'alpha'))) {
594 $langs->load(
"errors");
595 setEventMessages($langs->transnoentities(
"ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities(
"Ref")),
null,
'errors');
599 $arrayotherlang = explode(
',',
GETPOST(
'WEBSITE_OTHERLANG',
'alphanohtml'));
600 foreach ($arrayotherlang as $key => $val) {
602 if (empty(trim($val)))
continue;
603 $arrayotherlang[$key] = substr(trim($val), 0, 2);
607 $tmpobject->ref =
GETPOST(
'WEBSITE_REF',
'alpha');
608 $tmpobject->description =
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml');
609 $tmpobject->lang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
610 $tmpobject->otherlang = join(
',', $arrayotherlang);
611 $tmpobject->virtualhost =
GETPOST(
'virtualhost',
'alpha');
613 $result = $tmpobject->create($user);
625 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$tmpobject->ref);
629 $action =
'createsite';
639 if ($action ==
'addcontainer' && $usercanedit) {
644 $objectpage->fk_website = $object->id;
647 $urltograb =
GETPOST(
'externalurl',
'alpha');
648 $grabimages =
GETPOST(
'grabimages',
'alpha');
649 $grabimagesinto =
GETPOST(
'grabimagesinto',
'alpha');
651 include_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
653 if (empty($urltograb)) {
655 $langs->load(
"errors");
656 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"URL")),
null,
'errors');
657 $action =
'createcontainer';
658 } elseif (!preg_match(
'/^http/', $urltograb)) {
660 $langs->load(
"errors");
661 setEventMessages(
'Error URL must start with http:// or https://',
null,
'errors');
662 $action =
'createcontainer';
668 $urltograbwithoutdomainandparam = preg_replace(
'/^https?:\/\/[^\/]+\/?/i',
'', $urltograb);
670 $urltograbwithoutdomainandparam = preg_replace(
'/\?.*$/',
'', $urltograbwithoutdomainandparam);
671 if (empty($urltograbwithoutdomainandparam) && !preg_match(
'/\/$/', $urltograb)) {
674 $pageurl =
dol_sanitizeFileName(preg_replace(
'/[\/\.]/',
'-', preg_replace(
'/\/+$/',
'', $urltograbwithoutdomainandparam)));
676 $urltograbdirwithoutslash = dirname($urltograb.
'.');
685 $result = $tmpwebsitepage->fetch(0, $object->id, $pageurl);
687 setEventMessages($langs->trans(
"AliasPageAlreadyExists", $pageurl),
null,
'errors');
689 $action =
'createcontainer';
694 $tmp =
getURLContent($urltograb,
'GET',
'', 1, array(), array(
'http',
'https'), 0);
695 if ($tmp[
'curl_error_no']) {
697 setEventMessages(
'Error getting '.$urltograb.
': '.$tmp[
'curl_error_msg'],
null,
'errors');
698 $action =
'createcontainer';
699 } elseif ($tmp[
'http_code'] !=
'200') {
701 setEventMessages(
'Error getting '.$urltograb.
': '.$tmp[
'http_code'],
null,
'errors');
702 $action =
'createcontainer';
709 preg_match(
'/<head>(.*)<\/head>/ims', $tmp[
'content'], $regs);
712 $objectpage->type_container =
'page';
713 $objectpage->pageurl = $pageurl;
714 if (empty($objectpage->pageurl)) {
716 $objectpage->pageurl = $tmpdomain.
'-home';
719 $objectpage->aliasalt =
'';
721 if (preg_match(
'/^(\d+)\-/', basename($urltograb), $regs)) {
722 $objectpage->aliasalt = $regs[1];
726 if (preg_match(
'/<title>(.*)<\/title>/ims', $head, $regtmp)) {
727 $objectpage->title = $regtmp[1];
729 if (preg_match(
'/<meta name="title"[^"]+content="([^"]+)"/ims', $head, $regtmp)) {
730 if (empty($objectpage->title)) {
731 $objectpage->title = $regtmp[1];
734 if (preg_match(
'/<meta name="description"[^"]+content="([^"]+)"/ims', $head, $regtmp)) {
735 $objectpage->description = $regtmp[1];
737 if (preg_match(
'/<meta name="keywords"[^"]+content="([^"]+)"/ims', $head, $regtmp)) {
738 $objectpage->keywords = $regtmp[1];
740 if (preg_match(
'/<html\s+lang="([^"]+)"/ims', $tmp[
'content'], $regtmp)) {
741 $tmplang = explode(
'-', $regtmp[1]);
742 $objectpage->lang = $tmplang[0].($tmplang[1] ?
'_'.strtoupper($tmplang[1]) :
'');
745 $tmp[
'content'] = preg_replace(
'/\s*<meta name="generator"[^"]+content="([^"]+)"\s*\/?>/ims',
'', $tmp[
'content']);
747 $objectpage->content = $tmp[
'content'];
748 $objectpage->content = preg_replace(
'/^.*<body(\s[^>]*)*>/ims',
'', $objectpage->content);
749 $objectpage->content = preg_replace(
'/<\/body(\s[^>]*)*>.*$/ims',
'', $objectpage->content);
751 $absoluteurlinaction = $urltograbdirwithoutslash;
758 $objectpage->htmlheader = $tmp[
'content'];
759 $objectpage->htmlheader = preg_replace(
'/^.*<head(\s[^>]*)*>/ims',
'', $objectpage->htmlheader);
760 $objectpage->htmlheader = preg_replace(
'/<\/head(\s[^>]*)*>.*$/ims',
'', $objectpage->htmlheader);
761 $objectpage->htmlheader = preg_replace(
'/<base(\s[^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
762 $objectpage->htmlheader = preg_replace(
'/<meta http-equiv="content-type"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
763 $objectpage->htmlheader = preg_replace(
'/<meta name="robots"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
764 $objectpage->htmlheader = preg_replace(
'/<meta name="title"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
765 $objectpage->htmlheader = preg_replace(
'/<meta name="description"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
766 $objectpage->htmlheader = preg_replace(
'/<meta name="keywords"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
767 $objectpage->htmlheader = preg_replace(
'/<meta name="generator"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
770 $objectpage->htmlheader = preg_replace(
'/<title>[^<]*<\/title>\n*/ims',
'', $objectpage->htmlheader);
771 $objectpage->htmlheader = preg_replace(
'/<link[^>]*rel="shortcut[^>]*>\n/ims',
'', $objectpage->htmlheader);
772 $objectpage->htmlheader = preg_replace(
'/<link[^>]*rel="alternate[^>]*>\n/ims',
'', $objectpage->htmlheader);
773 $objectpage->htmlheader = preg_replace(
'/<link[^>]*rel="canonical[^>]*>\n/ims',
'', $objectpage->htmlheader);
776 $tmp = $objectpage->htmlheader;
779 preg_match_all(
'/<script([^\.>]+)src=["\']([^"\'>]+)["\']([^>]*)><\/script>/i', $objectpage->htmlheader, $regs);
780 $errorforsubresource = 0;
781 foreach ($regs[0] as $key => $val) {
782 dol_syslog(
"We will grab the script resource found into script tag ".$regs[2][$key]);
784 $linkwithoutdomain = $regs[2][$key];
785 if (preg_match(
'/^\//', $regs[2][$key])) {
786 $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key];
788 $urltograbbis = $urltograbdirwithoutslash.
'/'.$regs[2][$key];
792 if (preg_match(
'/^http/', $regs[2][$key])) {
793 $urltograbbis = $regs[2][$key];
794 $linkwithoutdomain = preg_replace(
'/^https?:\/\/[^\/]+\//i',
'', $regs[2][$key]);
804 if ($domaintograb != $domaintograbbis) {
837 $tmp = preg_replace(
'/'.preg_quote($regs[0][$key],
'/').
'/i',
'', $tmp);
839 $objectpage->htmlheader = trim($tmp).
"\n";
843 $pagecsscontent =
"\n".
'<style>'.
"\n";
845 preg_match_all(
'/<link([^\.>]+)href=["\']([^"\'>]+\.css[^"\'>]*)["\']([^>]*)>/i', $objectpage->htmlheader, $regs);
846 $errorforsubresource = 0;
847 foreach ($regs[0] as $key => $val) {
848 dol_syslog(
"We will grab the css resources found into link tag ".$regs[2][$key]);
850 $linkwithoutdomain = $regs[2][$key];
851 if (preg_match(
'/^\//', $regs[2][$key])) {
852 $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key];
854 $urltograbbis = $urltograbdirwithoutslash.
'/'.$regs[2][$key];
858 if (preg_match(
'/^http/', $regs[2][$key])) {
859 $urltograbbis = $regs[2][$key];
860 $linkwithoutdomain = preg_replace(
'/^https?:\/\/[^\/]+\//i',
'', $regs[2][$key]);
870 if ($domaintograb != $domaintograbbis) {
874 $tmpgeturl =
getURLContent($urltograbbis,
'GET',
'', 1, array(), array(
'http',
'https'), 0);
875 if ($tmpgeturl[
'curl_error_no']) {
876 $errorforsubresource++;
877 setEventMessages(
'Error getting link tag url '.$urltograbbis.
': '.$tmpgeturl[
'curl_error_msg'],
null,
'errors');
878 dol_syslog(
'Error getting '.$urltograbbis.
': '.$tmpgeturl[
'curl_error_msg']);
879 $action =
'createcontainer';
880 } elseif ($tmpgeturl[
'http_code'] !=
'200') {
881 $errorforsubresource++;
882 setEventMessages(
'Error getting link tag url '.$urltograbbis.
': '.$tmpgeturl[
'http_code'],
null,
'errors');
883 dol_syslog(
'Error getting '.$urltograbbis.
': '.$tmpgeturl[
'curl_error_msg']);
884 $action =
'createcontainer';
893 $tmpgeturl[
'content'] = preg_replace(
'/\/\*\s+CSS content[a-z\s]*\s+\*\//',
'', $tmpgeturl[
'content']);
904 $pagecsscontent .=
'/* Content of file '.$urltograbbis.
' */'.
"\n";
906 getAllImages($object, $objectpage, $urltograbbis, $tmpgeturl[
'content'], $action, 1, $grabimages, $grabimagesinto);
909 include_once DOL_DOCUMENT_ROOT.
'/core/class/lessc.class.php';
910 $lesscobj =
new Lessc();
912 $contentforlessc =
".bodywebsite {\n".$tmpgeturl[
'content'].
"\n}\n";
914 $contentforlessc = $lesscobj->compile($contentforlessc);
917 $pagecsscontent .= $contentforlessc.
"\n";
919 }
catch (exception $e) {
921 dol_syslog(
"Failed to compile the CSS from URL ".$urltograbbis.
" with lessc: ".$e->getMessage(), LOG_WARNING);
922 $pagecsscontent .= $tmpgeturl[
'content'].
"\n";
925 $objectpage->htmlheader = preg_replace(
'/'.preg_quote($regs[0][$key],
'/').
'\n*/ims',
'', $objectpage->htmlheader);
929 $pagecsscontent .=
'</style>';
933 $objectpage->htmlheader .= trim($pagecsscontent).
"\n";
937 $tmp = $objectpage->content;
939 getAllImages($object, $objectpage, $urltograb, $tmp, $action, 1, $grabimages, $grabimagesinto);
942 $tmp = preg_replace(
'/a href="\/([^\/"]+)\/([^\/"]+)"/',
'a href="/\1-\2.php"', $tmp);
943 $tmp = preg_replace(
'/a href="\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)"/',
'a href="/\1-\2-\3.php"', $tmp);
944 $tmp = preg_replace(
'/a href="\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)"/',
'a href="/\1-\2-\3-\4.php"', $tmp);
947 $objectpage->content = $tmp;
949 $objectpage->grabbed_from = $urltograb;
954 if (!$error &&
GETPOST(
'WEBSITE_ALIASALT',
'alpha')) {
955 $arrayofaliastotest = explode(
',', str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_ALIASALT',
'alpha')));
957 foreach ($arrayofaliastotest as $aliastotest) {
958 $aliastotest = trim(preg_replace(
'/\.php$/i',
'', $aliastotest));
961 if (preg_match(
'/^page\d+/i', $aliastotest)) {
963 $langs->load(
"errors");
965 $action =
'createcontainer';
968 $result = $websitepagetemp->fetch(0, $object->id, $aliastotest);
971 $langs->load(
"errors");
972 setEventMessages($websitepagetemp->error, $websitepagetemp->errors,
'errors');
973 $action =
'createcontainer';
978 $langs->load(
"errors");
979 setEventMessages($langs->trans(
"ErrorAPageWithThisNameOrAliasAlreadyExists", $websitepagetemp->pageurl),
null,
'errors');
980 $action =
'createcontainer';
983 $newaliasnames .= ($newaliasnames ?
', ' :
'').$aliastotest;
988 $objectpage->title = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_TITLE',
'alphanohtml'));
989 $objectpage->type_container =
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'aZ09');
990 $objectpage->pageurl =
GETPOST(
'WEBSITE_PAGENAME',
'alpha');
991 $objectpage->aliasalt = $newaliasnames;
992 $objectpage->description = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml'));
993 $objectpage->lang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
994 $objectpage->otherlang =
GETPOST(
'WEBSITE_OTHERLANG',
'aZ09comma');
995 $objectpage->image =
GETPOST(
'WEBSITE_IMAGE',
'alpha');
996 $objectpage->keywords = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_KEYWORDS',
'alphanohtml'));
997 $objectpage->allowed_in_frames =
GETPOST(
'WEBSITE_ALLOWED_IN_FRAMES',
'aZ09');
998 $objectpage->htmlheader =
GETPOST(
'htmlheader',
'none');
999 $objectpage->author_alias =
GETPOST(
'WEBSITE_AUTHORALIAS',
'alphanohtml');
1000 $objectpage->object_type =
GETPOST(
'WEBSITE_OBJECTCLASS');
1001 $objectpage->fk_object =
GETPOST(
'WEBSITE_OBJECTID');
1002 $substitutionarray = array();
1003 $substitutionarray[
'__WEBSITE_CREATE_BY__'] = $user->getFullName($langs);
1006 $pageidfortranslation = (
GETPOST(
'pageidfortranslation',
'int') > 0 ?
GETPOST(
'pageidfortranslation',
'int') : 0);
1007 if ($pageidfortranslation > 0) {
1010 $objectpagetmp->fetch($pageidfortranslation);
1011 if ($objectpagetmp->fk_page > 0) {
1012 $pageidfortranslation = $objectpagetmp->fk_page;
1015 $objectpage->fk_page = $pageidfortranslation;
1017 $sample =
GETPOST(
'sample',
'alpha');
1018 if (empty($sample)) {
1022 $pathtosample = DOL_DOCUMENT_ROOT.
'/website/samples/page-sample-'.
dol_sanitizeFileName($sample).
'.html';
1025 $objectpage->content =
make_substitutions(@file_get_contents($pathtosample), $substitutionarray);
1029 if (empty($objectpage->pageurl)) {
1030 $langs->load(
"errors");
1031 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WEBSITE_PAGENAME")),
null,
'errors');
1033 $action =
'createcontainer';
1034 } elseif (!preg_match(
'/^[a-z0-9\-\_]+$/i', $objectpage->pageurl)) {
1035 $langs->load(
"errors");
1036 setEventMessages($langs->transnoentities(
"ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities(
'WEBSITE_PAGENAME')),
null,
'errors');
1038 $action =
'createcontainer';
1040 if (empty($objectpage->title)) {
1041 $langs->load(
"errors");
1042 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WEBSITE_TITLE")),
null,
'errors');
1044 $action =
'createcontainer';
1046 if ($objectpage->fk_page > 0 && empty($objectpage->lang)) {
1047 $langs->load(
"errors");
1048 setEventMessages($langs->trans(
"ErrorLanguageRequiredIfPageIsTranslationOfAnother"),
null,
'errors');
1050 $action =
'createcontainer';
1052 if ($objectpage->fk_page > 0 && !empty($objectpage->lang)) {
1053 if ($objectpage->lang == $website->lang) {
1054 $langs->load(
"errors");
1055 setEventMessages($langs->trans(
"ErrorLanguageMustNotBeSourceLanguageIfPageIsTranslationOfAnother"),
null,
'errors');
1057 $action =
'createcontainer';
1063 $pageid = $objectpage->create($user);
1067 $action =
'createcontainer';
1073 $categoriesarray =
GETPOST(
'categories',
'array');
1074 $result = $objectpage->setCategories($categoriesarray);
1083 if (empty($object->fk_default_home)) {
1084 $object->fk_default_home = $pageid;
1085 $res = $object->update($user);
1090 $filetpl = $pathofwebsite.
'/page'.$pageid.
'.tpl.php';
1093 $result =
dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper, $object);
1103 if (!empty($objectpage->content)) {
1104 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
1105 $filetpl = $pathofwebsite.
'/page'.$objectpage->id.
'.tpl.php';
1110 setEventMessages(
'Failed to write file '.basename($filealias),
null,
'errors');
1119 $action =
'createcontainer';
1126 setEventMessages($langs->trans(
"PageAdded", $objectpage->pageurl),
null,
'mesgs');
1133 $pageid = $objectpage->id;
1138 $pathtomedias = DOL_DATA_ROOT.
'/medias';
1139 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
1141 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
1142 dol_mkdir(dirname($pathtomediasinwebsite));
1143 $result = symlink($pathtomedias, $pathtomediasinwebsite);
1156 $htmlheadercontent =
"<html>\n";
1157 $htmlheadercontent .= $htmlheadercontentdefault;
1158 $htmlheadercontent .=
"</html>";
1163 $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;}";
1168 $jscontent =
"/* JS content (all pages) */\n";
1173 $robotcontent =
"# Robot file. Generated with Dolibarr\nUser-agent: *\nAllow: /public/\nDisallow: /administrator/";
1178 $htaccesscontent =
"# Order allow,deny\n# Deny from all";
1183 $manifestjsoncontent =
"";
1188 $readmecontent =
"Website generated by Dolibarr ERP CRM";
1192 $action =
'preview';
1197 if ($action ==
'confirm_deletesite' && $confirm ==
'yes' && $permissiontodelete) {
1202 $res = $object->fetch(
GETPOST(
'id',
'int'));
1206 $res = $object->delete($user);
1213 if (
GETPOST(
'delete_also_js',
'alpha') ==
'on') {
1214 $pathofwebsitejs = DOL_DATA_ROOT.
'/medias/js/'.$object->ref;
1218 if (
GETPOST(
'delete_also_medias',
'alpha') ==
'on') {
1219 $pathofwebsitemedias = DOL_DATA_ROOT.
'/medias/image/'.$object->ref;
1227 setEventMessages($langs->trans(
"SiteDeleted", $object->ref),
null,
'mesgs');
1229 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.$object->id);
1238 if (
GETPOSTISSET(
'pageid') && $action ==
'delete' && $permissiontodelete && !
GETPOST(
'file_manager')) {
1243 $res = $object->fetch(0, $websitekey);
1246 $res = $objectpage->fetch($pageid, $object->id);
1249 $res = $objectpage->delete($user);
1258 setEventMessages($langs->trans(
"PageDeleted", $objectpage->pageurl, $websitekey),
null,
'mesgs');
1260 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$websitekey);
1269 $objectclass =
'WebsitePage';
1273 if (!$error && ($massaction ==
'delete' || ($action ==
'delete' && $confirm ==
'yes')) && $permissiontodelete) {
1276 $objecttmp =
new $objectclass($db);
1278 foreach ($toselect as $toselectid) {
1279 $result = $objecttmp->fetch($toselectid);
1281 $result = $objecttmp->delete($user);
1310 if ($action ==
'delete') {
1311 $action =
'replacesiteconfirm';
1313 $containertype =
GETPOST(
'optioncontainertype',
'aZ09') !=
'-1' ?
GETPOST(
'optioncontainertype',
'aZ09') :
'';
1314 $langcode =
GETPOST(
'optionlanguage',
'aZ09');
1315 $otherfilters = array();
1316 if (
GETPOST(
'optioncategory',
'int') > 0) {
1317 $otherfilters[
'category'] =
GETPOST(
'optioncategory',
'int');
1320 $listofpages =
getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters);
1325 if ($action ==
'updatecss' && $usercanedit) {
1328 $action =
'editcss';
1330 $res = $object->fetch(0, $websitekey);
1334 $tmpvirtualhost = preg_replace(
'/\/$/',
'',
GETPOST(
'virtualhost',
'alpha'));
1335 if ($tmpvirtualhost && !preg_match(
'/^http/', $tmpvirtualhost)) {
1337 setEventMessages($langs->trans(
'ErrorURLMustStartWithHttp', $langs->transnoentitiesnoconv(
"VirtualHost")),
null,
'errors');
1338 $action =
'editcss';
1342 $arrayotherlang = explode(
',',
GETPOST(
'WEBSITE_OTHERLANG',
'alphanohtml'));
1343 foreach ($arrayotherlang as $key => $val) {
1345 if (empty(trim($val)))
continue;
1346 $arrayotherlang[$key] = substr(trim($val), 0, 2);
1349 $object->virtualhost = $tmpvirtualhost;
1350 $object->lang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
1351 $object->otherlang = join(
',', $arrayotherlang);
1352 $object->use_manifest =
GETPOST(
'use_manifest',
'alpha');
1354 $result = $object->update($user);
1358 $action =
'editcss';
1364 if (($_FILES[
'addedfile'][
"name"] !=
'')) {
1365 $uploadfolder = $conf->website->dir_output.
'/'.$websitekey;
1366 if ($_FILES[
'addedfile'][
'type'] !=
'image/png') {
1370 $filetoread = realpath(
dol_osencode($_FILES[
'addedfile'][
'tmp_name']));
1371 $filesize = getimagesize($filetoread);
1372 if ($filesize[0] != $filesize[1]) {
1374 setEventMessages($langs->trans(
'ErrorFaviconMustBeASquaredImage'), array(),
'errors');
1376 if (! $error && ($filesize[0] != 16 && $filesize[0] != 32 && $filesize[0] != 64)) {
1386 $action =
'preview';
1388 $backtopage = preg_replace(
'/searchstring=[^&]*/',
'', $backtopage);
1389 header(
"Location: ".$backtopage);
1393 $action =
'editcss';
1412 $dataposted = trim(
GETPOST(
'WEBSITE_HTML_HEADER',
'none'));
1413 $dataposted = preg_replace(array(
'/<html>\n*/ims',
'/<\/html>\n*/ims'), array(
'',
''), $dataposted);
1414 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1417 $phpfullcodestringold =
'';
1421 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1423 if (!$errorphpcheck) {
1424 $htmlheadercontent =
'';
1436 $htmlheadercontent .= $dataposted.
"\n";
1451 $dataposted = trim(
GETPOST(
'WEBSITE_CSS_INLINE',
'none'));
1452 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1455 $phpfullcodestringold =
'';
1459 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1461 if (!$errorphpcheck) {
1464 $csscontent .=
"<?php // BEGIN PHP\n";
1465 $csscontent .=
'$websitekey=basename(__DIR__);'.
"\n";
1466 $csscontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded\n";
1467 $csscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
1468 $csscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
1469 $csscontent .=
"ob_start();\n";
1470 $csscontent .=
"if (! headers_sent()) { /* because file is included inline when in edit mode and we don't want warning */ \n";
1471 $csscontent .=
"header('Cache-Control: max-age=3600, public, must-revalidate');\n";
1472 $csscontent .=
"header('Content-type: text/css');\n";
1473 $csscontent .=
"}\n";
1474 $csscontent .=
"// END PHP ?>\n";
1476 $csscontent .= $dataposted.
"\n";
1478 $csscontent .=
'<?php // BEGIN PHP'.
"\n";
1479 $csscontent .=
'$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "css");'.
"\n";
1480 $csscontent .=
"// END PHP ?>\n";
1482 dol_syslog(
"Save css content into ".$filecss);
1494 $dataposted = trim(
GETPOST(
'WEBSITE_JS_INLINE',
'none'));
1495 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1498 $phpfullcodestringold =
'';
1502 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1504 if (!$errorphpcheck) {
1507 $jscontent .=
"<?php // BEGIN PHP\n";
1508 $jscontent .=
'$websitekey=basename(__DIR__);'.
"\n";
1509 $jscontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded\n";
1510 $jscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
1511 $jscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
1512 $jscontent .=
"ob_start();\n";
1513 $jscontent .=
"header('Cache-Control: max-age=3600, public, must-revalidate');\n";
1514 $jscontent .=
"header('Content-type: application/javascript');\n";
1515 $jscontent .=
"// END PHP ?>\n";
1517 $jscontent .= $dataposted.
"\n";
1519 $jscontent .=
'<?php // BEGIN PHP'.
"\n";
1520 $jscontent .=
'$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "js");'.
"\n";
1521 $jscontent .=
"// END PHP ?>\n";
1532 $dataposted = trim(
GETPOST(
'WEBSITE_ROBOT',
'restricthtml'));
1533 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1536 $phpfullcodestringold =
'';
1540 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1542 if (!$errorphpcheck) {
1555 $robotcontent .= $dataposted.
"\n";
1570 $dataposted = trim(
GETPOST(
'WEBSITE_HTACCESS',
'restricthtml'));
1571 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1574 $phpfullcodestringold =
'';
1578 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1580 if (!$errorphpcheck) {
1581 $htaccesscontent =
'';
1582 $htaccesscontent .= $dataposted.
"\n";
1594 $dataposted = trim(
GETPOST(
'WEBSITE_MANIFEST_JSON',
'none'));
1595 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1598 $phpfullcodestringold =
'';
1602 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1604 if (!$errorphpcheck) {
1605 $manifestjsoncontent =
'';
1607 $manifestjsoncontent .=
"<?php // BEGIN PHP\n";
1608 $manifestjsoncontent .=
'$websitekey=basename(__DIR__);'.
"\n";
1609 $manifestjsoncontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded\n";
1610 $manifestjsoncontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
1611 $manifestjsoncontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
1612 $manifestjsoncontent .=
"ob_start();\n";
1613 $manifestjsoncontent .=
"header('Cache-Control: max-age=3600, public, must-revalidate');\n";
1614 $manifestjsoncontent .=
"header('Content-type: application/manifest+json');\n";
1615 $manifestjsoncontent .=
"// END PHP ?>\n";
1617 $manifestjsoncontent .= $dataposted.
"\n";
1619 $manifestjsoncontent .=
'<?php // BEGIN PHP'.
"\n";
1620 $manifestjsoncontent .=
'$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "manifest");'.
"\n";
1621 $manifestjsoncontent .=
"// END PHP ?>\n";
1626 setEventMessages(
'Failed to write file '.$filemanifestjson,
null,
'errors');
1632 $dataposted = trim(
GETPOST(
'WEBSITE_README',
'restricthtml'));
1633 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1636 $phpfullcodestringold =
'';
1640 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1642 if (!$errorphpcheck) {
1643 $readmecontent =
'';
1655 $readmecontent .= $dataposted.
"\n";
1681 $action =
'preview';
1683 $backtopage = preg_replace(
'/searchstring=[^&]*/',
'', $backtopage);
1684 header(
"Location: ".$backtopage);
1688 $action =
'editcss';
1695 if ($action ==
'setashome' && $usercanedit) {
1697 $object->fetch(0, $websitekey);
1700 $object->fk_default_home = $pageid;
1701 $res = $object->update($user);
1710 $filetpl = $pathofwebsite.
'/page'.$pageid.
'.tpl.php';
1713 $result =
dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper, $object);
1721 $action =
'preview';
1728 if ($action ==
'updatemeta' && $usercanedit) {
1731 $result = $object->fetch(0, $websitekey);
1734 $objectpage->fk_website = $object->id;
1737 if (!preg_match(
'/^[a-z0-9\-\_]+$/i',
GETPOST(
'WEBSITE_PAGENAME',
'alpha'))) {
1739 $langs->load(
"errors");
1740 setEventMessages($langs->transnoentities(
"ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities(
'WEBSITE_PAGENAME')),
null,
'errors');
1741 $action =
'editmeta';
1744 $res = $objectpage->fetch($pageid, $object->id);
1747 setEventMessages(
'Page not found '.$objectpage->error, $objectpage->errors,
'errors');
1751 if (!$error &&
GETPOST(
'WEBSITE_PAGENAME',
'alpha')) {
1753 $result = $websitepagetemp->fetch(-1 * $objectpage->id, $object->id,
GETPOST(
'WEBSITE_PAGENAME',
'alpha'));
1756 $langs->load(
"errors");
1757 setEventMessages($websitepagetemp->error, $websitepagetemp->errors,
'errors');
1758 $action =
'editmeta';
1762 $langs->load(
"errors");
1763 setEventMessages($langs->trans(
"ErrorAPageWithThisNameOrAliasAlreadyExists", $websitepagetemp->pageurl),
null,
'errors');
1764 $action =
'editmeta';
1768 $newaliasnames =
'';
1769 if (!$error &&
GETPOST(
'WEBSITE_ALIASALT',
'alpha')) {
1770 $arrayofaliastotest = explode(
',', str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_ALIASALT',
'alpha')));
1773 foreach ($arrayofaliastotest as $aliastotest) {
1774 $aliastotest = trim(preg_replace(
'/\.php$/i',
'', $aliastotest));
1777 if (preg_match(
'/^page\d+/i', $aliastotest)) {
1779 $langs->load(
"errors");
1781 $action =
'editmeta';
1784 $result = $websitepagetemp->fetch(-1 * $objectpage->id, $object->id, $aliastotest);
1787 $langs->load(
"errors");
1788 setEventMessages($websitepagetemp->error, $websitepagetemp->errors,
'errors');
1789 $action =
'editmeta';
1794 $langs->load(
"errors");
1795 setEventMessages($langs->trans(
"ErrorAPageWithThisNameOrAliasAlreadyExists", $websitepagetemp->pageurl),
null,
'errors');
1796 $action =
'editmeta';
1799 $newaliasnames .= ($newaliasnames ?
', ' :
'').$aliastotest;
1805 $objectpage->old_object = clone $objectpage;
1807 $objectpage->title = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_TITLE',
'alphanohtml'));
1808 $objectpage->type_container =
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'aZ09');
1809 $objectpage->pageurl =
GETPOST(
'WEBSITE_PAGENAME',
'alpha');
1810 $objectpage->aliasalt = $newaliasnames;
1811 $objectpage->lang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
1812 $objectpage->otherlang =
GETPOST(
'WEBSITE_OTHERLANG',
'aZ09comma');
1813 $objectpage->description = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml'));
1814 $objectpage->image =
GETPOST(
'WEBSITE_IMAGE',
'alpha');
1815 $objectpage->keywords = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_KEYWORDS',
'alphanohtml'));
1816 $objectpage->allowed_in_frames =
GETPOST(
'WEBSITE_ALLOWED_IN_FRAMES',
'aZ09');
1817 $objectpage->htmlheader = trim(
GETPOST(
'htmlheader',
'none'));
1818 $objectpage->fk_page = (
GETPOST(
'pageidfortranslation',
'int') > 0 ?
GETPOST(
'pageidfortranslation',
'int') : 0);
1819 $objectpage->author_alias = trim(
GETPOST(
'WEBSITE_AUTHORALIAS',
'alphanohtml'));
1820 $objectpage->object_type =
GETPOST(
'WEBSITE_OBJECTCLASS',
'alpha');
1821 $objectpage->fk_object =
GETPOST(
'WEBSITE_OBJECTID',
'aZ09');
1823 $newdatecreation =
dol_mktime(
GETPOST(
'datecreationhour',
'int'),
GETPOST(
'datecreationmin',
'int'),
GETPOST(
'datecreationsec',
'int'),
GETPOST(
'datecreationmonth',
'int'),
GETPOST(
'datecreationday',
'int'),
GETPOST(
'datecreationyear',
'int'));
1824 if ($newdatecreation) {
1825 $objectpage->date_creation = $newdatecreation;
1828 $res = $objectpage->update($user);
1830 $langs->load(
"errors");
1831 if ($db->lasterrno ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
1833 $langs->load(
"errors");
1834 setEventMessages($langs->trans(
"ErrorAPageWithThisNameOrAliasAlreadyExists"),
null,
'errors');
1835 $action =
'editmeta';
1838 $langs->load(
"errors");
1840 $action =
'editmeta';
1847 $categoriesarray =
GETPOST(
'categories',
'array');
1848 $result = $objectpage->setCategories($categoriesarray);
1862 $filemaster = $pathofwebsite.
'/master.inc.php';
1863 $fileoldalias = $pathofwebsite.
'/'.$objectpage->old_object->pageurl.
'.php';
1864 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
1875 if (!empty($fileoldalias)) {
1876 dol_syslog(
"We delete old alias page name=".$fileoldalias.
" to build a new alias page=".$filealias);
1880 if (empty($objectpage->lang) || !in_array($objectpage->lang, explode(
',', $object->otherlang))) {
1881 $dirname = dirname($fileoldalias);
1882 $filename = basename($fileoldalias);
1883 $sublangs = explode(
',', $object->otherlang);
1884 foreach ($sublangs as $sublang) {
1888 if (empty(trim($sublang)))
continue;
1889 $fileoldaliassub = $dirname.
'/'.$sublang.
'/'.$filename;
1895 if (!empty($objectpage->old_object->aliasalt)) {
1896 $tmpaltaliases = explode(
',', $objectpage->old_object->aliasalt);
1897 if (is_array($tmpaltaliases)) {
1898 foreach ($tmpaltaliases as $tmpaliasalt) {
1899 dol_syslog(
"We delete old alt alias pages name=".trim($tmpaliasalt));
1903 if (empty($objectpage->lang) || !in_array($objectpage->lang, explode(
',', $object->otherlang))) {
1904 $dirname = dirname($pathofwebsite.
'/'.trim($tmpaliasalt).
'.php');
1905 $filename = basename($pathofwebsite.
'/'.trim($tmpaliasalt).
'.php');
1906 $sublangs = explode(
',', $object->otherlang);
1907 foreach ($sublangs as $sublang) {
1911 if (empty(trim($sublang)))
continue;
1912 $fileoldaliassub = $dirname.
'/'.$sublang.
'/'.$filename;
1926 if (!empty($objectpage->aliasalt)) {
1927 $tmpaltaliases = explode(
',', $objectpage->aliasalt);
1928 if (is_array($tmpaltaliases)) {
1929 foreach ($tmpaltaliases as $tmpaliasalt) {
1930 if (trim($tmpaliasalt)) {
1931 $filealias = $pathofwebsite.
'/'.trim($tmpaliasalt).
'.php';
1934 setEventMessages(
'Failed to write file '.basename($filealias),
null,
'errors');
1950 $action =
'preview';
1952 $action =
'editmeta';
1958 $action =
'preview';
1964 if ($usercanedit && (($action ==
'updatesource' || $action ==
'updatecontent' || $action ==
'confirm_createfromclone' || $action ==
'confirm_createpagefromclone')
1965 || ($action ==
'preview' && (
GETPOST(
'refreshsite') ||
GETPOST(
'refreshpage') ||
GETPOST(
'preview'))))) {
1966 $object->fetch(0, $websitekey);
1969 if ($action ==
'confirm_createfromclone') {
1972 $objectnew =
new Website($db);
1973 $result = $objectnew->createFromClone($user,
GETPOST(
'id',
'int'),
GETPOST(
'siteref',
'aZ09'), (
GETPOST(
'newlang',
'aZ09') ?
GETPOST(
'newlang',
'aZ09') :
''));
1978 $action =
'preview';
1982 $object = $objectnew;
1984 $pageid = $object->fk_default_home;
1985 $websitekey =
GETPOST(
'siteref',
'aZ09');
1991 if ($action ==
'confirm_createpagefromclone') {
1992 $istranslation = (
GETPOST(
'is_a_translation',
'aZ09') ==
'on' ? 1 : 0);
1994 if ($istranslation) {
1995 if (
GETPOST(
'newlang',
'aZ09') == $objectpage->lang || !
GETPOST(
'newlang',
'aZ09')) {
1997 setEventMessages($langs->trans(
"LanguageMustNotBeSameThanClonedPage"),
null,
'errors');
1998 $action =
'preview';
2000 if (
GETPOST(
'newwebsite',
'int') != $object->id) {
2002 setEventMessages($langs->trans(
"WebsiteMustBeSameThanClonedPageIfTranslation"),
null,
'errors');
2003 $action =
'preview';
2010 $newwebsiteid =
GETPOST(
'newwebsite',
'int');
2011 $pathofwebsitenew = $pathofwebsite;
2013 $tmpwebsite =
new Website($db);
2014 if ($newwebsiteid > 0 && $newwebsiteid != $object->id) {
2015 $tmpwebsite->fetch($newwebsiteid);
2016 $pathofwebsitenew = $dolibarr_main_data_root.($conf->entity > 1 ?
'/'.$conf->entity :
'').
'/website/'.$tmpwebsite->ref;
2018 $tmpwebsite = $object;
2022 $resultpage = $objectpage->createFromClone($user, $pageid,
GETPOST(
'newpageurl',
'aZ09'), (
GETPOST(
'newlang',
'aZ09') ?
GETPOST(
'newlang',
'aZ09') :
''), $istranslation, $newwebsiteid,
GETPOST(
'newtitle',
'alphanohtml'));
2023 if ($resultpage < 0) {
2026 $action =
'createpagefromclone';
2030 $filetpl = $pathofwebsitenew.
'/page'.$resultpage->id.
'.tpl.php';
2031 $fileindex = $pathofwebsitenew.
'/index.php';
2032 $filewrapper = $pathofwebsitenew.
'/wrapper.php';
2041 if (empty($newwebsiteid) || $newwebsiteid == $object->id) {
2042 $pageid = $resultpage->id;
2054 $pathtomedias = DOL_DATA_ROOT.
'/medias';
2055 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
2057 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
2058 dol_mkdir(dirname($pathtomediasinwebsite));
2059 $result = symlink($pathtomedias, $pathtomediasinwebsite);
2068 $objectpage->fk_website = $object->id;
2071 $res = $objectpage->fetch($pageid);
2074 if ($object->fk_default_home > 0) {
2075 $res = $objectpage->fetch($object->fk_default_home);
2078 $res = $objectpage->fetch(0, $object->id);
2083 if (!$error && $res > 0) {
2084 if ($action ==
'updatesource' || $action ==
'updatecontent') {
2089 $objectpage->content =
GETPOST(
'PAGE_CONTENT',
'none');
2094 $error =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
2097 if ($action ==
'updatesource') {
2098 $action =
'editsource';
2100 if ($action ==
'updatecontent') {
2101 $action =
'editcontent';
2106 $objectpage->content = preg_replace(
'/<head>.*<\/head>/ims',
'', $objectpage->content);
2110 $res = $objectpage->update($user);
2114 if ($action ==
'updatesource') {
2115 $action =
'editsource';
2117 if ($action ==
'updatecontent') {
2118 $action =
'editcontent';
2125 $filemaster = $pathofwebsite.
'/master.inc.php';
2127 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
2135 setEventMessages(
'Failed to write the master file file '.$filemaster,
null,
'errors');
2159 setEventMessages(
'Failed to write the alias file '.basename($filealias),
null,
'errors');
2169 header(
"Location: ".$backtopage);
2172 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$websitekey.
'&pageid='.$pageid);
2176 if ($action ==
'updatesource') {
2177 $action =
'editsource';
2179 if ($action ==
'updatecontent') {
2180 $action =
'editcontent';
2185 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$websitekey.
'&pageid='.$pageid);
2192 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$websitekey.
'&pageid='.$pageid);
2197 if (empty($websitekey) || $websitekey ==
'-1') {
2198 setEventMessages($langs->trans(
"NoWebSiteCreateOneFirst"),
null,
'warnings');
2201 setEventMessages($langs->trans(
"YouCanCreatePageOrImportTemplate"),
null,
'warnings');
2208 if ($action ==
'exportsite' && !empty($user->rights->website->export)) {
2209 $fileofzip = $object->exportWebSite();
2212 $file_name = basename($fileofzip);
2214 header(
"Content-Type: application/zip");
2215 header(
"Content-Disposition: attachment; filename=".$file_name);
2216 header(
"Content-Length: ".filesize($fileofzip));
2218 readfile($fileofzip);
2222 $action =
'preview';
2227 if ($action ==
'regeneratesite' && $usercanedit) {
2229 $pathtomedias = DOL_DATA_ROOT.
'/medias';
2230 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
2232 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
2233 dol_mkdir(dirname($pathtomediasinwebsite));
2234 $result = symlink($pathtomedias, $pathtomediasinwebsite);
2236 setEventMessages($langs->trans(
"ErrorFieldToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias),
null,
'errors');
2237 $action =
'preview';
2241 $result = $object->rebuildWebSiteFiles();
2243 setEventMessages($langs->trans(
"PagesRegenerated", $result),
null,
'mesgs');
2244 $action =
'preview';
2247 $action =
'preview';
2252 if ($action ==
'importsiteconfirm' && $usercanedit) {
2253 if (empty($_FILES) && !
GETPOSTISSET(
'templateuserfile')) {
2254 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"File")),
null,
'errors');
2255 $action =
'importsite';
2257 if (!empty($_FILES) ||
GETPOSTISSET(
'templateuserfile')) {
2259 $pathtomedias = DOL_DATA_ROOT.
'/medias';
2260 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
2262 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
2263 dol_mkdir(dirname($pathtomediasinwebsite));
2264 $result = symlink($pathtomedias, $pathtomediasinwebsite);
2266 setEventMessages($langs->trans(
"ErrorFieldToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias),
null,
'errors');
2267 $action =
'importsite';
2273 $fileofzip = DOL_DATA_ROOT.
'/doctemplates/websites/'.
GETPOST(
'templateuserfile',
'alpha');
2274 } elseif (!empty($_FILES) && is_array($_FILES[
'userfile'])) {
2275 if (is_array($_FILES[
'userfile'][
'tmp_name'])) {
2276 $userfiles = $_FILES[
'userfile'][
'tmp_name'];
2278 $userfiles = array($_FILES[
'userfile'][
'tmp_name']);
2281 foreach ($userfiles as $key => $userfile) {
2282 if (empty($_FILES[
'userfile'][
'tmp_name'][$key])) {
2284 if ($_FILES[
'userfile'][
'error'][$key] == 1 || $_FILES[
'userfile'][
'error'][$key] == 2) {
2286 $action =
'importsite';
2288 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"File")),
null,
'errors');
2289 $action =
'importsite';
2295 $upload_dir = $conf->website->dir_temp;
2300 $fileofzip = $upload_dir.
'/unknown';
2301 foreach ($_FILES as $key => $ifile) {
2302 foreach ($ifile[
'name'] as $key2 => $ifile2) {
2303 $fileofzip = $upload_dir.
'/'.$ifile2;
2309 $result = $object->importWebSite($fileofzip);
2313 $action =
'importsite';
2316 dolibarr_set_const($db,
'WEBSITE_SUBCONTAINERSINLINE', 1,
'chaine', 0,
'', $conf->entity);
2318 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$object->ref);
2326 $domainname =
'0.0.0.0:8080';
2327 $tempdir = $conf->website->dir_output.
'/'.$websitekey.
'/';
2330 if ($action ==
'generatesitemaps' && $usercanedit) {
2331 $domtree =
new DOMDocument(
'1.0',
'UTF-8');
2333 $root = $domtree->createElementNS(
'http://www.sitemaps.org/schemas/sitemap/0.9',
'urlset');
2334 $root->setAttributeNS(
'http://www.w3.org/2000/xmlns/',
'xmlns:xhtml',
'http://www.w3.org/1999/xhtml');
2336 $domtree->formatOutput =
true;
2338 $xmlname =
'sitemap.xml';
2340 $sql =
"SELECT wp.rowid, wp.type_container , wp.pageurl, wp.lang, wp.fk_page, wp.tms as tms,";
2341 $sql .=
" w.virtualhost, w.fk_default_home";
2342 $sql .=
" FROM ".MAIN_DB_PREFIX.
"website_page as wp, ".MAIN_DB_PREFIX.
"website as w";
2343 $sql .=
" WHERE wp.type_container IN ('page', 'blogpost')";
2344 $sql .=
" AND wp.fk_website = w.rowid";
2345 $sql .=
" AND wp.status = ".WebsitePage::STATUS_VALIDATED;
2346 $sql .=
" AND wp.pageurl NOT IN ('404', '500', '501', '503')";
2347 $sql .=
" AND w.ref = '".dol_escape_json($websitekey).
"'";
2348 $sql .=
" ORDER BY wp.tms DESC, wp.rowid DESC";
2349 $resql = $db->query($sql);
2351 $num_rows = $db->num_rows(
$resql);
2352 if ($num_rows > 0) {
2354 while ($i < $num_rows) {
2355 $objp = $db->fetch_object(
$resql);
2356 $url = $domtree->createElement(
'url');
2358 $shortlangcode =
'';
2360 $shortlangcode = substr($objp->lang, 0, 2);
2362 if (empty($shortlangcode)) {
2363 $shortlangcode = substr($object->lang, 0, 2);
2367 $pageurl = $objp->pageurl.
'.php';
2368 if ($objp->fk_default_home == $objp->rowid) {
2371 if ($shortlangcode != substr($object->lang, 0, 2)) {
2372 $pageurl = $shortlangcode.
'/'.$pageurl;
2376 if ($objp->virtualhost) {
2377 $domainname = $objp->virtualhost;
2379 if (! preg_match(
'/^http/i', $domainname)) {
2380 $domainname =
'https://'.$domainname;
2385 $loc = $domtree->createElement(
'loc', $domainname.
'/'.$pageurl);
2386 $lastmod = $domtree->createElement(
'lastmod',
dol_print_date($db->jdate($objp->tms),
'dayrfc',
'gmt'));
2387 $changefreq = $domtree->createElement(
'changefreq',
'weekly');
2388 $priority = $domtree->createElement(
'priority',
'1');
2390 $url->appendChild($loc);
2391 $url->appendChild($lastmod);
2393 if (!empty($conf->global->WEBSITE_SITEMAPS_ADD_WEEKLY_FREQ)) {
2394 $url->appendChild($changefreq);
2397 if ($objp->fk_default_home == $objp->rowid) {
2398 $url->appendChild($priority);
2402 if ($object->isMultiLang()) {
2403 $alternatefound = 0;
2406 $translationof = $objp->fk_page;
2407 if ($translationof) {
2409 $tmppage->fetch($translationof);
2410 if ($tmppage->id > 0) {
2411 $tmpshortlangcode =
'';
2412 if ($tmppage->lang) {
2413 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'', $tmppage->lang);
2415 if (empty($tmpshortlangcode)) {
2416 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'', $object->lang);
2418 if ($tmpshortlangcode != $shortlangcode) {
2419 $xhtmllink = $domtree->createElement(
'xhtml:link',
'');
2420 $xhtmllink->setAttribute(
"rel",
"alternate");
2421 $xhtmllink->setAttribute(
"hreflang", $tmpshortlangcode);
2422 $xhtmllink->setAttribute(
"href", $domainname.($objp->fk_default_home == $tmppage->id ?
'/' : (($tmpshortlangcode != substr($object->lang, 0, 2)) ?
'/'.$tmpshortlangcode :
'').
'/'.$tmppage->pageurl.
'.php'));
2423 $url->appendChild($xhtmllink);
2431 $sql =
'SELECT rowid as id, lang, pageurl from '.MAIN_DB_PREFIX.
'website_page';
2432 $sql .=
" WHERE status = ".((int) WebsitePage::STATUS_VALIDATED).
' AND fk_page IN ('.$db->sanitize($objp->rowid.($translationof ?
", ".$translationof :
"")).
")";
2433 $resqlhastrans = $db->query($sql);
2434 if ($resqlhastrans) {
2435 $num_rows_hastrans = $db->num_rows($resqlhastrans);
2436 if ($num_rows_hastrans > 0) {
2437 while ($objhastrans = $db->fetch_object($resqlhastrans)) {
2438 $tmpshortlangcode =
'';
2439 if ($objhastrans->lang) {
2440 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'', $objhastrans->lang);
2442 if ($tmpshortlangcode != $shortlangcode) {
2443 $xhtmllink = $domtree->createElement(
'xhtml:link',
'');
2444 $xhtmllink->setAttribute(
"rel",
"alternate");
2445 $xhtmllink->setAttribute(
"hreflang", $tmpshortlangcode);
2446 $xhtmllink->setAttribute(
"href", $domainname.($objp->fk_default_home == $objhastrans->id ?
'/' : (($tmpshortlangcode != substr($object->lang, 0, 2) ?
'/'.$tmpshortlangcode :
'')).
'/'.$objhastrans->pageurl.
'.php'));
2447 $url->appendChild($xhtmllink);
2457 if ($alternatefound) {
2459 $xhtmllink = $domtree->createElement(
'xhtml:link',
'');
2460 $xhtmllink->setAttribute(
"rel",
"alternate");
2461 $xhtmllink->setAttribute(
"hreflang", $shortlangcode);
2462 $xhtmllink->setAttribute(
"href", $domainname.
'/'.$pageurl);
2463 $url->appendChild($xhtmllink);
2479 $root->appendChild($url);
2482 $domtree->appendChild($root);
2483 if ($domtree->save($tempdir.$xmlname)) {
2484 if (!empty($conf->global->MAIN_UMASK)) {
2485 @chmod($tempdir.$xmlname, octdec($conf->global->MAIN_UMASK));
2487 setEventMessages($langs->trans(
"SitemapGenerated", $xmlname),
null,
'mesgs');
2497 $robotcontent = @file_get_contents($filerobot);
2498 $result = preg_replace(
'/<?php // BEGIN PHP[^?]END PHP ?>\n/ims',
'', $robotcontent);
2500 $robotcontent = $result;
2502 $robotsitemap =
"Sitemap: ".$domainname.
"/".$xmlname;
2503 $result = strpos($robotcontent,
'Sitemap: ');
2505 $result = preg_replace(
'/Sitemap:.*/', $robotsitemap, $robotcontent);
2506 $robotcontent = $result ? $result : $robotcontent;
2508 $robotcontent .= $robotsitemap.
"\n";
2515 $action =
'preview';
2530 if ($action ==
'confirmgeneratesitemaps') {
2531 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?website='.urlencode($website->ref), $langs->trans(
'ConfirmSitemapsCreation'), $langs->trans(
'ConfirmGenerateSitemaps', $object->ref),
'generatesitemaps',
'',
"yes", 1);
2532 $action =
'preview';
2534 $helpurl =
'EN:Module_Website|FR:Module_Website_FR|ES:Módulo_Website';
2537 '/includes/ace/src/ace.js',
2538 '/includes/ace/src/ext-statusbar.js',
2539 '/includes/ace/src/ext-language_tools.js',
2543 $arrayofcss = array();
2548 $arrayofjs[] =
'includes/jquery/plugins/blockUI/jquery.blockUI.js';
2549 $arrayofjs[] =
'core/js/blockUI.js';
2550 if (empty($conf->global->MAIN_ECM_DISABLE_JS)) {
2551 $arrayofjs[] =
"includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js";
2554 $moreheadjs .=
'<script type="text/javascript">'.
"\n";
2555 $moreheadjs .=
'var indicatorBlockUI = \''.DOL_URL_ROOT.
"/theme/".$conf->theme.
"/img/working.gif".
'\';
'."\n";
2556 $moreheadjs .= '</script>
'."\n";
2558 llxHeader($moreheadcss.$moreheadjs, $langs->trans("WebsiteSetup"), $helpurl, '', 0, 0, $arrayofjs, $arrayofcss, '', '', '<!-- Begin div
class=
"fiche" -->
'."\n".'<div
class=
"fichebutwithotherclass">
');
2561 print '<!-- Open form
for all page -->
'."\n";
2562 print '<form action=
"'.$_SERVER["PHP_SELF
"].($action == 'file_manager' ? '?uploadform=1': '').'" method=
"POST" enctype=
"multipart/form-data" class=
"websiteformtoolbar">
';
2563 print '<input
type=
"hidden" name=
"token" value=
"'.newToken().'">
';
2564 print '<input
type=
"hidden" name=
"backtopage" value=
"'.$backtopage.'">
';
2565 print '<input
type=
"hidden" name=
"dol_openinpopup" value=
"'.$dol_openinpopup.'">
';
2567 if ($action == 'createsite
') {
2568 print '<input
type=
"hidden" name=
"action" value=
"addsite">
';
2570 if ($action == 'createcontainer
') {
2571 print '<input
type=
"hidden" name=
"action" value=
"addcontainer">
';
2573 if ($action == 'editcss
') {
2574 print '<input
type=
"hidden" name=
"action" value=
"updatecss">
';
2576 if ($action == 'editmenu
') {
2577 print '<input
type=
"hidden" name=
"action" value=
"updatemenu">
';
2579 if ($action == 'setashome
') {
2580 print '<input
type=
"hidden" name=
"action" value=
"updateashome">
';
2582 if ($action == 'editmeta
') {
2583 print '<input
type=
"hidden" name=
"action" value=
"updatemeta">
';
2585 if ($action == 'editsource
') {
2586 print '<input
type=
"hidden" name=
"action" value=
"updatesource">
';
2588 if ($action == 'editcontent
') {
2589 print '<input
type=
"hidden" name=
"action" value=
"updatecontent">
';
2591 if ($action == 'edit
') {
2592 print '<input
type=
"hidden" name=
"action" value=
"update">
';
2594 if ($action == 'importsite
') {
2595 print '<input
type=
"hidden" name=
"action" value=
"importsiteconfirm">
';
2597 if ($action == 'file_manager
') {
2598 print '<input
type=
"hidden" name=
"action" value=
"file_manager">
';
2600 if ($action == 'replacesite
') {
2601 print '<input
type=
"hidden" name=
"action" value=
"replacesiteconfirm">
';
2603 if ($action == 'replacesiteconfirm
') {
2604 print '<input
type=
"hidden" name=
"action" value=
"replacesiteconfirm">
';
2609 // Add a margin under toolbar ?
2611 if ($action != 'preview
' && $action != 'editcontent
' && $action != 'editsource
' && !GETPOST('createpagefromclone
', 'alphanohtml
')) {
2612 $style = ' margin-bottom: 5px;
';
2616 if (!GETPOST('hide_websitemenu
')) {
2618 if (empty($user->rights->website->write)) {
2619 $disabled = ' disabled=
"disabled"';
2621 $disabledexport = '';
2622 if (empty($user->rights->website->export)) {
2623 $disabledexport = ' disabled=
"disabled"';
2628 $dataroot = DOL_DATA_ROOT.($conf->entity > 1 ? '/
'.$conf->entity : '').'/website/
'.$websitekey;
2629 if (!empty($object->virtualhost)) {
2630 $virtualurl = $object->virtualhost;
2635 if ($object->id > 0) {
2636 $array = $objectpage->fetchAll($object->id, 'ASC,ASC
', 'type_container,pageurl
');
2637 $object->lines = $array;
2639 if (!is_array($array) && $array < 0) {
2640 dol_print_error('', $objectpage->error, $objectpage->errors);
2642 $atleastonepage = (is_array($array) && count($array) > 0);
2645 //var_dump($objectpage);exit;
2646 print '<div
class=
"centpercent websitebar'.(GETPOST('dol_openinpopup', 'aZ09') ? ' hidden' : '').'">
';
2649 // Toolbar for websites
2652 print '<!-- Bar
for website -->
';
2653 if ($action != 'file_manager
') {
2654 print '<span
class=
"websiteselection hideonsmartphoneimp minwidth100 tdoverflowmax100">
';
2655 print $langs->trans("Website").':
';
2658 $urltocreatenewwebsite = $_SERVER["PHP_SELF"].'?action=createsite
';
2659 if (empty($conf->use_javascript_ajax)) {
2660 print '<span
class=
"websiteselection hideonsmartphoneimp">
';
2661 print '<a href=
"'.$urltocreatenewwebsite.'" class=
"button bordertransp"'.$disabled.' title=
"'.dol_escape_htmltag($langs->trans("AddWebsite
")).'"><span
class=
"fa fa-plus-circle valignmiddle btnTitle-icon"><span></a>
';
2666 print '<span
class=
"websiteselection">
';
2668 $out .= '<select
name=
"website" class=
"minwidth100 width200 maxwidth150onsmartphone" id=
"website">
';
2669 if (empty($object->records)) {
2670 $out .= '<option value=
"-1"> </option>
';
2672 if (!empty($conf->use_javascript_ajax)) {
2673 $valueoption = '<span
class=
"classlink">
'.img_picto('', 'add
', 'class=
"paddingrightonly"').$langs->trans("AddWebsite").'</span>
';
2674 $out .= '<option value=
"-2" data-html=
"'.dol_escape_htmltag($valueoption).'">
'.$valueoption.'</option>
';
2676 // Loop on each sites
2678 foreach ($object->records as $key => $valwebsite) {
2679 if (empty($websitekey)) {
2680 if ($action != 'createsite
') {
2681 $websitekey = $valwebsite->ref;
2685 $out .= '<option value=
"'.$valwebsite->ref.'"';
2686 if ($websitekey == $valwebsite->ref) {
2687 $out .= ' selected
'; // To preselect a value
2689 //$outoption = $valwebsite->getLibStatut(3).' '.$valwebsite->ref.' ';
2690 $outoption = (($valwebsite->status == $valwebsite::STATUS_DRAFT) ? '<span
class=
"opacitymedium">
' : '').$valwebsite->ref.(($valwebsite->status == $valwebsite::STATUS_DRAFT) ? '</span>
' : '');
2691 $out .= ' data-html=
"'.dol_escape_htmltag($outoption).'"';
2693 $out .= $valwebsite->ref;
2694 $out .= '</option>
';
2697 $out .= '</select>
';
2698 $out .= ajax_combobox('website
');
2700 if (!empty($conf->use_javascript_ajax)) {
2701 $out .= '<script
type=
"text/javascript">
';
2702 $out .= 'jQuery(document).ready(
function () {
';
2703 $out .= ' jQuery(
"#website").change(
function () {
';
2704 $out .= ' console.log(
"We select "+jQuery(
"#website option:selected").val());
';
2705 $out .= ' if (jQuery(
"#website option:selected").val() == \
'-2\') {';
2706 $out .=
' window.location.href = "'.dol_escape_js($urltocreatenewwebsite).
'";';
2707 $out .=
' } else {';
2708 $out .=
' window.location.href = "'.$_SERVER[
"PHP_SELF"].
'?website="+jQuery("#website option:selected").val();';
2712 $out .=
'</script>';
2716 if (empty($conf->use_javascript_ajax)) {
2717 print
'<input type="image" class="valignmiddle" src="'.img_picto(
'',
'refresh',
'', 0, 1).
'" name="refreshsite" value="'.$langs->trans(
"Load").
'">';
2720 if ($websitekey && $websitekey !=
'-1' && ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite')) {
2724 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?website='.$object->ref.
'&pageid='.$pageid.
'&action=editcss&token='.
newToken().
'" class="button bordertransp" title="'.
dol_escape_htmltag($langs->trans(
"EditCss")).
'"'.$disabled.
'><span class="fa fa-cog paddingrightonly"></span><span class="hideonsmartphone">'.
dol_escape_htmltag($langs->trans(
"EditCss")).
'</span></a>';
2726 $importlabel = $langs->trans(
"ImportSite");
2727 $exportlabel = $langs->trans(
"ExportSite");
2728 if (!empty($conf->dol_optimize_smallscreen)) {
2729 $importlabel = $langs->trans(
"Import");
2730 $exportlabel = $langs->trans(
"Export");
2733 if ($atleastonepage) {
2734 print
'<input type="submit" class="button bordertransp" disabled="disabled" value="'.dol_escape_htmltag($importlabel).
'" name="importsite">';
2736 print
'<input type="submit" class="button bordertransp"'.$disabled.
' value="'.
dol_escape_htmltag($importlabel).
'" name="importsite">';
2740 print
'<input type="submit" class="button bordertransp"'.$disabledexport.
' value="'.
dol_escape_htmltag($exportlabel).
'" name="exportsite">';
2742 print
'<input type="submit" class="button bordertransp"'.$disabled.
' value="'.
dol_escape_htmltag($langs->trans(
"CloneSite")).
'" name="createfromclone">';
2745 if ($website->status == $website::STATUS_VALIDATED) {
2746 print
'<input type="submit" class="buttonDelete bordertransp" name="deletesite" value="'.$langs->trans(
"Delete").
'" disabled="disabled" title="'.
dol_escape_htmltag($langs->trans(
"WebsiteMustBeDisabled")).
'">';
2748 print
'<input type="submit" class="buttonDelete bordertransp" name="deletesite" value="'.$langs->trans(
"Delete").
'"'.($atleastonepage ?
' disabled="disabled"' :
'').
'>';
2752 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=regeneratesite&token='.
newToken().
'&website='.urlencode($website->ref).
'" class="button bordertransp"'.$disabled.
' title="'.
dol_escape_htmltag($langs->trans(
"RegenerateWebsiteContent")).
'"><span class="far fa-hdd"></span></a>';
2755 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=confirmgeneratesitemaps&token='.
newToken().
'&website='.urlencode($website->ref).
'" class="button bordertransp"'.$disabled.
' title="'.
dol_escape_htmltag($langs->trans(
"GenerateSitemaps")).
'"><span class="fa fa-sitemap"></span></a>';
2757 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=replacesite&token='.
newToken().
'&website='.urlencode($website->ref).
'" class="button bordertransp"'.$disabled.
' title="'.
dol_escape_htmltag($langs->trans(
"ReplaceWebsiteContent")).
'"><span class="fa fa-search"></span></a>';
2762 if ($websitekey && $websitekey !=
'-1' && ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite')) {
2763 print
'<span class="websiteselection">';
2765 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);
2767 if (!empty($conf->categorie->enabled)) {
2769 print
dolButtonToOpenUrlInDialogPopup(
'categories', $langs->transnoentitiesnoconv(
"Categories"),
'<span class="fa fa-tags"></span>',
'/categories/index.php?leftmenu=website&nosearch=1&type=website_page&website='.urlencode($website->ref), $disabled);
2775 print
'<input type="hidden" name="website" id="website" value="'.$websitekey.
'">';
2779 print
'<span class="websitetools">';
2781 if ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite') {
2782 $urlext = $virtualurl;
2783 $urlint = $urlwithroot.
'/public/website/index.php?website='.$websitekey;
2785 print
'<span class="websiteinputurl valignmiddle" id="websiteinputurl">';
2786 $linktotestonwebserver =
'<a href="'.($virtualurl ? $virtualurl :
'#').
'" class="valignmiddle">';
2787 $linktotestonwebserver .=
'<span class="hideonsmartphone paddingrightonly">'.$langs->trans(
"TestDeployOnWeb", $virtualurl).
'</span>'.
img_picto(
'',
'globe');
2788 $linktotestonwebserver .=
'</a>';
2790 if (empty($object->fk_default_home)) {
2791 $htmltext .=
'<br><span class="error">'.$langs->trans(
"YouMustDefineTheHomePage").
'</span><br><br>';
2792 } elseif (empty($virtualurl)) {
2795 $htmltext .=
'<br><center>'.$langs->trans(
"GoTo").
' <a href="'.$virtualurl.
'" target="_website">'.$virtualurl.
'</a></center><br>';
2797 if (!empty($conf->global->WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER)) {
2798 $htmltext .=
'<!-- Message defined translate key set into WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER -->';
2799 $htmltext .=
'<br>'.$langs->trans($conf->global->WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER);
2801 $htmltext .= $langs->trans(
"SetHereVirtualHost", $dataroot);
2802 $htmltext .=
'<br>';
2803 $htmltext .=
'<br>'.$langs->trans(
"CheckVirtualHostPerms", $langs->transnoentitiesnoconv(
"ReadPerm"), DOL_DOCUMENT_ROOT);
2804 $htmltext .=
'<br>'.$langs->trans(
"CheckVirtualHostPerms", $langs->transnoentitiesnoconv(
"WritePerm"),
'{s1}');
2805 $htmltext = str_replace(
'{s1}', DOL_DATA_ROOT.
'/website<br>'.DOL_DATA_ROOT.
'/medias', $htmltext);
2807 $examplewithapache =
'#php_admin_value open_basedir /tmp/:'.DOL_DOCUMENT_ROOT.
':'.DOL_DATA_ROOT.
':/dev/urandom'.
"\n";
2808 $examplewithapache .=
'<Directory "'.DOL_DOCUMENT_ROOT.
'">'.
"\n";
2809 $examplewithapache .=
'AllowOverride FileInfo Options
2810 Options -Indexes -MultiViews -FollowSymLinks -ExecCGI
2813 <Directory "'.DOL_DATA_ROOT.
'/website">
2814 AllowOverride FileInfo Options
2815 Options -Indexes -MultiViews +FollowSymLinks -ExecCGI
2818 <Directory "'.DOL_DATA_ROOT.
'/medias">
2819 AllowOverride FileInfo Options
2820 Options -Indexes -MultiViews -FollowSymLinks -ExecCGI
2824 $htmltext .=
'<br>'.$langs->trans(
"ExampleToUseInApacheVirtualHostConfig").
':<br>';
2825 $htmltext .=
'<div class="centpercent exampleapachesetup">'.dol_nl2br(
dol_escape_htmltag($examplewithapache, 1, 1)).
'</div>';
2827 $htmltext .=
'<br>';
2828 $htmltext .= $langs->trans(
"YouCanAlsoTestWithPHPS", $dataroot);
2829 $htmltext .=
'<br>';
2830 $htmltext .=
'<br>';
2831 $htmltext .= $langs->trans(
"YouCanAlsoDeployToAnotherWHP");
2833 print
$form->textwithpicto($linktotestonwebserver, $htmltext, 1,
'none',
'valignmiddle', 0, 3,
'helpvirtualhost');
2837 if (in_array($action, array(
'editcss',
'editmenu',
'file_manager',
'replacesite',
'replacesiteconfirm'))) {
2838 if ($action ==
'editcss') {
2839 print
'<input type="submit" id="savefileandstay" class="button buttonforacesave hideonsmartphone small" value="'.dol_escape_htmltag($langs->trans(
"SaveAndStay")).
'" name="updateandstay">';
2841 if (preg_match(
'/^create/', $action) && $action !=
'file_manager' && $action !=
'replacesite' && $action !=
'replacesiteconfirm') {
2842 print
'<input type="submit" id="savefile" class="button buttonforacesave button-save small" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
2844 if (preg_match(
'/^edit/', $action) && $action !=
'file_manager' && $action !=
'replacesite' && $action !=
'replacesiteconfirm') {
2845 print
'<input type="submit" id="savefile" class="button buttonforacesave button-save small" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
2847 if ($action !=
'preview') {
2848 print
'<input type="submit" class="button button-cancel small" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'" name="cancel">';
2858 if ($websitekey && $websitekey !=
'-1' && !in_array($action, array(
'editcss',
'editmenu',
'importsite',
'file_manager',
'replacesite',
'replacesiteconfirm')) && !$file_manager) {
2861 print
'<!-- Bar for websitepage -->';
2862 print
'<div class="centpercent websitebar"'.($style ?
' style="'.$style.
'"' :
'').
'">';
2864 print
'<span class="websiteselection hideonsmartphoneimp minwidth100 tdoverflowmax100">';
2865 print $langs->trans(
"PageContainer").
': ';
2868 print
'<span class="websiteselection">';
2869 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=createcontainer&token='.
newToken().
'&website='.urlencode($website->ref).
'" class="button bordertransp"'.$disabled.
' title="'.
dol_escape_htmltag($langs->trans(
"AddPage")).
'"><span class="fa fa-plus-circle valignmiddle btnTitle-icon"></span></a>';
2874 if ($action !=
'addcontainer') {
2877 $s = $formwebsite->selectContainer($website,
'pageid', $pageid, 0, $action,
'maxwidth200onsmartphone');
2879 if ($formwebsite->num > 0) {
2880 $out .=
'<span class="websiteselection">';
2884 $urltocreatenewpage = $_SERVER[
"PHP_SELF"].
'?action=createcontainer&token='.
newToken().
'&website='.urlencode($website->ref);
2886 if (!empty($conf->use_javascript_ajax)) {
2887 $out .=
'<script type="text/javascript">';
2888 $out .=
'jQuery(document).ready(function () {';
2889 $out .=
' jQuery("#pageid").change(function () {';
2890 $out .=
' console.log("We select "+jQuery("#pageid option:selected").val());';
2891 $out .=
' if (jQuery("#pgeid option:selected").val() == \'-2\') {';
2892 $out .=
' window.location.href = "'.$urltocreatenewpage.
'";';
2893 $out .=
' } else {';
2894 $out .=
' window.location.href = "'.$_SERVER[
"PHP_SELF"].
'?website='.urlencode($website->ref).
'&pageid="+jQuery("#pageid option:selected").val();';
2898 $out .=
'</script>';
2904 print $langs->trans(
"New");
2908 print
'<span class="websiteselection">';
2910 print
'<input type="image" class="valignmiddle" src="'.img_picto(
'',
'refresh',
'', 0, 1).
'" name="refreshpage" value="'.$langs->trans(
"Load").
'"'.(($atleastonepage && $action !=
'editsource') ?
'' :
' disabled="disabled"').
'>';
2913 $pagepreviousid = 0;
2916 $sql =
"SELECT MAX(rowid) as pagepreviousid FROM ".MAIN_DB_PREFIX.
"website_page WHERE rowid < ".((int) $pageid).
" AND fk_website = ".((int) $object->id);
2917 $resql = $db->query($sql);
2919 $obj = $db->fetch_object(
$resql);
2921 $pagepreviousid = $obj->pagepreviousid;
2926 $sql =
"SELECT MIN(rowid) as pagenextid FROM ".MAIN_DB_PREFIX.
"website_page WHERE rowid > ".((int) $pageid).
" AND fk_website = ".((int) $object->id);
2927 $resql = $db->query($sql);
2929 $obj = $db->fetch_object(
$resql);
2931 $pagenextid = $obj->pagenextid;
2938 if ($pagepreviousid) {
2939 print
'<a class="valignmiddle" href="'.$_SERVER[
'PHP_SELF'].
'?website='.urlencode($object->ref).
'&pageid='.$pagepreviousid.
'&action='.$action.
'&token='.
newToken().
'">'.
img_previous($langs->trans(
"PreviousContainer")).
'</a>';
2941 print
'<span class="valignmiddle opacitymedium">'.img_previous($langs->trans(
"Previous")).
'</span>';
2944 print
'<a class="valignmiddle" href="'.$_SERVER[
'PHP_SELF'].
'?website='.urlencode($object->ref).
'&pageid='.$pagenextid.
'&action='.$action.
'&token='.
newToken().
'">'.
img_next($langs->trans(
"NextContainer")).
'</a>';
2946 print
'<span class="valignmiddle opacitymedium">'.img_next($langs->trans(
"Next")).
'</span>';
2951 $websitepage =
new WebSitePage($db);
2952 if ($pageid > 0 && ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone')) {
2953 $websitepage->fetch($pageid);
2956 if ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite') {
2958 if (empty($user->rights->website->write)) {
2959 $disabled =
' disabled="disabled"';
2963 if ($action ==
'deletesite') {
2965 $formquestion = array(
2966 array(
'type' =>
'checkbox',
'name' =>
'delete_also_js',
'label' => $langs->trans(
"DeleteAlsoJs"),
'value' => 0),
2967 array(
'type' =>
'checkbox',
'name' =>
'delete_also_medias',
'label' => $langs->trans(
"DeleteAlsoMedias"),
'value' => 0),
2972 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeleteWebsite'),
'',
'confirm_deletesite', $formquestion, 0, 1, 200);
2978 if ($action ==
'createfromclone') {
2980 $formquestion = array(
2981 array(
'type' =>
'text',
'name' =>
'siteref',
'label'=> $langs->trans(
"WebSite"),
'value'=>
'copy_of_'.$object->ref)
2984 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'CloneSite'),
'',
'confirm_createfromclone', $formquestion, 0, 1, 200);
2989 if ($pageid > 0 && $atleastonepage) {
2991 if ($action ==
'createpagefromclone') {
2993 $preselectedlanguage =
GETPOST(
'newlang',
'aZ09') ?
GETPOST(
'newlang',
'aZ09') :
'';
2994 $onlylang = array();
2995 if ($website->otherlang) {
2996 if (!empty($website->lang)) {
2997 $onlylang[$website->lang] = $website->lang.
' ('.$langs->trans(
"Default").
')';
2999 foreach (explode(
',', $website->otherlang) as $langkey) {
3000 if (empty(trim($langkey)))
continue;
3001 $onlylang[$langkey] = $langkey;
3003 $textifempty = $langs->trans(
"Default");
3005 $onlylang[
'none'] =
'none';
3006 $textifempty = $langs->trans(
"Default");
3008 $formquestion = array(
3009 array(
'type' =>
'hidden',
'name' =>
'sourcepageurl',
'value'=> $objectpage->pageurl),
3010 array(
'type' =>
'other',
'tdclass'=>
'fieldrequired',
'name' =>
'newwebsite',
'label' => $langs->trans(
"WebSite"),
'value' => $formwebsite->selectWebsite($object->id,
'newwebsite', 0)),
3011 array(
'type' =>
'text',
'tdclass'=>
'maxwidth200 fieldrequired',
'moreattr'=>
'autofocus="autofocus"',
'name' =>
'newtitle',
'label'=> $langs->trans(
"WEBSITE_TITLE"),
'value'=> $langs->trans(
"CopyOf").
' '.$objectpage->title),
3012 array(
'type' =>
'text',
'tdclass'=>
'maxwidth200',
'name' =>
'newpageurl',
'label'=> $langs->trans(
"WEBSITE_PAGENAME"),
'value'=>
'')
3014 if (count($onlylang) > 1) {
3015 $formquestion[] = array(
'type' =>
'checkbox',
'tdclass'=>
'maxwidth200',
'name' =>
'is_a_translation',
'label' => $langs->trans(
"PageIsANewTranslation"),
'value' => 0,
'morecss'=>
'margintoponly');
3018 $value= $formadmin->select_language($preselectedlanguage,
'newlang', 0,
null, $textifempty, 0, 0,
'minwidth200', 1, 0, 0, $onlylang, 1);
3019 $formquestion[] = array(
'type' =>
'other',
'name' =>
'newlang',
'label' =>
$form->textwithpicto($langs->trans(
"Language"), $langs->trans(
"DefineListOfAltLanguagesInWebsiteProperties")),
'value' => $value);
3021 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?website='.$object->ref.
'&pageid='.$pageid, $langs->trans(
'ClonePage'),
'',
'confirm_createpagefromclone', $formquestion, 0, 1, 300, 550);
3026 print
'<span class="websiteselection">';
3031 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?website='.$object->ref.
'&pageid='.$pageid.
'&action=editmeta&token='.
newToken().
'" class="button bordertransp" title="'.
dol_escape_htmltag($langs->trans(
"EditPageMeta")).
'"'.$disabled.
'><span class="fa fa-cog paddingrightonly"></span><span class="hideonsmartphone">'.
dol_escape_htmltag($langs->trans(
"EditPageMeta")).
'</span></a>';
3034 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?website='.$object->ref.
'&pageid='.$pageid.
'&action=editsource&token='.
newToken().
'" class="button bordertransp"'.$disabled.
'>'.
dol_escape_htmltag($langs->trans($conf->dol_optimize_smallscreen ?
"HTML" :
"EditHTMLSource")).
'</a>';
3037 print
'<!-- button EditInLine and ShowSubcontainers -->'.
"\n";
3038 print
'<div class="websiteselectionsection inline-block">';
3040 print
'<div class="inline-block marginrightonly">';
3041 print $langs->trans(
"ShowSubcontainers");
3042 if (empty($conf->global->WEBSITE_SUBCONTAINERSINLINE)) {
3043 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',
'',
false, 0, 0,
'',
'nomarginleft').
'</a>';
3045 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',
'',
false, 0, 0,
'',
'nomarginleft').
'</a>';
3049 print
'<div class="inline-block marginrightonly">';
3051 print
'<span id="switchckeditorinline">'.
"\n";
3052 print
'<!-- Code to enabled edit inline ckeditor -->'.
"\n";
3053 print
'<script type="text/javascript">
3054 $(document).ready(function() {
3055 var isEditingEnabled = '.(getDolGlobalString(
"WEBSITE_EDITINLINE") ?
'true' :
'false').
';
3056 if (isEditingEnabled)
3058 switchEditorOnline(true);
3061 $( "#switchckeditorinline" ).click(function() {
3062 switchEditorOnline();
3065 function switchEditorOnline(forceenable)
3067 if (! isEditingEnabled || forceenable)
3069 console.log("Enable inline edit");
3070 jQuery(\'section[contenteditable="true"],div[contenteditable="true"]\').each(function(idx){
3071 var idtouse = $(this).attr(\'id\');
3072 console.log("Enable inline edit for "+idtouse);
3073 CKEDITOR.inline(idtouse, {
3074 // Allow some non-standard markup that we used in the introduction.
3075 extraAllowedContent: \'span(*);cite(*);q(*);dl(*);dt(*);dd(*);ul(*);li(*);header(*);button(*);h1(*);h2(*);\',
3076 //extraPlugins: \'sourcedialog\',
3077 removePlugins: \'flash,stylescombo,exportpdf,scayt,wsc,pagebreak,iframe,smiley\',
3078 // Show toolbar on startup (optional).
3079 // startupFocus: true
3083 isEditingEnabled = true;
3086 console.log("Disable inline edit");
3087 for(name in CKEDITOR.instances)
3089 CKEDITOR.instances[name].destroy(true);
3091 isEditingEnabled = false;
3096 print $langs->trans(
"EditInLine");
3100 $disableeditinline = 0;
3101 if ($disableeditinline) {
3103 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',
'',
false, 0, 0,
'',
'nomarginleft').
'</a>';
3106 if (empty($conf->global->WEBSITE_EDITINLINE)) {
3107 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',
'',
false, 0, 0,
'',
'nomarginleft').
'</a>';
3109 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',
'',
false, 0, 0,
'',
'nomarginleft').
'</a>';
3118 if ($object->fk_default_home > 0 && $pageid == $object->fk_default_home) {
3122 print
'<a href="#" class="button bordertransp disabled" disabled="disabled" title="'.dol_escape_htmltag($langs->trans(
"SetAsHomePage")).
'"><span class="fa fa-home valignmiddle btnTitle-icon"></span></a>';
3126 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setashome&token='.
newToken().
'&website='.urlencode($website->ref).
'&pageid='.((int) $pageid).
'" class="button bordertransp"'.$disabled.
' title="'.
dol_escape_htmltag($langs->trans(
"SetAsHomePage")).
'"><span class="fa fa-home valignmiddle btnTitle-icon"></span></a>';
3128 print
'<input type="submit" class="button bordertransp"'.$disabled.
' value="'.
dol_escape_htmltag($langs->trans(
"ClonePage")).
'" name="createpagefromclone">';
3129 print
'<input type="submit" class="buttonDelete bordertransp" name="delete" value="'.$langs->trans(
"Delete").
'"'.($atleastonepage ?
'' :
' disabled="disabled"').
'>';
3135 print
'<span class="websitetools">';
3137 if (($pageid > 0 && $atleastonepage) && ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite')) {
3138 $realpage = $urlwithroot.
'/public/website/index.php?website='.$websitekey.
'&pageref='.$websitepage->pageurl;
3139 $pagealias = $websitepage->pageurl;
3141 $htmltext = $langs->trans(
"PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv(
"Page"), $langs->transnoentitiesnoconv(
"Page"), $realpage, $dataroot);
3142 $htmltext .=
'<br>'.$langs->trans(
"CheckVirtualHostPerms", $langs->transnoentitiesnoconv(
"ReadPerm"),
'{s1}');
3143 $htmltext = str_replace(
'{s1}', $dataroot.
'<br>'.DOL_DATA_ROOT.
'/medias<br>'.DOL_DOCUMENT_ROOT, $htmltext);
3147 print
'<div class="websiteinputurl inline-block paddingright">';
3148 print
'<a class="websitebuttonsitepreview inline-block" id="previewpage" href="'.$realpage.
'&nocache='.
dol_now().
'" class="button" target="tab'.$websitekey.
'" alt="'.
dol_escape_htmltag($htmltext).
'">';
3149 print
$form->textwithpicto(
'', $htmltext, 1,
'preview');
3173 if (!in_array($action, array(
'editcss',
'editmenu',
'file_manager',
'replacesite',
'replacesiteconfirm',
'createsite',
'createcontainer',
'createfromclone',
'createpagefromclone',
'deletesite'))) {
3174 if ($action ==
'editsource' || $action ==
'editmeta') {
3175 print
'<input type="submit" id="savefileandstay" class="button buttonforacesave hideonsmartphone small" value="'.dol_escape_htmltag($langs->trans(
"SaveAndStay")).
'" name="updateandstay">';
3177 if (preg_match(
'/^create/', $action)) {
3178 print
'<input type="submit" id="savefile" class="button buttonforacesave button-save small" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
3180 if (preg_match(
'/^edit/', $action)) {
3181 print
'<input type="submit" id="savefile" class="button buttonforacesave button-save small" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
3183 if ($action !=
'preview') {
3184 print
'<input type="submit" class="button button-cancel small" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'" name="cancel">';
3190 print
'<span class="websitehelp">';
3191 if ($action ==
'editsource' || $action ==
'editcontent' ||
GETPOST(
'editsource',
'alpha') ||
GETPOST(
'editcontent',
'alpha')) {
3192 $url =
'https://wiki.dolibarr.org/index.php/Module_Website';
3194 $htmltext = $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource", $url);
3195 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource2", $url);
3196 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSourceMore", $url);
3197 $htmltext .=
'<br>';
3198 if ($conf->browser->layout ==
'phone') {
3199 print
$form->textwithpicto(
'', $htmltext, 1,
'help',
'inline-block', 1, 2,
'tooltipsubstitution');
3202 print
$form->textwithpicto($langs->trans(
"SyntaxHelp").
' '.
img_help(2, $langs->trans(
"SyntaxHelp")), $htmltext, 1,
'none',
'inline-block', 1, 2,
'tooltipsubstitution');
3208 if ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone') {
3210 if (!empty($conf->use_javascript_ajax)) {
3211 print
'<script type="text/javascript">
3212 jQuery(document).ready(function() {
3213 jQuery("#websiteinputurl").keyup(function() {
3214 console.log("Website external url modified "+jQuery("#previewsiteurl").val());
3215 if (jQuery("#previewsiteurl").val() != "" && jQuery("#previewsiteurl").val().startsWith("http"))
3217 jQuery("a.websitebuttonsitepreviewdisabled img").css({ opacity: 1 });
3219 else jQuery("a.websitebuttonsitepreviewdisabled img").css({ opacity: 0.2 });
3223 jQuery("#previewsiteext,#previewpageext").click(function() {
3225 newurl=jQuery("#previewsiteurl").val();
3226 if (! newurl.startsWith("http"))
3228 alert(\''.dol_escape_js($langs->trans(
"ErrorURLMustStartWithHttp")).
'\');
3232 newpage=jQuery(
"#previewsiteurl").val() +
"/" + jQuery(
"#previewpageurl").val() +
".php";
3233 console.log(
"Open url "+newurl);
3237 url:
"'.DOL_URL_ROOT.'/core/ajax/saveinplace.php",
3239 field: \
'editval_virtualhost\',
3240 element: \'website\',
3241 table_element: \'website\',
3242 fk_element: '.((int) $object->id).
',
3245 context: document.body
3248 jQuery("#previewsiteext").attr("href",newurl);
3249 jQuery("#previewpageext").attr("href",newpage);
3268 if ($action ==
'editcss') {
3269 print
'<div class="fiche">';
3274 $csscontent = @file_get_contents($filecss);
3276 $csscontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims',
'', $csscontent);
3278 $csscontent =
GETPOST(
'WEBSITE_CSS_INLINE',
'none');
3280 if (!trim($csscontent)) {
3281 $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;}";
3285 $jscontent = @file_get_contents($filejs);
3287 $jscontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims',
'', $jscontent);
3289 $jscontent =
GETPOST(
'WEBSITE_JS_INLINE',
'none');
3291 if (!trim($jscontent)) {
3292 $jscontent =
'/* JS content (all pages) */'.
"\n";
3296 $htmlheadercontent = @file_get_contents($filehtmlheader);
3298 $htmlheadercontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims',
'', $htmlheadercontent);
3300 $htmlheadercontent =
GETPOST(
'WEBSITE_HTML_HEADER',
'none');
3302 if (!trim($htmlheadercontent)) {
3303 $htmlheadercontent =
"<html>\n";
3304 $htmlheadercontent .= $htmlheadercontentdefault;
3305 $htmlheadercontent .=
"</html>";
3307 $htmlheadercontent = preg_replace(
'/^\s*<html>/ims',
'', $htmlheadercontent);
3308 $htmlheadercontent = preg_replace(
'/<\/html>\s*$/ims',
'', $htmlheadercontent);
3309 $htmlheadercontent =
'<html>'.
"\n".trim($htmlheadercontent).
"\n".
'</html>';
3313 $robotcontent = @file_get_contents($filerobot);
3315 $robotcontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims',
'', $robotcontent);
3317 $robotcontent =
GETPOST(
'WEBSITE_ROBOT',
'nothtml');
3319 if (!trim($robotcontent)) {
3320 $robotcontent .=
"# Robot file. Generated with ".DOL_APPLICATION_TITLE.
"\n";
3321 $robotcontent .=
"User-agent: *\n";
3322 $robotcontent .=
"Allow: /public/\n";
3323 $robotcontent .=
"Disallow: /administrator/\n";
3327 $htaccesscontent = @file_get_contents($filehtaccess);
3329 $htaccesscontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims',
'', $htaccesscontent);
3331 $htaccesscontent =
GETPOST(
'WEBSITE_HTACCESS',
'nohtml');
3333 if (!trim($htaccesscontent)) {
3334 $htaccesscontent .=
"# Order allow,deny\n";
3335 $htaccesscontent .=
"# Deny from all\n";
3340 $manifestjsoncontent = @file_get_contents($filemanifestjson);
3342 $manifestjsoncontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims',
'', $manifestjsoncontent);
3344 $manifestjsoncontent =
GETPOST(
'WEBSITE_MANIFEST_JSON',
'restricthtml');
3346 if (!trim($manifestjsoncontent)) {
3351 $readmecontent = @file_get_contents($filereadme);
3353 $readmecontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims',
'', $readmecontent);
3355 $readmecontent =
GETPOST(
'WEBSITE_README',
'none');
3357 if (!trim($readmecontent)) {
3363 print
'<!-- Edit Website properties -->'.
"\n";
3364 print
'<table class="border centpercent">';
3367 print
'<tr><td class="titlefieldcreate fieldrequired">';
3368 print $langs->trans(
'WebSite');
3374 print
'<!-- Status of website -->'.
"\n";
3375 print
'<tr><td class="fieldrequired">';
3376 print $langs->trans(
'Status');
3383 print
'<tr><td class="tdtop fieldrequired">';
3385 print
$form->textwithpicto($langs->trans(
'MainLanguage'), $htmltext, 1,
'help',
'', 0, 2,
'WEBSITE_LANG');
3387 print $formadmin->select_language((
GETPOSTISSET(
'WEBSITE_LANG') ?
GETPOST(
'WEBSITE_LANG',
'aZ09comma') : ($object->lang ? $object->lang :
'0')),
'WEBSITE_LANG', 0,
null, 1, 0, 0,
'minwidth300', 2, 0, 0, array(), 1);
3392 print
'<tr><td class="tdtop">';
3393 $htmltext = $langs->trans(
"Example").
': fr,de,sv,it,pt';
3394 print
$form->textwithpicto($langs->trans(
'OtherLanguages'), $htmltext, 1,
'help',
'', 0, 2);
3396 print
'<input type="text" class="flat" value="'.(GETPOSTISSET(
'WEBSITE_OTHERLANG') ?
GETPOST(
'WEBSITE_OTHERLANG',
'alpha') : $object->otherlang).
'" name="WEBSITE_OTHERLANG">';
3401 print
'<tr><td class="tdtop">';
3403 $htmltext = $langs->trans(
"SetHereVirtualHost", DOL_DATA_ROOT.($conf->entity > 1 ?
'/'.$conf->entity :
'').
'/website/{s1}'.$websitekey.
'{s2}');
3404 $htmltext = str_replace(array(
'{s1}',
'{s2}'), array(
'<i>',
'</i>'), $htmltext);
3405 $htmltext .=
'<br>';
3406 $htmltext .=
'<br>'.$langs->trans(
"CheckVirtualHostPerms", $langs->transnoentitiesnoconv(
"ReadPerm"), DOL_DOCUMENT_ROOT);
3407 $htmltext .=
'<br>'.$langs->trans(
"CheckVirtualHostPerms", $langs->transnoentitiesnoconv(
"WritePerm"),
'{s1}');
3408 $htmltext = str_replace(
'{s1}', DOL_DATA_ROOT.
'/website<br>'.DOL_DATA_ROOT.
'/medias', $htmltext);
3410 print
$form->textwithpicto($langs->trans(
'Virtualhost'), $htmltext, 1,
'help',
'', 0, 2,
'virtualhosttooltip');
3412 print
'<input type="text" class="flat minwidth300" value="'.(GETPOSTISSET(
'virtualhost') ?
GETPOST(
'virtualhost',
'alpha') : $virtualurl).
'" name="virtualhost">';
3418 print
$form->textwithpicto($langs->trans(
'ImportFavicon'), $langs->trans(
'FaviconTooltip'));
3421 $maxmin = $maxfilesizearray[
'maxmin'];
3423 print
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
3425 print
'<input type="file" class="flat minwidth300" name="addedfile" id="addedfile"/>';
3429 print
'<tr><td class="tdtop">';
3430 $htmlhelp = $langs->trans(
"CSSContentTooltipHelp");
3431 print
$form->textwithpicto($langs->trans(
'WEBSITE_CSS_INLINE'), $htmlhelp, 1,
'help',
'', 0, 2,
'csstooltip');
3434 $poscursor = array(
'x'=>
GETPOST(
'WEBSITE_CSS_INLINE_x'),
'y'=>
GETPOST(
'WEBSITE_CSS_INLINE_y'));
3435 $doleditor =
new DolEditor(
'WEBSITE_CSS_INLINE', $csscontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'', $poscursor);
3436 print $doleditor->Create(1,
'',
true,
'CSS',
'css');
3441 print
'<tr><td class="tdtop">';
3442 $textwithhelp = $langs->trans(
'WEBSITE_JS_INLINE');
3443 $htmlhelp2 = $langs->trans(
"LinkAndScriptsHereAreNotLoadedInEditor").
'<br>';
3444 print
$form->textwithpicto($textwithhelp, $htmlhelp2, 1,
'warning',
'', 0, 2,
'htmljstooltip2');
3448 $poscursor = array(
'x'=>
GETPOST(
'WEBSITE_JS_INLINE_x'),
'y'=>
GETPOST(
'WEBSITE_JS_INLINE_y'));
3449 $doleditor =
new DolEditor(
'WEBSITE_JS_INLINE', $jscontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'', $poscursor);
3450 print $doleditor->Create(1,
'',
true,
'JS',
'javascript');
3455 print
'<tr><td class="tdtop">';
3456 print $langs->trans(
'WEBSITE_HTML_HEADER');
3457 $htmlhelp = $langs->trans(
"Example").
' :<br>';
3459 $textwithhelp =
$form->textwithpicto(
'', $htmlhelp, 1,
'help',
'', 0, 2,
'htmlheadertooltip');
3460 $htmlhelp2 = $langs->trans(
"LinkAndScriptsHereAreNotLoadedInEditor").
'<br>';
3461 print
$form->textwithpicto($textwithhelp, $htmlhelp2, 1,
'warning',
'', 0, 2,
'htmlheadertooltip2');
3464 $poscursor = array(
'x'=>
GETPOST(
'WEBSITE_HTML_HEADER_x'),
'y'=>
GETPOST(
'WEBSITE_HTML_HEADER_y'));
3465 $doleditor =
new DolEditor(
'WEBSITE_HTML_HEADER', $htmlheadercontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'', $poscursor);
3466 print $doleditor->Create(1,
'',
true,
'HTML Header',
'html');
3471 print
'<tr><td class="tdtop">';
3472 print $langs->trans(
'WEBSITE_ROBOT');
3475 $poscursor = array(
'x'=>
GETPOST(
'WEBSITE_ROBOT_x'),
'y'=>
GETPOST(
'WEBSITE_ROBOT_y'));
3476 $doleditor =
new DolEditor(
'WEBSITE_ROBOT', $robotcontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'', $poscursor);
3477 print $doleditor->Create(1,
'',
true,
'Robot file',
'text');
3482 print
'<tr><td class="tdtop">';
3483 print $langs->trans(
'WEBSITE_HTACCESS');
3486 $poscursor = array(
'x'=>
GETPOST(
'WEBSITE_HTACCESS_x'),
'y'=>
GETPOST(
'WEBSITE_HTACCESS_y'));
3487 $doleditor =
new DolEditor(
'WEBSITE_HTACCESS', $htaccesscontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'', $poscursor);
3488 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' .htaccess',
'text');
3493 print
'<tr><td class="tdtop">';
3494 $htmlhelp = $langs->trans(
"Example").
' :<br>';
3496 print
$form->textwithpicto($langs->trans(
'WEBSITE_MANIFEST_JSON'), $htmlhelp, 1,
'help',
'', 0, 2,
'manifestjsontooltip');
3498 print $langs->trans(
"UseManifest").
': '.
$form->selectyesno(
'use_manifest', $website->use_manifest, 1).
'<br>';
3500 $poscursor = array(
'x'=>
GETPOST(
'WEBSITE_MANIFEST_JSON_x'),
'y'=>
GETPOST(
'WEBSITE_MANIFEST_JSON_y'));
3501 $doleditor =
new DolEditor(
'WEBSITE_MANIFEST_JSON', $manifestjsoncontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'', $poscursor);
3502 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' manifest.json',
'text');
3506 print
'<tr><td class="tdtop">';
3507 $htmlhelp = $langs->trans(
"EnterHereLicenseInformation");
3508 print
$form->textwithpicto($langs->trans(
'WEBSITE_README'), $htmlhelp, 1,
'help',
'', 0, 2,
'readmetooltip');
3511 $poscursor = array(
'x'=>
GETPOST(
'WEBSITE_README_x'),
'y'=>
GETPOST(
'WEBSITE_README_y'));
3512 $doleditor =
new DolEditor(
'WEBSITE_README', $readmecontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'', $poscursor);
3513 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' README.md',
'text');
3518 print
'<tr><td class="tdtop">';
3519 $htmlhelp = $langs->trans(
'RSSFeedDesc');
3520 print
$form->textwithpicto($langs->trans(
'RSSFeed'), $htmlhelp, 1,
'help',
'', 0, 2,
'');
3522 print
'/wrapper.php?rss=1[&l=XX][&limit=123]';
3535 if ($action ==
'createsite') {
3536 print
'<div class="fiche">';
3550 if ($action ==
'createcontainer') {
3554 print
'<!-- Add site -->'.
"\n";
3557 print
'<table class="border centpercent">';
3559 $siteref = $sitedesc = $sitelang = $siteotherlang =
'';
3561 $siteref =
GETPOST(
'WEBSITE_REF',
'aZ09');
3563 if (
GETPOST(
'WEBSITE_DESCRIPTION')) {
3564 $sitedesc =
GETPOST(
'WEBSITE_DESCRIPTION',
'alpha');
3566 if (
GETPOST(
'WEBSITE_LANG')) {
3567 $sitelang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
3569 if (
GETPOST(
'WEBSITE_OTHERLANG')) {
3570 $siteotherlang =
GETPOST(
'WEBSITE_OTHERLANG',
'aZ09comma');
3573 print
'<tr><td class="titlefieldcreate fieldrequired">';
3574 print
$form->textwithpicto($langs->trans(
'WebSite'), $langs->trans(
"Example").
': www.mywebsite.com, myportal, ...');
3576 print
'<input type="text" class="flat maxwidth300" name="WEBSITE_REF" value="'.dol_escape_htmltag($siteref).
'" autofocus>';
3579 print
'<tr><td class="fieldrequired">';
3580 print $langs->trans(
'MainLanguage');
3582 $shortlangcode = preg_replace(
'/[_-].*$/',
'', trim($langs->defaultlang));
3583 print $formadmin->select_language((
GETPOSTISSET(
'WEBSITE_LANG') ?
GETPOST(
'WEBSITE_LANG',
'aZ09comma') : $shortlangcode),
'WEBSITE_LANG', 0,
null, 1, 0, 0,
'minwidth300', 2, 0, 0, array(), 1);
3587 print $langs->trans(
'Description');
3589 print
'<input type="text" class="flat minwidth500" name="WEBSITE_DESCRIPTION" value="'.dol_escape_htmltag($sitedesc).
'">';
3593 $htmltext = $langs->trans(
"Example").
': fr,de,sv,it,pt';
3594 print
$form->textwithpicto($langs->trans(
'OtherLanguages'), $htmltext, 1,
'help',
'', 0, 2);
3596 print
'<input type="text" class="flat minwidth300" name="WEBSITE_OTHERLANG" value="'.dol_escape_htmltag($siteotherlang).
'">';
3601 $htmltext = $langs->trans(
"SetHereVirtualHost",
'{s1}');
3602 $htmltext = str_replace(
'{s1}', DOL_DATA_ROOT.($conf->entity > 1 ?
'/'.$conf->entity :
'').
'/website/<i>websiteref</i>', $htmltext);
3603 $htmltext .=
'<br>';
3604 $htmltext .=
'<br>'.$langs->trans(
"CheckVirtualHostPerms", $langs->transnoentitiesnoconv(
"ReadPerm"), DOL_DOCUMENT_ROOT);
3605 $htmltext .=
'<br>'.$langs->trans(
"CheckVirtualHostPerms", $langs->transnoentitiesnoconv(
"WritePerm"),
'{s1}');
3606 $htmltext = str_replace(
'{s1}', DOL_DATA_ROOT.
'/website<br>'.DOL_DATA_ROOT.
'/medias', $htmltext);
3608 print
$form->textwithpicto($langs->trans(
'Virtualhost'), $htmltext, 1,
'help',
'', 0, 2,
'virtualhosttooltip');
3610 print
'<input type="text" class="flat minwidth300" name="virtualhost" value="'.dol_escape_htmltag(
GETPOST(
'virtualhost',
'alpha')).
'">';
3616 if ($action ==
'createsite') {
3617 print
'<div class="center">';
3619 print
'<input type="submit" class="button small" name="addcontainer" value="'.$langs->trans(
"Create").
'">';
3620 print
'<input class="button button-cancel small" type="submit" name="preview" value="'.$langs->trans(
"Cancel").
'">';
3635 if ($action ==
'importsite') {
3636 print
'<div class="fiche">';
3644 print
'<span class="opacitymedium">'.$langs->trans(
"ZipOfWebsitePackageToImport").
'</span><br><br>';
3647 $maxmin = $maxfilesizearray[
'maxmin'];
3649 print
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
3651 print
'<input class="flat minwidth400" type="file" name="userfile[]" accept=".zip">';
3652 print
'<input type="submit" class="button small" name="buttonsubmitimportfile" value="'.dol_escape_htmltag($langs->trans(
"Upload")).
'">';
3653 print
'<input type="submit" class="button button-cancel small" name="preview" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
3655 print
'<br><br><br>';
3658 print
'<span class="opacitymedium">'.$langs->trans(
"ZipOfWebsitePackageToLoad").
'</span><br><br>';
3669 if ($action ==
'editmeta' || $action ==
'createcontainer') {
3670 print
'<div class="fiche">';
3684 if ($action ==
'createcontainer') {
3688 print
'<!-- Edit or create page/container -->'.
"\n";
3691 $hiddenfromfetchingafterload =
' hideobject';
3692 $hiddenmanuallyafterload =
' hideobject';
3693 if (
GETPOST(
'radiocreatefrom') ==
'checkboxcreatefromfetching') {
3694 $hiddenfromfetchingafterload =
'';
3696 if (
GETPOST(
'radiocreatefrom') ==
'checkboxcreatemanually') {
3697 $hiddenmanuallyafterload =
'';
3700 if ($action ==
'editmeta' || empty($conf->use_javascript_ajax)) {
3701 $hiddenfromfetchingafterload =
'';
3702 $hiddenmanuallyafterload =
'';
3705 if ($action ==
'createcontainer') {
3708 if (!empty($conf->use_javascript_ajax)) {
3709 print
'<input type="radio" name="radiocreatefrom" id="checkboxcreatemanually" value="checkboxcreatemanually"'.(GETPOST(
'radiocreatefrom') ==
'checkboxcreatemanually' ?
' checked' :
'').
'> ';
3711 print
'<label for="checkboxcreatemanually"><span class="opacitymediumxx">'.$langs->trans(
"OrEnterPageInfoManually").
'</span></label><br>';
3712 print
'<hr class="tablecheckboxcreatemanually'.$hiddenmanuallyafterload.
'">';
3715 print
'<table class="border tableforfield nobackground centpercent tablecheckboxcreatemanually'.$hiddenmanuallyafterload.
'">';
3717 if ($action !=
'createcontainer') {
3718 print
'<tr><td class="titlefield fieldrequired">';
3719 print $langs->trans(
'IDOfPage').
' - '.$langs->trans(
'InternalURLOfPage');
3727 print
' - ';
3728 print
'/public/website/index.php?website='.urlencode($websitekey).
'&pageid='.urlencode($pageid);
3732 $type_container = $objectpage->type_container;
3733 $pageurl = $objectpage->pageurl;
3734 $pagealiasalt = $objectpage->aliasalt;
3735 $pagetitle = $objectpage->title;
3736 $pagedescription = $objectpage->description;
3737 $pageimage = $objectpage->image;
3738 $pagekeywords = $objectpage->keywords;
3739 $pagelang = $objectpage->lang;
3740 $pageallowedinframes = $objectpage->allowed_in_frames;
3741 $pagehtmlheader = $objectpage->htmlheader;
3742 $pagedatecreation = $objectpage->date_creation;
3743 $pagedatemodification = $objectpage->date_modification;
3744 $pageauthorid = $objectpage->fk_user_creat;
3745 $pageusermodifid = $objectpage->fk_user_modif;
3746 $pageauthoralias = $objectpage->author_alias;
3747 $pagestatus = $objectpage->status;
3749 $type_container =
'page';
3753 $pagedescription =
'';
3757 $pageallowedinframes = 0;
3758 $pagehtmlheader =
'';
3759 $pagedatecreation =
dol_now();
3760 $pagedatemodification =
'';
3761 $pageauthorid = $user->id;
3762 $pageusermodifid = 0;
3763 $pageauthoralias =
'';
3766 if (
GETPOST(
'WEBSITE_TITLE',
'alpha')) {
3767 $pagetitle = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_TITLE',
'alphanohtml'));
3769 if (
GETPOST(
'WEBSITE_PAGENAME',
'alpha')) {
3770 $pageurl =
GETPOST(
'WEBSITE_PAGENAME',
'alpha');
3772 if (
GETPOST(
'WEBSITE_ALIASALT',
'alpha')) {
3773 $pagealiasalt = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_ALIASALT',
'alphanohtml'));
3775 if (
GETPOST(
'WEBSITE_DESCRIPTION',
'alpha')) {
3776 $pagedescription = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml'));
3778 if (
GETPOST(
'WEBSITE_IMAGE',
'alpha')) {
3779 $pageimage =
GETPOST(
'WEBSITE_IMAGE',
'alpha');
3781 if (
GETPOST(
'WEBSITE_KEYWORDS',
'alpha')) {
3782 $pagekeywords = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_KEYWORDS',
'alphanohtml'));
3784 if (
GETPOST(
'WEBSITE_LANG',
'aZ09')) {
3785 $pagelang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
3787 if (
GETPOST(
'WEBSITE_ALLOWED_IN_FRAMES',
'aZ09')) {
3788 $pageallowedinframes =
GETPOST(
'WEBSITE_ALLOWED_IN_FRAMES',
'aZ09');
3790 if (
GETPOST(
'htmlheader',
'none')) {
3791 $pagehtmlheader =
GETPOST(
'htmlheader',
'none');
3794 if ($action !=
'createcontainer') {
3795 print
'<!-- Status of page -->'.
"\n";
3796 print
'<tr><td class="fieldrequired">';
3797 print $langs->trans(
'Status');
3799 print
ajax_object_onoff($objectpage,
'status',
'status',
'Enabled',
'Disabled');
3805 print
'<tr><td class="titlefield fieldrequired">';
3806 print $langs->trans(
'WEBSITE_TYPE_CONTAINER');
3808 print
img_picto(
'',
'object_technic',
'class="paddingrightonly"').
' ';
3809 $formwebsite->selectTypeOfContainer(
'WEBSITE_TYPE_CONTAINER', (
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'alpha') ?
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'alpha') : $type_container), 0,
'', 1);
3812 if ($action ==
'createcontainer') {
3813 print
'<tr><td class="titlefield fieldrequired">';
3814 print $langs->trans(
'WEBSITE_PAGE_EXAMPLE');
3816 print $formwebsite->selectSampleOfContainer(
'sample', (
GETPOSTISSET(
'sample') ?
GETPOST(
'sample',
'alpha') :
'empty'), 0,
'', 1,
'minwidth300');
3821 print
'<tr><td class="fieldrequired">';
3822 print $langs->trans(
'WEBSITE_TITLE');
3824 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_TITLE" id="WEBSITE_TITLE" value="'.dol_escape_htmltag($pagetitle).
'" autofocus>';
3828 print
'<tr><td class="titlefieldcreate fieldrequired">';
3829 print $langs->trans(
'WEBSITE_PAGENAME');
3831 print
'<input type="text" class="flat minwidth300" name="WEBSITE_PAGENAME" id="WEBSITE_PAGENAME" value="'.dol_escape_htmltag($pageurl).
'">';
3834 print
'<tr><td class="titlefieldcreate">';
3835 $htmlhelp = $langs->trans(
"WEBSITE_ALIASALTDesc");
3836 print
$form->textwithpicto($langs->trans(
'WEBSITE_ALIASALT'), $htmlhelp, 1,
'help',
'', 0, 2,
'aliastooltip');
3838 print
'<input type="text" class="flat minwidth500" name="WEBSITE_ALIASALT" value="'.dol_escape_htmltag($pagealiasalt).
'">';
3842 print $langs->trans(
'WEBSITE_DESCRIPTION');
3844 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_DESCRIPTION" value="'.dol_escape_htmltag($pagedescription).
'">';
3848 $htmlhelp = $langs->trans(
"WEBSITE_IMAGEDesc");
3849 print
$form->textwithpicto($langs->trans(
'WEBSITE_IMAGE'), $htmlhelp, 1,
'help',
'', 0, 2,
'imagetooltip');
3851 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_IMAGE" value="'.dol_escape_htmltag($pageimage).
'">';
3856 $htmlhelp = $langs->trans(
"WEBSITE_KEYWORDSDesc");
3857 print
$form->textwithpicto($langs->trans(
'WEBSITE_KEYWORDS'), $htmlhelp, 1,
'help',
'', 0, 2,
'keywordtooltip');
3859 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_KEYWORDS" value="'.dol_escape_htmltag($pagekeywords).
'">';
3863 print $langs->trans(
'Language');
3865 $onlykeys = array();
3866 if ($object->lang) {
3867 $onlykeys[$object->lang] = $object->lang;
3869 $onlykeys[$langs->defaultlang] = $langs->defaultlang;
3871 if ($object->otherlang) {
3872 $tmparray = explode(
',', $object->otherlang);
3873 foreach ($tmparray as $key) {
3874 $tmpkey = trim($key);
3875 if (strlen($key) == 2) {
3876 $tmpkey = strtolower($key);
3878 $onlykeys[$tmpkey] = $tmpkey;
3881 if (empty($object->lang) && empty($object->otherlang)) {
3884 print
img_picto(
'',
'language',
'class="pictofixedwidth"').$formadmin->select_language($pagelang ? $pagelang :
'',
'WEBSITE_LANG', 0,
null,
'1', 0, 0,
'minwidth200', 0, 0, 0, $onlykeys, 1);
3885 $htmltext = $langs->trans(
"AvailableLanguagesAreDefinedIntoWebsiteProperties");
3886 print
$form->textwithpicto(
'', $htmltext);
3892 print
'<!-- Translation of --><tr><td>';
3893 print $langs->trans(
'TranslationLinks');
3895 if ($action !=
'createcontainer') {
3897 $sql =
"SELECT rowid, lang from ".MAIN_DB_PREFIX.
"website_page where fk_page = ".((int) $objectpage->id);
3898 $resql = $db->query($sql);
3900 $num_rows = $db->num_rows(
$resql);
3901 if ($num_rows > 0) {
3902 print
'<span class="opacitymedium">'.$langs->trans(
'ThisPageHasTranslationPages').
':</span>';
3906 while ($obj = $db->fetch_object(
$resql)) {
3907 $result = $tmppage->fetch($obj->rowid);
3910 $tmpstring .=
'<br>';
3912 $tmpstring .= $tmppage->getNomUrl(1).
' ('.$tmppage->lang.
')';
3928 if (empty($translatedby) && ($action ==
'editmeta' || $action ==
'createcontainer' || $objectpage->fk_page > 0)) {
3930 $result = $sourcepage->fetch($objectpage->fk_page);
3933 } elseif ($result > 0) {
3934 $translationof = $objectpage->fk_page;
3935 print
'<span class="opacitymedium">'.$langs->trans(
'ThisPageIsTranslationOf').
'</span> ';
3936 print $formwebsite->selectContainer($website,
'pageidfortranslation', ($translationof ? $translationof : -1), 1, $action,
'minwidth300', array($objectpage->id));
3937 if ($translationof > 0 && $sourcepage->lang) {
3938 print $sourcepage->getNomUrl(2).
' ('.$sourcepage->lang.
')';
3946 print $langs->trans(
'AllowedInFrames');
3950 print
'<input type="checkbox" class="flat" name="WEBSITE_ALLOWED_IN_FRAMES" value="1"'.($pageallowedinframes ?
'checked="checked"' :
'').
'>';
3954 if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) {
3955 $langs->load(
'categories');
3958 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_WEBSITE_PAGE,
'',
null,
null,
null, 1);
3960 $cats = $c->containing($objectpage->id, Categorie::TYPE_WEBSITE_PAGE);
3961 $arrayselected = array();
3962 if (is_array($cats)) {
3963 foreach ($cats as $cat) {
3964 $arrayselected[] = $cat->id;
3968 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_WEBSITE_PAGE,
'',
'parent',
null,
null, 1);
3971 print
'<tr><td class="toptd">'.$form->editfieldkey(
'Categories',
'categories',
'', $objectpage, 0).
'</td><td>';
3972 print
img_picto(
'',
'category',
'class="pictofixedwidth"');
3973 print
$form->multiselectarray(
'categories', $cate_arbo, (
GETPOSTISSET(
'categories') ?
GETPOST(
'categories',
'array') : $arrayselected),
null,
null,
'minwidth200 widthcentpercentminusxx');
3977 if (!empty($conf->global->WEBSITE_PAGE_SHOW_INTERNAL_LINKS_TO_OBJECT)) {
3978 print
'<tr><td class="titlefieldcreate">';
3979 print
'ObjectClass';
3981 print
'<input type="text" class="flat minwidth300" name="WEBSITE_OBJECTCLASS" placeholder="ClassName::/path/class/ObjectClass.class.php" >';
3984 print
'<tr><td class="titlefieldcreate">';
3987 print
'<input type="text" class="flat minwidth300" name="WEBSITE_OBJECTID" >';
3991 $fuser =
new User($db);
3994 print $langs->trans(
'Author');
3996 if ($pageauthorid > 0) {
3997 $fuser->fetch($pageauthorid);
3998 print $fuser->getNomUrl(1);
4000 print
'<span class="opacitymedium">'.$langs->trans(
"Unknown").
'</span>';
4005 print $langs->trans(
'PublicAuthorAlias');
4007 print
'<input type="text" class="flat minwidth300" name="WEBSITE_AUTHORALIAS" value="'.dol_escape_htmltag($pageauthoralias).
'" placeholder="Anonymous">';
4011 print $langs->trans(
'DateCreation');
4013 print
$form->selectDate($pagedatecreation,
'datecreation', 1, 1, 0,
'', 1, 1);
4017 if ($action !=
'createcontainer') {
4019 print $langs->trans(
'UserModif');
4021 if ($pageusermodifid > 0) {
4022 $fuser->fetch($pageusermodifid);
4023 print $fuser->getNomUrl(1);
4028 print $langs->trans(
'DateModification');
4030 print
dol_print_date($pagedatemodification,
'dayhour',
'tzuser');
4034 print
'<tr><td class="tdhtmlheader tdtop">';
4035 $htmlhelp = $langs->trans(
"EditTheWebSiteForACommonHeader").
'<br><br>';
4036 $htmlhelp .= $langs->trans(
"Example").
' :<br>';
4038 print
$form->textwithpicto($langs->trans(
'HtmlHeaderPage'), $htmlhelp, 1,
'help',
'', 0, 2,
'htmlheadertooltip');
4040 $poscursor = array(
'x'=>
GETPOST(
'htmlheader_x'),
'y'=>
GETPOST(
'htmlheader_y'));
4041 $doleditor =
new DolEditor(
'htmlheader', $pagehtmlheader,
'',
'120',
'ace',
'In',
true,
false,
'ace', ROWS_3,
'100%',
'', $poscursor);
4042 print $doleditor->Create(1,
'',
true,
'HTML Header',
'html');
4046 if ($action ==
'createcontainer') {
4047 print
'<div class="center tablecheckboxcreatemanually'.$hiddenmanuallyafterload.
'">';
4049 print
'<input type="submit" class="button small" name="addcontainer" value="'.$langs->trans(
"Create").
'">';
4050 print
'<input class="button button-cancel small" type="submit" name="preview" value="'.$langs->trans(
"Cancel").
'">';
4057 if (!empty($conf->use_javascript_ajax)) {
4058 print
'<input type="radio" name="radiocreatefrom" id="checkboxcreatefromfetching" value="checkboxcreatefromfetching"'.(GETPOST(
'radiocreatefrom') ==
'checkboxcreatefromfetching' ?
' checked' :
'').
'> ';
4060 print
'<label for="checkboxcreatefromfetching"><span class="opacitymediumxx">'.$langs->trans(
"CreateByFetchingExternalPage").
'</span></label><br>';
4061 print
'<hr class="tablecheckboxcreatefromfetching'.$hiddenfromfetchingafterload.
'">';
4062 print
'<table class="tableforfield centpercent tablecheckboxcreatefromfetching'.$hiddenfromfetchingafterload.
'">';
4063 print
'<tr><td class="titlefield">';
4064 print $langs->trans(
"URL");
4066 print
info_admin($langs->trans(
"OnlyEditionOfSourceForGrabbedContentFuture"), 0, 0,
'warning');
4067 print
'<input class="flat minwidth500" type="text" name="externalurl" value="'.dol_escape_htmltag(
GETPOST(
'externalurl',
'alpha')).
'" placeholder="https://externalsite/pagetofetch"> ';
4068 print
'<br><input class="flat paddingtop" type="checkbox" name="grabimages" value="1" checked="checked"> '.$langs->trans(
"GrabImagesInto");
4070 print $langs->trans(
"ImagesShouldBeSavedInto").
' ';
4071 $arraygrabimagesinto = array(
'root'=>$langs->trans(
"WebsiteRootOfImages"),
'subpage'=>$langs->trans(
"SubdirOfPage"));
4072 print
$form->selectarray(
'grabimagesinto', $arraygrabimagesinto,
GETPOSTISSET(
'grabimagesinto') ?
GETPOST(
'grabimagesinto') :
'root', 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
4074 print
'<input class="button" style="margin-top: 5px" type="submit" name="fetchexternalurl" value="'.dol_escape_htmltag($langs->trans(
"FetchAndCreate")).
'">';
4079 if ($action ==
'createcontainer') {
4080 print
'<script type="text/javascript">
4081 jQuery(document).ready(function() {
4082 var disableautofillofalias = 0;
4083 var selectedm = \'\';
4084 var selectedf = \'\';
4085 jQuery("#WEBSITE_TITLE").keyup(function() {
4086 if (disableautofillofalias == 0)
4088 var valnospecial = jQuery("#WEBSITE_TITLE").val();
4089 valnospecial = valnospecial.replace(/[éèê]/g, \'e\').replace(/[à ]/g, \'a\').replace(/[ù]/g, \'u\').replace(/[î]/g, \'i\');
4090 valnospecial = valnospecial.replace(/[ç]/g, \'c\').replace(/[ö]/g, \'o\');
4091 valnospecial = valnospecial.replace(/[^\w]/gi, \'-\').toLowerCase();
4092 valnospecial = valnospecial.replace(/\-+/g, \'-\').replace(/\-$/, \'\');
4093 console.log("disableautofillofalias=0 so we replace WEBSITE_TITLE with "+valnospecial);
4094 jQuery("#WEBSITE_PAGENAME").val(valnospecial);
4097 jQuery("#WEBSITE_PAGENAME").keyup(function() {
4098 disableautofillofalias = 1;
4101 jQuery("#checkboxcreatefromfetching,#checkboxcreatemanually").click(function() {
4102 console.log("we select a method to create a new container "+jQuery("#checkboxcreatefromfetching:checked").val())
4103 jQuery(".tablecheckboxcreatefromfetching").hide();
4104 jQuery(".tablecheckboxcreatemanually").hide();
4105 if (typeof(jQuery("#checkboxcreatefromfetching:checked").val()) != \'undefined\') {
4106 console.log("show a");
4107 if (selectedf != \'createfromfetching\') {
4108 jQuery(".tablecheckboxcreatefromfetching").show();
4109 selectedf = \'createfromfetching\';
4112 jQuery(".tablecheckboxcreatefromfetching").hide();
4116 if (typeof(jQuery("#checkboxcreatemanually:checked").val()) != \'undefined\') {
4117 console.log("show b");
4118 if (selectedm != \'createmanually\') {
4119 jQuery(".tablecheckboxcreatemanually").show();
4120 selectedm = \'createmanually\';
4123 jQuery(".tablecheckboxcreatemanually").hide();
4142 if ($action ==
'preview') {
4146 if ($action ==
'editfile' || $action ==
'file_manager' || $action ==
'convertimgwebp' || $action ==
'confirmconvertimgwebp') {
4147 print
'<!-- Edit Media -->'.
"\n";
4148 print
'<div class="fiche"><br>';
4153 $formalreadyopen = 2;
4155 $url = DOL_URL_ROOT.
'/website/index.php';
4157 include DOL_DOCUMENT_ROOT.
'/core/tpl/filemanager.tpl.php';
4162 if ($action ==
'editmenu') {
4163 print
'<!-- Edit Menu -->'.
"\n";
4164 print
'<div class="center">'.$langs->trans(
"FeatureNotYetAvailable").
'</center>';
4167 if ($action ==
'editsource') {
4170 $contentforedit =
'';
4174 $contentforedit .= $objectpage->content;
4176 $maxheightwin = 480;
4177 if (isset($_SESSION[
"dol_screenheight"])) {
4178 if ($_SESSION[
"dol_screenheight"] > 680) {
4179 $maxheightwin = $_SESSION[
"dol_screenheight"] - 400;
4181 if ($_SESSION[
"dol_screenheight"] > 800) {
4182 $maxheightwin = $_SESSION[
"dol_screenheight"] - 490;
4186 $poscursor = array(
'x'=>
GETPOST(
'PAGE_CONTENT_x'),
'y'=>
GETPOST(
'PAGE_CONTENT_y'));
4187 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
4188 $doleditor =
new DolEditor(
'PAGE_CONTENT', $contentforedit,
'', $maxheightwin,
'Full',
'',
true,
true,
'ace', ROWS_5,
'40%', 0, $poscursor);
4189 $doleditor->Create(0,
'',
false,
'HTML Source',
'php');
4214 if ($action ==
'replacesite' || $action ==
'replacesiteconfirm' || $massaction ==
'replace') {
4215 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4216 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4217 print
'<input type="hidden" name="action" value="replacesiteconfirm">';
4218 print
'<input type="hidden" name="website" value="'.$website->ref.
'">';
4221 print
'<!-- Search page and replace string -->'.
"\n";
4222 print
'<div class="fiche"><br>';
4224 print
load_fiche_titre($langs->trans(
"ReplaceWebsiteContent"),
'',
'search');
4226 print
'<div class="fichecenter"><div class="fichehalfleft">';
4228 print
'<div class="tagtable">';
4230 print
'<div class="tagtr">';
4231 print
'<div class="tagtd paddingrightonly opacitymedium">';
4232 print $langs->trans(
"SearchReplaceInto");
4234 print
'<div class="tagtd">';
4235 print
'<input type="checkbox" class="marginleftonly" id="checkboxoptioncontent" name="optioncontent" value="content"'.((!
GETPOSTISSET(
'buttonreplacesitesearch') ||
GETPOST(
'optioncontent',
'aZ09')) ?
' checked' :
'').
'> <label for="checkboxoptioncontent" class="tdoverflowmax150onsmartphone inline-block valignmiddle">'.$langs->trans(
"Content").
'</label><br>';
4236 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(
"Title").
' | '.$langs->trans(
"Description").
' | '.$langs->trans(
"Keywords").
'</label><br>';
4237 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>';
4241 print
'<div class="tagtr">';
4242 print
'<div class="tagtd paddingrightonly opacitymedium" style="padding-right: 10px !important">';
4243 print $langs->trans(
"SearchString");
4245 print
'<div class="tagtd">';
4246 print
'<input type="text" name="searchstring" value="'.dol_escape_htmltag($searchkey, 0, 0,
'', 1).
'" autofocus>';
4252 print
'</div><div class="fichehalfleft">';
4254 print
'<div class="tagtable">';
4256 print
'<div class="tagtr">';
4257 print
'<div class="tagtd paddingrightonly opacitymedium tdoverflowmax100onsmartphone" style="padding-right: 10px !important">';
4258 print $langs->trans(
"WEBSITE_TYPE_CONTAINER");
4260 print
'<div class="tagtd">';
4261 print
img_picto(
'',
'object_technic',
'class="paddingrightonly"').
' ';
4262 $formwebsite->selectTypeOfContainer(
'optioncontainertype', (
GETPOST(
'optioncontainertype',
'alpha') ?
GETPOST(
'optioncontainertype',
'alpha') :
''), 1,
'', 1,
'minwidth125 maxwidth400 widthcentpercentminusx');
4266 print
'<div class="tagtr">';
4267 print
'<div class="tagtd paddingrightonly opacitymedium tdoverflowmax100onsmartphone" style="padding-right: 10px !important">';
4268 print $langs->trans(
"Language");
4270 print
'<div class="tagtd">';
4271 print
img_picto(
'',
'language',
'class="paddingrightonly"').
' '.$formadmin->select_language(
GETPOSTISSET(
'optionlanguage') ?
GETPOST(
'optionlanguage') :
'',
'optionlanguage', 0,
null,
'1', 0, 0,
'minwidth125 maxwidth400 widthcentpercentminusx', 2, 0, 0,
null, 1);
4276 if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) {
4277 print
'<div class="tagtr">';
4278 print
'<div class="tagtd paddingrightonly marginrightonly opacitymedium tdoverflowmax100onsmartphone" style="padding-right: 10px !important">';
4279 print $langs->trans(
"Category");
4281 print
'<div class="tagtd">';
4282 print
img_picto(
'',
'category',
'class="paddingrightonly"').
' '.
$form->select_all_categories(Categorie::TYPE_WEBSITE_PAGE,
GETPOSTISSET(
'optioncategory') ?
GETPOST(
'optioncategory') :
'',
'optioncategory', 0, 0, 0, 0,
'minwidth125 maxwidth400 widthcentpercentminusx');
4283 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
4291 print
'<input type="submit" class="button margintoponly" name="buttonreplacesitesearch" value="'.dol_escape_htmltag($langs->trans(
"Search")).
'">';
4293 print
'</div></div>';
4295 if ($action ==
'replacesiteconfirm') {
4296 print
'<!-- List of search result -->'.
"\n";
4297 print
'<div class="rowsearchresult clearboth">';
4302 if ($listofpages[
'code'] ==
'OK') {
4303 $arrayofselected = is_array($toselect) ? $toselect : array();
4305 $nbtotalofrecords = count($listofpages[
'list']);
4307 $permissiontodelete = $user->rights->website->delete;
4310 $arrayofmassactions = array();
4311 if ($user->rights->website->writephp && $searchkey) {
4312 $arrayofmassactions[
'replace'] = $langs->trans(
"Replace");
4314 if ($user->rights->website->write) {
4315 $arrayofmassactions[
'setcategory'] = $langs->trans(
"ClassifyInCategory");
4317 if ($permissiontodelete) {
4318 $arrayofmassactions[
'predelete'] =
'<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans(
"Delete");
4320 if (
GETPOST(
'nomassaction',
'int') || in_array($massaction, array(
'presend',
'predelete'))) {
4321 $arrayofmassactions = array();
4324 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
4325 $massactionbutton .=
'<div class="massactionother massactionreplace hidden">';
4326 $massactionbutton .= $langs->trans(
"ReplaceString");
4327 $massactionbutton .=
' <input type="text" name="replacestring" value="'.dol_escape_htmltag(
GETPOST(
'replacestring',
'none')).
'">';
4328 $massactionbutton .=
'</div>';
4329 $massactionbutton .=
'<div class="massactionother massactionsetcategory hidden">';
4330 $massactionbutton .= $langs->trans(
"Category");
4331 $massactionbutton .=
' '.$form->select_all_categories(Categorie::TYPE_WEBSITE_PAGE,
GETPOSTISSET(
'setcategory') ?
GETPOST(
'setcategory') :
'',
'setcategory', 64, 0, 0, 0,
'minwidth300 alignstart');
4332 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
4334 $massactionbutton .=
'</div>';
4336 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
4338 $selectedfields .=
$form->showCheckAddButtons(
'checkforselect', 1);
4340 print_barre_liste($langs->trans(
"Results"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'generic', 0,
'',
'', $limit, 1, 1, 1);
4342 $topicmail =
"WebsitePageRef";
4343 $modelmail =
"websitepage_send";
4345 $trackid =
'wsp'.$object->id;
4346 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
4348 $param =
'action=replacesiteconfirm&website='.urlencode($website->ref);
4349 $param .=
'&searchstring='.urlencode($searchkey);
4350 if (
GETPOST(
'optioncontent')) {
4351 $param .=
'&optioncontent=content';
4354 $param .=
'&optionmeta=meta';
4356 if (
GETPOST(
'optionsitefiles')) {
4357 $param .=
'&optionsitefiles=optionsitefiles';
4359 if (
GETPOST(
'optioncontainertype')) {
4360 $param .=
'&optioncontainertype='.GETPOST(
'optioncontainertype',
'aZ09');
4362 if (
GETPOST(
'optionlanguage')) {
4363 $param .=
'&optionlanguage='.GETPOST(
'optionlanguage',
'aZ09');
4365 if (
GETPOST(
'optioncategory')) {
4366 $param .=
'&optioncategory='.GETPOST(
'optioncategory',
'aZ09');
4369 print
'<div class="div-table-responsive-no-min">';
4370 print
'<table class="noborder centpercent">';
4371 print
'<tr class="liste_titre">';
4372 print
getTitleFieldOfList(
"Type", 0, $_SERVER[
'PHP_SELF'],
'type_container',
'', $param,
'', $sortfield, $sortorder,
'').
"\n";
4373 print
getTitleFieldOfList(
"Page", 0, $_SERVER[
'PHP_SELF'],
'pageurl',
'', $param,
'', $sortfield, $sortorder,
'').
"\n";
4375 print
getTitleFieldOfList(
"Language", 0, $_SERVER[
'PHP_SELF'],
'lang',
'', $param,
'', $sortfield, $sortorder,
'center ').
"\n";
4377 print
getTitleFieldOfList(
"DateLastModification", 0, $_SERVER[
'PHP_SELF'],
'tms',
'', $param,
'', $sortfield, $sortorder,
'center ').
"\n";
4379 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
4382 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
4387 foreach ($listofpages[
'list'] as $answerrecord) {
4388 if (get_class($answerrecord) ==
'WebsitePage') {
4392 print
'<td class="nowraponall">'.$langs->trans(
"Container").
' - ';
4393 print $langs->trans($answerrecord->type_container);
4398 print $answerrecord->getNomUrl(1);
4399 print
' <span class="opacitymedium">('.($answerrecord->title ? $answerrecord->title : $langs->trans(
"NoTitle")).
')</span>';
4403 print
'<span class="opacitymedium">'.$answerrecord->description.
'</span>';
4408 if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) {
4410 $existing = $c->containing($answerrecord->id, Categorie::TYPE_WEBSITE_PAGE,
'object');
4411 if (is_array($existing)) {
4412 foreach ($existing as $tmpcategory) {
4414 print
img_object($langs->trans(
"Category").
' : '.$tmpcategory->label,
'category',
'style="padding-left: 2px; padding-right: 2px; color: #'.($tmpcategory->color !=
'' ? $tmpcategory->color :
'888').
'"');
4422 $param =
'?action=replacesiteconfirm';
4423 $param .=
'&websiteid='.$website->id;
4424 $param .=
'&optioncontent='.GETPOST(
'optioncontent',
'aZ09');
4425 $param .=
'&optionmeta='.GETPOST(
'optionmeta',
'aZ09');
4426 $param .=
'&optionsitefiles='.GETPOST(
'optionsitefiles',
'aZ09');
4427 $param .=
'&optioncontainertype='.GETPOST(
'optioncontainertype',
'aZ09');
4428 $param .=
'&optionlanguage='.GETPOST(
'optionlanguage',
'aZ09');
4429 $param .=
'&optioncategory='.GETPOST(
'optioncategory',
'aZ09');
4430 $param .=
'&searchstring='.urlencode($searchkey);
4433 print
'<td class="center">';
4438 print
'<td class="center nowraponall">';
4440 $characterMap =
'áà éèëÃóúüñùç0123456789';
4441 $nbofwords = str_word_count($textwithouthtml, 0, $characterMap);
4443 print $nbofwords.
' '.$langs->trans(
"words");
4444 $totalnbwords += $nbofwords;
4449 print
'<td class="center nowraponall">';
4450 print
dol_print_date($answerrecord->date_modification,
'dayhour');
4454 print
'<td class="tdwebsitesearchresult right nowraponall">';
4456 $urltoedithtmlsource = $_SERVER[
"PHP_SELF"].
'?action=editmeta&token='.
newToken().
'&websiteid='.$website->id.
'&pageid='.$answerrecord->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].$param);
4457 if (empty($user->rights->website->write)) {
4458 $disabled =
' disabled';
4459 $urltoedithtmlsource =
'';
4461 print
'<a class="editfielda marginleftonly marginrightonly '.$disabled.
'" href="'.$urltoedithtmlsource.
'" title="'.$langs->trans(
"EditPageMeta").
'">'.
img_picto($langs->trans(
"EditPageMeta"),
'pencil-ruler').
'</a>';
4464 $urltoedithtmlsource = $_SERVER[
"PHP_SELF"].
'?action=editsource&token='.
newToken().
'&websiteid='.$website->id.
'&pageid='.$answerrecord->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].$param);
4465 if (empty($user->rights->website->write)) {
4466 $disabled =
' disabled';
4467 $urltoedithtmlsource =
'';
4469 print
'<a class="editfielda marginleftonly marginrightonly '.$disabled.
'" href="'.$urltoedithtmlsource.
'" title="'.$langs->trans(
"EditHTMLSource").
'">'.
img_picto($langs->trans(
"EditHTMLSource"),
'edit').
'</a>';
4471 print
'<span class="marginleftonly marginrightonly"></span>'.ajax_object_onoff($answerrecord,
'status',
'status',
'Enabled',
'Disabled', array(),
'valignmiddle');
4476 print
'<td class="nowrap center">';
4478 print
'<!-- Status of page -->'.
"\n";
4479 if ($massactionbutton || $massaction) {
4481 if (in_array($answerrecord->id, $arrayofselected)) {
4484 print
'<input id="'.$answerrecord->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$answerrecord->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
4494 $translateofrecordtype = array(
4495 'website_csscontent'=>
'WEBSITE_CSS_INLINE',
4496 'website_jscontent'=>
'WEBSITE_JS_INLINE',
4497 'website_robotcontent'=>
'WEBSITE_ROBOT',
4498 'website_htmlheadercontent'=>
'WEBSITE_HTML_HEADER',
4499 'website_htaccess'=>
'WEBSITE_HTACCESS',
4500 'website_readme'=>
'WEBSITE_README',
4501 'website_manifestjson'=>
'WEBSITE_MANIFEST_JSON'
4503 if (!empty($translateofrecordtype[$answerrecord[
'type']])) {
4504 print $langs->trans($translateofrecordtype[$answerrecord[
'type']]);
4506 print $answerrecord[
'type'];
4510 $param =
'?action=replacesiteconfirm';
4511 $param .=
'&websiteid='.$website->id;
4512 $param .=
'&optioncontent='.GETPOST(
'optioncontent',
'aZ09');
4513 $param .=
'&optionmeta='.GETPOST(
'optionmeta',
'aZ09');
4514 $param .=
'&optionsitefiles='.GETPOST(
'optionsitefiles',
'aZ09');
4515 $param .=
'&optioncontainertype='.GETPOST(
'optioncontainertype',
'aZ09');
4516 $param .=
'&optionlanguage='.GETPOST(
'optionlanguage',
'aZ09');
4517 $param .=
'&optioncategory='.GETPOST(
'optioncategory',
'aZ09');
4518 $param .=
'&searchstring='.urlencode($searchkey);
4522 $backtopageurl = $_SERVER[
"PHP_SELF"].$param;
4523 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=editcss&token='.
newToken().
'&website='.urlencode($website->ref).
'&backtopage='.urlencode($backtopageurl).
'">'.$langs->trans(
"EditCss").
'</a>';
4539 print
'<td class="center nowraponall">';
4548 print
'<td class="nowrap center">';
4555 if (count($listofpages[
'list']) >= 2) {
4557 print
'<tr class="lite_titre">';
4561 print $langs->trans(
"Total");
4577 print
'<td class="center nowraponall">';
4578 print $totalnbwords.
' '.$langs->trans(
"words");
4590 print
'<td class="nowrap center">';
4600 print
'<div class="warning">'.$listofpages[
'message'].
'</div>';
4609 if ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone') {
4610 if ($pageid > 0 && $atleastonepage) {
4616 $objectpage->fetch($pageid);
4618 $jscontent = @file_get_contents($filejs);
4620 $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";
4629 $out .=
"\n<html><head>\n";
4630 $out .=
"<!-- htmlheader/style of page from database -->\n";
4633 $out .=
"<!-- htmlheader/style of website from files -->\n";
4651 $out .=
"</head>\n";
4655 $out .=
'<div id="websitecontentundertopmenu" class="websitecontentundertopmenu boostrap-iso">'.
"\n";
4659 $out .=
'<!-- style of website from file -->'.
"\n";
4660 $out .=
'<style scoped>'.
"\n";
4662 $tmpout .=
'/* Include website CSS file */'.
"\n";
4666 $csscontent = ob_get_contents();
4669 $tmpout .=
'/* Include style from the HTML header of page */'.
"\n";
4671 $tmp = preg_split(
'(<style[^>]*>|</style>)', $objectpage->htmlheader);
4672 $tmpstyleinheader =
'';
4674 foreach ($tmp as $valtmp) {
4677 $tmpstyleinheader .= $valtmp.
"\n";
4680 $tmpout .= $tmpstyleinheader.
"\n";
4682 $tmpout = preg_replace(
'/}[\s\n]*body\s*{[^}]+}/ims',
'}', $tmpout);
4684 $out .=
'</style>'.
"\n";
4691 $out .=
'<div id="divbodywebsite" class="bodywebsite bodywebpage-'.$objectpage->ref.
'">'.
"\n";
4693 $newcontent = $objectpage->content;
4696 if (!empty($conf->global->WEBSITE_SUBCONTAINERSINLINE)) {
4700 $filephp = $filetpl;
4703 $res = include $filephp;
4705 print
"ERROR: Failed to include file '".$filephp.
"'. Try to edit and re-save page ith this ID.";
4708 print $e->getMessage();
4710 $newcontent = ob_get_contents();
4715 if (empty($conf->global->WEBSITE_EDITINLINE)) {
4717 $newcontent = preg_replace(
'/(div|section)(\s[^>]*)contenteditable="true"/',
'\1\2', $newcontent);
4726 $out .=
'</div> <!-- End div id=websitecontentundertopmenu -->';
4732 $out .=
"\n</body></html>\n";
4734 $out .=
"\n".
'<!-- End page content '.$filetpl.
' -->'.
"\n\n";
4759 if (empty($websitekey) || $websitekey ==
'-1') {
4760 print
'<br><br><div class="center previewnotyetavailable"><span class="">'.$langs->trans(
"NoWebSiteCreateOneFirst").
'</span></div><br><br><br>';
4761 print
'<div class="center"><div class="logo_setup"></div></div>';
4763 print
'<br><br><div class="center previewnotyetavailable"><span class="">'.$langs->trans(
"PreviewOfSiteNotYetAvailable", $object->ref).
'</span></div><br><br><br>';
4764 print
'<div class="center"><div class="logo_setup"></div></div>';