25define(
'NOSCANPOSTFORINJECTION', 1);
26define(
'NOSTYLECHECK', 1);
27define(
'USEDOLIBARREDITOR', 1);
28define(
'FORCE_CKEDITOR', 1);
29if (!defined(
'DISABLE_JS_GRAHP')) {
30 define(
'DISABLE_JS_GRAPH', 1);
36require
'../main.inc.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/lib/website.lib.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/lib/website2.lib.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formwebsite.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/website/class/website.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/website/class/websitepage.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
52$langs->loadLangs(array(
"admin",
"other",
"website",
"errors"));
55if (!$user->hasRight(
'website',
'read')) {
59$conf->dol_hide_leftmenu = 1;
62$websiteid =
GETPOST(
'websiteid',
'int');
63$websitekey =
GETPOST(
'website',
'alpha');
64$page =
GETPOST(
'page',
'alpha');
65$pageid =
GETPOST(
'pageid',
'int');
66$pageref =
GETPOST(
'pageref',
'alphanohtml');
68$action =
GETPOST(
'action',
'aZ09');
69$massaction =
GETPOST(
'massaction',
'alpha');
70$confirm =
GETPOST(
'confirm',
'alpha');
71$cancel =
GETPOST(
'cancel',
'alpha');
72$toselect =
GETPOST(
'toselect',
'array');
73$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'websitelist';
74$backtopage =
GETPOST(
'backtopage',
'alpha');
75$optioncss =
GETPOST(
'optioncss',
'aZ');
76$dol_hide_topmenu =
GETPOST(
'dol_hide_topmenu',
'int');
77$dol_hide_leftmenu =
GETPOST(
'dol_hide_leftmenu',
'int');
78$dol_openinpopup =
GETPOST(
'dol_openinpopup',
'aZ09');
80$type_container =
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'alpha');
81$section_dir =
GETPOST(
'section_dir',
'alpha');
82$file_manager =
GETPOST(
'file_manager',
'alpha');
83$replacesite =
GETPOST(
'replacesite',
'alpha');
84$mode =
GETPOST(
'mode',
'alpha');
86if (
GETPOST(
'deletesite',
'alpha')) {
87 $action =
'deletesite';
89if (
GETPOST(
'delete',
'alpha')) {
92if (
GETPOST(
'preview',
'alpha')) {
95if (
GETPOST(
'createsite',
'alpha')) {
96 $action =
'createsite';
98if (
GETPOST(
'createcontainer',
'alpha')) {
99 $action =
'createcontainer';
101if (
GETPOST(
'editcss',
'alpha')) {
104if (
GETPOST(
'editmenu',
'alpha')) {
105 $action =
'editmenu';
107if (
GETPOST(
'setashome',
'alpha')) {
108 $action =
'setashome';
110if (
GETPOST(
'editmeta',
'alpha')) {
111 $action =
'editmeta';
113if (
GETPOST(
'editsource',
'alpha')) {
114 $action =
'editsource';
116if (
GETPOST(
'editcontent',
'alpha')) {
117 $action =
'editcontent';
119if (
GETPOST(
'exportsite',
'alpha')) {
120 $action =
'exportsite';
122if (
GETPOST(
'importsite',
'alpha')) {
123 $action =
'importsite';
125if (
GETPOST(
'createfromclone',
'alpha')) {
126 $action =
'createfromclone';
128if (
GETPOST(
'createpagefromclone',
'alpha')) {
129 $action =
'createpagefromclone';
131if (empty($action) && $file_manager) {
132 $action =
'file_manager';
134if ($action ==
'replacesite' || (empty($action) && $replacesite)) {
135 $mode =
'replacesite';
142$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
143$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
144$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
145$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
146if (empty($page) || $page == -1) {
149$offset = $limit * $page;
150$pageprev = $page - 1;
151$pagenext = $page + 1;
162$listofwebsites = $object->fetchAll(
'ASC',
'position');
165if (!($websiteid > 0) && empty($websitekey) && $action !=
'createsite') {
166 foreach ($listofwebsites as $key => $valwebsite) {
167 $websitekey = $valwebsite->ref;
171if ($websiteid > 0 || $websitekey) {
172 $res = $object->fetch($websiteid, $websitekey);
173 $websitekey = $object->ref;
182if (($pageid > 0 || $pageref) && $action !=
'addcontainer') {
183 $res = $objectpage->fetch($pageid, ($object->id > 0 ? $object->id : null), $pageref);
185 $res = $objectpage->fetch($pageid, ($object->id > 0 ? $object->id : null), null, $pageref);
189 if ($res >= 0 && $object->id > 0) {
190 if ($objectpage->fk_website != $object->id) {
191 if ($object->fk_default_home > 0) {
192 $res = $objectpage->fetch($object->fk_default_home, $object->id,
'');
194 $pageid = $object->fk_default_home;
197 $res = $objectpage->fetch(0, $object->id,
'');
201 $pageid = $objectpage->id;
205 $pageid = $objectpage->id;
211if (empty($pageid) && empty($pageref) && $object->id > 0 && $action !=
'createcontainer') {
212 $pageid = $object->fk_default_home;
213 if (empty($pageid)) {
214 $array = $objectpage->fetchAll($object->id,
'ASC,ASC',
'type_container,pageurl');
215 if (!is_array($array) && $array < 0) {
218 $atleastonepage = (is_array($array) && count($array) > 0);
222 foreach ($array as $key => $valpage) {
223 if (empty($firstpageid)) {
224 $firstpageid = $valpage->id;
226 if ($object->fk_default_home && $key == $object->fk_default_home) {
227 $homepageid = $valpage->id;
230 $pageid = ($homepageid ? $homepageid : $firstpageid);
235global $dolibarr_main_data_root;
236$pathofwebsite = $dolibarr_main_data_root.($conf->entity > 1 ?
'/'.$conf->entity :
'').
'/website/'.$websitekey;
237$filehtmlheader = $pathofwebsite.
'/htmlheader.html';
238$filecss = $pathofwebsite.
'/styles.css.php';
239$filejs = $pathofwebsite.
'/javascript.js.php';
240$filerobot = $pathofwebsite.
'/robots.txt';
241$filehtaccess = $pathofwebsite.
'/.htaccess';
242$filetpl = $pathofwebsite.
'/page'.$pageid.
'.tpl.php';
243$fileindex = $pathofwebsite.
'/index.php';
244$filewrapper = $pathofwebsite.
'/wrapper.php';
245$filemanifestjson = $pathofwebsite.
'/manifest.json.php';
246$filereadme = $pathofwebsite.
'/README.md';
247$filelicense = $pathofwebsite.
'/LICENSE';
248$filemaster = $pathofwebsite.
'/master.inc.php';
251$urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
252$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
256$permtouploadfile = $user->hasRight(
'website',
'write');
257$diroutput = $conf->medias->multidir_output[$conf->entity];
259$relativepath = $section_dir;
260$upload_dir = preg_replace(
'/\/$/',
'', $diroutput).
'/'.preg_replace(
'/^\//',
'', $relativepath);
262$htmlheadercontentdefault =
'';
263$htmlheadercontentdefault .=
'<link rel="stylesheet" id="google-fonts-css" href="//fonts.googleapis.com/css?family=Open+Sans:300,400,700" />'.
"\n";
264$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";
265$htmlheadercontentdefault .=
'<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>'.
"\n";
266$htmlheadercontentdefault .=
'<script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>'.
"\n";
267$htmlheadercontentdefault .=
'<!--'.
"\n";
268$htmlheadercontentdefault .=
'<script src="/document.php?modulepart=medias&file=css/myfile.css"></script>'.
"\n";
269$htmlheadercontentdefault .=
'<script src="/document.php?modulepart=medias&file=js/myfile.js"></script>'.
"\n";
270$htmlheadercontentdefault .=
'-->'.
"\n";
272$manifestjsoncontentdefault =
'';
273$manifestjsoncontentdefault .=
'{
275 "short_name": "MyWebsite",
278 "display": "standalone",
279 "background_color": "#fff",
280 "description": "A simple Web app.",
282 "src": "images/'.urlencode($website->ref).
'/homescreen48.png",
286 "src": "image/'.urlencode($website->ref).
'/homescreen72.png",
290 "src": "image/'.urlencode($website->ref).
'/homescreen96.png",
294 "src": "image/'.urlencode($website->ref).
'/homescreen144.png",
298 "src": "image/'.urlencode($website->ref).
'/homescreen168.png",
302 "src": "image/'.urlencode($website->ref).
'/homescreen192.png",
306 "related_applications": [{
308 "url": "https://play.google.com/store/apps/details?id=com.nltechno.dolidroidpro"
312$listofpages = array();
321if (
GETPOST(
'optionsitefiles')) {
322 $algo .=
'sitefiles';
325if (empty($sortfield)) {
326 if ($action ==
'file_manager') {
330 $sortfield =
'pageurl';
335$searchkey =
GETPOST(
'searchstring',
'restricthtml');
337if ($action ==
'replacesite' || $mode ==
'replacesite') {
338 $containertype =
GETPOST(
'optioncontainertype',
'aZ09') !=
'-1' ?
GETPOST(
'optioncontainertype',
'aZ09') :
'';
339 $langcode =
GETPOST(
'optionlanguage',
'aZ09');
340 $otherfilters = array();
341 if (
GETPOST(
'optioncategory',
'int') > 0) {
342 $otherfilters[
'category'] =
GETPOST(
'optioncategory',
'int');
345 $listofpages =
getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters, -1);
348$usercanedit = $user->rights->website->write;
349$permissiontoadd = $user->rights->website->write;
350$permissiontodelete = $user->hasRight(
'website',
'delete');
361if (
GETPOST(
'refreshsite',
'alpha') ||
GETPOST(
'refreshsite.x',
'alpha') ||
GETPOST(
'refreshsite_x',
'alpha')) {
362 if ($action ==
'addsite') {
365 if ($action ==
'updatesource') {
369 $pageid = $object->fk_default_home;
370 if (empty($pageid)) {
371 $array = $objectpage->fetchAll($object->id,
'ASC,ASC',
'type_container,pageurl');
372 if (!is_array($array) && $array < 0) {
375 $atleastonepage = (is_array($array) && count($array) > 0);
379 foreach ($array as $key => $valpage) {
380 if (empty($firstpageid)) {
381 $firstpageid = $valpage->id;
383 if ($object->fk_default_home && $key == $object->fk_default_home) {
384 $homepageid = $valpage->id;
387 $pageid = ($homepageid ? $homepageid : $firstpageid);
390if (
GETPOST(
'refreshpage',
'alpha') && !in_array($action, array(
'updatecss'))) {
394if ($cancel && $action ==
'renamefile') {
403 header(
"Location: ".$backtopage);
408$savbacktopage = $backtopage;
409$backtopage = $_SERVER[
"PHP_SELF"].
'?file_manager=1&website='.urlencode($websitekey).
'&pageid='.urlencode($pageid).(GETPOST(
'section_dir',
'alpha') ?
'§ion_dir='.urlencode(
GETPOST(
'section_dir',
'alpha')) :
'');
411 $backtopage .=
'&sortfield='.urlencode($sortfield);
414 $backtopage .=
'&sortorder='.urlencode($sortorder);
416include DOL_DOCUMENT_ROOT.
'/core/actions_linkedfiles.inc.php';
418$backtopage = $savbacktopage;
422if ($action ==
'renamefile') {
423 $action =
'file_manager';
426if ($action ==
'setwebsiteonline' && $usercanedit) {
427 $website->setStatut($website::STATUS_VALIDATED,
null,
'',
'WEBSITE_MODIFY',
'status');
429 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.
GETPOST(
'website',
'alphanohtml').
'&pageid='.
GETPOST(
'websitepage',
'int'));
432if ($action ==
'setwebsiteoffline' && $usercanedit) {
433 $result = $website->setStatut($website::STATUS_DRAFT,
null,
'',
'WEBSITE_MODIFY',
'status');
435 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.
GETPOST(
'website',
'alphanohtml').
'&pageid='.
GETPOST(
'websitepage',
'int'));
438if ($action ==
'seteditinline') {
440 setEventMessages($langs->trans(
"FeatureNotYetAvailable"),
null,
'warnings');
442 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.
GETPOST(
'website',
'alphanohtml').
'&pageid='.
GETPOST(
'pageid',
'int'));
445if ($action ==
'unseteditinline') {
447 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.
GETPOST(
'website',
'alphanohtml').
'&pageid='.
GETPOST(
'pageid',
'int'));
450if ($action ==
'setshowsubcontainers') {
453 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.
GETPOST(
'website',
'alphanohtml').
'&pageid='.
GETPOST(
'pageid',
'int'));
456if ($action ==
'unsetshowsubcontainers') {
458 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.
GETPOST(
'website',
'alphanohtml').
'&pageid='.
GETPOST(
'pageid',
'int'));
462if ($massaction ==
'replace' &&
GETPOST(
'confirmmassaction',
'alpha') && !$searchkey && $usercanedit) {
463 $mode =
'replacesite';
464 $action =
'replacesite';
468if ($action ==
'deletetemplate' && $usercanedit) {
469 $dirthemes = array(
'/doctemplates/websites');
470 if (!empty($conf->modules_parts[
'websitetemplates'])) {
471 foreach ($conf->modules_parts[
'websitetemplates'] as $reldir) {
472 $dirthemes = array_merge($dirthemes, (array) ($reldir.
'doctemplates/websites'));
475 $dirthemes = array_unique($dirthemes);
479 $mode =
'importsite';
480 $action =
'importsite';
482 if (count($dirthemes)) {
484 foreach ($dirthemes as $dir) {
486 $dirtheme = DOL_DATA_ROOT.$dir;
487 if (is_dir($dirtheme)) {
488 $templateuserfile =
GETPOST(
'templateuserfile');
489 $imguserfile = preg_replace(
'/\.zip$/',
'', $templateuserfile).
'.jpg';
498if ($massaction ==
'setcategory' &&
GETPOST(
'confirmmassaction',
'alpha') && $usercanedit) {
504 $categoryid =
GETPOST(
'setcategory',
'int');
505 if ($categoryid > 0) {
508 $category->fetch($categoryid);
510 foreach ($toselect as $tmpid) {
511 $tmpwebsitepage->id = $tmpid;
512 $result = $category->add_type($tmpwebsitepage,
'website_page');
513 if ($result < 0 && $result != -3) {
527 setEventMessages($langs->trans(
"RecordsModified", $nbupdate),
null,
'mesgs');
533 $listofpages =
getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters, -1);
537if ($massaction ==
'delcategory' &&
GETPOST(
'confirmmassaction',
'alpha') && $usercanedit) {
543 $categoryid =
GETPOST(
'setcategory',
'int');
544 if ($categoryid > 0) {
547 $category->fetch($categoryid);
549 foreach ($toselect as $tmpid) {
550 $tmpwebsitepage->id = $tmpid;
551 $result = $category->del_type($tmpwebsitepage,
'website_page');
552 if ($result < 0 && $result != -3) {
566 setEventMessages($langs->trans(
"RecordsModified", $nbupdate),
null,
'mesgs');
572 $listofpages =
getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters, -1);
576if ($massaction ==
'replace' &&
GETPOST(
'confirmmassaction',
'alpha') && $usercanedit) {
577 $replacestring =
GETPOST(
'replacestring',
'none');
579 $dolibarrdataroot = preg_replace(
'/([\\/]+)$/i',
'', DOL_DATA_ROOT);
580 $allowimportsite =
true;
581 if (
dol_is_file($dolibarrdataroot.
'/installmodules.lock')) {
582 $allowimportsite =
false;
585 if (!$allowimportsite) {
589 $message = $langs->trans(
'InstallModuleFromWebHasBeenDisabledContactUs');
592 $message = $langs->trans(
"InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.
'/installmodules.lock');
595 } elseif (!$user->hasRight(
'website',
'writephp')) {
597 } elseif (!$replacestring) {
602 foreach ($toselect as $keyselected) {
603 $objectpage = $listofpages[
'list'][$keyselected];
604 if ($objectpage->pageurl) {
605 dol_syslog(
"Replace string into page ".$objectpage->pageurl);
607 if (
GETPOST(
'optioncontent',
'aZ09')) {
608 $objectpage->content = str_replace($searchkey, $replacestring, $objectpage->content);
610 if (
GETPOST(
'optionmeta',
'aZ09')) {
611 $objectpage->title = str_replace($searchkey, $replacestring, $objectpage->title);
612 $objectpage->description = str_replace($searchkey, $replacestring, $objectpage->description);
613 $objectpage->keywords = str_replace($searchkey, $replacestring, $objectpage->keywords);
616 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
617 $filetpl = $pathofwebsite.
'/page'.$objectpage->id.
'.tpl.php';
622 setEventMessages(
'Failed to write file '.basename($filealias),
null,
'errors');
630 $objectpage->update($user);
634 $action =
'createcontainer';
640 if ($nbreplacement > 0) {
641 setEventMessages($langs->trans(
"ReplacementDoneInXPages", $nbreplacement),
null,
'mesgs');
644 $containertype =
GETPOST(
'optioncontainertype',
'aZ09') !=
'-1' ?
GETPOST(
'optioncontainertype',
'aZ09') :
'';
645 $langcode =
GETPOST(
'optionlanguage',
'aZ09');
646 $otherfilters = array();
647 if (
GETPOST(
'optioncategory',
'int') > 0) {
648 $otherfilters[
'category'] =
GETPOST(
'optioncategory',
'int');
652 $listofpages =
getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters);
682if ($action ==
'addsite' && $usercanedit) {
685 if (
GETPOST(
'virtualhost',
'alpha') && !preg_match(
'/^http/',
GETPOST(
'virtualhost',
'alpha'))) {
687 setEventMessages($langs->trans(
'ErrorURLMustStartWithHttp', $langs->transnoentitiesnoconv(
"VirtualHost")),
null,
'errors');
690 if (!$error && !
GETPOST(
'WEBSITE_REF',
'alpha')) {
692 $langs->load(
"errors");
693 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->transnoentities(
"WebsiteName")),
null,
'errors');
695 if (!$error && !preg_match(
'/^[a-z0-9_\-\.]+$/i',
GETPOST(
'WEBSITE_REF',
'alpha'))) {
697 $langs->load(
"errors");
698 setEventMessages($langs->transnoentities(
"ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities(
"Ref")),
null,
'errors');
702 $arrayotherlang = explode(
',',
GETPOST(
'WEBSITE_OTHERLANG',
'alphanohtml'));
703 foreach ($arrayotherlang as $key => $val) {
705 if (empty(trim($val))) {
708 $arrayotherlang[$key] = substr(trim($val), 0, 2);
712 $tmpobject->ref =
GETPOST(
'WEBSITE_REF',
'alpha');
713 $tmpobject->description =
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml');
714 $tmpobject->lang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
715 $tmpobject->otherlang = join(
',', $arrayotherlang);
716 $tmpobject->virtualhost =
GETPOST(
'virtualhost',
'alpha');
718 $result = $tmpobject->create($user);
722 } elseif ($result < 0) {
733 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$tmpobject->ref);
737 $action =
'createsite';
747if ($action ==
'addcontainer' && $usercanedit) {
752 $objectpage->fk_website = $object->id;
754 if (GETPOSTISSET(
'fetchexternalurl')) {
755 $urltograb =
GETPOST(
'externalurl',
'alpha');
756 $grabimages =
GETPOST(
'grabimages',
'alpha');
757 $grabimagesinto =
GETPOST(
'grabimagesinto',
'alpha');
759 include_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
761 if (empty($urltograb)) {
763 $langs->load(
"errors");
764 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"URL")),
null,
'errors');
765 $action =
'createcontainer';
766 } elseif (!preg_match(
'/^http/', $urltograb)) {
768 $langs->load(
"errors");
769 setEventMessages(
'Error URL must start with http:// or https://',
null,
'errors');
770 $action =
'createcontainer';
776 $urltograbwithoutdomainandparam = preg_replace(
'/^https?:\/\/[^\/]+\/?/i',
'', $urltograb);
778 $urltograbwithoutdomainandparam = preg_replace(
'/\?.*$/',
'', $urltograbwithoutdomainandparam);
779 if (empty($urltograbwithoutdomainandparam) && !preg_match(
'/\/$/', $urltograb)) {
782 $pageurl =
dol_sanitizeFileName(preg_replace(
'/[\/\.]/',
'-', preg_replace(
'/\/+$/',
'', $urltograbwithoutdomainandparam)));
784 $urltograbdirwithoutslash = dirname($urltograb.
'.');
793 $result = $tmpwebsitepage->fetch(0, $object->id, $pageurl);
795 setEventMessages($langs->trans(
"AliasPageAlreadyExists", $pageurl),
null,
'errors');
797 $action =
'createcontainer';
802 $tmp =
getURLContent($urltograb,
'GET',
'', 1, array(), array(
'http',
'https'), 0);
805 if (!empty($tmp[
'content_type']) && preg_match(
'/ISO-8859-1/', $tmp[
'content_type'])) {
806 if (function_exists(
'mb_check_encoding')) {
807 if (mb_check_encoding($tmp[
'content'],
'ISO-8859-1')) {
809 $tmp[
'content'] = mb_convert_encoding($tmp[
'content'],
'ISO-8859-1',
'UTF-8');
812 setEventMessages(
'Error getting '.$urltograb.
': content seems non valid ISO-8859-1',
null,
'errors');
813 $action =
'createcontainer';
817 setEventMessages(
'Error getting '.$urltograb.
': content seems ISO-8859-1 but functions to convert into UTF-8 are not available in your PHP',
null,
'errors');
818 $action =
'createcontainer';
821 if (empty($tmp[
'content_type']) || (!empty($tmp[
'content_type']) && preg_match(
'/UTF-8/', $tmp[
'content_type']))) {
822 if (function_exists(
'mb_check_encoding')) {
823 if (mb_check_encoding($tmp[
'content'],
'UTF-8')) {
827 setEventMessages(
'Error getting '.$urltograb.
': content seems not a valid UTF-8',
null,
'errors');
828 $action =
'createcontainer';
833 if ($tmp[
'curl_error_no']) {
835 setEventMessages(
'Error getting '.$urltograb.
': '.$tmp[
'curl_error_msg'],
null,
'errors');
836 $action =
'createcontainer';
837 } elseif ($tmp[
'http_code'] !=
'200') {
839 setEventMessages(
'Error getting '.$urltograb.
': '.$tmp[
'http_code'],
null,
'errors');
840 $action =
'createcontainer';
849 setEventMessages(
'Error getting '.$urltograb.
': file that include PHP content is not allowed',
null,
'errors');
850 $action =
'createcontainer';
857 preg_match(
'/<head>(.*)<\/head>/ims', $tmp[
'content'], $regs);
860 $objectpage->type_container =
'page';
861 $objectpage->pageurl = $pageurl;
862 if (empty($objectpage->pageurl)) {
864 $objectpage->pageurl = $tmpdomain.
'-home';
867 $objectpage->aliasalt =
'';
869 if (preg_match(
'/^(\d+)\-/', basename($urltograb), $regs)) {
870 $objectpage->aliasalt = $regs[1];
874 if (preg_match(
'/<title>(.*)<\/title>/ims', $head, $regtmp)) {
875 $objectpage->title = $regtmp[1];
877 if (preg_match(
'/<meta name="title"[^"]+content="([^"]+)"/ims', $head, $regtmp)) {
878 if (empty($objectpage->title)) {
879 $objectpage->title = $regtmp[1];
882 if (preg_match(
'/<meta name="description"[^"]+content="([^"]+)"/ims', $head, $regtmp)) {
883 $objectpage->description = $regtmp[1];
885 if (preg_match(
'/<meta name="keywords"[^"]+content="([^"]+)"/ims', $head, $regtmp)) {
886 $objectpage->keywords = $regtmp[1];
888 if (preg_match(
'/<html\s+lang="([^"]+)"/ims', $tmp[
'content'], $regtmp)) {
889 $tmplang = explode(
'-', $regtmp[1]);
890 $objectpage->lang = $tmplang[0].($tmplang[1] ?
'_'.strtoupper($tmplang[1]) :
'');
893 $tmp[
'content'] = preg_replace(
'/\s*<meta name="generator"[^"]+content="([^"]+)"\s*\/?>/ims',
'', $tmp[
'content']);
895 $objectpage->content = $tmp[
'content'];
896 $objectpage->content = preg_replace(
'/^.*<body(\s[^>]*)*>/ims',
'', $objectpage->content);
897 $objectpage->content = preg_replace(
'/<\/body(\s[^>]*)*>.*$/ims',
'', $objectpage->content);
905 $objectpage->htmlheader = $tmp[
'content'];
906 $objectpage->htmlheader = preg_replace(
'/^.*<head(\s[^>]*)*>/ims',
'', $objectpage->htmlheader);
907 $objectpage->htmlheader = preg_replace(
'/<\/head(\s[^>]*)*>.*$/ims',
'', $objectpage->htmlheader);
908 $objectpage->htmlheader = preg_replace(
'/<base(\s[^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
909 $objectpage->htmlheader = preg_replace(
'/<meta http-equiv="content-type"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
910 $objectpage->htmlheader = preg_replace(
'/<meta name="robots"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
911 $objectpage->htmlheader = preg_replace(
'/<meta name="title"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
912 $objectpage->htmlheader = preg_replace(
'/<meta name="description"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
913 $objectpage->htmlheader = preg_replace(
'/<meta name="keywords"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
914 $objectpage->htmlheader = preg_replace(
'/<meta name="generator"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
917 $objectpage->htmlheader = preg_replace(
'/<title>[^<]*<\/title>\n*/ims',
'', $objectpage->htmlheader);
918 $objectpage->htmlheader = preg_replace(
'/<link[^>]*rel="shortcut[^>]*>\n/ims',
'', $objectpage->htmlheader);
919 $objectpage->htmlheader = preg_replace(
'/<link[^>]*rel="alternate[^>]*>\n/ims',
'', $objectpage->htmlheader);
920 $objectpage->htmlheader = preg_replace(
'/<link[^>]*rel="canonical[^>]*>\n/ims',
'', $objectpage->htmlheader);
923 $tmp = $objectpage->htmlheader;
926 preg_match_all(
'/<script([^\.>]+)src=["\']([^"\'>]+)["\']([^>]*)><\/script>/i', $objectpage->htmlheader, $regs);
927 $errorforsubresource = 0;
928 foreach ($regs[0] as $key => $val) {
929 dol_syslog(
"We will grab the script resource found into script tag ".$regs[2][$key]);
931 $linkwithoutdomain = $regs[2][$key];
932 if (preg_match(
'/^\//', $regs[2][$key])) {
933 $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key];
935 $urltograbbis = $urltograbdirwithoutslash.
'/'.$regs[2][$key];
939 if (preg_match(
'/^http/', $regs[2][$key])) {
940 $urltograbbis = $regs[2][$key];
941 $linkwithoutdomain = preg_replace(
'/^https?:\/\/[^\/]+\//i',
'', $regs[2][$key]);
951 if ($domaintograb != $domaintograbbis) {
983 $tmp = preg_replace(
'/'.preg_quote($regs[0][$key],
'/').
'/i',
'', $tmp);
985 $objectpage->htmlheader = trim($tmp).
"\n";
989 $pagecsscontent =
"\n".
'<style>'.
"\n";
991 preg_match_all(
'/<link([^\.>]+)href=["\']([^"\'>]+\.css[^"\'>]*)["\']([^>]*)>/i', $objectpage->htmlheader, $regs);
992 $errorforsubresource = 0;
993 foreach ($regs[0] as $key => $val) {
994 dol_syslog(
"We will grab the css resources found into link tag ".$regs[2][$key]);
996 $linkwithoutdomain = $regs[2][$key];
997 if (preg_match(
'/^\//', $regs[2][$key])) {
998 $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key];
1000 $urltograbbis = $urltograbdirwithoutslash.
'/'.$regs[2][$key];
1004 if (preg_match(
'/^http/', $regs[2][$key])) {
1005 $urltograbbis = $regs[2][$key];
1006 $linkwithoutdomain = preg_replace(
'/^https?:\/\/[^\/]+\//i',
'', $regs[2][$key]);
1016 if ($domaintograb != $domaintograbbis) {
1020 $tmpgeturl =
getURLContent($urltograbbis,
'GET',
'', 1, array(), array(
'http',
'https'), 0);
1021 if ($tmpgeturl[
'curl_error_no']) {
1022 $errorforsubresource++;
1023 setEventMessages(
'Error getting link tag url '.$urltograbbis.
': '.$tmpgeturl[
'curl_error_msg'],
null,
'errors');
1024 dol_syslog(
'Error getting '.$urltograbbis.
': '.$tmpgeturl[
'curl_error_msg']);
1025 $action =
'createcontainer';
1026 } elseif ($tmpgeturl[
'http_code'] !=
'200') {
1027 $errorforsubresource++;
1028 setEventMessages(
'Error getting link tag url '.$urltograbbis.
': '.$tmpgeturl[
'http_code'],
null,
'errors');
1029 dol_syslog(
'Error getting '.$urltograbbis.
': '.$tmpgeturl[
'curl_error_msg']);
1030 $action =
'createcontainer';
1039 $tmpgeturl[
'content'] = preg_replace(
'/\/\*\s+CSS content[a-z\s]*\s+\*\//',
'', $tmpgeturl[
'content']);
1049 $pagecsscontent .=
'/* Content of file '.$urltograbbis.
' */'.
"\n";
1051 getAllImages($object, $objectpage, $urltograbbis, $tmpgeturl[
'content'], $action, 1, $grabimages, $grabimagesinto);
1054 include_once DOL_DOCUMENT_ROOT.
'/core/class/lessc.class.php';
1055 $lesscobj =
new Lessc();
1057 $contentforlessc =
".bodywebsite {\n".$tmpgeturl[
'content'].
"\n}\n";
1059 $contentforlessc = $lesscobj->compile($contentforlessc);
1062 $pagecsscontent .= $contentforlessc.
"\n";
1064 }
catch (exception $e) {
1066 dol_syslog(
"Failed to compile the CSS from URL ".$urltograbbis.
" with lessc: ".$e->getMessage(), LOG_WARNING);
1067 $pagecsscontent .= $tmpgeturl[
'content'].
"\n";
1070 $objectpage->htmlheader = preg_replace(
'/'.preg_quote($regs[0][$key],
'/').
'\n*/ims',
'', $objectpage->htmlheader);
1074 $pagecsscontent .=
'</style>';
1078 $objectpage->htmlheader .= trim($pagecsscontent).
"\n";
1082 $tmp = $objectpage->content;
1084 getAllImages($object, $objectpage, $urltograb, $tmp, $action, 1, $grabimages, $grabimagesinto);
1087 $tmp = preg_replace(
'/a href="\/([^\/"]+)\/([^\/"]+)"/',
'a href="/\1-\2.php"', $tmp);
1088 $tmp = preg_replace(
'/a href="\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)"/',
'a href="/\1-\2-\3.php"', $tmp);
1089 $tmp = preg_replace(
'/a href="\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)"/',
'a href="/\1-\2-\3-\4.php"', $tmp);
1092 $objectpage->content = $tmp;
1094 $objectpage->grabbed_from = $urltograb;
1098 $newaliasnames =
'';
1099 if (!$error &&
GETPOST(
'WEBSITE_ALIASALT',
'alpha')) {
1100 $arrayofaliastotest = explode(
',', str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_ALIASALT',
'alpha')));
1102 foreach ($arrayofaliastotest as $aliastotest) {
1103 $aliastotest = trim(preg_replace(
'/\.php$/i',
'', $aliastotest));
1106 if (preg_match(
'/^page\d+/i', $aliastotest)) {
1108 $langs->load(
"errors");
1110 $action =
'createcontainer';
1113 $result = $websitepagetemp->fetch(0, $object->id, $aliastotest);
1116 $langs->load(
"errors");
1117 setEventMessages($websitepagetemp->error, $websitepagetemp->errors,
'errors');
1118 $action =
'createcontainer';
1123 $langs->load(
"errors");
1124 setEventMessages($langs->trans(
"ErrorAPageWithThisNameOrAliasAlreadyExists", $websitepagetemp->pageurl),
null,
'errors');
1125 $action =
'createcontainer';
1128 $newaliasnames .= ($newaliasnames ?
', ' :
'').$aliastotest;
1133 $objectpage->title = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_TITLE',
'alphanohtml'));
1134 $objectpage->type_container =
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'aZ09');
1135 $objectpage->pageurl =
GETPOST(
'WEBSITE_PAGENAME',
'alpha');
1136 $objectpage->aliasalt = $newaliasnames;
1137 $objectpage->description = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml'));
1138 $objectpage->lang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
1139 $objectpage->otherlang =
GETPOST(
'WEBSITE_OTHERLANG',
'aZ09comma');
1140 $objectpage->image =
GETPOST(
'WEBSITE_IMAGE',
'alpha');
1141 $objectpage->keywords = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_KEYWORDS',
'alphanohtml'));
1142 $objectpage->allowed_in_frames =
GETPOST(
'WEBSITE_ALLOWED_IN_FRAMES',
'aZ09');
1143 $objectpage->htmlheader =
GETPOST(
'htmlheader',
'none');
1144 $objectpage->author_alias =
GETPOST(
'WEBSITE_AUTHORALIAS',
'alphanohtml');
1145 $objectpage->object_type =
GETPOST(
'WEBSITE_OBJECTCLASS');
1146 $objectpage->fk_object =
GETPOST(
'WEBSITE_OBJECTID');
1147 $substitutionarray = array();
1148 $substitutionarray[
'__WEBSITE_CREATE_BY__'] = $user->getFullName($langs);
1151 $pageidfortranslation = (
GETPOST(
'pageidfortranslation',
'int') > 0 ?
GETPOST(
'pageidfortranslation',
'int') : 0);
1152 if ($pageidfortranslation > 0) {
1155 $objectpagetmp->fetch($pageidfortranslation);
1156 if ($objectpagetmp->fk_page > 0) {
1157 $pageidfortranslation = $objectpagetmp->fk_page;
1160 $objectpage->fk_page = $pageidfortranslation;
1162 $sample =
GETPOST(
'sample',
'alpha');
1163 if (empty($sample)) {
1167 $pathtosample = DOL_DOCUMENT_ROOT.
'/website/samples/page-sample-'.
dol_sanitizeFileName($sample).
'.html';
1170 $objectpage->content =
make_substitutions(@file_get_contents($pathtosample), $substitutionarray);
1174 if (empty($objectpage->pageurl)) {
1175 $langs->load(
"errors");
1176 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WEBSITE_PAGENAME")),
null,
'errors');
1178 $action =
'createcontainer';
1179 } elseif (!preg_match(
'/^[a-z0-9\-\_]+$/i', $objectpage->pageurl)) {
1180 $langs->load(
"errors");
1181 setEventMessages($langs->transnoentities(
"ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities(
'WEBSITE_PAGENAME')),
null,
'errors');
1183 $action =
'createcontainer';
1185 if (empty($objectpage->title)) {
1186 $langs->load(
"errors");
1187 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WEBSITE_TITLE")),
null,
'errors');
1189 $action =
'createcontainer';
1191 if ($objectpage->fk_page > 0 && empty($objectpage->lang)) {
1192 $langs->load(
"errors");
1193 setEventMessages($langs->trans(
"ErrorLanguageRequiredIfPageIsTranslationOfAnother"),
null,
'errors');
1195 $action =
'createcontainer';
1197 if ($objectpage->fk_page > 0 && !empty($objectpage->lang)) {
1198 if ($objectpage->lang == $website->lang) {
1199 $langs->load(
"errors");
1200 setEventMessages($langs->trans(
"ErrorLanguageMustNotBeSourceLanguageIfPageIsTranslationOfAnother"),
null,
'errors');
1202 $action =
'createcontainer';
1208 $pageid = $objectpage->create($user);
1212 $action =
'createcontainer';
1218 $categoriesarray =
GETPOST(
'categories',
'array');
1219 $result = $objectpage->setCategories($categoriesarray);
1228 if (empty($object->fk_default_home)) {
1229 $object->fk_default_home = $pageid;
1230 $res = $object->update($user);
1235 $filetpl = $pathofwebsite.
'/page'.$pageid.
'.tpl.php';
1238 $result =
dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper, $object);
1248 if (!empty($objectpage->content)) {
1249 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
1250 $filetpl = $pathofwebsite.
'/page'.$objectpage->id.
'.tpl.php';
1255 setEventMessages(
'Failed to write file '.basename($filealias),
null,
'errors');
1264 $action =
'createcontainer';
1271 setEventMessages($langs->trans(
"PageAdded", $objectpage->pageurl),
null,
'mesgs');
1278 $pageid = $objectpage->id;
1283 $pathtomedias = DOL_DATA_ROOT.
'/medias';
1284 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
1286 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
1287 dol_mkdir(dirname($pathtomediasinwebsite));
1288 $result = symlink($pathtomedias, $pathtomediasinwebsite);
1301 $htmlheadercontent =
"<html>\n";
1302 $htmlheadercontent .= $htmlheadercontentdefault;
1303 $htmlheadercontent .=
"</html>";
1308 $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;}";
1313 $jscontent =
"/* JS content (all pages) */\n";
1318 $robotcontent =
"# Robot file. Generated with Dolibarr\nUser-agent: *\nAllow: /public/\nDisallow: /administrator/";
1323 $htaccesscontent =
"# Order allow,deny\n# Deny from all";
1328 $manifestjsoncontent =
"";
1333 $readmecontent =
"Website generated by Dolibarr ERP CRM";
1338 $licensecontent =
"MIT License";
1342 $action =
'preview';
1347if ($action ==
'confirm_deletesite' && $confirm ==
'yes' && $permissiontodelete) {
1352 $res = $object->fetch(
GETPOST(
'id',
'int'));
1356 $res = $object->delete($user);
1363 if (
GETPOST(
'delete_also_js',
'alpha') ==
'on') {
1364 $pathofwebsitejs = DOL_DATA_ROOT.
'/medias/js/'.$object->ref;
1368 if (
GETPOST(
'delete_also_medias',
'alpha') ==
'on') {
1369 $pathofwebsitemedias = DOL_DATA_ROOT.
'/medias/image/'.$object->ref;
1377 setEventMessages($langs->trans(
"SiteDeleted", $object->ref),
null,
'mesgs');
1379 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.$object->id);
1388if (GETPOSTISSET(
'pageid') && $action ==
'delete' && $permissiontodelete && !
GETPOST(
'file_manager')) {
1393 $res = $object->fetch(0, $websitekey);
1396 $res = $objectpage->fetch($pageid, $object->id);
1399 $res = $objectpage->delete($user);
1408 setEventMessages($langs->trans(
"PageDeleted", $objectpage->pageurl, $websitekey),
null,
'mesgs');
1410 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$websitekey);
1418if (!GETPOSTISSET(
'pageid')) {
1419 $objectclass =
'WebsitePage';
1423 if (!$error && ($massaction ==
'delete' || ($action ==
'delete' && $confirm ==
'yes')) && $permissiontodelete) {
1426 $objecttmp =
new $objectclass($db);
1428 foreach ($toselect as $toselectid) {
1429 $result = $objecttmp->fetch($toselectid);
1431 $result = $objecttmp->delete($user);
1460 if ($action ==
'delete') {
1461 $mode =
'replacesite';
1462 $action =
'replacesite';
1464 $containertype =
GETPOST(
'optioncontainertype',
'aZ09') !=
'-1' ?
GETPOST(
'optioncontainertype',
'aZ09') :
'';
1465 $langcode =
GETPOST(
'optionlanguage',
'aZ09');
1466 $otherfilters = array();
1467 if (
GETPOST(
'optioncategory',
'int') > 0) {
1468 $otherfilters[
'category'] =
GETPOST(
'optioncategory',
'int');
1471 $listofpages =
getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters);
1476if ($action ==
'updatecss' && $usercanedit) {
1479 $action =
'editcss';
1481 $res = $object->fetch(0, $websitekey);
1484 if (GETPOSTISSET(
'virtualhost')) {
1485 $tmpvirtualhost = preg_replace(
'/\/$/',
'',
GETPOST(
'virtualhost',
'alpha'));
1486 if ($tmpvirtualhost && !preg_match(
'/^http/', $tmpvirtualhost)) {
1488 setEventMessages($langs->trans(
'ErrorURLMustStartWithHttp', $langs->transnoentitiesnoconv(
"VirtualHost")),
null,
'errors');
1489 $action =
'editcss';
1493 $arrayotherlang = explode(
',',
GETPOST(
'WEBSITE_OTHERLANG',
'alphanohtml'));
1494 foreach ($arrayotherlang as $key => $val) {
1496 if (empty(trim($val))) {
1499 $arrayotherlang[$key] = substr(trim($val), 0, 2);
1502 $object->virtualhost = $tmpvirtualhost;
1503 $object->lang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
1504 $object->otherlang = join(
',', $arrayotherlang);
1505 $object->use_manifest =
GETPOSTINT(
'use_manifest');
1507 $result = $object->update($user);
1511 $action =
'editcss';
1517 if (($_FILES[
'addedfile'][
"name"] !=
'')) {
1518 $uploadfolder = $conf->website->dir_output.
'/'.$websitekey;
1519 if ($_FILES[
'addedfile'][
'type'] !=
'image/png') {
1523 $filetoread = realpath(
dol_osencode($_FILES[
'addedfile'][
'tmp_name']));
1524 $filesize = getimagesize($filetoread);
1525 if ($filesize[0] != $filesize[1]) {
1527 setEventMessages($langs->trans(
'ErrorFaviconMustBeASquaredImage'), array(),
'errors');
1529 if (! $error && ($filesize[0] != 16 && $filesize[0] != 32 && $filesize[0] != 64)) {
1538 if (!GETPOSTISSET(
'updateandstay')) {
1539 $action =
'preview';
1541 $backtopage = preg_replace(
'/searchstring=[^&]*/',
'', $backtopage);
1542 header(
"Location: ".$backtopage);
1546 $action =
'editcss';
1565 $dataposted = trim(
GETPOST(
'WEBSITE_HTML_HEADER',
'none'));
1566 $dataposted = preg_replace(array(
'/<html>\n*/ims',
'/<\/html>\n*/ims'), array(
'',
''), $dataposted);
1567 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1570 $phpfullcodestringold =
'';
1574 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1576 if (!$errorphpcheck) {
1577 $htmlheadercontent =
'';
1589 $htmlheadercontent .= $dataposted.
"\n";
1604 $dataposted = trim(
GETPOST(
'WEBSITE_CSS_INLINE',
'none'));
1605 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1608 $phpfullcodestringold =
'';
1612 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1614 if (!$errorphpcheck) {
1617 $csscontent .=
"<?php // BEGIN PHP\n";
1618 $csscontent .=
'$websitekey=basename(__DIR__);'.
"\n";
1619 $csscontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded\n";
1620 $csscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
1621 $csscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
1622 $csscontent .=
"ob_start();\n";
1623 $csscontent .=
"if (! headers_sent()) { /* because file is included inline when in edit mode and we don't want warning */ \n";
1624 $csscontent .=
"header('Cache-Control: max-age=3600, public, must-revalidate');\n";
1625 $csscontent .=
"header('Content-type: text/css');\n";
1626 $csscontent .=
"}\n";
1627 $csscontent .=
"// END PHP ?>\n";
1629 $csscontent .= $dataposted.
"\n";
1631 $csscontent .=
'<?php // BEGIN PHP'.
"\n";
1632 $csscontent .=
'$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "css");'.
"\n";
1633 $csscontent .=
"// END PHP ?>\n";
1635 dol_syslog(
"Save css content into ".$filecss);
1647 $dataposted = trim(
GETPOST(
'WEBSITE_JS_INLINE',
'none'));
1648 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1651 $phpfullcodestringold =
'';
1655 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1657 if (!$errorphpcheck) {
1660 $jscontent .=
"<?php // BEGIN PHP\n";
1661 $jscontent .=
'$websitekey=basename(__DIR__);'.
"\n";
1662 $jscontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded\n";
1663 $jscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
1664 $jscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
1665 $jscontent .=
"ob_start();\n";
1666 $jscontent .=
"header('Cache-Control: max-age=3600, public, must-revalidate');\n";
1667 $jscontent .=
"header('Content-type: application/javascript');\n";
1668 $jscontent .=
"// END PHP ?>\n";
1670 $jscontent .= $dataposted.
"\n";
1672 $jscontent .=
'<?php // BEGIN PHP'.
"\n";
1673 $jscontent .=
'$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "js");'.
"\n";
1674 $jscontent .=
"// END PHP ?>\n";
1685 $dataposted = trim(
GETPOST(
'WEBSITE_ROBOT',
'restricthtml'));
1686 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1689 $phpfullcodestringold =
'';
1693 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1695 if (!$errorphpcheck) {
1708 $robotcontent .= $dataposted.
"\n";
1723 $dataposted = trim(
GETPOST(
'WEBSITE_HTACCESS',
'restricthtml'));
1724 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1727 $phpfullcodestringold =
'';
1731 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1733 if (!$errorphpcheck) {
1734 $htaccesscontent =
'';
1735 $htaccesscontent .= $dataposted.
"\n";
1747 $dataposted = trim(
GETPOST(
'WEBSITE_MANIFEST_JSON',
'none'));
1748 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1751 $phpfullcodestringold =
'';
1755 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1757 if (!$errorphpcheck) {
1758 $manifestjsoncontent =
'';
1760 $manifestjsoncontent .=
"<?php // BEGIN PHP\n";
1761 $manifestjsoncontent .=
'$websitekey=basename(__DIR__);'.
"\n";
1762 $manifestjsoncontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded\n";
1763 $manifestjsoncontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
1764 $manifestjsoncontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
1765 $manifestjsoncontent .=
"ob_start();\n";
1766 $manifestjsoncontent .=
"header('Cache-Control: max-age=3600, public, must-revalidate');\n";
1767 $manifestjsoncontent .=
"header('Content-type: application/manifest+json');\n";
1768 $manifestjsoncontent .=
"// END PHP ?>\n";
1770 $manifestjsoncontent .= $dataposted.
"\n";
1772 $manifestjsoncontent .=
'<?php // BEGIN PHP'.
"\n";
1773 $manifestjsoncontent .=
'$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "manifest");'.
"\n";
1774 $manifestjsoncontent .=
"// END PHP ?>\n";
1779 setEventMessages(
'Failed to write file '.$filemanifestjson,
null,
'errors');
1785 $dataposted = trim(
GETPOST(
'WEBSITE_README',
'restricthtml'));
1786 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1789 $phpfullcodestringold =
'';
1793 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1795 if (!$errorphpcheck) {
1796 $readmecontent =
'';
1808 $readmecontent .= $dataposted.
"\n";
1823 $dataposted = trim(
GETPOST(
'WEBSITE_LICENSE',
'restricthtml'));
1824 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1827 $phpfullcodestringold =
'';
1831 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1833 if (!$errorphpcheck) {
1834 $licensecontent =
'';
1846 $licensecontent .= $dataposted.
"\n";
1870 if (!GETPOSTISSET(
'updateandstay')) {
1871 $action =
'preview';
1873 $backtopage = preg_replace(
'/searchstring=[^&]*/',
'', $backtopage);
1874 header(
"Location: ".$backtopage);
1878 $action =
'editcss';
1885if ($action ==
'setashome' && $usercanedit) {
1887 $object->fetch(0, $websitekey);
1890 $object->fk_default_home = $pageid;
1891 $res = $object->update($user);
1900 $filetpl = $pathofwebsite.
'/page'.$pageid.
'.tpl.php';
1903 $result =
dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper, $object);
1911 $action =
'preview';
1918if ($action ==
'updatemeta' && $usercanedit) {
1921 $result = $object->fetch(0, $websitekey);
1924 $objectpage->fk_website = $object->id;
1927 if (!preg_match(
'/^[a-z0-9\-\_]+$/i',
GETPOST(
'WEBSITE_PAGENAME',
'alpha'))) {
1929 $langs->load(
"errors");
1930 setEventMessages($langs->transnoentities(
"ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities(
'WEBSITE_PAGENAME')),
null,
'errors');
1931 $action =
'editmeta';
1934 $res = $objectpage->fetch($pageid, $object->id);
1937 setEventMessages(
'Page not found '.$objectpage->error, $objectpage->errors,
'errors');
1941 if (!$error &&
GETPOST(
'WEBSITE_PAGENAME',
'alpha')) {
1943 $result = $websitepagetemp->fetch(-1 * $objectpage->id, $object->id,
GETPOST(
'WEBSITE_PAGENAME',
'alpha'));
1946 $langs->load(
"errors");
1947 setEventMessages($websitepagetemp->error, $websitepagetemp->errors,
'errors');
1948 $action =
'editmeta';
1952 $langs->load(
"errors");
1953 setEventMessages($langs->trans(
"ErrorAPageWithThisNameOrAliasAlreadyExists", $websitepagetemp->pageurl),
null,
'errors');
1954 $action =
'editmeta';
1958 $newaliasnames =
'';
1959 if (!$error &&
GETPOST(
'WEBSITE_ALIASALT',
'alpha')) {
1960 $arrayofaliastotest = explode(
',', str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_ALIASALT',
'alpha')));
1963 foreach ($arrayofaliastotest as $aliastotest) {
1964 $aliastotest = trim(preg_replace(
'/\.php$/i',
'', $aliastotest));
1967 if (preg_match(
'/^page\d+/i', $aliastotest)) {
1969 $langs->load(
"errors");
1971 $action =
'editmeta';
1974 $result = $websitepagetemp->fetch(-1 * $objectpage->id, $object->id, $aliastotest);
1977 $langs->load(
"errors");
1978 setEventMessages($websitepagetemp->error, $websitepagetemp->errors,
'errors');
1979 $action =
'editmeta';
1984 $langs->load(
"errors");
1985 setEventMessages($langs->trans(
"ErrorAPageWithThisNameOrAliasAlreadyExists", $websitepagetemp->pageurl),
null,
'errors');
1986 $action =
'editmeta';
1989 $newaliasnames .= ($newaliasnames ?
', ' :
'').$aliastotest;
1995 $objectpage->old_object = clone $objectpage;
1997 $objectpage->title = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_TITLE',
'alphanohtml'));
1998 $objectpage->type_container =
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'aZ09');
1999 $objectpage->pageurl =
GETPOST(
'WEBSITE_PAGENAME',
'alpha');
2000 $objectpage->aliasalt = $newaliasnames;
2001 $objectpage->lang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
2002 $objectpage->otherlang =
GETPOST(
'WEBSITE_OTHERLANG',
'aZ09comma');
2003 $objectpage->description = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml'));
2004 $objectpage->image =
GETPOST(
'WEBSITE_IMAGE',
'alpha');
2005 $objectpage->keywords = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_KEYWORDS',
'alphanohtml'));
2006 $objectpage->allowed_in_frames =
GETPOST(
'WEBSITE_ALLOWED_IN_FRAMES',
'aZ09');
2007 $objectpage->htmlheader = trim(
GETPOST(
'htmlheader',
'none'));
2008 $objectpage->fk_page = (
GETPOST(
'pageidfortranslation',
'int') > 0 ?
GETPOST(
'pageidfortranslation',
'int') : 0);
2009 $objectpage->author_alias = trim(
GETPOST(
'WEBSITE_AUTHORALIAS',
'alphanohtml'));
2010 $objectpage->object_type =
GETPOST(
'WEBSITE_OBJECTCLASS',
'alpha');
2011 $objectpage->fk_object =
GETPOST(
'WEBSITE_OBJECTID',
'aZ09');
2013 $newdatecreation =
dol_mktime(
GETPOST(
'datecreationhour',
'int'),
GETPOST(
'datecreationmin',
'int'),
GETPOST(
'datecreationsec',
'int'),
GETPOST(
'datecreationmonth',
'int'),
GETPOST(
'datecreationday',
'int'),
GETPOST(
'datecreationyear',
'int'));
2014 if ($newdatecreation) {
2015 $objectpage->date_creation = $newdatecreation;
2018 $res = $objectpage->update($user);
2020 $langs->load(
"errors");
2021 if ($db->lasterrno ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
2023 $langs->load(
"errors");
2024 setEventMessages($langs->trans(
"ErrorAPageWithThisNameOrAliasAlreadyExists"),
null,
'errors');
2025 $action =
'editmeta';
2028 $langs->load(
"errors");
2030 $action =
'editmeta';
2037 $categoriesarray =
GETPOST(
'categories',
'array');
2038 $result = $objectpage->setCategories($categoriesarray);
2052 $filemaster = $pathofwebsite.
'/master.inc.php';
2053 $fileoldalias = $pathofwebsite.
'/'.$objectpage->old_object->pageurl.
'.php';
2054 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
2065 if (!empty($fileoldalias)) {
2066 dol_syslog(
"We delete old alias page name=".$fileoldalias.
" to build a new alias page=".$filealias);
2070 if (empty($objectpage->lang) || !in_array($objectpage->lang, explode(
',', $object->otherlang))) {
2071 $dirname = dirname($fileoldalias);
2072 $filename = basename($fileoldalias);
2073 $sublangs = explode(
',', $object->otherlang);
2074 foreach ($sublangs as $sublang) {
2078 if (empty(trim($sublang))) {
2081 $fileoldaliassub = $dirname.
'/'.$sublang.
'/'.$filename;
2087 if (!empty($objectpage->old_object->aliasalt)) {
2088 $tmpaltaliases = explode(
',', $objectpage->old_object->aliasalt);
2089 if (is_array($tmpaltaliases)) {
2090 foreach ($tmpaltaliases as $tmpaliasalt) {
2091 dol_syslog(
"We delete old alt alias pages name=".trim($tmpaliasalt));
2095 if (empty($objectpage->lang) || !in_array($objectpage->lang, explode(
',', $object->otherlang))) {
2096 $dirname = dirname($pathofwebsite.
'/'.trim($tmpaliasalt).
'.php');
2097 $filename = basename($pathofwebsite.
'/'.trim($tmpaliasalt).
'.php');
2098 $sublangs = explode(
',', $object->otherlang);
2099 foreach ($sublangs as $sublang) {
2103 if (empty(trim($sublang))) {
2106 $fileoldaliassub = $dirname.
'/'.$sublang.
'/'.$filename;
2120 if (!empty($objectpage->aliasalt)) {
2121 $tmpaltaliases = explode(
',', $objectpage->aliasalt);
2122 if (is_array($tmpaltaliases)) {
2123 foreach ($tmpaltaliases as $tmpaliasalt) {
2124 if (trim($tmpaliasalt)) {
2125 $filealias = $pathofwebsite.
'/'.trim($tmpaliasalt).
'.php';
2128 setEventMessages(
'Failed to write file '.basename($filealias),
null,
'errors');
2141 if (!GETPOSTISSET(
'updateandstay')) {
2144 $action =
'preview';
2146 $action =
'editmeta';
2152 $action =
'preview';
2158if ($usercanedit && (($action ==
'updatesource' || $action ==
'updatecontent' || $action ==
'confirm_createfromclone' || $action ==
'confirm_createpagefromclone')
2159 || ($action ==
'preview' && (
GETPOST(
'refreshsite') ||
GETPOST(
'refreshpage') ||
GETPOST(
'preview'))))) {
2160 $object->fetch(0, $websitekey);
2163 if ($action ==
'confirm_createfromclone') {
2166 $objectnew =
new Website($db);
2167 $result = $objectnew->createFromClone($user,
GETPOST(
'id',
'int'),
GETPOST(
'siteref',
'aZ09'), (
GETPOST(
'newlang',
'aZ09') ?
GETPOST(
'newlang',
'aZ09') :
''));
2172 $action =
'preview';
2176 $object = $objectnew;
2178 $pageid = $object->fk_default_home;
2179 $websitekey =
GETPOST(
'siteref',
'aZ09');
2185 if ($action ==
'confirm_createpagefromclone') {
2186 $istranslation = (
GETPOST(
'is_a_translation',
'aZ09') ==
'on' ? 1 : 0);
2188 if ($istranslation) {
2189 if (
GETPOST(
'newlang',
'aZ09') == $objectpage->lang || !
GETPOST(
'newlang',
'aZ09')) {
2191 setEventMessages($langs->trans(
"LanguageMustNotBeSameThanClonedPage"),
null,
'errors');
2192 $action =
'preview';
2194 if (
GETPOST(
'newwebsite',
'int') != $object->id) {
2196 setEventMessages($langs->trans(
"WebsiteMustBeSameThanClonedPageIfTranslation"),
null,
'errors');
2197 $action =
'preview';
2204 $newwebsiteid =
GETPOST(
'newwebsite',
'int');
2205 $pathofwebsitenew = $pathofwebsite;
2207 $tmpwebsite =
new Website($db);
2208 if ($newwebsiteid > 0 && $newwebsiteid != $object->id) {
2209 $tmpwebsite->fetch($newwebsiteid);
2210 $pathofwebsitenew = $dolibarr_main_data_root.($conf->entity > 1 ?
'/'.$conf->entity :
'').
'/website/'.$tmpwebsite->ref;
2212 $tmpwebsite = $object;
2216 $resultpage = $objectpage->createFromClone($user, $pageid,
GETPOST(
'newpageurl',
'aZ09'), (
GETPOST(
'newlang',
'aZ09') ?
GETPOST(
'newlang',
'aZ09') :
''), $istranslation, $newwebsiteid,
GETPOST(
'newtitle',
'alphanohtml'));
2217 if ($resultpage < 0) {
2220 $action =
'createpagefromclone';
2224 $filetpl = $pathofwebsitenew.
'/page'.$resultpage->id.
'.tpl.php';
2225 $fileindex = $pathofwebsitenew.
'/index.php';
2226 $filewrapper = $pathofwebsitenew.
'/wrapper.php';
2235 if (empty($newwebsiteid) || $newwebsiteid == $object->id) {
2236 $pageid = $resultpage->id;
2248 $pathtomedias = DOL_DATA_ROOT.
'/medias';
2249 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
2251 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
2252 dol_mkdir(dirname($pathtomediasinwebsite));
2253 $result = symlink($pathtomedias, $pathtomediasinwebsite);
2262 $objectpage->fk_website = $object->id;
2265 $res = $objectpage->fetch($pageid);
2268 if ($object->fk_default_home > 0) {
2269 $res = $objectpage->fetch($object->fk_default_home);
2272 $res = $objectpage->fetch(0, $object->id);
2277 if (!$error && $res > 0) {
2278 if ($action ==
'updatesource' || $action ==
'updatecontent') {
2283 $objectpage->content =
GETPOST(
'PAGE_CONTENT',
'none');
2288 $error =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
2291 if ($action ==
'updatesource') {
2292 $action =
'editsource';
2294 if ($action ==
'updatecontent') {
2295 $action =
'editcontent';
2300 $objectpage->content = preg_replace(
'/<head>.*<\/head>/ims',
'', $objectpage->content);
2304 $res = $objectpage->update($user);
2308 if ($action ==
'updatesource') {
2309 $action =
'editsource';
2311 if ($action ==
'updatecontent') {
2312 $action =
'editcontent';
2319 $filemaster = $pathofwebsite.
'/master.inc.php';
2321 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
2329 setEventMessages(
'Failed to write the master file file '.$filemaster,
null,
'errors');
2353 setEventMessages(
'Failed to write the alias file '.basename($filealias),
null,
'errors');
2361 if (!GETPOSTISSET(
'updateandstay')) {
2363 header(
"Location: ".$backtopage);
2366 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$websitekey.
'&pageid='.$pageid);
2370 if ($action ==
'updatesource') {
2371 $action =
'editsource';
2373 if ($action ==
'updatecontent') {
2374 $action =
'editcontent';
2379 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$websitekey.
'&pageid='.$pageid);
2386 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$websitekey.
'&pageid='.$pageid);
2391 if (empty($websitekey) || $websitekey ==
'-1') {
2392 setEventMessages($langs->trans(
"NoWebSiteCreateOneFirst"),
null,
'warnings');
2395 setEventMessages($langs->trans(
"YouCanCreatePageOrImportTemplate"),
null,
'warnings');
2402if ($action ==
'exportsite' && $user->hasRight(
'website',
'export')) {
2403 $fileofzip = $object->exportWebSite();
2406 $file_name = basename($fileofzip);
2408 header(
"Content-Type: application/zip");
2409 header(
"Content-Disposition: attachment; filename=".$file_name);
2410 header(
"Content-Length: ".filesize($fileofzip));
2412 readfile($fileofzip);
2416 $action =
'preview';
2421if ($action ==
'regeneratesite' && $usercanedit) {
2423 $pathtomedias = DOL_DATA_ROOT.
'/medias';
2424 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
2426 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
2427 dol_mkdir(dirname($pathtomediasinwebsite));
2428 $result = symlink($pathtomedias, $pathtomediasinwebsite);
2430 $langs->load(
"errors");
2431 setEventMessages($langs->trans(
"ErrorFailedToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias),
null,
'errors');
2432 $action =
'preview';
2436 $result = $object->rebuildWebSiteFiles();
2438 setEventMessages($langs->trans(
"PagesRegenerated", $result),
null,
'mesgs');
2439 $action =
'preview';
2442 $action =
'preview';
2447if ($action ==
'importsiteconfirm' && $usercanedit) {
2448 $dolibarrdataroot = preg_replace(
'/([\\/]+)$/i',
'', DOL_DATA_ROOT);
2449 $allowimportsite =
true;
2450 if (
dol_is_file($dolibarrdataroot.
'/installmodules.lock')) {
2451 $allowimportsite =
false;
2454 if ($allowimportsite) {
2455 if (empty($_FILES) && !GETPOSTISSET(
'templateuserfile')) {
2456 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"File")),
null,
'errors');
2457 $action =
'importsite';
2459 if (!empty($_FILES) || GETPOSTISSET(
'templateuserfile')) {
2461 $pathtomedias = DOL_DATA_ROOT.
'/medias';
2462 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
2464 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
2465 dol_mkdir(dirname($pathtomediasinwebsite));
2466 $result = symlink($pathtomedias, $pathtomediasinwebsite);
2468 $langs->load(
"errors");
2469 setEventMessages($langs->trans(
"ErrorFailedToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias),
null,
'errors');
2470 $action =
'importsite';
2475 if (GETPOSTISSET(
'templateuserfile')) {
2477 $fileofzip = DOL_DATA_ROOT.
'/doctemplates/websites/'.
GETPOST(
'templateuserfile',
'alpha');
2478 } elseif (!empty($_FILES) && is_array($_FILES[
'userfile'])) {
2480 if (is_array($_FILES[
'userfile'][
'tmp_name'])) {
2481 $userfiles = $_FILES[
'userfile'][
'tmp_name'];
2483 $userfiles = array($_FILES[
'userfile'][
'tmp_name']);
2487 foreach ($userfiles as $key => $userfile) {
2488 if (empty($_FILES[
'userfile'][
'tmp_name'][$key])) {
2490 if ($_FILES[
'userfile'][
'error'][$key] == 1 || $_FILES[
'userfile'][
'error'][$key] == 2) {
2492 $action =
'importsite';
2494 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"File")),
null,
'errors');
2495 $action =
'importsite';
2502 $upload_dir = DOL_DATA_ROOT.
'/doctemplates/websites/';
2516 $action =
'importsite';
2519 if (!$error && GETPOSTISSET(
'templateuserfile')) {
2520 $result = $object->importWebSite($fileofzip);
2524 $action =
'importsite';
2527 dolibarr_set_const($db,
'WEBSITE_SUBCONTAINERSINLINE', 1,
'chaine', 0,
'', $conf->entity);
2529 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$object->ref);
2538 $message = $langs->trans(
'InstallModuleFromWebHasBeenDisabledContactUs');
2541 $message = $langs->trans(
"InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.
'/installmodules.lock');
2547$domainname =
'0.0.0.0:8080';
2548$tempdir = $conf->website->dir_output.
'/'.$websitekey.
'/';
2551if ($action ==
'generatesitemaps' && $usercanedit) {
2553 if ($website->virtualhost) {
2554 $domainname = $website->virtualhost;
2556 if (! preg_match(
'/^http/i', $domainname)) {
2557 $domainname =
'https://'.$domainname;
2560 $domtree =
new DOMDocument(
'1.0',
'UTF-8');
2562 $root = $domtree->createElementNS(
'http://www.sitemaps.org/schemas/sitemap/0.9',
'urlset');
2563 $root->setAttributeNS(
'http://www.w3.org/2000/xmlns/',
'xmlns:xhtml',
'http://www.w3.org/1999/xhtml');
2565 $domtree->formatOutput =
true;
2568 $xmlname =
'sitemap.xml';
2570 $sql =
"SELECT wp.rowid, wp.type_container , wp.pageurl, wp.lang, wp.fk_page, wp.tms as tms,";
2571 $sql .=
" w.virtualhost, w.fk_default_home";
2572 $sql .=
" FROM ".MAIN_DB_PREFIX.
"website_page as wp, ".MAIN_DB_PREFIX.
"website as w";
2573 $sql .=
" WHERE wp.type_container IN ('page', 'blogpost')";
2574 $sql .=
" AND wp.fk_website = w.rowid";
2575 $sql .=
" AND wp.status = ".WebsitePage::STATUS_VALIDATED;
2576 $sql .=
" AND wp.pageurl NOT IN ('404', '500', '501', '503')";
2577 $sql .=
" AND w.ref = '".dol_escape_json($websitekey).
"'";
2578 $sql .=
" ORDER BY wp.tms DESC, wp.rowid DESC";
2579 $resql = $db->query($sql);
2581 $num_rows = $db->num_rows($resql);
2582 if ($num_rows > 0) {
2584 while ($i < $num_rows) {
2585 $objp = $db->fetch_object($resql);
2586 $url = $domtree->createElement(
'url');
2588 $shortlangcode =
'';
2590 $shortlangcode = substr($objp->lang, 0, 2);
2592 if (empty($shortlangcode)) {
2593 $shortlangcode = substr($object->lang, 0, 2);
2597 if ($objp->type_container ==
'blogpost') {
2602 $pageurl = $objp->pageurl.
'.php';
2603 if ($objp->fk_default_home == $objp->rowid) {
2606 if ($shortlangcode != substr($object->lang, 0, 2)) {
2607 $pageurl = $shortlangcode.
'/'.$pageurl;
2614 $loc = $domtree->createElement(
'loc', $domainname.
'/'.$pageurl);
2615 $lastmod = $domtree->createElement(
'lastmod',
dol_print_date($db->jdate($objp->tms),
'dayrfc',
'gmt'));
2616 $priority = $domtree->createElement(
'priority',
'1');
2618 $url->appendChild($loc);
2619 $url->appendChild($lastmod);
2622 $changefreq = $domtree->createElement(
'changefreq',
'weekly');
2623 $url->appendChild($changefreq);
2626 if ($objp->fk_default_home == $objp->rowid) {
2627 $url->appendChild($priority);
2631 if ($object->isMultiLang()) {
2632 $alternatefound = 0;
2635 $translationof = $objp->fk_page;
2636 if ($translationof) {
2638 $tmppage->fetch($translationof);
2639 if ($tmppage->id > 0) {
2640 $tmpshortlangcode =
'';
2641 if ($tmppage->lang) {
2642 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'', $tmppage->lang);
2644 if (empty($tmpshortlangcode)) {
2645 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'', $object->lang);
2647 if ($tmpshortlangcode != $shortlangcode) {
2648 $xhtmllink = $domtree->createElement(
'xhtml:link',
'');
2649 $xhtmllink->setAttribute(
"rel",
"alternate");
2650 $xhtmllink->setAttribute(
"hreflang", $tmpshortlangcode);
2651 $xhtmllink->setAttribute(
"href", $domainname.($objp->fk_default_home == $tmppage->id ?
'/' : (($tmpshortlangcode != substr($object->lang, 0, 2)) ?
'/'.$tmpshortlangcode :
'').
'/'.$tmppage->pageurl.
'.php'));
2652 $url->appendChild($xhtmllink);
2660 $sql =
'SELECT rowid as id, lang, pageurl from '.MAIN_DB_PREFIX.
'website_page';
2661 $sql .=
" WHERE status = ".((int) WebsitePage::STATUS_VALIDATED).
' AND fk_page IN ('.$db->sanitize($objp->rowid.($translationof ?
", ".$translationof :
"")).
")";
2662 $resqlhastrans = $db->query($sql);
2663 if ($resqlhastrans) {
2664 $num_rows_hastrans = $db->num_rows($resqlhastrans);
2665 if ($num_rows_hastrans > 0) {
2666 while ($objhastrans = $db->fetch_object($resqlhastrans)) {
2667 $tmpshortlangcode =
'';
2668 if ($objhastrans->lang) {
2669 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'', $objhastrans->lang);
2671 if ($tmpshortlangcode != $shortlangcode) {
2672 $xhtmllink = $domtree->createElement(
'xhtml:link',
'');
2673 $xhtmllink->setAttribute(
"rel",
"alternate");
2674 $xhtmllink->setAttribute(
"hreflang", $tmpshortlangcode);
2675 $xhtmllink->setAttribute(
"href", $domainname.($objp->fk_default_home == $objhastrans->id ?
'/' : (($tmpshortlangcode != substr($object->lang, 0, 2) ?
'/'.$tmpshortlangcode :
'')).
'/'.$objhastrans->pageurl.
'.php'));
2676 $url->appendChild($xhtmllink);
2686 if ($alternatefound) {
2688 $xhtmllink = $domtree->createElement(
'xhtml:link',
'');
2689 $xhtmllink->setAttribute(
"rel",
"alternate");
2690 $xhtmllink->setAttribute(
"hreflang", $shortlangcode);
2691 $xhtmllink->setAttribute(
"href", $domainname.
'/'.$pageurl);
2692 $url->appendChild($xhtmllink);
2708 $root->appendChild($url);
2714 if ($addrsswrapper &&
getDolGlobalInt(
'WEBSITE_ADD_RSS_FEED_INTO_SITEMAP')) {
2715 $url = $domtree->createElement(
'url');
2717 $pageurl =
'wrapper.php?rss=1';
2720 $loc = $domtree->createElement(
'loc', $domainname.
'/'.$pageurl);
2721 $lastmod = $domtree->createElement(
'lastmod',
dol_print_date($db->jdate(
dol_now()),
'dayrfc',
'gmt'));
2723 $url->appendChild($loc);
2724 $url->appendChild($lastmod);
2727 $changefreq = $domtree->createElement(
'changefreq',
'weekly');
2728 $url->appendChild($changefreq);
2731 $root->appendChild($url);
2734 $domtree->appendChild($root);
2736 if ($domtree->save($tempdir.$xmlname)) {
2738 setEventMessages($langs->trans(
"SitemapGenerated", $xmlname),
null,
'mesgs');
2748 $robotcontent = @file_get_contents($filerobot);
2749 $result = preg_replace(
'/<?php \/\/ BEGIN PHP[^?]END PHP ?>\n/ims',
'', $robotcontent);
2751 $robotcontent = $result;
2753 $robotsitemap =
"Sitemap: ".$domainname.
"/".$xmlname;
2754 $result = strpos($robotcontent,
'Sitemap: ');
2756 $result = preg_replace(
'/Sitemap:.*/', $robotsitemap, $robotcontent);
2757 $robotcontent = $result ? $result : $robotcontent;
2759 $robotcontent .= $robotsitemap.
"\n";
2766 $action =
'preview';
2774$form =
new Form($db);
2781if ($action ==
'confirmgeneratesitemaps') {
2782 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?website='.urlencode($website->ref), $langs->trans(
'ConfirmSitemapsCreation'), $langs->trans(
'ConfirmGenerateSitemaps', $object->ref),
'generatesitemaps',
'',
"yes", 1);
2783 $action =
'preview';
2785$helpurl =
'EN:Module_Website|FR:Module_Website_FR|ES:Módulo_Website';
2788 '/includes/ace/src/ace.js',
2789 '/includes/ace/src/ext-statusbar.js',
2790 '/includes/ace/src/ext-language_tools.js',
2794$arrayofcss = array();
2799$arrayofjs[] =
'includes/jquery/plugins/blockUI/jquery.blockUI.js';
2800$arrayofjs[] =
'core/js/blockUI.js';
2802 $arrayofjs[] =
"includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js";
2805$moreheadjs .=
'<script type="text/javascript">'.
"\n";
2806$moreheadjs .=
'var indicatorBlockUI = \''.DOL_URL_ROOT.
"/theme/".$conf->theme.
"/img/working.gif".
'\';
'."\n";
2807$moreheadjs .= '</script>
'."\n";
2809llxHeader($moreheadcss.$moreheadjs, $langs->trans("Website").(empty($website->ref) ? '' : ' -
'.$website->ref), $helpurl, '', 0, 0, $arrayofjs, $arrayofcss, '', '', '<!-- Begin div
class=
"fiche" -->
'."\n".'<div
class=
"fichebutwithotherclass">
');
2812print '<!-- Open form
for all page -->
'."\n";
2813print '<form action=
"'.$_SERVER["PHP_SELF
"].($action == 'file_manager' ? '?uploadform=1' : '').'" method=
"POST" enctype=
"multipart/form-data" class=
"websiteformtoolbar">
';
2814print '<input
type=
"hidden" name=
"token" value=
"'.newToken().'">
';
2815print '<input
type=
"hidden" name=
"backtopage" value=
"'.$backtopage.'">
';
2816print '<input
type=
"hidden" name=
"dol_openinpopup" value=
"'.$dol_openinpopup.'">
';
2818if ($action == 'createsite
') {
2819 print '<input
type=
"hidden" name=
"action" value=
"addsite">
';
2821if ($action == 'createcontainer
') {
2822 print '<input
type=
"hidden" name=
"action" value=
"addcontainer">
';
2824if ($action == 'editcss
') {
2825 print '<input
type=
"hidden" name=
"action" value=
"updatecss">
';
2827if ($action == 'editmenu
') {
2828 print '<input
type=
"hidden" name=
"action" value=
"updatemenu">
';
2830if ($action == 'setashome
') {
2831 print '<input
type=
"hidden" name=
"action" value=
"updateashome">
';
2833if ($action == 'editmeta
') {
2834 print '<input
type=
"hidden" name=
"action" value=
"updatemeta">
';
2836if ($action == 'editsource
') {
2837 print '<input
type=
"hidden" name=
"action" value=
"updatesource">
';
2839if ($action == 'editcontent
') {
2840 print '<input
type=
"hidden" name=
"action" value=
"updatecontent">
';
2842if ($action == 'edit
') {
2843 print '<input
type=
"hidden" name=
"action" value=
"update">
';
2845if ($action == 'importsite
') {
2846 print '<input
type=
"hidden" name=
"action" value=
"importsiteconfirm">
';
2848if ($action == 'file_manager
') {
2849 print '<input
type=
"hidden" name=
"action" value=
"file_manager">
';
2852 print '<input
type=
"hidden" name=
"mode" value=
"'.$mode.'">
';
2857// Add a margin under toolbar ?
2859if ($action != 'preview
' && $action != 'editcontent
' && $action != 'editsource
' && !GETPOST('createpagefromclone
', 'alphanohtml
')) {
2860 $style = ' margin-bottom: 5px;
';
2864if (!GETPOST('hide_websitemenu
')) {
2866 if (!$user->hasRight('website
', 'write
')) {
2867 $disabled = ' disabled=
"disabled"';
2869 $disabledexport = '';
2870 if (!$user->hasRight('website
', 'export
')) {
2871 $disabledexport = ' disabled=
"disabled"';
2876 $dataroot = DOL_DATA_ROOT.($conf->entity > 1 ? '/
'.$conf->entity : '').'/website/
'.$websitekey;
2877 if (!empty($object->virtualhost)) {
2878 $virtualurl = $object->virtualhost;
2883 if ($object->id > 0) {
2884 $array = $objectpage->fetchAll($object->id, 'ASC,ASC
', 'type_container,pageurl
');
2885 $object->lines = $array;
2887 if (!is_array($array) && $array < 0) {
2888 dol_print_error('', $objectpage->error, $objectpage->errors);
2890 $atleastonepage = (is_array($array) && count($array) > 0);
2892 $websitepage = new WebsitePage($db);
2894 $websitepage->fetch($pageid);
2898 //var_dump($objectpage);exit;
2899 print '<div
class=
"centpercent websitebar'.(GETPOST('dol_openinpopup', 'aZ09') ? ' hiddenforpopup' : '').'">
';
2902 // Toolbar for websites
2905 print '<!-- Toolbar
for website -->
';
2906 if ($action != 'file_manager
') {
2907 print '<div
class=
"websiteselection hideonsmartphoneimp minwidth75 tdoverflowmax100 inline-block">
';
2908 print $langs->trans("Website").':
';
2911 // Button Add new website
2912 $urltocreatenewwebsite = $_SERVER["PHP_SELF"].'?action=createsite
';
2913 print '<span
class=
"websiteselection paddingrightonly">
';
2914 print '<a href=
"'.$urltocreatenewwebsite.'" class=
""'.$disabled.' title=
"'.dol_escape_htmltag($langs->trans("AddWebsite
")).'"><span
class=
"fa fa-plus-circle valignmiddle btnTitle-icon"><span></a>
';
2918 print '<span
class=
"websiteselection nopaddingrightimp">
';
2921 $out .= '<select
name=
"website" class=
"minwidth100 width200 maxwidth150onsmartphone" id=
"website">
';
2922 if (empty($listofwebsites)) {
2923 $out .= '<option value=
"-1"> </option>
';
2926 // Loop on each sites
2928 foreach ($listofwebsites as $key => $valwebsite) {
2929 if (empty($websitekey)) {
2930 if ($action != 'createsite
') {
2931 $websitekey = $valwebsite->ref;
2935 $out .= '<option value=
"'.$valwebsite->ref.'"';
2936 if ($websitekey == $valwebsite->ref) {
2937 $out .= ' selected
'; // To preselect a value
2939 //$outoption = $valwebsite->getLibStatut(3).' '.$valwebsite->ref.' ';
2940 $outoption = (($valwebsite->status == $valwebsite::STATUS_DRAFT) ? '<span
class=
"opacitymedium">
' : '').$valwebsite->ref.(($valwebsite->status == $valwebsite::STATUS_DRAFT) ? '</span>
' : '');
2941 $out .= ' data-html=
"'.dol_escape_htmltag($outoption).'"';
2943 $out .= $valwebsite->ref;
2944 $out .= '</option>
';
2947 $out .= '</select>
';
2948 $out .= ajax_combobox('website
');
2950 if (!empty($conf->use_javascript_ajax)) {
2951 $out .= '<script
type=
"text/javascript">
';
2952 $out .= 'jQuery(document).ready(
function () {
';
2953 $out .= ' jQuery(
"#website").change(
function () {
';
2954 $out .= ' console.log(
"We select "+jQuery(
"#website option:selected").val());
';
2955 $out .= ' if (jQuery(
"#website option:selected").val() == \
'-2\') {';
2956 $out .=
' window.location.href = "'.dol_escape_js($urltocreatenewwebsite).
'";';
2957 $out .=
' } else {';
2958 $out .=
' window.location.href = "'.$_SERVER[
"PHP_SELF"].
'?website="+jQuery("#website option:selected").val();';
2962 $out .=
'</script>';
2969 if (!empty($conf->use_javascript_ajax)) {
2970 print
'<span class="websiteselection">';
2975 if ($website->status == $website::STATUS_DRAFT) {
2976 $text_off =
'Offline';
2977 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setwebsiteonline&token='.newToken().
'&website='.urlencode($website->ref).
'&websitepage='.((int) $websitepage->id).
'">'.
img_picto($langs->trans($text_off),
'switch_off').
'</a>';
2979 $text_off =
'Online';
2980 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setwebsiteoffline&token='.newToken().
'&website='.urlencode($website->ref).
'&websitepage='.((int) $websitepage->id).
'">'.
img_picto($langs->trans($text_off),
'switch_on').
'</a>';
2986 if (empty($conf->use_javascript_ajax)) {
2987 print
'<span class="websiteselection">';
2988 print
'<input type="image" class="valignmiddle" src="'.img_picto(
'',
'refresh',
'', 0, 1).
'" name="refreshsite" value="'.$langs->trans(
"Load").
'">';
2993 print
'<span class="websiteselection">';
2995 if ($websitekey && $websitekey !=
'-1' && ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite')) {
2997 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?website='.urlencode($object->ref).
'&pageid='.((int) $pageid).
'&action=editcss&token='.newToken().
'" class="button bordertransp" title="'.
dol_escape_htmltag($langs->trans(
"EditCss")).
'"'.$disabled.
'><span class="fa fa-cog paddingrightonly"></span><span class="hideonsmartphone">'.
dol_escape_htmltag($langs->trans(
"EditCss")).
'</span></a>';
3000 $importlabel = $langs->trans(
"ImportSite");
3001 $exportlabel = $langs->trans(
"ExportSite");
3002 if (!empty($conf->dol_optimize_smallscreen)) {
3003 $importlabel = $langs->trans(
"Import");
3004 $exportlabel = $langs->trans(
"Export");
3007 if ($atleastonepage) {
3008 print
'<input type="submit" class="button bordertransp" disabled="disabled" value="'.dol_escape_htmltag($importlabel).
'" name="importsite">';
3010 print
'<input type="submit" class="button bordertransp"'.$disabled.
' value="'.
dol_escape_htmltag($importlabel).
'" name="importsite">';
3014 print
'<input type="submit" class="button bordertransp"'.$disabledexport.
' value="'.
dol_escape_htmltag($exportlabel).
'" name="exportsite">';
3017 print
'<input type="submit" class="button bordertransp"'.$disabled.
' value="'.
dol_escape_htmltag($langs->trans(
"CloneSite")).
'" name="createfromclone">';
3020 if (!$permissiontodelete) {
3021 $disabled =
' disabled="disabled"';
3022 $title = $langs->trans(
"NotEnoughPermissions");
3025 if ($website->status == $website::STATUS_VALIDATED) {
3026 $disabled =
' disabled="disabled"';
3027 $title = $langs->trans(
"WebsiteMustBeDisabled", $langs->transnoentitiesnoconv($website->LibStatut(0, 0)));
3031 $title = $langs->trans(
"Delete");
3032 $url = $_SERVER[
"PHP_SELF"].
'?action=deletesite&token='.newToken().
'&website='.urlencode($website->ref);
3035 print
'<a href="'.$url.
'" class="button buttonDelete bordertransp'.($disabled ?
' disabled' :
'').
'"'.$disabled.
' title="'.
dol_escape_htmltag($title).
'">'.
img_picto(
'',
'delete',
'class=""').
'<span class="hideonsmartphone paddingleft">'.$langs->trans(
"Delete").
'</span></a>';
3038 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=regeneratesite&token='.newToken().
'&website='.urlencode($website->ref).
'" class="button bordertransp"'.$disabled.
' title="'.
dol_escape_htmltag($langs->trans(
"RegenerateWebsiteContent")).
'"><span class="far fa-hdd"></span></a>';
3041 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=confirmgeneratesitemaps&token='.newToken().
'&website='.urlencode($website->ref).
'" class="button bordertransp"'.$disabled.
' title="'.
dol_escape_htmltag($langs->trans(
"GenerateSitemaps")).
'"><span class="fa fa-sitemap"></span></a>';
3044 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=replacesite&website='.urlencode($website->ref).
'" class="button bordertransp"'.$disabled.
' title="'.
dol_escape_htmltag($langs->trans(
"ReplaceWebsiteContent")).
'"><span class="fa fa-search"></span></a>';
3049 if ($websitekey && $websitekey !=
'-1' && ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite')) {
3050 print
'<span class="websiteselection">';
3052 print
dolButtonToOpenUrlInDialogPopup(
'file_manager', $langs->transnoentitiesnoconv(
"MediaFiles"),
'<span class="fa fa-image"></span>',
'/website/index.php?action=file_manager&website='.urlencode($website->ref).
'§ion_dir='.urlencode(
'image/'.$website->ref.
'/'), $disabled);
3054 if (isModEnabled(
'categorie')) {
3056 print
dolButtonToOpenUrlInDialogPopup(
'categories', $langs->transnoentitiesnoconv(
"Categories"),
'<span class="fa fa-tags"></span>',
'/categories/index.php?leftmenu=website&nosearch=1&type=website_page&website='.urlencode($website->ref), $disabled);
3062 print
'<input type="hidden" name="website" id="website" value="'.$websitekey.
'">';
3066 print
'<span class="websitetools">';
3068 if ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite') {
3069 $urlext = $virtualurl;
3070 $urlint = $urlwithroot.
'/public/website/index.php?website='.$websitekey;
3072 print
'<span class="websiteinputurl valignmiddle" id="websiteinputurl">';
3073 $linktotestonwebserver =
'<a href="'.($virtualurl ? $virtualurl :
'#').
'" class="valignmiddle">';
3074 $linktotestonwebserver .=
'<span class="hideonsmartphone paddingrightonly">'.$langs->trans(
"TestDeployOnWeb", $virtualurl).
'</span>'.
img_picto(
'',
'globe');
3075 $linktotestonwebserver .=
'</a>';
3077 if (empty($object->fk_default_home)) {
3078 $htmltext .=
'<br><span class="error">'.$langs->trans(
"YouMustDefineTheHomePage").
'</span><br><br>';
3079 } elseif (empty($virtualurl)) {
3082 $htmltext .=
'<br><center>'.$langs->trans(
"GoTo").
' <a href="'.$virtualurl.
'" target="_website">'.$virtualurl.
'</a></center><br>';
3085 $htmltext .=
'<!-- Message defined translate key set into WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER -->';
3086 $htmltext .=
'<br>'.$langs->trans($conf->global->WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER);
3088 $htmltext .= $langs->trans(
"SetHereVirtualHost", $dataroot);
3089 $htmltext .=
'<br>';
3090 $htmltext .=
'<br>'.$langs->trans(
"CheckVirtualHostPerms", $langs->transnoentitiesnoconv(
"ReadPerm"), DOL_DOCUMENT_ROOT);
3091 $htmltext .=
'<br>'.$langs->trans(
"CheckVirtualHostPerms", $langs->transnoentitiesnoconv(
"WritePerm"),
'{s1}');
3092 $htmltext = str_replace(
'{s1}', DOL_DATA_ROOT.
'/website<br>'.DOL_DATA_ROOT.
'/medias', $htmltext);
3094 $examplewithapache =
'#php_admin_value open_basedir /tmp/:'.DOL_DOCUMENT_ROOT.
':'.DOL_DATA_ROOT.
':/dev/urandom'.
"\n";
3095 $examplewithapache .=
'<Directory "'.DOL_DOCUMENT_ROOT.
'">'.
"\n";
3096 $examplewithapache .=
'AllowOverride FileInfo Options
3097 Options -Indexes -MultiViews -FollowSymLinks -ExecCGI
3100 <Directory "'.DOL_DATA_ROOT.
'/website">
3101 AllowOverride FileInfo Options
3102 Options -Indexes -MultiViews +FollowSymLinks -ExecCGI
3105 <Directory "'.DOL_DATA_ROOT.
'/medias">
3106 AllowOverride FileInfo Options
3107 Options -Indexes -MultiViews -FollowSymLinks -ExecCGI
3111 $htmltext .=
'<br>'.$langs->trans(
"ExampleToUseInApacheVirtualHostConfig").
':<br>';
3112 $htmltext .=
'<div class="centpercent exampleapachesetup">'.dol_nl2br(
dol_escape_htmltag($examplewithapache, 1, 1)).
'</div>';
3114 $htmltext .=
'<br>';
3115 $htmltext .= $langs->trans(
"YouCanAlsoTestWithPHPS", $dataroot);
3116 $htmltext .=
'<br>';
3117 $htmltext .=
'<br>';
3118 $htmltext .= $langs->trans(
"YouCanAlsoDeployToAnotherWHP");
3120 print $form->textwithpicto($linktotestonwebserver, $htmltext, 1,
'none',
'valignmiddle', 0, 3,
'helpvirtualhost');
3124 if (in_array($action, array(
'editcss',
'editmenu',
'file_manager',
'replacesiteconfirm')) || in_array($mode, array(
'replacesite'))) {
3125 if ($action ==
'editcss') {
3126 print
'<input type="submit" id="savefileandstay" class="button buttonforacesave hideonsmartphone small" value="'.dol_escape_htmltag($langs->trans(
"SaveAndStay")).
'" name="updateandstay">';
3128 if (preg_match(
'/^create/', $action) && $action !=
'file_manager' && $action !=
'replacesite' && $action !=
'replacesiteconfirm') {
3129 print
'<input type="submit" id="savefile" class="button buttonforacesave button-save small" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
3131 if (preg_match(
'/^edit/', $action) && $action !=
'file_manager' && $action !=
'replacesite' && $action !=
'replacesiteconfirm') {
3132 print
'<input type="submit" id="savefile" class="button buttonforacesave button-save small" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
3134 if ($action !=
'preview') {
3135 print
'<input type="submit" class="button button-cancel small" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'" name="cancel">';
3145 if ($websitekey && $websitekey !=
'-1' && (!in_array($action, array(
'editcss',
'editmenu',
'importsite',
'file_manager',
'replacesite',
'replacesiteconfirm'))) && (!in_array($mode, array(
'replacesite'))) && !$file_manager) {
3148 print
'<!-- Toolbar for websitepage -->';
3149 print
'<div class="centpercent websitebar"'.($style ?
' style="'.$style.
'"' :
'').
'>';
3151 print
'<div class="websiteselection hideonsmartphoneimp minwidth75 tdoverflowmax100 inline-block">';
3152 print $langs->trans(
"PageContainer").
': ';
3156 print
'<span class="websiteselection paddingrightonly">';
3157 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=createcontainer&token='.newToken().
'&website='.urlencode($website->ref).
'" class=""'.$disabled.
' title="'.
dol_escape_htmltag($langs->trans(
"AddPage")).
'"><span class="fa fa-plus-circle valignmiddle btnTitle-icon"></span></a>';
3163 $s = $formwebsite->selectContainer($website,
'pageid', $pageid, 0, $action,
'minwidth100 maxwidth200onsmartphone');
3165 $out .=
'<span class="websiteselection nopaddingrightimp">';
3169 $urltocreatenewpage = $_SERVER[
"PHP_SELF"].
'?action=createcontainer&token='.newToken().
'&website='.urlencode($website->ref);
3171 if (!empty($conf->use_javascript_ajax)) {
3172 $out .=
'<script type="text/javascript">';
3173 $out .=
'jQuery(document).ready(function () {';
3174 $out .=
' jQuery("#pageid").change(function () {';
3175 $out .=
' console.log("We select "+jQuery("#pageid option:selected").val());';
3176 $out .=
' if (jQuery("#pageid option:selected").val() == \'-2\') {';
3177 $out .=
' window.location.href = "'.$urltocreatenewpage.
'";';
3178 $out .=
' } else {';
3179 $out .=
' window.location.href = "'.$_SERVER[
"PHP_SELF"].
'?website='.urlencode($website->ref).
'&pageid="+jQuery("#pageid option:selected").val();';
3183 $out .=
'</script>';
3188 if (!empty($conf->use_javascript_ajax)) {
3189 print
'<span class="websiteselection">';
3191 if ($object->status == $object::STATUS_DRAFT) {
3192 $text_off =
'SetWebsiteOnlineBefore';
3193 if ($websitepage->status == $websitepage::STATUS_DRAFT) {
3194 print
'<span class="valignmiddle disabled opacitymedium">'.img_picto($langs->trans($text_off),
'switch_off').
'</span>';
3196 print
'<span class="valignmiddle disabled opacitymedium">'.img_picto($langs->trans($text_off),
'switch_on').
'</span>';
3199 print
ajax_object_onoff($websitepage,
'status',
'status',
'Online',
'Offline', array(),
'valignmiddle inline-block'.(empty($websitepage->id) ?
' opacitymedium disabled' :
''),
'statuswebsitepage');
3205 print
'<span class="websiteselection">';
3207 print
'<input type="image" class="valignmiddle buttonwebsite" src="'.img_picto(
'',
'refresh',
'', 0, 1).
'" name="refreshpage" value="'.$langs->trans(
"Load").
'"'.(($action !=
'editsource') ?
'' :
' disabled="disabled"').
'>';
3210 $pagepreviousid = 0;
3213 $sql =
"SELECT MAX(rowid) as pagepreviousid FROM ".MAIN_DB_PREFIX.
"website_page WHERE rowid < ".((int) $pageid).
" AND fk_website = ".((int) $object->id);
3214 $resql = $db->query($sql);
3216 $obj = $db->fetch_object($resql);
3218 $pagepreviousid = $obj->pagepreviousid;
3223 $sql =
"SELECT MIN(rowid) as pagenextid FROM ".MAIN_DB_PREFIX.
"website_page WHERE rowid > ".((int) $pageid).
" AND fk_website = ".((int) $object->id);
3224 $resql = $db->query($sql);
3226 $obj = $db->fetch_object($resql);
3228 $pagenextid = $obj->pagenextid;
3235 if ($pagepreviousid) {
3236 print
'<a class="valignmiddle" href="'.$_SERVER[
'PHP_SELF'].
'?website='.urlencode($object->ref).
'&pageid='.((int) $pagepreviousid).
'&action='.urlencode($action).
'&token='.newToken().
'">'.
img_previous($langs->trans(
"PreviousContainer")).
'</a>';
3238 print
'<span class="valignmiddle opacitymedium">'.img_previous($langs->trans(
"PreviousContainer")).
'</span>';
3241 print
'<a class="valignmiddle" href="'.$_SERVER[
'PHP_SELF'].
'?website='.urlencode($object->ref).
'&pageid='.((int) $pagenextid).
'&action='.urlencode($action).
'&token='.newToken().
'">'.
img_next($langs->trans(
"NextContainer")).
'</a>';
3243 print
'<span class="valignmiddle opacitymedium">'.img_next($langs->trans(
"NextContainer")).
'</span>';
3248 if ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite') {
3250 if (!$user->hasRight(
'website',
'write')) {
3251 $disabled =
' disabled="disabled"';
3255 if ($action ==
'deletesite') {
3257 $formquestion = array(
3258 array(
'type' =>
'checkbox',
'name' =>
'delete_also_js',
'label' => $langs->trans(
"DeleteAlsoJs"),
'value' => 0),
3259 array(
'type' =>
'checkbox',
'name' =>
'delete_also_medias',
'label' => $langs->trans(
"DeleteAlsoMedias"),
'value' => 0),
3264 if ($atleastonepage) {
3265 $langs->load(
"errors");
3266 $formquestion[] = array(
'type' =>
'onecolumn',
'value' =>
'<div class="warning">'.$langs->trans(
"WarningPagesWillBeDeleted").
'</div>');
3269 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeleteWebsite'),
'',
'confirm_deletesite', $formquestion, 0, 1, 210 + ($atleastonepage ? 70 : 0), 580);
3275 if ($action ==
'createfromclone') {
3277 $formquestion = array(
3278 array(
'type' =>
'text',
'name' =>
'siteref',
'label'=> $langs->trans(
"WebSite"),
'value'=>
'copy_of_'.$object->ref)
3281 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'CloneSite'),
'',
'confirm_createfromclone', $formquestion, 0, 1, 200);
3286 if ($pageid > 0 && $atleastonepage) {
3288 if ($action ==
'createpagefromclone') {
3290 $preselectedlanguage =
GETPOST(
'newlang',
'aZ09') ?
GETPOST(
'newlang',
'aZ09') :
'';
3291 $onlylang = array();
3292 if ($website->otherlang) {
3293 if (!empty($website->lang)) {
3294 $onlylang[$website->lang] = $website->lang.
' ('.$langs->trans(
"Default").
')';
3296 foreach (explode(
',', $website->otherlang) as $langkey) {
3297 if (empty(trim($langkey))) {
3300 $onlylang[$langkey] = $langkey;
3302 $textifempty = $langs->trans(
"Default");
3304 $onlylang[
'none'] =
'none';
3305 $textifempty = $langs->trans(
"Default");
3307 $formquestion = array(
3308 array(
'type' =>
'hidden',
'name' =>
'sourcepageurl',
'value'=> $objectpage->pageurl),
3309 array(
'type' =>
'other',
'tdclass'=>
'fieldrequired',
'name' =>
'newwebsite',
'label' => $langs->trans(
"WebSite"),
'value' => $formwebsite->selectWebsite($object->id,
'newwebsite', 0)),
3310 array(
'type' =>
'text',
'tdclass'=>
'maxwidth200 fieldrequired',
'moreattr'=>
'autofocus="autofocus"',
'name' =>
'newtitle',
'label'=> $langs->trans(
"WEBSITE_TITLE"),
'value'=> $langs->trans(
"CopyOf").
' '.$objectpage->title),
3311 array(
'type' =>
'text',
'tdclass'=>
'maxwidth200',
'name' =>
'newpageurl',
'label'=> $langs->trans(
"WEBSITE_PAGENAME"),
'value'=>
'')
3313 if (count($onlylang) > 1) {
3314 $formquestion[] = array(
'type' =>
'checkbox',
'tdclass'=>
'maxwidth200',
'name' =>
'is_a_translation',
'label' => $langs->trans(
"PageIsANewTranslation"),
'value' => 0,
'morecss'=>
'margintoponly');
3317 $value= $formadmin->select_language($preselectedlanguage,
'newlang', 0,
null, $textifempty, 0, 0,
'minwidth200', 1, 0, 0, $onlylang, 1);
3318 $formquestion[] = array(
'type' =>
'other',
'name' =>
'newlang',
'label' => $form->textwithpicto($langs->trans(
"Language"), $langs->trans(
"DefineListOfAltLanguagesInWebsiteProperties")),
'value' => $value);
3320 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?website='.$object->ref.
'&pageid='.$pageid, $langs->trans(
'ClonePage'),
'',
'confirm_createpagefromclone', $formquestion, 0, 1, 300, 550);
3325 print
'<span class="websiteselection">';
3328 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?website='.$object->ref.
'&pageid='.$pageid.
'&action=editmeta&token='.newToken().
'" class="button bordertransp" title="'.
dol_escape_htmltag($langs->trans(
"EditPageMeta")).
'"'.$disabled.
'><span class="fa fa-cog paddingrightonly"></span><span class="hideonsmartphone">'.
dol_escape_htmltag($langs->trans(
"EditPageMeta")).
'</span></a>';
3331 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?website='.$object->ref.
'&pageid='.$pageid.
'&action=editsource&token='.newToken().
'" class="button bordertransp"'.$disabled.
'>'.
dol_escape_htmltag($langs->trans($conf->dol_optimize_smallscreen ?
"HTML" :
"EditHTMLSource")).
'</a>';
3335 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?website='.$object->ref.
'&pageid='.$pageid.
'&action=editcontent&token='.newToken().
'" class="button bordertransp"'.$disabled.
'>'.
dol_escape_htmltag($langs->trans($conf->dol_optimize_smallscreen ?
"CKEditor" :
"CKEditor")).
'</a>';
3342 print
'<!-- button EditInLine and ShowSubcontainers -->'.
"\n";
3343 print
'<div class="websiteselectionsection inline-block">';
3345 print
'<div class="inline-block marginrightonly">';
3346 print $langs->trans(
"ShowSubcontainers");
3348 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>';
3350 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>';
3354 print
'<div class="inline-block marginrightonly">';
3356 print
'<span id="switchckeditorinline">'.
"\n";
3358 print
'<!-- Code to enabled edit inline ckeditor -->'.
"\n";
3359 print
'<script type="text/javascript">
3360 $(document).ready(function() {
3361 var isEditingEnabled = '.(getDolGlobalString(
"WEBSITE_EDITINLINE") ?
'true' :
'false').
';
3362 if (isEditingEnabled)
3364 switchEditorOnline(true);
3367 $( "#switchckeditorinline" ).click(function() {
3368 switchEditorOnline();
3371 function switchEditorOnline(forceenable)
3373 if (! isEditingEnabled || forceenable)
3375 console.log("Enable inline edit");
3377 jQuery(\'section[contenteditable="true"],div[contenteditable="true"]\').each(function(idx){
3378 var idtouse = $(this).attr(\'id\');
3379 console.log("Enable inline edit for "+idtouse);
3380 if (idtouse !== undefined) {
3381 var inlineditor = CKEDITOR.inline(idtouse, {
3382 // Allow some non-standard markup that we used in the introduction.
3383 // + a[target];div{float,display} ?
3384 extraAllowedContent: \'span(*);cite(*);q(*);dl(*);dt(*);dd(*);ul(*);li(*);header(*);button(*);h1(*);h2(*);\',
3385 //extraPlugins: \'sourcedialog\',
3386 removePlugins: \'flash,stylescombo,exportpdf,scayt,wsc,pagebreak,iframe,smiley\',
3387 // Show toolbar on startup (optional).
3388 // startupFocus: true
3392 // Note the Source tool does not work on inline
3393 inlineditor.config.toolbar = [
3394 [\'Templates\',\'NewPage\'],
3396 [\'Maximize\',\'Preview\'],
3398 [\'Undo\',\'Redo\',\'-\',\'Find\',\'Replace\',\'-\',\'SelectAll\',\'RemoveFormat\'],
3399 [\'CreateDiv\',\'ShowBlocks\'],
3400 [\'Form\', \'Checkbox\', \'Radio\', \'TextField\', \'Textarea\', \'Select\', \'Button\', \'ImageButton\', \'HiddenField\'],
3401 [\'Bold\',\'Italic\',\'Underline\',\'Strike\',\'Superscript\'],
3402 [\'NumberedList\',\'BulletedList\',\'-\',\'Outdent\',\'Indent\',\'Blockquote\'],
3403 [\'JustifyLeft\',\'JustifyCenter\',\'JustifyRight\',\'JustifyBlock\'],
3404 [\'Link\',\'Unlink\'],
3405 [\'Image\',\'Table\',\'HorizontalRule\'],
3406 [\'Styles\',\'Format\',\'Font\',\'FontSize\'],
3407 [\'TextColor\',\'BGColor\']
3411 //inlineditor.on(\'instanceReady\', function () {
3418 isEditingEnabled = true;
3420 console.log("Disable inline edit");
3421 for(name in CKEDITOR.instances) {
3422 CKEDITOR.instances[name].destroy(true);
3424 isEditingEnabled = false;
3429 print $langs->trans(
"EditInLine");
3433 $disableeditinline = 0;
3434 if ($disableeditinline) {
3436 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>';
3440 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>';
3442 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>';
3451 print
'<span class="websiteselection">';
3452 if ($object->fk_default_home > 0 && $pageid == $object->fk_default_home) {
3456 print
'<a href="#" class="button bordertransp disabled" disabled="disabled" title="'.dol_escape_htmltag($langs->trans(
"SetAsHomePage")).
'"><span class="fas fa-home valignmiddle btnTitle-icon"></span></a>';
3460 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setashome&token='.newToken().
'&website='.urlencode($website->ref).
'&pageid='.((int) $pageid).
'" class="button bordertransp"'.$disabled.
' title="'.
dol_escape_htmltag($langs->trans(
"SetAsHomePage")).
'"><span class="fas fa-home valignmiddle btnTitle-icon"></span></a>';
3462 print
'<input type="submit" class="button bordertransp"'.$disabled.
' value="'.
dol_escape_htmltag($langs->trans(
"ClonePage")).
'" name="createpagefromclone">';
3465 if ($websitepage->status != $websitepage::STATUS_DRAFT) {
3466 $disabled =
' disabled="disabled"';
3467 $title = $langs->trans(
"WebpageMustBeDisabled", $langs->transnoentitiesnoconv($websitepage->LibStatut(0, 0)));
3472 $url = $_SERVER[
"PHP_SELF"].
'?action=delete&token='.newToken().
'&pageid='.((int) $websitepage->id).
'&website='.urlencode($website->ref);
3474 print
'<a href="'.$url.
'" class="button buttonDelete bordertransp'.($disabled ?
' disabled' :
'').
'"'.$disabled.
' title="'.
dol_escape_htmltag($title).
'">'.
img_picto(
'',
'delete',
'class=""').
'<span class="hideonsmartphone paddingleft">'.$langs->trans(
"Delete").
'</span></a>';
3481 print
'<span class="websitetools">';
3483 if (($pageid > 0 && $atleastonepage) && ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite')) {
3484 $realpage = $urlwithroot.
'/public/website/index.php?website='.$websitekey.
'&pageref='.$websitepage->pageurl;
3485 $pagealias = $websitepage->pageurl;
3487 $htmltext = $langs->trans(
"PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv(
"Page"), $langs->transnoentitiesnoconv(
"Page"), $realpage, $dataroot);
3488 $htmltext .=
'<br>'.$langs->trans(
"CheckVirtualHostPerms", $langs->transnoentitiesnoconv(
"ReadPerm"),
'{s1}');
3489 $htmltext = str_replace(
'{s1}', $dataroot.
'<br>'.DOL_DATA_ROOT.
'/medias<br>'.DOL_DOCUMENT_ROOT, $htmltext);
3493 print
'<div class="websiteinputurl inline-block paddingright">';
3494 print
'<a class="websitebuttonsitepreview inline-block" id="previewpage" href="'.$realpage.
'&nocache='.
dol_now().
'" class="button" target="tab'.$websitekey.
'" alt="'.
dol_escape_htmltag($htmltext).
'">';
3495 print $form->textwithpicto(
'', $htmltext, 1,
'preview');
3519 if (!in_array($mode, array(
'replacesite')) && !in_array($action, array(
'editcss',
'editmenu',
'file_manager',
'replacesiteconfirm',
'createsite',
'createcontainer',
'createfromclone',
'createpagefromclone',
'deletesite'))) {
3520 if ($action ==
'editsource' || $action ==
'editmeta') {
3521 print
'<input type="submit" id="savefileandstay" class="button buttonforacesave hideonsmartphone small" value="'.dol_escape_htmltag($langs->trans(
"SaveAndStay")).
'" name="updateandstay">';
3523 if (preg_match(
'/^create/', $action)) {
3524 print
'<input type="submit" id="savefile" class="button buttonforacesave button-save small" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
3526 if (preg_match(
'/^edit/', $action)) {
3527 print
'<input type="submit" id="savefile" class="button buttonforacesave button-save small" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
3529 if ($action !=
'preview') {
3530 print
'<input type="submit" class="button button-cancel small" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'" name="cancel">';
3536 print
'<span class="websitehelp">';
3537 if ($action ==
'editsource' || $action ==
'editcontent' ||
GETPOST(
'editsource',
'alpha') ||
GETPOST(
'editcontent',
'alpha')) {
3538 $url =
'https://wiki.dolibarr.org/index.php/Module_Website';
3540 $htmltext = $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource", $url);
3541 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource2", $url);
3542 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSourceMore", $url);
3543 $htmltext .=
'<br>';
3544 if ($conf->browser->layout ==
'phone') {
3545 print $form->textwithpicto(
'', $htmltext, 1,
'help',
'inline-block', 1, 2,
'tooltipsubstitution');
3548 print $form->textwithpicto($langs->trans(
"SyntaxHelp").
' '.
img_help(2, $langs->trans(
"SyntaxHelp")), $htmltext, 1,
'none',
'inline-block', 1, 2,
'tooltipsubstitution');
3554 if ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone') {
3556 if (!empty($conf->use_javascript_ajax)) {
3557 print
'<script type="text/javascript">
3558 jQuery(document).ready(function() {
3559 jQuery("#websiteinputurl").keyup(function() {
3560 console.log("Website external url modified "+jQuery("#previewsiteurl").val());
3561 if (jQuery("#previewsiteurl").val() != "" && jQuery("#previewsiteurl").val().startsWith("http"))
3563 jQuery("a.websitebuttonsitepreviewdisabled img").css({ opacity: 1 });
3565 else jQuery("a.websitebuttonsitepreviewdisabled img").css({ opacity: 0.2 });
3569 jQuery("#previewsiteext,#previewpageext").click(function() {
3571 newurl=jQuery("#previewsiteurl").val();
3572 if (! newurl.startsWith("http"))
3574 alert(\''.dol_escape_js($langs->trans(
"ErrorURLMustStartWithHttp")).
'\');
3578 newpage=jQuery(
"#previewsiteurl").val() +
"/" + jQuery(
"#previewpageurl").val() +
".php";
3579 console.log(
"Open url "+newurl);
3583 url:
"'.DOL_URL_ROOT.'/core/ajax/saveinplace.php",
3585 field: \
'editval_virtualhost\',
3586 element: \'website\',
3587 table_element: \'website\',
3588 fk_element: '.((int) $object->id).
',
3591 context: document.body
3594 jQuery("#previewsiteext").attr("href",newurl);
3595 jQuery("#previewpageext").attr("href",newpage);
3614if ($action ==
'editcss') {
3615 print
'<div class="fiche">';
3619 if (!GETPOSTISSET(
'WEBSITE_CSS_INLINE')) {
3620 $csscontent = @file_get_contents($filecss);
3622 $csscontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims',
'', $csscontent);
3624 $csscontent =
GETPOST(
'WEBSITE_CSS_INLINE',
'none');
3626 if (!trim($csscontent)) {
3627 $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;}";
3630 if (!GETPOSTISSET(
'WEBSITE_JS_INLINE')) {
3631 $jscontent = @file_get_contents($filejs);
3633 $jscontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims',
'', $jscontent);
3635 $jscontent =
GETPOST(
'WEBSITE_JS_INLINE',
'none');
3637 if (!trim($jscontent)) {
3638 $jscontent =
'/* JS content (all pages) */'.
"\n";
3641 if (!GETPOSTISSET(
'WEBSITE_HTML_HEADER')) {
3642 $htmlheadercontent = @file_get_contents($filehtmlheader);
3644 $htmlheadercontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims',
'', $htmlheadercontent);
3646 $htmlheadercontent =
GETPOST(
'WEBSITE_HTML_HEADER',
'none');
3648 if (!trim($htmlheadercontent)) {
3649 $htmlheadercontent =
"<html>\n";
3650 $htmlheadercontent .= $htmlheadercontentdefault;
3651 $htmlheadercontent .=
"</html>";
3653 $htmlheadercontent = preg_replace(
'/^\s*<html>/ims',
'', $htmlheadercontent);
3654 $htmlheadercontent = preg_replace(
'/<\/html>\s*$/ims',
'', $htmlheadercontent);
3655 $htmlheadercontent =
'<html>'.
"\n".trim($htmlheadercontent).
"\n".
'</html>';
3658 if (!GETPOSTISSET(
'WEBSITE_ROBOT')) {
3659 $robotcontent = @file_get_contents($filerobot);
3661 $robotcontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims',
'', $robotcontent);
3663 $robotcontent =
GETPOST(
'WEBSITE_ROBOT',
'nohtml');
3665 if (!trim($robotcontent)) {
3666 $robotcontent .=
"# Robot file. Generated with ".DOL_APPLICATION_TITLE.
"\n";
3667 $robotcontent .=
"User-agent: *\n";
3668 $robotcontent .=
"Allow: /public/\n";
3669 $robotcontent .=
"Disallow: /administrator/\n";
3672 if (!GETPOSTISSET(
'WEBSITE_HTACCESS')) {
3673 $htaccesscontent = @file_get_contents($filehtaccess);
3675 $htaccesscontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims',
'', $htaccesscontent);
3677 $htaccesscontent =
GETPOST(
'WEBSITE_HTACCESS',
'nohtml');
3679 if (!trim($htaccesscontent)) {
3680 $htaccesscontent .=
"# Order allow,deny\n";
3681 $htaccesscontent .=
"# Deny from all\n";
3685 if (!GETPOSTISSET(
'WEBSITE_MANIFEST_JSON')) {
3686 $manifestjsoncontent = @file_get_contents($filemanifestjson);
3688 $manifestjsoncontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims',
'', $manifestjsoncontent);
3690 $manifestjsoncontent =
GETPOST(
'WEBSITE_MANIFEST_JSON',
'restricthtml');
3692 if (!trim($manifestjsoncontent)) {
3696 if (!GETPOSTISSET(
'WEBSITE_README')) {
3697 $readmecontent = @file_get_contents($filereadme);
3699 $readmecontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims',
'', $readmecontent);
3701 $readmecontent =
GETPOST(
'WEBSITE_README',
'none');
3703 if (!trim($readmecontent)) {
3707 if (!GETPOSTISSET(
'WEBSITE_LICENSE')) {
3708 $licensecontent = @file_get_contents($filelicense);
3710 $licensecontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims',
'', $licensecontent);
3712 $licensecontent =
GETPOST(
'WEBSITE_LICENSE',
'none');
3714 if (!trim($licensecontent)) {
3720 print
'<!-- Edit Website properties -->'.
"\n";
3721 print
'<table class="border centpercent">';
3724 print
'<tr><td class="titlefieldcreate fieldrequired">';
3725 print $langs->trans(
'WebSite');
3731 if ($action !=
'createcontainer') {
3732 if (empty($conf->use_javascript_ajax)) {
3733 print
'<!-- Status of web site page -->'.
"\n";
3734 print
'<tr><td class="fieldrequired">';
3735 print $langs->trans(
'Status');
3737 print $form->selectyesno(
'status', $object->status);
3743 print
'<tr><td class="tdtop fieldrequired">';
3745 print $form->textwithpicto($langs->trans(
'MainLanguage'), $htmltext, 1,
'help',
'', 0, 2,
'WEBSITE_LANG');
3747 print
img_picto(
'',
'language',
'class="picotfixedwidth"');
3748 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);
3753 print
'<tr><td class="tdtop">';
3754 $htmltext = $langs->trans(
"Example").
': fr,de,sv,it,pt';
3755 print $form->textwithpicto($langs->trans(
'OtherLanguages'), $htmltext, 1,
'help',
'', 0, 2);
3757 print
img_picto(
'',
'language',
'class="picotfixedwidth"');
3758 print
'<input type="text" class="flat" value="'.(GETPOSTISSET(
'WEBSITE_OTHERLANG') ?
GETPOST(
'WEBSITE_OTHERLANG',
'alpha') : $object->otherlang).
'" name="WEBSITE_OTHERLANG">';
3763 print
'<tr><td class="tdtop">';
3765 $htmltext = $langs->trans(
"VirtualhostDesc");
3766 print $form->textwithpicto($langs->trans(
'Virtualhost'), $htmltext, 1,
'help',
'', 0, 2,
'virtualhosttooltip');
3768 print
'<input type="text" class="flat minwidth300" value="'.(GETPOSTISSET(
'virtualhost') ?
GETPOST(
'virtualhost',
'alpha') : $virtualurl).
'" name="virtualhost">';
3774 print $form->textwithpicto($langs->trans(
'ImportFavicon'), $langs->trans(
'FaviconTooltip'));
3777 $maxmin = $maxfilesizearray[
'maxmin'];
3779 print
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
3781 print
'<input type="file" class="flat minwidth300" name="addedfile" id="addedfile"/>';
3783 $uploadfolder = $conf->website->dir_output.
'/'.$websitekey;
3785 print
'<div class="inline-block valignmiddle marginrightonly">';
3786 print
'<img style="max-height: 80px" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart=website&file='.$websitekey.
'/favicon.png">';
3792 print
'<tr><td class="tdtop">';
3793 $htmlhelp = $langs->trans(
"CSSContentTooltipHelp");
3794 print $form->textwithpicto($langs->trans(
'WEBSITE_CSS_INLINE'), $htmlhelp, 1,
'help',
'', 0, 2,
'csstooltip');
3797 $poscursor = array(
'x'=>
GETPOST(
'WEBSITE_CSS_INLINE_x'),
'y'=>
GETPOST(
'WEBSITE_CSS_INLINE_y'));
3798 $doleditor =
new DolEditor(
'WEBSITE_CSS_INLINE', $csscontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'', $poscursor);
3799 print $doleditor->Create(1,
'',
true,
'CSS',
'css');
3804 print
'<tr><td class="tdtop">';
3805 $textwithhelp = $langs->trans(
'WEBSITE_JS_INLINE');
3806 $htmlhelp2 = $langs->trans(
"LinkAndScriptsHereAreNotLoadedInEditor").
'<br>';
3807 print $form->textwithpicto($textwithhelp, $htmlhelp2, 1,
'warning',
'', 0, 2,
'htmljstooltip2');
3811 $poscursor = array(
'x'=>
GETPOST(
'WEBSITE_JS_INLINE_x'),
'y'=>
GETPOST(
'WEBSITE_JS_INLINE_y'));
3812 $doleditor =
new DolEditor(
'WEBSITE_JS_INLINE', $jscontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'', $poscursor);
3813 print $doleditor->Create(1,
'',
true,
'JS',
'javascript');
3818 print
'<tr><td class="tdtop">';
3819 print $langs->trans(
'WEBSITE_HTML_HEADER');
3820 $htmlhelp = $langs->trans(
"Example").
' :<br>';
3822 $textwithhelp = $form->textwithpicto(
'', $htmlhelp, 1,
'help',
'', 0, 2,
'htmlheadertooltip');
3823 $htmlhelp2 = $langs->trans(
"LinkAndScriptsHereAreNotLoadedInEditor").
'<br>';
3824 print $form->textwithpicto($textwithhelp, $htmlhelp2, 1,
'warning',
'', 0, 2,
'htmlheadertooltip2');
3827 $poscursor = array(
'x'=>
GETPOST(
'WEBSITE_HTML_HEADER_x'),
'y'=>
GETPOST(
'WEBSITE_HTML_HEADER_y'));
3828 $doleditor =
new DolEditor(
'WEBSITE_HTML_HEADER', $htmlheadercontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'', $poscursor);
3829 print $doleditor->Create(1,
'',
true,
'HTML Header',
'html');
3834 print
'<tr><td class="tdtop">';
3835 print $langs->trans(
'WEBSITE_ROBOT');
3838 $poscursor = array(
'x'=>
GETPOST(
'WEBSITE_ROBOT_x'),
'y'=>
GETPOST(
'WEBSITE_ROBOT_y'));
3839 $doleditor =
new DolEditor(
'WEBSITE_ROBOT', $robotcontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'', $poscursor);
3840 print $doleditor->Create(1,
'',
true,
'Robot file',
'text');
3845 print
'<tr><td class="tdtop">';
3846 print $langs->trans(
'WEBSITE_HTACCESS');
3849 $poscursor = array(
'x'=>
GETPOST(
'WEBSITE_HTACCESS_x'),
'y'=>
GETPOST(
'WEBSITE_HTACCESS_y'));
3850 $doleditor =
new DolEditor(
'WEBSITE_HTACCESS', $htaccesscontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'', $poscursor);
3851 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' .htaccess',
'text');
3856 print
'<tr><td class="tdtop">';
3857 $htmlhelp = $langs->trans(
"Example").
' :<br>';
3858 $htmlhelp .=
'<small>'.dol_htmlentitiesbr($manifestjsoncontentdefault).
'</small>';
3859 print $form->textwithpicto($langs->trans(
'WEBSITE_MANIFEST_JSON'), $htmlhelp, 1,
'help',
'', 0, 2,
'manifestjsontooltip');
3861 print $langs->trans(
"UseManifest").
': '.$form->selectyesno(
'use_manifest', $website->use_manifest, 1).
'<br>';
3863 $poscursor = array(
'x'=>
GETPOST(
'WEBSITE_MANIFEST_JSON_x'),
'y'=>
GETPOST(
'WEBSITE_MANIFEST_JSON_y'));
3864 $doleditor =
new DolEditor(
'WEBSITE_MANIFEST_JSON', $manifestjsoncontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'', $poscursor);
3865 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' manifest.json',
'text');
3869 print
'<tr><td class="tdtop">';
3870 $htmlhelp = $langs->trans(
"EnterHereReadmeInformation");
3871 print $form->textwithpicto($langs->trans(
"File").
' README.md', $htmlhelp, 1,
'help',
'', 0, 2,
'readmetooltip');
3874 $poscursor = array(
'x'=>
GETPOST(
'WEBSITE_README_x'),
'y'=>
GETPOST(
'WEBSITE_README_y'));
3875 $doleditor =
new DolEditor(
'WEBSITE_README', $readmecontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'', $poscursor);
3876 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' README.md',
'text');
3881 print
'<tr><td class="tdtop">';
3882 $htmlhelp = $langs->trans(
"EnterHereLicenseInformation");
3883 print $form->textwithpicto($langs->trans(
"File").
' LICENSE', $htmlhelp, 1,
'help',
'', 0, 2,
'licensetooltip');
3886 $poscursor = array(
'x'=>
GETPOST(
'WEBSITE_LICENSE_x'),
'y'=>
GETPOST(
'WEBSITE_LICENSE_y'));
3887 $doleditor =
new DolEditor(
'WEBSITE_LICENSE', $licensecontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'', $poscursor);
3888 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' LICENSE',
'text');
3893 print
'<tr><td class="tdtop">';
3894 $htmlhelp = $langs->trans(
'RSSFeedDesc');
3895 print $form->textwithpicto($langs->trans(
'RSSFeed'), $htmlhelp, 1,
'help',
'', 0, 2,
'');
3897 print
'/wrapper.php?rss=1[&l=XX][&limit=123]';
3910if ($action ==
'createsite') {
3911 print
'<div class="fiche">';
3925 if ($action ==
'createcontainer') {
3929 print
'<!-- Add site -->'.
"\n";
3930 print
'<div class="tabBar tabBarWithBottom">';
3932 print
'<table class="border centpercent">';
3934 $siteref = $sitedesc = $sitelang = $siteotherlang =
'';
3936 $siteref =
GETPOST(
'WEBSITE_REF',
'aZ09');
3938 if (
GETPOST(
'WEBSITE_DESCRIPTION')) {
3939 $sitedesc =
GETPOST(
'WEBSITE_DESCRIPTION',
'alpha');
3941 if (
GETPOST(
'WEBSITE_LANG')) {
3942 $sitelang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
3944 if (
GETPOST(
'WEBSITE_OTHERLANG')) {
3945 $siteotherlang =
GETPOST(
'WEBSITE_OTHERLANG',
'aZ09comma');
3948 print
'<tr><td class="titlefieldcreate fieldrequired">';
3949 print $form->textwithpicto($langs->trans(
'WebsiteName'), $langs->trans(
"Example").
': MyPortal, www.mywebsite.com, ...');
3951 print
'<input type="text" class="flat maxwidth300" name="WEBSITE_REF" value="'.dol_escape_htmltag($siteref).
'" autofocus>';
3954 print
'<tr><td class="fieldrequired">';
3955 print $langs->trans(
'MainLanguage');
3957 $shortlangcode = preg_replace(
'/[_-].*$/',
'', trim($langs->defaultlang));
3958 print
img_picto(
'',
'language',
'class="pictofixedwidth"');
3959 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);
3963 $htmltext = $langs->trans(
"Example").
': fr,de,sv,it,pt';
3964 print $form->textwithpicto($langs->trans(
'OtherLanguages'), $htmltext, 1,
'help',
'', 0, 2);
3966 print
img_picto(
'',
'language',
'class="pictofixedwidth"');
3967 print
'<input type="text" class="flat minwidth300" name="WEBSITE_OTHERLANG" value="'.dol_escape_htmltag($siteotherlang).
'">';
3971 print $langs->trans(
'Description');
3973 print
'<input type="text" class="flat minwidth500" name="WEBSITE_DESCRIPTION" value="'.dol_escape_htmltag($sitedesc).
'">';
3978 $htmltext = $langs->trans(
"VirtualhostDesc");
3986 print $form->textwithpicto($langs->trans(
'Virtualhost'), $htmltext, 1,
'help',
'', 0, 2,
'');
3988 print
'<input type="text" class="flat minwidth300" name="virtualhost" value="'.dol_escape_htmltag(
GETPOST(
'virtualhost',
'alpha')).
'">';
3994 if ($action ==
'createsite') {
3995 print
'<div class="center">';
3997 print
'<input type="submit" class="button small" name="addcontainer" value="'.$langs->trans(
"Create").
'">';
3998 print
'<input class="button button-cancel small" type="submit" name="preview" value="'.$langs->trans(
"Cancel").
'">';
4013if ($action ==
'importsite') {
4014 print
'<div class="fiche">';
4022 print
'<span class="opacitymedium">'.$langs->trans(
"ZipOfWebsitePackageToImport").
'</span><br><br>';
4025 $dolibarrdataroot = preg_replace(
'/([\\/]+)$/i',
'', DOL_DATA_ROOT);
4026 $allowimportsite =
true;
4027 if (
dol_is_file($dolibarrdataroot.
'/installmodules.lock')) {
4028 $allowimportsite =
false;
4031 if ($allowimportsite) {
4033 $maxmin = $maxfilesizearray[
'maxmin'];
4035 print
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
4037 print
'<input class="flat minwidth400" type="file" name="userfile[]" accept=".zip">';
4038 print
'<input type="submit" class="button small" name="buttonsubmitimportfile" value="'.dol_escape_htmltag($langs->trans(
"Upload")).
'">';
4039 print
'<input type="submit" class="button button-cancel small" name="preview" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
4040 print
'<br><br><br>';
4044 $message = $langs->trans(
'InstallModuleFromWebHasBeenDisabledContactUs');
4047 $message = $langs->trans(
"InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.
'/installmodules.lock');
4053 print
'<span class="opacitymedium">'.$langs->trans(
"ZipOfWebsitePackageToLoad").
'</span><br><br>';
4064if ($action ==
'editmeta' || $action ==
'createcontainer') {
4065 print
'<div class="fiche">';
4079 if ($action ==
'createcontainer') {
4083 print
'<!-- Edit or create page/container -->'.
"\n";
4086 $hiddenfromfetchingafterload =
' hideobject';
4087 $hiddenmanuallyafterload =
' hideobject';
4088 if (
GETPOST(
'radiocreatefrom') ==
'checkboxcreatefromfetching') {
4089 $hiddenfromfetchingafterload =
'';
4091 if (
GETPOST(
'radiocreatefrom') ==
'checkboxcreatemanually') {
4092 $hiddenmanuallyafterload =
'';
4095 if ($action ==
'editmeta' || empty($conf->use_javascript_ajax)) {
4096 $hiddenfromfetchingafterload =
'';
4097 $hiddenmanuallyafterload =
'';
4100 if ($action ==
'createcontainer') {
4103 if (!empty($conf->use_javascript_ajax)) {
4104 print
'<input type="radio" name="radiocreatefrom" id="checkboxcreatemanually" value="checkboxcreatemanually"'.(GETPOST(
'radiocreatefrom') ==
'checkboxcreatemanually' ?
' checked' :
'').
'> ';
4106 print
'<label for="checkboxcreatemanually"><span class="opacitymediumxx">'.$langs->trans(
"OrEnterPageInfoManually").
'</span></label><br>';
4107 print
'<hr class="tablecheckboxcreatemanually'.$hiddenmanuallyafterload.
'">';
4110 print
'<table class="border tableforfield nobackground centpercent tablecheckboxcreatemanually'.$hiddenmanuallyafterload.
'">';
4112 if ($action !=
'createcontainer') {
4113 print
'<tr><td class="titlefield fieldrequired">';
4114 print $langs->trans(
'IDOfPage').
' - '.$langs->trans(
'InternalURLOfPage');
4122 print
' - ';
4123 print
'/public/website/index.php?website='.urlencode($websitekey).
'&pageid='.urlencode($pageid);
4127 $type_container = $objectpage->type_container;
4128 $pageurl = $objectpage->pageurl;
4129 $pagealiasalt = $objectpage->aliasalt;
4130 $pagetitle = $objectpage->title;
4131 $pagedescription = $objectpage->description;
4132 $pageimage = $objectpage->image;
4133 $pagekeywords = $objectpage->keywords;
4134 $pagelang = $objectpage->lang;
4135 $pageallowedinframes = $objectpage->allowed_in_frames;
4136 $pagehtmlheader = $objectpage->htmlheader;
4137 $pagedatecreation = $objectpage->date_creation;
4138 $pagedatemodification = $objectpage->date_modification;
4139 $pageauthorid = $objectpage->fk_user_creat;
4140 $pageusermodifid = $objectpage->fk_user_modif;
4141 $pageauthoralias = $objectpage->author_alias;
4142 $pagestatus = $objectpage->status;
4144 $type_container =
'page';
4148 $pagedescription =
'';
4152 $pageallowedinframes = 0;
4153 $pagehtmlheader =
'';
4154 $pagedatecreation =
dol_now();
4155 $pagedatemodification =
'';
4156 $pageauthorid = $user->id;
4157 $pageusermodifid = 0;
4158 $pageauthoralias =
'';
4161 if (
GETPOST(
'WEBSITE_TITLE',
'alpha')) {
4162 $pagetitle = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_TITLE',
'alphanohtml'));
4164 if (
GETPOST(
'WEBSITE_PAGENAME',
'alpha')) {
4165 $pageurl =
GETPOST(
'WEBSITE_PAGENAME',
'alpha');
4167 if (
GETPOST(
'WEBSITE_ALIASALT',
'alpha')) {
4168 $pagealiasalt = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_ALIASALT',
'alphanohtml'));
4170 if (
GETPOST(
'WEBSITE_DESCRIPTION',
'alpha')) {
4171 $pagedescription = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml'));
4173 if (
GETPOST(
'WEBSITE_IMAGE',
'alpha')) {
4174 $pageimage =
GETPOST(
'WEBSITE_IMAGE',
'alpha');
4176 if (
GETPOST(
'WEBSITE_KEYWORDS',
'alpha')) {
4177 $pagekeywords = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_KEYWORDS',
'alphanohtml'));
4179 if (
GETPOST(
'WEBSITE_LANG',
'aZ09')) {
4180 $pagelang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
4182 if (
GETPOST(
'WEBSITE_ALLOWED_IN_FRAMES',
'aZ09')) {
4183 $pageallowedinframes =
GETPOST(
'WEBSITE_ALLOWED_IN_FRAMES',
'aZ09');
4185 if (
GETPOST(
'htmlheader',
'none')) {
4186 $pagehtmlheader =
GETPOST(
'htmlheader',
'none');
4189 if ($action !=
'createcontainer') {
4190 if (empty($conf->use_javascript_ajax)) {
4191 print
'<!-- Status of web site page -->'.
"\n";
4192 print
'<tr><td class="fieldrequired">';
4193 print $langs->trans(
'Status');
4195 print $form->selectyesno(
'status', $objectpage->status);
4201 print
'<tr><td class="titlefield fieldrequired">';
4202 print $langs->trans(
'WEBSITE_TYPE_CONTAINER');
4204 print
img_picto(
'',
'object_technic',
'class="paddingrightonly"').
' ';
4205 $formwebsite->selectTypeOfContainer(
'WEBSITE_TYPE_CONTAINER', (
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'alpha') ?
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'alpha') : $type_container), 0,
'', 1);
4209 if ($action ==
'createcontainer') {
4210 print
'<tr><td class="titlefield fieldrequired">';
4211 print $langs->trans(
'WEBSITE_PAGE_EXAMPLE');
4213 print $formwebsite->selectSampleOfContainer(
'sample', (GETPOSTISSET(
'sample') ?
GETPOST(
'sample',
'alpha') :
'empty'), 0,
'', 1,
'minwidth300');
4218 print
'<tr><td class="fieldrequired">';
4219 print $langs->trans(
'WEBSITE_TITLE');
4221 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_TITLE" id="WEBSITE_TITLE" value="'.dol_escape_htmltag($pagetitle).
'" autofocus>';
4225 print
'<tr><td class="titlefieldcreate fieldrequired">';
4226 print $langs->trans(
'WEBSITE_PAGENAME');
4228 print
'<input type="text" class="flat minwidth300" name="WEBSITE_PAGENAME" id="WEBSITE_PAGENAME" value="'.dol_escape_htmltag($pageurl).
'">';
4231 print
'<tr><td class="titlefieldcreate">';
4232 $htmlhelp = $langs->trans(
"WEBSITE_ALIASALTDesc");
4233 print $form->textwithpicto($langs->trans(
'WEBSITE_ALIASALT'), $htmlhelp, 1,
'help',
'', 0, 2,
'aliastooltip');
4235 print
'<input type="text" class="flat minwidth500" name="WEBSITE_ALIASALT" value="'.dol_escape_htmltag($pagealiasalt).
'">';
4239 print $langs->trans(
'WEBSITE_DESCRIPTION');
4241 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_DESCRIPTION" value="'.dol_escape_htmltag($pagedescription).
'">';
4245 $htmlhelp = $langs->trans(
"WEBSITE_IMAGEDesc");
4246 print $form->textwithpicto($langs->trans(
'WEBSITE_IMAGE'), $htmlhelp, 1,
'help',
'', 0, 2,
'imagetooltip');
4248 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_IMAGE" value="'.dol_escape_htmltag($pageimage).
'">';
4253 $htmlhelp = $langs->trans(
"WEBSITE_KEYWORDSDesc");
4254 print $form->textwithpicto($langs->trans(
'WEBSITE_KEYWORDS'), $htmlhelp, 1,
'help',
'', 0, 2,
'keywordtooltip');
4256 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_KEYWORDS" value="'.dol_escape_htmltag($pagekeywords).
'">';
4260 print $langs->trans(
'Language');
4262 $onlykeys = array();
4263 if ($object->lang) {
4264 $onlykeys[$object->lang] = $object->lang;
4266 $onlykeys[$langs->defaultlang] = $langs->defaultlang;
4268 if ($object->otherlang) {
4269 $tmparray = explode(
',', $object->otherlang);
4270 foreach ($tmparray as $key) {
4271 $tmpkey = trim($key);
4272 if (strlen($key) == 2) {
4273 $tmpkey = strtolower($key);
4275 $onlykeys[$tmpkey] = $tmpkey;
4278 if (empty($object->lang) && empty($object->otherlang)) {
4281 print
img_picto(
'',
'language',
'class="pictofixedwidth"').$formadmin->select_language($pagelang ? $pagelang :
'',
'WEBSITE_LANG', 0, null,
'1', 0, 0,
'minwidth200', 0, 0, 0, $onlykeys, 1);
4282 $htmltext = $langs->trans(
"AvailableLanguagesAreDefinedIntoWebsiteProperties");
4283 print $form->textwithpicto(
'', $htmltext);
4289 print
'<!-- Translation of --><tr><td>';
4290 print $langs->trans(
'TranslationLinks');
4292 if ($action !=
'createcontainer') {
4294 $sql =
"SELECT rowid, lang from ".MAIN_DB_PREFIX.
"website_page where fk_page = ".((int) $objectpage->id);
4295 $resql = $db->query($sql);
4297 $num_rows = $db->num_rows($resql);
4298 if ($num_rows > 0) {
4299 print
'<span class="opacitymedium">'.$langs->trans(
'ThisPageHasTranslationPages').
':</span>';
4303 while ($obj = $db->fetch_object($resql)) {
4304 $result = $tmppage->fetch($obj->rowid);
4307 $tmpstring .=
'<br>';
4309 $tmpstring .= $tmppage->getNomUrl(1).
' ('.$tmppage->lang.
')';
4325 if (empty($translatedby) && ($action ==
'editmeta' || $action ==
'createcontainer' || $objectpage->fk_page > 0)) {
4327 $result = $sourcepage->fetch($objectpage->fk_page);
4330 } elseif ($result > 0) {
4331 $translationof = $objectpage->fk_page;
4332 print
'<span class="opacitymedium">'.$langs->trans(
'ThisPageIsTranslationOf').
'</span> ';
4333 print $formwebsite->selectContainer($website,
'pageidfortranslation', ($translationof ? $translationof : -1), 1, $action,
'minwidth300', array($objectpage->id));
4334 if ($translationof > 0 && $sourcepage->lang) {
4335 print $sourcepage->getNomUrl(2).
' ('.$sourcepage->lang.
')';
4343 print $langs->trans(
'AllowedInFrames');
4347 print
'<input type="checkbox" class="flat" name="WEBSITE_ALLOWED_IN_FRAMES" value="1"'.($pageallowedinframes ?
'checked="checked"' :
'').
'>';
4351 if (isModEnabled(
'categorie') && $user->hasRight(
'categorie',
'lire')) {
4352 $langs->load(
'categories');
4354 if (!GETPOSTISSET(
'categories')) {
4355 $cate_arbo = $form->select_all_categories(Categorie::TYPE_WEBSITE_PAGE,
'',
null,
null,
null, 1);
4357 $cats = $c->containing($objectpage->id, Categorie::TYPE_WEBSITE_PAGE);
4358 $arrayselected = array();
4359 if (is_array($cats)) {
4360 foreach ($cats as $cat) {
4361 $arrayselected[] = $cat->id;
4365 $cate_arbo = $form->select_all_categories(Categorie::TYPE_WEBSITE_PAGE,
'',
'parent',
null,
null, 1);
4368 print
'<tr><td class="toptd">'.$form->editfieldkey(
'Categories',
'categories',
'', $objectpage, 0).
'</td><td>';
4369 print
img_picto(
'',
'category',
'class="pictofixedwidth"');
4370 print $form->multiselectarray(
'categories', $cate_arbo, (GETPOSTISSET(
'categories') ?
GETPOST(
'categories',
'array') : $arrayselected), null, null,
'minwidth200 widthcentpercentminusxx');
4375 print
'<tr><td class="titlefieldcreate">';
4376 print
'ObjectClass';
4378 print
'<input type="text" class="flat minwidth300" name="WEBSITE_OBJECTCLASS" placeholder="ClassName::/path/class/ObjectClass.class.php" >';
4381 print
'<tr><td class="titlefieldcreate">';
4384 print
'<input type="text" class="flat minwidth300" name="WEBSITE_OBJECTID" >';
4388 $fuser =
new User($db);
4391 print $langs->trans(
'Author');
4393 if ($pageauthorid > 0) {
4394 $fuser->fetch($pageauthorid);
4395 print $fuser->getNomUrl(1);
4397 print
'<span class="opacitymedium">'.$langs->trans(
"Unknown").
'</span>';
4402 print $langs->trans(
'PublicAuthorAlias');
4404 print
'<input type="text" class="flat minwidth300" name="WEBSITE_AUTHORALIAS" value="'.dol_escape_htmltag($pageauthoralias).
'" placeholder="Anonymous">';
4408 print $langs->trans(
'DateCreation');
4410 print $form->selectDate($pagedatecreation,
'datecreation', 1, 1, 0,
'', 1, 1);
4414 if ($action !=
'createcontainer') {
4416 print $langs->trans(
'UserModif');
4418 if ($pageusermodifid > 0) {
4419 $fuser->fetch($pageusermodifid);
4420 print $fuser->getNomUrl(1);
4425 print $langs->trans(
'DateModification');
4427 print
dol_print_date($pagedatemodification,
'dayhour',
'tzuser');
4431 print
'<tr><td class="tdhtmlheader tdtop">';
4432 $htmlhelp = $langs->trans(
"EditTheWebSiteForACommonHeader").
'<br><br>';
4433 $htmlhelp .= $langs->trans(
"Example").
' :<br>';
4435 print $form->textwithpicto($langs->trans(
'HtmlHeaderPage'), $htmlhelp, 1,
'help',
'', 0, 2,
'htmlheadertooltip');
4437 $poscursor = array(
'x'=>
GETPOST(
'htmlheader_x'),
'y'=>
GETPOST(
'htmlheader_y'));
4438 $doleditor =
new DolEditor(
'htmlheader', $pagehtmlheader,
'',
'120',
'ace',
'In',
true,
false,
'ace', ROWS_3,
'100%',
'', $poscursor);
4439 print $doleditor->Create(1,
'',
true,
'HTML Header',
'html');
4444 if ($action ==
'createcontainer') {
4445 print
'<div class="center tablecheckboxcreatemanually'.$hiddenmanuallyafterload.
'">';
4447 print
'<input type="submit" class="button small" name="addcontainer" value="'.$langs->trans(
"Create").
'">';
4448 print
'<input class="button button-cancel small" type="submit" name="preview" value="'.$langs->trans(
"Cancel").
'">';
4455 if (!empty($conf->use_javascript_ajax)) {
4456 print
'<input type="radio" name="radiocreatefrom" id="checkboxcreatefromfetching" value="checkboxcreatefromfetching"'.(GETPOST(
'radiocreatefrom') ==
'checkboxcreatefromfetching' ?
' checked' :
'').
'> ';
4458 print
'<label for="checkboxcreatefromfetching"><span class="opacitymediumxx">'.$langs->trans(
"CreateByFetchingExternalPage").
'</span></label><br>';
4459 print
'<hr class="tablecheckboxcreatefromfetching'.$hiddenfromfetchingafterload.
'">';
4460 print
'<table class="tableforfield centpercent tablecheckboxcreatefromfetching'.$hiddenfromfetchingafterload.
'">';
4461 print
'<tr><td class="titlefield">';
4462 print $langs->trans(
"URL");
4464 print
info_admin($langs->trans(
"OnlyEditionOfSourceForGrabbedContentFuture"), 0, 0,
'warning');
4465 print
'<input class="flat minwidth500" type="text" name="externalurl" value="'.dol_escape_htmltag(
GETPOST(
'externalurl',
'alpha')).
'" placeholder="https://externalsite/pagetofetch"> ';
4466 print
'<br><input class="flat paddingtop" type="checkbox" name="grabimages" value="1" checked="checked"> '.$langs->trans(
"GrabImagesInto");
4468 print $langs->trans(
"ImagesShouldBeSavedInto").
' ';
4469 $arraygrabimagesinto = array(
'root'=>$langs->trans(
"WebsiteRootOfImages"),
'subpage'=>$langs->trans(
"SubdirOfPage"));
4470 print $form->selectarray(
'grabimagesinto', $arraygrabimagesinto, GETPOSTISSET(
'grabimagesinto') ?
GETPOST(
'grabimagesinto') :
'root', 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
4473 print
'<input class="button small" style="margin-top: 5px" type="submit" name="fetchexternalurl" value="'.dol_escape_htmltag($langs->trans(
"FetchAndCreate")).
'">';
4474 print
'<input class="button button-cancel small" type="submit" name="preview" value="'.$langs->trans(
"Cancel").
'">';
4480 if ($action ==
'createcontainer') {
4481 print
'<script type="text/javascript">
4482 jQuery(document).ready(function() {
4483 var disableautofillofalias = 0;
4484 var selectedm = \'\';
4485 var selectedf = \'\';
4486 jQuery("#WEBSITE_TITLE").keyup(function() {
4487 if (disableautofillofalias == 0)
4489 var valnospecial = jQuery("#WEBSITE_TITLE").val();
4490 valnospecial = valnospecial.replace(/[éèê]/g, \'e\').replace(/[à ]/g, \'a\').replace(/[ù]/g, \'u\').replace(/[î]/g, \'i\');
4491 valnospecial = valnospecial.replace(/[ç]/g, \'c\').replace(/[ö]/g, \'o\');
4492 valnospecial = valnospecial.replace(/[^\w]/gi, \'-\').toLowerCase();
4493 valnospecial = valnospecial.replace(/\-+/g, \'-\').replace(/\-$/, \'\');
4494 console.log("disableautofillofalias=0 so we replace WEBSITE_TITLE with "+valnospecial);
4495 jQuery("#WEBSITE_PAGENAME").val(valnospecial);
4498 jQuery("#WEBSITE_PAGENAME").keyup(function() {
4499 disableautofillofalias = 1;
4502 jQuery("#checkboxcreatefromfetching,#checkboxcreatemanually").click(function() {
4503 console.log("we select a method to create a new container "+jQuery("#checkboxcreatefromfetching:checked").val())
4504 jQuery(".tablecheckboxcreatefromfetching").hide();
4505 jQuery(".tablecheckboxcreatemanually").hide();
4506 if (typeof(jQuery("#checkboxcreatefromfetching:checked").val()) != \'undefined\') {
4507 console.log("show a");
4508 if (selectedf != \'createfromfetching\') {
4509 jQuery(".tablecheckboxcreatefromfetching").show();
4510 selectedf = \'createfromfetching\';
4513 jQuery(".tablecheckboxcreatefromfetching").hide();
4517 if (typeof(jQuery("#checkboxcreatemanually:checked").val()) != \'undefined\') {
4518 console.log("show b");
4519 if (selectedm != \'createmanually\') {
4520 jQuery(".tablecheckboxcreatemanually").show();
4521 selectedm = \'createmanually\';
4524 jQuery(".tablecheckboxcreatemanually").hide();
4543if ($action ==
'preview') {
4547if ($action ==
'editfile' || $action ==
'file_manager' || $action ==
'convertimgwebp' || $action ==
'confirmconvertimgwebp') {
4548 print
'<!-- Edit Media -->'.
"\n";
4549 print
'<div class="fiche"><br>';
4554 $formalreadyopen = 2;
4556 $url = DOL_URL_ROOT.
'/website/index.php';
4558 include DOL_DOCUMENT_ROOT.
'/core/tpl/filemanager.tpl.php';
4563if ($action ==
'editmenu') {
4564 print
'<!-- Edit Menu -->'.
"\n";
4565 print
'<div class="center">'.$langs->trans(
"FeatureNotYetAvailable").
'</center>';
4568if ($action ==
'editsource') {
4571 $contentforedit =
'';
4575 $contentforedit .= $objectpage->content;
4577 $maxheightwin = 480;
4578 if (isset($_SESSION[
"dol_screenheight"])) {
4579 if ($_SESSION[
"dol_screenheight"] > 680) {
4580 $maxheightwin = $_SESSION[
"dol_screenheight"] - 400;
4582 if ($_SESSION[
"dol_screenheight"] > 800) {
4583 $maxheightwin = $_SESSION[
"dol_screenheight"] - 490;
4587 $poscursor = array(
'x'=>
GETPOST(
'PAGE_CONTENT_x'),
'y'=>
GETPOST(
'PAGE_CONTENT_y'));
4588 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
4589 $doleditor =
new DolEditor(
'PAGE_CONTENT', $contentforedit,
'', $maxheightwin,
'Full',
'',
true,
true,
'ace', ROWS_5,
'40%', 0, $poscursor);
4590 $doleditor->Create(0,
'',
false,
'HTML Source',
'php');
4593if ($action ==
'editcontent') {
4596 $contentforedit =
'';
4600 $contentforedit .= $objectpage->content;
4603 $contentforedit = preg_replace(
'/(<img.*src=")(?!http)/',
'\1'.DOL_URL_ROOT.
'/viewimage.php?modulepart=medias&file=', $contentforedit, -1, $nbrep);
4605 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
4606 $poscursor = array(
'x'=>
GETPOST(
'PAGE_CONTENT_x'),
'y'=>
GETPOST(
'PAGE_CONTENT_y'));
4607 $doleditor=
new DolEditor(
'PAGE_CONTENT', $contentforedit,
'', 500,
'Full',
'',
true,
true,
true, ROWS_5,
'90%', 0, $poscursor);
4608 $doleditor->Create(0,
'',
false);
4616if ($mode ==
'replacesite' || $massaction ==
'replace') {
4617 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4618 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4619 print
'<input type="hidden" name="action" value="replacesiteconfirm">';
4620 print
'<input type="hidden" name="mode" value="replacesite">';
4621 print
'<input type="hidden" name="website" value="'.$website->ref.
'">';
4624 print
'<!-- Search page and replace string -->'.
"\n";
4625 print
'<div class="fiche"><br>';
4627 print
load_fiche_titre($langs->trans(
"ReplaceWebsiteContent"),
'',
'search');
4629 print
'<div class="fichecenter"><div class="fichehalfleft">';
4631 print
'<div class="tagtable">';
4633 print
'<div class="tagtr">';
4634 print
'<div class="tagtd paddingrightonly opacitymedium">';
4635 print $langs->trans(
"SearchReplaceInto");
4637 print
'<div class="tagtd">';
4638 print
'<input type="checkbox" class="marginleftonly" id="checkboxoptioncontent" name="optioncontent" value="content"'.((!GETPOSTISSET(
'buttonreplacesitesearch') ||
GETPOST(
'optioncontent',
'aZ09')) ?
' checked' :
'').
'> <label for="checkboxoptioncontent" class="tdoverflowmax150onsmartphone inline-block valignmiddle">'.$langs->trans(
"Content").
'</label><br>';
4639 print
'<input type="checkbox" class="marginleftonly" id="checkboxoptionmeta" name="optionmeta" value="meta"'.(GETPOST(
'optionmeta',
'aZ09') ?
' checked' :
'').
'> <label for="checkboxoptionmeta" class="tdoverflowmax150onsmartphone inline-block valignmiddle">'.$langs->trans(
"Title").
' | '.$langs->trans(
"Description").
' | '.$langs->trans(
"Keywords").
'</label><br>';
4640 print
'<input type="checkbox" class="marginleftonly" id="checkboxoptionsitefiles" name="optionsitefiles" value="sitefiles"'.(GETPOST(
'optionsitefiles',
'aZ09') ?
' checked' :
'').
'> <label for="checkboxoptionsitefiles" class="tdoverflowmax150onsmartphone inline-block valignmiddle">'.$langs->trans(
"GlobalCSSorJS").
'</label><br>';
4644 print
'<div class="tagtr">';
4645 print
'<div class="tagtd paddingrightonly opacitymedium" style="padding-right: 10px !important">';
4646 print $langs->trans(
"SearchString");
4648 print
'<div class="tagtd">';
4649 print
'<input type="text" name="searchstring" value="'.dol_escape_htmltag($searchkey, 0, 0,
'', 1).
'" autofocus>';
4655 print
'</div><div class="fichehalfleft">';
4657 print
'<div class="tagtable">';
4659 print
'<div class="tagtr">';
4660 print
'<div class="tagtd paddingrightonly opacitymedium tdoverflowmax100onsmartphone" style="padding-right: 10px !important">';
4661 print $langs->trans(
"WEBSITE_TYPE_CONTAINER");
4663 print
'<div class="tagtd">';
4664 print
img_picto(
'',
'object_technic',
'class="paddingrightonly"').
' ';
4665 $formwebsite->selectTypeOfContainer(
'optioncontainertype', (
GETPOST(
'optioncontainertype',
'alpha') ?
GETPOST(
'optioncontainertype',
'alpha') :
''), 1,
'', 1,
'minwidth125 maxwidth400 widthcentpercentminusx');
4669 print
'<div class="tagtr">';
4670 print
'<div class="tagtd paddingrightonly opacitymedium tdoverflowmax100onsmartphone" style="padding-right: 10px !important">';
4671 print $langs->trans(
"Language");
4673 print
'<div class="tagtd">';
4674 print
img_picto(
'',
'language',
'class="paddingrightonly"').
' '.$formadmin->select_language(GETPOSTISSET(
'optionlanguage') ?
GETPOST(
'optionlanguage') :
'',
'optionlanguage', 0, null,
'1', 0, 0,
'minwidth125 maxwidth400 widthcentpercentminusx', 2, 0, 0, null, 1);
4679 if (isModEnabled(
'categorie') && $user->hasRight(
'categorie',
'lire')) {
4680 print
'<div class="tagtr">';
4681 print
'<div class="tagtd paddingrightonly marginrightonly opacitymedium tdoverflowmax100onsmartphone" style="padding-right: 10px !important">';
4682 print $langs->trans(
"Category");
4684 print
'<div class="tagtd">';
4685 print
img_picto(
'',
'category',
'class="paddingrightonly"').
' '.$form->select_all_categories(Categorie::TYPE_WEBSITE_PAGE, GETPOSTISSET(
'optioncategory') ?
GETPOST(
'optioncategory') :
'',
'optioncategory', 0, 0, 0, 0,
'minwidth125 maxwidth400 widthcentpercentminusx');
4686 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
4694 print
'<input type="submit" class="button margintoponly" name="buttonreplacesitesearch" value="'.dol_escape_htmltag($langs->trans(
"Search")).
'">';
4696 print
'</div></div>';
4698 if ($mode ==
'replacesite') {
4699 print
'<!-- List of search result -->'.
"\n";
4700 print
'<div class="rowsearchresult clearboth">';
4705 if ($listofpages[
'code'] ==
'OK') {
4706 $arrayofselected = is_array($toselect) ? $toselect : array();
4708 $nbtotalofrecords = count($listofpages[
'list']);
4710 $permissiontodelete = $user->hasRight(
'website',
'delete');
4713 $arrayofmassactions = array();
4714 if ($user->hasRight(
'website',
'writephp') && $searchkey) {
4715 $arrayofmassactions[
'replace'] =
img_picto(
'',
'replacement',
'class="pictofixedwidth"').$langs->trans(
"Replace");
4717 if ($user->hasRight(
'website',
'write')) {
4718 $arrayofmassactions[
'setcategory'] =
img_picto(
'',
'category',
'class="pictofixedwidth"').$langs->trans(
"ClassifyInCategory");
4720 if ($user->hasRight(
'website',
'write')) {
4721 $arrayofmassactions[
'delcategory'] =
img_picto(
'',
'category',
'class="pictofixedwidth"').$langs->trans(
"RemoveCategory");
4723 if ($permissiontodelete) {
4724 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
4726 if (
GETPOST(
'nomassaction',
'int') || in_array($massaction, array(
'presend',
'predelete'))) {
4727 $arrayofmassactions = array();
4730 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
4731 $massactionbutton .=
'<div class="massactionother massactionreplace hidden">';
4732 $massactionbutton .= $langs->trans(
"ReplaceString");
4733 $massactionbutton .=
' <input type="text" name="replacestring" value="'.dol_escape_htmltag(
GETPOST(
'replacestring',
'none')).
'">';
4734 $massactionbutton .=
'</div>';
4735 $massactionbutton .=
'<div class="massactionother massactionsetcategory massactiondelcategory hidden">';
4736 $massactionbutton .=
img_picto(
'',
'category').
' '.$langs->trans(
"Category");
4737 $massactionbutton .=
' '.$form->select_all_categories(Categorie::TYPE_WEBSITE_PAGE, GETPOSTISSET(
'setcategory') ?
GETPOST(
'setcategory') :
'',
'setcategory', 64, 0, 0, 0,
'minwidth300 alignstart');
4738 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
4740 $massactionbutton .=
'</div>';
4742 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
4745 $selectedfields =
'';
4746 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
4748 print_barre_liste($langs->trans(
"Results"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'generic', 0,
'',
'', $limit, 1, 1, 1);
4750 $topicmail =
"WebsitePageRef";
4751 $modelmail =
"websitepage_send";
4753 $trackid =
'wsp'.$object->id;
4754 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
4756 $param =
'mode=replacesite&website='.urlencode($website->ref);
4757 $param .=
'&searchstring='.urlencode($searchkey);
4758 if (
GETPOST(
'optioncontent')) {
4759 $param .=
'&optioncontent=content';
4762 $param .=
'&optionmeta=meta';
4764 if (
GETPOST(
'optionsitefiles')) {
4765 $param .=
'&optionsitefiles=optionsitefiles';
4767 if (
GETPOST(
'optioncontainertype')) {
4768 $param .=
'&optioncontainertype='.GETPOST(
'optioncontainertype',
'aZ09');
4770 if (
GETPOST(
'optionlanguage')) {
4771 $param .=
'&optionlanguage='.GETPOST(
'optionlanguage',
'aZ09');
4773 if (
GETPOST(
'optioncategory')) {
4774 $param .=
'&optioncategory='.GETPOST(
'optioncategory',
'aZ09');
4777 print
'<div class="div-table-responsive-no-min">';
4778 print
'<table class="noborder centpercent">';
4779 print
'<tr class="liste_titre">';
4780 print
getTitleFieldOfList(
"Type", 0, $_SERVER[
'PHP_SELF'],
'type_container',
'', $param,
'', $sortfield, $sortorder,
'').
"\n";
4781 print
getTitleFieldOfList(
"Page", 0, $_SERVER[
'PHP_SELF'],
'pageurl',
'', $param,
'', $sortfield, $sortorder,
'').
"\n";
4783 print
getTitleFieldOfList(
"Language", 0, $_SERVER[
'PHP_SELF'],
'lang',
'', $param,
'', $sortfield, $sortorder,
'center ').
"\n";
4785 print
getTitleFieldOfList(
"DateLastModification", 0, $_SERVER[
'PHP_SELF'],
'tms',
'', $param,
'', $sortfield, $sortorder,
'center ').
"\n";
4787 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
4790 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
4795 foreach ($listofpages[
'list'] as $answerrecord) {
4796 if (is_object($answerrecord) && get_class($answerrecord) ==
'WebsitePage') {
4800 print
'<td class="nowraponall">'.$langs->trans(
"Container").
' - ';
4801 print $langs->trans($answerrecord->type_container);
4806 print $answerrecord->getNomUrl(1);
4807 print
' <span class="opacitymedium">('.($answerrecord->title ? $answerrecord->title : $langs->trans(
"NoTitle")).
')</span>';
4811 print
'<span class="opacitymedium">'.$answerrecord->description.
'</span>';
4815 print
'<td class="center">';
4816 if (isModEnabled(
'categorie') && $user->hasRight(
'categorie',
'lire')) {
4818 $existing = $c->containing($answerrecord->id, Categorie::TYPE_WEBSITE_PAGE,
'object');
4819 if (is_array($existing)) {
4820 foreach ($existing as $tmpcategory) {
4822 print
img_object($langs->trans(
"Category").
' : '.$tmpcategory->label,
'category',
'style="padding-left: 2px; padding-right: 2px; color: #'.($tmpcategory->color !=
'' ? $tmpcategory->color :
'888').
'"');
4830 $param =
'?mode=replacesite';
4831 $param .=
'&websiteid='.$website->id;
4832 $param .=
'&optioncontent='.GETPOST(
'optioncontent',
'aZ09');
4833 $param .=
'&optionmeta='.GETPOST(
'optionmeta',
'aZ09');
4834 $param .=
'&optionsitefiles='.GETPOST(
'optionsitefiles',
'aZ09');
4835 $param .=
'&optioncontainertype='.GETPOST(
'optioncontainertype',
'aZ09');
4836 $param .=
'&optionlanguage='.GETPOST(
'optionlanguage',
'aZ09');
4837 $param .=
'&optioncategory='.GETPOST(
'optioncategory',
'aZ09');
4838 $param .=
'&searchstring='.urlencode($searchkey);
4841 print
'<td class="center">';
4846 print
'<td class="center nowraponall">';
4848 $characterMap =
'áà éèëÃóúüñùç0123456789';
4849 $nbofwords = str_word_count($textwithouthtml, 0, $characterMap);
4851 print $nbofwords.
' '.$langs->trans(
"words");
4852 $totalnbwords += $nbofwords;
4857 print
'<td class="center nowraponall">';
4858 print
dol_print_date($answerrecord->date_modification,
'dayhour');
4862 print
'<td class="tdwebsitesearchresult right nowraponall">';
4864 $urltoedithtmlsource = $_SERVER[
"PHP_SELF"].
'?action=editmeta&token='.newToken().
'&websiteid='.$website->id.
'&pageid='.$answerrecord->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].$param);
4865 if (!$user->hasRight(
'website',
'write')) {
4866 $disabled =
' disabled';
4867 $urltoedithtmlsource =
'';
4869 print
'<a class="editfielda marginleftonly marginrightonly '.$disabled.
'" href="'.$urltoedithtmlsource.
'" title="'.$langs->trans(
"EditPageMeta").
'">'.
img_picto($langs->trans(
"EditPageMeta"),
'pencil-ruler').
'</a>';
4872 $urltoedithtmlsource = $_SERVER[
"PHP_SELF"].
'?action=editsource&token='.newToken().
'&websiteid='.$website->id.
'&pageid='.$answerrecord->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].$param);
4873 if (!$user->hasRight(
'website',
'write')) {
4874 $disabled =
' disabled';
4875 $urltoedithtmlsource =
'';
4877 print
'<a class="editfielda marginleftonly marginrightonly '.$disabled.
'" href="'.$urltoedithtmlsource.
'" title="'.$langs->trans(
"EditHTMLSource").
'">'.
img_picto($langs->trans(
"EditHTMLSource"),
'edit').
'</a>';
4879 print
'<span class="marginleftonly marginrightonly"></span>';
4880 print
ajax_object_onoff($answerrecord,
'status',
'status',
'Enabled',
'Disabled', array(),
'valignmiddle inline-block');
4885 print
'<td class="nowrap center">';
4887 print
'<!-- Status of page -->'.
"\n";
4888 if ($massactionbutton || $massaction) {
4890 if (in_array($answerrecord->id, $arrayofselected)) {
4893 print
'<input id="'.$answerrecord->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$answerrecord->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
4903 $translateofrecordtype = array(
4904 'website_csscontent'=>
'WEBSITE_CSS_INLINE',
4905 'website_jscontent'=>
'WEBSITE_JS_INLINE',
4906 'website_robotcontent'=>
'WEBSITE_ROBOT',
4907 'website_htmlheadercontent'=>
'WEBSITE_HTML_HEADER',
4908 'website_htaccess'=>
'WEBSITE_HTACCESS',
4909 'website_readme'=>
'WEBSITE_README',
4910 'website_manifestjson'=>
'WEBSITE_MANIFEST_JSON'
4912 if (!empty($translateofrecordtype[$answerrecord[
'type']])) {
4913 print $langs->trans($translateofrecordtype[$answerrecord[
'type']]);
4915 print $answerrecord[
'type'];
4919 $param =
'?mode=replacesite';
4920 $param .=
'&websiteid='.$website->id;
4921 $param .=
'&optioncontent='.GETPOST(
'optioncontent',
'aZ09');
4922 $param .=
'&optionmeta='.GETPOST(
'optionmeta',
'aZ09');
4923 $param .=
'&optionsitefiles='.GETPOST(
'optionsitefiles',
'aZ09');
4924 $param .=
'&optioncontainertype='.GETPOST(
'optioncontainertype',
'aZ09');
4925 $param .=
'&optionlanguage='.GETPOST(
'optionlanguage',
'aZ09');
4926 $param .=
'&optioncategory='.GETPOST(
'optioncategory',
'aZ09');
4927 $param .=
'&searchstring='.urlencode($searchkey);
4931 $backtopageurl = $_SERVER[
"PHP_SELF"].$param;
4932 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=editcss&token='.newToken().
'&website='.urlencode($website->ref).
'&backtopage='.urlencode($backtopageurl).
'">'.$langs->trans(
"EditCss").
'</a>';
4948 print
'<td class="center nowraponall">';
4957 print
'<td class="nowrap center">';
4964 if (count($listofpages[
'list']) >= 2) {
4966 print
'<tr class="lite_titre">';
4970 print $langs->trans(
"Total");
4986 print
'<td class="center nowraponall">';
4987 print $totalnbwords.
' '.$langs->trans(
"words");
4999 print
'<td class="nowrap center">';
5009 print
'<div class="warning">'.$listofpages[
'message'].
'</div>';
5018if ((empty($action) || $action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone') && !in_array($mode, array(
'replacesite'))) {
5019 if ($pageid > 0 && $atleastonepage) {
5025 $objectpage->fetch($pageid);
5027 $jscontent = @file_get_contents($filejs);
5029 $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";
5038 $out .=
"\n<html><head>\n";
5039 $out .=
"<!-- htmlheader/style of page from database -->\n";
5042 $out .=
"<!-- htmlheader/style of website from files -->\n";
5060 $out .=
"</head>\n";
5064 $out .=
'<div id="websitecontentundertopmenu" class="websitecontentundertopmenu boostrap-iso">'.
"\n";
5068 $out .=
'<!-- style of website from file -->'.
"\n";
5069 $out .=
'<style scoped>'.
"\n";
5071 $tmpout .=
'/* Include website CSS file */'.
"\n";
5075 $csscontent = ob_get_contents();
5078 $tmpout .=
'/* Include style from the HTML header of page */'.
"\n";
5080 $tmp = preg_split(
'(<style[^>]*>|</style>)', $objectpage->htmlheader);
5081 $tmpstyleinheader =
'';
5083 foreach ($tmp as $valtmp) {
5086 $tmpstyleinheader .= $valtmp.
"\n";
5089 $tmpout .= $tmpstyleinheader.
"\n";
5091 $tmpout = preg_replace(
'/}[\s\n]*body\s*{[^}]+}/ims',
'}', $tmpout);
5093 $out .=
'</style>'.
"\n";
5100 $out .=
'<div id="divbodywebsite" class="bodywebsite bodywebpage-'.$objectpage->ref.
'">'.
"\n";
5102 $newcontent = $objectpage->content;
5109 $filephp = $filetpl;
5112 $res = include $filephp;
5114 print
"ERROR: Failed to include file '".$filephp.
"'. Try to edit and re-save page ith this ID.";
5117 print $e->getMessage();
5119 $newcontent = ob_get_contents();
5126 $newcontent = preg_replace(
'/(div|section)(\s[^>]*)contenteditable="true"/',
'\1\2', $newcontent);
5135 $out .=
'</div> <!-- End div id=websitecontentundertopmenu -->';
5141 $out .=
"\n</body></html>\n";
5143 $out .=
"\n".
'<!-- End page content '.$filetpl.
' -->'.
"\n\n";
5167 if (empty($websitekey) || $websitekey ==
'-1') {
5168 print
'<br><br><div class="center previewnotyetavailable"><span class="">'.$langs->trans(
"NoWebSiteCreateOneFirst").
'</span></div><br><br><br>';
5169 print
'<div class="center"><div class="logo_setup"></div></div>';
5171 print
'<br><br><div class="center previewnotyetavailable"><span class="">'.$langs->trans(
"PreviewOfSiteNotYetAvailable", $object->ref).
'</span></div><br><br><br>';
5172 print
'<div class="center"><div class="logo_setup"></div></div>';
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input=array(), $morecss='', $htmlname='', $forcenojs=0)
On/off button to change a property status of an object This uses the ajax service objectonoff....
Class to manage categories.
Class to manage a WYSIWYG editor.
lessphp v0.8.0 http://leafo.net/lessphp
Class to manage Dolibarr users.
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories)
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_is_file($pathoffile)
Return if path is a file.
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).
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...
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_help($usehelpcursor=1, $usealttitle=1)
Show help logo with cursor "?".
GETPOSTINT($paramname, $method=0)
Return value of a param into GET or POST supervariable.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled='', $morecss='classlink button bordertransp', $jsonopen='', $backtopagejsfields='', $accesskey='')
Return HTML code to output a button to open a dialog popup box.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dolChmod($filepath, $newmask='')
Change mod of a file.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
img_previous($titlealt='default', $moreatt='')
Show previous logo.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
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.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
img_next($titlealt='default', $moreatt='')
Show next logo.
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...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
getDomainFromURL($url, $mode=0)
Function get second level domain name.
getRootURLFromURL($url)
Function root url from a long url For example: https://www.abc.mydomain.com/dir/page....
getURLContent($url, $postorget='GET', $param='', $followlocation=1, $addheaders=array(), $allowedschemes=array('http', 'https'), $localurl=0, $ssl_verifypeer=-1)
Function to get a content from an URL (use proxy if proxy defined).
removeHtmlComment($content)
Function to remove comments into HTML content.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
$conf db name
Only used if Module[ID]Name translation string is not found.
getMaxFileSizeArray()
Return the max allowed for file upload.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
checkPHPCode($phpfullcodestringold, $phpfullcodestring)
Check a new string containing only php code (including <php tag)
dolSaveMasterFile($filemaster)
Save content of a page on disk.
showWebsiteTemplates(Website $website)
Show list of themes.
dolSaveLicense($file, $content)
Save content of a page on disk.
dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent)
Save content of a page on disk.
dolSaveReadme($file, $content)
Save content of a page on disk.
dolSaveManifestJson($file, $content)
Save content of a page on disk.
dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper, $object=null)
Save content of the index.php and/or the wrapper.php page.
dolSavePageAlias($filealias, $object, $objectpage)
Save an alias page on disk (A page that include the reference page).
dolSaveHtaccessFile($filehtaccess, $htaccess)
Save content of a page on disk.
dolSaveJsFile($filejs, $jscontent)
Save content of a page on disk.
dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage, $backupold=0)
Save content of a page on disk (page name is generally ID_of_page.php).
dolSaveCssFile($filecss, $csscontent)
Save content of a page on disk.
dolSaveRobotFile($filerobot, $robotcontent)
Save content of a page on disk.
getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modifylinks=0, $grabimages=1, $grabimagesinto='subpage')
Download all images found into page content $tmp.
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.
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.
dolStripPhpCode($str, $replacewith='')
Remove PHP code part from a string.
dolKeepOnlyPhpCode($str)
Keep only PHP code part from a HTML string page.