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 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
GETPOST(
'website')).
'&pageid='.
GETPOSTINT(
'pageid'));
462if ($action ==
'unseteditinline') {
464 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
GETPOST(
'website')).
'&pageid='.
GETPOSTINT(
'pageid'));
467if ($action ==
'setshowsubcontainers') {
470 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
GETPOST(
'website')).
'&pageid='.
GETPOSTINT(
'pageid'));
473if ($action ==
'unsetshowsubcontainers') {
475 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
GETPOST(
'website')).
'&pageid='.
GETPOSTINT(
'pageid'));
479if ($massaction ==
'replace' &&
GETPOST(
'confirmmassaction',
'alpha') && !$searchkey && $usercanedit) {
480 $mode =
'replacesite';
481 $action =
'replacesite';
485if ($action ==
'deletetemplate' && $usercanedit) {
486 $dirthemes = array(
'/doctemplates/websites');
487 if (!empty(
$conf->modules_parts[
'websitetemplates'])) {
488 foreach (
$conf->modules_parts[
'websitetemplates'] as $reldir) {
489 $dirthemes = array_merge($dirthemes, (array) ($reldir.
'doctemplates/websites'));
492 $dirthemes = array_unique($dirthemes);
496 $mode =
'importsite';
497 $action =
'importsite';
499 if (count($dirthemes)) {
501 foreach ($dirthemes as $dir) {
503 $dirtheme = DOL_DATA_ROOT.$dir;
504 if (is_dir($dirtheme)) {
505 $templateuserfile =
GETPOST(
'templateuserfile');
506 $imguserfile = preg_replace(
'/\.zip$/',
'', $templateuserfile).
'.jpg';
515if ($massaction ==
'setcategory' &&
GETPOST(
'confirmmassaction',
'alpha') && $usercanedit) {
522 if ($categoryid > 0) {
525 $category->fetch($categoryid);
527 foreach ($toselect as $tmpid) {
528 $tmpwebsitepage->id = $tmpid;
529 $result = $category->add_type($tmpwebsitepage,
'website_page');
530 if ($result < 0 && $result != -3) {
544 setEventMessages($langs->trans(
"RecordsModified", $nbupdate),
null,
'mesgs');
550 $listofpages =
getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters, -1);
554if ($massaction ==
'delcategory' &&
GETPOST(
'confirmmassaction',
'alpha') && $usercanedit) {
561 if ($categoryid > 0) {
564 $category->fetch($categoryid);
566 foreach ($toselect as $tmpid) {
567 $tmpwebsitepage->id = $tmpid;
568 $result = $category->del_type($tmpwebsitepage,
'website_page');
569 if ($result < 0 && $result != -3) {
583 setEventMessages($langs->trans(
"RecordsModified", $nbupdate),
null,
'mesgs');
589 $listofpages =
getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters, -1);
593if ($massaction ==
'replace' &&
GETPOST(
'confirmmassaction',
'alpha') && $usercanedit) {
594 $replacestring =
GETPOST(
'replacestring',
'restricthtmlallowunvalid');
596 $dolibarrdataroot = preg_replace(
'/([\\/]+)$/i',
'', DOL_DATA_ROOT);
597 $allowimportsite =
true;
598 if (
dol_is_file($dolibarrdataroot.
'/installmodules.lock')) {
599 $allowimportsite =
false;
602 if (!$allowimportsite) {
606 $message = $langs->trans(
'InstallModuleFromWebHasBeenDisabledContactUs');
609 $message = $langs->trans(
"InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.
'/installmodules.lock');
612 } elseif (!$user->hasRight(
'website',
'writephp')) {
614 } elseif (!$replacestring) {
619 foreach ($toselect as $keyselected) {
620 $objectpage = $listofpages[
'list'][$keyselected];
621 if ($objectpage->pageurl) {
622 dol_syslog(
"Replace string into page ".$objectpage->pageurl);
624 if (
GETPOST(
'optioncontent',
'aZ09')) {
625 $objectpage->content = str_replace($searchkey, $replacestring, $objectpage->content);
627 if (
GETPOST(
'optionmeta',
'aZ09')) {
628 $objectpage->title = str_replace($searchkey, $replacestring, $objectpage->title);
629 $objectpage->description = str_replace($searchkey, $replacestring, $objectpage->description);
630 $objectpage->keywords = str_replace($searchkey, $replacestring, $objectpage->keywords);
633 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
634 $filetpl = $pathofwebsite.
'/page'.$objectpage->id.
'.tpl.php';
639 setEventMessages(
'Failed to write file '.basename($filealias),
null,
'errors');
647 $objectpage->update($user);
651 $action =
'createcontainer';
657 if ($nbreplacement > 0) {
658 setEventMessages($langs->trans(
"ReplacementDoneInXPages", $nbreplacement),
null,
'mesgs');
661 $containertype =
GETPOST(
'optioncontainertype',
'aZ09') !=
'-1' ?
GETPOST(
'optioncontainertype',
'aZ09') :
'';
662 $langcode =
GETPOST(
'optionlanguage',
'aZ09');
663 $otherfilters = array();
665 $otherfilters[
'category'] =
GETPOSTINT(
'optioncategory');
669 $listofpages =
getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters);
699if ($action ==
'addsite' && $usercanedit) {
702 if (
GETPOST(
'virtualhost',
'alpha') && !preg_match(
'/^http/',
GETPOST(
'virtualhost',
'alpha'))) {
704 setEventMessages($langs->trans(
'ErrorURLMustStartWithHttp', $langs->transnoentitiesnoconv(
"VirtualHost")),
null,
'errors');
707 if (!$error && !
GETPOST(
'WEBSITE_REF',
'alpha')) {
709 $langs->load(
"errors");
710 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->transnoentities(
"WebsiteName")),
null,
'errors');
712 if (!$error && !preg_match(
'/^[a-z0-9_\-\.]+$/i',
GETPOST(
'WEBSITE_REF',
'alpha'))) {
714 $langs->load(
"errors");
715 setEventMessages($langs->transnoentities(
"ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities(
"Ref")),
null,
'errors');
719 $arrayotherlang = explode(
',',
GETPOST(
'WEBSITE_OTHERLANG',
'alphanohtml'));
720 foreach ($arrayotherlang as $key => $val) {
722 if (empty(trim($val))) {
725 $arrayotherlang[$key] = substr(trim($val), 0, 2);
729 $tmpobject->ref =
GETPOST(
'WEBSITE_REF',
'alpha');
730 $tmpobject->description =
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml');
731 $tmpobject->lang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
732 $tmpobject->otherlang = implode(
',', $arrayotherlang);
733 $tmpobject->virtualhost =
GETPOST(
'virtualhost',
'alpha');
735 $result = $tmpobject->create($user);
739 } elseif ($result < 0) {
750 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$tmpobject->ref);
754 $action =
'createsite';
763'@phan-var-force int $error';
766if ($action ==
'addcontainer' && $usercanedit) {
771 $objectpage->fk_website =
$object->id;
773 if (GETPOSTISSET(
'fetchexternalurl')) {
774 $urltograb =
GETPOST(
'externalurl',
'alpha');
775 $grabimages =
GETPOSTINT(
'grabimages') ? 1 : 0;
776 $grabimagesinto =
GETPOST(
'grabimagesinto',
'alpha');
778 include_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
781 if (empty($urltograb)) {
783 $langs->load(
"errors");
784 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"URL")),
null,
'errors');
785 $action =
'createcontainer';
786 } elseif (!preg_match(
'/^http/', $urltograb)) {
788 $langs->load(
"errors");
789 setEventMessages(
'Error URL must start with http:// or https://',
null,
'errors');
790 $action =
'createcontainer';
797 $urltograbwithoutdomainandparam = preg_replace(
'/^https?:\/\/[^\/]+\/?/i',
'', $urltograb);
799 $urltograbwithoutdomainandparam = preg_replace(
'/\?.*$/',
'', $urltograbwithoutdomainandparam);
800 if (empty($urltograbwithoutdomainandparam) && !preg_match(
'/\/$/', $urltograb)) {
803 $pageurl =
dol_sanitizeFileName(preg_replace(
'/[\/\.]/',
'-', preg_replace(
'/\/+$/',
'', $urltograbwithoutdomainandparam)));
805 $urltograbdirwithoutslash = dirname($urltograb.
'.');
814 $result = $tmpwebsitepage->fetch(0,
$object->id, $pageurl);
816 setEventMessages($langs->trans(
"AliasPageAlreadyExists", $pageurl),
null,
'errors');
818 $action =
'createcontainer';
823 $tmp =
getURLContent($urltograb,
'GET',
'', 1, array(), array(
'http',
'https'), 0);
826 if (!empty($tmp[
'content_type']) && preg_match(
'/ISO-8859-1/', $tmp[
'content_type'])) {
827 if (function_exists(
'mb_check_encoding')) {
828 if (mb_check_encoding($tmp[
'content'],
'ISO-8859-1')) {
830 $tmp[
'content'] = mb_convert_encoding($tmp[
'content'],
'ISO-8859-1',
'UTF-8');
833 setEventMessages(
'Error getting '.$urltograb.
': content seems non valid ISO-8859-1',
null,
'errors');
834 $action =
'createcontainer';
838 setEventMessages(
'Error getting '.$urltograb.
': content seems ISO-8859-1 but functions to convert into UTF-8 are not available in your PHP',
null,
'errors');
839 $action =
'createcontainer';
842 if (empty($tmp[
'content_type']) || (!empty($tmp[
'content_type']) && preg_match(
'/UTF-8/', $tmp[
'content_type']))) {
843 if (function_exists(
'mb_check_encoding')) {
844 if (mb_check_encoding($tmp[
'content'],
'UTF-8')) {
848 setEventMessages(
'Error getting '.$urltograb.
': content seems not a valid UTF-8',
null,
'errors');
849 $action =
'createcontainer';
854 if ($tmp[
'curl_error_no']) {
856 setEventMessages(
'Error getting '.$urltograb.
': '.$tmp[
'curl_error_msg'],
null,
'errors');
857 $action =
'createcontainer';
858 } elseif ($tmp[
'http_code'] !=
'200') {
860 setEventMessages(
'Error getting '.$urltograb.
': '.$tmp[
'http_code'],
null,
'errors');
861 $action =
'createcontainer';
870 setEventMessages(
'Error getting '.$urltograb.
': file that include PHP content is not allowed',
null,
'errors');
871 $action =
'createcontainer';
878 preg_match(
'/<head>(.*)<\/head>/ims', $tmp[
'content'], $regs);
881 $objectpage->type_container =
'page';
882 $objectpage->pageurl = $pageurl;
883 if (empty($objectpage->pageurl)) {
885 $objectpage->pageurl = $tmpdomain.
'-home';
888 $objectpage->aliasalt =
'';
890 if (preg_match(
'/^(\d+)\-/', basename($urltograb), $regs)) {
891 $objectpage->aliasalt = $regs[1];
895 if (preg_match(
'/<title>(.*)<\/title>/ims', $head, $regtmp)) {
896 $objectpage->title = $regtmp[1];
898 if (preg_match(
'/<meta name="title"[^"]+content="([^"]+)"/ims', $head, $regtmp)) {
899 if (empty($objectpage->title)) {
900 $objectpage->title = $regtmp[1];
903 if (preg_match(
'/<meta name="description"[^"]+content="([^"]+)"/ims', $head, $regtmp)) {
904 $objectpage->description = $regtmp[1];
906 if (preg_match(
'/<meta name="keywords"[^"]+content="([^"]+)"/ims', $head, $regtmp)) {
907 $objectpage->keywords = $regtmp[1];
909 if (preg_match(
'/<html\s+lang="([^"]+)"/ims', $tmp[
'content'], $regtmp)) {
910 $tmplang = explode(
'-', $regtmp[1]);
911 $objectpage->lang = $tmplang[0].($tmplang[1] ?
'_'.strtoupper($tmplang[1]) :
'');
914 $tmp[
'content'] = preg_replace(
'/\s*<meta name="generator"[^"]+content="([^"]+)"\s*\/?>/ims',
'', $tmp[
'content']);
916 $objectpage->content = $tmp[
'content'];
917 $objectpage->content = preg_replace(
'/^.*<body(\s[^>]*)*>/ims',
'', $objectpage->content);
918 $objectpage->content = preg_replace(
'/<\/body(\s[^>]*)*>.*$/ims',
'', $objectpage->content);
926 $objectpage->htmlheader = $tmp[
'content'];
927 $objectpage->htmlheader = preg_replace(
'/^.*<head(\s[^>]*)*>/ims',
'', $objectpage->htmlheader);
928 $objectpage->htmlheader = preg_replace(
'/<\/head(\s[^>]*)*>.*$/ims',
'', $objectpage->htmlheader);
929 $objectpage->htmlheader = preg_replace(
'/<base(\s[^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
930 $objectpage->htmlheader = preg_replace(
'/<meta http-equiv="content-type"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
931 $objectpage->htmlheader = preg_replace(
'/<meta name="robots"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
932 $objectpage->htmlheader = preg_replace(
'/<meta name="title"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
933 $objectpage->htmlheader = preg_replace(
'/<meta name="description"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
934 $objectpage->htmlheader = preg_replace(
'/<meta name="keywords"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
935 $objectpage->htmlheader = preg_replace(
'/<meta name="generator"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
938 $objectpage->htmlheader = preg_replace(
'/<title>[^<]*<\/title>\n*/ims',
'', $objectpage->htmlheader);
939 $objectpage->htmlheader = preg_replace(
'/<link[^>]*rel="shortcut[^>]*>\n/ims',
'', $objectpage->htmlheader);
940 $objectpage->htmlheader = preg_replace(
'/<link[^>]*rel="alternate[^>]*>\n/ims',
'', $objectpage->htmlheader);
941 $objectpage->htmlheader = preg_replace(
'/<link[^>]*rel="canonical[^>]*>\n/ims',
'', $objectpage->htmlheader);
944 $tmp = $objectpage->htmlheader;
947 preg_match_all(
'/<script([^\.>]+)src=["\']([^"\'>]+)["\']([^>]*)><\/script>/i', $objectpage->htmlheader, $regs);
948 $errorforsubresource = 0;
949 foreach ($regs[0] as $key => $val) {
950 dol_syslog(
"We will grab the script resource found into script tag ".$regs[2][$key]);
952 $linkwithoutdomain = $regs[2][$key];
953 if (preg_match(
'/^\//', $regs[2][$key])) {
954 $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key];
956 $urltograbbis = $urltograbdirwithoutslash.
'/'.$regs[2][$key];
960 if (preg_match(
'/^http/', $regs[2][$key])) {
961 $urltograbbis = $regs[2][$key];
962 $linkwithoutdomain = preg_replace(
'/^https?:\/\/[^\/]+\//i',
'', $regs[2][$key]);
972 if ($domaintograb != $domaintograbbis) {
1004 $tmp = preg_replace(
'/'.preg_quote($regs[0][$key],
'/').
'/i',
'', $tmp);
1006 $objectpage->htmlheader = trim($tmp).
"\n";
1010 $pagecsscontent =
"\n".
'<style>'.
"\n";
1012 preg_match_all(
'/<link([^\.>]+)href=["\']([^"\'>]+\.css[^"\'>]*)["\']([^>]*)>/i', $objectpage->htmlheader, $regs);
1013 $errorforsubresource = 0;
1014 foreach ($regs[0] as $key => $val) {
1015 dol_syslog(
"We will grab the css resources found into link tag ".$regs[2][$key]);
1017 $linkwithoutdomain = $regs[2][$key];
1018 if (preg_match(
'/^\//', $regs[2][$key])) {
1019 $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key];
1021 $urltograbbis = $urltograbdirwithoutslash.
'/'.$regs[2][$key];
1025 if (preg_match(
'/^http/', $regs[2][$key])) {
1026 $urltograbbis = $regs[2][$key];
1027 $linkwithoutdomain = preg_replace(
'/^https?:\/\/[^\/]+\//i',
'', $regs[2][$key]);
1037 if ($domaintograb != $domaintograbbis) {
1041 $tmpgeturl =
getURLContent($urltograbbis,
'GET',
'', 1, array(), array(
'http',
'https'), 0);
1042 if ($tmpgeturl[
'curl_error_no']) {
1043 $errorforsubresource++;
1044 setEventMessages(
'Error getting link tag url '.$urltograbbis.
': '.$tmpgeturl[
'curl_error_msg'],
null,
'errors');
1045 dol_syslog(
'Error getting '.$urltograbbis.
': '.$tmpgeturl[
'curl_error_msg']);
1046 $action =
'createcontainer';
1047 } elseif ($tmpgeturl[
'http_code'] !=
'200') {
1048 $errorforsubresource++;
1049 setEventMessages(
'Error getting link tag url '.$urltograbbis.
': '.$tmpgeturl[
'http_code'],
null,
'errors');
1050 dol_syslog(
'Error getting '.$urltograbbis.
': '.$tmpgeturl[
'curl_error_msg']);
1051 $action =
'createcontainer';
1060 $tmpgeturl[
'content'] = preg_replace(
'/\/\*\s+CSS content[a-z\s]*\s+\*\//',
'', $tmpgeturl[
'content']);
1070 $pagecsscontent .=
'/* Content of file '.$urltograbbis.
' */'.
"\n";
1072 getAllImages($object, $objectpage, $urltograbbis, $tmpgeturl[
'content'], $action, 1, $grabimages, $grabimagesinto);
1075 include_once DOL_DOCUMENT_ROOT.
'/core/class/lessc.class.php';
1076 $lesscobj =
new Lessc();
1078 $contentforlessc =
".bodywebsite {\n".$tmpgeturl[
'content'].
"\n}\n";
1080 $contentforlessc = $lesscobj->compile($contentforlessc);
1083 $pagecsscontent .= $contentforlessc.
"\n";
1085 }
catch (exception $e) {
1087 dol_syslog(
"Failed to compile the CSS from URL ".$urltograbbis.
" with lessc: ".$e->getMessage(), LOG_WARNING);
1088 $pagecsscontent .= $tmpgeturl[
'content'].
"\n";
1091 $objectpage->htmlheader = preg_replace(
'/'.preg_quote($regs[0][$key],
'/').
'\n*/ims',
'', $objectpage->htmlheader);
1095 $pagecsscontent .=
'</style>';
1099 $objectpage->htmlheader .= trim($pagecsscontent).
"\n";
1103 $tmp = $objectpage->content;
1105 getAllImages($object, $objectpage, $urltograb, $tmp, $action, 1, $grabimages, $grabimagesinto);
1108 $tmp = preg_replace(
'/a href="\/([^\/"]+)\/([^\/"]+)"/',
'a href="/\1-\2.php"', $tmp);
1109 $tmp = preg_replace(
'/a href="\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)"/',
'a href="/\1-\2-\3.php"', $tmp);
1110 $tmp = preg_replace(
'/a href="\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)"/',
'a href="/\1-\2-\3-\4.php"', $tmp);
1113 $objectpage->content = $tmp;
1115 $objectpage->grabbed_from = $urltograb;
1119 $newaliasnames =
'';
1120 if (!$error &&
GETPOST(
'WEBSITE_ALIASALT',
'alpha')) {
1121 $arrayofaliastotest = explode(
',', str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_ALIASALT',
'alpha')));
1123 foreach ($arrayofaliastotest as $aliastotest) {
1124 $aliastotest = trim(preg_replace(
'/\.php$/i',
'', $aliastotest));
1127 if (preg_match(
'/^page\d+/i', $aliastotest)) {
1129 $langs->load(
"errors");
1131 $action =
'createcontainer';
1134 $result = $websitepagetemp->fetch(0,
$object->id, $aliastotest);
1137 $langs->load(
"errors");
1138 setEventMessages($websitepagetemp->error, $websitepagetemp->errors,
'errors');
1139 $action =
'createcontainer';
1144 $langs->load(
"errors");
1145 setEventMessages($langs->trans(
"ErrorAPageWithThisNameOrAliasAlreadyExists", $websitepagetemp->pageurl),
null,
'errors');
1146 $action =
'createcontainer';
1149 $newaliasnames .= ($newaliasnames ?
', ' :
'').$aliastotest;
1154 $objectpage->title = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_TITLE',
'alphanohtml'));
1155 $objectpage->type_container =
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'aZ09');
1156 $objectpage->pageurl =
GETPOST(
'WEBSITE_PAGENAME',
'alpha');
1157 $objectpage->aliasalt = $newaliasnames;
1158 $objectpage->description = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml'));
1159 $objectpage->lang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
1160 $objectpage->otherlang =
GETPOST(
'WEBSITE_OTHERLANG',
'aZ09comma');
1161 $objectpage->image =
GETPOST(
'WEBSITE_IMAGE',
'alpha');
1162 $objectpage->keywords = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_KEYWORDS',
'alphanohtml'));
1163 $objectpage->allowed_in_frames =
GETPOST(
'WEBSITE_ALLOWED_IN_FRAMES',
'aZ09') ? 1 : 0;
1164 $objectpage->htmlheader =
GETPOST(
'htmlheader',
'none');
1165 $objectpage->author_alias =
GETPOST(
'WEBSITE_AUTHORALIAS',
'alphanohtml');
1166 $objectpage->object_type =
GETPOST(
'WEBSITE_OBJECTCLASS');
1167 $objectpage->fk_object =
GETPOST(
'WEBSITE_OBJECTID');
1168 $substitutionarray = array();
1169 $substitutionarray[
'__WEBSITE_CREATED_BY__'] = $user->getFullName($langs);
1182 $pageidfortranslation = (
GETPOSTINT(
'pageidfortranslation') > 0 ?
GETPOSTINT(
'pageidfortranslation') : 0);
1183 if ($pageidfortranslation > 0) {
1186 $objectpagetmp->fetch($pageidfortranslation);
1187 if ($objectpagetmp->fk_page > 0) {
1188 $pageidfortranslation = $objectpagetmp->fk_page;
1191 $objectpage->fk_page = $pageidfortranslation;
1195 if (GETPOSTISSET(
'content')) {
1197 $content =
GETPOST(
'content',
'none');
1214 if (empty($objectpage->pageurl)) {
1215 $langs->load(
"errors");
1216 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WEBSITE_PAGENAME")),
null,
'errors');
1218 $action =
'createcontainer';
1219 } elseif (!preg_match(
'/^[a-z0-9\-\_]+$/i', $objectpage->pageurl)) {
1220 $langs->load(
"errors");
1221 setEventMessages($langs->transnoentities(
"ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities(
'WEBSITE_PAGENAME')),
null,
'errors');
1223 $action =
'createcontainer';
1225 if (empty($objectpage->title)) {
1226 $langs->load(
"errors");
1227 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WEBSITE_TITLE")),
null,
'errors');
1229 $action =
'createcontainer';
1231 if ($objectpage->fk_page > 0 && empty($objectpage->lang)) {
1232 $langs->load(
"errors");
1233 setEventMessages($langs->trans(
"ErrorLanguageRequiredIfPageIsTranslationOfAnother"),
null,
'errors');
1235 $action =
'createcontainer';
1237 if ($objectpage->fk_page > 0 && !empty($objectpage->lang)) {
1238 if ($objectpage->lang == $website->lang) {
1239 $langs->load(
"errors");
1240 setEventMessages($langs->trans(
"ErrorLanguageMustNotBeSourceLanguageIfPageIsTranslationOfAnother"),
null,
'errors');
1242 $action =
'createcontainer';
1249 $pageid = $objectpage->create($user);
1253 $action =
'createcontainer';
1259 $categoriesarray =
GETPOST(
'categories',
'array');
1260 $result = $objectpage->setCategories($categoriesarray);
1269 if (empty(
$object->fk_default_home)) {
1270 $object->fk_default_home = $pageid;
1271 $res =
$object->update($user);
1276 $filetpl = $pathofwebsite.
'/page'.$pageid.
'.tpl.php';
1279 $result =
dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper, $object);
1290 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
1291 $filetpl = $pathofwebsite.
'/page'.$objectpage->id.
'.tpl.php';
1296 setEventMessages(
'Failed to write file '.basename($filealias),
null,
'errors');
1305 $action =
'createcontainer';
1312 setEventMessages($langs->trans(
"PageAdded", $objectpage->pageurl),
null,
'mesgs');
1319 $pageid = $objectpage->id;
1324 $pathtomedias = DOL_DATA_ROOT.
'/medias';
1325 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
1327 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
1328 dol_mkdir(dirname($pathtomediasinwebsite));
1329 $result = symlink($pathtomedias, $pathtomediasinwebsite);
1342 $htmlheadercontent =
"<html>\n";
1343 $htmlheadercontent .= $htmlheadercontentdefault;
1344 $htmlheadercontent .=
"</html>";
1349 $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;}";
1354 $jscontent =
"/* JS content (all pages) */\n";
1359 $robotcontent =
"# Robot file. Generated with Dolibarr\nUser-agent: *\nAllow: /public/\nDisallow: /administrator/";
1364 $htaccesscontent =
"# Order allow,deny\n# Deny from all";
1369 $manifestjsoncontent =
"";
1374 $readmecontent =
"Website generated by Dolibarr ERP CRM";
1379 $licensecontent =
"MIT License";
1383 $action =
'preview';
1388if ($action ==
'confirm_deletesite' && $confirm ==
'yes' && $permissiontodelete) {
1397 $res =
$object->delete($user);
1404 if (
GETPOST(
'delete_also_js',
'alpha') ==
'on') {
1405 $pathofwebsitejs = DOL_DATA_ROOT.
'/medias/js/'.
$object->ref;
1409 if (
GETPOST(
'delete_also_medias',
'alpha') ==
'on') {
1410 $pathofwebsitemedias = DOL_DATA_ROOT.
'/medias/image/'.
$object->ref;
1420 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
1429if (GETPOSTISSET(
'pageid') && $action ==
'delete' && $permissiontodelete && !
GETPOST(
'file_manager')) {
1434 $res =
$object->fetch(0, $websitekey);
1437 $res = $objectpage->fetch($pageid,
$object->id);
1440 $res = $objectpage->delete($user);
1449 setEventMessages($langs->trans(
"PageDeleted", $objectpage->pageurl, $websitekey),
null,
'mesgs');
1451 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$websitekey);
1459if (!GETPOSTISSET(
'pageid')) {
1460 $objectclass =
'WebsitePage';
1464 if (!$error && ($massaction ==
'delete' || ($action ==
'delete' && $confirm ==
'yes')) && $permissiontodelete) {
1467 $objecttmp =
new $objectclass($db);
1469 foreach ($toselect as $toselectid) {
1470 $result = $objecttmp->fetch($toselectid);
1472 $result = $objecttmp->delete($user);
1501 if ($action ==
'delete') {
1502 $mode =
'replacesite';
1503 $action =
'replacesite';
1505 $containertype =
GETPOST(
'optioncontainertype',
'aZ09') !=
'-1' ?
GETPOST(
'optioncontainertype',
'aZ09') :
'';
1506 $langcode =
GETPOST(
'optionlanguage',
'aZ09');
1507 $otherfilters = array();
1509 $otherfilters[
'category'] =
GETPOSTINT(
'optioncategory');
1512 $listofpages =
getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters);
1517if ($action ==
'updatecss' && $usercanedit) {
1520 $action =
'editcss';
1522 $res =
$object->fetch(0, $websitekey);
1525 if (GETPOSTISSET(
'virtualhost')) {
1526 $tmpvirtualhost = preg_replace(
'/\/$/',
'',
GETPOST(
'virtualhost',
'alpha'));
1527 if ($tmpvirtualhost && !preg_match(
'/^http/', $tmpvirtualhost)) {
1529 setEventMessages($langs->trans(
'ErrorURLMustStartWithHttp', $langs->transnoentitiesnoconv(
"VirtualHost")),
null,
'errors');
1530 $action =
'editcss';
1534 $arrayotherlang = explode(
',',
GETPOST(
'WEBSITE_OTHERLANG',
'alphanohtml'));
1535 foreach ($arrayotherlang as $key => $val) {
1537 if (empty(trim($val))) {
1540 $arrayotherlang[$key] = substr(trim($val), 0, 2);
1543 $object->virtualhost = $tmpvirtualhost;
1545 $object->otherlang = implode(
',', $arrayotherlang);
1548 $result =
$object->update($user);
1552 $action =
'editcss';
1558 if (($_FILES[
'addedfile'][
"name"] !=
'')) {
1559 $uploadfolder =
$conf->website->dir_output.
'/'.$websitekey;
1560 if ($_FILES[
'addedfile'][
'type'] !=
'image/png') {
1564 $filetoread = realpath(
dol_osencode($_FILES[
'addedfile'][
'tmp_name']));
1565 $filesize = getimagesize($filetoread);
1566 if ($filesize[0] != $filesize[1]) {
1568 setEventMessages($langs->trans(
'ErrorFaviconMustBeASquaredImage'), array(),
'errors');
1570 if (! $error && ($filesize[0] != 16 && $filesize[0] != 32 && $filesize[0] != 64)) {
1579 if (!GETPOSTISSET(
'updateandstay')) {
1580 $action =
'preview';
1582 $backtopage = preg_replace(
'/searchstring=[^&]*/',
'', $backtopage);
1583 header(
"Location: ".$backtopage);
1587 $action =
'editcss';
1606 $dataposted = trim(
GETPOST(
'WEBSITE_HTML_HEADER',
'restricthtmlallowlinkscript'));
1607 $dataposted = preg_replace(array(
'/<html>\n*/ims',
'/<\/html>\n*/ims'), array(
'',
''), $dataposted);
1608 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1611 $phpfullcodestringold =
'';
1615 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1617 if (!$errorphpcheck) {
1618 $htmlheadercontent =
'';
1630 $htmlheadercontent .= $dataposted.
"\n";
1645 $dataposted = trim(
GETPOST(
'WEBSITE_CSS_INLINE',
'none'));
1646 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1649 $phpfullcodestringold =
'';
1653 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1655 if (!$errorphpcheck) {
1658 $csscontent .=
"<?php // BEGIN PHP\n";
1659 $csscontent .=
'$websitekey=basename(__DIR__);'.
"\n";
1660 $csscontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded\n";
1661 $csscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
1662 $csscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
1663 $csscontent .=
"ob_start();\n";
1664 $csscontent .=
"if (! headers_sent()) { /* because file is included inline when in edit mode and we don't want warning */ \n";
1665 $csscontent .=
"header('Cache-Control: max-age=3600, public, must-revalidate');\n";
1666 $csscontent .=
"header('Content-type: text/css');\n";
1667 $csscontent .=
"}\n";
1668 $csscontent .=
"// END PHP ?>\n";
1670 $csscontent .= $dataposted.
"\n";
1672 $csscontent .=
'<?php // BEGIN PHP'.
"\n";
1673 $csscontent .=
'$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "css");'.
"\n";
1674 $csscontent .=
"// END PHP\n";
1676 dol_syslog(
"Save css content into ".$filecss);
1688 $dataposted = trim(
GETPOST(
'WEBSITE_JS_INLINE',
'none'));
1689 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1692 $phpfullcodestringold =
'';
1696 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1698 if (!$errorphpcheck) {
1701 $jscontent .=
"<?php // BEGIN PHP\n";
1702 $jscontent .=
'$websitekey=basename(__DIR__);'.
"\n";
1703 $jscontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded\n";
1704 $jscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
1705 $jscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
1706 $jscontent .=
"ob_start();\n";
1707 $jscontent .=
"header('Cache-Control: max-age=3600, public, must-revalidate');\n";
1708 $jscontent .=
"header('Content-type: application/javascript');\n";
1709 $jscontent .=
"// END PHP ?>\n";
1711 $jscontent .= $dataposted.
"\n";
1713 $jscontent .=
'<?php // BEGIN PHP'.
"\n";
1714 $jscontent .=
'$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "js");'.
"\n";
1715 $jscontent .=
"// END PHP\n";
1726 $dataposted = trim(
GETPOST(
'WEBSITE_ROBOT',
'nohtml'));
1727 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1730 $phpfullcodestringold =
'';
1734 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1736 if (!$errorphpcheck) {
1749 $robotcontent .= $dataposted.
"\n";
1764 $dataposted = trim(
GETPOST(
'WEBSITE_HTACCESS',
'nohtml'));
1765 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1768 $phpfullcodestringold =
'';
1772 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1774 if (!$errorphpcheck) {
1775 $htaccesscontent =
'';
1776 $htaccesscontent .= $dataposted.
"\n";
1788 $dataposted = trim(
GETPOST(
'WEBSITE_MANIFEST_JSON',
'restricthtmlallowunvalid'));
1789 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1792 $phpfullcodestringold =
'';
1796 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1798 if (!$errorphpcheck) {
1799 $manifestjsoncontent =
'';
1801 $manifestjsoncontent .=
"<?php // BEGIN PHP\n";
1802 $manifestjsoncontent .=
'$websitekey=basename(__DIR__);'.
"\n";
1803 $manifestjsoncontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded\n";
1804 $manifestjsoncontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
1805 $manifestjsoncontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
1806 $manifestjsoncontent .=
"ob_start();\n";
1807 $manifestjsoncontent .=
"header('Cache-Control: max-age=3600, public, must-revalidate');\n";
1808 $manifestjsoncontent .=
"header('Content-type: application/manifest+json');\n";
1809 $manifestjsoncontent .=
"// END PHP ?>\n";
1811 $manifestjsoncontent .= $dataposted.
"\n";
1813 $manifestjsoncontent .=
'<?php // BEGIN PHP'.
"\n";
1814 $manifestjsoncontent .=
'$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "manifest");'.
"\n";
1815 $manifestjsoncontent .=
"// END PHP\n";
1820 setEventMessages(
'Failed to write file '.$filemanifestjson,
null,
'errors');
1827 $dataposted = trim(
GETPOST(
'WEBSITE_README',
'nohtml'));
1828 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1831 $phpfullcodestringold =
'';
1835 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1837 if (!$errorphpcheck) {
1838 $readmecontent =
'';
1850 $readmecontent .= $dataposted.
"\n";
1866 $dataposted = trim(
GETPOST(
'WEBSITE_LICENSE',
'nohtml'));
1867 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1870 $phpfullcodestringold =
'';
1874 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1876 if (!$errorphpcheck) {
1877 $licensecontent =
'';
1889 $licensecontent .= $dataposted.
"\n";
1913 if (!GETPOSTISSET(
'updateandstay')) {
1914 $action =
'preview';
1916 $backtopage = preg_replace(
'/searchstring=[^&]*/',
'', $backtopage);
1917 header(
"Location: ".$backtopage);
1921 $action =
'editcss';
1928if ($action ==
'setashome' && $usercanedit) {
1930 $object->fetch(0, $websitekey);
1933 $object->fk_default_home = $pageid;
1934 $res =
$object->update($user);
1943 $filetpl = $pathofwebsite.
'/page'.$pageid.
'.tpl.php';
1946 $result =
dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper, $object);
1954 $action =
'preview';
1961if ($action ==
'updatemeta' && $usercanedit) {
1964 $result =
$object->fetch(0, $websitekey);
1967 $objectpage->fk_website =
$object->id;
1970 if (!preg_match(
'/^[a-z0-9\-\_]+$/i',
GETPOST(
'WEBSITE_PAGENAME',
'alpha'))) {
1972 $langs->load(
"errors");
1973 setEventMessages($langs->transnoentities(
"ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities(
'WEBSITE_PAGENAME')),
null,
'errors');
1974 $action =
'editmeta';
1977 $res = $objectpage->fetch($pageid,
$object->id);
1980 setEventMessages(
'Page not found '.$objectpage->error, $objectpage->errors,
'errors');
1984 if (!$error &&
GETPOST(
'WEBSITE_PAGENAME',
'alpha')) {
1986 $result = $websitepagetemp->fetch(-1 * $objectpage->id,
$object->id,
GETPOST(
'WEBSITE_PAGENAME',
'alpha'));
1989 $langs->load(
"errors");
1990 setEventMessages($websitepagetemp->error, $websitepagetemp->errors,
'errors');
1991 $action =
'editmeta';
1995 $langs->load(
"errors");
1996 setEventMessages($langs->trans(
"ErrorAPageWithThisNameOrAliasAlreadyExists", $websitepagetemp->pageurl),
null,
'errors');
1997 $action =
'editmeta';
2001 $newaliasnames =
'';
2002 if (!$error &&
GETPOST(
'WEBSITE_ALIASALT',
'alpha')) {
2003 $arrayofaliastotest = explode(
',', str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_ALIASALT',
'alpha')));
2006 foreach ($arrayofaliastotest as $aliastotest) {
2007 $aliastotest = trim(preg_replace(
'/\.php$/i',
'', $aliastotest));
2010 if (preg_match(
'/^page\d+/i', $aliastotest)) {
2012 $langs->load(
"errors");
2014 $action =
'editmeta';
2017 $result = $websitepagetemp->fetch(-1 * $objectpage->id,
$object->id, $aliastotest);
2020 $langs->load(
"errors");
2021 setEventMessages($websitepagetemp->error, $websitepagetemp->errors,
'errors');
2022 $action =
'editmeta';
2027 $langs->load(
"errors");
2028 setEventMessages($langs->trans(
"ErrorAPageWithThisNameOrAliasAlreadyExists", $websitepagetemp->pageurl),
null,
'errors');
2029 $action =
'editmeta';
2032 $newaliasnames .= ($newaliasnames ?
', ' :
'').$aliastotest;
2038 $objectpage->old_object = clone $objectpage;
2040 $objectpage->title = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_TITLE',
'alphanohtml'));
2041 $objectpage->type_container =
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'aZ09');
2042 $objectpage->pageurl =
GETPOST(
'WEBSITE_PAGENAME',
'alpha');
2043 $objectpage->aliasalt = $newaliasnames;
2044 $objectpage->lang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
2045 $objectpage->otherlang =
GETPOST(
'WEBSITE_OTHERLANG',
'aZ09comma');
2046 $objectpage->description = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml'));
2047 $objectpage->image =
GETPOST(
'WEBSITE_IMAGE',
'alpha');
2048 $objectpage->keywords = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_KEYWORDS',
'alphanohtml'));
2049 $objectpage->allowed_in_frames =
GETPOST(
'WEBSITE_ALLOWED_IN_FRAMES',
'aZ09') ? 1 : 0;
2050 $objectpage->htmlheader = trim(
GETPOST(
'htmlheader',
'restricthtmlallowlinkscript'));
2051 $objectpage->fk_page = (
GETPOSTINT(
'pageidfortranslation') > 0 ?
GETPOSTINT(
'pageidfortranslation') : 0);
2052 $objectpage->author_alias = trim(
GETPOST(
'WEBSITE_AUTHORALIAS',
'alphanohtml'));
2053 $objectpage->object_type =
GETPOST(
'WEBSITE_OBJECTCLASS',
'alpha');
2054 $objectpage->fk_object =
GETPOST(
'WEBSITE_OBJECTID',
'aZ09');
2057 if ($newdatecreation) {
2058 $objectpage->date_creation = $newdatecreation;
2061 $res = $objectpage->update($user);
2063 $langs->load(
"errors");
2064 if ($db->lasterrno ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
2066 $langs->load(
"errors");
2067 setEventMessages($langs->trans(
"ErrorAPageWithThisNameOrAliasAlreadyExists"),
null,
'errors');
2068 $action =
'editmeta';
2071 $langs->load(
"errors");
2073 $action =
'editmeta';
2080 $categoriesarray =
GETPOST(
'categories',
'array');
2081 $result = $objectpage->setCategories($categoriesarray);
2095 $filemaster = $pathofwebsite.
'/master.inc.php';
2096 $fileoldalias = $pathofwebsite.
'/'.$objectpage->old_object->pageurl.
'.php';
2097 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
2108 if (!empty($fileoldalias)) {
2109 dol_syslog(
"We delete old alias page name=".$fileoldalias.
" to build a new alias page=".$filealias);
2113 if (empty($objectpage->lang) || !in_array($objectpage->lang, explode(
',',
$object->otherlang))) {
2114 $dirname = dirname($fileoldalias);
2115 $filename = basename($fileoldalias);
2116 $sublangs = explode(
',',
$object->otherlang);
2117 foreach ($sublangs as $sublang) {
2121 if (empty(trim($sublang))) {
2124 $fileoldaliassub = $dirname.
'/'.$sublang.
'/'.$filename;
2130 if (!empty($objectpage->old_object->aliasalt)) {
2131 $tmpaltaliases = explode(
',', $objectpage->old_object->aliasalt);
2132 if (is_array($tmpaltaliases)) {
2133 foreach ($tmpaltaliases as $tmpaliasalt) {
2134 dol_syslog(
"We delete old alt alias pages name=".trim($tmpaliasalt));
2138 if (empty($objectpage->lang) || !in_array($objectpage->lang, explode(
',',
$object->otherlang))) {
2139 $dirname = dirname($pathofwebsite.
'/'.trim($tmpaliasalt).
'.php');
2140 $filename = basename($pathofwebsite.
'/'.trim($tmpaliasalt).
'.php');
2141 $sublangs = explode(
',',
$object->otherlang);
2142 foreach ($sublangs as $sublang) {
2146 if (empty(trim($sublang))) {
2149 $fileoldaliassub = $dirname.
'/'.$sublang.
'/'.$filename;
2163 if (!empty($objectpage->aliasalt)) {
2164 $tmpaltaliases = explode(
',', $objectpage->aliasalt);
2165 if (is_array($tmpaltaliases)) {
2166 foreach ($tmpaltaliases as $tmpaliasalt) {
2167 if (trim($tmpaliasalt)) {
2168 $filealias = $pathofwebsite.
'/'.trim($tmpaliasalt).
'.php';
2171 setEventMessages(
'Failed to write file '.basename($filealias),
null,
'errors');
2184 if (!GETPOSTISSET(
'updateandstay')) {
2187 $action =
'preview';
2189 $action =
'editmeta';
2195 $action =
'preview';
2201if ((($action ==
'updatesource' || $action ==
'updatecontent' || $action ==
'confirm_createfromclone' || $action ==
'confirm_createpagefromclone') || ($action ==
'preview' && (
GETPOST(
'refreshsite') ||
GETPOST(
'refreshpage') ||
GETPOST(
'preview')))) && $usercanedit) {
2202 $object->fetch(0, $websitekey);
2205 if ($action ==
'confirm_createfromclone') {
2208 $objectnew =
new Website($db);
2214 $action =
'preview';
2221 $pageid =
$object->fk_default_home;
2222 $websitekey =
GETPOST(
'siteref',
'aZ09');
2228 if ($action ==
'confirm_createpagefromclone') {
2229 $istranslation = (
GETPOST(
'is_a_translation',
'aZ09') ==
'on' ? 1 : 0);
2231 if ($istranslation) {
2232 if (
GETPOST(
'newlang',
'aZ09') == $objectpage->lang || !
GETPOST(
'newlang',
'aZ09')) {
2234 setEventMessages($langs->trans(
"LanguageMustNotBeSameThanClonedPage"),
null,
'errors');
2235 $action =
'preview';
2239 setEventMessages($langs->trans(
"WebsiteMustBeSameThanClonedPageIfTranslation"),
null,
'errors');
2240 $action =
'preview';
2248 $pathofwebsitenew = $pathofwebsite;
2250 $tmpwebsite =
new Website($db);
2251 if ($newwebsiteid > 0 && $newwebsiteid !=
$object->id) {
2252 $tmpwebsite->fetch($newwebsiteid);
2253 $pathofwebsitenew = $dolibarr_main_data_root.($conf->entity > 1 ?
'/'.$conf->entity :
'').
'/website/'.$tmpwebsite->ref;
2259 $resultpage = $objectpage->createFromClone($user, $pageid,
GETPOST(
'newpageurl',
'aZ09'), (
GETPOST(
'newlang',
'aZ09') ?
GETPOST(
'newlang',
'aZ09') :
''), $istranslation, $newwebsiteid,
GETPOST(
'newtitle',
'alphanohtml'), $tmpwebsite);
2260 if ($resultpage < 0) {
2263 $action =
'createpagefromclone';
2267 $filetpl = $pathofwebsitenew.
'/page'.$resultpage->id.
'.tpl.php';
2268 $fileindex = $pathofwebsitenew.
'/index.php';
2269 $filewrapper = $pathofwebsitenew.
'/wrapper.php';
2278 if (empty($newwebsiteid) || $newwebsiteid ==
$object->id) {
2279 $pageid = $resultpage->id;
2291 $pathtomedias = DOL_DATA_ROOT.
'/medias';
2292 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
2294 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
2295 dol_mkdir(dirname($pathtomediasinwebsite));
2296 $result = symlink($pathtomedias, $pathtomediasinwebsite);
2305 $objectpage->fk_website =
$object->id;
2308 $res = $objectpage->fetch($pageid);
2311 if (
$object->fk_default_home > 0) {
2312 $res = $objectpage->fetch(
$object->fk_default_home);
2315 $res = $objectpage->fetch(0,
$object->id);
2320 if (!$error && $res > 0) {
2321 if ($action ==
'updatesource' || $action ==
'updatecontent') {
2326 $objectpage->content =
GETPOST(
'PAGE_CONTENT',
'none');
2331 $error =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
2334 if ($action ==
'updatesource') {
2335 $action =
'editsource';
2337 if ($action ==
'updatecontent') {
2338 $action =
'editcontent';
2343 $objectpage->content = preg_replace(
'/<head>.*<\/head>/ims',
'', $objectpage->content);
2347 $res = $objectpage->update($user);
2351 if ($action ==
'updatesource') {
2352 $action =
'editsource';
2354 if ($action ==
'updatecontent') {
2355 $action =
'editcontent';
2362 $filemaster = $pathofwebsite.
'/master.inc.php';
2364 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
2372 setEventMessages(
'Failed to write the master file file '.$filemaster,
null,
'errors');
2396 setEventMessages(
'Failed to write the alias file '.basename($filealias),
null,
'errors');
2404 if (!GETPOSTISSET(
'updateandstay')) {
2406 header(
"Location: ".$backtopage);
2409 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$websitekey.
'&pageid='.$pageid);
2413 if ($action ==
'updatesource') {
2414 $action =
'editsource';
2416 if ($action ==
'updatecontent') {
2417 $action =
'editcontent';
2422 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$websitekey.
'&pageid='.$pageid);
2429 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$websitekey.
'&pageid='.$pageid);
2434 if (empty($websitekey) || $websitekey ==
'-1') {
2435 setEventMessages($langs->trans(
"NoWebSiteCreateOneFirst"),
null,
'warnings');
2438 setEventMessages($langs->trans(
"YouCanCreatePageOrImportTemplate"),
null,
'warnings');
2444if ($action ==
'deletelang' && $usercanedit) {
2445 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"website_page SET fk_page = NULL";
2446 $sql .=
" WHERE rowid = ".GETPOSTINT(
'deletelangforid');
2449 $resql = $db->query($sql);
2453 $objectpage->fk_page =
null;
2456 $action =
'editmeta';
2461if ($action ==
'exportsite' && $user->hasRight(
'website',
'export')) {
2462 $fileofzip =
$object->exportWebSite();
2465 $file_name = basename($fileofzip);
2466 header(
"Content-Type: application/zip");
2467 header(
"Content-Disposition: attachment; filename=".$file_name);
2468 header(
"Content-Length: ".filesize($fileofzip));
2470 readfile($fileofzip);
2474 $action =
'preview';
2479if ($action ==
'overwritesite' && $user->hasRight(
'website',
'export')) {
2481 $fileofzip =
$object->exportWebSite();
2482 $pathToExport =
GETPOST(
'export_path');
2484 $object->overwriteTemplate($fileofzip, $pathToExport);
2491if ($action ==
'regeneratesite' && $usercanedit) {
2493 $pathtomedias = DOL_DATA_ROOT.
'/medias';
2494 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
2496 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
2497 dol_mkdir(dirname($pathtomediasinwebsite));
2498 $result = symlink($pathtomedias, $pathtomediasinwebsite);
2500 $langs->load(
"errors");
2501 setEventMessages($langs->trans(
"ErrorFailedToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias),
null,
'errors');
2502 $action =
'preview';
2506 $result =
$object->rebuildWebSiteFiles();
2508 setEventMessages($langs->trans(
"PagesRegenerated", $result),
null,
'mesgs');
2509 $action =
'preview';
2512 $action =
'preview';
2517if ($action ==
'importsiteconfirm' && $usercanedit) {
2518 $dolibarrdataroot = preg_replace(
'/([\\/]+)$/i',
'', DOL_DATA_ROOT);
2519 $allowimportsite =
true;
2520 if (
dol_is_file($dolibarrdataroot.
'/installmodules.lock')) {
2521 $allowimportsite =
false;
2524 if ($allowimportsite) {
2525 if (empty($_FILES) && !GETPOSTISSET(
'templateuserfile')) {
2526 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"File")),
null,
'errors');
2527 $action =
'importsite';
2529 if (!empty($_FILES) || GETPOSTISSET(
'templateuserfile')) {
2531 $pathtomedias = DOL_DATA_ROOT.
'/medias';
2532 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
2534 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
2535 dol_mkdir(dirname($pathtomediasinwebsite));
2536 $result = symlink($pathtomedias, $pathtomediasinwebsite);
2538 $langs->load(
"errors");
2539 setEventMessages($langs->trans(
"ErrorFailedToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias),
null,
'errors');
2540 $action =
'importsite';
2545 if (GETPOSTISSET(
'templateuserfile')) {
2547 $fileofzip = DOL_DATA_ROOT.
'/doctemplates/websites/'.
GETPOST(
'templateuserfile',
'alpha');
2548 } elseif (!empty($_FILES) && is_array($_FILES[
'userfile'])) {
2550 if (is_array($_FILES[
'userfile'][
'tmp_name'])) {
2551 $userfiles = $_FILES[
'userfile'][
'tmp_name'];
2553 $userfiles = array($_FILES[
'userfile'][
'tmp_name']);
2557 foreach ($userfiles as $key => $userfile) {
2558 if (empty($_FILES[
'userfile'][
'tmp_name'][$key])) {
2560 if ($_FILES[
'userfile'][
'error'][$key] == 1 || $_FILES[
'userfile'][
'error'][$key] == 2) {
2562 $action =
'importsite';
2564 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"File")),
null,
'errors');
2565 $action =
'importsite';
2572 $upload_dir = DOL_DATA_ROOT.
'/doctemplates/websites/';
2586 $action =
'importsite';
2589 if (!$error && GETPOSTISSET(
'templateuserfile')) {
2590 $templatewithoutzip = preg_replace(
'/\.zip$/i',
'',
GETPOST(
'templateuserfile'));
2591 $object->setTemplateName($templatewithoutzip);
2593 $result =
$object->importWebSite($fileofzip);
2597 $action =
'importsite';
2602 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.
$object->ref);
2611 $message = $langs->trans(
'InstallModuleFromWebHasBeenDisabledContactUs');
2614 $message = $langs->trans(
"InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.
'/installmodules.lock');
2620$domainname =
'0.0.0.0:8080';
2621$tempdir =
$conf->website->dir_output.
'/'.$websitekey.
'/';
2624if ($action ==
'generatesitemaps' && $usercanedit) {
2626 if ($website->virtualhost) {
2627 $domainname = $website->virtualhost;
2629 if (! preg_match(
'/^http/i', $domainname)) {
2630 $domainname =
'https://'.$domainname;
2633 $domtree =
new DOMDocument(
'1.0',
'UTF-8');
2635 $root = $domtree->createElementNS(
'http://www.sitemaps.org/schemas/sitemap/0.9',
'urlset');
2636 $root->setAttributeNS(
'http://www.w3.org/2000/xmlns/',
'xmlns:xhtml',
'http://www.w3.org/1999/xhtml');
2638 $domtree->formatOutput =
true;
2641 $xmlname =
'sitemap.xml';
2643 $sql =
"SELECT wp.rowid, wp.type_container , wp.pageurl, wp.lang, wp.fk_page, wp.tms as tms,";
2644 $sql .=
" w.virtualhost, w.fk_default_home";
2645 $sql .=
" FROM ".MAIN_DB_PREFIX.
"website_page as wp, ".MAIN_DB_PREFIX.
"website as w";
2646 $sql .=
" WHERE wp.type_container IN ('page', 'blogpost')";
2647 $sql .=
" AND wp.fk_website = w.rowid";
2648 $sql .=
" AND wp.status = ".WebsitePage::STATUS_VALIDATED;
2649 $sql .=
" AND wp.pageurl NOT IN ('404', '500', '501', '503')";
2650 $sql .=
" AND w.ref = '".dol_escape_json($websitekey).
"'";
2651 $sql .=
" ORDER BY wp.tms DESC, wp.rowid DESC";
2652 $resql = $db->query($sql);
2654 $num_rows = $db->num_rows($resql);
2655 if ($num_rows > 0) {
2657 while ($i < $num_rows) {
2658 $objp = $db->fetch_object($resql);
2659 $url = $domtree->createElement(
'url');
2661 $shortlangcode =
'';
2663 $shortlangcode = substr($objp->lang, 0, 2);
2665 if (empty($shortlangcode)) {
2666 $shortlangcode = substr(
$object->lang, 0, 2);
2670 if ($objp->type_container ==
'blogpost') {
2675 $pageurl = $objp->pageurl.
'.php';
2676 if ($objp->fk_default_home == $objp->rowid) {
2679 if ($shortlangcode != substr(
$object->lang, 0, 2)) {
2680 $pageurl = $shortlangcode.
'/'.$pageurl;
2687 $loc = $domtree->createElement(
'loc', $domainname.
'/'.$pageurl);
2688 $lastmod = $domtree->createElement(
'lastmod',
dol_print_date($db->jdate($objp->tms),
'dayrfc',
'gmt'));
2689 $priority = $domtree->createElement(
'priority',
'1');
2691 $url->appendChild($loc);
2692 $url->appendChild($lastmod);
2695 $changefreq = $domtree->createElement(
'changefreq',
'weekly');
2696 $url->appendChild($changefreq);
2699 if ($objp->fk_default_home == $objp->rowid) {
2700 $url->appendChild($priority);
2705 $alternatefound = 0;
2708 $translationof = $objp->fk_page;
2709 if ($translationof) {
2711 $tmppage->fetch($translationof);
2712 if ($tmppage->id > 0) {
2713 $tmpshortlangcode =
'';
2714 if ($tmppage->lang) {
2715 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'', $tmppage->lang);
2717 if (empty($tmpshortlangcode)) {
2718 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'',
$object->lang);
2720 if ($tmpshortlangcode != $shortlangcode) {
2721 $xhtmllink = $domtree->createElement(
'xhtml:link',
'');
2722 $xhtmllink->setAttribute(
"rel",
"alternate");
2723 $xhtmllink->setAttribute(
"hreflang", $tmpshortlangcode);
2724 $xhtmllink->setAttribute(
"href", $domainname.($objp->fk_default_home == $tmppage->id ?
'/' : (($tmpshortlangcode != substr(
$object->lang, 0, 2)) ?
'/'.$tmpshortlangcode :
'').
'/'.$tmppage->pageurl.
'.php'));
2725 $url->appendChild($xhtmllink);
2733 $sql =
'SELECT rowid as id, lang, pageurl from '.MAIN_DB_PREFIX.
'website_page';
2734 $sql .=
" WHERE status = ".((int) WebsitePage::STATUS_VALIDATED).
' AND fk_page IN ('.$db->sanitize($objp->rowid.($translationof ?
", ".$translationof :
"")).
")";
2735 $resqlhastrans = $db->query($sql);
2736 if ($resqlhastrans) {
2737 $num_rows_hastrans = $db->num_rows($resqlhastrans);
2738 if ($num_rows_hastrans > 0) {
2739 while ($objhastrans = $db->fetch_object($resqlhastrans)) {
2740 $tmpshortlangcode =
'';
2741 if ($objhastrans->lang) {
2742 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'', $objhastrans->lang);
2744 if ($tmpshortlangcode != $shortlangcode) {
2745 $xhtmllink = $domtree->createElement(
'xhtml:link',
'');
2746 $xhtmllink->setAttribute(
"rel",
"alternate");
2747 $xhtmllink->setAttribute(
"hreflang", $tmpshortlangcode);
2748 $xhtmllink->setAttribute(
"href", $domainname.($objp->fk_default_home == $objhastrans->id ?
'/' : (($tmpshortlangcode != substr(
$object->lang, 0, 2) ?
'/'.$tmpshortlangcode :
'')).
'/'.$objhastrans->pageurl.
'.php'));
2749 $url->appendChild($xhtmllink);
2759 if ($alternatefound) {
2761 $xhtmllink = $domtree->createElement(
'xhtml:link',
'');
2762 $xhtmllink->setAttribute(
"rel",
"alternate");
2763 $xhtmllink->setAttribute(
"hreflang", $shortlangcode);
2764 $xhtmllink->setAttribute(
"href", $domainname.
'/'.$pageurl);
2765 $url->appendChild($xhtmllink);
2781 $root->appendChild($url);
2787 if ($addrsswrapper &&
getDolGlobalInt(
'WEBSITE_ADD_RSS_FEED_INTO_SITEMAP')) {
2788 $url = $domtree->createElement(
'url');
2790 $pageurl =
'wrapper.php?rss=1';
2793 $loc = $domtree->createElement(
'loc', $domainname.
'/'.$pageurl);
2794 $lastmod = $domtree->createElement(
'lastmod',
dol_print_date($db->jdate(
dol_now()),
'dayrfc',
'gmt'));
2796 $url->appendChild($loc);
2797 $url->appendChild($lastmod);
2800 $changefreq = $domtree->createElement(
'changefreq',
'weekly');
2801 $url->appendChild($changefreq);
2804 $root->appendChild($url);
2807 $domtree->appendChild($root);
2809 if ($domtree->save($tempdir.$xmlname)) {
2811 setEventMessages($langs->trans(
"SitemapGenerated", $xmlname),
null,
'mesgs');
2821 $robotcontent = @file_get_contents($filerobot);
2822 $result = preg_replace(
'/<?php \/\/ BEGIN PHP[^?]END PHP ?>\n/ims',
'', $robotcontent);
2824 $robotcontent = $result;
2826 $robotsitemap =
"Sitemap: ".$domainname.
"/".$xmlname;
2827 $result = strpos($robotcontent,
'Sitemap: ');
2829 $result = preg_replace(
'/Sitemap:.*/', $robotsitemap, $robotcontent);
2830 $robotcontent = $result ? $result : $robotcontent;
2832 $robotcontent .= $robotsitemap.
"\n";
2839 $action =
'preview';
2847$form =
new Form($db);
2854if ($action ==
'confirmgeneratesitemaps') {
2855 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?website='.urlencode($website->ref), $langs->trans(
'ConfirmSitemapsCreation'), $langs->trans(
'ConfirmGenerateSitemaps',
$object->ref),
'generatesitemaps',
'',
"yes", 1);
2856 $action =
'preview';
2858$helpurl =
'EN:Module_Website|FR:Module_Website_FR|ES:Módulo_Website';
2861 '/includes/ace/src/ace.js',
2862 '/includes/ace/src/ext-statusbar.js',
2863 '/includes/ace/src/ext-language_tools.js',
2867$arrayofcss = array();
2872$arrayofjs[] =
'includes/jquery/plugins/blockUI/jquery.blockUI.js';
2873$arrayofjs[] =
'core/js/blockUI.js';
2875 $arrayofjs[] =
"includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js";
2878$moreheadjs .=
'<script type="text/javascript">'.
"\n";
2879$moreheadjs .=
'var indicatorBlockUI = \''.DOL_URL_ROOT.
"/theme/".
$conf->theme.
"/img/working.gif".
'\';
'."\n";
2880$moreheadjs .= '</script>
'."\n";
2882llxHeader($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">
');
2885print '<!-- Open form
for all page -->
'."\n";
2886print '<form action=
"'.$_SERVER["PHP_SELF
"].($action == 'file_manager' ? '?uploadform=1' : '').'" method=
"POST" enctype=
"multipart/form-data" class=
"websiteformtoolbar">
';
2887print '<input
type=
"hidden" name=
"token" value=
"'.newToken().'">
';
2888print '<input
type=
"hidden" name=
"backtopage" value=
"'.$backtopage.'">
';
2889print '<input
type=
"hidden" name=
"dol_openinpopup" value=
"'.$dol_openinpopup.'">
';
2891if ($action == 'createsite
') {
2892 print '<input
type=
"hidden" name=
"action" value=
"addsite">
';
2894if ($action == 'createcontainer
') {
2895 print '<input
type=
"hidden" name=
"action" value=
"addcontainer">
';
2897if ($action == 'editcss
') {
2898 print '<input
type=
"hidden" name=
"action" value=
"updatecss">
';
2900if ($action == 'editmenu
') {
2901 print '<input
type=
"hidden" name=
"action" value=
"updatemenu">
';
2903if ($action == 'setashome
') {
2904 print '<input
type=
"hidden" name=
"action" value=
"updateashome">
';
2906if ($action == 'editmeta
') {
2907 print '<input
type=
"hidden" name=
"action" value=
"updatemeta">
';
2909if ($action == 'editsource
') {
2910 print '<input
type=
"hidden" name=
"action" value=
"updatesource">
';
2912if ($action == 'editcontent
') {
2913 print '<input
type=
"hidden" name=
"action" value=
"updatecontent">
';
2915if ($action == 'edit
') {
2916 print '<input
type=
"hidden" name=
"action" value=
"update">
';
2918if ($action == 'importsite
') {
2919 print '<input
type=
"hidden" name=
"action" value=
"importsiteconfirm">
';
2921if ($action == 'file_manager
') {
2922 print '<input
type=
"hidden" name=
"action" value=
"file_manager">
';
2925 print '<input
type=
"hidden" name=
"mode" value=
"'.$mode.'">
';
2930// Add a margin under toolbar ?
2932if ($action != 'preview
' && $action != 'editcontent
' && $action != 'editsource
' && !GETPOST('createpagefromclone
', 'alphanohtml
')) {
2933 $style = ' margin-bottom: 5px;
';
2937if (!GETPOST('hide_websitemenu
')) {
2939 if (!$user->hasRight('website
', 'write
')) {
2940 $disabled = ' disabled=
"disabled"';
2942 $disabledexport = '';
2943 if (!$user->hasRight('website
', 'export
')) {
2944 $disabledexport = ' disabled=
"disabled"';
2949 $dataroot = DOL_DATA_ROOT.($conf->entity > 1 ? '/
'.$conf->entity : '').'/website/
'.$websitekey;
2950 if (!empty($object->virtualhost)) {
2951 $virtualurl = $object->virtualhost;
2956 if ($object->id > 0) {
2957 $array = $objectpage->fetchAll($object->id, 'ASC,ASC
', 'type_container,pageurl
');
2958 $object->lines = $array;
2960 if (!is_array($array) && $array < 0) {
2961 dol_print_error(null, $objectpage->error, $objectpage->errors);
2963 $atleastonepage = (is_array($array) && count($array) > 0);
2965 $websitepage = new WebsitePage($db);
2967 $websitepage->fetch($pageid);
2971 //var_dump($objectpage);exit;
2972 print '<div
class=
"centpercent websitebar'.(GETPOST('dol_openinpopup', 'aZ09') ? ' hiddenforpopup' : '').'">
';
2975 // Toolbar for websites
2978 print '<!-- Toolbar
for website -->
';
2979 if ($action != 'file_manager
') {
2980 print '<div
class=
"websiteselection hideonsmartphoneimp minwidth75 tdoverflowmax100 inline-block">
';
2981 print $langs->trans("Website").':
';
2984 // Button Add new website
2985 $urltocreatenewwebsite = $_SERVER["PHP_SELF"].'?action=createsite
';
2986 print '<span
class=
"websiteselection paddingrightonly">
';
2987 print '<a href=
"'.$urltocreatenewwebsite.'" class=
""'.$disabled.' title=
"'.dol_escape_htmltag($langs->trans("AddWebsite
")).'"><span
class=
"fa fa-plus-circle valignmiddle btnTitle-icon"><span></a>
';
2991 print '<span
class=
"websiteselection nopaddingrightimp">
';
2994 $out .= '<select
name=
"website" class=
"minwidth100 width200 maxwidth150onsmartphone" id=
"website">
';
2995 if (empty($listofwebsites)) {
2996 $out .= '<option value=
"-1"> </option>
';
2999 // Loop on each sites
3001 foreach ($listofwebsites as $key => $valwebsite) {
3002 if (empty($websitekey)) {
3003 if ($action != 'createsite
') {
3004 $websitekey = $valwebsite->ref;
3008 $out .= '<option value=
"'.$valwebsite->ref.'"';
3009 if ($websitekey == $valwebsite->ref) {
3010 $out .= ' selected
'; // To preselect a value
3012 //$outoption = $valwebsite->getLibStatut(3).' '.$valwebsite->ref.' ';
3013 $outoption = (($valwebsite->status == $valwebsite::STATUS_DRAFT) ? '<span
class=
"opacitymedium">
' : '').$valwebsite->ref.(($valwebsite->status == $valwebsite::STATUS_DRAFT) ? '</span>
' : '');
3014 $out .= ' data-html=
"'.dol_escape_htmltag($outoption).'"';
3016 $out .= $valwebsite->ref;
3017 $out .= '</option>
';
3020 $out .= '</select>
';
3021 $out .= ajax_combobox('website
');
3023 if (!empty($conf->use_javascript_ajax)) {
3024 $out .= '<script
type=
"text/javascript">
';
3025 $out .= 'jQuery(document).ready(
function () {
';
3026 $out .= ' jQuery(
"#website").change(
function () {
';
3027 $out .= ' console.log(
"We select "+jQuery(
"#website option:selected").val());
';
3028 $out .= ' if (jQuery(
"#website option:selected").val() == \
'-2\') {';
3029 $out .=
' window.location.href = "'.dol_escape_js($urltocreatenewwebsite).
'";';
3030 $out .=
' } else {';
3031 $out .=
' window.location.href = "'.$_SERVER[
"PHP_SELF"].
'?website="+jQuery("#website option:selected").val();';
3035 $out .=
'</script>';
3042 if (!empty(
$conf->use_javascript_ajax)) {
3043 print
'<span class="websiteselection">';
3048 if ($website->status == $website::STATUS_DRAFT) {
3049 $text_off =
'Offline';
3050 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>';
3052 $text_off =
'Online';
3053 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>';
3059 if (empty(
$conf->use_javascript_ajax)) {
3060 print
'<span class="websiteselection">';
3061 print
'<input type="image" class="valignmiddle" src="'.img_picto(
'',
'refresh',
'', 0, 1).
'" name="refreshsite" value="'.$langs->trans(
"Load").
'">';
3066 print
'<span class="websiteselection">';
3068 if ($websitekey && $websitekey !=
'-1' && ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite')) {
3070 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
$object->ref).
'&pageid='.((int) $pageid).
'&action=editcss&token='.
newToken().
'" class="button bordertransp" title="'.
dol_escape_htmltag($langs->trans(
"EditCss")).
'"'.$disabled.
'><span class="fa fa-cog paddingrightonly"></span><span class="hideonsmartphone">'.
dol_escape_htmltag($langs->trans(
"EditCss")).
'</span></a>';
3073 $importlabel = $langs->trans(
"ImportSite");
3074 $exportlabel = $langs->trans(
"ExportSite");
3075 if (!empty(
$conf->dol_optimize_smallscreen)) {
3076 $importlabel = $langs->trans(
"Import");
3077 $exportlabel = $langs->trans(
"Export");
3080 if ($atleastonepage) {
3081 print
'<input type="submit" class="button bordertransp" disabled="disabled" value="'.dol_escape_htmltag($importlabel).
'" name="importsite">';
3083 print
'<input type="submit" class="button bordertransp"'.$disabled.
' value="'.
dol_escape_htmltag($importlabel).
'" name="importsite">';
3087 $extraCssClass =
getDolGlobalString(
'WEBSITE_ALLOW_OVERWRITE_GIT_SOURCE') ?
'hideobject' :
'';
3088 print
'<input type="submit" class="button bordertransp ' . $extraCssClass .
'" ' . $disabledexport .
' value="' .
dol_escape_htmltag($exportlabel) .
'" name="exportsite">';
3092 $overwriteGitUrl = $_SERVER[
"PHP_SELF"] .
'?action=overwritesite&website=' . urlencode($website->ref);
3093 print
dolButtonToOpenExportDialog(
'exportpopup', $langs->trans(
'ExportOptions'), $langs->trans(
'ExportSite'),
'exportsite', $overwriteGitUrl, $website);
3098 print
'<input type="submit" class="button bordertransp"'.$disabled.
' value="'.
dol_escape_htmltag($langs->trans(
"CloneSite")).
'" name="createfromclone">';
3101 if (!$permissiontodelete) {
3102 $disabled =
' disabled="disabled"';
3103 $title = $langs->trans(
"NotEnoughPermissions");
3106 if ($website->status == $website::STATUS_VALIDATED) {
3107 $disabled =
' disabled="disabled"';
3108 $title = $langs->trans(
"WebsiteMustBeDisabled", $langs->transnoentitiesnoconv($website->LibStatut(0, 0)));
3112 $title = $langs->trans(
"Delete");
3113 $url = $_SERVER[
"PHP_SELF"].
'?action=deletesite&token='.
newToken().
'&website='.urlencode($website->ref);
3116 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>';
3119 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>';
3122 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>';
3125 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>';
3130 if ($websitekey && $websitekey !=
'-1' && ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite')) {
3131 print
'<span class="websiteselection">';
3133 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);
3135 if (isModEnabled(
'category')) {
3137 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);
3143 print
'<input type="hidden" name="website" id="website" value="'.$websitekey.
'">';
3147 print
'<span class="websitetools">';
3149 if ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite') {
3150 $urlext = $virtualurl;
3151 $urlint = $urlwithroot.
'/public/website/index.php?website='.$websitekey;
3153 print
'<span class="websiteinputurl valignmiddle" id="websiteinputurl">';
3154 $linktotestonwebserver =
'<a href="'.($virtualurl ? $virtualurl :
'#').
'" class="valignmiddle">';
3155 $linktotestonwebserver .=
'<span class="hideonsmartphone paddingrightonly">'.$langs->trans(
"TestDeployOnWeb", $virtualurl).
'</span>'.
img_picto(
'',
'globe');
3156 $linktotestonwebserver .=
'</a>';
3159 if (empty(
$object->fk_default_home)) {
3160 $htmltext .=
'<br><span class="error">'.$langs->trans(
"YouMustDefineTheHomePage").
'</span><br><br>';
3161 } elseif (empty($virtualurl)) {
3164 $htmltext .=
'<br><center>'.$langs->trans(
"GoTo").
' <a href="'.$virtualurl.
'" target="_website">'.$virtualurl.
'</a></center><br>';
3167 $htmltext .=
'<!-- Message defined translate key set into WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER -->';
3168 $htmltext .=
'<br>'.$langs->trans(
getDolGlobalString(
'WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER'));
3170 $htmltext .= $langs->trans(
"ToDeployYourWebsiteOnLiveYouHave3Solutions").
'<br><br>';
3171 $htmltext .=
'<div class="titre inline-block">1</div> - '.$langs->trans(
"SetHereVirtualHost", $dataroot);
3172 $htmltext .=
'<br>';
3173 $htmltext .=
'<br>'.$langs->trans(
"CheckVirtualHostPerms", $langs->transnoentitiesnoconv(
"ReadPerm"), DOL_DOCUMENT_ROOT);
3174 $htmltext .=
'<br>'.$langs->trans(
"CheckVirtualHostPerms", $langs->transnoentitiesnoconv(
"WritePerm"),
'{s1}');
3175 $htmltext = str_replace(
'{s1}', DOL_DATA_ROOT.
'/website<br>'.DOL_DATA_ROOT.
'/medias', $htmltext);
3177 $examplewithapache =
"<VirtualHost *:80>\n";
3178 $examplewithapache .=
'#php_admin_value open_basedir /tmp/:'.DOL_DOCUMENT_ROOT.
':'.DOL_DATA_ROOT.
':/dev/urandom'.
"\n";
3179 $examplewithapache .=
"\n";
3180 $examplewithapache .=
'DocumentRoot "'.DOL_DOCUMENT_ROOT.
'"'.
"\n";
3181 $examplewithapache .=
"\n";
3182 $examplewithapache .=
'<Directory "'.DOL_DOCUMENT_ROOT.
'">'.
"\n";
3183 $examplewithapache .=
'AllowOverride FileInfo Options
3184 Options -Indexes -MultiViews -FollowSymLinks -ExecCGI
3186 </Directory>'.
"\n".
'
3187 <Directory "'.DOL_DATA_ROOT.
'/website">
3188 AllowOverride FileInfo Options
3189 Options -Indexes -MultiViews +FollowSymLinks -ExecCGI
3191 </Directory>'.
"\n".
'
3192 <Directory "'.DOL_DATA_ROOT.
'/medias">
3193 AllowOverride FileInfo Options
3194 Options -Indexes -MultiViews -FollowSymLinks -ExecCGI
3198 $examplewithapache .=
"\n";
3199 $examplewithapache .=
"#ErrorLog /var/log/apache2/".$websitekey.
"_error_log\n";
3200 $examplewithapache .=
"#TransferLog /var/log/apache2/".$websitekey.
"_access_log\n";
3202 $examplewithapache .=
"</VirtualHost>\n";
3204 $htmltext .=
'<br>'.$langs->trans(
"ExampleToUseInApacheVirtualHostConfig").
':<br>';
3205 $htmltext .=
'<div class="quatrevingtpercent exampleapachesetup wordbreak" spellcheck="false">'.dol_nl2br(
dol_escape_htmltag($examplewithapache, 1, 1)).
'</div>';
3207 $htmltext .=
'<br>';
3208 $htmltext .=
'<div class="titre inline-block">2</div> - '.$langs->trans(
"YouCanAlsoTestWithPHPS");
3209 $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>';
3211 $htmltext .=
'<br>';
3212 $htmltext .=
'<div class="titre inline-block">3</div> - '.$langs->trans(
"YouCanAlsoDeployToAnotherWHP");
3214 print $form->textwithpicto($linktotestonwebserver, $htmltext, 1,
'none',
'valignmiddle', 0, 3,
'helpvirtualhost');
3218 if (in_array($action, array(
'editcss',
'editmenu',
'file_manager',
'replacesiteconfirm')) || in_array($mode, array(
'replacesite'))) {
3219 if ($action ==
'editcss') {
3222 $stringforfirstkey = $langs->trans(
"KeyboardShortcut");
3223 if (
$conf->browser->name ==
'chrome') {
3224 $stringforfirstkey .=
' ALT +';
3225 } elseif (
$conf->browser->name ==
'firefox') {
3226 $stringforfirstkey .=
' ALT + SHIFT +';
3228 $stringforfirstkey .=
' CTL +';
3231 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">';
3233 if (preg_match(
'/^create/', $action) && $action !=
'file_manager' && $action !=
'replacesite' && $action !=
'replacesiteconfirm') {
3234 print
'<input type="submit" id="savefile" class="button buttonforacesave button-save small" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
3236 if (preg_match(
'/^edit/', $action) && $action !=
'file_manager' && $action !=
'replacesite' && $action !=
'replacesiteconfirm') {
3237 print
'<input type="submit" id="savefile" class="button buttonforacesave button-save small" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
3239 if ($action !=
'preview') {
3240 print
'<input type="submit" class="button button-cancel small" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'" name="cancel">';
3250 if ($websitekey && $websitekey !=
'-1' && (!in_array($action, array(
'editcss',
'editmenu',
'importsite',
'file_manager',
'replacesite',
'replacesiteconfirm'))) && (!in_array($mode, array(
'replacesite'))) && !$file_manager) {
3253 print
'<!-- Toolbar for websitepage -->';
3254 print
'<div class="centpercent websitebar"'.($style ?
' style="'.$style.
'"' :
'').
'>';
3256 print
'<div class="websiteselection hideonsmartphoneimp minwidth75 tdoverflowmax100 inline-block">';
3257 print $langs->trans(
"PageContainer").
': ';
3261 print
'<span class="websiteselection paddingrightonly">';
3262 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>';
3268 $s = $formwebsite->selectContainer($website,
'pageid', $pageid, 0, $action,
'minwidth100 maxwidth200onsmartphone');
3270 $out .=
'<span class="websiteselection nopaddingrightimp">';
3274 $urltocreatenewpage = $_SERVER[
"PHP_SELF"].
'?action=createcontainer&token='.
newToken().
'&website='.urlencode($website->ref);
3276 if (!empty(
$conf->use_javascript_ajax)) {
3277 $out .=
'<script type="text/javascript">';
3278 $out .=
'jQuery(document).ready(function () {';
3279 $out .=
' jQuery("#pageid").change(function () {';
3280 $out .=
' console.log("We select "+jQuery("#pageid option:selected").val());';
3281 $out .=
' if (jQuery("#pageid option:selected").val() == \'-2\') {';
3282 $out .=
' window.location.href = "'.$urltocreatenewpage.
'";';
3283 $out .=
' } else {';
3284 $out .=
' window.location.href = "'.$_SERVER[
"PHP_SELF"].
'?website='.urlencode($website->ref).
'&pageid="+jQuery("#pageid option:selected").val();';
3288 $out .=
'</script>';
3294 if (!empty(
$conf->use_javascript_ajax)) {
3295 print
'<span class="websiteselection">';
3297 if (
$object->status == $object::STATUS_DRAFT) {
3298 $text_off =
'SetWebsiteOnlineBefore';
3299 if ($websitepage->status == $websitepage::STATUS_DRAFT) {
3300 print
'<span class="valignmiddle disabled opacitymedium">'.img_picto($langs->trans($text_off),
'switch_off').
'</span>';
3302 print
'<span class="valignmiddle disabled opacitymedium">'.img_picto($langs->trans($text_off),
'switch_on').
'</span>';
3305 print
ajax_object_onoff($websitepage,
'status',
'status',
'Online',
'Offline', array(),
'valignmiddle inline-block'.(empty($websitepage->id) ?
' opacitymedium disabled' :
''),
'statuswebsitepage', 1,
'pageid='.$websitepage->id);
3311 print
'<span class="websiteselection">';
3313 print
'<input type="image" class="valignmiddle buttonwebsite" src="'.img_picto(
'',
'refresh',
'', 0, 1).
'" name="refreshpage" value="'.$langs->trans(
"Load").
'"'.(($action !=
'editsource') ?
'' :
' disabled="disabled"').
'>';
3316 $pagepreviousid = 0;
3319 $sql =
"SELECT MAX(rowid) as pagepreviousid FROM ".MAIN_DB_PREFIX.
"website_page WHERE rowid < ".((int) $pageid).
" AND fk_website = ".((int)
$object->id);
3320 $resql = $db->query($sql);
3322 $obj = $db->fetch_object($resql);
3324 $pagepreviousid = $obj->pagepreviousid;
3329 $sql =
"SELECT MIN(rowid) as pagenextid FROM ".MAIN_DB_PREFIX.
"website_page WHERE rowid > ".((int) $pageid).
" AND fk_website = ".((int)
$object->id);
3330 $resql = $db->query($sql);
3332 $obj = $db->fetch_object($resql);
3334 $pagenextid = $obj->pagenextid;
3341 if ($pagepreviousid) {
3342 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>';
3344 print
'<span class="valignmiddle opacitymedium">'.img_previous($langs->trans(
"PreviousContainer")).
'</span>';
3347 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>';
3349 print
'<span class="valignmiddle opacitymedium">'.img_next($langs->trans(
"NextContainer")).
'</span>';
3354 if ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite') {
3356 if (!$user->hasRight(
'website',
'write')) {
3357 $disabled =
' disabled="disabled"';
3361 if ($action ==
'deletesite') {
3363 $formquestion = array(
3364 array(
'type' =>
'checkbox',
'name' =>
'delete_also_js',
'label' => $langs->trans(
"DeleteAlsoJs"),
'value' => 0),
3365 array(
'type' =>
'checkbox',
'name' =>
'delete_also_medias',
'label' => $langs->trans(
"DeleteAlsoMedias"),
'value' => 0),
3370 if ($atleastonepage) {
3371 $langs->load(
"errors");
3372 $formquestion[] = array(
'type' =>
'onecolumn',
'value' =>
'<div class="warning">'.$langs->trans(
"WarningPagesWillBeDeleted").
'</div>');
3375 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteWebsite'),
'',
'confirm_deletesite', $formquestion, 0, 1, 210 + ($atleastonepage ? 70 : 0), 580);
3381 if ($action ==
'createfromclone') {
3383 $formquestion = array(
3384 array(
'type' =>
'text',
'name' =>
'siteref',
'label' => $langs->trans(
"WebSite"),
'value' =>
'copy_of_'.$object->ref)
3387 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'CloneSite'),
'',
'confirm_createfromclone', $formquestion, 0, 1, 200);
3392 if ($pageid > 0 && $atleastonepage) {
3394 if ($action ==
'createpagefromclone') {
3396 $preselectedlanguage =
GETPOST(
'newlang',
'aZ09') ?
GETPOST(
'newlang',
'aZ09') :
'';
3397 $onlylang = array();
3398 if ($website->otherlang) {
3399 if (!empty($website->lang)) {
3400 $onlylang[$website->lang] = $website->lang.
' ('.$langs->trans(
"Default").
')';
3402 foreach (explode(
',', $website->otherlang) as $langkey) {
3403 if (empty(trim($langkey))) {
3406 $onlylang[$langkey] = $langkey;
3408 $textifempty = $langs->trans(
"Default");
3410 $onlylang[
'none'] =
'none';
3411 $textifempty = $langs->trans(
"Default");
3413 $formquestion = array(
3414 array(
'type' =>
'hidden',
'name' =>
'sourcepageurl',
'value' => $objectpage->pageurl),
3415 array(
'type' =>
'other',
'tdclass' =>
'fieldrequired',
'name' =>
'newwebsite',
'label' => $langs->trans(
"WebSite"),
'value' => $formwebsite->selectWebsite(
$object->id,
'newwebsite', 0)),
3416 array(
'type' =>
'text',
'tdclass' =>
'maxwidth200 fieldrequired',
'moreattr' =>
'autofocus="autofocus"',
'name' =>
'newtitle',
'label' => $langs->trans(
"WEBSITE_TITLE"),
'value' => $langs->trans(
"CopyOf").
' '.$objectpage->title),
3417 array(
'type' =>
'text',
'tdclass' =>
'maxwidth200',
'name' =>
'newpageurl',
'label' => $langs->trans(
"WEBSITE_PAGENAME"),
'value' =>
'')
3419 if (count($onlylang) > 1) {
3420 $formquestion[] = array(
'type' =>
'checkbox',
'tdclass' =>
'maxwidth200',
'name' =>
'is_a_translation',
'label' => $langs->trans(
"PageIsANewTranslation"),
'value' => 0,
'morecss' =>
'margintoponly');
3423 $value = $formadmin->select_language($preselectedlanguage,
'newlang', 0, array(), $textifempty, 0, 0,
'minwidth200', 1, 0, 0, $onlylang, 1);
3424 $formquestion[] = array(
'type' =>
'other',
'name' =>
'newlang',
'label' => $form->textwithpicto($langs->trans(
"Language"), $langs->trans(
"DefineListOfAltLanguagesInWebsiteProperties")),
'value' => $value);
3426 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?website='.
$object->ref.
'&pageid='.$pageid, $langs->trans(
'ClonePage'),
'',
'confirm_createpagefromclone', $formquestion, 0, 1, 300, 550);
3431 print
'<span class="websiteselection">';
3434 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?website='.
$object->ref.
'&pageid='.$pageid.
'&action=editmeta&token='.
newToken().
'" class="button bordertransp" title="'.
dol_escape_htmltag($langs->trans(
"EditPageMeta")).
'"'.$disabled.
'><span class="fa fa-cog paddingrightonly"></span><span class="hideonsmartphone">'.
dol_escape_htmltag($langs->trans(
"EditPageMeta")).
'</span></a>';
3437 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?website='.
$object->ref.
'&pageid='.$pageid.
'&action=editsource&token='.
newToken().
'" class="button bordertransp"'.$disabled.
'>'.
dol_escape_htmltag($langs->trans(
$conf->dol_optimize_smallscreen ?
"HTML" :
"EditHTMLSource")).
'</a>';
3441 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?website='.
$object->ref.
'&pageid='.$pageid.
'&action=editcontent&token='.
newToken().
'" class="button bordertransp"'.$disabled.
'>'.
dol_escape_htmltag(
"CKEditor").
'</a>';
3443 print
'<!-- Add option WEBSITE_ALLOW_CKEDITOR to allow ckeditor -->';
3450 print
'<!-- button EditInLine and ShowSubcontainers -->'.
"\n";
3451 print
'<div class="websiteselectionsection inline-block">';
3453 print
'<div class="inline-block marginrightonly">';
3454 print $langs->trans(
"ShowSubcontainers");
3456 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>';
3458 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>';
3462 print
'<div class="inline-block marginrightonly">';
3464 print
'<span id="switchckeditorinline">'.
"\n";
3466 print
'<!-- Code to enabled edit inline ckeditor -->'.
"\n";
3467 print
'<script type="text/javascript">
3468 $(document).ready(function() {
3469 var isEditingEnabled = '.(getDolGlobalString(
"WEBSITE_EDITINLINE") ?
'true' :
'false').
';
3470 if (isEditingEnabled)
3472 switchEditorOnline(true);
3475 $( "#switchckeditorinline" ).click(function() {
3476 switchEditorOnline();
3479 function switchEditorOnline(forceenable)
3481 if (! isEditingEnabled || forceenable)
3483 console.log("Enable inline edit for some html tags with contenteditable=true attribute");
3485 jQuery(\'section[contenteditable="true"],div[contenteditable="true"],header[contenteditable="true"],main[contenteditable="true"],footer[contenteditable="true"]\').each(function(idx){
3486 var idtouse = $(this).attr(\'id\');
3487 console.log("Enable inline edit for "+idtouse);
3488 if (idtouse !== undefined) {
3489 var inlineditor = CKEDITOR.inline(idtouse, {
3490 // Allow some non-standard markup that we used in the introduction.
3491 // + a[target];div{float,display} ?
3492 extraAllowedContent: \'span(*);cite(*);q(*);dl(*);dt(*);dd(*);ul(*);li(*);header(*);main(*);footer(*);button(*);h1(*);h2(*);h3(*);\',
3493 //extraPlugins: \'sourcedialog\',
3494 removePlugins: \'flash,stylescombo,exportpdf,scayt,wsc,pagebreak,iframe,smiley\',
3495 // Show toolbar on startup (optional).
3496 // startupFocus: true
3500 // Note the Source tool does not work on inline
3501 inlineditor.config.toolbar = [
3502 [\'Templates\',\'NewPage\'],
3504 [\'Maximize\',\'Preview\'],
3506 [\'Undo\',\'Redo\',\'-\',\'Find\',\'Replace\',\'-\',\'SelectAll\',\'RemoveFormat\'],
3507 [\'CreateDiv\',\'ShowBlocks\'],
3508 [\'Form\', \'Checkbox\', \'Radio\', \'TextField\', \'Textarea\', \'Select\', \'Button\', \'ImageButton\', \'HiddenField\'],
3509 [\'Bold\',\'Italic\',\'Underline\',\'Strike\',\'Superscript\'],
3510 [\'NumberedList\',\'BulletedList\',\'-\',\'Outdent\',\'Indent\',\'Blockquote\'],
3511 [\'JustifyLeft\',\'JustifyCenter\',\'JustifyRight\',\'JustifyBlock\'],
3512 [\'Link\',\'Unlink\'],
3513 [\'Image\',\'Table\',\'HorizontalRule\'],
3514 [\'Styles\',\'Format\',\'Font\',\'FontSize\'],
3515 [\'TextColor\',\'BGColor\']
3519 //inlineditor.on(\'instanceReady\', function () {
3523 CKEDITOR.instances[idtouse].on(\'change\', function() {
3524 $(this.element.$).addClass(\'modified\');
3527 console.warn("A html section has the contenteditable=true attribute but has no id attribute");
3531 isEditingEnabled = true;
3533 // Trigger the function when clicking outside the elements with contenteditable=true attribute
3534 $(document).on(\'click\', function(e) {
3535 var target = $(e.target);
3536 // Check if the click is outside the elements with contenteditable=true attribute
3537 if (!target.closest(\'[contenteditable="true"]\').length) {
3538 // Repeat through the elements with contenteditable="true" attribute
3539 $(\'[contenteditable="true"]\').each(function() {
3540 var idToUse = $(this).attr(\'id\');
3541 var elementType = $(this).prop("tagName").toLowerCase(); // Get the tag name (div, section, footer...)
3542 var instance = CKEDITOR.instances[idToUse];
3543 // Check if the element has been modified
3544 if ($(this).hasClass(\'modified\')) {
3545 var content = instance.getData();
3546 content = "\\n" + content;
3548 // Retrieving the content and ID of the element
3549 var elementId = $(this).attr(\'id\');
3551 // Sending data via AJAX
3554 url: \'' . DOL_URL_ROOT .
'/core/ajax/editinline.php\',
3556 website_ref: \''.$website->ref.
'\',
3557 page_id: \
'' . $websitepage->id .
'\',
3559 element_id: elementId,
3560 element_type: elementType,
3561 action: \'updatedElementContent\',
3564 success: function(response) {
3565 console.log(response);
3566 var $lastWebsitebar = $(".websitebar").last();
3567 var $span = $("<span></span>").html("'.$langs->trans(
"Saved").
'").css({
3568 \'display\': \'block\',
3569 \'position\': \'absolute\',
3570 \'margin-top\': \'6px\',
3572 \'background-color\': \'#e3f0db\',
3573 \'color\': \'#446548\',
3574 \'font-size\': \'14px\',
3575 \'padding\': \'0px 5px\',
3578 $lastWebsitebar.after($span);
3580 // Close message after 2 seconds
3581 setTimeout(function() {
3582 $span.fadeOut(500, function() {
3589 $(this).removeClass(\'modified\');
3596 console.log("Disable inline edit");
3597 for(name in CKEDITOR.instances) {
3598 CKEDITOR.instances[name].destroy(true);
3600 isEditingEnabled = false;
3605 print $langs->trans(
"EditInLine");
3609 $disableeditinline = 0;
3610 if ($disableeditinline) {
3612 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>';
3616 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>';
3618 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>';
3627 print
'<span class="websiteselection">';
3628 if (
$object->fk_default_home > 0 && $pageid ==
$object->fk_default_home) {
3632 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>';
3636 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>';
3638 print
'<input type="submit" class="button bordertransp"'.$disabled.
' value="'.
dol_escape_htmltag($langs->trans(
"ClonePage")).
'" name="createpagefromclone">';
3641 if ($websitepage->status != $websitepage::STATUS_DRAFT) {
3642 $disabled =
' disabled="disabled"';
3643 $title = $langs->trans(
"WebpageMustBeDisabled", $langs->transnoentitiesnoconv($websitepage->LibStatut(0, 0)));
3648 $url = $_SERVER[
"PHP_SELF"].
'?action=delete&token='.
newToken().
'&pageid='.((int) $websitepage->id).
'&website='.urlencode($website->ref);
3650 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>';
3657 print
'<span class="websitetools">';
3659 if (($pageid > 0 && $atleastonepage) && ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite')) {
3660 $realpage = $urlwithroot.
'/public/website/index.php?website='.$websitekey.
'&pageref='.$websitepage->pageurl;
3661 $pagealias = $websitepage->pageurl;
3663 $htmltext = $langs->trans(
"PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv(
"Page"), $langs->transnoentitiesnoconv(
"Page"), $realpage, $langs->transnoentitiesnoconv(
"TestDeployOnWeb"));
3669 print
'<div class="websiteinputurl inline-block paddingright">';
3670 print
'<a class="websitebuttonsitepreview inline-block" id="previewpage" href="'.$realpage.
'&nocache='.
dol_now().
'" class="button" target="tab'.$websitekey.
'" alt="'.
dol_escape_htmltag($htmltext).
'">';
3671 print $form->textwithpicto(
'', $htmltext, 1,
'preview');
3695 if (!in_array($mode, array(
'replacesite')) && !in_array($action, array(
'editcss',
'editmenu',
'file_manager',
'replacesiteconfirm',
'createsite',
'createcontainer',
'createfromclone',
'createpagefromclone',
'deletesite'))) {
3696 if ($action ==
'editsource' || $action ==
'editmeta') {
3699 $stringforfirstkey = $langs->trans(
"KeyboardShortcut");
3700 if (
$conf->browser->name ==
'chrome') {
3701 $stringforfirstkey .=
' ALT +';
3702 } elseif (
$conf->browser->name ==
'firefox') {
3703 $stringforfirstkey .=
' ALT + SHIFT +';
3705 $stringforfirstkey .=
' CTL +';
3708 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">';
3710 if (preg_match(
'/^create/', $action)) {
3711 print
'<input type="submit" id="savefile" class="button buttonforacesave button-save small" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
3713 if (preg_match(
'/^edit/', $action)) {
3714 print
'<input type="submit" id="savefile" class="button buttonforacesave button-save small" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
3716 if ($action !=
'preview') {
3717 print
'<input type="submit" class="button button-cancel small" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'" name="cancel">';
3723 print
'<span class="websitehelp">';
3724 if ($action ==
'editsource' || $action ==
'editcontent' ||
GETPOST(
'editsource',
'alpha') ||
GETPOST(
'editcontent',
'alpha')) {
3725 $url =
'https://wiki.dolibarr.org/index.php/Module_Website';
3727 $htmltext =
'<small>';
3728 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource", $url);
3729 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource1", $url);
3730 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource2", $url);
3731 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource3", $url);
3732 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource4", $url);
3733 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSourceMore", $url);
3734 $htmltext .=
'<br>';
3735 $htmltext .=
'</small>';
3736 if (
$conf->browser->layout ==
'phone') {
3737 print $form->textwithpicto(
'', $htmltext, 1,
'help',
'inline-block', 1, 2,
'tooltipsubstitution');
3740 print $form->textwithpicto($langs->trans(
"SyntaxHelp").
' '.
img_help(2, $langs->trans(
"SyntaxHelp")), $htmltext, 1,
'none',
'inline-block', 1, 2,
'tooltipsubstitution');
3746 if ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone') {
3748 if (!empty(
$conf->use_javascript_ajax)) {
3749 print
'<script type="text/javascript">
3750 jQuery(document).ready(function() {
3751 jQuery("#websiteinputurl").keyup(function() {
3752 console.log("Website external url modified "+jQuery("#previewsiteurl").val());
3753 if (jQuery("#previewsiteurl").val() != "" && jQuery("#previewsiteurl").val().startsWith("http"))
3755 jQuery("a.websitebuttonsitepreviewdisabled img").css({ opacity: 1 });
3757 else jQuery("a.websitebuttonsitepreviewdisabled img").css({ opacity: 0.2 });
3761 jQuery("#previewsiteext,#previewpageext").click(function() {
3763 newurl=jQuery("#previewsiteurl").val();
3764 if (! newurl.startsWith("http"))
3766 alert(\''.dol_escape_js($langs->trans(
"ErrorURLMustStartWithHttp")).
'\');
3770 newpage=jQuery(
"#previewsiteurl").val() +
"/" + jQuery(
"#previewpageurl").val() +
".php";
3771 console.log(
"Open url "+newurl);
3775 url:
"'.DOL_URL_ROOT.'/core/ajax/saveinplace.php",
3777 field: \
'editval_virtualhost\',
3778 element: \'website\',
3779 table_element: \'website\',
3780 fk_element: '.((int)
$object->id).
',
3783 context: document.body
3786 jQuery("#previewsiteext").attr("href",newurl);
3787 jQuery("#previewpageext").attr("href",newpage);
3806if ($action ==
'editcss') {
3807 print
'<div class="fiche">';
3811 if (!GETPOSTISSET(
'WEBSITE_CSS_INLINE')) {
3812 $csscontent = @file_get_contents($filecss);
3814 $csscontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $csscontent);
3816 $csscontent =
GETPOST(
'WEBSITE_CSS_INLINE',
'none');
3818 if (!trim($csscontent)) {
3819 $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;}";
3822 if (!GETPOSTISSET(
'WEBSITE_JS_INLINE')) {
3823 $jscontent = @file_get_contents($filejs);
3825 $jscontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $jscontent);
3827 $jscontent =
GETPOST(
'WEBSITE_JS_INLINE',
'none');
3829 if (!trim($jscontent)) {
3830 $jscontent =
'/* JS content (all pages) */'.
"\n";
3833 if (!GETPOSTISSET(
'WEBSITE_HTML_HEADER')) {
3834 $htmlheadercontent = @file_get_contents($filehtmlheader);
3836 $htmlheadercontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $htmlheadercontent);
3838 $htmlheadercontent =
GETPOST(
'WEBSITE_HTML_HEADER',
'none');
3840 if (!trim($htmlheadercontent)) {
3841 $htmlheadercontent =
"<html>\n";
3842 $htmlheadercontent .= $htmlheadercontentdefault;
3843 $htmlheadercontent .=
"</html>";
3845 $htmlheadercontent = preg_replace(
'/^\s*<html>/ims',
'', $htmlheadercontent);
3846 $htmlheadercontent = preg_replace(
'/<\/html>\s*$/ims',
'', $htmlheadercontent);
3847 $htmlheadercontent =
'<html>'.
"\n".trim($htmlheadercontent).
"\n".
'</html>';
3850 if (!GETPOSTISSET(
'WEBSITE_ROBOT')) {
3851 $robotcontent = @file_get_contents($filerobot);
3853 $robotcontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $robotcontent);
3855 $robotcontent =
GETPOST(
'WEBSITE_ROBOT',
'nohtml');
3857 if (!trim($robotcontent)) {
3858 $robotcontent .=
"# Robot file. Generated with ".DOL_APPLICATION_TITLE.
"\n";
3859 $robotcontent .=
"User-agent: *\n";
3860 $robotcontent .=
"Allow: /public/\n";
3861 $robotcontent .=
"Disallow: /administrator/\n";
3864 if (!GETPOSTISSET(
'WEBSITE_HTACCESS')) {
3865 $htaccesscontent = @file_get_contents($filehtaccess);
3867 $htaccesscontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $htaccesscontent);
3869 $htaccesscontent =
GETPOST(
'WEBSITE_HTACCESS',
'nohtml');
3871 if (!trim($htaccesscontent)) {
3872 $htaccesscontent .=
"# Order allow,deny\n";
3873 $htaccesscontent .=
"# Deny from all\n";
3876 if (!GETPOSTISSET(
'WEBSITE_MANIFEST_JSON')) {
3877 $manifestjsoncontent = @file_get_contents($filemanifestjson);
3879 $manifestjsoncontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $manifestjsoncontent);
3881 $manifestjsoncontent =
GETPOST(
'WEBSITE_MANIFEST_JSON',
'restricthtml');
3887 if (!GETPOSTISSET(
'WEBSITE_README')) {
3888 $readmecontent = @file_get_contents($filereadme);
3890 $readmecontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $readmecontent);
3892 $readmecontent =
GETPOST(
'WEBSITE_README',
'restricthtmlallowunvalid');
3898 if (!GETPOSTISSET(
'WEBSITE_LICENSE')) {
3899 $licensecontent = @file_get_contents($filelicense);
3901 $licensecontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $licensecontent);
3903 $licensecontent =
GETPOST(
'WEBSITE_LICENSE',
'restricthtmlallowunvalid');
3911 print
'<!-- Edit Website properties -->'.
"\n";
3912 print
'<table class="border centpercent">';
3915 print
'<tr><td class="titlefieldcreate fieldrequired">';
3916 print $langs->trans(
'WebSite');
3922 if ($action !=
'createcontainer') {
3923 if (empty(
$conf->use_javascript_ajax)) {
3924 print
'<!-- Status of web site page -->'.
"\n";
3925 print
'<tr><td class="fieldrequired">';
3926 print $langs->trans(
'Status');
3928 print $form->selectyesno(
'status',
$object->status);
3934 print
'<tr><td class="tdtop fieldrequired">';
3936 print $form->textwithpicto($langs->trans(
'MainLanguage'), $htmltext, 1,
'help',
'', 0, 2,
'WEBSITE_LANG');
3938 print
img_picto(
'',
'language',
'class="picotfixedwidth"');
3939 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);
3944 print
'<tr><td class="tdtop">';
3945 $htmltext = $langs->trans(
"Example").
': fr,de,sv,it,pt';
3946 print $form->textwithpicto($langs->trans(
'OtherLanguages'), $htmltext, 1,
'help',
'', 0, 2);
3948 print
img_picto(
'',
'language',
'class="picotfixedwidth"');
3949 print
'<input type="text" class="flat" value="'.(GETPOSTISSET(
'WEBSITE_OTHERLANG') ?
GETPOST(
'WEBSITE_OTHERLANG',
'alpha') :
$object->otherlang).
'" name="WEBSITE_OTHERLANG">';
3954 print
'<tr><td class="tdtop">';
3956 $htmltext = $langs->trans(
"VirtualhostDesc");
3957 print $form->textwithpicto($langs->trans(
'Virtualhost'), $htmltext, 1,
'help',
'', 0, 2,
'virtualhosttooltip');
3959 print
'<input type="text" class="flat minwidth300" value="'.(GETPOSTISSET(
'virtualhost') ?
GETPOST(
'virtualhost',
'alpha') : $virtualurl).
'" name="virtualhost">';
3965 print $form->textwithpicto($langs->trans(
'ImportFavicon'), $langs->trans(
'FaviconTooltip'));
3968 $maxmin = $maxfilesizearray[
'maxmin'];
3970 print
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
3972 print
'<input type="file" class="flat minwidth300" name="addedfile" id="addedfile"/>';
3974 $uploadfolder =
$conf->website->dir_output.
'/'.$websitekey;
3976 print
'<div class="inline-block valignmiddle marginrightonly">';
3977 print
'<img style="max-height: 80px" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart=website&file='.$websitekey.
'/favicon.png">';
3983 print
'<tr><td class="tdtop">';
3984 $htmlhelp = $langs->trans(
"CSSContentTooltipHelp");
3985 print $form->textwithpicto($langs->trans(
'WEBSITE_CSS_INLINE'), $htmlhelp, 1,
'help',
'', 0, 2,
'csstooltip');
3988 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_CSS_INLINE_x'),
'y' =>
GETPOST(
'WEBSITE_CSS_INLINE_y'));
3989 $doleditor =
new DolEditor(
'WEBSITE_CSS_INLINE', $csscontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
3990 print $doleditor->Create(1,
'',
true,
'CSS',
'css');
3995 print
'<tr><td class="tdtop">';
3996 $textwithhelp = $langs->trans(
'WEBSITE_JS_INLINE');
3997 $htmlhelp2 = $langs->trans(
"LinkAndScriptsHereAreNotLoadedInEditor").
'<br>';
3998 print $form->textwithpicto($textwithhelp, $htmlhelp2, 1,
'warning',
'', 0, 2,
'htmljstooltip2');
4002 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_JS_INLINE_x'),
'y' =>
GETPOST(
'WEBSITE_JS_INLINE_y'));
4003 $doleditor =
new DolEditor(
'WEBSITE_JS_INLINE', $jscontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4004 print $doleditor->Create(1,
'',
true,
'JS',
'javascript');
4009 print
'<tr><td class="tdtop">';
4010 print $langs->trans(
'WEBSITE_HTML_HEADER');
4011 $htmlhelp = $langs->trans(
"Example").
' :<br>';
4013 $textwithhelp = $form->textwithpicto(
'', $htmlhelp, 1,
'help',
'', 0, 2,
'htmlheadertooltip');
4014 $htmlhelp2 = $langs->trans(
"LinkAndScriptsHereAreNotLoadedInEditor").
'<br>';
4015 print $form->textwithpicto($textwithhelp, $htmlhelp2, 1,
'warning',
'', 0, 2,
'htmlheadertooltip2');
4018 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_HTML_HEADER_x'),
'y' =>
GETPOST(
'WEBSITE_HTML_HEADER_y'));
4019 $doleditor =
new DolEditor(
'WEBSITE_HTML_HEADER', $htmlheadercontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4020 print $doleditor->Create(1,
'',
true,
'HTML Header',
'html');
4025 print
'<tr><td class="tdtop">';
4026 print $langs->trans(
'WEBSITE_ROBOT');
4029 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_ROBOT_x'),
'y' =>
GETPOST(
'WEBSITE_ROBOT_y'));
4030 $doleditor =
new DolEditor(
'WEBSITE_ROBOT', $robotcontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4031 print $doleditor->Create(1,
'',
true,
'Robot file',
'text');
4036 print
'<tr><td class="tdtop">';
4037 print $langs->trans(
'WEBSITE_HTACCESS');
4040 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_HTACCESS_x'),
'y' =>
GETPOST(
'WEBSITE_HTACCESS_y'));
4041 $doleditor =
new DolEditor(
'WEBSITE_HTACCESS', $htaccesscontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4042 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' .htaccess',
'text');
4047 print
'<tr><td class="tdtop">';
4048 $htmlhelp = $langs->trans(
"Example").
' :<br>';
4049 $htmlhelp .=
'<small>'.dol_htmlentitiesbr($manifestjsoncontentdefault).
'</small>';
4050 print $form->textwithpicto($langs->trans(
'WEBSITE_MANIFEST_JSON'), $htmlhelp, 1,
'help',
'', 0, 2,
'manifestjsontooltip');
4052 print $langs->trans(
"UseManifest").
': '.$form->selectyesno(
'use_manifest', $website->use_manifest, 1).
'<br>';
4054 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_MANIFEST_JSON_x'),
'y' =>
GETPOST(
'WEBSITE_MANIFEST_JSON_y'));
4055 $doleditor =
new DolEditor(
'WEBSITE_MANIFEST_JSON', $manifestjsoncontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4056 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' manifest.json',
'text');
4060 print
'<tr><td class="tdtop">';
4061 $htmlhelp = $langs->trans(
"EnterHereReadmeInformation");
4062 print $form->textwithpicto($langs->trans(
"File").
' README.md', $htmlhelp, 1,
'help',
'', 0, 2,
'readmetooltip');
4065 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_README_x'),
'y' =>
GETPOST(
'WEBSITE_README_y'));
4066 $doleditor =
new DolEditor(
'WEBSITE_README', $readmecontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4067 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' README.md',
'text');
4072 print
'<tr><td class="tdtop">';
4073 $htmlhelp = $langs->trans(
"EnterHereLicenseInformation");
4074 print $form->textwithpicto($langs->trans(
"File").
' LICENSE', $htmlhelp, 1,
'help',
'', 0, 2,
'licensetooltip');
4077 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_LICENSE_x'),
'y' =>
GETPOST(
'WEBSITE_LICENSE_y'));
4078 $doleditor =
new DolEditor(
'WEBSITE_LICENSE', $licensecontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4079 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' LICENSE',
'text');
4084 print
'<tr><td class="tdtop">';
4085 $htmlhelp = $langs->trans(
'RSSFeedDesc');
4086 print $form->textwithpicto($langs->trans(
'RSSFeed'), $htmlhelp, 1,
'help',
'', 0, 2,
'');
4088 print
'/wrapper.php?rss=1[&l=XX][&limit=123]';
4101if ($action ==
'createsite') {
4102 print
'<div class="fiche">';
4116 if ($action ==
'createcontainer') {
4120 print
'<!-- Add site -->'.
"\n";
4121 print
'<div class="tabBar tabBarWithBottom">';
4123 print
'<table class="border centpercent">';
4125 $siteref = $sitedesc = $sitelang = $siteotherlang =
'';
4127 $siteref =
GETPOST(
'WEBSITE_REF',
'aZ09');
4129 if (
GETPOST(
'WEBSITE_DESCRIPTION')) {
4130 $sitedesc =
GETPOST(
'WEBSITE_DESCRIPTION',
'alpha');
4132 if (
GETPOST(
'WEBSITE_LANG')) {
4133 $sitelang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
4135 if (
GETPOST(
'WEBSITE_OTHERLANG')) {
4136 $siteotherlang =
GETPOST(
'WEBSITE_OTHERLANG',
'aZ09comma');
4139 print
'<tr><td class="titlefieldcreate fieldrequired">';
4140 print $form->textwithpicto($langs->trans(
'WebsiteName'), $langs->trans(
"Example").
': MyPortal, www.mywebsite.com, ...');
4142 print
'<input type="text" class="flat maxwidth300" name="WEBSITE_REF" value="'.dol_escape_htmltag($siteref).
'" autofocus>';
4145 print
'<tr><td class="fieldrequired">';
4146 print $langs->trans(
'MainLanguage');
4148 $shortlangcode = preg_replace(
'/[_-].*$/',
'', trim($langs->defaultlang));
4149 print
img_picto(
'',
'language',
'class="pictofixedwidth"');
4150 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);
4154 $htmltext = $langs->trans(
"Example").
': fr,de,sv,it,pt';
4155 print $form->textwithpicto($langs->trans(
'OtherLanguages'), $htmltext, 1,
'help',
'', 0, 2);
4157 print
img_picto(
'',
'language',
'class="pictofixedwidth"');
4158 print
'<input type="text" class="flat minwidth300" name="WEBSITE_OTHERLANG" value="'.dol_escape_htmltag($siteotherlang).
'">';
4162 print $langs->trans(
'Description');
4164 print
'<input type="text" class="flat minwidth500" name="WEBSITE_DESCRIPTION" value="'.dol_escape_htmltag($sitedesc).
'">';
4169 $htmltext = $langs->trans(
"VirtualhostDesc");
4177 print $form->textwithpicto($langs->trans(
'Virtualhost'), $htmltext, 1,
'help',
'', 0, 2,
'');
4179 print
'<input type="text" class="flat minwidth300" name="virtualhost" value="'.dol_escape_htmltag(
GETPOST(
'virtualhost',
'alpha')).
'">';
4185 if ($action ==
'createsite') {
4186 print
'<div class="center">';
4188 print
'<input type="submit" class="button small" name="addcontainer" value="'.$langs->trans(
"Create").
'">';
4189 print
'<input class="button button-cancel small" type="submit" name="preview" value="'.$langs->trans(
"Cancel").
'">';
4204if ($action ==
'importsite') {
4205 print
'<!-- action=importsite -->';
4206 print
'<div class="fiche">';
4214 print
'<span class="opacitymedium">'.$langs->trans(
"ZipOfWebsitePackageToImport").
'</span><br><br>';
4217 $dolibarrdataroot = preg_replace(
'/([\\/]+)$/i',
'', DOL_DATA_ROOT);
4218 $allowimportsite =
true;
4219 if (
dol_is_file($dolibarrdataroot.
'/installmodules.lock')) {
4220 $allowimportsite =
false;
4223 if ($allowimportsite) {
4225 $maxmin = $maxfilesizearray[
'maxmin'];
4227 print
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
4229 print
'<input class="flat minwidth400" type="file" name="userfile[]" accept=".zip">';
4230 print
'<input type="submit" class="button small" name="buttonsubmitimportfile" value="'.dol_escape_htmltag($langs->trans(
"Upload")).
'">';
4231 print
'<input type="submit" class="button button-cancel small" name="preview" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
4232 print
'<br><br><br>';
4236 $message = $langs->trans(
'InstallModuleFromWebHasBeenDisabledContactUs');
4239 $message = $langs->trans(
"InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.
'/installmodules.lock');
4245 print
'<span class="opacitymedium">'.$langs->trans(
"ZipOfWebsitePackageToLoad").
'</span><br><br>';
4256if ($action ==
'editmeta' || $action ==
'createcontainer') {
4257 print
'<div class="fiche">';
4271 if ($action ==
'createcontainer') {
4275 print
'<!-- Edit or create page/container -->'.
"\n";
4278 $hiddenfromfetchingafterload =
' hideobject';
4279 $hiddenmanuallyafterload =
' hideobject';
4280 if (
GETPOST(
'radiocreatefrom') ==
'checkboxcreatefromfetching') {
4281 $hiddenfromfetchingafterload =
'';
4283 if (
GETPOST(
'radiocreatefrom') ==
'checkboxcreatemanually') {
4284 $hiddenmanuallyafterload =
'';
4287 if ($action ==
'editmeta' || empty(
$conf->use_javascript_ajax)) {
4288 $hiddenfromfetchingafterload =
'';
4289 $hiddenmanuallyafterload =
'';
4292 if ($action ==
'createcontainer') {
4295 if (!empty(
$conf->use_javascript_ajax)) {
4296 print
'<input type="radio" name="radiocreatefrom" id="checkboxcreatemanually" value="checkboxcreatemanually"'.(GETPOST(
'radiocreatefrom') ==
'checkboxcreatemanually' ?
' checked' :
'').
'> ';
4298 print
'<label for="checkboxcreatemanually"><span class="opacitymediumxx">'.$langs->trans(
"OrEnterPageInfoManually").
'</span></label><br>';
4299 print
'<hr class="tablecheckboxcreatemanually'.$hiddenmanuallyafterload.
'">';
4302 print
'<table class="border tableforfield nobackground centpercent tablecheckboxcreatemanually'.$hiddenmanuallyafterload.
'">';
4304 if ($action !=
'createcontainer') {
4305 print
'<tr><td class="titlefield fieldrequired">';
4306 print $langs->trans(
'IDOfPage').
' - '.$langs->trans(
'InternalURLOfPage');
4314 print
' - ';
4315 print
'/public/website/index.php?website='.urlencode($websitekey).
'&pageid='.urlencode((
string) $pageid);
4319 $type_container = $objectpage->type_container;
4320 $pageurl = $objectpage->pageurl;
4321 $pagealiasalt = $objectpage->aliasalt;
4322 $pagetitle = $objectpage->title;
4323 $pagedescription = $objectpage->description;
4324 $pageimage = $objectpage->image;
4325 $pagekeywords = $objectpage->keywords;
4326 $pagelang = $objectpage->lang;
4327 $pageallowedinframes = $objectpage->allowed_in_frames;
4328 $pagehtmlheader = $objectpage->htmlheader;
4329 $pagedatecreation = $objectpage->date_creation;
4330 $pagedatemodification = $objectpage->date_modification;
4331 $pageauthorid = $objectpage->fk_user_creat;
4332 $pageusermodifid = $objectpage->fk_user_modif;
4333 $pageauthoralias = $objectpage->author_alias;
4334 $pagestatus = $objectpage->status;
4336 $type_container =
'page';
4340 $pagedescription =
'';
4344 $pageallowedinframes = 0;
4345 $pagehtmlheader =
'';
4346 $pagedatecreation =
dol_now();
4347 $pagedatemodification =
'';
4348 $pageauthorid = $user->id;
4349 $pageusermodifid = 0;
4350 $pageauthoralias =
'';
4353 if (
GETPOST(
'WEBSITE_TITLE',
'alpha')) {
4354 $pagetitle = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_TITLE',
'alphanohtml'));
4356 if (
GETPOST(
'WEBSITE_PAGENAME',
'alpha')) {
4357 $pageurl =
GETPOST(
'WEBSITE_PAGENAME',
'alpha');
4359 if (
GETPOST(
'WEBSITE_ALIASALT',
'alpha')) {
4360 $pagealiasalt = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_ALIASALT',
'alphanohtml'));
4362 if (
GETPOST(
'WEBSITE_DESCRIPTION',
'alpha')) {
4363 $pagedescription = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml'));
4365 if (
GETPOST(
'WEBSITE_IMAGE',
'alpha')) {
4366 $pageimage =
GETPOST(
'WEBSITE_IMAGE',
'alpha');
4368 if (
GETPOST(
'WEBSITE_KEYWORDS',
'alpha')) {
4369 $pagekeywords = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_KEYWORDS',
'alphanohtml'));
4371 if (
GETPOST(
'WEBSITE_LANG',
'aZ09')) {
4372 $pagelang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
4374 if (
GETPOST(
'WEBSITE_ALLOWED_IN_FRAMES',
'aZ09')) {
4375 $pageallowedinframes =
GETPOST(
'WEBSITE_ALLOWED_IN_FRAMES',
'aZ09') ? 1 : 0;
4377 if (
GETPOST(
'htmlheader',
'none')) {
4378 $pagehtmlheader =
GETPOST(
'htmlheader',
'none');
4381 if ($action !=
'createcontainer') {
4382 if (empty(
$conf->use_javascript_ajax)) {
4383 print
'<!-- Status of web site page -->'.
"\n";
4384 print
'<tr><td class="fieldrequired">';
4385 print $langs->trans(
'Status');
4387 print $form->selectyesno(
'status', $objectpage->status);
4393 print
'<tr><td class="titlefield fieldrequired">';
4394 print $langs->trans(
'WEBSITE_TYPE_CONTAINER');
4396 print
img_picto(
'',
'object_technic',
'class="paddingrightonly"').
' ';
4397 print $formwebsite->selectTypeOfContainer(
'WEBSITE_TYPE_CONTAINER', (
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'alpha') ?
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'alpha') : $type_container), 0,
'', 1,
'minwidth300');
4400 print
'<script type="text/javascript">
4401 jQuery(document).ready(function() {
4402 jQuery("#selectWEBSITE_TYPE_CONTAINER").change(function() {
4403 console.log("We change type of page : "+jQuery("#selectWEBSITE_TYPE_CONTAINER").val());
4404 if (jQuery("#selectWEBSITE_TYPE_CONTAINER").val() == \'blogpost\') {
4405 jQuery(".trpublicauthor").show();
4407 jQuery(".trpublicauthor").hide();
4409 if (jQuery("#selectWEBSITE_TYPE_CONTAINER").val() == \'service\' || jQuery("#selectWEBSITE_TYPE_CONTAINER").val() == \'library\') {
4410 $(".spanprefix").html("_" + $("#selectWEBSITE_TYPE_CONTAINER").val() + "_");
4411 jQuery(".spanprefix").show();
4413 jQuery(".spanprefix").hide();
4417 // Force at init execution a first time of the handler change
4418 jQuery("#selectWEBSITE_TYPE_CONTAINER").trigger(\'change\');
4424 print
'<tr><td class="fieldrequired">';
4425 print $langs->trans(
'WEBSITE_TITLE');
4427 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_TITLE" id="WEBSITE_TITLE" value="'.dol_escape_htmltag($pagetitle).
'" autofocus>';
4431 print
'<tr><td class="titlefieldcreate fieldrequired">';
4432 print $langs->trans(
'WEBSITE_PAGENAME');
4434 print
'<span class="opacitymedium spanprefix hidden"></span> ';
4435 print
'<input type="text" class="flat minwidth300" name="WEBSITE_PAGENAME" id="WEBSITE_PAGENAME" value="'.dol_escape_htmltag((
string) preg_replace(
'/^_[a-z]+_/',
'', (
string) $pageurl)).
'">';
4438 print
'<script type="text/javascript">
4439 $(document).ready(function() {
4440 console.log("Manage prefix for service or library");
4441 if ($("#selectWEBSITE_TYPE_CONTAINER").val() == "service" || $("#selectWEBSITE_TYPE_CONTAINER").val() == "library") {
4442 $(".spanprefix").html("_" + $("#selectWEBSITE_TYPE_CONTAINER").val() + "_");
4443 $(".spanprefix").show();
4445 $(".websiteformtoolbar").on("submit", function(event) {
4446 if ($("#selectWEBSITE_TYPE_CONTAINER").val() == "service" || $("#selectWEBSITE_TYPE_CONTAINER").val() == "library") {
4447 var prefix = "_" + $("#selectWEBSITE_TYPE_CONTAINER").val() + "_";
4448 var userInput = $("#WEBSITE_PAGENAME").val();
4449 var $inputField = $("#WEBSITE_PAGENAME");
4450 if (userInput.indexOf(prefix) !== 0) {
4451 $inputField.val(prefix + userInput);
4459 print
'<tr><td class="titlefieldcreate">';
4460 $htmlhelp = $langs->trans(
"WEBSITE_ALIASALTDesc");
4461 print $form->textwithpicto($langs->trans(
'WEBSITE_ALIASALT'), $htmlhelp, 1,
'help',
'', 0, 2,
'aliastooltip');
4463 print
'<input type="text" class="flat minwidth500" name="WEBSITE_ALIASALT" value="'.dol_escape_htmltag($pagealiasalt).
'">';
4467 print $langs->trans(
'WEBSITE_DESCRIPTION');
4469 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_DESCRIPTION" value="'.dol_escape_htmltag($pagedescription).
'">';
4474 print
'<tr class="trimageforpage hidden"><td>';
4475 $htmlhelp = $langs->trans(
"WEBSITE_IMAGEDesc");
4476 print $form->textwithpicto($langs->trans(
'WEBSITE_IMAGE'), $htmlhelp, 1,
'help',
'', 0, 2,
'imagetooltip');
4478 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_IMAGE" value="'.dol_escape_htmltag($pageimage).
'">';
4481 print
'<script type="text/javascript">
4482 jQuery(document).ready(function() {
4483 jQuery("#selectWEBSITE_TYPE_CONTAINER").change(function() {
4484 console.log("We change type of page : "+jQuery("#selectWEBSITE_TYPE_CONTAINER").val());
4485 if (jQuery("#selectWEBSITE_TYPE_CONTAINER").val() == \'blogpost\') {
4486 jQuery(".trimageforpage").show();
4488 jQuery(".trimageforpage").hide();
4498 $htmlhelp = $langs->trans(
"WEBSITE_KEYWORDSDesc");
4499 print $form->textwithpicto($langs->trans(
'WEBSITE_KEYWORDS'), $htmlhelp, 1,
'help',
'', 0, 2,
'keywordtooltip');
4501 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_KEYWORDS" value="'.dol_escape_htmltag($pagekeywords).
'">';
4505 print $langs->trans(
'Language');
4507 $onlykeys = array();
4511 $onlykeys[$langs->defaultlang] = $langs->defaultlang;
4514 $tmparray = explode(
',',
$object->otherlang);
4515 foreach ($tmparray as $key) {
4516 $tmpkey = trim($key);
4517 if (strlen($key) == 2) {
4518 $tmpkey = strtolower($key);
4520 $onlykeys[$tmpkey] = $tmpkey;
4526 print
img_picto(
'',
'language',
'class="pictofixedwidth"').$formadmin->select_language($pagelang ? $pagelang :
'',
'WEBSITE_LANG', 0, array(),
'1', 0, 0,
'minwidth200', 0, 0, 0, $onlykeys, 1);
4527 $htmltext = $langs->trans(
"AvailableLanguagesAreDefinedIntoWebsiteProperties");
4528 print $form->textwithpicto(
'', $htmltext);
4534 print
'<!-- Translation of --><tr><td>';
4535 print $langs->trans(
'TranslationLinks');
4537 if ($action !=
'createcontainer') {
4539 $sql =
"SELECT rowid, lang from ".MAIN_DB_PREFIX.
"website_page where fk_page = ".((int) $objectpage->id);
4540 $resql = $db->query($sql);
4542 $num_rows = $db->num_rows($resql);
4543 if ($num_rows > 0) {
4544 print
'<span class="opacitymedium">'.$langs->trans(
'ThisPageHasTranslationPages').
':</span>';
4548 while ($obj = $db->fetch_object($resql)) {
4549 $result = $tmppage->fetch($obj->rowid);
4552 $tmpstring .=
'<br>';
4554 $tmpstring .= $tmppage->getNomUrl(1).
' '.
picto_from_langcode($tmppage->lang).
' '.$tmppage->lang;
4556 $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>';
4572 if ((empty($translatedby) || ($objectpage->lang !=
$object->lang)) && ($action ==
'editmeta' || $action ==
'createcontainer' || $objectpage->fk_page > 0)) {
4575 if ($objectpage->fk_page > 0) {
4576 $result = $sourcepage->fetch($objectpage->fk_page);
4583 if ($translatedby) {
4586 $translationof = $objectpage->fk_page;
4587 print
'<span class="opacitymedium">'.$langs->trans(
'ThisPageIsTranslationOf').
'</span> ';
4588 print $sourcepage->getNomUrl(2).
' '.$formwebsite->selectContainer($website,
'pageidfortranslation', ($translationof ? $translationof : -1), 1, $action,
'minwidth300', array($objectpage->id));
4589 if ($translationof > 0 && $sourcepage->lang) {
4592 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>';
4599 if (isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire')) {
4600 $langs->load(
'categories');
4602 if (!GETPOSTISSET(
'categories')) {
4604 $cats = $c->containing($objectpage->id, Categorie::TYPE_WEBSITE_PAGE);
4605 $arrayselected = array();
4606 if (is_array($cats)) {
4607 foreach ($cats as $cat) {
4608 $arrayselected[] = $cat->id;
4613 $cate_arbo = $form->select_all_categories(Categorie::TYPE_WEBSITE_PAGE,
'',
'parent', 0, 0, 3);
4616 print
'<tr><td class="toptd">'.$form->editfieldkey(
'Categories',
'categories',
'', $objectpage, 0).
'</td><td>';
4617 print
img_picto(
'',
'category',
'class="pictofixedwidth"');
4618 print $form->multiselectarray(
'categories', $cate_arbo, (GETPOSTISSET(
'categories') ?
GETPOST(
'categories',
'array') : $arrayselected), 0, 0,
'minwidth200 widthcentpercentminusxx');
4620 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);
4626 print
'<tr><td class="titlefieldcreate">';
4627 print
'ObjectClass';
4629 print
'<input type="text" class="flat minwidth300" name="WEBSITE_OBJECTCLASS" placeholder="ClassName::/path/class/ObjectClass.class.php" >';
4632 print
'<tr><td class="titlefieldcreate">';
4635 print
'<input type="text" class="flat minwidth300" name="WEBSITE_OBJECTID" >';
4639 $fuser =
new User($db);
4642 if ($action !=
'createcontainer') {
4644 print $langs->trans(
'DateLastModification');
4646 print
dol_print_date($pagedatemodification,
'dayhour',
'tzuser');
4650 print $langs->trans(
'UserModification');
4652 if ($pageusermodifid > 0) {
4653 $fuser->fetch($pageusermodifid);
4654 print $fuser->getNomUrl(-1);
4656 print
'<span class="opacitymedium">'.$langs->trans(
"Unknown").
'</span>';
4662 $url =
'https://wiki.dolibarr.org/index.php/Module_Website';
4663 $htmltext =
'<small>';
4664 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource", $url);
4665 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource1", $url);
4666 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource2", $url);
4667 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource3", $url);
4668 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource4", $url);
4669 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSourceMore", $url);
4670 $htmltext .=
'<br>';
4671 $htmltext .=
'</small>';
4674 $formmail->withaiprompt =
'html';
4675 $formmail->withlayout =
'websitepage';
4676 $showlinktolayout = $formmail->withlayout;
4677 $showlinktoai = ($formmail->withaiprompt && isModEnabled(
'ai')) ?
'textgenerationwebpage' :
'';
4678 if (($action ==
'createcontainer' && $showlinktolayout) || ($action ==
'createcontainer' && $showlinktoai)) {
4679 print
'<tr><td class="titlefield tdtop">';
4680 if (
$conf->browser->layout ==
'phone') {
4681 print $form->textwithpicto(
'', $htmltext, 1,
'help',
'inline-block', 1, 2,
'tooltipsubstitution');
4684 print $form->textwithpicto($langs->trans(
"PreviewPageContent").
' '.
img_help(2, $langs->trans(
"PreviewPageContent")), $htmltext, 1,
'none',
'inline-block', 1, 2,
'tooltipsubstitution');
4686 print
'</td><td class="tdtop">';
4690 $showlinktolayoutlabel = $langs->trans(
"FillPageWithALayout");
4691 $showlinktoailabel = $langs->trans(
"FillPageWithAIContent");
4692 $htmlname =
'content';
4694 include DOL_DOCUMENT_ROOT.
'/core/tpl/formlayoutai.tpl.php';
4700 if ($action ==
'createcontainer') {
4701 print
'<tr id="pageContent"><td class="tdtop">';
4702 if (!$showlinktolayout || !$showlinktoai) {
4703 if (
$conf->browser->layout ==
'phone') {
4704 print $form->textwithpicto(
'', $htmltext, 1,
'help',
'inline-block', 1, 2,
'tooltipsubstitution');
4707 print $form->textwithpicto($langs->trans(
"PreviewPageContent").
' '.
img_help(2, $langs->trans(
"PreviewPageContent")), $htmltext, 1,
'none',
'inline-block', 1, 2,
'tooltipsubstitution');
4712 $doleditor =
new DolEditor(
'content',
GETPOST(
'content',
'none'),
'', 200,
'dolibarr_mailings',
'In',
true,
true,
true, 40,
'90%');
4713 $doleditor->Create();
4720 print $langs->trans(
'DateCreation');
4722 print $form->selectDate($pagedatecreation,
'datecreation', 1, 1, 0,
'', 1, 1);
4728 print $langs->trans(
'Author');
4730 if ($pageauthorid > 0) {
4731 $fuser->fetch($pageauthorid);
4732 print $fuser->getNomUrl(-1);
4734 print
'<span class="opacitymedium">'.$langs->trans(
"Unknown").
'</span>';
4739 print
'<tr class="trpublicauthor hidden"><td>';
4740 print $langs->trans(
'PublicAuthorAlias');
4742 print
'<input type="text" class="flat minwidth300" name="WEBSITE_AUTHORALIAS" value="'.dol_escape_htmltag($pageauthoralias).
'" placeholder="Anonymous">';
4745 print
'<tr><td class="tdhtmlheader tdtop">';
4746 $htmlhelp = $langs->trans(
"EditTheWebSiteForACommonHeader").
'<br><br>';
4747 $htmlhelp .= $langs->trans(
"Example").
' :<br>';
4749 print $form->textwithpicto($langs->transnoentitiesnoconv(
'HtmlHeaderPage'), $htmlhelp, 1,
'help',
'', 0, 2,
'htmlheadertooltip');
4751 $poscursor = array(
'x' =>
GETPOST(
'htmlheader_x'),
'y' =>
GETPOST(
'htmlheader_y'));
4752 $doleditor =
new DolEditor(
'htmlheader', $pagehtmlheader,
'', 120,
'ace',
'In',
true,
false,
'ace', ROWS_3,
'100%', 0, $poscursor);
4753 print $doleditor->Create(1,
'',
true,
'HTML Header',
'html');
4758 print $langs->trans(
'AllowedInFrames');
4762 print
'<input type="checkbox" class="flat" name="WEBSITE_ALLOWED_IN_FRAMES" value="1"'.($pageallowedinframes ?
'checked="checked"' :
'').
'>';
4767 if ($action ==
'createcontainer') {
4768 print
'<div class="center tablecheckboxcreatemanually'.$hiddenmanuallyafterload.
'">';
4770 print
'<input type="submit" class="button small" name="addcontainer" value="'.$langs->trans(
"Create").
'">';
4771 print
'<input class="button button-cancel small" type="submit" name="preview" value="'.$langs->trans(
"Cancel").
'">';
4778 if (!empty(
$conf->use_javascript_ajax)) {
4779 print
'<input type="radio" name="radiocreatefrom" id="checkboxcreatefromfetching" value="checkboxcreatefromfetching"'.(GETPOST(
'radiocreatefrom') ==
'checkboxcreatefromfetching' ?
' checked' :
'').
'> ';
4781 print
'<label for="checkboxcreatefromfetching"><span class="opacitymediumxx">'.$langs->trans(
"CreateByFetchingExternalPage").
'</span></label><br>';
4782 print
'<hr class="tablecheckboxcreatefromfetching'.$hiddenfromfetchingafterload.
'">';
4783 print
'<table class="tableforfield centpercent tablecheckboxcreatefromfetching'.$hiddenfromfetchingafterload.
'">';
4784 print
'<tr><td class="titlefield">';
4785 print $langs->trans(
"URL");
4787 print
info_admin($langs->trans(
"OnlyEditionOfSourceForGrabbedContentFuture"), 0, 0,
'warning');
4788 print
'<input class="flat minwidth500" type="text" name="externalurl" value="'.dol_escape_htmltag(
GETPOST(
'externalurl',
'alpha')).
'" placeholder="https://externalsite/pagetofetch"> ';
4789 print
'<br><input class="flat paddingtop" type="checkbox" name="grabimages" value="1" checked="checked"> '.$langs->trans(
"GrabImagesInto");
4791 print $langs->trans(
"ImagesShouldBeSavedInto").
' ';
4792 $arraygrabimagesinto = array(
'root' => $langs->trans(
"WebsiteRootOfImages"),
'subpage' => $langs->trans(
"SubdirOfPage"));
4793 print $form->selectarray(
'grabimagesinto', $arraygrabimagesinto, GETPOSTISSET(
'grabimagesinto') ?
GETPOST(
'grabimagesinto') :
'root', 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
4796 print
'<input class="button small" style="margin-top: 5px" type="submit" name="fetchexternalurl" value="'.dol_escape_htmltag($langs->trans(
"FetchAndCreate")).
'">';
4797 print
'<input class="button button-cancel small" type="submit" name="preview" value="'.$langs->trans(
"Cancel").
'">';
4803 if ($action ==
'createcontainer') {
4804 print
'<script type="text/javascript">
4805 jQuery(document).ready(function() {
4806 var disableautofillofalias = 0;
4807 var selectedm = \'\';
4808 var selectedf = \'\';
4810 jQuery("#WEBSITE_TITLE").keyup(function() {
4811 if (disableautofillofalias == 0) {
4812 var valnospecial = jQuery("#WEBSITE_TITLE").val();
4813 valnospecial = valnospecial.replace(/[éèê]/g, \'e\').replace(/[à]/g, \'a\').replace(/[ù]/g, \'u\').replace(/[î]/g, \'i\');
4814 valnospecial = valnospecial.replace(/[ç]/g, \'c\').replace(/[ö]/g, \'o\');
4815 valnospecial = valnospecial.replace(/[^\w]/gi, \'-\').toLowerCase();
4816 valnospecial = valnospecial.replace(/\-+/g, \'-\').replace(/\-$/, \'\');
4817 console.log("disableautofillofalias=0 so we replace WEBSITE_TITLE with "+valnospecial);
4818 jQuery("#WEBSITE_PAGENAME").val(valnospecial);
4821 jQuery("#WEBSITE_PAGENAME").keyup(function() {
4822 if (jQuery("#WEBSITE_PAGENAME").val() == \'\') {
4823 disableautofillofalias = 0;
4825 disableautofillofalias = 1;
4828 jQuery("#WEBSITE_PAGENAME").blur(function() {
4829 if (jQuery("#WEBSITE_PAGENAME").val() == \'\') {
4830 disableautofillofalias = 0;
4831 jQuery("#WEBSITE_TITLE").trigger(\'keyup\');
4835 jQuery("#checkboxcreatefromfetching,#checkboxcreatemanually").click(function() {
4836 console.log("we select a method to create a new container "+jQuery("#checkboxcreatefromfetching:checked").val())
4837 jQuery(".tablecheckboxcreatefromfetching").hide();
4838 jQuery(".tablecheckboxcreatemanually").hide();
4839 if (typeof(jQuery("#checkboxcreatefromfetching:checked").val()) != \'undefined\') {
4840 console.log("show create from spider form");
4841 if (selectedf != \'createfromfetching\') {
4842 jQuery(".tablecheckboxcreatefromfetching").show();
4843 selectedf = \'createfromfetching\';
4846 jQuery(".tablecheckboxcreatefromfetching").hide();
4850 if (typeof(jQuery("#checkboxcreatemanually:checked").val()) != \'undefined\') {
4851 console.log("show create from scratch or template form");
4852 if (selectedm != \'createmanually\') {
4853 jQuery(".tablecheckboxcreatemanually").show();
4854 selectedm = \'createmanually\';
4857 jQuery(".tablecheckboxcreatemanually").hide();
4876if ($action ==
'preview') {
4880if ($action ==
'editfile' || $action ==
'file_manager' || $action ==
'convertimgwebp' || $action ==
'confirmconvertimgwebp') {
4881 print
'<!-- Edit Media -->'.
"\n";
4882 print
'<div class="fiche"><br>';
4887 $formalreadyopen = 2;
4889 $url = DOL_URL_ROOT.
'/website/index.php';
4891 include DOL_DOCUMENT_ROOT.
'/core/tpl/filemanager.tpl.php';
4896if ($action ==
'editmenu') {
4897 print
'<!-- Edit Menu -->'.
"\n";
4898 print
'<div class="center">'.$langs->trans(
"FeatureNotYetAvailable").
'</center>';
4901if ($action ==
'editsource') {
4904 $contentforedit =
'';
4908 $contentforedit .= $objectpage->content;
4910 $maxheightwin = 480;
4911 if (isset($_SESSION[
"dol_screenheight"])) {
4912 if ($_SESSION[
"dol_screenheight"] > 680) {
4913 $maxheightwin = $_SESSION[
"dol_screenheight"] - 400;
4915 if ($_SESSION[
"dol_screenheight"] > 800) {
4916 $maxheightwin = $_SESSION[
"dol_screenheight"] - 490;
4920 $poscursor = array(
'x' =>
GETPOST(
'PAGE_CONTENT_x'),
'y' =>
GETPOST(
'PAGE_CONTENT_y'));
4921 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
4922 $doleditor =
new DolEditor(
'PAGE_CONTENT', $contentforedit,
'', $maxheightwin,
'Full',
'',
true,
true,
'ace', ROWS_5,
'40%', 0, $poscursor);
4923 $doleditor->Create(0,
'',
false,
'HTML Source',
'php');
4926if ($action ==
'editcontent') {
4929 $contentforedit =
'';
4933 $contentforedit .= $objectpage->content;
4938 $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);
4940 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
4941 $poscursor = array(
'x' =>
GETPOST(
'PAGE_CONTENT_x'),
'y' =>
GETPOST(
'PAGE_CONTENT_y'));
4942 $doleditor =
new DolEditor(
'PAGE_CONTENT', $contentforedit,
'', 500,
'Full',
'',
true,
true,
true, ROWS_5,
'90%', 0, $poscursor);
4943 $doleditor->Create(0,
'',
false);
4950if ($mode ==
'replacesite' || $massaction ==
'replace') {
4951 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4952 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4953 print
'<input type="hidden" name="action" value="replacesiteconfirm">';
4954 print
'<input type="hidden" name="mode" value="replacesite">';
4955 print
'<input type="hidden" name="website" value="'.$website->ref.
'">';
4958 print
'<!-- Search page and replace string -->'.
"\n";
4959 print
'<div class="fiche"><br>';
4961 print
load_fiche_titre($langs->trans(
"ReplaceWebsiteContent"),
'',
'search');
4963 print
'<div class="fichecenter"><div class="fichehalfleft">';
4965 print
'<div class="tagtable">';
4967 print
'<div class="tagtr">';
4968 print
'<div class="tagtd paddingrightonly opacitymedium">';
4969 print $langs->trans(
"SearchReplaceInto");
4971 print
'<div class="tagtd">';
4972 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>';
4973 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>';
4974 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>';
4978 print
'<div class="tagtr">';
4979 print
'<div class="tagtd paddingrightonly opacitymedium" style="padding-right: 10px !important">';
4980 print $langs->trans(
"SearchString");
4982 print
'<div class="tagtd">';
4983 print
'<input type="text" name="searchstring" value="'.dol_escape_htmltag($searchkey, 0, 0,
'', 1).
'" autofocus>';
4989 print
'</div><div class="fichehalfleft">';
4991 print
'<div class="tagtable">';
4993 print
'<div class="tagtr">';
4994 print
'<div class="tagtd paddingrightonly opacitymedium tdoverflowmax100onsmartphone" style="padding-right: 10px !important">';
4995 print $langs->trans(
"WEBSITE_TYPE_CONTAINER");
4997 print
'<div class="tagtd">';
4998 print
img_picto(
'',
'object_technic',
'class="paddingrightonly"').
' ';
4999 print $formwebsite->selectTypeOfContainer(
'optioncontainertype', (
GETPOST(
'optioncontainertype',
'alpha') ?
GETPOST(
'optioncontainertype',
'alpha') :
''), 1,
'', 1,
'minwidth125 maxwidth400 widthcentpercentminusx');
5003 print
'<div class="tagtr">';
5004 print
'<div class="tagtd paddingrightonly opacitymedium tdoverflowmax100onsmartphone" style="padding-right: 10px !important">';
5005 print $langs->trans(
"Language");
5007 print
'<div class="tagtd">';
5008 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);
5013 if (isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire')) {
5014 print
'<div class="tagtr">';
5015 print
'<div class="tagtd paddingrightonly marginrightonly opacitymedium tdoverflowmax100onsmartphone" style="padding-right: 10px !important">';
5016 print $langs->trans(
"Category");
5018 print
'<div class="tagtd">';
5019 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');
5020 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
5028 print
'<input type="submit" class="button margintoponly" name="buttonreplacesitesearch" value="'.dol_escape_htmltag($langs->trans(
"Search")).
'">';
5030 print
'</div></div>';
5032 if ($mode ==
'replacesite') {
5033 print
'<!-- List of search result -->'.
"\n";
5034 print
'<div class="rowsearchresult clearboth">';
5039 if ($listofpages[
'code'] ==
'OK') {
5040 $arrayofselected = is_array($toselect) ? $toselect : array();
5042 $nbtotalofrecords = count($listofpages[
'list']);
5044 $permissiontodelete = $user->hasRight(
'website',
'delete');
5047 $arrayofmassactions = array();
5048 if ($user->hasRight(
'website',
'writephp') && $searchkey) {
5049 $arrayofmassactions[
'replace'] =
img_picto(
'',
'replacement',
'class="pictofixedwidth"').$langs->trans(
"Replace");
5051 if ($user->hasRight(
'website',
'write')) {
5052 $arrayofmassactions[
'setcategory'] =
img_picto(
'',
'category',
'class="pictofixedwidth"').$langs->trans(
"ClassifyInCategory");
5054 if ($user->hasRight(
'website',
'write')) {
5055 $arrayofmassactions[
'delcategory'] =
img_picto(
'',
'category',
'class="pictofixedwidth"').$langs->trans(
"RemoveCategory");
5057 if ($permissiontodelete) {
5058 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
5060 if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete'))) {
5061 $arrayofmassactions = array();
5064 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
5065 $massactionbutton .=
'<div class="massactionother massactionreplace hidden">';
5066 $massactionbutton .= $langs->trans(
"ReplaceString");
5067 $massactionbutton .=
' <input type="text" name="replacestring" value="'.dol_escape_htmltag(
GETPOST(
'replacestring',
'none')).
'">';
5068 $massactionbutton .=
'</div>';
5069 $massactionbutton .=
'<div class="massactionother massactionsetcategory massactiondelcategory hidden">';
5070 $massactionbutton .=
img_picto(
'',
'category',
'class="pictofixedwidth"');
5071 $massactionbutton .= $form->select_all_categories(Categorie::TYPE_WEBSITE_PAGE, GETPOSTISSET(
'setcategory') ?
GETPOST(
'setcategory') :
'',
'setcategory', 64, 0, 0, 0,
'minwidth300 alignstart');
5072 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
5074 $massactionbutton .=
'</div>';
5076 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
5079 $selectedfields =
'';
5080 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
5082 print_barre_liste($langs->trans(
"Results"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'generic', 0,
'',
'', $limit, 1, 1, 1);
5084 $topicmail =
"WebsitePageRef";
5085 $modelmail =
"websitepage_send";
5087 $trackid =
'wsp'.$object->id;
5088 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
5090 $param =
'mode=replacesite&website='.urlencode($website->ref);
5091 $param .=
'&searchstring='.urlencode($searchkey);
5092 if (
GETPOST(
'optioncontent')) {
5093 $param .=
'&optioncontent=content';
5096 $param .=
'&optionmeta=meta';
5098 if (
GETPOST(
'optionsitefiles')) {
5099 $param .=
'&optionsitefiles=optionsitefiles';
5101 if (
GETPOST(
'optioncontainertype')) {
5102 $param .=
'&optioncontainertype='.GETPOST(
'optioncontainertype',
'aZ09');
5104 if (
GETPOST(
'optionlanguage')) {
5105 $param .=
'&optionlanguage='.GETPOST(
'optionlanguage',
'aZ09');
5107 if (
GETPOST(
'optioncategory')) {
5108 $param .=
'&optioncategory='.GETPOST(
'optioncategory',
'aZ09');
5111 print
'<div class="div-table-responsive-no-min">';
5112 print
'<table class="noborder centpercent">';
5113 print
'<tr class="liste_titre">';
5116 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
5118 print
getTitleFieldOfList(
"Type", 0, $_SERVER[
'PHP_SELF'],
'type_container',
'', $param,
'', $sortfield, $sortorder,
'').
"\n";
5119 print
getTitleFieldOfList(
"Page", 0, $_SERVER[
'PHP_SELF'],
'pageurl',
'', $param,
'', $sortfield, $sortorder,
'').
"\n";
5120 print
getTitleFieldOfList(
"Language", 0, $_SERVER[
'PHP_SELF'],
'lang',
'', $param,
'', $sortfield, $sortorder,
'center ').
"\n";
5121 print
getTitleFieldOfList(
"Categories", 0, $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'center ').
"\n";
5123 print
getTitleFieldOfList(
"UserCreation", 0, $_SERVER[
'PHP_SELF'],
'fk_user_creat',
'', $param,
'', $sortfield, $sortorder,
'').
"\n";
5124 print
getTitleFieldOfList(
"DateCreation", 0, $_SERVER[
'PHP_SELF'],
'date_creation',
'', $param,
'', $sortfield, $sortorder,
'center ').
"\n";
5125 print
getTitleFieldOfList(
"DateLastModification", 0, $_SERVER[
'PHP_SELF'],
'tms',
'', $param,
'', $sortfield, $sortorder,
'center ').
"\n";
5129 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
5133 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
5138 foreach ($listofpages[
'list'] as $answerrecord) {
5139 if (is_object($answerrecord) && get_class($answerrecord) ==
'WebsitePage') {
5140 $param =
'?mode=replacesite';
5141 $param .=
'&websiteid='.$website->id;
5142 $param .=
'&optioncontent='.GETPOST(
'optioncontent',
'aZ09');
5143 $param .=
'&optionmeta='.GETPOST(
'optionmeta',
'aZ09');
5144 $param .=
'&optionsitefiles='.GETPOST(
'optionsitefiles',
'aZ09');
5145 $param .=
'&optioncontainertype='.GETPOST(
'optioncontainertype',
'aZ09');
5146 $param .=
'&optionlanguage='.GETPOST(
'optionlanguage',
'aZ09');
5147 $param .=
'&optioncategory='.GETPOST(
'optioncategory',
'aZ09');
5148 $param .=
'&searchstring='.urlencode($searchkey);
5154 print
'<td class="nowrap center">';
5156 print
'<!-- Status of page -->'.
"\n";
5157 if ($massactionbutton || $massaction) {
5159 if (in_array($answerrecord->id, $arrayofselected)) {
5162 print
'<input id="'.$answerrecord->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$answerrecord->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
5168 print
'<td class="nowraponall">';
5170 if (!empty(
$conf->cache[
'type_of_container'][$answerrecord->type_container])) {
5171 print $langs->trans(
$conf->cache[
'type_of_container'][$answerrecord->type_container]);
5173 print $langs->trans($answerrecord->type_container);
5178 $titleofpage = ($answerrecord->title ? $answerrecord->title : $langs->trans(
"NoTitle"));
5179 print
'<td class="tdoverflowmax300" title="'.dol_escape_htmltag($titleofpage).
'">';
5180 print $answerrecord->getNomUrl(1);
5181 print
' <span class="opacitymedium">('.dol_escape_htmltag($titleofpage).
')</span>';
5185 print
'<span class="opacitymedium">'.dol_escape_htmltag($answerrecord->description ? $answerrecord->description : $langs->trans(
"NoDescription")).
'</span>';
5189 print
'<td class="center">';
5194 print
'<td class="center">';
5195 if (isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire')) {
5197 $existing = $c->containing($answerrecord->id, Categorie::TYPE_WEBSITE_PAGE,
'object');
5198 if (is_array($existing)) {
5199 foreach ($existing as $tmpcategory) {
5201 print
img_object($langs->trans(
"Category").
' : '.$tmpcategory->label,
'category',
'style="padding-left: 2px; padding-right: 2px; color: #'.($tmpcategory->color !=
'' ? $tmpcategory->color :
'888').
'"');
5209 print
'<td class="center nowraponall">';
5211 $characterMap =
'áàéèëíóúüñùç0123456789';
5212 $nbofwords = str_word_count($textwithouthtml, 0, $characterMap);
5214 print $nbofwords.
' '.$langs->trans(
"words");
5215 $totalnbwords += $nbofwords;
5220 print
'<td class="tdoverflowmax125">';
5221 if (!empty($answerrecord->fk_user_creat)) {
5222 if (empty(
$conf->cache[
'user'][$answerrecord->fk_user_creat])) {
5223 $tmpuser =
new User($db);
5224 $tmpuser->fetch($answerrecord->fk_user_creat);
5225 $conf->cache[
'user'][$answerrecord->fk_user_creat] = $tmpuser;
5227 $tmpuser =
$conf->cache[
'user'][$answerrecord->fk_user_creat];
5229 print $tmpuser->getNomUrl(-1,
'', 0, 0, 0, 0,
'login');
5234 print
'<td class="center nowraponall">';
5239 print
'<td class="center nowraponall">';
5240 print
dol_print_date($answerrecord->date_modification,
'dayhour');
5244 print
'<td class="tdwebsitesearchresult right nowraponall">';
5246 $urltoedithtmlsource = $_SERVER[
"PHP_SELF"].
'?action=editmeta&token='.
newToken().
'&websiteid='.$website->id.
'&pageid='.$answerrecord->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].$param);
5247 if (!$user->hasRight(
'website',
'write')) {
5248 $disabled =
' disabled';
5249 $urltoedithtmlsource =
'';
5251 print
'<a class="editfielda marginleftonly marginrightonly '.$disabled.
'" href="'.$urltoedithtmlsource.
'" title="'.$langs->trans(
"EditPageMeta").
'">'.
img_picto($langs->trans(
"EditPageMeta"),
'pencil-ruler').
'</a>';
5254 $urltoedithtmlsource = $_SERVER[
"PHP_SELF"].
'?action=editsource&token='.
newToken().
'&websiteid='.$website->id.
'&pageid='.$answerrecord->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].$param);
5255 if (!$user->hasRight(
'website',
'write')) {
5256 $disabled =
' disabled';
5257 $urltoedithtmlsource =
'';
5259 print
'<a class="editfielda marginleftonly marginrightonly '.$disabled.
'" href="'.$urltoedithtmlsource.
'" title="'.$langs->trans(
"EditHTMLSource").
'">'.
img_picto($langs->trans(
"EditHTMLSource"),
'edit').
'</a>';
5261 print
'<span class="marginleftonly marginrightonly"></span>';
5262 print
ajax_object_onoff($answerrecord,
'status',
'status',
'Enabled',
'Disabled', array(),
'valignmiddle inline-block');
5268 print
'<td class="nowrap center">';
5270 print
'<!-- Status of page -->'.
"\n";
5271 if ($massactionbutton || $massaction) {
5273 if (in_array($answerrecord->id, $arrayofselected)) {
5276 print
'<input id="'.$answerrecord->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$answerrecord->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
5284 '@phan-var-force array{type:string} $answerrecord';
5285 $param =
'?mode=replacesite';
5286 $param .=
'&websiteid='.$website->id;
5287 $param .=
'&optioncontent='.GETPOST(
'optioncontent',
'aZ09');
5288 $param .=
'&optionmeta='.GETPOST(
'optionmeta',
'aZ09');
5289 $param .=
'&optionsitefiles='.GETPOST(
'optionsitefiles',
'aZ09');
5290 $param .=
'&optioncontainertype='.GETPOST(
'optioncontainertype',
'aZ09');
5291 $param .=
'&optionlanguage='.GETPOST(
'optionlanguage',
'aZ09');
5292 $param .=
'&optioncategory='.GETPOST(
'optioncategory',
'aZ09');
5293 $param .=
'&searchstring='.urlencode($searchkey);
5299 print
'<td class="nowrap center">';
5305 $translateofrecordtype = array(
5306 'website_csscontent' =>
'WEBSITE_CSS_INLINE',
5307 'website_jscontent' =>
'WEBSITE_JS_INLINE',
5308 'website_robotcontent' =>
'WEBSITE_ROBOT',
5309 'website_htmlheadercontent' =>
'WEBSITE_HTML_HEADER',
5310 'website_htaccess' =>
'WEBSITE_HTACCESS',
5311 'website_readme' =>
'WEBSITE_README',
5312 'website_manifestjson' =>
'WEBSITE_MANIFEST_JSON'
5314 print
'<span class="opacitymedium">';
5315 if (!empty($translateofrecordtype[$answerrecord[
'type']])) {
5316 print $langs->trans($translateofrecordtype[$answerrecord[
'type']]);
5318 print $answerrecord[
'type'];
5325 $backtopageurl = $_SERVER[
"PHP_SELF"].$param;
5326 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=editcss&token='.
newToken().
'&website='.urlencode($website->ref).
'&backtopage='.urlencode($backtopageurl).
'">'.$langs->trans(
"EditCss").
'</a>';
5348 print
'<td class="center nowraponall">';
5358 print
'<td class="nowrap center">';
5366 if (count($listofpages[
'list']) >= 2) {
5368 print
'<tr class="lite_titre">';
5372 print
'<td class="nowrap center">';
5378 print $langs->trans(
"Total");
5394 print
'<td class="center nowraponall">';
5395 print $totalnbwords.
' '.$langs->trans(
"words");
5414 print
'<td class="nowrap center">';
5425 print
'<div class="warning">'.$listofpages[
'message'].
'</div>';
5434if ((empty($action) || $action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone') && !in_array($mode, array(
'replacesite'))) {
5435 if ($pageid > 0 && $atleastonepage) {
5441 $objectpage->fetch($pageid);
5443 $jscontent = @file_get_contents($filejs);
5445 $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";
5454 $out .=
"\n<html><head>\n";
5455 $out .=
"<!-- htmlheader/style of page from database -->\n";
5458 $out .=
"<!-- htmlheader/style of website from files -->\n";
5476 $out .=
"</head>\n";
5480 $out .=
'<div id="websitecontentundertopmenu" class="websitecontentundertopmenu boostrap-iso">'.
"\n";
5484 $out .=
'<!-- style of website from file -->'.
"\n";
5485 $out .=
'<style scoped>'.
"\n";
5487 $tmpout .=
'/* Include website CSS file */'.
"\n";
5491 $csscontent = ob_get_contents();
5494 $tmpout .=
'/* Include style from the HTML header of page */'.
"\n";
5496 $tmp = preg_split(
'(<style[^>]*>|</style>)', $objectpage->htmlheader);
5497 $tmpstyleinheader =
'';
5499 foreach ($tmp as $valtmp) {
5502 $tmpstyleinheader .= $valtmp.
"\n";
5505 $tmpout .= $tmpstyleinheader.
"\n";
5507 $tmpout = preg_replace(
'/}[\s\n]*body\s*{[^}]+}/ims',
'}', $tmpout);
5509 $out .=
'</style>'.
"\n";
5516 $out .=
'<div id="divbodywebsite" class="bodywebsite bodywebpage-'.$objectpage->ref.
'">'.
"\n";
5518 $newcontent = $objectpage->content;
5525 $filephp = $filetpl;
5528 $savsessionname = session_name();
5529 $savsessionid = $_COOKIE[$savsessionname];
5530 $_COOKIE[$savsessionname] =
'obfuscatedcookie';
5534 $res = include $filephp;
5536 print
"ERROR: Failed to include file '".$filephp.
"'. Try to edit and re-save page with this ID.";
5539 print $e->getMessage();
5541 $newcontent = ob_get_contents();
5545 $_COOKIE[$savsessionname] = $savsessionid;
5551 $newcontent = preg_replace(
'/(div|section|header|main|footer)(\s[^>]*)contenteditable="true"/',
'\1\2', $newcontent);
5560 $out .=
'</div> <!-- End div id=websitecontentundertopmenu -->';
5566 $out .=
"\n</body></html>\n";
5568 $out .=
"\n".
'<!-- End page content '.$filetpl.
' -->'.
"\n\n";
5592 if (empty($websitekey) || $websitekey ==
'-1') {
5593 print
'<br><br><div class="center previewnotyetavailable"><span class="">'.$langs->trans(
"NoWebSiteCreateOneFirst").
'</span></div><br><br><br>';
5594 print
'<div class="center"><div class="logo_setup"></div></div>';
5596 print
'<br><br><div class="center previewnotyetavailable"><span class="">'.$langs->trans(
"PreviewOfSiteNotYetAvailable",
$object->ref).
'</span></div><br><br><br>';
5597 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....
Class to manage categories.
Class to manage a WYSIWYG editor.
lessphp v0.8.0 http://leafo.net/lessphp
Class to manage Dolibarr users.
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories)
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_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.