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';
859 preg_match(
'/<head>(.*)<\/head>/ims', $tmp[
'content'], $regs);
862 $objectpage->type_container =
'page';
863 $objectpage->pageurl = $pageurl;
864 if (empty($objectpage->pageurl)) {
866 $objectpage->pageurl = $tmpdomain.
'-home';
869 $objectpage->aliasalt =
'';
871 if (preg_match(
'/^(\d+)\-/', basename($urltograb), $regs)) {
872 $objectpage->aliasalt = $regs[1];
876 if (preg_match(
'/<title>(.*)<\/title>/ims', $head, $regtmp)) {
877 $objectpage->title = $regtmp[1];
879 if (preg_match(
'/<meta name="title"[^"]+content="([^"]+)"/ims', $head, $regtmp)) {
880 if (empty($objectpage->title)) {
881 $objectpage->title = $regtmp[1];
884 if (preg_match(
'/<meta name="description"[^"]+content="([^"]+)"/ims', $head, $regtmp)) {
885 $objectpage->description = $regtmp[1];
887 if (preg_match(
'/<meta name="keywords"[^"]+content="([^"]+)"/ims', $head, $regtmp)) {
888 $objectpage->keywords = $regtmp[1];
890 if (preg_match(
'/<html\s+lang="([^"]+)"/ims', $tmp[
'content'], $regtmp)) {
891 $tmplang = explode(
'-', $regtmp[1]);
892 $objectpage->lang = $tmplang[0].($tmplang[1] ?
'_'.strtoupper($tmplang[1]) :
'');
895 $tmp[
'content'] = preg_replace(
'/\s*<meta name="generator"[^"]+content="([^"]+)"\s*\/?>/ims',
'', $tmp[
'content']);
897 $objectpage->content = $tmp[
'content'];
898 $objectpage->content = preg_replace(
'/^.*<body(\s[^>]*)*>/ims',
'', $objectpage->content);
899 $objectpage->content = preg_replace(
'/<\/body(\s[^>]*)*>.*$/ims',
'', $objectpage->content);
907 $objectpage->htmlheader = $tmp[
'content'];
908 $objectpage->htmlheader = preg_replace(
'/^.*<head(\s[^>]*)*>/ims',
'', $objectpage->htmlheader);
909 $objectpage->htmlheader = preg_replace(
'/<\/head(\s[^>]*)*>.*$/ims',
'', $objectpage->htmlheader);
910 $objectpage->htmlheader = preg_replace(
'/<base(\s[^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
911 $objectpage->htmlheader = preg_replace(
'/<meta http-equiv="content-type"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
912 $objectpage->htmlheader = preg_replace(
'/<meta name="robots"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
913 $objectpage->htmlheader = preg_replace(
'/<meta name="title"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
914 $objectpage->htmlheader = preg_replace(
'/<meta name="description"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
915 $objectpage->htmlheader = preg_replace(
'/<meta name="keywords"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
916 $objectpage->htmlheader = preg_replace(
'/<meta name="generator"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
919 $objectpage->htmlheader = preg_replace(
'/<title>[^<]*<\/title>\n*/ims',
'', $objectpage->htmlheader);
920 $objectpage->htmlheader = preg_replace(
'/<link[^>]*rel="shortcut[^>]*>\n/ims',
'', $objectpage->htmlheader);
921 $objectpage->htmlheader = preg_replace(
'/<link[^>]*rel="alternate[^>]*>\n/ims',
'', $objectpage->htmlheader);
922 $objectpage->htmlheader = preg_replace(
'/<link[^>]*rel="canonical[^>]*>\n/ims',
'', $objectpage->htmlheader);
925 $tmp = $objectpage->htmlheader;
928 preg_match_all(
'/<script([^\.>]+)src=["\']([^"\'>]+)["\']([^>]*)><\/script>/i', $objectpage->htmlheader, $regs);
929 $errorforsubresource = 0;
930 foreach ($regs[0] as $key => $val) {
931 dol_syslog(
"We will grab the script resource found into script tag ".$regs[2][$key]);
933 $linkwithoutdomain = $regs[2][$key];
934 if (preg_match(
'/^\//', $regs[2][$key])) {
935 $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key];
937 $urltograbbis = $urltograbdirwithoutslash.
'/'.$regs[2][$key];
941 if (preg_match(
'/^http/', $regs[2][$key])) {
942 $urltograbbis = $regs[2][$key];
943 $linkwithoutdomain = preg_replace(
'/^https?:\/\/[^\/]+\//i',
'', $regs[2][$key]);
953 if ($domaintograb != $domaintograbbis) {
985 $tmp = preg_replace(
'/'.preg_quote($regs[0][$key],
'/').
'/i',
'', $tmp);
987 $objectpage->htmlheader = trim($tmp).
"\n";
991 $pagecsscontent =
"\n".
'<style>'.
"\n";
993 preg_match_all(
'/<link([^\.>]+)href=["\']([^"\'>]+\.css[^"\'>]*)["\']([^>]*)>/i', $objectpage->htmlheader, $regs);
994 $errorforsubresource = 0;
995 foreach ($regs[0] as $key => $val) {
996 dol_syslog(
"We will grab the css resources found into link tag ".$regs[2][$key]);
998 $linkwithoutdomain = $regs[2][$key];
999 if (preg_match(
'/^\//', $regs[2][$key])) {
1000 $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key];
1002 $urltograbbis = $urltograbdirwithoutslash.
'/'.$regs[2][$key];
1006 if (preg_match(
'/^http/', $regs[2][$key])) {
1007 $urltograbbis = $regs[2][$key];
1008 $linkwithoutdomain = preg_replace(
'/^https?:\/\/[^\/]+\//i',
'', $regs[2][$key]);
1018 if ($domaintograb != $domaintograbbis) {
1022 $tmpgeturl =
getURLContent($urltograbbis,
'GET',
'', 1, array(), array(
'http',
'https'), 0);
1023 if ($tmpgeturl[
'curl_error_no']) {
1024 $errorforsubresource++;
1025 setEventMessages(
'Error getting link tag url '.$urltograbbis.
': '.$tmpgeturl[
'curl_error_msg'],
null,
'errors');
1026 dol_syslog(
'Error getting '.$urltograbbis.
': '.$tmpgeturl[
'curl_error_msg']);
1027 $action =
'createcontainer';
1028 } elseif ($tmpgeturl[
'http_code'] !=
'200') {
1029 $errorforsubresource++;
1030 setEventMessages(
'Error getting link tag url '.$urltograbbis.
': '.$tmpgeturl[
'http_code'],
null,
'errors');
1031 dol_syslog(
'Error getting '.$urltograbbis.
': '.$tmpgeturl[
'curl_error_msg']);
1032 $action =
'createcontainer';
1041 $tmpgeturl[
'content'] = preg_replace(
'/\/\*\s+CSS content[a-z\s]*\s+\*\//',
'', $tmpgeturl[
'content']);
1051 $pagecsscontent .=
'/* Content of file '.$urltograbbis.
' */'.
"\n";
1053 getAllImages($object, $objectpage, $urltograbbis, $tmpgeturl[
'content'], $action, 1, $grabimages, $grabimagesinto);
1056 include_once DOL_DOCUMENT_ROOT.
'/core/class/lessc.class.php';
1057 $lesscobj =
new Lessc();
1059 $contentforlessc =
".bodywebsite {\n".$tmpgeturl[
'content'].
"\n}\n";
1061 $contentforlessc = $lesscobj->compile($contentforlessc);
1064 $pagecsscontent .= $contentforlessc.
"\n";
1066 }
catch (exception $e) {
1068 dol_syslog(
"Failed to compile the CSS from URL ".$urltograbbis.
" with lessc: ".$e->getMessage(), LOG_WARNING);
1069 $pagecsscontent .= $tmpgeturl[
'content'].
"\n";
1072 $objectpage->htmlheader = preg_replace(
'/'.preg_quote($regs[0][$key],
'/').
'\n*/ims',
'', $objectpage->htmlheader);
1076 $pagecsscontent .=
'</style>';
1080 $objectpage->htmlheader .= trim($pagecsscontent).
"\n";
1084 $tmp = $objectpage->content;
1086 getAllImages($object, $objectpage, $urltograb, $tmp, $action, 1, $grabimages, $grabimagesinto);
1089 $tmp = preg_replace(
'/a href="\/([^\/"]+)\/([^\/"]+)"/',
'a href="/\1-\2.php"', $tmp);
1090 $tmp = preg_replace(
'/a href="\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)"/',
'a href="/\1-\2-\3.php"', $tmp);
1091 $tmp = preg_replace(
'/a href="\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)"/',
'a href="/\1-\2-\3-\4.php"', $tmp);
1094 $objectpage->content = $tmp;
1096 $objectpage->grabbed_from = $urltograb;
1100 $newaliasnames =
'';
1101 if (!$error &&
GETPOST(
'WEBSITE_ALIASALT',
'alpha')) {
1102 $arrayofaliastotest = explode(
',', str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_ALIASALT',
'alpha')));
1104 foreach ($arrayofaliastotest as $aliastotest) {
1105 $aliastotest = trim(preg_replace(
'/\.php$/i',
'', $aliastotest));
1108 if (preg_match(
'/^page\d+/i', $aliastotest)) {
1110 $langs->load(
"errors");
1112 $action =
'createcontainer';
1115 $result = $websitepagetemp->fetch(0, $object->id, $aliastotest);
1118 $langs->load(
"errors");
1119 setEventMessages($websitepagetemp->error, $websitepagetemp->errors,
'errors');
1120 $action =
'createcontainer';
1125 $langs->load(
"errors");
1126 setEventMessages($langs->trans(
"ErrorAPageWithThisNameOrAliasAlreadyExists", $websitepagetemp->pageurl),
null,
'errors');
1127 $action =
'createcontainer';
1130 $newaliasnames .= ($newaliasnames ?
', ' :
'').$aliastotest;
1135 $objectpage->title = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_TITLE',
'alphanohtml'));
1136 $objectpage->type_container =
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'aZ09');
1137 $objectpage->pageurl =
GETPOST(
'WEBSITE_PAGENAME',
'alpha');
1138 $objectpage->aliasalt = $newaliasnames;
1139 $objectpage->description = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml'));
1140 $objectpage->lang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
1141 $objectpage->otherlang =
GETPOST(
'WEBSITE_OTHERLANG',
'aZ09comma');
1142 $objectpage->image =
GETPOST(
'WEBSITE_IMAGE',
'alpha');
1143 $objectpage->keywords = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_KEYWORDS',
'alphanohtml'));
1144 $objectpage->allowed_in_frames =
GETPOST(
'WEBSITE_ALLOWED_IN_FRAMES',
'aZ09');
1145 $objectpage->htmlheader =
GETPOST(
'htmlheader',
'none');
1146 $objectpage->author_alias =
GETPOST(
'WEBSITE_AUTHORALIAS',
'alphanohtml');
1147 $objectpage->object_type =
GETPOST(
'WEBSITE_OBJECTCLASS');
1148 $objectpage->fk_object =
GETPOST(
'WEBSITE_OBJECTID');
1149 $substitutionarray = array();
1150 $substitutionarray[
'__WEBSITE_CREATE_BY__'] = $user->getFullName($langs);
1153 $pageidfortranslation = (
GETPOST(
'pageidfortranslation',
'int') > 0 ?
GETPOST(
'pageidfortranslation',
'int') : 0);
1154 if ($pageidfortranslation > 0) {
1157 $objectpagetmp->fetch($pageidfortranslation);
1158 if ($objectpagetmp->fk_page > 0) {
1159 $pageidfortranslation = $objectpagetmp->fk_page;
1162 $objectpage->fk_page = $pageidfortranslation;
1164 $sample =
GETPOST(
'sample',
'alpha');
1165 if (empty($sample)) {
1169 $pathtosample = DOL_DOCUMENT_ROOT.
'/website/samples/page-sample-'.
dol_sanitizeFileName($sample).
'.html';
1172 $objectpage->content =
make_substitutions(@file_get_contents($pathtosample), $substitutionarray);
1176 if (empty($objectpage->pageurl)) {
1177 $langs->load(
"errors");
1178 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WEBSITE_PAGENAME")),
null,
'errors');
1180 $action =
'createcontainer';
1181 } elseif (!preg_match(
'/^[a-z0-9\-\_]+$/i', $objectpage->pageurl)) {
1182 $langs->load(
"errors");
1183 setEventMessages($langs->transnoentities(
"ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities(
'WEBSITE_PAGENAME')),
null,
'errors');
1185 $action =
'createcontainer';
1187 if (empty($objectpage->title)) {
1188 $langs->load(
"errors");
1189 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WEBSITE_TITLE")),
null,
'errors');
1191 $action =
'createcontainer';
1193 if ($objectpage->fk_page > 0 && empty($objectpage->lang)) {
1194 $langs->load(
"errors");
1195 setEventMessages($langs->trans(
"ErrorLanguageRequiredIfPageIsTranslationOfAnother"),
null,
'errors');
1197 $action =
'createcontainer';
1199 if ($objectpage->fk_page > 0 && !empty($objectpage->lang)) {
1200 if ($objectpage->lang == $website->lang) {
1201 $langs->load(
"errors");
1202 setEventMessages($langs->trans(
"ErrorLanguageMustNotBeSourceLanguageIfPageIsTranslationOfAnother"),
null,
'errors');
1204 $action =
'createcontainer';
1211 $pageid = $objectpage->create($user);
1215 $action =
'createcontainer';
1221 $categoriesarray =
GETPOST(
'categories',
'array');
1222 $result = $objectpage->setCategories($categoriesarray);
1231 if (empty($object->fk_default_home)) {
1232 $object->fk_default_home = $pageid;
1233 $res = $object->update($user);
1238 $filetpl = $pathofwebsite.
'/page'.$pageid.
'.tpl.php';
1241 $result =
dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper, $object);
1251 if (!empty($objectpage->content)) {
1252 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
1253 $filetpl = $pathofwebsite.
'/page'.$objectpage->id.
'.tpl.php';
1258 setEventMessages(
'Failed to write file '.basename($filealias),
null,
'errors');
1267 $action =
'createcontainer';
1274 setEventMessages($langs->trans(
"PageAdded", $objectpage->pageurl),
null,
'mesgs');
1281 $pageid = $objectpage->id;
1286 $pathtomedias = DOL_DATA_ROOT.
'/medias';
1287 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
1289 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
1290 dol_mkdir(dirname($pathtomediasinwebsite));
1291 $result = symlink($pathtomedias, $pathtomediasinwebsite);
1304 $htmlheadercontent =
"<html>\n";
1305 $htmlheadercontent .= $htmlheadercontentdefault;
1306 $htmlheadercontent .=
"</html>";
1311 $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;}";
1316 $jscontent =
"/* JS content (all pages) */\n";
1321 $robotcontent =
"# Robot file. Generated with Dolibarr\nUser-agent: *\nAllow: /public/\nDisallow: /administrator/";
1326 $htaccesscontent =
"# Order allow,deny\n# Deny from all";
1331 $manifestjsoncontent =
"";
1336 $readmecontent =
"Website generated by Dolibarr ERP CRM";
1341 $licensecontent =
"MIT License";
1345 $action =
'preview';
1350if ($action ==
'confirm_deletesite' && $confirm ==
'yes' && $permissiontodelete) {
1355 $res = $object->fetch(
GETPOST(
'id',
'int'));
1359 $res = $object->delete($user);
1366 if (
GETPOST(
'delete_also_js',
'alpha') ==
'on') {
1367 $pathofwebsitejs = DOL_DATA_ROOT.
'/medias/js/'.$object->ref;
1371 if (
GETPOST(
'delete_also_medias',
'alpha') ==
'on') {
1372 $pathofwebsitemedias = DOL_DATA_ROOT.
'/medias/image/'.$object->ref;
1380 setEventMessages($langs->trans(
"SiteDeleted", $object->ref),
null,
'mesgs');
1382 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.$object->id);
1391if (GETPOSTISSET(
'pageid') && $action ==
'delete' && $permissiontodelete && !
GETPOST(
'file_manager')) {
1396 $res = $object->fetch(0, $websitekey);
1399 $res = $objectpage->fetch($pageid, $object->id);
1402 $res = $objectpage->delete($user);
1411 setEventMessages($langs->trans(
"PageDeleted", $objectpage->pageurl, $websitekey),
null,
'mesgs');
1413 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$websitekey);
1421if (!GETPOSTISSET(
'pageid')) {
1422 $objectclass =
'WebsitePage';
1426 if (!$error && ($massaction ==
'delete' || ($action ==
'delete' && $confirm ==
'yes')) && $permissiontodelete) {
1429 $objecttmp =
new $objectclass($db);
1431 foreach ($toselect as $toselectid) {
1432 $result = $objecttmp->fetch($toselectid);
1434 $result = $objecttmp->delete($user);
1463 if ($action ==
'delete') {
1464 $mode =
'replacesite';
1465 $action =
'replacesite';
1467 $containertype =
GETPOST(
'optioncontainertype',
'aZ09') !=
'-1' ?
GETPOST(
'optioncontainertype',
'aZ09') :
'';
1468 $langcode =
GETPOST(
'optionlanguage',
'aZ09');
1469 $otherfilters = array();
1470 if (
GETPOST(
'optioncategory',
'int') > 0) {
1471 $otherfilters[
'category'] =
GETPOST(
'optioncategory',
'int');
1474 $listofpages =
getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters);
1479if ($action ==
'updatecss' && $usercanedit) {
1482 $action =
'editcss';
1484 $res = $object->fetch(0, $websitekey);
1487 if (GETPOSTISSET(
'virtualhost')) {
1488 $tmpvirtualhost = preg_replace(
'/\/$/',
'',
GETPOST(
'virtualhost',
'alpha'));
1489 if ($tmpvirtualhost && !preg_match(
'/^http/', $tmpvirtualhost)) {
1491 setEventMessages($langs->trans(
'ErrorURLMustStartWithHttp', $langs->transnoentitiesnoconv(
"VirtualHost")),
null,
'errors');
1492 $action =
'editcss';
1496 $arrayotherlang = explode(
',',
GETPOST(
'WEBSITE_OTHERLANG',
'alphanohtml'));
1497 foreach ($arrayotherlang as $key => $val) {
1499 if (empty(trim($val))) {
1502 $arrayotherlang[$key] = substr(trim($val), 0, 2);
1505 $object->virtualhost = $tmpvirtualhost;
1506 $object->lang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
1507 $object->otherlang = join(
',', $arrayotherlang);
1508 $object->use_manifest =
GETPOSTINT(
'use_manifest');
1510 $result = $object->update($user);
1514 $action =
'editcss';
1520 if (($_FILES[
'addedfile'][
"name"] !=
'')) {
1521 $uploadfolder = $conf->website->dir_output.
'/'.$websitekey;
1522 if ($_FILES[
'addedfile'][
'type'] !=
'image/png') {
1526 $filetoread = realpath(
dol_osencode($_FILES[
'addedfile'][
'tmp_name']));
1527 $filesize = getimagesize($filetoread);
1528 if ($filesize[0] != $filesize[1]) {
1530 setEventMessages($langs->trans(
'ErrorFaviconMustBeASquaredImage'), array(),
'errors');
1532 if (! $error && ($filesize[0] != 16 && $filesize[0] != 32 && $filesize[0] != 64)) {
1541 if (!GETPOSTISSET(
'updateandstay')) {
1542 $action =
'preview';
1544 $backtopage = preg_replace(
'/searchstring=[^&]*/',
'', $backtopage);
1545 header(
"Location: ".$backtopage);
1549 $action =
'editcss';
1568 $dataposted = trim(
GETPOST(
'WEBSITE_HTML_HEADER',
'none'));
1569 $dataposted = preg_replace(array(
'/<html>\n*/ims',
'/<\/html>\n*/ims'), array(
'',
''), $dataposted);
1570 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1573 $phpfullcodestringold =
'';
1577 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1579 if (!$errorphpcheck) {
1580 $htmlheadercontent =
'';
1592 $htmlheadercontent .= $dataposted.
"\n";
1607 $dataposted = trim(
GETPOST(
'WEBSITE_CSS_INLINE',
'none'));
1608 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1611 $phpfullcodestringold =
'';
1615 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1617 if (!$errorphpcheck) {
1620 $csscontent .=
"<?php // BEGIN PHP\n";
1621 $csscontent .=
'$websitekey=basename(__DIR__);'.
"\n";
1622 $csscontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded\n";
1623 $csscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
1624 $csscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
1625 $csscontent .=
"ob_start();\n";
1626 $csscontent .=
"if (! headers_sent()) { /* because file is included inline when in edit mode and we don't want warning */ \n";
1627 $csscontent .=
"header('Cache-Control: max-age=3600, public, must-revalidate');\n";
1628 $csscontent .=
"header('Content-type: text/css');\n";
1629 $csscontent .=
"}\n";
1630 $csscontent .=
"// END PHP ?>\n";
1632 $csscontent .= $dataposted.
"\n";
1634 $csscontent .=
'<?php // BEGIN PHP'.
"\n";
1635 $csscontent .=
'$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "css");'.
"\n";
1636 $csscontent .=
"// END PHP ?>\n";
1638 dol_syslog(
"Save css content into ".$filecss);
1650 $dataposted = trim(
GETPOST(
'WEBSITE_JS_INLINE',
'none'));
1651 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1654 $phpfullcodestringold =
'';
1658 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1660 if (!$errorphpcheck) {
1663 $jscontent .=
"<?php // BEGIN PHP\n";
1664 $jscontent .=
'$websitekey=basename(__DIR__);'.
"\n";
1665 $jscontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded\n";
1666 $jscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
1667 $jscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
1668 $jscontent .=
"ob_start();\n";
1669 $jscontent .=
"header('Cache-Control: max-age=3600, public, must-revalidate');\n";
1670 $jscontent .=
"header('Content-type: application/javascript');\n";
1671 $jscontent .=
"// END PHP ?>\n";
1673 $jscontent .= $dataposted.
"\n";
1675 $jscontent .=
'<?php // BEGIN PHP'.
"\n";
1676 $jscontent .=
'$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "js");'.
"\n";
1677 $jscontent .=
"// END PHP ?>\n";
1688 $dataposted = trim(
GETPOST(
'WEBSITE_ROBOT',
'restricthtml'));
1689 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1692 $phpfullcodestringold =
'';
1696 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1698 if (!$errorphpcheck) {
1711 $robotcontent .= $dataposted.
"\n";
1726 $dataposted = trim(
GETPOST(
'WEBSITE_HTACCESS',
'restricthtml'));
1727 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1730 $phpfullcodestringold =
'';
1734 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1736 if (!$errorphpcheck) {
1737 $htaccesscontent =
'';
1738 $htaccesscontent .= $dataposted.
"\n";
1750 $dataposted = trim(
GETPOST(
'WEBSITE_MANIFEST_JSON',
'none'));
1751 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1754 $phpfullcodestringold =
'';
1758 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1760 if (!$errorphpcheck) {
1761 $manifestjsoncontent =
'';
1763 $manifestjsoncontent .=
"<?php // BEGIN PHP\n";
1764 $manifestjsoncontent .=
'$websitekey=basename(__DIR__);'.
"\n";
1765 $manifestjsoncontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded\n";
1766 $manifestjsoncontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
1767 $manifestjsoncontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
1768 $manifestjsoncontent .=
"ob_start();\n";
1769 $manifestjsoncontent .=
"header('Cache-Control: max-age=3600, public, must-revalidate');\n";
1770 $manifestjsoncontent .=
"header('Content-type: application/manifest+json');\n";
1771 $manifestjsoncontent .=
"// END PHP ?>\n";
1773 $manifestjsoncontent .= $dataposted.
"\n";
1775 $manifestjsoncontent .=
'<?php // BEGIN PHP'.
"\n";
1776 $manifestjsoncontent .=
'$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "manifest");'.
"\n";
1777 $manifestjsoncontent .=
"// END PHP ?>\n";
1782 setEventMessages(
'Failed to write file '.$filemanifestjson,
null,
'errors');
1788 $dataposted = trim(
GETPOST(
'WEBSITE_README',
'restricthtml'));
1789 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1792 $phpfullcodestringold =
'';
1796 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1798 if (!$errorphpcheck) {
1799 $readmecontent =
'';
1811 $readmecontent .= $dataposted.
"\n";
1826 $dataposted = trim(
GETPOST(
'WEBSITE_LICENSE',
'restricthtml'));
1827 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1830 $phpfullcodestringold =
'';
1834 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1836 if (!$errorphpcheck) {
1837 $licensecontent =
'';
1849 $licensecontent .= $dataposted.
"\n";
1873 if (!GETPOSTISSET(
'updateandstay')) {
1874 $action =
'preview';
1876 $backtopage = preg_replace(
'/searchstring=[^&]*/',
'', $backtopage);
1877 header(
"Location: ".$backtopage);
1881 $action =
'editcss';
1888if ($action ==
'setashome' && $usercanedit) {
1890 $object->fetch(0, $websitekey);
1893 $object->fk_default_home = $pageid;
1894 $res = $object->update($user);
1903 $filetpl = $pathofwebsite.
'/page'.$pageid.
'.tpl.php';
1906 $result =
dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper, $object);
1914 $action =
'preview';
1921if ($action ==
'updatemeta' && $usercanedit) {
1924 $result = $object->fetch(0, $websitekey);
1927 $objectpage->fk_website = $object->id;
1930 if (!preg_match(
'/^[a-z0-9\-\_]+$/i',
GETPOST(
'WEBSITE_PAGENAME',
'alpha'))) {
1932 $langs->load(
"errors");
1933 setEventMessages($langs->transnoentities(
"ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities(
'WEBSITE_PAGENAME')),
null,
'errors');
1934 $action =
'editmeta';
1937 $res = $objectpage->fetch($pageid, $object->id);
1940 setEventMessages(
'Page not found '.$objectpage->error, $objectpage->errors,
'errors');
1944 if (!$error &&
GETPOST(
'WEBSITE_PAGENAME',
'alpha')) {
1946 $result = $websitepagetemp->fetch(-1 * $objectpage->id, $object->id,
GETPOST(
'WEBSITE_PAGENAME',
'alpha'));
1949 $langs->load(
"errors");
1950 setEventMessages($websitepagetemp->error, $websitepagetemp->errors,
'errors');
1951 $action =
'editmeta';
1955 $langs->load(
"errors");
1956 setEventMessages($langs->trans(
"ErrorAPageWithThisNameOrAliasAlreadyExists", $websitepagetemp->pageurl),
null,
'errors');
1957 $action =
'editmeta';
1961 $newaliasnames =
'';
1962 if (!$error &&
GETPOST(
'WEBSITE_ALIASALT',
'alpha')) {
1963 $arrayofaliastotest = explode(
',', str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_ALIASALT',
'alpha')));
1966 foreach ($arrayofaliastotest as $aliastotest) {
1967 $aliastotest = trim(preg_replace(
'/\.php$/i',
'', $aliastotest));
1970 if (preg_match(
'/^page\d+/i', $aliastotest)) {
1972 $langs->load(
"errors");
1974 $action =
'editmeta';
1977 $result = $websitepagetemp->fetch(-1 * $objectpage->id, $object->id, $aliastotest);
1980 $langs->load(
"errors");
1981 setEventMessages($websitepagetemp->error, $websitepagetemp->errors,
'errors');
1982 $action =
'editmeta';
1987 $langs->load(
"errors");
1988 setEventMessages($langs->trans(
"ErrorAPageWithThisNameOrAliasAlreadyExists", $websitepagetemp->pageurl),
null,
'errors');
1989 $action =
'editmeta';
1992 $newaliasnames .= ($newaliasnames ?
', ' :
'').$aliastotest;
1998 $objectpage->old_object = clone $objectpage;
2000 $objectpage->title = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_TITLE',
'alphanohtml'));
2001 $objectpage->type_container =
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'aZ09');
2002 $objectpage->pageurl =
GETPOST(
'WEBSITE_PAGENAME',
'alpha');
2003 $objectpage->aliasalt = $newaliasnames;
2004 $objectpage->lang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
2005 $objectpage->otherlang =
GETPOST(
'WEBSITE_OTHERLANG',
'aZ09comma');
2006 $objectpage->description = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml'));
2007 $objectpage->image =
GETPOST(
'WEBSITE_IMAGE',
'alpha');
2008 $objectpage->keywords = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_KEYWORDS',
'alphanohtml'));
2009 $objectpage->allowed_in_frames =
GETPOST(
'WEBSITE_ALLOWED_IN_FRAMES',
'aZ09');
2010 $objectpage->htmlheader = trim(
GETPOST(
'htmlheader',
'none'));
2011 $objectpage->fk_page = (
GETPOST(
'pageidfortranslation',
'int') > 0 ?
GETPOST(
'pageidfortranslation',
'int') : 0);
2012 $objectpage->author_alias = trim(
GETPOST(
'WEBSITE_AUTHORALIAS',
'alphanohtml'));
2013 $objectpage->object_type =
GETPOST(
'WEBSITE_OBJECTCLASS',
'alpha');
2014 $objectpage->fk_object =
GETPOST(
'WEBSITE_OBJECTID',
'aZ09');
2016 $newdatecreation =
dol_mktime(
GETPOST(
'datecreationhour',
'int'),
GETPOST(
'datecreationmin',
'int'),
GETPOST(
'datecreationsec',
'int'),
GETPOST(
'datecreationmonth',
'int'),
GETPOST(
'datecreationday',
'int'),
GETPOST(
'datecreationyear',
'int'));
2017 if ($newdatecreation) {
2018 $objectpage->date_creation = $newdatecreation;
2021 $res = $objectpage->update($user);
2023 $langs->load(
"errors");
2024 if ($db->lasterrno ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
2026 $langs->load(
"errors");
2027 setEventMessages($langs->trans(
"ErrorAPageWithThisNameOrAliasAlreadyExists"),
null,
'errors');
2028 $action =
'editmeta';
2031 $langs->load(
"errors");
2033 $action =
'editmeta';
2040 $categoriesarray =
GETPOST(
'categories',
'array');
2041 $result = $objectpage->setCategories($categoriesarray);
2055 $filemaster = $pathofwebsite.
'/master.inc.php';
2056 $fileoldalias = $pathofwebsite.
'/'.$objectpage->old_object->pageurl.
'.php';
2057 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
2068 if (!empty($fileoldalias)) {
2069 dol_syslog(
"We delete old alias page name=".$fileoldalias.
" to build a new alias page=".$filealias);
2073 if (empty($objectpage->lang) || !in_array($objectpage->lang, explode(
',', $object->otherlang))) {
2074 $dirname = dirname($fileoldalias);
2075 $filename = basename($fileoldalias);
2076 $sublangs = explode(
',', $object->otherlang);
2077 foreach ($sublangs as $sublang) {
2081 if (empty(trim($sublang))) {
2084 $fileoldaliassub = $dirname.
'/'.$sublang.
'/'.$filename;
2090 if (!empty($objectpage->old_object->aliasalt)) {
2091 $tmpaltaliases = explode(
',', $objectpage->old_object->aliasalt);
2092 if (is_array($tmpaltaliases)) {
2093 foreach ($tmpaltaliases as $tmpaliasalt) {
2094 dol_syslog(
"We delete old alt alias pages name=".trim($tmpaliasalt));
2098 if (empty($objectpage->lang) || !in_array($objectpage->lang, explode(
',', $object->otherlang))) {
2099 $dirname = dirname($pathofwebsite.
'/'.trim($tmpaliasalt).
'.php');
2100 $filename = basename($pathofwebsite.
'/'.trim($tmpaliasalt).
'.php');
2101 $sublangs = explode(
',', $object->otherlang);
2102 foreach ($sublangs as $sublang) {
2106 if (empty(trim($sublang))) {
2109 $fileoldaliassub = $dirname.
'/'.$sublang.
'/'.$filename;
2123 if (!empty($objectpage->aliasalt)) {
2124 $tmpaltaliases = explode(
',', $objectpage->aliasalt);
2125 if (is_array($tmpaltaliases)) {
2126 foreach ($tmpaltaliases as $tmpaliasalt) {
2127 if (trim($tmpaliasalt)) {
2128 $filealias = $pathofwebsite.
'/'.trim($tmpaliasalt).
'.php';
2131 setEventMessages(
'Failed to write file '.basename($filealias),
null,
'errors');
2144 if (!GETPOSTISSET(
'updateandstay')) {
2147 $action =
'preview';
2149 $action =
'editmeta';
2155 $action =
'preview';
2161if ($usercanedit && (($action ==
'updatesource' || $action ==
'updatecontent' || $action ==
'confirm_createfromclone' || $action ==
'confirm_createpagefromclone')
2162 || ($action ==
'preview' && (
GETPOST(
'refreshsite') ||
GETPOST(
'refreshpage') ||
GETPOST(
'preview'))))) {
2163 $object->fetch(0, $websitekey);
2166 if ($action ==
'confirm_createfromclone') {
2169 $objectnew =
new Website($db);
2170 $result = $objectnew->createFromClone($user,
GETPOST(
'id',
'int'),
GETPOST(
'siteref',
'aZ09'), (
GETPOST(
'newlang',
'aZ09') ?
GETPOST(
'newlang',
'aZ09') :
''));
2175 $action =
'preview';
2179 $object = $objectnew;
2181 $pageid = $object->fk_default_home;
2182 $websitekey =
GETPOST(
'siteref',
'aZ09');
2188 if ($action ==
'confirm_createpagefromclone') {
2189 $istranslation = (
GETPOST(
'is_a_translation',
'aZ09') ==
'on' ? 1 : 0);
2191 if ($istranslation) {
2192 if (
GETPOST(
'newlang',
'aZ09') == $objectpage->lang || !
GETPOST(
'newlang',
'aZ09')) {
2194 setEventMessages($langs->trans(
"LanguageMustNotBeSameThanClonedPage"),
null,
'errors');
2195 $action =
'preview';
2197 if (
GETPOST(
'newwebsite',
'int') != $object->id) {
2199 setEventMessages($langs->trans(
"WebsiteMustBeSameThanClonedPageIfTranslation"),
null,
'errors');
2200 $action =
'preview';
2207 $newwebsiteid =
GETPOST(
'newwebsite',
'int');
2208 $pathofwebsitenew = $pathofwebsite;
2210 $tmpwebsite =
new Website($db);
2211 if ($newwebsiteid > 0 && $newwebsiteid != $object->id) {
2212 $tmpwebsite->fetch($newwebsiteid);
2213 $pathofwebsitenew = $dolibarr_main_data_root.($conf->entity > 1 ?
'/'.$conf->entity :
'').
'/website/'.$tmpwebsite->ref;
2215 $tmpwebsite = $object;
2219 $resultpage = $objectpage->createFromClone($user, $pageid,
GETPOST(
'newpageurl',
'aZ09'), (
GETPOST(
'newlang',
'aZ09') ?
GETPOST(
'newlang',
'aZ09') :
''), $istranslation, $newwebsiteid,
GETPOST(
'newtitle',
'alphanohtml'));
2220 if ($resultpage < 0) {
2223 $action =
'createpagefromclone';
2227 $filetpl = $pathofwebsitenew.
'/page'.$resultpage->id.
'.tpl.php';
2228 $fileindex = $pathofwebsitenew.
'/index.php';
2229 $filewrapper = $pathofwebsitenew.
'/wrapper.php';
2238 if (empty($newwebsiteid) || $newwebsiteid == $object->id) {
2239 $pageid = $resultpage->id;
2251 $pathtomedias = DOL_DATA_ROOT.
'/medias';
2252 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
2254 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
2255 dol_mkdir(dirname($pathtomediasinwebsite));
2256 $result = symlink($pathtomedias, $pathtomediasinwebsite);
2265 $objectpage->fk_website = $object->id;
2268 $res = $objectpage->fetch($pageid);
2271 if ($object->fk_default_home > 0) {
2272 $res = $objectpage->fetch($object->fk_default_home);
2275 $res = $objectpage->fetch(0, $object->id);
2280 if (!$error && $res > 0) {
2281 if ($action ==
'updatesource' || $action ==
'updatecontent') {
2286 $objectpage->content =
GETPOST(
'PAGE_CONTENT',
'none');
2291 $error =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
2294 if ($action ==
'updatesource') {
2295 $action =
'editsource';
2297 if ($action ==
'updatecontent') {
2298 $action =
'editcontent';
2303 $objectpage->content = preg_replace(
'/<head>.*<\/head>/ims',
'', $objectpage->content);
2307 $res = $objectpage->update($user);
2311 if ($action ==
'updatesource') {
2312 $action =
'editsource';
2314 if ($action ==
'updatecontent') {
2315 $action =
'editcontent';
2322 $filemaster = $pathofwebsite.
'/master.inc.php';
2324 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
2332 setEventMessages(
'Failed to write the master file file '.$filemaster,
null,
'errors');
2356 setEventMessages(
'Failed to write the alias file '.basename($filealias),
null,
'errors');
2364 if (!GETPOSTISSET(
'updateandstay')) {
2366 header(
"Location: ".$backtopage);
2369 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$websitekey.
'&pageid='.$pageid);
2373 if ($action ==
'updatesource') {
2374 $action =
'editsource';
2376 if ($action ==
'updatecontent') {
2377 $action =
'editcontent';
2382 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$websitekey.
'&pageid='.$pageid);
2389 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$websitekey.
'&pageid='.$pageid);
2394 if (empty($websitekey) || $websitekey ==
'-1') {
2395 setEventMessages($langs->trans(
"NoWebSiteCreateOneFirst"),
null,
'warnings');
2398 setEventMessages($langs->trans(
"YouCanCreatePageOrImportTemplate"),
null,
'warnings');
2405if ($action ==
'exportsite' && $user->hasRight(
'website',
'export')) {
2406 $fileofzip = $object->exportWebSite();
2409 $file_name = basename($fileofzip);
2411 header(
"Content-Type: application/zip");
2412 header(
"Content-Disposition: attachment; filename=".$file_name);
2413 header(
"Content-Length: ".filesize($fileofzip));
2415 readfile($fileofzip);
2419 $action =
'preview';
2424if ($action ==
'regeneratesite' && $usercanedit) {
2426 $pathtomedias = DOL_DATA_ROOT.
'/medias';
2427 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
2429 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
2430 dol_mkdir(dirname($pathtomediasinwebsite));
2431 $result = symlink($pathtomedias, $pathtomediasinwebsite);
2433 $langs->load(
"errors");
2434 setEventMessages($langs->trans(
"ErrorFailedToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias),
null,
'errors');
2435 $action =
'preview';
2439 $result = $object->rebuildWebSiteFiles();
2441 setEventMessages($langs->trans(
"PagesRegenerated", $result),
null,
'mesgs');
2442 $action =
'preview';
2445 $action =
'preview';
2450if ($action ==
'importsiteconfirm' && $usercanedit) {
2451 $dolibarrdataroot = preg_replace(
'/([\\/]+)$/i',
'', DOL_DATA_ROOT);
2452 $allowimportsite =
true;
2453 if (
dol_is_file($dolibarrdataroot.
'/installmodules.lock')) {
2454 $allowimportsite =
false;
2457 if ($allowimportsite) {
2458 if (empty($_FILES) && !GETPOSTISSET(
'templateuserfile')) {
2459 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"File")),
null,
'errors');
2460 $action =
'importsite';
2462 if (!empty($_FILES) || GETPOSTISSET(
'templateuserfile')) {
2464 $pathtomedias = DOL_DATA_ROOT.
'/medias';
2465 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
2467 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
2468 dol_mkdir(dirname($pathtomediasinwebsite));
2469 $result = symlink($pathtomedias, $pathtomediasinwebsite);
2471 $langs->load(
"errors");
2472 setEventMessages($langs->trans(
"ErrorFailedToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias),
null,
'errors');
2473 $action =
'importsite';
2478 if (GETPOSTISSET(
'templateuserfile')) {
2480 $fileofzip = DOL_DATA_ROOT.
'/doctemplates/websites/'.
GETPOST(
'templateuserfile',
'alpha');
2481 } elseif (!empty($_FILES) && is_array($_FILES[
'userfile'])) {
2483 if (is_array($_FILES[
'userfile'][
'tmp_name'])) {
2484 $userfiles = $_FILES[
'userfile'][
'tmp_name'];
2486 $userfiles = array($_FILES[
'userfile'][
'tmp_name']);
2490 foreach ($userfiles as $key => $userfile) {
2491 if (empty($_FILES[
'userfile'][
'tmp_name'][$key])) {
2493 if ($_FILES[
'userfile'][
'error'][$key] == 1 || $_FILES[
'userfile'][
'error'][$key] == 2) {
2495 $action =
'importsite';
2497 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"File")),
null,
'errors');
2498 $action =
'importsite';
2505 $upload_dir = DOL_DATA_ROOT.
'/doctemplates/websites/';
2519 $action =
'importsite';
2522 if (!$error && GETPOSTISSET(
'templateuserfile')) {
2523 $result = $object->importWebSite($fileofzip);
2527 $action =
'importsite';
2530 dolibarr_set_const($db,
'WEBSITE_SUBCONTAINERSINLINE', 1,
'chaine', 0,
'', $conf->entity);
2532 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$object->ref);
2541 $message = $langs->trans(
'InstallModuleFromWebHasBeenDisabledContactUs');
2544 $message = $langs->trans(
"InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.
'/installmodules.lock');
2550$domainname =
'0.0.0.0:8080';
2551$tempdir = $conf->website->dir_output.
'/'.$websitekey.
'/';
2554if ($action ==
'generatesitemaps' && $usercanedit) {
2556 if ($website->virtualhost) {
2557 $domainname = $website->virtualhost;
2559 if (! preg_match(
'/^http/i', $domainname)) {
2560 $domainname =
'https://'.$domainname;
2563 $domtree =
new DOMDocument(
'1.0',
'UTF-8');
2565 $root = $domtree->createElementNS(
'http://www.sitemaps.org/schemas/sitemap/0.9',
'urlset');
2566 $root->setAttributeNS(
'http://www.w3.org/2000/xmlns/',
'xmlns:xhtml',
'http://www.w3.org/1999/xhtml');
2568 $domtree->formatOutput =
true;
2571 $xmlname =
'sitemap.xml';
2573 $sql =
"SELECT wp.rowid, wp.type_container , wp.pageurl, wp.lang, wp.fk_page, wp.tms as tms,";
2574 $sql .=
" w.virtualhost, w.fk_default_home";
2575 $sql .=
" FROM ".MAIN_DB_PREFIX.
"website_page as wp, ".MAIN_DB_PREFIX.
"website as w";
2576 $sql .=
" WHERE wp.type_container IN ('page', 'blogpost')";
2577 $sql .=
" AND wp.fk_website = w.rowid";
2578 $sql .=
" AND wp.status = ".WebsitePage::STATUS_VALIDATED;
2579 $sql .=
" AND wp.pageurl NOT IN ('404', '500', '501', '503')";
2580 $sql .=
" AND w.ref = '".dol_escape_json($websitekey).
"'";
2581 $sql .=
" ORDER BY wp.tms DESC, wp.rowid DESC";
2582 $resql = $db->query($sql);
2584 $num_rows = $db->num_rows($resql);
2585 if ($num_rows > 0) {
2587 while ($i < $num_rows) {
2588 $objp = $db->fetch_object($resql);
2589 $url = $domtree->createElement(
'url');
2591 $shortlangcode =
'';
2593 $shortlangcode = substr($objp->lang, 0, 2);
2595 if (empty($shortlangcode)) {
2596 $shortlangcode = substr($object->lang, 0, 2);
2600 if ($objp->type_container ==
'blogpost') {
2605 $pageurl = $objp->pageurl.
'.php';
2606 if ($objp->fk_default_home == $objp->rowid) {
2609 if ($shortlangcode != substr($object->lang, 0, 2)) {
2610 $pageurl = $shortlangcode.
'/'.$pageurl;
2617 $loc = $domtree->createElement(
'loc', $domainname.
'/'.$pageurl);
2618 $lastmod = $domtree->createElement(
'lastmod',
dol_print_date($db->jdate($objp->tms),
'dayrfc',
'gmt'));
2619 $priority = $domtree->createElement(
'priority',
'1');
2621 $url->appendChild($loc);
2622 $url->appendChild($lastmod);
2625 $changefreq = $domtree->createElement(
'changefreq',
'weekly');
2626 $url->appendChild($changefreq);
2629 if ($objp->fk_default_home == $objp->rowid) {
2630 $url->appendChild($priority);
2634 if ($object->isMultiLang()) {
2635 $alternatefound = 0;
2638 $translationof = $objp->fk_page;
2639 if ($translationof) {
2641 $tmppage->fetch($translationof);
2642 if ($tmppage->id > 0) {
2643 $tmpshortlangcode =
'';
2644 if ($tmppage->lang) {
2645 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'', $tmppage->lang);
2647 if (empty($tmpshortlangcode)) {
2648 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'', $object->lang);
2650 if ($tmpshortlangcode != $shortlangcode) {
2651 $xhtmllink = $domtree->createElement(
'xhtml:link',
'');
2652 $xhtmllink->setAttribute(
"rel",
"alternate");
2653 $xhtmllink->setAttribute(
"hreflang", $tmpshortlangcode);
2654 $xhtmllink->setAttribute(
"href", $domainname.($objp->fk_default_home == $tmppage->id ?
'/' : (($tmpshortlangcode != substr($object->lang, 0, 2)) ?
'/'.$tmpshortlangcode :
'').
'/'.$tmppage->pageurl.
'.php'));
2655 $url->appendChild($xhtmllink);
2663 $sql =
'SELECT rowid as id, lang, pageurl from '.MAIN_DB_PREFIX.
'website_page';
2664 $sql .=
" WHERE status = ".((int) WebsitePage::STATUS_VALIDATED).
' AND fk_page IN ('.$db->sanitize($objp->rowid.($translationof ?
", ".$translationof :
"")).
")";
2665 $resqlhastrans = $db->query($sql);
2666 if ($resqlhastrans) {
2667 $num_rows_hastrans = $db->num_rows($resqlhastrans);
2668 if ($num_rows_hastrans > 0) {
2669 while ($objhastrans = $db->fetch_object($resqlhastrans)) {
2670 $tmpshortlangcode =
'';
2671 if ($objhastrans->lang) {
2672 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'', $objhastrans->lang);
2674 if ($tmpshortlangcode != $shortlangcode) {
2675 $xhtmllink = $domtree->createElement(
'xhtml:link',
'');
2676 $xhtmllink->setAttribute(
"rel",
"alternate");
2677 $xhtmllink->setAttribute(
"hreflang", $tmpshortlangcode);
2678 $xhtmllink->setAttribute(
"href", $domainname.($objp->fk_default_home == $objhastrans->id ?
'/' : (($tmpshortlangcode != substr($object->lang, 0, 2) ?
'/'.$tmpshortlangcode :
'')).
'/'.$objhastrans->pageurl.
'.php'));
2679 $url->appendChild($xhtmllink);
2689 if ($alternatefound) {
2691 $xhtmllink = $domtree->createElement(
'xhtml:link',
'');
2692 $xhtmllink->setAttribute(
"rel",
"alternate");
2693 $xhtmllink->setAttribute(
"hreflang", $shortlangcode);
2694 $xhtmllink->setAttribute(
"href", $domainname.
'/'.$pageurl);
2695 $url->appendChild($xhtmllink);
2711 $root->appendChild($url);
2717 if ($addrsswrapper &&
getDolGlobalInt(
'WEBSITE_ADD_RSS_FEED_INTO_SITEMAP')) {
2718 $url = $domtree->createElement(
'url');
2720 $pageurl =
'wrapper.php?rss=1';
2723 $loc = $domtree->createElement(
'loc', $domainname.
'/'.$pageurl);
2724 $lastmod = $domtree->createElement(
'lastmod',
dol_print_date($db->jdate(
dol_now()),
'dayrfc',
'gmt'));
2726 $url->appendChild($loc);
2727 $url->appendChild($lastmod);
2730 $changefreq = $domtree->createElement(
'changefreq',
'weekly');
2731 $url->appendChild($changefreq);
2734 $root->appendChild($url);
2737 $domtree->appendChild($root);
2739 if ($domtree->save($tempdir.$xmlname)) {
2741 setEventMessages($langs->trans(
"SitemapGenerated", $xmlname),
null,
'mesgs');
2751 $robotcontent = @file_get_contents($filerobot);
2752 $result = preg_replace(
'/<?php \/\/ BEGIN PHP[^?]END PHP ?>\n/ims',
'', $robotcontent);
2754 $robotcontent = $result;
2756 $robotsitemap =
"Sitemap: ".$domainname.
"/".$xmlname;
2757 $result = strpos($robotcontent,
'Sitemap: ');
2759 $result = preg_replace(
'/Sitemap:.*/', $robotsitemap, $robotcontent);
2760 $robotcontent = $result ? $result : $robotcontent;
2762 $robotcontent .= $robotsitemap.
"\n";
2769 $action =
'preview';
2777$form =
new Form($db);
2784if ($action ==
'confirmgeneratesitemaps') {
2785 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?website='.urlencode($website->ref), $langs->trans(
'ConfirmSitemapsCreation'), $langs->trans(
'ConfirmGenerateSitemaps', $object->ref),
'generatesitemaps',
'',
"yes", 1);
2786 $action =
'preview';
2788$helpurl =
'EN:Module_Website|FR:Module_Website_FR|ES:Módulo_Website';
2791 '/includes/ace/src/ace.js',
2792 '/includes/ace/src/ext-statusbar.js',
2793 '/includes/ace/src/ext-language_tools.js',
2797$arrayofcss = array();
2802$arrayofjs[] =
'includes/jquery/plugins/blockUI/jquery.blockUI.js';
2803$arrayofjs[] =
'core/js/blockUI.js';
2805 $arrayofjs[] =
"includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js";
2808$moreheadjs .=
'<script type="text/javascript">'.
"\n";
2809$moreheadjs .=
'var indicatorBlockUI = \''.DOL_URL_ROOT.
"/theme/".$conf->theme.
"/img/working.gif".
'\';
'."\n";
2810$moreheadjs .= '</script>
'."\n";
2812llxHeader($moreheadcss.$moreheadjs, $langs->trans("Website").(empty($website->ref) ? '' : ' -
'.$website->ref), $helpurl, '', 0, 0, $arrayofjs, $arrayofcss, '', '', '<!-- Begin div
class=
"fiche" -->
'."\n".'<div
class=
"fichebutwithotherclass">
');
2815print '<!-- Open form
for all page -->
'."\n";
2816print '<form action=
"'.$_SERVER["PHP_SELF
"].($action == 'file_manager' ? '?uploadform=1' : '').'" method=
"POST" enctype=
"multipart/form-data" class=
"websiteformtoolbar">
';
2817print '<input
type=
"hidden" name=
"token" value=
"'.newToken().'">
';
2818print '<input
type=
"hidden" name=
"backtopage" value=
"'.$backtopage.'">
';
2819print '<input
type=
"hidden" name=
"dol_openinpopup" value=
"'.$dol_openinpopup.'">
';
2821if ($action == 'createsite
') {
2822 print '<input
type=
"hidden" name=
"action" value=
"addsite">
';
2824if ($action == 'createcontainer
') {
2825 print '<input
type=
"hidden" name=
"action" value=
"addcontainer">
';
2827if ($action == 'editcss
') {
2828 print '<input
type=
"hidden" name=
"action" value=
"updatecss">
';
2830if ($action == 'editmenu
') {
2831 print '<input
type=
"hidden" name=
"action" value=
"updatemenu">
';
2833if ($action == 'setashome
') {
2834 print '<input
type=
"hidden" name=
"action" value=
"updateashome">
';
2836if ($action == 'editmeta
') {
2837 print '<input
type=
"hidden" name=
"action" value=
"updatemeta">
';
2839if ($action == 'editsource
') {
2840 print '<input
type=
"hidden" name=
"action" value=
"updatesource">
';
2842if ($action == 'editcontent
') {
2843 print '<input
type=
"hidden" name=
"action" value=
"updatecontent">
';
2845if ($action == 'edit
') {
2846 print '<input
type=
"hidden" name=
"action" value=
"update">
';
2848if ($action == 'importsite
') {
2849 print '<input
type=
"hidden" name=
"action" value=
"importsiteconfirm">
';
2851if ($action == 'file_manager
') {
2852 print '<input
type=
"hidden" name=
"action" value=
"file_manager">
';
2855 print '<input
type=
"hidden" name=
"mode" value=
"'.$mode.'">
';
2860// Add a margin under toolbar ?
2862if ($action != 'preview
' && $action != 'editcontent
' && $action != 'editsource
' && !GETPOST('createpagefromclone
', 'alphanohtml
')) {
2863 $style = ' margin-bottom: 5px;
';
2867if (!GETPOST('hide_websitemenu
')) {
2869 if (!$user->hasRight('website
', 'write
')) {
2870 $disabled = ' disabled=
"disabled"';
2872 $disabledexport = '';
2873 if (!$user->hasRight('website
', 'export
')) {
2874 $disabledexport = ' disabled=
"disabled"';
2879 $dataroot = DOL_DATA_ROOT.($conf->entity > 1 ? '/
'.$conf->entity : '').'/website/
'.$websitekey;
2880 if (!empty($object->virtualhost)) {
2881 $virtualurl = $object->virtualhost;
2886 if ($object->id > 0) {
2887 $array = $objectpage->fetchAll($object->id, 'ASC,ASC
', 'type_container,pageurl
');
2888 $object->lines = $array;
2890 if (!is_array($array) && $array < 0) {
2891 dol_print_error('', $objectpage->error, $objectpage->errors);
2893 $atleastonepage = (is_array($array) && count($array) > 0);
2895 $websitepage = new WebsitePage($db);
2897 $websitepage->fetch($pageid);
2901 //var_dump($objectpage);exit;
2902 print '<div
class=
"centpercent websitebar'.(GETPOST('dol_openinpopup', 'aZ09') ? ' hiddenforpopup' : '').'">
';
2905 // Toolbar for websites
2908 print '<!-- Toolbar
for website -->
';
2909 if ($action != 'file_manager
') {
2910 print '<div
class=
"websiteselection hideonsmartphoneimp minwidth75 tdoverflowmax100 inline-block">
';
2911 print $langs->trans("Website").':
';
2914 // Button Add new website
2915 $urltocreatenewwebsite = $_SERVER["PHP_SELF"].'?action=createsite
';
2916 print '<span
class=
"websiteselection paddingrightonly">
';
2917 print '<a href=
"'.$urltocreatenewwebsite.'" class=
""'.$disabled.' title=
"'.dol_escape_htmltag($langs->trans("AddWebsite
")).'"><span
class=
"fa fa-plus-circle valignmiddle btnTitle-icon"><span></a>
';
2921 print '<span
class=
"websiteselection nopaddingrightimp">
';
2924 $out .= '<select
name=
"website" class=
"minwidth100 width200 maxwidth150onsmartphone" id=
"website">
';
2925 if (empty($listofwebsites)) {
2926 $out .= '<option value=
"-1"> </option>
';
2929 // Loop on each sites
2931 foreach ($listofwebsites as $key => $valwebsite) {
2932 if (empty($websitekey)) {
2933 if ($action != 'createsite
') {
2934 $websitekey = $valwebsite->ref;
2938 $out .= '<option value=
"'.$valwebsite->ref.'"';
2939 if ($websitekey == $valwebsite->ref) {
2940 $out .= ' selected
'; // To preselect a value
2942 //$outoption = $valwebsite->getLibStatut(3).' '.$valwebsite->ref.' ';
2943 $outoption = (($valwebsite->status == $valwebsite::STATUS_DRAFT) ? '<span
class=
"opacitymedium">
' : '').$valwebsite->ref.(($valwebsite->status == $valwebsite::STATUS_DRAFT) ? '</span>
' : '');
2944 $out .= ' data-html=
"'.dol_escape_htmltag($outoption).'"';
2946 $out .= $valwebsite->ref;
2947 $out .= '</option>
';
2950 $out .= '</select>
';
2951 $out .= ajax_combobox('website
');
2953 if (!empty($conf->use_javascript_ajax)) {
2954 $out .= '<script
type=
"text/javascript">
';
2955 $out .= 'jQuery(document).ready(
function () {
';
2956 $out .= ' jQuery(
"#website").change(
function () {
';
2957 $out .= ' console.log(
"We select "+jQuery(
"#website option:selected").val());
';
2958 $out .= ' if (jQuery(
"#website option:selected").val() == \
'-2\') {';
2959 $out .=
' window.location.href = "'.dol_escape_js($urltocreatenewwebsite).
'";';
2960 $out .=
' } else {';
2961 $out .=
' window.location.href = "'.$_SERVER[
"PHP_SELF"].
'?website="+jQuery("#website option:selected").val();';
2965 $out .=
'</script>';
2972 if (!empty($conf->use_javascript_ajax)) {
2973 print
'<span class="websiteselection">';
2978 if ($website->status == $website::STATUS_DRAFT) {
2979 $text_off =
'Offline';
2980 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>';
2982 $text_off =
'Online';
2983 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>';
2989 if (empty($conf->use_javascript_ajax)) {
2990 print
'<span class="websiteselection">';
2991 print
'<input type="image" class="valignmiddle" src="'.img_picto(
'',
'refresh',
'', 0, 1).
'" name="refreshsite" value="'.$langs->trans(
"Load").
'">';
2996 print
'<span class="websiteselection">';
2998 if ($websitekey && $websitekey !=
'-1' && ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite')) {
3000 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>';
3003 $importlabel = $langs->trans(
"ImportSite");
3004 $exportlabel = $langs->trans(
"ExportSite");
3005 if (!empty($conf->dol_optimize_smallscreen)) {
3006 $importlabel = $langs->trans(
"Import");
3007 $exportlabel = $langs->trans(
"Export");
3010 if ($atleastonepage) {
3011 print
'<input type="submit" class="button bordertransp" disabled="disabled" value="'.dol_escape_htmltag($importlabel).
'" name="importsite">';
3013 print
'<input type="submit" class="button bordertransp"'.$disabled.
' value="'.
dol_escape_htmltag($importlabel).
'" name="importsite">';
3017 print
'<input type="submit" class="button bordertransp"'.$disabledexport.
' value="'.
dol_escape_htmltag($exportlabel).
'" name="exportsite">';
3020 print
'<input type="submit" class="button bordertransp"'.$disabled.
' value="'.
dol_escape_htmltag($langs->trans(
"CloneSite")).
'" name="createfromclone">';
3023 if (!$permissiontodelete) {
3024 $disabled =
' disabled="disabled"';
3025 $title = $langs->trans(
"NotEnoughPermissions");
3028 if ($website->status == $website::STATUS_VALIDATED) {
3029 $disabled =
' disabled="disabled"';
3030 $title = $langs->trans(
"WebsiteMustBeDisabled", $langs->transnoentitiesnoconv($website->LibStatut(0, 0)));
3034 $title = $langs->trans(
"Delete");
3035 $url = $_SERVER[
"PHP_SELF"].
'?action=deletesite&token='.newToken().
'&website='.urlencode($website->ref);
3038 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>';
3041 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>';
3044 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>';
3047 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>';
3052 if ($websitekey && $websitekey !=
'-1' && ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite')) {
3053 print
'<span class="websiteselection">';
3055 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);
3057 if (isModEnabled(
'categorie')) {
3059 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);
3065 print
'<input type="hidden" name="website" id="website" value="'.$websitekey.
'">';
3069 print
'<span class="websitetools">';
3071 if ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite') {
3072 $urlext = $virtualurl;
3073 $urlint = $urlwithroot.
'/public/website/index.php?website='.$websitekey;
3075 print
'<span class="websiteinputurl valignmiddle" id="websiteinputurl">';
3076 $linktotestonwebserver =
'<a href="'.($virtualurl ? $virtualurl :
'#').
'" class="valignmiddle">';
3077 $linktotestonwebserver .=
'<span class="hideonsmartphone paddingrightonly">'.$langs->trans(
"TestDeployOnWeb", $virtualurl).
'</span>'.
img_picto(
'',
'globe');
3078 $linktotestonwebserver .=
'</a>';
3080 if (empty($object->fk_default_home)) {
3081 $htmltext .=
'<br><span class="error">'.$langs->trans(
"YouMustDefineTheHomePage").
'</span><br><br>';
3082 } elseif (empty($virtualurl)) {
3085 $htmltext .=
'<br><center>'.$langs->trans(
"GoTo").
' <a href="'.$virtualurl.
'" target="_website">'.$virtualurl.
'</a></center><br>';
3088 $htmltext .=
'<!-- Message defined translate key set into WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER -->';
3089 $htmltext .=
'<br>'.$langs->trans($conf->global->WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER);
3091 $htmltext .= $langs->trans(
"SetHereVirtualHost", $dataroot);
3092 $htmltext .=
'<br>';
3093 $htmltext .=
'<br>'.$langs->trans(
"CheckVirtualHostPerms", $langs->transnoentitiesnoconv(
"ReadPerm"), DOL_DOCUMENT_ROOT);
3094 $htmltext .=
'<br>'.$langs->trans(
"CheckVirtualHostPerms", $langs->transnoentitiesnoconv(
"WritePerm"),
'{s1}');
3095 $htmltext = str_replace(
'{s1}', DOL_DATA_ROOT.
'/website<br>'.DOL_DATA_ROOT.
'/medias', $htmltext);
3097 $examplewithapache =
'#php_admin_value open_basedir /tmp/:'.DOL_DOCUMENT_ROOT.
':'.DOL_DATA_ROOT.
':/dev/urandom'.
"\n";
3098 $examplewithapache .=
'<Directory "'.DOL_DOCUMENT_ROOT.
'">'.
"\n";
3099 $examplewithapache .=
'AllowOverride FileInfo Options
3100 Options -Indexes -MultiViews -FollowSymLinks -ExecCGI
3103 <Directory "'.DOL_DATA_ROOT.
'/website">
3104 AllowOverride FileInfo Options
3105 Options -Indexes -MultiViews +FollowSymLinks -ExecCGI
3108 <Directory "'.DOL_DATA_ROOT.
'/medias">
3109 AllowOverride FileInfo Options
3110 Options -Indexes -MultiViews -FollowSymLinks -ExecCGI
3114 $htmltext .=
'<br>'.$langs->trans(
"ExampleToUseInApacheVirtualHostConfig").
':<br>';
3115 $htmltext .=
'<div class="centpercent exampleapachesetup">'.dol_nl2br(
dol_escape_htmltag($examplewithapache, 1, 1)).
'</div>';
3117 $htmltext .=
'<br>';
3118 $htmltext .= $langs->trans(
"YouCanAlsoTestWithPHPS", $dataroot);
3119 $htmltext .=
'<br>';
3120 $htmltext .=
'<br>';
3121 $htmltext .= $langs->trans(
"YouCanAlsoDeployToAnotherWHP");
3123 print $form->textwithpicto($linktotestonwebserver, $htmltext, 1,
'none',
'valignmiddle', 0, 3,
'helpvirtualhost');
3127 if (in_array($action, array(
'editcss',
'editmenu',
'file_manager',
'replacesiteconfirm')) || in_array($mode, array(
'replacesite'))) {
3128 if ($action ==
'editcss') {
3129 print
'<input type="submit" id="savefileandstay" class="button buttonforacesave hideonsmartphone small" value="'.dol_escape_htmltag($langs->trans(
"SaveAndStay")).
'" name="updateandstay">';
3131 if (preg_match(
'/^create/', $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 (preg_match(
'/^edit/', $action) && $action !=
'file_manager' && $action !=
'replacesite' && $action !=
'replacesiteconfirm') {
3135 print
'<input type="submit" id="savefile" class="button buttonforacesave button-save small" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
3137 if ($action !=
'preview') {
3138 print
'<input type="submit" class="button button-cancel small" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'" name="cancel">';
3148 if ($websitekey && $websitekey !=
'-1' && (!in_array($action, array(
'editcss',
'editmenu',
'importsite',
'file_manager',
'replacesite',
'replacesiteconfirm'))) && (!in_array($mode, array(
'replacesite'))) && !$file_manager) {
3151 print
'<!-- Toolbar for websitepage -->';
3152 print
'<div class="centpercent websitebar"'.($style ?
' style="'.$style.
'"' :
'').
'>';
3154 print
'<div class="websiteselection hideonsmartphoneimp minwidth75 tdoverflowmax100 inline-block">';
3155 print $langs->trans(
"PageContainer").
': ';
3159 print
'<span class="websiteselection paddingrightonly">';
3160 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>';
3166 $s = $formwebsite->selectContainer($website,
'pageid', $pageid, 0, $action,
'minwidth100 maxwidth200onsmartphone');
3168 $out .=
'<span class="websiteselection nopaddingrightimp">';
3172 $urltocreatenewpage = $_SERVER[
"PHP_SELF"].
'?action=createcontainer&token='.newToken().
'&website='.urlencode($website->ref);
3174 if (!empty($conf->use_javascript_ajax)) {
3175 $out .=
'<script type="text/javascript">';
3176 $out .=
'jQuery(document).ready(function () {';
3177 $out .=
' jQuery("#pageid").change(function () {';
3178 $out .=
' console.log("We select "+jQuery("#pageid option:selected").val());';
3179 $out .=
' if (jQuery("#pageid option:selected").val() == \'-2\') {';
3180 $out .=
' window.location.href = "'.$urltocreatenewpage.
'";';
3181 $out .=
' } else {';
3182 $out .=
' window.location.href = "'.$_SERVER[
"PHP_SELF"].
'?website='.urlencode($website->ref).
'&pageid="+jQuery("#pageid option:selected").val();';
3186 $out .=
'</script>';
3191 if (!empty($conf->use_javascript_ajax)) {
3192 print
'<span class="websiteselection">';
3194 if ($object->status == $object::STATUS_DRAFT) {
3195 $text_off =
'SetWebsiteOnlineBefore';
3196 if ($websitepage->status == $websitepage::STATUS_DRAFT) {
3197 print
'<span class="valignmiddle disabled opacitymedium">'.img_picto($langs->trans($text_off),
'switch_off').
'</span>';
3199 print
'<span class="valignmiddle disabled opacitymedium">'.img_picto($langs->trans($text_off),
'switch_on').
'</span>';
3202 print
ajax_object_onoff($websitepage,
'status',
'status',
'Online',
'Offline', array(),
'valignmiddle inline-block'.(empty($websitepage->id) ?
' opacitymedium disabled' :
''),
'statuswebsitepage');
3208 print
'<span class="websiteselection">';
3210 print
'<input type="image" class="valignmiddle buttonwebsite" src="'.img_picto(
'',
'refresh',
'', 0, 1).
'" name="refreshpage" value="'.$langs->trans(
"Load").
'"'.(($action !=
'editsource') ?
'' :
' disabled="disabled"').
'>';
3213 $pagepreviousid = 0;
3216 $sql =
"SELECT MAX(rowid) as pagepreviousid FROM ".MAIN_DB_PREFIX.
"website_page WHERE rowid < ".((int) $pageid).
" AND fk_website = ".((int) $object->id);
3217 $resql = $db->query($sql);
3219 $obj = $db->fetch_object($resql);
3221 $pagepreviousid = $obj->pagepreviousid;
3226 $sql =
"SELECT MIN(rowid) as pagenextid FROM ".MAIN_DB_PREFIX.
"website_page WHERE rowid > ".((int) $pageid).
" AND fk_website = ".((int) $object->id);
3227 $resql = $db->query($sql);
3229 $obj = $db->fetch_object($resql);
3231 $pagenextid = $obj->pagenextid;
3238 if ($pagepreviousid) {
3239 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>';
3241 print
'<span class="valignmiddle opacitymedium">'.img_previous($langs->trans(
"PreviousContainer")).
'</span>';
3244 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>';
3246 print
'<span class="valignmiddle opacitymedium">'.img_next($langs->trans(
"NextContainer")).
'</span>';
3251 if ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite') {
3253 if (!$user->hasRight(
'website',
'write')) {
3254 $disabled =
' disabled="disabled"';
3258 if ($action ==
'deletesite') {
3260 $formquestion = array(
3261 array(
'type' =>
'checkbox',
'name' =>
'delete_also_js',
'label' => $langs->trans(
"DeleteAlsoJs"),
'value' => 0),
3262 array(
'type' =>
'checkbox',
'name' =>
'delete_also_medias',
'label' => $langs->trans(
"DeleteAlsoMedias"),
'value' => 0),
3267 if ($atleastonepage) {
3268 $langs->load(
"errors");
3269 $formquestion[] = array(
'type' =>
'onecolumn',
'value' =>
'<div class="warning">'.$langs->trans(
"WarningPagesWillBeDeleted").
'</div>');
3272 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeleteWebsite'),
'',
'confirm_deletesite', $formquestion, 0, 1, 210 + ($atleastonepage ? 70 : 0), 580);
3278 if ($action ==
'createfromclone') {
3280 $formquestion = array(
3281 array(
'type' =>
'text',
'name' =>
'siteref',
'label'=> $langs->trans(
"WebSite"),
'value'=>
'copy_of_'.$object->ref)
3284 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'CloneSite'),
'',
'confirm_createfromclone', $formquestion, 0, 1, 200);
3289 if ($pageid > 0 && $atleastonepage) {
3291 if ($action ==
'createpagefromclone') {
3293 $preselectedlanguage =
GETPOST(
'newlang',
'aZ09') ?
GETPOST(
'newlang',
'aZ09') :
'';
3294 $onlylang = array();
3295 if ($website->otherlang) {
3296 if (!empty($website->lang)) {
3297 $onlylang[$website->lang] = $website->lang.
' ('.$langs->trans(
"Default").
')';
3299 foreach (explode(
',', $website->otherlang) as $langkey) {
3300 if (empty(trim($langkey))) {
3303 $onlylang[$langkey] = $langkey;
3305 $textifempty = $langs->trans(
"Default");
3307 $onlylang[
'none'] =
'none';
3308 $textifempty = $langs->trans(
"Default");
3310 $formquestion = array(
3311 array(
'type' =>
'hidden',
'name' =>
'sourcepageurl',
'value'=> $objectpage->pageurl),
3312 array(
'type' =>
'other',
'tdclass'=>
'fieldrequired',
'name' =>
'newwebsite',
'label' => $langs->trans(
"WebSite"),
'value' => $formwebsite->selectWebsite($object->id,
'newwebsite', 0)),
3313 array(
'type' =>
'text',
'tdclass'=>
'maxwidth200 fieldrequired',
'moreattr'=>
'autofocus="autofocus"',
'name' =>
'newtitle',
'label'=> $langs->trans(
"WEBSITE_TITLE"),
'value'=> $langs->trans(
"CopyOf").
' '.$objectpage->title),
3314 array(
'type' =>
'text',
'tdclass'=>
'maxwidth200',
'name' =>
'newpageurl',
'label'=> $langs->trans(
"WEBSITE_PAGENAME"),
'value'=>
'')
3316 if (count($onlylang) > 1) {
3317 $formquestion[] = array(
'type' =>
'checkbox',
'tdclass'=>
'maxwidth200',
'name' =>
'is_a_translation',
'label' => $langs->trans(
"PageIsANewTranslation"),
'value' => 0,
'morecss'=>
'margintoponly');
3320 $value= $formadmin->select_language($preselectedlanguage,
'newlang', 0,
null, $textifempty, 0, 0,
'minwidth200', 1, 0, 0, $onlylang, 1);
3321 $formquestion[] = array(
'type' =>
'other',
'name' =>
'newlang',
'label' => $form->textwithpicto($langs->trans(
"Language"), $langs->trans(
"DefineListOfAltLanguagesInWebsiteProperties")),
'value' => $value);
3323 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?website='.$object->ref.
'&pageid='.$pageid, $langs->trans(
'ClonePage'),
'',
'confirm_createpagefromclone', $formquestion, 0, 1, 300, 550);
3328 print
'<span class="websiteselection">';
3331 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>';
3334 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>';
3338 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>';
3345 print
'<!-- button EditInLine and ShowSubcontainers -->'.
"\n";
3346 print
'<div class="websiteselectionsection inline-block">';
3348 print
'<div class="inline-block marginrightonly">';
3349 print $langs->trans(
"ShowSubcontainers");
3351 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>';
3353 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>';
3357 print
'<div class="inline-block marginrightonly">';
3359 print
'<span id="switchckeditorinline">'.
"\n";
3361 print
'<!-- Code to enabled edit inline ckeditor -->'.
"\n";
3362 print
'<script type="text/javascript">
3363 $(document).ready(function() {
3364 var isEditingEnabled = '.(getDolGlobalString(
"WEBSITE_EDITINLINE") ?
'true' :
'false').
';
3365 if (isEditingEnabled)
3367 switchEditorOnline(true);
3370 $( "#switchckeditorinline" ).click(function() {
3371 switchEditorOnline();
3374 function switchEditorOnline(forceenable)
3376 if (! isEditingEnabled || forceenable)
3378 console.log("Enable inline edit");
3380 jQuery(\'section[contenteditable="true"],div[contenteditable="true"]\').each(function(idx){
3381 var idtouse = $(this).attr(\'id\');
3382 console.log("Enable inline edit for "+idtouse);
3383 if (idtouse !== undefined) {
3384 var inlineditor = CKEDITOR.inline(idtouse, {
3385 // Allow some non-standard markup that we used in the introduction.
3386 // + a[target];div{float,display} ?
3387 extraAllowedContent: \'span(*);cite(*);q(*);dl(*);dt(*);dd(*);ul(*);li(*);header(*);button(*);h1(*);h2(*);\',
3388 //extraPlugins: \'sourcedialog\',
3389 removePlugins: \'flash,stylescombo,exportpdf,scayt,wsc,pagebreak,iframe,smiley\',
3390 // Show toolbar on startup (optional).
3391 // startupFocus: true
3395 // Note the Source tool does not work on inline
3396 inlineditor.config.toolbar = [
3397 [\'Templates\',\'NewPage\'],
3399 [\'Maximize\',\'Preview\'],
3401 [\'Undo\',\'Redo\',\'-\',\'Find\',\'Replace\',\'-\',\'SelectAll\',\'RemoveFormat\'],
3402 [\'CreateDiv\',\'ShowBlocks\'],
3403 [\'Form\', \'Checkbox\', \'Radio\', \'TextField\', \'Textarea\', \'Select\', \'Button\', \'ImageButton\', \'HiddenField\'],
3404 [\'Bold\',\'Italic\',\'Underline\',\'Strike\',\'Superscript\'],
3405 [\'NumberedList\',\'BulletedList\',\'-\',\'Outdent\',\'Indent\',\'Blockquote\'],
3406 [\'JustifyLeft\',\'JustifyCenter\',\'JustifyRight\',\'JustifyBlock\'],
3407 [\'Link\',\'Unlink\'],
3408 [\'Image\',\'Table\',\'HorizontalRule\'],
3409 [\'Styles\',\'Format\',\'Font\',\'FontSize\'],
3410 [\'TextColor\',\'BGColor\']
3414 //inlineditor.on(\'instanceReady\', function () {
3421 isEditingEnabled = true;
3423 console.log("Disable inline edit");
3424 for(name in CKEDITOR.instances) {
3425 CKEDITOR.instances[name].destroy(true);
3427 isEditingEnabled = false;
3432 print $langs->trans(
"EditInLine");
3436 $disableeditinline = 0;
3437 if ($disableeditinline) {
3439 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>';
3443 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>';
3445 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>';
3454 print
'<span class="websiteselection">';
3455 if ($object->fk_default_home > 0 && $pageid == $object->fk_default_home) {
3459 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>';
3463 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>';
3465 print
'<input type="submit" class="button bordertransp"'.$disabled.
' value="'.
dol_escape_htmltag($langs->trans(
"ClonePage")).
'" name="createpagefromclone">';
3468 if ($websitepage->status != $websitepage::STATUS_DRAFT) {
3469 $disabled =
' disabled="disabled"';
3470 $title = $langs->trans(
"WebpageMustBeDisabled", $langs->transnoentitiesnoconv($websitepage->LibStatut(0, 0)));
3475 $url = $_SERVER[
"PHP_SELF"].
'?action=delete&token='.newToken().
'&pageid='.((int) $websitepage->id).
'&website='.urlencode($website->ref);
3477 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>';
3484 print
'<span class="websitetools">';
3486 if (($pageid > 0 && $atleastonepage) && ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite')) {
3487 $realpage = $urlwithroot.
'/public/website/index.php?website='.$websitekey.
'&pageref='.$websitepage->pageurl;
3488 $pagealias = $websitepage->pageurl;
3490 $htmltext = $langs->trans(
"PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv(
"Page"), $langs->transnoentitiesnoconv(
"Page"), $realpage, $dataroot);
3491 $htmltext .=
'<br>'.$langs->trans(
"CheckVirtualHostPerms", $langs->transnoentitiesnoconv(
"ReadPerm"),
'{s1}');
3492 $htmltext = str_replace(
'{s1}', $dataroot.
'<br>'.DOL_DATA_ROOT.
'/medias<br>'.DOL_DOCUMENT_ROOT, $htmltext);
3496 print
'<div class="websiteinputurl inline-block paddingright">';
3497 print
'<a class="websitebuttonsitepreview inline-block" id="previewpage" href="'.$realpage.
'&nocache='.
dol_now().
'" class="button" target="tab'.$websitekey.
'" alt="'.
dol_escape_htmltag($htmltext).
'">';
3498 print $form->textwithpicto(
'', $htmltext, 1,
'preview');
3522 if (!in_array($mode, array(
'replacesite')) && !in_array($action, array(
'editcss',
'editmenu',
'file_manager',
'replacesiteconfirm',
'createsite',
'createcontainer',
'createfromclone',
'createpagefromclone',
'deletesite'))) {
3523 if ($action ==
'editsource' || $action ==
'editmeta') {
3524 print
'<input type="submit" id="savefileandstay" class="button buttonforacesave hideonsmartphone small" value="'.dol_escape_htmltag($langs->trans(
"SaveAndStay")).
'" name="updateandstay">';
3526 if (preg_match(
'/^create/', $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 (preg_match(
'/^edit/', $action)) {
3530 print
'<input type="submit" id="savefile" class="button buttonforacesave button-save small" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
3532 if ($action !=
'preview') {
3533 print
'<input type="submit" class="button button-cancel small" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'" name="cancel">';
3539 print
'<span class="websitehelp">';
3540 if ($action ==
'editsource' || $action ==
'editcontent' ||
GETPOST(
'editsource',
'alpha') ||
GETPOST(
'editcontent',
'alpha')) {
3541 $url =
'https://wiki.dolibarr.org/index.php/Module_Website';
3543 $htmltext = $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource", $url);
3544 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource2", $url);
3545 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSourceMore", $url);
3546 $htmltext .=
'<br>';
3547 if ($conf->browser->layout ==
'phone') {
3548 print $form->textwithpicto(
'', $htmltext, 1,
'help',
'inline-block', 1, 2,
'tooltipsubstitution');
3551 print $form->textwithpicto($langs->trans(
"SyntaxHelp").
' '.
img_help(2, $langs->trans(
"SyntaxHelp")), $htmltext, 1,
'none',
'inline-block', 1, 2,
'tooltipsubstitution');
3557 if ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone') {
3559 if (!empty($conf->use_javascript_ajax)) {
3560 print
'<script type="text/javascript">
3561 jQuery(document).ready(function() {
3562 jQuery("#websiteinputurl").keyup(function() {
3563 console.log("Website external url modified "+jQuery("#previewsiteurl").val());
3564 if (jQuery("#previewsiteurl").val() != "" && jQuery("#previewsiteurl").val().startsWith("http"))
3566 jQuery("a.websitebuttonsitepreviewdisabled img").css({ opacity: 1 });
3568 else jQuery("a.websitebuttonsitepreviewdisabled img").css({ opacity: 0.2 });
3572 jQuery("#previewsiteext,#previewpageext").click(function() {
3574 newurl=jQuery("#previewsiteurl").val();
3575 if (! newurl.startsWith("http"))
3577 alert(\''.dol_escape_js($langs->trans(
"ErrorURLMustStartWithHttp")).
'\');
3581 newpage=jQuery(
"#previewsiteurl").val() +
"/" + jQuery(
"#previewpageurl").val() +
".php";
3582 console.log(
"Open url "+newurl);
3586 url:
"'.DOL_URL_ROOT.'/core/ajax/saveinplace.php",
3588 field: \
'editval_virtualhost\',
3589 element: \'website\',
3590 table_element: \'website\',
3591 fk_element: '.((int) $object->id).
',
3594 context: document.body
3597 jQuery("#previewsiteext").attr("href",newurl);
3598 jQuery("#previewpageext").attr("href",newpage);
3617if ($action ==
'editcss') {
3618 print
'<div class="fiche">';
3622 if (!GETPOSTISSET(
'WEBSITE_CSS_INLINE')) {
3623 $csscontent = @file_get_contents($filecss);
3625 $csscontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims',
'', $csscontent);
3627 $csscontent =
GETPOST(
'WEBSITE_CSS_INLINE',
'none');
3629 if (!trim($csscontent)) {
3630 $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;}";
3633 if (!GETPOSTISSET(
'WEBSITE_JS_INLINE')) {
3634 $jscontent = @file_get_contents($filejs);
3636 $jscontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims',
'', $jscontent);
3638 $jscontent =
GETPOST(
'WEBSITE_JS_INLINE',
'none');
3640 if (!trim($jscontent)) {
3641 $jscontent =
'/* JS content (all pages) */'.
"\n";
3644 if (!GETPOSTISSET(
'WEBSITE_HTML_HEADER')) {
3645 $htmlheadercontent = @file_get_contents($filehtmlheader);
3647 $htmlheadercontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims',
'', $htmlheadercontent);
3649 $htmlheadercontent =
GETPOST(
'WEBSITE_HTML_HEADER',
'none');
3651 if (!trim($htmlheadercontent)) {
3652 $htmlheadercontent =
"<html>\n";
3653 $htmlheadercontent .= $htmlheadercontentdefault;
3654 $htmlheadercontent .=
"</html>";
3656 $htmlheadercontent = preg_replace(
'/^\s*<html>/ims',
'', $htmlheadercontent);
3657 $htmlheadercontent = preg_replace(
'/<\/html>\s*$/ims',
'', $htmlheadercontent);
3658 $htmlheadercontent =
'<html>'.
"\n".trim($htmlheadercontent).
"\n".
'</html>';
3661 if (!GETPOSTISSET(
'WEBSITE_ROBOT')) {
3662 $robotcontent = @file_get_contents($filerobot);
3664 $robotcontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims',
'', $robotcontent);
3666 $robotcontent =
GETPOST(
'WEBSITE_ROBOT',
'nohtml');
3668 if (!trim($robotcontent)) {
3669 $robotcontent .=
"# Robot file. Generated with ".DOL_APPLICATION_TITLE.
"\n";
3670 $robotcontent .=
"User-agent: *\n";
3671 $robotcontent .=
"Allow: /public/\n";
3672 $robotcontent .=
"Disallow: /administrator/\n";
3675 if (!GETPOSTISSET(
'WEBSITE_HTACCESS')) {
3676 $htaccesscontent = @file_get_contents($filehtaccess);
3678 $htaccesscontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims',
'', $htaccesscontent);
3680 $htaccesscontent =
GETPOST(
'WEBSITE_HTACCESS',
'nohtml');
3682 if (!trim($htaccesscontent)) {
3683 $htaccesscontent .=
"# Order allow,deny\n";
3684 $htaccesscontent .=
"# Deny from all\n";
3688 if (!GETPOSTISSET(
'WEBSITE_MANIFEST_JSON')) {
3689 $manifestjsoncontent = @file_get_contents($filemanifestjson);
3691 $manifestjsoncontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims',
'', $manifestjsoncontent);
3693 $manifestjsoncontent =
GETPOST(
'WEBSITE_MANIFEST_JSON',
'restricthtml');
3695 if (!trim($manifestjsoncontent)) {
3699 if (!GETPOSTISSET(
'WEBSITE_README')) {
3700 $readmecontent = @file_get_contents($filereadme);
3702 $readmecontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims',
'', $readmecontent);
3704 $readmecontent =
GETPOST(
'WEBSITE_README',
'none');
3706 if (!trim($readmecontent)) {
3710 if (!GETPOSTISSET(
'WEBSITE_LICENSE')) {
3711 $licensecontent = @file_get_contents($filelicense);
3713 $licensecontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims',
'', $licensecontent);
3715 $licensecontent =
GETPOST(
'WEBSITE_LICENSE',
'none');
3717 if (!trim($licensecontent)) {
3723 print
'<!-- Edit Website properties -->'.
"\n";
3724 print
'<table class="border centpercent">';
3727 print
'<tr><td class="titlefieldcreate fieldrequired">';
3728 print $langs->trans(
'WebSite');
3734 if ($action !=
'createcontainer') {
3735 if (empty($conf->use_javascript_ajax)) {
3736 print
'<!-- Status of web site page -->'.
"\n";
3737 print
'<tr><td class="fieldrequired">';
3738 print $langs->trans(
'Status');
3740 print $form->selectyesno(
'status', $object->status);
3746 print
'<tr><td class="tdtop fieldrequired">';
3748 print $form->textwithpicto($langs->trans(
'MainLanguage'), $htmltext, 1,
'help',
'', 0, 2,
'WEBSITE_LANG');
3750 print
img_picto(
'',
'language',
'class="picotfixedwidth"');
3751 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);
3756 print
'<tr><td class="tdtop">';
3757 $htmltext = $langs->trans(
"Example").
': fr,de,sv,it,pt';
3758 print $form->textwithpicto($langs->trans(
'OtherLanguages'), $htmltext, 1,
'help',
'', 0, 2);
3760 print
img_picto(
'',
'language',
'class="picotfixedwidth"');
3761 print
'<input type="text" class="flat" value="'.(GETPOSTISSET(
'WEBSITE_OTHERLANG') ?
GETPOST(
'WEBSITE_OTHERLANG',
'alpha') : $object->otherlang).
'" name="WEBSITE_OTHERLANG">';
3766 print
'<tr><td class="tdtop">';
3768 $htmltext = $langs->trans(
"VirtualhostDesc");
3769 print $form->textwithpicto($langs->trans(
'Virtualhost'), $htmltext, 1,
'help',
'', 0, 2,
'virtualhosttooltip');
3771 print
'<input type="text" class="flat minwidth300" value="'.(GETPOSTISSET(
'virtualhost') ?
GETPOST(
'virtualhost',
'alpha') : $virtualurl).
'" name="virtualhost">';
3777 print $form->textwithpicto($langs->trans(
'ImportFavicon'), $langs->trans(
'FaviconTooltip'));
3780 $maxmin = $maxfilesizearray[
'maxmin'];
3782 print
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
3784 print
'<input type="file" class="flat minwidth300" name="addedfile" id="addedfile"/>';
3786 $uploadfolder = $conf->website->dir_output.
'/'.$websitekey;
3788 print
'<div class="inline-block valignmiddle marginrightonly">';
3789 print
'<img style="max-height: 80px" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart=website&file='.$websitekey.
'/favicon.png">';
3795 print
'<tr><td class="tdtop">';
3796 $htmlhelp = $langs->trans(
"CSSContentTooltipHelp");
3797 print $form->textwithpicto($langs->trans(
'WEBSITE_CSS_INLINE'), $htmlhelp, 1,
'help',
'', 0, 2,
'csstooltip');
3800 $poscursor = array(
'x'=>
GETPOST(
'WEBSITE_CSS_INLINE_x'),
'y'=>
GETPOST(
'WEBSITE_CSS_INLINE_y'));
3801 $doleditor =
new DolEditor(
'WEBSITE_CSS_INLINE', $csscontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'', $poscursor);
3802 print $doleditor->Create(1,
'',
true,
'CSS',
'css');
3807 print
'<tr><td class="tdtop">';
3808 $textwithhelp = $langs->trans(
'WEBSITE_JS_INLINE');
3809 $htmlhelp2 = $langs->trans(
"LinkAndScriptsHereAreNotLoadedInEditor").
'<br>';
3810 print $form->textwithpicto($textwithhelp, $htmlhelp2, 1,
'warning',
'', 0, 2,
'htmljstooltip2');
3814 $poscursor = array(
'x'=>
GETPOST(
'WEBSITE_JS_INLINE_x'),
'y'=>
GETPOST(
'WEBSITE_JS_INLINE_y'));
3815 $doleditor =
new DolEditor(
'WEBSITE_JS_INLINE', $jscontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'', $poscursor);
3816 print $doleditor->Create(1,
'',
true,
'JS',
'javascript');
3821 print
'<tr><td class="tdtop">';
3822 print $langs->trans(
'WEBSITE_HTML_HEADER');
3823 $htmlhelp = $langs->trans(
"Example").
' :<br>';
3825 $textwithhelp = $form->textwithpicto(
'', $htmlhelp, 1,
'help',
'', 0, 2,
'htmlheadertooltip');
3826 $htmlhelp2 = $langs->trans(
"LinkAndScriptsHereAreNotLoadedInEditor").
'<br>';
3827 print $form->textwithpicto($textwithhelp, $htmlhelp2, 1,
'warning',
'', 0, 2,
'htmlheadertooltip2');
3830 $poscursor = array(
'x'=>
GETPOST(
'WEBSITE_HTML_HEADER_x'),
'y'=>
GETPOST(
'WEBSITE_HTML_HEADER_y'));
3831 $doleditor =
new DolEditor(
'WEBSITE_HTML_HEADER', $htmlheadercontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'', $poscursor);
3832 print $doleditor->Create(1,
'',
true,
'HTML Header',
'html');
3837 print
'<tr><td class="tdtop">';
3838 print $langs->trans(
'WEBSITE_ROBOT');
3841 $poscursor = array(
'x'=>
GETPOST(
'WEBSITE_ROBOT_x'),
'y'=>
GETPOST(
'WEBSITE_ROBOT_y'));
3842 $doleditor =
new DolEditor(
'WEBSITE_ROBOT', $robotcontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'', $poscursor);
3843 print $doleditor->Create(1,
'',
true,
'Robot file',
'text');
3848 print
'<tr><td class="tdtop">';
3849 print $langs->trans(
'WEBSITE_HTACCESS');
3852 $poscursor = array(
'x'=>
GETPOST(
'WEBSITE_HTACCESS_x'),
'y'=>
GETPOST(
'WEBSITE_HTACCESS_y'));
3853 $doleditor =
new DolEditor(
'WEBSITE_HTACCESS', $htaccesscontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'', $poscursor);
3854 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' .htaccess',
'text');
3859 print
'<tr><td class="tdtop">';
3860 $htmlhelp = $langs->trans(
"Example").
' :<br>';
3861 $htmlhelp .=
'<small>'.dol_htmlentitiesbr($manifestjsoncontentdefault).
'</small>';
3862 print $form->textwithpicto($langs->trans(
'WEBSITE_MANIFEST_JSON'), $htmlhelp, 1,
'help',
'', 0, 2,
'manifestjsontooltip');
3864 print $langs->trans(
"UseManifest").
': '.$form->selectyesno(
'use_manifest', $website->use_manifest, 1).
'<br>';
3866 $poscursor = array(
'x'=>
GETPOST(
'WEBSITE_MANIFEST_JSON_x'),
'y'=>
GETPOST(
'WEBSITE_MANIFEST_JSON_y'));
3867 $doleditor =
new DolEditor(
'WEBSITE_MANIFEST_JSON', $manifestjsoncontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'', $poscursor);
3868 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' manifest.json',
'text');
3872 print
'<tr><td class="tdtop">';
3873 $htmlhelp = $langs->trans(
"EnterHereReadmeInformation");
3874 print $form->textwithpicto($langs->trans(
"File").
' README.md', $htmlhelp, 1,
'help',
'', 0, 2,
'readmetooltip');
3877 $poscursor = array(
'x'=>
GETPOST(
'WEBSITE_README_x'),
'y'=>
GETPOST(
'WEBSITE_README_y'));
3878 $doleditor =
new DolEditor(
'WEBSITE_README', $readmecontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'', $poscursor);
3879 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' README.md',
'text');
3884 print
'<tr><td class="tdtop">';
3885 $htmlhelp = $langs->trans(
"EnterHereLicenseInformation");
3886 print $form->textwithpicto($langs->trans(
"File").
' LICENSE', $htmlhelp, 1,
'help',
'', 0, 2,
'licensetooltip');
3889 $poscursor = array(
'x'=>
GETPOST(
'WEBSITE_LICENSE_x'),
'y'=>
GETPOST(
'WEBSITE_LICENSE_y'));
3890 $doleditor =
new DolEditor(
'WEBSITE_LICENSE', $licensecontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'', $poscursor);
3891 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' LICENSE',
'text');
3896 print
'<tr><td class="tdtop">';
3897 $htmlhelp = $langs->trans(
'RSSFeedDesc');
3898 print $form->textwithpicto($langs->trans(
'RSSFeed'), $htmlhelp, 1,
'help',
'', 0, 2,
'');
3900 print
'/wrapper.php?rss=1[&l=XX][&limit=123]';
3913if ($action ==
'createsite') {
3914 print
'<div class="fiche">';
3928 if ($action ==
'createcontainer') {
3932 print
'<!-- Add site -->'.
"\n";
3933 print
'<div class="tabBar tabBarWithBottom">';
3935 print
'<table class="border centpercent">';
3937 $siteref = $sitedesc = $sitelang = $siteotherlang =
'';
3939 $siteref =
GETPOST(
'WEBSITE_REF',
'aZ09');
3941 if (
GETPOST(
'WEBSITE_DESCRIPTION')) {
3942 $sitedesc =
GETPOST(
'WEBSITE_DESCRIPTION',
'alpha');
3944 if (
GETPOST(
'WEBSITE_LANG')) {
3945 $sitelang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
3947 if (
GETPOST(
'WEBSITE_OTHERLANG')) {
3948 $siteotherlang =
GETPOST(
'WEBSITE_OTHERLANG',
'aZ09comma');
3951 print
'<tr><td class="titlefieldcreate fieldrequired">';
3952 print $form->textwithpicto($langs->trans(
'WebsiteName'), $langs->trans(
"Example").
': MyPortal, www.mywebsite.com, ...');
3954 print
'<input type="text" class="flat maxwidth300" name="WEBSITE_REF" value="'.dol_escape_htmltag($siteref).
'" autofocus>';
3957 print
'<tr><td class="fieldrequired">';
3958 print $langs->trans(
'MainLanguage');
3960 $shortlangcode = preg_replace(
'/[_-].*$/',
'', trim($langs->defaultlang));
3961 print
img_picto(
'',
'language',
'class="pictofixedwidth"');
3962 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);
3966 $htmltext = $langs->trans(
"Example").
': fr,de,sv,it,pt';
3967 print $form->textwithpicto($langs->trans(
'OtherLanguages'), $htmltext, 1,
'help',
'', 0, 2);
3969 print
img_picto(
'',
'language',
'class="pictofixedwidth"');
3970 print
'<input type="text" class="flat minwidth300" name="WEBSITE_OTHERLANG" value="'.dol_escape_htmltag($siteotherlang).
'">';
3974 print $langs->trans(
'Description');
3976 print
'<input type="text" class="flat minwidth500" name="WEBSITE_DESCRIPTION" value="'.dol_escape_htmltag($sitedesc).
'">';
3981 $htmltext = $langs->trans(
"VirtualhostDesc");
3989 print $form->textwithpicto($langs->trans(
'Virtualhost'), $htmltext, 1,
'help',
'', 0, 2,
'');
3991 print
'<input type="text" class="flat minwidth300" name="virtualhost" value="'.dol_escape_htmltag(
GETPOST(
'virtualhost',
'alpha')).
'">';
3997 if ($action ==
'createsite') {
3998 print
'<div class="center">';
4000 print
'<input type="submit" class="button small" name="addcontainer" value="'.$langs->trans(
"Create").
'">';
4001 print
'<input class="button button-cancel small" type="submit" name="preview" value="'.$langs->trans(
"Cancel").
'">';
4016if ($action ==
'importsite') {
4017 print
'<div class="fiche">';
4025 print
'<span class="opacitymedium">'.$langs->trans(
"ZipOfWebsitePackageToImport").
'</span><br><br>';
4028 $dolibarrdataroot = preg_replace(
'/([\\/]+)$/i',
'', DOL_DATA_ROOT);
4029 $allowimportsite =
true;
4030 if (
dol_is_file($dolibarrdataroot.
'/installmodules.lock')) {
4031 $allowimportsite =
false;
4034 if ($allowimportsite) {
4036 $maxmin = $maxfilesizearray[
'maxmin'];
4038 print
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
4040 print
'<input class="flat minwidth400" type="file" name="userfile[]" accept=".zip">';
4041 print
'<input type="submit" class="button small" name="buttonsubmitimportfile" value="'.dol_escape_htmltag($langs->trans(
"Upload")).
'">';
4042 print
'<input type="submit" class="button button-cancel small" name="preview" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
4043 print
'<br><br><br>';
4047 $message = $langs->trans(
'InstallModuleFromWebHasBeenDisabledContactUs');
4050 $message = $langs->trans(
"InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.
'/installmodules.lock');
4056 print
'<span class="opacitymedium">'.$langs->trans(
"ZipOfWebsitePackageToLoad").
'</span><br><br>';
4067if ($action ==
'editmeta' || $action ==
'createcontainer') {
4068 print
'<div class="fiche">';
4082 if ($action ==
'createcontainer') {
4086 print
'<!-- Edit or create page/container -->'.
"\n";
4089 $hiddenfromfetchingafterload =
' hideobject';
4090 $hiddenmanuallyafterload =
' hideobject';
4091 if (
GETPOST(
'radiocreatefrom') ==
'checkboxcreatefromfetching') {
4092 $hiddenfromfetchingafterload =
'';
4094 if (
GETPOST(
'radiocreatefrom') ==
'checkboxcreatemanually') {
4095 $hiddenmanuallyafterload =
'';
4098 if ($action ==
'editmeta' || empty($conf->use_javascript_ajax)) {
4099 $hiddenfromfetchingafterload =
'';
4100 $hiddenmanuallyafterload =
'';
4103 if ($action ==
'createcontainer') {
4106 if (!empty($conf->use_javascript_ajax)) {
4107 print
'<input type="radio" name="radiocreatefrom" id="checkboxcreatemanually" value="checkboxcreatemanually"'.(GETPOST(
'radiocreatefrom') ==
'checkboxcreatemanually' ?
' checked' :
'').
'> ';
4109 print
'<label for="checkboxcreatemanually"><span class="opacitymediumxx">'.$langs->trans(
"OrEnterPageInfoManually").
'</span></label><br>';
4110 print
'<hr class="tablecheckboxcreatemanually'.$hiddenmanuallyafterload.
'">';
4113 print
'<table class="border tableforfield nobackground centpercent tablecheckboxcreatemanually'.$hiddenmanuallyafterload.
'">';
4115 if ($action !=
'createcontainer') {
4116 print
'<tr><td class="titlefield fieldrequired">';
4117 print $langs->trans(
'IDOfPage').
' - '.$langs->trans(
'InternalURLOfPage');
4125 print
' - ';
4126 print
'/public/website/index.php?website='.urlencode($websitekey).
'&pageid='.urlencode($pageid);
4130 $type_container = $objectpage->type_container;
4131 $pageurl = $objectpage->pageurl;
4132 $pagealiasalt = $objectpage->aliasalt;
4133 $pagetitle = $objectpage->title;
4134 $pagedescription = $objectpage->description;
4135 $pageimage = $objectpage->image;
4136 $pagekeywords = $objectpage->keywords;
4137 $pagelang = $objectpage->lang;
4138 $pageallowedinframes = $objectpage->allowed_in_frames;
4139 $pagehtmlheader = $objectpage->htmlheader;
4140 $pagedatecreation = $objectpage->date_creation;
4141 $pagedatemodification = $objectpage->date_modification;
4142 $pageauthorid = $objectpage->fk_user_creat;
4143 $pageusermodifid = $objectpage->fk_user_modif;
4144 $pageauthoralias = $objectpage->author_alias;
4145 $pagestatus = $objectpage->status;
4147 $type_container =
'page';
4151 $pagedescription =
'';
4155 $pageallowedinframes = 0;
4156 $pagehtmlheader =
'';
4157 $pagedatecreation =
dol_now();
4158 $pagedatemodification =
'';
4159 $pageauthorid = $user->id;
4160 $pageusermodifid = 0;
4161 $pageauthoralias =
'';
4164 if (
GETPOST(
'WEBSITE_TITLE',
'alpha')) {
4165 $pagetitle = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_TITLE',
'alphanohtml'));
4167 if (
GETPOST(
'WEBSITE_PAGENAME',
'alpha')) {
4168 $pageurl =
GETPOST(
'WEBSITE_PAGENAME',
'alpha');
4170 if (
GETPOST(
'WEBSITE_ALIASALT',
'alpha')) {
4171 $pagealiasalt = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_ALIASALT',
'alphanohtml'));
4173 if (
GETPOST(
'WEBSITE_DESCRIPTION',
'alpha')) {
4174 $pagedescription = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml'));
4176 if (
GETPOST(
'WEBSITE_IMAGE',
'alpha')) {
4177 $pageimage =
GETPOST(
'WEBSITE_IMAGE',
'alpha');
4179 if (
GETPOST(
'WEBSITE_KEYWORDS',
'alpha')) {
4180 $pagekeywords = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_KEYWORDS',
'alphanohtml'));
4182 if (
GETPOST(
'WEBSITE_LANG',
'aZ09')) {
4183 $pagelang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
4185 if (
GETPOST(
'WEBSITE_ALLOWED_IN_FRAMES',
'aZ09')) {
4186 $pageallowedinframes =
GETPOST(
'WEBSITE_ALLOWED_IN_FRAMES',
'aZ09');
4188 if (
GETPOST(
'htmlheader',
'none')) {
4189 $pagehtmlheader =
GETPOST(
'htmlheader',
'none');
4192 if ($action !=
'createcontainer') {
4193 if (empty($conf->use_javascript_ajax)) {
4194 print
'<!-- Status of web site page -->'.
"\n";
4195 print
'<tr><td class="fieldrequired">';
4196 print $langs->trans(
'Status');
4198 print $form->selectyesno(
'status', $objectpage->status);
4204 print
'<tr><td class="titlefield fieldrequired">';
4205 print $langs->trans(
'WEBSITE_TYPE_CONTAINER');
4207 print
img_picto(
'',
'object_technic',
'class="paddingrightonly"').
' ';
4208 $formwebsite->selectTypeOfContainer(
'WEBSITE_TYPE_CONTAINER', (
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'alpha') ?
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'alpha') : $type_container), 0,
'', 1);
4212 if ($action ==
'createcontainer') {
4213 print
'<tr><td class="titlefield fieldrequired">';
4214 print $langs->trans(
'WEBSITE_PAGE_EXAMPLE');
4216 print $formwebsite->selectSampleOfContainer(
'sample', (GETPOSTISSET(
'sample') ?
GETPOST(
'sample',
'alpha') :
'empty'), 0,
'', 1,
'minwidth300');
4221 print
'<tr><td class="fieldrequired">';
4222 print $langs->trans(
'WEBSITE_TITLE');
4224 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_TITLE" id="WEBSITE_TITLE" value="'.dol_escape_htmltag($pagetitle).
'" autofocus>';
4228 print
'<tr><td class="titlefieldcreate fieldrequired">';
4229 print $langs->trans(
'WEBSITE_PAGENAME');
4231 print
'<input type="text" class="flat minwidth300" name="WEBSITE_PAGENAME" id="WEBSITE_PAGENAME" value="'.dol_escape_htmltag($pageurl).
'">';
4234 print
'<tr><td class="titlefieldcreate">';
4235 $htmlhelp = $langs->trans(
"WEBSITE_ALIASALTDesc");
4236 print $form->textwithpicto($langs->trans(
'WEBSITE_ALIASALT'), $htmlhelp, 1,
'help',
'', 0, 2,
'aliastooltip');
4238 print
'<input type="text" class="flat minwidth500" name="WEBSITE_ALIASALT" value="'.dol_escape_htmltag($pagealiasalt).
'">';
4242 print $langs->trans(
'WEBSITE_DESCRIPTION');
4244 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_DESCRIPTION" value="'.dol_escape_htmltag($pagedescription).
'">';
4248 $htmlhelp = $langs->trans(
"WEBSITE_IMAGEDesc");
4249 print $form->textwithpicto($langs->trans(
'WEBSITE_IMAGE'), $htmlhelp, 1,
'help',
'', 0, 2,
'imagetooltip');
4251 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_IMAGE" value="'.dol_escape_htmltag($pageimage).
'">';
4256 $htmlhelp = $langs->trans(
"WEBSITE_KEYWORDSDesc");
4257 print $form->textwithpicto($langs->trans(
'WEBSITE_KEYWORDS'), $htmlhelp, 1,
'help',
'', 0, 2,
'keywordtooltip');
4259 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_KEYWORDS" value="'.dol_escape_htmltag($pagekeywords).
'">';
4263 print $langs->trans(
'Language');
4265 $onlykeys = array();
4266 if ($object->lang) {
4267 $onlykeys[$object->lang] = $object->lang;
4269 $onlykeys[$langs->defaultlang] = $langs->defaultlang;
4271 if ($object->otherlang) {
4272 $tmparray = explode(
',', $object->otherlang);
4273 foreach ($tmparray as $key) {
4274 $tmpkey = trim($key);
4275 if (strlen($key) == 2) {
4276 $tmpkey = strtolower($key);
4278 $onlykeys[$tmpkey] = $tmpkey;
4281 if (empty($object->lang) && empty($object->otherlang)) {
4284 print
img_picto(
'',
'language',
'class="pictofixedwidth"').$formadmin->select_language($pagelang ? $pagelang :
'',
'WEBSITE_LANG', 0, null,
'1', 0, 0,
'minwidth200', 0, 0, 0, $onlykeys, 1);
4285 $htmltext = $langs->trans(
"AvailableLanguagesAreDefinedIntoWebsiteProperties");
4286 print $form->textwithpicto(
'', $htmltext);
4292 print
'<!-- Translation of --><tr><td>';
4293 print $langs->trans(
'TranslationLinks');
4295 if ($action !=
'createcontainer') {
4297 $sql =
"SELECT rowid, lang from ".MAIN_DB_PREFIX.
"website_page where fk_page = ".((int) $objectpage->id);
4298 $resql = $db->query($sql);
4300 $num_rows = $db->num_rows($resql);
4301 if ($num_rows > 0) {
4302 print
'<span class="opacitymedium">'.$langs->trans(
'ThisPageHasTranslationPages').
':</span>';
4306 while ($obj = $db->fetch_object($resql)) {
4307 $result = $tmppage->fetch($obj->rowid);
4310 $tmpstring .=
'<br>';
4312 $tmpstring .= $tmppage->getNomUrl(1).
' ('.$tmppage->lang.
')';
4328 if (empty($translatedby) && ($action ==
'editmeta' || $action ==
'createcontainer' || $objectpage->fk_page > 0)) {
4330 $result = $sourcepage->fetch($objectpage->fk_page);
4333 } elseif ($result > 0) {
4334 $translationof = $objectpage->fk_page;
4335 print
'<span class="opacitymedium">'.$langs->trans(
'ThisPageIsTranslationOf').
'</span> ';
4336 print $formwebsite->selectContainer($website,
'pageidfortranslation', ($translationof ? $translationof : -1), 1, $action,
'minwidth300', array($objectpage->id));
4337 if ($translationof > 0 && $sourcepage->lang) {
4338 print $sourcepage->getNomUrl(2).
' ('.$sourcepage->lang.
')';
4346 print $langs->trans(
'AllowedInFrames');
4350 print
'<input type="checkbox" class="flat" name="WEBSITE_ALLOWED_IN_FRAMES" value="1"'.($pageallowedinframes ?
'checked="checked"' :
'').
'>';
4354 if (isModEnabled(
'categorie') && $user->hasRight(
'categorie',
'lire')) {
4355 $langs->load(
'categories');
4357 if (!GETPOSTISSET(
'categories')) {
4358 $cate_arbo = $form->select_all_categories(Categorie::TYPE_WEBSITE_PAGE,
'',
null,
null,
null, 1);
4360 $cats = $c->containing($objectpage->id, Categorie::TYPE_WEBSITE_PAGE);
4361 $arrayselected = array();
4362 if (is_array($cats)) {
4363 foreach ($cats as $cat) {
4364 $arrayselected[] = $cat->id;
4368 $cate_arbo = $form->select_all_categories(Categorie::TYPE_WEBSITE_PAGE,
'',
'parent',
null,
null, 1);
4371 print
'<tr><td class="toptd">'.$form->editfieldkey(
'Categories',
'categories',
'', $objectpage, 0).
'</td><td>';
4372 print
img_picto(
'',
'category',
'class="pictofixedwidth"');
4373 print $form->multiselectarray(
'categories', $cate_arbo, (GETPOSTISSET(
'categories') ?
GETPOST(
'categories',
'array') : $arrayselected), null, null,
'minwidth200 widthcentpercentminusxx');
4378 print
'<tr><td class="titlefieldcreate">';
4379 print
'ObjectClass';
4381 print
'<input type="text" class="flat minwidth300" name="WEBSITE_OBJECTCLASS" placeholder="ClassName::/path/class/ObjectClass.class.php" >';
4384 print
'<tr><td class="titlefieldcreate">';
4387 print
'<input type="text" class="flat minwidth300" name="WEBSITE_OBJECTID" >';
4391 $fuser =
new User($db);
4394 print $langs->trans(
'Author');
4396 if ($pageauthorid > 0) {
4397 $fuser->fetch($pageauthorid);
4398 print $fuser->getNomUrl(1);
4400 print
'<span class="opacitymedium">'.$langs->trans(
"Unknown").
'</span>';
4405 print $langs->trans(
'PublicAuthorAlias');
4407 print
'<input type="text" class="flat minwidth300" name="WEBSITE_AUTHORALIAS" value="'.dol_escape_htmltag($pageauthoralias).
'" placeholder="Anonymous">';
4411 print $langs->trans(
'DateCreation');
4413 print $form->selectDate($pagedatecreation,
'datecreation', 1, 1, 0,
'', 1, 1);
4417 if ($action !=
'createcontainer') {
4419 print $langs->trans(
'UserModif');
4421 if ($pageusermodifid > 0) {
4422 $fuser->fetch($pageusermodifid);
4423 print $fuser->getNomUrl(1);
4428 print $langs->trans(
'DateModification');
4430 print
dol_print_date($pagedatemodification,
'dayhour',
'tzuser');
4434 print
'<tr><td class="tdhtmlheader tdtop">';
4435 $htmlhelp = $langs->trans(
"EditTheWebSiteForACommonHeader").
'<br><br>';
4436 $htmlhelp .= $langs->trans(
"Example").
' :<br>';
4438 print $form->textwithpicto($langs->trans(
'HtmlHeaderPage'), $htmlhelp, 1,
'help',
'', 0, 2,
'htmlheadertooltip');
4440 $poscursor = array(
'x'=>
GETPOST(
'htmlheader_x'),
'y'=>
GETPOST(
'htmlheader_y'));
4441 $doleditor =
new DolEditor(
'htmlheader', $pagehtmlheader,
'',
'120',
'ace',
'In',
true,
false,
'ace', ROWS_3,
'100%',
'', $poscursor);
4442 print $doleditor->Create(1,
'',
true,
'HTML Header',
'html');
4447 if ($action ==
'createcontainer') {
4448 print
'<div class="center tablecheckboxcreatemanually'.$hiddenmanuallyafterload.
'">';
4450 print
'<input type="submit" class="button small" name="addcontainer" value="'.$langs->trans(
"Create").
'">';
4451 print
'<input class="button button-cancel small" type="submit" name="preview" value="'.$langs->trans(
"Cancel").
'">';
4458 if (!empty($conf->use_javascript_ajax)) {
4459 print
'<input type="radio" name="radiocreatefrom" id="checkboxcreatefromfetching" value="checkboxcreatefromfetching"'.(GETPOST(
'radiocreatefrom') ==
'checkboxcreatefromfetching' ?
' checked' :
'').
'> ';
4461 print
'<label for="checkboxcreatefromfetching"><span class="opacitymediumxx">'.$langs->trans(
"CreateByFetchingExternalPage").
'</span></label><br>';
4462 print
'<hr class="tablecheckboxcreatefromfetching'.$hiddenfromfetchingafterload.
'">';
4463 print
'<table class="tableforfield centpercent tablecheckboxcreatefromfetching'.$hiddenfromfetchingafterload.
'">';
4464 print
'<tr><td class="titlefield">';
4465 print $langs->trans(
"URL");
4467 print
info_admin($langs->trans(
"OnlyEditionOfSourceForGrabbedContentFuture"), 0, 0,
'warning');
4468 print
'<input class="flat minwidth500" type="text" name="externalurl" value="'.dol_escape_htmltag(
GETPOST(
'externalurl',
'alpha')).
'" placeholder="https://externalsite/pagetofetch"> ';
4469 print
'<br><input class="flat paddingtop" type="checkbox" name="grabimages" value="1" checked="checked"> '.$langs->trans(
"GrabImagesInto");
4471 print $langs->trans(
"ImagesShouldBeSavedInto").
' ';
4472 $arraygrabimagesinto = array(
'root'=>$langs->trans(
"WebsiteRootOfImages"),
'subpage'=>$langs->trans(
"SubdirOfPage"));
4473 print $form->selectarray(
'grabimagesinto', $arraygrabimagesinto, GETPOSTISSET(
'grabimagesinto') ?
GETPOST(
'grabimagesinto') :
'root', 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
4476 print
'<input class="button small" style="margin-top: 5px" type="submit" name="fetchexternalurl" value="'.dol_escape_htmltag($langs->trans(
"FetchAndCreate")).
'">';
4477 print
'<input class="button button-cancel small" type="submit" name="preview" value="'.$langs->trans(
"Cancel").
'">';
4483 if ($action ==
'createcontainer') {
4484 print
'<script type="text/javascript">
4485 jQuery(document).ready(function() {
4486 var disableautofillofalias = 0;
4487 var selectedm = \'\';
4488 var selectedf = \'\';
4489 jQuery("#WEBSITE_TITLE").keyup(function() {
4490 if (disableautofillofalias == 0)
4492 var valnospecial = jQuery("#WEBSITE_TITLE").val();
4493 valnospecial = valnospecial.replace(/[éèê]/g, \'e\').replace(/[à ]/g, \'a\').replace(/[ù]/g, \'u\').replace(/[î]/g, \'i\');
4494 valnospecial = valnospecial.replace(/[ç]/g, \'c\').replace(/[ö]/g, \'o\');
4495 valnospecial = valnospecial.replace(/[^\w]/gi, \'-\').toLowerCase();
4496 valnospecial = valnospecial.replace(/\-+/g, \'-\').replace(/\-$/, \'\');
4497 console.log("disableautofillofalias=0 so we replace WEBSITE_TITLE with "+valnospecial);
4498 jQuery("#WEBSITE_PAGENAME").val(valnospecial);
4501 jQuery("#WEBSITE_PAGENAME").keyup(function() {
4502 disableautofillofalias = 1;
4505 jQuery("#checkboxcreatefromfetching,#checkboxcreatemanually").click(function() {
4506 console.log("we select a method to create a new container "+jQuery("#checkboxcreatefromfetching:checked").val())
4507 jQuery(".tablecheckboxcreatefromfetching").hide();
4508 jQuery(".tablecheckboxcreatemanually").hide();
4509 if (typeof(jQuery("#checkboxcreatefromfetching:checked").val()) != \'undefined\') {
4510 console.log("show a");
4511 if (selectedf != \'createfromfetching\') {
4512 jQuery(".tablecheckboxcreatefromfetching").show();
4513 selectedf = \'createfromfetching\';
4516 jQuery(".tablecheckboxcreatefromfetching").hide();
4520 if (typeof(jQuery("#checkboxcreatemanually:checked").val()) != \'undefined\') {
4521 console.log("show b");
4522 if (selectedm != \'createmanually\') {
4523 jQuery(".tablecheckboxcreatemanually").show();
4524 selectedm = \'createmanually\';
4527 jQuery(".tablecheckboxcreatemanually").hide();
4546if ($action ==
'preview') {
4550if ($action ==
'editfile' || $action ==
'file_manager' || $action ==
'convertimgwebp' || $action ==
'confirmconvertimgwebp') {
4551 print
'<!-- Edit Media -->'.
"\n";
4552 print
'<div class="fiche"><br>';
4557 $formalreadyopen = 2;
4559 $url = DOL_URL_ROOT.
'/website/index.php';
4561 include DOL_DOCUMENT_ROOT.
'/core/tpl/filemanager.tpl.php';
4566if ($action ==
'editmenu') {
4567 print
'<!-- Edit Menu -->'.
"\n";
4568 print
'<div class="center">'.$langs->trans(
"FeatureNotYetAvailable").
'</center>';
4571if ($action ==
'editsource') {
4574 $contentforedit =
'';
4578 $contentforedit .= $objectpage->content;
4580 $maxheightwin = 480;
4581 if (isset($_SESSION[
"dol_screenheight"])) {
4582 if ($_SESSION[
"dol_screenheight"] > 680) {
4583 $maxheightwin = $_SESSION[
"dol_screenheight"] - 400;
4585 if ($_SESSION[
"dol_screenheight"] > 800) {
4586 $maxheightwin = $_SESSION[
"dol_screenheight"] - 490;
4590 $poscursor = array(
'x'=>
GETPOST(
'PAGE_CONTENT_x'),
'y'=>
GETPOST(
'PAGE_CONTENT_y'));
4591 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
4592 $doleditor =
new DolEditor(
'PAGE_CONTENT', $contentforedit,
'', $maxheightwin,
'Full',
'',
true,
true,
'ace', ROWS_5,
'40%', 0, $poscursor);
4593 $doleditor->Create(0,
'',
false,
'HTML Source',
'php');
4596if ($action ==
'editcontent') {
4599 $contentforedit =
'';
4603 $contentforedit .= $objectpage->content;
4606 $contentforedit = preg_replace(
'/(<img.*src=")(?!http)/',
'\1'.DOL_URL_ROOT.
'/viewimage.php?modulepart=medias&file=', $contentforedit, -1, $nbrep);
4608 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
4609 $poscursor = array(
'x'=>
GETPOST(
'PAGE_CONTENT_x'),
'y'=>
GETPOST(
'PAGE_CONTENT_y'));
4610 $doleditor=
new DolEditor(
'PAGE_CONTENT', $contentforedit,
'', 500,
'Full',
'',
true,
true,
true, ROWS_5,
'90%', 0, $poscursor);
4611 $doleditor->Create(0,
'',
false);
4619if ($mode ==
'replacesite' || $massaction ==
'replace') {
4620 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4621 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4622 print
'<input type="hidden" name="action" value="replacesiteconfirm">';
4623 print
'<input type="hidden" name="mode" value="replacesite">';
4624 print
'<input type="hidden" name="website" value="'.$website->ref.
'">';
4627 print
'<!-- Search page and replace string -->'.
"\n";
4628 print
'<div class="fiche"><br>';
4630 print
load_fiche_titre($langs->trans(
"ReplaceWebsiteContent"),
'',
'search');
4632 print
'<div class="fichecenter"><div class="fichehalfleft">';
4634 print
'<div class="tagtable">';
4636 print
'<div class="tagtr">';
4637 print
'<div class="tagtd paddingrightonly opacitymedium">';
4638 print $langs->trans(
"SearchReplaceInto");
4640 print
'<div class="tagtd">';
4641 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>';
4642 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>';
4643 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>';
4647 print
'<div class="tagtr">';
4648 print
'<div class="tagtd paddingrightonly opacitymedium" style="padding-right: 10px !important">';
4649 print $langs->trans(
"SearchString");
4651 print
'<div class="tagtd">';
4652 print
'<input type="text" name="searchstring" value="'.dol_escape_htmltag($searchkey, 0, 0,
'', 1).
'" autofocus>';
4658 print
'</div><div class="fichehalfleft">';
4660 print
'<div class="tagtable">';
4662 print
'<div class="tagtr">';
4663 print
'<div class="tagtd paddingrightonly opacitymedium tdoverflowmax100onsmartphone" style="padding-right: 10px !important">';
4664 print $langs->trans(
"WEBSITE_TYPE_CONTAINER");
4666 print
'<div class="tagtd">';
4667 print
img_picto(
'',
'object_technic',
'class="paddingrightonly"').
' ';
4668 $formwebsite->selectTypeOfContainer(
'optioncontainertype', (
GETPOST(
'optioncontainertype',
'alpha') ?
GETPOST(
'optioncontainertype',
'alpha') :
''), 1,
'', 1,
'minwidth125 maxwidth400 widthcentpercentminusx');
4672 print
'<div class="tagtr">';
4673 print
'<div class="tagtd paddingrightonly opacitymedium tdoverflowmax100onsmartphone" style="padding-right: 10px !important">';
4674 print $langs->trans(
"Language");
4676 print
'<div class="tagtd">';
4677 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);
4682 if (isModEnabled(
'categorie') && $user->hasRight(
'categorie',
'lire')) {
4683 print
'<div class="tagtr">';
4684 print
'<div class="tagtd paddingrightonly marginrightonly opacitymedium tdoverflowmax100onsmartphone" style="padding-right: 10px !important">';
4685 print $langs->trans(
"Category");
4687 print
'<div class="tagtd">';
4688 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');
4689 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
4697 print
'<input type="submit" class="button margintoponly" name="buttonreplacesitesearch" value="'.dol_escape_htmltag($langs->trans(
"Search")).
'">';
4699 print
'</div></div>';
4701 if ($mode ==
'replacesite') {
4702 print
'<!-- List of search result -->'.
"\n";
4703 print
'<div class="rowsearchresult clearboth">';
4708 if ($listofpages[
'code'] ==
'OK') {
4709 $arrayofselected = is_array($toselect) ? $toselect : array();
4711 $nbtotalofrecords = count($listofpages[
'list']);
4713 $permissiontodelete = $user->hasRight(
'website',
'delete');
4716 $arrayofmassactions = array();
4717 if ($user->hasRight(
'website',
'writephp') && $searchkey) {
4718 $arrayofmassactions[
'replace'] =
img_picto(
'',
'replacement',
'class="pictofixedwidth"').$langs->trans(
"Replace");
4720 if ($user->hasRight(
'website',
'write')) {
4721 $arrayofmassactions[
'setcategory'] =
img_picto(
'',
'category',
'class="pictofixedwidth"').$langs->trans(
"ClassifyInCategory");
4723 if ($user->hasRight(
'website',
'write')) {
4724 $arrayofmassactions[
'delcategory'] =
img_picto(
'',
'category',
'class="pictofixedwidth"').$langs->trans(
"RemoveCategory");
4726 if ($permissiontodelete) {
4727 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
4729 if (
GETPOST(
'nomassaction',
'int') || in_array($massaction, array(
'presend',
'predelete'))) {
4730 $arrayofmassactions = array();
4733 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
4734 $massactionbutton .=
'<div class="massactionother massactionreplace hidden">';
4735 $massactionbutton .= $langs->trans(
"ReplaceString");
4736 $massactionbutton .=
' <input type="text" name="replacestring" value="'.dol_escape_htmltag(
GETPOST(
'replacestring',
'none')).
'">';
4737 $massactionbutton .=
'</div>';
4738 $massactionbutton .=
'<div class="massactionother massactionsetcategory massactiondelcategory hidden">';
4739 $massactionbutton .=
img_picto(
'',
'category').
' '.$langs->trans(
"Category");
4740 $massactionbutton .=
' '.$form->select_all_categories(Categorie::TYPE_WEBSITE_PAGE, GETPOSTISSET(
'setcategory') ?
GETPOST(
'setcategory') :
'',
'setcategory', 64, 0, 0, 0,
'minwidth300 alignstart');
4741 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
4743 $massactionbutton .=
'</div>';
4745 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
4748 $selectedfields =
'';
4749 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
4751 print_barre_liste($langs->trans(
"Results"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'generic', 0,
'',
'', $limit, 1, 1, 1);
4753 $topicmail =
"WebsitePageRef";
4754 $modelmail =
"websitepage_send";
4756 $trackid =
'wsp'.$object->id;
4757 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
4759 $param =
'mode=replacesite&website='.urlencode($website->ref);
4760 $param .=
'&searchstring='.urlencode($searchkey);
4761 if (
GETPOST(
'optioncontent')) {
4762 $param .=
'&optioncontent=content';
4765 $param .=
'&optionmeta=meta';
4767 if (
GETPOST(
'optionsitefiles')) {
4768 $param .=
'&optionsitefiles=optionsitefiles';
4770 if (
GETPOST(
'optioncontainertype')) {
4771 $param .=
'&optioncontainertype='.GETPOST(
'optioncontainertype',
'aZ09');
4773 if (
GETPOST(
'optionlanguage')) {
4774 $param .=
'&optionlanguage='.GETPOST(
'optionlanguage',
'aZ09');
4776 if (
GETPOST(
'optioncategory')) {
4777 $param .=
'&optioncategory='.GETPOST(
'optioncategory',
'aZ09');
4780 print
'<div class="div-table-responsive-no-min">';
4781 print
'<table class="noborder centpercent">';
4782 print
'<tr class="liste_titre">';
4783 print
getTitleFieldOfList(
"Type", 0, $_SERVER[
'PHP_SELF'],
'type_container',
'', $param,
'', $sortfield, $sortorder,
'').
"\n";
4784 print
getTitleFieldOfList(
"Page", 0, $_SERVER[
'PHP_SELF'],
'pageurl',
'', $param,
'', $sortfield, $sortorder,
'').
"\n";
4786 print
getTitleFieldOfList(
"Language", 0, $_SERVER[
'PHP_SELF'],
'lang',
'', $param,
'', $sortfield, $sortorder,
'center ').
"\n";
4788 print
getTitleFieldOfList(
"DateLastModification", 0, $_SERVER[
'PHP_SELF'],
'tms',
'', $param,
'', $sortfield, $sortorder,
'center ').
"\n";
4790 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
4793 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
4798 foreach ($listofpages[
'list'] as $answerrecord) {
4799 if (is_object($answerrecord) && get_class($answerrecord) ==
'WebsitePage') {
4803 print
'<td class="nowraponall">'.$langs->trans(
"Container").
' - ';
4804 print $langs->trans($answerrecord->type_container);
4809 print $answerrecord->getNomUrl(1);
4810 print
' <span class="opacitymedium">('.($answerrecord->title ? $answerrecord->title : $langs->trans(
"NoTitle")).
')</span>';
4814 print
'<span class="opacitymedium">'.$answerrecord->description.
'</span>';
4818 print
'<td class="center">';
4819 if (isModEnabled(
'categorie') && $user->hasRight(
'categorie',
'lire')) {
4821 $existing = $c->containing($answerrecord->id, Categorie::TYPE_WEBSITE_PAGE,
'object');
4822 if (is_array($existing)) {
4823 foreach ($existing as $tmpcategory) {
4825 print
img_object($langs->trans(
"Category").
' : '.$tmpcategory->label,
'category',
'style="padding-left: 2px; padding-right: 2px; color: #'.($tmpcategory->color !=
'' ? $tmpcategory->color :
'888').
'"');
4833 $param =
'?mode=replacesite';
4834 $param .=
'&websiteid='.$website->id;
4835 $param .=
'&optioncontent='.GETPOST(
'optioncontent',
'aZ09');
4836 $param .=
'&optionmeta='.GETPOST(
'optionmeta',
'aZ09');
4837 $param .=
'&optionsitefiles='.GETPOST(
'optionsitefiles',
'aZ09');
4838 $param .=
'&optioncontainertype='.GETPOST(
'optioncontainertype',
'aZ09');
4839 $param .=
'&optionlanguage='.GETPOST(
'optionlanguage',
'aZ09');
4840 $param .=
'&optioncategory='.GETPOST(
'optioncategory',
'aZ09');
4841 $param .=
'&searchstring='.urlencode($searchkey);
4844 print
'<td class="center">';
4849 print
'<td class="center nowraponall">';
4851 $characterMap =
'áà éèëÃóúüñùç0123456789';
4852 $nbofwords = str_word_count($textwithouthtml, 0, $characterMap);
4854 print $nbofwords.
' '.$langs->trans(
"words");
4855 $totalnbwords += $nbofwords;
4860 print
'<td class="center nowraponall">';
4861 print
dol_print_date($answerrecord->date_modification,
'dayhour');
4865 print
'<td class="tdwebsitesearchresult right nowraponall">';
4867 $urltoedithtmlsource = $_SERVER[
"PHP_SELF"].
'?action=editmeta&token='.newToken().
'&websiteid='.$website->id.
'&pageid='.$answerrecord->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].$param);
4868 if (!$user->hasRight(
'website',
'write')) {
4869 $disabled =
' disabled';
4870 $urltoedithtmlsource =
'';
4872 print
'<a class="editfielda marginleftonly marginrightonly '.$disabled.
'" href="'.$urltoedithtmlsource.
'" title="'.$langs->trans(
"EditPageMeta").
'">'.
img_picto($langs->trans(
"EditPageMeta"),
'pencil-ruler').
'</a>';
4875 $urltoedithtmlsource = $_SERVER[
"PHP_SELF"].
'?action=editsource&token='.newToken().
'&websiteid='.$website->id.
'&pageid='.$answerrecord->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].$param);
4876 if (!$user->hasRight(
'website',
'write')) {
4877 $disabled =
' disabled';
4878 $urltoedithtmlsource =
'';
4880 print
'<a class="editfielda marginleftonly marginrightonly '.$disabled.
'" href="'.$urltoedithtmlsource.
'" title="'.$langs->trans(
"EditHTMLSource").
'">'.
img_picto($langs->trans(
"EditHTMLSource"),
'edit').
'</a>';
4882 print
'<span class="marginleftonly marginrightonly"></span>';
4883 print
ajax_object_onoff($answerrecord,
'status',
'status',
'Enabled',
'Disabled', array(),
'valignmiddle inline-block');
4888 print
'<td class="nowrap center">';
4890 print
'<!-- Status of page -->'.
"\n";
4891 if ($massactionbutton || $massaction) {
4893 if (in_array($answerrecord->id, $arrayofselected)) {
4896 print
'<input id="'.$answerrecord->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$answerrecord->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
4906 $translateofrecordtype = array(
4907 'website_csscontent'=>
'WEBSITE_CSS_INLINE',
4908 'website_jscontent'=>
'WEBSITE_JS_INLINE',
4909 'website_robotcontent'=>
'WEBSITE_ROBOT',
4910 'website_htmlheadercontent'=>
'WEBSITE_HTML_HEADER',
4911 'website_htaccess'=>
'WEBSITE_HTACCESS',
4912 'website_readme'=>
'WEBSITE_README',
4913 'website_manifestjson'=>
'WEBSITE_MANIFEST_JSON'
4915 if (!empty($translateofrecordtype[$answerrecord[
'type']])) {
4916 print $langs->trans($translateofrecordtype[$answerrecord[
'type']]);
4918 print $answerrecord[
'type'];
4922 $param =
'?mode=replacesite';
4923 $param .=
'&websiteid='.$website->id;
4924 $param .=
'&optioncontent='.GETPOST(
'optioncontent',
'aZ09');
4925 $param .=
'&optionmeta='.GETPOST(
'optionmeta',
'aZ09');
4926 $param .=
'&optionsitefiles='.GETPOST(
'optionsitefiles',
'aZ09');
4927 $param .=
'&optioncontainertype='.GETPOST(
'optioncontainertype',
'aZ09');
4928 $param .=
'&optionlanguage='.GETPOST(
'optionlanguage',
'aZ09');
4929 $param .=
'&optioncategory='.GETPOST(
'optioncategory',
'aZ09');
4930 $param .=
'&searchstring='.urlencode($searchkey);
4934 $backtopageurl = $_SERVER[
"PHP_SELF"].$param;
4935 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=editcss&token='.newToken().
'&website='.urlencode($website->ref).
'&backtopage='.urlencode($backtopageurl).
'">'.$langs->trans(
"EditCss").
'</a>';
4951 print
'<td class="center nowraponall">';
4960 print
'<td class="nowrap center">';
4967 if (count($listofpages[
'list']) >= 2) {
4969 print
'<tr class="lite_titre">';
4973 print $langs->trans(
"Total");
4989 print
'<td class="center nowraponall">';
4990 print $totalnbwords.
' '.$langs->trans(
"words");
5002 print
'<td class="nowrap center">';
5012 print
'<div class="warning">'.$listofpages[
'message'].
'</div>';
5021if ((empty($action) || $action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone') && !in_array($mode, array(
'replacesite'))) {
5022 if ($pageid > 0 && $atleastonepage) {
5028 $objectpage->fetch($pageid);
5030 $jscontent = @file_get_contents($filejs);
5032 $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";
5041 $out .=
"\n<html><head>\n";
5042 $out .=
"<!-- htmlheader/style of page from database -->\n";
5045 $out .=
"<!-- htmlheader/style of website from files -->\n";
5063 $out .=
"</head>\n";
5067 $out .=
'<div id="websitecontentundertopmenu" class="websitecontentundertopmenu boostrap-iso">'.
"\n";
5071 $out .=
'<!-- style of website from file -->'.
"\n";
5072 $out .=
'<style scoped>'.
"\n";
5074 $tmpout .=
'/* Include website CSS file */'.
"\n";
5078 $csscontent = ob_get_contents();
5081 $tmpout .=
'/* Include style from the HTML header of page */'.
"\n";
5083 $tmp = preg_split(
'(<style[^>]*>|</style>)', $objectpage->htmlheader);
5084 $tmpstyleinheader =
'';
5086 foreach ($tmp as $valtmp) {
5089 $tmpstyleinheader .= $valtmp.
"\n";
5092 $tmpout .= $tmpstyleinheader.
"\n";
5094 $tmpout = preg_replace(
'/}[\s\n]*body\s*{[^}]+}/ims',
'}', $tmpout);
5096 $out .=
'</style>'.
"\n";
5103 $out .=
'<div id="divbodywebsite" class="bodywebsite bodywebpage-'.$objectpage->ref.
'">'.
"\n";
5105 $newcontent = $objectpage->content;
5112 $filephp = $filetpl;
5115 $res = include $filephp;
5117 print
"ERROR: Failed to include file '".$filephp.
"'. Try to edit and re-save page ith this ID.";
5120 print $e->getMessage();
5122 $newcontent = ob_get_contents();
5129 $newcontent = preg_replace(
'/(div|section)(\s[^>]*)contenteditable="true"/',
'\1\2', $newcontent);
5138 $out .=
'</div> <!-- End div id=websitecontentundertopmenu -->';
5144 $out .=
"\n</body></html>\n";
5146 $out .=
"\n".
'<!-- End page content '.$filetpl.
' -->'.
"\n\n";
5170 if (empty($websitekey) || $websitekey ==
'-1') {
5171 print
'<br><br><div class="center previewnotyetavailable"><span class="">'.$langs->trans(
"NoWebSiteCreateOneFirst").
'</span></div><br><br><br>';
5172 print
'<div class="center"><div class="logo_setup"></div></div>';
5174 print
'<br><br><div class="center previewnotyetavailable"><span class="">'.$langs->trans(
"PreviewOfSiteNotYetAvailable", $object->ref).
'</span></div><br><br><br>';
5175 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.