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';
67$langs->loadLangs(array(
"admin",
"other",
"website",
"errors"));
70if (!$user->hasRight(
'website',
'read')) {
74$conf->dol_hide_leftmenu = 1;
80$websitekey =
GETPOST(
'website',
'alpha');
81$page =
GETPOST(
'page',
'alpha');
83$pageref =
GETPOST(
'pageref',
'alphanohtml');
85$action =
GETPOST(
'action',
'aZ09');
86$massaction =
GETPOST(
'massaction',
'alpha');
87$confirm =
GETPOST(
'confirm',
'alpha');
88$cancel =
GETPOST(
'cancel',
'alpha');
89$toselect =
GETPOST(
'toselect',
'array');
90$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'websitelist';
91$backtopage =
GETPOST(
'backtopage',
'alpha');
92$optioncss =
GETPOST(
'optioncss',
'aZ');
93$dol_hide_topmenu =
GETPOSTINT(
'dol_hide_topmenu');
94$dol_hide_leftmenu =
GETPOSTINT(
'dol_hide_leftmenu');
95$dol_openinpopup =
GETPOST(
'dol_openinpopup',
'aZ09');
97$type_container =
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'alpha');
98$section_dir =
GETPOST(
'section_dir',
'alpha');
99$file_manager =
GETPOST(
'file_manager',
'alpha');
100$replacesite =
GETPOST(
'replacesite',
'alpha');
101$mode =
GETPOST(
'mode',
'alpha');
103if (
GETPOST(
'deletesite',
'alpha')) {
104 $action =
'deletesite';
106if (
GETPOST(
'delete',
'alpha')) {
109if (
GETPOST(
'preview',
'alpha')) {
112if (
GETPOST(
'createsite',
'alpha')) {
113 $action =
'createsite';
115if (
GETPOST(
'createcontainer',
'alpha')) {
116 $action =
'createcontainer';
118if (
GETPOST(
'editcss',
'alpha')) {
121if (
GETPOST(
'editmenu',
'alpha')) {
122 $action =
'editmenu';
124if (
GETPOST(
'setashome',
'alpha')) {
125 $action =
'setashome';
127if (
GETPOST(
'editmeta',
'alpha')) {
128 $action =
'editmeta';
130if (
GETPOST(
'editsource',
'alpha')) {
131 $action =
'editsource';
133if (
GETPOST(
'editcontent',
'alpha')) {
134 $action =
'editcontent';
136if (
GETPOST(
'exportsite',
'alpha')) {
137 $action =
'exportsite';
139if (
GETPOST(
'importsite',
'alpha')) {
140 $action =
'importsite';
142if (
GETPOST(
'createfromclone',
'alpha')) {
143 $action =
'createfromclone';
145if (
GETPOST(
'createpagefromclone',
'alpha')) {
146 $action =
'createpagefromclone';
148if (empty($action) && $file_manager) {
149 $action =
'file_manager';
151if ($action ==
'replacesite' || (empty($action) && $replacesite)) {
152 $mode =
'replacesite';
160$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
161$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
163if (empty($page) || $page == -1) {
166$offset = $limit * $page;
167$pageprev = $page - 1;
168$pagenext = $page + 1;
179$listofwebsites =
$object->fetchAll(
'ASC',
'position');
182if (!($websiteid > 0) && empty($websitekey) && $action !=
'createsite') {
183 foreach ($listofwebsites as $key => $valwebsite) {
184 $websitekey = $valwebsite->ref;
188if ($websiteid > 0 || $websitekey) {
189 $res =
$object->fetch($websiteid, $websitekey);
199if (($pageid > 0 || $pageref) && $action !=
'addcontainer') {
200 $res = $objectpage->fetch($pageid, (
$object->id > 0 ?
$object->id : null), $pageref);
203 $res = $objectpage->fetch($pageid, (
$object->id > 0 ?
$object->id : null), null, $pageref);
207 if ($res >= 0 &&
$object->id > 0) {
208 if ($objectpage->fk_website !=
$object->id) {
209 if (
$object->fk_default_home > 0) {
210 $res = $objectpage->fetch(
$object->fk_default_home,
$object->id,
'');
212 $pageid =
$object->fk_default_home;
215 $res = $objectpage->fetch(0,
$object->id,
'');
219 $pageid = $objectpage->id;
223 $pageid = $objectpage->id;
229if (empty($pageid) && empty($pageref) &&
$object->id > 0 && $action !=
'createcontainer') {
230 $pageid =
$object->fk_default_home;
231 if (empty($pageid)) {
232 $array = $objectpage->fetchAll(
$object->id,
'ASC,ASC',
'type_container,pageurl');
233 if (!is_array($array) && $array < 0) {
236 $atleastonepage = (is_array($array) && count($array) > 0);
240 foreach ($array as $key => $valpage) {
241 if (empty($firstpageid)) {
242 $firstpageid = $valpage->id;
244 if (
$object->fk_default_home && $key ==
$object->fk_default_home) {
245 $homepageid = $valpage->id;
248 $pageid = ($homepageid ? $homepageid : $firstpageid);
253global $dolibarr_main_data_root;
254$pathofwebsite = $dolibarr_main_data_root.($conf->entity > 1 ?
'/'.$conf->entity :
'').
'/website/'.$websitekey;
255$filehtmlheader = $pathofwebsite.
'/htmlheader.html';
256$filecss = $pathofwebsite.
'/styles.css.php';
257$filejs = $pathofwebsite.
'/javascript.js.php';
258$filerobot = $pathofwebsite.
'/robots.txt';
259$filehtaccess = $pathofwebsite.
'/.htaccess';
260$filetpl = $pathofwebsite.
'/page'.$pageid.
'.tpl.php';
261$fileindex = $pathofwebsite.
'/index.php';
262$filewrapper = $pathofwebsite.
'/wrapper.php';
263$filemanifestjson = $pathofwebsite.
'/manifest.json.php';
264$filereadme = $pathofwebsite.
'/README.md';
265$filelicense = $pathofwebsite.
'/LICENSE';
266$filemaster = $pathofwebsite.
'/master.inc.php';
269$urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
270$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
274$permtouploadfile = $user->hasRight(
'website',
'write');
275$diroutput =
$conf->medias->multidir_output[
$conf->entity];
277$relativepath = $section_dir;
278$upload_dir = preg_replace(
'/\/$/',
'', $diroutput).
'/'.preg_replace(
'/^\//',
'', $relativepath);
280$htmlheadercontentdefault =
'';
281$htmlheadercontentdefault .=
'<link rel="stylesheet" id="google-fonts-css" href="//fonts.googleapis.com/css?family=Open+Sans:300,400,700" />'.
"\n";
282$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";
283$htmlheadercontentdefault .=
'<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>'.
"\n";
284$htmlheadercontentdefault .=
'<script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>'.
"\n";
285$htmlheadercontentdefault .=
'<!--'.
"\n";
286$htmlheadercontentdefault .=
'<script src="/document.php?modulepart=medias&file=css/myfile.css"></script>'.
"\n";
287$htmlheadercontentdefault .=
'<script src="/document.php?modulepart=medias&file=js/myfile.js"></script>'.
"\n";
288$htmlheadercontentdefault .=
'-->'.
"\n";
290$manifestjsoncontentdefault =
'';
291$manifestjsoncontentdefault .=
'{
293 "short_name": "MyWebsite",
296 "display": "standalone",
297 "background_color": "#fff",
298 "description": "A simple Web app.",
300 "src": "images/'.urlencode($website->ref).
'/homescreen48.png",
304 "src": "image/'.urlencode($website->ref).
'/homescreen72.png",
308 "src": "image/'.urlencode($website->ref).
'/homescreen96.png",
312 "src": "image/'.urlencode($website->ref).
'/homescreen144.png",
316 "src": "image/'.urlencode($website->ref).
'/homescreen168.png",
320 "src": "image/'.urlencode($website->ref).
'/homescreen192.png",
324 "related_applications": [{
326 "url": "https://play.google.com/store/apps/details?id=com.nltechno.dolidroidpro"
330$listofpages = array();
339if (
GETPOST(
'optionsitefiles')) {
340 $algo .=
'sitefiles';
343if (empty($sortfield)) {
344 if ($action ==
'file_manager') {
348 $sortfield =
'pageurl';
353$searchkey =
GETPOST(
'searchstring',
'restricthtmlallowunvalid');
355if ($action ==
'replacesite' || $mode ==
'replacesite') {
356 $containertype =
GETPOST(
'optioncontainertype',
'aZ09') !=
'-1' ?
GETPOST(
'optioncontainertype',
'aZ09') :
'';
357 $langcode =
GETPOST(
'optionlanguage',
'aZ09');
358 $otherfilters = array();
360 $otherfilters[
'category'] =
GETPOSTINT(
'optioncategory');
363 $listofpages =
getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters, -1);
366$usercanedit = $user->hasRight(
'website',
'write');
367$permissiontoadd = $user->hasRight(
'website',
'write');
368$permissiontodelete = $user->hasRight(
'website',
'delete');
379if (
GETPOST(
'refreshsite',
'alpha') ||
GETPOST(
'refreshsite.x',
'alpha') ||
GETPOST(
'refreshsite_x',
'alpha')) {
380 if ($action ==
'addsite') {
383 if ($action ==
'updatesource') {
387 $pageid =
$object->fk_default_home;
388 if (empty($pageid)) {
389 $array = $objectpage->fetchAll(
$object->id,
'ASC,ASC',
'type_container,pageurl');
390 if (!is_array($array) && $array < 0) {
393 $atleastonepage = (is_array($array) && count($array) > 0);
397 foreach ($array as $key => $valpage) {
398 if (empty($firstpageid)) {
399 $firstpageid = $valpage->id;
401 if (
$object->fk_default_home && $key ==
$object->fk_default_home) {
402 $homepageid = $valpage->id;
405 $pageid = ($homepageid ? $homepageid : $firstpageid);
408if (
GETPOST(
'refreshpage',
'alpha') && !in_array($action, array(
'updatecss'))) {
412if ($cancel && $action ==
'renamefile') {
421 header(
"Location: ".$backtopage);
426$savbacktopage = $backtopage;
427$backtopage = $_SERVER[
"PHP_SELF"].
'?file_manager=1&website='.urlencode($websitekey).
'&pageid='.urlencode((
string) $pageid).(GETPOST(
'section_dir',
'alpha') ?
'§ion_dir='.urlencode(
GETPOST(
'section_dir',
'alpha')) :
'');
429 $backtopage .=
'&sortfield='.urlencode($sortfield);
432 $backtopage .=
'&sortorder='.urlencode($sortorder);
434include DOL_DOCUMENT_ROOT.
'/core/actions_linkedfiles.inc.php';
436$backtopage = $savbacktopage;
440if ($action ==
'renamefile') {
441 $action =
'file_manager';
444if ($action ==
'setwebsiteonline' && $usercanedit) {
445 $website->setStatut($website::STATUS_VALIDATED,
null,
'',
'WEBSITE_MODIFY',
'status');
447 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
GETPOST(
'website')).
'&pageid='.
GETPOSTINT(
'websitepage'));
450if ($action ==
'setwebsiteoffline' && $usercanedit) {
451 $result = $website->setStatut($website::STATUS_DRAFT,
null,
'',
'WEBSITE_MODIFY',
'status');
453 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
GETPOST(
'website')).
'&pageid='.
GETPOSTINT(
'websitepage'));
456if ($action ==
'seteditinline') {
459 setEventMessages($langs->trans(
"FeatureNotYetAvailable"),
null,
'warnings');
464 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
GETPOST(
'website')).
'&pageid='.
GETPOSTINT(
'pageid'));
467if ($action ==
'unseteditinline') {
469 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
GETPOST(
'website')).
'&pageid='.
GETPOSTINT(
'pageid'));
472if ($action ==
'setshowsubcontainers') {
475 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
GETPOST(
'website')).
'&pageid='.
GETPOSTINT(
'pageid'));
478if ($action ==
'unsetshowsubcontainers') {
480 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
GETPOST(
'website')).
'&pageid='.
GETPOSTINT(
'pageid'));
484if ($massaction ==
'replace' &&
GETPOST(
'confirmmassaction',
'alpha') && !$searchkey && $usercanedit) {
485 $mode =
'replacesite';
486 $action =
'replacesite';
490if ($action ==
'deletetemplate' && $usercanedit) {
491 $dirthemes = array(
'/doctemplates/websites');
492 if (!empty(
$conf->modules_parts[
'websitetemplates'])) {
493 foreach (
$conf->modules_parts[
'websitetemplates'] as $reldir) {
494 $dirthemes = array_merge($dirthemes, (array) ($reldir.
'doctemplates/websites'));
497 $dirthemes = array_unique($dirthemes);
501 $mode =
'importsite';
502 $action =
'importsite';
504 if (count($dirthemes)) {
506 foreach ($dirthemes as $dir) {
508 $dirtheme = DOL_DATA_ROOT.$dir;
509 if (is_dir($dirtheme)) {
510 $templateuserfile =
GETPOST(
'templateuserfile');
511 $imguserfile = preg_replace(
'/\.zip$/',
'', $templateuserfile).
'.jpg';
520if ($massaction ==
'setcategory' &&
GETPOST(
'confirmmassaction',
'alpha') && $usercanedit) {
527 if ($categoryid > 0) {
530 $category->fetch($categoryid);
532 foreach ($toselect as $tmpid) {
533 $tmpwebsitepage->id = $tmpid;
534 $result = $category->add_type($tmpwebsitepage,
'website_page');
535 if ($result < 0 && $result != -3) {
549 setEventMessages($langs->trans(
"RecordsModified", $nbupdate),
null,
'mesgs');
555 $listofpages =
getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters, -1);
559if ($massaction ==
'delcategory' &&
GETPOST(
'confirmmassaction',
'alpha') && $usercanedit) {
566 if ($categoryid > 0) {
569 $category->fetch($categoryid);
571 foreach ($toselect as $tmpid) {
572 $tmpwebsitepage->id = $tmpid;
573 $result = $category->del_type($tmpwebsitepage,
'website_page');
574 if ($result < 0 && $result != -3) {
588 setEventMessages($langs->trans(
"RecordsModified", $nbupdate),
null,
'mesgs');
594 $listofpages =
getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters, -1);
598if ($massaction ==
'replace' &&
GETPOST(
'confirmmassaction',
'alpha') && $usercanedit) {
599 $replacestring =
GETPOST(
'replacestring',
'restricthtmlallowunvalid');
601 $dolibarrdataroot = preg_replace(
'/([\\/]+)$/i',
'', DOL_DATA_ROOT);
602 $allowimportsite =
true;
603 if (
dol_is_file($dolibarrdataroot.
'/installmodules.lock')) {
604 $allowimportsite =
false;
607 if (!$allowimportsite) {
611 $message = $langs->trans(
'InstallModuleFromWebHasBeenDisabledContactUs');
614 $message = $langs->trans(
"InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.
'/installmodules.lock');
617 } elseif (!$user->hasRight(
'website',
'writephp')) {
619 } elseif (!$replacestring) {
624 foreach ($toselect as $keyselected) {
625 $objectpage = $listofpages[
'list'][$keyselected];
626 if ($objectpage->pageurl) {
627 dol_syslog(
"Replace string into page ".$objectpage->pageurl);
629 if (
GETPOST(
'optioncontent',
'aZ09')) {
630 $objectpage->content = str_replace($searchkey, $replacestring, $objectpage->content);
632 if (
GETPOST(
'optionmeta',
'aZ09')) {
633 $objectpage->title = str_replace($searchkey, $replacestring, $objectpage->title);
634 $objectpage->description = str_replace($searchkey, $replacestring, $objectpage->description);
635 $objectpage->keywords = str_replace($searchkey, $replacestring, $objectpage->keywords);
638 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
639 $filetpl = $pathofwebsite.
'/page'.$objectpage->id.
'.tpl.php';
644 setEventMessages(
'Failed to write file '.basename($filealias),
null,
'errors');
652 $objectpage->update($user);
656 $action =
'createcontainer';
662 if ($nbreplacement > 0) {
663 setEventMessages($langs->trans(
"ReplacementDoneInXPages", $nbreplacement),
null,
'mesgs');
666 $containertype =
GETPOST(
'optioncontainertype',
'aZ09') !=
'-1' ?
GETPOST(
'optioncontainertype',
'aZ09') :
'';
667 $langcode =
GETPOST(
'optionlanguage',
'aZ09');
668 $otherfilters = array();
670 $otherfilters[
'category'] =
GETPOSTINT(
'optioncategory');
674 $listofpages =
getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters);
704if ($action ==
'addsite' && $usercanedit) {
707 if (
GETPOST(
'virtualhost',
'alpha') && !preg_match(
'/^http/',
GETPOST(
'virtualhost',
'alpha'))) {
709 setEventMessages($langs->trans(
'ErrorURLMustStartWithHttp', $langs->transnoentitiesnoconv(
"VirtualHost")),
null,
'errors');
712 if (!$error && !
GETPOST(
'WEBSITE_REF',
'alpha')) {
714 $langs->load(
"errors");
715 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->transnoentities(
"WebsiteName")),
null,
'errors');
717 if (!$error && !preg_match(
'/^[a-z0-9_\-\.]+$/i',
GETPOST(
'WEBSITE_REF',
'alpha'))) {
719 $langs->load(
"errors");
720 setEventMessages($langs->transnoentities(
"ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities(
"Ref")),
null,
'errors');
724 $arrayotherlang = explode(
',',
GETPOST(
'WEBSITE_OTHERLANG',
'alphanohtml'));
725 foreach ($arrayotherlang as $key => $val) {
727 if (empty(trim($val))) {
730 $arrayotherlang[$key] = substr(trim($val), 0, 2);
734 $tmpobject->ref =
GETPOST(
'WEBSITE_REF',
'alpha');
735 $tmpobject->description =
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml');
736 $tmpobject->lang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
737 $tmpobject->otherlang = implode(
',', $arrayotherlang);
738 $tmpobject->virtualhost =
GETPOST(
'virtualhost',
'alpha');
740 $result = $tmpobject->create($user);
744 } elseif ($result < 0) {
755 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$tmpobject->ref);
759 $action =
'createsite';
768'@phan-var-force int $error';
771if ($action ==
'addcontainer' && $usercanedit) {
776 $objectpage->fk_website =
$object->id;
778 if (GETPOSTISSET(
'fetchexternalurl')) {
779 $urltograb =
GETPOST(
'externalurl',
'alpha');
780 $grabimages =
GETPOSTINT(
'grabimages') ? 1 : 0;
781 $grabimagesinto =
GETPOST(
'grabimagesinto',
'alpha');
783 include_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
786 if (empty($urltograb)) {
788 $langs->load(
"errors");
789 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"URL")),
null,
'errors');
790 $action =
'createcontainer';
791 } elseif (!preg_match(
'/^http/', $urltograb)) {
793 $langs->load(
"errors");
794 setEventMessages(
'Error URL must start with http:// or https://',
null,
'errors');
795 $action =
'createcontainer';
802 $urltograbwithoutdomainandparam = preg_replace(
'/^https?:\/\/[^\/]+\/?/i',
'', $urltograb);
804 $urltograbwithoutdomainandparam = preg_replace(
'/\?.*$/',
'', $urltograbwithoutdomainandparam);
805 if (empty($urltograbwithoutdomainandparam) && !preg_match(
'/\/$/', $urltograb)) {
808 $pageurl =
dol_sanitizeFileName(preg_replace(
'/[\/\.]/',
'-', preg_replace(
'/\/+$/',
'', $urltograbwithoutdomainandparam)));
810 $urltograbdirwithoutslash = dirname($urltograb.
'.');
819 $result = $tmpwebsitepage->fetch(0,
$object->id, $pageurl);
821 setEventMessages($langs->trans(
"AliasPageAlreadyExists", $pageurl),
null,
'errors');
823 $action =
'createcontainer';
828 $tmp =
getURLContent($urltograb,
'GET',
'', 1, array(), array(
'http',
'https'), 0);
831 if (!empty($tmp[
'content_type']) && preg_match(
'/ISO-8859-1/', $tmp[
'content_type'])) {
832 if (function_exists(
'mb_check_encoding')) {
833 if (mb_check_encoding($tmp[
'content'],
'ISO-8859-1')) {
835 $tmp[
'content'] = mb_convert_encoding($tmp[
'content'],
'ISO-8859-1',
'UTF-8');
838 setEventMessages(
'Error getting '.$urltograb.
': content seems non valid ISO-8859-1',
null,
'errors');
839 $action =
'createcontainer';
843 setEventMessages(
'Error getting '.$urltograb.
': content seems ISO-8859-1 but functions to convert into UTF-8 are not available in your PHP',
null,
'errors');
844 $action =
'createcontainer';
847 if (empty($tmp[
'content_type']) || (!empty($tmp[
'content_type']) && preg_match(
'/UTF-8/', $tmp[
'content_type']))) {
848 if (function_exists(
'mb_check_encoding')) {
849 if (mb_check_encoding($tmp[
'content'],
'UTF-8')) {
853 setEventMessages(
'Error getting '.$urltograb.
': content seems not a valid UTF-8',
null,
'errors');
854 $action =
'createcontainer';
859 if ($tmp[
'curl_error_no']) {
861 setEventMessages(
'Error getting '.$urltograb.
': '.$tmp[
'curl_error_msg'],
null,
'errors');
862 $action =
'createcontainer';
863 } elseif ($tmp[
'http_code'] !=
'200') {
865 setEventMessages(
'Error getting '.$urltograb.
': '.$tmp[
'http_code'],
null,
'errors');
866 $action =
'createcontainer';
875 setEventMessages(
'Error getting '.$urltograb.
': file that include PHP content is not allowed',
null,
'errors');
876 $action =
'createcontainer';
883 preg_match(
'/<head>(.*)<\/head>/ims', $tmp[
'content'], $regs);
886 $objectpage->type_container =
'page';
887 $objectpage->pageurl = $pageurl;
888 if (empty($objectpage->pageurl)) {
890 $objectpage->pageurl = $tmpdomain.
'-home';
893 $objectpage->aliasalt =
'';
895 if (preg_match(
'/^(\d+)\-/', basename($urltograb), $regs)) {
896 $objectpage->aliasalt = $regs[1];
900 if (preg_match(
'/<title>(.*)<\/title>/ims', $head, $regtmp)) {
901 $objectpage->title = $regtmp[1];
903 if (preg_match(
'/<meta name="title"[^"]+content="([^"]+)"/ims', $head, $regtmp)) {
904 if (empty($objectpage->title)) {
905 $objectpage->title = $regtmp[1];
908 if (preg_match(
'/<meta name="description"[^"]+content="([^"]+)"/ims', $head, $regtmp)) {
909 $objectpage->description = $regtmp[1];
911 if (preg_match(
'/<meta name="keywords"[^"]+content="([^"]+)"/ims', $head, $regtmp)) {
912 $objectpage->keywords = $regtmp[1];
914 if (preg_match(
'/<html\s+lang="([^"]+)"/ims', $tmp[
'content'], $regtmp)) {
915 $tmplang = explode(
'-', $regtmp[1]);
916 $objectpage->lang = $tmplang[0].($tmplang[1] ?
'_'.strtoupper($tmplang[1]) :
'');
919 $tmp[
'content'] = preg_replace(
'/\s*<meta name="generator"[^"]+content="([^"]+)"\s*\/?>/ims',
'', $tmp[
'content']);
921 $objectpage->content = $tmp[
'content'];
922 $objectpage->content = preg_replace(
'/^.*<body(\s[^>]*)*>/ims',
'', $objectpage->content);
923 $objectpage->content = preg_replace(
'/<\/body(\s[^>]*)*>.*$/ims',
'', $objectpage->content);
931 $objectpage->htmlheader = $tmp[
'content'];
932 $objectpage->htmlheader = preg_replace(
'/^.*<head(\s[^>]*)*>/ims',
'', $objectpage->htmlheader);
933 $objectpage->htmlheader = preg_replace(
'/<\/head(\s[^>]*)*>.*$/ims',
'', $objectpage->htmlheader);
934 $objectpage->htmlheader = preg_replace(
'/<base(\s[^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
935 $objectpage->htmlheader = preg_replace(
'/<meta http-equiv="content-type"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
936 $objectpage->htmlheader = preg_replace(
'/<meta name="robots"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
937 $objectpage->htmlheader = preg_replace(
'/<meta name="title"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
938 $objectpage->htmlheader = preg_replace(
'/<meta name="description"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
939 $objectpage->htmlheader = preg_replace(
'/<meta name="keywords"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
940 $objectpage->htmlheader = preg_replace(
'/<meta name="generator"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
943 $objectpage->htmlheader = preg_replace(
'/<title>[^<]*<\/title>\n*/ims',
'', $objectpage->htmlheader);
944 $objectpage->htmlheader = preg_replace(
'/<link[^>]*rel="shortcut[^>]*>\n/ims',
'', $objectpage->htmlheader);
945 $objectpage->htmlheader = preg_replace(
'/<link[^>]*rel="alternate[^>]*>\n/ims',
'', $objectpage->htmlheader);
946 $objectpage->htmlheader = preg_replace(
'/<link[^>]*rel="canonical[^>]*>\n/ims',
'', $objectpage->htmlheader);
949 $tmp = $objectpage->htmlheader;
952 preg_match_all(
'/<script([^\.>]+)src=["\']([^"\'>]+)["\']([^>]*)><\/script>/i', $objectpage->htmlheader, $regs);
953 $errorforsubresource = 0;
954 foreach ($regs[0] as $key => $val) {
955 dol_syslog(
"We will grab the script resource found into script tag ".$regs[2][$key]);
957 $linkwithoutdomain = $regs[2][$key];
958 if (preg_match(
'/^\//', $regs[2][$key])) {
959 $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key];
961 $urltograbbis = $urltograbdirwithoutslash.
'/'.$regs[2][$key];
965 if (preg_match(
'/^http/', $regs[2][$key])) {
966 $urltograbbis = $regs[2][$key];
967 $linkwithoutdomain = preg_replace(
'/^https?:\/\/[^\/]+\//i',
'', $regs[2][$key]);
977 if ($domaintograb != $domaintograbbis) {
1009 $tmp = preg_replace(
'/'.preg_quote($regs[0][$key],
'/').
'/i',
'', $tmp);
1011 $objectpage->htmlheader = trim($tmp).
"\n";
1015 $pagecsscontent =
"\n".
'<style>'.
"\n";
1017 preg_match_all(
'/<link([^\.>]+)href=["\']([^"\'>]+\.css[^"\'>]*)["\']([^>]*)>/i', $objectpage->htmlheader, $regs);
1018 $errorforsubresource = 0;
1019 foreach ($regs[0] as $key => $val) {
1020 dol_syslog(
"We will grab the css resources found into link tag ".$regs[2][$key]);
1022 $linkwithoutdomain = $regs[2][$key];
1023 if (preg_match(
'/^\//', $regs[2][$key])) {
1024 $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key];
1026 $urltograbbis = $urltograbdirwithoutslash.
'/'.$regs[2][$key];
1030 if (preg_match(
'/^http/', $regs[2][$key])) {
1031 $urltograbbis = $regs[2][$key];
1032 $linkwithoutdomain = preg_replace(
'/^https?:\/\/[^\/]+\//i',
'', $regs[2][$key]);
1042 if ($domaintograb != $domaintograbbis) {
1046 $tmpgeturl =
getURLContent($urltograbbis,
'GET',
'', 1, array(), array(
'http',
'https'), 0);
1047 if ($tmpgeturl[
'curl_error_no']) {
1048 $errorforsubresource++;
1049 setEventMessages(
'Error getting link tag url '.$urltograbbis.
': '.$tmpgeturl[
'curl_error_msg'],
null,
'errors');
1050 dol_syslog(
'Error getting '.$urltograbbis.
': '.$tmpgeturl[
'curl_error_msg']);
1051 $action =
'createcontainer';
1052 } elseif ($tmpgeturl[
'http_code'] !=
'200') {
1053 $errorforsubresource++;
1054 setEventMessages(
'Error getting link tag url '.$urltograbbis.
': '.$tmpgeturl[
'http_code'],
null,
'errors');
1055 dol_syslog(
'Error getting '.$urltograbbis.
': '.$tmpgeturl[
'curl_error_msg']);
1056 $action =
'createcontainer';
1065 $tmpgeturl[
'content'] = preg_replace(
'/\/\*\s+CSS content[a-z\s]*\s+\*\//',
'', $tmpgeturl[
'content']);
1075 $pagecsscontent .=
'/* Content of file '.$urltograbbis.
' */'.
"\n";
1077 getAllImages($object, $objectpage, $urltograbbis, $tmpgeturl[
'content'], $action, 1, $grabimages, $grabimagesinto);
1080 include_once DOL_DOCUMENT_ROOT.
'/core/class/lessc.class.php';
1081 $lesscobj =
new Lessc();
1083 $contentforlessc =
".bodywebsite {\n".$tmpgeturl[
'content'].
"\n}\n";
1085 $contentforlessc = $lesscobj->compile($contentforlessc);
1088 $pagecsscontent .= $contentforlessc.
"\n";
1090 }
catch (exception $e) {
1092 dol_syslog(
"Failed to compile the CSS from URL ".$urltograbbis.
" with lessc: ".$e->getMessage(), LOG_WARNING);
1093 $pagecsscontent .= $tmpgeturl[
'content'].
"\n";
1096 $objectpage->htmlheader = preg_replace(
'/'.preg_quote($regs[0][$key],
'/').
'\n*/ims',
'', $objectpage->htmlheader);
1100 $pagecsscontent .=
'</style>';
1104 $objectpage->htmlheader .= trim($pagecsscontent).
"\n";
1108 $tmp = $objectpage->content;
1110 getAllImages($object, $objectpage, $urltograb, $tmp, $action, 1, $grabimages, $grabimagesinto);
1113 $tmp = preg_replace(
'/a href="\/([^\/"]+)\/([^\/"]+)"/',
'a href="/\1-\2.php"', $tmp);
1114 $tmp = preg_replace(
'/a href="\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)"/',
'a href="/\1-\2-\3.php"', $tmp);
1115 $tmp = preg_replace(
'/a href="\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)"/',
'a href="/\1-\2-\3-\4.php"', $tmp);
1118 $objectpage->content = $tmp;
1120 $objectpage->grabbed_from = $urltograb;
1124 $newaliasnames =
'';
1125 if (!$error &&
GETPOST(
'WEBSITE_ALIASALT',
'alpha')) {
1126 $arrayofaliastotest = explode(
',', str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_ALIASALT',
'alpha')));
1128 foreach ($arrayofaliastotest as $aliastotest) {
1129 $aliastotest = trim(preg_replace(
'/\.php$/i',
'', $aliastotest));
1132 if (preg_match(
'/^page\d+/i', $aliastotest)) {
1134 $langs->load(
"errors");
1136 $action =
'createcontainer';
1139 $result = $websitepagetemp->fetch(0,
$object->id, $aliastotest);
1142 $langs->load(
"errors");
1143 setEventMessages($websitepagetemp->error, $websitepagetemp->errors,
'errors');
1144 $action =
'createcontainer';
1149 $langs->load(
"errors");
1150 setEventMessages($langs->trans(
"ErrorAPageWithThisNameOrAliasAlreadyExists", $websitepagetemp->pageurl),
null,
'errors');
1151 $action =
'createcontainer';
1154 $newaliasnames .= ($newaliasnames ?
', ' :
'').$aliastotest;
1159 $objectpage->title = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_TITLE',
'alphanohtml'));
1160 $objectpage->type_container =
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'aZ09');
1161 $objectpage->pageurl =
GETPOST(
'WEBSITE_PAGENAME',
'alpha');
1162 $objectpage->aliasalt = $newaliasnames;
1163 $objectpage->description = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml'));
1164 $objectpage->lang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
1165 $objectpage->otherlang =
GETPOST(
'WEBSITE_OTHERLANG',
'aZ09comma');
1166 $objectpage->image =
GETPOST(
'WEBSITE_IMAGE',
'alpha');
1167 $objectpage->keywords = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_KEYWORDS',
'alphanohtml'));
1168 $objectpage->allowed_in_frames =
GETPOST(
'WEBSITE_ALLOWED_IN_FRAMES',
'aZ09') ? 1 : 0;
1169 $objectpage->htmlheader =
GETPOST(
'htmlheader',
'none');
1170 $objectpage->author_alias =
GETPOST(
'WEBSITE_AUTHORALIAS',
'alphanohtml');
1171 $objectpage->object_type =
GETPOST(
'WEBSITE_OBJECTCLASS');
1172 $objectpage->fk_object =
GETPOST(
'WEBSITE_OBJECTID');
1173 $substitutionarray = array();
1174 $substitutionarray[
'__WEBSITE_CREATED_BY__'] = $user->getFullName($langs);
1187 $pageidfortranslation = (
GETPOSTINT(
'pageidfortranslation') > 0 ?
GETPOSTINT(
'pageidfortranslation') : 0);
1188 if ($pageidfortranslation > 0) {
1191 $objectpagetmp->fetch($pageidfortranslation);
1192 if ($objectpagetmp->fk_page > 0) {
1193 $pageidfortranslation = $objectpagetmp->fk_page;
1196 $objectpage->fk_page = $pageidfortranslation;
1200 if (GETPOSTISSET(
'content')) {
1202 $content =
GETPOST(
'content',
'none');
1219 if (empty($objectpage->pageurl)) {
1220 $langs->load(
"errors");
1221 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WEBSITE_PAGENAME")),
null,
'errors');
1223 $action =
'createcontainer';
1224 } elseif (!preg_match(
'/^[a-z0-9\-\_]+$/i', $objectpage->pageurl)) {
1225 $langs->load(
"errors");
1226 setEventMessages($langs->transnoentities(
"ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities(
'WEBSITE_PAGENAME')),
null,
'errors');
1228 $action =
'createcontainer';
1230 if (empty($objectpage->title)) {
1231 $langs->load(
"errors");
1232 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WEBSITE_TITLE")),
null,
'errors');
1234 $action =
'createcontainer';
1236 if ($objectpage->fk_page > 0 && empty($objectpage->lang)) {
1237 $langs->load(
"errors");
1238 setEventMessages($langs->trans(
"ErrorLanguageRequiredIfPageIsTranslationOfAnother"),
null,
'errors');
1240 $action =
'createcontainer';
1242 if ($objectpage->fk_page > 0 && !empty($objectpage->lang)) {
1243 if ($objectpage->lang == $website->lang) {
1244 $langs->load(
"errors");
1245 setEventMessages($langs->trans(
"ErrorLanguageMustNotBeSourceLanguageIfPageIsTranslationOfAnother"),
null,
'errors');
1247 $action =
'createcontainer';
1254 $pageid = $objectpage->create($user);
1258 $action =
'createcontainer';
1264 $categoriesarray =
GETPOST(
'categories',
'array');
1265 $result = $objectpage->setCategories($categoriesarray);
1274 if (empty(
$object->fk_default_home)) {
1275 $object->fk_default_home = $pageid;
1276 $res =
$object->update($user);
1281 $filetpl = $pathofwebsite.
'/page'.$pageid.
'.tpl.php';
1284 $result =
dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper, $object);
1295 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
1296 $filetpl = $pathofwebsite.
'/page'.$objectpage->id.
'.tpl.php';
1301 setEventMessages(
'Failed to write file '.basename($filealias),
null,
'errors');
1310 $action =
'createcontainer';
1317 setEventMessages($langs->trans(
"PageAdded", $objectpage->pageurl),
null,
'mesgs');
1324 $pageid = $objectpage->id;
1330 $pathtomedias = DOL_DATA_ROOT.
'/medias';
1331 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
1333 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
1334 dol_mkdir(dirname($pathtomediasinwebsite));
1335 $result = symlink($pathtomedias, $pathtomediasinwebsite);
1337 $langs->load(
"errors");
1338 setEventMessages($langs->trans(
"ErrorFailedToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias),
null,
'errors');
1352 $htmlheadercontent =
"<html>\n";
1353 $htmlheadercontent .= $htmlheadercontentdefault;
1354 $htmlheadercontent .=
"</html>";
1359 $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;}";
1364 $jscontent =
"/* JS content (all pages) */\n";
1369 $robotcontent =
"# Robot file. Generated with Dolibarr\nUser-agent: *\nAllow: /public/\nDisallow: /administrator/";
1374 $htaccesscontent =
"# Order allow,deny\n# Deny from all";
1379 $manifestjsoncontent =
"";
1384 $readmecontent =
"Website generated by Dolibarr ERP CRM";
1389 $licensecontent =
"MIT License";
1393 $action =
'preview';
1398if ($action ==
'confirm_deletesite' && $confirm ==
'yes' && $permissiontodelete) {
1407 $res =
$object->delete($user);
1414 if (
GETPOST(
'delete_also_js',
'alpha') ==
'on') {
1415 $pathofwebsitejs = DOL_DATA_ROOT.
'/medias/js/'.
$object->ref;
1419 if (
GETPOST(
'delete_also_medias',
'alpha') ==
'on') {
1420 $pathofwebsitemedias = DOL_DATA_ROOT.
'/medias/image/'.
$object->ref;
1430 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
1439if (GETPOSTISSET(
'pageid') && $action ==
'delete' && $permissiontodelete && !
GETPOST(
'file_manager')) {
1444 $res =
$object->fetch(0, $websitekey);
1447 $res = $objectpage->fetch($pageid,
$object->id);
1450 $res = $objectpage->delete($user);
1459 setEventMessages($langs->trans(
"PageDeleted", $objectpage->pageurl, $websitekey),
null,
'mesgs');
1461 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$websitekey);
1469if (!GETPOSTISSET(
'pageid')) {
1470 $objectclass =
'WebsitePage';
1474 if (!$error && ($massaction ==
'delete' || ($action ==
'delete' && $confirm ==
'yes')) && $permissiontodelete) {
1477 $objecttmp =
new $objectclass($db);
1479 foreach ($toselect as $toselectid) {
1480 $result = $objecttmp->fetch($toselectid);
1482 $result = $objecttmp->delete($user);
1511 if ($action ==
'delete') {
1512 $mode =
'replacesite';
1513 $action =
'replacesite';
1515 $containertype =
GETPOST(
'optioncontainertype',
'aZ09') !=
'-1' ?
GETPOST(
'optioncontainertype',
'aZ09') :
'';
1516 $langcode =
GETPOST(
'optionlanguage',
'aZ09');
1517 $otherfilters = array();
1519 $otherfilters[
'category'] =
GETPOSTINT(
'optioncategory');
1522 $listofpages =
getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters);
1527if ($action ==
'updatecss' && $usercanedit) {
1530 $action =
'editcss';
1532 $res =
$object->fetch(0, $websitekey);
1535 if (GETPOSTISSET(
'virtualhost')) {
1536 $tmpvirtualhost = preg_replace(
'/\/$/',
'',
GETPOST(
'virtualhost',
'alpha'));
1537 if ($tmpvirtualhost && !preg_match(
'/^http/', $tmpvirtualhost)) {
1539 setEventMessages($langs->trans(
'ErrorURLMustStartWithHttp', $langs->transnoentitiesnoconv(
"VirtualHost")),
null,
'errors');
1540 $action =
'editcss';
1544 $arrayotherlang = explode(
',',
GETPOST(
'WEBSITE_OTHERLANG',
'alphanohtml'));
1545 foreach ($arrayotherlang as $key => $val) {
1547 if (empty(trim($val))) {
1550 $arrayotherlang[$key] = substr(trim($val), 0, 2);
1553 $object->virtualhost = $tmpvirtualhost;
1555 $object->otherlang = implode(
',', $arrayotherlang);
1558 $result =
$object->update($user);
1562 $action =
'editcss';
1568 if (($_FILES[
'addedfile'][
"name"] !=
'')) {
1569 $uploadfolder =
$conf->website->dir_output.
'/'.$websitekey;
1570 if ($_FILES[
'addedfile'][
'type'] !=
'image/png') {
1574 $filetoread = realpath(
dol_osencode($_FILES[
'addedfile'][
'tmp_name']));
1575 $filesize = getimagesize($filetoread);
1576 if ($filesize[0] != $filesize[1]) {
1578 setEventMessages($langs->trans(
'ErrorFaviconMustBeASquaredImage'), array(),
'errors');
1580 if (! $error && ($filesize[0] != 16 && $filesize[0] != 32 && $filesize[0] != 64)) {
1589 if (!GETPOSTISSET(
'updateandstay')) {
1590 $action =
'preview';
1592 $backtopage = preg_replace(
'/searchstring=[^&]*/',
'', $backtopage);
1593 header(
"Location: ".$backtopage);
1597 $action =
'editcss';
1616 $dataposted = trim(
GETPOST(
'WEBSITE_HTML_HEADER',
'restricthtmlallowlinkscript'));
1618 $dataposted = preg_replace(array(
'/<html>\n*/ims',
'/<\/html>\n*/ims'), array(
'',
''), $dataposted);
1619 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1622 $phpfullcodestringold =
'';
1626 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1628 if (!$errorphpcheck) {
1629 $htmlheadercontent =
'';
1641 $htmlheadercontent .= $dataposted.
"\n";
1656 $dataposted = trim(
GETPOST(
'WEBSITE_CSS_INLINE',
'none'));
1657 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1660 $phpfullcodestringold =
'';
1664 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1666 if (!$errorphpcheck) {
1669 $csscontent .=
"<?php // BEGIN PHP\n";
1670 $csscontent .=
'$websitekey=basename(__DIR__);'.
"\n";
1671 $csscontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded\n";
1672 $csscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
1673 $csscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
1674 $csscontent .=
"ob_start();\n";
1675 $csscontent .=
"if (! headers_sent()) { /* because file is included inline when in edit mode and we don't want warning */ \n";
1676 $csscontent .=
"header('Cache-Control: max-age=3600, public, must-revalidate');\n";
1677 $csscontent .=
"header('Content-type: text/css');\n";
1678 $csscontent .=
"}\n";
1679 $csscontent .=
"// END PHP ?>\n";
1681 $csscontent .= $dataposted.
"\n";
1683 $csscontent .=
'<?php // BEGIN PHP'.
"\n";
1684 $csscontent .=
'$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "css");'.
"\n";
1685 $csscontent .=
"// END PHP\n";
1687 dol_syslog(
"Save css content into ".$filecss);
1699 $dataposted = trim(
GETPOST(
'WEBSITE_JS_INLINE',
'none'));
1700 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1703 $phpfullcodestringold =
'';
1707 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1709 if (!$errorphpcheck) {
1712 $jscontent .=
"<?php // BEGIN PHP\n";
1713 $jscontent .=
'$websitekey=basename(__DIR__);'.
"\n";
1714 $jscontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded\n";
1715 $jscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
1716 $jscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
1717 $jscontent .=
"ob_start();\n";
1718 $jscontent .=
"header('Cache-Control: max-age=3600, public, must-revalidate');\n";
1719 $jscontent .=
"header('Content-type: application/javascript');\n";
1720 $jscontent .=
"// END PHP ?>\n";
1722 $jscontent .= $dataposted.
"\n";
1724 $jscontent .=
'<?php // BEGIN PHP'.
"\n";
1725 $jscontent .=
'$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "js");'.
"\n";
1726 $jscontent .=
"// END PHP\n";
1737 $dataposted = trim(
GETPOST(
'WEBSITE_ROBOT',
'nohtml'));
1738 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1741 $phpfullcodestringold =
'';
1745 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1747 if (!$errorphpcheck) {
1760 $robotcontent .= $dataposted.
"\n";
1775 $dataposted = trim(
GETPOST(
'WEBSITE_HTACCESS',
'nohtml'));
1776 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1779 $phpfullcodestringold =
'';
1783 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1785 if (!$errorphpcheck) {
1787 $htaccesscontent =
'';
1788 $htaccesscontent .= $dataposted.
"\n";
1803 $dataposted = trim(
GETPOST(
'WEBSITE_MANIFEST_JSON',
'restricthtmlallowunvalid'));
1804 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1807 $phpfullcodestringold =
'';
1811 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1813 if (!$errorphpcheck) {
1814 $manifestjsoncontent =
'';
1816 $manifestjsoncontent .=
"<?php // BEGIN PHP\n";
1817 $manifestjsoncontent .=
'$websitekey=basename(__DIR__);'.
"\n";
1818 $manifestjsoncontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded\n";
1819 $manifestjsoncontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
1820 $manifestjsoncontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
1821 $manifestjsoncontent .=
"ob_start();\n";
1822 $manifestjsoncontent .=
"header('Cache-Control: max-age=3600, public, must-revalidate');\n";
1823 $manifestjsoncontent .=
"header('Content-type: application/manifest+json');\n";
1824 $manifestjsoncontent .=
"// END PHP ?>\n";
1826 $manifestjsoncontent .= $dataposted.
"\n";
1828 $manifestjsoncontent .=
'<?php // BEGIN PHP'.
"\n";
1829 $manifestjsoncontent .=
'$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "manifest");'.
"\n";
1830 $manifestjsoncontent .=
"// END PHP\n";
1835 setEventMessages(
'Failed to write file '.$filemanifestjson,
null,
'errors');
1842 $dataposted = trim(
GETPOST(
'WEBSITE_README',
'nohtml'));
1843 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1846 $phpfullcodestringold =
'';
1850 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1852 if (!$errorphpcheck) {
1853 $readmecontent =
'';
1865 $readmecontent .= $dataposted.
"\n";
1881 $dataposted = trim(
GETPOST(
'WEBSITE_LICENSE',
'nohtml'));
1882 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1885 $phpfullcodestringold =
'';
1889 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1891 if (!$errorphpcheck) {
1892 $licensecontent =
'';
1904 $licensecontent .= $dataposted.
"\n";
1928 if (!GETPOSTISSET(
'updateandstay')) {
1929 $action =
'preview';
1931 $backtopage = preg_replace(
'/searchstring=[^&]*/',
'', $backtopage);
1932 header(
"Location: ".$backtopage);
1936 $action =
'editcss';
1943if ($action ==
'setashome' && $usercanedit) {
1945 $object->fetch(0, $websitekey);
1948 $object->fk_default_home = $pageid;
1949 $res =
$object->update($user);
1958 $filetpl = $pathofwebsite.
'/page'.$pageid.
'.tpl.php';
1961 $result =
dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper, $object);
1969 $action =
'preview';
1976if ($action ==
'updatemeta' && $usercanedit) {
1979 $result =
$object->fetch(0, $websitekey);
1982 $objectpage->fk_website =
$object->id;
1985 if (!preg_match(
'/^[a-z0-9\-\_]+$/i',
GETPOST(
'WEBSITE_PAGENAME',
'alpha'))) {
1987 $langs->load(
"errors");
1988 setEventMessages($langs->transnoentities(
"ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities(
'WEBSITE_PAGENAME')),
null,
'errors');
1989 $action =
'editmeta';
1992 $res = $objectpage->fetch($pageid,
$object->id);
1995 setEventMessages(
'Page not found '.$objectpage->error, $objectpage->errors,
'errors');
1999 if (!$error &&
GETPOST(
'WEBSITE_PAGENAME',
'alpha')) {
2001 $result = $websitepagetemp->fetch(-1 * $objectpage->id,
$object->id,
GETPOST(
'WEBSITE_PAGENAME',
'alpha'));
2004 $langs->load(
"errors");
2005 setEventMessages($websitepagetemp->error, $websitepagetemp->errors,
'errors');
2006 $action =
'editmeta';
2010 $langs->load(
"errors");
2011 setEventMessages($langs->trans(
"ErrorAPageWithThisNameOrAliasAlreadyExists", $websitepagetemp->pageurl),
null,
'errors');
2012 $action =
'editmeta';
2016 $newaliasnames =
'';
2017 if (!$error &&
GETPOST(
'WEBSITE_ALIASALT',
'alpha')) {
2018 $arrayofaliastotest = explode(
',', str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_ALIASALT',
'alpha')));
2021 foreach ($arrayofaliastotest as $aliastotest) {
2022 $aliastotest = trim(preg_replace(
'/\.php$/i',
'', $aliastotest));
2025 if (preg_match(
'/^page\d+/i', $aliastotest)) {
2027 $langs->load(
"errors");
2029 $action =
'editmeta';
2032 $result = $websitepagetemp->fetch(-1 * $objectpage->id,
$object->id, $aliastotest);
2035 $langs->load(
"errors");
2036 setEventMessages($websitepagetemp->error, $websitepagetemp->errors,
'errors');
2037 $action =
'editmeta';
2042 $langs->load(
"errors");
2043 setEventMessages($langs->trans(
"ErrorAPageWithThisNameOrAliasAlreadyExists", $websitepagetemp->pageurl),
null,
'errors');
2044 $action =
'editmeta';
2047 $newaliasnames .= ($newaliasnames ?
', ' :
'').$aliastotest;
2053 $objectpage->old_object = clone $objectpage;
2055 $objectpage->title = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_TITLE',
'alphanohtml'));
2056 $objectpage->type_container =
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'aZ09');
2057 $objectpage->pageurl =
GETPOST(
'WEBSITE_PAGENAME',
'alpha');
2058 $objectpage->aliasalt = $newaliasnames;
2059 $objectpage->lang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
2060 $objectpage->otherlang =
GETPOST(
'WEBSITE_OTHERLANG',
'aZ09comma');
2061 $objectpage->description = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml'));
2062 $objectpage->image =
GETPOST(
'WEBSITE_IMAGE',
'alpha');
2063 $objectpage->keywords = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_KEYWORDS',
'alphanohtml'));
2064 $objectpage->allowed_in_frames =
GETPOST(
'WEBSITE_ALLOWED_IN_FRAMES',
'aZ09') ? 1 : 0;
2065 $objectpage->htmlheader = trim(
GETPOST(
'htmlheader',
'restricthtmlallowlinkscript'));
2066 $objectpage->fk_page = (
GETPOSTINT(
'pageidfortranslation') > 0 ?
GETPOSTINT(
'pageidfortranslation') : 0);
2067 $objectpage->author_alias = trim(
GETPOST(
'WEBSITE_AUTHORALIAS',
'alphanohtml'));
2068 $objectpage->object_type =
GETPOST(
'WEBSITE_OBJECTCLASS',
'alpha');
2069 $objectpage->fk_object =
GETPOST(
'WEBSITE_OBJECTID',
'aZ09');
2072 if ($newdatecreation) {
2073 $objectpage->date_creation = $newdatecreation;
2076 $res = $objectpage->update($user);
2078 $langs->load(
"errors");
2079 if ($db->lasterrno ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
2081 $langs->load(
"errors");
2082 setEventMessages($langs->trans(
"ErrorAPageWithThisNameOrAliasAlreadyExists"),
null,
'errors');
2083 $action =
'editmeta';
2086 $langs->load(
"errors");
2088 $action =
'editmeta';
2095 $categoriesarray =
GETPOST(
'categories',
'array');
2096 $result = $objectpage->setCategories($categoriesarray);
2110 $filemaster = $pathofwebsite.
'/master.inc.php';
2111 $fileoldalias = $pathofwebsite.
'/'.$objectpage->old_object->pageurl.
'.php';
2112 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
2123 if (!empty($fileoldalias)) {
2124 dol_syslog(
"We delete old alias page name=".$fileoldalias.
" to build a new alias page=".$filealias);
2128 if (empty($objectpage->lang) || !in_array($objectpage->lang, explode(
',',
$object->otherlang))) {
2129 $dirname = dirname($fileoldalias);
2130 $filename = basename($fileoldalias);
2131 $sublangs = explode(
',',
$object->otherlang);
2132 foreach ($sublangs as $sublang) {
2136 if (empty(trim($sublang))) {
2139 $fileoldaliassub = $dirname.
'/'.$sublang.
'/'.$filename;
2145 if (!empty($objectpage->old_object->aliasalt)) {
2146 $tmpaltaliases = explode(
',', $objectpage->old_object->aliasalt);
2147 if (is_array($tmpaltaliases)) {
2148 foreach ($tmpaltaliases as $tmpaliasalt) {
2149 dol_syslog(
"We delete old alt alias pages name=".trim($tmpaliasalt));
2153 if (empty($objectpage->lang) || !in_array($objectpage->lang, explode(
',',
$object->otherlang))) {
2154 $dirname = dirname($pathofwebsite.
'/'.trim($tmpaliasalt).
'.php');
2155 $filename = basename($pathofwebsite.
'/'.trim($tmpaliasalt).
'.php');
2156 $sublangs = explode(
',',
$object->otherlang);
2157 foreach ($sublangs as $sublang) {
2161 if (empty(trim($sublang))) {
2164 $fileoldaliassub = $dirname.
'/'.$sublang.
'/'.$filename;
2178 if (!empty($objectpage->aliasalt)) {
2179 $tmpaltaliases = explode(
',', $objectpage->aliasalt);
2180 if (is_array($tmpaltaliases)) {
2181 foreach ($tmpaltaliases as $tmpaliasalt) {
2182 if (trim($tmpaliasalt)) {
2183 $filealias = $pathofwebsite.
'/'.trim($tmpaliasalt).
'.php';
2186 setEventMessages(
'Failed to write file '.basename($filealias),
null,
'errors');
2199 if (!GETPOSTISSET(
'updateandstay')) {
2202 $action =
'preview';
2204 $action =
'editmeta';
2210 $action =
'preview';
2216if ((($action ==
'updatesource' || $action ==
'updatecontent' || $action ==
'confirm_createfromclone' || $action ==
'confirm_createpagefromclone') || ($action ==
'preview' && (
GETPOST(
'refreshsite') ||
GETPOST(
'refreshpage') ||
GETPOST(
'preview')))) && $usercanedit) {
2217 $object->fetch(0, $websitekey);
2220 if ($action ==
'confirm_createfromclone') {
2223 $objectnew =
new Website($db);
2229 $action =
'preview';
2236 $pageid =
$object->fk_default_home;
2237 $websitekey =
GETPOST(
'siteref',
'aZ09');
2243 if ($action ==
'confirm_createpagefromclone') {
2244 $istranslation = (
GETPOST(
'is_a_translation',
'aZ09') ==
'on' ? 1 : 0);
2246 if ($istranslation) {
2247 if (
GETPOST(
'newlang',
'aZ09') == $objectpage->lang || !
GETPOST(
'newlang',
'aZ09')) {
2249 setEventMessages($langs->trans(
"LanguageMustNotBeSameThanClonedPage"),
null,
'errors');
2250 $action =
'preview';
2254 setEventMessages($langs->trans(
"WebsiteMustBeSameThanClonedPageIfTranslation"),
null,
'errors');
2255 $action =
'preview';
2263 $pathofwebsitenew = $pathofwebsite;
2265 $tmpwebsite =
new Website($db);
2266 if ($newwebsiteid > 0 && $newwebsiteid !=
$object->id) {
2267 $tmpwebsite->fetch($newwebsiteid);
2268 $pathofwebsitenew = $dolibarr_main_data_root.($conf->entity > 1 ?
'/'.$conf->entity :
'').
'/website/'.$tmpwebsite->ref;
2274 $resultpage = $objectpage->createFromClone($user, $pageid,
GETPOST(
'newpageurl',
'aZ09'), (
GETPOST(
'newlang',
'aZ09') ?
GETPOST(
'newlang',
'aZ09') :
''), $istranslation, $newwebsiteid,
GETPOST(
'newtitle',
'alphanohtml'), $tmpwebsite);
2275 if ($resultpage < 0) {
2278 $action =
'createpagefromclone';
2282 $filetpl = $pathofwebsitenew.
'/page'.$resultpage->id.
'.tpl.php';
2283 $fileindex = $pathofwebsitenew.
'/index.php';
2284 $filewrapper = $pathofwebsitenew.
'/wrapper.php';
2293 if (empty($newwebsiteid) || $newwebsiteid ==
$object->id) {
2294 $pageid = $resultpage->id;
2307 $pathtomedias = DOL_DATA_ROOT.
'/medias';
2308 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
2310 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
2311 dol_mkdir(dirname($pathtomediasinwebsite));
2312 $result = symlink($pathtomedias, $pathtomediasinwebsite);
2314 $langs->load(
"errors");
2315 setEventMessages($langs->trans(
"ErrorFailedToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias),
null,
'errors');
2325 $objectpage->fk_website =
$object->id;
2328 $res = $objectpage->fetch($pageid);
2331 if (
$object->fk_default_home > 0) {
2332 $res = $objectpage->fetch(
$object->fk_default_home);
2335 $res = $objectpage->fetch(0,
$object->id);
2340 if (!$error && $res > 0) {
2341 if ($action ==
'updatesource' || $action ==
'updatecontent') {
2346 $objectpage->content =
GETPOST(
'PAGE_CONTENT',
'none');
2351 $error =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
2354 if ($action ==
'updatesource') {
2355 $action =
'editsource';
2357 if ($action ==
'updatecontent') {
2358 $action =
'editcontent';
2363 $objectpage->content = preg_replace(
'/<head>.*<\/head>/ims',
'', $objectpage->content);
2367 $res = $objectpage->update($user);
2371 if ($action ==
'updatesource') {
2372 $action =
'editsource';
2374 if ($action ==
'updatecontent') {
2375 $action =
'editcontent';
2382 $filemaster = $pathofwebsite.
'/master.inc.php';
2384 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
2392 setEventMessages(
'Failed to write the master file file '.$filemaster,
null,
'errors');
2416 setEventMessages(
'Failed to write the alias file '.basename($filealias),
null,
'errors');
2424 if (!GETPOSTISSET(
'updateandstay')) {
2426 header(
"Location: ".$backtopage);
2429 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$websitekey.
'&pageid='.$pageid);
2433 if ($action ==
'updatesource') {
2434 $action =
'editsource';
2436 if ($action ==
'updatecontent') {
2437 $action =
'editcontent';
2442 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$websitekey.
'&pageid='.$pageid);
2449 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$websitekey.
'&pageid='.$pageid);
2454 if (empty($websitekey) || $websitekey ==
'-1') {
2455 setEventMessages($langs->trans(
"NoWebSiteCreateOneFirst"),
null,
'warnings');
2458 setEventMessages($langs->trans(
"YouCanCreatePageOrImportTemplate"),
null,
'warnings');
2464if ($action ==
'deletelang' && $usercanedit) {
2465 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"website_page SET fk_page = NULL";
2466 $sql .=
" WHERE rowid = ".GETPOSTINT(
'deletelangforid');
2469 $resql = $db->query($sql);
2473 $objectpage->fk_page =
null;
2476 $action =
'editmeta';
2481if ($action ==
'exportsite' && $user->hasRight(
'website',
'export')) {
2482 $fileofzip =
$object->exportWebSite();
2485 $file_name = basename($fileofzip);
2486 header(
"Content-Type: application/zip");
2487 header(
"Content-Disposition: attachment; filename=".$file_name);
2488 header(
"Content-Length: ".filesize($fileofzip));
2490 readfile($fileofzip);
2494 $action =
'preview';
2499if ($action ==
'overwritesite' && $user->hasRight(
'website',
'export')) {
2501 $fileofzip =
$object->exportWebSite();
2502 $pathToExport =
GETPOST(
'export_path');
2504 $object->overwriteTemplate($fileofzip, $pathToExport);
2511if ($action ==
'regeneratesite' && $usercanedit) {
2514 $pathtomedias = DOL_DATA_ROOT.
'/medias';
2515 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
2517 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
2518 dol_mkdir(dirname($pathtomediasinwebsite));
2519 $result = symlink($pathtomedias, $pathtomediasinwebsite);
2521 $langs->load(
"errors");
2522 setEventMessages($langs->trans(
"ErrorFailedToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias),
null,
'errors');
2523 $action =
'preview';
2527 $result =
$object->rebuildWebSiteFiles();
2529 setEventMessages($langs->trans(
"PagesRegenerated", $result),
null,
'mesgs');
2530 $action =
'preview';
2533 $action =
'preview';
2538if ($action ==
'importsiteconfirm' && $usercanedit) {
2539 $dolibarrdataroot = preg_replace(
'/([\\/]+)$/i',
'', DOL_DATA_ROOT);
2540 $allowimportsite =
true;
2541 if (
dol_is_file($dolibarrdataroot.
'/installmodules.lock')) {
2542 $allowimportsite =
false;
2545 if ($allowimportsite) {
2546 if (empty($_FILES) && !GETPOSTISSET(
'templateuserfile')) {
2547 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"File")),
null,
'errors');
2548 $action =
'importsite';
2550 if (!empty($_FILES) || GETPOSTISSET(
'templateuserfile')) {
2553 $pathtomedias = DOL_DATA_ROOT.
'/medias';
2554 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
2556 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
2557 dol_mkdir(dirname($pathtomediasinwebsite));
2558 $result = symlink($pathtomedias, $pathtomediasinwebsite);
2560 $langs->load(
"errors");
2561 setEventMessages($langs->trans(
"ErrorFailedToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias),
null,
'errors');
2562 $action =
'importsite';
2567 if (GETPOSTISSET(
'templateuserfile')) {
2569 $fileofzip = DOL_DATA_ROOT.
'/doctemplates/websites/'.
GETPOST(
'templateuserfile',
'alpha');
2570 } elseif (!empty($_FILES) && is_array($_FILES[
'userfile'])) {
2572 if (is_array($_FILES[
'userfile'][
'tmp_name'])) {
2573 $userfiles = $_FILES[
'userfile'][
'tmp_name'];
2575 $userfiles = array($_FILES[
'userfile'][
'tmp_name']);
2579 foreach ($userfiles as $key => $userfile) {
2580 if (empty($_FILES[
'userfile'][
'tmp_name'][$key])) {
2582 if ($_FILES[
'userfile'][
'error'][$key] == 1 || $_FILES[
'userfile'][
'error'][$key] == 2) {
2584 $action =
'importsite';
2586 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"File")),
null,
'errors');
2587 $action =
'importsite';
2594 $upload_dir = DOL_DATA_ROOT.
'/doctemplates/websites/';
2608 $action =
'importsite';
2611 if (!$error && GETPOSTISSET(
'templateuserfile')) {
2612 $templatewithoutzip = preg_replace(
'/\.zip$/i',
'',
GETPOST(
'templateuserfile'));
2613 $object->setTemplateName($templatewithoutzip);
2615 $result =
$object->importWebSite($fileofzip);
2619 $action =
'importsite';
2624 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.
$object->ref);
2633 $message = $langs->trans(
'InstallModuleFromWebHasBeenDisabledContactUs');
2636 $message = $langs->trans(
"InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.
'/installmodules.lock');
2642$domainname =
'0.0.0.0:8080';
2643$tempdir =
$conf->website->dir_output.
'/'.$websitekey.
'/';
2646if ($action ==
'generatesitemaps' && $usercanedit) {
2648 if ($website->virtualhost) {
2649 $domainname = $website->virtualhost;
2651 if (! preg_match(
'/^http/i', $domainname)) {
2652 $domainname =
'https://'.$domainname;
2655 $domtree =
new DOMDocument(
'1.0',
'UTF-8');
2657 $root = $domtree->createElementNS(
'http://www.sitemaps.org/schemas/sitemap/0.9',
'urlset');
2658 $root->setAttributeNS(
'http://www.w3.org/2000/xmlns/',
'xmlns:xhtml',
'http://www.w3.org/1999/xhtml');
2660 $domtree->formatOutput =
true;
2663 $xmlname =
'sitemap.xml';
2665 $sql =
"SELECT wp.rowid, wp.type_container , wp.pageurl, wp.lang, wp.fk_page, wp.tms as tms,";
2666 $sql .=
" w.virtualhost, w.fk_default_home";
2667 $sql .=
" FROM ".MAIN_DB_PREFIX.
"website_page as wp, ".MAIN_DB_PREFIX.
"website as w";
2668 $sql .=
" WHERE wp.type_container IN ('page', 'blogpost')";
2669 $sql .=
" AND wp.fk_website = w.rowid";
2670 $sql .=
" AND wp.status = ".WebsitePage::STATUS_VALIDATED;
2671 $sql .=
" AND wp.pageurl NOT IN ('404', '500', '501', '503')";
2672 $sql .=
" AND w.ref = '".dol_escape_json($websitekey).
"'";
2673 $sql .=
" ORDER BY wp.tms DESC, wp.rowid DESC";
2674 $resql = $db->query($sql);
2676 $num_rows = $db->num_rows($resql);
2677 if ($num_rows > 0) {
2679 while ($i < $num_rows) {
2680 $objp = $db->fetch_object($resql);
2681 $url = $domtree->createElement(
'url');
2683 $shortlangcode =
'';
2685 $shortlangcode = substr($objp->lang, 0, 2);
2687 if (empty($shortlangcode)) {
2688 $shortlangcode = substr(
$object->lang, 0, 2);
2692 if ($objp->type_container ==
'blogpost') {
2697 $pageurl = $objp->pageurl.
'.php';
2698 if ($objp->fk_default_home == $objp->rowid) {
2701 if ($shortlangcode != substr(
$object->lang, 0, 2)) {
2702 $pageurl = $shortlangcode.
'/'.$pageurl;
2709 $loc = $domtree->createElement(
'loc', $domainname.
'/'.$pageurl);
2710 $lastmod = $domtree->createElement(
'lastmod',
dol_print_date($db->jdate($objp->tms),
'dayrfc',
'gmt'));
2711 $priority = $domtree->createElement(
'priority',
'1');
2713 $url->appendChild($loc);
2714 $url->appendChild($lastmod);
2717 $changefreq = $domtree->createElement(
'changefreq',
'weekly');
2718 $url->appendChild($changefreq);
2721 if ($objp->fk_default_home == $objp->rowid) {
2722 $url->appendChild($priority);
2727 $alternatefound = 0;
2730 $translationof = $objp->fk_page;
2731 if ($translationof) {
2733 $tmppage->fetch($translationof);
2734 if ($tmppage->id > 0) {
2735 $tmpshortlangcode =
'';
2736 if ($tmppage->lang) {
2737 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'', $tmppage->lang);
2739 if (empty($tmpshortlangcode)) {
2740 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'',
$object->lang);
2742 if ($tmpshortlangcode != $shortlangcode) {
2743 $xhtmllink = $domtree->createElement(
'xhtml:link',
'');
2744 $xhtmllink->setAttribute(
"rel",
"alternate");
2745 $xhtmllink->setAttribute(
"hreflang", $tmpshortlangcode);
2746 $xhtmllink->setAttribute(
"href", $domainname.($objp->fk_default_home == $tmppage->id ?
'/' : (($tmpshortlangcode != substr(
$object->lang, 0, 2)) ?
'/'.$tmpshortlangcode :
'').
'/'.$tmppage->pageurl.
'.php'));
2747 $url->appendChild($xhtmllink);
2755 $sql =
'SELECT rowid as id, lang, pageurl from '.MAIN_DB_PREFIX.
'website_page';
2756 $sql .=
" WHERE status = ".((int) WebsitePage::STATUS_VALIDATED).
' AND fk_page IN ('.$db->sanitize($objp->rowid.($translationof ?
", ".$translationof :
"")).
")";
2757 $resqlhastrans = $db->query($sql);
2758 if ($resqlhastrans) {
2759 $num_rows_hastrans = $db->num_rows($resqlhastrans);
2760 if ($num_rows_hastrans > 0) {
2761 while ($objhastrans = $db->fetch_object($resqlhastrans)) {
2762 $tmpshortlangcode =
'';
2763 if ($objhastrans->lang) {
2764 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'', $objhastrans->lang);
2766 if ($tmpshortlangcode != $shortlangcode) {
2767 $xhtmllink = $domtree->createElement(
'xhtml:link',
'');
2768 $xhtmllink->setAttribute(
"rel",
"alternate");
2769 $xhtmllink->setAttribute(
"hreflang", $tmpshortlangcode);
2770 $xhtmllink->setAttribute(
"href", $domainname.($objp->fk_default_home == $objhastrans->id ?
'/' : (($tmpshortlangcode != substr(
$object->lang, 0, 2) ?
'/'.$tmpshortlangcode :
'')).
'/'.$objhastrans->pageurl.
'.php'));
2771 $url->appendChild($xhtmllink);
2781 if ($alternatefound) {
2783 $xhtmllink = $domtree->createElement(
'xhtml:link',
'');
2784 $xhtmllink->setAttribute(
"rel",
"alternate");
2785 $xhtmllink->setAttribute(
"hreflang", $shortlangcode);
2786 $xhtmllink->setAttribute(
"href", $domainname.
'/'.$pageurl);
2787 $url->appendChild($xhtmllink);
2803 $root->appendChild($url);
2809 if ($addrsswrapper &&
getDolGlobalInt(
'WEBSITE_ADD_RSS_FEED_INTO_SITEMAP')) {
2810 $url = $domtree->createElement(
'url');
2812 $pageurl =
'wrapper.php?rss=1';
2815 $loc = $domtree->createElement(
'loc', $domainname.
'/'.$pageurl);
2816 $lastmod = $domtree->createElement(
'lastmod',
dol_print_date($db->jdate(
dol_now()),
'dayrfc',
'gmt'));
2818 $url->appendChild($loc);
2819 $url->appendChild($lastmod);
2822 $changefreq = $domtree->createElement(
'changefreq',
'weekly');
2823 $url->appendChild($changefreq);
2826 $root->appendChild($url);
2829 $domtree->appendChild($root);
2831 if ($domtree->save($tempdir.$xmlname)) {
2833 setEventMessages($langs->trans(
"SitemapGenerated", $xmlname),
null,
'mesgs');
2843 $robotcontent = @file_get_contents($filerobot);
2844 $result = preg_replace(
'/<?php \/\/ BEGIN PHP[^?]END PHP ?>\n/ims',
'', $robotcontent);
2846 $robotcontent = $result;
2848 $robotsitemap =
"Sitemap: ".$domainname.
"/".$xmlname;
2849 $result = strpos($robotcontent,
'Sitemap: ');
2851 $result = preg_replace(
'/Sitemap:.*/', $robotsitemap, $robotcontent);
2852 $robotcontent = $result ? $result : $robotcontent;
2854 $robotcontent .= $robotsitemap.
"\n";
2861 $action =
'preview';
2869$form =
new Form($db);
2876if ($action ==
'confirmgeneratesitemaps') {
2877 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?website='.urlencode($website->ref), $langs->trans(
'ConfirmSitemapsCreation'), $langs->trans(
'ConfirmGenerateSitemaps',
$object->ref),
'generatesitemaps',
'',
"yes", 1);
2878 $action =
'preview';
2880$helpurl =
'EN:Module_Website|FR:Module_Website_FR|ES:Módulo_Website';
2883 '/includes/ace/src/ace.js',
2884 '/includes/ace/src/ext-statusbar.js',
2885 '/includes/ace/src/ext-language_tools.js',
2889$arrayofcss = array();
2894$arrayofjs[] =
'includes/jquery/plugins/blockUI/jquery.blockUI.js';
2895$arrayofjs[] =
'core/js/blockUI.js';
2897 $arrayofjs[] =
"includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js";
2900$moreheadjs .=
'<script type="text/javascript">'.
"\n";
2901$moreheadjs .=
'var indicatorBlockUI = \''.DOL_URL_ROOT.
"/theme/".
$conf->theme.
"/img/working.gif".
'\';
'."\n";
2902$moreheadjs .= '</script>
'."\n";
2904llxHeader($moreheadcss.$moreheadjs, $langs->trans("Website").(empty($website->ref) ? '' : ' -
'.$website->ref), $helpurl, '', 0, 0, $arrayofjs, $arrayofcss, '', 'mod-website page-index
', '<!-- Begin div
class=
"fiche" -->
'."\n".'<div
class=
"fichebutwithotherclass">
');
2907print '<!-- Open form
for all page -->
'."\n";
2908print '<form action=
"'.$_SERVER["PHP_SELF
"].($action == 'file_manager' ? '?uploadform=1' : '').'" method=
"POST" enctype=
"multipart/form-data" class=
"websiteformtoolbar">
';
2909print '<input
type=
"hidden" name=
"token" value=
"'.newToken().'">
';
2910print '<input
type=
"hidden" name=
"backtopage" value=
"'.$backtopage.'">
';
2911print '<input
type=
"hidden" name=
"dol_openinpopup" value=
"'.$dol_openinpopup.'">
';
2913if ($action == 'createsite
') {
2914 print '<input
type=
"hidden" name=
"action" value=
"addsite">
';
2916if ($action == 'createcontainer
') {
2917 print '<input
type=
"hidden" name=
"action" value=
"addcontainer">
';
2919if ($action == 'editcss
') {
2920 print '<input
type=
"hidden" name=
"action" value=
"updatecss">
';
2922if ($action == 'editmenu
') {
2923 print '<input
type=
"hidden" name=
"action" value=
"updatemenu">
';
2925if ($action == 'setashome
') {
2926 print '<input
type=
"hidden" name=
"action" value=
"updateashome">
';
2928if ($action == 'editmeta
') {
2929 print '<input
type=
"hidden" name=
"action" value=
"updatemeta">
';
2931if ($action == 'editsource
') {
2932 print '<input
type=
"hidden" name=
"action" value=
"updatesource">
';
2934if ($action == 'editcontent
') {
2935 print '<input
type=
"hidden" name=
"action" value=
"updatecontent">
';
2937if ($action == 'edit
') {
2938 print '<input
type=
"hidden" name=
"action" value=
"update">
';
2940if ($action == 'importsite
') {
2941 print '<input
type=
"hidden" name=
"action" value=
"importsiteconfirm">
';
2943if ($action == 'file_manager
') {
2944 print '<input
type=
"hidden" name=
"action" value=
"file_manager">
';
2947 print '<input
type=
"hidden" name=
"mode" value=
"'.$mode.'">
';
2952// Add a margin under toolbar ?
2954if ($action != 'preview
' && $action != 'editcontent
' && $action != 'editsource
' && !GETPOST('createpagefromclone
', 'alphanohtml
')) {
2955 $style = ' margin-bottom: 5px;
';
2959if (!GETPOST('hide_websitemenu
')) {
2961 if (!$user->hasRight('website
', 'write
')) {
2962 $disabled = ' disabled=
"disabled"';
2964 $disabledexport = '';
2965 if (!$user->hasRight('website
', 'export
')) {
2966 $disabledexport = ' disabled=
"disabled"';
2971 $dataroot = DOL_DATA_ROOT.($conf->entity > 1 ? '/
'.$conf->entity : '').'/website/
'.$websitekey;
2972 if (!empty($object->virtualhost)) {
2973 $virtualurl = $object->virtualhost;
2978 if ($object->id > 0) {
2979 $array = $objectpage->fetchAll($object->id, 'ASC,ASC
', 'type_container,pageurl
');
2980 $object->lines = $array;
2982 if (!is_array($array) && $array < 0) {
2983 dol_print_error(null, $objectpage->error, $objectpage->errors);
2985 $atleastonepage = (is_array($array) && count($array) > 0);
2987 $websitepage = new WebsitePage($db);
2989 $websitepage->fetch($pageid);
2993 //var_dump($objectpage);exit;
2994 print '<div
class=
"centpercent websitebar'.(GETPOST('dol_openinpopup', 'aZ09') ? ' hiddenforpopup' : '').'">
';
2997 // Toolbar for websites
3000 print '<!-- Toolbar
for website -->
';
3001 if ($action != 'file_manager
') {
3002 print '<div
class=
"websiteselection hideonsmartphoneimp minwidth75 tdoverflowmax100 inline-block">
';
3003 print $langs->trans("Website").':
';
3006 // Button Add new website
3007 $urltocreatenewwebsite = $_SERVER["PHP_SELF"].'?action=createsite
';
3008 print '<span
class=
"websiteselection paddingrightonly">
';
3009 print '<a href=
"'.$urltocreatenewwebsite.'" class=
""'.$disabled.' title=
"'.dol_escape_htmltag($langs->trans("AddWebsite
")).'"><span
class=
"fa fa-plus-circle valignmiddle btnTitle-icon"><span></a>
';
3013 print '<span
class=
"websiteselection nopaddingrightimp">
';
3016 $out .= '<select
name=
"website" class=
"minwidth100 width200 maxwidth150onsmartphone" id=
"website">
';
3017 if (empty($listofwebsites)) {
3018 $out .= '<option value=
"-1"> </option>
';
3021 // Loop on each sites
3023 foreach ($listofwebsites as $key => $valwebsite) {
3024 if (empty($websitekey)) {
3025 if ($action != 'createsite
') {
3026 $websitekey = $valwebsite->ref;
3030 $out .= '<option value=
"'.$valwebsite->ref.'"';
3031 if ($websitekey == $valwebsite->ref) {
3032 $out .= ' selected
'; // To preselect a value
3034 //$outoption = $valwebsite->getLibStatut(3).' '.$valwebsite->ref.' ';
3035 $outoption = (($valwebsite->status == $valwebsite::STATUS_DRAFT) ? '<span
class=
"opacitymedium">
' : '').$valwebsite->ref.(($valwebsite->status == $valwebsite::STATUS_DRAFT) ? '</span>
' : '');
3036 $out .= ' data-html=
"'.dol_escape_htmltag($outoption).'"';
3038 $out .= $valwebsite->ref;
3039 $out .= '</option>
';
3042 $out .= '</select>
';
3043 $out .= ajax_combobox('website
');
3045 if (!empty($conf->use_javascript_ajax)) {
3046 $out .= '<script
type=
"text/javascript">
';
3047 $out .= 'jQuery(document).ready(
function () {
';
3048 $out .= ' jQuery(
"#website").change(
function () {
';
3049 $out .= ' console.log(
"We select "+jQuery(
"#website option:selected").val());
';
3050 $out .= ' if (jQuery(
"#website option:selected").val() == \
'-2\') {';
3051 $out .=
' window.location.href = "'.dol_escape_js($urltocreatenewwebsite).
'";';
3052 $out .=
' } else {';
3053 $out .=
' window.location.href = "'.$_SERVER[
"PHP_SELF"].
'?website="+jQuery("#website option:selected").val();';
3057 $out .=
'</script>';
3064 if (!empty(
$conf->use_javascript_ajax)) {
3065 print
'<span class="websiteselection">';
3070 if ($website->status == $website::STATUS_DRAFT) {
3071 $text_off =
'Offline';
3072 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>';
3074 $text_off =
'Online';
3075 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>';
3081 if (empty(
$conf->use_javascript_ajax)) {
3082 print
'<span class="websiteselection">';
3083 print
'<input type="image" class="valignmiddle" src="'.img_picto(
'',
'refresh',
'', 0, 1).
'" name="refreshsite" value="'.$langs->trans(
"Load").
'">';
3088 print
'<span class="websiteselection">';
3090 if ($websitekey && $websitekey !=
'-1' && ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite')) {
3092 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
$object->ref).
'&pageid='.((int) $pageid).
'&action=editcss&token='.
newToken().
'" class="button bordertransp valignmiddle" title="'.
dol_escape_htmltag($langs->trans(
"EditCss")).
'"'.$disabled.
'>';
3094 print
'<span class="hideonsmartphone paddingleft">'.dol_escape_htmltag($langs->trans(
"EditCss")).
'</span>';
3098 $importlabel = $langs->trans(
"ImportSite");
3099 $exportlabel = $langs->trans(
"ExportSite");
3100 if (!empty(
$conf->dol_optimize_smallscreen)) {
3101 $importlabel = $langs->trans(
"Import");
3102 $exportlabel = $langs->trans(
"Export");
3105 if ($atleastonepage) {
3106 print
'<input type="submit" class="button bordertransp" disabled="disabled" value="'.dol_escape_htmltag($importlabel).
'" name="importsite">';
3108 print
'<input type="submit" class="button bordertransp"'.$disabled.
' value="'.
dol_escape_htmltag($importlabel).
'" name="importsite">';
3112 $extraCssClass =
getDolGlobalString(
'WEBSITE_ALLOW_OVERWRITE_GIT_SOURCE') ?
'hideobject' :
'';
3113 print
'<input type="submit" class="button bordertransp ' . $extraCssClass .
'" ' . $disabledexport .
' value="' .
dol_escape_htmltag($exportlabel) .
'" name="exportsite">';
3117 $overwriteGitUrl = $_SERVER[
"PHP_SELF"] .
'?action=overwritesite&website=' . urlencode($website->ref);
3118 print
dolButtonToOpenExportDialog(
'exportpopup', $langs->trans(
'ExportOptions'), $langs->trans(
'ExportSite'),
'exportsite', $overwriteGitUrl, $website);
3123 print
'<input type="submit" class="button bordertransp"'.$disabled.
' value="'.
dol_escape_htmltag($langs->trans(
"CloneSite")).
'" name="createfromclone">';
3126 if (!$permissiontodelete) {
3127 $disabled =
' disabled="disabled"';
3128 $title = $langs->trans(
"NotEnoughPermissions");
3131 if ($website->status == $website::STATUS_VALIDATED) {
3132 $disabled =
' disabled="disabled"';
3133 $title = $langs->trans(
"WebsiteMustBeDisabled", $langs->transnoentitiesnoconv($website->LibStatut(0, 0)));
3137 $title = $langs->trans(
"Delete");
3138 $url = $_SERVER[
"PHP_SELF"].
'?action=deletesite&token='.
newToken().
'&website='.urlencode($website->ref);
3141 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>';
3144 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>';
3147 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>';
3150 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>';
3155 if ($websitekey && $websitekey !=
'-1' && ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite')) {
3156 print
'<span class="websiteselection">';
3158 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);
3160 if (isModEnabled(
'category')) {
3162 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);
3168 print
'<input type="hidden" name="website" id="website" value="'.$websitekey.
'">';
3172 print
'<span class="websitetools">';
3174 if ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite') {
3175 $urlext = $virtualurl;
3176 $urlint = $urlwithroot.
'/public/website/index.php?website='.$websitekey;
3178 print
'<span class="websiteinputurl valignmiddle" id="websiteinputurl">';
3179 $linktotestonwebserver =
'<a href="'.($virtualurl ? $virtualurl :
'#').
'" class="valignmiddle">';
3180 $linktotestonwebserver .=
'<span class="hideonsmartphone paddingrightonly">'.$langs->trans(
"TestDeployOnWeb", $virtualurl).
'</span>'.
img_picto(
'',
'globe');
3181 $linktotestonwebserver .=
'</a>';
3184 if (empty(
$object->fk_default_home)) {
3185 $htmltext .=
'<br><span class="error">'.$langs->trans(
"YouMustDefineTheHomePage").
'</span><br><br>';
3186 } elseif (empty($virtualurl)) {
3189 $htmltext .=
'<br><center>'.$langs->trans(
"GoTo").
' <a href="'.$virtualurl.
'" target="_website">'.$virtualurl.
'</a></center><br>';
3192 $htmltext .=
'<!-- Message defined translate key set into WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER -->';
3193 $htmltext .=
'<br>'.$langs->trans(
getDolGlobalString(
'WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER'));
3195 $htmltext .= $langs->trans(
"ToDeployYourWebsiteOnLiveYouHave3Solutions").
'<br><br>';
3196 $htmltext .=
'<div class="titre inline-block">1</div> - '.$langs->trans(
"SetHereVirtualHost", $dataroot);
3197 $htmltext .=
'<br>';
3198 $htmltext .=
'<br>'.$langs->trans(
"CheckVirtualHostPerms", $langs->transnoentitiesnoconv(
"ReadPerm"), DOL_DOCUMENT_ROOT);
3199 $htmltext .=
'<br>'.$langs->trans(
"CheckVirtualHostPerms", $langs->transnoentitiesnoconv(
"WritePerm"),
'{s1}');
3200 $htmltext = str_replace(
'{s1}', DOL_DATA_ROOT.
'/website<br>'.DOL_DATA_ROOT.
'/medias', $htmltext);
3202 $examplewithapache =
"<VirtualHost *:80>\n";
3203 $examplewithapache .=
'#php_admin_value open_basedir /tmp/:'.DOL_DOCUMENT_ROOT.
':'.DOL_DATA_ROOT.
':/dev/urandom'.
"\n";
3204 $examplewithapache .=
"\n";
3205 $examplewithapache .=
'DocumentRoot "'.DOL_DOCUMENT_ROOT.
'"'.
"\n";
3206 $examplewithapache .=
"\n";
3207 $examplewithapache .=
'<Directory "'.DOL_DOCUMENT_ROOT.
'">'.
"\n";
3208 $examplewithapache .=
'AllowOverride FileInfo Options
3209 Options -Indexes -MultiViews -FollowSymLinks -ExecCGI
3211 </Directory>'.
"\n".
'
3212 <Directory "'.DOL_DATA_ROOT.
'/website">
3213 AllowOverride FileInfo Options
3214 Options -Indexes -MultiViews +FollowSymLinks -ExecCGI
3216 </Directory>'.
"\n".
'
3217 <Directory "'.DOL_DATA_ROOT.
'/medias">
3218 AllowOverride FileInfo Options
3219 Options -Indexes -MultiViews -FollowSymLinks -ExecCGI
3223 $examplewithapache .=
"\n";
3224 $examplewithapache .=
"#ErrorLog /var/log/apache2/".$websitekey.
"_error_log\n";
3225 $examplewithapache .=
"#TransferLog /var/log/apache2/".$websitekey.
"_access_log\n";
3227 $examplewithapache .=
"</VirtualHost>\n";
3229 $htmltext .=
'<br>'.$langs->trans(
"ExampleToUseInApacheVirtualHostConfig").
':<br>';
3230 $htmltext .=
'<div class="quatrevingtpercent exampleapachesetup wordbreak" spellcheck="false">'.dol_nl2br(
dol_escape_htmltag($examplewithapache, 1, 1)).
'</div>';
3232 $htmltext .=
'<br>';
3233 $htmltext .=
'<div class="titre inline-block">2</div> - '.$langs->trans(
"YouCanAlsoTestWithPHPS");
3234 $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>';
3236 $htmltext .=
'<br>';
3237 $htmltext .=
'<div class="titre inline-block">3</div> - '.$langs->trans(
"YouCanAlsoDeployToAnotherWHP");
3239 print $form->textwithpicto($linktotestonwebserver, $htmltext, 1,
'none',
'valignmiddle', 0, 3,
'helpvirtualhost');
3243 if (in_array($action, array(
'editcss',
'editmenu',
'file_manager',
'replacesiteconfirm')) || in_array($mode, array(
'replacesite'))) {
3244 if ($action ==
'editcss') {
3247 $stringforfirstkey = $langs->trans(
"KeyboardShortcut");
3248 if (
$conf->browser->name ==
'chrome') {
3249 $stringforfirstkey .=
' ALT +';
3250 } elseif (
$conf->browser->name ==
'firefox') {
3251 $stringforfirstkey .=
' ALT + SHIFT +';
3253 $stringforfirstkey .=
' CTL +';
3256 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">';
3258 if (preg_match(
'/^create/', $action) && $action !=
'file_manager' && $action !=
'replacesite' && $action !=
'replacesiteconfirm') {
3259 print
'<input type="submit" id="savefile" class="button buttonforacesave button-save small" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
3261 if (preg_match(
'/^edit/', $action) && $action !=
'file_manager' && $action !=
'replacesite' && $action !=
'replacesiteconfirm') {
3262 print
'<input type="submit" id="savefile" class="button buttonforacesave button-save small" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
3264 if ($action !=
'preview') {
3265 print
'<input type="submit" class="button button-cancel small" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'" name="cancel">';
3275 if ($websitekey && $websitekey !=
'-1' && (!in_array($action, array(
'editcss',
'editmenu',
'importsite',
'file_manager',
'replacesite',
'replacesiteconfirm'))) && (!in_array($mode, array(
'replacesite'))) && !$file_manager) {
3278 print
'<!-- Toolbar for websitepage -->';
3279 print
'<div class="centpercent websitebar"'.($style ?
' style="'.$style.
'"' :
'').
'>';
3281 print
'<div class="websiteselection hideonsmartphoneimp minwidth75 tdoverflowmax100 inline-block">';
3282 print $langs->trans(
"PageContainer").
': ';
3286 print
'<span class="websiteselection paddingrightonly">';
3287 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>';
3293 $s = $formwebsite->selectContainer($website,
'pageid', $pageid, 0, $action,
'minwidth100 maxwidth200onsmartphone');
3295 $out .=
'<span class="websiteselection nopaddingrightimp">';
3299 $urltocreatenewpage = $_SERVER[
"PHP_SELF"].
'?action=createcontainer&token='.
newToken().
'&website='.urlencode($website->ref);
3301 if (!empty(
$conf->use_javascript_ajax)) {
3302 $out .=
'<script type="text/javascript">';
3303 $out .=
'jQuery(document).ready(function () {';
3304 $out .=
' jQuery("#pageid").change(function () {';
3305 $out .=
' console.log("We select "+jQuery("#pageid option:selected").val());';
3306 $out .=
' if (jQuery("#pageid option:selected").val() == \'-2\') {';
3307 $out .=
' window.location.href = "'.$urltocreatenewpage.
'";';
3308 $out .=
' } else {';
3309 $out .=
' window.location.href = "'.$_SERVER[
"PHP_SELF"].
'?website='.urlencode($website->ref).
'&pageid="+jQuery("#pageid option:selected").val();';
3313 $out .=
'</script>';
3319 if (!empty(
$conf->use_javascript_ajax)) {
3320 print
'<span class="websiteselection">';
3322 if (
$object->status == $object::STATUS_DRAFT) {
3323 $text_off =
'SetWebsiteOnlineBefore';
3324 if ($websitepage->status == $websitepage::STATUS_DRAFT) {
3325 print
'<span class="valignmiddle disabled opacitymedium">'.img_picto($langs->trans($text_off),
'switch_off').
'</span>';
3327 print
'<span class="valignmiddle disabled opacitymedium">'.img_picto($langs->trans($text_off),
'switch_on').
'</span>';
3330 print
ajax_object_onoff($websitepage,
'status',
'status',
'Online',
'Offline', array(),
'valignmiddle inline-block'.(empty($websitepage->id) ?
' opacitymedium disabled' :
''),
'statuswebsitepage', 1,
'pageid='.$websitepage->id);
3336 print
'<span class="websiteselection">';
3338 print
'<input type="image" class="valignmiddle buttonwebsite" src="'.img_picto(
'',
'refresh',
'', 0, 1).
'" name="refreshpage" value="'.$langs->trans(
"Load").
'"'.(($action !=
'editsource') ?
'' :
' disabled="disabled"').
'>';
3341 $pagepreviousid = 0;
3344 $sql =
"SELECT MAX(rowid) as pagepreviousid FROM ".MAIN_DB_PREFIX.
"website_page WHERE rowid < ".((int) $pageid).
" AND fk_website = ".((int)
$object->id);
3345 $resql = $db->query($sql);
3347 $obj = $db->fetch_object($resql);
3349 $pagepreviousid = $obj->pagepreviousid;
3354 $sql =
"SELECT MIN(rowid) as pagenextid FROM ".MAIN_DB_PREFIX.
"website_page WHERE rowid > ".((int) $pageid).
" AND fk_website = ".((int)
$object->id);
3355 $resql = $db->query($sql);
3357 $obj = $db->fetch_object($resql);
3359 $pagenextid = $obj->pagenextid;
3366 if ($pagepreviousid) {
3367 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>';
3369 print
'<span class="valignmiddle opacitymedium">'.img_previous($langs->trans(
"PreviousContainer")).
'</span>';
3372 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>';
3374 print
'<span class="valignmiddle opacitymedium">'.img_next($langs->trans(
"NextContainer")).
'</span>';
3379 if ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite') {
3381 if (!$user->hasRight(
'website',
'write')) {
3382 $disabled =
' disabled="disabled"';
3386 if ($action ==
'deletesite') {
3388 $formquestion = array(
3389 array(
'type' =>
'checkbox',
'name' =>
'delete_also_js',
'label' => $langs->trans(
"DeleteAlsoJs"),
'value' => 0),
3390 array(
'type' =>
'checkbox',
'name' =>
'delete_also_medias',
'label' => $langs->trans(
"DeleteAlsoMedias"),
'value' => 0),
3395 if ($atleastonepage) {
3396 $langs->load(
"errors");
3397 $formquestion[] = array(
'type' =>
'onecolumn',
'value' =>
'<div class="warning">'.$langs->trans(
"WarningPagesWillBeDeleted").
'</div>');
3400 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteWebsite'),
'',
'confirm_deletesite', $formquestion, 0, 1, 210 + ($atleastonepage ? 70 : 0), 580);
3406 if ($action ==
'createfromclone') {
3408 $formquestion = array(
3409 array(
'type' =>
'text',
'name' =>
'siteref',
'label' => $langs->trans(
"WebSite"),
'value' =>
'copy_of_'.$object->ref)
3412 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'CloneSite'),
'',
'confirm_createfromclone', $formquestion, 0, 1, 200);
3417 if ($pageid > 0 && $atleastonepage) {
3419 if ($action ==
'createpagefromclone') {
3421 $preselectedlanguage =
GETPOST(
'newlang',
'aZ09') ?
GETPOST(
'newlang',
'aZ09') :
'';
3422 $onlylang = array();
3423 if ($website->otherlang) {
3424 if (!empty($website->lang)) {
3425 $onlylang[$website->lang] = $website->lang.
' ('.$langs->trans(
"Default").
')';
3427 foreach (explode(
',', $website->otherlang) as $langkey) {
3428 if (empty(trim($langkey))) {
3431 $onlylang[$langkey] = $langkey;
3433 $textifempty = $langs->trans(
"Default");
3435 $onlylang[
'none'] =
'none';
3436 $textifempty = $langs->trans(
"Default");
3438 $formquestion = array(
3439 array(
'type' =>
'hidden',
'name' =>
'sourcepageurl',
'value' => $objectpage->pageurl),
3440 array(
'type' =>
'other',
'tdclass' =>
'fieldrequired',
'name' =>
'newwebsite',
'label' => $langs->trans(
"WebSite"),
'value' => $formwebsite->selectWebsite(
$object->id,
'newwebsite', 0)),
3441 array(
'type' =>
'text',
'tdclass' =>
'maxwidth200 fieldrequired',
'moreattr' =>
'autofocus="autofocus"',
'name' =>
'newtitle',
'label' => $langs->trans(
"WEBSITE_TITLE"),
'value' => $langs->trans(
"CopyOf").
' '.$objectpage->title),
3442 array(
'type' =>
'text',
'tdclass' =>
'maxwidth200',
'name' =>
'newpageurl',
'label' => $langs->trans(
"WEBSITE_PAGENAME"),
'value' =>
'')
3444 if (count($onlylang) > 1) {
3445 $formquestion[] = array(
'type' =>
'checkbox',
'tdclass' =>
'maxwidth200',
'name' =>
'is_a_translation',
'label' => $langs->trans(
"PageIsANewTranslation"),
'value' => 0,
'morecss' =>
'margintoponly');
3448 $value = $formadmin->select_language($preselectedlanguage,
'newlang', 0, array(), $textifempty, 0, 0,
'minwidth200', 1, 0, 0, $onlylang, 1);
3449 $formquestion[] = array(
'type' =>
'other',
'name' =>
'newlang',
'label' => $form->textwithpicto($langs->trans(
"Language"), $langs->trans(
"DefineListOfAltLanguagesInWebsiteProperties")),
'value' => $value);
3451 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?website='.
$object->ref.
'&pageid='.$pageid, $langs->trans(
'ClonePage'),
'',
'confirm_createpagefromclone', $formquestion, 0, 1, 300, 550);
3456 print
'<span class="websiteselection">';
3459 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?website='.
$object->ref.
'&pageid='.$pageid.
'&action=editmeta&token='.
newToken().
'" class="button bordertransp valignmiddle" title="'.
dol_escape_htmltag($langs->trans(
"EditPageMeta")).
'"'.$disabled.
'>';
3461 print
'<span class="hideonsmartphone paddingleft">'.dol_escape_htmltag($langs->trans(
"EditPageMeta")).
'</span>';
3465 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?website='.
$object->ref.
'&pageid='.$pageid.
'&action=editsource&token='.
newToken().
'" class="button bordertransp"'.$disabled.
'>';
3467 print
'<span class="hideonsmartphone paddingleft">'.dol_escape_htmltag($langs->trans(
$conf->dol_optimize_smallscreen ?
"HTML" :
"EditHTMLSource")).
'</span>';
3472 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?website='.
$object->ref.
'&pageid='.$pageid.
'&action=editcontent&token='.
newToken().
'" class="button bordertransp"'.$disabled.
'>'.
dol_escape_htmltag(
"CKEditor").
'</a>';
3474 print
'<!-- Add option WEBSITE_ALLOW_CKEDITOR to allow ckeditor -->';
3481 print
'<!-- button EditInLine and ShowSubcontainers -->'.
"\n";
3482 print
'<div class="websiteselectionsection inline-block">';
3484 print
'<div class="inline-block marginrightonly">';
3485 print $langs->trans(
"ShowSubcontainers");
3487 print
'<a class="nobordertransp nohoverborder marginleftonlyshort valignmiddle"'.$disabled.
' href="'.$_SERVER[
"PHP_SELF"].
'?website='.
$object->ref.
'&pageid='.$websitepage->id.
'&action=setshowsubcontainers&token='.
newToken().
'">'.
img_picto($langs->trans(
"ShowSubContainersOnOff", $langs->transnoentitiesnoconv(
"Off")),
'switch_off',
'', 0, 0, 0,
'',
'nomarginleft').
'</a>';
3489 print
'<a class="nobordertransp nohoverborder marginleftonlyshort valignmiddle"'.$disabled.
' href="'.$_SERVER[
"PHP_SELF"].
'?website='.
$object->ref.
'&pageid='.$websitepage->id.
'&action=unsetshowsubcontainers&token='.
newToken().
'">'.
img_picto($langs->trans(
"ShowSubContainersOnOff", $langs->transnoentitiesnoconv(
"On")),
'switch_on',
'', 0, 0, 0,
'',
'nomarginleft').
'</a>';
3493 print
'<div class="inline-block marginrightonly">';
3495 print
'<span id="switchckeditorinline">'.
"\n";
3497 print
'<!-- Code to enabled edit inline ckeditor -->'.
"\n";
3498 print
'<script type="text/javascript">
3499 $(document).ready(function() {
3500 var isEditingEnabled = '.(getDolGlobalString(
"WEBSITE_EDITINLINE") ?
'true' :
'false').
';
3501 if (isEditingEnabled)
3503 switchEditorOnline(true);
3506 $( "#switchckeditorinline" ).click(function() {
3507 switchEditorOnline();
3510 function switchEditorOnline(forceenable)
3512 if (! isEditingEnabled || forceenable)
3514 console.log("Enable inline edit for some html tags with contenteditable=true attribute");
3516 jQuery(\'section[contenteditable="true"],div[contenteditable="true"],header[contenteditable="true"],main[contenteditable="true"],footer[contenteditable="true"]\').each(function(idx){
3517 var idtouse = $(this).attr(\'id\');
3518 console.log("Enable inline edit for "+idtouse);
3519 if (idtouse !== undefined) {
3520 var inlineditor = CKEDITOR.inline(idtouse, {
3521 // Allow some non-standard markup that we used in the introduction.
3522 // + a[target];div{float,display} ?
3523 extraAllowedContent: \'span(*);cite(*);q(*);dl(*);dt(*);dd(*);ul(*);li(*);header(*);main(*);footer(*);button(*);h1(*);h2(*);h3(*);\',
3524 //extraPlugins: \'sourcedialog\',
3525 removePlugins: \'flash,stylescombo,exportpdf,scayt,wsc,pagebreak,iframe,smiley\',
3526 // Show toolbar on startup (optional).
3527 // startupFocus: true
3531 // Note the Source tool does not work on inline
3532 inlineditor.config.toolbar = [
3533 [\'Templates\',\'NewPage\'],
3535 [\'Maximize\',\'Preview\'],
3537 [\'Undo\',\'Redo\',\'-\',\'Find\',\'Replace\',\'-\',\'SelectAll\',\'RemoveFormat\'],
3538 [\'CreateDiv\',\'ShowBlocks\'],
3539 [\'Form\', \'Checkbox\', \'Radio\', \'TextField\', \'Textarea\', \'Select\', \'Button\', \'ImageButton\', \'HiddenField\'],
3540 [\'Bold\',\'Italic\',\'Underline\',\'Strike\',\'Superscript\'],
3541 [\'NumberedList\',\'BulletedList\',\'-\',\'Outdent\',\'Indent\',\'Blockquote\'],
3542 [\'JustifyLeft\',\'JustifyCenter\',\'JustifyRight\',\'JustifyBlock\'],
3543 [\'Link\',\'Unlink\'],
3544 [\'Image\',\'Table\',\'HorizontalRule\'],
3545 [\'Styles\',\'Format\',\'Font\',\'FontSize\'],
3546 [\'TextColor\',\'BGColor\']
3550 //inlineditor.on(\'instanceReady\', function () {
3554 CKEDITOR.instances[idtouse].on(\'change\', function() {
3555 $(this.element.$).addClass(\'modified\');
3558 console.warn("A html section has the contenteditable=true attribute but has no id attribute");
3562 isEditingEnabled = true;
3564 // Trigger the function when clicking outside the elements with contenteditable=true attribute
3565 // so we can save the change.
3566 $(document).on(\'click\', function(e) {
3567 var target = $(e.target);
3569 // Check if the click is outside the elements with contenteditable=true attribute
3570 if (!target.closest(\'[contenteditable="true"]\').length) {
3571 // Repeat through the elements with contenteditable="true" attribute
3572 $(\'[contenteditable="true"]\').each(function() {
3573 var idToUse = $(this).attr(\'id\');
3574 var elementType = $(this).prop("tagName").toLowerCase(); // Get the tag name (div, section, footer...)
3575 var instance = CKEDITOR.instances[idToUse];
3577 // Check if the element has been modified
3578 if ($(this).hasClass(\'modified\')) {
3579 var content = instance.getData();
3580 content = "\\n" + content;
3582 // Retrieving the content and ID of the element
3583 var elementId = $(this).attr(\'id\');
3588 console.log("A change has been detected, we send new content for update with ajax");
3590 // Sending data via AJAX to update section
3593 url: \'' . DOL_URL_ROOT .
'/core/ajax/editinline.php\',
3595 website_ref: \''.dol_escape_js($website->ref).
'\',
3596 page_id: \
'' . ((int) $websitepage->id) .
'\',
3598 element_id: elementId,
3599 element_type: elementType,
3600 action: \
'updatedElementContent\',
3603 success:
function(response) {
3604 console.log(response);
3605 var $lastWebsitebar = $(
".websitebar").last();
3606 var $span = $(
"<span></span>").html(
"'.$langs->trans("Saved
").'").css({
3607 \
'display\': \'block\',
3608 \'position\': \'absolute\',
3609 \'margin-top\': \'6px\',
3611 \'background-color\': \'#e3f0db\',
3612 \'color\': \'#446548\',
3613 \'font-size\': \'14px\',
3614 \'padding\': \'0px 5px\',
3617 $lastWebsitebar.after($span);
3619 // Close message after 2 seconds
3620 setTimeout(function() {
3621 $span.fadeOut(500, function() {
3629 print
'console.log("A change has been detected, but saving is not enabled by option WEBSITE_EDITINLINE_SAVE_CKEDITOR_EDIT, so no ajax update is done");';
3633 $(this).removeClass(\'modified\');
3640 console.log("Disable inline edit");
3641 for(name in CKEDITOR.instances) {
3642 CKEDITOR.instances[name].destroy(true);
3644 isEditingEnabled = false;
3649 print $langs->trans(
"EditInLine");
3653 $disableeditinline = 0;
3654 if ($disableeditinline) {
3656 print
'<a class="nobordertransp opacitymedium nohoverborder marginleftonlyshort"'.$disabled.
' href="#" disabled="disabled" title="'.
dol_escape_htmltag($langs->trans(
"OnlyEditionOfSourceForGrabbedContent")).
'">'.
img_picto($langs->trans(
"OnlyEditionOfSourceForGrabbedContent"),
'switch_off',
'', 0, 0, 0,
'',
'nomarginleft').
'</a>';
3660 print
'<a class="nobordertransp nohoverborder marginleftonlyshort valignmiddle"'.$disabled.
' href="'.$_SERVER[
"PHP_SELF"].
'?website='.
$object->ref.
'&pageid='.$websitepage->id.
'&action=seteditinline&token='.
newToken().
'">'.
img_picto($langs->trans(
"EditInLineOnOff", $langs->transnoentitiesnoconv(
"Off")),
'switch_off',
'', 0, 0, 0,
'',
'nomarginleft').
'</a>';
3662 print
'<a class="nobordertransp nohoverborder marginleftonlyshort valignmiddle"'.$disabled.
' href="'.$_SERVER[
"PHP_SELF"].
'?website='.
$object->ref.
'&pageid='.$websitepage->id.
'&action=unseteditinline&token='.
newToken().
'">'.
img_picto($langs->trans(
"EditInLineOnOff", $langs->transnoentitiesnoconv(
"On")),
'switch_on',
'', 0, 0, 0,
'',
'nomarginleft').
'</a>';
3671 print
'<span class="websiteselection">';
3672 if (
$object->fk_default_home > 0 && $pageid ==
$object->fk_default_home) {
3676 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>';
3680 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>';
3682 print
'<input type="submit" class="button bordertransp"'.$disabled.
' value="'.
dol_escape_htmltag($langs->trans(
"ClonePage")).
'" name="createpagefromclone">';
3685 if ($websitepage->status != $websitepage::STATUS_DRAFT) {
3686 $disabled =
' disabled="disabled"';
3687 $title = $langs->trans(
"WebpageMustBeDisabled", $langs->transnoentitiesnoconv($websitepage->LibStatut(0, 0)));
3692 $url = $_SERVER[
"PHP_SELF"].
'?action=delete&token='.
newToken().
'&pageid='.((int) $websitepage->id).
'&website='.urlencode($website->ref);
3694 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>';
3701 print
'<span class="websitetools">';
3703 if (($pageid > 0 && $atleastonepage) && ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite')) {
3704 $realpage = $urlwithroot.
'/public/website/index.php?website='.$websitekey.
'&pageref='.$websitepage->pageurl;
3705 $pagealias = $websitepage->pageurl;
3707 $htmltext = $langs->trans(
"PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv(
"Page"), $langs->transnoentitiesnoconv(
"Page"), $realpage, $langs->transnoentitiesnoconv(
"TestDeployOnWeb"));
3713 print
'<div class="websiteinputurl inline-block paddingright">';
3714 print
'<a class="websitebuttonsitepreview inline-block" id="previewpage" href="'.$realpage.
'&nocache='.
dol_now().
'" class="button" target="tab'.$websitekey.
'" alt="'.
dol_escape_htmltag($htmltext).
'">';
3715 print $form->textwithpicto(
'', $htmltext, 1,
'preview');
3739 if (!in_array($mode, array(
'replacesite')) && !in_array($action, array(
'editcss',
'editmenu',
'file_manager',
'replacesiteconfirm',
'createsite',
'createcontainer',
'createfromclone',
'createpagefromclone',
'deletesite'))) {
3740 if ($action ==
'editsource' || $action ==
'editmeta') {
3743 $stringforfirstkey = $langs->trans(
"KeyboardShortcut");
3744 if (
$conf->browser->name ==
'chrome') {
3745 $stringforfirstkey .=
' ALT +';
3746 } elseif (
$conf->browser->name ==
'firefox') {
3747 $stringforfirstkey .=
' ALT + SHIFT +';
3749 $stringforfirstkey .=
' CTL +';
3752 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">';
3754 if (preg_match(
'/^create/', $action)) {
3755 print
'<input type="submit" id="savefile" class="button buttonforacesave button-save small" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
3757 if (preg_match(
'/^edit/', $action)) {
3758 print
'<input type="submit" id="savefile" class="button buttonforacesave button-save small" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
3760 if ($action !=
'preview') {
3761 print
'<input type="submit" class="button button-cancel small" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'" name="cancel">';
3767 print
'<span class="websitehelp">';
3768 if ($action ==
'editsource' || $action ==
'editcontent' ||
GETPOST(
'editsource',
'alpha') ||
GETPOST(
'editcontent',
'alpha')) {
3769 $url =
'https://wiki.dolibarr.org/index.php/Module_Website';
3771 $htmltext =
'<small>';
3772 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource", $url);
3773 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource1", $url);
3774 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource2", $url);
3775 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource3", $url);
3776 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource4", $url);
3777 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSourceMore", $url);
3778 $htmltext .=
'<br>';
3779 $htmltext .=
'</small>';
3780 if (
$conf->browser->layout ==
'phone') {
3781 print $form->textwithpicto(
'', $htmltext, 1,
'help',
'inline-block', 1, 2,
'tooltipsubstitution');
3784 print $form->textwithpicto($langs->trans(
"SyntaxHelp").
' '.
img_help(2, $langs->trans(
"SyntaxHelp")), $htmltext, 1,
'none',
'inline-block', 1, 2,
'tooltipsubstitution');
3790 if ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone') {
3792 if (!empty(
$conf->use_javascript_ajax)) {
3793 print
'<script type="text/javascript">
3794 jQuery(document).ready(function() {
3795 jQuery("#websiteinputurl").keyup(function() {
3796 console.log("Website external url modified "+jQuery("#previewsiteurl").val());
3797 if (jQuery("#previewsiteurl").val() != "" && jQuery("#previewsiteurl").val().startsWith("http"))
3799 jQuery("a.websitebuttonsitepreviewdisabled img").css({ opacity: 1 });
3801 else jQuery("a.websitebuttonsitepreviewdisabled img").css({ opacity: 0.2 });
3805 jQuery("#previewsiteext,#previewpageext").click(function() {
3807 newurl=jQuery("#previewsiteurl").val();
3808 if (! newurl.startsWith("http"))
3810 alert(\''.dol_escape_js($langs->trans(
"ErrorURLMustStartWithHttp")).
'\');
3814 newpage=jQuery(
"#previewsiteurl").val() +
"/" + jQuery(
"#previewpageurl").val() +
".php";
3815 console.log(
"Open url "+newurl);
3819 url:
"'.DOL_URL_ROOT.'/core/ajax/saveinplace.php",
3821 field: \
'editval_virtualhost\',
3822 element: \'website\',
3823 table_element: \'website\',
3824 fk_element: '.((int)
$object->id).
',
3827 context: document.body
3830 jQuery("#previewsiteext").attr("href",newurl);
3831 jQuery("#previewpageext").attr("href",newpage);
3850if ($action ==
'editcss') {
3851 print
'<div class="fiche">';
3855 if (!GETPOSTISSET(
'WEBSITE_CSS_INLINE')) {
3856 $csscontent = @file_get_contents($filecss);
3858 $csscontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $csscontent);
3860 $csscontent =
GETPOST(
'WEBSITE_CSS_INLINE',
'none');
3862 if (!trim($csscontent)) {
3863 $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;}";
3866 if (!GETPOSTISSET(
'WEBSITE_JS_INLINE')) {
3867 $jscontent = @file_get_contents($filejs);
3869 $jscontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $jscontent);
3871 $jscontent =
GETPOST(
'WEBSITE_JS_INLINE',
'none');
3873 if (!trim($jscontent)) {
3874 $jscontent =
'/* JS content (all pages) */'.
"\n";
3877 if (!GETPOSTISSET(
'WEBSITE_HTML_HEADER')) {
3878 $htmlheadercontent = @file_get_contents($filehtmlheader);
3880 $htmlheadercontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $htmlheadercontent);
3882 $htmlheadercontent =
GETPOST(
'WEBSITE_HTML_HEADER',
'none');
3884 if (!trim($htmlheadercontent)) {
3885 $htmlheadercontent =
"<html>\n";
3886 $htmlheadercontent .= $htmlheadercontentdefault;
3887 $htmlheadercontent .=
"</html>";
3889 $htmlheadercontent = preg_replace(
'/^\s*<html>/ims',
'', $htmlheadercontent);
3890 $htmlheadercontent = preg_replace(
'/<\/html>\s*$/ims',
'', $htmlheadercontent);
3891 $htmlheadercontent =
'<html>'.
"\n".trim($htmlheadercontent).
"\n".
'</html>';
3894 if (!GETPOSTISSET(
'WEBSITE_ROBOT')) {
3895 $robotcontent = @file_get_contents($filerobot);
3897 $robotcontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $robotcontent);
3899 $robotcontent =
GETPOST(
'WEBSITE_ROBOT',
'nohtml');
3901 if (!trim($robotcontent)) {
3902 $robotcontent .=
"# Robot file. Generated with ".DOL_APPLICATION_TITLE.
"\n";
3903 $robotcontent .=
"User-agent: *\n";
3904 $robotcontent .=
"Allow: /public/\n";
3905 $robotcontent .=
"Disallow: /administrator/\n";
3908 if (!GETPOSTISSET(
'WEBSITE_HTACCESS')) {
3909 $htaccesscontent = @file_get_contents($filehtaccess);
3911 $htaccesscontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $htaccesscontent);
3913 $htaccesscontent =
GETPOST(
'WEBSITE_HTACCESS',
'nohtml');
3916 if (!GETPOSTISSET(
'WEBSITE_MANIFEST_JSON')) {
3917 $manifestjsoncontent = @file_get_contents($filemanifestjson);
3919 $manifestjsoncontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $manifestjsoncontent);
3921 $manifestjsoncontent =
GETPOST(
'WEBSITE_MANIFEST_JSON',
'restricthtml');
3927 if (!GETPOSTISSET(
'WEBSITE_README')) {
3928 $readmecontent = @file_get_contents($filereadme);
3930 $readmecontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $readmecontent);
3932 $readmecontent =
GETPOST(
'WEBSITE_README',
'restricthtmlallowunvalid');
3938 if (!GETPOSTISSET(
'WEBSITE_LICENSE')) {
3939 $licensecontent = @file_get_contents($filelicense);
3941 $licensecontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $licensecontent);
3943 $licensecontent =
GETPOST(
'WEBSITE_LICENSE',
'restricthtmlallowunvalid');
3951 print
'<!-- Edit Website properties -->'.
"\n";
3952 print
'<table class="border centpercent">';
3955 print
'<tr><td class="titlefieldcreate fieldrequired">';
3956 print $langs->trans(
'WebSite');
3962 if ($action !=
'createcontainer') {
3963 if (empty(
$conf->use_javascript_ajax)) {
3964 print
'<!-- Status of web site page -->'.
"\n";
3965 print
'<tr><td class="fieldrequired">';
3966 print $langs->trans(
'Status');
3968 print $form->selectyesno(
'status',
$object->status);
3974 print
'<tr><td class="tdtop fieldrequired">';
3976 print $form->textwithpicto($langs->trans(
'MainLanguage'), $htmltext, 1,
'help',
'', 0, 2,
'WEBSITE_LANG');
3978 print
img_picto(
'',
'language',
'class="picotfixedwidth"');
3979 print $formadmin->select_language((GETPOSTISSET(
'WEBSITE_LANG') ?
GETPOST(
'WEBSITE_LANG',
'aZ09comma') : (
$object->lang ?
$object->lang :
'0')),
'WEBSITE_LANG', 0, array(), 1, 0, 0,
'minwidth300', 2, 0, 0, array(), 1);
3984 print
'<tr><td class="tdtop">';
3985 $htmltext = $langs->trans(
"Example").
': fr,de,sv,it,pt';
3986 print $form->textwithpicto($langs->trans(
'OtherLanguages'), $htmltext, 1,
'help',
'', 0, 2);
3988 print
img_picto(
'',
'language',
'class="picotfixedwidth"');
3989 print
'<input type="text" class="flat maxwidth200" value="'.(GETPOSTISSET(
'WEBSITE_OTHERLANG') ?
GETPOST(
'WEBSITE_OTHERLANG',
'alpha') :
$object->otherlang).
'" name="WEBSITE_OTHERLANG">';
3994 print
'<tr><td class="tdtop">';
3996 $htmltext = $langs->trans(
"VirtualhostDesc");
3997 print $form->textwithpicto($langs->trans(
'Virtualhost'), $htmltext, 1,
'help',
'', 0, 2,
'virtualhosttooltip');
3999 print
'<input type="text" class="flat minwidth300" value="'.(GETPOSTISSET(
'virtualhost') ?
GETPOST(
'virtualhost',
'alpha') : $virtualurl).
'" name="virtualhost">';
4005 print $form->textwithpicto($langs->trans(
'ImportFavicon'), $langs->trans(
'FaviconTooltip'));
4008 $maxmin = $maxfilesizearray[
'maxmin'];
4010 print
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
4012 print
'<input type="file" class="flat minwidth300" name="addedfile" id="addedfile"/>';
4014 $uploadfolder =
$conf->website->dir_output.
'/'.$websitekey;
4016 print
'<div class="inline-block valignmiddle marginrightonly">';
4017 print
'<img style="max-height: 80px" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart=website&file='.$websitekey.
'/favicon.png">';
4023 print
'<tr><td class="tdtop">';
4024 $htmlhelp = $langs->trans(
"CSSContentTooltipHelp");
4025 print $form->textwithpicto($langs->trans(
'WEBSITE_CSS_INLINE'), $htmlhelp, 1,
'help',
'', 0, 2,
'csstooltip');
4028 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_CSS_INLINE_x'),
'y' =>
GETPOST(
'WEBSITE_CSS_INLINE_y'));
4029 $doleditor =
new DolEditor(
'WEBSITE_CSS_INLINE', $csscontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4030 print $doleditor->Create(1,
'',
true,
'CSS',
'css');
4035 print
'<tr><td class="tdtop">';
4036 $textwithhelp = $langs->trans(
'WEBSITE_JS_INLINE');
4037 $htmlhelp2 = $langs->trans(
"LinkAndScriptsHereAreNotLoadedInEditor").
'<br>';
4038 print $form->textwithpicto($textwithhelp, $htmlhelp2, 1,
'warning',
'', 0, 2,
'htmljstooltip2');
4042 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_JS_INLINE_x'),
'y' =>
GETPOST(
'WEBSITE_JS_INLINE_y'));
4043 $doleditor =
new DolEditor(
'WEBSITE_JS_INLINE', $jscontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4044 print $doleditor->Create(1,
'',
true,
'JS',
'javascript');
4049 print
'<tr><td class="tdtop">';
4050 print $langs->trans(
'WEBSITE_HTML_HEADER');
4051 $htmlhelp = $langs->trans(
"Example").
' :<br>';
4053 $textwithhelp = $form->textwithpicto(
'', $htmlhelp, 1,
'help',
'', 0, 2,
'htmlheadertooltip');
4054 $htmlhelp2 = $langs->trans(
"LinkAndScriptsHereAreNotLoadedInEditor").
'<br>';
4055 print $form->textwithpicto($textwithhelp, $htmlhelp2, 1,
'warning',
'', 0, 2,
'htmlheadertooltip2');
4058 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_HTML_HEADER_x'),
'y' =>
GETPOST(
'WEBSITE_HTML_HEADER_y'));
4059 $doleditor =
new DolEditor(
'WEBSITE_HTML_HEADER', $htmlheadercontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4060 print $doleditor->Create(1,
'',
true,
'HTML Header',
'html');
4065 print
'<tr><td class="tdtop">';
4066 print $langs->trans(
'WEBSITE_ROBOT');
4069 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_ROBOT_x'),
'y' =>
GETPOST(
'WEBSITE_ROBOT_y'));
4070 $doleditor =
new DolEditor(
'WEBSITE_ROBOT', $robotcontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4071 print $doleditor->Create(1,
'',
true,
'Robot file',
'text');
4076 print
'<tr><td class="tdtop">';
4078 $textwithhelp3 = $langs->trans(
"Example").
' :';
4079 $textwithhelp3 .=
"<br># Order allow,deny\n";
4080 $textwithhelp3 .=
"<br># Deny from all\n";
4081 $textwithhelp3 .=
"<br># Require all granted\n";
4083 print $form->textwithpicto($langs->trans(
'WEBSITE_HTACCESS'), $textwithhelp3, 1,
'help',
'', 0, 2,
'htmlheadertooltip3');
4086 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_HTACCESS_x'),
'y' =>
GETPOST(
'WEBSITE_HTACCESS_y'));
4087 $doleditor =
new DolEditor(
'WEBSITE_HTACCESS', $htaccesscontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4088 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' .htaccess',
'text');
4093 print
'<tr><td class="tdtop">';
4094 $htmlhelp = $langs->trans(
"Example").
' :<br>';
4095 $htmlhelp .=
'<small>'.dol_htmlentitiesbr($manifestjsoncontentdefault).
'</small>';
4096 print $form->textwithpicto($langs->trans(
'WEBSITE_MANIFEST_JSON'), $htmlhelp, 1,
'help',
'', 0, 2,
'manifestjsontooltip');
4098 print $langs->trans(
"UseManifest").
': '.$form->selectyesno(
'use_manifest', $website->use_manifest, 1).
'<br>';
4100 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_MANIFEST_JSON_x'),
'y' =>
GETPOST(
'WEBSITE_MANIFEST_JSON_y'));
4101 $doleditor =
new DolEditor(
'WEBSITE_MANIFEST_JSON', $manifestjsoncontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4102 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' manifest.json',
'text');
4106 print
'<tr><td class="tdtop">';
4107 $htmlhelp = $langs->trans(
"EnterHereReadmeInformation");
4108 print $form->textwithpicto($langs->trans(
"File").
' README.md', $htmlhelp, 1,
'help',
'', 0, 2,
'readmetooltip');
4111 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_README_x'),
'y' =>
GETPOST(
'WEBSITE_README_y'));
4112 $doleditor =
new DolEditor(
'WEBSITE_README', $readmecontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4113 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' README.md',
'text');
4118 print
'<tr><td class="tdtop">';
4119 $htmlhelp = $langs->trans(
"EnterHereLicenseInformation");
4120 print $form->textwithpicto($langs->trans(
"File").
' LICENSE', $htmlhelp, 1,
'help',
'', 0, 2,
'licensetooltip');
4123 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_LICENSE_x'),
'y' =>
GETPOST(
'WEBSITE_LICENSE_y'));
4124 $doleditor =
new DolEditor(
'WEBSITE_LICENSE', $licensecontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4125 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' LICENSE',
'text');
4130 print
'<tr><td class="tdtop">';
4131 $htmlhelp = $langs->trans(
'RSSFeedDesc');
4132 print $form->textwithpicto($langs->trans(
'RSSFeed'), $htmlhelp, 1,
'help',
'', 0, 2,
'');
4134 print
'/wrapper.php?rss=1[&l=XX][&limit=123]';
4147if ($action ==
'createsite') {
4148 print
'<div class="fiche">';
4162 if ($action ==
'createcontainer') {
4166 print
'<!-- Add site -->'.
"\n";
4167 print
'<div class="tabBar tabBarWithBottom">';
4169 print
'<table class="border centpercent">';
4171 $siteref = $sitedesc = $sitelang = $siteotherlang =
'';
4173 $siteref =
GETPOST(
'WEBSITE_REF',
'aZ09');
4175 if (
GETPOST(
'WEBSITE_DESCRIPTION')) {
4176 $sitedesc =
GETPOST(
'WEBSITE_DESCRIPTION',
'alpha');
4178 if (
GETPOST(
'WEBSITE_LANG')) {
4179 $sitelang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
4181 if (
GETPOST(
'WEBSITE_OTHERLANG')) {
4182 $siteotherlang =
GETPOST(
'WEBSITE_OTHERLANG',
'aZ09comma');
4185 print
'<tr><td class="titlefieldcreate fieldrequired">';
4186 print $form->textwithpicto($langs->trans(
'WebsiteName'), $langs->trans(
"Example").
': MyPortal, www.mywebsite.com, ...');
4188 print
'<input type="text" class="flat maxwidth300" name="WEBSITE_REF" value="'.dol_escape_htmltag($siteref).
'" autofocus>';
4191 print
'<tr><td class="fieldrequired">';
4192 print $langs->trans(
'MainLanguage');
4194 $shortlangcode = preg_replace(
'/[_-].*$/',
'', trim($langs->defaultlang));
4195 print
img_picto(
'',
'language',
'class="pictofixedwidth"');
4196 print $formadmin->select_language((GETPOSTISSET(
'WEBSITE_LANG') ?
GETPOST(
'WEBSITE_LANG',
'aZ09comma') : $shortlangcode),
'WEBSITE_LANG', 0, array(), 1, 0, 0,
'minwidth300', 2, 0, 0, array(), 1);
4200 $htmltext = $langs->trans(
"Example").
': fr,de,sv,it,pt';
4201 print $form->textwithpicto($langs->trans(
'OtherLanguages'), $htmltext, 1,
'help',
'', 0, 2);
4203 print
img_picto(
'',
'language',
'class="pictofixedwidth"');
4204 print
'<input type="text" class="flat minwidth300" name="WEBSITE_OTHERLANG" value="'.dol_escape_htmltag($siteotherlang).
'">';
4208 print $langs->trans(
'Description');
4210 print
'<input type="text" class="flat minwidth500" name="WEBSITE_DESCRIPTION" value="'.dol_escape_htmltag($sitedesc).
'">';
4215 $htmltext = $langs->trans(
"VirtualhostDesc");
4223 print $form->textwithpicto($langs->trans(
'Virtualhost'), $htmltext, 1,
'help',
'', 0, 2,
'');
4225 print
'<input type="text" class="flat minwidth300" name="virtualhost" value="'.dol_escape_htmltag(
GETPOST(
'virtualhost',
'alpha')).
'">';
4231 if ($action ==
'createsite') {
4232 print
'<div class="center">';
4234 print
'<input type="submit" class="button small" name="addcontainer" value="'.$langs->trans(
"Create").
'">';
4235 print
'<input class="button button-cancel small" type="submit" name="preview" value="'.$langs->trans(
"Cancel").
'">';
4251if ($action ==
'importsite') {
4252 print
'<!-- action=importsite -->';
4253 print
'<div class="fiche">';
4261 print
'<span class="opacitymedium">'.$langs->trans(
"ZipOfWebsitePackageToImport").
'</span><br><br>';
4264 $dolibarrdataroot = preg_replace(
'/([\\/]+)$/i',
'', DOL_DATA_ROOT);
4265 $allowimportsite =
true;
4266 if (
dol_is_file($dolibarrdataroot.
'/installmodules.lock')) {
4267 $allowimportsite =
false;
4270 if ($allowimportsite) {
4272 $maxmin = $maxfilesizearray[
'maxmin'];
4274 print
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
4276 print
'<input class="flat minwidth400" type="file" name="userfile[]" accept=".zip">';
4277 print
'<input type="submit" class="button small" name="buttonsubmitimportfile" value="'.dol_escape_htmltag($langs->trans(
"Upload")).
'">';
4278 print
'<input type="submit" class="button button-cancel small" name="preview" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
4279 print
'<br><br><br>';
4283 $message = $langs->trans(
'InstallModuleFromWebHasBeenDisabledContactUs');
4286 $message = $langs->trans(
"InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.
'/installmodules.lock');
4292 print
'<span class="opacitymedium">'.$langs->trans(
"ZipOfWebsitePackageToLoad").
'</span><br><br>';
4303if ($action ==
'editmeta' || $action ==
'createcontainer') {
4304 print
'<div class="fiche">';
4318 if ($action ==
'createcontainer') {
4322 print
'<!-- Edit or create page/container -->'.
"\n";
4325 $hiddenfromfetchingafterload =
' hideobject';
4326 $hiddenmanuallyafterload =
' hideobject';
4327 if (
GETPOST(
'radiocreatefrom') ==
'checkboxcreatefromfetching') {
4328 $hiddenfromfetchingafterload =
'';
4330 if (
GETPOST(
'radiocreatefrom') ==
'checkboxcreatemanually') {
4331 $hiddenmanuallyafterload =
'';
4334 if ($action ==
'editmeta' || empty(
$conf->use_javascript_ajax)) {
4335 $hiddenfromfetchingafterload =
'';
4336 $hiddenmanuallyafterload =
'';
4339 if ($action ==
'createcontainer') {
4342 if (!empty(
$conf->use_javascript_ajax)) {
4343 print
'<input type="radio" name="radiocreatefrom" id="checkboxcreatemanually" value="checkboxcreatemanually"'.(GETPOST(
'radiocreatefrom') ==
'checkboxcreatemanually' ?
' checked' :
'').
'> ';
4345 print
'<label for="checkboxcreatemanually"><span class="opacitymediumxx">'.$langs->trans(
"OrEnterPageInfoManually").
'</span></label><br>';
4346 print
'<hr class="tablecheckboxcreatemanually'.$hiddenmanuallyafterload.
'">';
4349 print
'<table class="border tableforfield nobackground centpercent tablecheckboxcreatemanually'.$hiddenmanuallyafterload.
'">';
4351 if ($action !=
'createcontainer') {
4352 print
'<tr><td class="titlefield fieldrequired">';
4353 print $langs->trans(
'IDOfPage').
' - '.$langs->trans(
'InternalURLOfPage');
4361 print
' - ';
4362 print
'/public/website/index.php?website='.urlencode($websitekey).
'&pageid='.urlencode((
string) $pageid);
4366 $type_container = $objectpage->type_container;
4367 $pageurl = $objectpage->pageurl;
4368 $pagealiasalt = $objectpage->aliasalt;
4369 $pagetitle = $objectpage->title;
4370 $pagedescription = $objectpage->description;
4371 $pageimage = $objectpage->image;
4372 $pagekeywords = $objectpage->keywords;
4373 $pagelang = $objectpage->lang;
4374 $pageallowedinframes = $objectpage->allowed_in_frames;
4375 $pagehtmlheader = $objectpage->htmlheader;
4376 $pagedatecreation = $objectpage->date_creation;
4377 $pagedatemodification = $objectpage->date_modification;
4378 $pageauthorid = $objectpage->fk_user_creat;
4379 $pageusermodifid = $objectpage->fk_user_modif;
4380 $pageauthoralias = $objectpage->author_alias;
4381 $pagestatus = $objectpage->status;
4383 $type_container =
'page';
4387 $pagedescription =
'';
4391 $pageallowedinframes = 0;
4392 $pagehtmlheader =
'';
4393 $pagedatecreation =
dol_now();
4394 $pagedatemodification =
'';
4395 $pageauthorid = $user->id;
4396 $pageusermodifid = 0;
4397 $pageauthoralias =
'';
4400 if (
GETPOST(
'WEBSITE_TITLE',
'alpha')) {
4401 $pagetitle = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_TITLE',
'alphanohtml'));
4403 if (
GETPOST(
'WEBSITE_PAGENAME',
'alpha')) {
4404 $pageurl =
GETPOST(
'WEBSITE_PAGENAME',
'alpha');
4406 if (
GETPOST(
'WEBSITE_ALIASALT',
'alpha')) {
4407 $pagealiasalt = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_ALIASALT',
'alphanohtml'));
4409 if (
GETPOST(
'WEBSITE_DESCRIPTION',
'alpha')) {
4410 $pagedescription = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml'));
4412 if (
GETPOST(
'WEBSITE_IMAGE',
'alpha')) {
4413 $pageimage =
GETPOST(
'WEBSITE_IMAGE',
'alpha');
4415 if (
GETPOST(
'WEBSITE_KEYWORDS',
'alpha')) {
4416 $pagekeywords = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_KEYWORDS',
'alphanohtml'));
4418 if (
GETPOST(
'WEBSITE_LANG',
'aZ09')) {
4419 $pagelang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
4421 if (
GETPOST(
'WEBSITE_ALLOWED_IN_FRAMES',
'aZ09')) {
4422 $pageallowedinframes =
GETPOST(
'WEBSITE_ALLOWED_IN_FRAMES',
'aZ09') ? 1 : 0;
4424 if (
GETPOST(
'htmlheader',
'none')) {
4425 $pagehtmlheader =
GETPOST(
'htmlheader',
'none');
4428 if ($action !=
'createcontainer') {
4429 if (empty(
$conf->use_javascript_ajax)) {
4430 print
'<!-- Status of web site page -->'.
"\n";
4431 print
'<tr><td class="fieldrequired">';
4432 print $langs->trans(
'Status');
4434 print $form->selectyesno(
'status', $objectpage->status);
4440 print
'<tr><td class="titlefield fieldrequired">';
4441 print $langs->trans(
'WEBSITE_TYPE_CONTAINER');
4443 print
img_picto(
'',
'object_technic',
'class="paddingrightonly"').
' ';
4444 print $formwebsite->selectTypeOfContainer(
'WEBSITE_TYPE_CONTAINER', (
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'alpha') ?
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'alpha') : $type_container), 0,
'', 1,
'minwidth300');
4447 print
'<script type="text/javascript">
4448 jQuery(document).ready(function() {
4449 jQuery("#selectWEBSITE_TYPE_CONTAINER").change(function() {
4450 console.log("We change type of page : "+jQuery("#selectWEBSITE_TYPE_CONTAINER").val());
4451 if (jQuery("#selectWEBSITE_TYPE_CONTAINER").val() == \'blogpost\') {
4452 jQuery(".trpublicauthor").show();
4454 jQuery(".trpublicauthor").hide();
4456 if (jQuery("#selectWEBSITE_TYPE_CONTAINER").val() == \'service\' || jQuery("#selectWEBSITE_TYPE_CONTAINER").val() == \'library\') {
4457 $(".spanprefix").html("_" + $("#selectWEBSITE_TYPE_CONTAINER").val() + "_");
4458 jQuery(".spanprefix").show();
4460 jQuery(".spanprefix").hide();
4464 // Force at init execution a first time of the handler change
4465 jQuery("#selectWEBSITE_TYPE_CONTAINER").trigger(\'change\');
4471 print
'<tr><td class="fieldrequired">';
4472 print $langs->trans(
'WEBSITE_TITLE');
4474 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_TITLE" id="WEBSITE_TITLE" value="'.dol_escape_htmltag($pagetitle).
'" autofocus>';
4478 print
'<tr><td class="titlefieldcreate fieldrequired">';
4479 print $langs->trans(
'WEBSITE_PAGENAME');
4481 print
'<span class="opacitymedium spanprefix hidden"></span> ';
4482 print
'<input type="text" class="flat minwidth300" name="WEBSITE_PAGENAME" id="WEBSITE_PAGENAME" value="'.dol_escape_htmltag((
string) preg_replace(
'/^_[a-z]+_/',
'', (
string) $pageurl)).
'">';
4485 print
'<script type="text/javascript">
4486 $(document).ready(function() {
4487 console.log("Manage prefix for service or library");
4488 if ($("#selectWEBSITE_TYPE_CONTAINER").val() == "service" || $("#selectWEBSITE_TYPE_CONTAINER").val() == "library") {
4489 $(".spanprefix").html("_" + $("#selectWEBSITE_TYPE_CONTAINER").val() + "_");
4490 $(".spanprefix").show();
4492 $(".websiteformtoolbar").on("submit", function(event) {
4493 if ($("#selectWEBSITE_TYPE_CONTAINER").val() == "service" || $("#selectWEBSITE_TYPE_CONTAINER").val() == "library") {
4494 var prefix = "_" + $("#selectWEBSITE_TYPE_CONTAINER").val() + "_";
4495 var userInput = $("#WEBSITE_PAGENAME").val();
4496 var $inputField = $("#WEBSITE_PAGENAME");
4497 if (userInput.indexOf(prefix) !== 0) {
4498 $inputField.val(prefix + userInput);
4506 print
'<tr><td class="titlefieldcreate">';
4507 $htmlhelp = $langs->trans(
"WEBSITE_ALIASALTDesc");
4508 print $form->textwithpicto($langs->trans(
'WEBSITE_ALIASALT'), $htmlhelp, 1,
'help',
'', 0, 2,
'aliastooltip');
4510 print
'<input type="text" class="flat minwidth500" name="WEBSITE_ALIASALT" value="'.dol_escape_htmltag($pagealiasalt).
'">';
4514 print $langs->trans(
'WEBSITE_DESCRIPTION');
4516 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_DESCRIPTION" value="'.dol_escape_htmltag($pagedescription).
'">';
4521 print
'<tr class="trimageforpage hidden"><td>';
4522 $htmlhelp = $langs->trans(
"WEBSITE_IMAGEDesc");
4523 print $form->textwithpicto($langs->trans(
'WEBSITE_IMAGE'), $htmlhelp, 1,
'help',
'', 0, 2,
'imagetooltip');
4525 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_IMAGE" value="'.dol_escape_htmltag($pageimage).
'">';
4528 print
'<script type="text/javascript">
4529 jQuery(document).ready(function() {
4530 jQuery("#selectWEBSITE_TYPE_CONTAINER").change(function() {
4531 console.log("We change type of page : "+jQuery("#selectWEBSITE_TYPE_CONTAINER").val());
4532 if (jQuery("#selectWEBSITE_TYPE_CONTAINER").val() == \'blogpost\') {
4533 jQuery(".trimageforpage").show();
4535 jQuery(".trimageforpage").hide();
4545 $htmlhelp = $langs->trans(
"WEBSITE_KEYWORDSDesc");
4546 print $form->textwithpicto($langs->trans(
'WEBSITE_KEYWORDS'), $htmlhelp, 1,
'help',
'', 0, 2,
'keywordtooltip');
4548 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_KEYWORDS" value="'.dol_escape_htmltag($pagekeywords).
'">';
4552 print $langs->trans(
'Language');
4554 $onlykeys = array();
4558 $onlykeys[$langs->defaultlang] = $langs->defaultlang;
4561 $tmparray = explode(
',',
$object->otherlang);
4562 foreach ($tmparray as $key) {
4563 $tmpkey = trim($key);
4564 if (strlen($key) == 2) {
4565 $tmpkey = strtolower($key);
4567 $onlykeys[$tmpkey] = $tmpkey;
4573 print
img_picto(
'',
'language',
'class="pictofixedwidth"').$formadmin->select_language($pagelang ? $pagelang :
'',
'WEBSITE_LANG', 0, array(),
'1', 0, 0,
'minwidth200', 0, 0, 0, $onlykeys, 1);
4574 $htmltext = $langs->trans(
"AvailableLanguagesAreDefinedIntoWebsiteProperties");
4575 print $form->textwithpicto(
'', $htmltext);
4581 print
'<!-- Translation of --><tr><td>';
4582 print $langs->trans(
'TranslationLinks');
4584 if ($action !=
'createcontainer') {
4586 $sql =
"SELECT rowid, lang from ".MAIN_DB_PREFIX.
"website_page where fk_page = ".((int) $objectpage->id);
4587 $resql = $db->query($sql);
4589 $num_rows = $db->num_rows($resql);
4590 if ($num_rows > 0) {
4591 print
'<span class="opacitymedium">'.$langs->trans(
'ThisPageHasTranslationPages').
':</span>';
4595 while ($obj = $db->fetch_object($resql)) {
4596 $result = $tmppage->fetch($obj->rowid);
4599 $tmpstring .=
'<br>';
4601 $tmpstring .= $tmppage->getNomUrl(1).
' '.
picto_from_langcode($tmppage->lang).
' '.$tmppage->lang;
4603 $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>';
4619 if ((empty($translatedby) || ($objectpage->lang !=
$object->lang)) && ($action ==
'editmeta' || $action ==
'createcontainer' || $objectpage->fk_page > 0)) {
4622 if ($objectpage->fk_page > 0) {
4623 $result = $sourcepage->fetch($objectpage->fk_page);
4630 if ($translatedby) {
4633 $translationof = $objectpage->fk_page;
4634 print
'<span class="opacitymedium">'.$langs->trans(
'ThisPageIsTranslationOf').
'</span> ';
4635 print $sourcepage->getNomUrl(2).
' '.$formwebsite->selectContainer($website,
'pageidfortranslation', ($translationof ? $translationof : -1), 1, $action,
'minwidth300', array($objectpage->id));
4636 if ($translationof > 0 && $sourcepage->lang) {
4639 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>';
4646 if (isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire')) {
4647 $langs->load(
'categories');
4649 if (!GETPOSTISSET(
'categories')) {
4651 $cats = $c->containing($objectpage->id, Categorie::TYPE_WEBSITE_PAGE);
4652 $arrayselected = array();
4653 if (is_array($cats)) {
4654 foreach ($cats as $cat) {
4655 $arrayselected[] = $cat->id;
4660 $cate_arbo = $form->select_all_categories(Categorie::TYPE_WEBSITE_PAGE,
'',
'parent', 0, 0, 3);
4663 print
'<tr><td class="toptd">'.$form->editfieldkey(
'Categories',
'categories',
'', $objectpage, 0).
'</td><td>';
4664 print
img_picto(
'',
'category',
'class="pictofixedwidth"');
4665 print $form->multiselectarray(
'categories', $cate_arbo, (GETPOSTISSET(
'categories') ?
GETPOST(
'categories',
'array') : $arrayselected), 0, 0,
'minwidth200 widthcentpercentminusxx');
4667 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);
4673 print
'<tr><td class="titlefieldcreate">';
4674 print
'ObjectClass';
4676 print
'<input type="text" class="flat minwidth300" name="WEBSITE_OBJECTCLASS" placeholder="ClassName::/path/class/ObjectClass.class.php" >';
4679 print
'<tr><td class="titlefieldcreate">';
4682 print
'<input type="text" class="flat minwidth300" name="WEBSITE_OBJECTID" >';
4686 $fuser =
new User($db);
4689 if ($action !=
'createcontainer') {
4691 print $langs->trans(
'DateLastModification');
4693 print
dol_print_date($pagedatemodification,
'dayhour',
'tzuser');
4697 print $langs->trans(
'UserModification');
4699 if ($pageusermodifid > 0) {
4700 $fuser->fetch($pageusermodifid);
4701 print $fuser->getNomUrl(-1);
4703 print
'<span class="opacitymedium">'.$langs->trans(
"Unknown").
'</span>';
4709 $url =
'https://wiki.dolibarr.org/index.php/Module_Website';
4710 $htmltext =
'<small>';
4711 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource", $url);
4712 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource1", $url);
4713 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource2", $url);
4714 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource3", $url);
4715 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource4", $url);
4716 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSourceMore", $url);
4717 $htmltext .=
'<br>';
4718 $htmltext .=
'</small>';
4721 $formmail->withaiprompt =
'html';
4722 $formmail->withlayout =
'websitepage';
4723 $showlinktolayout = $formmail->withlayout;
4724 $showlinktoai = ($formmail->withaiprompt && isModEnabled(
'ai')) ?
'textgenerationwebpage' :
'';
4725 if (($action ==
'createcontainer' && $showlinktolayout) || ($action ==
'createcontainer' && $showlinktoai)) {
4726 print
'<tr><td class="titlefield tdtop">';
4727 if (
$conf->browser->layout ==
'phone') {
4728 print $form->textwithpicto(
'', $htmltext, 1,
'help',
'inline-block', 1, 2,
'tooltipsubstitution');
4731 print $form->textwithpicto($langs->trans(
"PreviewPageContent").
' '.
img_help(2, $langs->trans(
"PreviewPageContent")), $htmltext, 1,
'none',
'inline-block', 1, 2,
'tooltipsubstitution');
4733 print
'</td><td class="tdtop">';
4737 $showlinktolayoutlabel = $langs->trans(
"FillPageWithALayout");
4738 $showlinktoailabel = $langs->trans(
"FillPageWithAIContent");
4739 $htmlname =
'content';
4741 include DOL_DOCUMENT_ROOT.
'/core/tpl/formlayoutai.tpl.php';
4747 if ($action ==
'createcontainer') {
4748 print
'<tr id="pageContent"><td class="tdtop">';
4749 if (!$showlinktolayout || !$showlinktoai) {
4750 if (
$conf->browser->layout ==
'phone') {
4751 print $form->textwithpicto(
'', $htmltext, 1,
'help',
'inline-block', 1, 2,
'tooltipsubstitution');
4754 print $form->textwithpicto($langs->trans(
"PreviewPageContent").
' '.
img_help(2, $langs->trans(
"PreviewPageContent")), $htmltext, 1,
'none',
'inline-block', 1, 2,
'tooltipsubstitution');
4759 $doleditor =
new DolEditor(
'content',
GETPOST(
'content',
'none'),
'', 200,
'dolibarr_mailings',
'In',
true,
true,
true, 40,
'90%');
4760 $doleditor->Create();
4767 print $langs->trans(
'DateCreation');
4769 print $form->selectDate($pagedatecreation,
'datecreation', 1, 1, 0,
'', 1, 1);
4775 print $langs->trans(
'Author');
4777 if ($pageauthorid > 0) {
4778 $fuser->fetch($pageauthorid);
4779 print $fuser->getNomUrl(-1);
4781 print
'<span class="opacitymedium">'.$langs->trans(
"Unknown").
'</span>';
4786 print
'<tr class="trpublicauthor hidden"><td>';
4787 print $langs->trans(
'PublicAuthorAlias');
4789 print
'<input type="text" class="flat minwidth300" name="WEBSITE_AUTHORALIAS" value="'.dol_escape_htmltag($pageauthoralias).
'" placeholder="Anonymous">';
4792 print
'<tr><td class="tdhtmlheader tdtop">';
4793 $htmlhelp = $langs->trans(
"EditTheWebSiteForACommonHeader").
'<br><br>';
4794 $htmlhelp .= $langs->trans(
"Example").
' :<br>';
4796 print $form->textwithpicto($langs->transnoentitiesnoconv(
'HtmlHeaderPage'), $htmlhelp, 1,
'help',
'', 0, 2,
'htmlheadertooltip');
4798 $poscursor = array(
'x' =>
GETPOST(
'htmlheader_x'),
'y' =>
GETPOST(
'htmlheader_y'));
4799 $doleditor =
new DolEditor(
'htmlheader', $pagehtmlheader,
'', 120,
'ace',
'In',
true,
false,
'ace', ROWS_3,
'100%', 0, $poscursor);
4800 print $doleditor->Create(1,
'',
true,
'HTML Header',
'html');
4805 print $langs->trans(
'AllowedInFrames');
4809 print
'<input type="checkbox" class="flat" name="WEBSITE_ALLOWED_IN_FRAMES" value="1"'.($pageallowedinframes ?
'checked="checked"' :
'').
'>';
4814 if ($action ==
'createcontainer') {
4815 print
'<div class="center tablecheckboxcreatemanually'.$hiddenmanuallyafterload.
'">';
4817 print
'<input type="submit" class="button small" name="addcontainer" value="'.$langs->trans(
"Create").
'">';
4818 print
'<input class="button button-cancel small" type="submit" name="preview" value="'.$langs->trans(
"Cancel").
'">';
4825 if (!empty(
$conf->use_javascript_ajax)) {
4826 print
'<input type="radio" name="radiocreatefrom" id="checkboxcreatefromfetching" value="checkboxcreatefromfetching"'.(GETPOST(
'radiocreatefrom') ==
'checkboxcreatefromfetching' ?
' checked' :
'').
'> ';
4828 print
'<label for="checkboxcreatefromfetching"><span class="opacitymediumxx">'.$langs->trans(
"CreateByFetchingExternalPage").
'</span></label><br>';
4829 print
'<hr class="tablecheckboxcreatefromfetching'.$hiddenfromfetchingafterload.
'">';
4830 print
'<table class="tableforfield centpercent tablecheckboxcreatefromfetching'.$hiddenfromfetchingafterload.
'">';
4831 print
'<tr><td class="titlefield">';
4832 print $langs->trans(
"URL");
4834 print
info_admin($langs->trans(
"OnlyEditionOfSourceForGrabbedContentFuture"), 0, 0,
'warning');
4835 print
'<input class="flat minwidth500" type="text" name="externalurl" value="'.dol_escape_htmltag(
GETPOST(
'externalurl',
'alpha')).
'" placeholder="https://externalsite/pagetofetch"> ';
4836 print
'<br><input class="flat paddingtop" type="checkbox" name="grabimages" value="1" checked="checked"> '.$langs->trans(
"GrabImagesInto");
4838 print $langs->trans(
"ImagesShouldBeSavedInto").
' ';
4839 $arraygrabimagesinto = array(
'root' => $langs->trans(
"WebsiteRootOfImages"),
'subpage' => $langs->trans(
"SubdirOfPage"));
4840 print $form->selectarray(
'grabimagesinto', $arraygrabimagesinto, GETPOSTISSET(
'grabimagesinto') ?
GETPOST(
'grabimagesinto') :
'root', 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
4843 print
'<input class="button small" style="margin-top: 5px" type="submit" name="fetchexternalurl" value="'.dol_escape_htmltag($langs->trans(
"FetchAndCreate")).
'">';
4844 print
'<input class="button button-cancel small" type="submit" name="preview" value="'.$langs->trans(
"Cancel").
'">';
4850 if ($action ==
'createcontainer') {
4851 print
'<script type="text/javascript">
4852 jQuery(document).ready(function() {
4853 var disableautofillofalias = 0;
4854 var selectedm = \'\';
4855 var selectedf = \'\';
4857 jQuery("#WEBSITE_TITLE").keyup(function() {
4858 if (disableautofillofalias == 0) {
4859 var valnospecial = jQuery("#WEBSITE_TITLE").val();
4860 valnospecial = valnospecial.replace(/[éèê]/g, \'e\').replace(/[à]/g, \'a\').replace(/[ù]/g, \'u\').replace(/[î]/g, \'i\');
4861 valnospecial = valnospecial.replace(/[ç]/g, \'c\').replace(/[ö]/g, \'o\');
4862 valnospecial = valnospecial.replace(/[^\w]/gi, \'-\').toLowerCase();
4863 valnospecial = valnospecial.replace(/\-+/g, \'-\').replace(/\-$/, \'\');
4864 console.log("disableautofillofalias=0 so we replace WEBSITE_TITLE with "+valnospecial);
4865 jQuery("#WEBSITE_PAGENAME").val(valnospecial);
4868 jQuery("#WEBSITE_PAGENAME").keyup(function() {
4869 if (jQuery("#WEBSITE_PAGENAME").val() == \'\') {
4870 disableautofillofalias = 0;
4872 disableautofillofalias = 1;
4875 jQuery("#WEBSITE_PAGENAME").blur(function() {
4876 if (jQuery("#WEBSITE_PAGENAME").val() == \'\') {
4877 disableautofillofalias = 0;
4878 jQuery("#WEBSITE_TITLE").trigger(\'keyup\');
4882 jQuery("#checkboxcreatefromfetching,#checkboxcreatemanually").click(function() {
4883 console.log("we select a method to create a new container "+jQuery("#checkboxcreatefromfetching:checked").val())
4884 jQuery(".tablecheckboxcreatefromfetching").hide();
4885 jQuery(".tablecheckboxcreatemanually").hide();
4886 if (typeof(jQuery("#checkboxcreatefromfetching:checked").val()) != \'undefined\') {
4887 console.log("show create from spider form");
4888 if (selectedf != \'createfromfetching\') {
4889 jQuery(".tablecheckboxcreatefromfetching").show();
4890 selectedf = \'createfromfetching\';
4893 jQuery(".tablecheckboxcreatefromfetching").hide();
4897 if (typeof(jQuery("#checkboxcreatemanually:checked").val()) != \'undefined\') {
4898 console.log("show create from scratch or template form");
4899 if (selectedm != \'createmanually\') {
4900 jQuery(".tablecheckboxcreatemanually").show();
4901 selectedm = \'createmanually\';
4904 jQuery(".tablecheckboxcreatemanually").hide();
4923if ($action ==
'preview') {
4927if ($action ==
'editfile' || $action ==
'file_manager' || $action ==
'convertimgwebp' || $action ==
'confirmconvertimgwebp') {
4928 print
'<!-- Edit Media -->'.
"\n";
4929 print
'<div class="fiche"><br>';
4932 $formalreadyopen = 2;
4934 $url = DOL_URL_ROOT.
'/website/index.php';
4936 include DOL_DOCUMENT_ROOT.
'/core/tpl/filemanager.tpl.php';
4941if ($action ==
'editmenu') {
4942 print
'<!-- Edit Menu -->'.
"\n";
4943 print
'<div class="center">'.$langs->trans(
"FeatureNotYetAvailable").
'</center>';
4946if ($action ==
'editsource') {
4949 $contentforedit =
'';
4953 $contentforedit .= $objectpage->content;
4955 $maxheightwin = 480;
4956 if (isset($_SESSION[
"dol_screenheight"])) {
4957 if ($_SESSION[
"dol_screenheight"] > 680) {
4958 $maxheightwin = $_SESSION[
"dol_screenheight"] - 400;
4960 if ($_SESSION[
"dol_screenheight"] > 800) {
4961 $maxheightwin = $_SESSION[
"dol_screenheight"] - 490;
4965 $poscursor = array(
'x' =>
GETPOST(
'PAGE_CONTENT_x'),
'y' =>
GETPOST(
'PAGE_CONTENT_y'));
4966 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
4967 $doleditor =
new DolEditor(
'PAGE_CONTENT', $contentforedit,
'', $maxheightwin,
'Full',
'',
true,
true,
'ace', ROWS_5,
'40%', 0, $poscursor);
4968 $doleditor->Create(0,
'',
false,
'HTML Source',
'php');
4971if ($action ==
'editcontent') {
4974 $contentforedit =
'';
4978 $contentforedit .= $objectpage->content;
4983 $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);
4985 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
4986 $poscursor = array(
'x' =>
GETPOST(
'PAGE_CONTENT_x'),
'y' =>
GETPOST(
'PAGE_CONTENT_y'));
4987 $doleditor =
new DolEditor(
'PAGE_CONTENT', $contentforedit,
'', 500,
'Full',
'',
true,
true,
true, ROWS_5,
'90%', 0, $poscursor);
4988 $doleditor->Create(0,
'',
false);
4995if ($mode ==
'replacesite' || $massaction ==
'replace') {
4996 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4997 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4998 print
'<input type="hidden" name="action" value="replacesiteconfirm">';
4999 print
'<input type="hidden" name="mode" value="replacesite">';
5000 print
'<input type="hidden" name="website" value="'.$website->ref.
'">';
5003 print
'<!-- Search page and replace string -->'.
"\n";
5004 print
'<div class="fiche"><br>';
5006 print
load_fiche_titre($langs->trans(
"ReplaceWebsiteContent"),
'',
'search');
5008 print
'<div class="fichecenter"><div class="fichehalfleft">';
5010 print
'<div class="tagtable">';
5012 print
'<div class="tagtr">';
5013 print
'<div class="tagtd paddingrightonly opacitymedium">';
5014 print $langs->trans(
"SearchReplaceInto");
5016 print
'<div class="tagtd">';
5017 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>';
5018 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>';
5019 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>';
5023 print
'<div class="tagtr">';
5024 print
'<div class="tagtd paddingrightonly opacitymedium" style="padding-right: 10px !important">';
5025 print $langs->trans(
"SearchString");
5027 print
'<div class="tagtd">';
5028 print
'<input type="text" name="searchstring" value="'.dol_escape_htmltag($searchkey, 0, 0,
'', 1).
'" autofocus>';
5034 print
'</div><div class="fichehalfleft">';
5036 print
'<div class="tagtable">';
5038 print
'<div class="tagtr">';
5039 print
'<div class="tagtd paddingrightonly opacitymedium tdoverflowmax100onsmartphone" style="padding-right: 10px !important">';
5040 print $langs->trans(
"WEBSITE_TYPE_CONTAINER");
5042 print
'<div class="tagtd">';
5043 print
img_picto(
'',
'object_technic',
'class="paddingrightonly"').
' ';
5044 print $formwebsite->selectTypeOfContainer(
'optioncontainertype', (
GETPOST(
'optioncontainertype',
'alpha') ?
GETPOST(
'optioncontainertype',
'alpha') :
''), 1,
'', 1,
'minwidth125 maxwidth400 widthcentpercentminusx');
5048 print
'<div class="tagtr">';
5049 print
'<div class="tagtd paddingrightonly opacitymedium tdoverflowmax100onsmartphone" style="padding-right: 10px !important">';
5050 print $langs->trans(
"Language");
5052 print
'<div class="tagtd">';
5053 print
img_picto(
'',
'language',
'class="paddingrightonly"').
' '.$formadmin->select_language(GETPOSTISSET(
'optionlanguage') ?
GETPOST(
'optionlanguage') :
'',
'optionlanguage', 0, array(),
'1', 0, 0,
'minwidth125 maxwidth400 widthcentpercentminusx', 2, 0, 0, array(), 1);
5058 if (isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire')) {
5059 print
'<div class="tagtr">';
5060 print
'<div class="tagtd paddingrightonly marginrightonly opacitymedium tdoverflowmax100onsmartphone" style="padding-right: 10px !important">';
5061 print $langs->trans(
"Category");
5063 print
'<div class="tagtd">';
5064 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');
5065 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
5073 print
'<input type="submit" class="button margintoponly" name="buttonreplacesitesearch" value="'.dol_escape_htmltag($langs->trans(
"Search")).
'">';
5075 print
'</div></div>';
5077 if ($mode ==
'replacesite') {
5078 print
'<!-- List of search result -->'.
"\n";
5079 print
'<div class="rowsearchresult clearboth">';
5084 if ($listofpages[
'code'] ==
'OK') {
5085 $arrayofselected = is_array($toselect) ? $toselect : array();
5087 $nbtotalofrecords = count($listofpages[
'list']);
5089 $permissiontodelete = $user->hasRight(
'website',
'delete');
5092 $arrayofmassactions = array();
5093 if ($user->hasRight(
'website',
'writephp') && $searchkey) {
5094 $arrayofmassactions[
'replace'] =
img_picto(
'',
'replacement',
'class="pictofixedwidth"').$langs->trans(
"Replace");
5096 if ($user->hasRight(
'website',
'write')) {
5097 $arrayofmassactions[
'setcategory'] =
img_picto(
'',
'category',
'class="pictofixedwidth"').$langs->trans(
"ClassifyInCategory");
5099 if ($user->hasRight(
'website',
'write')) {
5100 $arrayofmassactions[
'delcategory'] =
img_picto(
'',
'category',
'class="pictofixedwidth"').$langs->trans(
"RemoveCategory");
5102 if ($permissiontodelete) {
5103 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
5105 if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete'))) {
5106 $arrayofmassactions = array();
5109 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
5110 $massactionbutton .=
'<div class="massactionother massactionreplace hidden">';
5111 $massactionbutton .= $langs->trans(
"ReplaceString");
5112 $massactionbutton .=
' <input type="text" name="replacestring" value="'.dol_escape_htmltag(
GETPOST(
'replacestring',
'none')).
'">';
5113 $massactionbutton .=
'</div>';
5114 $massactionbutton .=
'<div class="massactionother massactionsetcategory massactiondelcategory hidden">';
5115 $massactionbutton .=
img_picto(
'',
'category',
'class="pictofixedwidth"');
5116 $massactionbutton .= $form->select_all_categories(Categorie::TYPE_WEBSITE_PAGE, GETPOSTISSET(
'setcategory') ?
GETPOST(
'setcategory') :
'',
'setcategory', 64, 0, 0, 0,
'minwidth300 alignstart');
5117 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
5119 $massactionbutton .=
'</div>';
5121 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
5124 $selectedfields =
'';
5125 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
5127 print_barre_liste($langs->trans(
"Results"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'generic', 0,
'',
'', $limit, 1, 1, 1);
5129 $topicmail =
"WebsitePageRef";
5130 $modelmail =
"websitepage_send";
5132 $trackid =
'wsp'.$object->id;
5133 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
5135 $param =
'mode=replacesite&website='.urlencode($website->ref);
5136 $param .=
'&searchstring='.urlencode($searchkey);
5137 if (
GETPOST(
'optioncontent')) {
5138 $param .=
'&optioncontent=content';
5141 $param .=
'&optionmeta=meta';
5143 if (
GETPOST(
'optionsitefiles')) {
5144 $param .=
'&optionsitefiles=optionsitefiles';
5146 if (
GETPOST(
'optioncontainertype')) {
5147 $param .=
'&optioncontainertype='.GETPOST(
'optioncontainertype',
'aZ09');
5149 if (
GETPOST(
'optionlanguage')) {
5150 $param .=
'&optionlanguage='.GETPOST(
'optionlanguage',
'aZ09');
5152 if (
GETPOST(
'optioncategory')) {
5153 $param .=
'&optioncategory='.GETPOST(
'optioncategory',
'aZ09');
5156 print
'<div class="div-table-responsive-no-min">';
5157 print
'<table class="noborder centpercent">';
5158 print
'<tr class="liste_titre">';
5161 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
5163 print
getTitleFieldOfList(
"Type", 0, $_SERVER[
'PHP_SELF'],
'type_container',
'', $param,
'', $sortfield, $sortorder,
'').
"\n";
5164 print
getTitleFieldOfList(
"Page", 0, $_SERVER[
'PHP_SELF'],
'pageurl',
'', $param,
'', $sortfield, $sortorder,
'').
"\n";
5165 print
getTitleFieldOfList(
"Language", 0, $_SERVER[
'PHP_SELF'],
'lang',
'', $param,
'', $sortfield, $sortorder,
'center ').
"\n";
5166 print
getTitleFieldOfList(
"Categories", 0, $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'center ').
"\n";
5168 print
getTitleFieldOfList(
"UserCreation", 0, $_SERVER[
'PHP_SELF'],
'fk_user_creat',
'', $param,
'', $sortfield, $sortorder,
'').
"\n";
5169 print
getTitleFieldOfList(
"DateCreation", 0, $_SERVER[
'PHP_SELF'],
'date_creation',
'', $param,
'', $sortfield, $sortorder,
'center ').
"\n";
5170 print
getTitleFieldOfList(
"DateLastModification", 0, $_SERVER[
'PHP_SELF'],
'tms',
'', $param,
'', $sortfield, $sortorder,
'center ').
"\n";
5174 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
5178 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
5183 foreach ($listofpages[
'list'] as $answerrecord) {
5184 if (is_object($answerrecord) && get_class($answerrecord) ==
'WebsitePage') {
5185 $param =
'?mode=replacesite';
5186 $param .=
'&websiteid='.$website->id;
5187 $param .=
'&optioncontent='.GETPOST(
'optioncontent',
'aZ09');
5188 $param .=
'&optionmeta='.GETPOST(
'optionmeta',
'aZ09');
5189 $param .=
'&optionsitefiles='.GETPOST(
'optionsitefiles',
'aZ09');
5190 $param .=
'&optioncontainertype='.GETPOST(
'optioncontainertype',
'aZ09');
5191 $param .=
'&optionlanguage='.GETPOST(
'optionlanguage',
'aZ09');
5192 $param .=
'&optioncategory='.GETPOST(
'optioncategory',
'aZ09');
5193 $param .=
'&searchstring='.urlencode($searchkey);
5199 print
'<td class="nowrap center">';
5201 print
'<!-- Status of page -->'.
"\n";
5202 if ($massactionbutton || $massaction) {
5204 if (in_array($answerrecord->id, $arrayofselected)) {
5207 print
'<input id="'.$answerrecord->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$answerrecord->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
5213 print
'<td class="nowraponall">';
5215 if (!empty(
$conf->cache[
'type_of_container'][$answerrecord->type_container])) {
5216 print $langs->trans(
$conf->cache[
'type_of_container'][$answerrecord->type_container]);
5218 print $langs->trans($answerrecord->type_container);
5223 $titleofpage = ($answerrecord->title ? $answerrecord->title : $langs->trans(
"NoTitle"));
5224 print
'<td class="tdoverflowmax300" title="'.dol_escape_htmltag($titleofpage).
'">';
5225 print $answerrecord->getNomUrl(1);
5226 print
' <span class="opacitymedium">('.dol_escape_htmltag($titleofpage).
')</span>';
5230 print
'<span class="opacitymedium">'.dol_escape_htmltag($answerrecord->description ? $answerrecord->description : $langs->trans(
"NoDescription")).
'</span>';
5234 print
'<td class="center">';
5239 print
'<td class="center">';
5240 if (isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire')) {
5242 $existing = $c->containing($answerrecord->id, Categorie::TYPE_WEBSITE_PAGE,
'object');
5243 if (is_array($existing)) {
5244 foreach ($existing as $tmpcategory) {
5246 print
img_object($langs->trans(
"Category").
' : '.$tmpcategory->label,
'category',
'style="padding-left: 2px; padding-right: 2px; color: #'.($tmpcategory->color !=
'' ? $tmpcategory->color :
'888').
'"');
5254 print
'<td class="center nowraponall">';
5256 $characterMap =
'áàéèëíóúüñùç0123456789';
5257 $nbofwords = str_word_count($textwithouthtml, 0, $characterMap);
5259 print $nbofwords.
' '.$langs->trans(
"words");
5260 $totalnbwords += $nbofwords;
5265 print
'<td class="tdoverflowmax125">';
5266 if (!empty($answerrecord->fk_user_creat)) {
5267 if (empty(
$conf->cache[
'user'][$answerrecord->fk_user_creat])) {
5268 $tmpuser =
new User($db);
5269 $tmpuser->fetch($answerrecord->fk_user_creat);
5270 $conf->cache[
'user'][$answerrecord->fk_user_creat] = $tmpuser;
5272 $tmpuser =
$conf->cache[
'user'][$answerrecord->fk_user_creat];
5274 print $tmpuser->getNomUrl(-1,
'', 0, 0, 0, 0,
'login');
5279 print
'<td class="center nowraponall">';
5284 print
'<td class="center nowraponall">';
5285 print
dol_print_date($answerrecord->date_modification,
'dayhour');
5289 print
'<td class="tdwebsitesearchresult right nowraponall">';
5291 $urltoedithtmlsource = $_SERVER[
"PHP_SELF"].
'?action=editmeta&token='.
newToken().
'&websiteid='.$website->id.
'&pageid='.$answerrecord->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].$param);
5292 if (!$user->hasRight(
'website',
'write')) {
5293 $disabled =
' disabled';
5294 $urltoedithtmlsource =
'';
5296 print
'<a class="editfielda marginleftonly marginrightonly '.$disabled.
'" href="'.$urltoedithtmlsource.
'" title="'.$langs->trans(
"EditPageMeta").
'">'.
img_picto($langs->trans(
"EditPageMeta"),
'pencil-ruler').
'</a>';
5299 $urltoedithtmlsource = $_SERVER[
"PHP_SELF"].
'?action=editsource&token='.
newToken().
'&websiteid='.$website->id.
'&pageid='.$answerrecord->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].$param);
5300 if (!$user->hasRight(
'website',
'write')) {
5301 $disabled =
' disabled';
5302 $urltoedithtmlsource =
'';
5304 print
'<a class="editfielda marginleftonly marginrightonly '.$disabled.
'" href="'.$urltoedithtmlsource.
'" title="'.$langs->trans(
"EditHTMLSource").
'">'.
img_picto($langs->trans(
"EditHTMLSource"),
'edit').
'</a>';
5306 print
'<span class="marginleftonly marginrightonly"></span>';
5307 print
ajax_object_onoff($answerrecord,
'status',
'status',
'Enabled',
'Disabled', array(),
'valignmiddle inline-block');
5313 print
'<td class="nowrap center">';
5315 print
'<!-- Status of page -->'.
"\n";
5316 if ($massactionbutton || $massaction) {
5318 if (in_array($answerrecord->id, $arrayofselected)) {
5321 print
'<input id="'.$answerrecord->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$answerrecord->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
5329 '@phan-var-force array{type:string} $answerrecord';
5330 $param =
'?mode=replacesite';
5331 $param .=
'&websiteid='.$website->id;
5332 $param .=
'&optioncontent='.GETPOST(
'optioncontent',
'aZ09');
5333 $param .=
'&optionmeta='.GETPOST(
'optionmeta',
'aZ09');
5334 $param .=
'&optionsitefiles='.GETPOST(
'optionsitefiles',
'aZ09');
5335 $param .=
'&optioncontainertype='.GETPOST(
'optioncontainertype',
'aZ09');
5336 $param .=
'&optionlanguage='.GETPOST(
'optionlanguage',
'aZ09');
5337 $param .=
'&optioncategory='.GETPOST(
'optioncategory',
'aZ09');
5338 $param .=
'&searchstring='.urlencode($searchkey);
5344 print
'<td class="nowrap center">';
5350 $translateofrecordtype = array(
5351 'website_csscontent' =>
'WEBSITE_CSS_INLINE',
5352 'website_jscontent' =>
'WEBSITE_JS_INLINE',
5353 'website_robotcontent' =>
'WEBSITE_ROBOT',
5354 'website_htmlheadercontent' =>
'WEBSITE_HTML_HEADER',
5355 'website_htaccess' =>
'WEBSITE_HTACCESS',
5356 'website_readme' =>
'WEBSITE_README',
5357 'website_manifestjson' =>
'WEBSITE_MANIFEST_JSON'
5359 print
'<span class="opacitymedium">';
5360 if (!empty($translateofrecordtype[$answerrecord[
'type']])) {
5361 print $langs->trans($translateofrecordtype[$answerrecord[
'type']]);
5363 print $answerrecord[
'type'];
5370 $backtopageurl = $_SERVER[
"PHP_SELF"].$param;
5371 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=editcss&token='.
newToken().
'&website='.urlencode($website->ref).
'&backtopage='.urlencode($backtopageurl).
'">'.$langs->trans(
"EditCss").
'</a>';
5393 print
'<td class="center nowraponall">';
5403 print
'<td class="nowrap center">';
5411 if (count($listofpages[
'list']) >= 2) {
5413 print
'<tr class="lite_titre">';
5417 print
'<td class="nowrap center">';
5423 print $langs->trans(
"Total");
5439 print
'<td class="center nowraponall">';
5440 print $totalnbwords.
' '.$langs->trans(
"words");
5459 print
'<td class="nowrap center">';
5470 print
'<div class="warning">'.$listofpages[
'message'].
'</div>';
5479if ((empty($action) || $action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone') && !in_array($mode, array(
'replacesite'))) {
5480 if ($pageid > 0 && $atleastonepage) {
5486 $objectpage->fetch($pageid);
5488 $jscontent = @file_get_contents($filejs);
5490 $out =
'<!-- Page content '.$filetpl.
' : Div with (Htmlheader/Style of page from database + CSS Of website from file + Page content from database or by include if WEBSITE_SUBCONTAINERSINLINE is on) -->'.
"\n";
5499 $out .=
"\n<html><head>\n";
5500 $out .=
"<!-- htmlheader/style of page from database -->\n";
5503 $out .=
"<!-- htmlheader/style of website from files -->\n";
5521 $out .=
"</head>\n";
5525 $out .=
'<div id="websitecontentundertopmenu" class="websitecontentundertopmenu boostrap-iso">'.
"\n";
5529 $out .=
'<!-- style of website from file -->'.
"\n";
5530 $out .=
'<style scoped>'.
"\n";
5532 $tmpout .=
'/* Include website CSS file */'.
"\n";
5536 $csscontent = ob_get_contents();
5539 $tmpout .=
'/* Include style from the HTML header of page */'.
"\n";
5541 $tmp = preg_split(
'(<style[^>]*>|</style>)', $objectpage->htmlheader);
5542 $tmpstyleinheader =
'';
5544 foreach ($tmp as $valtmp) {
5547 $tmpstyleinheader .= $valtmp.
"\n";
5550 $tmpout .= $tmpstyleinheader.
"\n";
5552 $tmpout = preg_replace(
'/}[\s\n]*body\s*{[^}]+}/ims',
'}', $tmpout);
5554 $out .=
'</style>'.
"\n";
5561 $out .=
'<div id="divbodywebsite" class="bodywebsite bodywebpage-'.$objectpage->ref.
'">'.
"\n";
5563 $newcontent = $objectpage->content;
5570 $filephp = $filetpl;
5573 $savsessionname = session_name();
5574 $savsessionid = $_COOKIE[$savsessionname];
5575 $_COOKIE[$savsessionname] =
'obfuscatedcookie';
5579 $res = include $filephp;
5581 print
"ERROR: Failed to include file '".$filephp.
"'. Try to edit and re-save page with this ID.";
5584 print $e->getMessage();
5586 $newcontent = ob_get_contents();
5590 $_COOKIE[$savsessionname] = $savsessionid;
5596 $newcontent = preg_replace(
'/(div|section|header|main|footer)(\s[^>]*)contenteditable="true"/',
'\1\2', $newcontent);
5605 $out .=
'</div> <!-- End div id=websitecontentundertopmenu -->';
5611 $out .=
"\n</body></html>\n";
5613 $out .=
"\n".
'<!-- End page content '.$filetpl.
' -->'.
"\n\n";
5637 if (empty($websitekey) || $websitekey ==
'-1') {
5638 print
'<br><br><div class="center previewnotyetavailable"><span class="">'.$langs->trans(
"NoWebSiteCreateOneFirst").
'</span></div><br><br><br>';
5639 print
'<div class="center"><div class="logo_setup"></div></div>';
5641 print
'<br><br><div class="center previewnotyetavailable"><span class="">'.$langs->trans(
"PreviewOfSiteNotYetAvailable",
$object->ref).
'</span></div><br><br><br>';
5642 print
'<div class="center"><div class="logo_setup"></div></div>';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input=array(), $morecss='', $htmlname='', $forcenojs=0, $moreparam='')
On/off button to change a property status of an object This uses the ajax service objectonoff....
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Class to manage categories.
Class to manage a WYSIWYG editor.
lessphp v0.8.0 http://leafo.net/lessphp
Class to manage Dolibarr users.
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0, $level=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories)
dol_add_file_process($upload_dir, $allowoverwrite=0, $updatesessionordb=0, $varfiles='addedfile', $savingdocmask='', $link=null, $trackid='', $generatethumbs=1, $object=null, $forceFullTestIndexation='')
Get and save an upload file (for example after submitting a new file a mail form).
dol_is_file($pathoffile)
Return if path is a file.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_help($usehelpcursor=1, $usealttitle=1)
Show help logo with cursor "?".
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $disabled='', $morecss='classlink button bordertransp', $jsonopen='', $backtopagejsfields='', $accesskey='')
Return HTML code to output a button to open a dialog popup box.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
dolButtonToOpenExportDialog($name, $label, $buttonstring, $exportSiteName, $overwriteGitUrl, $website)
Create a dialog with two buttons for export and overwrite of a website.
dolChmod($filepath, $newmask='')
Change mod of a file.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
ajax_autoselect($htmlname, $addlink='', $textonlink='Link')
Make content of an input box selected when we click into input field.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
newToken()
Return the value of token currently saved into session with name 'newtoken'.
img_previous($titlealt='default', $moreatt='')
Show previous logo.
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_next($titlealt='default', $moreatt='')
Show next logo.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
getDomainFromURL($url, $mode=0)
Function get second level domain name.
getRootURLFromURL($url)
Function root url from a long url For example: https://www.abc.mydomain.com/dir/page....
getURLContent($url, $postorget='GET', $param='', $followlocation=1, $addheaders=array(), $allowedschemes=array('http', 'https'), $localurl=0, $ssl_verifypeer=-1)
Function to get a content from an URL (use proxy if proxy defined).
removeHtmlComment($content)
Function to remove comments into HTML content.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
$conf db name
Only used if Module[ID]Name translation string is not found.
getMaxFileSizeArray()
Return the max allowed for file upload.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
dolSaveMasterFile($filemaster)
Save content of a page on disk.
showWebsiteTemplates(Website $website)
Show list of themes.
dolSaveLicense($file, $content)
Save content of a page on disk.
checkPHPCode(&$phpfullcodestringold, &$phpfullcodestring)
Check a new string containing only php code (including <php tag)
dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent)
Save content of a page on disk.
dolSaveReadme($file, $content)
Save content of a page on disk.
dolSaveManifestJson($file, $content)
Save content of a page on disk.
dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper, $object=null)
Save content of the index.php and/or the wrapper.php page.
dolSavePageAlias($filealias, $object, $objectpage)
Save an alias page on disk (A page that include the reference page).
dolSaveHtaccessFile($filehtaccess, $htaccess)
Save content of a page on disk.
dolSaveJsFile($filejs, $jscontent)
Save content of a page on disk.
dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage, $backupold=0)
Save content of a page on disk (page name is generally ID_of_page.php).
dolSaveCssFile($filecss, $csscontent)
Save content of a page on disk.
dolSaveRobotFile($filerobot, $robotcontent)
Save content of a page on disk.
getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modifylinks=0, $grabimages=1, $grabimagesinto='subpage')
Download all images found into an external URL.
dolStripPhpCode($str, $replacewith='')
Remove PHP code part from a string.
dolWebsiteReplacementOfLinks($website, $content, $removephppart=0, $contenttype='html', $containerid=0)
Convert a page content to have correct links (based on DOL_URL_ROOT) into an html content.
getPagesFromSearchCriterias($type, $algo, $searchstring, $max=25, $sortfield='date_creation', $sortorder='DESC', $langcode='', $otherfilters=[], $status=1)
Return list of containers object that match a criteria.
dolKeepOnlyPhpCode($str)
Keep only PHP code part from a HTML string page.