25 define(
'NOSCANPOSTFORINJECTION', 1);
26 define(
'NOSTYLECHECK', 1);
27 define(
'USEDOLIBARREDITOR', 1);
28 define(
'FORCE_CKEDITOR', 1);
32 require
'../main.inc.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/website.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/website2.lib.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formwebsite.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/website/class/website.class.php';
42 require_once DOL_DOCUMENT_ROOT.
'/website/class/websitepage.class.php';
43 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
45 $langs->loadLangs(array(
"admin",
"other",
"website",
"errors"));
49 $conf->dol_hide_leftmenu = 1;
52 $websiteid =
GETPOST(
'websiteid',
'int');
53 $websitekey =
GETPOST(
'website',
'alpha');
54 $page =
GETPOST(
'page',
'alpha');
55 $pageid =
GETPOST(
'pageid',
'int');
56 $pageref =
GETPOST(
'pageref',
'alphanohtml');
58 $action =
GETPOST(
'action',
'aZ09');
59 $massaction =
GETPOST(
'massaction',
'alpha');
60 $confirm =
GETPOST(
'confirm',
'alpha');
61 $cancel =
GETPOST(
'cancel',
'alpha');
62 $toselect =
GETPOST(
'toselect',
'array');
63 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'websitelist';
64 $backtopage =
GETPOST(
'backtopage',
'alpha');
65 $optioncss =
GETPOST(
'optioncss',
'aZ');
67 $type_container =
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'alpha');
69 $section_dir =
GETPOST(
'section_dir',
'alpha');
70 $file_manager =
GETPOST(
'file_manager',
'alpha');
71 $replacesite =
GETPOST(
'replacesite',
'alpha');
73 if (
GETPOST(
'deletesite',
'alpha')) { $action =
'deletesite'; }
74 if (
GETPOST(
'delete',
'alpha')) { $action =
'delete'; }
75 if (
GETPOST(
'preview',
'alpha')) $action =
'preview';
76 if (
GETPOST(
'createsite',
'alpha')) { $action =
'createsite'; }
77 if (
GETPOST(
'createcontainer',
'alpha')) { $action =
'createcontainer'; }
78 if (
GETPOST(
'editcss',
'alpha')) { $action =
'editcss'; }
79 if (
GETPOST(
'editmenu',
'alpha')) { $action =
'editmenu'; }
80 if (
GETPOST(
'setashome',
'alpha')) { $action =
'setashome'; }
81 if (
GETPOST(
'editmeta',
'alpha')) { $action =
'editmeta'; }
82 if (
GETPOST(
'editsource',
'alpha')) { $action =
'editsource'; }
83 if (
GETPOST(
'editcontent',
'alpha')) { $action =
'editcontent'; }
84 if (
GETPOST(
'exportsite',
'alpha')) { $action =
'exportsite'; }
85 if (
GETPOST(
'importsite',
'alpha')) { $action =
'importsite'; }
86 if (
GETPOST(
'createfromclone',
'alpha')) { $action =
'createfromclone'; }
87 if (
GETPOST(
'createpagefromclone',
'alpha')) { $action =
'createpagefromclone'; }
88 if (empty($action) && $file_manager) $action =
'file_manager';
89 if (empty($action) && $replacesite) $action =
'replacesite';
93 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
94 $sortfield =
GETPOST(
"sortfield",
'alpha');
95 $sortorder =
GETPOST(
"sortorder",
'alpha');
97 if (empty($page) || $page == -1) { $page = 0; }
98 $offset = $limit * $page;
99 $pageprev = $page - 1;
100 $pagenext = $page + 1;
104 if (empty($action)) $action =
'preview';
109 $object->fetchAll(
'ASC',
'position');
112 if (!($websiteid > 0) && empty($websitekey) && $action !=
'createsite')
114 foreach ($object->records as $key => $valwebsite)
116 $websitekey = $valwebsite->ref;
120 if ($websiteid > 0 || $websitekey)
122 $res = $object->fetch($websiteid, $websitekey);
123 $websitekey = $object->ref;
129 if ($pageid < 0) $pageid = 0;
130 if (($pageid > 0 || $pageref) && $action !=
'addcontainer')
132 $res = $objectpage->fetch($pageid, ($object->id > 0 ? $object->id : null), $pageref);
135 $res = $objectpage->fetch($pageid, ($object->id > 0 ? $object->id : null), null, $pageref);
139 if ($res >= 0 && $object->id > 0)
141 if ($objectpage->fk_website != $object->id)
143 if ($object->fk_default_home > 0)
145 $res = $objectpage->fetch($object->fk_default_home, $object->id,
'');
146 if ($res > 0) $pageid = $object->fk_default_home;
149 $res = $objectpage->fetch(0, $object->id,
'');
156 $pageid = $objectpage->id;
162 $pageid = $objectpage->id;
168 if (empty($pageid) && empty($pageref) && $object->id > 0 && $action !=
'createcontainer')
170 $pageid = $object->fk_default_home;
173 $array = $objectpage->fetchAll($object->id,
'ASC,ASC',
'type_container,pageurl');
174 if (!is_array($array) && $array < 0)
dol_print_error(
'', $objectpage->error, $objectpage->errors);
175 $atleastonepage = (is_array($array) && count($array) > 0);
177 $firstpageid = 0; $homepageid = 0;
178 foreach ($array as $key => $valpage)
180 if (empty($firstpageid)) $firstpageid = $valpage->id;
181 if ($object->fk_default_home && $key == $object->fk_default_home) $homepageid = $valpage->id;
183 $pageid = ($homepageid ? $homepageid : $firstpageid);
188 global $dolibarr_main_data_root;
189 $pathofwebsite = $dolibarr_main_data_root.
'/website/'.$websitekey;
190 $filehtmlheader = $pathofwebsite.
'/htmlheader.html';
191 $filecss = $pathofwebsite.
'/styles.css.php';
192 $filejs = $pathofwebsite.
'/javascript.js.php';
193 $filerobot = $pathofwebsite.
'/robots.txt';
194 $filehtaccess = $pathofwebsite.
'/.htaccess';
195 $filetpl = $pathofwebsite.
'/page'.$pageid.
'.tpl.php';
196 $fileindex = $pathofwebsite.
'/index.php';
197 $filewrapper = $pathofwebsite.
'/wrapper.php';
198 $filemanifestjson = $pathofwebsite.
'/manifest.json.php';
199 $filereadme = $pathofwebsite.
'/README.md';
200 $filemaster = $pathofwebsite.
'/master.inc.php';
203 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
204 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
208 $permtouploadfile = $user->rights->website->write;
209 $diroutput = $conf->medias->multidir_output[$conf->entity];
211 $relativepath = $section_dir;
212 $upload_dir = preg_replace(
'/\/$/',
'', $diroutput).
'/'.preg_replace(
'/^\//',
'', $relativepath);
214 $htmlheadercontentdefault =
'';
215 $htmlheadercontentdefault .=
'<link rel="stylesheet" id="google-fonts-css" href="//fonts.googleapis.com/css?family=Open+Sans:300,400,700" />'.
"\n";
216 $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";
217 $htmlheadercontentdefault .=
'<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>'.
"\n";
218 $htmlheadercontentdefault .=
'<script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>'.
"\n";
219 $htmlheadercontentdefault .=
'<script src="//cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js"></script>'.
"\n";
220 $htmlheadercontentdefault .=
'<script src="//cdnjs.cloudflare.com/ajax/libs/popper.js/1.13.0/umd/popper.min.js"></script>'.
"\n";
221 $htmlheadercontentdefault .=
'<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>'.
"\n";
222 $htmlheadercontentdefault .=
'<!--'.
"\n";
223 $htmlheadercontentdefault .=
'<script src="/document.php?modulepart=medias&file=css/myfile.css"></script>'.
"\n";
224 $htmlheadercontentdefault .=
'<script src="/document.php?modulepart=medias&file=js/myfile.js"></script>'.
"\n";
225 $htmlheadercontentdefault .=
'-->'.
"\n";
227 $manifestjsoncontentdefault =
'';
228 $manifestjsoncontentdefault .=
'{
230 "short_name": "MyWebsite",
233 "display": "standalone",
234 "background_color": "#fff",
235 "description": "A simple Web app.",
237 "src": "images/'.$website->ref.
'/homescreen48.png",
241 "src": "image/'.$website->ref.
'/homescreen72.png",
245 "src": "image/'.$website->ref.
'/homescreen96.png",
249 "src": "image/'.$website->ref.
'/homescreen144.png",
253 "src": "image/'.$website->ref.
'/homescreen168.png",
257 "src": "image/'.$website->ref.
'/homescreen192.png",
261 "related_applications": [{
263 "url": "https://play.google.com/store/apps/details?id=com.nltechno.dolidroidpro"
267 $listofpages = array();
270 if (
GETPOST(
'optionmeta')) $algo .=
'meta';
271 if (
GETPOST(
'optioncontent')) $algo .=
'content';
272 if (
GETPOST(
'optionsitefiles')) $algo .=
'sitefiles';
274 if (empty($sortfield)) {
275 if ($action ==
'file_manager') {
276 $sortfield =
'name'; $sortorder =
'ASC';
278 $sortfield =
'pageurl'; $sortorder =
'ASC';
282 $searchkey =
GETPOST(
'searchstring',
'restricthtml');
284 if ($action ==
'replacesiteconfirm') {
285 $containertype =
GETPOST(
'optioncontainertype',
'aZ09') !=
'-1' ?
GETPOST(
'optioncontainertype',
'aZ09') :
'';
286 $langcode =
GETPOST(
'optionlanguage',
'aZ09');
287 $otherfilters = array();
288 if (
GETPOST(
'optioncategory',
'int') > 0) {
289 $otherfilters[
'category'] =
GETPOST(
'optioncategory',
'int');
292 $listofpages =
getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters, -1);
295 $usercanedit = $user->rights->website->write;
296 $permissiontodelete = $user->rights->website->delete;
308 if (
GETPOST(
'refreshsite',
'alpha') ||
GETPOST(
'refreshsite.x',
'alpha') ||
GETPOST(
'refreshsite_x',
'alpha'))
310 if ($action ==
'addsite') $action =
'preview';
311 if ($action ==
'updatesource') $action =
'preview';
313 $pageid = $object->fk_default_home;
316 $array = $objectpage->fetchAll($object->id,
'ASC,ASC',
'type_container,pageurl');
317 if (!is_array($array) && $array < 0)
dol_print_error(
'', $objectpage->error, $objectpage->errors);
318 $atleastonepage = (is_array($array) && count($array) > 0);
320 $firstpageid = 0; $homepageid = 0;
321 foreach ($array as $key => $valpage)
323 if (empty($firstpageid)) $firstpageid = $valpage->id;
324 if ($object->fk_default_home && $key == $object->fk_default_home) $homepageid = $valpage->id;
326 $pageid = ($homepageid ? $homepageid : $firstpageid);
329 if (
GETPOST(
'refreshpage',
'alpha') && !in_array($action, array(
'updatecss'))) $action =
'preview';
331 if ($cancel && $action ==
'renamefile') {
341 header(
"Location: ".$backtopage);
346 $savbacktopage = $backtopage;
347 $backtopage =
$_SERVER[
"PHP_SELF"].
'?file_manager=1&website='.$websitekey.
'&pageid='.$pageid.(GETPOST(
'section_dir',
'alpha') ?
'§ion_dir='.urlencode(
GETPOST(
'section_dir',
'alpha')) :
'');
348 if ($sortfield) $backtopage .=
'&sortfield='.$sortfield;
349 if ($sortorder) $backtopage .=
'&sortorder='.$sortorder;
350 include DOL_DOCUMENT_ROOT.
'/core/actions_linkedfiles.inc.php';
351 $backtopage = $savbacktopage;
353 if ($action ==
'renamefile') {
354 $action =
'file_manager';
357 if ($action ==
'seteditinline')
360 setEventMessages($langs->trans(
"FeatureNotYetAvailable"), null,
'warnings');
362 header(
"Location: ".
$_SERVER[
"PHP_SELF"].
'?website='.
GETPOST(
'website',
'alphanohtml').
'&pageid='.
GETPOST(
'pageid',
'int'));
365 if ($action ==
'unseteditinline')
368 header(
"Location: ".
$_SERVER[
"PHP_SELF"].
'?website='.
GETPOST(
'website',
'alphanohtml').
'&pageid='.
GETPOST(
'pageid',
'int'));
371 if ($action ==
'setshowsubcontainers')
375 header(
"Location: ".
$_SERVER[
"PHP_SELF"].
'?website='.
GETPOST(
'website',
'alphanohtml').
'&pageid='.
GETPOST(
'pageid',
'int'));
378 if ($action ==
'unsetshowsubcontainers')
381 header(
"Location: ".
$_SERVER[
"PHP_SELF"].
'?website='.
GETPOST(
'website',
'alphanohtml').
'&pageid='.
GETPOST(
'pageid',
'int'));
385 if ($massaction ==
'replace' &&
GETPOST(
'confirmmassaction',
'alpha') && !$searchkey)
387 $action =
'replacesite';
392 if ($massaction ==
'setcategory' &&
GETPOST(
'confirmmassaction',
'alpha') && $usercanedit)
399 $categoryid =
GETPOST(
'setcategory',
'restricthtml');
400 if ($categoryid > 0) {
403 $category->fetch($categoryid);
405 foreach ($toselect as $tmpid) {
406 $tmpwebsitepage->id = $tmpid;
407 $result = $category->add_type($tmpwebsitepage,
'website_page');
408 if ($result < 0 && $result != -3) {
422 setEventMessages($langs->trans(
"RecordsModified", $nbupdate), null,
'mesgs');
428 $listofpages =
getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters, -1);
432 if ($massaction ==
'replace' &&
GETPOST(
'confirmmassaction',
'alpha'))
434 $replacestring =
GETPOST(
'replacestring',
'none');
436 if (empty($user->rights->website->writephp)) {
439 elseif (!$replacestring) {
445 foreach ($toselect as $keyselected) {
446 $objectpage = $listofpages[
'list'][$keyselected];
447 if ($objectpage->pageurl) {
448 dol_syslog(
"Replace string into page ".$objectpage->pageurl);
450 if (
GETPOST(
'optioncontent',
'aZ09')) {
451 $objectpage->content = str_replace($searchkey, $replacestring, $objectpage->content);
453 if (
GETPOST(
'optionmeta',
'aZ09')) {
454 $objectpage->title = str_replace($searchkey, $replacestring, $objectpage->title);
455 $objectpage->description = str_replace($searchkey, $replacestring, $objectpage->description);
456 $objectpage->keywords = str_replace($searchkey, $replacestring, $objectpage->keywords);
459 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
460 $filetpl = $pathofwebsite.
'/page'.$objectpage->id.
'.tpl.php';
466 setEventMessages(
'Failed to write file '.basename($filealias), null,
'errors');
475 $objectpage->update($user);
479 $action =
'createcontainer';
485 if ($nbreplacement > 0) {
486 setEventMessages($langs->trans(
"ReplacementDoneInXPages", $nbreplacement), null,
'mesgs');
489 $containertype =
GETPOST(
'optioncontainertype',
'aZ09') !=
'-1' ?
GETPOST(
'optioncontainertype',
'aZ09') :
'';
490 $langcode =
GETPOST(
'optionlanguage',
'aZ09');
491 $otherfilters = array();
492 if (
GETPOST(
'optioncategory',
'int') > 0) {
493 $otherfilters[
'category'] =
GETPOST(
'optioncategory',
'int');
497 $listofpages =
getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters);
527 if ($action ==
'addsite')
531 if (
GETPOST(
'virtualhost',
'alpha') && !preg_match(
'/^http/',
GETPOST(
'virtualhost',
'alpha')))
534 setEventMessages($langs->trans(
'ErrorURLMustStartWithHttp', $langs->transnoentitiesnoconv(
"VirtualHost")), null,
'errors');
537 if (!$error && !
GETPOST(
'WEBSITE_REF',
'alpha'))
540 $langs->load(
"errors");
541 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->transnoentities(
"Ref")), null,
'errors');
543 if (!$error && !preg_match(
'/^[a-z0-9_\-\.]+$/i',
GETPOST(
'WEBSITE_REF',
'alpha')))
546 $langs->load(
"errors");
547 setEventMessages($langs->transnoentities(
"ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities(
"Ref")), null,
'errors');
552 $arrayotherlang = explode(
',',
GETPOST(
'WEBSITE_OTHERLANG',
'alphanohtml'));
553 foreach ($arrayotherlang as $key => $val) {
554 $arrayotherlang[$key] = substr(trim($val), 0, 2);
558 $tmpobject->ref =
GETPOST(
'WEBSITE_REF',
'alpha');
559 $tmpobject->description =
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml');
560 $tmpobject->lang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
561 $tmpobject->otherlang = join(
',', $arrayotherlang);
562 $tmpobject->virtualhost =
GETPOST(
'virtualhost',
'alpha');
564 $result = $tmpobject->create($user);
578 header(
"Location: ".
$_SERVER[
"PHP_SELF"].
'?website='.$tmpobject->ref);
583 $action =
'createsite';
594 if ($action ==
'addcontainer')
600 $objectpage->fk_website = $object->id;
604 $urltograb =
GETPOST(
'externalurl',
'alpha');
605 $grabimages =
GETPOST(
'grabimages',
'alpha');
606 $grabimagesinto =
GETPOST(
'grabimagesinto',
'alpha');
608 include_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
610 if (empty($urltograb))
613 $langs->load(
"errors");
614 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"URL")), null,
'errors');
615 $action =
'createcontainer';
617 elseif (!preg_match(
'/^http/', $urltograb))
620 $langs->load(
"errors");
621 setEventMessages(
'Error URL must start with http:// or https://', null,
'errors');
622 $action =
'createcontainer';
629 $urltograbwithoutdomainandparam = preg_replace(
'/^https?:\/\/[^\/]+\/?/i',
'', $urltograb);
631 $urltograbwithoutdomainandparam = preg_replace(
'/\?.*$/',
'', $urltograbwithoutdomainandparam);
632 if (empty($urltograbwithoutdomainandparam) && !preg_match(
'/\/$/', $urltograb))
636 $pageurl =
dol_sanitizeFileName(preg_replace(
'/[\/\.]/',
'-', preg_replace(
'/\/+$/',
'', $urltograbwithoutdomainandparam)));
638 $urltograbdirwithoutslash = dirname($urltograb.
'.');
648 $result = $tmpwebsitepage->fetch(0, $object->id, $pageurl);
651 setEventMessages($langs->trans(
"AliasPageAlreadyExists", $pageurl), null,
'errors');
653 $action =
'createcontainer';
660 if ($tmp[
'curl_error_no'])
663 setEventMessages(
'Error getting '.$urltograb.
': '.$tmp[
'curl_error_msg'], null,
'errors');
664 $action =
'createcontainer';
666 elseif ($tmp[
'http_code'] !=
'200')
669 setEventMessages(
'Error getting '.$urltograb.
': '.$tmp[
'http_code'], null,
'errors');
670 $action =
'createcontainer';
678 preg_match(
'/<head>(.*)<\/head>/ims', $tmp[
'content'], $regs);
681 $objectpage->type_container =
'page';
682 $objectpage->pageurl = $pageurl;
683 if (empty($objectpage->pageurl))
686 $objectpage->pageurl = $tmpdomain.
'-home';
689 $objectpage->aliasalt =
'';
691 if (preg_match(
'/^(\d+)\-/', basename($urltograb), $regs)) $objectpage->aliasalt = $regs[1];
694 if (preg_match(
'/<title>(.*)<\/title>/ims', $head, $regtmp))
696 $objectpage->title = $regtmp[1];
698 if (preg_match(
'/<meta name="title"[^"]+content="([^"]+)"/ims', $head, $regtmp))
700 if (empty($objectpage->title)) $objectpage->title = $regtmp[1];
702 if (preg_match(
'/<meta name="description"[^"]+content="([^"]+)"/ims', $head, $regtmp))
704 $objectpage->description = $regtmp[1];
706 if (preg_match(
'/<meta name="keywords"[^"]+content="([^"]+)"/ims', $head, $regtmp))
708 $objectpage->keywords = $regtmp[1];
710 if (preg_match(
'/<html\s+lang="([^"]+)"/ims', $tmp[
'content'], $regtmp))
712 $tmplang = explode(
'-', $regtmp[1]);
713 $objectpage->lang = $tmplang[0].($tmplang[1] ?
'_'.strtoupper($tmplang[1]) :
'');
716 $tmp[
'content'] = preg_replace(
'/\s*<meta name="generator"[^"]+content="([^"]+)"\s*\/?>/ims',
'', $tmp[
'content']);
718 $objectpage->content = $tmp[
'content'];
719 $objectpage->content = preg_replace(
'/^.*<body(\s[^>]*)*>/ims',
'', $objectpage->content);
720 $objectpage->content = preg_replace(
'/<\/body(\s[^>]*)*>.*$/ims',
'', $objectpage->content);
722 $absoluteurlinaction = $urltograbdirwithoutslash;
729 $objectpage->htmlheader = $tmp[
'content'];
730 $objectpage->htmlheader = preg_replace(
'/^.*<head(\s[^>]*)*>/ims',
'', $objectpage->htmlheader);
731 $objectpage->htmlheader = preg_replace(
'/<\/head(\s[^>]*)*>.*$/ims',
'', $objectpage->htmlheader);
732 $objectpage->htmlheader = preg_replace(
'/<base(\s[^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
733 $objectpage->htmlheader = preg_replace(
'/<meta http-equiv="content-type"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
734 $objectpage->htmlheader = preg_replace(
'/<meta name="robots"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
735 $objectpage->htmlheader = preg_replace(
'/<meta name="title"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
736 $objectpage->htmlheader = preg_replace(
'/<meta name="description"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
737 $objectpage->htmlheader = preg_replace(
'/<meta name="keywords"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
738 $objectpage->htmlheader = preg_replace(
'/<meta name="generator"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
741 $objectpage->htmlheader = preg_replace(
'/<title>[^<]*<\/title>\n*/ims',
'', $objectpage->htmlheader);
742 $objectpage->htmlheader = preg_replace(
'/<link[^>]*rel="shortcut[^>]*>\n/ims',
'', $objectpage->htmlheader);
743 $objectpage->htmlheader = preg_replace(
'/<link[^>]*rel="alternate[^>]*>\n/ims',
'', $objectpage->htmlheader);
744 $objectpage->htmlheader = preg_replace(
'/<link[^>]*rel="canonical[^>]*>\n/ims',
'', $objectpage->htmlheader);
747 $tmp = $objectpage->htmlheader;
750 preg_match_all(
'/<script([^\.>]+)src=["\']([^"\'>]+)["\']([^>]*)><\/script>/i', $objectpage->htmlheader, $regs);
751 $errorforsubresource = 0;
752 foreach ($regs[0] as $key => $val)
754 dol_syslog(
"We will grab the script resource found into script tag ".$regs[2][$key]);
756 $linkwithoutdomain = $regs[2][$key];
757 if (preg_match(
'/^\//', $regs[2][$key]))
759 $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key];
762 $urltograbbis = $urltograbdirwithoutslash.
'/'.$regs[2][$key];
766 if (preg_match(
'/^http/', $regs[2][$key]))
768 $urltograbbis = $regs[2][$key];
769 $linkwithoutdomain = preg_replace(
'/^https?:\/\/[^\/]+\//i',
'', $regs[2][$key]);
779 if ($domaintograb != $domaintograbbis)
continue;
810 $tmp = preg_replace(
'/'.preg_quote($regs[0][$key],
'/').
'/i',
'', $tmp);
812 $objectpage->htmlheader = trim($tmp).
"\n";
816 $pagecsscontent =
"\n".
'<style>'.
"\n";
818 preg_match_all(
'/<link([^\.>]+)href=["\']([^"\'>]+\.css[^"\'>]*)["\']([^>]*)>/i', $objectpage->htmlheader, $regs);
819 $errorforsubresource = 0;
820 foreach ($regs[0] as $key => $val)
822 dol_syslog(
"We will grab the css resources found into link tag ".$regs[2][$key]);
824 $linkwithoutdomain = $regs[2][$key];
825 if (preg_match(
'/^\//', $regs[2][$key]))
827 $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key];
830 $urltograbbis = $urltograbdirwithoutslash.
'/'.$regs[2][$key];
834 if (preg_match(
'/^http/', $regs[2][$key]))
836 $urltograbbis = $regs[2][$key];
837 $linkwithoutdomain = preg_replace(
'/^https?:\/\/[^\/]+\//i',
'', $regs[2][$key]);
847 if ($domaintograb != $domaintograbbis)
continue;
850 if ($tmpgeturl[
'curl_error_no'])
852 $errorforsubresource++;
853 setEventMessages(
'Error getting link tag url '.$urltograbbis.
': '.$tmpgeturl[
'curl_error_msg'], null,
'errors');
854 dol_syslog(
'Error getting '.$urltograbbis.
': '.$tmpgeturl[
'curl_error_msg']);
855 $action =
'createcontainer';
857 elseif ($tmpgeturl[
'http_code'] !=
'200')
859 $errorforsubresource++;
860 setEventMessages(
'Error getting link tag url '.$urltograbbis.
': '.$tmpgeturl[
'http_code'], null,
'errors');
861 dol_syslog(
'Error getting '.$urltograbbis.
': '.$tmpgeturl[
'curl_error_msg']);
862 $action =
'createcontainer';
873 $tmpgeturl[
'content'] = preg_replace(
'/\/\*\s+CSS content[a-z\s]*\s+\*\//',
'', $tmpgeturl[
'content']);
884 $pagecsscontent .=
'/* Content of file '.$urltograbbis.
' */'.
"\n";
886 getAllImages($object, $objectpage, $urltograbbis, $tmpgeturl[
'content'], $action, 1, $grabimages, $grabimagesinto);
888 include_once DOL_DOCUMENT_ROOT.
'/core/class/lessc.class.php';
889 $lesscobj =
new Lessc();
891 $contentforlessc =
".bodywebsite {\n".$tmpgeturl[
'content'].
"\n}\n";
893 $contentforlessc = $lesscobj->compile($contentforlessc);
896 $pagecsscontent .= $contentforlessc.
"\n";
898 }
catch (exception $e) {
900 dol_syslog(
"Failed to compile the CSS from URL ".$urltograbbis.
" with lessc: ".$e->getMessage(), LOG_WARNING);
901 $pagecsscontent .= $tmpgeturl[
'content'].
"\n";
904 $objectpage->htmlheader = preg_replace(
'/'.preg_quote($regs[0][$key],
'/').
'\n*/ims',
'', $objectpage->htmlheader);
908 $pagecsscontent .=
'</style>';
912 $objectpage->htmlheader .= trim($pagecsscontent).
"\n";
916 $tmp = $objectpage->content;
918 getAllImages($object, $objectpage, $urltograb, $tmp, $action, 1, $grabimages, $grabimagesinto);
921 $tmp = preg_replace(
'/a href="\/([^\/"]+)\/([^\/"]+)"/',
'a href="/\1-\2.php"', $tmp);
922 $tmp = preg_replace(
'/a href="\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)"/',
'a href="/\1-\2-\3.php"', $tmp);
923 $tmp = preg_replace(
'/a href="\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)"/',
'a href="/\1-\2-\3-\4.php"', $tmp);
926 $objectpage->content = $tmp;
928 $objectpage->grabbed_from = $urltograb;
932 $objectpage->title = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_TITLE',
'alphanohtml'));
933 $objectpage->type_container =
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'aZ09');
934 $objectpage->pageurl =
GETPOST(
'WEBSITE_PAGENAME',
'alpha');
935 $objectpage->aliasalt = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_ALIASALT',
'alphanohtml'));
936 $objectpage->description = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml'));
937 $objectpage->lang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
938 $objectpage->otherlang =
GETPOST(
'WEBSITE_OTHERLANG',
'aZ09comma');
939 $objectpage->image =
GETPOST(
'WEBSITE_IMAGE',
'alpha');
940 $objectpage->keywords = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_KEYWORDS',
'alphanohtml'));
941 $objectpage->allowed_in_frames =
GETPOST(
'WEBSITE_ALLOWED_IN_FRAMES',
'aZ09');
942 $objectpage->htmlheader =
GETPOST(
'htmlheader',
'none');
943 $objectpage->author_alias =
GETPOST(
'WEBSITE_AUTHORALIAS',
'alphanohtml');
944 $objectpage->object_type =
GETPOST(
'WEBSITE_OBJECTCLASS');
945 $objectpage->fk_object =
GETPOST(
'WEBSITE_OBJECTID');
946 $substitutionarray = array();
947 $substitutionarray[
'__WEBSITE_CREATE_BY__'] = $user->getFullName($langs);
950 $pageidfortranslation = (
GETPOST(
'pageidfortranslation',
'int') > 0 ?
GETPOST(
'pageidfortranslation',
'int') : 0);
951 if ($pageidfortranslation > 0) {
954 $objectpagetmp->fetch($pageidfortranslation);
955 if ($objectpagetmp->fk_page > 0) {
956 $pageidfortranslation = $objectpagetmp->fk_page;
959 $objectpage->fk_page = $pageidfortranslation;
961 $sample =
GETPOST(
'sample',
'alpha');
962 if (empty($sample)) $sample =
'empty';
964 $pathtosample = DOL_DOCUMENT_ROOT.
'/website/samples/page-sample-'.
dol_sanitizeFileName($sample).
'.html';
967 $objectpage->content =
make_substitutions(@file_get_contents($pathtosample), $substitutionarray);
972 if (empty($objectpage->pageurl))
974 $langs->load(
"errors");
975 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WEBSITE_PAGENAME")), null,
'errors');
977 $action =
'createcontainer';
979 elseif (!preg_match(
'/^[a-z0-9\-\_]+$/i', $objectpage->pageurl))
981 $langs->load(
"errors");
982 setEventMessages($langs->transnoentities(
"ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities(
'WEBSITE_PAGENAME')), null,
'errors');
984 $action =
'createcontainer';
986 if (empty($objectpage->title))
988 $langs->load(
"errors");
989 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WEBSITE_TITLE")), null,
'errors');
991 $action =
'createcontainer';
993 if ($objectpage->fk_page > 0 && empty($objectpage->lang))
995 $langs->load(
"errors");
996 setEventMessages($langs->trans(
"ErrorLanguageRequiredIfPageIsTranslationOfAnother"), null,
'errors');
998 $action =
'createcontainer';
1000 if ($objectpage->fk_page > 0 && !empty($objectpage->lang))
1002 if ($objectpage->lang == $website->lang) {
1003 $langs->load(
"errors");
1004 setEventMessages($langs->trans(
"ErrorLanguageMustNotBeSourceLanguageIfPageIsTranslationOfAnother"), null,
'errors');
1006 $action =
'createcontainer';
1013 $pageid = $objectpage->create($user);
1017 $action =
'createcontainer';
1023 $categoriesarray =
GETPOST(
'categories',
'array');
1024 $result = $objectpage->setCategories($categoriesarray);
1034 if (empty($object->fk_default_home)) {
1035 $object->fk_default_home = $pageid;
1036 $res = $object->update($user);
1042 $filetpl = $pathofwebsite.
'/page'.$pageid.
'.tpl.php';
1045 $result =
dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper);
1047 if ($result <= 0)
setEventMessages(
'Failed to write file '.$fileindex, null,
'errors');
1054 if (!empty($objectpage->content))
1056 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
1057 $filetpl = $pathofwebsite.
'/page'.$objectpage->id.
'.tpl.php';
1063 setEventMessages(
'Failed to write file '.basename($filealias), null,
'errors');
1074 $action =
'createcontainer';
1082 setEventMessages($langs->trans(
"PageAdded", $objectpage->pageurl), null,
'mesgs');
1091 $pageid = $objectpage->id;
1096 $pathtomedias = DOL_DATA_ROOT.
'/medias';
1097 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
1100 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
1101 dol_mkdir(dirname($pathtomediasinwebsite));
1102 $result = symlink($pathtomedias, $pathtomediasinwebsite);
1118 $htmlheadercontent =
"<html>\n";
1119 $htmlheadercontent .= $htmlheadercontentdefault;
1120 $htmlheadercontent .=
"</html>";
1126 $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;}";
1132 $jscontent =
"/* JS content (all pages) */\n";
1138 $robotcontent =
"# Robot file. Generated with Dolibarr\nUser-agent: *\nAllow: /public/\nDisallow: /administrator/";
1144 $htaccesscontent =
"# Order allow,deny\n# Deny from all";
1150 $manifestjsoncontent =
"";
1156 $readmecontent =
"Website generated by Dolibarr ERP CRM";
1160 $action =
'preview';
1165 if ($action ==
'confirm_deletesite' && $confirm ==
'yes')
1171 $res = $object->fetch(
GETPOST(
'id',
'int'));
1176 $res = $object->delete($user);
1185 if (
GETPOST(
'delete_also_js',
'alpha') ==
'on')
1187 $pathofwebsitejs = DOL_DATA_ROOT.
'/medias/js/'.$object->ref;
1191 if (
GETPOST(
'delete_also_medias',
'alpha') ==
'on')
1193 $pathofwebsitemedias = DOL_DATA_ROOT.
'/medias/image/'.$object->ref;
1202 setEventMessages($langs->trans(
"SiteDeleted", $object->ref), null,
'mesgs');
1204 header(
"Location: ".
$_SERVER[
"PHP_SELF"].
'?id='.$object->id);
1214 if (
GETPOSTISSET(
'pageid') && $action ==
'delete' && $permissiontodelete) {
1219 $res = $object->fetch(0, $websitekey);
1222 $res = $objectpage->fetch($pageid, $object->id);
1226 $res = $objectpage->delete($user);
1237 setEventMessages($langs->trans(
"PageDeleted", $objectpage->pageurl, $websitekey), null,
'mesgs');
1239 header(
"Location: ".
$_SERVER[
"PHP_SELF"].
'?website='.$websitekey);
1249 $objectclass =
'WebsitePage';
1253 if (!$error && ($massaction ==
'delete' || ($action ==
'delete' && $confirm ==
'yes')) && $permissiontodelete)
1257 $objecttmp =
new $objectclass($db);
1259 foreach ($toselect as $toselectid)
1261 $result = $objecttmp->fetch($toselectid);
1264 $result = $objecttmp->delete($user);
1281 if ($nbok > 1)
setEventMessages($langs->trans(
"RecordsDeleted", $nbok), null,
'mesgs');
1282 else setEventMessages($langs->trans(
"RecordDeleted", $nbok), null,
'mesgs');
1290 if ($action ==
'delete') {
1291 $action =
'replacesiteconfirm';
1293 $containertype =
GETPOST(
'optioncontainertype',
'aZ09') !=
'-1' ?
GETPOST(
'optioncontainertype',
'aZ09') :
'';
1294 $langcode =
GETPOST(
'optionlanguage',
'aZ09');
1295 $otherfilters = array();
1296 if (
GETPOST(
'optioncategory',
'int') > 0) {
1297 $otherfilters[
'category'] =
GETPOST(
'optioncategory',
'int');
1300 $listofpages =
getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters);
1305 if ($action ==
'updatecss')
1310 $action =
'editcss';
1313 $res = $object->fetch(0, $websitekey);
1318 $tmpvirtualhost = preg_replace(
'/\/$/',
'',
GETPOST(
'virtualhost',
'alpha'));
1319 if ($tmpvirtualhost && !preg_match(
'/^http/', $tmpvirtualhost))
1322 setEventMessages($langs->trans(
'ErrorURLMustStartWithHttp', $langs->transnoentitiesnoconv(
"VirtualHost")), null,
'errors');
1323 $action =
'editcss';
1328 $arrayotherlang = explode(
',',
GETPOST(
'WEBSITE_OTHERLANG',
'alphanohtml'));
1329 foreach ($arrayotherlang as $key => $val) {
1330 $arrayotherlang[$key] = substr(trim($val), 0, 2);
1333 $object->virtualhost = $tmpvirtualhost;
1334 $object->lang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
1335 $object->otherlang = join(
',', $arrayotherlang);
1336 $object->use_manifest =
GETPOST(
'use_manifest',
'alpha');
1338 $result = $object->update($user);
1343 $action =
'editcss';
1365 $htmlheadercontent =
'';
1377 $htmlheadercontent .= preg_replace(array(
'/<html>\n*/ims',
'/<\/html>\n*/ims'), array(
'',
''),
GETPOST(
'WEBSITE_HTML_HEADER',
'none'));
1383 $htmlheadercontent = trim($htmlheadercontent).
"\n";
1396 $csscontent .=
"<?php // BEGIN PHP\n";
1397 $csscontent .=
'$websitekey=basename(__DIR__);'.
"\n";
1398 $csscontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded\n";
1399 $csscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
1400 $csscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
1401 $csscontent .=
"ob_start();\n";
1402 $csscontent .=
"if (! headers_sent()) { /* because file is included inline when in edit mode and we don't want warning */ \n";
1403 $csscontent .=
"header('Cache-Control: max-age=3600, public, must-revalidate');\n";
1404 $csscontent .=
"header('Content-type: text/css');\n";
1405 $csscontent .=
"}\n";
1406 $csscontent .=
"// END PHP ?>\n";
1408 $csscontent .= trim(
GETPOST(
'WEBSITE_CSS_INLINE',
'none')).
"\n";
1410 $csscontent .=
'<?php // BEGIN PHP'.
"\n";
1411 $csscontent .=
'$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "css");'.
"\n";
1412 $csscontent .=
"// END PHP ?>\n";
1414 dol_syslog(
"Save css content into ".$filecss);
1427 $jscontent .=
"<?php // BEGIN PHP\n";
1428 $jscontent .=
'$websitekey=basename(__DIR__);'.
"\n";
1429 $jscontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded\n";
1430 $jscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
1431 $jscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
1432 $jscontent .=
"ob_start();\n";
1433 $jscontent .=
"header('Cache-Control: max-age=3600, public, must-revalidate');\n";
1434 $jscontent .=
"header('Content-type: application/javascript');\n";
1435 $jscontent .=
"// END PHP ?>\n";
1437 $jscontent .= trim(
GETPOST(
'WEBSITE_JS_INLINE',
'none')).
"\n";
1439 $jscontent .=
'<?php // BEGIN PHP'.
"\n";
1440 $jscontent .=
'$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "js");'.
"\n";
1441 $jscontent .=
"// END PHP ?>\n";
1464 $robotcontent .= trim(
GETPOST(
'WEBSITE_ROBOT',
'restricthtml')).
"\n";
1479 $htaccesscontent =
'';
1480 $htaccesscontent .= trim(
GETPOST(
'WEBSITE_HTACCESS',
'restricthtml')).
"\n";
1491 $manifestjsoncontent =
'';
1493 $manifestjsoncontent .=
"<?php // BEGIN PHP\n";
1494 $manifestjsoncontent .=
'$websitekey=basename(__DIR__);'.
"\n";
1495 $manifestjsoncontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded\n";
1496 $manifestjsoncontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
1497 $manifestjsoncontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
1498 $manifestjsoncontent .=
"ob_start();\n";
1499 $manifestjsoncontent .=
"header('Cache-Control: max-age=3600, public, must-revalidate');\n";
1500 $manifestjsoncontent .=
"header('Content-type: application/manifest+json');\n";
1501 $manifestjsoncontent .=
"// END PHP ?>\n";
1503 $manifestjsoncontent .= trim(
GETPOST(
'WEBSITE_MANIFEST_JSON',
'none')).
"\n";
1505 $manifestjsoncontent .=
'<?php // BEGIN PHP'.
"\n";
1506 $manifestjsoncontent .=
'$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "manifest");'.
"\n";
1507 $manifestjsoncontent .=
"// END PHP ?>\n";
1513 setEventMessages(
'Failed to write file '.$filemanifestjson, null,
'errors');
1518 $readmecontent =
'';
1530 $readmecontent .= trim(
GETPOST(
'WEBSITE_README',
'restricthtml')).
"\n";
1556 $action =
'preview';
1559 header(
"Location: ".$backtopage);
1564 $action =
'editcss';
1571 if ($action ==
'setashome')
1574 $object->fetch(0, $websitekey);
1577 $object->fk_default_home = $pageid;
1578 $res = $object->update($user);
1589 $filetpl = $pathofwebsite.
'/page'.$pageid.
'.tpl.php';
1592 $result =
dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper);
1597 $action =
'preview';
1605 if ($action ==
'updatemeta')
1609 $result = $object->fetch(0, $websitekey);
1612 $objectpage->fk_website = $object->id;
1615 if (!preg_match(
'/^[a-z0-9\-\_]+$/i',
GETPOST(
'WEBSITE_PAGENAME',
'alpha')))
1618 $langs->load(
"errors");
1619 setEventMessages($langs->transnoentities(
"ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities(
'WEBSITE_PAGENAME')), null,
'errors');
1620 $action =
'editmeta';
1623 $res = $objectpage->fetch($pageid, $object->id);
1627 setEventMessages(
'Page not found '.$objectpage->error, $objectpage->errors,
'errors');
1631 if (!$error &&
GETPOST(
'WEBSITE_PAGENAME',
'alpha'))
1634 $result = $websitepagetemp->fetch(-1 * $objectpage->id, $object->id,
GETPOST(
'WEBSITE_PAGENAME',
'alpha'));
1638 $langs->load(
"errors");
1639 setEventMessages($websitepagetemp->error, $websitepagetemp->errors,
'errors');
1640 $action =
'editmeta';
1645 $langs->load(
"errors");
1646 setEventMessages($langs->trans(
"ErrorAPageWithThisNameOrAliasAlreadyExists", $websitepagetemp->pageurl), null,
'errors');
1647 $action =
'editmeta';
1650 if (!$error &&
GETPOST(
'WEBSITE_ALIASALT',
'alpha'))
1652 $arrayofaliastotest = explode(
',',
GETPOST(
'WEBSITE_ALIASALT',
'alpha'));
1654 foreach ($arrayofaliastotest as $aliastotest)
1657 if (preg_match(
'/^page\d+/i', $aliastotest)) {
1659 $langs->load(
"errors");
1661 $action =
'editmeta';
1664 $result = $websitepagetemp->fetch(-1 * $objectpage->id, $object->id, $aliastotest);
1668 $langs->load(
"errors");
1669 setEventMessages($websitepagetemp->error, $websitepagetemp->errors,
'errors');
1670 $action =
'editmeta';
1676 $langs->load(
"errors");
1677 setEventMessages($langs->trans(
"ErrorAPageWithThisNameOrAliasAlreadyExists", $websitepagetemp->pageurl), null,
'errors');
1678 $action =
'editmeta';
1687 $objectpage->old_object = clone $objectpage;
1689 $objectpage->title = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_TITLE',
'alphanohtml'));
1690 $objectpage->type_container =
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'aZ09');
1691 $objectpage->pageurl =
GETPOST(
'WEBSITE_PAGENAME',
'alpha');
1692 $objectpage->aliasalt = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_ALIASALT',
'alphanohtml'));
1693 $objectpage->lang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
1694 $objectpage->otherlang =
GETPOST(
'WEBSITE_OTHERLANG',
'aZ09comma');
1695 $objectpage->description = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml'));
1696 $objectpage->image =
GETPOST(
'WEBSITE_IMAGE',
'alpha');
1697 $objectpage->keywords = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_KEYWORDS',
'alphanohtml'));
1698 $objectpage->allowed_in_frames =
GETPOST(
'WEBSITE_ALLOWED_IN_FRAMES',
'aZ09');
1699 $objectpage->htmlheader = trim(
GETPOST(
'htmlheader',
'none'));
1700 $objectpage->fk_page = (
GETPOST(
'pageidfortranslation',
'int') > 0 ?
GETPOST(
'pageidfortranslation',
'int') : 0);
1701 $objectpage->author_alias = trim(
GETPOST(
'WEBSITE_AUTHORALIAS',
'alphanohtml'));
1702 $objectpage->object_type =
GETPOST(
'WEBSITE_OBJECTCLASS',
'alpha');
1703 $objectpage->fk_object =
GETPOST(
'WEBSITE_OBJECTID',
'aZ09');
1705 $newdatecreation =
dol_mktime(
GETPOST(
'datecreationhour',
'int'),
GETPOST(
'datecreationmin',
'int'),
GETPOST(
'datecreationsec',
'int'),
GETPOST(
'datecreationmonth',
'int'),
GETPOST(
'datecreationday',
'int'),
GETPOST(
'datecreationyear',
'int'));
1706 if ($newdatecreation) $objectpage->date_creation = $newdatecreation;
1708 $res = $objectpage->update($user);
1711 $langs->load(
"errors");
1712 if ($db->lasterrno ==
'DB_ERROR_RECORD_ALREADY_EXISTS')
1715 $langs->load(
"errors");
1716 setEventMessages($langs->trans(
"ErrorAPageWithThisNameOrAliasAlreadyExists"), null,
'errors');
1717 $action =
'editmeta';
1721 $langs->load(
"errors");
1723 $action =
'editmeta';
1730 $categoriesarray =
GETPOST(
'categories',
'array');
1731 $result = $objectpage->setCategories($categoriesarray);
1749 $filemaster = $pathofwebsite.
'/master.inc.php';
1750 $fileoldalias = $pathofwebsite.
'/'.$objectpage->old_object->pageurl.
'.php';
1751 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
1757 if (!$result)
setEventMessages(
'Failed to write file '.$filemaster, null,
'errors');
1760 if (!empty($fileoldalias))
1762 dol_syslog(
"We delete old alias page name=".$fileoldalias.
" to build a new alias page=".$filealias);
1766 if (empty($objectpage->lang) || !in_array($objectpage->lang, explode(
',', $object->otherlang))) {
1767 $dirname = dirname($fileoldalias);
1768 $filename = basename($fileoldalias);
1769 $sublangs = explode(
',', $object->otherlang);
1770 foreach ($sublangs as $sublang) {
1771 $fileoldaliassub = $dirname.
'/'.$sublang.
'/'.$filename;
1777 if (!empty($objectpage->old_object->aliasalt))
1779 $tmpaltaliases = explode(
',', $objectpage->old_object->aliasalt);
1780 if (is_array($tmpaltaliases))
1782 foreach ($tmpaltaliases as $tmpaliasalt)
1784 dol_syslog(
"We delete old alt alias pages name=".trim($tmpaliasalt));
1788 if (empty($objectpage->lang) || !in_array($objectpage->lang, explode(
',', $object->otherlang))) {
1789 $dirname = dirname($pathofwebsite.
'/'.trim($tmpaliasalt).
'.php');
1790 $filename = basename($pathofwebsite.
'/'.trim($tmpaliasalt).
'.php');
1791 $sublangs = explode(
',', $object->otherlang);
1792 foreach ($sublangs as $sublang) {
1793 $fileoldaliassub = $dirname.
'/'.$sublang.
'/'.$filename;
1803 if (!$result)
setEventMessages(
'Failed to write file '.$filealias, null,
'errors');
1805 if (!empty($objectpage->aliasalt))
1807 $tmpaltaliases = explode(
',', $objectpage->aliasalt);
1808 if (is_array($tmpaltaliases))
1810 foreach ($tmpaltaliases as $tmpaliasalt)
1812 if (trim($tmpaliasalt))
1814 $filealias = $pathofwebsite.
'/'.trim($tmpaliasalt).
'.php';
1816 if (!$result)
setEventMessages(
'Failed to write file '.basename($filealias), null,
'errors');
1833 $action =
'preview';
1836 $action =
'editmeta';
1843 $action =
'preview';
1849 if (($action ==
'updatesource' || $action ==
'updatecontent' || $action ==
'confirm_createfromclone' || $action ==
'confirm_createpagefromclone')
1850 || ($action ==
'preview' && (
GETPOST(
'refreshsite') ||
GETPOST(
'refreshpage') ||
GETPOST(
'preview'))))
1852 $object->fetch(0, $websitekey);
1855 if ($action ==
'confirm_createfromclone')
1859 $objectnew =
new Website($db);
1860 $result = $objectnew->createFromClone($user,
GETPOST(
'id',
'int'),
GETPOST(
'siteref',
'aZ09'), (
GETPOST(
'newlang',
'aZ09') ?
GETPOST(
'newlang',
'aZ09') :
''));
1866 $action =
'preview';
1871 $object = $objectnew;
1873 $pageid = $object->fk_default_home;
1874 $websitekey =
GETPOST(
'siteref',
'aZ09');
1880 if ($action ==
'confirm_createpagefromclone')
1882 $istranslation = (
GETPOST(
'is_a_translation',
'aZ09') ==
'on' ? 1 : 0);
1886 if (
GETPOST(
'newlang',
'aZ09') == $objectpage->lang || !
GETPOST(
'newlang',
'aZ09')) {
1888 setEventMessages($langs->trans(
"LanguageMustNotBeSameThanClonedPage"), null,
'errors');
1889 $action =
'preview';
1891 if (
GETPOST(
'newwebsite',
'int') != $object->id) {
1893 setEventMessages($langs->trans(
"WebsiteMustBeSameThanClonedPageIfTranslation"), null,
'errors');
1894 $action =
'preview';
1902 $newwebsiteid =
GETPOST(
'newwebsite',
'int');
1903 $pathofwebsitenew = $pathofwebsite;
1905 $tmpwebsite =
new Website($db);
1906 if ($newwebsiteid > 0 && $newwebsiteid != $object->id)
1908 $tmpwebsite->fetch($newwebsiteid);
1909 $pathofwebsitenew = $dolibarr_main_data_root.
'/website/'.$tmpwebsite->ref;
1912 $tmpwebsite = $object;
1916 $resultpage = $objectpage->createFromClone($user, $pageid,
GETPOST(
'newpageurl',
'aZ09'), (
GETPOST(
'newlang',
'aZ09') ?
GETPOST(
'newlang',
'aZ09') :
''), $istranslation, $newwebsiteid,
GETPOST(
'newtitle',
'alphanohtml'));
1917 if ($resultpage < 0)
1921 $action =
'createpagefromclone';
1925 $filetpl = $pathofwebsitenew.
'/page'.$resultpage->id.
'.tpl.php';
1926 $fileindex = $pathofwebsitenew.
'/index.php';
1927 $filewrapper = $pathofwebsitenew.
'/wrapper.php';
1936 if (empty($newwebsiteid) || $newwebsiteid == $object->id)
1938 $pageid = $resultpage->id;
1951 $pathtomedias = DOL_DATA_ROOT.
'/medias';
1952 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
1955 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
1956 dol_mkdir(dirname($pathtomediasinwebsite));
1957 $result = symlink($pathtomedias, $pathtomediasinwebsite);
1966 $objectpage->fk_website = $object->id;
1970 $res = $objectpage->fetch($pageid);
1974 if ($object->fk_default_home > 0)
1976 $res = $objectpage->fetch($object->fk_default_home);
1980 $res = $objectpage->fetch(0, $object->id);
1985 if (!$error && $res > 0)
1987 if ($action ==
'updatesource' || $action ==
'updatecontent')
1993 $objectpage->content =
GETPOST(
'PAGE_CONTENT',
'none');
1998 $forbiddenphpcommands = array(
"exec",
"passthru",
"system",
"shell_exec",
"proc_open");
1999 if (empty($conf->global->WEBSITE_PHP_ALLOW_WRITE))
2001 $forbiddenphpcommands = array_merge($forbiddenphpcommands, array(
"fopen",
"file_put_contents",
"fputs",
"fputscsv",
"fwrite",
"fpassthru",
"unlink",
"mkdir",
"rmdir",
"symlink",
"touch",
"umask"));
2003 foreach ($forbiddenphpcommands as $forbiddenphpcommand)
2005 if (preg_match(
'/'.$forbiddenphpcommand.
'\s*\(/ms', $phpfullcodestring))
2008 setEventMessages($langs->trans(
"DynamicPHPCodeContainsAForbiddenInstruction", $forbiddenphpcommand), null,
'errors');
2009 if ($action ==
'updatesource') $action =
'editsource';
2010 if ($action ==
'updatecontent') $action =
'editcontent';
2014 if (empty($user->rights->website->writephp))
2016 if ($phpfullcodestringold != $phpfullcodestring)
2019 setEventMessages($langs->trans(
"NotAllowedToAddDynamicContent"), null,
'errors');
2020 if ($action ==
'updatesource') $action =
'editsource';
2021 if ($action ==
'updatecontent') $action =
'editcontent';
2026 $objectpage->content = preg_replace(
'/<head>.*<\/head>/ims',
'', $objectpage->content);
2030 $res = $objectpage->update($user);
2035 if ($action ==
'updatesource') $action =
'editsource';
2036 if ($action ==
'updatecontent') $action =
'editcontent';
2043 $filemaster = $pathofwebsite.
'/master.inc.php';
2045 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
2052 if (!$result)
setEventMessages(
'Failed to write the master file file '.$filemaster, null,
'errors');
2074 if (!$result)
setEventMessages(
'Failed to write the alias file '.basename($filealias), null,
'errors');
2085 header(
"Location: ".$backtopage);
2088 header(
"Location: ".
$_SERVER[
"PHP_SELF"].
'?website='.$websitekey.
'&pageid='.$pageid);
2092 if ($action ==
'updatesource') $action =
'editsource';
2093 if ($action ==
'updatecontent') $action =
'editcontent';
2097 header(
"Location: ".
$_SERVER[
"PHP_SELF"].
'?website='.$websitekey.
'&pageid='.$pageid);
2104 header(
"Location: ".
$_SERVER[
"PHP_SELF"].
'?website='.$websitekey.
'&pageid='.$pageid);
2110 if (empty($websitekey) || $websitekey ==
'-1')
2112 setEventMessages($langs->trans(
"NoWebSiteCreateOneFirst"), null,
'warnings');
2115 setEventMessages($langs->trans(
"YouCanCreatePageOrImportTemplate"), null,
'warnings');
2122 if ($action ==
'exportsite')
2124 $fileofzip = $object->exportWebSite();
2128 $file_name = basename($fileofzip);
2130 header(
"Content-Type: application/zip");
2131 header(
"Content-Disposition: attachment; filename=".$file_name);
2132 header(
"Content-Length: ".filesize($fileofzip));
2134 readfile($fileofzip);
2139 $action =
'preview';
2144 if ($action ==
'regeneratesite')
2146 $result = $object->rebuildWebSiteFiles();
2149 setEventMessages($langs->trans(
"PagesRegenerated", $result), null,
'mesgs');
2150 $action =
'preview';
2153 $action =
'preview';
2158 if ($action ==
'importsiteconfirm')
2160 if (empty($_FILES) && !
GETPOSTISSET(
'templateuserfile'))
2162 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"File")), null,
'errors');
2163 $action =
'importsite';
2166 if (!empty($_FILES) ||
GETPOSTISSET(
'templateuserfile'))
2169 $pathtomedias = DOL_DATA_ROOT.
'/medias';
2170 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
2173 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
2174 dol_mkdir(dirname($pathtomediasinwebsite));
2175 $result = symlink($pathtomedias, $pathtomediasinwebsite);
2178 setEventMessages($langs->trans(
"ErrorFieldToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias), null,
'errors');
2179 $action =
'importsite';
2186 $fileofzip = DOL_DATA_ROOT.
'/doctemplates/websites/'.
GETPOST(
'templateuserfile',
'alpha');
2188 elseif (!empty($_FILES))
2190 if (is_array($_FILES[
'userfile'][
'tmp_name'])) $userfiles = $_FILES[
'userfile'][
'tmp_name'];
2191 else $userfiles = array($_FILES[
'userfile'][
'tmp_name']);
2193 foreach ($userfiles as $key => $userfile)
2195 if (empty($_FILES[
'userfile'][
'tmp_name'][$key]))
2198 if ($_FILES[
'userfile'][
'error'][$key] == 1 || $_FILES[
'userfile'][
'error'][$key] == 2) {
2200 $action =
'importsite';
2203 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"File")), null,
'errors');
2204 $action =
'importsite';
2211 $upload_dir = $conf->website->dir_temp;
2216 $fileofzip = $upload_dir.
'/unknown';
2217 foreach ($_FILES as $key => $ifile)
2219 foreach ($ifile[
'name'] as $key2 => $ifile2)
2221 $fileofzip = $upload_dir.
'/'.$ifile2;
2228 $result = $object->importWebSite($fileofzip);
2232 $action =
'importsite';
2236 dolibarr_set_const($db,
'WEBSITE_SUBCONTAINERSINLINE', 1,
'chaine', 0,
'', $conf->entity);
2238 header(
"Location: ".
$_SERVER[
"PHP_SELF"].
'?website='.$object->ref);
2253 $form =
new Form($db);
2258 $helpurl =
'EN:Module_Website|FR:Module_Website_FR|ES:Módulo_Website';
2261 '/includes/ace/src/ace.js',
2262 '/includes/ace/src/ext-statusbar.js',
2263 '/includes/ace/src/ext-language_tools.js',
2267 $arrayofcss = array();
2272 $arrayofjs[] =
'includes/jquery/plugins/blockUI/jquery.blockUI.js';
2273 $arrayofjs[] =
'core/js/blockUI.js';
2274 if (empty($conf->global->MAIN_ECM_DISABLE_JS)) $arrayofjs[] =
"includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js";
2276 $moreheadjs .=
'<script type="text/javascript">'.
"\n";
2277 $moreheadjs .=
'var indicatorBlockUI = \''.DOL_URL_ROOT.
"/theme/".$conf->theme.
"/img/working.gif".
'\';
'."\n";
2278 $moreheadjs .= '</script>
'."\n";
2280 llxHeader($moreheadcss.$moreheadjs, $langs->trans("WebsiteSetup"), $helpurl, '', 0, 0, $arrayofjs, $arrayofcss, '', '', '<!-- Begin div
class=
"fiche" -->
'."\n".'<div
class=
"fichebutwithotherclass">
');
2283 print '<form action=
"'.$_SERVER["PHP_SELF
"].'" method=
"POST" enctype=
"multipart/form-data">
';
2284 print '<input
type=
"hidden" name=
"token" value=
"'.newToken().'">
';
2285 print '<input type=
"hidden" name=
"backtopage" value=
"'.$backtopage.'">
';
2287 if ($action == 'createsite
')
2289 print '<input type=
"hidden" name=
"action" value=
"addsite">
';
2291 if ($action == 'createcontainer
')
2293 print '<input type=
"hidden" name=
"action" value=
"addcontainer">
';
2295 if ($action == 'editcss
')
2297 print '<input type=
"hidden" name=
"action" value=
"updatecss">
';
2299 if ($action == 'editmenu
')
2301 print '<input type=
"hidden" name=
"action" value=
"updatemenu">
';
2303 if ($action == 'setashome
')
2305 print '<input type=
"hidden" name=
"action" value=
"updateashome">
';
2307 if ($action == 'editmeta
')
2309 print '<input type=
"hidden" name=
"action" value=
"updatemeta">
';
2311 if ($action == 'editsource
')
2313 print '<input type=
"hidden" name=
"action" value=
"updatesource">
';
2315 if ($action == 'editcontent
')
2317 print '<input type=
"hidden" name=
"action" value=
"updatecontent">
';
2319 if ($action == 'edit
')
2321 print '<input type=
"hidden" name=
"action" value=
"update">
';
2323 if ($action == 'importsite
')
2325 print '<input type=
"hidden" name=
"action" value=
"importsiteconfirm">
';
2327 if ($action == 'file_manager
')
2329 print '<input type=
"hidden" name=
"action" value=
"file_manager">
';
2331 if ($action == 'replacesite
')
2333 print '<input type=
"hidden" name=
"action" value=
"replacesiteconfirm">
';
2335 if ($action == 'replacesiteconfirm
')
2337 print '<input type=
"hidden" name=
"action" value=
"replacesiteconfirm">
';
2342 // Add a margin under toolbar ?
2344 if ($action != 'preview
' && $action != 'editcontent
' && $action != 'editsource
' && !GETPOST('createpagefromclone
', 'alphanohtml
')) $style = ' margin-bottom: 5px;
';
2347 if (!GETPOST('hide_websitemenu
'))
2350 if (empty($user->rights->website->write)) $disabled = ' disabled=
"disabled"';
2355 $dataroot = DOL_DATA_ROOT.'/website/
'.$websitekey;
2356 if (!empty($object->virtualhost)) $virtualurl = $object->virtualhost;
2360 if ($object->id > 0)
2362 $array = $objectpage->fetchAll($object->id, 'ASC,ASC
', 'type_container,pageurl
');
2363 $object->lines = $array;
2365 if (!is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors);
2366 $atleastonepage = (is_array($array) && count($array) > 0);
2369 //var_dump($objectpage);exit;
2370 print '<div
class=
"centpercent websitebar'.(GETPOST('dol_openinpopup', 'int') ? ' hidden' : '').'">
';
2373 // Toolbar for websites
2376 print '<!-- Bar
for website -->
';
2377 if ($action != 'file_manager
') {
2378 print '<span
class=
"websiteselection hideonsmartphoneimp minwidth100 tdoverflowmax100">
';
2379 print $langs->trans("Website").' :
';
2382 $urltocreatenewwebsite = $_SERVER["PHP_SEFL"].'?action=createsite
';
2383 if (empty($conf->use_javascript_ajax)) {
2384 print '<span
class=
"websiteselection hideonsmartphoneimp">
';
2385 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>
';
2390 print '<span
class=
"websiteselection">
';
2392 $out .= '<select
name=
"website" class=
"minwidth100 width200 maxwidth150onsmartphone" id=
"website">
';
2393 if (empty($object->records)) $out .= '<option value=
"-1"> </option>
';
2394 if (!empty($conf->use_javascript_ajax)) {
2395 $valueoption = '<span
class=
"classlink">
'.img_picto('', 'add
', 'class=
"paddingrightonly"').$langs->trans("AddWebsite").'</span>
';
2396 $out .= '<option value=
"-2" data-html=
"'.dol_escape_htmltag($valueoption).'">
'.$valueoption.'</option>
';
2398 // Loop on each sites
2400 foreach ($object->records as $key => $valwebsite)
2402 if (empty($websitekey)) {
2403 if ($action != 'createsite
') $websitekey = $valwebsite->ref;
2406 $out .= '<option value=
"'.$valwebsite->ref.'"';
2407 if ($websitekey == $valwebsite->ref) $out .= ' selected
'; // To preselect a value
2408 //$outoption = $valwebsite->getLibStatut(3).' '.$valwebsite->ref.' ';
2409 $outoption = (($valwebsite->status == $valwebsite::STATUS_DRAFT) ? '<span
class=
"opacitymedium">
' : '').$valwebsite->ref.(($valwebsite->status == $valwebsite::STATUS_DRAFT) ? '</span>
' : '');
2410 $out .= ' data-html=
"'.dol_escape_htmltag($outoption).'"';
2412 $out .= $valwebsite->ref;
2413 $out .= '</option>
';
2416 $out .= '</select>
';
2417 $out .= ajax_combobox('website
');
2419 if (!empty($conf->use_javascript_ajax)) {
2420 $out .= '<script language=
"javascript">
';
2421 $out .= 'jQuery(document).ready(
function () {
';
2422 $out .= ' jQuery(
"#website").change(
function () {
';
2423 $out .= ' console.log(
"We select "+jQuery(
"#website option:selected").val());
';
2424 $out .= ' if (jQuery(
"#website option:selected").val() == \
'-2\') {';
2425 $out .=
' window.location.href = "'.$urltocreatenewwebsite.
'";';
2426 $out .=
' } else {';
2427 $out .=
' window.location.href = "'.$_SERVER[
"PHP_SEFL"].
'?website="+jQuery("#website option:selected").val();';
2431 $out .=
'</script>';
2435 if (empty($conf->use_javascript_ajax)) {
2436 print '<input type="image" class="valignmiddle" src="'.img_picto(
'',
'refresh',
'', 0, 1).
'" name="refreshsite" value="'.$langs->trans(
"Load").
'">';
2439 if ($websitekey && $websitekey !=
'-1' && ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite'))
2443 print '<input type="submit" class="button bordertransp"'.$disabled.
' value="'.
dol_escape_htmltag($langs->trans(
"EditCss")).
'" name="editcss">';
2445 $importlabel = $langs->trans(
"ImportSite");
2446 $exportlabel = $langs->trans(
"ExportSite");
2447 if (!empty($conf->dol_optimize_smallscreen)) {
2448 $importlabel = $langs->trans(
"Import");
2449 $exportlabel = $langs->trans(
"Export");
2452 if ($atleastonepage)
2454 print '<input type="submit" class="button bordertransp" disabled="disabled" value="'.dol_escape_htmltag($importlabel).
'" name="importsite">';
2457 print '<input type="submit" class="button bordertransp"'.$disabled.
' value="'.
dol_escape_htmltag($importlabel).
'" name="importsite">';
2461 print '<input type="submit" class="button bordertransp"'.$disabled.
' value="'.
dol_escape_htmltag($exportlabel).
'" name="exportsite">';
2463 print '<input type="submit" class="button bordertransp"'.$disabled.
' value="'.
dol_escape_htmltag($langs->trans(
"CloneSite")).
'" name="createfromclone">';
2465 print '<input type="submit" class="buttonDelete bordertransp" name="deletesite" value="'.$langs->trans(
"Delete").
'"'.($atleastonepage ?
' disabled="disabled"' :
'').
'>';
2468 print '<a href="'.$_SERVER[
"PHP_SEFL"].
'?action=regeneratesite&website='.$website->ref.
'" class="button bordertransp"'.$disabled.
' title="'.
dol_escape_htmltag($langs->trans(
"RegenerateWebsiteContent")).
'"><span class="fa fa-cogs"><span></a>';
2472 print
'<a href="'.$_SERVER[
"PHP_SEFL"].
'?action=replacesite&website='.$website->ref.
'" class="button bordertransp"'.$disabled.
' title="'.
dol_escape_htmltag($langs->trans(
"ReplaceWebsiteContent")).
'"><span class="fa fa-search"><span></a>';
2477 if ($websitekey && $websitekey !=
'-1' && ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite'))
2479 print
'<span class="websiteselection">';
2481 print
dolButtonToOpenUrlInDialogPopup(
'file_manager', $langs->transnoentitiesnoconv(
"MediaFiles"),
'<span class="fa fa-image"><span>',
'/website/index.php?action=file_manager&website='.$website->ref, $disabled);
2483 if (!empty($conf->categorie->enabled)) {
2485 print
dolButtonToOpenUrlInDialogPopup(
'categories', $langs->transnoentitiesnoconv(
"Categories"),
'<span class="fa fa-tags"><span>',
'/categories/index.php?leftmenu=website&nosearch=1&type=website_page&website='.$website->ref, $disabled);
2491 print
'<input type="hidden" name="website" id="website" value="'.$websitekey.
'">';
2495 print
'<span class="websitetools websiteselection">';
2497 if ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite')
2499 $urlext = $virtualurl;
2500 $urlint = $urlwithroot.
'/public/website/index.php?website='.$websitekey;
2502 print
'<span class="websiteinputurl valignmiddle" id="websiteinputurl">';
2503 $linktotestonwebserver =
'<a href="'.($virtualurl ? $virtualurl :
'#').
'" class="valignmiddle">';
2504 $linktotestonwebserver .=
'<span class="hideonsmartphone paddingrightonly">'.$langs->trans(
"TestDeployOnWeb", $virtualurl).
'</span>'.
img_picto(
'',
'globe');
2505 $linktotestonwebserver .=
'</a>';
2507 if (empty($object->fk_default_home))
2509 $htmltext .=
'<br><span class="error">'.$langs->trans(
"YouMustDefineTheHomePage").
'</span><br><br>';
2511 elseif (empty($virtualurl))
2516 $htmltext .=
'<br><center>'.$langs->trans(
"GoTo").
' <a href="'.$virtualurl.
'" target="_website">'.$virtualurl.
'</a></center><br>';
2518 if (!empty($conf->global->WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER))
2520 $htmltext .=
'<br>'.$langs->trans($conf->global->WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER);
2523 $htmltext .= $langs->trans(
"SetHereVirtualHost", $dataroot);
2524 $htmltext .=
'<br>';
2525 $htmltext .=
'<br>'.$langs->trans(
"CheckVirtualHostPerms", $langs->transnoentitiesnoconv(
"ReadPerm"), DOL_DOCUMENT_ROOT);
2526 $htmltext .=
'<br>'.$langs->trans(
"CheckVirtualHostPerms", $langs->transnoentitiesnoconv(
"WritePerm"),
'{s1}');
2527 $htmltext = str_replace(
'{s1}', DOL_DATA_ROOT.
'/website<br>'.DOL_DATA_ROOT.
'/medias', $htmltext);
2529 $examplewithapache =
'#php_admin_value open_basedir /tmp/:'.DOL_DOCUMENT_ROOT.
':'.DOL_DATA_ROOT.
':/dev/urandom'.
"\n";
2530 $examplewithapache .=
'<Directory "'.DOL_DOCUMENT_ROOT.
'">'.
"\n";
2531 $examplewithapache .=
'AllowOverride FileInfo Options
2532 Options -Indexes -MultiViews -FollowSymLinks -ExecCGI
2535 <Directory "'.DOL_DATA_ROOT.
'/website">
2536 AllowOverride FileInfo Options
2537 Options -Indexes -MultiViews +FollowSymLinks -ExecCGI
2540 <Directory "'.DOL_DATA_ROOT.
'/medias">
2541 AllowOverride FileInfo Options
2542 Options -Indexes -MultiViews -FollowSymLinks -ExecCGI
2546 $htmltext .=
'<br>'.$langs->trans(
"ExampleToUseInApacheVirtualHostConfig").
':<br>';
2547 $htmltext .=
'<div class="centpercent exampleapachesetup">'.dol_nl2br(
dol_escape_htmltag($examplewithapache, 1, 1)).
'</div>';
2549 $htmltext .=
'<br>';
2550 $htmltext .= $langs->trans(
"YouCanAlsoTestWithPHPS", $dataroot);
2551 $htmltext .=
'<br>';
2552 $htmltext .=
'<br>';
2553 $htmltext .= $langs->trans(
"YouCanAlsoDeployToAnotherWHP");
2555 print $form->textwithpicto($linktotestonwebserver, $htmltext, 1,
'none',
'valignmiddle', 0, 3,
'helpvirtualhost');
2559 if (in_array($action, array(
'editcss',
'editmenu',
'file_manager',
'replacesite',
'replacesiteconfirm')))
2561 if ($action ==
'editcss') print
'<input type="submit" id="savefilean stay" class="button buttonforacesave" value="'.dol_escape_htmltag($langs->trans(
"SaveAndStay")).
'" name="updateandstay">';
2562 if (preg_match(
'/^create/', $action) && $action !=
'file_manager' && $action !=
'replacesite' && $action !=
'replacesiteconfirm') print
'<input type="submit" id="savefile" class="button buttonforacesave button-save" value="'.
dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
2563 if (preg_match(
'/^edit/', $action) && $action !=
'file_manager' && $action !=
'replacesite' && $action !=
'replacesiteconfirm') print
'<input type="submit" id="savefile" class="button buttonforacesave button-save" value="'.
dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
2564 if ($action !=
'preview') print
'<input type="submit" class="button button-cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'" name="cancel">';
2573 if ($websitekey && $websitekey !=
'-1' && !in_array($action, array(
'editcss',
'editmenu',
'importsite',
'file_manager',
'replacesite',
'replacesiteconfirm')) && !$file_manager)
2577 print
'<!-- Bar for websitepage -->';
2578 print
'<div class="centpercent websitebar"'.($style ?
' style="'.$style.
'"' :
'').
'">';
2580 print
'<span class="websiteselection hideonsmartphoneimp minwidth100 tdoverflowmax100">';
2581 print $langs->trans(
"PageContainer").
': ';
2584 print
'<span class="websiteselection hideonsmartphoneimp">';
2585 print
'<a href="'.$_SERVER[
"PHP_SEFL"].
'?action=createcontainer&website='.$website->ref.
'" class="button bordertransp"'.$disabled.
' title="'.
dol_escape_htmltag($langs->trans(
"AddPage")).
'"><span class="fa fa-plus-circle valignmiddle btnTitle-icon"><span></a>';
2590 if ($action !=
'addcontainer')
2594 $s = $formwebsite->selectContainer($website,
'pageid', $pageid, 0, $action,
'maxwidth200onsmartphone');
2596 if ($formwebsite->num > 0) {
2597 $out .=
'<span class="websiteselection">';
2601 $urltocreatenewpage =
$_SERVER[
"PHP_SEFL"].
'?action=createcontainer&website='.$website->ref;
2603 if (!empty($conf->use_javascript_ajax)) {
2604 $out .=
'<script language="javascript">';
2605 $out .=
'jQuery(document).ready(function () {';
2606 $out .=
' jQuery("#pageid").change(function () {';
2607 $out .=
' console.log("We select "+jQuery("#pageid option:selected").val());';
2608 $out .=
' if (jQuery("#pgeid option:selected").val() == \'-2\') {';
2609 $out .=
' window.location.href = "'.$urltocreatenewpage.
'";';
2610 $out .=
' } else {';
2611 $out .=
' window.location.href = "'.$_SERVER[
"PHP_SEFL"].
'?website='.$website->ref.
'&pageid="+jQuery("#pageid option:selected").val();';
2615 $out .=
'</script>';
2622 print $langs->trans(
"New");
2626 print
'<input type="image" class="valignmiddle" src="'.img_picto(
'',
'refresh',
'', 0, 1).
'" name="refreshpage" value="'.$langs->trans(
"Load").
'"'.(($atleastonepage && $action !=
'editsource') ?
'' :
' disabled="disabled"').
'>';
2630 $pagepreviousid = 0;
2634 $sql =
'SELECT MAX(rowid) as pagepreviousid FROM '.MAIN_DB_PREFIX.
'website_page WHERE rowid < '.$pageid.
' AND fk_website = '.$object->id;
2635 $resql = $db->query($sql);
2638 $obj = $db->fetch_object(
$resql);
2641 $pagepreviousid = $obj->pagepreviousid;
2645 $sql =
'SELECT MIN(rowid) as pagenextid FROM '.MAIN_DB_PREFIX.
'website_page WHERE rowid > '.$pageid.
' AND fk_website = '.$object->id;
2646 $resql = $db->query($sql);
2649 $obj = $db->fetch_object(
$resql);
2652 $pagenextid = $obj->pagenextid;
2658 if ($pagepreviousid) print
'<a class="valignmiddle" href="'.$_SERVER[
'PHP_SELF'].
'?website='.urlencode($object->ref).
'&pageid='.$pagepreviousid.
'&action='.$action.
'">'.
img_previous($langs->trans(
"PreviousContainer")).
'</a>';
2659 else print
'<span class="valignmiddle opacitymedium">'.img_previous($langs->trans(
"Previous")).
'</span>';
2660 if ($pagenextid) print
'<a class="valignmiddle" href="'.$_SERVER[
'PHP_SELF'].
'?website='.urlencode($object->ref).
'&pageid='.$pagenextid.
'&action='.$action.
'">'.
img_next($langs->trans(
"NextContainer")).
'</a>';
2661 else print
'<span class="valignmiddle opacitymedium">'.img_next($langs->trans(
"Next")).
'</span>';
2663 $websitepage =
new WebSitePage($db);
2664 if ($pageid > 0 && ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone'))
2666 $websitepage->fetch($pageid);
2669 if ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite')
2672 if (empty($user->rights->website->write)) $disabled =
' disabled="disabled"';
2675 if ($action ==
'deletesite') {
2677 $formquestion = array(
2678 array(
'type' =>
'checkbox',
'name' =>
'delete_also_js',
'label' => $langs->trans(
"DeleteAlsoJs"),
'value' => 0),
2679 array(
'type' =>
'checkbox',
'name' =>
'delete_also_medias',
'label' => $langs->trans(
"DeleteAlsoMedias"),
'value' => 0),
2684 $formconfirm = $form->formconfirm(
$_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeleteWebsite'),
'',
'confirm_deletesite', $formquestion, 0, 1, 200);
2690 if ($action ==
'createfromclone') {
2692 $formquestion = array(
2693 array(
'type' =>
'text',
'name' =>
'siteref',
'label'=> $langs->trans(
"WebSite"),
'value'=>
'copy_of_'.$object->ref)
2696 $formconfirm = $form->formconfirm(
$_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'CloneSite'),
'',
'confirm_createfromclone', $formquestion, 0, 1, 200);
2701 if ($pageid > 0 && $atleastonepage)
2704 if ($action ==
'createpagefromclone') {
2706 $preselectedlanguage =
GETPOST(
'newlang',
'aZ09') ?
GETPOST(
'newlang',
'aZ09') :
'';
2707 $onlylang = array();
2708 if ($website->otherlang) {
2709 if (!empty($website->lang)) {
2710 $onlylang[$website->lang] = $website->lang.
' ('.$langs->trans(
"Default").
')';
2712 foreach (explode(
',', $website->otherlang) as $langkey) {
2713 $onlylang[$langkey] = $langkey;
2715 $textifempty = $langs->trans(
"Default");
2717 $onlylang[
'none'] =
'none';
2718 $textifempty = $langs->trans(
"Default");
2720 $formquestion = array(
2721 array(
'type' =>
'hidden',
'name' =>
'sourcepageurl',
'value'=> $objectpage->pageurl),
2722 array(
'type' =>
'other',
'tdclass'=>
'fieldrequired',
'name' =>
'newwebsite',
'label' => $langs->trans(
"WebSite"),
'value' => $formwebsite->selectWebsite($object->id,
'newwebsite', 0)),
2723 array(
'type' =>
'text',
'tdclass'=>
'maxwidth200 fieldrequired',
'moreattr'=>
'autofocus="autofocus"',
'name' =>
'newtitle',
'label'=> $langs->trans(
"WEBSITE_TITLE"),
'value'=> $langs->trans(
"CopyOf").
' '.$objectpage->title),
2724 array(
'type' =>
'text',
'tdclass'=>
'maxwidth200',
'name' =>
'newpageurl',
'label'=> $langs->trans(
"WEBSITE_PAGENAME"),
'value'=>
'')
2726 if (count($onlylang) > 1) {
2727 $formquestion[] = array(
'type' =>
'checkbox',
'tdclass'=>
'maxwidth200',
'name' =>
'is_a_translation',
'label' => $langs->trans(
"PageIsANewTranslation"),
'value' => 0,
'morecss'=>
'margintoponly');
2730 $value= $formadmin->select_language($preselectedlanguage,
'newlang', 0, null, $textifempty, 0, 0,
'minwidth200', 1, 0, 0, $onlylang, 1);
2731 $formquestion[] = array(
'type' =>
'other',
'name' =>
'newlang',
'label' => $form->textwithpicto($langs->trans(
"Language"), $langs->trans(
"DefineListOfAltLanguagesInWebsiteProperties")),
'value' => $value);
2733 $formconfirm = $form->formconfirm(
$_SERVER[
"PHP_SELF"].
'?website='.$object->ref.
'&pageid='.$pageid, $langs->trans(
'ClonePage'),
'',
'confirm_createpagefromclone', $formquestion, 0, 1, 300, 550);
2740 print
'<input type="submit" class="button bordertransp"'.$disabled.
' value="'.
dol_escape_htmltag($langs->trans(
"EditPageMeta")).
'" name="editmeta">';
2742 print
'<input type="submit" class="button bordertransp"'.$disabled.
' value="'.
dol_escape_htmltag($langs->trans(
"EditHTMLSource")).
'" name="editsource">';
2744 print
'<!-- button EditInLine and ShowSubcontainers -->'.
"\n";
2745 print
'<div class="websiteselectionsection inline-block">';
2746 print
'<div class="inline-block marginrightonly">';
2748 print
'<span id="switchckeditorinline">'.
"\n";
2749 print
'<!-- Code to enabled edit inline ckeditor -->'.
"\n";
2750 print
'<script type="text/javascript">
2751 $(document).ready(function() {
2752 var isEditingEnabled = '.($conf->global->WEBSITE_EDITINLINE ?
'true' :
'false').
';
2753 if (isEditingEnabled)
2755 switchEditorOnline(true);
2758 $( "#switchckeditorinline" ).click(function() {
2759 switchEditorOnline();
2762 function switchEditorOnline(forceenable)
2764 if (! isEditingEnabled || forceenable)
2766 console.log("Enable inline edit");
2767 jQuery(\'section[contenteditable="true"],div[contenteditable="true"]\').each(function(idx){
2768 var idtouse = $(this).attr(\'id\');
2769 console.log("Enable inline edit for "+idtouse);
2770 CKEDITOR.inline(idtouse, {
2771 // Allow some non-standard markup that we used in the introduction.
2772 extraAllowedContent: \'span(*);cite(*);q(*);dl(*);dt(*);dd(*);ul(*);li(*);header(*);button(*);h1(*);h2(*);\',
2773 //extraPlugins: \'sourcedialog\',
2774 removePlugins: \'flash,stylescombo\',
2775 // Show toolbar on startup (optional).
2776 // startupFocus: true
2780 isEditingEnabled = true;
2783 console.log("Disable inline edit");
2784 for(name in CKEDITOR.instances)
2786 CKEDITOR.instances[name].destroy(true);
2788 isEditingEnabled = false;
2793 print $langs->trans(
"EditInLine");
2797 $disableeditinline = 0;
2798 if ($disableeditinline)
2801 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>';
2805 if (empty($conf->global->WEBSITE_EDITINLINE))
2807 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>';
2810 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>';
2815 print
'<div class="inline-block marginrightonly">';
2816 print $langs->trans(
"ShowSubcontainers");
2817 if (empty($conf->global->WEBSITE_SUBCONTAINERSINLINE))
2819 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>';
2822 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>';
2829 if ($object->fk_default_home > 0 && $pageid == $object->fk_default_home)
2834 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>';
2839 print
'<a href="'.$_SERVER[
"PHP_SEFL"].
'?action=setashome&token='.
newToken().
'&website='.$website->ref.
'&pageid='.$pageid.
'" class="button bordertransp"'.$disabled.
' title="'.
dol_escape_htmltag($langs->trans(
"SetAsHomePage")).
'"><span class="fa fa-home valignmiddle btnTitle-icon"><span></a>';
2841 print
'<input type="submit" class="button bordertransp"'.$disabled.
' value="'.
dol_escape_htmltag($langs->trans(
"ClonePage")).
'" name="createpagefromclone">';
2842 print
'<input type="submit" class="buttonDelete bordertransp" name="delete" value="'.$langs->trans(
"Delete").
'"'.($atleastonepage ?
'' :
' disabled="disabled"').
'>';
2848 print
'<span class="websitetools">';
2850 if (($pageid > 0 && $atleastonepage) && ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite'))
2852 $realpage = $urlwithroot.
'/public/website/index.php?website='.$websitekey.
'&pageref='.$websitepage->pageurl;
2853 $pagealias = $websitepage->pageurl;
2855 $htmltext = $langs->trans(
"PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv(
"Page"), $langs->transnoentitiesnoconv(
"Page"), $realpage, $dataroot);
2856 $htmltext .=
'<br>'.$langs->trans(
"CheckVirtualHostPerms", $langs->transnoentitiesnoconv(
"ReadPerm"), DOL_DOCUMENT_ROOT);
2857 $htmltext .=
'<br>'.$langs->trans(
"CheckVirtualHostPerms", $langs->transnoentitiesnoconv(
"WritePerm"),
'{s1}');
2858 $htmltext = str_replace(
'{s1}', DOL_DATA_ROOT.
'/website<br>'.DOL_DATA_ROOT.
'/medias', $htmltext);
2860 print
'<div class="websiteinputurl inline-block paddingright">';
2861 print
'<a class="websitebuttonsitepreview inline-block" id="previewpage" href="'.$realpage.
'&nocache='.
dol_now().
'" class="button" target="tab'.$websitekey.
'" alt="'.
dol_escape_htmltag($htmltext).
'">';
2862 print $form->textwithpicto(
'', $htmltext, 1,
'preview');
2886 if (!in_array($action, array(
'editcss',
'editmenu',
'file_manager',
'replacesite',
'replacesiteconfirm',
'createsite',
'createcontainer',
'createfromclone',
'createpagefromclone',
'deletesite')))
2888 if ($action ==
'editsource' || $action ==
'editmeta') print
'<input type="submit" id="savefilean stay" class="button buttonforacesave" value="'.dol_escape_htmltag($langs->trans(
"SaveAndStay")).
'" name="updateandstay">';
2889 if (preg_match(
'/^create/', $action)) print
'<input type="submit" id="savefile" class="button buttonforacesave button-save" value="'.
dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
2890 if (preg_match(
'/^edit/', $action)) print
'<input type="submit" id="savefile" class="button buttonforacesave button-save" value="'.
dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
2891 if ($action !=
'preview') print
'<input type="submit" class="button button-cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'" name="cancel">';
2896 print
'<span class="websitehelp">';
2897 if (
GETPOST(
'editsource',
'alpha') ||
GETPOST(
'editcontent',
'alpha'))
2899 $url =
'https://wiki.dolibarr.org/index.php/Module_Website';
2901 $htmltext = $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource", $url);
2902 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource2", $url);
2903 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSourceMore", $url);
2904 $htmltext .=
'<br>';
2905 if ($conf->browser->layout ==
'phone')
2907 print $form->textwithpicto(
'', $htmltext, 1,
'help',
'inline-block', 1, 2,
'tooltipsubstitution');
2911 print $form->textwithpicto($langs->trans(
"SyntaxHelp").
' '.
img_help(2, $langs->trans(
"SyntaxHelp")), $htmltext, 1,
'none',
'inline-block', 1, 2,
'tooltipsubstitution');
2917 if ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone')
2920 if (!empty($conf->use_javascript_ajax))
2922 print
'<script type="text/javascript" language="javascript">
2923 jQuery(document).ready(function() {
2924 jQuery("#websiteinputurl").keyup(function() {
2925 console.log("Website external url modified "+jQuery("#previewsiteurl").val());
2926 if (jQuery("#previewsiteurl").val() != "" && jQuery("#previewsiteurl").val().startsWith("http"))
2928 jQuery("a.websitebuttonsitepreviewdisabled img").css({ opacity: 1 });
2930 else jQuery("a.websitebuttonsitepreviewdisabled img").css({ opacity: 0.2 });
2934 jQuery("#previewsiteext,#previewpageext").click(function() {
2936 newurl=jQuery("#previewsiteurl").val();
2937 if (! newurl.startsWith("http"))
2939 alert(\''.dol_escape_js($langs->trans(
"ErrorURLMustStartWithHttp")).
'\');
2943 newpage=jQuery(
"#previewsiteurl").val() +
"/" + jQuery(
"#previewpageurl").val() +
".php";
2944 console.log(
"Open url "+newurl);
2948 url:
"'.DOL_URL_ROOT.'/core/ajax/saveinplace.php",
2950 field: \
'editval_virtualhost\',
2951 element: \'website\',
2952 table_element: \'website\',
2953 fk_element: '.$object->id.
',
2956 context: document.body
2959 jQuery("#previewsiteext").attr("href",newurl);
2960 jQuery("#previewpageext").attr("href",newpage);
2979 if ($action ==
'editcss')
2981 print
'<div class="fiche">';
2987 $csscontent = @file_get_contents($filecss);
2989 $csscontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims',
'', $csscontent);
2992 $csscontent =
GETPOST(
'WEBSITE_CSS_INLINE',
'none');
2994 if (!trim($csscontent)) {
2995 $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;}";
3000 $jscontent = @file_get_contents($filejs);
3002 $jscontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims',
'', $jscontent);
3005 $jscontent =
GETPOST(
'WEBSITE_JS_INLINE',
'none');
3007 if (!trim($jscontent)) $jscontent =
'/* JS content (all pages) */'.
"\n";
3011 $htmlheadercontent = @file_get_contents($filehtmlheader);
3013 $htmlheadercontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims',
'', $htmlheadercontent);
3016 $htmlheadercontent =
GETPOST(
'WEBSITE_HTML_HEADER',
'none');
3018 if (!trim($htmlheadercontent))
3020 $htmlheadercontent =
"<html>\n";
3021 $htmlheadercontent .= $htmlheadercontentdefault;
3022 $htmlheadercontent .=
"</html>";
3025 $htmlheadercontent = preg_replace(
'/^\s*<html>/ims',
'', $htmlheadercontent);
3026 $htmlheadercontent = preg_replace(
'/<\/html>\s*$/ims',
'', $htmlheadercontent);
3027 $htmlheadercontent =
'<html>'.
"\n".trim($htmlheadercontent).
"\n".
'</html>';
3032 $robotcontent = @file_get_contents($filerobot);
3034 $robotcontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims',
'', $robotcontent);
3037 $robotcontent =
GETPOST(
'WEBSITE_ROBOT',
'nothtml');
3039 if (!trim($robotcontent))
3041 $robotcontent .=
"# Robot file. Generated with ".DOL_APPLICATION_TITLE.
"\n";
3042 $robotcontent .=
"User-agent: *\n";
3043 $robotcontent .=
"Allow: /public/\n";
3044 $robotcontent .=
"Disallow: /administrator/\n";
3049 $htaccesscontent = @file_get_contents($filehtaccess);
3051 $htaccesscontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims',
'', $htaccesscontent);
3054 $htaccesscontent =
GETPOST(
'WEBSITE_HTACCESS',
'nohtml');
3056 if (!trim($htaccesscontent))
3058 $htaccesscontent .=
"# Order allow,deny\n";
3059 $htaccesscontent .=
"# Deny from all\n";
3065 $manifestjsoncontent = @file_get_contents($filemanifestjson);
3067 $manifestjsoncontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims',
'', $manifestjsoncontent);
3070 $manifestjsoncontent =
GETPOST(
'WEBSITE_MANIFEST_JSON',
'restricthtml');
3072 if (!trim($manifestjsoncontent))
3079 $readmecontent = @file_get_contents($filereadme);
3081 $readmecontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims',
'', $readmecontent);
3084 $readmecontent =
GETPOST(
'WEBSITE_README',
'none');
3086 if (!trim($readmecontent))
3093 print
'<!-- Edit Website properties -->'.
"\n";
3094 print
'<table class="border centpercent">';
3097 print
'<tr><td class="titlefieldcreate fieldrequired">';
3098 print $langs->trans(
'WebSite');
3104 print
'<!-- Status of website -->'.
"\n";
3105 print
'<tr><td class="fieldrequired">';
3106 print $langs->trans(
'Status');
3113 print
'<tr><td class="tdtop fieldrequired">';
3115 print $form->textwithpicto($langs->trans(
'MainLanguage'), $htmltext, 1,
'help',
'', 0, 2,
'WEBSITE_LANG');
3117 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);
3122 print
'<tr><td class="tdtop">';
3123 $htmltext = $langs->trans(
"Example").
': fr,de,sv,it,pt';
3124 print $form->textwithpicto($langs->trans(
'OtherLanguages'), $htmltext, 1,
'help',
'', 0, 2);
3126 print
'<input type="text" class="flat" value="'.(GETPOSTISSET(
'WEBSITE_OTHERLANG') ?
GETPOST(
'WEBSITE_OTHERLANG',
'alpha') : $object->otherlang).
'" name="WEBSITE_OTHERLANG">';
3131 print
'<tr><td class="tdtop">';
3133 $htmltext = $langs->trans(
"SetHereVirtualHost", DOL_DATA_ROOT.
'/website/{s1}'.$websitekey.
'{s2}');
3134 $htmltext = str_replace(array(
'{s1}',
'{s2}'), array(
'<i>',
'</i>'), $htmltext);
3135 $htmltext .=
'<br>';
3136 $htmltext .=
'<br>'.$langs->trans(
"CheckVirtualHostPerms", $langs->transnoentitiesnoconv(
"ReadPerm"), DOL_DOCUMENT_ROOT);
3137 $htmltext .=
'<br>'.$langs->trans(
"CheckVirtualHostPerms", $langs->transnoentitiesnoconv(
"WritePerm"),
'{s1}');
3138 $htmltext = str_replace(
'{s1}', DOL_DATA_ROOT.
'/website<br>'.DOL_DATA_ROOT.
'/medias', $htmltext);
3140 print $form->textwithpicto($langs->trans(
'Virtualhost'), $htmltext, 1,
'help',
'', 0, 2,
'virtualhosttooltip');
3142 print
'<input type="text" class="flat" value="'.(GETPOSTISSET(
'virtualhost') ?
GETPOST(
'virtualhost',
'alpha') : $virtualurl).
'" name="virtualhost">';
3147 print
'<tr><td class="tdtop">';
3148 $htmlhelp = $langs->trans(
"CSSContentTooltipHelp");
3149 print $form->textwithpicto($langs->trans(
'WEBSITE_CSS_INLINE'), $htmlhelp, 1,
'help',
'', 0, 2,
'csstooltip');
3152 $doleditor =
new DolEditor(
'WEBSITE_CSS_INLINE', $csscontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'');
3153 print $doleditor->Create(1,
'',
true,
'CSS',
'css');
3158 print
'<tr><td class="tdtop">';
3159 $textwithhelp = $langs->trans(
'WEBSITE_JS_INLINE');
3160 $htmlhelp2 = $langs->trans(
"LinkAndScriptsHereAreNotLoadedInEditor").
'<br>';
3161 print $form->textwithpicto($textwithhelp, $htmlhelp2, 1,
'warning',
'', 0, 2,
'htmljstooltip2');
3165 $doleditor =
new DolEditor(
'WEBSITE_JS_INLINE', $jscontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'');
3166 print $doleditor->Create(1,
'',
true,
'JS',
'javascript');
3171 print
'<tr><td class="tdtop">';
3172 print $langs->trans(
'WEBSITE_HTML_HEADER');
3173 $htmlhelp = $langs->trans(
"Example").
' :<br>';
3175 $textwithhelp = $form->textwithpicto(
'', $htmlhelp, 1,
'help',
'', 0, 2,
'htmlheadertooltip');
3176 $htmlhelp2 = $langs->trans(
"LinkAndScriptsHereAreNotLoadedInEditor").
'<br>';
3177 print $form->textwithpicto($textwithhelp, $htmlhelp2, 1,
'warning',
'', 0, 2,
'htmlheadertooltip2');
3180 $doleditor =
new DolEditor(
'WEBSITE_HTML_HEADER', $htmlheadercontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'');
3181 print $doleditor->Create(1,
'',
true,
'HTML Header',
'html');
3186 print
'<tr><td class="tdtop">';
3187 print $langs->trans(
'WEBSITE_ROBOT');
3190 $doleditor =
new DolEditor(
'WEBSITE_ROBOT', $robotcontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'');
3191 print $doleditor->Create(1,
'',
true,
'Robot file',
'text');
3196 print
'<tr><td class="tdtop">';
3197 print $langs->trans(
'WEBSITE_HTACCESS');
3200 $doleditor =
new DolEditor(
'WEBSITE_HTACCESS', $htaccesscontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'');
3201 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' .htaccess',
'text');
3206 print
'<tr><td class="tdtop">';
3207 $htmlhelp = $langs->trans(
"Example").
' :<br>';
3209 print $form->textwithpicto($langs->trans(
'WEBSITE_MANIFEST_JSON'), $htmlhelp, 1,
'help',
'', 0, 2,
'manifestjsontooltip');
3211 print $langs->trans(
"UseManifest").
': '.$form->selectyesno(
'use_manifest', $website->use_manifest, 1).
'<br>';
3212 $doleditor =
new DolEditor(
'WEBSITE_MANIFEST_JSON', $manifestjsoncontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'');
3213 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' manifest.json',
'text');
3217 print
'<tr><td class="tdtop">';
3218 $htmlhelp = $langs->trans(
"EnterHereLicenseInformation");
3219 print $form->textwithpicto($langs->trans(
'WEBSITE_README'), $htmlhelp, 1,
'help',
'', 0, 2,
'readmetooltip');
3222 $doleditor =
new DolEditor(
'WEBSITE_README', $readmecontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'');
3223 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' README.md',
'text');
3228 print
'<tr><td class="tdtop">';
3229 $htmlhelp = $langs->trans(
'RSSFeedDesc');
3230 print $form->textwithpicto($langs->trans(
'RSSFeed'), $htmlhelp, 1,
'help',
'', 0, 2,
'');
3232 print
'/wrapper.php?rss=1[&l=XX][&limit=123]';
3245 if ($action ==
'createsite')
3247 print
'<div class="fiche">';
3261 if ($action ==
'createcontainer') print
load_fiche_titre($langs->trans(
"AddSite"));
3263 print
'<!-- Add site -->'.
"\n";
3266 print
'<table class="border centpercent">';
3268 $siteref = $sitedesc = $sitelang = $siteotherlang =
'';
3269 if (
GETPOST(
'WEBSITE_REF')) $siteref =
GETPOST(
'WEBSITE_REF',
'alpha');
3270 if (
GETPOST(
'WEBSITE_DESCRIPTION')) $sitedesc =
GETPOST(
'WEBSITE_DESCRIPTION',
'alpha');
3271 if (
GETPOST(
'WEBSITE_LANG')) $sitelang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
3272 if (
GETPOST(
'WEBSITE_OTHERLANG')) $siteotherlang =
GETPOST(
'WEBSITE_OTHERLANG',
'aZ09comma');
3274 print
'<tr><td class="titlefieldcreate fieldrequired">';
3275 print $form->textwithpicto($langs->trans(
'WebSite'), $langs->trans(
"Example").
': www.mywebsite.com, myportal, ...');
3277 print
'<input type="text" class="flat maxwidth300" name="WEBSITE_REF" value="'.dol_escape_htmltag($siteref).
'" autofocus>';
3280 print
'<tr><td class="fieldrequired">';
3281 print $langs->trans(
'MainLanguage');
3283 $shortlangcode = preg_replace(
'/[_-].*$/',
'', trim($langs->defaultlang));
3284 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);
3288 print $langs->trans(
'Description');
3290 print
'<input type="text" class="flat minwidth500" name="WEBSITE_DESCRIPTION" value="'.dol_escape_htmltag($sitedesc).
'">';
3294 $htmltext = $langs->trans(
"Example").
': fr,de,sv,it,pt';
3295 print $form->textwithpicto($langs->trans(
'OtherLanguages'), $htmltext, 1,
'help',
'', 0, 2);
3297 print
'<input type="text" class="flat minwidth300" name="WEBSITE_OTHERLANG" value="'.dol_escape_htmltag($siteotherlang).
'">';
3302 $htmltext = $langs->trans(
"SetHereVirtualHost",
'{s1}');
3303 $htmltext = str_replace(
'{s1}', DOL_DATA_ROOT.
'/website/<i>websiteref</i>', $htmltext);
3304 $htmltext .=
'<br>';
3305 $htmltext .=
'<br>'.$langs->trans(
"CheckVirtualHostPerms", $langs->transnoentitiesnoconv(
"ReadPerm"), DOL_DOCUMENT_ROOT);
3306 $htmltext .=
'<br>'.$langs->trans(
"CheckVirtualHostPerms", $langs->transnoentitiesnoconv(
"WritePerm"),
'{s1}');
3307 $htmltext = str_replace(
'{s1}', DOL_DATA_ROOT.
'/website<br>'.DOL_DATA_ROOT.
'/medias', $htmltext);
3309 print $form->textwithpicto($langs->trans(
'Virtualhost'), $htmltext, 1,
'help',
'', 0, 2,
'virtualhosttooltip');
3311 print
'<input type="text" class="flat minwidth300" name="virtualhost" value="'.dol_escape_htmltag(
GETPOST(
'virtualhost',
'alpha')).
'">';
3317 if ($action ==
'createsite')
3319 print
'<div class="center">';
3321 print
'<input class="button" type="submit" name="addcontainer" value="'.$langs->trans(
"Create").
'">';
3322 print
'<input class="button button-cancel" type="submit" name="preview" value="'.$langs->trans(
"Cancel").
'">';
3337 if ($action ==
'importsite')
3339 print
'<div class="fiche">';
3347 print
'<span class="opacitymedium">'.$langs->trans(
"ZipOfWebsitePackageToImport").
'</span><br><br>';
3349 print
'<input type="hidden" name="max_file_size" value="'.$conf->maxfilesize.
'">';
3350 print
'<input class="flat minwidth400" type="file" name="userfile[]" accept=".zip">';
3351 print
'<input type="submit" class="button" name="buttonsubmitimportfile" value="'.dol_escape_htmltag($langs->trans(
"Upload")).
'">';
3352 print
'<input type="submit" class="button button-cancel" name="preview" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
3354 print
'<br><br><br>';
3357 print
'<span class="opacitymedium">'.$langs->trans(
"ZipOfWebsitePackageToLoad").
'</span><br><br>';
3368 if ($action ==
'editmeta' || $action ==
'createcontainer')
3370 print
'<div class="fiche">';
3384 if ($action ==
'createcontainer') print
load_fiche_titre($langs->trans(
"AddPage"));
3386 print
'<!-- Edit or create page/container -->'.
"\n";
3389 $hiddenfromfetchingafterload =
' hideobject';
3390 $hiddenmanuallyafterload =
' hideobject';
3391 if (
GETPOST(
'radiocreatefrom') ==
'checkboxcreatefromfetching') $hiddenfromfetchingafterload =
'';
3392 if (
GETPOST(
'radiocreatefrom') ==
'checkboxcreatemanually') $hiddenmanuallyafterload =
'';
3394 if ($action ==
'editmeta' || empty($conf->use_javascript_ajax)) {
3395 $hiddenfromfetchingafterload =
'';
3396 $hiddenmanuallyafterload =
'';
3399 if ($action ==
'createcontainer')
3403 if (!empty($conf->use_javascript_ajax)) print
'<input type="radio" name="radiocreatefrom" id="checkboxcreatefromfetching" value="checkboxcreatefromfetching"'.(
GETPOST(
'radiocreatefrom') ==
'checkboxcreatefromfetching' ?
' checked' :
'').
'> ';
3404 print
'<label for="checkboxcreatefromfetching"><span class="opacitymediumxx">'.$langs->trans(
"CreateByFetchingExternalPage").
'</span></label><br>';
3405 print
'<hr class="tablecheckboxcreatefromfetching'.$hiddenfromfetchingafterload.
'">';
3406 print
'<table class="tableforfield centpercent tablecheckboxcreatefromfetching'.$hiddenfromfetchingafterload.
'">';
3407 print
'<tr><td class="titlefield">';
3408 print $langs->trans(
"URL");
3410 print
info_admin($langs->trans(
"OnlyEditionOfSourceForGrabbedContentFuture"), 0, 0,
'warning');
3411 print
'<input class="flat minwidth500" type="text" name="externalurl" value="'.dol_escape_htmltag(
GETPOST(
'externalurl',
'alpha')).
'" placeholder="https://externalsite/pagetofetch"> ';
3412 print
'<br><input class="flat paddingtop" type="checkbox" name="grabimages" value="1" checked="checked"> '.$langs->trans(
"GrabImagesInto");
3414 print $langs->trans(
"ImagesShouldBeSavedInto").
' ';
3415 $arraygrabimagesinto = array(
'root'=>$langs->trans(
"WebsiteRootOfImages"),
'subpage'=>$langs->trans(
"SubdirOfPage"));
3416 print $form->selectarray(
'grabimagesinto', $arraygrabimagesinto,
GETPOSTISSET(
'grabimagesinto') ?
GETPOST(
'grabimagesinto') :
'root', 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
3418 print
'<input class="button" style="margin-top: 5px" type="submit" name="fetchexternalurl" value="'.dol_escape_htmltag($langs->trans(
"FetchAndCreate")).
'">';
3424 if (!empty($conf->use_javascript_ajax)) print
'<input type="radio" name="radiocreatefrom" id="checkboxcreatemanually" value="checkboxcreatemanually"'.(
GETPOST(
'radiocreatefrom') ==
'checkboxcreatemanually' ?
' checked' :
'').
'> ';
3425 print
'<label for="checkboxcreatemanually"><span class="opacitymediumxx">'.$langs->trans(
"OrEnterPageInfoManually").
'</span></label><br>';
3426 print
'<hr class="tablecheckboxcreatemanually'.$hiddenmanuallyafterload.
'">';
3429 print
'<table class="border tableforfield nobackground centpercent tablecheckboxcreatemanually'.$hiddenmanuallyafterload.
'">';
3431 if ($action !=
'createcontainer')
3433 print
'<tr><td class="titlefield fieldrequired">';
3434 print $langs->trans(
'IDOfPage').
' - '.$langs->trans(
'InternalURLOfPage');
3442 print
' - ';
3443 print
'/public/website/index.php?website='.urlencode($websitekey).
'&pageid='.urlencode($pageid);
3447 $type_container = $objectpage->type_container;
3448 $pageurl = $objectpage->pageurl;
3449 $pagealiasalt = $objectpage->aliasalt;
3450 $pagetitle = $objectpage->title;
3451 $pagedescription = $objectpage->description;
3452 $pageimage = $objectpage->image;
3453 $pagekeywords = $objectpage->keywords;
3454 $pagelang = $objectpage->lang;
3455 $pageallowedinframes = $objectpage->allowed_in_frames;
3456 $pagehtmlheader = $objectpage->htmlheader;
3457 $pagedatecreation = $objectpage->date_creation;
3458 $pagedatemodification = $objectpage->date_modification;
3459 $pageauthorid = $objectpage->fk_user_creat;
3460 $pageusermodifid = $objectpage->fk_user_modif;
3461 $pageauthoralias = $objectpage->author_alias;
3462 $pagestatus = $objectpage->status;
3465 $type_container =
'page';
3466 $pagedatecreation =
dol_now();
3467 $pageauthorid = $user->id;
3468 $pageusermodifid = 0;
3469 $pageauthoralias =
'';
3472 if (
GETPOST(
'WEBSITE_TITLE',
'alpha')) $pagetitle = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_TITLE',
'alphanohtml'));
3473 if (
GETPOST(
'WEBSITE_PAGENAME',
'alpha')) $pageurl =
GETPOST(
'WEBSITE_PAGENAME',
'alpha');
3474 if (
GETPOST(
'WEBSITE_ALIASALT',
'alpha')) $pagealiasalt = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_ALIASALT',
'alphanohtml'));
3475 if (
GETPOST(
'WEBSITE_DESCRIPTION',
'alpha')) $pagedescription = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml'));
3476 if (
GETPOST(
'WEBSITE_IMAGE',
'alpha')) $pageimage =
GETPOST(
'WEBSITE_IMAGE',
'alpha');
3477 if (
GETPOST(
'WEBSITE_KEYWORDS',
'alpha')) $pagekeywords = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_KEYWORDS',
'alphanohtml'));
3478 if (
GETPOST(
'WEBSITE_LANG',
'aZ09')) $pagelang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
3479 if (
GETPOST(
'WEBSITE_ALLOWED_IN_FRAMES',
'aZ09')) $pageallowedinframes =
GETPOST(
'WEBSITE_ALLOWED_IN_FRAMES',
'aZ09');
3480 if (
GETPOST(
'htmlheader',
'none')) $pagehtmlheader =
GETPOST(
'htmlheader',
'none');
3482 if ($action !=
'createcontainer')
3484 print
'<!-- Status of page -->'.
"\n";
3485 print
'<tr><td class="fieldrequired">';
3486 print $langs->trans(
'Status');
3488 print
ajax_object_onoff($objectpage,
'status',
'status',
'Enabled',
'Disabled');
3494 print
'<tr><td class="titlefield fieldrequired">';
3495 print $langs->trans(
'WEBSITE_TYPE_CONTAINER');
3497 print
img_picto(
'',
'object_technic',
'class="paddingrightonly"').
' ';
3498 $formwebsite->selectTypeOfContainer(
'WEBSITE_TYPE_CONTAINER', (
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'alpha') ?
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'alpha') : $type_container), 0,
'', 1);
3501 if ($action ==
'createcontainer')
3503 print
'<tr><td class="titlefield fieldrequired">';
3504 print $langs->trans(
'WEBSITE_PAGE_EXAMPLE');
3506 print $formwebsite->selectSampleOfContainer(
'sample', (
GETPOSTISSET(
'sample') ?
GETPOST(
'sample',
'alpha') :
'empty'), 0,
'', 1);
3511 print
'<tr><td class="fieldrequired">';
3512 print $langs->trans(
'WEBSITE_TITLE');
3514 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_TITLE" id="WEBSITE_TITLE" value="'.dol_escape_htmltag($pagetitle).
'" autofocus>';
3518 print
'<tr><td class="titlefieldcreate fieldrequired">';
3519 print $langs->trans(
'WEBSITE_PAGENAME');
3521 print
'<input type="text" class="flat minwidth300" name="WEBSITE_PAGENAME" id="WEBSITE_PAGENAME" value="'.dol_escape_htmltag($pageurl).
'">';
3524 print
'<tr><td class="titlefieldcreate">';
3525 $htmlhelp = $langs->trans(
"WEBSITE_ALIASALTDesc");
3526 print $form->textwithpicto($langs->trans(
'WEBSITE_ALIASALT'), $htmlhelp, 1,
'help',
'', 0, 2,
'aliastooltip');
3528 print
'<input type="text" class="flat minwidth500" name="WEBSITE_ALIASALT" value="'.dol_escape_htmltag($pagealiasalt).
'">';
3532 print $langs->trans(
'WEBSITE_DESCRIPTION');
3534 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_DESCRIPTION" value="'.dol_escape_htmltag($pagedescription).
'">';
3538 $htmlhelp = $langs->trans(
"WEBSITE_IMAGEDesc");
3539 print $form->textwithpicto($langs->trans(
'WEBSITE_IMAGE'), $htmlhelp, 1,
'help',
'', 0, 2,
'imagetooltip');
3541 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_IMAGE" value="'.dol_escape_htmltag($pageimage).
'">';
3546 $htmlhelp = $langs->trans(
"WEBSITE_KEYWORDSDesc");
3547 print $form->textwithpicto($langs->trans(
'WEBSITE_KEYWORDS'), $htmlhelp, 1,
'help',
'', 0, 2,
'keywordtooltip');
3549 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_KEYWORDS" value="'.dol_escape_htmltag($pagekeywords).
'">';
3553 print $langs->trans(
'Language');
3555 $onlykeys = array();
3556 if ($object->lang) $onlykeys[$object->lang] = $object->lang;
3557 else $onlykeys[$langs->defaultlang] = $langs->defaultlang;
3558 if ($object->otherlang) {
3559 $tmparray = explode(
',', $object->otherlang);
3560 foreach ($tmparray as $key) {
3561 $tmpkey = trim($key);
3562 if (strlen($key) == 2) {
3563 $tmpkey = strtolower($key);
3565 $onlykeys[$tmpkey] = $tmpkey;
3568 if (empty($object->lang) && empty($object->otherlang)) {
3571 print $formadmin->select_language($pagelang ? $pagelang :
'',
'WEBSITE_LANG', 0, null,
'1', 0, 0,
'minwidth200', 0, 0, 0, $onlykeys, 1);
3572 $htmltext = $langs->trans(
"AvailableLanguagesAreDefinedIntoWebsiteProperties");
3573 print $form->textwithpicto(
'', $htmltext);
3579 print
'<!-- Translation of --><tr><td>';
3580 print $langs->trans(
'TranslationLinks');
3582 if ($action !=
'createcontainer')
3585 $sql =
'SELECT rowid, lang from '.MAIN_DB_PREFIX.
'website_page where fk_page = '.$objectpage->id;
3586 $resql = $db->query($sql);
3589 $num_rows = $db->num_rows(
$resql);
3592 print
'<span class="opacitymedium">'.$langs->trans(
'ThisPageHasTranslationPages').
':</span>';
3596 while ($obj = $db->fetch_object(
$resql))
3598 $result = $tmppage->fetch($obj->rowid);
3600 if ($i > 0) $tmpstring .=
'<br>';
3601 $tmpstring .= $tmppage->getNomUrl(1).
' ('.$tmppage->lang.
')';
3606 if ($i > 1) print
'<br>';
3613 if (empty($translatedby) && ($action ==
'editmeta' || $action ==
'createcontainer' || $objectpage->fk_page > 0))
3616 $result = $sourcepage->fetch($objectpage->fk_page);
3621 elseif ($result > 0)
3623 $translationof = $objectpage->fk_page;
3624 print
'<span class="opacitymedium">'.$langs->trans(
'ThisPageIsTranslationOf').
'</span> ';
3625 print $formwebsite->selectContainer($website,
'pageidfortranslation', ($translationof ? $translationof : -1), 1, $action,
'minwidth300', array($objectpage->id));
3626 if ($translationof > 0 && $sourcepage->lang) {
3627 print $sourcepage->getNomUrl(2).
' ('.$sourcepage->lang.
')';
3635 print $langs->trans(
'AllowedInFrames');
3639 print
'<input type="checkbox" class="flat" name="WEBSITE_ALLOWED_IN_FRAMES" value="1"'.($pageallowedinframes ?
'checked="checked"' :
'').
'>';
3643 if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire))
3645 $langs->load(
'categories');
3648 $cate_arbo = $form->select_all_categories(Categorie::TYPE_WEBSITE_PAGE,
'', null, null, null, 1);
3650 $cats = $c->containing($objectpage->id, Categorie::TYPE_WEBSITE_PAGE);
3651 $arrayselected = array();
3652 if (is_array($cats)) {
3653 foreach ($cats as $cat) {
3654 $arrayselected[] = $cat->id;
3658 $cate_arbo = $form->select_all_categories(Categorie::TYPE_WEBSITE_PAGE,
'',
'parent', null, null, 1);
3661 print
'<tr><td class="toptd">'.$form->editfieldkey(
'Categories',
'categories',
'', $objectpage, 0).
'</td><td>';
3662 print
img_picto(
'',
'category',
'class="paddingright"');
3663 print $form->multiselectarray(
'categories', $cate_arbo, (
GETPOSTISSET(
'categories') ?
GETPOST(
'categories',
'array') : $arrayselected), null, null,
'minwidth200 widthcentpercentminusxx');
3667 if (!empty($conf->global->WEBSITE_PAGE_SHOW_INTERNAL_LINKS_TO_OBJECT)) {
3668 print
'<tr><td class="titlefieldcreate">';
3669 print
'ObjectClass';
3671 print
'<input type="text" class="flat minwidth300" name="WEBSITE_OBJECTCLASS" placeholder="ClassName::/path/class/ObjectClass.class.php" >';
3674 print
'<tr><td class="titlefieldcreate">';
3677 print
'<input type="text" class="flat minwidth300" name="WEBSITE_OBJECTID" >';
3681 $fuser =
new User($db);
3684 print $langs->trans(
'Author');
3686 if ($pageauthorid > 0)
3688 $fuser->fetch($pageauthorid);
3689 print $fuser->getNomUrl(1);
3691 print
'<span class="opacitymedium">'.$langs->trans(
"Unknown").
'</span>';
3696 print $langs->trans(
'PublicAuthorAlias');
3698 print
'<input type="text" class="flat minwidth300" name="WEBSITE_AUTHORALIAS" value="'.dol_escape_htmltag($pageauthoralias).
'">';
3702 print $langs->trans(
'DateCreation');
3704 print $form->selectDate($pagedatecreation,
'datecreation', 1, 1, 0,
'', 1, 1);
3708 if ($action !=
'createcontainer')
3711 print $langs->trans(
'UserModif');
3713 if ($pageusermodifid > 0)
3715 $fuser->fetch($pageusermodifid);
3716 print $fuser->getNomUrl(1);
3721 print $langs->trans(
'DateModification');
3723 print
dol_print_date($pagedatemodification,
'dayhour',
'tzuser');
3727 print
'<tr><td class="tdhtmlheader tdtop">';
3728 $htmlhelp = $langs->trans(
"EditTheWebSiteForACommonHeader").
'<br><br>';
3729 $htmlhelp .= $langs->trans(
"Example").
' :<br>';
3731 print $form->textwithpicto($langs->trans(
'HtmlHeaderPage'), $htmlhelp, 1,
'help',
'', 0, 2,
'htmlheadertooltip');
3733 $doleditor =
new DolEditor(
'htmlheader', $pagehtmlheader,
'',
'120',
'ace',
'In',
true,
false,
'ace', ROWS_3,
'100%',
'');
3734 print $doleditor->Create(1,
'',
true,
'HTML Header',
'html');
3738 if ($action ==
'createcontainer')
3740 print
'<div class="center tablecheckboxcreatemanually'.$hiddenmanuallyafterload.
'">';
3742 print
'<input class="button" type="submit" name="addcontainer" value="'.$langs->trans(
"Create").
'">';
3743 print
'<input class="button button-cancel" type="submit" name="preview" value="'.$langs->trans(
"Cancel").
'">';
3748 if ($action ==
'createcontainer')
3750 print
'<script type="text/javascript" language="javascript">
3751 jQuery(document).ready(function() {
3752 var disableautofillofalias = 0;
3753 jQuery("#WEBSITE_TITLE").keyup(function() {
3754 if (disableautofillofalias == 0)
3756 var valnospecial = jQuery("#WEBSITE_TITLE").val();
3757 valnospecial = valnospecial.replace(/[éèê]/g, \'e\').replace(/[à ]/g, \'a\').replace(/[ù]/g, \'u\').replace(/[î]/g, \'i\');
3758 valnospecial = valnospecial.replace(/[ç]/g, \'c\').replace(/[ö]/g, \'o\');
3759 valnospecial = valnospecial.replace(/[^\w]/gi, \'-\').toLowerCase();
3760 valnospecial = valnospecial.replace(/\-+/g, \'-\').replace(/\-$/, \'\');
3761 console.log("disableautofillofalias=0 so we replace WEBSITE_TITLE with "+valnospecial);
3762 jQuery("#WEBSITE_PAGENAME").val(valnospecial);
3765 jQuery("#WEBSITE_PAGENAME").keyup(function() {
3766 disableautofillofalias = 1;
3769 jQuery("#checkboxcreatefromfetching,#checkboxcreatemanually").change(function() {
3770 console.log("we select a method to create a new container"+jQuery("#checkboxcreatefromfetching:checked").val())
3771 if (typeof(jQuery("#checkboxcreatefromfetching:checked").val()) != \'undefined\')
3773 jQuery(".tablecheckboxcreatefromfetching").show();
3774 jQuery(".tablecheckboxcreatemanually").hide();
3776 if (typeof(jQuery("#checkboxcreatemanually:checked").val()) != \'undefined\')
3778 jQuery(".tablecheckboxcreatefromfetching").hide();
3779 jQuery(".tablecheckboxcreatemanually").show();
3794 if ($action ==
'editfile' || $action ==
'file_manager')
3796 print
'<!-- Edit Media -->'.
"\n";
3797 print
'<div class="fiche"><br>';
3801 if (empty($url)) $url = DOL_URL_ROOT.
'/website/index.php';
3802 include DOL_DOCUMENT_ROOT.
'/core/tpl/filemanager.tpl.php';
3807 if ($action ==
'editmenu')
3809 print
'<!-- Edit Menu -->'.
"\n";
3810 print
'<div class="center">'.$langs->trans(
"FeatureNotYetAvailable").
'</center>';
3813 if ($action ==
'editsource')
3817 $contentforedit =
'';
3821 $contentforedit .= $objectpage->content;
3823 $maxheightwin = 480;
3824 if (isset($_SESSION[
"dol_screenheight"]))
3826 if ($_SESSION[
"dol_screenheight"] > 680) $maxheightwin = $_SESSION[
"dol_screenheight"] - 400;
3827 if ($_SESSION[
"dol_screenheight"] > 800) $maxheightwin = $_SESSION[
"dol_screenheight"] - 490;
3830 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
3831 $doleditor =
new DolEditor(
'PAGE_CONTENT', $contentforedit,
'', $maxheightwin,
'Full',
'',
true,
true,
'ace', ROWS_5,
'40%');
3832 $doleditor->Create(0,
'',
false,
'HTML Source',
'php');
3856 if ($action ==
'replacesite' || $action ==
'replacesiteconfirm' || $massaction ==
'replace')
3858 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3859 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3860 print
'<input type="hidden" name="action" value="replacesiteconfirm">';
3861 print
'<input type="hidden" name="website" value="'.$website->ref.
'">';
3864 print
'<!-- Search page and replace string -->'.
"\n";
3865 print
'<div class="fiche"><br>';
3867 print
load_fiche_titre($langs->trans(
"ReplaceWebsiteContent"),
'',
'search');
3869 print
'<div class="fichecenter"><div class="fichehalfleft">';
3871 print
'<div class="tagtable">';
3873 print
'<div class="tagtr">';
3874 print
'<div class="tagtd paddingrightonly opacitymedium">';
3875 print $langs->trans(
"SearchReplaceInto");
3877 print
'<div class="tagtd">';
3878 print
'<input type="checkbox" class="marginleftonly" name="optioncontent" value="content"'.((!
GETPOSTISSET(
'buttonreplacesitesearch') ||
GETPOST(
'optioncontent',
'aZ09')) ?
' checked' :
'').
'> '.$langs->trans(
"Content").
'<br>';
3879 print
'<input type="checkbox" class="marginleftonly" name="optionmeta" value="meta"'.(GETPOST(
'optionmeta',
'aZ09') ?
' checked' :
'').
'> '.$langs->trans(
"Title").
' | '.$langs->trans(
"Description").
' | '.$langs->trans(
"Keywords").
'<br>';
3880 print
'<input type="checkbox" class="marginleftonly" name="optionsitefiles" value="sitefiles"'.(GETPOST(
'optionsitefiles',
'aZ09') ?
' checked' :
'').
'> '.$langs->trans(
"GlobalCSSorJS").
'<br>';
3884 print
'<div class="tagtr">';
3885 print
'<div class="tagtd paddingrightonly opacitymedium" style="padding-right: 10px !important">';
3886 print $langs->trans(
"SearchString");
3888 print
'<div class="tagtd">';
3889 print
'<input type="text" name="searchstring" value="'.dol_escape_htmltag($searchkey, 0, 0,
'', 1).
'" autofocus>';
3895 print
'</div><div class="fichehalfleft">';
3897 print
'<div class="tagtable">';
3899 print
'<div class="tagtr">';
3900 print
'<div class="tagtd paddingrightonly opacitymedium" style="padding-right: 10px !important">';
3901 print $langs->trans(
"WEBSITE_TYPE_CONTAINER");
3903 print
'<div class="tagtd">';
3904 print
img_picto(
'',
'object_technic',
'class="paddingrightonly"').
' ';
3905 $formwebsite->selectTypeOfContainer(
'optioncontainertype', (
GETPOST(
'optioncontainertype',
'alpha') ?
GETPOST(
'optioncontainertype',
'alpha') :
''), 1);
3909 print
'<div class="tagtr">';
3910 print
'<div class="tagtd paddingrightonly opacitymedium" style="padding-right: 10px !important">';
3911 print $langs->trans(
"Language");
3913 print
'<div class="tagtd">';
3914 print
img_picto(
'',
'language',
'class="paddingrightonly"').
' '.$formadmin->select_language(
GETPOSTISSET(
'optionlanguage') ?
GETPOST(
'optionlanguage') :
'',
'optionlanguage', 0, null,
'1', 0, 0,
'minwidth300', 2, 0, 0, null, 1);
3919 if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire))
3921 print
'<div class="tagtr">';
3922 print
'<div class="tagtd paddingrightonly marginrightonly opacitymedium" style="padding-right: 10px !important">';
3923 print $langs->trans(
"Category");
3925 print
'<div class="tagtd">';
3926 print
img_picto(
'',
'category',
'class="paddingrightonly"').
' '.$form->select_all_categories(Categorie::TYPE_WEBSITE_PAGE,
GETPOSTISSET(
'optioncategory') ?
GETPOST(
'optioncategory') :
'',
'optioncategory', null, null);
3927 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
3935 print
'<input type="submit" class="button" name="buttonreplacesitesearch" value="'.dol_escape_htmltag($langs->trans(
"Search")).
'">';
3937 print
'</div></div>';
3939 if ($action ==
'replacesiteconfirm')
3941 print
'<!-- List of search result -->'.
"\n";
3942 print
'<div class="rowsearchresult clearboth">';
3947 if ($listofpages[
'code'] ==
'OK')
3949 $arrayofselected = is_array($toselect) ? $toselect : array();
3951 $nbtotalofrecords = count($listofpages[
'list']);
3953 $permissiontodelete = $user->rights->website->delete;
3956 $arrayofmassactions = array();
3957 if ($user->rights->website->writephp && $searchkey) $arrayofmassactions[
'replace'] = $langs->trans(
"Replace");
3958 if ($user->rights->website->write) $arrayofmassactions[
'setcategory'] = $langs->trans(
"ClassifyInCategory");
3959 if ($permissiontodelete) $arrayofmassactions[
'predelete'] =
'<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans(
"Delete");
3960 if (
GETPOST(
'nomassaction',
'int') || in_array($massaction, array(
'presend',
'predelete'))) $arrayofmassactions = array();
3962 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
3963 $massactionbutton .=
'<div class="massactionother massactionreplace hidden">';
3964 $massactionbutton .= $langs->trans(
"ReplaceString");
3965 $massactionbutton .=
' <input type="text" name="replacestring" value="'.dol_escape_htmltag(
GETPOST(
'replacestring',
'none')).
'">';
3966 $massactionbutton .=
'</div>';
3967 $massactionbutton .=
'<div class="massactionother massactionsetcategory hidden">';
3968 $massactionbutton .= $langs->trans(
"Category");
3969 $massactionbutton .=
' '.$form->select_all_categories(Categorie::TYPE_WEBSITE_PAGE,
GETPOSTISSET(
'setcategory') ?
GETPOST(
'setcategory') :
'',
'setcategory', 64, 0, 0, 0,
'minwidth300 alignstart');
3970 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
3972 $massactionbutton .=
'</div>';
3974 $varpage = empty($contextpage) ?
$_SERVER[
"PHP_SELF"] : $contextpage;
3976 $selectedfields .= $form->showCheckAddButtons(
'checkforselect', 1);
3978 print_barre_liste($langs->trans(
"Results"), $page,
$_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'generic', 0,
'',
'', $limit, 1, 1, 1);
3980 $topicmail =
"WebsitePageRef";
3981 $modelmail =
"websitepage_send";
3983 $trackid =
'wsp'.$object->id;
3984 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
3986 $param =
'action=replacesiteconfirm&website='.urlencode($website->ref);
3987 $param .=
'&searchstring='.urlencode($searchkey);
3988 if (
GETPOST(
'optioncontent')) $param .=
'&optioncontent=content';
3989 if (
GETPOST(
'optionmeta')) $param .=
'&optionmeta=meta';
3990 if (
GETPOST(
'optionsitefiles')) $param .=
'&optionsitefiles=optionsitefiles';
3991 if (
GETPOST(
'optioncontainertype')) $param .=
'&optioncontainertype='.GETPOST(
'optioncontainertype',
'aZ09');
3992 if (
GETPOST(
'optionlanguage')) $param .=
'&optionlanguage='.GETPOST(
'optionlanguage',
'aZ09');
3993 if (
GETPOST(
'optioncategory')) $param .=
'&optioncategory='.GETPOST(
'optioncategory',
'aZ09');
3995 print
'<div class="div-table-responsive-no-min">';
3996 print
'<table class="noborder centpercent">';
3997 print
'<tr class="liste_titre">';
3998 print
getTitleFieldOfList(
"Type", 0, $_SERVER[
'PHP_SELF'],
'type_container',
'', $param,
'', $sortfield, $sortorder,
'').
"\n";
3999 print
getTitleFieldOfList(
"Page", 0, $_SERVER[
'PHP_SELF'],
'pageurl',
'', $param,
'', $sortfield, $sortorder,
'').
"\n";
4004 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
4007 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
4012 foreach ($listofpages[
'list'] as $answerrecord)
4014 if (get_class($answerrecord) ==
'WebsitePage')
4019 print
'<td class="nowraponall">'.$langs->trans(
"Container").
' - ';
4020 print $langs->trans($answerrecord->type_container);
4025 print $answerrecord->getNomUrl(1);
4026 print
' <span class="opacitymedium">('.($answerrecord->title ? $answerrecord->title : $langs->trans(
"NoTitle")).
')</span>';
4030 print
'<span class="opacitymedium">'.$answerrecord->description.
'</span>';
4035 if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire))
4038 $existing = $c->containing($answerrecord->id, Categorie::TYPE_WEBSITE_PAGE,
'object');
4039 if (is_array($existing)) {
4040 foreach ($existing as $tmpcategory) {
4042 print
img_object($langs->trans(
"Category").
' : '.$tmpcategory->label,
'category',
'style="padding-left: 2px; padding-right: 2px; color: #'.($tmpcategory->color !=
'' ? $tmpcategory->color :
'888').
'"');
4050 $param =
'?action=replacesiteconfirm';
4051 $param .=
'&websiteid='.$website->id;
4052 $param .=
'&optioncontent='.GETPOST(
'optioncontent',
'aZ09');
4053 $param .=
'&optionmeta='.GETPOST(
'optionmeta',
'aZ09');
4054 $param .=
'&optionsitefiles='.GETPOST(
'optionsitefiles',
'aZ09');
4055 $param .=
'&optioncontainertype='.GETPOST(
'optioncontainertype',
'aZ09');
4056 $param .=
'&optionlanguage='.GETPOST(
'optionlanguage',
'aZ09');
4057 $param .=
'&optioncategory='.GETPOST(
'optioncategory',
'aZ09');
4058 $param .=
'&searchstring='.urlencode($searchkey);
4062 print $answerrecord->lang;
4066 print
'<td class="center nowraponall">';
4068 $characterMap =
'áà éèëÃóúüñùç0123456789';
4069 $nbofwords = str_word_count($textwithouthtml, 0, $characterMap);
4071 print $nbofwords.
' '.$langs->trans(
"words");
4072 $totalnbwords += $nbofwords;
4078 print
'<td class="tdwebsitesearchresult right nowraponall">';
4080 $urltoedithtmlsource = $_SERVER[
"PHP_SELF"].
'?action=editmeta&websiteid='.$website->id.
'&pageid='.$answerrecord->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].$param);
4081 if (empty($user->rights->website->write)) {
4082 $disabled =
' disabled';
4083 $urltoedithtmlsource =
'';
4085 print
'<a class="editfielda marginleftonly marginrightonly '.$disabled.
'" href="'.$urltoedithtmlsource.
'" title="'.$langs->trans(
"EditPageMeta").
'">'.
img_picto($langs->trans(
"EditPageMeta"),
'pencil-ruler').
'</a>';
4088 $urltoedithtmlsource = $_SERVER[
"PHP_SELF"].
'?action=editsource&websiteid='.$website->id.
'&pageid='.$answerrecord->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].$param);
4089 if (empty($user->rights->website->write)) {
4090 $disabled =
' disabled';
4091 $urltoedithtmlsource =
'';
4093 print
'<a class="editfielda marginleftonly marginrightonly '.$disabled.
'" href="'.$urltoedithtmlsource.
'" title="'.$langs->trans(
"EditHTMLSource").
'">'.
img_picto($langs->trans(
"EditHTMLSource"),
'edit').
'</a>';
4095 print
'<span class="marginleftonly marginrightonly"></span>'.ajax_object_onoff($answerrecord,
'status',
'status',
'Enabled',
'Disabled');
4100 print
'<td class="nowrap center">';
4102 print
'<!-- Status of page -->'.
"\n";
4103 if ($massactionbutton || $massaction)
4106 if (in_array($answerrecord->id, $arrayofselected)) $selected = 1;
4107 print
'<input id="'.$answerrecord->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$answerrecord->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
4117 $translateofrecordtype = array(
4118 'website_csscontent'=>
'WEBSITE_CSS_INLINE',
4119 'website_jscontent'=>
'WEBSITE_JS_INLINE',
4120 'website_robotcontent'=>
'WEBSITE_ROBOT',
4121 'website_htmlheadercontent'=>
'WEBSITE_HTML_HEADER',
4122 'website_htaccess'=>
'WEBSITE_HTACCESS',
4123 'website_readme'=>
'WEBSITE_README',
4124 'website_manifestjson'=>
'WEBSITE_MANIFEST_JSON'
4126 if (!empty($translateofrecordtype[$answerrecord[
'type']])) {
4127 print $langs->trans($translateofrecordtype[$answerrecord[
'type']]);
4129 print $answerrecord[
'type'];
4133 $param =
'?action=replacesiteconfirm';
4134 $param .=
'&websiteid='.$website->id;
4135 $param .=
'&optioncontent='.GETPOST(
'optioncontent',
'aZ09');
4136 $param .=
'&optionmeta='.GETPOST(
'optionmeta',
'aZ09');
4137 $param .=
'&optionsitefiles='.GETPOST(
'optionsitefiles',
'aZ09');
4138 $param .=
'&optioncontainertype='.GETPOST(
'optioncontainertype',
'aZ09');
4139 $param .=
'&optionlanguage='.GETPOST(
'optionlanguage',
'aZ09');
4140 $param .=
'&optioncategory='.GETPOST(
'optioncategory',
'aZ09');
4141 $param .=
'&searchstring='.urlencode($searchkey);
4145 $backtopageurl = $_SERVER[
"PHP_SELF"].$param;
4146 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=editcss&website='.$website->ref.
'&backtopage='.urlencode($backtopageurl).
'">'.$langs->trans(
"EditCss").
'</a>';
4166 print
'<td class="nowrap center">';
4173 if (count($listofpages[
'list']) >= 2) {
4175 print
'<tr class="lite_titre">';
4179 print $langs->trans(
"Total");
4195 print
'<td class="center nowraponall">';
4196 print $totalnbwords.
' '.$langs->trans(
"words");
4204 print
'<td class="nowrap center">';
4215 print
'<div class="warning">'.$listofpages[
'message'].
'</div>';
4224 if ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone')
4226 if ($pageid > 0 && $atleastonepage)
4233 $objectpage->fetch($pageid);
4235 $jscontent = @file_get_contents($filejs);
4237 $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";
4246 $out .=
"\n<html><head>\n";
4247 $out .=
"<!-- htmlheader/style of page from database -->\n";
4250 $out .=
"<!-- htmlheader/style of website from files -->\n";
4268 $out .=
"</head>\n";
4272 $out .=
'<div id="websitecontentundertopmenu" class="websitecontentundertopmenu boostrap-iso">'.
"\n";
4276 $out .=
'<!-- style of website from file -->'.
"\n";
4277 $out .=
'<style scoped>'.
"\n";
4279 $tmpout .=
'/* Include website CSS file */'.
"\n";
4283 $csscontent = ob_get_contents();
4286 $tmpout .=
'/* Include style from the HTML header of page */'.
"\n";
4288 $tmp = preg_split(
'(<style[^>]*>|</style>)', $objectpage->htmlheader);
4289 $tmpstyleinheader =
'';
4291 foreach ($tmp as $valtmp)
4294 if ($i % 2 == 0) $tmpstyleinheader .= $valtmp.
"\n";
4296 $tmpout .= $tmpstyleinheader.
"\n";
4298 $tmpout = preg_replace(
'/}[\s\n]*body\s*{[^}]+}/ims',
'}', $tmpout);
4300 $out .=
'</style>'.
"\n";
4307 $out .=
'<div id="divbodywebsite" class="bodywebsite bodywebpage-'.$objectpage->ref.
'">'.
"\n";
4309 $newcontent = $objectpage->content;
4312 if (!empty($conf->global->WEBSITE_SUBCONTAINERSINLINE))
4317 $filephp = $filetpl;
4320 $res = include $filephp;
4322 print
"ERROR: Failed to include file '".$filephp.
"'. Try to edit and save page.";
4326 print $e->getMessage();
4328 $newcontent = ob_get_contents();
4333 if (empty($conf->global->WEBSITE_EDITINLINE))
4336 $newcontent = preg_replace(
'/(div|section)(\s[^>]*)contenteditable="true"/',
'\1\2', $newcontent);
4346 $out .=
'</div> <!-- End div id=websitecontentundertopmenu -->';
4352 $out .=
"\n</body></html>\n";
4354 $out .=
"\n".
'<!-- End page content '.$filetpl.
' -->'.
"\n\n";
4380 if (empty($websitekey) || $websitekey ==
'-1')
4382 print
'<br><br><div class="center previewnotyetavailable"><span class="">'.$langs->trans(
"NoWebSiteCreateOneFirst").
'</span></div><br><br><br>';
4383 print
'<div class="center"><div class="logo_setup"></div></div>';
4386 print
'<br><br><div class="center previewnotyetavailable"><span class="">'.$langs->trans(
"PreviewOfSiteNotYetAvailable", $object->ref).
'</span></div><br><br><br>';
4387 print
'<div class="center"><div class="logo_setup"></div></div>';
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
removeHtmlComment($content)
Function to remove comments into HTML content.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto= 'UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm= 'auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled= '')
Return HTML code to output a button to open a dialog popup box.
dolSaveHtaccessFile($filehtaccess, $htaccess)
Save content of a page on disk.
dolWebsiteReplacementOfLinks($website, $content, $removephppart=0, $contenttype= 'html', $containerid= '')
Convert a page content to have correct links (based on DOL_URL_ROOT) into an html content...
img_help($usehelpcursor=1, $usealttitle=1)
Show help logo with cursor "?".
dolSaveMasterFile($filemaster)
Save content of a page on disk.
dol_now($mode= 'auto')
Return date for now.
dolibarr_set_const($db, $name, $value, $type= 'chaine', $visible=0, $note= '', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent)
Save content of a page on disk.
Class to manage Dolibarr users.
dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage)
Save content of a page on disk (page name is generally ID_of_page.php).
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete= 'resolve')
Convert a html select field into an ajax combobox.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom= 'UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getRootURLFromURL($url)
Function root url from a long url For example: https://www.abc.mydomain.com/dir/page.html return 'https://www.abc.mydomain.com' For example: http://www.abc.mydomain.com/ return 'https://www.abc.mydomain.com'.
showWebsiteTemplates(Website $website)
Show list of themes.
$conf db name
Only used if Module[ID]Name translation string is not found.
getURLContent($url, $postorget= 'GET', $param= '', $followlocation=1, $addheaders=array(), $allowedschemes=array('http', 'https'), $localurl=0)
Function to get a content from an URL (use proxy if proxy defined).
dolSaveManifestJson($file, $content)
Save content of a page on disk.
dolKeepOnlyPhpCode($str)
Keep only PHP code part from a HTML string page.
getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modifylinks=0, $grabimages=1, $grabimagesinto= 'subpage')
Download all images found into page content $tmp.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options= '', $sortfield= '', $sortorder= '', $morehtmlcenter= '', $num=-1, $totalnboflines= '', $picto= 'generic', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow= '')
Print a title with navigation controls for pagination.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage categories.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
dolibarr_del_const($db, $name, $entity=1)
Effacement d'une constante dans la base de donnees.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories) ...
dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper)
Save content of the index.php and/or wrapper.php page.
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1)
Remove a file or several files with a mask.
dolSaveReadme($file, $content)
Save content of a page on disk.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
dolSavePageAlias($filealias, $object, $objectpage)
Save an alias page on disk (A page that include the reference page).
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
getDomainFromURL($url, $mode=0)
Function get second level domain name.
dolSaveJsFile($filejs, $jscontent)
Save content of a page on disk.
dolStripPhpCode($str, $replacewith= '')
Remove PHP code part from a string.
dolSaveCssFile($filecss, $csscontent)
Save content of a page on disk.
dol_is_file($pathoffile)
Return if path is a file.
print $_SERVER["PHP_SELF"]
Edit parameters.
img_next($titlealt= 'default', $moreatt= '')
Show next logo.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
img_previous($titlealt= 'default', $moreatt= '')
Show previous logo.
lessphp v0.5.0 http://leafo.net/lessphp
ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input=array())
On/off button to change status of an object This is called when MAIN_DIRECT_STATUS_UPDATE is set and ...
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Class to manage a WYSIWYG editor.
make_substitutions($text, $substitutionarray, $outputlangs=null)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesession=0, $varfiles= 'addedfile', $savingdocmask= '', $link=null, $trackid= '', $generatethumbs=1, $object=null)
Get and save an upload file (for example after submitting a new file a mail form).
dolSaveRobotFile($filerobot, $robotcontent)
Save content of a page on disk.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip= '', $forcenowrapcolumntitle=0)
Get title line of an array.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin= '1', $morecss= '', $textfordropdown= '')
Show information for admin users or standard users.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)
getPagesFromSearchCriterias($type, $algo, $searchstring, $max=25, $sortfield= 'date_creation', $sortorder= 'DESC', $langcode= '', $otherfilters= 'null', $status=1)
Return list of containers object that match a criteria.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...