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($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') {
450 setEventMessages($langs->trans(
"FeatureNotYetAvailable"),
null,
'warnings');
452 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
GETPOST(
'website')).
'&pageid='.
GETPOSTINT(
'pageid'));
455if ($action ==
'unseteditinline') {
457 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
GETPOST(
'website')).
'&pageid='.
GETPOSTINT(
'pageid'));
460if ($action ==
'setshowsubcontainers') {
463 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
GETPOST(
'website')).
'&pageid='.
GETPOSTINT(
'pageid'));
466if ($action ==
'unsetshowsubcontainers') {
468 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
GETPOST(
'website')).
'&pageid='.
GETPOSTINT(
'pageid'));
472if ($massaction ==
'replace' &&
GETPOST(
'confirmmassaction',
'alpha') && !$searchkey && $usercanedit) {
473 $mode =
'replacesite';
474 $action =
'replacesite';
478if ($action ==
'deletetemplate' && $usercanedit) {
479 $dirthemes = array(
'/doctemplates/websites');
480 if (!empty($conf->modules_parts[
'websitetemplates'])) {
481 foreach ($conf->modules_parts[
'websitetemplates'] as $reldir) {
482 $dirthemes = array_merge($dirthemes, (array) ($reldir.
'doctemplates/websites'));
485 $dirthemes = array_unique($dirthemes);
489 $mode =
'importsite';
490 $action =
'importsite';
492 if (count($dirthemes)) {
494 foreach ($dirthemes as $dir) {
496 $dirtheme = DOL_DATA_ROOT.$dir;
497 if (is_dir($dirtheme)) {
498 $templateuserfile =
GETPOST(
'templateuserfile');
499 $imguserfile = preg_replace(
'/\.zip$/',
'', $templateuserfile).
'.jpg';
508if ($massaction ==
'setcategory' &&
GETPOST(
'confirmmassaction',
'alpha') && $usercanedit) {
515 if ($categoryid > 0) {
518 $category->fetch($categoryid);
520 foreach ($toselect as $tmpid) {
521 $tmpwebsitepage->id = $tmpid;
522 $result = $category->add_type($tmpwebsitepage,
'website_page');
523 if ($result < 0 && $result != -3) {
537 setEventMessages($langs->trans(
"RecordsModified", $nbupdate),
null,
'mesgs');
543 $listofpages =
getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters, -1);
547if ($massaction ==
'delcategory' &&
GETPOST(
'confirmmassaction',
'alpha') && $usercanedit) {
554 if ($categoryid > 0) {
557 $category->fetch($categoryid);
559 foreach ($toselect as $tmpid) {
560 $tmpwebsitepage->id = $tmpid;
561 $result = $category->del_type($tmpwebsitepage,
'website_page');
562 if ($result < 0 && $result != -3) {
576 setEventMessages($langs->trans(
"RecordsModified", $nbupdate),
null,
'mesgs');
582 $listofpages =
getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters, -1);
586if ($massaction ==
'replace' &&
GETPOST(
'confirmmassaction',
'alpha') && $usercanedit) {
587 $replacestring =
GETPOST(
'replacestring',
'restricthtmlallowunvalid');
589 $dolibarrdataroot = preg_replace(
'/([\\/]+)$/i',
'', DOL_DATA_ROOT);
590 $allowimportsite =
true;
591 if (
dol_is_file($dolibarrdataroot.
'/installmodules.lock')) {
592 $allowimportsite =
false;
595 if (!$allowimportsite) {
599 $message = $langs->trans(
'InstallModuleFromWebHasBeenDisabledContactUs');
602 $message = $langs->trans(
"InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.
'/installmodules.lock');
605 } elseif (!$user->hasRight(
'website',
'writephp')) {
607 } elseif (!$replacestring) {
612 foreach ($toselect as $keyselected) {
613 $objectpage = $listofpages[
'list'][$keyselected];
614 if ($objectpage->pageurl) {
615 dol_syslog(
"Replace string into page ".$objectpage->pageurl);
617 if (
GETPOST(
'optioncontent',
'aZ09')) {
618 $objectpage->content = str_replace($searchkey, $replacestring, $objectpage->content);
620 if (
GETPOST(
'optionmeta',
'aZ09')) {
621 $objectpage->title = str_replace($searchkey, $replacestring, $objectpage->title);
622 $objectpage->description = str_replace($searchkey, $replacestring, $objectpage->description);
623 $objectpage->keywords = str_replace($searchkey, $replacestring, $objectpage->keywords);
626 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
627 $filetpl = $pathofwebsite.
'/page'.$objectpage->id.
'.tpl.php';
632 setEventMessages(
'Failed to write file '.basename($filealias),
null,
'errors');
640 $objectpage->update($user);
644 $action =
'createcontainer';
650 if ($nbreplacement > 0) {
651 setEventMessages($langs->trans(
"ReplacementDoneInXPages", $nbreplacement),
null,
'mesgs');
654 $containertype =
GETPOST(
'optioncontainertype',
'aZ09') !=
'-1' ?
GETPOST(
'optioncontainertype',
'aZ09') :
'';
655 $langcode =
GETPOST(
'optionlanguage',
'aZ09');
656 $otherfilters = array();
658 $otherfilters[
'category'] =
GETPOSTINT(
'optioncategory');
662 $listofpages =
getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters);
692if ($action ==
'addsite' && $usercanedit) {
695 if (
GETPOST(
'virtualhost',
'alpha') && !preg_match(
'/^http/',
GETPOST(
'virtualhost',
'alpha'))) {
697 setEventMessages($langs->trans(
'ErrorURLMustStartWithHttp', $langs->transnoentitiesnoconv(
"VirtualHost")),
null,
'errors');
700 if (!$error && !
GETPOST(
'WEBSITE_REF',
'alpha')) {
702 $langs->load(
"errors");
703 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->transnoentities(
"WebsiteName")),
null,
'errors');
705 if (!$error && !preg_match(
'/^[a-z0-9_\-\.]+$/i',
GETPOST(
'WEBSITE_REF',
'alpha'))) {
707 $langs->load(
"errors");
708 setEventMessages($langs->transnoentities(
"ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities(
"Ref")),
null,
'errors');
712 $arrayotherlang = explode(
',',
GETPOST(
'WEBSITE_OTHERLANG',
'alphanohtml'));
713 foreach ($arrayotherlang as $key => $val) {
715 if (empty(trim($val))) {
718 $arrayotherlang[$key] = substr(trim($val), 0, 2);
722 $tmpobject->ref =
GETPOST(
'WEBSITE_REF',
'alpha');
723 $tmpobject->description =
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml');
724 $tmpobject->lang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
725 $tmpobject->otherlang = implode(
',', $arrayotherlang);
726 $tmpobject->virtualhost =
GETPOST(
'virtualhost',
'alpha');
728 $result = $tmpobject->create($user);
732 } elseif ($result < 0) {
743 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$tmpobject->ref);
747 $action =
'createsite';
756'@phan-var-force int $error';
759if ($action ==
'addcontainer' && $usercanedit) {
764 $objectpage->fk_website =
$object->id;
766 if (GETPOSTISSET(
'fetchexternalurl')) {
767 $urltograb =
GETPOST(
'externalurl',
'alpha');
768 $grabimages =
GETPOST(
'grabimages',
'alpha');
769 $grabimagesinto =
GETPOST(
'grabimagesinto',
'alpha');
771 include_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
774 if (empty($urltograb)) {
776 $langs->load(
"errors");
777 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"URL")),
null,
'errors');
778 $action =
'createcontainer';
779 } elseif (!preg_match(
'/^http/', $urltograb)) {
781 $langs->load(
"errors");
782 setEventMessages(
'Error URL must start with http:// or https://',
null,
'errors');
783 $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');
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',
'none'));
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',
'none'));
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');
2042 $objectpage->htmlheader = trim(
GETPOST(
'htmlheader',
'none'));
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 ($usercanedit && (($action ==
'updatesource' || $action ==
'updatecontent' || $action ==
'confirm_createfromclone' || $action ==
'confirm_createpagefromclone')
2194 || ($action ==
'preview' && (
GETPOST(
'refreshsite') ||
GETPOST(
'refreshpage') ||
GETPOST(
'preview'))))) {
2195 $object->fetch(0, $websitekey);
2198 if ($action ==
'confirm_createfromclone') {
2201 $objectnew =
new Website($db);
2207 $action =
'preview';
2214 $pageid =
$object->fk_default_home;
2215 $websitekey =
GETPOST(
'siteref',
'aZ09');
2221 if ($action ==
'confirm_createpagefromclone') {
2222 $istranslation = (
GETPOST(
'is_a_translation',
'aZ09') ==
'on' ? 1 : 0);
2224 if ($istranslation) {
2225 if (
GETPOST(
'newlang',
'aZ09') == $objectpage->lang || !
GETPOST(
'newlang',
'aZ09')) {
2227 setEventMessages($langs->trans(
"LanguageMustNotBeSameThanClonedPage"),
null,
'errors');
2228 $action =
'preview';
2232 setEventMessages($langs->trans(
"WebsiteMustBeSameThanClonedPageIfTranslation"),
null,
'errors');
2233 $action =
'preview';
2241 $pathofwebsitenew = $pathofwebsite;
2243 $tmpwebsite =
new Website($db);
2244 if ($newwebsiteid > 0 && $newwebsiteid !=
$object->id) {
2245 $tmpwebsite->fetch($newwebsiteid);
2246 $pathofwebsitenew = $dolibarr_main_data_root.($conf->entity > 1 ?
'/'.$conf->entity :
'').
'/website/'.$tmpwebsite->ref;
2252 $resultpage = $objectpage->createFromClone($user, $pageid,
GETPOST(
'newpageurl',
'aZ09'), (
GETPOST(
'newlang',
'aZ09') ?
GETPOST(
'newlang',
'aZ09') :
''), $istranslation, $newwebsiteid,
GETPOST(
'newtitle',
'alphanohtml'), $tmpwebsite);
2253 if ($resultpage < 0) {
2256 $action =
'createpagefromclone';
2260 $filetpl = $pathofwebsitenew.
'/page'.$resultpage->id.
'.tpl.php';
2261 $fileindex = $pathofwebsitenew.
'/index.php';
2262 $filewrapper = $pathofwebsitenew.
'/wrapper.php';
2271 if (empty($newwebsiteid) || $newwebsiteid ==
$object->id) {
2272 $pageid = $resultpage->id;
2284 $pathtomedias = DOL_DATA_ROOT.
'/medias';
2285 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
2287 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
2288 dol_mkdir(dirname($pathtomediasinwebsite));
2289 $result = symlink($pathtomedias, $pathtomediasinwebsite);
2298 $objectpage->fk_website =
$object->id;
2301 $res = $objectpage->fetch($pageid);
2304 if (
$object->fk_default_home > 0) {
2305 $res = $objectpage->fetch(
$object->fk_default_home);
2308 $res = $objectpage->fetch(0,
$object->id);
2313 if (!$error && $res > 0) {
2314 if ($action ==
'updatesource' || $action ==
'updatecontent') {
2319 $objectpage->content =
GETPOST(
'PAGE_CONTENT',
'none');
2324 $error =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
2327 if ($action ==
'updatesource') {
2328 $action =
'editsource';
2330 if ($action ==
'updatecontent') {
2331 $action =
'editcontent';
2336 $objectpage->content = preg_replace(
'/<head>.*<\/head>/ims',
'', $objectpage->content);
2340 $res = $objectpage->update($user);
2344 if ($action ==
'updatesource') {
2345 $action =
'editsource';
2347 if ($action ==
'updatecontent') {
2348 $action =
'editcontent';
2355 $filemaster = $pathofwebsite.
'/master.inc.php';
2357 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
2365 setEventMessages(
'Failed to write the master file file '.$filemaster,
null,
'errors');
2389 setEventMessages(
'Failed to write the alias file '.basename($filealias),
null,
'errors');
2397 if (!GETPOSTISSET(
'updateandstay')) {
2399 header(
"Location: ".$backtopage);
2402 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$websitekey.
'&pageid='.$pageid);
2406 if ($action ==
'updatesource') {
2407 $action =
'editsource';
2409 if ($action ==
'updatecontent') {
2410 $action =
'editcontent';
2415 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$websitekey.
'&pageid='.$pageid);
2422 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$websitekey.
'&pageid='.$pageid);
2427 if (empty($websitekey) || $websitekey ==
'-1') {
2428 setEventMessages($langs->trans(
"NoWebSiteCreateOneFirst"),
null,
'warnings');
2431 setEventMessages($langs->trans(
"YouCanCreatePageOrImportTemplate"),
null,
'warnings');
2437if ($action ==
'deletelang' && $usercanedit) {
2438 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"website_page SET fk_page = NULL";
2439 $sql .=
" WHERE rowid = ".GETPOSTINT(
'deletelangforid');
2442 $resql = $db->query($sql);
2446 $objectpage->fk_page =
null;
2449 $action =
'editmeta';
2454if ($action ==
'exportsite' && $user->hasRight(
'website',
'export')) {
2455 $fileofzip =
$object->exportWebSite();
2458 $file_name = basename($fileofzip);
2459 header(
"Content-Type: application/zip");
2460 header(
"Content-Disposition: attachment; filename=".$file_name);
2461 header(
"Content-Length: ".filesize($fileofzip));
2463 readfile($fileofzip);
2467 $action =
'preview';
2472if ($action ==
'overwritesite' && $user->hasRight(
'website',
'export')) {
2474 $fileofzip =
$object->exportWebSite();
2475 $pathToExport =
GETPOST(
'export_path');
2477 $object->overwriteTemplate($fileofzip, $pathToExport);
2484if ($action ==
'regeneratesite' && $usercanedit) {
2486 $pathtomedias = DOL_DATA_ROOT.
'/medias';
2487 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
2489 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
2490 dol_mkdir(dirname($pathtomediasinwebsite));
2491 $result = symlink($pathtomedias, $pathtomediasinwebsite);
2493 $langs->load(
"errors");
2494 setEventMessages($langs->trans(
"ErrorFailedToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias),
null,
'errors');
2495 $action =
'preview';
2499 $result =
$object->rebuildWebSiteFiles();
2501 setEventMessages($langs->trans(
"PagesRegenerated", $result),
null,
'mesgs');
2502 $action =
'preview';
2505 $action =
'preview';
2510if ($action ==
'importsiteconfirm' && $usercanedit) {
2511 $dolibarrdataroot = preg_replace(
'/([\\/]+)$/i',
'', DOL_DATA_ROOT);
2512 $allowimportsite =
true;
2513 if (
dol_is_file($dolibarrdataroot.
'/installmodules.lock')) {
2514 $allowimportsite =
false;
2517 if ($allowimportsite) {
2518 if (empty($_FILES) && !GETPOSTISSET(
'templateuserfile')) {
2519 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"File")),
null,
'errors');
2520 $action =
'importsite';
2522 if (!empty($_FILES) || GETPOSTISSET(
'templateuserfile')) {
2524 $pathtomedias = DOL_DATA_ROOT.
'/medias';
2525 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
2527 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
2528 dol_mkdir(dirname($pathtomediasinwebsite));
2529 $result = symlink($pathtomedias, $pathtomediasinwebsite);
2531 $langs->load(
"errors");
2532 setEventMessages($langs->trans(
"ErrorFailedToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias),
null,
'errors');
2533 $action =
'importsite';
2538 if (GETPOSTISSET(
'templateuserfile')) {
2540 $fileofzip = DOL_DATA_ROOT.
'/doctemplates/websites/'.
GETPOST(
'templateuserfile',
'alpha');
2541 } elseif (!empty($_FILES) && is_array($_FILES[
'userfile'])) {
2543 if (is_array($_FILES[
'userfile'][
'tmp_name'])) {
2544 $userfiles = $_FILES[
'userfile'][
'tmp_name'];
2546 $userfiles = array($_FILES[
'userfile'][
'tmp_name']);
2550 foreach ($userfiles as $key => $userfile) {
2551 if (empty($_FILES[
'userfile'][
'tmp_name'][$key])) {
2553 if ($_FILES[
'userfile'][
'error'][$key] == 1 || $_FILES[
'userfile'][
'error'][$key] == 2) {
2555 $action =
'importsite';
2557 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"File")),
null,
'errors');
2558 $action =
'importsite';
2565 $upload_dir = DOL_DATA_ROOT.
'/doctemplates/websites/';
2579 $action =
'importsite';
2582 if (!$error && GETPOSTISSET(
'templateuserfile')) {
2583 $templatewithoutzip = preg_replace(
'/\.zip$/i',
'',
GETPOST(
'templateuserfile'));
2584 $object->setTemplateName($templatewithoutzip);
2586 $result =
$object->importWebSite($fileofzip);
2590 $action =
'importsite';
2593 dolibarr_set_const($db,
'WEBSITE_SUBCONTAINERSINLINE', 1,
'chaine', 0,
'', $conf->entity);
2595 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.
$object->ref);
2604 $message = $langs->trans(
'InstallModuleFromWebHasBeenDisabledContactUs');
2607 $message = $langs->trans(
"InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.
'/installmodules.lock');
2613$domainname =
'0.0.0.0:8080';
2614$tempdir = $conf->website->dir_output.
'/'.$websitekey.
'/';
2617if ($action ==
'generatesitemaps' && $usercanedit) {
2619 if ($website->virtualhost) {
2620 $domainname = $website->virtualhost;
2622 if (! preg_match(
'/^http/i', $domainname)) {
2623 $domainname =
'https://'.$domainname;
2626 $domtree =
new DOMDocument(
'1.0',
'UTF-8');
2628 $root = $domtree->createElementNS(
'http://www.sitemaps.org/schemas/sitemap/0.9',
'urlset');
2629 $root->setAttributeNS(
'http://www.w3.org/2000/xmlns/',
'xmlns:xhtml',
'http://www.w3.org/1999/xhtml');
2631 $domtree->formatOutput =
true;
2634 $xmlname =
'sitemap.xml';
2636 $sql =
"SELECT wp.rowid, wp.type_container , wp.pageurl, wp.lang, wp.fk_page, wp.tms as tms,";
2637 $sql .=
" w.virtualhost, w.fk_default_home";
2638 $sql .=
" FROM ".MAIN_DB_PREFIX.
"website_page as wp, ".MAIN_DB_PREFIX.
"website as w";
2639 $sql .=
" WHERE wp.type_container IN ('page', 'blogpost')";
2640 $sql .=
" AND wp.fk_website = w.rowid";
2641 $sql .=
" AND wp.status = ".WebsitePage::STATUS_VALIDATED;
2642 $sql .=
" AND wp.pageurl NOT IN ('404', '500', '501', '503')";
2643 $sql .=
" AND w.ref = '".dol_escape_json($websitekey).
"'";
2644 $sql .=
" ORDER BY wp.tms DESC, wp.rowid DESC";
2645 $resql = $db->query($sql);
2647 $num_rows = $db->num_rows($resql);
2648 if ($num_rows > 0) {
2650 while ($i < $num_rows) {
2651 $objp = $db->fetch_object($resql);
2652 $url = $domtree->createElement(
'url');
2654 $shortlangcode =
'';
2656 $shortlangcode = substr($objp->lang, 0, 2);
2658 if (empty($shortlangcode)) {
2659 $shortlangcode = substr(
$object->lang, 0, 2);
2663 if ($objp->type_container ==
'blogpost') {
2668 $pageurl = $objp->pageurl.
'.php';
2669 if ($objp->fk_default_home == $objp->rowid) {
2672 if ($shortlangcode != substr(
$object->lang, 0, 2)) {
2673 $pageurl = $shortlangcode.
'/'.$pageurl;
2680 $loc = $domtree->createElement(
'loc', $domainname.
'/'.$pageurl);
2681 $lastmod = $domtree->createElement(
'lastmod',
dol_print_date($db->jdate($objp->tms),
'dayrfc',
'gmt'));
2682 $priority = $domtree->createElement(
'priority',
'1');
2684 $url->appendChild($loc);
2685 $url->appendChild($lastmod);
2688 $changefreq = $domtree->createElement(
'changefreq',
'weekly');
2689 $url->appendChild($changefreq);
2692 if ($objp->fk_default_home == $objp->rowid) {
2693 $url->appendChild($priority);
2698 $alternatefound = 0;
2701 $translationof = $objp->fk_page;
2702 if ($translationof) {
2704 $tmppage->fetch($translationof);
2705 if ($tmppage->id > 0) {
2706 $tmpshortlangcode =
'';
2707 if ($tmppage->lang) {
2708 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'', $tmppage->lang);
2710 if (empty($tmpshortlangcode)) {
2711 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'',
$object->lang);
2713 if ($tmpshortlangcode != $shortlangcode) {
2714 $xhtmllink = $domtree->createElement(
'xhtml:link',
'');
2715 $xhtmllink->setAttribute(
"rel",
"alternate");
2716 $xhtmllink->setAttribute(
"hreflang", $tmpshortlangcode);
2717 $xhtmllink->setAttribute(
"href", $domainname.($objp->fk_default_home == $tmppage->id ?
'/' : (($tmpshortlangcode != substr(
$object->lang, 0, 2)) ?
'/'.$tmpshortlangcode :
'').
'/'.$tmppage->pageurl.
'.php'));
2718 $url->appendChild($xhtmllink);
2726 $sql =
'SELECT rowid as id, lang, pageurl from '.MAIN_DB_PREFIX.
'website_page';
2727 $sql .=
" WHERE status = ".((int) WebsitePage::STATUS_VALIDATED).
' AND fk_page IN ('.$db->sanitize($objp->rowid.($translationof ?
", ".$translationof :
"")).
")";
2728 $resqlhastrans = $db->query($sql);
2729 if ($resqlhastrans) {
2730 $num_rows_hastrans = $db->num_rows($resqlhastrans);
2731 if ($num_rows_hastrans > 0) {
2732 while ($objhastrans = $db->fetch_object($resqlhastrans)) {
2733 $tmpshortlangcode =
'';
2734 if ($objhastrans->lang) {
2735 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'', $objhastrans->lang);
2737 if ($tmpshortlangcode != $shortlangcode) {
2738 $xhtmllink = $domtree->createElement(
'xhtml:link',
'');
2739 $xhtmllink->setAttribute(
"rel",
"alternate");
2740 $xhtmllink->setAttribute(
"hreflang", $tmpshortlangcode);
2741 $xhtmllink->setAttribute(
"href", $domainname.($objp->fk_default_home == $objhastrans->id ?
'/' : (($tmpshortlangcode != substr(
$object->lang, 0, 2) ?
'/'.$tmpshortlangcode :
'')).
'/'.$objhastrans->pageurl.
'.php'));
2742 $url->appendChild($xhtmllink);
2752 if ($alternatefound) {
2754 $xhtmllink = $domtree->createElement(
'xhtml:link',
'');
2755 $xhtmllink->setAttribute(
"rel",
"alternate");
2756 $xhtmllink->setAttribute(
"hreflang", $shortlangcode);
2757 $xhtmllink->setAttribute(
"href", $domainname.
'/'.$pageurl);
2758 $url->appendChild($xhtmllink);
2774 $root->appendChild($url);
2780 if ($addrsswrapper &&
getDolGlobalInt(
'WEBSITE_ADD_RSS_FEED_INTO_SITEMAP')) {
2781 $url = $domtree->createElement(
'url');
2783 $pageurl =
'wrapper.php?rss=1';
2786 $loc = $domtree->createElement(
'loc', $domainname.
'/'.$pageurl);
2787 $lastmod = $domtree->createElement(
'lastmod',
dol_print_date($db->jdate(
dol_now()),
'dayrfc',
'gmt'));
2789 $url->appendChild($loc);
2790 $url->appendChild($lastmod);
2793 $changefreq = $domtree->createElement(
'changefreq',
'weekly');
2794 $url->appendChild($changefreq);
2797 $root->appendChild($url);
2800 $domtree->appendChild($root);
2802 if ($domtree->save($tempdir.$xmlname)) {
2804 setEventMessages($langs->trans(
"SitemapGenerated", $xmlname),
null,
'mesgs');
2814 $robotcontent = @file_get_contents($filerobot);
2815 $result = preg_replace(
'/<?php \/\/ BEGIN PHP[^?]END PHP ?>\n/ims',
'', $robotcontent);
2817 $robotcontent = $result;
2819 $robotsitemap =
"Sitemap: ".$domainname.
"/".$xmlname;
2820 $result = strpos($robotcontent,
'Sitemap: ');
2822 $result = preg_replace(
'/Sitemap:.*/', $robotsitemap, $robotcontent);
2823 $robotcontent = $result ? $result : $robotcontent;
2825 $robotcontent .= $robotsitemap.
"\n";
2832 $action =
'preview';
2840$form =
new Form($db);
2847if ($action ==
'confirmgeneratesitemaps') {
2848 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?website='.urlencode($website->ref), $langs->trans(
'ConfirmSitemapsCreation'), $langs->trans(
'ConfirmGenerateSitemaps',
$object->ref),
'generatesitemaps',
'',
"yes", 1);
2849 $action =
'preview';
2851$helpurl =
'EN:Module_Website|FR:Module_Website_FR|ES:Módulo_Website';
2854 '/includes/ace/src/ace.js',
2855 '/includes/ace/src/ext-statusbar.js',
2856 '/includes/ace/src/ext-language_tools.js',
2860$arrayofcss = array();
2865$arrayofjs[] =
'includes/jquery/plugins/blockUI/jquery.blockUI.js';
2866$arrayofjs[] =
'core/js/blockUI.js';
2868 $arrayofjs[] =
"includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js";
2871$moreheadjs .=
'<script type="text/javascript">'.
"\n";
2872$moreheadjs .=
'var indicatorBlockUI = \''.DOL_URL_ROOT.
"/theme/".$conf->theme.
"/img/working.gif".
'\';
'."\n";
2873$moreheadjs .= '</script>
'."\n";
2875llxHeader($moreheadcss.$moreheadjs, $langs->trans("Website").(empty($website->ref) ? '' : ' -
'.$website->ref), $helpurl, '', 0, 0, $arrayofjs, $arrayofcss, '', '', '<!-- Begin div
class=
"fiche" -->
'."\n".'<div
class=
"fichebutwithotherclass">
');
2878print '<!-- Open form
for all page -->
'."\n";
2879print '<form action=
"'.$_SERVER["PHP_SELF
"].($action == 'file_manager' ? '?uploadform=1' : '').'" method=
"POST" enctype=
"multipart/form-data" class=
"websiteformtoolbar">
';
2880print '<input
type=
"hidden" name=
"token" value=
"'.newToken().'">
';
2881print '<input
type=
"hidden" name=
"backtopage" value=
"'.$backtopage.'">
';
2882print '<input
type=
"hidden" name=
"dol_openinpopup" value=
"'.$dol_openinpopup.'">
';
2884if ($action == 'createsite
') {
2885 print '<input
type=
"hidden" name=
"action" value=
"addsite">
';
2887if ($action == 'createcontainer
') {
2888 print '<input
type=
"hidden" name=
"action" value=
"addcontainer">
';
2890if ($action == 'editcss
') {
2891 print '<input
type=
"hidden" name=
"action" value=
"updatecss">
';
2893if ($action == 'editmenu
') {
2894 print '<input
type=
"hidden" name=
"action" value=
"updatemenu">
';
2896if ($action == 'setashome
') {
2897 print '<input
type=
"hidden" name=
"action" value=
"updateashome">
';
2899if ($action == 'editmeta
') {
2900 print '<input
type=
"hidden" name=
"action" value=
"updatemeta">
';
2902if ($action == 'editsource
') {
2903 print '<input
type=
"hidden" name=
"action" value=
"updatesource">
';
2905if ($action == 'editcontent
') {
2906 print '<input
type=
"hidden" name=
"action" value=
"updatecontent">
';
2908if ($action == 'edit
') {
2909 print '<input
type=
"hidden" name=
"action" value=
"update">
';
2911if ($action == 'importsite
') {
2912 print '<input
type=
"hidden" name=
"action" value=
"importsiteconfirm">
';
2914if ($action == 'file_manager
') {
2915 print '<input
type=
"hidden" name=
"action" value=
"file_manager">
';
2918 print '<input
type=
"hidden" name=
"mode" value=
"'.$mode.'">
';
2923// Add a margin under toolbar ?
2925if ($action != 'preview
' && $action != 'editcontent
' && $action != 'editsource
' && !GETPOST('createpagefromclone
', 'alphanohtml
')) {
2926 $style = ' margin-bottom: 5px;
';
2930if (!GETPOST('hide_websitemenu
')) {
2932 if (!$user->hasRight('website
', 'write
')) {
2933 $disabled = ' disabled=
"disabled"';
2935 $disabledexport = '';
2936 if (!$user->hasRight('website
', 'export
')) {
2937 $disabledexport = ' disabled=
"disabled"';
2942 $dataroot = DOL_DATA_ROOT.($conf->entity > 1 ? '/
'.$conf->entity : '').'/website/
'.$websitekey;
2943 if (!empty($object->virtualhost)) {
2944 $virtualurl = $object->virtualhost;
2949 if ($object->id > 0) {
2950 $array = $objectpage->fetchAll($object->id, 'ASC,ASC
', 'type_container,pageurl
');
2951 $object->lines = $array;
2953 if (!is_array($array) && $array < 0) {
2954 dol_print_error(null, $objectpage->error, $objectpage->errors);
2956 $atleastonepage = (is_array($array) && count($array) > 0);
2958 $websitepage = new WebsitePage($db);
2960 $websitepage->fetch($pageid);
2964 //var_dump($objectpage);exit;
2965 print '<div
class=
"centpercent websitebar'.(GETPOST('dol_openinpopup', 'aZ09') ? ' hiddenforpopup' : '').'">
';
2968 // Toolbar for websites
2971 print '<!-- Toolbar
for website -->
';
2972 if ($action != 'file_manager
') {
2973 print '<div
class=
"websiteselection hideonsmartphoneimp minwidth75 tdoverflowmax100 inline-block">
';
2974 print $langs->trans("Website").':
';
2977 // Button Add new website
2978 $urltocreatenewwebsite = $_SERVER["PHP_SELF"].'?action=createsite
';
2979 print '<span
class=
"websiteselection paddingrightonly">
';
2980 print '<a href=
"'.$urltocreatenewwebsite.'" class=
""'.$disabled.' title=
"'.dol_escape_htmltag($langs->trans("AddWebsite
")).'"><span
class=
"fa fa-plus-circle valignmiddle btnTitle-icon"><span></a>
';
2984 print '<span
class=
"websiteselection nopaddingrightimp">
';
2987 $out .= '<select
name=
"website" class=
"minwidth100 width200 maxwidth150onsmartphone" id=
"website">
';
2988 if (empty($listofwebsites)) {
2989 $out .= '<option value=
"-1"> </option>
';
2992 // Loop on each sites
2994 foreach ($listofwebsites as $key => $valwebsite) {
2995 if (empty($websitekey)) {
2996 if ($action != 'createsite
') {
2997 $websitekey = $valwebsite->ref;
3001 $out .= '<option value=
"'.$valwebsite->ref.'"';
3002 if ($websitekey == $valwebsite->ref) {
3003 $out .= ' selected
'; // To preselect a value
3005 //$outoption = $valwebsite->getLibStatut(3).' '.$valwebsite->ref.' ';
3006 $outoption = (($valwebsite->status == $valwebsite::STATUS_DRAFT) ? '<span
class=
"opacitymedium">
' : '').$valwebsite->ref.(($valwebsite->status == $valwebsite::STATUS_DRAFT) ? '</span>
' : '');
3007 $out .= ' data-html=
"'.dol_escape_htmltag($outoption).'"';
3009 $out .= $valwebsite->ref;
3010 $out .= '</option>
';
3013 $out .= '</select>
';
3014 $out .= ajax_combobox('website
');
3016 if (!empty($conf->use_javascript_ajax)) {
3017 $out .= '<script
type=
"text/javascript">
';
3018 $out .= 'jQuery(document).ready(
function () {
';
3019 $out .= ' jQuery(
"#website").change(
function () {
';
3020 $out .= ' console.log(
"We select "+jQuery(
"#website option:selected").val());
';
3021 $out .= ' if (jQuery(
"#website option:selected").val() == \
'-2\') {';
3022 $out .=
' window.location.href = "'.dol_escape_js($urltocreatenewwebsite).
'";';
3023 $out .=
' } else {';
3024 $out .=
' window.location.href = "'.$_SERVER[
"PHP_SELF"].
'?website="+jQuery("#website option:selected").val();';
3028 $out .=
'</script>';
3035 if (!empty($conf->use_javascript_ajax)) {
3036 print
'<span class="websiteselection">';
3041 if ($website->status == $website::STATUS_DRAFT) {
3042 $text_off =
'Offline';
3043 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>';
3045 $text_off =
'Online';
3046 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>';
3052 if (empty($conf->use_javascript_ajax)) {
3053 print
'<span class="websiteselection">';
3054 print
'<input type="image" class="valignmiddle" src="'.img_picto(
'',
'refresh',
'', 0, 1).
'" name="refreshsite" value="'.$langs->trans(
"Load").
'">';
3059 print
'<span class="websiteselection">';
3061 if ($websitekey && $websitekey !=
'-1' && ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite')) {
3063 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>';
3066 $importlabel = $langs->trans(
"ImportSite");
3067 $exportlabel = $langs->trans(
"ExportSite");
3068 if (!empty($conf->dol_optimize_smallscreen)) {
3069 $importlabel = $langs->trans(
"Import");
3070 $exportlabel = $langs->trans(
"Export");
3073 if ($atleastonepage) {
3074 print
'<input type="submit" class="button bordertransp" disabled="disabled" value="'.dol_escape_htmltag($importlabel).
'" name="importsite">';
3076 print
'<input type="submit" class="button bordertransp"'.$disabled.
' value="'.
dol_escape_htmltag($importlabel).
'" name="importsite">';
3080 $extraCssClass =
getDolGlobalString(
'WEBSITE_ALLOW_OVERWRITE_GIT_SOURCE') ?
'hideobject' :
'';
3081 print
'<input type="submit" class="button bordertransp ' . $extraCssClass .
'" ' . $disabledexport .
' value="' .
dol_escape_htmltag($exportlabel) .
'" name="exportsite">';
3085 $overwriteGitUrl = $_SERVER[
"PHP_SELF"] .
'?action=overwritesite&website=' . urlencode($website->ref);
3086 print
dolButtonToOpenExportDialog(
'exportpopup', $langs->trans(
'ExportOptions'), $langs->trans(
'ExportSite'),
'exportsite', $overwriteGitUrl, $website);
3091 print
'<input type="submit" class="button bordertransp"'.$disabled.
' value="'.
dol_escape_htmltag($langs->trans(
"CloneSite")).
'" name="createfromclone">';
3094 if (!$permissiontodelete) {
3095 $disabled =
' disabled="disabled"';
3096 $title = $langs->trans(
"NotEnoughPermissions");
3099 if ($website->status == $website::STATUS_VALIDATED) {
3100 $disabled =
' disabled="disabled"';
3101 $title = $langs->trans(
"WebsiteMustBeDisabled", $langs->transnoentitiesnoconv($website->LibStatut(0, 0)));
3105 $title = $langs->trans(
"Delete");
3106 $url = $_SERVER[
"PHP_SELF"].
'?action=deletesite&token='.
newToken().
'&website='.urlencode($website->ref);
3109 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>';
3112 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>';
3115 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>';
3118 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>';
3123 if ($websitekey && $websitekey !=
'-1' && ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite')) {
3124 print
'<span class="websiteselection">';
3126 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);
3128 if (isModEnabled(
'category')) {
3130 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);
3136 print
'<input type="hidden" name="website" id="website" value="'.$websitekey.
'">';
3140 print
'<span class="websitetools">';
3142 if ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite') {
3143 $urlext = $virtualurl;
3144 $urlint = $urlwithroot.
'/public/website/index.php?website='.$websitekey;
3146 print
'<span class="websiteinputurl valignmiddle" id="websiteinputurl">';
3147 $linktotestonwebserver =
'<a href="'.($virtualurl ? $virtualurl :
'#').
'" class="valignmiddle">';
3148 $linktotestonwebserver .=
'<span class="hideonsmartphone paddingrightonly">'.$langs->trans(
"TestDeployOnWeb", $virtualurl).
'</span>'.
img_picto(
'',
'globe');
3149 $linktotestonwebserver .=
'</a>';
3152 if (empty(
$object->fk_default_home)) {
3153 $htmltext .=
'<br><span class="error">'.$langs->trans(
"YouMustDefineTheHomePage").
'</span><br><br>';
3154 } elseif (empty($virtualurl)) {
3157 $htmltext .=
'<br><center>'.$langs->trans(
"GoTo").
' <a href="'.$virtualurl.
'" target="_website">'.$virtualurl.
'</a></center><br>';
3160 $htmltext .=
'<!-- Message defined translate key set into WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER -->';
3161 $htmltext .=
'<br>'.$langs->trans(
getDolGlobalString(
'WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER'));
3163 $htmltext .= $langs->trans(
"ToDeployYourWebsiteOnLiveYouHave3Solutions").
'<br><br>';
3164 $htmltext .=
'<div class="titre inline-block">1</div> - '.$langs->trans(
"SetHereVirtualHost", $dataroot);
3165 $htmltext .=
'<br>';
3166 $htmltext .=
'<br>'.$langs->trans(
"CheckVirtualHostPerms", $langs->transnoentitiesnoconv(
"ReadPerm"), DOL_DOCUMENT_ROOT);
3167 $htmltext .=
'<br>'.$langs->trans(
"CheckVirtualHostPerms", $langs->transnoentitiesnoconv(
"WritePerm"),
'{s1}');
3168 $htmltext = str_replace(
'{s1}', DOL_DATA_ROOT.
'/website<br>'.DOL_DATA_ROOT.
'/medias', $htmltext);
3170 $examplewithapache =
"<VirtualHost *:80>\n";
3171 $examplewithapache .=
'#php_admin_value open_basedir /tmp/:'.DOL_DOCUMENT_ROOT.
':'.DOL_DATA_ROOT.
':/dev/urandom'.
"\n";
3172 $examplewithapache .=
"\n";
3173 $examplewithapache .=
'DocumentRoot "'.DOL_DOCUMENT_ROOT.
'"'.
"\n";
3174 $examplewithapache .=
"\n";
3175 $examplewithapache .=
'<Directory "'.DOL_DOCUMENT_ROOT.
'">'.
"\n";
3176 $examplewithapache .=
'AllowOverride FileInfo Options
3177 Options -Indexes -MultiViews -FollowSymLinks -ExecCGI
3179 </Directory>'.
"\n".
'
3180 <Directory "'.DOL_DATA_ROOT.
'/website">
3181 AllowOverride FileInfo Options
3182 Options -Indexes -MultiViews +FollowSymLinks -ExecCGI
3184 </Directory>'.
"\n".
'
3185 <Directory "'.DOL_DATA_ROOT.
'/medias">
3186 AllowOverride FileInfo Options
3187 Options -Indexes -MultiViews -FollowSymLinks -ExecCGI
3191 $examplewithapache .=
"\n";
3192 $examplewithapache .=
"#ErrorLog /var/log/apache2/".$websitekey.
"_error_log\n";
3193 $examplewithapache .=
"#TransferLog /var/log/apache2/".$websitekey.
"_access_log\n";
3195 $examplewithapache .=
"</VirtualHost>\n";
3197 $htmltext .=
'<br>'.$langs->trans(
"ExampleToUseInApacheVirtualHostConfig").
':<br>';
3198 $htmltext .=
'<div class="quatrevingtpercent exampleapachesetup wordbreak" spellcheck="false">'.dol_nl2br(
dol_escape_htmltag($examplewithapache, 1, 1)).
'</div>';
3200 $htmltext .=
'<br>';
3201 $htmltext .=
'<div class="titre inline-block">2</div> - '.$langs->trans(
"YouCanAlsoTestWithPHPS");
3202 $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>';
3204 $htmltext .=
'<br>';
3205 $htmltext .=
'<div class="titre inline-block">3</div> - '.$langs->trans(
"YouCanAlsoDeployToAnotherWHP");
3207 print $form->textwithpicto($linktotestonwebserver, $htmltext, 1,
'none',
'valignmiddle', 0, 3,
'helpvirtualhost');
3211 if (in_array($action, array(
'editcss',
'editmenu',
'file_manager',
'replacesiteconfirm')) || in_array($mode, array(
'replacesite'))) {
3212 if ($action ==
'editcss') {
3215 $stringforfirstkey = $langs->trans(
"KeyboardShortcut");
3216 if ($conf->browser->name ==
'chrome') {
3217 $stringforfirstkey .=
' ALT +';
3218 } elseif ($conf->browser->name ==
'firefox') {
3219 $stringforfirstkey .=
' ALT + SHIFT +';
3221 $stringforfirstkey .=
' CTL +';
3224 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">';
3226 if (preg_match(
'/^create/', $action) && $action !=
'file_manager' && $action !=
'replacesite' && $action !=
'replacesiteconfirm') {
3227 print
'<input type="submit" id="savefile" class="button buttonforacesave button-save small" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
3229 if (preg_match(
'/^edit/', $action) && $action !=
'file_manager' && $action !=
'replacesite' && $action !=
'replacesiteconfirm') {
3230 print
'<input type="submit" id="savefile" class="button buttonforacesave button-save small" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
3232 if ($action !=
'preview') {
3233 print
'<input type="submit" class="button button-cancel small" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'" name="cancel">';
3243 if ($websitekey && $websitekey !=
'-1' && (!in_array($action, array(
'editcss',
'editmenu',
'importsite',
'file_manager',
'replacesite',
'replacesiteconfirm'))) && (!in_array($mode, array(
'replacesite'))) && !$file_manager) {
3246 print
'<!-- Toolbar for websitepage -->';
3247 print
'<div class="centpercent websitebar"'.($style ?
' style="'.$style.
'"' :
'').
'>';
3249 print
'<div class="websiteselection hideonsmartphoneimp minwidth75 tdoverflowmax100 inline-block">';
3250 print $langs->trans(
"PageContainer").
': ';
3254 print
'<span class="websiteselection paddingrightonly">';
3255 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>';
3261 $s = $formwebsite->selectContainer($website,
'pageid', $pageid, 0, $action,
'minwidth100 maxwidth200onsmartphone');
3263 $out .=
'<span class="websiteselection nopaddingrightimp">';
3267 $urltocreatenewpage = $_SERVER[
"PHP_SELF"].
'?action=createcontainer&token='.
newToken().
'&website='.urlencode($website->ref);
3269 if (!empty($conf->use_javascript_ajax)) {
3270 $out .=
'<script type="text/javascript">';
3271 $out .=
'jQuery(document).ready(function () {';
3272 $out .=
' jQuery("#pageid").change(function () {';
3273 $out .=
' console.log("We select "+jQuery("#pageid option:selected").val());';
3274 $out .=
' if (jQuery("#pageid option:selected").val() == \'-2\') {';
3275 $out .=
' window.location.href = "'.$urltocreatenewpage.
'";';
3276 $out .=
' } else {';
3277 $out .=
' window.location.href = "'.$_SERVER[
"PHP_SELF"].
'?website='.urlencode($website->ref).
'&pageid="+jQuery("#pageid option:selected").val();';
3281 $out .=
'</script>';
3287 if (!empty($conf->use_javascript_ajax)) {
3288 print
'<span class="websiteselection">';
3290 if (
$object->status == $object::STATUS_DRAFT) {
3291 $text_off =
'SetWebsiteOnlineBefore';
3292 if ($websitepage->status == $websitepage::STATUS_DRAFT) {
3293 print
'<span class="valignmiddle disabled opacitymedium">'.img_picto($langs->trans($text_off),
'switch_off').
'</span>';
3295 print
'<span class="valignmiddle disabled opacitymedium">'.img_picto($langs->trans($text_off),
'switch_on').
'</span>';
3298 print
ajax_object_onoff($websitepage,
'status',
'status',
'Online',
'Offline', array(),
'valignmiddle inline-block'.(empty($websitepage->id) ?
' opacitymedium disabled' :
''),
'statuswebsitepage', 1,
'pageid='.$websitepage->id);
3304 print
'<span class="websiteselection">';
3306 print
'<input type="image" class="valignmiddle buttonwebsite" src="'.img_picto(
'',
'refresh',
'', 0, 1).
'" name="refreshpage" value="'.$langs->trans(
"Load").
'"'.(($action !=
'editsource') ?
'' :
' disabled="disabled"').
'>';
3309 $pagepreviousid = 0;
3312 $sql =
"SELECT MAX(rowid) as pagepreviousid FROM ".MAIN_DB_PREFIX.
"website_page WHERE rowid < ".((int) $pageid).
" AND fk_website = ".((int)
$object->id);
3313 $resql = $db->query($sql);
3315 $obj = $db->fetch_object($resql);
3317 $pagepreviousid = $obj->pagepreviousid;
3322 $sql =
"SELECT MIN(rowid) as pagenextid FROM ".MAIN_DB_PREFIX.
"website_page WHERE rowid > ".((int) $pageid).
" AND fk_website = ".((int)
$object->id);
3323 $resql = $db->query($sql);
3325 $obj = $db->fetch_object($resql);
3327 $pagenextid = $obj->pagenextid;
3334 if ($pagepreviousid) {
3335 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>';
3337 print
'<span class="valignmiddle opacitymedium">'.img_previous($langs->trans(
"PreviousContainer")).
'</span>';
3340 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>';
3342 print
'<span class="valignmiddle opacitymedium">'.img_next($langs->trans(
"NextContainer")).
'</span>';
3347 if ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite') {
3349 if (!$user->hasRight(
'website',
'write')) {
3350 $disabled =
' disabled="disabled"';
3354 if ($action ==
'deletesite') {
3356 $formquestion = array(
3357 array(
'type' =>
'checkbox',
'name' =>
'delete_also_js',
'label' => $langs->trans(
"DeleteAlsoJs"),
'value' => 0),
3358 array(
'type' =>
'checkbox',
'name' =>
'delete_also_medias',
'label' => $langs->trans(
"DeleteAlsoMedias"),
'value' => 0),
3363 if ($atleastonepage) {
3364 $langs->load(
"errors");
3365 $formquestion[] = array(
'type' =>
'onecolumn',
'value' =>
'<div class="warning">'.$langs->trans(
"WarningPagesWillBeDeleted").
'</div>');
3368 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteWebsite'),
'',
'confirm_deletesite', $formquestion, 0, 1, 210 + ($atleastonepage ? 70 : 0), 580);
3374 if ($action ==
'createfromclone') {
3376 $formquestion = array(
3377 array(
'type' =>
'text',
'name' =>
'siteref',
'label' => $langs->trans(
"WebSite"),
'value' =>
'copy_of_'.$object->ref)
3380 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'CloneSite'),
'',
'confirm_createfromclone', $formquestion, 0, 1, 200);
3385 if ($pageid > 0 && $atleastonepage) {
3387 if ($action ==
'createpagefromclone') {
3389 $preselectedlanguage =
GETPOST(
'newlang',
'aZ09') ?
GETPOST(
'newlang',
'aZ09') :
'';
3390 $onlylang = array();
3391 if ($website->otherlang) {
3392 if (!empty($website->lang)) {
3393 $onlylang[$website->lang] = $website->lang.
' ('.$langs->trans(
"Default").
')';
3395 foreach (explode(
',', $website->otherlang) as $langkey) {
3396 if (empty(trim($langkey))) {
3399 $onlylang[$langkey] = $langkey;
3401 $textifempty = $langs->trans(
"Default");
3403 $onlylang[
'none'] =
'none';
3404 $textifempty = $langs->trans(
"Default");
3406 $formquestion = array(
3407 array(
'type' =>
'hidden',
'name' =>
'sourcepageurl',
'value' => $objectpage->pageurl),
3408 array(
'type' =>
'other',
'tdclass' =>
'fieldrequired',
'name' =>
'newwebsite',
'label' => $langs->trans(
"WebSite"),
'value' => $formwebsite->selectWebsite(
$object->id,
'newwebsite', 0)),
3409 array(
'type' =>
'text',
'tdclass' =>
'maxwidth200 fieldrequired',
'moreattr' =>
'autofocus="autofocus"',
'name' =>
'newtitle',
'label' => $langs->trans(
"WEBSITE_TITLE"),
'value' => $langs->trans(
"CopyOf").
' '.$objectpage->title),
3410 array(
'type' =>
'text',
'tdclass' =>
'maxwidth200',
'name' =>
'newpageurl',
'label' => $langs->trans(
"WEBSITE_PAGENAME"),
'value' =>
'')
3412 if (count($onlylang) > 1) {
3413 $formquestion[] = array(
'type' =>
'checkbox',
'tdclass' =>
'maxwidth200',
'name' =>
'is_a_translation',
'label' => $langs->trans(
"PageIsANewTranslation"),
'value' => 0,
'morecss' =>
'margintoponly');
3416 $value = $formadmin->select_language($preselectedlanguage,
'newlang', 0,
null, $textifempty, 0, 0,
'minwidth200', 1, 0, 0, $onlylang, 1);
3417 $formquestion[] = array(
'type' =>
'other',
'name' =>
'newlang',
'label' => $form->textwithpicto($langs->trans(
"Language"), $langs->trans(
"DefineListOfAltLanguagesInWebsiteProperties")),
'value' => $value);
3419 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?website='.
$object->ref.
'&pageid='.$pageid, $langs->trans(
'ClonePage'),
'',
'confirm_createpagefromclone', $formquestion, 0, 1, 300, 550);
3424 print
'<span class="websiteselection">';
3427 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>';
3430 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>';
3434 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?website='.
$object->ref.
'&pageid='.$pageid.
'&action=editcontent&token='.
newToken().
'" class="button bordertransp"'.$disabled.
'>'.
dol_escape_htmltag(
"CKEditor").
'</a>';
3436 print
'<!-- Add option WEBSITE_ALLOW_CKEDITOR to allow ckeditor -->';
3443 print
'<!-- button EditInLine and ShowSubcontainers -->'.
"\n";
3444 print
'<div class="websiteselectionsection inline-block">';
3446 print
'<div class="inline-block marginrightonly">';
3447 print $langs->trans(
"ShowSubcontainers");
3449 print
'<a class="nobordertransp nohoverborder marginleftonlyshort valignmiddle"'.$disabled.
' href="'.$_SERVER[
"PHP_SELF"].
'?website='.
$object->ref.
'&pageid='.$websitepage->id.
'&action=setshowsubcontainers&token='.
newToken().
'">'.
img_picto($langs->trans(
"ShowSubContainersOnOff", $langs->transnoentitiesnoconv(
"Off")),
'switch_off',
'',
false, 0, 0,
'',
'nomarginleft').
'</a>';
3451 print
'<a class="nobordertransp nohoverborder marginleftonlyshort valignmiddle"'.$disabled.
' href="'.$_SERVER[
"PHP_SELF"].
'?website='.
$object->ref.
'&pageid='.$websitepage->id.
'&action=unsetshowsubcontainers&token='.
newToken().
'">'.
img_picto($langs->trans(
"ShowSubContainersOnOff", $langs->transnoentitiesnoconv(
"On")),
'switch_on',
'',
false, 0, 0,
'',
'nomarginleft').
'</a>';
3455 print
'<div class="inline-block marginrightonly">';
3457 print
'<span id="switchckeditorinline">'.
"\n";
3459 print
'<!-- Code to enabled edit inline ckeditor -->'.
"\n";
3460 print
'<script type="text/javascript">
3461 $(document).ready(function() {
3462 var isEditingEnabled = '.(getDolGlobalString(
"WEBSITE_EDITINLINE") ?
'true' :
'false').
';
3463 if (isEditingEnabled)
3465 switchEditorOnline(true);
3468 $( "#switchckeditorinline" ).click(function() {
3469 switchEditorOnline();
3472 function switchEditorOnline(forceenable)
3474 if (! isEditingEnabled || forceenable)
3476 console.log("Enable inline edit for some html tags with contenteditable=true attribute");
3478 jQuery(\'section[contenteditable="true"],div[contenteditable="true"],header[contenteditable="true"],main[contenteditable="true"],footer[contenteditable="true"]\').each(function(idx){
3479 var idtouse = $(this).attr(\'id\');
3480 console.log("Enable inline edit for "+idtouse);
3481 if (idtouse !== undefined) {
3482 var inlineditor = CKEDITOR.inline(idtouse, {
3483 // Allow some non-standard markup that we used in the introduction.
3484 // + a[target];div{float,display} ?
3485 extraAllowedContent: \'span(*);cite(*);q(*);dl(*);dt(*);dd(*);ul(*);li(*);header(*);main(*);footer(*);button(*);h1(*);h2(*);h3(*);\',
3486 //extraPlugins: \'sourcedialog\',
3487 removePlugins: \'flash,stylescombo,exportpdf,scayt,wsc,pagebreak,iframe,smiley\',
3488 // Show toolbar on startup (optional).
3489 // startupFocus: true
3493 // Note the Source tool does not work on inline
3494 inlineditor.config.toolbar = [
3495 [\'Templates\',\'NewPage\'],
3497 [\'Maximize\',\'Preview\'],
3499 [\'Undo\',\'Redo\',\'-\',\'Find\',\'Replace\',\'-\',\'SelectAll\',\'RemoveFormat\'],
3500 [\'CreateDiv\',\'ShowBlocks\'],
3501 [\'Form\', \'Checkbox\', \'Radio\', \'TextField\', \'Textarea\', \'Select\', \'Button\', \'ImageButton\', \'HiddenField\'],
3502 [\'Bold\',\'Italic\',\'Underline\',\'Strike\',\'Superscript\'],
3503 [\'NumberedList\',\'BulletedList\',\'-\',\'Outdent\',\'Indent\',\'Blockquote\'],
3504 [\'JustifyLeft\',\'JustifyCenter\',\'JustifyRight\',\'JustifyBlock\'],
3505 [\'Link\',\'Unlink\'],
3506 [\'Image\',\'Table\',\'HorizontalRule\'],
3507 [\'Styles\',\'Format\',\'Font\',\'FontSize\'],
3508 [\'TextColor\',\'BGColor\']
3512 //inlineditor.on(\'instanceReady\', function () {
3516 CKEDITOR.instances[idtouse].on(\'change\', function() {
3517 $(this.element.$).addClass(\'modified\');
3520 console.warn("A html section has the contenteditable=true attribute but has no id attribute");
3524 isEditingEnabled = true;
3526 // Trigger the function when clicking outside the elements with contenteditable=true attribute
3527 $(document).on(\'click\', function(e) {
3528 var target = $(e.target);
3529 // Check if the click is outside the elements with contenteditable=true attribute
3530 if (!target.closest(\'[contenteditable="true"]\').length) {
3531 // Repeat through the elements with contenteditable="true" attribute
3532 $(\'[contenteditable="true"]\').each(function() {
3533 var idToUse = $(this).attr(\'id\');
3534 var elementType = $(this).prop("tagName").toLowerCase(); // Get the tag name (div, section, footer...)
3535 var instance = CKEDITOR.instances[idToUse];
3536 // Check if the element has been modified
3537 if ($(this).hasClass(\'modified\')) {
3538 var content = instance.getData();
3539 content = "\\n" + content;
3541 // Retrieving the content and ID of the element
3542 var elementId = $(this).attr(\'id\');
3544 // Sending data via AJAX
3547 url: \'' . DOL_URL_ROOT .
'/core/ajax/editinline.php\',
3549 website_ref: \''.$website->ref.
'\',
3550 page_id: \
'' . $websitepage->id .
'\',
3552 element_id: elementId,
3553 element_type: elementType,
3554 action: \'updatedElementContent\',
3557 success: function(response) {
3558 console.log(response);
3562 $(this).removeClass(\'modified\');
3569 console.log("Disable inline edit");
3570 for(name in CKEDITOR.instances) {
3571 CKEDITOR.instances[name].destroy(true);
3573 isEditingEnabled = false;
3578 print $langs->trans(
"EditInLine");
3582 $disableeditinline = 0;
3583 if ($disableeditinline) {
3585 print
'<a class="nobordertransp opacitymedium nohoverborder marginleftonlyshort"'.$disabled.
' href="#" disabled="disabled" title="'.
dol_escape_htmltag($langs->trans(
"OnlyEditionOfSourceForGrabbedContent")).
'">'.
img_picto($langs->trans(
"OnlyEditionOfSourceForGrabbedContent"),
'switch_off',
'',
false, 0, 0,
'',
'nomarginleft').
'</a>';
3589 print
'<a class="nobordertransp nohoverborder marginleftonlyshort valignmiddle"'.$disabled.
' href="'.$_SERVER[
"PHP_SELF"].
'?website='.
$object->ref.
'&pageid='.$websitepage->id.
'&action=seteditinline&token='.
newToken().
'">'.
img_picto($langs->trans(
"EditInLineOnOff", $langs->transnoentitiesnoconv(
"Off")),
'switch_off',
'',
false, 0, 0,
'',
'nomarginleft').
'</a>';
3591 print
'<a class="nobordertransp nohoverborder marginleftonlyshort valignmiddle"'.$disabled.
' href="'.$_SERVER[
"PHP_SELF"].
'?website='.
$object->ref.
'&pageid='.$websitepage->id.
'&action=unseteditinline&token='.
newToken().
'">'.
img_picto($langs->trans(
"EditInLineOnOff", $langs->transnoentitiesnoconv(
"On")),
'switch_on',
'',
false, 0, 0,
'',
'nomarginleft').
'</a>';
3600 print
'<span class="websiteselection">';
3601 if (
$object->fk_default_home > 0 && $pageid ==
$object->fk_default_home) {
3605 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>';
3609 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>';
3611 print
'<input type="submit" class="button bordertransp"'.$disabled.
' value="'.
dol_escape_htmltag($langs->trans(
"ClonePage")).
'" name="createpagefromclone">';
3614 if ($websitepage->status != $websitepage::STATUS_DRAFT) {
3615 $disabled =
' disabled="disabled"';
3616 $title = $langs->trans(
"WebpageMustBeDisabled", $langs->transnoentitiesnoconv($websitepage->LibStatut(0, 0)));
3621 $url = $_SERVER[
"PHP_SELF"].
'?action=delete&token='.
newToken().
'&pageid='.((int) $websitepage->id).
'&website='.urlencode($website->ref);
3623 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>';
3630 print
'<span class="websitetools">';
3632 if (($pageid > 0 && $atleastonepage) && ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite')) {
3633 $realpage = $urlwithroot.
'/public/website/index.php?website='.$websitekey.
'&pageref='.$websitepage->pageurl;
3634 $pagealias = $websitepage->pageurl;
3636 $htmltext = $langs->trans(
"PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv(
"Page"), $langs->transnoentitiesnoconv(
"Page"), $realpage, $dataroot);
3637 $htmltext .=
'<br>'.$langs->trans(
"CheckVirtualHostPerms", $langs->transnoentitiesnoconv(
"ReadPerm"),
'{s1}');
3638 $htmltext = str_replace(
'{s1}', $dataroot.
'<br>'.DOL_DATA_ROOT.
'/medias<br>'.DOL_DOCUMENT_ROOT, $htmltext);
3642 print
'<div class="websiteinputurl inline-block paddingright">';
3643 print
'<a class="websitebuttonsitepreview inline-block" id="previewpage" href="'.$realpage.
'&nocache='.
dol_now().
'" class="button" target="tab'.$websitekey.
'" alt="'.
dol_escape_htmltag($htmltext).
'">';
3644 print $form->textwithpicto(
'', $htmltext, 1,
'preview');
3668 if (!in_array($mode, array(
'replacesite')) && !in_array($action, array(
'editcss',
'editmenu',
'file_manager',
'replacesiteconfirm',
'createsite',
'createcontainer',
'createfromclone',
'createpagefromclone',
'deletesite'))) {
3669 if ($action ==
'editsource' || $action ==
'editmeta') {
3672 $stringforfirstkey = $langs->trans(
"KeyboardShortcut");
3673 if ($conf->browser->name ==
'chrome') {
3674 $stringforfirstkey .=
' ALT +';
3675 } elseif ($conf->browser->name ==
'firefox') {
3676 $stringforfirstkey .=
' ALT + SHIFT +';
3678 $stringforfirstkey .=
' CTL +';
3681 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">';
3683 if (preg_match(
'/^create/', $action)) {
3684 print
'<input type="submit" id="savefile" class="button buttonforacesave button-save small" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
3686 if (preg_match(
'/^edit/', $action)) {
3687 print
'<input type="submit" id="savefile" class="button buttonforacesave button-save small" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
3689 if ($action !=
'preview') {
3690 print
'<input type="submit" class="button button-cancel small" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'" name="cancel">';
3696 print
'<span class="websitehelp">';
3697 if ($action ==
'editsource' || $action ==
'editcontent' ||
GETPOST(
'editsource',
'alpha') ||
GETPOST(
'editcontent',
'alpha')) {
3698 $url =
'https://wiki.dolibarr.org/index.php/Module_Website';
3700 $htmltext =
'<small>';
3701 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource", $url);
3702 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource1", $url);
3703 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource2", $url);
3704 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource3", $url);
3705 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSourceMore", $url);
3706 $htmltext .=
'<br>';
3707 $htmltext .=
'</small>';
3708 if ($conf->browser->layout ==
'phone') {
3709 print $form->textwithpicto(
'', $htmltext, 1,
'help',
'inline-block', 1, 2,
'tooltipsubstitution');
3712 print $form->textwithpicto($langs->trans(
"SyntaxHelp").
' '.
img_help(2, $langs->trans(
"SyntaxHelp")), $htmltext, 1,
'none',
'inline-block', 1, 2,
'tooltipsubstitution');
3718 if ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone') {
3720 if (!empty($conf->use_javascript_ajax)) {
3721 print
'<script type="text/javascript">
3722 jQuery(document).ready(function() {
3723 jQuery("#websiteinputurl").keyup(function() {
3724 console.log("Website external url modified "+jQuery("#previewsiteurl").val());
3725 if (jQuery("#previewsiteurl").val() != "" && jQuery("#previewsiteurl").val().startsWith("http"))
3727 jQuery("a.websitebuttonsitepreviewdisabled img").css({ opacity: 1 });
3729 else jQuery("a.websitebuttonsitepreviewdisabled img").css({ opacity: 0.2 });
3733 jQuery("#previewsiteext,#previewpageext").click(function() {
3735 newurl=jQuery("#previewsiteurl").val();
3736 if (! newurl.startsWith("http"))
3738 alert(\''.dol_escape_js($langs->trans(
"ErrorURLMustStartWithHttp")).
'\');
3742 newpage=jQuery(
"#previewsiteurl").val() +
"/" + jQuery(
"#previewpageurl").val() +
".php";
3743 console.log(
"Open url "+newurl);
3747 url:
"'.DOL_URL_ROOT.'/core/ajax/saveinplace.php",
3749 field: \
'editval_virtualhost\',
3750 element: \'website\',
3751 table_element: \'website\',
3752 fk_element: '.((int)
$object->id).
',
3755 context: document.body
3758 jQuery("#previewsiteext").attr("href",newurl);
3759 jQuery("#previewpageext").attr("href",newpage);
3778if ($action ==
'editcss') {
3779 print
'<div class="fiche">';
3783 if (!GETPOSTISSET(
'WEBSITE_CSS_INLINE')) {
3784 $csscontent = @file_get_contents($filecss);
3786 $csscontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $csscontent);
3788 $csscontent =
GETPOST(
'WEBSITE_CSS_INLINE',
'none');
3790 if (!trim($csscontent)) {
3791 $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;}";
3794 if (!GETPOSTISSET(
'WEBSITE_JS_INLINE')) {
3795 $jscontent = @file_get_contents($filejs);
3797 $jscontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $jscontent);
3799 $jscontent =
GETPOST(
'WEBSITE_JS_INLINE',
'none');
3801 if (!trim($jscontent)) {
3802 $jscontent =
'/* JS content (all pages) */'.
"\n";
3805 if (!GETPOSTISSET(
'WEBSITE_HTML_HEADER')) {
3806 $htmlheadercontent = @file_get_contents($filehtmlheader);
3808 $htmlheadercontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $htmlheadercontent);
3810 $htmlheadercontent =
GETPOST(
'WEBSITE_HTML_HEADER',
'none');
3812 if (!trim($htmlheadercontent)) {
3813 $htmlheadercontent =
"<html>\n";
3814 $htmlheadercontent .= $htmlheadercontentdefault;
3815 $htmlheadercontent .=
"</html>";
3817 $htmlheadercontent = preg_replace(
'/^\s*<html>/ims',
'', $htmlheadercontent);
3818 $htmlheadercontent = preg_replace(
'/<\/html>\s*$/ims',
'', $htmlheadercontent);
3819 $htmlheadercontent =
'<html>'.
"\n".trim($htmlheadercontent).
"\n".
'</html>';
3822 if (!GETPOSTISSET(
'WEBSITE_ROBOT')) {
3823 $robotcontent = @file_get_contents($filerobot);
3825 $robotcontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $robotcontent);
3827 $robotcontent =
GETPOST(
'WEBSITE_ROBOT',
'nohtml');
3829 if (!trim($robotcontent)) {
3830 $robotcontent .=
"# Robot file. Generated with ".DOL_APPLICATION_TITLE.
"\n";
3831 $robotcontent .=
"User-agent: *\n";
3832 $robotcontent .=
"Allow: /public/\n";
3833 $robotcontent .=
"Disallow: /administrator/\n";
3836 if (!GETPOSTISSET(
'WEBSITE_HTACCESS')) {
3837 $htaccesscontent = @file_get_contents($filehtaccess);
3839 $htaccesscontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $htaccesscontent);
3841 $htaccesscontent =
GETPOST(
'WEBSITE_HTACCESS',
'nohtml');
3843 if (!trim($htaccesscontent)) {
3844 $htaccesscontent .=
"# Order allow,deny\n";
3845 $htaccesscontent .=
"# Deny from all\n";
3848 if (!GETPOSTISSET(
'WEBSITE_MANIFEST_JSON')) {
3849 $manifestjsoncontent = @file_get_contents($filemanifestjson);
3851 $manifestjsoncontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $manifestjsoncontent);
3853 $manifestjsoncontent =
GETPOST(
'WEBSITE_MANIFEST_JSON',
'restricthtml');
3855 if (!trim($manifestjsoncontent)) {
3859 if (!GETPOSTISSET(
'WEBSITE_README')) {
3860 $readmecontent = @file_get_contents($filereadme);
3862 $readmecontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $readmecontent);
3864 $readmecontent =
GETPOST(
'WEBSITE_README',
'none');
3866 if (!trim($readmecontent)) {
3870 if (!GETPOSTISSET(
'WEBSITE_LICENSE')) {
3871 $licensecontent = @file_get_contents($filelicense);
3873 $licensecontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $licensecontent);
3875 $licensecontent =
GETPOST(
'WEBSITE_LICENSE',
'none');
3877 if (!trim($licensecontent)) {
3883 print
'<!-- Edit Website properties -->'.
"\n";
3884 print
'<table class="border centpercent">';
3887 print
'<tr><td class="titlefieldcreate fieldrequired">';
3888 print $langs->trans(
'WebSite');
3894 if ($action !=
'createcontainer') {
3895 if (empty($conf->use_javascript_ajax)) {
3896 print
'<!-- Status of web site page -->'.
"\n";
3897 print
'<tr><td class="fieldrequired">';
3898 print $langs->trans(
'Status');
3900 print $form->selectyesno(
'status',
$object->status);
3906 print
'<tr><td class="tdtop fieldrequired">';
3908 print $form->textwithpicto($langs->trans(
'MainLanguage'), $htmltext, 1,
'help',
'', 0, 2,
'WEBSITE_LANG');
3910 print
img_picto(
'',
'language',
'class="picotfixedwidth"');
3911 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);
3916 print
'<tr><td class="tdtop">';
3917 $htmltext = $langs->trans(
"Example").
': fr,de,sv,it,pt';
3918 print $form->textwithpicto($langs->trans(
'OtherLanguages'), $htmltext, 1,
'help',
'', 0, 2);
3920 print
img_picto(
'',
'language',
'class="picotfixedwidth"');
3921 print
'<input type="text" class="flat" value="'.(GETPOSTISSET(
'WEBSITE_OTHERLANG') ?
GETPOST(
'WEBSITE_OTHERLANG',
'alpha') :
$object->otherlang).
'" name="WEBSITE_OTHERLANG">';
3926 print
'<tr><td class="tdtop">';
3928 $htmltext = $langs->trans(
"VirtualhostDesc");
3929 print $form->textwithpicto($langs->trans(
'Virtualhost'), $htmltext, 1,
'help',
'', 0, 2,
'virtualhosttooltip');
3931 print
'<input type="text" class="flat minwidth300" value="'.(GETPOSTISSET(
'virtualhost') ?
GETPOST(
'virtualhost',
'alpha') : $virtualurl).
'" name="virtualhost">';
3937 print $form->textwithpicto($langs->trans(
'ImportFavicon'), $langs->trans(
'FaviconTooltip'));
3940 $maxmin = $maxfilesizearray[
'maxmin'];
3942 print
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
3944 print
'<input type="file" class="flat minwidth300" name="addedfile" id="addedfile"/>';
3946 $uploadfolder = $conf->website->dir_output.
'/'.$websitekey;
3948 print
'<div class="inline-block valignmiddle marginrightonly">';
3949 print
'<img style="max-height: 80px" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart=website&file='.$websitekey.
'/favicon.png">';
3955 print
'<tr><td class="tdtop">';
3956 $htmlhelp = $langs->trans(
"CSSContentTooltipHelp");
3957 print $form->textwithpicto($langs->trans(
'WEBSITE_CSS_INLINE'), $htmlhelp, 1,
'help',
'', 0, 2,
'csstooltip');
3960 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_CSS_INLINE_x'),
'y' =>
GETPOST(
'WEBSITE_CSS_INLINE_y'));
3961 $doleditor =
new DolEditor(
'WEBSITE_CSS_INLINE', $csscontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'', $poscursor);
3962 print $doleditor->Create(1,
'',
true,
'CSS',
'css');
3967 print
'<tr><td class="tdtop">';
3968 $textwithhelp = $langs->trans(
'WEBSITE_JS_INLINE');
3969 $htmlhelp2 = $langs->trans(
"LinkAndScriptsHereAreNotLoadedInEditor").
'<br>';
3970 print $form->textwithpicto($textwithhelp, $htmlhelp2, 1,
'warning',
'', 0, 2,
'htmljstooltip2');
3974 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_JS_INLINE_x'),
'y' =>
GETPOST(
'WEBSITE_JS_INLINE_y'));
3975 $doleditor =
new DolEditor(
'WEBSITE_JS_INLINE', $jscontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'', $poscursor);
3976 print $doleditor->Create(1,
'',
true,
'JS',
'javascript');
3981 print
'<tr><td class="tdtop">';
3982 print $langs->trans(
'WEBSITE_HTML_HEADER');
3983 $htmlhelp = $langs->trans(
"Example").
' :<br>';
3985 $textwithhelp = $form->textwithpicto(
'', $htmlhelp, 1,
'help',
'', 0, 2,
'htmlheadertooltip');
3986 $htmlhelp2 = $langs->trans(
"LinkAndScriptsHereAreNotLoadedInEditor").
'<br>';
3987 print $form->textwithpicto($textwithhelp, $htmlhelp2, 1,
'warning',
'', 0, 2,
'htmlheadertooltip2');
3990 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_HTML_HEADER_x'),
'y' =>
GETPOST(
'WEBSITE_HTML_HEADER_y'));
3991 $doleditor =
new DolEditor(
'WEBSITE_HTML_HEADER', $htmlheadercontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'', $poscursor);
3992 print $doleditor->Create(1,
'',
true,
'HTML Header',
'html');
3997 print
'<tr><td class="tdtop">';
3998 print $langs->trans(
'WEBSITE_ROBOT');
4001 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_ROBOT_x'),
'y' =>
GETPOST(
'WEBSITE_ROBOT_y'));
4002 $doleditor =
new DolEditor(
'WEBSITE_ROBOT', $robotcontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'', $poscursor);
4003 print $doleditor->Create(1,
'',
true,
'Robot file',
'text');
4008 print
'<tr><td class="tdtop">';
4009 print $langs->trans(
'WEBSITE_HTACCESS');
4012 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_HTACCESS_x'),
'y' =>
GETPOST(
'WEBSITE_HTACCESS_y'));
4013 $doleditor =
new DolEditor(
'WEBSITE_HTACCESS', $htaccesscontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'', $poscursor);
4014 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' .htaccess',
'text');
4019 print
'<tr><td class="tdtop">';
4020 $htmlhelp = $langs->trans(
"Example").
' :<br>';
4021 $htmlhelp .=
'<small>'.dol_htmlentitiesbr($manifestjsoncontentdefault).
'</small>';
4022 print $form->textwithpicto($langs->trans(
'WEBSITE_MANIFEST_JSON'), $htmlhelp, 1,
'help',
'', 0, 2,
'manifestjsontooltip');
4024 print $langs->trans(
"UseManifest").
': '.$form->selectyesno(
'use_manifest', $website->use_manifest, 1).
'<br>';
4026 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_MANIFEST_JSON_x'),
'y' =>
GETPOST(
'WEBSITE_MANIFEST_JSON_y'));
4027 $doleditor =
new DolEditor(
'WEBSITE_MANIFEST_JSON', $manifestjsoncontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'', $poscursor);
4028 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' manifest.json',
'text');
4032 print
'<tr><td class="tdtop">';
4033 $htmlhelp = $langs->trans(
"EnterHereReadmeInformation");
4034 print $form->textwithpicto($langs->trans(
"File").
' README.md', $htmlhelp, 1,
'help',
'', 0, 2,
'readmetooltip');
4037 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_README_x'),
'y' =>
GETPOST(
'WEBSITE_README_y'));
4038 $doleditor =
new DolEditor(
'WEBSITE_README', $readmecontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'', $poscursor);
4039 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' README.md',
'text');
4044 print
'<tr><td class="tdtop">';
4045 $htmlhelp = $langs->trans(
"EnterHereLicenseInformation");
4046 print $form->textwithpicto($langs->trans(
"File").
' LICENSE', $htmlhelp, 1,
'help',
'', 0, 2,
'licensetooltip');
4049 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_LICENSE_x'),
'y' =>
GETPOST(
'WEBSITE_LICENSE_y'));
4050 $doleditor =
new DolEditor(
'WEBSITE_LICENSE', $licensecontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'', $poscursor);
4051 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' LICENSE',
'text');
4056 print
'<tr><td class="tdtop">';
4057 $htmlhelp = $langs->trans(
'RSSFeedDesc');
4058 print $form->textwithpicto($langs->trans(
'RSSFeed'), $htmlhelp, 1,
'help',
'', 0, 2,
'');
4060 print
'/wrapper.php?rss=1[&l=XX][&limit=123]';
4073if ($action ==
'createsite') {
4074 print
'<div class="fiche">';
4088 if ($action ==
'createcontainer') {
4092 print
'<!-- Add site -->'.
"\n";
4093 print
'<div class="tabBar tabBarWithBottom">';
4095 print
'<table class="border centpercent">';
4097 $siteref = $sitedesc = $sitelang = $siteotherlang =
'';
4099 $siteref =
GETPOST(
'WEBSITE_REF',
'aZ09');
4101 if (
GETPOST(
'WEBSITE_DESCRIPTION')) {
4102 $sitedesc =
GETPOST(
'WEBSITE_DESCRIPTION',
'alpha');
4104 if (
GETPOST(
'WEBSITE_LANG')) {
4105 $sitelang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
4107 if (
GETPOST(
'WEBSITE_OTHERLANG')) {
4108 $siteotherlang =
GETPOST(
'WEBSITE_OTHERLANG',
'aZ09comma');
4111 print
'<tr><td class="titlefieldcreate fieldrequired">';
4112 print $form->textwithpicto($langs->trans(
'WebsiteName'), $langs->trans(
"Example").
': MyPortal, www.mywebsite.com, ...');
4114 print
'<input type="text" class="flat maxwidth300" name="WEBSITE_REF" value="'.dol_escape_htmltag($siteref).
'" autofocus>';
4117 print
'<tr><td class="fieldrequired">';
4118 print $langs->trans(
'MainLanguage');
4120 $shortlangcode = preg_replace(
'/[_-].*$/',
'', trim($langs->defaultlang));
4121 print
img_picto(
'',
'language',
'class="pictofixedwidth"');
4122 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);
4126 $htmltext = $langs->trans(
"Example").
': fr,de,sv,it,pt';
4127 print $form->textwithpicto($langs->trans(
'OtherLanguages'), $htmltext, 1,
'help',
'', 0, 2);
4129 print
img_picto(
'',
'language',
'class="pictofixedwidth"');
4130 print
'<input type="text" class="flat minwidth300" name="WEBSITE_OTHERLANG" value="'.dol_escape_htmltag($siteotherlang).
'">';
4134 print $langs->trans(
'Description');
4136 print
'<input type="text" class="flat minwidth500" name="WEBSITE_DESCRIPTION" value="'.dol_escape_htmltag($sitedesc).
'">';
4141 $htmltext = $langs->trans(
"VirtualhostDesc");
4149 print $form->textwithpicto($langs->trans(
'Virtualhost'), $htmltext, 1,
'help',
'', 0, 2,
'');
4151 print
'<input type="text" class="flat minwidth300" name="virtualhost" value="'.dol_escape_htmltag(
GETPOST(
'virtualhost',
'alpha')).
'">';
4157 if ($action ==
'createsite') {
4158 print
'<div class="center">';
4160 print
'<input type="submit" class="button small" name="addcontainer" value="'.$langs->trans(
"Create").
'">';
4161 print
'<input class="button button-cancel small" type="submit" name="preview" value="'.$langs->trans(
"Cancel").
'">';
4176if ($action ==
'importsite') {
4177 print
'<!-- action=importsite -->';
4178 print
'<div class="fiche">';
4186 print
'<span class="opacitymedium">'.$langs->trans(
"ZipOfWebsitePackageToImport").
'</span><br><br>';
4189 $dolibarrdataroot = preg_replace(
'/([\\/]+)$/i',
'', DOL_DATA_ROOT);
4190 $allowimportsite =
true;
4191 if (
dol_is_file($dolibarrdataroot.
'/installmodules.lock')) {
4192 $allowimportsite =
false;
4195 if ($allowimportsite) {
4197 $maxmin = $maxfilesizearray[
'maxmin'];
4199 print
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
4201 print
'<input class="flat minwidth400" type="file" name="userfile[]" accept=".zip">';
4202 print
'<input type="submit" class="button small" name="buttonsubmitimportfile" value="'.dol_escape_htmltag($langs->trans(
"Upload")).
'">';
4203 print
'<input type="submit" class="button button-cancel small" name="preview" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
4204 print
'<br><br><br>';
4208 $message = $langs->trans(
'InstallModuleFromWebHasBeenDisabledContactUs');
4211 $message = $langs->trans(
"InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.
'/installmodules.lock');
4217 print
'<span class="opacitymedium">'.$langs->trans(
"ZipOfWebsitePackageToLoad").
'</span><br><br>';
4228if ($action ==
'editmeta' || $action ==
'createcontainer') {
4229 print
'<div class="fiche">';
4243 if ($action ==
'createcontainer') {
4247 print
'<!-- Edit or create page/container -->'.
"\n";
4250 $hiddenfromfetchingafterload =
' hideobject';
4251 $hiddenmanuallyafterload =
' hideobject';
4252 if (
GETPOST(
'radiocreatefrom') ==
'checkboxcreatefromfetching') {
4253 $hiddenfromfetchingafterload =
'';
4255 if (
GETPOST(
'radiocreatefrom') ==
'checkboxcreatemanually') {
4256 $hiddenmanuallyafterload =
'';
4259 if ($action ==
'editmeta' || empty($conf->use_javascript_ajax)) {
4260 $hiddenfromfetchingafterload =
'';
4261 $hiddenmanuallyafterload =
'';
4264 if ($action ==
'createcontainer') {
4267 if (!empty($conf->use_javascript_ajax)) {
4268 print
'<input type="radio" name="radiocreatefrom" id="checkboxcreatemanually" value="checkboxcreatemanually"'.(GETPOST(
'radiocreatefrom') ==
'checkboxcreatemanually' ?
' checked' :
'').
'> ';
4270 print
'<label for="checkboxcreatemanually"><span class="opacitymediumxx">'.$langs->trans(
"OrEnterPageInfoManually").
'</span></label><br>';
4271 print
'<hr class="tablecheckboxcreatemanually'.$hiddenmanuallyafterload.
'">';
4274 print
'<table class="border tableforfield nobackground centpercent tablecheckboxcreatemanually'.$hiddenmanuallyafterload.
'">';
4276 if ($action !=
'createcontainer') {
4277 print
'<tr><td class="titlefield fieldrequired">';
4278 print $langs->trans(
'IDOfPage').
' - '.$langs->trans(
'InternalURLOfPage');
4286 print
' - ';
4287 print
'/public/website/index.php?website='.urlencode($websitekey).
'&pageid='.urlencode($pageid);
4291 $type_container = $objectpage->type_container;
4292 $pageurl = $objectpage->pageurl;
4293 $pagealiasalt = $objectpage->aliasalt;
4294 $pagetitle = $objectpage->title;
4295 $pagedescription = $objectpage->description;
4296 $pageimage = $objectpage->image;
4297 $pagekeywords = $objectpage->keywords;
4298 $pagelang = $objectpage->lang;
4299 $pageallowedinframes = $objectpage->allowed_in_frames;
4300 $pagehtmlheader = $objectpage->htmlheader;
4301 $pagedatecreation = $objectpage->date_creation;
4302 $pagedatemodification = $objectpage->date_modification;
4303 $pageauthorid = $objectpage->fk_user_creat;
4304 $pageusermodifid = $objectpage->fk_user_modif;
4305 $pageauthoralias = $objectpage->author_alias;
4306 $pagestatus = $objectpage->status;
4308 $type_container =
'page';
4312 $pagedescription =
'';
4316 $pageallowedinframes = 0;
4317 $pagehtmlheader =
'';
4318 $pagedatecreation =
dol_now();
4319 $pagedatemodification =
'';
4320 $pageauthorid = $user->id;
4321 $pageusermodifid = 0;
4322 $pageauthoralias =
'';
4325 if (
GETPOST(
'WEBSITE_TITLE',
'alpha')) {
4326 $pagetitle = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_TITLE',
'alphanohtml'));
4328 if (
GETPOST(
'WEBSITE_PAGENAME',
'alpha')) {
4329 $pageurl =
GETPOST(
'WEBSITE_PAGENAME',
'alpha');
4331 if (
GETPOST(
'WEBSITE_ALIASALT',
'alpha')) {
4332 $pagealiasalt = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_ALIASALT',
'alphanohtml'));
4334 if (
GETPOST(
'WEBSITE_DESCRIPTION',
'alpha')) {
4335 $pagedescription = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml'));
4337 if (
GETPOST(
'WEBSITE_IMAGE',
'alpha')) {
4338 $pageimage =
GETPOST(
'WEBSITE_IMAGE',
'alpha');
4340 if (
GETPOST(
'WEBSITE_KEYWORDS',
'alpha')) {
4341 $pagekeywords = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_KEYWORDS',
'alphanohtml'));
4343 if (
GETPOST(
'WEBSITE_LANG',
'aZ09')) {
4344 $pagelang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
4346 if (
GETPOST(
'WEBSITE_ALLOWED_IN_FRAMES',
'aZ09')) {
4347 $pageallowedinframes =
GETPOST(
'WEBSITE_ALLOWED_IN_FRAMES',
'aZ09');
4349 if (
GETPOST(
'htmlheader',
'none')) {
4350 $pagehtmlheader =
GETPOST(
'htmlheader',
'none');
4353 if ($action !=
'createcontainer') {
4354 if (empty($conf->use_javascript_ajax)) {
4355 print
'<!-- Status of web site page -->'.
"\n";
4356 print
'<tr><td class="fieldrequired">';
4357 print $langs->trans(
'Status');
4359 print $form->selectyesno(
'status', $objectpage->status);
4365 print
'<tr><td class="titlefield fieldrequired">';
4366 print $langs->trans(
'WEBSITE_TYPE_CONTAINER');
4368 print
img_picto(
'',
'object_technic',
'class="paddingrightonly"').
' ';
4369 print $formwebsite->selectTypeOfContainer(
'WEBSITE_TYPE_CONTAINER', (
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'alpha') ?
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'alpha') : $type_container), 0,
'', 1,
'minwidth300');
4372 print
'<script type="text/javascript">
4373 jQuery(document).ready(function() {
4374 jQuery("#selectWEBSITE_TYPE_CONTAINER").change(function() {
4375 console.log("We change type of page : "+jQuery("#selectWEBSITE_TYPE_CONTAINER").val());
4376 if (jQuery("#selectWEBSITE_TYPE_CONTAINER").val() == \'blogpost\') {
4377 jQuery(".trpublicauthor").show();
4379 jQuery(".trpublicauthor").hide();
4381 if (jQuery("#selectWEBSITE_TYPE_CONTAINER").val() == \'service\' || jQuery("#selectWEBSITE_TYPE_CONTAINER").val() == \'library\') {
4382 $(".spanprefix").html("_" + $("#selectWEBSITE_TYPE_CONTAINER").val() + "_");
4383 jQuery(".spanprefix").show();
4385 jQuery(".spanprefix").hide();
4389 // Force at init execution a first time of the handler change
4390 jQuery("#selectWEBSITE_TYPE_CONTAINER").trigger(\'change\');
4396 print
'<tr><td class="fieldrequired">';
4397 print $langs->trans(
'WEBSITE_TITLE');
4399 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_TITLE" id="WEBSITE_TITLE" value="'.dol_escape_htmltag($pagetitle).
'" autofocus>';
4403 print
'<tr><td class="titlefieldcreate fieldrequired">';
4404 print $langs->trans(
'WEBSITE_PAGENAME');
4406 print
'<span class="opacitymedium spanprefix hidden"></span> ';
4407 print
'<input type="text" class="flat minwidth300" name="WEBSITE_PAGENAME" id="WEBSITE_PAGENAME" value="'.dol_escape_htmltag((
string) preg_replace(
'/^_[a-z]+_/',
'', (
string) $pageurl)).
'">';
4410 print
'<script type="text/javascript">
4411 $(document).ready(function() {
4412 console.log("Manage prefix for service or library");
4413 if ($("#selectWEBSITE_TYPE_CONTAINER").val() == "service" || $("#selectWEBSITE_TYPE_CONTAINER").val() == "library") {
4414 $(".spanprefix").html("_" + $("#selectWEBSITE_TYPE_CONTAINER").val() + "_");
4415 $(".spanprefix").show();
4417 $(".websiteformtoolbar").on("submit", function(event) {
4418 if ($("#selectWEBSITE_TYPE_CONTAINER").val() == "service" || $("#selectWEBSITE_TYPE_CONTAINER").val() == "library") {
4419 var prefix = "_" + $("#selectWEBSITE_TYPE_CONTAINER").val() + "_";
4420 var userInput = $("#WEBSITE_PAGENAME").val();
4421 var $inputField = $("#WEBSITE_PAGENAME");
4422 if (userInput.indexOf(prefix) !== 0) {
4423 $inputField.val(prefix + userInput);
4431 print
'<tr><td class="titlefieldcreate">';
4432 $htmlhelp = $langs->trans(
"WEBSITE_ALIASALTDesc");
4433 print $form->textwithpicto($langs->trans(
'WEBSITE_ALIASALT'), $htmlhelp, 1,
'help',
'', 0, 2,
'aliastooltip');
4435 print
'<input type="text" class="flat minwidth500" name="WEBSITE_ALIASALT" value="'.dol_escape_htmltag($pagealiasalt).
'">';
4439 print $langs->trans(
'WEBSITE_DESCRIPTION');
4441 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_DESCRIPTION" value="'.dol_escape_htmltag($pagedescription).
'">';
4446 print
'<tr class="trimageforpage hidden"><td>';
4447 $htmlhelp = $langs->trans(
"WEBSITE_IMAGEDesc");
4448 print $form->textwithpicto($langs->trans(
'WEBSITE_IMAGE'), $htmlhelp, 1,
'help',
'', 0, 2,
'imagetooltip');
4450 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_IMAGE" value="'.dol_escape_htmltag($pageimage).
'">';
4453 print
'<script type="text/javascript">
4454 jQuery(document).ready(function() {
4455 jQuery("#selectWEBSITE_TYPE_CONTAINER").change(function() {
4456 console.log("We change type of page : "+jQuery("#selectWEBSITE_TYPE_CONTAINER").val());
4457 if (jQuery("#selectWEBSITE_TYPE_CONTAINER").val() == \'blogpost\') {
4458 jQuery(".trimageforpage").show();
4460 jQuery(".trimageforpage").hide();
4470 $htmlhelp = $langs->trans(
"WEBSITE_KEYWORDSDesc");
4471 print $form->textwithpicto($langs->trans(
'WEBSITE_KEYWORDS'), $htmlhelp, 1,
'help',
'', 0, 2,
'keywordtooltip');
4473 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_KEYWORDS" value="'.dol_escape_htmltag($pagekeywords).
'">';
4477 print $langs->trans(
'Language');
4479 $onlykeys = array();
4483 $onlykeys[$langs->defaultlang] = $langs->defaultlang;
4486 $tmparray = explode(
',',
$object->otherlang);
4487 foreach ($tmparray as $key) {
4488 $tmpkey = trim($key);
4489 if (strlen($key) == 2) {
4490 $tmpkey = strtolower($key);
4492 $onlykeys[$tmpkey] = $tmpkey;
4498 print
img_picto(
'',
'language',
'class="pictofixedwidth"').$formadmin->select_language($pagelang ? $pagelang :
'',
'WEBSITE_LANG', 0, null,
'1', 0, 0,
'minwidth200', 0, 0, 0, $onlykeys, 1);
4499 $htmltext = $langs->trans(
"AvailableLanguagesAreDefinedIntoWebsiteProperties");
4500 print $form->textwithpicto(
'', $htmltext);
4506 print
'<!-- Translation of --><tr><td>';
4507 print $langs->trans(
'TranslationLinks');
4509 if ($action !=
'createcontainer') {
4511 $sql =
"SELECT rowid, lang from ".MAIN_DB_PREFIX.
"website_page where fk_page = ".((int) $objectpage->id);
4512 $resql = $db->query($sql);
4514 $num_rows = $db->num_rows($resql);
4515 if ($num_rows > 0) {
4516 print
'<span class="opacitymedium">'.$langs->trans(
'ThisPageHasTranslationPages').
':</span>';
4520 while ($obj = $db->fetch_object($resql)) {
4521 $result = $tmppage->fetch($obj->rowid);
4524 $tmpstring .=
'<br>';
4526 $tmpstring .= $tmppage->getNomUrl(1).
' '.
picto_from_langcode($tmppage->lang).
' '.$tmppage->lang;
4528 $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>';
4544 if ((empty($translatedby) || ($objectpage->lang !=
$object->lang)) && ($action ==
'editmeta' || $action ==
'createcontainer' || $objectpage->fk_page > 0)) {
4547 if ($objectpage->fk_page > 0) {
4548 $result = $sourcepage->fetch($objectpage->fk_page);
4555 if ($translatedby) {
4558 $translationof = $objectpage->fk_page;
4559 print
'<span class="opacitymedium">'.$langs->trans(
'ThisPageIsTranslationOf').
'</span> ';
4560 print $sourcepage->getNomUrl(2).
' '.$formwebsite->selectContainer($website,
'pageidfortranslation', ($translationof ? $translationof : -1), 1, $action,
'minwidth300', array($objectpage->id));
4561 if ($translationof > 0 && $sourcepage->lang) {
4564 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>';
4571 if (isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire')) {
4572 $langs->load(
'categories');
4574 if (!GETPOSTISSET(
'categories')) {
4576 $cats = $c->containing($objectpage->id, Categorie::TYPE_WEBSITE_PAGE);
4577 $arrayselected = array();
4578 if (is_array($cats)) {
4579 foreach ($cats as $cat) {
4580 $arrayselected[] = $cat->id;
4585 $cate_arbo = $form->select_all_categories(Categorie::TYPE_WEBSITE_PAGE,
'',
'parent', 0, 0, 3);
4588 print
'<tr><td class="toptd">'.$form->editfieldkey(
'Categories',
'categories',
'', $objectpage, 0).
'</td><td>';
4589 print
img_picto(
'',
'category',
'class="pictofixedwidth"');
4590 print $form->multiselectarray(
'categories', $cate_arbo, (GETPOSTISSET(
'categories') ?
GETPOST(
'categories',
'array') : $arrayselected), null, null,
'minwidth200 widthcentpercentminusxx');
4592 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);
4598 print
'<tr><td class="titlefieldcreate">';
4599 print
'ObjectClass';
4601 print
'<input type="text" class="flat minwidth300" name="WEBSITE_OBJECTCLASS" placeholder="ClassName::/path/class/ObjectClass.class.php" >';
4604 print
'<tr><td class="titlefieldcreate">';
4607 print
'<input type="text" class="flat minwidth300" name="WEBSITE_OBJECTID" >';
4611 $fuser =
new User($db);
4614 if ($action !=
'createcontainer') {
4616 print $langs->trans(
'DateLastModification');
4618 print
dol_print_date($pagedatemodification,
'dayhour',
'tzuser');
4622 print $langs->trans(
'UserModification');
4624 if ($pageusermodifid > 0) {
4625 $fuser->fetch($pageusermodifid);
4626 print $fuser->getNomUrl(-1);
4628 print
'<span class="opacitymedium">'.$langs->trans(
"Unknown").
'</span>';
4634 $url =
'https://wiki.dolibarr.org/index.php/Module_Website';
4635 $htmltext =
'<small>';
4636 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource", $url);
4637 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource1", $url);
4638 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource2", $url);
4639 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource3", $url);
4640 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSourceMore", $url);
4641 $htmltext .=
'<br>';
4642 $htmltext .=
'</small>';
4645 $formmail->withaiprompt =
'html';
4646 $formmail->withlayout = 1;
4647 $showlinktolayout = $formmail->withlayout;
4648 $showlinktoai = ($formmail->withaiprompt && isModEnabled(
'ai')) ?
'textgenerationwebpage' :
'';
4649 if (($action ==
'createcontainer' && $showlinktolayout) || ($action ==
'createcontainer' && $showlinktoai)) {
4650 print
'<tr><td class="titlefield tdtop">';
4651 if ($conf->browser->layout ==
'phone') {
4652 print $form->textwithpicto(
'', $htmltext, 1,
'help',
'inline-block', 1, 2,
'tooltipsubstitution');
4655 print $form->textwithpicto($langs->trans(
"PreviewPageContent").
' '.
img_help(2, $langs->trans(
"PreviewPageContent")), $htmltext, 1,
'none',
'inline-block', 1, 2,
'tooltipsubstitution');
4657 print
'</td><td class="tdtop">';
4661 $showlinktolayoutlabel = $langs->trans(
"FillPageWithALayout");
4662 $showlinktoailabel = $langs->trans(
"FillPageWithAIContent");
4663 $htmlname =
'content';
4665 include DOL_DOCUMENT_ROOT.
'/core/tpl/formlayoutai.tpl.php';
4671 if ($action ==
'createcontainer') {
4672 print
'<tr id="pageContent"><td class="tdtop">';
4673 if (!$showlinktolayout || !$showlinktoai) {
4674 if ($conf->browser->layout ==
'phone') {
4675 print $form->textwithpicto(
'', $htmltext, 1,
'help',
'inline-block', 1, 2,
'tooltipsubstitution');
4678 print $form->textwithpicto($langs->trans(
"PreviewPageContent").
' '.
img_help(2, $langs->trans(
"PreviewPageContent")), $htmltext, 1,
'none',
'inline-block', 1, 2,
'tooltipsubstitution');
4683 $doleditor =
new DolEditor(
'content',
GETPOST(
'content',
'none'),
'', 200,
'dolibarr_mailings',
'In',
true,
true,
true, 40,
'90%');
4684 $doleditor->Create();
4693 print $langs->trans(
'DateCreation');
4695 print $form->selectDate($pagedatecreation,
'datecreation', 1, 1, 0,
'', 1, 1);
4701 print $langs->trans(
'Author');
4703 if ($pageauthorid > 0) {
4704 $fuser->fetch($pageauthorid);
4705 print $fuser->getNomUrl(-1);
4707 print
'<span class="opacitymedium">'.$langs->trans(
"Unknown").
'</span>';
4712 print
'<tr class="trpublicauthor hidden"><td>';
4713 print $langs->trans(
'PublicAuthorAlias');
4715 print
'<input type="text" class="flat minwidth300" name="WEBSITE_AUTHORALIAS" value="'.dol_escape_htmltag($pageauthoralias).
'" placeholder="Anonymous">';
4718 print
'<tr><td class="tdhtmlheader tdtop">';
4719 $htmlhelp = $langs->trans(
"EditTheWebSiteForACommonHeader").
'<br><br>';
4720 $htmlhelp .= $langs->trans(
"Example").
' :<br>';
4722 print $form->textwithpicto($langs->transnoentitiesnoconv(
'HtmlHeaderPage'), $htmlhelp, 1,
'help',
'', 0, 2,
'htmlheadertooltip');
4724 $poscursor = array(
'x' =>
GETPOST(
'htmlheader_x'),
'y' =>
GETPOST(
'htmlheader_y'));
4725 $doleditor =
new DolEditor(
'htmlheader', $pagehtmlheader,
'',
'120',
'ace',
'In',
true,
false,
'ace', ROWS_3,
'100%',
'', $poscursor);
4726 print $doleditor->Create(1,
'',
true,
'HTML Header',
'html');
4731 print $langs->trans(
'AllowedInFrames');
4735 print
'<input type="checkbox" class="flat" name="WEBSITE_ALLOWED_IN_FRAMES" value="1"'.($pageallowedinframes ?
'checked="checked"' :
'').
'>';
4740 if ($action ==
'createcontainer') {
4741 print
'<div class="center tablecheckboxcreatemanually'.$hiddenmanuallyafterload.
'">';
4743 print
'<input type="submit" class="button small" name="addcontainer" value="'.$langs->trans(
"Create").
'">';
4744 print
'<input class="button button-cancel small" type="submit" name="preview" value="'.$langs->trans(
"Cancel").
'">';
4751 if (!empty($conf->use_javascript_ajax)) {
4752 print
'<input type="radio" name="radiocreatefrom" id="checkboxcreatefromfetching" value="checkboxcreatefromfetching"'.(GETPOST(
'radiocreatefrom') ==
'checkboxcreatefromfetching' ?
' checked' :
'').
'> ';
4754 print
'<label for="checkboxcreatefromfetching"><span class="opacitymediumxx">'.$langs->trans(
"CreateByFetchingExternalPage").
'</span></label><br>';
4755 print
'<hr class="tablecheckboxcreatefromfetching'.$hiddenfromfetchingafterload.
'">';
4756 print
'<table class="tableforfield centpercent tablecheckboxcreatefromfetching'.$hiddenfromfetchingafterload.
'">';
4757 print
'<tr><td class="titlefield">';
4758 print $langs->trans(
"URL");
4760 print
info_admin($langs->trans(
"OnlyEditionOfSourceForGrabbedContentFuture"), 0, 0,
'warning');
4761 print
'<input class="flat minwidth500" type="text" name="externalurl" value="'.dol_escape_htmltag(
GETPOST(
'externalurl',
'alpha')).
'" placeholder="https://externalsite/pagetofetch"> ';
4762 print
'<br><input class="flat paddingtop" type="checkbox" name="grabimages" value="1" checked="checked"> '.$langs->trans(
"GrabImagesInto");
4764 print $langs->trans(
"ImagesShouldBeSavedInto").
' ';
4765 $arraygrabimagesinto = array(
'root' => $langs->trans(
"WebsiteRootOfImages"),
'subpage' => $langs->trans(
"SubdirOfPage"));
4766 print $form->selectarray(
'grabimagesinto', $arraygrabimagesinto, GETPOSTISSET(
'grabimagesinto') ?
GETPOST(
'grabimagesinto') :
'root', 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
4769 print
'<input class="button small" style="margin-top: 5px" type="submit" name="fetchexternalurl" value="'.dol_escape_htmltag($langs->trans(
"FetchAndCreate")).
'">';
4770 print
'<input class="button button-cancel small" type="submit" name="preview" value="'.$langs->trans(
"Cancel").
'">';
4776 if ($action ==
'createcontainer') {
4777 print
'<script type="text/javascript">
4778 jQuery(document).ready(function() {
4779 var disableautofillofalias = 0;
4780 var selectedm = \'\';
4781 var selectedf = \'\';
4783 jQuery("#WEBSITE_TITLE").keyup(function() {
4784 if (disableautofillofalias == 0) {
4785 var valnospecial = jQuery("#WEBSITE_TITLE").val();
4786 valnospecial = valnospecial.replace(/[éèê]/g, \'e\').replace(/[à]/g, \'a\').replace(/[ù]/g, \'u\').replace(/[î]/g, \'i\');
4787 valnospecial = valnospecial.replace(/[ç]/g, \'c\').replace(/[ö]/g, \'o\');
4788 valnospecial = valnospecial.replace(/[^\w]/gi, \'-\').toLowerCase();
4789 valnospecial = valnospecial.replace(/\-+/g, \'-\').replace(/\-$/, \'\');
4790 console.log("disableautofillofalias=0 so we replace WEBSITE_TITLE with "+valnospecial);
4791 jQuery("#WEBSITE_PAGENAME").val(valnospecial);
4794 jQuery("#WEBSITE_PAGENAME").keyup(function() {
4795 if (jQuery("#WEBSITE_PAGENAME").val() == \'\') {
4796 disableautofillofalias = 0;
4798 disableautofillofalias = 1;
4801 jQuery("#WEBSITE_PAGENAME").blur(function() {
4802 if (jQuery("#WEBSITE_PAGENAME").val() == \'\') {
4803 disableautofillofalias = 0;
4804 jQuery("#WEBSITE_TITLE").trigger(\'keyup\');
4808 jQuery("#checkboxcreatefromfetching,#checkboxcreatemanually").click(function() {
4809 console.log("we select a method to create a new container "+jQuery("#checkboxcreatefromfetching:checked").val())
4810 jQuery(".tablecheckboxcreatefromfetching").hide();
4811 jQuery(".tablecheckboxcreatemanually").hide();
4812 if (typeof(jQuery("#checkboxcreatefromfetching:checked").val()) != \'undefined\') {
4813 console.log("show create from spider form");
4814 if (selectedf != \'createfromfetching\') {
4815 jQuery(".tablecheckboxcreatefromfetching").show();
4816 selectedf = \'createfromfetching\';
4819 jQuery(".tablecheckboxcreatefromfetching").hide();
4823 if (typeof(jQuery("#checkboxcreatemanually:checked").val()) != \'undefined\') {
4824 console.log("show create from scratch or template form");
4825 if (selectedm != \'createmanually\') {
4826 jQuery(".tablecheckboxcreatemanually").show();
4827 selectedm = \'createmanually\';
4830 jQuery(".tablecheckboxcreatemanually").hide();
4849if ($action ==
'preview') {
4853if ($action ==
'editfile' || $action ==
'file_manager' || $action ==
'convertimgwebp' || $action ==
'confirmconvertimgwebp') {
4854 print
'<!-- Edit Media -->'.
"\n";
4855 print
'<div class="fiche"><br>';
4860 $formalreadyopen = 2;
4862 $url = DOL_URL_ROOT.
'/website/index.php';
4864 include DOL_DOCUMENT_ROOT.
'/core/tpl/filemanager.tpl.php';
4869if ($action ==
'editmenu') {
4870 print
'<!-- Edit Menu -->'.
"\n";
4871 print
'<div class="center">'.$langs->trans(
"FeatureNotYetAvailable").
'</center>';
4874if ($action ==
'editsource') {
4877 $contentforedit =
'';
4881 $contentforedit .= $objectpage->content;
4883 $maxheightwin = 480;
4884 if (isset($_SESSION[
"dol_screenheight"])) {
4885 if ($_SESSION[
"dol_screenheight"] > 680) {
4886 $maxheightwin = $_SESSION[
"dol_screenheight"] - 400;
4888 if ($_SESSION[
"dol_screenheight"] > 800) {
4889 $maxheightwin = $_SESSION[
"dol_screenheight"] - 490;
4893 $poscursor = array(
'x' =>
GETPOST(
'PAGE_CONTENT_x'),
'y' =>
GETPOST(
'PAGE_CONTENT_y'));
4894 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
4895 $doleditor =
new DolEditor(
'PAGE_CONTENT', $contentforedit,
'', $maxheightwin,
'Full',
'',
true,
true,
'ace', ROWS_5,
'40%', 0, $poscursor);
4896 $doleditor->Create(0,
'',
false,
'HTML Source',
'php');
4899if ($action ==
'editcontent') {
4902 $contentforedit =
'';
4906 $contentforedit .= $objectpage->content;
4911 $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);
4913 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
4914 $poscursor = array(
'x' =>
GETPOST(
'PAGE_CONTENT_x'),
'y' =>
GETPOST(
'PAGE_CONTENT_y'));
4915 $doleditor =
new DolEditor(
'PAGE_CONTENT', $contentforedit,
'', 500,
'Full',
'',
true,
true,
true, ROWS_5,
'90%', 0, $poscursor);
4916 $doleditor->Create(0,
'',
false);
4923if ($mode ==
'replacesite' || $massaction ==
'replace') {
4924 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4925 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4926 print
'<input type="hidden" name="action" value="replacesiteconfirm">';
4927 print
'<input type="hidden" name="mode" value="replacesite">';
4928 print
'<input type="hidden" name="website" value="'.$website->ref.
'">';
4931 print
'<!-- Search page and replace string -->'.
"\n";
4932 print
'<div class="fiche"><br>';
4934 print
load_fiche_titre($langs->trans(
"ReplaceWebsiteContent"),
'',
'search');
4936 print
'<div class="fichecenter"><div class="fichehalfleft">';
4938 print
'<div class="tagtable">';
4940 print
'<div class="tagtr">';
4941 print
'<div class="tagtd paddingrightonly opacitymedium">';
4942 print $langs->trans(
"SearchReplaceInto");
4944 print
'<div class="tagtd">';
4945 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>';
4946 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>';
4947 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>';
4951 print
'<div class="tagtr">';
4952 print
'<div class="tagtd paddingrightonly opacitymedium" style="padding-right: 10px !important">';
4953 print $langs->trans(
"SearchString");
4955 print
'<div class="tagtd">';
4956 print
'<input type="text" name="searchstring" value="'.dol_escape_htmltag($searchkey, 0, 0,
'', 1).
'" autofocus>';
4962 print
'</div><div class="fichehalfleft">';
4964 print
'<div class="tagtable">';
4966 print
'<div class="tagtr">';
4967 print
'<div class="tagtd paddingrightonly opacitymedium tdoverflowmax100onsmartphone" style="padding-right: 10px !important">';
4968 print $langs->trans(
"WEBSITE_TYPE_CONTAINER");
4970 print
'<div class="tagtd">';
4971 print
img_picto(
'',
'object_technic',
'class="paddingrightonly"').
' ';
4972 print $formwebsite->selectTypeOfContainer(
'optioncontainertype', (
GETPOST(
'optioncontainertype',
'alpha') ?
GETPOST(
'optioncontainertype',
'alpha') :
''), 1,
'', 1,
'minwidth125 maxwidth400 widthcentpercentminusx');
4976 print
'<div class="tagtr">';
4977 print
'<div class="tagtd paddingrightonly opacitymedium tdoverflowmax100onsmartphone" style="padding-right: 10px !important">';
4978 print $langs->trans(
"Language");
4980 print
'<div class="tagtd">';
4981 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);
4986 if (isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire')) {
4987 print
'<div class="tagtr">';
4988 print
'<div class="tagtd paddingrightonly marginrightonly opacitymedium tdoverflowmax100onsmartphone" style="padding-right: 10px !important">';
4989 print $langs->trans(
"Category");
4991 print
'<div class="tagtd">';
4992 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');
4993 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
5001 print
'<input type="submit" class="button margintoponly" name="buttonreplacesitesearch" value="'.dol_escape_htmltag($langs->trans(
"Search")).
'">';
5003 print
'</div></div>';
5005 if ($mode ==
'replacesite') {
5006 print
'<!-- List of search result -->'.
"\n";
5007 print
'<div class="rowsearchresult clearboth">';
5012 if ($listofpages[
'code'] ==
'OK') {
5013 $arrayofselected = is_array($toselect) ? $toselect : array();
5015 $nbtotalofrecords = count($listofpages[
'list']);
5017 $permissiontodelete = $user->hasRight(
'website',
'delete');
5020 $arrayofmassactions = array();
5021 if ($user->hasRight(
'website',
'writephp') && $searchkey) {
5022 $arrayofmassactions[
'replace'] =
img_picto(
'',
'replacement',
'class="pictofixedwidth"').$langs->trans(
"Replace");
5024 if ($user->hasRight(
'website',
'write')) {
5025 $arrayofmassactions[
'setcategory'] =
img_picto(
'',
'category',
'class="pictofixedwidth"').$langs->trans(
"ClassifyInCategory");
5027 if ($user->hasRight(
'website',
'write')) {
5028 $arrayofmassactions[
'delcategory'] =
img_picto(
'',
'category',
'class="pictofixedwidth"').$langs->trans(
"RemoveCategory");
5030 if ($permissiontodelete) {
5031 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
5033 if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete'))) {
5034 $arrayofmassactions = array();
5037 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
5038 $massactionbutton .=
'<div class="massactionother massactionreplace hidden">';
5039 $massactionbutton .= $langs->trans(
"ReplaceString");
5040 $massactionbutton .=
' <input type="text" name="replacestring" value="'.dol_escape_htmltag(
GETPOST(
'replacestring',
'none')).
'">';
5041 $massactionbutton .=
'</div>';
5042 $massactionbutton .=
'<div class="massactionother massactionsetcategory massactiondelcategory hidden">';
5043 $massactionbutton .=
img_picto(
'',
'category',
'class="pictofixedwidth"');
5044 $massactionbutton .= $form->select_all_categories(Categorie::TYPE_WEBSITE_PAGE, GETPOSTISSET(
'setcategory') ?
GETPOST(
'setcategory') :
'',
'setcategory', 64, 0, 0, 0,
'minwidth300 alignstart');
5045 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
5047 $massactionbutton .=
'</div>';
5049 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
5052 $selectedfields =
'';
5053 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
5055 print_barre_liste($langs->trans(
"Results"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'generic', 0,
'',
'', $limit, 1, 1, 1);
5057 $topicmail =
"WebsitePageRef";
5058 $modelmail =
"websitepage_send";
5060 $trackid =
'wsp'.$object->id;
5061 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
5063 $param =
'mode=replacesite&website='.urlencode($website->ref);
5064 $param .=
'&searchstring='.urlencode($searchkey);
5065 if (
GETPOST(
'optioncontent')) {
5066 $param .=
'&optioncontent=content';
5069 $param .=
'&optionmeta=meta';
5071 if (
GETPOST(
'optionsitefiles')) {
5072 $param .=
'&optionsitefiles=optionsitefiles';
5074 if (
GETPOST(
'optioncontainertype')) {
5075 $param .=
'&optioncontainertype='.GETPOST(
'optioncontainertype',
'aZ09');
5077 if (
GETPOST(
'optionlanguage')) {
5078 $param .=
'&optionlanguage='.GETPOST(
'optionlanguage',
'aZ09');
5080 if (
GETPOST(
'optioncategory')) {
5081 $param .=
'&optioncategory='.GETPOST(
'optioncategory',
'aZ09');
5084 print
'<div class="div-table-responsive-no-min">';
5085 print
'<table class="noborder centpercent">';
5086 print
'<tr class="liste_titre">';
5089 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
5091 print
getTitleFieldOfList(
"Type", 0, $_SERVER[
'PHP_SELF'],
'type_container',
'', $param,
'', $sortfield, $sortorder,
'').
"\n";
5092 print
getTitleFieldOfList(
"Page", 0, $_SERVER[
'PHP_SELF'],
'pageurl',
'', $param,
'', $sortfield, $sortorder,
'').
"\n";
5093 print
getTitleFieldOfList(
"Language", 0, $_SERVER[
'PHP_SELF'],
'lang',
'', $param,
'', $sortfield, $sortorder,
'center ').
"\n";
5094 print
getTitleFieldOfList(
"Categories", 0, $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'center ').
"\n";
5096 print
getTitleFieldOfList(
"UserCreation", 0, $_SERVER[
'PHP_SELF'],
'fk_user_creat',
'', $param,
'', $sortfield, $sortorder,
'').
"\n";
5097 print
getTitleFieldOfList(
"DateCreation", 0, $_SERVER[
'PHP_SELF'],
'date_creation',
'', $param,
'', $sortfield, $sortorder,
'center ').
"\n";
5098 print
getTitleFieldOfList(
"DateLastModification", 0, $_SERVER[
'PHP_SELF'],
'tms',
'', $param,
'', $sortfield, $sortorder,
'center ').
"\n";
5102 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
5106 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
5111 foreach ($listofpages[
'list'] as $answerrecord) {
5112 if (is_object($answerrecord) && get_class($answerrecord) ==
'WebsitePage') {
5113 $param =
'?mode=replacesite';
5114 $param .=
'&websiteid='.$website->id;
5115 $param .=
'&optioncontent='.GETPOST(
'optioncontent',
'aZ09');
5116 $param .=
'&optionmeta='.GETPOST(
'optionmeta',
'aZ09');
5117 $param .=
'&optionsitefiles='.GETPOST(
'optionsitefiles',
'aZ09');
5118 $param .=
'&optioncontainertype='.GETPOST(
'optioncontainertype',
'aZ09');
5119 $param .=
'&optionlanguage='.GETPOST(
'optionlanguage',
'aZ09');
5120 $param .=
'&optioncategory='.GETPOST(
'optioncategory',
'aZ09');
5121 $param .=
'&searchstring='.urlencode($searchkey);
5127 print
'<td class="nowrap center">';
5129 print
'<!-- Status of page -->'.
"\n";
5130 if ($massactionbutton || $massaction) {
5132 if (in_array($answerrecord->id, $arrayofselected)) {
5135 print
'<input id="'.$answerrecord->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$answerrecord->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
5141 print
'<td class="nowraponall">';
5143 if (!empty($conf->cache[
'type_of_container'][$answerrecord->type_container])) {
5144 print $langs->trans($conf->cache[
'type_of_container'][$answerrecord->type_container]);
5146 print $langs->trans($answerrecord->type_container);
5151 $titleofpage = ($answerrecord->title ? $answerrecord->title : $langs->trans(
"NoTitle"));
5152 print
'<td class="tdoverflowmax300" title="'.dol_escape_htmltag($titleofpage).
'">';
5153 print $answerrecord->getNomUrl(1);
5154 print
' <span class="opacitymedium">('.dol_escape_htmltag($titleofpage).
')</span>';
5158 print
'<span class="opacitymedium">'.dol_escape_htmltag($answerrecord->description ? $answerrecord->description : $langs->trans(
"NoDescription")).
'</span>';
5162 print
'<td class="center">';