30define(
'NOSCANPOSTFORINJECTION', array(
'PAGE_CONTENT',
'WEBSITE_CSS_INLINE',
'WEBSITE_JS_INLINE',
'WEBSITE_HTML_HEADER',
'htmlheader'));
32define(
'USEDOLIBARREDITOR', 1);
33define(
'FORCE_CKEDITOR', 1);
34if (!defined(
'DISABLE_JS_GRAHP')) {
35 define(
'DISABLE_JS_GRAPH', 1);
41require
'../main.inc.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/lib/website.lib.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/lib/website2.lib.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formwebsite.class.php';
50require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
52require_once DOL_DOCUMENT_ROOT.
'/website/class/website.class.php';
53require_once DOL_DOCUMENT_ROOT.
'/website/class/websitepage.class.php';
54require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
55require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
59$langs->loadLangs(array(
"admin",
"other",
"website",
"errors"));
62if (!$user->hasRight(
'website',
'read')) {
66$conf->dol_hide_leftmenu = 1;
72$websitekey =
GETPOST(
'website',
'alpha');
73$page =
GETPOST(
'page',
'alpha');
75$pageref =
GETPOST(
'pageref',
'alphanohtml');
77$action =
GETPOST(
'action',
'aZ09');
78$massaction =
GETPOST(
'massaction',
'alpha');
79$confirm =
GETPOST(
'confirm',
'alpha');
80$cancel =
GETPOST(
'cancel',
'alpha');
81$toselect =
GETPOST(
'toselect',
'array');
82$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'websitelist';
83$backtopage =
GETPOST(
'backtopage',
'alpha');
84$optioncss =
GETPOST(
'optioncss',
'aZ');
85$dol_hide_topmenu =
GETPOSTINT(
'dol_hide_topmenu');
86$dol_hide_leftmenu =
GETPOSTINT(
'dol_hide_leftmenu');
87$dol_openinpopup =
GETPOST(
'dol_openinpopup',
'aZ09');
89$type_container =
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'alpha');
90$section_dir =
GETPOST(
'section_dir',
'alpha');
91$file_manager =
GETPOST(
'file_manager',
'alpha');
92$replacesite =
GETPOST(
'replacesite',
'alpha');
93$mode =
GETPOST(
'mode',
'alpha');
95if (
GETPOST(
'deletesite',
'alpha')) {
96 $action =
'deletesite';
98if (
GETPOST(
'delete',
'alpha')) {
101if (
GETPOST(
'preview',
'alpha')) {
104if (
GETPOST(
'createsite',
'alpha')) {
105 $action =
'createsite';
107if (
GETPOST(
'createcontainer',
'alpha')) {
108 $action =
'createcontainer';
110if (
GETPOST(
'editcss',
'alpha')) {
113if (
GETPOST(
'editmenu',
'alpha')) {
114 $action =
'editmenu';
116if (
GETPOST(
'setashome',
'alpha')) {
117 $action =
'setashome';
119if (
GETPOST(
'editmeta',
'alpha')) {
120 $action =
'editmeta';
122if (
GETPOST(
'editsource',
'alpha')) {
123 $action =
'editsource';
125if (
GETPOST(
'editcontent',
'alpha')) {
126 $action =
'editcontent';
128if (
GETPOST(
'exportsite',
'alpha')) {
129 $action =
'exportsite';
131if (
GETPOST(
'importsite',
'alpha')) {
132 $action =
'importsite';
134if (
GETPOST(
'createfromclone',
'alpha')) {
135 $action =
'createfromclone';
137if (
GETPOST(
'createpagefromclone',
'alpha')) {
138 $action =
'createpagefromclone';
140if (empty($action) && $file_manager) {
141 $action =
'file_manager';
143if ($action ==
'replacesite' || (empty($action) && $replacesite)) {
144 $mode =
'replacesite';
152$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
153$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
155if (empty($page) || $page == -1) {
158$offset = $limit * $page;
159$pageprev = $page - 1;
160$pagenext = $page + 1;
171$listofwebsites =
$object->fetchAll(
'ASC',
'position');
174if (!($websiteid > 0) && empty($websitekey) && $action !=
'createsite') {
175 foreach ($listofwebsites as $key => $valwebsite) {
176 $websitekey = $valwebsite->ref;
180if ($websiteid > 0 || $websitekey) {
181 $res =
$object->fetch($websiteid, $websitekey);
191if (($pageid > 0 || $pageref) && $action !=
'addcontainer') {
192 $res = $objectpage->fetch($pageid, (
$object->id > 0 ?
$object->id : null), $pageref);
195 $res = $objectpage->fetch($pageid, (
$object->id > 0 ?
$object->id : null), null, $pageref);
199 if ($res >= 0 &&
$object->id > 0) {
200 if ($objectpage->fk_website !=
$object->id) {
201 if (
$object->fk_default_home > 0) {
202 $res = $objectpage->fetch(
$object->fk_default_home,
$object->id,
'');
204 $pageid =
$object->fk_default_home;
207 $res = $objectpage->fetch(0,
$object->id,
'');
211 $pageid = $objectpage->id;
215 $pageid = $objectpage->id;
221if (empty($pageid) && empty($pageref) &&
$object->id > 0 && $action !=
'createcontainer') {
222 $pageid =
$object->fk_default_home;
223 if (empty($pageid)) {
224 $array = $objectpage->fetchAll(
$object->id,
'ASC,ASC',
'type_container,pageurl');
225 if (!is_array($array) && $array < 0) {
228 $atleastonepage = (is_array($array) && count($array) > 0);
232 foreach ($array as $key => $valpage) {
233 if (empty($firstpageid)) {
234 $firstpageid = $valpage->id;
236 if (
$object->fk_default_home && $key ==
$object->fk_default_home) {
237 $homepageid = $valpage->id;
240 $pageid = ($homepageid ? $homepageid : $firstpageid);
245global $dolibarr_main_data_root;
246$pathofwebsite = $dolibarr_main_data_root.($conf->entity > 1 ?
'/'.$conf->entity :
'').
'/website/'.$websitekey;
247$filehtmlheader = $pathofwebsite.
'/htmlheader.html';
248$filecss = $pathofwebsite.
'/styles.css.php';
249$filejs = $pathofwebsite.
'/javascript.js.php';
250$filerobot = $pathofwebsite.
'/robots.txt';
251$filehtaccess = $pathofwebsite.
'/.htaccess';
252$filetpl = $pathofwebsite.
'/page'.$pageid.
'.tpl.php';
253$fileindex = $pathofwebsite.
'/index.php';
254$filewrapper = $pathofwebsite.
'/wrapper.php';
255$filemanifestjson = $pathofwebsite.
'/manifest.json.php';
256$filereadme = $pathofwebsite.
'/README.md';
257$filelicense = $pathofwebsite.
'/LICENSE';
258$filemaster = $pathofwebsite.
'/master.inc.php';
261$urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
262$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
266$permtouploadfile = $user->hasRight(
'website',
'write');
267$diroutput = $conf->medias->multidir_output[$conf->entity];
269$relativepath = $section_dir;
270$upload_dir = preg_replace(
'/\/$/',
'', $diroutput).
'/'.preg_replace(
'/^\//',
'', $relativepath);
272$htmlheadercontentdefault =
'';
273$htmlheadercontentdefault .=
'<link rel="stylesheet" id="google-fonts-css" href="//fonts.googleapis.com/css?family=Open+Sans:300,400,700" />'.
"\n";
274$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";
275$htmlheadercontentdefault .=
'<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>'.
"\n";
276$htmlheadercontentdefault .=
'<script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>'.
"\n";
277$htmlheadercontentdefault .=
'<!--'.
"\n";
278$htmlheadercontentdefault .=
'<script src="/document.php?modulepart=medias&file=css/myfile.css"></script>'.
"\n";
279$htmlheadercontentdefault .=
'<script src="/document.php?modulepart=medias&file=js/myfile.js"></script>'.
"\n";
280$htmlheadercontentdefault .=
'-->'.
"\n";
282$manifestjsoncontentdefault =
'';
283$manifestjsoncontentdefault .=
'{
285 "short_name": "MyWebsite",
288 "display": "standalone",
289 "background_color": "#fff",
290 "description": "A simple Web app.",
292 "src": "images/'.urlencode($website->ref).
'/homescreen48.png",
296 "src": "image/'.urlencode($website->ref).
'/homescreen72.png",
300 "src": "image/'.urlencode($website->ref).
'/homescreen96.png",
304 "src": "image/'.urlencode($website->ref).
'/homescreen144.png",
308 "src": "image/'.urlencode($website->ref).
'/homescreen168.png",
312 "src": "image/'.urlencode($website->ref).
'/homescreen192.png",
316 "related_applications": [{
318 "url": "https://play.google.com/store/apps/details?id=com.nltechno.dolidroidpro"
322$listofpages = array();
331if (
GETPOST(
'optionsitefiles')) {
332 $algo .=
'sitefiles';
335if (empty($sortfield)) {
336 if ($action ==
'file_manager') {
340 $sortfield =
'pageurl';
345$searchkey =
GETPOST(
'searchstring',
'restricthtmlallowunvalid');
347if ($action ==
'replacesite' || $mode ==
'replacesite') {
348 $containertype =
GETPOST(
'optioncontainertype',
'aZ09') !=
'-1' ?
GETPOST(
'optioncontainertype',
'aZ09') :
'';
349 $langcode =
GETPOST(
'optionlanguage',
'aZ09');
350 $otherfilters = array();
352 $otherfilters[
'category'] =
GETPOSTINT(
'optioncategory');
355 $listofpages =
getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters, -1);
358$usercanedit = $user->hasRight(
'website',
'write');
359$permissiontoadd = $user->hasRight(
'website',
'write');
360$permissiontodelete = $user->hasRight(
'website',
'delete');
371if (
GETPOST(
'refreshsite',
'alpha') ||
GETPOST(
'refreshsite.x',
'alpha') ||
GETPOST(
'refreshsite_x',
'alpha')) {
372 if ($action ==
'addsite') {
375 if ($action ==
'updatesource') {
379 $pageid =
$object->fk_default_home;
380 if (empty($pageid)) {
381 $array = $objectpage->fetchAll(
$object->id,
'ASC,ASC',
'type_container,pageurl');
382 if (!is_array($array) && $array < 0) {
385 $atleastonepage = (is_array($array) && count($array) > 0);
389 foreach ($array as $key => $valpage) {
390 if (empty($firstpageid)) {
391 $firstpageid = $valpage->id;
393 if (
$object->fk_default_home && $key ==
$object->fk_default_home) {
394 $homepageid = $valpage->id;
397 $pageid = ($homepageid ? $homepageid : $firstpageid);
400if (
GETPOST(
'refreshpage',
'alpha') && !in_array($action, array(
'updatecss'))) {
404if ($cancel && $action ==
'renamefile') {
413 header(
"Location: ".$backtopage);
418$savbacktopage = $backtopage;
419$backtopage = $_SERVER[
"PHP_SELF"].
'?file_manager=1&website='.urlencode($websitekey).
'&pageid='.urlencode((
string) $pageid).(GETPOST(
'section_dir',
'alpha') ?
'§ion_dir='.urlencode(
GETPOST(
'section_dir',
'alpha')) :
'');
421 $backtopage .=
'&sortfield='.urlencode($sortfield);
424 $backtopage .=
'&sortorder='.urlencode($sortorder);
426include DOL_DOCUMENT_ROOT.
'/core/actions_linkedfiles.inc.php';
428$backtopage = $savbacktopage;
432if ($action ==
'renamefile') {
433 $action =
'file_manager';
436if ($action ==
'setwebsiteonline' && $usercanedit) {
437 $website->setStatut($website::STATUS_VALIDATED,
null,
'',
'WEBSITE_MODIFY',
'status');
439 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
GETPOST(
'website')).
'&pageid='.
GETPOSTINT(
'websitepage'));
442if ($action ==
'setwebsiteoffline' && $usercanedit) {
443 $result = $website->setStatut($website::STATUS_DRAFT,
null,
'',
'WEBSITE_MODIFY',
'status');
445 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
GETPOST(
'website')).
'&pageid='.
GETPOSTINT(
'websitepage'));
448if ($action ==
'seteditinline') {
451 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
GETPOST(
'website')).
'&pageid='.
GETPOSTINT(
'pageid'));
454if ($action ==
'unseteditinline') {
456 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
GETPOST(
'website')).
'&pageid='.
GETPOSTINT(
'pageid'));
459if ($action ==
'setshowsubcontainers') {
462 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
GETPOST(
'website')).
'&pageid='.
GETPOSTINT(
'pageid'));
465if ($action ==
'unsetshowsubcontainers') {
467 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
GETPOST(
'website')).
'&pageid='.
GETPOSTINT(
'pageid'));
471if ($massaction ==
'replace' &&
GETPOST(
'confirmmassaction',
'alpha') && !$searchkey && $usercanedit) {
472 $mode =
'replacesite';
473 $action =
'replacesite';
477if ($action ==
'deletetemplate' && $usercanedit) {
478 $dirthemes = array(
'/doctemplates/websites');
479 if (!empty($conf->modules_parts[
'websitetemplates'])) {
480 foreach ($conf->modules_parts[
'websitetemplates'] as $reldir) {
481 $dirthemes = array_merge($dirthemes, (array) ($reldir.
'doctemplates/websites'));
484 $dirthemes = array_unique($dirthemes);
488 $mode =
'importsite';
489 $action =
'importsite';
491 if (count($dirthemes)) {
493 foreach ($dirthemes as $dir) {
495 $dirtheme = DOL_DATA_ROOT.$dir;
496 if (is_dir($dirtheme)) {
497 $templateuserfile =
GETPOST(
'templateuserfile');
498 $imguserfile = preg_replace(
'/\.zip$/',
'', $templateuserfile).
'.jpg';
507if ($massaction ==
'setcategory' &&
GETPOST(
'confirmmassaction',
'alpha') && $usercanedit) {
514 if ($categoryid > 0) {
517 $category->fetch($categoryid);
519 foreach ($toselect as $tmpid) {
520 $tmpwebsitepage->id = $tmpid;
521 $result = $category->add_type($tmpwebsitepage,
'website_page');
522 if ($result < 0 && $result != -3) {
536 setEventMessages($langs->trans(
"RecordsModified", $nbupdate),
null,
'mesgs');
542 $listofpages =
getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters, -1);
546if ($massaction ==
'delcategory' &&
GETPOST(
'confirmmassaction',
'alpha') && $usercanedit) {
553 if ($categoryid > 0) {
556 $category->fetch($categoryid);
558 foreach ($toselect as $tmpid) {
559 $tmpwebsitepage->id = $tmpid;
560 $result = $category->del_type($tmpwebsitepage,
'website_page');
561 if ($result < 0 && $result != -3) {
575 setEventMessages($langs->trans(
"RecordsModified", $nbupdate),
null,
'mesgs');
581 $listofpages =
getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters, -1);
585if ($massaction ==
'replace' &&
GETPOST(
'confirmmassaction',
'alpha') && $usercanedit) {
586 $replacestring =
GETPOST(
'replacestring',
'restricthtmlallowunvalid');
588 $dolibarrdataroot = preg_replace(
'/([\\/]+)$/i',
'', DOL_DATA_ROOT);
589 $allowimportsite =
true;
590 if (
dol_is_file($dolibarrdataroot.
'/installmodules.lock')) {
591 $allowimportsite =
false;
594 if (!$allowimportsite) {
598 $message = $langs->trans(
'InstallModuleFromWebHasBeenDisabledContactUs');
601 $message = $langs->trans(
"InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.
'/installmodules.lock');
604 } elseif (!$user->hasRight(
'website',
'writephp')) {
606 } elseif (!$replacestring) {
611 foreach ($toselect as $keyselected) {
612 $objectpage = $listofpages[
'list'][$keyselected];
613 if ($objectpage->pageurl) {
614 dol_syslog(
"Replace string into page ".$objectpage->pageurl);
616 if (
GETPOST(
'optioncontent',
'aZ09')) {
617 $objectpage->content = str_replace($searchkey, $replacestring, $objectpage->content);
619 if (
GETPOST(
'optionmeta',
'aZ09')) {
620 $objectpage->title = str_replace($searchkey, $replacestring, $objectpage->title);
621 $objectpage->description = str_replace($searchkey, $replacestring, $objectpage->description);
622 $objectpage->keywords = str_replace($searchkey, $replacestring, $objectpage->keywords);
625 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
626 $filetpl = $pathofwebsite.
'/page'.$objectpage->id.
'.tpl.php';
631 setEventMessages(
'Failed to write file '.basename($filealias),
null,
'errors');
639 $objectpage->update($user);
643 $action =
'createcontainer';
649 if ($nbreplacement > 0) {
650 setEventMessages($langs->trans(
"ReplacementDoneInXPages", $nbreplacement),
null,
'mesgs');
653 $containertype =
GETPOST(
'optioncontainertype',
'aZ09') !=
'-1' ?
GETPOST(
'optioncontainertype',
'aZ09') :
'';
654 $langcode =
GETPOST(
'optionlanguage',
'aZ09');
655 $otherfilters = array();
657 $otherfilters[
'category'] =
GETPOSTINT(
'optioncategory');
661 $listofpages =
getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters);
691if ($action ==
'addsite' && $usercanedit) {
694 if (
GETPOST(
'virtualhost',
'alpha') && !preg_match(
'/^http/',
GETPOST(
'virtualhost',
'alpha'))) {
696 setEventMessages($langs->trans(
'ErrorURLMustStartWithHttp', $langs->transnoentitiesnoconv(
"VirtualHost")),
null,
'errors');
699 if (!$error && !
GETPOST(
'WEBSITE_REF',
'alpha')) {
701 $langs->load(
"errors");
702 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->transnoentities(
"WebsiteName")),
null,
'errors');
704 if (!$error && !preg_match(
'/^[a-z0-9_\-\.]+$/i',
GETPOST(
'WEBSITE_REF',
'alpha'))) {
706 $langs->load(
"errors");
707 setEventMessages($langs->transnoentities(
"ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities(
"Ref")),
null,
'errors');
711 $arrayotherlang = explode(
',',
GETPOST(
'WEBSITE_OTHERLANG',
'alphanohtml'));
712 foreach ($arrayotherlang as $key => $val) {
714 if (empty(trim($val))) {
717 $arrayotherlang[$key] = substr(trim($val), 0, 2);
721 $tmpobject->ref =
GETPOST(
'WEBSITE_REF',
'alpha');
722 $tmpobject->description =
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml');
723 $tmpobject->lang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
724 $tmpobject->otherlang = implode(
',', $arrayotherlang);
725 $tmpobject->virtualhost =
GETPOST(
'virtualhost',
'alpha');
727 $result = $tmpobject->create($user);
731 } elseif ($result < 0) {
742 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$tmpobject->ref);
746 $action =
'createsite';
755'@phan-var-force int $error';
758if ($action ==
'addcontainer' && $usercanedit) {
763 $objectpage->fk_website =
$object->id;
765 if (GETPOSTISSET(
'fetchexternalurl')) {
766 $urltograb =
GETPOST(
'externalurl',
'alpha');
767 $grabimages =
GETPOSTINT(
'grabimages') ? 1 : 0;
768 $grabimagesinto =
GETPOST(
'grabimagesinto',
'alpha');
770 include_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
773 if (empty($urltograb)) {
775 $langs->load(
"errors");
776 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"URL")),
null,
'errors');
777 $action =
'createcontainer';
778 } elseif (!preg_match(
'/^http/', $urltograb)) {
780 $langs->load(
"errors");
781 setEventMessages(
'Error URL must start with http:// or https://',
null,
'errors');
782 $action =
'createcontainer';
789 $urltograbwithoutdomainandparam = preg_replace(
'/^https?:\/\/[^\/]+\/?/i',
'', $urltograb);
791 $urltograbwithoutdomainandparam = preg_replace(
'/\?.*$/',
'', $urltograbwithoutdomainandparam);
792 if (empty($urltograbwithoutdomainandparam) && !preg_match(
'/\/$/', $urltograb)) {
795 $pageurl =
dol_sanitizeFileName(preg_replace(
'/[\/\.]/',
'-', preg_replace(
'/\/+$/',
'', $urltograbwithoutdomainandparam)));
797 $urltograbdirwithoutslash = dirname($urltograb.
'.');
806 $result = $tmpwebsitepage->fetch(0,
$object->id, $pageurl);
808 setEventMessages($langs->trans(
"AliasPageAlreadyExists", $pageurl),
null,
'errors');
810 $action =
'createcontainer';
815 $tmp =
getURLContent($urltograb,
'GET',
'', 1, array(), array(
'http',
'https'), 0);
818 if (!empty($tmp[
'content_type']) && preg_match(
'/ISO-8859-1/', $tmp[
'content_type'])) {
819 if (function_exists(
'mb_check_encoding')) {
820 if (mb_check_encoding($tmp[
'content'],
'ISO-8859-1')) {
822 $tmp[
'content'] = mb_convert_encoding($tmp[
'content'],
'ISO-8859-1',
'UTF-8');
825 setEventMessages(
'Error getting '.$urltograb.
': content seems non valid ISO-8859-1',
null,
'errors');
826 $action =
'createcontainer';
830 setEventMessages(
'Error getting '.$urltograb.
': content seems ISO-8859-1 but functions to convert into UTF-8 are not available in your PHP',
null,
'errors');
831 $action =
'createcontainer';
834 if (empty($tmp[
'content_type']) || (!empty($tmp[
'content_type']) && preg_match(
'/UTF-8/', $tmp[
'content_type']))) {
835 if (function_exists(
'mb_check_encoding')) {
836 if (mb_check_encoding($tmp[
'content'],
'UTF-8')) {
840 setEventMessages(
'Error getting '.$urltograb.
': content seems not a valid UTF-8',
null,
'errors');
841 $action =
'createcontainer';
846 if ($tmp[
'curl_error_no']) {
848 setEventMessages(
'Error getting '.$urltograb.
': '.$tmp[
'curl_error_msg'],
null,
'errors');
849 $action =
'createcontainer';
850 } elseif ($tmp[
'http_code'] !=
'200') {
852 setEventMessages(
'Error getting '.$urltograb.
': '.$tmp[
'http_code'],
null,
'errors');
853 $action =
'createcontainer';
862 setEventMessages(
'Error getting '.$urltograb.
': file that include PHP content is not allowed',
null,
'errors');
863 $action =
'createcontainer';
870 preg_match(
'/<head>(.*)<\/head>/ims', $tmp[
'content'], $regs);
873 $objectpage->type_container =
'page';
874 $objectpage->pageurl = $pageurl;
875 if (empty($objectpage->pageurl)) {
877 $objectpage->pageurl = $tmpdomain.
'-home';
880 $objectpage->aliasalt =
'';
882 if (preg_match(
'/^(\d+)\-/', basename($urltograb), $regs)) {
883 $objectpage->aliasalt = $regs[1];
887 if (preg_match(
'/<title>(.*)<\/title>/ims', $head, $regtmp)) {
888 $objectpage->title = $regtmp[1];
890 if (preg_match(
'/<meta name="title"[^"]+content="([^"]+)"/ims', $head, $regtmp)) {
891 if (empty($objectpage->title)) {
892 $objectpage->title = $regtmp[1];
895 if (preg_match(
'/<meta name="description"[^"]+content="([^"]+)"/ims', $head, $regtmp)) {
896 $objectpage->description = $regtmp[1];
898 if (preg_match(
'/<meta name="keywords"[^"]+content="([^"]+)"/ims', $head, $regtmp)) {
899 $objectpage->keywords = $regtmp[1];
901 if (preg_match(
'/<html\s+lang="([^"]+)"/ims', $tmp[
'content'], $regtmp)) {
902 $tmplang = explode(
'-', $regtmp[1]);
903 $objectpage->lang = $tmplang[0].($tmplang[1] ?
'_'.strtoupper($tmplang[1]) :
'');
906 $tmp[
'content'] = preg_replace(
'/\s*<meta name="generator"[^"]+content="([^"]+)"\s*\/?>/ims',
'', $tmp[
'content']);
908 $objectpage->content = $tmp[
'content'];
909 $objectpage->content = preg_replace(
'/^.*<body(\s[^>]*)*>/ims',
'', $objectpage->content);
910 $objectpage->content = preg_replace(
'/<\/body(\s[^>]*)*>.*$/ims',
'', $objectpage->content);
918 $objectpage->htmlheader = $tmp[
'content'];
919 $objectpage->htmlheader = preg_replace(
'/^.*<head(\s[^>]*)*>/ims',
'', $objectpage->htmlheader);
920 $objectpage->htmlheader = preg_replace(
'/<\/head(\s[^>]*)*>.*$/ims',
'', $objectpage->htmlheader);
921 $objectpage->htmlheader = preg_replace(
'/<base(\s[^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
922 $objectpage->htmlheader = preg_replace(
'/<meta http-equiv="content-type"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
923 $objectpage->htmlheader = preg_replace(
'/<meta name="robots"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
924 $objectpage->htmlheader = preg_replace(
'/<meta name="title"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
925 $objectpage->htmlheader = preg_replace(
'/<meta name="description"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
926 $objectpage->htmlheader = preg_replace(
'/<meta name="keywords"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
927 $objectpage->htmlheader = preg_replace(
'/<meta name="generator"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
930 $objectpage->htmlheader = preg_replace(
'/<title>[^<]*<\/title>\n*/ims',
'', $objectpage->htmlheader);
931 $objectpage->htmlheader = preg_replace(
'/<link[^>]*rel="shortcut[^>]*>\n/ims',
'', $objectpage->htmlheader);
932 $objectpage->htmlheader = preg_replace(
'/<link[^>]*rel="alternate[^>]*>\n/ims',
'', $objectpage->htmlheader);
933 $objectpage->htmlheader = preg_replace(
'/<link[^>]*rel="canonical[^>]*>\n/ims',
'', $objectpage->htmlheader);
936 $tmp = $objectpage->htmlheader;
939 preg_match_all(
'/<script([^\.>]+)src=["\']([^"\'>]+)["\']([^>]*)><\/script>/i', $objectpage->htmlheader, $regs);
940 $errorforsubresource = 0;
941 foreach ($regs[0] as $key => $val) {
942 dol_syslog(
"We will grab the script resource found into script tag ".$regs[2][$key]);
944 $linkwithoutdomain = $regs[2][$key];
945 if (preg_match(
'/^\//', $regs[2][$key])) {
946 $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key];
948 $urltograbbis = $urltograbdirwithoutslash.
'/'.$regs[2][$key];
952 if (preg_match(
'/^http/', $regs[2][$key])) {
953 $urltograbbis = $regs[2][$key];
954 $linkwithoutdomain = preg_replace(
'/^https?:\/\/[^\/]+\//i',
'', $regs[2][$key]);
964 if ($domaintograb != $domaintograbbis) {
996 $tmp = preg_replace(
'/'.preg_quote($regs[0][$key],
'/').
'/i',
'', $tmp);
998 $objectpage->htmlheader = trim($tmp).
"\n";
1002 $pagecsscontent =
"\n".
'<style>'.
"\n";
1004 preg_match_all(
'/<link([^\.>]+)href=["\']([^"\'>]+\.css[^"\'>]*)["\']([^>]*)>/i', $objectpage->htmlheader, $regs);
1005 $errorforsubresource = 0;
1006 foreach ($regs[0] as $key => $val) {
1007 dol_syslog(
"We will grab the css resources found into link tag ".$regs[2][$key]);
1009 $linkwithoutdomain = $regs[2][$key];
1010 if (preg_match(
'/^\//', $regs[2][$key])) {
1011 $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key];
1013 $urltograbbis = $urltograbdirwithoutslash.
'/'.$regs[2][$key];
1017 if (preg_match(
'/^http/', $regs[2][$key])) {
1018 $urltograbbis = $regs[2][$key];
1019 $linkwithoutdomain = preg_replace(
'/^https?:\/\/[^\/]+\//i',
'', $regs[2][$key]);
1029 if ($domaintograb != $domaintograbbis) {
1033 $tmpgeturl =
getURLContent($urltograbbis,
'GET',
'', 1, array(), array(
'http',
'https'), 0);
1034 if ($tmpgeturl[
'curl_error_no']) {
1035 $errorforsubresource++;
1036 setEventMessages(
'Error getting link tag url '.$urltograbbis.
': '.$tmpgeturl[
'curl_error_msg'],
null,
'errors');
1037 dol_syslog(
'Error getting '.$urltograbbis.
': '.$tmpgeturl[
'curl_error_msg']);
1038 $action =
'createcontainer';
1039 } elseif ($tmpgeturl[
'http_code'] !=
'200') {
1040 $errorforsubresource++;
1041 setEventMessages(
'Error getting link tag url '.$urltograbbis.
': '.$tmpgeturl[
'http_code'],
null,
'errors');
1042 dol_syslog(
'Error getting '.$urltograbbis.
': '.$tmpgeturl[
'curl_error_msg']);
1043 $action =
'createcontainer';
1052 $tmpgeturl[
'content'] = preg_replace(
'/\/\*\s+CSS content[a-z\s]*\s+\*\//',
'', $tmpgeturl[
'content']);
1062 $pagecsscontent .=
'/* Content of file '.$urltograbbis.
' */'.
"\n";
1064 getAllImages($object, $objectpage, $urltograbbis, $tmpgeturl[
'content'], $action, 1, $grabimages, $grabimagesinto);
1067 include_once DOL_DOCUMENT_ROOT.
'/core/class/lessc.class.php';
1068 $lesscobj =
new Lessc();
1070 $contentforlessc =
".bodywebsite {\n".$tmpgeturl[
'content'].
"\n}\n";
1072 $contentforlessc = $lesscobj->compile($contentforlessc);
1075 $pagecsscontent .= $contentforlessc.
"\n";
1077 }
catch (exception $e) {
1079 dol_syslog(
"Failed to compile the CSS from URL ".$urltograbbis.
" with lessc: ".$e->getMessage(), LOG_WARNING);
1080 $pagecsscontent .= $tmpgeturl[
'content'].
"\n";
1083 $objectpage->htmlheader = preg_replace(
'/'.preg_quote($regs[0][$key],
'/').
'\n*/ims',
'', $objectpage->htmlheader);
1087 $pagecsscontent .=
'</style>';
1091 $objectpage->htmlheader .= trim($pagecsscontent).
"\n";
1095 $tmp = $objectpage->content;
1097 getAllImages($object, $objectpage, $urltograb, $tmp, $action, 1, $grabimages, $grabimagesinto);
1100 $tmp = preg_replace(
'/a href="\/([^\/"]+)\/([^\/"]+)"/',
'a href="/\1-\2.php"', $tmp);
1101 $tmp = preg_replace(
'/a href="\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)"/',
'a href="/\1-\2-\3.php"', $tmp);
1102 $tmp = preg_replace(
'/a href="\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)"/',
'a href="/\1-\2-\3-\4.php"', $tmp);
1105 $objectpage->content = $tmp;
1107 $objectpage->grabbed_from = $urltograb;
1111 $newaliasnames =
'';
1112 if (!$error &&
GETPOST(
'WEBSITE_ALIASALT',
'alpha')) {
1113 $arrayofaliastotest = explode(
',', str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_ALIASALT',
'alpha')));
1115 foreach ($arrayofaliastotest as $aliastotest) {
1116 $aliastotest = trim(preg_replace(
'/\.php$/i',
'', $aliastotest));
1119 if (preg_match(
'/^page\d+/i', $aliastotest)) {
1121 $langs->load(
"errors");
1123 $action =
'createcontainer';
1126 $result = $websitepagetemp->fetch(0,
$object->id, $aliastotest);
1129 $langs->load(
"errors");
1130 setEventMessages($websitepagetemp->error, $websitepagetemp->errors,
'errors');
1131 $action =
'createcontainer';
1136 $langs->load(
"errors");
1137 setEventMessages($langs->trans(
"ErrorAPageWithThisNameOrAliasAlreadyExists", $websitepagetemp->pageurl),
null,
'errors');
1138 $action =
'createcontainer';
1141 $newaliasnames .= ($newaliasnames ?
', ' :
'').$aliastotest;
1146 $objectpage->title = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_TITLE',
'alphanohtml'));
1147 $objectpage->type_container =
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'aZ09');
1148 $objectpage->pageurl =
GETPOST(
'WEBSITE_PAGENAME',
'alpha');
1149 $objectpage->aliasalt = $newaliasnames;
1150 $objectpage->description = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml'));
1151 $objectpage->lang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
1152 $objectpage->otherlang =
GETPOST(
'WEBSITE_OTHERLANG',
'aZ09comma');
1153 $objectpage->image =
GETPOST(
'WEBSITE_IMAGE',
'alpha');
1154 $objectpage->keywords = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_KEYWORDS',
'alphanohtml'));
1155 $objectpage->allowed_in_frames =
GETPOST(
'WEBSITE_ALLOWED_IN_FRAMES',
'aZ09') ? 1 : 0;
1156 $objectpage->htmlheader =
GETPOST(
'htmlheader',
'none');
1157 $objectpage->author_alias =
GETPOST(
'WEBSITE_AUTHORALIAS',
'alphanohtml');
1158 $objectpage->object_type =
GETPOST(
'WEBSITE_OBJECTCLASS');
1159 $objectpage->fk_object =
GETPOST(
'WEBSITE_OBJECTID');
1160 $substitutionarray = array();
1161 $substitutionarray[
'__WEBSITE_CREATED_BY__'] = $user->getFullName($langs);
1174 $pageidfortranslation = (
GETPOSTINT(
'pageidfortranslation') > 0 ?
GETPOSTINT(
'pageidfortranslation') : 0);
1175 if ($pageidfortranslation > 0) {
1178 $objectpagetmp->fetch($pageidfortranslation);
1179 if ($objectpagetmp->fk_page > 0) {
1180 $pageidfortranslation = $objectpagetmp->fk_page;
1183 $objectpage->fk_page = $pageidfortranslation;
1187 if (GETPOSTISSET(
'content')) {
1189 $content =
GETPOST(
'content',
'none');
1206 if (empty($objectpage->pageurl)) {
1207 $langs->load(
"errors");
1208 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WEBSITE_PAGENAME")),
null,
'errors');
1210 $action =
'createcontainer';
1211 } elseif (!preg_match(
'/^[a-z0-9\-\_]+$/i', $objectpage->pageurl)) {
1212 $langs->load(
"errors");
1213 setEventMessages($langs->transnoentities(
"ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities(
'WEBSITE_PAGENAME')),
null,
'errors');
1215 $action =
'createcontainer';
1217 if (empty($objectpage->title)) {
1218 $langs->load(
"errors");
1219 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WEBSITE_TITLE")),
null,
'errors');
1221 $action =
'createcontainer';
1223 if ($objectpage->fk_page > 0 && empty($objectpage->lang)) {
1224 $langs->load(
"errors");
1225 setEventMessages($langs->trans(
"ErrorLanguageRequiredIfPageIsTranslationOfAnother"),
null,
'errors');
1227 $action =
'createcontainer';
1229 if ($objectpage->fk_page > 0 && !empty($objectpage->lang)) {
1230 if ($objectpage->lang == $website->lang) {
1231 $langs->load(
"errors");
1232 setEventMessages($langs->trans(
"ErrorLanguageMustNotBeSourceLanguageIfPageIsTranslationOfAnother"),
null,
'errors');
1234 $action =
'createcontainer';
1241 $pageid = $objectpage->create($user);
1245 $action =
'createcontainer';
1251 $categoriesarray =
GETPOST(
'categories',
'array');
1252 $result = $objectpage->setCategories($categoriesarray);
1261 if (empty(
$object->fk_default_home)) {
1262 $object->fk_default_home = $pageid;
1263 $res =
$object->update($user);
1268 $filetpl = $pathofwebsite.
'/page'.$pageid.
'.tpl.php';
1271 $result =
dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper, $object);
1282 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
1283 $filetpl = $pathofwebsite.
'/page'.$objectpage->id.
'.tpl.php';
1288 setEventMessages(
'Failed to write file '.basename($filealias),
null,
'errors');
1297 $action =
'createcontainer';
1304 setEventMessages($langs->trans(
"PageAdded", $objectpage->pageurl),
null,
'mesgs');
1311 $pageid = $objectpage->id;
1316 $pathtomedias = DOL_DATA_ROOT.
'/medias';
1317 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
1319 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
1320 dol_mkdir(dirname($pathtomediasinwebsite));
1321 $result = symlink($pathtomedias, $pathtomediasinwebsite);
1334 $htmlheadercontent =
"<html>\n";
1335 $htmlheadercontent .= $htmlheadercontentdefault;
1336 $htmlheadercontent .=
"</html>";
1341 $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;}";
1346 $jscontent =
"/* JS content (all pages) */\n";
1351 $robotcontent =
"# Robot file. Generated with Dolibarr\nUser-agent: *\nAllow: /public/\nDisallow: /administrator/";
1356 $htaccesscontent =
"# Order allow,deny\n# Deny from all";
1361 $manifestjsoncontent =
"";
1366 $readmecontent =
"Website generated by Dolibarr ERP CRM";
1371 $licensecontent =
"MIT License";
1375 $action =
'preview';
1380if ($action ==
'confirm_deletesite' && $confirm ==
'yes' && $permissiontodelete) {
1389 $res =
$object->delete($user);
1396 if (
GETPOST(
'delete_also_js',
'alpha') ==
'on') {
1397 $pathofwebsitejs = DOL_DATA_ROOT.
'/medias/js/'.
$object->ref;
1401 if (
GETPOST(
'delete_also_medias',
'alpha') ==
'on') {
1402 $pathofwebsitemedias = DOL_DATA_ROOT.
'/medias/image/'.
$object->ref;
1412 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
1421if (GETPOSTISSET(
'pageid') && $action ==
'delete' && $permissiontodelete && !
GETPOST(
'file_manager')) {
1426 $res =
$object->fetch(0, $websitekey);
1429 $res = $objectpage->fetch($pageid,
$object->id);
1432 $res = $objectpage->delete($user);
1441 setEventMessages($langs->trans(
"PageDeleted", $objectpage->pageurl, $websitekey),
null,
'mesgs');
1443 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$websitekey);
1451if (!GETPOSTISSET(
'pageid')) {
1452 $objectclass =
'WebsitePage';
1456 if (!$error && ($massaction ==
'delete' || ($action ==
'delete' && $confirm ==
'yes')) && $permissiontodelete) {
1459 $objecttmp =
new $objectclass($db);
1461 foreach ($toselect as $toselectid) {
1462 $result = $objecttmp->fetch($toselectid);
1464 $result = $objecttmp->delete($user);
1493 if ($action ==
'delete') {
1494 $mode =
'replacesite';
1495 $action =
'replacesite';
1497 $containertype =
GETPOST(
'optioncontainertype',
'aZ09') !=
'-1' ?
GETPOST(
'optioncontainertype',
'aZ09') :
'';
1498 $langcode =
GETPOST(
'optionlanguage',
'aZ09');
1499 $otherfilters = array();
1501 $otherfilters[
'category'] =
GETPOSTINT(
'optioncategory');
1504 $listofpages =
getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters);
1509if ($action ==
'updatecss' && $usercanedit) {
1512 $action =
'editcss';
1514 $res =
$object->fetch(0, $websitekey);
1517 if (GETPOSTISSET(
'virtualhost')) {
1518 $tmpvirtualhost = preg_replace(
'/\/$/',
'',
GETPOST(
'virtualhost',
'alpha'));
1519 if ($tmpvirtualhost && !preg_match(
'/^http/', $tmpvirtualhost)) {
1521 setEventMessages($langs->trans(
'ErrorURLMustStartWithHttp', $langs->transnoentitiesnoconv(
"VirtualHost")),
null,
'errors');
1522 $action =
'editcss';
1526 $arrayotherlang = explode(
',',
GETPOST(
'WEBSITE_OTHERLANG',
'alphanohtml'));
1527 foreach ($arrayotherlang as $key => $val) {
1529 if (empty(trim($val))) {
1532 $arrayotherlang[$key] = substr(trim($val), 0, 2);
1535 $object->virtualhost = $tmpvirtualhost;
1537 $object->otherlang = implode(
',', $arrayotherlang);
1540 $result =
$object->update($user);
1544 $action =
'editcss';
1550 if (($_FILES[
'addedfile'][
"name"] !=
'')) {
1551 $uploadfolder = $conf->website->dir_output.
'/'.$websitekey;
1552 if ($_FILES[
'addedfile'][
'type'] !=
'image/png') {
1556 $filetoread = realpath(
dol_osencode($_FILES[
'addedfile'][
'tmp_name']));
1557 $filesize = getimagesize($filetoread);
1558 if ($filesize[0] != $filesize[1]) {
1560 setEventMessages($langs->trans(
'ErrorFaviconMustBeASquaredImage'), array(),
'errors');
1562 if (! $error && ($filesize[0] != 16 && $filesize[0] != 32 && $filesize[0] != 64)) {
1571 if (!GETPOSTISSET(
'updateandstay')) {
1572 $action =
'preview';
1574 $backtopage = preg_replace(
'/searchstring=[^&]*/',
'', $backtopage);
1575 header(
"Location: ".$backtopage);
1579 $action =
'editcss';
1598 $dataposted = trim(
GETPOST(
'WEBSITE_HTML_HEADER',
'restricthtmlallowlinkscript'));
1599 $dataposted = preg_replace(array(
'/<html>\n*/ims',
'/<\/html>\n*/ims'), array(
'',
''), $dataposted);
1600 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1603 $phpfullcodestringold =
'';
1607 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1609 if (!$errorphpcheck) {
1610 $htmlheadercontent =
'';
1622 $htmlheadercontent .= $dataposted.
"\n";
1637 $dataposted = trim(
GETPOST(
'WEBSITE_CSS_INLINE',
'none'));
1638 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1641 $phpfullcodestringold =
'';
1645 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1647 if (!$errorphpcheck) {
1650 $csscontent .=
"<?php // BEGIN PHP\n";
1651 $csscontent .=
'$websitekey=basename(__DIR__);'.
"\n";
1652 $csscontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded\n";
1653 $csscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
1654 $csscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
1655 $csscontent .=
"ob_start();\n";
1656 $csscontent .=
"if (! headers_sent()) { /* because file is included inline when in edit mode and we don't want warning */ \n";
1657 $csscontent .=
"header('Cache-Control: max-age=3600, public, must-revalidate');\n";
1658 $csscontent .=
"header('Content-type: text/css');\n";
1659 $csscontent .=
"}\n";
1660 $csscontent .=
"// END PHP ?>\n";
1662 $csscontent .= $dataposted.
"\n";
1664 $csscontent .=
'<?php // BEGIN PHP'.
"\n";
1665 $csscontent .=
'$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "css");'.
"\n";
1666 $csscontent .=
"// END PHP\n";
1668 dol_syslog(
"Save css content into ".$filecss);
1680 $dataposted = trim(
GETPOST(
'WEBSITE_JS_INLINE',
'none'));
1681 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1684 $phpfullcodestringold =
'';
1688 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1690 if (!$errorphpcheck) {
1693 $jscontent .=
"<?php // BEGIN PHP\n";
1694 $jscontent .=
'$websitekey=basename(__DIR__);'.
"\n";
1695 $jscontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded\n";
1696 $jscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
1697 $jscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
1698 $jscontent .=
"ob_start();\n";
1699 $jscontent .=
"header('Cache-Control: max-age=3600, public, must-revalidate');\n";
1700 $jscontent .=
"header('Content-type: application/javascript');\n";
1701 $jscontent .=
"// END PHP ?>\n";
1703 $jscontent .= $dataposted.
"\n";
1705 $jscontent .=
'<?php // BEGIN PHP'.
"\n";
1706 $jscontent .=
'$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "js");'.
"\n";
1707 $jscontent .=
"// END PHP\n";
1718 $dataposted = trim(
GETPOST(
'WEBSITE_ROBOT',
'nohtml'));
1719 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1722 $phpfullcodestringold =
'';
1726 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1728 if (!$errorphpcheck) {
1741 $robotcontent .= $dataposted.
"\n";
1756 $dataposted = trim(
GETPOST(
'WEBSITE_HTACCESS',
'nohtml'));
1757 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1760 $phpfullcodestringold =
'';
1764 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1766 if (!$errorphpcheck) {
1767 $htaccesscontent =
'';
1768 $htaccesscontent .= $dataposted.
"\n";
1780 $dataposted = trim(
GETPOST(
'WEBSITE_MANIFEST_JSON',
'restricthtmlallowunvalid'));
1781 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1784 $phpfullcodestringold =
'';
1788 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1790 if (!$errorphpcheck) {
1791 $manifestjsoncontent =
'';
1793 $manifestjsoncontent .=
"<?php // BEGIN PHP\n";
1794 $manifestjsoncontent .=
'$websitekey=basename(__DIR__);'.
"\n";
1795 $manifestjsoncontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded\n";
1796 $manifestjsoncontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
1797 $manifestjsoncontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
1798 $manifestjsoncontent .=
"ob_start();\n";
1799 $manifestjsoncontent .=
"header('Cache-Control: max-age=3600, public, must-revalidate');\n";
1800 $manifestjsoncontent .=
"header('Content-type: application/manifest+json');\n";
1801 $manifestjsoncontent .=
"// END PHP ?>\n";
1803 $manifestjsoncontent .= $dataposted.
"\n";
1805 $manifestjsoncontent .=
'<?php // BEGIN PHP'.
"\n";
1806 $manifestjsoncontent .=
'$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "manifest");'.
"\n";
1807 $manifestjsoncontent .=
"// END PHP\n";
1812 setEventMessages(
'Failed to write file '.$filemanifestjson,
null,
'errors');
1819 $dataposted = trim(
GETPOST(
'WEBSITE_README',
'nohtml'));
1820 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1823 $phpfullcodestringold =
'';
1827 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1829 if (!$errorphpcheck) {
1830 $readmecontent =
'';
1842 $readmecontent .= $dataposted.
"\n";
1858 $dataposted = trim(
GETPOST(
'WEBSITE_LICENSE',
'nohtml'));
1859 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1862 $phpfullcodestringold =
'';
1866 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1868 if (!$errorphpcheck) {
1869 $licensecontent =
'';
1881 $licensecontent .= $dataposted.
"\n";
1905 if (!GETPOSTISSET(
'updateandstay')) {
1906 $action =
'preview';
1908 $backtopage = preg_replace(
'/searchstring=[^&]*/',
'', $backtopage);
1909 header(
"Location: ".$backtopage);
1913 $action =
'editcss';
1920if ($action ==
'setashome' && $usercanedit) {
1922 $object->fetch(0, $websitekey);
1925 $object->fk_default_home = $pageid;
1926 $res =
$object->update($user);
1935 $filetpl = $pathofwebsite.
'/page'.$pageid.
'.tpl.php';
1938 $result =
dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper, $object);
1946 $action =
'preview';
1953if ($action ==
'updatemeta' && $usercanedit) {
1956 $result =
$object->fetch(0, $websitekey);
1959 $objectpage->fk_website =
$object->id;
1962 if (!preg_match(
'/^[a-z0-9\-\_]+$/i',
GETPOST(
'WEBSITE_PAGENAME',
'alpha'))) {
1964 $langs->load(
"errors");
1965 setEventMessages($langs->transnoentities(
"ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities(
'WEBSITE_PAGENAME')),
null,
'errors');
1966 $action =
'editmeta';
1969 $res = $objectpage->fetch($pageid,
$object->id);
1972 setEventMessages(
'Page not found '.$objectpage->error, $objectpage->errors,
'errors');
1976 if (!$error &&
GETPOST(
'WEBSITE_PAGENAME',
'alpha')) {
1978 $result = $websitepagetemp->fetch(-1 * $objectpage->id,
$object->id,
GETPOST(
'WEBSITE_PAGENAME',
'alpha'));
1981 $langs->load(
"errors");
1982 setEventMessages($websitepagetemp->error, $websitepagetemp->errors,
'errors');
1983 $action =
'editmeta';
1987 $langs->load(
"errors");
1988 setEventMessages($langs->trans(
"ErrorAPageWithThisNameOrAliasAlreadyExists", $websitepagetemp->pageurl),
null,
'errors');
1989 $action =
'editmeta';
1993 $newaliasnames =
'';
1994 if (!$error &&
GETPOST(
'WEBSITE_ALIASALT',
'alpha')) {
1995 $arrayofaliastotest = explode(
',', str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_ALIASALT',
'alpha')));
1998 foreach ($arrayofaliastotest as $aliastotest) {
1999 $aliastotest = trim(preg_replace(
'/\.php$/i',
'', $aliastotest));
2002 if (preg_match(
'/^page\d+/i', $aliastotest)) {
2004 $langs->load(
"errors");
2006 $action =
'editmeta';
2009 $result = $websitepagetemp->fetch(-1 * $objectpage->id,
$object->id, $aliastotest);
2012 $langs->load(
"errors");
2013 setEventMessages($websitepagetemp->error, $websitepagetemp->errors,
'errors');
2014 $action =
'editmeta';
2019 $langs->load(
"errors");
2020 setEventMessages($langs->trans(
"ErrorAPageWithThisNameOrAliasAlreadyExists", $websitepagetemp->pageurl),
null,
'errors');
2021 $action =
'editmeta';
2024 $newaliasnames .= ($newaliasnames ?
', ' :
'').$aliastotest;
2030 $objectpage->old_object = clone $objectpage;
2032 $objectpage->title = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_TITLE',
'alphanohtml'));
2033 $objectpage->type_container =
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'aZ09');
2034 $objectpage->pageurl =
GETPOST(
'WEBSITE_PAGENAME',
'alpha');
2035 $objectpage->aliasalt = $newaliasnames;
2036 $objectpage->lang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
2037 $objectpage->otherlang =
GETPOST(
'WEBSITE_OTHERLANG',
'aZ09comma');
2038 $objectpage->description = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml'));
2039 $objectpage->image =
GETPOST(
'WEBSITE_IMAGE',
'alpha');
2040 $objectpage->keywords = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_KEYWORDS',
'alphanohtml'));
2041 $objectpage->allowed_in_frames =
GETPOST(
'WEBSITE_ALLOWED_IN_FRAMES',
'aZ09') ? 1 : 0;
2042 $objectpage->htmlheader = trim(
GETPOST(
'htmlheader',
'restricthtmlallowlinkscript'));
2043 $objectpage->fk_page = (
GETPOSTINT(
'pageidfortranslation') > 0 ?
GETPOSTINT(
'pageidfortranslation') : 0);
2044 $objectpage->author_alias = trim(
GETPOST(
'WEBSITE_AUTHORALIAS',
'alphanohtml'));
2045 $objectpage->object_type =
GETPOST(
'WEBSITE_OBJECTCLASS',
'alpha');
2046 $objectpage->fk_object =
GETPOST(
'WEBSITE_OBJECTID',
'aZ09');
2049 if ($newdatecreation) {
2050 $objectpage->date_creation = $newdatecreation;
2053 $res = $objectpage->update($user);
2055 $langs->load(
"errors");
2056 if ($db->lasterrno ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
2058 $langs->load(
"errors");
2059 setEventMessages($langs->trans(
"ErrorAPageWithThisNameOrAliasAlreadyExists"),
null,
'errors');
2060 $action =
'editmeta';
2063 $langs->load(
"errors");
2065 $action =
'editmeta';
2072 $categoriesarray =
GETPOST(
'categories',
'array');
2073 $result = $objectpage->setCategories($categoriesarray);
2087 $filemaster = $pathofwebsite.
'/master.inc.php';
2088 $fileoldalias = $pathofwebsite.
'/'.$objectpage->old_object->pageurl.
'.php';
2089 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
2100 if (!empty($fileoldalias)) {
2101 dol_syslog(
"We delete old alias page name=".$fileoldalias.
" to build a new alias page=".$filealias);
2105 if (empty($objectpage->lang) || !in_array($objectpage->lang, explode(
',',
$object->otherlang))) {
2106 $dirname = dirname($fileoldalias);
2107 $filename = basename($fileoldalias);
2108 $sublangs = explode(
',',
$object->otherlang);
2109 foreach ($sublangs as $sublang) {
2113 if (empty(trim($sublang))) {
2116 $fileoldaliassub = $dirname.
'/'.$sublang.
'/'.$filename;
2122 if (!empty($objectpage->old_object->aliasalt)) {
2123 $tmpaltaliases = explode(
',', $objectpage->old_object->aliasalt);
2124 if (is_array($tmpaltaliases)) {
2125 foreach ($tmpaltaliases as $tmpaliasalt) {
2126 dol_syslog(
"We delete old alt alias pages name=".trim($tmpaliasalt));
2130 if (empty($objectpage->lang) || !in_array($objectpage->lang, explode(
',',
$object->otherlang))) {
2131 $dirname = dirname($pathofwebsite.
'/'.trim($tmpaliasalt).
'.php');
2132 $filename = basename($pathofwebsite.
'/'.trim($tmpaliasalt).
'.php');
2133 $sublangs = explode(
',',
$object->otherlang);
2134 foreach ($sublangs as $sublang) {
2138 if (empty(trim($sublang))) {
2141 $fileoldaliassub = $dirname.
'/'.$sublang.
'/'.$filename;
2155 if (!empty($objectpage->aliasalt)) {
2156 $tmpaltaliases = explode(
',', $objectpage->aliasalt);
2157 if (is_array($tmpaltaliases)) {
2158 foreach ($tmpaltaliases as $tmpaliasalt) {
2159 if (trim($tmpaliasalt)) {
2160 $filealias = $pathofwebsite.
'/'.trim($tmpaliasalt).
'.php';
2163 setEventMessages(
'Failed to write file '.basename($filealias),
null,
'errors');
2176 if (!GETPOSTISSET(
'updateandstay')) {
2179 $action =
'preview';
2181 $action =
'editmeta';
2187 $action =
'preview';
2193if ((($action ==
'updatesource' || $action ==
'updatecontent' || $action ==
'confirm_createfromclone' || $action ==
'confirm_createpagefromclone') || ($action ==
'preview' && (
GETPOST(
'refreshsite') ||
GETPOST(
'refreshpage') ||
GETPOST(
'preview')))) && $usercanedit) {
2194 $object->fetch(0, $websitekey);
2197 if ($action ==
'confirm_createfromclone') {
2200 $objectnew =
new Website($db);
2206 $action =
'preview';
2213 $pageid =
$object->fk_default_home;
2214 $websitekey =
GETPOST(
'siteref',
'aZ09');
2220 if ($action ==
'confirm_createpagefromclone') {
2221 $istranslation = (
GETPOST(
'is_a_translation',
'aZ09') ==
'on' ? 1 : 0);
2223 if ($istranslation) {
2224 if (
GETPOST(
'newlang',
'aZ09') == $objectpage->lang || !
GETPOST(
'newlang',
'aZ09')) {
2226 setEventMessages($langs->trans(
"LanguageMustNotBeSameThanClonedPage"),
null,
'errors');
2227 $action =
'preview';
2231 setEventMessages($langs->trans(
"WebsiteMustBeSameThanClonedPageIfTranslation"),
null,
'errors');
2232 $action =
'preview';
2240 $pathofwebsitenew = $pathofwebsite;
2242 $tmpwebsite =
new Website($db);
2243 if ($newwebsiteid > 0 && $newwebsiteid !=
$object->id) {
2244 $tmpwebsite->fetch($newwebsiteid);
2245 $pathofwebsitenew = $dolibarr_main_data_root.($conf->entity > 1 ?
'/'.$conf->entity :
'').
'/website/'.$tmpwebsite->ref;
2251 $resultpage = $objectpage->createFromClone($user, $pageid,
GETPOST(
'newpageurl',
'aZ09'), (
GETPOST(
'newlang',
'aZ09') ?
GETPOST(
'newlang',
'aZ09') :
''), $istranslation, $newwebsiteid,
GETPOST(
'newtitle',
'alphanohtml'), $tmpwebsite);
2252 if ($resultpage < 0) {
2255 $action =
'createpagefromclone';
2259 $filetpl = $pathofwebsitenew.
'/page'.$resultpage->id.
'.tpl.php';
2260 $fileindex = $pathofwebsitenew.
'/index.php';
2261 $filewrapper = $pathofwebsitenew.
'/wrapper.php';
2270 if (empty($newwebsiteid) || $newwebsiteid ==
$object->id) {
2271 $pageid = $resultpage->id;
2283 $pathtomedias = DOL_DATA_ROOT.
'/medias';
2284 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
2286 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
2287 dol_mkdir(dirname($pathtomediasinwebsite));
2288 $result = symlink($pathtomedias, $pathtomediasinwebsite);
2297 $objectpage->fk_website =
$object->id;
2300 $res = $objectpage->fetch($pageid);
2303 if (
$object->fk_default_home > 0) {
2304 $res = $objectpage->fetch(
$object->fk_default_home);
2307 $res = $objectpage->fetch(0,
$object->id);
2312 if (!$error && $res > 0) {
2313 if ($action ==
'updatesource' || $action ==
'updatecontent') {
2318 $objectpage->content =
GETPOST(
'PAGE_CONTENT',
'none');
2323 $error =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
2326 if ($action ==
'updatesource') {
2327 $action =
'editsource';
2329 if ($action ==
'updatecontent') {
2330 $action =
'editcontent';
2335 $objectpage->content = preg_replace(
'/<head>.*<\/head>/ims',
'', $objectpage->content);
2339 $res = $objectpage->update($user);
2343 if ($action ==
'updatesource') {
2344 $action =
'editsource';
2346 if ($action ==
'updatecontent') {
2347 $action =
'editcontent';
2354 $filemaster = $pathofwebsite.
'/master.inc.php';
2356 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
2364 setEventMessages(
'Failed to write the master file file '.$filemaster,
null,
'errors');
2388 setEventMessages(
'Failed to write the alias file '.basename($filealias),
null,
'errors');
2396 if (!GETPOSTISSET(
'updateandstay')) {
2398 header(
"Location: ".$backtopage);
2401 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$websitekey.
'&pageid='.$pageid);
2405 if ($action ==
'updatesource') {
2406 $action =
'editsource';
2408 if ($action ==
'updatecontent') {
2409 $action =
'editcontent';
2414 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$websitekey.
'&pageid='.$pageid);
2421 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$websitekey.
'&pageid='.$pageid);
2426 if (empty($websitekey) || $websitekey ==
'-1') {
2427 setEventMessages($langs->trans(
"NoWebSiteCreateOneFirst"),
null,
'warnings');
2430 setEventMessages($langs->trans(
"YouCanCreatePageOrImportTemplate"),
null,
'warnings');
2436if ($action ==
'deletelang' && $usercanedit) {
2437 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"website_page SET fk_page = NULL";
2438 $sql .=
" WHERE rowid = ".GETPOSTINT(
'deletelangforid');
2441 $resql = $db->query($sql);
2445 $objectpage->fk_page =
null;
2448 $action =
'editmeta';
2453if ($action ==
'exportsite' && $user->hasRight(
'website',
'export')) {
2454 $fileofzip =
$object->exportWebSite();
2457 $file_name = basename($fileofzip);
2458 header(
"Content-Type: application/zip");
2459 header(
"Content-Disposition: attachment; filename=".$file_name);
2460 header(
"Content-Length: ".filesize($fileofzip));
2462 readfile($fileofzip);
2466 $action =
'preview';
2471if ($action ==
'overwritesite' && $user->hasRight(
'website',
'export')) {
2473 $fileofzip =
$object->exportWebSite();
2474 $pathToExport =
GETPOST(
'export_path');
2476 $object->overwriteTemplate($fileofzip, $pathToExport);
2483if ($action ==
'regeneratesite' && $usercanedit) {
2485 $pathtomedias = DOL_DATA_ROOT.
'/medias';
2486 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
2488 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
2489 dol_mkdir(dirname($pathtomediasinwebsite));
2490 $result = symlink($pathtomedias, $pathtomediasinwebsite);
2492 $langs->load(
"errors");
2493 setEventMessages($langs->trans(
"ErrorFailedToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias),
null,
'errors');
2494 $action =
'preview';
2498 $result =
$object->rebuildWebSiteFiles();
2500 setEventMessages($langs->trans(
"PagesRegenerated", $result),
null,
'mesgs');
2501 $action =
'preview';
2504 $action =
'preview';
2509if ($action ==
'importsiteconfirm' && $usercanedit) {
2510 $dolibarrdataroot = preg_replace(
'/([\\/]+)$/i',
'', DOL_DATA_ROOT);
2511 $allowimportsite =
true;
2512 if (
dol_is_file($dolibarrdataroot.
'/installmodules.lock')) {
2513 $allowimportsite =
false;
2516 if ($allowimportsite) {
2517 if (empty($_FILES) && !GETPOSTISSET(
'templateuserfile')) {
2518 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"File")),
null,
'errors');
2519 $action =
'importsite';
2521 if (!empty($_FILES) || GETPOSTISSET(
'templateuserfile')) {
2523 $pathtomedias = DOL_DATA_ROOT.
'/medias';
2524 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
2526 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
2527 dol_mkdir(dirname($pathtomediasinwebsite));
2528 $result = symlink($pathtomedias, $pathtomediasinwebsite);
2530 $langs->load(
"errors");
2531 setEventMessages($langs->trans(
"ErrorFailedToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias),
null,
'errors');
2532 $action =
'importsite';
2537 if (GETPOSTISSET(
'templateuserfile')) {
2539 $fileofzip = DOL_DATA_ROOT.
'/doctemplates/websites/'.
GETPOST(
'templateuserfile',
'alpha');
2540 } elseif (!empty($_FILES) && is_array($_FILES[
'userfile'])) {
2542 if (is_array($_FILES[
'userfile'][
'tmp_name'])) {
2543 $userfiles = $_FILES[
'userfile'][
'tmp_name'];
2545 $userfiles = array($_FILES[
'userfile'][
'tmp_name']);
2549 foreach ($userfiles as $key => $userfile) {
2550 if (empty($_FILES[
'userfile'][
'tmp_name'][$key])) {
2552 if ($_FILES[
'userfile'][
'error'][$key] == 1 || $_FILES[
'userfile'][
'error'][$key] == 2) {
2554 $action =
'importsite';
2556 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"File")),
null,
'errors');
2557 $action =
'importsite';
2564 $upload_dir = DOL_DATA_ROOT.
'/doctemplates/websites/';
2578 $action =
'importsite';
2581 if (!$error && GETPOSTISSET(
'templateuserfile')) {
2582 $templatewithoutzip = preg_replace(
'/\.zip$/i',
'',
GETPOST(
'templateuserfile'));
2583 $object->setTemplateName($templatewithoutzip);
2585 $result =
$object->importWebSite($fileofzip);
2589 $action =
'importsite';
2592 dolibarr_set_const($db,
'WEBSITE_SUBCONTAINERSINLINE', 1,
'chaine', 0,
'', $conf->entity);
2594 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.
$object->ref);
2603 $message = $langs->trans(
'InstallModuleFromWebHasBeenDisabledContactUs');
2606 $message = $langs->trans(
"InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.
'/installmodules.lock');
2612$domainname =
'0.0.0.0:8080';
2613$tempdir = $conf->website->dir_output.
'/'.$websitekey.
'/';
2616if ($action ==
'generatesitemaps' && $usercanedit) {
2618 if ($website->virtualhost) {
2619 $domainname = $website->virtualhost;
2621 if (! preg_match(
'/^http/i', $domainname)) {
2622 $domainname =
'https://'.$domainname;
2625 $domtree =
new DOMDocument(
'1.0',
'UTF-8');
2627 $root = $domtree->createElementNS(
'http://www.sitemaps.org/schemas/sitemap/0.9',
'urlset');
2628 $root->setAttributeNS(
'http://www.w3.org/2000/xmlns/',
'xmlns:xhtml',
'http://www.w3.org/1999/xhtml');
2630 $domtree->formatOutput =
true;
2633 $xmlname =
'sitemap.xml';
2635 $sql =
"SELECT wp.rowid, wp.type_container , wp.pageurl, wp.lang, wp.fk_page, wp.tms as tms,";
2636 $sql .=
" w.virtualhost, w.fk_default_home";
2637 $sql .=
" FROM ".MAIN_DB_PREFIX.
"website_page as wp, ".MAIN_DB_PREFIX.
"website as w";
2638 $sql .=
" WHERE wp.type_container IN ('page', 'blogpost')";
2639 $sql .=
" AND wp.fk_website = w.rowid";
2640 $sql .=
" AND wp.status = ".WebsitePage::STATUS_VALIDATED;
2641 $sql .=
" AND wp.pageurl NOT IN ('404', '500', '501', '503')";
2642 $sql .=
" AND w.ref = '".dol_escape_json($websitekey).
"'";
2643 $sql .=
" ORDER BY wp.tms DESC, wp.rowid DESC";
2644 $resql = $db->query($sql);
2646 $num_rows = $db->num_rows($resql);
2647 if ($num_rows > 0) {
2649 while ($i < $num_rows) {
2650 $objp = $db->fetch_object($resql);
2651 $url = $domtree->createElement(
'url');
2653 $shortlangcode =
'';
2655 $shortlangcode = substr($objp->lang, 0, 2);
2657 if (empty($shortlangcode)) {
2658 $shortlangcode = substr(
$object->lang, 0, 2);
2662 if ($objp->type_container ==
'blogpost') {
2667 $pageurl = $objp->pageurl.
'.php';
2668 if ($objp->fk_default_home == $objp->rowid) {
2671 if ($shortlangcode != substr(
$object->lang, 0, 2)) {
2672 $pageurl = $shortlangcode.
'/'.$pageurl;
2679 $loc = $domtree->createElement(
'loc', $domainname.
'/'.$pageurl);
2680 $lastmod = $domtree->createElement(
'lastmod',
dol_print_date($db->jdate($objp->tms),
'dayrfc',
'gmt'));
2681 $priority = $domtree->createElement(
'priority',
'1');
2683 $url->appendChild($loc);
2684 $url->appendChild($lastmod);
2687 $changefreq = $domtree->createElement(
'changefreq',
'weekly');
2688 $url->appendChild($changefreq);
2691 if ($objp->fk_default_home == $objp->rowid) {
2692 $url->appendChild($priority);
2697 $alternatefound = 0;
2700 $translationof = $objp->fk_page;
2701 if ($translationof) {
2703 $tmppage->fetch($translationof);
2704 if ($tmppage->id > 0) {
2705 $tmpshortlangcode =
'';
2706 if ($tmppage->lang) {
2707 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'', $tmppage->lang);
2709 if (empty($tmpshortlangcode)) {
2710 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'',
$object->lang);
2712 if ($tmpshortlangcode != $shortlangcode) {
2713 $xhtmllink = $domtree->createElement(
'xhtml:link',
'');
2714 $xhtmllink->setAttribute(
"rel",
"alternate");
2715 $xhtmllink->setAttribute(
"hreflang", $tmpshortlangcode);
2716 $xhtmllink->setAttribute(
"href", $domainname.($objp->fk_default_home == $tmppage->id ?
'/' : (($tmpshortlangcode != substr(
$object->lang, 0, 2)) ?
'/'.$tmpshortlangcode :
'').
'/'.$tmppage->pageurl.
'.php'));
2717 $url->appendChild($xhtmllink);
2725 $sql =
'SELECT rowid as id, lang, pageurl from '.MAIN_DB_PREFIX.
'website_page';
2726 $sql .=
" WHERE status = ".((int) WebsitePage::STATUS_VALIDATED).
' AND fk_page IN ('.$db->sanitize($objp->rowid.($translationof ?
", ".$translationof :
"")).
")";
2727 $resqlhastrans = $db->query($sql);
2728 if ($resqlhastrans) {
2729 $num_rows_hastrans = $db->num_rows($resqlhastrans);
2730 if ($num_rows_hastrans > 0) {
2731 while ($objhastrans = $db->fetch_object($resqlhastrans)) {
2732 $tmpshortlangcode =
'';
2733 if ($objhastrans->lang) {
2734 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'', $objhastrans->lang);
2736 if ($tmpshortlangcode != $shortlangcode) {
2737 $xhtmllink = $domtree->createElement(
'xhtml:link',
'');
2738 $xhtmllink->setAttribute(
"rel",
"alternate");
2739 $xhtmllink->setAttribute(
"hreflang", $tmpshortlangcode);
2740 $xhtmllink->setAttribute(
"href", $domainname.($objp->fk_default_home == $objhastrans->id ?
'/' : (($tmpshortlangcode != substr(
$object->lang, 0, 2) ?
'/'.$tmpshortlangcode :
'')).
'/'.$objhastrans->pageurl.
'.php'));
2741 $url->appendChild($xhtmllink);
2751 if ($alternatefound) {
2753 $xhtmllink = $domtree->createElement(
'xhtml:link',
'');
2754 $xhtmllink->setAttribute(
"rel",
"alternate");
2755 $xhtmllink->setAttribute(
"hreflang", $shortlangcode);
2756 $xhtmllink->setAttribute(
"href", $domainname.
'/'.$pageurl);
2757 $url->appendChild($xhtmllink);
2773 $root->appendChild($url);
2779 if ($addrsswrapper &&
getDolGlobalInt(
'WEBSITE_ADD_RSS_FEED_INTO_SITEMAP')) {
2780 $url = $domtree->createElement(
'url');
2782 $pageurl =
'wrapper.php?rss=1';
2785 $loc = $domtree->createElement(
'loc', $domainname.
'/'.$pageurl);
2786 $lastmod = $domtree->createElement(
'lastmod',
dol_print_date($db->jdate(
dol_now()),
'dayrfc',
'gmt'));
2788 $url->appendChild($loc);
2789 $url->appendChild($lastmod);
2792 $changefreq = $domtree->createElement(
'changefreq',
'weekly');
2793 $url->appendChild($changefreq);
2796 $root->appendChild($url);
2799 $domtree->appendChild($root);
2801 if ($domtree->save($tempdir.$xmlname)) {
2803 setEventMessages($langs->trans(
"SitemapGenerated", $xmlname),
null,
'mesgs');
2813 $robotcontent = @file_get_contents($filerobot);
2814 $result = preg_replace(
'/<?php \/\/ BEGIN PHP[^?]END PHP ?>\n/ims',
'', $robotcontent);
2816 $robotcontent = $result;
2818 $robotsitemap =
"Sitemap: ".$domainname.
"/".$xmlname;
2819 $result = strpos($robotcontent,
'Sitemap: ');
2821 $result = preg_replace(
'/Sitemap:.*/', $robotsitemap, $robotcontent);
2822 $robotcontent = $result ? $result : $robotcontent;
2824 $robotcontent .= $robotsitemap.
"\n";
2831 $action =
'preview';
2839$form =
new Form($db);
2846if ($action ==
'confirmgeneratesitemaps') {
2847 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?website='.urlencode($website->ref), $langs->trans(
'ConfirmSitemapsCreation'), $langs->trans(
'ConfirmGenerateSitemaps',
$object->ref),
'generatesitemaps',
'',
"yes", 1);
2848 $action =
'preview';
2850$helpurl =
'EN:Module_Website|FR:Module_Website_FR|ES:Módulo_Website';
2853 '/includes/ace/src/ace.js',
2854 '/includes/ace/src/ext-statusbar.js',
2855 '/includes/ace/src/ext-language_tools.js',
2859$arrayofcss = array();
2864$arrayofjs[] =
'includes/jquery/plugins/blockUI/jquery.blockUI.js';
2865$arrayofjs[] =
'core/js/blockUI.js';
2867 $arrayofjs[] =
"includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js";
2870$moreheadjs .=
'<script type="text/javascript">'.
"\n";
2871$moreheadjs .=
'var indicatorBlockUI = \''.DOL_URL_ROOT.
"/theme/".$conf->theme.
"/img/working.gif".
'\';
'."\n";
2872$moreheadjs .= '</script>
'."\n";
2874llxHeader($moreheadcss.$moreheadjs, $langs->trans("Website").(empty($website->ref) ? '' : ' -
'.$website->ref), $helpurl, '', 0, 0, $arrayofjs, $arrayofcss, '', 'mod-website page-index
', '<!-- Begin div
class=
"fiche" -->
'."\n".'<div
class=
"fichebutwithotherclass">
');
2877print '<!-- Open form
for all page -->
'."\n";
2878print '<form action=
"'.$_SERVER["PHP_SELF
"].($action == 'file_manager' ? '?uploadform=1' : '').'" method=
"POST" enctype=
"multipart/form-data" class=
"websiteformtoolbar">
';
2879print '<input
type=
"hidden" name=
"token" value=
"'.newToken().'">
';
2880print '<input
type=
"hidden" name=
"backtopage" value=
"'.$backtopage.'">
';
2881print '<input
type=
"hidden" name=
"dol_openinpopup" value=
"'.$dol_openinpopup.'">
';
2883if ($action == 'createsite
') {
2884 print '<input
type=
"hidden" name=
"action" value=
"addsite">
';
2886if ($action == 'createcontainer
') {
2887 print '<input
type=
"hidden" name=
"action" value=
"addcontainer">
';
2889if ($action == 'editcss
') {
2890 print '<input
type=
"hidden" name=
"action" value=
"updatecss">
';
2892if ($action == 'editmenu
') {
2893 print '<input
type=
"hidden" name=
"action" value=
"updatemenu">
';
2895if ($action == 'setashome
') {
2896 print '<input
type=
"hidden" name=
"action" value=
"updateashome">
';
2898if ($action == 'editmeta
') {
2899 print '<input
type=
"hidden" name=
"action" value=
"updatemeta">
';
2901if ($action == 'editsource
') {
2902 print '<input
type=
"hidden" name=
"action" value=
"updatesource">
';
2904if ($action == 'editcontent
') {
2905 print '<input
type=
"hidden" name=
"action" value=
"updatecontent">
';
2907if ($action == 'edit
') {
2908 print '<input
type=
"hidden" name=
"action" value=
"update">
';
2910if ($action == 'importsite
') {
2911 print '<input
type=
"hidden" name=
"action" value=
"importsiteconfirm">
';
2913if ($action == 'file_manager
') {
2914 print '<input
type=
"hidden" name=
"action" value=
"file_manager">
';
2917 print '<input
type=
"hidden" name=
"mode" value=
"'.$mode.'">
';
2922// Add a margin under toolbar ?
2924if ($action != 'preview
' && $action != 'editcontent
' && $action != 'editsource
' && !GETPOST('createpagefromclone
', 'alphanohtml
')) {
2925 $style = ' margin-bottom: 5px;
';
2929if (!GETPOST('hide_websitemenu
')) {
2931 if (!$user->hasRight('website
', 'write
')) {
2932 $disabled = ' disabled=
"disabled"';
2934 $disabledexport = '';
2935 if (!$user->hasRight('website
', 'export
')) {
2936 $disabledexport = ' disabled=
"disabled"';
2941 $dataroot = DOL_DATA_ROOT.($conf->entity > 1 ? '/
'.$conf->entity : '').'/website/
'.$websitekey;
2942 if (!empty($object->virtualhost)) {
2943 $virtualurl = $object->virtualhost;
2948 if ($object->id > 0) {
2949 $array = $objectpage->fetchAll($object->id, 'ASC,ASC
', 'type_container,pageurl
');
2950 $object->lines = $array;
2952 if (!is_array($array) && $array < 0) {
2953 dol_print_error(null, $objectpage->error, $objectpage->errors);
2955 $atleastonepage = (is_array($array) && count($array) > 0);
2957 $websitepage = new WebsitePage($db);
2959 $websitepage->fetch($pageid);
2963 //var_dump($objectpage);exit;
2964 print '<div
class=
"centpercent websitebar'.(GETPOST('dol_openinpopup', 'aZ09') ? ' hiddenforpopup' : '').'">
';
2967 // Toolbar for websites
2970 print '<!-- Toolbar
for website -->
';
2971 if ($action != 'file_manager
') {
2972 print '<div
class=
"websiteselection hideonsmartphoneimp minwidth75 tdoverflowmax100 inline-block">
';
2973 print $langs->trans("Website").':
';
2976 // Button Add new website
2977 $urltocreatenewwebsite = $_SERVER["PHP_SELF"].'?action=createsite
';
2978 print '<span
class=
"websiteselection paddingrightonly">
';
2979 print '<a href=
"'.$urltocreatenewwebsite.'" class=
""'.$disabled.' title=
"'.dol_escape_htmltag($langs->trans("AddWebsite
")).'"><span
class=
"fa fa-plus-circle valignmiddle btnTitle-icon"><span></a>
';
2983 print '<span
class=
"websiteselection nopaddingrightimp">
';
2986 $out .= '<select
name=
"website" class=
"minwidth100 width200 maxwidth150onsmartphone" id=
"website">
';
2987 if (empty($listofwebsites)) {
2988 $out .= '<option value=
"-1"> </option>
';
2991 // Loop on each sites
2993 foreach ($listofwebsites as $key => $valwebsite) {
2994 if (empty($websitekey)) {
2995 if ($action != 'createsite
') {
2996 $websitekey = $valwebsite->ref;
3000 $out .= '<option value=
"'.$valwebsite->ref.'"';
3001 if ($websitekey == $valwebsite->ref) {
3002 $out .= ' selected
'; // To preselect a value
3004 //$outoption = $valwebsite->getLibStatut(3).' '.$valwebsite->ref.' ';
3005 $outoption = (($valwebsite->status == $valwebsite::STATUS_DRAFT) ? '<span
class=
"opacitymedium">
' : '').$valwebsite->ref.(($valwebsite->status == $valwebsite::STATUS_DRAFT) ? '</span>
' : '');
3006 $out .= ' data-html=
"'.dol_escape_htmltag($outoption).'"';
3008 $out .= $valwebsite->ref;
3009 $out .= '</option>
';
3012 $out .= '</select>
';
3013 $out .= ajax_combobox('website
');
3015 if (!empty($conf->use_javascript_ajax)) {
3016 $out .= '<script
type=
"text/javascript">
';
3017 $out .= 'jQuery(document).ready(
function () {
';
3018 $out .= ' jQuery(
"#website").change(
function () {
';
3019 $out .= ' console.log(
"We select "+jQuery(
"#website option:selected").val());
';
3020 $out .= ' if (jQuery(
"#website option:selected").val() == \
'-2\') {';
3021 $out .=
' window.location.href = "'.dol_escape_js($urltocreatenewwebsite).
'";';
3022 $out .=
' } else {';
3023 $out .=
' window.location.href = "'.$_SERVER[
"PHP_SELF"].
'?website="+jQuery("#website option:selected").val();';
3027 $out .=
'</script>';
3034 if (!empty($conf->use_javascript_ajax)) {
3035 print
'<span class="websiteselection">';
3040 if ($website->status == $website::STATUS_DRAFT) {
3041 $text_off =
'Offline';
3042 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>';
3044 $text_off =
'Online';
3045 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>';
3051 if (empty($conf->use_javascript_ajax)) {
3052 print
'<span class="websiteselection">';
3053 print
'<input type="image" class="valignmiddle" src="'.img_picto(
'',
'refresh',
'', 0, 1).
'" name="refreshsite" value="'.$langs->trans(
"Load").
'">';
3058 print
'<span class="websiteselection">';
3060 if ($websitekey && $websitekey !=
'-1' && ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite')) {
3062 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>';
3065 $importlabel = $langs->trans(
"ImportSite");
3066 $exportlabel = $langs->trans(
"ExportSite");
3067 if (!empty($conf->dol_optimize_smallscreen)) {
3068 $importlabel = $langs->trans(
"Import");
3069 $exportlabel = $langs->trans(
"Export");
3072 if ($atleastonepage) {
3073 print
'<input type="submit" class="button bordertransp" disabled="disabled" value="'.dol_escape_htmltag($importlabel).
'" name="importsite">';
3075 print
'<input type="submit" class="button bordertransp"'.$disabled.
' value="'.
dol_escape_htmltag($importlabel).
'" name="importsite">';
3079 $extraCssClass =
getDolGlobalString(
'WEBSITE_ALLOW_OVERWRITE_GIT_SOURCE') ?
'hideobject' :
'';
3080 print
'<input type="submit" class="button bordertransp ' . $extraCssClass .
'" ' . $disabledexport .
' value="' .
dol_escape_htmltag($exportlabel) .
'" name="exportsite">';
3084 $overwriteGitUrl = $_SERVER[
"PHP_SELF"] .
'?action=overwritesite&website=' . urlencode($website->ref);
3085 print
dolButtonToOpenExportDialog(
'exportpopup', $langs->trans(
'ExportOptions'), $langs->trans(
'ExportSite'),
'exportsite', $overwriteGitUrl, $website);
3090 print
'<input type="submit" class="button bordertransp"'.$disabled.
' value="'.
dol_escape_htmltag($langs->trans(
"CloneSite")).
'" name="createfromclone">';
3093 if (!$permissiontodelete) {
3094 $disabled =
' disabled="disabled"';
3095 $title = $langs->trans(
"NotEnoughPermissions");
3098 if ($website->status == $website::STATUS_VALIDATED) {
3099 $disabled =
' disabled="disabled"';
3100 $title = $langs->trans(
"WebsiteMustBeDisabled", $langs->transnoentitiesnoconv($website->LibStatut(0, 0)));
3104 $title = $langs->trans(
"Delete");
3105 $url = $_SERVER[
"PHP_SELF"].
'?action=deletesite&token='.
newToken().
'&website='.urlencode($website->ref);
3108 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>';
3111 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>';
3114 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>';
3117 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=replacesite&token='.
newToken().
'&website='.urlencode($website->ref).
'" class="button bordertransp"'.$disabled.
' title="'.
dol_escape_htmltag($langs->trans(
"ReplaceWebsiteContent")).
'"><span class="fa fa-search"></span></a>';
3122 if ($websitekey && $websitekey !=
'-1' && ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite')) {
3123 print
'<span class="websiteselection">';
3125 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);
3127 if (isModEnabled(
'category')) {
3129 print
dolButtonToOpenUrlInDialogPopup(
'categories', $langs->transnoentitiesnoconv(
"Categories"),
'<span class="fa fa-tags"></span>',
'/categories/index.php?leftmenu=website&nosearch=1&type='.urlencode(Categorie::TYPE_WEBSITE_PAGE).
'&website='.urlencode($website->ref), $disabled);
3135 print
'<input type="hidden" name="website" id="website" value="'.$websitekey.
'">';
3139 print
'<span class="websitetools">';
3141 if ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite') {
3142 $urlext = $virtualurl;
3143 $urlint = $urlwithroot.
'/public/website/index.php?website='.$websitekey;
3145 print
'<span class="websiteinputurl valignmiddle" id="websiteinputurl">';
3146 $linktotestonwebserver =
'<a href="'.($virtualurl ? $virtualurl :
'#').
'" class="valignmiddle">';
3147 $linktotestonwebserver .=
'<span class="hideonsmartphone paddingrightonly">'.$langs->trans(
"TestDeployOnWeb", $virtualurl).
'</span>'.
img_picto(
'',
'globe');
3148 $linktotestonwebserver .=
'</a>';
3151 if (empty(
$object->fk_default_home)) {
3152 $htmltext .=
'<br><span class="error">'.$langs->trans(
"YouMustDefineTheHomePage").
'</span><br><br>';
3153 } elseif (empty($virtualurl)) {
3156 $htmltext .=
'<br><center>'.$langs->trans(
"GoTo").
' <a href="'.$virtualurl.
'" target="_website">'.$virtualurl.
'</a></center><br>';
3159 $htmltext .=
'<!-- Message defined translate key set into WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER -->';
3160 $htmltext .=
'<br>'.$langs->trans(
getDolGlobalString(
'WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER'));
3162 $htmltext .= $langs->trans(
"ToDeployYourWebsiteOnLiveYouHave3Solutions").
'<br><br>';
3163 $htmltext .=
'<div class="titre inline-block">1</div> - '.$langs->trans(
"SetHereVirtualHost", $dataroot);
3164 $htmltext .=
'<br>';
3165 $htmltext .=
'<br>'.$langs->trans(
"CheckVirtualHostPerms", $langs->transnoentitiesnoconv(
"ReadPerm"), DOL_DOCUMENT_ROOT);
3166 $htmltext .=
'<br>'.$langs->trans(
"CheckVirtualHostPerms", $langs->transnoentitiesnoconv(
"WritePerm"),
'{s1}');
3167 $htmltext = str_replace(
'{s1}', DOL_DATA_ROOT.
'/website<br>'.DOL_DATA_ROOT.
'/medias', $htmltext);
3169 $examplewithapache =
"<VirtualHost *:80>\n";
3170 $examplewithapache .=
'#php_admin_value open_basedir /tmp/:'.DOL_DOCUMENT_ROOT.
':'.DOL_DATA_ROOT.
':/dev/urandom'.
"\n";
3171 $examplewithapache .=
"\n";
3172 $examplewithapache .=
'DocumentRoot "'.DOL_DOCUMENT_ROOT.
'"'.
"\n";
3173 $examplewithapache .=
"\n";
3174 $examplewithapache .=
'<Directory "'.DOL_DOCUMENT_ROOT.
'">'.
"\n";
3175 $examplewithapache .=
'AllowOverride FileInfo Options
3176 Options -Indexes -MultiViews -FollowSymLinks -ExecCGI
3178 </Directory>'.
"\n".
'
3179 <Directory "'.DOL_DATA_ROOT.
'/website">
3180 AllowOverride FileInfo Options
3181 Options -Indexes -MultiViews +FollowSymLinks -ExecCGI
3183 </Directory>'.
"\n".
'
3184 <Directory "'.DOL_DATA_ROOT.
'/medias">
3185 AllowOverride FileInfo Options
3186 Options -Indexes -MultiViews -FollowSymLinks -ExecCGI
3190 $examplewithapache .=
"\n";
3191 $examplewithapache .=
"#ErrorLog /var/log/apache2/".$websitekey.
"_error_log\n";
3192 $examplewithapache .=
"#TransferLog /var/log/apache2/".$websitekey.
"_access_log\n";
3194 $examplewithapache .=
"</VirtualHost>\n";
3196 $htmltext .=
'<br>'.$langs->trans(
"ExampleToUseInApacheVirtualHostConfig").
':<br>';
3197 $htmltext .=
'<div class="quatrevingtpercent exampleapachesetup wordbreak" spellcheck="false">'.dol_nl2br(
dol_escape_htmltag($examplewithapache, 1, 1)).
'</div>';
3199 $htmltext .=
'<br>';
3200 $htmltext .=
'<div class="titre inline-block">2</div> - '.$langs->trans(
"YouCanAlsoTestWithPHPS");
3201 $htmltext .=
'<br><div class="urllink"><input type="text" id="cliphpserver" spellcheck="false" class="quatrevingtpercent" value="php -S 0.0.0.0:8080 -t '.$dataroot.
'"></div>';
3203 $htmltext .=
'<br>';
3204 $htmltext .=
'<div class="titre inline-block">3</div> - '.$langs->trans(
"YouCanAlsoDeployToAnotherWHP");
3206 print $form->textwithpicto($linktotestonwebserver, $htmltext, 1,
'none',
'valignmiddle', 0, 3,
'helpvirtualhost');
3210 if (in_array($action, array(
'editcss',
'editmenu',
'file_manager',
'replacesiteconfirm')) || in_array($mode, array(
'replacesite'))) {
3211 if ($action ==
'editcss') {
3214 $stringforfirstkey = $langs->trans(
"KeyboardShortcut");
3215 if ($conf->browser->name ==
'chrome') {
3216 $stringforfirstkey .=
' ALT +';
3217 } elseif ($conf->browser->name ==
'firefox') {
3218 $stringforfirstkey .=
' ALT + SHIFT +';
3220 $stringforfirstkey .=
' CTL +';
3223 print
'<input type="submit" accesskey="s" title="'.dol_escape_htmltag($stringforfirstkey.
' s').
'" id="savefileandstay" class="button buttonforacesave hideonsmartphone small" value="'.
dol_escape_htmltag($langs->trans(
"SaveAndStay")).
'" name="updateandstay">';
3225 if (preg_match(
'/^create/', $action) && $action !=
'file_manager' && $action !=
'replacesite' && $action !=
'replacesiteconfirm') {
3226 print
'<input type="submit" id="savefile" class="button buttonforacesave button-save small" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
3228 if (preg_match(
'/^edit/', $action) && $action !=
'file_manager' && $action !=
'replacesite' && $action !=
'replacesiteconfirm') {
3229 print
'<input type="submit" id="savefile" class="button buttonforacesave button-save small" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
3231 if ($action !=
'preview') {
3232 print
'<input type="submit" class="button button-cancel small" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'" name="cancel">';
3242 if ($websitekey && $websitekey !=
'-1' && (!in_array($action, array(
'editcss',
'editmenu',
'importsite',
'file_manager',
'replacesite',
'replacesiteconfirm'))) && (!in_array($mode, array(
'replacesite'))) && !$file_manager) {
3245 print
'<!-- Toolbar for websitepage -->';
3246 print
'<div class="centpercent websitebar"'.($style ?
' style="'.$style.
'"' :
'').
'>';
3248 print
'<div class="websiteselection hideonsmartphoneimp minwidth75 tdoverflowmax100 inline-block">';
3249 print $langs->trans(
"PageContainer").
': ';
3253 print
'<span class="websiteselection paddingrightonly">';
3254 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>';
3260 $s = $formwebsite->selectContainer($website,
'pageid', $pageid, 0, $action,
'minwidth100 maxwidth200onsmartphone');
3262 $out .=
'<span class="websiteselection nopaddingrightimp">';
3266 $urltocreatenewpage = $_SERVER[
"PHP_SELF"].
'?action=createcontainer&token='.
newToken().
'&website='.urlencode($website->ref);
3268 if (!empty($conf->use_javascript_ajax)) {
3269 $out .=
'<script type="text/javascript">';
3270 $out .=
'jQuery(document).ready(function () {';
3271 $out .=
' jQuery("#pageid").change(function () {';
3272 $out .=
' console.log("We select "+jQuery("#pageid option:selected").val());';
3273 $out .=
' if (jQuery("#pageid option:selected").val() == \'-2\') {';
3274 $out .=
' window.location.href = "'.$urltocreatenewpage.
'";';
3275 $out .=
' } else {';
3276 $out .=
' window.location.href = "'.$_SERVER[
"PHP_SELF"].
'?website='.urlencode($website->ref).
'&pageid="+jQuery("#pageid option:selected").val();';
3280 $out .=
'</script>';
3286 if (!empty($conf->use_javascript_ajax)) {
3287 print
'<span class="websiteselection">';
3289 if (
$object->status == $object::STATUS_DRAFT) {
3290 $text_off =
'SetWebsiteOnlineBefore';
3291 if ($websitepage->status == $websitepage::STATUS_DRAFT) {
3292 print
'<span class="valignmiddle disabled opacitymedium">'.img_picto($langs->trans($text_off),
'switch_off').
'</span>';
3294 print
'<span class="valignmiddle disabled opacitymedium">'.img_picto($langs->trans($text_off),
'switch_on').
'</span>';
3297 print
ajax_object_onoff($websitepage,
'status',
'status',
'Online',
'Offline', array(),
'valignmiddle inline-block'.(empty($websitepage->id) ?
' opacitymedium disabled' :
''),
'statuswebsitepage', 1,
'pageid='.$websitepage->id);
3303 print
'<span class="websiteselection">';
3305 print
'<input type="image" class="valignmiddle buttonwebsite" src="'.img_picto(
'',
'refresh',
'', 0, 1).
'" name="refreshpage" value="'.$langs->trans(
"Load").
'"'.(($action !=
'editsource') ?
'' :
' disabled="disabled"').
'>';
3308 $pagepreviousid = 0;
3311 $sql =
"SELECT MAX(rowid) as pagepreviousid FROM ".MAIN_DB_PREFIX.
"website_page WHERE rowid < ".((int) $pageid).
" AND fk_website = ".((int)
$object->id);
3312 $resql = $db->query($sql);
3314 $obj = $db->fetch_object($resql);
3316 $pagepreviousid = $obj->pagepreviousid;
3321 $sql =
"SELECT MIN(rowid) as pagenextid FROM ".MAIN_DB_PREFIX.
"website_page WHERE rowid > ".((int) $pageid).
" AND fk_website = ".((int)
$object->id);
3322 $resql = $db->query($sql);
3324 $obj = $db->fetch_object($resql);
3326 $pagenextid = $obj->pagenextid;
3333 if ($pagepreviousid) {
3334 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>';
3336 print
'<span class="valignmiddle opacitymedium">'.img_previous($langs->trans(
"PreviousContainer")).
'</span>';
3339 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>';
3341 print
'<span class="valignmiddle opacitymedium">'.img_next($langs->trans(
"NextContainer")).
'</span>';
3346 if ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite') {
3348 if (!$user->hasRight(
'website',
'write')) {
3349 $disabled =
' disabled="disabled"';
3353 if ($action ==
'deletesite') {
3355 $formquestion = array(
3356 array(
'type' =>
'checkbox',
'name' =>
'delete_also_js',
'label' => $langs->trans(
"DeleteAlsoJs"),
'value' => 0),
3357 array(
'type' =>
'checkbox',
'name' =>
'delete_also_medias',
'label' => $langs->trans(
"DeleteAlsoMedias"),
'value' => 0),
3362 if ($atleastonepage) {
3363 $langs->load(
"errors");
3364 $formquestion[] = array(
'type' =>
'onecolumn',
'value' =>
'<div class="warning">'.$langs->trans(
"WarningPagesWillBeDeleted").
'</div>');
3367 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteWebsite'),
'',
'confirm_deletesite', $formquestion, 0, 1, 210 + ($atleastonepage ? 70 : 0), 580);
3373 if ($action ==
'createfromclone') {
3375 $formquestion = array(
3376 array(
'type' =>
'text',
'name' =>
'siteref',
'label' => $langs->trans(
"WebSite"),
'value' =>
'copy_of_'.$object->ref)
3379 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'CloneSite'),
'',
'confirm_createfromclone', $formquestion, 0, 1, 200);
3384 if ($pageid > 0 && $atleastonepage) {
3386 if ($action ==
'createpagefromclone') {
3388 $preselectedlanguage =
GETPOST(
'newlang',
'aZ09') ?
GETPOST(
'newlang',
'aZ09') :
'';
3389 $onlylang = array();
3390 if ($website->otherlang) {
3391 if (!empty($website->lang)) {
3392 $onlylang[$website->lang] = $website->lang.
' ('.$langs->trans(
"Default").
')';
3394 foreach (explode(
',', $website->otherlang) as $langkey) {
3395 if (empty(trim($langkey))) {
3398 $onlylang[$langkey] = $langkey;
3400 $textifempty = $langs->trans(
"Default");
3402 $onlylang[
'none'] =
'none';
3403 $textifempty = $langs->trans(
"Default");
3405 $formquestion = array(
3406 array(
'type' =>
'hidden',
'name' =>
'sourcepageurl',
'value' => $objectpage->pageurl),
3407 array(
'type' =>
'other',
'tdclass' =>
'fieldrequired',
'name' =>
'newwebsite',
'label' => $langs->trans(
"WebSite"),
'value' => $formwebsite->selectWebsite(
$object->id,
'newwebsite', 0)),
3408 array(
'type' =>
'text',
'tdclass' =>
'maxwidth200 fieldrequired',
'moreattr' =>
'autofocus="autofocus"',
'name' =>
'newtitle',
'label' => $langs->trans(
"WEBSITE_TITLE"),
'value' => $langs->trans(
"CopyOf").
' '.$objectpage->title),
3409 array(
'type' =>
'text',
'tdclass' =>
'maxwidth200',
'name' =>
'newpageurl',
'label' => $langs->trans(
"WEBSITE_PAGENAME"),
'value' =>
'')
3411 if (count($onlylang) > 1) {
3412 $formquestion[] = array(
'type' =>
'checkbox',
'tdclass' =>
'maxwidth200',
'name' =>
'is_a_translation',
'label' => $langs->trans(
"PageIsANewTranslation"),
'value' => 0,
'morecss' =>
'margintoponly');
3415 $value = $formadmin->select_language($preselectedlanguage,
'newlang', 0,
null, $textifempty, 0, 0,
'minwidth200', 1, 0, 0, $onlylang, 1);
3416 $formquestion[] = array(
'type' =>
'other',
'name' =>
'newlang',
'label' => $form->textwithpicto($langs->trans(
"Language"), $langs->trans(
"DefineListOfAltLanguagesInWebsiteProperties")),
'value' => $value);
3418 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?website='.
$object->ref.
'&pageid='.$pageid, $langs->trans(
'ClonePage'),
'',
'confirm_createpagefromclone', $formquestion, 0, 1, 300, 550);
3423 print
'<span class="websiteselection">';
3426 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>';
3429 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>';
3433 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?website='.
$object->ref.
'&pageid='.$pageid.
'&action=editcontent&token='.
newToken().
'" class="button bordertransp"'.$disabled.
'>'.
dol_escape_htmltag(
"CKEditor").
'</a>';
3435 print
'<!-- Add option WEBSITE_ALLOW_CKEDITOR to allow ckeditor -->';
3442 print
'<!-- button EditInLine and ShowSubcontainers -->'.
"\n";
3443 print
'<div class="websiteselectionsection inline-block">';
3445 print
'<div class="inline-block marginrightonly">';
3446 print $langs->trans(
"ShowSubcontainers");
3448 print
'<a class="nobordertransp nohoverborder marginleftonlyshort valignmiddle"'.$disabled.
' href="'.$_SERVER[
"PHP_SELF"].
'?website='.
$object->ref.
'&pageid='.$websitepage->id.
'&action=setshowsubcontainers&token='.
newToken().
'">'.
img_picto($langs->trans(
"ShowSubContainersOnOff", $langs->transnoentitiesnoconv(
"Off")),
'switch_off',
'', 0, 0, 0,
'',
'nomarginleft').
'</a>';
3450 print
'<a class="nobordertransp nohoverborder marginleftonlyshort valignmiddle"'.$disabled.
' href="'.$_SERVER[
"PHP_SELF"].
'?website='.
$object->ref.
'&pageid='.$websitepage->id.
'&action=unsetshowsubcontainers&token='.
newToken().
'">'.
img_picto($langs->trans(
"ShowSubContainersOnOff", $langs->transnoentitiesnoconv(
"On")),
'switch_on',
'', 0, 0, 0,
'',
'nomarginleft').
'</a>';
3454 print
'<div class="inline-block marginrightonly">';
3456 print
'<span id="switchckeditorinline">'.
"\n";
3458 print
'<!-- Code to enabled edit inline ckeditor -->'.
"\n";
3459 print
'<script type="text/javascript">
3460 $(document).ready(function() {
3461 var isEditingEnabled = '.(getDolGlobalString(
"WEBSITE_EDITINLINE") ?
'true' :
'false').
';
3462 if (isEditingEnabled)
3464 switchEditorOnline(true);
3467 $( "#switchckeditorinline" ).click(function() {
3468 switchEditorOnline();
3471 function switchEditorOnline(forceenable)
3473 if (! isEditingEnabled || forceenable)
3475 console.log("Enable inline edit for some html tags with contenteditable=true attribute");
3477 jQuery(\'section[contenteditable="true"],div[contenteditable="true"],header[contenteditable="true"],main[contenteditable="true"],footer[contenteditable="true"]\').each(function(idx){
3478 var idtouse = $(this).attr(\'id\');
3479 console.log("Enable inline edit for "+idtouse);
3480 if (idtouse !== undefined) {
3481 var inlineditor = CKEDITOR.inline(idtouse, {
3482 // Allow some non-standard markup that we used in the introduction.
3483 // + a[target];div{float,display} ?
3484 extraAllowedContent: \'span(*);cite(*);q(*);dl(*);dt(*);dd(*);ul(*);li(*);header(*);main(*);footer(*);button(*);h1(*);h2(*);h3(*);\',
3485 //extraPlugins: \'sourcedialog\',
3486 removePlugins: \'flash,stylescombo,exportpdf,scayt,wsc,pagebreak,iframe,smiley\',
3487 // Show toolbar on startup (optional).
3488 // startupFocus: true
3492 // Note the Source tool does not work on inline
3493 inlineditor.config.toolbar = [
3494 [\'Templates\',\'NewPage\'],
3496 [\'Maximize\',\'Preview\'],
3498 [\'Undo\',\'Redo\',\'-\',\'Find\',\'Replace\',\'-\',\'SelectAll\',\'RemoveFormat\'],
3499 [\'CreateDiv\',\'ShowBlocks\'],
3500 [\'Form\', \'Checkbox\', \'Radio\', \'TextField\', \'Textarea\', \'Select\', \'Button\', \'ImageButton\', \'HiddenField\'],
3501 [\'Bold\',\'Italic\',\'Underline\',\'Strike\',\'Superscript\'],
3502 [\'NumberedList\',\'BulletedList\',\'-\',\'Outdent\',\'Indent\',\'Blockquote\'],
3503 [\'JustifyLeft\',\'JustifyCenter\',\'JustifyRight\',\'JustifyBlock\'],
3504 [\'Link\',\'Unlink\'],
3505 [\'Image\',\'Table\',\'HorizontalRule\'],
3506 [\'Styles\',\'Format\',\'Font\',\'FontSize\'],
3507 [\'TextColor\',\'BGColor\']
3511 //inlineditor.on(\'instanceReady\', function () {
3515 CKEDITOR.instances[idtouse].on(\'change\', function() {
3516 $(this.element.$).addClass(\'modified\');
3519 console.warn("A html section has the contenteditable=true attribute but has no id attribute");
3523 isEditingEnabled = true;
3525 // Trigger the function when clicking outside the elements with contenteditable=true attribute
3526 $(document).on(\'click\', function(e) {
3527 var target = $(e.target);
3528 // Check if the click is outside the elements with contenteditable=true attribute
3529 if (!target.closest(\'[contenteditable="true"]\').length) {
3530 // Repeat through the elements with contenteditable="true" attribute
3531 $(\'[contenteditable="true"]\').each(function() {
3532 var idToUse = $(this).attr(\'id\');
3533 var elementType = $(this).prop("tagName").toLowerCase(); // Get the tag name (div, section, footer...)
3534 var instance = CKEDITOR.instances[idToUse];
3535 // Check if the element has been modified
3536 if ($(this).hasClass(\'modified\')) {
3537 var content = instance.getData();
3538 content = "\\n" + content;
3540 // Retrieving the content and ID of the element
3541 var elementId = $(this).attr(\'id\');
3543 // Sending data via AJAX
3546 url: \'' . DOL_URL_ROOT .
'/core/ajax/editinline.php\',
3548 website_ref: \''.$website->ref.
'\',
3549 page_id: \
'' . $websitepage->id .
'\',
3551 element_id: elementId,
3552 element_type: elementType,
3553 action: \'updatedElementContent\',
3556 success: function(response) {
3557 console.log(response);
3558 var $lastWebsitebar = $(".websitebar").last();
3559 var $span = $("<span></span>").html("'.$langs->trans(
"Saved").
'").css({
3560 \'display\': \'block\',
3561 \'position\': \'absolute\',
3562 \'margin-top\': \'6px\',
3564 \'background-color\': \'#e3f0db\',
3565 \'color\': \'#446548\',
3566 \'font-size\': \'14px\',
3567 \'padding\': \'0px 5px\',
3570 $lastWebsitebar.after($span);
3572 // Close message after 2 seconds
3573 setTimeout(function() {
3574 $span.fadeOut(500, function() {
3581 $(this).removeClass(\'modified\');
3588 console.log("Disable inline edit");
3589 for(name in CKEDITOR.instances) {
3590 CKEDITOR.instances[name].destroy(true);
3592 isEditingEnabled = false;
3597 print $langs->trans(
"EditInLine");
3601 $disableeditinline = 0;
3602 if ($disableeditinline) {
3604 print
'<a class="nobordertransp opacitymedium nohoverborder marginleftonlyshort"'.$disabled.
' href="#" disabled="disabled" title="'.
dol_escape_htmltag($langs->trans(
"OnlyEditionOfSourceForGrabbedContent")).
'">'.
img_picto($langs->trans(
"OnlyEditionOfSourceForGrabbedContent"),
'switch_off',
'', 0, 0, 0,
'',
'nomarginleft').
'</a>';
3608 print
'<a class="nobordertransp nohoverborder marginleftonlyshort valignmiddle"'.$disabled.
' href="'.$_SERVER[
"PHP_SELF"].
'?website='.
$object->ref.
'&pageid='.$websitepage->id.
'&action=seteditinline&token='.
newToken().
'">'.
img_picto($langs->trans(
"EditInLineOnOff", $langs->transnoentitiesnoconv(
"Off")),
'switch_off',
'', 0, 0, 0,
'',
'nomarginleft').
'</a>';
3610 print
'<a class="nobordertransp nohoverborder marginleftonlyshort valignmiddle"'.$disabled.
' href="'.$_SERVER[
"PHP_SELF"].
'?website='.
$object->ref.
'&pageid='.$websitepage->id.
'&action=unseteditinline&token='.
newToken().
'">'.
img_picto($langs->trans(
"EditInLineOnOff", $langs->transnoentitiesnoconv(
"On")),
'switch_on',
'', 0, 0, 0,
'',
'nomarginleft').
'</a>';
3619 print
'<span class="websiteselection">';
3620 if (
$object->fk_default_home > 0 && $pageid ==
$object->fk_default_home) {
3624 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>';
3628 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>';
3630 print
'<input type="submit" class="button bordertransp"'.$disabled.
' value="'.
dol_escape_htmltag($langs->trans(
"ClonePage")).
'" name="createpagefromclone">';
3633 if ($websitepage->status != $websitepage::STATUS_DRAFT) {
3634 $disabled =
' disabled="disabled"';
3635 $title = $langs->trans(
"WebpageMustBeDisabled", $langs->transnoentitiesnoconv($websitepage->LibStatut(0, 0)));
3640 $url = $_SERVER[
"PHP_SELF"].
'?action=delete&token='.
newToken().
'&pageid='.((int) $websitepage->id).
'&website='.urlencode($website->ref);
3642 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>';
3649 print
'<span class="websitetools">';
3651 if (($pageid > 0 && $atleastonepage) && ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite')) {
3652 $realpage = $urlwithroot.
'/public/website/index.php?website='.$websitekey.
'&pageref='.$websitepage->pageurl;
3653 $pagealias = $websitepage->pageurl;
3655 $htmltext = $langs->trans(
"PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv(
"Page"), $langs->transnoentitiesnoconv(
"Page"), $realpage, $dataroot);
3656 $htmltext .=
'<br>'.$langs->trans(
"CheckVirtualHostPerms", $langs->transnoentitiesnoconv(
"ReadPerm"),
'{s1}');
3657 $htmltext = str_replace(
'{s1}', $dataroot.
'<br>'.DOL_DATA_ROOT.
'/medias<br>'.DOL_DOCUMENT_ROOT, $htmltext);
3661 print
'<div class="websiteinputurl inline-block paddingright">';
3662 print
'<a class="websitebuttonsitepreview inline-block" id="previewpage" href="'.$realpage.
'&nocache='.
dol_now().
'" class="button" target="tab'.$websitekey.
'" alt="'.
dol_escape_htmltag($htmltext).
'">';
3663 print $form->textwithpicto(
'', $htmltext, 1,
'preview');
3687 if (!in_array($mode, array(
'replacesite')) && !in_array($action, array(
'editcss',
'editmenu',
'file_manager',
'replacesiteconfirm',
'createsite',
'createcontainer',
'createfromclone',
'createpagefromclone',
'deletesite'))) {
3688 if ($action ==
'editsource' || $action ==
'editmeta') {
3691 $stringforfirstkey = $langs->trans(
"KeyboardShortcut");
3692 if ($conf->browser->name ==
'chrome') {
3693 $stringforfirstkey .=
' ALT +';
3694 } elseif ($conf->browser->name ==
'firefox') {
3695 $stringforfirstkey .=
' ALT + SHIFT +';
3697 $stringforfirstkey .=
' CTL +';
3700 print
'<input type="submit" accesskey="s" title="'.dol_escape_htmltag($stringforfirstkey.
' s').
'" id="savefileandstay" class="button buttonforacesave hideonsmartphone small" value="'.
dol_escape_htmltag($langs->trans(
"SaveAndStay")).
'" name="updateandstay">';
3702 if (preg_match(
'/^create/', $action)) {
3703 print
'<input type="submit" id="savefile" class="button buttonforacesave button-save small" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
3705 if (preg_match(
'/^edit/', $action)) {
3706 print
'<input type="submit" id="savefile" class="button buttonforacesave button-save small" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
3708 if ($action !=
'preview') {
3709 print
'<input type="submit" class="button button-cancel small" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'" name="cancel">';
3715 print
'<span class="websitehelp">';
3716 if ($action ==
'editsource' || $action ==
'editcontent' ||
GETPOST(
'editsource',
'alpha') ||
GETPOST(
'editcontent',
'alpha')) {
3717 $url =
'https://wiki.dolibarr.org/index.php/Module_Website';
3719 $htmltext =
'<small>';
3720 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource", $url);
3721 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource1", $url);
3722 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource2", $url);
3723 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource3", $url);
3724 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSourceMore", $url);
3725 $htmltext .=
'<br>';
3726 $htmltext .=
'</small>';
3727 if ($conf->browser->layout ==
'phone') {
3728 print $form->textwithpicto(
'', $htmltext, 1,
'help',
'inline-block', 1, 2,
'tooltipsubstitution');
3731 print $form->textwithpicto($langs->trans(
"SyntaxHelp").
' '.
img_help(2, $langs->trans(
"SyntaxHelp")), $htmltext, 1,
'none',
'inline-block', 1, 2,
'tooltipsubstitution');
3737 if ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone') {
3739 if (!empty($conf->use_javascript_ajax)) {
3740 print
'<script type="text/javascript">
3741 jQuery(document).ready(function() {
3742 jQuery("#websiteinputurl").keyup(function() {
3743 console.log("Website external url modified "+jQuery("#previewsiteurl").val());
3744 if (jQuery("#previewsiteurl").val() != "" && jQuery("#previewsiteurl").val().startsWith("http"))
3746 jQuery("a.websitebuttonsitepreviewdisabled img").css({ opacity: 1 });
3748 else jQuery("a.websitebuttonsitepreviewdisabled img").css({ opacity: 0.2 });
3752 jQuery("#previewsiteext,#previewpageext").click(function() {
3754 newurl=jQuery("#previewsiteurl").val();
3755 if (! newurl.startsWith("http"))
3757 alert(\''.dol_escape_js($langs->trans(
"ErrorURLMustStartWithHttp")).
'\');
3761 newpage=jQuery(
"#previewsiteurl").val() +
"/" + jQuery(
"#previewpageurl").val() +
".php";
3762 console.log(
"Open url "+newurl);
3766 url:
"'.DOL_URL_ROOT.'/core/ajax/saveinplace.php",
3768 field: \
'editval_virtualhost\',
3769 element: \'website\',
3770 table_element: \'website\',
3771 fk_element: '.((int)
$object->id).
',
3774 context: document.body
3777 jQuery("#previewsiteext").attr("href",newurl);
3778 jQuery("#previewpageext").attr("href",newpage);
3797if ($action ==
'editcss') {
3798 print
'<div class="fiche">';
3802 if (!GETPOSTISSET(
'WEBSITE_CSS_INLINE')) {
3803 $csscontent = @file_get_contents($filecss);
3805 $csscontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $csscontent);
3807 $csscontent =
GETPOST(
'WEBSITE_CSS_INLINE',
'none');
3809 if (!trim($csscontent)) {
3810 $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;}";
3813 if (!GETPOSTISSET(
'WEBSITE_JS_INLINE')) {
3814 $jscontent = @file_get_contents($filejs);
3816 $jscontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $jscontent);
3818 $jscontent =
GETPOST(
'WEBSITE_JS_INLINE',
'none');
3820 if (!trim($jscontent)) {
3821 $jscontent =
'/* JS content (all pages) */'.
"\n";
3824 if (!GETPOSTISSET(
'WEBSITE_HTML_HEADER')) {
3825 $htmlheadercontent = @file_get_contents($filehtmlheader);
3827 $htmlheadercontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $htmlheadercontent);
3829 $htmlheadercontent =
GETPOST(
'WEBSITE_HTML_HEADER',
'none');
3831 if (!trim($htmlheadercontent)) {
3832 $htmlheadercontent =
"<html>\n";
3833 $htmlheadercontent .= $htmlheadercontentdefault;
3834 $htmlheadercontent .=
"</html>";
3836 $htmlheadercontent = preg_replace(
'/^\s*<html>/ims',
'', $htmlheadercontent);
3837 $htmlheadercontent = preg_replace(
'/<\/html>\s*$/ims',
'', $htmlheadercontent);
3838 $htmlheadercontent =
'<html>'.
"\n".trim($htmlheadercontent).
"\n".
'</html>';
3841 if (!GETPOSTISSET(
'WEBSITE_ROBOT')) {
3842 $robotcontent = @file_get_contents($filerobot);
3844 $robotcontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $robotcontent);
3846 $robotcontent =
GETPOST(
'WEBSITE_ROBOT',
'nohtml');
3848 if (!trim($robotcontent)) {
3849 $robotcontent .=
"# Robot file. Generated with ".DOL_APPLICATION_TITLE.
"\n";
3850 $robotcontent .=
"User-agent: *\n";
3851 $robotcontent .=
"Allow: /public/\n";
3852 $robotcontent .=
"Disallow: /administrator/\n";
3855 if (!GETPOSTISSET(
'WEBSITE_HTACCESS')) {
3856 $htaccesscontent = @file_get_contents($filehtaccess);
3858 $htaccesscontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $htaccesscontent);
3860 $htaccesscontent =
GETPOST(
'WEBSITE_HTACCESS',
'nohtml');
3862 if (!trim($htaccesscontent)) {
3863 $htaccesscontent .=
"# Order allow,deny\n";
3864 $htaccesscontent .=
"# Deny from all\n";
3867 if (!GETPOSTISSET(
'WEBSITE_MANIFEST_JSON')) {
3868 $manifestjsoncontent = @file_get_contents($filemanifestjson);
3870 $manifestjsoncontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $manifestjsoncontent);
3872 $manifestjsoncontent =
GETPOST(
'WEBSITE_MANIFEST_JSON',
'restricthtml');
3874 if (!trim($manifestjsoncontent)) {
3878 if (!GETPOSTISSET(
'WEBSITE_README')) {
3879 $readmecontent = @file_get_contents($filereadme);
3881 $readmecontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $readmecontent);
3883 $readmecontent =
GETPOST(
'WEBSITE_README',
'restricthtmlallowunvalid');
3885 if (!trim($readmecontent)) {
3889 if (!GETPOSTISSET(
'WEBSITE_LICENSE')) {
3890 $licensecontent = @file_get_contents($filelicense);
3892 $licensecontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $licensecontent);
3894 $licensecontent =
GETPOST(
'WEBSITE_LICENSE',
'restricthtmlallowunvalid');
3896 if (!trim($licensecontent)) {
3902 print
'<!-- Edit Website properties -->'.
"\n";
3903 print
'<table class="border centpercent">';
3906 print
'<tr><td class="titlefieldcreate fieldrequired">';
3907 print $langs->trans(
'WebSite');
3913 if ($action !=
'createcontainer') {
3914 if (empty($conf->use_javascript_ajax)) {
3915 print
'<!-- Status of web site page -->'.
"\n";
3916 print
'<tr><td class="fieldrequired">';
3917 print $langs->trans(
'Status');
3919 print $form->selectyesno(
'status',
$object->status);
3925 print
'<tr><td class="tdtop fieldrequired">';
3927 print $form->textwithpicto($langs->trans(
'MainLanguage'), $htmltext, 1,
'help',
'', 0, 2,
'WEBSITE_LANG');
3929 print
img_picto(
'',
'language',
'class="picotfixedwidth"');
3930 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);
3935 print
'<tr><td class="tdtop">';
3936 $htmltext = $langs->trans(
"Example").
': fr,de,sv,it,pt';
3937 print $form->textwithpicto($langs->trans(
'OtherLanguages'), $htmltext, 1,
'help',
'', 0, 2);
3939 print
img_picto(
'',
'language',
'class="picotfixedwidth"');
3940 print
'<input type="text" class="flat" value="'.(GETPOSTISSET(
'WEBSITE_OTHERLANG') ?
GETPOST(
'WEBSITE_OTHERLANG',
'alpha') :
$object->otherlang).
'" name="WEBSITE_OTHERLANG">';
3945 print
'<tr><td class="tdtop">';
3947 $htmltext = $langs->trans(
"VirtualhostDesc");
3948 print $form->textwithpicto($langs->trans(
'Virtualhost'), $htmltext, 1,
'help',
'', 0, 2,
'virtualhosttooltip');
3950 print
'<input type="text" class="flat minwidth300" value="'.(GETPOSTISSET(
'virtualhost') ?
GETPOST(
'virtualhost',
'alpha') : $virtualurl).
'" name="virtualhost">';
3956 print $form->textwithpicto($langs->trans(
'ImportFavicon'), $langs->trans(
'FaviconTooltip'));
3959 $maxmin = $maxfilesizearray[
'maxmin'];
3961 print
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
3963 print
'<input type="file" class="flat minwidth300" name="addedfile" id="addedfile"/>';
3965 $uploadfolder = $conf->website->dir_output.
'/'.$websitekey;
3967 print
'<div class="inline-block valignmiddle marginrightonly">';
3968 print
'<img style="max-height: 80px" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart=website&file='.$websitekey.
'/favicon.png">';
3974 print
'<tr><td class="tdtop">';
3975 $htmlhelp = $langs->trans(
"CSSContentTooltipHelp");
3976 print $form->textwithpicto($langs->trans(
'WEBSITE_CSS_INLINE'), $htmlhelp, 1,
'help',
'', 0, 2,
'csstooltip');
3979 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_CSS_INLINE_x'),
'y' =>
GETPOST(
'WEBSITE_CSS_INLINE_y'));
3980 $doleditor =
new DolEditor(
'WEBSITE_CSS_INLINE', $csscontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
3981 print $doleditor->Create(1,
'',
true,
'CSS',
'css');
3986 print
'<tr><td class="tdtop">';
3987 $textwithhelp = $langs->trans(
'WEBSITE_JS_INLINE');
3988 $htmlhelp2 = $langs->trans(
"LinkAndScriptsHereAreNotLoadedInEditor").
'<br>';
3989 print $form->textwithpicto($textwithhelp, $htmlhelp2, 1,
'warning',
'', 0, 2,
'htmljstooltip2');
3993 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_JS_INLINE_x'),
'y' =>
GETPOST(
'WEBSITE_JS_INLINE_y'));
3994 $doleditor =
new DolEditor(
'WEBSITE_JS_INLINE', $jscontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
3995 print $doleditor->Create(1,
'',
true,
'JS',
'javascript');
4000 print
'<tr><td class="tdtop">';
4001 print $langs->trans(
'WEBSITE_HTML_HEADER');
4002 $htmlhelp = $langs->trans(
"Example").
' :<br>';
4004 $textwithhelp = $form->textwithpicto(
'', $htmlhelp, 1,
'help',
'', 0, 2,
'htmlheadertooltip');
4005 $htmlhelp2 = $langs->trans(
"LinkAndScriptsHereAreNotLoadedInEditor").
'<br>';
4006 print $form->textwithpicto($textwithhelp, $htmlhelp2, 1,
'warning',
'', 0, 2,
'htmlheadertooltip2');
4009 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_HTML_HEADER_x'),
'y' =>
GETPOST(
'WEBSITE_HTML_HEADER_y'));
4010 $doleditor =
new DolEditor(
'WEBSITE_HTML_HEADER', $htmlheadercontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4011 print $doleditor->Create(1,
'',
true,
'HTML Header',
'html');
4016 print
'<tr><td class="tdtop">';
4017 print $langs->trans(
'WEBSITE_ROBOT');
4020 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_ROBOT_x'),
'y' =>
GETPOST(
'WEBSITE_ROBOT_y'));
4021 $doleditor =
new DolEditor(
'WEBSITE_ROBOT', $robotcontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4022 print $doleditor->Create(1,
'',
true,
'Robot file',
'text');
4027 print
'<tr><td class="tdtop">';
4028 print $langs->trans(
'WEBSITE_HTACCESS');
4031 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_HTACCESS_x'),
'y' =>
GETPOST(
'WEBSITE_HTACCESS_y'));
4032 $doleditor =
new DolEditor(
'WEBSITE_HTACCESS', $htaccesscontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4033 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' .htaccess',
'text');
4038 print
'<tr><td class="tdtop">';
4039 $htmlhelp = $langs->trans(
"Example").
' :<br>';
4040 $htmlhelp .=
'<small>'.dol_htmlentitiesbr($manifestjsoncontentdefault).
'</small>';
4041 print $form->textwithpicto($langs->trans(
'WEBSITE_MANIFEST_JSON'), $htmlhelp, 1,
'help',
'', 0, 2,
'manifestjsontooltip');
4043 print $langs->trans(
"UseManifest").
': '.$form->selectyesno(
'use_manifest', $website->use_manifest, 1).
'<br>';
4045 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_MANIFEST_JSON_x'),
'y' =>
GETPOST(
'WEBSITE_MANIFEST_JSON_y'));
4046 $doleditor =
new DolEditor(
'WEBSITE_MANIFEST_JSON', $manifestjsoncontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4047 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' manifest.json',
'text');
4051 print
'<tr><td class="tdtop">';
4052 $htmlhelp = $langs->trans(
"EnterHereReadmeInformation");
4053 print $form->textwithpicto($langs->trans(
"File").
' README.md', $htmlhelp, 1,
'help',
'', 0, 2,
'readmetooltip');
4056 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_README_x'),
'y' =>
GETPOST(
'WEBSITE_README_y'));
4057 $doleditor =
new DolEditor(
'WEBSITE_README', $readmecontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4058 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' README.md',
'text');
4063 print
'<tr><td class="tdtop">';
4064 $htmlhelp = $langs->trans(
"EnterHereLicenseInformation");
4065 print $form->textwithpicto($langs->trans(
"File").
' LICENSE', $htmlhelp, 1,
'help',
'', 0, 2,
'licensetooltip');
4068 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_LICENSE_x'),
'y' =>
GETPOST(
'WEBSITE_LICENSE_y'));
4069 $doleditor =
new DolEditor(
'WEBSITE_LICENSE', $licensecontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4070 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' LICENSE',
'text');
4075 print
'<tr><td class="tdtop">';
4076 $htmlhelp = $langs->trans(
'RSSFeedDesc');
4077 print $form->textwithpicto($langs->trans(
'RSSFeed'), $htmlhelp, 1,
'help',
'', 0, 2,
'');
4079 print
'/wrapper.php?rss=1[&l=XX][&limit=123]';
4092if ($action ==
'createsite') {
4093 print
'<div class="fiche">';
4107 if ($action ==
'createcontainer') {
4111 print
'<!-- Add site -->'.
"\n";
4112 print
'<div class="tabBar tabBarWithBottom">';
4114 print
'<table class="border centpercent">';
4116 $siteref = $sitedesc = $sitelang = $siteotherlang =
'';
4118 $siteref =
GETPOST(
'WEBSITE_REF',
'aZ09');
4120 if (
GETPOST(
'WEBSITE_DESCRIPTION')) {
4121 $sitedesc =
GETPOST(
'WEBSITE_DESCRIPTION',
'alpha');
4123 if (
GETPOST(
'WEBSITE_LANG')) {
4124 $sitelang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
4126 if (
GETPOST(
'WEBSITE_OTHERLANG')) {
4127 $siteotherlang =
GETPOST(
'WEBSITE_OTHERLANG',
'aZ09comma');
4130 print
'<tr><td class="titlefieldcreate fieldrequired">';
4131 print $form->textwithpicto($langs->trans(
'WebsiteName'), $langs->trans(
"Example").
': MyPortal, www.mywebsite.com, ...');
4133 print
'<input type="text" class="flat maxwidth300" name="WEBSITE_REF" value="'.dol_escape_htmltag($siteref).
'" autofocus>';
4136 print
'<tr><td class="fieldrequired">';
4137 print $langs->trans(
'MainLanguage');
4139 $shortlangcode = preg_replace(
'/[_-].*$/',
'', trim($langs->defaultlang));
4140 print
img_picto(
'',
'language',
'class="pictofixedwidth"');
4141 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);
4145 $htmltext = $langs->trans(
"Example").
': fr,de,sv,it,pt';
4146 print $form->textwithpicto($langs->trans(
'OtherLanguages'), $htmltext, 1,
'help',
'', 0, 2);
4148 print
img_picto(
'',
'language',
'class="pictofixedwidth"');
4149 print
'<input type="text" class="flat minwidth300" name="WEBSITE_OTHERLANG" value="'.dol_escape_htmltag($siteotherlang).
'">';
4153 print $langs->trans(
'Description');
4155 print
'<input type="text" class="flat minwidth500" name="WEBSITE_DESCRIPTION" value="'.dol_escape_htmltag($sitedesc).
'">';
4160 $htmltext = $langs->trans(
"VirtualhostDesc");
4168 print $form->textwithpicto($langs->trans(
'Virtualhost'), $htmltext, 1,
'help',
'', 0, 2,
'');
4170 print
'<input type="text" class="flat minwidth300" name="virtualhost" value="'.dol_escape_htmltag(
GETPOST(
'virtualhost',
'alpha')).
'">';
4176 if ($action ==
'createsite') {
4177 print
'<div class="center">';
4179 print
'<input type="submit" class="button small" name="addcontainer" value="'.$langs->trans(
"Create").
'">';
4180 print
'<input class="button button-cancel small" type="submit" name="preview" value="'.$langs->trans(
"Cancel").
'">';
4195if ($action ==
'importsite') {
4196 print
'<!-- action=importsite -->';
4197 print
'<div class="fiche">';
4205 print
'<span class="opacitymedium">'.$langs->trans(
"ZipOfWebsitePackageToImport").
'</span><br><br>';
4208 $dolibarrdataroot = preg_replace(
'/([\\/]+)$/i',
'', DOL_DATA_ROOT);
4209 $allowimportsite =
true;
4210 if (
dol_is_file($dolibarrdataroot.
'/installmodules.lock')) {
4211 $allowimportsite =
false;
4214 if ($allowimportsite) {
4216 $maxmin = $maxfilesizearray[
'maxmin'];
4218 print
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
4220 print
'<input class="flat minwidth400" type="file" name="userfile[]" accept=".zip">';
4221 print
'<input type="submit" class="button small" name="buttonsubmitimportfile" value="'.dol_escape_htmltag($langs->trans(
"Upload")).
'">';
4222 print
'<input type="submit" class="button button-cancel small" name="preview" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
4223 print
'<br><br><br>';
4227 $message = $langs->trans(
'InstallModuleFromWebHasBeenDisabledContactUs');
4230 $message = $langs->trans(
"InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.
'/installmodules.lock');
4236 print
'<span class="opacitymedium">'.$langs->trans(
"ZipOfWebsitePackageToLoad").
'</span><br><br>';
4247if ($action ==
'editmeta' || $action ==
'createcontainer') {
4248 print
'<div class="fiche">';
4262 if ($action ==
'createcontainer') {
4266 print
'<!-- Edit or create page/container -->'.
"\n";
4269 $hiddenfromfetchingafterload =
' hideobject';
4270 $hiddenmanuallyafterload =
' hideobject';
4271 if (
GETPOST(
'radiocreatefrom') ==
'checkboxcreatefromfetching') {
4272 $hiddenfromfetchingafterload =
'';
4274 if (
GETPOST(
'radiocreatefrom') ==
'checkboxcreatemanually') {
4275 $hiddenmanuallyafterload =
'';
4278 if ($action ==
'editmeta' || empty($conf->use_javascript_ajax)) {
4279 $hiddenfromfetchingafterload =
'';
4280 $hiddenmanuallyafterload =
'';
4283 if ($action ==
'createcontainer') {
4286 if (!empty($conf->use_javascript_ajax)) {
4287 print
'<input type="radio" name="radiocreatefrom" id="checkboxcreatemanually" value="checkboxcreatemanually"'.(GETPOST(
'radiocreatefrom') ==
'checkboxcreatemanually' ?
' checked' :
'').
'> ';
4289 print
'<label for="checkboxcreatemanually"><span class="opacitymediumxx">'.$langs->trans(
"OrEnterPageInfoManually").
'</span></label><br>';
4290 print
'<hr class="tablecheckboxcreatemanually'.$hiddenmanuallyafterload.
'">';
4293 print
'<table class="border tableforfield nobackground centpercent tablecheckboxcreatemanually'.$hiddenmanuallyafterload.
'">';
4295 if ($action !=
'createcontainer') {
4296 print
'<tr><td class="titlefield fieldrequired">';
4297 print $langs->trans(
'IDOfPage').
' - '.$langs->trans(
'InternalURLOfPage');
4305 print
' - ';
4306 print
'/public/website/index.php?website='.urlencode($websitekey).
'&pageid='.urlencode($pageid);
4310 $type_container = $objectpage->type_container;
4311 $pageurl = $objectpage->pageurl;
4312 $pagealiasalt = $objectpage->aliasalt;
4313 $pagetitle = $objectpage->title;
4314 $pagedescription = $objectpage->description;
4315 $pageimage = $objectpage->image;
4316 $pagekeywords = $objectpage->keywords;
4317 $pagelang = $objectpage->lang;
4318 $pageallowedinframes = $objectpage->allowed_in_frames;
4319 $pagehtmlheader = $objectpage->htmlheader;
4320 $pagedatecreation = $objectpage->date_creation;
4321 $pagedatemodification = $objectpage->date_modification;
4322 $pageauthorid = $objectpage->fk_user_creat;
4323 $pageusermodifid = $objectpage->fk_user_modif;
4324 $pageauthoralias = $objectpage->author_alias;
4325 $pagestatus = $objectpage->status;
4327 $type_container =
'page';
4331 $pagedescription =
'';
4335 $pageallowedinframes = 0;
4336 $pagehtmlheader =
'';
4337 $pagedatecreation =
dol_now();
4338 $pagedatemodification =
'';
4339 $pageauthorid = $user->id;
4340 $pageusermodifid = 0;
4341 $pageauthoralias =
'';
4344 if (
GETPOST(
'WEBSITE_TITLE',
'alpha')) {
4345 $pagetitle = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_TITLE',
'alphanohtml'));
4347 if (
GETPOST(
'WEBSITE_PAGENAME',
'alpha')) {
4348 $pageurl =
GETPOST(
'WEBSITE_PAGENAME',
'alpha');
4350 if (
GETPOST(
'WEBSITE_ALIASALT',
'alpha')) {
4351 $pagealiasalt = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_ALIASALT',
'alphanohtml'));
4353 if (
GETPOST(
'WEBSITE_DESCRIPTION',
'alpha')) {
4354 $pagedescription = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml'));
4356 if (
GETPOST(
'WEBSITE_IMAGE',
'alpha')) {
4357 $pageimage =
GETPOST(
'WEBSITE_IMAGE',
'alpha');
4359 if (
GETPOST(
'WEBSITE_KEYWORDS',
'alpha')) {
4360 $pagekeywords = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_KEYWORDS',
'alphanohtml'));
4362 if (
GETPOST(
'WEBSITE_LANG',
'aZ09')) {
4363 $pagelang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
4365 if (
GETPOST(
'WEBSITE_ALLOWED_IN_FRAMES',
'aZ09')) {
4366 $pageallowedinframes =
GETPOST(
'WEBSITE_ALLOWED_IN_FRAMES',
'aZ09') ? 1 : 0;
4368 if (
GETPOST(
'htmlheader',
'none')) {
4369 $pagehtmlheader =
GETPOST(
'htmlheader',
'none');
4372 if ($action !=
'createcontainer') {
4373 if (empty($conf->use_javascript_ajax)) {
4374 print
'<!-- Status of web site page -->'.
"\n";
4375 print
'<tr><td class="fieldrequired">';
4376 print $langs->trans(
'Status');
4378 print $form->selectyesno(
'status', $objectpage->status);
4384 print
'<tr><td class="titlefield fieldrequired">';
4385 print $langs->trans(
'WEBSITE_TYPE_CONTAINER');
4387 print
img_picto(
'',
'object_technic',
'class="paddingrightonly"').
' ';
4388 print $formwebsite->selectTypeOfContainer(
'WEBSITE_TYPE_CONTAINER', (
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'alpha') ?
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'alpha') : $type_container), 0,
'', 1,
'minwidth300');
4391 print
'<script type="text/javascript">
4392 jQuery(document).ready(function() {
4393 jQuery("#selectWEBSITE_TYPE_CONTAINER").change(function() {
4394 console.log("We change type of page : "+jQuery("#selectWEBSITE_TYPE_CONTAINER").val());
4395 if (jQuery("#selectWEBSITE_TYPE_CONTAINER").val() == \'blogpost\') {
4396 jQuery(".trpublicauthor").show();
4398 jQuery(".trpublicauthor").hide();
4400 if (jQuery("#selectWEBSITE_TYPE_CONTAINER").val() == \'service\' || jQuery("#selectWEBSITE_TYPE_CONTAINER").val() == \'library\') {
4401 $(".spanprefix").html("_" + $("#selectWEBSITE_TYPE_CONTAINER").val() + "_");
4402 jQuery(".spanprefix").show();
4404 jQuery(".spanprefix").hide();
4408 // Force at init execution a first time of the handler change
4409 jQuery("#selectWEBSITE_TYPE_CONTAINER").trigger(\'change\');
4415 print
'<tr><td class="fieldrequired">';
4416 print $langs->trans(
'WEBSITE_TITLE');
4418 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_TITLE" id="WEBSITE_TITLE" value="'.dol_escape_htmltag($pagetitle).
'" autofocus>';
4422 print
'<tr><td class="titlefieldcreate fieldrequired">';
4423 print $langs->trans(
'WEBSITE_PAGENAME');
4425 print
'<span class="opacitymedium spanprefix hidden"></span> ';
4426 print
'<input type="text" class="flat minwidth300" name="WEBSITE_PAGENAME" id="WEBSITE_PAGENAME" value="'.dol_escape_htmltag((
string) preg_replace(
'/^_[a-z]+_/',
'', (
string) $pageurl)).
'">';
4429 print
'<script type="text/javascript">
4430 $(document).ready(function() {
4431 console.log("Manage prefix for service or library");
4432 if ($("#selectWEBSITE_TYPE_CONTAINER").val() == "service" || $("#selectWEBSITE_TYPE_CONTAINER").val() == "library") {
4433 $(".spanprefix").html("_" + $("#selectWEBSITE_TYPE_CONTAINER").val() + "_");
4434 $(".spanprefix").show();
4436 $(".websiteformtoolbar").on("submit", function(event) {
4437 if ($("#selectWEBSITE_TYPE_CONTAINER").val() == "service" || $("#selectWEBSITE_TYPE_CONTAINER").val() == "library") {
4438 var prefix = "_" + $("#selectWEBSITE_TYPE_CONTAINER").val() + "_";
4439 var userInput = $("#WEBSITE_PAGENAME").val();
4440 var $inputField = $("#WEBSITE_PAGENAME");
4441 if (userInput.indexOf(prefix) !== 0) {
4442 $inputField.val(prefix + userInput);
4450 print
'<tr><td class="titlefieldcreate">';
4451 $htmlhelp = $langs->trans(
"WEBSITE_ALIASALTDesc");
4452 print $form->textwithpicto($langs->trans(
'WEBSITE_ALIASALT'), $htmlhelp, 1,
'help',
'', 0, 2,
'aliastooltip');
4454 print
'<input type="text" class="flat minwidth500" name="WEBSITE_ALIASALT" value="'.dol_escape_htmltag($pagealiasalt).
'">';
4458 print $langs->trans(
'WEBSITE_DESCRIPTION');
4460 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_DESCRIPTION" value="'.dol_escape_htmltag($pagedescription).
'">';
4465 print
'<tr class="trimageforpage hidden"><td>';
4466 $htmlhelp = $langs->trans(
"WEBSITE_IMAGEDesc");
4467 print $form->textwithpicto($langs->trans(
'WEBSITE_IMAGE'), $htmlhelp, 1,
'help',
'', 0, 2,
'imagetooltip');
4469 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_IMAGE" value="'.dol_escape_htmltag($pageimage).
'">';
4472 print
'<script type="text/javascript">
4473 jQuery(document).ready(function() {
4474 jQuery("#selectWEBSITE_TYPE_CONTAINER").change(function() {
4475 console.log("We change type of page : "+jQuery("#selectWEBSITE_TYPE_CONTAINER").val());
4476 if (jQuery("#selectWEBSITE_TYPE_CONTAINER").val() == \'blogpost\') {
4477 jQuery(".trimageforpage").show();
4479 jQuery(".trimageforpage").hide();
4489 $htmlhelp = $langs->trans(
"WEBSITE_KEYWORDSDesc");
4490 print $form->textwithpicto($langs->trans(
'WEBSITE_KEYWORDS'), $htmlhelp, 1,
'help',
'', 0, 2,
'keywordtooltip');
4492 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_KEYWORDS" value="'.dol_escape_htmltag($pagekeywords).
'">';
4496 print $langs->trans(
'Language');
4498 $onlykeys = array();
4502 $onlykeys[$langs->defaultlang] = $langs->defaultlang;
4505 $tmparray = explode(
',',
$object->otherlang);
4506 foreach ($tmparray as $key) {
4507 $tmpkey = trim($key);
4508 if (strlen($key) == 2) {
4509 $tmpkey = strtolower($key);
4511 $onlykeys[$tmpkey] = $tmpkey;
4517 print
img_picto(
'',
'language',
'class="pictofixedwidth"').$formadmin->select_language($pagelang ? $pagelang :
'',
'WEBSITE_LANG', 0, null,
'1', 0, 0,
'minwidth200', 0, 0, 0, $onlykeys, 1);
4518 $htmltext = $langs->trans(
"AvailableLanguagesAreDefinedIntoWebsiteProperties");
4519 print $form->textwithpicto(
'', $htmltext);
4525 print
'<!-- Translation of --><tr><td>';
4526 print $langs->trans(
'TranslationLinks');
4528 if ($action !=
'createcontainer') {
4530 $sql =
"SELECT rowid, lang from ".MAIN_DB_PREFIX.
"website_page where fk_page = ".((int) $objectpage->id);
4531 $resql = $db->query($sql);
4533 $num_rows = $db->num_rows($resql);
4534 if ($num_rows > 0) {
4535 print
'<span class="opacitymedium">'.$langs->trans(
'ThisPageHasTranslationPages').
':</span>';
4539 while ($obj = $db->fetch_object($resql)) {
4540 $result = $tmppage->fetch($obj->rowid);
4543 $tmpstring .=
'<br>';
4545 $tmpstring .= $tmppage->getNomUrl(1).
' '.
picto_from_langcode($tmppage->lang).
' '.$tmppage->lang;
4547 $tmpstring .=
' <a class="paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
$object->ref).
'&pageid='.((int) $objectpage->id).
'&action=deletelang&token='.
newToken().
'&deletelangforid='.((int) $tmppage->id).
'">'.
img_picto($langs->trans(
"Remove"),
'unlink').
'</a>';
4563 if ((empty($translatedby) || ($objectpage->lang !=
$object->lang)) && ($action ==
'editmeta' || $action ==
'createcontainer' || $objectpage->fk_page > 0)) {
4566 if ($objectpage->fk_page > 0) {
4567 $result = $sourcepage->fetch($objectpage->fk_page);
4574 if ($translatedby) {
4577 $translationof = $objectpage->fk_page;
4578 print
'<span class="opacitymedium">'.$langs->trans(
'ThisPageIsTranslationOf').
'</span> ';
4579 print $sourcepage->getNomUrl(2).
' '.$formwebsite->selectContainer($website,
'pageidfortranslation', ($translationof ? $translationof : -1), 1, $action,
'minwidth300', array($objectpage->id));
4580 if ($translationof > 0 && $sourcepage->lang) {
4583 print
' <a class="paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
$object->ref).
'&pageid='.((int) $objectpage->id).
'&action=deletelang&token='.
newToken().
'&deletelangforid='.((int) $objectpage->id).
'">'.
img_picto($langs->trans(
"Remove"),
'unlink').
'</a>';
4590 if (isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire')) {
4591 $langs->load(
'categories');
4593 if (!GETPOSTISSET(
'categories')) {
4595 $cats = $c->containing($objectpage->id, Categorie::TYPE_WEBSITE_PAGE);
4596 $arrayselected = array();
4597 if (is_array($cats)) {
4598 foreach ($cats as $cat) {
4599 $arrayselected[] = $cat->id;
4604 $cate_arbo = $form->select_all_categories(Categorie::TYPE_WEBSITE_PAGE,
'',
'parent', 0, 0, 3);
4607 print
'<tr><td class="toptd">'.$form->editfieldkey(
'Categories',
'categories',
'', $objectpage, 0).
'</td><td>';
4608 print
img_picto(
'',
'category',
'class="pictofixedwidth"');
4609 print $form->multiselectarray(
'categories', $cate_arbo, (GETPOSTISSET(
'categories') ?
GETPOST(
'categories',
'array') : $arrayselected), null, null,
'minwidth200 widthcentpercentminusxx');
4611 print
dolButtonToOpenUrlInDialogPopup(
'categories', $langs->transnoentitiesnoconv(
"Categories"),
img_picto(
'',
'add'),
'/categories/index.php?leftmenu=website&nosearch=1&type='.urlencode(Categorie::TYPE_WEBSITE_PAGE).
'&website='.urlencode($website->ref), $disabled);
4617 print
'<tr><td class="titlefieldcreate">';
4618 print
'ObjectClass';
4620 print
'<input type="text" class="flat minwidth300" name="WEBSITE_OBJECTCLASS" placeholder="ClassName::/path/class/ObjectClass.class.php" >';
4623 print
'<tr><td class="titlefieldcreate">';
4626 print
'<input type="text" class="flat minwidth300" name="WEBSITE_OBJECTID" >';
4630 $fuser =
new User($db);
4633 if ($action !=
'createcontainer') {
4635 print $langs->trans(
'DateLastModification');
4637 print
dol_print_date($pagedatemodification,
'dayhour',
'tzuser');
4641 print $langs->trans(
'UserModification');
4643 if ($pageusermodifid > 0) {
4644 $fuser->fetch($pageusermodifid);
4645 print $fuser->getNomUrl(-1);
4647 print
'<span class="opacitymedium">'.$langs->trans(
"Unknown").
'</span>';
4653 $url =
'https://wiki.dolibarr.org/index.php/Module_Website';
4654 $htmltext =
'<small>';
4655 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource", $url);
4656 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource1", $url);
4657 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource2", $url);
4658 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource3", $url);
4659 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSourceMore", $url);
4660 $htmltext .=
'<br>';
4661 $htmltext .=
'</small>';
4664 $formmail->withaiprompt =
'html';
4665 $formmail->withlayout = 1;
4666 $showlinktolayout = $formmail->withlayout;
4667 $showlinktoai = ($formmail->withaiprompt && isModEnabled(
'ai')) ?
'textgenerationwebpage' :
'';
4668 if (($action ==
'createcontainer' && $showlinktolayout) || ($action ==
'createcontainer' && $showlinktoai)) {
4669 print
'<tr><td class="titlefield tdtop">';
4670 if ($conf->browser->layout ==
'phone') {
4671 print $form->textwithpicto(
'', $htmltext, 1,
'help',
'inline-block', 1, 2,
'tooltipsubstitution');
4674 print $form->textwithpicto($langs->trans(
"PreviewPageContent").
' '.
img_help(2, $langs->trans(
"PreviewPageContent")), $htmltext, 1,
'none',
'inline-block', 1, 2,
'tooltipsubstitution');
4676 print
'</td><td class="tdtop">';
4680 $showlinktolayoutlabel = $langs->trans(
"FillPageWithALayout");
4681 $showlinktoailabel = $langs->trans(
"FillPageWithAIContent");
4682 $htmlname =
'content';
4684 include DOL_DOCUMENT_ROOT.
'/core/tpl/formlayoutai.tpl.php';
4690 if ($action ==
'createcontainer') {
4691 print
'<tr id="pageContent"><td class="tdtop">';
4692 if (!$showlinktolayout || !$showlinktoai) {
4693 if ($conf->browser->layout ==
'phone') {
4694 print $form->textwithpicto(
'', $htmltext, 1,
'help',
'inline-block', 1, 2,
'tooltipsubstitution');
4697 print $form->textwithpicto($langs->trans(
"PreviewPageContent").
' '.
img_help(2, $langs->trans(
"PreviewPageContent")), $htmltext, 1,
'none',
'inline-block', 1, 2,
'tooltipsubstitution');
4702 $doleditor =
new DolEditor(
'content',
GETPOST(
'content',
'none'),
'', 200,
'dolibarr_mailings',
'In',
true,
true,
true, 40,
'90%');
4703 $doleditor->Create();
4710 print $langs->trans(
'DateCreation');
4712 print $form->selectDate($pagedatecreation,
'datecreation', 1, 1, 0,
'', 1, 1);
4718 print $langs->trans(
'Author');
4720 if ($pageauthorid > 0) {
4721 $fuser->fetch($pageauthorid);
4722 print $fuser->getNomUrl(-1);
4724 print
'<span class="opacitymedium">'.$langs->trans(
"Unknown").
'</span>';
4729 print
'<tr class="trpublicauthor hidden"><td>';
4730 print $langs->trans(
'PublicAuthorAlias');
4732 print
'<input type="text" class="flat minwidth300" name="WEBSITE_AUTHORALIAS" value="'.dol_escape_htmltag($pageauthoralias).
'" placeholder="Anonymous">';
4735 print
'<tr><td class="tdhtmlheader tdtop">';
4736 $htmlhelp = $langs->trans(
"EditTheWebSiteForACommonHeader").
'<br><br>';
4737 $htmlhelp .= $langs->trans(
"Example").
' :<br>';
4739 print $form->textwithpicto($langs->transnoentitiesnoconv(
'HtmlHeaderPage'), $htmlhelp, 1,
'help',
'', 0, 2,
'htmlheadertooltip');
4741 $poscursor = array(
'x' =>
GETPOST(
'htmlheader_x'),
'y' =>
GETPOST(
'htmlheader_y'));
4742 $doleditor =
new DolEditor(
'htmlheader', $pagehtmlheader,
'', 120,
'ace',
'In',
true,
false,
'ace', ROWS_3,
'100%', 0, $poscursor);
4743 print $doleditor->Create(1,
'',
true,
'HTML Header',
'html');
4748 print $langs->trans(
'AllowedInFrames');
4752 print
'<input type="checkbox" class="flat" name="WEBSITE_ALLOWED_IN_FRAMES" value="1"'.($pageallowedinframes ?
'checked="checked"' :
'').
'>';
4757 if ($action ==
'createcontainer') {
4758 print
'<div class="center tablecheckboxcreatemanually'.$hiddenmanuallyafterload.
'">';
4760 print
'<input type="submit" class="button small" name="addcontainer" value="'.$langs->trans(
"Create").
'">';
4761 print
'<input class="button button-cancel small" type="submit" name="preview" value="'.$langs->trans(
"Cancel").
'">';
4768 if (!empty($conf->use_javascript_ajax)) {
4769 print
'<input type="radio" name="radiocreatefrom" id="checkboxcreatefromfetching" value="checkboxcreatefromfetching"'.(GETPOST(
'radiocreatefrom') ==
'checkboxcreatefromfetching' ?
' checked' :
'').
'> ';
4771 print
'<label for="checkboxcreatefromfetching"><span class="opacitymediumxx">'.$langs->trans(
"CreateByFetchingExternalPage").
'</span></label><br>';
4772 print
'<hr class="tablecheckboxcreatefromfetching'.$hiddenfromfetchingafterload.
'">';
4773 print
'<table class="tableforfield centpercent tablecheckboxcreatefromfetching'.$hiddenfromfetchingafterload.
'">';
4774 print
'<tr><td class="titlefield">';
4775 print $langs->trans(
"URL");
4777 print
info_admin($langs->trans(
"OnlyEditionOfSourceForGrabbedContentFuture"), 0, 0,
'warning');
4778 print
'<input class="flat minwidth500" type="text" name="externalurl" value="'.dol_escape_htmltag(
GETPOST(
'externalurl',
'alpha')).
'" placeholder="https://externalsite/pagetofetch"> ';
4779 print
'<br><input class="flat paddingtop" type="checkbox" name="grabimages" value="1" checked="checked"> '.$langs->trans(
"GrabImagesInto");
4781 print $langs->trans(
"ImagesShouldBeSavedInto").
' ';
4782 $arraygrabimagesinto = array(
'root' => $langs->trans(
"WebsiteRootOfImages"),
'subpage' => $langs->trans(
"SubdirOfPage"));
4783 print $form->selectarray(
'grabimagesinto', $arraygrabimagesinto, GETPOSTISSET(
'grabimagesinto') ?
GETPOST(
'grabimagesinto') :
'root', 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
4786 print
'<input class="button small" style="margin-top: 5px" type="submit" name="fetchexternalurl" value="'.dol_escape_htmltag($langs->trans(
"FetchAndCreate")).
'">';
4787 print
'<input class="button button-cancel small" type="submit" name="preview" value="'.$langs->trans(
"Cancel").
'">';
4793 if ($action ==
'createcontainer') {
4794 print
'<script type="text/javascript">
4795 jQuery(document).ready(function() {
4796 var disableautofillofalias = 0;
4797 var selectedm = \'\';
4798 var selectedf = \'\';
4800 jQuery("#WEBSITE_TITLE").keyup(function() {
4801 if (disableautofillofalias == 0) {
4802 var valnospecial = jQuery("#WEBSITE_TITLE").val();
4803 valnospecial = valnospecial.replace(/[éèê]/g, \'e\').replace(/[à]/g, \'a\').replace(/[ù]/g, \'u\').replace(/[î]/g, \'i\');
4804 valnospecial = valnospecial.replace(/[ç]/g, \'c\').replace(/[ö]/g, \'o\');
4805 valnospecial = valnospecial.replace(/[^\w]/gi, \'-\').toLowerCase();
4806 valnospecial = valnospecial.replace(/\-+/g, \'-\').replace(/\-$/, \'\');
4807 console.log("disableautofillofalias=0 so we replace WEBSITE_TITLE with "+valnospecial);
4808 jQuery("#WEBSITE_PAGENAME").val(valnospecial);
4811 jQuery("#WEBSITE_PAGENAME").keyup(function() {
4812 if (jQuery("#WEBSITE_PAGENAME").val() == \'\') {
4813 disableautofillofalias = 0;
4815 disableautofillofalias = 1;
4818 jQuery("#WEBSITE_PAGENAME").blur(function() {
4819 if (jQuery("#WEBSITE_PAGENAME").val() == \'\') {
4820 disableautofillofalias = 0;
4821 jQuery("#WEBSITE_TITLE").trigger(\'keyup\');
4825 jQuery("#checkboxcreatefromfetching,#checkboxcreatemanually").click(function() {
4826 console.log("we select a method to create a new container "+jQuery("#checkboxcreatefromfetching:checked").val())
4827 jQuery(".tablecheckboxcreatefromfetching").hide();
4828 jQuery(".tablecheckboxcreatemanually").hide();
4829 if (typeof(jQuery("#checkboxcreatefromfetching:checked").val()) != \'undefined\') {
4830 console.log("show create from spider form");
4831 if (selectedf != \'createfromfetching\') {
4832 jQuery(".tablecheckboxcreatefromfetching").show();
4833 selectedf = \'createfromfetching\';
4836 jQuery(".tablecheckboxcreatefromfetching").hide();
4840 if (typeof(jQuery("#checkboxcreatemanually:checked").val()) != \'undefined\') {
4841 console.log("show create from scratch or template form");
4842 if (selectedm != \'createmanually\') {
4843 jQuery(".tablecheckboxcreatemanually").show();
4844 selectedm = \'createmanually\';
4847 jQuery(".tablecheckboxcreatemanually").hide();
4866if ($action ==
'preview') {
4870if ($action ==
'editfile' || $action ==
'file_manager' || $action ==
'convertimgwebp' || $action ==
'confirmconvertimgwebp') {
4871 print
'<!-- Edit Media -->'.
"\n";
4872 print
'<div class="fiche"><br>';
4877 $formalreadyopen = 2;
4879 $url = DOL_URL_ROOT.
'/website/index.php';
4881 include DOL_DOCUMENT_ROOT.
'/core/tpl/filemanager.tpl.php';
4886if ($action ==
'editmenu') {
4887 print
'<!-- Edit Menu -->'.
"\n";
4888 print
'<div class="center">'.$langs->trans(
"FeatureNotYetAvailable").
'</center>';
4891if ($action ==
'editsource') {
4894 $contentforedit =
'';
4898 $contentforedit .= $objectpage->content;
4900 $maxheightwin = 480;
4901 if (isset($_SESSION[
"dol_screenheight"])) {
4902 if ($_SESSION[
"dol_screenheight"] > 680) {
4903 $maxheightwin = $_SESSION[
"dol_screenheight"] - 400;
4905 if ($_SESSION[
"dol_screenheight"] > 800) {
4906 $maxheightwin = $_SESSION[
"dol_screenheight"] - 490;
4910 $poscursor = array(
'x' =>
GETPOST(
'PAGE_CONTENT_x'),
'y' =>
GETPOST(
'PAGE_CONTENT_y'));
4911 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
4912 $doleditor =
new DolEditor(
'PAGE_CONTENT', $contentforedit,
'', $maxheightwin,
'Full',
'',
true,
true,
'ace', ROWS_5,
'40%', 0, $poscursor);
4913 $doleditor->Create(0,
'',
false,
'HTML Source',
'php');
4916if ($action ==
'editcontent') {
4919 $contentforedit =
'';
4923 $contentforedit .= $objectpage->content;
4928 $contentforedit = preg_replace(
'/(<img.*\ssrc=")(?!http|\/viewimage\.php|'.preg_quote(DOL_URL_ROOT,
'/').
'\/viewimage\.php)/',
'\1'.DOL_URL_ROOT.
'/viewimage.php?modulepart=medias&file=', $contentforedit, -1, $nbrep);
4930 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
4931 $poscursor = array(
'x' =>
GETPOST(
'PAGE_CONTENT_x'),
'y' =>
GETPOST(
'PAGE_CONTENT_y'));
4932 $doleditor =
new DolEditor(
'PAGE_CONTENT', $contentforedit,
'', 500,
'Full',
'',
true,
true,
true, ROWS_5,
'90%', 0, $poscursor);
4933 $doleditor->Create(0,
'',
false);
4940if ($mode ==
'replacesite' || $massaction ==
'replace') {
4941 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4942 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4943 print
'<input type="hidden" name="action" value="replacesiteconfirm">';
4944 print
'<input type="hidden" name="mode" value="replacesite">';
4945 print
'<input type="hidden" name="website" value="'.$website->ref.
'">';
4948 print
'<!-- Search page and replace string -->'.
"\n";
4949 print
'<div class="fiche"><br>';
4951 print
load_fiche_titre($langs->trans(
"ReplaceWebsiteContent"),
'',
'search');
4953 print
'<div class="fichecenter"><div class="fichehalfleft">';
4955 print
'<div class="tagtable">';
4957 print
'<div class="tagtr">';
4958 print
'<div class="tagtd paddingrightonly opacitymedium">';
4959 print $langs->trans(
"SearchReplaceInto");
4961 print
'<div class="tagtd">';
4962 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>';
4963 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>';
4964 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>';
4968 print
'<div class="tagtr">';
4969 print
'<div class="tagtd paddingrightonly opacitymedium" style="padding-right: 10px !important">';
4970 print $langs->trans(
"SearchString");
4972 print
'<div class="tagtd">';
4973 print
'<input type="text" name="searchstring" value="'.dol_escape_htmltag($searchkey, 0, 0,
'', 1).
'" autofocus>';
4979 print
'</div><div class="fichehalfleft">';
4981 print
'<div class="tagtable">';
4983 print
'<div class="tagtr">';
4984 print
'<div class="tagtd paddingrightonly opacitymedium tdoverflowmax100onsmartphone" style="padding-right: 10px !important">';
4985 print $langs->trans(
"WEBSITE_TYPE_CONTAINER");
4987 print
'<div class="tagtd">';
4988 print
img_picto(
'',
'object_technic',
'class="paddingrightonly"').
' ';
4989 print $formwebsite->selectTypeOfContainer(
'optioncontainertype', (
GETPOST(
'optioncontainertype',
'alpha') ?
GETPOST(
'optioncontainertype',
'alpha') :
''), 1,
'', 1,
'minwidth125 maxwidth400 widthcentpercentminusx');
4993 print
'<div class="tagtr">';
4994 print
'<div class="tagtd paddingrightonly opacitymedium tdoverflowmax100onsmartphone" style="padding-right: 10px !important">';
4995 print $langs->trans(
"Language");
4997 print
'<div class="tagtd">';
4998 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);
5003 if (isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire')) {
5004 print
'<div class="tagtr">';
5005 print
'<div class="tagtd paddingrightonly marginrightonly opacitymedium tdoverflowmax100onsmartphone" style="padding-right: 10px !important">';
5006 print $langs->trans(
"Category");
5008 print
'<div class="tagtd">';
5009 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');
5010 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
5018 print
'<input type="submit" class="button margintoponly" name="buttonreplacesitesearch" value="'.dol_escape_htmltag($langs->trans(
"Search")).
'">';
5020 print
'</div></div>';
5022 if ($mode ==
'replacesite') {
5023 print
'<!-- List of search result -->'.
"\n";
5024 print
'<div class="rowsearchresult clearboth">';
5029 if ($listofpages[
'code'] ==
'OK') {
5030 $arrayofselected = is_array($toselect) ? $toselect : array();
5032 $nbtotalofrecords = count($listofpages[
'list']);
5034 $permissiontodelete = $user->hasRight(
'website',
'delete');
5037 $arrayofmassactions = array();
5038 if ($user->hasRight(
'website',
'writephp') && $searchkey) {
5039 $arrayofmassactions[
'replace'] =
img_picto(
'',
'replacement',
'class="pictofixedwidth"').$langs->trans(
"Replace");
5041 if ($user->hasRight(
'website',
'write')) {
5042 $arrayofmassactions[
'setcategory'] =
img_picto(
'',
'category',
'class="pictofixedwidth"').$langs->trans(
"ClassifyInCategory");
5044 if ($user->hasRight(
'website',
'write')) {
5045 $arrayofmassactions[
'delcategory'] =
img_picto(
'',
'category',
'class="pictofixedwidth"').$langs->trans(
"RemoveCategory");
5047 if ($permissiontodelete) {
5048 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
5050 if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete'))) {
5051 $arrayofmassactions = array();
5054 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
5055 $massactionbutton .=
'<div class="massactionother massactionreplace hidden">';
5056 $massactionbutton .= $langs->trans(
"ReplaceString");
5057 $massactionbutton .=
' <input type="text" name="replacestring" value="'.dol_escape_htmltag(
GETPOST(
'replacestring',
'none')).
'">';
5058 $massactionbutton .=
'</div>';
5059 $massactionbutton .=
'<div class="massactionother massactionsetcategory massactiondelcategory hidden">';
5060 $massactionbutton .=
img_picto(
'',
'category',
'class="pictofixedwidth"');
5061 $massactionbutton .= $form->select_all_categories(Categorie::TYPE_WEBSITE_PAGE, GETPOSTISSET(
'setcategory') ?
GETPOST(
'setcategory') :
'',
'setcategory', 64, 0, 0, 0,
'minwidth300 alignstart');
5062 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
5064 $massactionbutton .=
'</div>';
5066 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
5069 $selectedfields =
'';
5070 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
5072 print_barre_liste($langs->trans(
"Results"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'generic', 0,
'',
'', $limit, 1, 1, 1);
5074 $topicmail =
"WebsitePageRef";
5075 $modelmail =
"websitepage_send";
5077 $trackid =
'wsp'.$object->id;
5078 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
5080 $param =
'mode=replacesite&website='.urlencode($website->ref);
5081 $param .=
'&searchstring='.urlencode($searchkey);
5082 if (
GETPOST(
'optioncontent')) {
5083 $param .=
'&optioncontent=content';
5086 $param .=
'&optionmeta=meta';
5088 if (
GETPOST(
'optionsitefiles')) {
5089 $param .=
'&optionsitefiles=optionsitefiles';
5091 if (
GETPOST(
'optioncontainertype')) {
5092 $param .=
'&optioncontainertype='.GETPOST(
'optioncontainertype',
'aZ09');
5094 if (
GETPOST(
'optionlanguage')) {
5095 $param .=
'&optionlanguage='.GETPOST(
'optionlanguage',
'aZ09');
5097 if (
GETPOST(
'optioncategory')) {
5098 $param .=
'&optioncategory='.GETPOST(
'optioncategory',
'aZ09');
5101 print
'<div class="div-table-responsive-no-min">';
5102 print
'<table class="noborder centpercent">';
5103 print
'<tr class="liste_titre">';
5106 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
5108 print
getTitleFieldOfList(
"Type", 0, $_SERVER[
'PHP_SELF'],
'type_container',
'', $param,
'', $sortfield, $sortorder,
'').
"\n";
5109 print
getTitleFieldOfList(
"Page", 0, $_SERVER[
'PHP_SELF'],
'pageurl',
'', $param,
'', $sortfield, $sortorder,
'').
"\n";
5110 print
getTitleFieldOfList(
"Language", 0, $_SERVER[
'PHP_SELF'],
'lang',
'', $param,
'', $sortfield, $sortorder,
'center ').
"\n";
5111 print
getTitleFieldOfList(
"Categories", 0, $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'center ').
"\n";
5113 print
getTitleFieldOfList(
"UserCreation", 0, $_SERVER[
'PHP_SELF'],
'fk_user_creat',
'', $param,
'', $sortfield, $sortorder,
'').
"\n";
5114 print
getTitleFieldOfList(
"DateCreation", 0, $_SERVER[
'PHP_SELF'],
'date_creation',
'', $param,
'', $sortfield, $sortorder,
'center ').
"\n";
5115 print
getTitleFieldOfList(
"DateLastModification", 0, $_SERVER[
'PHP_SELF'],
'tms',
'', $param,
'', $sortfield, $sortorder,
'center ').
"\n";
5119 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
5123 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
5128 foreach ($listofpages[
'list'] as $answerrecord) {
5129 if (is_object($answerrecord) && get_class($answerrecord) ==
'WebsitePage') {
5130 $param =
'?mode=replacesite';
5131 $param .=
'&websiteid='.$website->id;
5132 $param .=
'&optioncontent='.GETPOST(
'optioncontent',
'aZ09');
5133 $param .=
'&optionmeta='.GETPOST(
'optionmeta',
'aZ09');
5134 $param .=
'&optionsitefiles='.GETPOST(
'optionsitefiles',
'aZ09');
5135 $param .=
'&optioncontainertype='.GETPOST(
'optioncontainertype',
'aZ09');
5136 $param .=
'&optionlanguage='.GETPOST(
'optionlanguage',
'aZ09');
5137 $param .=
'&optioncategory='.GETPOST(
'optioncategory',
'aZ09');
5138 $param .=
'&searchstring='.urlencode($searchkey);
5144 print
'<td class="nowrap center">';
5146 print
'<!-- Status of page -->'.
"\n";
5147 if ($massactionbutton || $massaction) {
5149 if (in_array($answerrecord->id, $arrayofselected)) {
5152 print
'<input id="'.$answerrecord->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$answerrecord->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
5158 print
'<td class="nowraponall">';
5160 if (!empty($conf->cache[
'type_of_container'][