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();
333if (
GETPOST(
'optiopagecontent')) {
339if (
GETPOST(
'optionsitefiles')) {
340 $algo .=
'sitefiles';
343if (empty($sortfield)) {
344 if ($action ==
'file_manager') {
348 $sortfield =
'pageurl';
353$searchkey =
GETPOST(
'searchstring',
'restricthtmlallowunvalid');
355if ($action ==
'replacesite' || $mode ==
'replacesite') {
356 $containertype =
GETPOST(
'optioncontainertype',
'aZ09') !=
'-1' ?
GETPOST(
'optioncontainertype',
'aZ09') :
'';
357 $langcode =
GETPOST(
'optionlanguage',
'aZ09');
358 $otherfilters = array();
360 $otherfilters[
'category'] =
GETPOSTINT(
'optioncategory');
363 $listofpages =
getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters, -1);
366$usercanedit = $user->hasRight(
'website',
'write');
367$permissiontoadd = $user->hasRight(
'website',
'write');
368$permissiontodelete = $user->hasRight(
'website',
'delete');
379if (
GETPOST(
'refreshsite',
'alpha') ||
GETPOST(
'refreshsite.x',
'alpha') ||
GETPOST(
'refreshsite_x',
'alpha')) {
380 if ($action ==
'addsite') {
383 if ($action ==
'updatesource') {
387 $pageid =
$object->fk_default_home;
388 if (empty($pageid)) {
389 $array = $objectpage->fetchAll(
$object->id,
'ASC,ASC',
'type_container,pageurl');
390 if (!is_array($array) && $array < 0) {
393 $atleastonepage = (is_array($array) && count($array) > 0);
397 foreach ($array as $key => $valpage) {
398 if (empty($firstpageid)) {
399 $firstpageid = $valpage->id;
401 if (
$object->fk_default_home && $key ==
$object->fk_default_home) {
402 $homepageid = $valpage->id;
405 $pageid = ($homepageid ? $homepageid : $firstpageid);
408if (
GETPOST(
'refreshpage',
'alpha') && !in_array($action, array(
'updatecss'))) {
412if ($cancel && $action ==
'renamefile') {
421 header(
"Location: ".$backtopage);
426$savbacktopage = $backtopage;
427$backtopage = $_SERVER[
"PHP_SELF"].
'?file_manager=1&website='.urlencode($websitekey).
'&pageid='.urlencode((
string) $pageid).(GETPOST(
'section_dir',
'alpha') ?
'§ion_dir='.urlencode(
GETPOST(
'section_dir',
'alpha')) :
'');
429 $backtopage .=
'&sortfield='.urlencode($sortfield);
432 $backtopage .=
'&sortorder='.urlencode($sortorder);
434include DOL_DOCUMENT_ROOT.
'/core/actions_linkedfiles.inc.php';
436$backtopage = $savbacktopage;
440if ($action ==
'renamefile') {
441 $action =
'file_manager';
444if ($action ==
'setwebsiteonline' && $usercanedit) {
445 $website->setStatut($website::STATUS_VALIDATED,
null,
'',
'WEBSITE_MODIFY',
'status');
447 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
GETPOST(
'website')).
'&pageid='.
GETPOSTINT(
'websitepage'));
450if ($action ==
'setwebsiteoffline' && $usercanedit) {
451 $result = $website->setStatut($website::STATUS_DRAFT,
null,
'',
'WEBSITE_MODIFY',
'status');
453 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
GETPOST(
'website')).
'&pageid='.
GETPOSTINT(
'websitepage'));
456if ($action ==
'seteditinline') {
459 setEventMessages($langs->trans(
"FeatureNotYetAvailable"),
null,
'warnings');
464 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
GETPOST(
'website')).
'&pageid='.
GETPOSTINT(
'pageid'));
467if ($action ==
'unseteditinline') {
469 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
GETPOST(
'website')).
'&pageid='.
GETPOSTINT(
'pageid'));
472if ($action ==
'setshowsubcontainers') {
475 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
GETPOST(
'website')).
'&pageid='.
GETPOSTINT(
'pageid'));
478if ($action ==
'unsetshowsubcontainers') {
480 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
GETPOST(
'website')).
'&pageid='.
GETPOSTINT(
'pageid'));
484if ($massaction ==
'replace' &&
GETPOST(
'confirmmassaction',
'alpha') && !$searchkey && $usercanedit) {
485 $mode =
'replacesite';
486 $action =
'replacesite';
490if ($action ==
'deletetemplate' && $usercanedit) {
491 $dirthemes = array(
'/doctemplates/websites');
492 if (!empty(
$conf->modules_parts[
'websitetemplates'])) {
493 foreach (
$conf->modules_parts[
'websitetemplates'] as $reldir) {
494 $dirthemes = array_merge($dirthemes, (array) ($reldir.
'doctemplates/websites'));
497 $dirthemes = array_unique($dirthemes);
501 $mode =
'importsite';
502 $action =
'importsite';
504 if (count($dirthemes)) {
506 foreach ($dirthemes as $dir) {
508 $dirtheme = DOL_DATA_ROOT.$dir;
509 if (is_dir($dirtheme)) {
510 $templateuserfile =
GETPOST(
'templateuserfile');
511 $imguserfile = preg_replace(
'/\.zip$/',
'', $templateuserfile).
'.jpg';
520if ($massaction ==
'setcategory' &&
GETPOST(
'confirmmassaction',
'alpha') && $usercanedit) {
527 if ($categoryid > 0) {
530 $category->fetch($categoryid);
532 foreach ($toselect as $tmpid) {
533 $tmpwebsitepage->id = $tmpid;
534 $result = $category->add_type($tmpwebsitepage,
'website_page');
535 if ($result < 0 && $result != -3) {
549 setEventMessages($langs->trans(
"RecordsModified", $nbupdate),
null,
'mesgs');
555 $listofpages =
getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters, -1);
559if ($massaction ==
'delcategory' &&
GETPOST(
'confirmmassaction',
'alpha') && $usercanedit) {
566 if ($categoryid > 0) {
569 $category->fetch($categoryid);
571 foreach ($toselect as $tmpid) {
572 $tmpwebsitepage->id = $tmpid;
573 $result = $category->del_type($tmpwebsitepage,
'website_page');
574 if ($result < 0 && $result != -3) {
588 setEventMessages($langs->trans(
"RecordsModified", $nbupdate),
null,
'mesgs');
594 $listofpages =
getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters, -1);
598if ($massaction ==
'replace' &&
GETPOST(
'confirmmassaction',
'alpha') && $usercanedit) {
599 $replacestring =
GETPOST(
'replacestring',
'restricthtmlallowunvalid');
601 $dolibarrdataroot = preg_replace(
'/([\\/]+)$/i',
'', DOL_DATA_ROOT);
602 $allowimportsite =
true;
603 if (
dol_is_file($dolibarrdataroot.
'/installmodules.lock')) {
604 $allowimportsite =
false;
607 if (!$allowimportsite) {
611 $message = $langs->trans(
'InstallModuleFromWebHasBeenDisabledContactUs');
614 $message = $langs->trans(
"InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.
'/installmodules.lock');
617 } elseif (!$user->hasRight(
'website',
'writephp')) {
619 } elseif (!$replacestring) {
624 foreach ($toselect as $keyselected) {
625 $objectpage = $listofpages[
'list'][$keyselected];
626 if ($objectpage->pageurl) {
627 dol_syslog(
"Replace string into page ".$objectpage->pageurl);
629 if (
GETPOST(
'optiopagecontent',
'aZ09')) {
630 $objectpage->content = str_replace($searchkey, $replacestring, $objectpage->content);
632 if (
GETPOST(
'optionmeta',
'aZ09')) {
633 $objectpage->title = str_replace($searchkey, $replacestring, $objectpage->title);
634 $objectpage->description = str_replace($searchkey, $replacestring, $objectpage->description);
635 $objectpage->keywords = str_replace($searchkey, $replacestring, $objectpage->keywords);
638 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
639 $filetpl = $pathofwebsite.
'/page'.$objectpage->id.
'.tpl.php';
644 setEventMessages(
'Failed to write file '.basename($filealias),
null,
'errors');
652 $objectpage->update($user);
656 $action =
'createcontainer';
662 if ($nbreplacement > 0) {
663 setEventMessages($langs->trans(
"ReplacementDoneInXPages", $nbreplacement),
null,
'mesgs');
666 $containertype =
GETPOST(
'optioncontainertype',
'aZ09') !=
'-1' ?
GETPOST(
'optioncontainertype',
'aZ09') :
'';
667 $langcode =
GETPOST(
'optionlanguage',
'aZ09');
668 $otherfilters = array();
670 $otherfilters[
'category'] =
GETPOSTINT(
'optioncategory');
674 $listofpages =
getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters);
704if ($action ==
'addsite' && $usercanedit) {
707 if (
GETPOST(
'virtualhost',
'alpha') && !preg_match(
'/^http/',
GETPOST(
'virtualhost',
'alpha'))) {
709 setEventMessages($langs->trans(
'ErrorURLMustStartWithHttp', $langs->transnoentitiesnoconv(
"VirtualHost")),
null,
'errors');
712 if (!$error && !
GETPOST(
'WEBSITE_REF',
'alpha')) {
714 $langs->load(
"errors");
715 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->transnoentities(
"WebsiteName")),
null,
'errors');
717 if (!$error && !preg_match(
'/^[a-z0-9_\-\.]+$/i',
GETPOST(
'WEBSITE_REF',
'alpha'))) {
719 $langs->load(
"errors");
720 setEventMessages($langs->transnoentities(
"ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities(
"Ref")),
null,
'errors');
724 $arrayotherlang = explode(
',',
GETPOST(
'WEBSITE_OTHERLANG',
'alphanohtml'));
725 foreach ($arrayotherlang as $key => $val) {
727 if (empty(trim($val))) {
730 $arrayotherlang[$key] = substr(trim($val), 0, 2);
734 $tmpobject->ref =
GETPOST(
'WEBSITE_REF',
'alpha');
735 $tmpobject->description =
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml');
736 $tmpobject->lang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
737 $tmpobject->otherlang = implode(
',', $arrayotherlang);
738 $tmpobject->virtualhost =
GETPOST(
'virtualhost',
'alpha');
740 $result = $tmpobject->create($user);
744 } elseif ($result < 0) {
755 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$tmpobject->ref);
759 $action =
'createsite';
768'@phan-var-force int $error';
771if ($action ==
'addcontainer' && $usercanedit) {
776 $objectpage->fk_website =
$object->id;
777 $objectpage->status = $objectpage::STATUS_DRAFT;
779 if (GETPOSTISSET(
'fetchexternalurl')) {
780 $urltograb =
GETPOST(
'externalurl',
'alpha');
781 $grabimages =
GETPOSTINT(
'grabimages') ? 1 : 0;
782 $grabimagesinto =
GETPOST(
'grabimagesinto',
'alpha');
784 include_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
787 if (empty($urltograb)) {
789 $langs->load(
"errors");
790 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"URL")),
null,
'errors');
791 $action =
'createcontainer';
792 } elseif (!preg_match(
'/^http/', $urltograb)) {
794 $langs->load(
"errors");
795 setEventMessages(
'Error URL must start with http:// or https://',
null,
'errors');
796 $action =
'createcontainer';
803 $urltograbwithoutdomainandparam = preg_replace(
'/^https?:\/\/[^\/]+\/?/i',
'', $urltograb);
805 $urltograbwithoutdomainandparam = preg_replace(
'/\?.*$/',
'', $urltograbwithoutdomainandparam);
806 if (empty($urltograbwithoutdomainandparam) && !preg_match(
'/\/$/', $urltograb)) {
809 $pageurl =
dol_sanitizeFileName(preg_replace(
'/[\/\.]/',
'-', preg_replace(
'/\/+$/',
'', $urltograbwithoutdomainandparam)));
811 $urltograbdirwithoutslash = dirname($urltograb.
'.');
820 $result = $tmpwebsitepage->fetch(0,
$object->id, $pageurl);
822 setEventMessages($langs->trans(
"AliasPageAlreadyExists", $pageurl),
null,
'errors');
824 $action =
'createcontainer';
829 $tmp =
getURLContent($urltograb,
'GET',
'', 1, array(), array(
'http',
'https'), 0);
832 if (!empty($tmp[
'content_type']) && preg_match(
'/ISO-8859-1/', $tmp[
'content_type'])) {
833 if (function_exists(
'mb_check_encoding')) {
834 if (mb_check_encoding($tmp[
'content'],
'ISO-8859-1')) {
836 $tmp[
'content'] = mb_convert_encoding($tmp[
'content'],
'ISO-8859-1',
'UTF-8');
839 setEventMessages(
'Error getting '.$urltograb.
': content seems non valid ISO-8859-1',
null,
'errors');
840 $action =
'createcontainer';
844 setEventMessages(
'Error getting '.$urltograb.
': content seems ISO-8859-1 but functions to convert into UTF-8 are not available in your PHP',
null,
'errors');
845 $action =
'createcontainer';
848 if (empty($tmp[
'content_type']) || (!empty($tmp[
'content_type']) && preg_match(
'/UTF-8/', $tmp[
'content_type']))) {
849 if (function_exists(
'mb_check_encoding')) {
850 if (mb_check_encoding($tmp[
'content'],
'UTF-8')) {
854 setEventMessages(
'Error getting '.$urltograb.
': content seems not a valid UTF-8',
null,
'errors');
855 $action =
'createcontainer';
860 if ($tmp[
'curl_error_no']) {
862 setEventMessages(
'Error getting '.$urltograb.
': '.$tmp[
'curl_error_msg'],
null,
'errors');
863 $action =
'createcontainer';
864 } elseif ($tmp[
'http_code'] !=
'200') {
866 setEventMessages(
'Error getting '.$urltograb.
': '.$tmp[
'http_code'],
null,
'errors');
867 $action =
'createcontainer';
886 preg_match(
'/<head>(.*)<\/head>/ims', $tmp[
'content'], $regs);
889 $objectpage->type_container =
'page';
890 $objectpage->pageurl = $pageurl;
891 if (empty($objectpage->pageurl)) {
893 $objectpage->pageurl = $tmpdomain.
'-home';
896 $objectpage->aliasalt =
'';
898 if (preg_match(
'/^(\d+)\-/', basename($urltograb), $regs)) {
899 $objectpage->aliasalt = $regs[1];
903 if (preg_match(
'/<title>(.*)<\/title>/ims', $head, $regtmp)) {
904 $objectpage->title = $regtmp[1];
906 if (preg_match(
'/<meta name="title"[^"]+content="([^"]+)"/ims', $head, $regtmp)) {
907 if (empty($objectpage->title)) {
908 $objectpage->title = $regtmp[1];
911 if (preg_match(
'/<meta name="description"[^"]+content="([^"]+)"/ims', $head, $regtmp)) {
912 $objectpage->description = $regtmp[1];
914 if (preg_match(
'/<meta name="keywords"[^"]+content="([^"]+)"/ims', $head, $regtmp)) {
915 $objectpage->keywords = $regtmp[1];
917 if (preg_match(
'/<html\s+lang="([^"]+)"/ims', $tmp[
'content'], $regtmp)) {
918 $tmplang = explode(
'-', $regtmp[1]);
919 $objectpage->lang = $tmplang[0].($tmplang[1] ?
'_'.strtoupper($tmplang[1]) :
'');
922 $tmp[
'content'] = preg_replace(
'/\s*<meta name="generator"[^"]+content="([^"]+)"\s*\/?>/ims',
'', $tmp[
'content']);
924 $objectpage->content = $tmp[
'content'];
925 $objectpage->content = preg_replace(
'/^.*<body(\s[^>]*)*>/ims',
'', $objectpage->content);
926 $objectpage->content = preg_replace(
'/<\/body(\s[^>]*)*>.*$/ims',
'', $objectpage->content);
934 $objectpage->htmlheader = $tmp[
'content'];
935 $objectpage->htmlheader = preg_replace(
'/^.*<head(\s[^>]*)*>/ims',
'', $objectpage->htmlheader);
936 $objectpage->htmlheader = preg_replace(
'/<\/head(\s[^>]*)*>.*$/ims',
'', $objectpage->htmlheader);
937 $objectpage->htmlheader = preg_replace(
'/<base(\s[^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
938 $objectpage->htmlheader = preg_replace(
'/<meta http-equiv="content-type"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
939 $objectpage->htmlheader = preg_replace(
'/<meta name="robots"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
940 $objectpage->htmlheader = preg_replace(
'/<meta name="title"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
941 $objectpage->htmlheader = preg_replace(
'/<meta name="description"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
942 $objectpage->htmlheader = preg_replace(
'/<meta name="keywords"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
943 $objectpage->htmlheader = preg_replace(
'/<meta name="generator"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
946 $objectpage->htmlheader = preg_replace(
'/<title>[^<]*<\/title>\n*/ims',
'', $objectpage->htmlheader);
947 $objectpage->htmlheader = preg_replace(
'/<link[^>]*rel="shortcut[^>]*>\n/ims',
'', $objectpage->htmlheader);
948 $objectpage->htmlheader = preg_replace(
'/<link[^>]*rel="alternate[^>]*>\n/ims',
'', $objectpage->htmlheader);
949 $objectpage->htmlheader = preg_replace(
'/<link[^>]*rel="canonical[^>]*>\n/ims',
'', $objectpage->htmlheader);
952 $tmp = $objectpage->htmlheader;
955 preg_match_all(
'/<script([^\.>]+)src=["\']([^"\'>]+)["\']([^>]*)><\/script>/i', $objectpage->htmlheader, $regs);
956 $errorforsubresource = 0;
957 foreach ($regs[0] as $key => $val) {
958 dol_syslog(
"We will grab the script resource found into script tag ".$regs[2][$key]);
960 $linkwithoutdomain = $regs[2][$key];
961 if (preg_match(
'/^\//', $regs[2][$key])) {
962 $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key];
964 $urltograbbis = $urltograbdirwithoutslash.
'/'.$regs[2][$key];
968 if (preg_match(
'/^http/', $regs[2][$key])) {
969 $urltograbbis = $regs[2][$key];
970 $linkwithoutdomain = preg_replace(
'/^https?:\/\/[^\/]+\//i',
'', $regs[2][$key]);
980 if ($domaintograb != $domaintograbbis) {
1012 $tmp = preg_replace(
'/'.preg_quote($regs[0][$key],
'/').
'/i',
'', $tmp);
1014 $objectpage->htmlheader = trim($tmp).
"\n";
1018 $pagecsscontent =
"\n".
'<style>'.
"\n";
1020 preg_match_all(
'/<link([^\.>]+)href=["\']([^"\'>]+\.css[^"\'>]*)["\']([^>]*)>/i', $objectpage->htmlheader, $regs);
1021 $errorforsubresource = 0;
1022 foreach ($regs[0] as $key => $val) {
1023 dol_syslog(
"We will grab the css resources found into link tag ".$regs[2][$key]);
1025 $linkwithoutdomain = $regs[2][$key];
1026 if (preg_match(
'/^\//', $regs[2][$key])) {
1027 $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key];
1029 $urltograbbis = $urltograbdirwithoutslash.
'/'.$regs[2][$key];
1033 if (preg_match(
'/^http/', $regs[2][$key])) {
1034 $urltograbbis = $regs[2][$key];
1035 $linkwithoutdomain = preg_replace(
'/^https?:\/\/[^\/]+\//i',
'', $regs[2][$key]);
1045 if ($domaintograb != $domaintograbbis) {
1049 $tmpgeturl =
getURLContent($urltograbbis,
'GET',
'', 1, array(), array(
'http',
'https'), 0);
1050 if ($tmpgeturl[
'curl_error_no']) {
1051 $errorforsubresource++;
1052 setEventMessages(
'Error getting link tag url '.$urltograbbis.
': '.$tmpgeturl[
'curl_error_msg'],
null,
'errors');
1053 dol_syslog(
'Error getting '.$urltograbbis.
': '.$tmpgeturl[
'curl_error_msg']);
1054 $action =
'createcontainer';
1055 } elseif ($tmpgeturl[
'http_code'] !=
'200') {
1056 $errorforsubresource++;
1057 setEventMessages(
'Error getting link tag url '.$urltograbbis.
': '.$tmpgeturl[
'http_code'],
null,
'errors');
1058 dol_syslog(
'Error getting '.$urltograbbis.
': '.$tmpgeturl[
'curl_error_msg']);
1059 $action =
'createcontainer';
1068 $tmpgeturl[
'content'] = preg_replace(
'/\/\*\s+CSS content[a-z\s]*\s+\*\//',
'', $tmpgeturl[
'content']);
1078 $pagecsscontent .=
'/* Content of file '.$urltograbbis.
' */'.
"\n";
1080 getAllImages($object, $objectpage, $urltograbbis, $tmpgeturl[
'content'], $action, 1, $grabimages, $grabimagesinto);
1083 include_once DOL_DOCUMENT_ROOT.
'/core/class/lessc.class.php';
1084 $lesscobj =
new Lessc();
1086 $contentforlessc =
".bodywebsite {\n".$tmpgeturl[
'content'].
"\n}\n";
1088 $contentforlessc = $lesscobj->compile($contentforlessc);
1091 $pagecsscontent .= $contentforlessc.
"\n";
1093 }
catch (exception $e) {
1095 dol_syslog(
"Failed to compile the CSS from URL ".$urltograbbis.
" with lessc: ".$e->getMessage(), LOG_WARNING);
1096 $pagecsscontent .= $tmpgeturl[
'content'].
"\n";
1099 $objectpage->htmlheader = preg_replace(
'/'.preg_quote($regs[0][$key],
'/').
'\n*/ims',
'', $objectpage->htmlheader);
1103 $pagecsscontent .=
'</style>';
1107 $objectpage->htmlheader .= trim($pagecsscontent).
"\n";
1111 $tmp = $objectpage->content;
1113 getAllImages($object, $objectpage, $urltograb, $tmp, $action, 1, $grabimages, $grabimagesinto);
1116 $tmp = preg_replace(
'/a href="\/([^\/"]+)\/([^\/"]+)"/',
'a href="/\1-\2.php"', $tmp);
1117 $tmp = preg_replace(
'/a href="\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)"/',
'a href="/\1-\2-\3.php"', $tmp);
1118 $tmp = preg_replace(
'/a href="\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)"/',
'a href="/\1-\2-\3-\4.php"', $tmp);
1121 $objectpage->content = $tmp;
1123 $objectpage->grabbed_from = $urltograb;
1127 $newaliasnames =
'';
1128 if (!$error &&
GETPOST(
'WEBSITE_ALIASALT',
'alpha')) {
1129 $arrayofaliastotest = explode(
',', str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_ALIASALT',
'alpha')));
1131 foreach ($arrayofaliastotest as $aliastotest) {
1132 $aliastotest = trim(preg_replace(
'/\.php$/i',
'', $aliastotest));
1135 if (preg_match(
'/^page\d+/i', $aliastotest)) {
1137 $langs->load(
"errors");
1139 $action =
'createcontainer';
1142 $result = $websitepagetemp->fetch(0,
$object->id, $aliastotest);
1145 $langs->load(
"errors");
1146 setEventMessages($websitepagetemp->error, $websitepagetemp->errors,
'errors');
1147 $action =
'createcontainer';
1152 $langs->load(
"errors");
1153 setEventMessages($langs->trans(
"ErrorAPageWithThisNameOrAliasAlreadyExists", $websitepagetemp->pageurl),
null,
'errors');
1154 $action =
'createcontainer';
1157 $newaliasnames .= ($newaliasnames ?
', ' :
'').$aliastotest;
1162 $objectpage->title = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_TITLE',
'alphanohtml'));
1163 $objectpage->type_container =
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'aZ09');
1164 $objectpage->pageurl =
GETPOST(
'WEBSITE_PAGENAME',
'alpha');
1165 $objectpage->aliasalt = $newaliasnames;
1166 $objectpage->description = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml'));
1167 $objectpage->lang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
1168 $objectpage->otherlang =
GETPOST(
'WEBSITE_OTHERLANG',
'aZ09comma');
1169 $objectpage->image =
GETPOST(
'WEBSITE_IMAGE',
'alpha');
1170 $objectpage->keywords = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_KEYWORDS',
'alphanohtml'));
1171 $objectpage->allowed_in_frames =
GETPOST(
'WEBSITE_ALLOWED_IN_FRAMES',
'aZ09') ? 1 : 0;
1172 $objectpage->htmlheader =
GETPOST(
'htmlheader',
'none');
1173 $objectpage->author_alias =
GETPOST(
'WEBSITE_AUTHORALIAS',
'alphanohtml');
1174 $objectpage->object_type =
GETPOST(
'WEBSITE_OBJECTCLASS');
1175 $objectpage->fk_object =
GETPOST(
'WEBSITE_OBJECTID');
1176 $substitutionarray = array();
1177 $substitutionarray[
'__WEBSITE_CREATED_BY__'] = $user->getFullName($langs);
1190 $pageidfortranslation = (
GETPOSTINT(
'pageidfortranslation') > 0 ?
GETPOSTINT(
'pageidfortranslation') : 0);
1191 if ($pageidfortranslation > 0) {
1194 $objectpagetmp->fetch($pageidfortranslation);
1195 if ($objectpagetmp->fk_page > 0) {
1196 $pageidfortranslation = $objectpagetmp->fk_page;
1199 $objectpage->fk_page = $pageidfortranslation;
1203 if (GETPOSTISSET(
'content')) {
1205 $content =
GETPOST(
'content',
'none');
1222 if (empty($objectpage->pageurl)) {
1223 $langs->load(
"errors");
1224 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WEBSITE_PAGENAME")),
null,
'errors');
1226 $action =
'createcontainer';
1227 } elseif (!preg_match(
'/^[a-z0-9\-\_]+$/i', $objectpage->pageurl)) {
1228 $langs->load(
"errors");
1229 setEventMessages($langs->transnoentities(
"ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities(
'WEBSITE_PAGENAME')),
null,
'errors');
1231 $action =
'createcontainer';
1233 if (empty($objectpage->title)) {
1234 $langs->load(
"errors");
1235 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WEBSITE_TITLE")),
null,
'errors');
1237 $action =
'createcontainer';
1239 if ($objectpage->fk_page > 0 && empty($objectpage->lang)) {
1240 $langs->load(
"errors");
1241 setEventMessages($langs->trans(
"ErrorLanguageRequiredIfPageIsTranslationOfAnother"),
null,
'errors');
1243 $action =
'createcontainer';
1245 if ($objectpage->fk_page > 0 && !empty($objectpage->lang)) {
1246 if ($objectpage->lang == $website->lang) {
1247 $langs->load(
"errors");
1248 setEventMessages($langs->trans(
"ErrorLanguageMustNotBeSourceLanguageIfPageIsTranslationOfAnother"),
null,
'errors');
1250 $action =
'createcontainer';
1258 $pageid = $objectpage->create($user);
1262 $action =
'createcontainer';
1268 $categoriesarray =
GETPOST(
'categories',
'array');
1269 $result = $objectpage->setCategories($categoriesarray);
1278 if (empty(
$object->fk_default_home)) {
1279 $object->fk_default_home = $pageid;
1280 $res =
$object->update($user);
1285 $filetpl = $pathofwebsite.
'/page'.$pageid.
'.tpl.php';
1288 $result =
dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper, $object);
1299 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
1300 $filetpl = $pathofwebsite.
'/page'.$objectpage->id.
'.tpl.php';
1305 setEventMessages(
'Failed to write file '.basename($filealias),
null,
'errors');
1314 $action =
'createcontainer';
1321 setEventMessages($langs->trans(
"PageAdded", $objectpage->pageurl),
null,
'mesgs');
1328 $pageid = $objectpage->id;
1334 $pathtomedias = DOL_DATA_ROOT.
'/medias';
1335 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
1337 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
1338 dol_mkdir(dirname($pathtomediasinwebsite));
1339 $result = symlink($pathtomedias, $pathtomediasinwebsite);
1341 $langs->load(
"errors");
1342 setEventMessages($langs->trans(
"ErrorFailedToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias),
null,
'errors');
1356 $htmlheadercontent =
"<html>\n";
1357 $htmlheadercontent .= $htmlheadercontentdefault;
1358 $htmlheadercontent .=
"</html>";
1363 $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;}";
1368 $jscontent =
"/* JS content (all pages) */\n";
1373 $robotcontent =
"# Robot file. Generated with Dolibarr\nUser-agent: *\nAllow: /public/\nDisallow: /administrator/";
1378 $htaccesscontent =
"# Order allow,deny\n# Deny from all";
1383 $manifestjsoncontent =
"";
1388 $readmecontent =
"Website generated by Dolibarr ERP CRM";
1393 $licensecontent =
"MIT License";
1397 $action =
'preview';
1402if ($action ==
'confirm_deletesite' && $confirm ==
'yes' && $permissiontodelete) {
1411 $res =
$object->delete($user);
1418 if (
GETPOST(
'delete_also_js',
'alpha') ==
'on') {
1419 $pathofwebsitejs = DOL_DATA_ROOT.
'/medias/js/'.
$object->ref;
1423 if (
GETPOST(
'delete_also_medias',
'alpha') ==
'on') {
1424 $pathofwebsitemedias = DOL_DATA_ROOT.
'/medias/image/'.
$object->ref;
1434 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.
$object->id);
1443if (GETPOSTISSET(
'pageid') && $action ==
'delete' && $permissiontodelete && !
GETPOST(
'file_manager')) {
1448 $res =
$object->fetch(0, $websitekey);
1451 $res = $objectpage->fetch($pageid,
$object->id);
1454 $res = $objectpage->delete($user);
1463 setEventMessages($langs->trans(
"PageDeleted", $objectpage->pageurl, $websitekey),
null,
'mesgs');
1465 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$websitekey);
1473if (!GETPOSTISSET(
'pageid')) {
1474 $objectclass =
'WebsitePage';
1478 if (!$error && ($massaction ==
'delete' || ($action ==
'delete' && $confirm ==
'yes')) && $permissiontodelete) {
1481 $objecttmp =
new $objectclass($db);
1483 foreach ($toselect as $toselectid) {
1484 $result = $objecttmp->fetch($toselectid);
1486 $result = $objecttmp->delete($user);
1515 if ($action ==
'delete') {
1516 $mode =
'replacesite';
1517 $action =
'replacesite';
1519 $containertype =
GETPOST(
'optioncontainertype',
'aZ09') !=
'-1' ?
GETPOST(
'optioncontainertype',
'aZ09') :
'';
1520 $langcode =
GETPOST(
'optionlanguage',
'aZ09');
1521 $otherfilters = array();
1523 $otherfilters[
'category'] =
GETPOSTINT(
'optioncategory');
1526 $listofpages =
getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters);
1531if ($action ==
'updatecss' && $usercanedit) {
1534 $action =
'editcss';
1536 $res =
$object->fetch(0, $websitekey);
1539 if (GETPOSTISSET(
'virtualhost')) {
1540 $tmpvirtualhost = preg_replace(
'/\/$/',
'',
GETPOST(
'virtualhost',
'alpha'));
1541 if ($tmpvirtualhost && !preg_match(
'/^http/', $tmpvirtualhost)) {
1543 setEventMessages($langs->trans(
'ErrorURLMustStartWithHttp', $langs->transnoentitiesnoconv(
"VirtualHost")),
null,
'errors');
1544 $action =
'editcss';
1548 $arrayotherlang = explode(
',',
GETPOST(
'WEBSITE_OTHERLANG',
'alphanohtml'));
1549 foreach ($arrayotherlang as $key => $val) {
1551 if (empty(trim($val))) {
1554 $arrayotherlang[$key] = substr(trim($val), 0, 2);
1557 $object->virtualhost = $tmpvirtualhost;
1559 $object->otherlang = implode(
',', $arrayotherlang);
1562 $result =
$object->update($user);
1566 $action =
'editcss';
1572 if (($_FILES[
'addedfile'][
"name"] !=
'')) {
1573 $uploadfolder =
$conf->website->dir_output.
'/'.$websitekey;
1574 if ($_FILES[
'addedfile'][
'type'] !=
'image/png') {
1578 $filetoread = realpath(
dol_osencode($_FILES[
'addedfile'][
'tmp_name']));
1579 $filesize = getimagesize($filetoread);
1580 if ($filesize[0] != $filesize[1]) {
1582 setEventMessages($langs->trans(
'ErrorFaviconMustBeASquaredImage'), array(),
'errors');
1584 if (! $error && ($filesize[0] != 16 && $filesize[0] != 32 && $filesize[0] != 64)) {
1593 if (!GETPOSTISSET(
'updateandstay')) {
1594 $action =
'preview';
1596 $backtopage = preg_replace(
'/searchstring=[^&]*/',
'', $backtopage);
1597 header(
"Location: ".$backtopage);
1601 $action =
'editcss';
1620 $dataposted = trim(
GETPOST(
'WEBSITE_HTML_HEADER',
'restricthtmlallowlinkscript'));
1622 $dataposted = preg_replace(array(
'/<html>\n*/ims',
'/<\/html>\n*/ims'), array(
'',
''), $dataposted);
1623 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1626 $phpfullcodestringold =
'';
1630 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1632 if (!$errorphpcheck) {
1633 $htmlheadercontent =
'';
1645 $htmlheadercontent .= $dataposted.
"\n";
1660 $dataposted = trim(
GETPOST(
'WEBSITE_CSS_INLINE',
'none'));
1661 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1664 $phpfullcodestringold =
'';
1668 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1670 if (!$errorphpcheck) {
1673 $csscontent .=
"<?php // BEGIN PHP\n";
1674 $csscontent .=
'$websitekey=basename(__DIR__);'.
"\n";
1675 $csscontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded\n";
1676 $csscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
1677 $csscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
1678 $csscontent .=
"ob_start();\n";
1679 $csscontent .=
"if (! headers_sent()) { /* because file is included inline when in edit mode and we don't want warning */ \n";
1680 $csscontent .=
"header('Cache-Control: max-age=3600, public, must-revalidate');\n";
1681 $csscontent .=
"header('Content-type: text/css');\n";
1682 $csscontent .=
"}\n";
1683 $csscontent .=
"// END PHP ?>\n";
1685 $csscontent .= $dataposted.
"\n";
1687 $csscontent .=
'<?php // BEGIN PHP'.
"\n";
1688 $csscontent .=
'$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "css");'.
"\n";
1689 $csscontent .=
"// END PHP\n";
1691 dol_syslog(
"Save css content into ".$filecss);
1703 $dataposted = trim(
GETPOST(
'WEBSITE_JS_INLINE',
'none'));
1704 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1707 $phpfullcodestringold =
'';
1711 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1713 if (!$errorphpcheck) {
1716 $jscontent .=
"<?php // BEGIN PHP\n";
1717 $jscontent .=
'$websitekey=basename(__DIR__);'.
"\n";
1718 $jscontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded\n";
1719 $jscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
1720 $jscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
1721 $jscontent .=
"ob_start();\n";
1722 $jscontent .=
"header('Cache-Control: max-age=3600, public, must-revalidate');\n";
1723 $jscontent .=
"header('Content-type: application/javascript');\n";
1724 $jscontent .=
"// END PHP ?>\n";
1726 $jscontent .= $dataposted.
"\n";
1728 $jscontent .=
'<?php // BEGIN PHP'.
"\n";
1729 $jscontent .=
'$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "js");'.
"\n";
1730 $jscontent .=
"// END PHP\n";
1741 $dataposted = trim(
GETPOST(
'WEBSITE_ROBOT',
'nohtml'));
1742 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1745 $phpfullcodestringold =
'';
1749 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1751 if (!$errorphpcheck) {
1764 $robotcontent .= $dataposted.
"\n";
1779 $dataposted = trim(
GETPOST(
'WEBSITE_HTACCESS',
'nohtml'));
1780 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1783 $phpfullcodestringold =
'';
1787 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1789 if (!$errorphpcheck) {
1791 $htaccesscontent =
'';
1792 $htaccesscontent .= $dataposted.
"\n";
1807 $dataposted = trim(
GETPOST(
'WEBSITE_MANIFEST_JSON',
'restricthtmlallowunvalid'));
1808 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1811 $phpfullcodestringold =
'';
1815 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1817 if (!$errorphpcheck) {
1818 $manifestjsoncontent =
'';
1820 $manifestjsoncontent .=
"<?php // BEGIN PHP\n";
1821 $manifestjsoncontent .=
'$websitekey=basename(__DIR__);'.
"\n";
1822 $manifestjsoncontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded\n";
1823 $manifestjsoncontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
1824 $manifestjsoncontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
1825 $manifestjsoncontent .=
"ob_start();\n";
1826 $manifestjsoncontent .=
"header('Cache-Control: max-age=3600, public, must-revalidate');\n";
1827 $manifestjsoncontent .=
"header('Content-type: application/manifest+json');\n";
1828 $manifestjsoncontent .=
"// END PHP ?>\n";
1830 $manifestjsoncontent .= $dataposted.
"\n";
1832 $manifestjsoncontent .=
'<?php // BEGIN PHP'.
"\n";
1833 $manifestjsoncontent .=
'$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "manifest");'.
"\n";
1834 $manifestjsoncontent .=
"// END PHP\n";
1839 setEventMessages(
'Failed to write file '.$filemanifestjson,
null,
'errors');
1846 $dataposted = trim(
GETPOST(
'WEBSITE_README',
'nohtml'));
1847 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1850 $phpfullcodestringold =
'';
1854 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1856 if (!$errorphpcheck) {
1857 $readmecontent =
'';
1869 $readmecontent .= $dataposted.
"\n";
1885 $dataposted = trim(
GETPOST(
'WEBSITE_LICENSE',
'nohtml'));
1886 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1889 $phpfullcodestringold =
'';
1893 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1895 if (!$errorphpcheck) {
1896 $licensecontent =
'';
1908 $licensecontent .= $dataposted.
"\n";
1932 if (!GETPOSTISSET(
'updateandstay')) {
1933 $action =
'preview';
1935 $backtopage = preg_replace(
'/searchstring=[^&]*/',
'', $backtopage);
1936 header(
"Location: ".$backtopage);
1940 $action =
'editcss';
1947if ($action ==
'setashome' && $usercanedit) {
1949 $object->fetch(0, $websitekey);
1952 $object->fk_default_home = $pageid;
1953 $res =
$object->update($user);
1962 $filetpl = $pathofwebsite.
'/page'.$pageid.
'.tpl.php';
1965 $result =
dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper, $object);
1973 $action =
'preview';
1980if ($action ==
'updatemeta' && $usercanedit) {
1983 $result =
$object->fetch(0, $websitekey);
1986 $objectpage->fk_website =
$object->id;
1989 if (!preg_match(
'/^[a-z0-9\-\_]+$/i',
GETPOST(
'WEBSITE_PAGENAME',
'alpha'))) {
1991 $langs->load(
"errors");
1992 setEventMessages($langs->transnoentities(
"ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities(
'WEBSITE_PAGENAME')),
null,
'errors');
1993 $action =
'editmeta';
1996 $res = $objectpage->fetch($pageid,
$object->id);
1999 setEventMessages(
'Page not found '.$objectpage->error, $objectpage->errors,
'errors');
2003 if (!$error &&
GETPOST(
'WEBSITE_PAGENAME',
'alpha')) {
2005 $result = $websitepagetemp->fetch(-1 * $objectpage->id,
$object->id,
GETPOST(
'WEBSITE_PAGENAME',
'alpha'));
2008 $langs->load(
"errors");
2009 setEventMessages($websitepagetemp->error, $websitepagetemp->errors,
'errors');
2010 $action =
'editmeta';
2014 $langs->load(
"errors");
2015 setEventMessages($langs->trans(
"ErrorAPageWithThisNameOrAliasAlreadyExists", $websitepagetemp->pageurl),
null,
'errors');
2016 $action =
'editmeta';
2020 $newaliasnames =
'';
2021 if (!$error &&
GETPOST(
'WEBSITE_ALIASALT',
'alpha')) {
2022 $arrayofaliastotest = explode(
',', str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_ALIASALT',
'alpha')));
2025 foreach ($arrayofaliastotest as $aliastotest) {
2026 $aliastotest = trim(preg_replace(
'/\.php$/i',
'', $aliastotest));
2029 if (preg_match(
'/^page\d+/i', $aliastotest)) {
2031 $langs->load(
"errors");
2033 $action =
'editmeta';
2036 $result = $websitepagetemp->fetch(-1 * $objectpage->id,
$object->id, $aliastotest);
2039 $langs->load(
"errors");
2040 setEventMessages($websitepagetemp->error, $websitepagetemp->errors,
'errors');
2041 $action =
'editmeta';
2046 $langs->load(
"errors");
2047 setEventMessages($langs->trans(
"ErrorAPageWithThisNameOrAliasAlreadyExists", $websitepagetemp->pageurl),
null,
'errors');
2048 $action =
'editmeta';
2051 $newaliasnames .= ($newaliasnames ?
', ' :
'').$aliastotest;
2057 $objectpage->old_object = clone $objectpage;
2059 $objectpage->title = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_TITLE',
'alphanohtml'));
2060 $objectpage->type_container =
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'aZ09');
2061 $objectpage->pageurl =
GETPOST(
'WEBSITE_PAGENAME',
'alpha');
2062 $objectpage->aliasalt = $newaliasnames;
2063 $objectpage->lang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
2064 $objectpage->otherlang =
GETPOST(
'WEBSITE_OTHERLANG',
'aZ09comma');
2065 $objectpage->description = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml'));
2066 $objectpage->image =
GETPOST(
'WEBSITE_IMAGE',
'alpha');
2067 $objectpage->keywords = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_KEYWORDS',
'alphanohtml'));
2068 $objectpage->allowed_in_frames =
GETPOST(
'WEBSITE_ALLOWED_IN_FRAMES',
'aZ09') ? 1 : 0;
2069 $objectpage->htmlheader = trim(
GETPOST(
'htmlheader',
'restricthtmlallowlinkscript'));
2070 $objectpage->fk_page = (
GETPOSTINT(
'pageidfortranslation') > 0 ?
GETPOSTINT(
'pageidfortranslation') : 0);
2071 $objectpage->author_alias = trim(
GETPOST(
'WEBSITE_AUTHORALIAS',
'alphanohtml'));
2072 $objectpage->object_type =
GETPOST(
'WEBSITE_OBJECTCLASS',
'alpha');
2073 $objectpage->fk_object =
GETPOST(
'WEBSITE_OBJECTID',
'aZ09');
2076 if ($newdatecreation) {
2077 $objectpage->date_creation = $newdatecreation;
2080 $res = $objectpage->update($user);
2082 $langs->load(
"errors");
2083 if ($db->lasterrno ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
2085 $langs->load(
"errors");
2086 setEventMessages($langs->trans(
"ErrorAPageWithThisNameOrAliasAlreadyExists"),
null,
'errors');
2087 $action =
'editmeta';
2090 $langs->load(
"errors");
2092 $action =
'editmeta';
2099 $categoriesarray =
GETPOST(
'categories',
'array');
2100 $result = $objectpage->setCategories($categoriesarray);
2114 $filemaster = $pathofwebsite.
'/master.inc.php';
2115 $fileoldalias = $pathofwebsite.
'/'.$objectpage->old_object->pageurl.
'.php';
2116 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
2127 if (!empty($fileoldalias)) {
2128 dol_syslog(
"We delete old alias page name=".$fileoldalias.
" to build a new alias page=".$filealias);
2132 if (empty($objectpage->lang) || !in_array($objectpage->lang, explode(
',',
$object->otherlang))) {
2133 $dirname = dirname($fileoldalias);
2134 $filename = basename($fileoldalias);
2135 $sublangs = explode(
',',
$object->otherlang);
2136 foreach ($sublangs as $sublang) {
2140 if (empty(trim($sublang))) {
2143 $fileoldaliassub = $dirname.
'/'.$sublang.
'/'.$filename;
2149 if (!empty($objectpage->old_object->aliasalt)) {
2150 $tmpaltaliases = explode(
',', $objectpage->old_object->aliasalt);
2151 if (is_array($tmpaltaliases)) {
2152 foreach ($tmpaltaliases as $tmpaliasalt) {
2153 dol_syslog(
"We delete old alt alias pages name=".trim($tmpaliasalt));
2157 if (empty($objectpage->lang) || !in_array($objectpage->lang, explode(
',',
$object->otherlang))) {
2158 $dirname = dirname($pathofwebsite.
'/'.trim($tmpaliasalt).
'.php');
2159 $filename = basename($pathofwebsite.
'/'.trim($tmpaliasalt).
'.php');
2160 $sublangs = explode(
',',
$object->otherlang);
2161 foreach ($sublangs as $sublang) {
2165 if (empty(trim($sublang))) {
2168 $fileoldaliassub = $dirname.
'/'.$sublang.
'/'.$filename;
2182 if (!empty($objectpage->aliasalt)) {
2183 $tmpaltaliases = explode(
',', $objectpage->aliasalt);
2184 if (is_array($tmpaltaliases)) {
2185 foreach ($tmpaltaliases as $tmpaliasalt) {
2186 if (trim($tmpaliasalt)) {
2187 $filealias = $pathofwebsite.
'/'.trim($tmpaliasalt).
'.php';
2190 setEventMessages(
'Failed to write file '.basename($filealias),
null,
'errors');
2203 if (!GETPOSTISSET(
'updateandstay')) {
2206 $action =
'preview';
2208 $action =
'editmeta';
2214 $action =
'preview';
2220if ((($action ==
'updatesource' || $action ==
'updatecontent' || $action ==
'confirm_createfromclone' || $action ==
'confirm_createpagefromclone') || ($action ==
'preview' && (
GETPOST(
'refreshsite') ||
GETPOST(
'refreshpage') ||
GETPOST(
'preview')))) && $usercanedit) {
2221 $object->fetch(0, $websitekey);
2224 if ($action ==
'confirm_createfromclone') {
2227 $objectnew =
new Website($db);
2233 $action =
'preview';
2240 $pageid =
$object->fk_default_home;
2241 $websitekey =
GETPOST(
'siteref',
'aZ09');
2247 if ($action ==
'confirm_createpagefromclone') {
2248 $istranslation = (
GETPOST(
'is_a_translation',
'aZ09') ==
'on' ? 1 : 0);
2250 if ($istranslation) {
2251 if (
GETPOST(
'newlang',
'aZ09') == $objectpage->lang || !
GETPOST(
'newlang',
'aZ09')) {
2253 setEventMessages($langs->trans(
"LanguageMustNotBeSameThanClonedPage"),
null,
'errors');
2254 $action =
'preview';
2258 setEventMessages($langs->trans(
"WebsiteMustBeSameThanClonedPageIfTranslation"),
null,
'errors');
2259 $action =
'preview';
2267 $pathofwebsitenew = $pathofwebsite;
2269 $tmpwebsite =
new Website($db);
2270 if ($newwebsiteid > 0 && $newwebsiteid !=
$object->id) {
2271 $tmpwebsite->fetch($newwebsiteid);
2272 $pathofwebsitenew = $dolibarr_main_data_root.($conf->entity > 1 ?
'/'.$conf->entity :
'').
'/website/'.$tmpwebsite->ref;
2278 $resultpage = $objectpage->createFromClone($user, $pageid,
GETPOST(
'newpageurl',
'aZ09'), (
GETPOST(
'newlang',
'aZ09') ?
GETPOST(
'newlang',
'aZ09') :
''), $istranslation, $newwebsiteid,
GETPOST(
'newtitle',
'alphanohtml'), $tmpwebsite);
2279 if ($resultpage < 0) {
2282 $action =
'createpagefromclone';
2286 $filetpl = $pathofwebsitenew.
'/page'.$resultpage->id.
'.tpl.php';
2287 $fileindex = $pathofwebsitenew.
'/index.php';
2288 $filewrapper = $pathofwebsitenew.
'/wrapper.php';
2297 if (empty($newwebsiteid) || $newwebsiteid ==
$object->id) {
2298 $pageid = $resultpage->id;
2311 $pathtomedias = DOL_DATA_ROOT.
'/medias';
2312 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
2314 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
2315 dol_mkdir(dirname($pathtomediasinwebsite));
2316 $result = symlink($pathtomedias, $pathtomediasinwebsite);
2318 $langs->load(
"errors");
2319 setEventMessages($langs->trans(
"ErrorFailedToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias),
null,
'errors');
2329 $objectpage->fk_website =
$object->id;
2332 $res = $objectpage->fetch($pageid);
2335 if (
$object->fk_default_home > 0) {
2336 $res = $objectpage->fetch(
$object->fk_default_home);
2339 $res = $objectpage->fetch(0,
$object->id);
2344 if (!$error && $res > 0) {
2345 if ($action ==
'updatesource' || $action ==
'updatecontent') {
2350 $objectpage->content =
GETPOST(
'PAGE_CONTENT',
'none');
2355 $error =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
2358 if ($action ==
'updatesource') {
2359 $action =
'editsource';
2361 if ($action ==
'updatecontent') {
2362 $action =
'editcontent';
2367 $objectpage->content = preg_replace(
'/<head>.*<\/head>/ims',
'', $objectpage->content);
2371 $res = $objectpage->update($user);
2375 if ($action ==
'updatesource') {
2376 $action =
'editsource';
2378 if ($action ==
'updatecontent') {
2379 $action =
'editcontent';
2386 $filemaster = $pathofwebsite.
'/master.inc.php';
2388 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
2396 setEventMessages(
'Failed to write the master file file '.$filemaster,
null,
'errors');
2420 setEventMessages(
'Failed to write the alias file '.basename($filealias),
null,
'errors');
2428 if (!GETPOSTISSET(
'updateandstay')) {
2430 header(
"Location: ".$backtopage);
2433 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$websitekey.
'&pageid='.$pageid);
2437 if ($action ==
'updatesource') {
2438 $action =
'editsource';
2440 if ($action ==
'updatecontent') {
2441 $action =
'editcontent';
2446 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$websitekey.
'&pageid='.$pageid);
2453 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$websitekey.
'&pageid='.$pageid);
2458 if (empty($websitekey) || $websitekey ==
'-1') {
2459 setEventMessages($langs->trans(
"NoWebSiteCreateOneFirst"),
null,
'warnings');
2462 setEventMessages($langs->trans(
"YouCanCreatePageOrImportTemplate"),
null,
'warnings');
2468if ($action ==
'deletelang' && $usercanedit) {
2469 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"website_page SET fk_page = NULL";
2470 $sql .=
" WHERE rowid = ".GETPOSTINT(
'deletelangforid');
2473 $resql = $db->query($sql);
2477 $objectpage->fk_page =
null;
2480 $action =
'editmeta';
2485if ($action ==
'exportsite' && $user->hasRight(
'website',
'export')) {
2486 $fileofzip =
$object->exportWebSite();
2489 $file_name = basename($fileofzip);
2490 header(
"Content-Type: application/zip");
2491 header(
"Content-Disposition: attachment; filename=".$file_name);
2492 header(
"Content-Length: ".filesize($fileofzip));
2494 readfile($fileofzip);
2498 $action =
'preview';
2503if ($action ==
'overwritesite' && $user->hasRight(
'website',
'export')) {
2505 $fileofzip =
$object->exportWebSite();
2506 $pathToExport =
GETPOST(
'export_path');
2508 $object->overwriteTemplate($fileofzip, $pathToExport);
2515if ($action ==
'regeneratesite' && $usercanedit) {
2518 $pathtomedias = DOL_DATA_ROOT.
'/medias';
2519 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
2521 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
2522 dol_mkdir(dirname($pathtomediasinwebsite));
2523 $result = symlink($pathtomedias, $pathtomediasinwebsite);
2525 $langs->load(
"errors");
2526 setEventMessages($langs->trans(
"ErrorFailedToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias),
null,
'errors');
2527 $action =
'preview';
2531 $result =
$object->rebuildWebSiteFiles();
2533 setEventMessages($langs->trans(
"PagesRegenerated", $result),
null,
'mesgs');
2534 $action =
'preview';
2537 $action =
'preview';
2542if ($action ==
'importsiteconfirm' && $usercanedit) {
2543 $dolibarrdataroot = preg_replace(
'/([\\/]+)$/i',
'', DOL_DATA_ROOT);
2544 $allowimportsite =
true;
2545 if (
dol_is_file($dolibarrdataroot.
'/installmodules.lock')) {
2546 $allowimportsite =
false;
2549 if ($allowimportsite) {
2550 if (empty($_FILES) && !GETPOSTISSET(
'templateuserfile')) {
2551 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"File")),
null,
'errors');
2552 $action =
'importsite';
2554 if (!empty($_FILES) || GETPOSTISSET(
'templateuserfile')) {
2557 $pathtomedias = DOL_DATA_ROOT.
'/medias';
2558 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
2560 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
2561 dol_mkdir(dirname($pathtomediasinwebsite));
2562 $result = symlink($pathtomedias, $pathtomediasinwebsite);
2564 $langs->load(
"errors");
2565 setEventMessages($langs->trans(
"ErrorFailedToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias),
null,
'errors');
2566 $action =
'importsite';
2571 if (GETPOSTISSET(
'templateuserfile')) {
2573 $fileofzip = DOL_DATA_ROOT.
'/doctemplates/websites/'.
GETPOST(
'templateuserfile',
'alpha');
2574 } elseif (!empty($_FILES) && is_array($_FILES[
'userfile'])) {
2576 if (is_array($_FILES[
'userfile'][
'tmp_name'])) {
2577 $userfiles = $_FILES[
'userfile'][
'tmp_name'];
2579 $userfiles = array($_FILES[
'userfile'][
'tmp_name']);
2583 foreach ($userfiles as $key => $userfile) {
2584 if (empty($_FILES[
'userfile'][
'tmp_name'][$key])) {
2586 if ($_FILES[
'userfile'][
'error'][$key] == 1 || $_FILES[
'userfile'][
'error'][$key] == 2) {
2588 $action =
'importsite';
2590 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"File")),
null,
'errors');
2591 $action =
'importsite';
2598 $upload_dir = DOL_DATA_ROOT.
'/doctemplates/websites/';
2612 $action =
'importsite';
2615 if (!$error && GETPOSTISSET(
'templateuserfile')) {
2616 $templatewithoutzip = preg_replace(
'/\.zip$/i',
'',
GETPOST(
'templateuserfile'));
2617 $object->setTemplateName($templatewithoutzip);
2619 $result =
$object->importWebSite($fileofzip);
2623 $action =
'importsite';
2628 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.
$object->ref);
2637 $message = $langs->trans(
'InstallModuleFromWebHasBeenDisabledContactUs');
2640 $message = $langs->trans(
"InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.
'/installmodules.lock');
2646$domainname =
'0.0.0.0:8080';
2647$tempdir =
$conf->website->dir_output.
'/'.$websitekey.
'/';
2650if ($action ==
'generatesitemaps' && $usercanedit) {
2652 if ($website->virtualhost) {
2653 $domainname = $website->virtualhost;
2655 if (! preg_match(
'/^http/i', $domainname)) {
2656 $domainname =
'https://'.$domainname;
2659 $domtree =
new DOMDocument(
'1.0',
'UTF-8');
2661 $root = $domtree->createElementNS(
'http://www.sitemaps.org/schemas/sitemap/0.9',
'urlset');
2662 $root->setAttributeNS(
'http://www.w3.org/2000/xmlns/',
'xmlns:xhtml',
'http://www.w3.org/1999/xhtml');
2664 $domtree->formatOutput =
true;
2667 $xmlname =
'sitemap.xml';
2669 $sql =
"SELECT wp.rowid, wp.type_container , wp.pageurl, wp.lang, wp.fk_page, wp.tms as tms,";
2670 $sql .=
" w.virtualhost, w.fk_default_home";
2671 $sql .=
" FROM ".MAIN_DB_PREFIX.
"website_page as wp, ".MAIN_DB_PREFIX.
"website as w";
2672 $sql .=
" WHERE wp.type_container IN ('page', 'blogpost')";
2673 $sql .=
" AND wp.fk_website = w.rowid";
2674 $sql .=
" AND wp.status = ".WebsitePage::STATUS_VALIDATED;
2675 $sql .=
" AND wp.pageurl NOT IN ('404', '500', '501', '503')";
2676 $sql .=
" AND w.ref = '".dol_escape_json($websitekey).
"'";
2677 $sql .=
" ORDER BY wp.tms DESC, wp.rowid DESC";
2678 $resql = $db->query($sql);
2680 $num_rows = $db->num_rows($resql);
2681 if ($num_rows > 0) {
2683 while ($i < $num_rows) {
2684 $objp = $db->fetch_object($resql);
2685 $url = $domtree->createElement(
'url');
2687 $shortlangcode =
'';
2689 $shortlangcode = substr($objp->lang, 0, 2);
2691 if (empty($shortlangcode)) {
2692 $shortlangcode = substr(
$object->lang, 0, 2);
2696 if ($objp->type_container ==
'blogpost') {
2701 $pageurl = $objp->pageurl.
'.php';
2702 if ($objp->fk_default_home == $objp->rowid) {
2705 if ($shortlangcode != substr(
$object->lang, 0, 2)) {
2706 $pageurl = $shortlangcode.
'/'.$pageurl;
2713 $loc = $domtree->createElement(
'loc', $domainname.
'/'.$pageurl);
2714 $lastmod = $domtree->createElement(
'lastmod',
dol_print_date($db->jdate($objp->tms),
'dayrfc',
'gmt'));
2715 $priority = $domtree->createElement(
'priority',
'1');
2717 $url->appendChild($loc);
2718 $url->appendChild($lastmod);
2721 $changefreq = $domtree->createElement(
'changefreq',
'weekly');
2722 $url->appendChild($changefreq);
2725 if ($objp->fk_default_home == $objp->rowid) {
2726 $url->appendChild($priority);
2731 $alternatefound = 0;
2734 $translationof = $objp->fk_page;
2735 if ($translationof) {
2737 $tmppage->fetch($translationof);
2738 if ($tmppage->id > 0) {
2739 $tmpshortlangcode =
'';
2740 if ($tmppage->lang) {
2741 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'', $tmppage->lang);
2743 if (empty($tmpshortlangcode)) {
2744 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'',
$object->lang);
2746 if ($tmpshortlangcode != $shortlangcode) {
2747 $xhtmllink = $domtree->createElement(
'xhtml:link',
'');
2748 $xhtmllink->setAttribute(
"rel",
"alternate");
2749 $xhtmllink->setAttribute(
"hreflang", $tmpshortlangcode);
2750 $xhtmllink->setAttribute(
"href", $domainname.($objp->fk_default_home == $tmppage->id ?
'/' : (($tmpshortlangcode != substr(
$object->lang, 0, 2)) ?
'/'.$tmpshortlangcode :
'').
'/'.$tmppage->pageurl.
'.php'));
2751 $url->appendChild($xhtmllink);
2759 $sql =
'SELECT rowid as id, lang, pageurl from '.MAIN_DB_PREFIX.
'website_page';
2760 $sql .=
" WHERE status = ".((int) WebsitePage::STATUS_VALIDATED).
' AND fk_page IN ('.$db->sanitize($objp->rowid.($translationof ?
", ".$translationof :
"")).
")";
2761 $resqlhastrans = $db->query($sql);
2762 if ($resqlhastrans) {
2763 $num_rows_hastrans = $db->num_rows($resqlhastrans);
2764 if ($num_rows_hastrans > 0) {
2765 while ($objhastrans = $db->fetch_object($resqlhastrans)) {
2766 $tmpshortlangcode =
'';
2767 if ($objhastrans->lang) {
2768 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'', $objhastrans->lang);
2770 if ($tmpshortlangcode != $shortlangcode) {
2771 $xhtmllink = $domtree->createElement(
'xhtml:link',
'');
2772 $xhtmllink->setAttribute(
"rel",
"alternate");
2773 $xhtmllink->setAttribute(
"hreflang", $tmpshortlangcode);
2774 $xhtmllink->setAttribute(
"href", $domainname.($objp->fk_default_home == $objhastrans->id ?
'/' : (($tmpshortlangcode != substr(
$object->lang, 0, 2) ?
'/'.$tmpshortlangcode :
'')).
'/'.$objhastrans->pageurl.
'.php'));
2775 $url->appendChild($xhtmllink);
2785 if ($alternatefound) {
2787 $xhtmllink = $domtree->createElement(
'xhtml:link',
'');
2788 $xhtmllink->setAttribute(
"rel",
"alternate");
2789 $xhtmllink->setAttribute(
"hreflang", $shortlangcode);
2790 $xhtmllink->setAttribute(
"href", $domainname.
'/'.$pageurl);
2791 $url->appendChild($xhtmllink);
2807 $root->appendChild($url);
2813 if ($addrsswrapper &&
getDolGlobalInt(
'WEBSITE_ADD_RSS_FEED_INTO_SITEMAP')) {
2814 $url = $domtree->createElement(
'url');
2816 $pageurl =
'wrapper.php?rss=1';
2819 $loc = $domtree->createElement(
'loc', $domainname.
'/'.$pageurl);
2820 $lastmod = $domtree->createElement(
'lastmod',
dol_print_date($db->jdate(
dol_now()),
'dayrfc',
'gmt'));
2822 $url->appendChild($loc);
2823 $url->appendChild($lastmod);
2826 $changefreq = $domtree->createElement(
'changefreq',
'weekly');
2827 $url->appendChild($changefreq);
2830 $root->appendChild($url);
2833 $domtree->appendChild($root);
2835 if ($domtree->save($tempdir.$xmlname)) {
2837 setEventMessages($langs->trans(
"SitemapGenerated", $xmlname),
null,
'mesgs');
2847 $robotcontent = @file_get_contents($filerobot);
2848 $result = preg_replace(
'/<?php \/\/ BEGIN PHP[^?]END PHP ?>\n/ims',
'', $robotcontent);
2850 $robotcontent = $result;
2852 $robotsitemap =
"Sitemap: ".$domainname.
"/".$xmlname;
2853 $result = strpos($robotcontent,
'Sitemap: ');
2855 $result = preg_replace(
'/Sitemap:.*/', $robotsitemap, $robotcontent);
2856 $robotcontent = $result ? $result : $robotcontent;
2858 $robotcontent .= $robotsitemap.
"\n";
2865 $action =
'preview';
2873$form =
new Form($db);
2880if ($action ==
'confirmgeneratesitemaps') {
2881 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?website='.urlencode($website->ref), $langs->trans(
'ConfirmSitemapsCreation'), $langs->trans(
'ConfirmGenerateSitemaps',
$object->ref),
'generatesitemaps',
'',
"yes", 1);
2882 $action =
'preview';
2884$helpurl =
'EN:Module_Website|FR:Module_Website_FR|ES:Módulo_Website';
2887 '/includes/ace/src/ace.js',
2888 '/includes/ace/src/ext-statusbar.js',
2889 '/includes/ace/src/ext-language_tools.js',
2893$arrayofcss = array();
2898$arrayofjs[] =
'includes/jquery/plugins/blockUI/jquery.blockUI.js';
2899$arrayofjs[] =
'core/js/blockUI.js';
2901 $arrayofjs[] =
"includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js";
2904$moreheadjs .=
'<script type="text/javascript">'.
"\n";
2905$moreheadjs .=
'var indicatorBlockUI = \''.DOL_URL_ROOT.
"/theme/".
$conf->theme.
"/img/working.gif".
'\';
'."\n";
2906$moreheadjs .= '</script>
'."\n";
2908llxHeader($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">
');
2911print '<!-- Open form
for all page -->
'."\n";
2912print '<form action=
"'.$_SERVER["PHP_SELF
"].($action == 'file_manager' ? '?uploadform=1' : '').'" method=
"POST" enctype=
"multipart/form-data" class=
"websiteformtoolbar">
'."\n";
2913print '<input
type=
"hidden" name=
"token" value=
"'.newToken().'">
';
2914print '<input
type=
"hidden" name=
"backtopage" value=
"'.$backtopage.'">
';
2915print '<input
type=
"hidden" name=
"dol_openinpopup" value=
"'.$dol_openinpopup.'">
';
2917if ($action == 'createsite
') {
2918 print '<input
type=
"hidden" name=
"action" value=
"addsite">
';
2920if ($action == 'createcontainer
') {
2921 print '<input
type=
"hidden" name=
"action" value=
"addcontainer">
';
2923if ($action == 'editcss
') {
2924 print '<input
type=
"hidden" name=
"action" value=
"updatecss">
';
2926if ($action == 'editmenu
') {
2927 print '<input
type=
"hidden" name=
"action" value=
"updatemenu">
';
2929if ($action == 'setashome
') {
2930 print '<input
type=
"hidden" name=
"action" value=
"updateashome">
';
2932if ($action == 'editmeta
') {
2933 print '<input
type=
"hidden" name=
"action" value=
"updatemeta">
';
2935if ($action == 'editsource
') {
2936 print '<input
type=
"hidden" name=
"action" value=
"updatesource">
';
2938if ($action == 'editcontent
') {
2939 print '<input
type=
"hidden" name=
"action" value=
"updatecontent">
';
2941if ($action == 'edit
') {
2942 print '<input
type=
"hidden" name=
"action" value=
"update">
';
2944if ($action == 'importsite
') {
2945 print '<input
type=
"hidden" name=
"action" value=
"importsiteconfirm">
';
2947if ($action == 'file_manager
') {
2948 print '<input
type=
"hidden" name=
"action" value=
"file_manager">
';
2951 print '<input
type=
"hidden" name=
"mode" value=
"'.$mode.'">
';
2956// Add a margin under toolbar ?
2958if ($action != 'preview
' && $action != 'editcontent
' && $action != 'editsource
' && !GETPOST('createpagefromclone
', 'alphanohtml
')) {
2959 $style = ' margin-bottom: 5px;
';
2963if (!GETPOST('hide_websitemenu
')) {
2965 if (!$user->hasRight('website
', 'write
')) {
2966 $disabled = ' disabled=
"disabled"';
2968 $disabledexport = '';
2969 if (!$user->hasRight('website
', 'export
')) {
2970 $disabledexport = ' disabled=
"disabled"';
2975 $dataroot = DOL_DATA_ROOT.($conf->entity > 1 ? '/
'.$conf->entity : '').'/website/
'.$websitekey;
2976 if (!empty($object->virtualhost)) {
2977 $virtualurl = $object->virtualhost;
2982 if ($object->id > 0) {
2983 $array = $objectpage->fetchAll($object->id, 'ASC,ASC
', 'type_container,pageurl
');
2984 $object->lines = $array;
2986 if (!is_array($array) && $array < 0) {
2987 dol_print_error(null, $objectpage->error, $objectpage->errors);
2989 $atleastonepage = (is_array($array) && count($array) > 0);
2991 $websitepage = new WebsitePage($db);
2993 $websitepage->fetch($pageid);
2997 //var_dump($objectpage);exit;
2998 print '<div
class=
"centpercent websitebar'.(GETPOST('dol_openinpopup', 'aZ09') ? ' hiddenforpopup' : '').'">
'."\n";
3001 // Toolbar for websites
3004 print '<!-- Toolbar
for website -->
';
3005 if ($action != 'file_manager
') {
3006 print '<div
class=
"websiteselection hideonsmartphoneimp minwidth75 tdoverflowmax100 inline-block">
';
3007 print $langs->trans("Website").':
';
3010 // Button Add new website
3011 $urltocreatenewwebsite = $_SERVER["PHP_SELF"].'?action=createsite
';
3012 print '<span
class=
"websiteselection paddingrightonly">
';
3013 print '<a href=
"'.$urltocreatenewwebsite.'" class=
""'.$disabled.' title=
"'.dol_escape_htmltag($langs->trans("AddWebsite
")).'"><span
class=
"fa fa-plus-circle valignmiddle btnTitle-icon"><span></a>
';
3017 print '<span
class=
"websiteselection nopaddingrightimp">
';
3020 $out .= '<select
name=
"website" class=
"minwidth100 width200 maxwidth150onsmartphone" id=
"website">
';
3021 if (empty($listofwebsites)) {
3022 $out .= '<option value=
"-1"> </option>
';
3025 // Loop on each sites
3027 foreach ($listofwebsites as $key => $valwebsite) {
3028 if (empty($websitekey)) {
3029 if ($action != 'createsite
') {
3030 $websitekey = $valwebsite->ref;
3034 $out .= '<option value=
"'.$valwebsite->ref.'"';
3035 if ($websitekey == $valwebsite->ref) {
3036 $out .= ' selected
'; // To preselect a value
3038 //$outoption = $valwebsite->getLibStatut(3).' '.$valwebsite->ref.' ';
3039 $outoption = (($valwebsite->status == $valwebsite::STATUS_DRAFT) ? '<span
class=
"opacitymedium">
' : '').$valwebsite->ref.(($valwebsite->status == $valwebsite::STATUS_DRAFT) ? '</span>
' : '');
3040 $out .= ' data-html=
"'.dol_escape_htmltag($outoption).'"';
3042 $out .= $valwebsite->ref;
3043 $out .= '</option>
';
3046 $out .= '</select>
';
3047 $out .= ajax_combobox('website
');
3049 if (!empty($conf->use_javascript_ajax)) {
3050 $out .= '<script
type=
"text/javascript">
';
3051 $out .= 'jQuery(document).ready(
function () {
';
3052 $out .= ' jQuery(
"#website").change(
function () {
';
3053 $out .= ' console.log(
"We select "+jQuery(
"#website option:selected").val());
';
3054 $out .= ' if (jQuery(
"#website option:selected").val() == \
'-2\') {';
3055 $out .=
' window.location.href = "'.dol_escape_js($urltocreatenewwebsite).
'";';
3056 $out .=
' } else {';
3057 $out .=
' window.location.href = "'.$_SERVER[
"PHP_SELF"].
'?website="+jQuery("#website option:selected").val();';
3061 $out .=
'</script>';
3068 if (!empty(
$conf->use_javascript_ajax)) {
3069 print
'<span class="websiteselection">';
3074 if ($website->status == $website::STATUS_DRAFT) {
3075 $text_off =
'Offline';
3076 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>';
3078 $text_off =
'Online';
3079 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>';
3085 if (empty(
$conf->use_javascript_ajax)) {
3086 print
'<span class="websiteselection">';
3087 print
'<input type="image" class="valignmiddle" src="'.img_picto(
'',
'refresh',
'', 0, 1).
'" name="refreshsite" value="'.$langs->trans(
"Load").
'">';
3092 print
'<span class="websiteselection">';
3094 if ($websitekey && $websitekey !=
'-1' && ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite')) {
3096 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?website='.urlencode(
$object->ref).
'&pageid='.((int) $pageid).
'&action=editcss&token='.
newToken().
'" class="button bordertransp valignmiddle" title="'.
dol_escape_htmltag($langs->trans(
"EditCss")).
'"'.$disabled.
'>';
3098 print
'<span class="hideonsmartphone paddingleft">'.dol_escape_htmltag($langs->trans(
"EditCss")).
'</span>';
3102 $importlabel = $langs->trans(
"ImportSite");
3103 $exportlabel = $langs->trans(
"ExportSite");
3104 if (!empty(
$conf->dol_optimize_smallscreen)) {
3105 $importlabel = $langs->trans(
"Import");
3106 $exportlabel = $langs->trans(
"Export");
3109 if ($atleastonepage) {
3110 print
'<input type="submit" class="button bordertransp" disabled="disabled" value="'.dol_escape_htmltag($importlabel).
'" name="importsite">';
3112 print
'<input type="submit" class="button bordertransp"'.$disabled.
' value="'.
dol_escape_htmltag($importlabel).
'" name="importsite">';
3116 $extraCssClass =
getDolGlobalString(
'WEBSITE_ALLOW_OVERWRITE_GIT_SOURCE') ?
'hideobject' :
'';
3117 print
'<input type="submit" class="button bordertransp ' . $extraCssClass .
'" ' . $disabledexport .
' value="' .
dol_escape_htmltag($exportlabel) .
'" name="exportsite">';
3121 $overwriteGitUrl = $_SERVER[
"PHP_SELF"] .
'?action=overwritesite&website=' . urlencode($website->ref);
3122 print
dolButtonToOpenExportDialog(
'exportpopup', $langs->trans(
'ExportOptions'), $langs->trans(
'ExportSite'),
'exportsite', $overwriteGitUrl, $website);
3127 print
'<input type="submit" class="button bordertransp"'.$disabled.
' value="'.
dol_escape_htmltag($langs->trans(
"CloneSite")).
'" name="createfromclone">';
3130 if (!$permissiontodelete) {
3131 $disabled =
' disabled="disabled"';
3132 $title = $langs->trans(
"NotEnoughPermissions");
3135 if ($website->status == $website::STATUS_VALIDATED) {
3136 $disabled =
' disabled="disabled"';
3137 $title = $langs->trans(
"WebsiteMustBeDisabled", $langs->transnoentitiesnoconv($website->LibStatut(0, 0)));
3141 $title = $langs->trans(
"Delete");
3142 $url = $_SERVER[
"PHP_SELF"].
'?action=deletesite&token='.
newToken().
'&website='.urlencode($website->ref);
3145 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>';
3148 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>';
3151 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>';
3154 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>';
3159 if ($websitekey && $websitekey !=
'-1' && ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite')) {
3160 print
'<span class="websiteselection">';
3162 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);
3164 if (isModEnabled(
'category')) {
3166 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);
3172 print
'<input type="hidden" name="website" id="website" value="'.$websitekey.
'">';
3176 print
'<span class="websitetools">';
3178 if ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite') {
3179 $urlext = $virtualurl;
3180 $urlint = $urlwithroot.
'/public/website/index.php?website='.$websitekey;
3182 print
'<span class="websiteinputurl valignmiddle" id="websiteinputurl">';
3183 $linktotestonwebserver =
'<a href="'.($virtualurl ? $virtualurl :
'#').
'" class="valignmiddle">';
3184 $linktotestonwebserver .=
'<span class="hideonsmartphone paddingrightonly">'.$langs->trans(
"TestDeployOnWeb", $virtualurl).
'</span>'.
img_picto(
'',
'globe');
3185 $linktotestonwebserver .=
'</a>';
3188 if (empty(
$object->fk_default_home)) {
3189 $htmltext .=
'<br><span class="error">'.$langs->trans(
"YouMustDefineTheHomePage").
'</span><br><br>';
3190 } elseif (empty($virtualurl)) {
3193 $htmltext .=
'<br><center>'.$langs->trans(
"GoTo").
' <a href="'.$virtualurl.
'" target="_website">'.$virtualurl.
'</a></center><br>';
3196 $htmltext .=
'<!-- Message defined translate key set into WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER -->';
3197 $htmltext .=
'<br>'.$langs->trans(
getDolGlobalString(
'WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER'));
3199 $htmltext .= $langs->trans(
"ToDeployYourWebsiteOnLiveYouHave3Solutions").
'<br><br>';
3200 $htmltext .=
'<div class="titre inline-block">1</div> - '.$langs->trans(
"SetHereVirtualHost", $dataroot);
3201 $htmltext .=
'<br>';
3202 $htmltext .=
'<br>'.$langs->trans(
"CheckVirtualHostPerms", $langs->transnoentitiesnoconv(
"ReadPerm"), DOL_DOCUMENT_ROOT);
3203 $htmltext .=
'<br>'.$langs->trans(
"CheckVirtualHostPerms", $langs->transnoentitiesnoconv(
"WritePerm"),
'{s1}');
3204 $htmltext = str_replace(
'{s1}', DOL_DATA_ROOT.
'/website<br>'.DOL_DATA_ROOT.
'/medias', $htmltext);
3206 $examplewithapache =
"<VirtualHost *:80>\n";
3207 $examplewithapache .=
'#php_admin_value open_basedir /tmp/:'.DOL_DOCUMENT_ROOT.
':'.DOL_DATA_ROOT.
':/dev/urandom'.
"\n";
3208 $examplewithapache .=
"\n";
3209 $examplewithapache .=
'DocumentRoot "'.DOL_DOCUMENT_ROOT.
'"'.
"\n";
3210 $examplewithapache .=
"\n";
3211 $examplewithapache .=
'<Directory "'.DOL_DOCUMENT_ROOT.
'">'.
"\n";
3212 $examplewithapache .=
'AllowOverride FileInfo Options
3213 Options -Indexes -MultiViews -FollowSymLinks -ExecCGI
3215 </Directory>'.
"\n".
'
3216 <Directory "'.DOL_DATA_ROOT.
'/website">
3217 AllowOverride FileInfo Options
3218 Options -Indexes -MultiViews +FollowSymLinks -ExecCGI
3220 </Directory>'.
"\n".
'
3221 <Directory "'.DOL_DATA_ROOT.
'/medias">
3222 AllowOverride FileInfo Options
3223 Options -Indexes -MultiViews -FollowSymLinks -ExecCGI
3227 $examplewithapache .=
"\n";
3228 $examplewithapache .=
"#ErrorLog /var/log/apache2/".$websitekey.
"_error_log\n";
3229 $examplewithapache .=
"#TransferLog /var/log/apache2/".$websitekey.
"_access_log\n";
3231 $examplewithapache .=
"\n";
3232 $examplewithapache .=
"# If you need include the payment page into a frame of the website,\n";
3233 $examplewithapache .=
"# you need to make a proxy redirection of URLs required for the payment to your backoffice pages\n";
3234 $examplewithapache .=
"#SSLProxyEngine On\n";
3235 $examplewithapache .=
"#SSLProxyVerify none\n";
3236 $examplewithapache .=
"#SSLProxyCheckPeerCN off\n";
3237 $examplewithapache .=
"#SSLProxyCheckPeerName off\n";
3238 $examplewithapache .=
"#ProxyPreserveHost Off\n";
3239 $examplewithapache .=
'#ProxyPass "/public/payment/" "'.$urlwithroot.
'/public/payment/'.
"\n";
3240 $examplewithapache .=
'#ProxyPassReverse "/public/payment/" "'.$urlwithroot.
'/public/payment/'.
"\n";
3241 $examplewithapache .=
'#ProxyPass "/includes/" "'.$urlwithroot.
'/includes/'.
"\n";
3242 $examplewithapache .=
'#ProxyPassReverse "/includes/" "'.$urlwithroot.
'/includes/'.
"\n";
3243 $examplewithapache .=
'#ProxyPass "/theme/" "'.$urlwithroot.
'/theme/'.
"\n";
3244 $examplewithapache .=
'#ProxyPassReverse "/theme/" "'.$urlwithroot.
'/theme/'.
"\n";
3245 $examplewithapache .=
'#ProxyPass "/core/js/" "'.$urlwithroot.
'/core/js/'.
"\n";
3246 $examplewithapache .=
'#ProxyPassReverse "/core/js/" "'.$urlwithroot.
'/core/js/'.
"\n";
3247 $examplewithapache .=
"\n";
3249 $examplewithapache .=
"</VirtualHost>\n";
3251 $htmltext .=
'<br>'.$langs->trans(
"ExampleToUseInApacheVirtualHostConfig").
':<br>';
3252 $htmltext .=
'<div class="quatrevingtpercent exampleapachesetup wordbreak" spellcheck="false">'.dol_nl2br(
dol_escape_htmltag($examplewithapache, 1, 1)).
'</div>';
3254 $htmltext .=
'<br>';
3255 $htmltext .=
'<div class="titre inline-block">2</div> - '.$langs->trans(
"YouCanAlsoTestWithPHPS");
3256 $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>';
3258 $htmltext .=
'<br>';
3259 $htmltext .=
'<div class="titre inline-block">3</div> - '.$langs->trans(
"YouCanAlsoDeployToAnotherWHP");
3261 print $form->textwithpicto($linktotestonwebserver, $htmltext, 1,
'none',
'valignmiddle', 0, 3,
'helpvirtualhost');
3265 if (in_array($action, array(
'editcss',
'editmenu',
'file_manager',
'replacesiteconfirm')) || in_array($mode, array(
'replacesite'))) {
3266 if ($action ==
'editcss') {
3269 $stringforfirstkey = $langs->trans(
"KeyboardShortcut");
3270 if (
$conf->browser->name ==
'chrome') {
3271 $stringforfirstkey .=
' ALT +';
3272 } elseif (
$conf->browser->name ==
'firefox') {
3273 $stringforfirstkey .=
' ALT + SHIFT +';
3275 $stringforfirstkey .=
' CTL +';
3278 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">';
3280 if (preg_match(
'/^create/', $action) && $action !=
'file_manager' && $action !=
'replacesite' && $action !=
'replacesiteconfirm') {
3281 print
'<input type="submit" id="savefile" class="button buttonforacesave button-save small" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
3283 if (preg_match(
'/^edit/', $action) && $action !=
'file_manager' && $action !=
'replacesite' && $action !=
'replacesiteconfirm') {
3284 print
'<input type="submit" id="savefile" class="button buttonforacesave button-save small" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
3286 if ($action !=
'preview') {
3287 print
'<input type="submit" class="button button-cancel small" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'" name="cancel">';
3297 if ($websitekey && $websitekey !=
'-1' && (!in_array($action, array(
'editcss',
'editmenu',
'importsite',
'file_manager',
'replacesite',
'replacesiteconfirm'))) && (!in_array($mode, array(
'replacesite'))) && !$file_manager) {
3298 print
'</div>'.
"\n";
3300 print
'<!-- Toolbar for websitepage -->';
3301 print
'<div class="centpercent websitebar"'.($style ?
' style="'.$style.
'"' :
'').
'>'.
"\n";
3303 print
'<div class="websiteselection hideonsmartphoneimp minwidth75 tdoverflowmax100 inline-block">';
3304 print $langs->trans(
"PageContainer").
': ';
3308 print
'<span class="websiteselection paddingrightonly">';
3309 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>';
3315 $s = $formwebsite->selectContainer($website,
'pageid', $pageid, 0, $action,
'minwidth100 maxwidth200onsmartphone');
3317 $out .=
'<span class="websiteselection nopaddingrightimp">';
3321 $urltocreatenewpage = $_SERVER[
"PHP_SELF"].
'?action=createcontainer&token='.
newToken().
'&website='.urlencode($website->ref);
3323 if (!empty(
$conf->use_javascript_ajax)) {
3324 $out .=
'<script type="text/javascript">';
3325 $out .=
'jQuery(document).ready(function () {';
3326 $out .=
' jQuery("#pageid").change(function () {';
3327 $out .=
' console.log("We select "+jQuery("#pageid option:selected").val());';
3328 $out .=
' if (jQuery("#pageid option:selected").val() == \'-2\') {';
3329 $out .=
' window.location.href = "'.$urltocreatenewpage.
'";';
3330 $out .=
' } else {';
3331 $out .=
' window.location.href = "'.$_SERVER[
"PHP_SELF"].
'?website='.urlencode($website->ref).
'&pageid="+jQuery("#pageid option:selected").val();';
3335 $out .=
'</script>';
3341 if (!empty(
$conf->use_javascript_ajax)) {
3342 print
'<span class="websiteselection">';
3344 if (
$object->status == $object::STATUS_DRAFT) {
3345 $text_off =
'SetWebsiteOnlineBefore';
3346 if ($websitepage->status == $websitepage::STATUS_DRAFT) {
3347 print
'<span class="valignmiddle disabled opacitymedium">'.img_picto($langs->trans($text_off),
'switch_off').
'</span>';
3349 print
'<span class="valignmiddle disabled opacitymedium">'.img_picto($langs->trans($text_off),
'switch_on').
'</span>';
3352 print
ajax_object_onoff($websitepage,
'status',
'status',
'Online',
'Offline', array(),
'valignmiddle inline-block'.(empty($websitepage->id) ?
' opacitymedium disabled' :
''),
'statuswebsitepage', 1,
'website='.urlencode($website->
ref).
'&pageid='.((int) $websitepage->id));
3358 print
'<span class="websiteselection">';
3360 print
'<input type="image" class="valignmiddle buttonwebsite hideonsmartphone" src="'.img_picto(
'',
'refresh',
'', 0, 1).
'" name="refreshpage" value="'.$langs->trans(
"Load").
'"'.(($action !=
'editsource') ?
'' :
' disabled="disabled"').
'>';
3363 $pagepreviousid = 0;
3366 $sql =
"SELECT MAX(rowid) as pagepreviousid FROM ".MAIN_DB_PREFIX.
"website_page WHERE rowid < ".((int) $pageid).
" AND fk_website = ".((int)
$object->id);
3367 $resql = $db->query($sql);
3369 $obj = $db->fetch_object($resql);
3371 $pagepreviousid = $obj->pagepreviousid;
3376 $sql =
"SELECT MIN(rowid) as pagenextid FROM ".MAIN_DB_PREFIX.
"website_page WHERE rowid > ".((int) $pageid).
" AND fk_website = ".((int)
$object->id);
3377 $resql = $db->query($sql);
3379 $obj = $db->fetch_object($resql);
3381 $pagenextid = $obj->pagenextid;
3388 if ($pagepreviousid) {
3389 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>';
3391 print
'<span class="valignmiddle opacitymedium">'.img_previous($langs->trans(
"PreviousContainer")).
'</span>';
3394 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>';
3396 print
'<span class="valignmiddle opacitymedium">'.img_next($langs->trans(
"NextContainer")).
'</span>';
3401 if ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite') {
3403 if (!$user->hasRight(
'website',
'write')) {
3404 $disabled =
' disabled="disabled"';
3408 if ($action ==
'deletesite') {
3410 $formquestion = array(
3411 array(
'type' =>
'checkbox',
'name' =>
'delete_also_js',
'label' => $langs->trans(
"DeleteAlsoJs"),
'value' => 0),
3412 array(
'type' =>
'checkbox',
'name' =>
'delete_also_medias',
'label' => $langs->trans(
"DeleteAlsoMedias"),
'value' => 0),
3417 if ($atleastonepage) {
3418 $langs->load(
"errors");
3419 $formquestion[] = array(
'type' =>
'onecolumn',
'value' =>
'<div class="warning">'.$langs->trans(
"WarningPagesWillBeDeleted").
'</div>');
3422 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeleteWebsite'),
'',
'confirm_deletesite', $formquestion, 0, 1, 210 + ($atleastonepage ? 70 : 0), 580);
3428 if ($action ==
'createfromclone') {
3430 $formquestion = array(
3431 array(
'type' =>
'text',
'name' =>
'siteref',
'label' => $langs->trans(
"WebSite"),
'value' =>
'copy_of_'.$object->ref)
3434 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'CloneSite'),
'',
'confirm_createfromclone', $formquestion, 0, 1, 200);
3439 if ($pageid > 0 && $atleastonepage) {
3441 if ($action ==
'createpagefromclone') {
3443 $preselectedlanguage =
GETPOST(
'newlang',
'aZ09') ?
GETPOST(
'newlang',
'aZ09') :
'';
3444 $onlylang = array();
3445 if ($website->otherlang) {
3446 if (!empty($website->lang)) {
3447 $onlylang[$website->lang] = $website->lang.
' ('.$langs->trans(
"Default").
')';
3449 foreach (explode(
',', $website->otherlang) as $langkey) {
3450 if (empty(trim($langkey))) {
3453 $onlylang[$langkey] = $langkey;
3455 $textifempty = $langs->trans(
"Default");
3457 $onlylang[
'none'] =
'none';
3458 $textifempty = $langs->trans(
"Default");
3460 $formquestion = array(
3461 array(
'type' =>
'hidden',
'name' =>
'sourcepageurl',
'value' => $objectpage->pageurl),
3462 array(
'type' =>
'other',
'tdclass' =>
'fieldrequired',
'name' =>
'newwebsite',
'label' => $langs->trans(
"WebSite"),
'value' => $formwebsite->selectWebsite(
$object->id,
'newwebsite', 0)),
3463 array(
'type' =>
'text',
'tdclass' =>
'maxwidth200 fieldrequired',
'moreattr' =>
'autofocus="autofocus"',
'name' =>
'newtitle',
'label' => $langs->trans(
"WEBSITE_TITLE"),
'value' => $langs->trans(
"CopyOf").
' '.$objectpage->title),
3464 array(
'type' =>
'text',
'tdclass' =>
'maxwidth200',
'name' =>
'newpageurl',
'label' => $langs->trans(
"WEBSITE_PAGENAME"),
'value' =>
'')
3466 if (count($onlylang) > 1) {
3467 $formquestion[] = array(
'type' =>
'checkbox',
'tdclass' =>
'maxwidth200',
'name' =>
'is_a_translation',
'label' => $langs->trans(
"PageIsANewTranslation"),
'value' => 0,
'morecss' =>
'margintoponly');
3470 $value = $formadmin->select_language($preselectedlanguage,
'newlang', 0, array(), $textifempty, 0, 0,
'minwidth200', 1, 0, 0, $onlylang, 1);
3471 $formquestion[] = array(
'type' =>
'other',
'name' =>
'newlang',
'label' => $form->textwithpicto($langs->trans(
"Language"), $langs->trans(
"DefineListOfAltLanguagesInWebsiteProperties")),
'value' => $value);
3473 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?website='.
$object->ref.
'&pageid='.$pageid, $langs->trans(
'ClonePage'),
'',
'confirm_createpagefromclone', $formquestion, 0, 1, 300, 550);
3478 print
'<span class="websiteselection">';
3481 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?website='.
$object->ref.
'&pageid='.$pageid.
'&action=editmeta&token='.
newToken().
'" class="button bordertransp valignmiddle" title="'.
dol_escape_htmltag($langs->trans(
"EditPageMeta")).
'"'.$disabled.
'>';
3483 print
'<span class="hideonsmartphone paddingleft">'.dol_escape_htmltag($langs->trans(
"EditPageMeta")).
'</span>';
3487 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?website='.
$object->ref.
'&pageid='.$pageid.
'&action=editsource&token='.
newToken().
'" class="button bordertransp"'.$disabled.
'>';
3489 print
'<span class="hideonsmartphone paddingleft">'.dol_escape_htmltag($langs->trans(
$conf->dol_optimize_smallscreen ?
"HTML" :
"EditHTMLSource")).
'</span>';
3494 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?website='.
$object->ref.
'&pageid='.$pageid.
'&action=editcontent&token='.
newToken().
'" class="button bordertransp"'.$disabled.
'>'.
dol_escape_htmltag(
"CKEditor").
'</a>';
3496 print
'<!-- Add option WEBSITE_ALLOW_CKEDITOR to allow ckeditor -->';
3503 print
'<!-- button EditInLine and ShowSubcontainers -->'.
"\n";
3504 print
'<div class="websiteselectionsection inline-block">';
3506 print
'<div class="inline-block marginrightonly">';
3507 print $langs->trans(
"ShowSubcontainers");
3509 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>';
3511 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>';
3515 print
'<div class="inline-block marginrightonly">';
3517 print
'<span id="switchckeditorinline">'.
"\n";
3519 print
'<!-- Code to enabled edit inline ckeditor -->'.
"\n";
3520 print
'<script type="text/javascript">
3521 $(document).ready(function() {
3522 var isEditingEnabled = '.(getDolGlobalString(
"WEBSITE_EDITINLINE") ?
'true' :
'false').
';
3523 if (isEditingEnabled)
3525 switchEditorOnline(true);
3528 $( "#switchckeditorinline" ).click(function() {
3529 switchEditorOnline();
3532 function switchEditorOnline(forceenable)
3534 if (! isEditingEnabled || forceenable)
3536 console.log("Enable inline edit for some html tags with contenteditable=true attribute");
3538 jQuery(\'section[contenteditable="true"],div[contenteditable="true"],header[contenteditable="true"],main[contenteditable="true"],footer[contenteditable="true"]\').each(function(idx){
3539 var idtouse = $(this).attr(\'id\');
3540 console.log("Enable inline edit for "+idtouse);
3541 if (idtouse !== undefined) {
3542 var inlineditor = CKEDITOR.inline(idtouse, {
3543 // Allow some non-standard markup that we used in the introduction.
3544 // + a[target];div{float,display} ?
3545 extraAllowedContent: \'span(*);cite(*);q(*);dl(*);dt(*);dd(*);ul(*);li(*);header(*);main(*);footer(*);button(*);h1(*);h2(*);h3(*);\',
3546 //extraPlugins: \'sourcedialog\',
3547 removePlugins: \'flash,stylescombo,exportpdf,scayt,wsc,pagebreak,iframe,smiley\',
3548 // Show toolbar on startup (optional).
3549 // startupFocus: true
3553 // Note the Source tool does not work on inline
3554 inlineditor.config.toolbar = [
3555 [\'Templates\',\'NewPage\'],
3557 [\'Maximize\',\'Preview\'],
3559 [\'Undo\',\'Redo\',\'-\',\'Find\',\'Replace\',\'-\',\'SelectAll\',\'RemoveFormat\'],
3560 [\'CreateDiv\',\'ShowBlocks\'],
3561 [\'Form\', \'Checkbox\', \'Radio\', \'TextField\', \'Textarea\', \'Select\', \'Button\', \'ImageButton\', \'HiddenField\'],
3562 [\'Bold\',\'Italic\',\'Underline\',\'Strike\',\'Superscript\'],
3563 [\'NumberedList\',\'BulletedList\',\'-\',\'Outdent\',\'Indent\',\'Blockquote\'],
3564 [\'JustifyLeft\',\'JustifyCenter\',\'JustifyRight\',\'JustifyBlock\'],
3565 [\'Link\',\'Unlink\'],
3566 [\'Image\',\'Table\',\'HorizontalRule\'],
3567 [\'Styles\',\'Format\',\'Font\',\'FontSize\'],
3568 [\'TextColor\',\'BGColor\']
3572 //inlineditor.on(\'instanceReady\', function () {
3576 CKEDITOR.instances[idtouse].on(\'change\', function() {
3577 $(this.element.$).addClass(\'modified\');
3580 console.warn("A html section has the contenteditable=true attribute but has no id attribute");
3584 isEditingEnabled = true;
3586 // Trigger the function when clicking outside the elements with contenteditable=true attribute
3587 // so we can save the change.
3588 $(document).on(\'click\', function(e) {
3589 var target = $(e.target);
3591 // Check if the click is outside the elements with contenteditable=true attribute
3592 if (!target.closest(\'[contenteditable="true"]\').length) {
3593 // Repeat through the elements with contenteditable="true" attribute
3594 $(\'[contenteditable="true"]\').each(function() {
3595 var idToUse = $(this).attr(\'id\');
3596 var elementType = $(this).prop("tagName").toLowerCase(); // Get the tag name (div, section, footer...)
3597 var instance = CKEDITOR.instances[idToUse];
3599 // Check if the element has been modified
3600 if ($(this).hasClass(\'modified\')) {
3601 var content = instance.getData();
3602 content = "\\n" + content;
3604 // Retrieving the content and ID of the element
3605 var elementId = $(this).attr(\'id\');
3610 console.log("A change has been detected, we send new content for update with ajax");
3612 // Sending data via AJAX to update section
3615 url: \'' . DOL_URL_ROOT .
'/core/ajax/editinline.php\',
3617 website_ref: \''.dol_escape_js($website->ref).
'\',
3618 page_id: \
'' . ((int) $websitepage->id) .
'\',
3620 element_id: elementId,
3621 element_type: elementType,
3622 action: \
'updatedElementContent\',
3625 success:
function(response) {
3626 console.log(response);
3627 var $lastWebsitebar = $(
".websitebar").last();
3628 var $span = $(
"<span></span>").html(
"'.$langs->trans("Saved
").'").css({
3629 \
'display\': \'block\',
3630 \'position\': \'absolute\',
3631 \'margin-top\': \'6px\',
3633 \'background-color\': \'#e3f0db\',
3634 \'color\': \'#446548\',
3635 \'font-size\': \'14px\',
3636 \'padding\': \'0px 5px\',
3639 $lastWebsitebar.after($span);
3641 // Close message after 2 seconds
3642 setTimeout(function() {
3643 $span.fadeOut(500, function() {
3651 print
'console.log("A change has been detected, but saving is not enabled by option WEBSITE_EDITINLINE_SAVE_CKEDITOR_EDIT, so no ajax update is done");';
3655 $(this).removeClass(\'modified\');
3662 console.log("Disable inline edit");
3663 for(name in CKEDITOR.instances) {
3664 CKEDITOR.instances[name].destroy(true);
3666 isEditingEnabled = false;
3671 print $langs->trans(
"EditInLine");
3675 $disableeditinline = 0;
3676 if ($disableeditinline) {
3678 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>';
3682 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>';
3684 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>';
3693 print
'<span class="websiteselection">';
3694 if (
$object->fk_default_home > 0 && $pageid ==
$object->fk_default_home) {
3698 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>';
3702 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>';
3704 print
'<input type="submit" class="button bordertransp"'.$disabled.
' value="'.
dol_escape_htmltag($langs->trans(
"ClonePage")).
'" name="createpagefromclone">';
3707 if ($websitepage->status != $websitepage::STATUS_DRAFT) {
3708 $disabled =
' disabled="disabled"';
3709 $title = $langs->trans(
"WebpageMustBeDisabled", $langs->transnoentitiesnoconv($websitepage->LibStatut(0, 0)));
3714 $url = $_SERVER[
"PHP_SELF"].
'?action=delete&token='.
newToken().
'&pageid='.((int) $websitepage->id).
'&website='.urlencode($website->ref);
3716 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>';
3723 print
'<span class="websitetools">';
3725 if (($pageid > 0 && $atleastonepage) && ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite')) {
3726 $realpage = $urlwithroot.
'/public/website/index.php?website='.$websitekey.
'&pageref='.$websitepage->pageurl;
3727 $pagealias = $websitepage->pageurl;
3729 $htmltext = $langs->trans(
"PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv(
"Page"), $langs->transnoentitiesnoconv(
"Page"), $realpage, $langs->transnoentitiesnoconv(
"TestDeployOnWeb"));
3735 print
'<div class="websiteinputurl inline-block paddingright">';
3736 print
'<a class="websitebuttonsitepreview inline-block" id="previewpage" href="'.$realpage.
'&nocache='.
dol_now().
'" class="button" target="tab'.$websitekey.
'" alt="'.
dol_escape_htmltag($htmltext).
'">';
3737 print $form->textwithpicto(
'', $htmltext, 1,
'preview');
3761 if (!in_array($mode, array(
'replacesite')) && !in_array($action, array(
'editcss',
'editmenu',
'file_manager',
'replacesiteconfirm',
'createsite',
'createcontainer',
'createfromclone',
'createpagefromclone',
'deletesite'))) {
3762 if ($action ==
'editsource' || $action ==
'editmeta') {
3765 $stringforfirstkey = $langs->trans(
"KeyboardShortcut");
3766 if (
$conf->browser->name ==
'chrome') {
3767 $stringforfirstkey .=
' ALT +';
3768 } elseif (
$conf->browser->name ==
'firefox') {
3769 $stringforfirstkey .=
' ALT + SHIFT +';
3771 $stringforfirstkey .=
' CTL +';
3774 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">';
3776 if (preg_match(
'/^create/', $action)) {
3777 print
'<input type="submit" id="savefile" class="button buttonforacesave button-save small" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
3779 if (preg_match(
'/^edit/', $action)) {
3780 print
'<input type="submit" id="savefile" class="button buttonforacesave button-save small" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
3782 if ($action !=
'preview') {
3783 print
'<input type="submit" class="button button-cancel small" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'" name="cancel">';
3789 print
'<span class="websitehelp">';
3790 if ($action ==
'editsource' || $action ==
'editcontent' ||
GETPOST(
'editsource',
'alpha') ||
GETPOST(
'editcontent',
'alpha')) {
3791 $url =
'https://wiki.dolibarr.org/index.php/Module_Website';
3793 $htmltext =
'<small>';
3794 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource", $url);
3795 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSourceb", $url);
3796 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSourcec", $url);
3797 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSourced", $url);
3798 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource1", $url);
3799 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource2", $url);
3800 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource3", $url);
3801 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource4", $url);
3802 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSourceMore", $url);
3803 $htmltext .=
'<br>';
3804 $htmltext .=
'</small>';
3805 if (
$conf->browser->layout ==
'phone') {
3806 print $form->textwithpicto(
'', $htmltext, 1,
'help',
'inline-block', 1, 2,
'tooltipsubstitution');
3809 print $form->textwithpicto($langs->trans(
"SyntaxHelp").
' '.
img_help(2, $langs->trans(
"SyntaxHelp")), $htmltext, 1,
'none',
'inline-block', 1, 2,
'tooltipsubstitution');
3815 if ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone') {
3817 if (!empty(
$conf->use_javascript_ajax)) {
3818 print
'<script type="text/javascript">
3819 jQuery(document).ready(function() {
3820 jQuery("#websiteinputurl").keyup(function() {
3821 console.log("Website external url modified "+jQuery("#previewsiteurl").val());
3822 if (jQuery("#previewsiteurl").val() != "" && jQuery("#previewsiteurl").val().startsWith("http"))
3824 jQuery("a.websitebuttonsitepreviewdisabled img").css({ opacity: 1 });
3826 else jQuery("a.websitebuttonsitepreviewdisabled img").css({ opacity: 0.2 });
3830 jQuery("#previewsiteext,#previewpageext").click(function() {
3832 newurl=jQuery("#previewsiteurl").val();
3833 if (! newurl.startsWith("http"))
3835 alert(\''.dol_escape_js($langs->trans(
"ErrorURLMustStartWithHttp")).
'\');
3839 newpage=jQuery(
"#previewsiteurl").val() +
"/" + jQuery(
"#previewpageurl").val() +
".php";
3840 console.log(
"Open url "+newurl);
3844 url:
"'.DOL_URL_ROOT.'/core/ajax/saveinplace.php",
3846 field: \
'editval_virtualhost\',
3847 element: \'website\',
3848 table_element: \'website\',
3849 fk_element: '.((int)
$object->id).
',
3852 context: document.body
3855 jQuery("#previewsiteext").attr("href",newurl);
3856 jQuery("#previewpageext").attr("href",newpage);
3864 print
'</div>'.
"\n";
3875if ($action ==
'editcss') {
3876 print
'<div class="fiche">';
3880 if (!GETPOSTISSET(
'WEBSITE_CSS_INLINE')) {
3881 $csscontent = @file_get_contents($filecss);
3883 $csscontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $csscontent);
3885 $csscontent =
GETPOST(
'WEBSITE_CSS_INLINE',
'none');
3887 if (!trim($csscontent)) {
3888 $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;}";
3891 if (!GETPOSTISSET(
'WEBSITE_JS_INLINE')) {
3892 $jscontent = @file_get_contents($filejs);
3894 $jscontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $jscontent);
3896 $jscontent =
GETPOST(
'WEBSITE_JS_INLINE',
'none');
3898 if (!trim($jscontent)) {
3899 $jscontent =
'/* JS content (all pages) */'.
"\n";
3902 if (!GETPOSTISSET(
'WEBSITE_HTML_HEADER')) {
3903 $htmlheadercontent = @file_get_contents($filehtmlheader);
3905 $htmlheadercontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $htmlheadercontent);
3907 $htmlheadercontent =
GETPOST(
'WEBSITE_HTML_HEADER',
'none');
3909 if (!trim($htmlheadercontent)) {
3910 $htmlheadercontent =
"<html>\n";
3911 $htmlheadercontent .= $htmlheadercontentdefault;
3912 $htmlheadercontent .=
"</html>";
3914 $htmlheadercontent = preg_replace(
'/^\s*<html>/ims',
'', $htmlheadercontent);
3915 $htmlheadercontent = preg_replace(
'/<\/html>\s*$/ims',
'', $htmlheadercontent);
3916 $htmlheadercontent =
'<html>'.
"\n".trim($htmlheadercontent).
"\n".
'</html>';
3919 if (!GETPOSTISSET(
'WEBSITE_ROBOT')) {
3920 $robotcontent = @file_get_contents($filerobot);
3922 $robotcontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $robotcontent);
3924 $robotcontent =
GETPOST(
'WEBSITE_ROBOT',
'nohtml');
3926 if (!trim($robotcontent)) {
3927 $robotcontent .=
"# Robot file. Generated with ".DOL_APPLICATION_TITLE.
"\n";
3928 $robotcontent .=
"User-agent: *\n";
3929 $robotcontent .=
"Allow: /public/\n";
3930 $robotcontent .=
"Disallow: /administrator/\n";
3933 if (!GETPOSTISSET(
'WEBSITE_HTACCESS')) {
3934 $htaccesscontent = @file_get_contents($filehtaccess);
3936 $htaccesscontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $htaccesscontent);
3938 $htaccesscontent =
GETPOST(
'WEBSITE_HTACCESS',
'nohtml');
3941 if (!GETPOSTISSET(
'WEBSITE_MANIFEST_JSON')) {
3942 $manifestjsoncontent = @file_get_contents($filemanifestjson);
3944 $manifestjsoncontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $manifestjsoncontent);
3946 $manifestjsoncontent = trim(
GETPOST(
'WEBSITE_MANIFEST_JSON',
'restricthtmlallowunvalid'));
3947 $manifestjsoncontent = str_replace(
'<?=',
'<?php', $manifestjsoncontent);
3954 if (!GETPOSTISSET(
'WEBSITE_README')) {
3955 $readmecontent = @file_get_contents($filereadme);
3957 $readmecontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $readmecontent);
3959 $readmecontent =
GETPOST(
'WEBSITE_README',
'restricthtmlallowunvalid');
3965 if (!GETPOSTISSET(
'WEBSITE_LICENSE')) {
3966 $licensecontent = @file_get_contents($filelicense);
3968 $licensecontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP( \?>)?\n*/ims',
'', $licensecontent);
3970 $licensecontent =
GETPOST(
'WEBSITE_LICENSE',
'restricthtmlallowunvalid');
3978 print
'<!-- Edit Website properties -->'.
"\n";
3979 print
'<table class="border centpercent">';
3982 print
'<tr><td class="titlefieldcreate fieldrequired">';
3983 print $langs->trans(
'WebSite');
3989 if ($action !=
'createcontainer') {
3990 if (empty(
$conf->use_javascript_ajax)) {
3991 print
'<!-- Status of web site page -->'.
"\n";
3992 print
'<tr><td class="fieldrequired">';
3993 print $langs->trans(
'Status');
3995 print $form->selectyesno(
'status',
$object->status);
4001 print
'<tr><td class="tdtop fieldrequired">';
4003 print $form->textwithpicto($langs->trans(
'MainLanguage'), $htmltext, 1,
'help',
'', 0, 2,
'WEBSITE_LANG');
4005 print
img_picto(
'',
'language',
'class="picotfixedwidth"');
4006 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);
4011 print
'<tr><td class="tdtop">';
4012 $htmltext = $langs->trans(
"Example").
': fr,de,sv,it,pt';
4013 print $form->textwithpicto($langs->trans(
'OtherLanguages'), $htmltext, 1,
'help',
'', 0, 2);
4015 print
img_picto(
'',
'language',
'class="picotfixedwidth"');
4016 print
'<input type="text" class="flat maxwidth200" value="'.(GETPOSTISSET(
'WEBSITE_OTHERLANG') ?
GETPOST(
'WEBSITE_OTHERLANG',
'alpha') :
$object->otherlang).
'" name="WEBSITE_OTHERLANG">';
4021 print
'<tr><td class="tdtop">';
4023 $htmltext = $langs->trans(
"VirtualhostDesc");
4024 print $form->textwithpicto($langs->trans(
'Virtualhost'), $htmltext, 1,
'help',
'', 0, 2,
'virtualhosttooltip');
4026 print
'<input type="text" class="flat minwidth300" value="'.(GETPOSTISSET(
'virtualhost') ?
GETPOST(
'virtualhost',
'alpha') : $virtualurl).
'" name="virtualhost">';
4032 print $form->textwithpicto($langs->trans(
'ImportFavicon'), $langs->trans(
'FaviconTooltip'));
4035 $maxmin = $maxfilesizearray[
'maxmin'];
4037 print
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
4039 print
'<input type="file" class="flat minwidth300" name="addedfile" id="addedfile"/>';
4041 $uploadfolder =
$conf->website->dir_output.
'/'.$websitekey;
4043 print
'<div class="inline-block valignmiddle marginrightonly">';
4044 print
'<img style="max-height: 80px" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart=website&file='.$websitekey.
'/favicon.png">';
4050 print
'<tr><td class="tdtop">';
4051 $htmlhelp = $langs->trans(
"CSSContentTooltipHelp");
4052 print $form->textwithpicto($langs->trans(
'WEBSITE_CSS_INLINE'), $htmlhelp, 1,
'help',
'', 0, 2,
'csstooltip');
4055 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_CSS_INLINE_x'),
'y' =>
GETPOST(
'WEBSITE_CSS_INLINE_y'));
4056 $doleditor =
new DolEditor(
'WEBSITE_CSS_INLINE', $csscontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4057 print $doleditor->Create(1,
'',
true,
'CSS',
'css');
4062 print
'<tr><td class="tdtop">';
4063 $textwithhelp = $langs->trans(
'WEBSITE_JS_INLINE');
4064 $htmlhelp2 = $langs->trans(
"LinkAndScriptsHereAreNotLoadedInEditor").
'<br>';
4065 print $form->textwithpicto($textwithhelp, $htmlhelp2, 1,
'warning',
'', 0, 2,
'htmljstooltip2');
4069 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_JS_INLINE_x'),
'y' =>
GETPOST(
'WEBSITE_JS_INLINE_y'));
4070 $doleditor =
new DolEditor(
'WEBSITE_JS_INLINE', $jscontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4071 print $doleditor->Create(1,
'',
true,
'JS',
'javascript');
4076 print
'<tr><td class="tdtop">';
4077 print $langs->trans(
'WEBSITE_HTML_HEADER');
4078 $htmlhelp = $langs->trans(
"Example").
' :<br>';
4080 $textwithhelp = $form->textwithpicto(
'', $htmlhelp, 1,
'help',
'', 0, 2,
'htmlheadertooltip');
4081 $htmlhelp2 = $langs->trans(
"LinkAndScriptsHereAreNotLoadedInEditor").
'<br>';
4082 print $form->textwithpicto($textwithhelp, $htmlhelp2, 1,
'warning',
'', 0, 2,
'htmlheadertooltip2');
4085 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_HTML_HEADER_x'),
'y' =>
GETPOST(
'WEBSITE_HTML_HEADER_y'));
4086 $doleditor =
new DolEditor(
'WEBSITE_HTML_HEADER', $htmlheadercontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4087 print $doleditor->Create(1,
'',
true,
'HTML Header',
'html');
4092 print
'<tr><td class="tdtop">';
4093 print $langs->trans(
'WEBSITE_ROBOT');
4096 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_ROBOT_x'),
'y' =>
GETPOST(
'WEBSITE_ROBOT_y'));
4097 $doleditor =
new DolEditor(
'WEBSITE_ROBOT', $robotcontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4098 print $doleditor->Create(1,
'',
true,
'Robot file',
'text');
4103 print
'<tr><td class="tdtop">';
4105 $textwithhelp3 = $langs->trans(
"Example").
' :';
4106 $textwithhelp3 .=
"<br># Order allow,deny\n";
4107 $textwithhelp3 .=
"<br># Deny from all\n";
4108 $textwithhelp3 .=
"<br># Require all granted\n";
4110 print $form->textwithpicto($langs->trans(
'WEBSITE_HTACCESS'), $textwithhelp3, 1,
'help',
'', 0, 2,
'htmlheadertooltip3');
4113 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_HTACCESS_x'),
'y' =>
GETPOST(
'WEBSITE_HTACCESS_y'));
4114 $doleditor =
new DolEditor(
'WEBSITE_HTACCESS', $htaccesscontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4115 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' .htaccess',
'text');
4120 print
'<tr><td class="tdtop">';
4121 $htmlhelp = $langs->trans(
"Example").
' :<br>';
4122 $htmlhelp .=
'<small>'.dol_htmlentitiesbr($manifestjsoncontentdefault).
'</small>';
4123 print $form->textwithpicto($langs->trans(
'WEBSITE_MANIFEST_JSON'), $htmlhelp, 1,
'help',
'', 0, 2,
'manifestjsontooltip');
4125 print $langs->trans(
"UseManifest").
': '.$form->selectyesno(
'use_manifest', $website->use_manifest, 1).
'<br>';
4127 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_MANIFEST_JSON_x'),
'y' =>
GETPOST(
'WEBSITE_MANIFEST_JSON_y'));
4128 $doleditor =
new DolEditor(
'WEBSITE_MANIFEST_JSON', $manifestjsoncontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4129 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' manifest.json',
'text');
4133 print
'<tr><td class="tdtop">';
4134 $htmlhelp = $langs->trans(
"EnterHereReadmeInformation");
4135 print $form->textwithpicto($langs->trans(
"File").
' README.md', $htmlhelp, 1,
'help',
'', 0, 2,
'readmetooltip');
4138 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_README_x'),
'y' =>
GETPOST(
'WEBSITE_README_y'));
4139 $doleditor =
new DolEditor(
'WEBSITE_README', $readmecontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4140 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' README.md',
'text');
4145 print
'<tr><td class="tdtop">';
4146 $htmlhelp = $langs->trans(
"EnterHereLicenseInformation");
4147 print $form->textwithpicto($langs->trans(
"File").
' LICENSE', $htmlhelp, 1,
'help',
'', 0, 2,
'licensetooltip');
4150 $poscursor = array(
'x' =>
GETPOST(
'WEBSITE_LICENSE_x'),
'y' =>
GETPOST(
'WEBSITE_LICENSE_y'));
4151 $doleditor =
new DolEditor(
'WEBSITE_LICENSE', $licensecontent,
'', 220,
'ace',
'In',
true,
false,
'ace', 0,
'100%', 0, $poscursor);
4152 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' LICENSE',
'text');
4157 print
'<tr><td class="tdtop">';
4158 $htmlhelp = $langs->trans(
'RSSFeedDesc');
4159 print $form->textwithpicto($langs->trans(
'RSSFeed'), $htmlhelp, 1,
'help',
'', 0, 2,
'');
4161 print
'/wrapper.php?rss=1[&l=XX][&limit=99][&cachedelay=99]';
4174if ($action ==
'createsite') {
4175 print
'<div class="fiche">';
4189 if ($action ==
'createcontainer') {
4193 print
'<!-- Add site -->'.
"\n";
4194 print
'<div class="tabBar tabBarWithBottom">';
4196 print
'<table class="border centpercent">';
4198 $siteref = $sitedesc = $sitelang = $siteotherlang =
'';
4200 $siteref =
GETPOST(
'WEBSITE_REF',
'aZ09');
4202 if (
GETPOST(
'WEBSITE_DESCRIPTION')) {
4203 $sitedesc =
GETPOST(
'WEBSITE_DESCRIPTION',
'alpha');
4205 if (
GETPOST(
'WEBSITE_LANG')) {
4206 $sitelang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
4208 if (
GETPOST(
'WEBSITE_OTHERLANG')) {
4209 $siteotherlang =
GETPOST(
'WEBSITE_OTHERLANG',
'aZ09comma');
4212 print
'<tr><td class="titlefieldcreate fieldrequired">';
4213 print $form->textwithpicto($langs->trans(
'WebsiteName'), $langs->trans(
"Example").
': MyPortal, www.mywebsite.com, ...');
4215 print
'<input type="text" class="flat maxwidth300" name="WEBSITE_REF" value="'.dol_escape_htmltag($siteref).
'" autofocus>';
4218 print
'<tr><td class="fieldrequired">';
4219 print $langs->trans(
'MainLanguage');
4221 $shortlangcode = preg_replace(
'/[_-].*$/',
'', trim($langs->defaultlang));
4222 print
img_picto(
'',
'language',
'class="pictofixedwidth"');
4223 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);
4227 $htmltext = $langs->trans(
"Example").
': fr,de,sv,it,pt';
4228 print $form->textwithpicto($langs->trans(
'OtherLanguages'), $htmltext, 1,
'help',
'', 0, 2);
4230 print
img_picto(
'',
'language',
'class="pictofixedwidth"');
4231 print
'<input type="text" class="flat minwidth300" name="WEBSITE_OTHERLANG" value="'.dol_escape_htmltag($siteotherlang).
'">';
4235 print $langs->trans(
'Description');
4237 print
'<input type="text" class="flat minwidth500" name="WEBSITE_DESCRIPTION" value="'.dol_escape_htmltag($sitedesc).
'">';
4242 $htmltext = $langs->trans(
"VirtualhostDesc");
4250 print $form->textwithpicto($langs->trans(
'Virtualhost'), $htmltext, 1,
'help',
'', 0, 2,
'');
4252 print
'<input type="text" class="flat minwidth300" name="virtualhost" value="'.dol_escape_htmltag(
GETPOST(
'virtualhost',
'alpha')).
'">';
4258 if ($action ==
'createsite') {
4259 print
'<div class="center">';
4261 print
'<input type="submit" class="button small" name="addcontainer" value="'.$langs->trans(
"Create").
'">';
4262 print
'<input class="button button-cancel small" type="submit" name="preview" value="'.$langs->trans(
"Cancel").
'">';
4278if ($action ==
'importsite') {
4279 print
'<!-- action=importsite -->';
4280 print
'<div class="fiche">';
4288 print
'<span class="opacitymedium">'.$langs->trans(
"ZipOfWebsitePackageToImport").
'</span><br><br>';
4291 $dolibarrdataroot = preg_replace(
'/([\\/]+)$/i',
'', DOL_DATA_ROOT);
4292 $allowimportsite =
true;
4293 if (
dol_is_file($dolibarrdataroot.
'/installmodules.lock')) {
4294 $allowimportsite =
false;
4297 if ($allowimportsite) {
4299 $maxmin = $maxfilesizearray[
'maxmin'];
4301 print
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
4303 print
'<input class="flat minwidth400" type="file" name="userfile[]" accept=".zip">';
4304 print
'<input type="submit" class="button small" name="buttonsubmitimportfile" value="'.dol_escape_htmltag($langs->trans(
"Upload")).
'">';
4305 print
'<input type="submit" class="button button-cancel small" name="preview" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
4306 print
'<br><br><br>';
4310 $message = $langs->trans(
'InstallModuleFromWebHasBeenDisabledContactUs');
4313 $message = $langs->trans(
"InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.
'/installmodules.lock');
4319 print
'<span class="opacitymedium">'.$langs->trans(
"ZipOfWebsitePackageToLoad").
'</span><br><br>';
4330if ($action ==
'editmeta' || $action ==
'createcontainer') {
4331 print
'<div class="fiche">';
4345 if ($action ==
'createcontainer') {
4349 print
'<!-- Edit or create page/container -->'.
"\n";
4352 $hiddenfromfetchingafterload =
' hideobject';
4353 $hiddenmanuallyafterload =
' hideobject';
4354 if (
GETPOST(
'radiocreatefrom') ==
'checkboxcreatefromfetching') {
4355 $hiddenfromfetchingafterload =
'';
4357 if (
GETPOST(
'radiocreatefrom') ==
'checkboxcreatemanually') {
4358 $hiddenmanuallyafterload =
'';
4361 if ($action ==
'editmeta' || empty(
$conf->use_javascript_ajax)) {
4362 $hiddenfromfetchingafterload =
'';
4363 $hiddenmanuallyafterload =
'';
4366 if ($action ==
'createcontainer') {
4369 if (!empty(
$conf->use_javascript_ajax)) {
4370 print
'<input type="radio" name="radiocreatefrom" id="checkboxcreatemanually" value="checkboxcreatemanually"'.(GETPOST(
'radiocreatefrom') ==
'checkboxcreatemanually' ?
' checked' :
'').
'> ';
4372 print
'<label for="checkboxcreatemanually"><span class="opacitymediumxx">'.$langs->trans(
"OrEnterPageInfoManually").
'</span></label><br>';
4373 print
'<hr class="tablecheckboxcreatemanually'.$hiddenmanuallyafterload.
'">';
4376 print
'<table class="border tableforfield nobackground centpercent tablecheckboxcreatemanually'.$hiddenmanuallyafterload.
'">';
4378 if ($action !=
'createcontainer') {
4379 print
'<tr><td class="titlefield fieldrequired">';
4380 print $langs->trans(
'IDOfPage').
' - '.$langs->trans(
'InternalURLOfPage');
4388 print
' - ';
4389 print
'/public/website/index.php?website='.urlencode($websitekey).
'&pageid='.urlencode((
string) $pageid);
4393 $type_container = $objectpage->type_container;
4394 $pageurl = $objectpage->pageurl;
4395 $pagealiasalt = $objectpage->aliasalt;
4396 $pagetitle = $objectpage->title;
4397 $pagedescription = $objectpage->description;
4398 $pageimage = $objectpage->image;
4399 $pagekeywords = $objectpage->keywords;
4400 $pagelang = $objectpage->lang;
4401 $pageallowedinframes = $objectpage->allowed_in_frames;
4402 $pagehtmlheader = $objectpage->htmlheader;
4403 $pagedatecreation = $objectpage->date_creation;
4404 $pagedatemodification = $objectpage->date_modification;
4405 $pageauthorid = $objectpage->fk_user_creat;
4406 $pageusermodifid = $objectpage->fk_user_modif;
4407 $pageauthoralias = $objectpage->author_alias;
4408 $pagestatus = $objectpage->status;
4410 $type_container =
'page';
4414 $pagedescription =
'';
4418 $pageallowedinframes = 0;
4419 $pagehtmlheader =
'';
4420 $pagedatecreation =
dol_now();
4421 $pagedatemodification =
'';
4422 $pageauthorid = $user->id;
4423 $pageusermodifid = 0;
4424 $pageauthoralias =
'';
4427 if (
GETPOST(
'WEBSITE_TITLE',
'alpha')) {
4428 $pagetitle = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_TITLE',
'alphanohtml'));
4430 if (
GETPOST(
'WEBSITE_PAGENAME',
'alpha')) {
4431 $pageurl =
GETPOST(
'WEBSITE_PAGENAME',
'alpha');
4433 if (
GETPOST(
'WEBSITE_ALIASALT',
'alpha')) {
4434 $pagealiasalt = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_ALIASALT',
'alphanohtml'));
4436 if (
GETPOST(
'WEBSITE_DESCRIPTION',
'alpha')) {
4437 $pagedescription = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml'));
4439 if (
GETPOST(
'WEBSITE_IMAGE',
'alpha')) {
4440 $pageimage =
GETPOST(
'WEBSITE_IMAGE',
'alpha');
4442 if (
GETPOST(
'WEBSITE_KEYWORDS',
'alpha')) {
4443 $pagekeywords = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_KEYWORDS',
'alphanohtml'));
4445 if (
GETPOST(
'WEBSITE_LANG',
'aZ09')) {
4446 $pagelang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
4448 if (
GETPOST(
'WEBSITE_ALLOWED_IN_FRAMES',
'aZ09')) {
4449 $pageallowedinframes = 1;
4451 if (
GETPOST(
'htmlheader',
'none')) {
4452 $pagehtmlheader =
GETPOST(
'htmlheader',
'none');
4455 if ($action !=
'createcontainer') {
4456 if (empty(
$conf->use_javascript_ajax)) {
4457 print
'<!-- Status of web site page -->'.
"\n";
4458 print
'<tr><td class="fieldrequired">';
4459 print $langs->trans(
'Status');
4461 print $form->selectyesno(
'status', $objectpage->status);
4467 print
'<tr><td class="titlefield fieldrequired">';
4468 print $langs->trans(
'WEBSITE_TYPE_CONTAINER');
4470 print
img_picto(
'',
'object_technic',
'class="paddingrightonly"').
' ';
4471 print $formwebsite->selectTypeOfContainer(
'WEBSITE_TYPE_CONTAINER', (
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'alpha') ?
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'alpha') : $type_container), 0,
'', 1,
'minwidth300');
4474 print
'<script type="text/javascript">
4475 jQuery(document).ready(function() {
4476 jQuery("#selectWEBSITE_TYPE_CONTAINER").change(function() {
4477 console.log("We change type of page : "+jQuery("#selectWEBSITE_TYPE_CONTAINER").val());
4478 if (jQuery("#selectWEBSITE_TYPE_CONTAINER").val() == \'blogpost\') {
4479 jQuery(".trpublicauthor").show();
4481 jQuery(".trpublicauthor").hide();
4483 if (jQuery("#selectWEBSITE_TYPE_CONTAINER").val() == \'service\' || jQuery("#selectWEBSITE_TYPE_CONTAINER").val() == \'library\') {
4484 $(".spanprefix").html("_" + $("#selectWEBSITE_TYPE_CONTAINER").val() + "_");
4485 jQuery(".spanprefix").show();
4487 jQuery(".spanprefix").hide();
4491 // Force at init execution a first time of the handler change
4492 jQuery("#selectWEBSITE_TYPE_CONTAINER").trigger(\'change\');
4498 print
'<tr><td class="fieldrequired">';
4499 print $langs->trans(
'WEBSITE_TITLE');
4501 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_TITLE" id="WEBSITE_TITLE" value="'.dol_escape_htmltag($pagetitle).
'" autofocus>';
4505 print
'<tr><td class="titlefieldcreate fieldrequired">';
4506 print $langs->trans(
'WEBSITE_PAGENAME');
4508 print
'<span class="opacitymedium spanprefix hidden"></span> ';
4509 print
'<input type="text" class="flat minwidth300" name="WEBSITE_PAGENAME" id="WEBSITE_PAGENAME" value="'.dol_escape_htmltag((
string) preg_replace(
'/^_[a-z]+_/',
'', (
string) $pageurl)).
'">';
4512 print
'<script type="text/javascript">
4513 $(document).ready(function() {
4514 console.log("Manage prefix for service or library");
4515 if ($("#selectWEBSITE_TYPE_CONTAINER").val() == "service" || $("#selectWEBSITE_TYPE_CONTAINER").val() == "library") {
4516 $(".spanprefix").html("_" + $("#selectWEBSITE_TYPE_CONTAINER").val() + "_");
4517 $(".spanprefix").show();
4519 $(".websiteformtoolbar").on("submit", function(event) {
4520 if ($("#selectWEBSITE_TYPE_CONTAINER").val() == "service" || $("#selectWEBSITE_TYPE_CONTAINER").val() == "library") {
4521 var prefix = "_" + $("#selectWEBSITE_TYPE_CONTAINER").val() + "_";
4522 var userInput = $("#WEBSITE_PAGENAME").val();
4523 var $inputField = $("#WEBSITE_PAGENAME");
4524 if (userInput.indexOf(prefix) !== 0) {
4525 $inputField.val(prefix + userInput);
4533 print
'<tr><td class="titlefieldcreate">';
4534 $htmlhelp = $langs->trans(
"WEBSITE_ALIASALTDesc");
4535 print $form->textwithpicto($langs->trans(
'WEBSITE_ALIASALT'), $htmlhelp, 1,
'help',
'', 0, 2,
'aliastooltip');
4537 print
'<input type="text" class="flat minwidth500" name="WEBSITE_ALIASALT" value="'.dol_escape_htmltag($pagealiasalt).
'">';
4541 print $langs->trans(
'WEBSITE_DESCRIPTION');
4543 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_DESCRIPTION" value="'.dol_escape_htmltag($pagedescription).
'">';
4548 print
'<tr class="trimageforpage hidden"><td>';
4549 $htmlhelp = $langs->trans(
"WEBSITE_IMAGEDesc");
4550 print $form->textwithpicto($langs->trans(
'WEBSITE_IMAGE'), $htmlhelp, 1,
'help',
'', 0, 2,
'imagetooltip');
4552 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_IMAGE" value="'.dol_escape_htmltag($pageimage).
'">';
4555 print
'<script type="text/javascript">
4556 jQuery(document).ready(function() {
4557 jQuery("#selectWEBSITE_TYPE_CONTAINER").change(function() {
4558 console.log("We change type of page : "+jQuery("#selectWEBSITE_TYPE_CONTAINER").val());
4559 if (jQuery("#selectWEBSITE_TYPE_CONTAINER").val() == \'blogpost\') {
4560 jQuery(".trimageforpage").show();
4562 jQuery(".trimageforpage").hide();
4572 $htmlhelp = $langs->trans(
"WEBSITE_KEYWORDSDesc");
4573 print $form->textwithpicto($langs->trans(
'WEBSITE_KEYWORDS'), $htmlhelp, 1,
'help',
'', 0, 2,
'keywordtooltip');
4575 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_KEYWORDS" value="'.dol_escape_htmltag($pagekeywords).
'">';
4579 print $langs->trans(
'Language');
4581 $onlykeys = array();
4585 $onlykeys[$langs->defaultlang] = $langs->defaultlang;
4588 $tmparray = explode(
',',
$object->otherlang);
4589 foreach ($tmparray as $key) {
4590 $tmpkey = trim($key);
4591 if (strlen($key) == 2) {
4592 $tmpkey = strtolower($key);
4594 $onlykeys[$tmpkey] = $tmpkey;
4600 print
img_picto(
'',
'language',
'class="pictofixedwidth"').$formadmin->select_language($pagelang ? $pagelang :
'',
'WEBSITE_LANG', 0, array(),
'1', 0, 0,
'minwidth200', 0, 0, 0, $onlykeys, 1);
4601 $htmltext = $langs->trans(
"AvailableLanguagesAreDefinedIntoWebsiteProperties");
4602 print $form->textwithpicto(
'', $htmltext);
4608 print
'<!-- Translation of --><tr><td>';
4609 print $langs->trans(
'TranslationLinks');
4611 if ($action !=
'createcontainer') {
4613 $sql =
"SELECT rowid, lang from ".MAIN_DB_PREFIX.
"website_page where fk_page = ".((int) $objectpage->id);
4614 $resql = $db->query($sql);
4616 $num_rows = $db->num_rows($resql);
4617 if ($num_rows > 0) {
4618 print
'<span class="opacitymedium">'.$langs->trans(
'ThisPageHasTranslationPages').
':</span>';
4622 while ($obj = $db->fetch_object($resql)) {
4623 $result = $tmppage->fetch($obj->rowid);
4626 $tmpstring .=
'<br>';
4628 $tmpstring .= $tmppage->getNomUrl(1).
' '.
picto_from_langcode($tmppage->lang).
' '.$tmppage->lang;
4630 $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>';
4646 if ((empty($translatedby) || ($objectpage->lang !=
$object->lang)) && ($action ==
'editmeta' || $action ==
'createcontainer' || $objectpage->fk_page > 0)) {
4649 if ($objectpage->fk_page > 0) {
4650 $result = $sourcepage->fetch($objectpage->fk_page);
4657 if ($translatedby) {
4660 $translationof = $objectpage->fk_page;
4661 print
'<span class="opacitymedium">'.$langs->trans(
'ThisPageIsTranslationOf').
'</span> ';
4662 print $sourcepage->getNomUrl(2).
' '.$formwebsite->selectContainer($website,
'pageidfortranslation', ($translationof ? $translationof : -1), 1, $action,
'minwidth300', array($objectpage->id));
4663 if ($translationof > 0 && $sourcepage->lang) {
4666 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>';
4673 if (isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire')) {
4674 $langs->load(
'categories');
4676 if (!GETPOSTISSET(
'categories')) {
4678 $cats =
$c->containing($objectpage->id, Categorie::TYPE_WEBSITE_PAGE);
4679 $arrayselected = array();
4680 if (is_array($cats)) {
4681 foreach ($cats as $cat) {
4682 $arrayselected[] = $cat->id;
4687 $cate_arbo = $form->select_all_categories(Categorie::TYPE_WEBSITE_PAGE,
'',
'parent', 0, 0, 3);
4690 print
'<tr><td class="toptd">'.$form->editfieldkey(
'Categories',
'categories',
'', $objectpage, 0).
'</td><td>';
4691 print
img_picto(
'',
'category',
'class="pictofixedwidth"');
4692 print $form->multiselectarray(
'categories', $cate_arbo, (GETPOSTISSET(
'categories') ?
GETPOST(
'categories',
'array') : $arrayselected), 0, 0,
'minwidth200 widthcentpercentminusxx');
4694 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);
4700 print
'<tr><td class="titlefieldcreate">';
4701 print
'ObjectClass';
4703 print
'<input type="text" class="flat minwidth300" name="WEBSITE_OBJECTCLASS" placeholder="ClassName::/path/class/ObjectClass.class.php" >';
4706 print
'<tr><td class="titlefieldcreate">';
4709 print
'<input type="text" class="flat minwidth300" name="WEBSITE_OBJECTID" >';
4713 $fuser =
new User($db);
4716 if ($action !=
'createcontainer') {
4718 print $langs->trans(
'DateLastModification');
4720 print
dol_print_date($pagedatemodification,
'dayhour',
'tzuser');
4724 print $langs->trans(
'UserModification');
4726 if ($pageusermodifid > 0) {
4727 $fuser->fetch($pageusermodifid);
4728 print $fuser->getNomUrl(-1);
4730 print
'<span class="opacitymedium">'.$langs->trans(
"Unknown").
'</span>';
4736 $url =
'https://wiki.dolibarr.org/index.php/Module_Website';
4737 $htmltext =
'<small>';
4738 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource", $url);
4739 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource1", $url);
4740 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource2", $url);
4741 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource3", $url);
4742 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource4", $url);
4743 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSourceMore", $url);
4744 $htmltext .=
'<br>';
4745 $htmltext .=
'</small>';
4748 $formmail->withaiprompt =
'html';
4749 $formmail->withlayout =
'websitepage';
4750 $showlinktolayout = $formmail->withlayout;
4751 $showlinktoai = ($formmail->withaiprompt && isModEnabled(
'ai')) ?
'textgenerationwebpage' :
'';
4752 if (($action ==
'createcontainer' && $showlinktolayout) || ($action ==
'createcontainer' && $showlinktoai)) {
4753 print
'<tr><td class="titlefield tdtop">';
4754 if (
$conf->browser->layout ==
'phone') {
4755 print $form->textwithpicto(
'', $htmltext, 1,
'help',
'inline-block', 1, 2,
'tooltipsubstitution');
4758 print $form->textwithpicto($langs->trans(
"PreviewPageContent").
' '.
img_help(2, $langs->trans(
"PreviewPageContent")), $htmltext, 1,
'none',
'inline-block', 1, 2,
'tooltipsubstitution');
4760 print
'</td><td class="tdtop">';
4764 $showlinktolayoutlabel = $langs->trans(
"FillPageWithALayout");
4765 $showlinktoailabel = $langs->trans(
"FillPageWithAIContent");
4766 $htmlname =
'content';
4768 include DOL_DOCUMENT_ROOT.
'/core/tpl/formlayoutai.tpl.php';
4774 if ($action ==
'createcontainer') {
4775 print
'<tr id="pageContent"><td class="tdtop">';
4776 if (!$showlinktolayout || !$showlinktoai) {
4777 if (
$conf->browser->layout ==
'phone') {
4778 print $form->textwithpicto(
'', $htmltext, 1,
'help',
'inline-block', 1, 2,
'tooltipsubstitution');
4781 print $form->textwithpicto($showlinktolayout ?
'' : ($langs->trans(
"PreviewPageContent").
' '.
img_help(2, $langs->trans(
"PreviewPageContent"))), $htmltext, 1,
'none',
'inline-block', 1, 2,
'tooltipsubstitution');
4786 $doleditor =
new DolEditor(
'content',
GETPOST(
'content',
'none'),
'', 200,
'dolibarr_mailings',
'In',
true,
true,
true, 40,
'90%');
4787 $doleditor->Create();
4794 print $langs->trans(
'DateCreation');
4796 print $form->selectDate($pagedatecreation,
'datecreation', 1, 1, 0,
'', 1, 1);
4802 print $langs->trans(
'Author');
4804 if ($pageauthorid > 0) {
4805 $fuser->fetch($pageauthorid);
4806 print $fuser->getNomUrl(-1);
4808 print
'<span class="opacitymedium">'.$langs->trans(
"Unknown").
'</span>';
4813 print
'<tr class="trpublicauthor hidden"><td>';
4814 print $langs->trans(
'PublicAuthorAlias');
4816 print
'<input type="text" class="flat minwidth300" name="WEBSITE_AUTHORALIAS" value="'.dol_escape_htmltag($pageauthoralias).
'" placeholder="Anonymous">';
4819 print
'<tr><td class="tdhtmlheader tdtop">';
4820 $htmlhelp = $langs->trans(
"EditTheWebSiteForACommonHeader").
'<br><br>';
4821 $htmlhelp .= $langs->trans(
"Example").
' :<br>';
4823 print $form->textwithpicto($langs->transnoentitiesnoconv(
'HtmlHeaderPage'), $htmlhelp, 1,
'help',
'', 0, 2,
'htmlheadertooltip');
4825 $poscursor = array(
'x' =>
GETPOST(
'htmlheader_x'),
'y' =>
GETPOST(
'htmlheader_y'));
4826 $doleditor =
new DolEditor(
'htmlheader', $pagehtmlheader,
'', 120,
'ace',
'In',
true,
false,
'ace', ROWS_3,
'100%', 0, $poscursor);
4827 print $doleditor->Create(1,
'',
true,
'HTML Header',
'html');
4832 print $langs->trans(
'AllowedInFrames');
4836 print
'<input type="checkbox" class="flat" name="WEBSITE_ALLOWED_IN_FRAMES" value="1"'.($pageallowedinframes ?
'checked="checked"' :
'').
'>';
4841 if ($action ==
'createcontainer') {
4842 print
'<div class="center tablecheckboxcreatemanually'.$hiddenmanuallyafterload.
'">';
4844 print
'<input type="submit" class="button small" name="addcontainer" value="'.$langs->trans(
"Create").
'">';
4845 print
'<input class="button button-cancel small" type="submit" name="preview" value="'.$langs->trans(
"Cancel").
'">';
4852 if (!empty(
$conf->use_javascript_ajax)) {
4853 print
'<input type="radio" name="radiocreatefrom" id="checkboxcreatefromfetching" value="checkboxcreatefromfetching"'.(GETPOST(
'radiocreatefrom') ==
'checkboxcreatefromfetching' ?
' checked' :
'').
'> ';
4855 print
'<label for="checkboxcreatefromfetching"><span class="opacitymediumxx">'.$langs->trans(
"CreateByFetchingExternalPage").
'</span></label><br>';
4856 print
'<hr class="tablecheckboxcreatefromfetching'.$hiddenfromfetchingafterload.
'">';
4857 print
'<table class="tableforfield centpercent tablecheckboxcreatefromfetching'.$hiddenfromfetchingafterload.
'">';
4858 print
'<tr><td class="titlefield">';
4859 print $langs->trans(
"URL");
4861 print
info_admin($langs->trans(
"OnlyEditionOfSourceForGrabbedContentFuture"), 0, 0,
'warning');
4862 print
'<input class="flat minwidth500" type="text" name="externalurl" value="'.dol_escape_htmltag(
GETPOST(
'externalurl',
'alpha')).
'" placeholder="https://externalsite/pagetofetch"> ';
4863 print
'<br><input class="flat paddingtop" type="checkbox" name="grabimages" value="1" checked="checked"> '.$langs->trans(
"GrabImagesInto");
4865 print $langs->trans(
"ImagesShouldBeSavedInto").
' ';
4866 $arraygrabimagesinto = array(
'root' => $langs->trans(
"WebsiteRootOfImages"),
'subpage' => $langs->trans(
"SubdirOfPage"));
4867 print $form->selectarray(
'grabimagesinto', $arraygrabimagesinto, GETPOSTISSET(
'grabimagesinto') ?
GETPOST(
'grabimagesinto') :
'root', 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
4870 print
'<input class="button small" style="margin-top: 5px" type="submit" name="fetchexternalurl" value="'.dol_escape_htmltag($langs->trans(
"FetchAndCreate")).
'">';
4871 print
'<input class="button button-cancel small" type="submit" name="preview" value="'.$langs->trans(
"Cancel").
'">';
4877 if ($action ==
'createcontainer') {
4878 print
'<script type="text/javascript">
4879 jQuery(document).ready(function() {
4880 var disableautofillofalias = 0;
4881 var selectedm = \'\';
4882 var selectedf = \'\';
4884 jQuery("#WEBSITE_TITLE").keyup(function() {
4885 if (disableautofillofalias == 0) {
4886 var valnospecial = jQuery("#WEBSITE_TITLE").val();
4887 valnospecial = valnospecial.replace(/[éèê]/g, \'e\').replace(/[à]/g, \'a\').replace(/[ù]/g, \'u\').replace(/[î]/g, \'i\');
4888 valnospecial = valnospecial.replace(/[ç]/g, \'c\').replace(/[ö]/g, \'o\');
4889 valnospecial = valnospecial.replace(/[^\w]/gi, \'-\').toLowerCase();
4890 valnospecial = valnospecial.replace(/\-+/g, \'-\').replace(/\-$/, \'\');
4891 console.log("disableautofillofalias=0 so we replace WEBSITE_TITLE with "+valnospecial);
4892 jQuery("#WEBSITE_PAGENAME").val(valnospecial);
4895 jQuery("#WEBSITE_PAGENAME").keyup(function() {
4896 if (jQuery("#WEBSITE_PAGENAME").val() == \'\') {
4897 disableautofillofalias = 0;
4899 disableautofillofalias = 1;
4902 jQuery("#WEBSITE_PAGENAME").blur(function() {
4903 if (jQuery("#WEBSITE_PAGENAME").val() == \'\') {
4904 disableautofillofalias = 0;
4905 jQuery("#WEBSITE_TITLE").trigger(\'keyup\');
4909 jQuery("#checkboxcreatefromfetching,#checkboxcreatemanually").click(function() {
4910 console.log("we select a method to create a new container "+jQuery("#checkboxcreatefromfetching:checked").val())
4911 jQuery(".tablecheckboxcreatefromfetching").hide();
4912 jQuery(".tablecheckboxcreatemanually").hide();
4913 if (typeof(jQuery("#checkboxcreatefromfetching:checked").val()) != \'undefined\') {
4914 console.log("show create from spider form");
4915 if (selectedf != \'createfromfetching\') {
4916 jQuery(".tablecheckboxcreatefromfetching").show();
4917 selectedf = \'createfromfetching\';
4920 jQuery(".tablecheckboxcreatefromfetching").hide();
4924 if (typeof(jQuery("#checkboxcreatemanually:checked").val()) != \'undefined\') {
4925 console.log("show create from scratch or template form");
4926 if (selectedm != \'createmanually\') {
4927 jQuery(".tablecheckboxcreatemanually").show();
4928 selectedm = \'createmanually\';
4931 jQuery(".tablecheckboxcreatemanually").hide();
4950if ($action ==
'preview') {
4954if ($action ==
'editfile' || $action ==
'file_manager' || $action ==
'convertimgwebp' || $action ==
'confirmconvertimgwebp') {
4955 print
'<!-- Edit Media -->'.
"\n";
4956 print
'<div class="fiche"><br>';
4959 $formalreadyopen = 2;
4961 $url = DOL_URL_ROOT.
'/website/index.php';
4963 include DOL_DOCUMENT_ROOT.
'/core/tpl/filemanager.tpl.php';
4968if ($action ==
'editmenu') {
4969 print
'<!-- Edit Menu -->'.
"\n";
4970 print
'<div class="center">'.$langs->trans(
"FeatureNotYetAvailable").
'</center>';
4973if ($action ==
'editsource') {
4976 $contentforedit =
'';
4980 $contentforedit .= $objectpage->content;
4982 $maxheightwin = 480;
4983 if (isset($_SESSION[
"dol_screenheight"])) {
4984 if ($_SESSION[
"dol_screenheight"] > 680) {
4985 $maxheightwin = $_SESSION[
"dol_screenheight"] - 400;
4987 if ($_SESSION[
"dol_screenheight"] > 800) {
4988 $maxheightwin = $_SESSION[
"dol_screenheight"] - 490;
4992 $poscursor = array(
'x' =>
GETPOST(
'PAGE_CONTENT_x'),
'y' =>
GETPOST(
'PAGE_CONTENT_y'));
4993 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
4994 $doleditor =
new DolEditor(
'PAGE_CONTENT', $contentforedit,
'', $maxheightwin,
'Full',
'',
true,
true,
'ace', ROWS_5,
'40%', 0, $poscursor);
4995 $doleditor->Create(0,
'',
false,
'HTML Source',
'php');
4998if ($action ==
'editcontent') {
5001 $contentforedit =
'';
5005 $contentforedit .= $objectpage->content;
5010 $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);
5012 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
5013 $poscursor = array(
'x' =>
GETPOST(
'PAGE_CONTENT_x'),
'y' =>
GETPOST(
'PAGE_CONTENT_y'));
5014 $doleditor =
new DolEditor(
'PAGE_CONTENT', $contentforedit,
'', 500,
'Full',
'',
true,
true,
true, ROWS_5,
'90%', 0, $poscursor);
5015 $doleditor->Create(0,
'',
false);
5022if ($mode ==
'replacesite' || $massaction ==
'replace') {
5023 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
5024 print
'<input type="hidden" name="token" value="'.newToken().
'">';
5025 print
'<input type="hidden" name="action" value="replacesiteconfirm">';
5026 print
'<input type="hidden" name="mode" value="replacesite">';
5027 print
'<input type="hidden" name="website" value="'.$website->ref.
'">';
5030 print
'<!-- Search page and replace string -->'.
"\n";
5031 print
'<div class="fiche"><br>';
5033 print
load_fiche_titre($langs->trans(
"ReplaceWebsiteContent"),
'',
'search');
5035 print
'<div class="fichecenter"><div class="fichehalfleft">';
5037 print
'<div class="tagtable">';
5039 print
'<div class="tagtr">';
5040 print
'<div class="tagtd paddingrightonly opacitymedium">';
5041 print $langs->trans(
"SearchReplaceInto");
5043 print
'<div class="tagtd">';
5044 print
'<input type="checkbox" class="marginleftonly" id="checkboxoptiopagecontent" name="optiopagecontent" value="content"'.((!GETPOSTISSET(
'buttonreplacesitesearch') ||
GETPOST(
'optiopagecontent',
'aZ09')) ?
' checked' :
'').
'> <label for="checkboxoptiopagecontent" class="tdoverflowmax150onsmartphone inline-block valignmiddle">'.$langs->trans(
"Content").
'</label><br>';
5045 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(
"WEBSITE_PAGENAME").
' | '.$langs->trans(
"Title").
' | '.$langs->trans(
"Description").
' | '.$langs->trans(
"Keywords").
'</label><br>';
5046 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>';
5050 print
'<div class="tagtr">';
5051 print
'<div class="tagtd paddingrightonly opacitymedium" style="padding-right: 10px !important">';
5052 print $langs->trans(
"SearchString");
5054 print
'<div class="tagtd">';
5055 print
'<input type="text" name="searchstring" value="'.dol_escape_htmltag($searchkey, 0, 0,
'', 1).
'" autofocus>';
5061 print
'</div><div class="fichehalfleft">';
5063 print
'<div class="tagtable">';
5065 print
'<div class="tagtr">';
5066 print
'<div class="tagtd paddingrightonly opacitymedium tdoverflowmax100onsmartphone" style="padding-right: 10px !important">';
5067 print $langs->trans(
"WEBSITE_TYPE_CONTAINER");
5069 print
'<div class="tagtd">';
5070 print
img_picto(
'',
'object_technic',
'class="paddingrightonly"').
' ';
5071 print $formwebsite->selectTypeOfContainer(
'optioncontainertype', (
GETPOST(
'optioncontainertype',
'alpha') ?
GETPOST(
'optioncontainertype',
'alpha') :
''), 1,
'', 1,
'minwidth125 maxwidth400 widthcentpercentminusx');
5075 print
'<div class="tagtr">';
5076 print
'<div class="tagtd paddingrightonly opacitymedium tdoverflowmax100onsmartphone" style="padding-right: 10px !important">';
5077 print $langs->trans(
"Language");
5079 print
'<div class="tagtd">';
5080 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);
5085 if (isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire')) {
5086 print
'<div class="tagtr">';
5087 print
'<div class="tagtd paddingrightonly marginrightonly opacitymedium tdoverflowmax100onsmartphone" style="padding-right: 10px !important">';
5088 print $langs->trans(
"Category");
5090 print
'<div class="tagtd">';
5091 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');
5092 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
5100 print
'<input type="submit" class="button margintoponly" name="buttonreplacesitesearch" value="'.dol_escape_htmltag($langs->trans(
"Search")).
'">';
5102 print
'</div></div>';
5104 if ($mode ==
'replacesite') {
5105 print
'<!-- List of search result -->'.
"\n";
5106 print
'<div class="rowsearchresult clearboth">';
5111 if ($listofpages[
'code'] ==
'OK') {
5112 $arrayofselected = is_array($toselect) ? $toselect : array();
5114 $nbtotalofrecords = count($listofpages[
'list']);
5116 $permissiontodelete = $user->hasRight(
'website',
'delete');
5119 $arrayofmassactions = array();
5120 if ($user->hasRight(
'website',
'writephp') && $searchkey) {
5121 $arrayofmassactions[
'replace'] =
img_picto(
'',
'replacement',
'class="pictofixedwidth"').$langs->trans(
"Replace");
5123 if ($user->hasRight(
'website',
'write')) {
5124 $arrayofmassactions[
'setcategory'] =
img_picto(
'',
'category',
'class="pictofixedwidth"').$langs->trans(
"ClassifyInCategory");
5126 if ($user->hasRight(
'website',
'write')) {
5127 $arrayofmassactions[
'delcategory'] =
img_picto(
'',
'category',
'class="pictofixedwidth"').$langs->trans(
"RemoveCategory");
5129 if ($permissiontodelete) {
5130 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
5132 if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete'))) {
5133 $arrayofmassactions = array();
5136 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
5137 $massactionbutton .=
'<div class="massactionother massactionreplace hidden">';
5138 $massactionbutton .= $langs->trans(
"ReplaceString");
5139 $massactionbutton .=
' <input type="text" name="replacestring" value="'.dol_escape_htmltag(
GETPOST(
'replacestring',
'none')).
'">';
5140 $massactionbutton .=
'</div>';
5141 $massactionbutton .=
'<div class="massactionother massactionsetcategory massactiondelcategory hidden">';
5142 $massactionbutton .=
img_picto(
'',
'category',
'class="pictofixedwidth"');
5143 $massactionbutton .= $form->select_all_categories(Categorie::TYPE_WEBSITE_PAGE, GETPOSTISSET(
'setcategory') ?
GETPOST(
'setcategory') :
'',
'setcategory', 64, 0, 0, 0,
'minwidth300 alignstart');
5144 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
5146 $massactionbutton .=
'</div>';
5148 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
5151 $selectedfields =
'';
5152 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
5154 print_barre_liste($langs->trans(
"Results"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'generic', 0,
'',
'', $limit, 1, 1, 1);
5156 $topicmail =
"WebsitePageRef";
5157 $modelmail =
"websitepage_send";
5159 $trackid =
'wsp'.$object->id;
5160 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
5162 $param =
'mode=replacesite&website='.urlencode($website->ref);
5163 $param .=
'&searchstring='.urlencode($searchkey);
5164 if (
GETPOST(
'optiopagecontent')) {
5165 $param .=
'&optiopagecontent=content';
5168 $param .=
'&optionmeta=meta';
5170 if (
GETPOST(
'optionsitefiles')) {
5171 $param .=
'&optionsitefiles=optionsitefiles';
5173 if (
GETPOST(
'optioncontainertype')) {
5174 $param .=
'&optioncontainertype='.GETPOST(
'optioncontainertype',
'aZ09');
5176 if (
GETPOST(
'optionlanguage')) {
5177 $param .=
'&optionlanguage='.GETPOST(
'optionlanguage',
'aZ09');
5179 if (
GETPOST(
'optioncategory')) {
5180 $param .=
'&optioncategory='.GETPOST(
'optioncategory',
'aZ09');
5183 print
'<div class="div-table-responsive-no-min">';
5184 print
'<table class="noborder centpercent">';
5185 print
'<tr class="liste_titre">';
5188 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
5190 print
getTitleFieldOfList(
"Type", 0, $_SERVER[
'PHP_SELF'],
'type_container',
'', $param,
'', $sortfield, $sortorder,
'').
"\n";
5191 print
getTitleFieldOfList(
"Page", 0, $_SERVER[
'PHP_SELF'],
'pageurl',
'', $param,
'', $sortfield, $sortorder,
'').
"\n";
5192 print
getTitleFieldOfList(
"Language", 0, $_SERVER[
'PHP_SELF'],
'lang',
'', $param,
'', $sortfield, $sortorder,
'center ').
"\n";
5193 print
getTitleFieldOfList(
"Categories", 0, $_SERVER[
'PHP_SELF'],
'',
'', $param,
'', $sortfield, $sortorder,
'center ').
"\n";
5195 print
getTitleFieldOfList(
"UserCreation", 0, $_SERVER[
'PHP_SELF'],
'fk_user_creat',
'', $param,
'', $sortfield, $sortorder,
'').
"\n";
5196 print
getTitleFieldOfList(
"DateCreation", 0, $_SERVER[
'PHP_SELF'],
'date_creation',
'', $param,
'', $sortfield, $sortorder,
'center ').
"\n";
5197 print
getTitleFieldOfList(
"DateLastModification", 0, $_SERVER[
'PHP_SELF'],
'tms',
'', $param,
'', $sortfield, $sortorder,
'center ').
"\n";
5201 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
5205 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
5210 foreach ($listofpages[
'list'] as $answerrecord) {
5211 if (is_object($answerrecord) && get_class($answerrecord) ==
'WebsitePage') {
5212 $param =
'?mode=replacesite';
5213 $param .=
'&websiteid='.$website->id;
5214 $param .=
'&optiopagecontent='.GETPOST(
'optiopagecontent',
'aZ09');
5215 $param .=
'&optionmeta='.GETPOST(
'optionmeta',
'aZ09');
5216 $param .=
'&optionsitefiles='.GETPOST(
'optionsitefiles',
'aZ09');
5217 $param .=
'&optioncontainertype='.GETPOST(
'optioncontainertype',
'aZ09');
5218 $param .=
'&optionlanguage='.GETPOST(
'optionlanguage',
'aZ09');
5219 $param .=
'&optioncategory='.GETPOST(
'optioncategory',
'aZ09');
5220 $param .=
'&searchstring='.urlencode($searchkey);
5226 print
'<td class="nowrap center">';
5228 print
'<!-- Status of page -->'.
"\n";
5229 if ($massactionbutton || $massaction) {
5231 if (in_array($answerrecord->id, $arrayofselected)) {
5234 print
'<input id="'.$answerrecord->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$answerrecord->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
5240 print
'<td class="nowraponall">';
5242 if (!empty(
$conf->cache[
'type_of_container'][$answerrecord->type_container])) {
5243 print $langs->trans(
$conf->cache[
'type_of_container'][$answerrecord->type_container]);
5245 print $langs->trans($answerrecord->type_container);
5250 $titleofpage = ($answerrecord->title ? $answerrecord->title : $langs->trans(
"NoTitle"));
5251 print
'<td class="tdoverflowmax300" title="'.dol_escape_htmltag($titleofpage).
'">';
5252 print $answerrecord->getNomUrl(1);
5253 print
' <span class="opacitymedium">('.dol_escape_htmltag($titleofpage).
')</span>';
5257 print
'<span class="opacitymedium">'.dol_escape_htmltag($answerrecord->description ? $answerrecord->description : $langs->trans(
"NoDescription")).
'</span>';
5261 print
'<td class="center">';
5266 print
'<td class="center">';
5267 if (isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire')) {
5269 $existing =
$c->containing($answerrecord->id, Categorie::TYPE_WEBSITE_PAGE,
'object');
5270 if (is_array($existing)) {
5271 foreach ($existing as $tmpcategory) {
5273 print
img_object($langs->trans(
"Category").
' : '.$tmpcategory->label,
'category',
'style="padding-left: 2px; padding-right: 2px; color: #'.($tmpcategory->color !=
'' ? $tmpcategory->color :
'888').
'"');
5281 print
'<td class="center nowraponall">';
5283 $characterMap =
'áàéèëíóúüñùç0123456789';
5284 $nbofwords = str_word_count($textwithouthtml, 0, $characterMap);
5286 print $nbofwords.
' '.$langs->trans(
"words");
5287 $totalnbwords += $nbofwords;
5292 print
'<td class="tdoverflowmax125">';
5293 if (!empty($answerrecord->fk_user_creat)) {
5294 if (empty(
$conf->cache[
'user'][$answerrecord->fk_user_creat])) {
5295 $tmpuser =
new User($db);
5296 $tmpuser->fetch($answerrecord->fk_user_creat);
5297 $conf->cache[
'user'][$answerrecord->fk_user_creat] = $tmpuser;
5299 $tmpuser =
$conf->cache[
'user'][$answerrecord->fk_user_creat];
5301 print $tmpuser->getNomUrl(-1,
'', 0, 0, 0, 0,
'login');
5306 print
'<td class="center nowraponall">';
5311 print
'<td class="center nowraponall">';
5312 print
dol_print_date($answerrecord->date_modification,
'dayhour');
5316 print
'<td class="tdwebsitesearchresult right nowraponall">';
5318 $urltoedithtmlsource = $_SERVER[
"PHP_SELF"].
'?action=editmeta&token='.
newToken().
'&websiteid='.$website->id.
'&pageid='.$answerrecord->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].$param);
5319 if (!$user->hasRight(
'website',
'write')) {
5320 $disabled =
' disabled';
5321 $urltoedithtmlsource =
'';
5323 print
'<a class="editfielda marginleftonly marginrightonly '.$disabled.
'" href="'.$urltoedithtmlsource.
'" title="'.$langs->trans(
"EditPageMeta").
'">'.
img_picto($langs->trans(
"EditPageMeta"),
'pencil-ruler').
'</a>';
5326 $urltoedithtmlsource = $_SERVER[
"PHP_SELF"].
'?action=editsource&token='.
newToken().
'&websiteid='.$website->id.
'&pageid='.$answerrecord->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].$param);
5327 if (!$user->hasRight(
'website',
'write')) {
5328 $disabled =
' disabled';
5329 $urltoedithtmlsource =
'';
5331 print
'<a class="editfielda marginleftonly marginrightonly '.$disabled.
'" href="'.$urltoedithtmlsource.
'" title="'.$langs->trans(
"EditHTMLSource").
'">'.
img_picto($langs->trans(
"EditHTMLSource"),
'edit').
'</a>';
5333 print
'<span class="marginleftonly marginrightonly"></span>';
5334 print
ajax_object_onoff($answerrecord,
'status',
'status',
'Enabled',
'Disabled', array(),
'valignmiddle inline-block');
5340 print
'<td class="nowrap center">';
5342 print
'<!-- Status of page -->'.
"\n";
5343 if ($massactionbutton || $massaction) {
5345 if (in_array($answerrecord->id, $arrayofselected)) {
5348 print
'<input id="'.$answerrecord->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$answerrecord->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
5356 '@phan-var-force array{type:string} $answerrecord';
5357 $param =
'?mode=replacesite';
5358 $param .=
'&websiteid='.$website->id;
5359 $param .=
'&optiopagecontent='.GETPOST(
'optiopagecontent',
'aZ09');
5360 $param .=
'&optionmeta='.GETPOST(
'optionmeta',
'aZ09');
5361 $param .=
'&optionsitefiles='.GETPOST(
'optionsitefiles',
'aZ09');
5362 $param .=
'&optioncontainertype='.GETPOST(
'optioncontainertype',
'aZ09');
5363 $param .=
'&optionlanguage='.GETPOST(
'optionlanguage',
'aZ09');
5364 $param .=
'&optioncategory='.GETPOST(
'optioncategory',
'aZ09');
5365 $param .=
'&searchstring='.urlencode($searchkey);
5371 print
'<td class="nowrap center">';
5377 $translateofrecordtype = array(
5378 'website_csscontent' =>
'WEBSITE_CSS_INLINE',
5379 'website_jscontent' =>
'WEBSITE_JS_INLINE',
5380 'website_robotcontent' =>
'WEBSITE_ROBOT',
5381 'website_htmlheadercontent' =>
'WEBSITE_HTML_HEADER',
5382 'website_htaccess' =>
'WEBSITE_HTACCESS',
5383 'website_readme' =>
'WEBSITE_README',
5384 'website_manifestjson' =>
'WEBSITE_MANIFEST_JSON'
5386 print
'<span class="opacitymedium">';
5387 if (!empty($translateofrecordtype[$answerrecord[
'type']])) {
5388 print $langs->trans($translateofrecordtype[$answerrecord[
'type']]);
5390 print $answerrecord[
'type'];
5397 $backtopageurl = $_SERVER[
"PHP_SELF"].$param;
5398 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=editcss&token='.
newToken().
'&website='.urlencode($website->ref).
'&backtopage='.urlencode($backtopageurl).
'">'.$langs->trans(
"EditCss").
'</a>';
5420 print
'<td class="center nowraponall">';
5430 print
'<td class="nowrap center">';
5438 if (count($listofpages[
'list']) >= 2) {
5440 print
'<tr class="lite_titre">';
5444 print
'<td class="nowrap center">';
5450 print $langs->trans(
"Total");
5466 print
'<td class="center nowraponall">';
5467 print $totalnbwords.
' '.$langs->trans(
"words");
5486 print
'<td class="nowrap center">';
5497 print
'<div class="warning">'.$listofpages[
'message'].
'</div>';
5506if ((empty($action) || $action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone') && !in_array($mode, array(
'replacesite'))) {
5507 if ($pageid > 0 && $atleastonepage) {
5513 $objectpage->fetch($pageid);
5515 $jscontent = @file_get_contents($filejs);
5517 $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";
5526 $out .=
"\n<html><head>\n";
5527 $out .=
"<!-- htmlheader/style of page from database -->\n";
5530 $out .=
"<!-- htmlheader/style of website from files -->\n";
5548 $out .=
"</head>\n";
5553 $out .=
'<div id="websitecontentundertopmenu" class="websitecontentundertopmenu boostrap-iso">'.
"\n";
5557 $out .=
'<!-- style of website from file -->'.
"\n";
5558 $out .=
'<style scoped>'.
"\n";
5560 $tmpout .=
'/* Include website CSS file */'.
"\n";
5564 $csscontent = ob_get_contents();
5567 $tmpout .=
'/* Include style from the HTML header of page */'.
"\n";
5569 $tmp = preg_split(
'(<style[^>]*>|</style>)', $objectpage->htmlheader);
5570 $tmpstyleinheader =
'';
5572 foreach ($tmp as $valtmp) {
5575 $tmpstyleinheader .= $valtmp.
"\n";
5578 $tmpout .= $tmpstyleinheader.
"\n";
5580 $tmpout = preg_replace(
'/}[\s\n]*body\s*{[^}]+}/ims',
'}', $tmpout);
5582 $out .=
'</style>'.
"\n";
5589 $out .=
'<div id="divbodywebsite" class="bodywebsite bodywebpage-'.$objectpage->ref.
'">'.
"\n";
5591 $newcontent = $objectpage->content;
5598 $filephp = $filetpl;
5601 $savsessionname = session_name();
5602 $savsessionid = $_COOKIE[$savsessionname];
5603 $_COOKIE[$savsessionname] =
'obfuscatedcookie';
5607 $res = include $filephp;
5609 print
"ERROR: Failed to include file '".$filephp.
"'. Try to edit and re-save page with this ID.";
5612 print $e->getMessage();
5614 $newcontent = ob_get_contents();
5618 $_COOKIE[$savsessionname] = $savsessionid;
5624 $newcontent = preg_replace(
'/(div|section|header|main|footer)(\s[^>]*)contenteditable="true"/',
'\1\2', $newcontent);
5631 $out .=
'</div>'.
"\n";
5633 $out .=
'</div> <!-- End div id=websitecontentundertopmenu -->'.
"\n";
5639 $out .=
"\n</body></html>\n";
5641 $out .=
"\n".
'<!-- End page content '.$filetpl.
' -->'.
"\n\n";
5665 if (empty($websitekey) || $websitekey ==
'-1') {
5666 print
'<br><br><div class="center previewnotyetavailable"><span class="">'.$langs->trans(
"NoWebSiteCreateOneFirst").
'</span></div><br><br><br>';
5667 print
'<div class="center"><div class="logo_setup"></div></div>';
5669 print
'<br><br><div class="center previewnotyetavailable"><span class="">'.$langs->trans(
"PreviewOfSiteNotYetAvailable",
$object->ref).
'</span></div><br><br><br>';
5670 print
'<div class="center"><div class="logo_setup"></div></div>';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input=array(), $morecss='', $htmlname='', $forcenojs=0, $moreparam='')
On/off button to change a property status of an object This uses the ajax service objectonoff....
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Class to manage categories.
Class to manage a WYSIWYG editor.
lessphp v0.8.0 http://leafo.net/lessphp
Class to manage Dolibarr users.
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0, $level=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories)
dol_is_file($pathoffile)
Return if path is a file.
dol_add_file_process($upload_dir, $allowoverwrite=0, $updatesessionordb=0, $varfiles='addedfile', $savingdocmask='', $link=null, $trackid='', $generatethumbs=1, $object=null, $forceFullTextIndexation='')
Get and save an upload file (for example after submitting a new file a mail form).
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed 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.
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, $allowothertags=array())
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.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
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_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.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
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.