25define(
'NOSCANPOSTFORINJECTION', 1);
26define(
'NOSTYLECHECK', 1);
27define(
'USEDOLIBARREDITOR', 1);
28define(
'FORCE_CKEDITOR', 1);
29if (!defined(
'DISABLE_JS_GRAHP')) define(
'DISABLE_JS_GRAPH', 1);
34require
'../main.inc.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/lib/website.lib.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/lib/website2.lib.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formwebsite.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/website/class/website.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/website/class/websitepage.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
50$langs->loadLangs(array(
"admin",
"other",
"website",
"errors"));
53if (!$user->rights->website->read) {
57$conf->dol_hide_leftmenu = 1;
60$websiteid =
GETPOST(
'websiteid',
'int');
61$websitekey =
GETPOST(
'website',
'alpha');
62$page =
GETPOST(
'page',
'alpha');
63$pageid =
GETPOST(
'pageid',
'int');
64$pageref =
GETPOST(
'pageref',
'alphanohtml');
66$action =
GETPOST(
'action',
'aZ09');
67$massaction =
GETPOST(
'massaction',
'alpha');
68$confirm =
GETPOST(
'confirm',
'alpha');
69$cancel =
GETPOST(
'cancel',
'alpha');
70$toselect =
GETPOST(
'toselect',
'array');
71$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'websitelist';
72$backtopage =
GETPOST(
'backtopage',
'alpha');
73$optioncss =
GETPOST(
'optioncss',
'aZ');
74$dol_hide_topmenu =
GETPOST(
'dol_hide_topmenu',
'int');
75$dol_hide_leftmenu =
GETPOST(
'dol_hide_leftmenu',
'int');
76$dol_openinpopup =
GETPOST(
'dol_openinpopup',
'aZ09');
78$type_container =
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'alpha');
79$section_dir =
GETPOST(
'section_dir',
'alpha');
80$file_manager =
GETPOST(
'file_manager',
'alpha');
81$replacesite =
GETPOST(
'replacesite',
'alpha');
82$mode =
GETPOST(
'mode',
'alpha');
84if (
GETPOST(
'deletesite',
'alpha')) {
85 $action =
'deletesite';
87if (
GETPOST(
'delete',
'alpha')) {
90if (
GETPOST(
'preview',
'alpha')) {
93if (
GETPOST(
'createsite',
'alpha')) {
94 $action =
'createsite';
96if (
GETPOST(
'createcontainer',
'alpha')) {
97 $action =
'createcontainer';
99if (
GETPOST(
'editcss',
'alpha')) {
102if (
GETPOST(
'editmenu',
'alpha')) {
103 $action =
'editmenu';
105if (
GETPOST(
'setashome',
'alpha')) {
106 $action =
'setashome';
108if (
GETPOST(
'editmeta',
'alpha')) {
109 $action =
'editmeta';
111if (
GETPOST(
'editsource',
'alpha')) {
112 $action =
'editsource';
114if (
GETPOST(
'editcontent',
'alpha')) {
115 $action =
'editcontent';
117if (
GETPOST(
'exportsite',
'alpha')) {
118 $action =
'exportsite';
120if (
GETPOST(
'importsite',
'alpha')) {
121 $action =
'importsite';
123if (
GETPOST(
'createfromclone',
'alpha')) {
124 $action =
'createfromclone';
126if (
GETPOST(
'createpagefromclone',
'alpha')) {
127 $action =
'createpagefromclone';
129if (empty($action) && $file_manager) {
130 $action =
'file_manager';
132if ($action ==
'replacesite' || (empty($action) && $replacesite)) {
133 $mode =
'replacesite';
140$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
141$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
142$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
143$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
144if (empty($page) || $page == -1) {
147$offset = $limit * $page;
148$pageprev = $page - 1;
149$pagenext = $page + 1;
160$object->fetchAll(
'ASC',
'position');
163if (!($websiteid > 0) && empty($websitekey) && $action !=
'createsite') {
164 foreach ($object->records as $key => $valwebsite) {
165 $websitekey = $valwebsite->ref;
169if ($websiteid > 0 || $websitekey) {
170 $res = $object->fetch($websiteid, $websitekey);
171 $websitekey = $object->ref;
180if (($pageid > 0 || $pageref) && $action !=
'addcontainer') {
181 $res = $objectpage->fetch($pageid, ($object->id > 0 ? $object->id : null), $pageref);
183 $res = $objectpage->fetch($pageid, ($object->id > 0 ? $object->id : null), null, $pageref);
187 if ($res >= 0 && $object->id > 0) {
188 if ($objectpage->fk_website != $object->id) {
189 if ($object->fk_default_home > 0) {
190 $res = $objectpage->fetch($object->fk_default_home, $object->id,
'');
192 $pageid = $object->fk_default_home;
195 $res = $objectpage->fetch(0, $object->id,
'');
200 $pageid = $objectpage->id;
205 $pageid = $objectpage->id;
211if (empty($pageid) && empty($pageref) && $object->id > 0 && $action !=
'createcontainer') {
212 $pageid = $object->fk_default_home;
213 if (empty($pageid)) {
214 $array = $objectpage->fetchAll($object->id,
'ASC,ASC',
'type_container,pageurl');
215 if (!is_array($array) && $array < 0) {
218 $atleastonepage = (is_array($array) && count($array) > 0);
220 $firstpageid = 0; $homepageid = 0;
221 foreach ($array as $key => $valpage) {
222 if (empty($firstpageid)) {
223 $firstpageid = $valpage->id;
225 if ($object->fk_default_home && $key == $object->fk_default_home) {
226 $homepageid = $valpage->id;
229 $pageid = ($homepageid ? $homepageid : $firstpageid);
234global $dolibarr_main_data_root;
235$pathofwebsite = $dolibarr_main_data_root.($conf->entity > 1 ?
'/'.$conf->entity :
'').
'/website/'.$websitekey;
236$filehtmlheader = $pathofwebsite.
'/htmlheader.html';
237$filecss = $pathofwebsite.
'/styles.css.php';
238$filejs = $pathofwebsite.
'/javascript.js.php';
239$filerobot = $pathofwebsite.
'/robots.txt';
240$filehtaccess = $pathofwebsite.
'/.htaccess';
241$filetpl = $pathofwebsite.
'/page'.$pageid.
'.tpl.php';
242$fileindex = $pathofwebsite.
'/index.php';
243$filewrapper = $pathofwebsite.
'/wrapper.php';
244$filemanifestjson = $pathofwebsite.
'/manifest.json.php';
245$filereadme = $pathofwebsite.
'/README.md';
246$filelicense = $pathofwebsite.
'/LICENSE';
247$filemaster = $pathofwebsite.
'/master.inc.php';
250$urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
251$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
255$permtouploadfile = $user->hasRight(
'website',
'write');
256$diroutput = $conf->medias->multidir_output[$conf->entity];
258$relativepath = $section_dir;
259$upload_dir = preg_replace(
'/\/$/',
'', $diroutput).
'/'.preg_replace(
'/^\//',
'', $relativepath);
261$htmlheadercontentdefault =
'';
262$htmlheadercontentdefault .=
'<link rel="stylesheet" id="google-fonts-css" href="//fonts.googleapis.com/css?family=Open+Sans:300,400,700" />'.
"\n";
263$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";
264$htmlheadercontentdefault .=
'<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>'.
"\n";
265$htmlheadercontentdefault .=
'<script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>'.
"\n";
266$htmlheadercontentdefault .=
'<!--'.
"\n";
267$htmlheadercontentdefault .=
'<script src="/document.php?modulepart=medias&file=css/myfile.css"></script>'.
"\n";
268$htmlheadercontentdefault .=
'<script src="/document.php?modulepart=medias&file=js/myfile.js"></script>'.
"\n";
269$htmlheadercontentdefault .=
'-->'.
"\n";
271$manifestjsoncontentdefault =
'';
272$manifestjsoncontentdefault .=
'{
274 "short_name": "MyWebsite",
277 "display": "standalone",
278 "background_color": "#fff",
279 "description": "A simple Web app.",
281 "src": "images/'.urlencode($website->ref).
'/homescreen48.png",
285 "src": "image/'.urlencode($website->ref).
'/homescreen72.png",
289 "src": "image/'.urlencode($website->ref).
'/homescreen96.png",
293 "src": "image/'.urlencode($website->ref).
'/homescreen144.png",
297 "src": "image/'.urlencode($website->ref).
'/homescreen168.png",
301 "src": "image/'.urlencode($website->ref).
'/homescreen192.png",
305 "related_applications": [{
307 "url": "https://play.google.com/store/apps/details?id=com.nltechno.dolidroidpro"
311$listofpages = array();
320if (
GETPOST(
'optionsitefiles')) {
321 $algo .=
'sitefiles';
324if (empty($sortfield)) {
325 if ($action ==
'file_manager') {
326 $sortfield =
'name'; $sortorder =
'ASC';
328 $sortfield =
'pageurl'; $sortorder =
'ASC';
332$searchkey =
GETPOST(
'searchstring',
'restricthtml');
334if ($action ==
'replacesite' || $mode ==
'replacesite') {
335 $containertype =
GETPOST(
'optioncontainertype',
'aZ09') !=
'-1' ?
GETPOST(
'optioncontainertype',
'aZ09') :
'';
336 $langcode =
GETPOST(
'optionlanguage',
'aZ09');
337 $otherfilters = array();
338 if (
GETPOST(
'optioncategory',
'int') > 0) {
339 $otherfilters[
'category'] =
GETPOST(
'optioncategory',
'int');
342 $listofpages =
getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters, -1);
345$usercanedit = $user->rights->website->write;
346$permissiontoadd = $user->rights->website->write;
347$permissiontodelete = $user->hasRight(
'website',
'delete');
358if (
GETPOST(
'refreshsite',
'alpha') ||
GETPOST(
'refreshsite.x',
'alpha') ||
GETPOST(
'refreshsite_x',
'alpha')) {
359 if ($action ==
'addsite') {
362 if ($action ==
'updatesource') {
366 $pageid = $object->fk_default_home;
367 if (empty($pageid)) {
368 $array = $objectpage->fetchAll($object->id,
'ASC,ASC',
'type_container,pageurl');
369 if (!is_array($array) && $array < 0) {
372 $atleastonepage = (is_array($array) && count($array) > 0);
374 $firstpageid = 0; $homepageid = 0;
375 foreach ($array as $key => $valpage) {
376 if (empty($firstpageid)) {
377 $firstpageid = $valpage->id;
379 if ($object->fk_default_home && $key == $object->fk_default_home) {
380 $homepageid = $valpage->id;
383 $pageid = ($homepageid ? $homepageid : $firstpageid);
386if (
GETPOST(
'refreshpage',
'alpha') && !in_array($action, array(
'updatecss'))) {
390if ($cancel && $action ==
'renamefile') {
399 header(
"Location: ".$backtopage);
404$savbacktopage = $backtopage;
405$backtopage = $_SERVER[
"PHP_SELF"].
'?file_manager=1&website='.urlencode($websitekey).
'&pageid='.urlencode($pageid).(GETPOST(
'section_dir',
'alpha') ?
'§ion_dir='.urlencode(
GETPOST(
'section_dir',
'alpha')) :
'');
407 $backtopage .=
'&sortfield='.urlencode($sortfield);
410 $backtopage .=
'&sortorder='.urlencode($sortorder);
412include DOL_DOCUMENT_ROOT.
'/core/actions_linkedfiles.inc.php';
414$backtopage = $savbacktopage;
418if ($action ==
'renamefile') {
419 $action =
'file_manager';
422if ($action ==
'setwebsiteonline' && $usercanedit) {
423 $website->setStatut($website::STATUS_VALIDATED,
null,
'',
'WEBSITE_MODIFY',
'status');
425 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.
GETPOST(
'website',
'alphanohtml').
'&pageid='.
GETPOST(
'websitepage',
'int'));
428if ($action ==
'setwebsiteoffline' && $usercanedit) {
429 $result = $website->setStatut($website::STATUS_DRAFT,
null,
'',
'WEBSITE_MODIFY',
'status');
431 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.
GETPOST(
'website',
'alphanohtml').
'&pageid='.
GETPOST(
'websitepage',
'int'));
434if ($action ==
'seteditinline') {
436 setEventMessages($langs->trans(
"FeatureNotYetAvailable"),
null,
'warnings');
438 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.
GETPOST(
'website',
'alphanohtml').
'&pageid='.
GETPOST(
'pageid',
'int'));
441if ($action ==
'unseteditinline') {
443 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.
GETPOST(
'website',
'alphanohtml').
'&pageid='.
GETPOST(
'pageid',
'int'));
446if ($action ==
'setshowsubcontainers') {
449 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.
GETPOST(
'website',
'alphanohtml').
'&pageid='.
GETPOST(
'pageid',
'int'));
452if ($action ==
'unsetshowsubcontainers') {
454 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.
GETPOST(
'website',
'alphanohtml').
'&pageid='.
GETPOST(
'pageid',
'int'));
458if ($massaction ==
'replace' &&
GETPOST(
'confirmmassaction',
'alpha') && !$searchkey && $usercanedit) {
459 $mode =
'replacesite';
460 $action =
'replacesite';
464if ($action ==
'deletetemplate' && $usercanedit) {
465 $dirthemes = array(
'/doctemplates/websites');
466 if (!empty($conf->modules_parts[
'websitetemplates'])) {
467 foreach ($conf->modules_parts[
'websitetemplates'] as $reldir) {
468 $dirthemes = array_merge($dirthemes, (array) ($reldir.
'doctemplates/websites'));
471 $dirthemes = array_unique($dirthemes);
475 $mode =
'importsite';
476 $action =
'importsite';
478 if (count($dirthemes)) {
480 foreach ($dirthemes as $dir) {
482 $dirtheme = DOL_DATA_ROOT.$dir;
483 if (is_dir($dirtheme)) {
484 $templateuserfile =
GETPOST(
'templateuserfile');
485 $imguserfile = preg_replace(
'/\.zip$/',
'', $templateuserfile).
'.jpg';
494if ($massaction ==
'setcategory' &&
GETPOST(
'confirmmassaction',
'alpha') && $usercanedit) {
500 $categoryid =
GETPOST(
'setcategory',
'int');
501 if ($categoryid > 0) {
504 $category->fetch($categoryid);
506 foreach ($toselect as $tmpid) {
507 $tmpwebsitepage->id = $tmpid;
508 $result = $category->add_type($tmpwebsitepage,
'website_page');
509 if ($result < 0 && $result != -3) {
523 setEventMessages($langs->trans(
"RecordsModified", $nbupdate),
null,
'mesgs');
529 $listofpages =
getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters, -1);
533if ($massaction ==
'delcategory' &&
GETPOST(
'confirmmassaction',
'alpha') && $usercanedit) {
539 $categoryid =
GETPOST(
'setcategory',
'int');
540 if ($categoryid > 0) {
543 $category->fetch($categoryid);
545 foreach ($toselect as $tmpid) {
546 $tmpwebsitepage->id = $tmpid;
547 $result = $category->del_type($tmpwebsitepage,
'website_page');
548 if ($result < 0 && $result != -3) {
562 setEventMessages($langs->trans(
"RecordsModified", $nbupdate),
null,
'mesgs');
568 $listofpages =
getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters, -1);
572if ($massaction ==
'replace' &&
GETPOST(
'confirmmassaction',
'alpha') && $usercanedit) {
573 $replacestring =
GETPOST(
'replacestring',
'none');
575 $dolibarrdataroot = preg_replace(
'/([\\/]+)$/i',
'', DOL_DATA_ROOT);
576 $allowimportsite =
true;
577 if (
dol_is_file($dolibarrdataroot.
'/installmodules.lock')) {
578 $allowimportsite =
false;
581 if (!$allowimportsite) {
585 $message = $langs->trans(
'InstallModuleFromWebHasBeenDisabledContactUs');
588 $message = $langs->trans(
"InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.
'/installmodules.lock');
591 } elseif (empty($user->rights->website->writephp)) {
593 } elseif (!$replacestring) {
598 foreach ($toselect as $keyselected) {
599 $objectpage = $listofpages[
'list'][$keyselected];
600 if ($objectpage->pageurl) {
601 dol_syslog(
"Replace string into page ".$objectpage->pageurl);
603 if (
GETPOST(
'optioncontent',
'aZ09')) {
604 $objectpage->content = str_replace($searchkey, $replacestring, $objectpage->content);
606 if (
GETPOST(
'optionmeta',
'aZ09')) {
607 $objectpage->title = str_replace($searchkey, $replacestring, $objectpage->title);
608 $objectpage->description = str_replace($searchkey, $replacestring, $objectpage->description);
609 $objectpage->keywords = str_replace($searchkey, $replacestring, $objectpage->keywords);
612 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
613 $filetpl = $pathofwebsite.
'/page'.$objectpage->id.
'.tpl.php';
618 setEventMessages(
'Failed to write file '.basename($filealias),
null,
'errors');
626 $objectpage->update($user);
630 $action =
'createcontainer';
636 if ($nbreplacement > 0) {
637 setEventMessages($langs->trans(
"ReplacementDoneInXPages", $nbreplacement),
null,
'mesgs');
640 $containertype =
GETPOST(
'optioncontainertype',
'aZ09') !=
'-1' ?
GETPOST(
'optioncontainertype',
'aZ09') :
'';
641 $langcode =
GETPOST(
'optionlanguage',
'aZ09');
642 $otherfilters = array();
643 if (
GETPOST(
'optioncategory',
'int') > 0) {
644 $otherfilters[
'category'] =
GETPOST(
'optioncategory',
'int');
648 $listofpages =
getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters);
678if ($action ==
'addsite' && $usercanedit) {
681 if (
GETPOST(
'virtualhost',
'alpha') && !preg_match(
'/^http/',
GETPOST(
'virtualhost',
'alpha'))) {
683 setEventMessages($langs->trans(
'ErrorURLMustStartWithHttp', $langs->transnoentitiesnoconv(
"VirtualHost")),
null,
'errors');
686 if (!$error && !
GETPOST(
'WEBSITE_REF',
'alpha')) {
688 $langs->load(
"errors");
689 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->transnoentities(
"WebsiteName")),
null,
'errors');
691 if (!$error && !preg_match(
'/^[a-z0-9_\-\.]+$/i',
GETPOST(
'WEBSITE_REF',
'alpha'))) {
693 $langs->load(
"errors");
694 setEventMessages($langs->transnoentities(
"ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities(
"Ref")),
null,
'errors');
698 $arrayotherlang = explode(
',',
GETPOST(
'WEBSITE_OTHERLANG',
'alphanohtml'));
699 foreach ($arrayotherlang as $key => $val) {
701 if (empty(trim($val)))
continue;
702 $arrayotherlang[$key] = substr(trim($val), 0, 2);
706 $tmpobject->ref =
GETPOST(
'WEBSITE_REF',
'alpha');
707 $tmpobject->description =
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml');
708 $tmpobject->lang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
709 $tmpobject->otherlang = join(
',', $arrayotherlang);
710 $tmpobject->virtualhost =
GETPOST(
'virtualhost',
'alpha');
712 $result = $tmpobject->create($user);
716 } elseif ($result < 0) {
727 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$tmpobject->ref);
731 $action =
'createsite';
741if ($action ==
'addcontainer' && $usercanedit) {
746 $objectpage->fk_website = $object->id;
748 if (GETPOSTISSET(
'fetchexternalurl')) {
749 $urltograb =
GETPOST(
'externalurl',
'alpha');
750 $grabimages =
GETPOST(
'grabimages',
'alpha');
751 $grabimagesinto =
GETPOST(
'grabimagesinto',
'alpha');
753 include_once DOL_DOCUMENT_ROOT.
'/core/lib/geturl.lib.php';
755 if (empty($urltograb)) {
757 $langs->load(
"errors");
758 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"URL")),
null,
'errors');
759 $action =
'createcontainer';
760 } elseif (!preg_match(
'/^http/', $urltograb)) {
762 $langs->load(
"errors");
763 setEventMessages(
'Error URL must start with http:// or https://',
null,
'errors');
764 $action =
'createcontainer';
770 $urltograbwithoutdomainandparam = preg_replace(
'/^https?:\/\/[^\/]+\/?/i',
'', $urltograb);
772 $urltograbwithoutdomainandparam = preg_replace(
'/\?.*$/',
'', $urltograbwithoutdomainandparam);
773 if (empty($urltograbwithoutdomainandparam) && !preg_match(
'/\/$/', $urltograb)) {
776 $pageurl =
dol_sanitizeFileName(preg_replace(
'/[\/\.]/',
'-', preg_replace(
'/\/+$/',
'', $urltograbwithoutdomainandparam)));
778 $urltograbdirwithoutslash = dirname($urltograb.
'.');
787 $result = $tmpwebsitepage->fetch(0, $object->id, $pageurl);
789 setEventMessages($langs->trans(
"AliasPageAlreadyExists", $pageurl),
null,
'errors');
791 $action =
'createcontainer';
796 $tmp =
getURLContent($urltograb,
'GET',
'', 1, array(), array(
'http',
'https'), 0);
797 if ($tmp[
'curl_error_no']) {
799 setEventMessages(
'Error getting '.$urltograb.
': '.$tmp[
'curl_error_msg'],
null,
'errors');
800 $action =
'createcontainer';
801 } elseif ($tmp[
'http_code'] !=
'200') {
803 setEventMessages(
'Error getting '.$urltograb.
': '.$tmp[
'http_code'],
null,
'errors');
804 $action =
'createcontainer';
823 preg_match(
'/<head>(.*)<\/head>/ims', $tmp[
'content'], $regs);
826 $objectpage->type_container =
'page';
827 $objectpage->pageurl = $pageurl;
828 if (empty($objectpage->pageurl)) {
830 $objectpage->pageurl = $tmpdomain.
'-home';
833 $objectpage->aliasalt =
'';
835 if (preg_match(
'/^(\d+)\-/', basename($urltograb), $regs)) {
836 $objectpage->aliasalt = $regs[1];
840 if (preg_match(
'/<title>(.*)<\/title>/ims', $head, $regtmp)) {
841 $objectpage->title = $regtmp[1];
843 if (preg_match(
'/<meta name="title"[^"]+content="([^"]+)"/ims', $head, $regtmp)) {
844 if (empty($objectpage->title)) {
845 $objectpage->title = $regtmp[1];
848 if (preg_match(
'/<meta name="description"[^"]+content="([^"]+)"/ims', $head, $regtmp)) {
849 $objectpage->description = $regtmp[1];
851 if (preg_match(
'/<meta name="keywords"[^"]+content="([^"]+)"/ims', $head, $regtmp)) {
852 $objectpage->keywords = $regtmp[1];
854 if (preg_match(
'/<html\s+lang="([^"]+)"/ims', $tmp[
'content'], $regtmp)) {
855 $tmplang = explode(
'-', $regtmp[1]);
856 $objectpage->lang = $tmplang[0].($tmplang[1] ?
'_'.strtoupper($tmplang[1]) :
'');
859 $tmp[
'content'] = preg_replace(
'/\s*<meta name="generator"[^"]+content="([^"]+)"\s*\/?>/ims',
'', $tmp[
'content']);
861 $objectpage->content = $tmp[
'content'];
862 $objectpage->content = preg_replace(
'/^.*<body(\s[^>]*)*>/ims',
'', $objectpage->content);
863 $objectpage->content = preg_replace(
'/<\/body(\s[^>]*)*>.*$/ims',
'', $objectpage->content);
871 $objectpage->htmlheader = $tmp[
'content'];
872 $objectpage->htmlheader = preg_replace(
'/^.*<head(\s[^>]*)*>/ims',
'', $objectpage->htmlheader);
873 $objectpage->htmlheader = preg_replace(
'/<\/head(\s[^>]*)*>.*$/ims',
'', $objectpage->htmlheader);
874 $objectpage->htmlheader = preg_replace(
'/<base(\s[^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
875 $objectpage->htmlheader = preg_replace(
'/<meta http-equiv="content-type"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
876 $objectpage->htmlheader = preg_replace(
'/<meta name="robots"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
877 $objectpage->htmlheader = preg_replace(
'/<meta name="title"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
878 $objectpage->htmlheader = preg_replace(
'/<meta name="description"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
879 $objectpage->htmlheader = preg_replace(
'/<meta name="keywords"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
880 $objectpage->htmlheader = preg_replace(
'/<meta name="generator"([^>]*)*>\n*/ims',
'', $objectpage->htmlheader);
883 $objectpage->htmlheader = preg_replace(
'/<title>[^<]*<\/title>\n*/ims',
'', $objectpage->htmlheader);
884 $objectpage->htmlheader = preg_replace(
'/<link[^>]*rel="shortcut[^>]*>\n/ims',
'', $objectpage->htmlheader);
885 $objectpage->htmlheader = preg_replace(
'/<link[^>]*rel="alternate[^>]*>\n/ims',
'', $objectpage->htmlheader);
886 $objectpage->htmlheader = preg_replace(
'/<link[^>]*rel="canonical[^>]*>\n/ims',
'', $objectpage->htmlheader);
889 $tmp = $objectpage->htmlheader;
892 preg_match_all(
'/<script([^\.>]+)src=["\']([^"\'>]+)["\']([^>]*)><\/script>/i', $objectpage->htmlheader, $regs);
893 $errorforsubresource = 0;
894 foreach ($regs[0] as $key => $val) {
895 dol_syslog(
"We will grab the script resource found into script tag ".$regs[2][$key]);
897 $linkwithoutdomain = $regs[2][$key];
898 if (preg_match(
'/^\//', $regs[2][$key])) {
899 $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key];
901 $urltograbbis = $urltograbdirwithoutslash.
'/'.$regs[2][$key];
905 if (preg_match(
'/^http/', $regs[2][$key])) {
906 $urltograbbis = $regs[2][$key];
907 $linkwithoutdomain = preg_replace(
'/^https?:\/\/[^\/]+\//i',
'', $regs[2][$key]);
917 if ($domaintograb != $domaintograbbis) {
949 $tmp = preg_replace(
'/'.preg_quote($regs[0][$key],
'/').
'/i',
'', $tmp);
951 $objectpage->htmlheader = trim($tmp).
"\n";
955 $pagecsscontent =
"\n".
'<style>'.
"\n";
957 preg_match_all(
'/<link([^\.>]+)href=["\']([^"\'>]+\.css[^"\'>]*)["\']([^>]*)>/i', $objectpage->htmlheader, $regs);
958 $errorforsubresource = 0;
959 foreach ($regs[0] as $key => $val) {
960 dol_syslog(
"We will grab the css resources found into link tag ".$regs[2][$key]);
962 $linkwithoutdomain = $regs[2][$key];
963 if (preg_match(
'/^\//', $regs[2][$key])) {
964 $urltograbbis = $urltograbdirrootwithoutslash.$regs[2][$key];
966 $urltograbbis = $urltograbdirwithoutslash.
'/'.$regs[2][$key];
970 if (preg_match(
'/^http/', $regs[2][$key])) {
971 $urltograbbis = $regs[2][$key];
972 $linkwithoutdomain = preg_replace(
'/^https?:\/\/[^\/]+\//i',
'', $regs[2][$key]);
982 if ($domaintograb != $domaintograbbis) {
986 $tmpgeturl =
getURLContent($urltograbbis,
'GET',
'', 1, array(), array(
'http',
'https'), 0);
987 if ($tmpgeturl[
'curl_error_no']) {
988 $errorforsubresource++;
989 setEventMessages(
'Error getting link tag url '.$urltograbbis.
': '.$tmpgeturl[
'curl_error_msg'],
null,
'errors');
990 dol_syslog(
'Error getting '.$urltograbbis.
': '.$tmpgeturl[
'curl_error_msg']);
991 $action =
'createcontainer';
992 } elseif ($tmpgeturl[
'http_code'] !=
'200') {
993 $errorforsubresource++;
994 setEventMessages(
'Error getting link tag url '.$urltograbbis.
': '.$tmpgeturl[
'http_code'],
null,
'errors');
995 dol_syslog(
'Error getting '.$urltograbbis.
': '.$tmpgeturl[
'curl_error_msg']);
996 $action =
'createcontainer';
1005 $tmpgeturl[
'content'] = preg_replace(
'/\/\*\s+CSS content[a-z\s]*\s+\*\//',
'', $tmpgeturl[
'content']);
1015 $pagecsscontent .=
'/* Content of file '.$urltograbbis.
' */'.
"\n";
1017 getAllImages($object, $objectpage, $urltograbbis, $tmpgeturl[
'content'], $action, 1, $grabimages, $grabimagesinto);
1020 include_once DOL_DOCUMENT_ROOT.
'/core/class/lessc.class.php';
1021 $lesscobj =
new Lessc();
1023 $contentforlessc =
".bodywebsite {\n".$tmpgeturl[
'content'].
"\n}\n";
1025 $contentforlessc = $lesscobj->compile($contentforlessc);
1028 $pagecsscontent .= $contentforlessc.
"\n";
1030 }
catch (exception $e) {
1032 dol_syslog(
"Failed to compile the CSS from URL ".$urltograbbis.
" with lessc: ".$e->getMessage(), LOG_WARNING);
1033 $pagecsscontent .= $tmpgeturl[
'content'].
"\n";
1036 $objectpage->htmlheader = preg_replace(
'/'.preg_quote($regs[0][$key],
'/').
'\n*/ims',
'', $objectpage->htmlheader);
1040 $pagecsscontent .=
'</style>';
1044 $objectpage->htmlheader .= trim($pagecsscontent).
"\n";
1048 $tmp = $objectpage->content;
1050 getAllImages($object, $objectpage, $urltograb, $tmp, $action, 1, $grabimages, $grabimagesinto);
1053 $tmp = preg_replace(
'/a href="\/([^\/"]+)\/([^\/"]+)"/',
'a href="/\1-\2.php"', $tmp);
1054 $tmp = preg_replace(
'/a href="\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)"/',
'a href="/\1-\2-\3.php"', $tmp);
1055 $tmp = preg_replace(
'/a href="\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)"/',
'a href="/\1-\2-\3-\4.php"', $tmp);
1058 $objectpage->content = $tmp;
1060 $objectpage->grabbed_from = $urltograb;
1064 $newaliasnames =
'';
1065 if (!$error &&
GETPOST(
'WEBSITE_ALIASALT',
'alpha')) {
1066 $arrayofaliastotest = explode(
',', str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_ALIASALT',
'alpha')));
1068 foreach ($arrayofaliastotest as $aliastotest) {
1069 $aliastotest = trim(preg_replace(
'/\.php$/i',
'', $aliastotest));
1072 if (preg_match(
'/^page\d+/i', $aliastotest)) {
1074 $langs->load(
"errors");
1076 $action =
'createcontainer';
1079 $result = $websitepagetemp->fetch(0, $object->id, $aliastotest);
1082 $langs->load(
"errors");
1083 setEventMessages($websitepagetemp->error, $websitepagetemp->errors,
'errors');
1084 $action =
'createcontainer';
1089 $langs->load(
"errors");
1090 setEventMessages($langs->trans(
"ErrorAPageWithThisNameOrAliasAlreadyExists", $websitepagetemp->pageurl),
null,
'errors');
1091 $action =
'createcontainer';
1094 $newaliasnames .= ($newaliasnames ?
', ' :
'').$aliastotest;
1099 $objectpage->title = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_TITLE',
'alphanohtml'));
1100 $objectpage->type_container =
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'aZ09');
1101 $objectpage->pageurl =
GETPOST(
'WEBSITE_PAGENAME',
'alpha');
1102 $objectpage->aliasalt = $newaliasnames;
1103 $objectpage->description = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml'));
1104 $objectpage->lang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
1105 $objectpage->otherlang =
GETPOST(
'WEBSITE_OTHERLANG',
'aZ09comma');
1106 $objectpage->image =
GETPOST(
'WEBSITE_IMAGE',
'alpha');
1107 $objectpage->keywords = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_KEYWORDS',
'alphanohtml'));
1108 $objectpage->allowed_in_frames =
GETPOST(
'WEBSITE_ALLOWED_IN_FRAMES',
'aZ09');
1109 $objectpage->htmlheader =
GETPOST(
'htmlheader',
'none');
1110 $objectpage->author_alias =
GETPOST(
'WEBSITE_AUTHORALIAS',
'alphanohtml');
1111 $objectpage->object_type =
GETPOST(
'WEBSITE_OBJECTCLASS');
1112 $objectpage->fk_object =
GETPOST(
'WEBSITE_OBJECTID');
1113 $substitutionarray = array();
1114 $substitutionarray[
'__WEBSITE_CREATE_BY__'] = $user->getFullName($langs);
1117 $pageidfortranslation = (
GETPOST(
'pageidfortranslation',
'int') > 0 ?
GETPOST(
'pageidfortranslation',
'int') : 0);
1118 if ($pageidfortranslation > 0) {
1121 $objectpagetmp->fetch($pageidfortranslation);
1122 if ($objectpagetmp->fk_page > 0) {
1123 $pageidfortranslation = $objectpagetmp->fk_page;
1126 $objectpage->fk_page = $pageidfortranslation;
1128 $sample =
GETPOST(
'sample',
'alpha');
1129 if (empty($sample)) {
1133 $pathtosample = DOL_DOCUMENT_ROOT.
'/website/samples/page-sample-'.
dol_sanitizeFileName($sample).
'.html';
1136 $objectpage->content =
make_substitutions(@file_get_contents($pathtosample), $substitutionarray);
1140 if (empty($objectpage->pageurl)) {
1141 $langs->load(
"errors");
1142 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WEBSITE_PAGENAME")),
null,
'errors');
1144 $action =
'createcontainer';
1145 } elseif (!preg_match(
'/^[a-z0-9\-\_]+$/i', $objectpage->pageurl)) {
1146 $langs->load(
"errors");
1147 setEventMessages($langs->transnoentities(
"ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities(
'WEBSITE_PAGENAME')),
null,
'errors');
1149 $action =
'createcontainer';
1151 if (empty($objectpage->title)) {
1152 $langs->load(
"errors");
1153 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WEBSITE_TITLE")),
null,
'errors');
1155 $action =
'createcontainer';
1157 if ($objectpage->fk_page > 0 && empty($objectpage->lang)) {
1158 $langs->load(
"errors");
1159 setEventMessages($langs->trans(
"ErrorLanguageRequiredIfPageIsTranslationOfAnother"),
null,
'errors');
1161 $action =
'createcontainer';
1163 if ($objectpage->fk_page > 0 && !empty($objectpage->lang)) {
1164 if ($objectpage->lang == $website->lang) {
1165 $langs->load(
"errors");
1166 setEventMessages($langs->trans(
"ErrorLanguageMustNotBeSourceLanguageIfPageIsTranslationOfAnother"),
null,
'errors');
1168 $action =
'createcontainer';
1175 $pageid = $objectpage->create($user);
1179 $action =
'createcontainer';
1185 $categoriesarray =
GETPOST(
'categories',
'array');
1186 $result = $objectpage->setCategories($categoriesarray);
1195 if (empty($object->fk_default_home)) {
1196 $object->fk_default_home = $pageid;
1197 $res = $object->update($user);
1202 $filetpl = $pathofwebsite.
'/page'.$pageid.
'.tpl.php';
1205 $result =
dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper, $object);
1215 if (!empty($objectpage->content)) {
1216 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
1217 $filetpl = $pathofwebsite.
'/page'.$objectpage->id.
'.tpl.php';
1222 setEventMessages(
'Failed to write file '.basename($filealias),
null,
'errors');
1231 $action =
'createcontainer';
1238 setEventMessages($langs->trans(
"PageAdded", $objectpage->pageurl),
null,
'mesgs');
1245 $pageid = $objectpage->id;
1250 $pathtomedias = DOL_DATA_ROOT.
'/medias';
1251 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
1253 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
1254 dol_mkdir(dirname($pathtomediasinwebsite));
1255 $result = symlink($pathtomedias, $pathtomediasinwebsite);
1268 $htmlheadercontent =
"<html>\n";
1269 $htmlheadercontent .= $htmlheadercontentdefault;
1270 $htmlheadercontent .=
"</html>";
1275 $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;}";
1280 $jscontent =
"/* JS content (all pages) */\n";
1285 $robotcontent =
"# Robot file. Generated with Dolibarr\nUser-agent: *\nAllow: /public/\nDisallow: /administrator/";
1290 $htaccesscontent =
"# Order allow,deny\n# Deny from all";
1295 $manifestjsoncontent =
"";
1300 $readmecontent =
"Website generated by Dolibarr ERP CRM";
1305 $licensecontent =
"MIT License";
1309 $action =
'preview';
1314if ($action ==
'confirm_deletesite' && $confirm ==
'yes' && $permissiontodelete) {
1319 $res = $object->fetch(
GETPOST(
'id',
'int'));
1323 $res = $object->delete($user);
1330 if (
GETPOST(
'delete_also_js',
'alpha') ==
'on') {
1331 $pathofwebsitejs = DOL_DATA_ROOT.
'/medias/js/'.$object->ref;
1335 if (
GETPOST(
'delete_also_medias',
'alpha') ==
'on') {
1336 $pathofwebsitemedias = DOL_DATA_ROOT.
'/medias/image/'.$object->ref;
1344 setEventMessages($langs->trans(
"SiteDeleted", $object->ref),
null,
'mesgs');
1346 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?id='.$object->id);
1355if (GETPOSTISSET(
'pageid') && $action ==
'delete' && $permissiontodelete && !
GETPOST(
'file_manager')) {
1360 $res = $object->fetch(0, $websitekey);
1363 $res = $objectpage->fetch($pageid, $object->id);
1366 $res = $objectpage->delete($user);
1375 setEventMessages($langs->trans(
"PageDeleted", $objectpage->pageurl, $websitekey),
null,
'mesgs');
1377 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$websitekey);
1385if (!GETPOSTISSET(
'pageid')) {
1386 $objectclass =
'WebsitePage';
1390 if (!$error && ($massaction ==
'delete' || ($action ==
'delete' && $confirm ==
'yes')) && $permissiontodelete) {
1393 $objecttmp =
new $objectclass($db);
1395 foreach ($toselect as $toselectid) {
1396 $result = $objecttmp->fetch($toselectid);
1398 $result = $objecttmp->delete($user);
1427 if ($action ==
'delete') {
1428 $mode =
'replacesite';
1429 $action =
'replacesite';
1431 $containertype =
GETPOST(
'optioncontainertype',
'aZ09') !=
'-1' ?
GETPOST(
'optioncontainertype',
'aZ09') :
'';
1432 $langcode =
GETPOST(
'optionlanguage',
'aZ09');
1433 $otherfilters = array();
1434 if (
GETPOST(
'optioncategory',
'int') > 0) {
1435 $otherfilters[
'category'] =
GETPOST(
'optioncategory',
'int');
1438 $listofpages =
getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters);
1443if ($action ==
'updatecss' && $usercanedit) {
1446 $action =
'editcss';
1448 $res = $object->fetch(0, $websitekey);
1451 if (GETPOSTISSET(
'virtualhost')) {
1452 $tmpvirtualhost = preg_replace(
'/\/$/',
'',
GETPOST(
'virtualhost',
'alpha'));
1453 if ($tmpvirtualhost && !preg_match(
'/^http/', $tmpvirtualhost)) {
1455 setEventMessages($langs->trans(
'ErrorURLMustStartWithHttp', $langs->transnoentitiesnoconv(
"VirtualHost")),
null,
'errors');
1456 $action =
'editcss';
1460 $arrayotherlang = explode(
',',
GETPOST(
'WEBSITE_OTHERLANG',
'alphanohtml'));
1461 foreach ($arrayotherlang as $key => $val) {
1463 if (empty(trim($val)))
continue;
1464 $arrayotherlang[$key] = substr(trim($val), 0, 2);
1467 $object->virtualhost = $tmpvirtualhost;
1468 $object->lang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
1469 $object->otherlang = join(
',', $arrayotherlang);
1470 $object->use_manifest =
GETPOST(
'use_manifest',
'alpha');
1472 $result = $object->update($user);
1476 $action =
'editcss';
1482 if (($_FILES[
'addedfile'][
"name"] !=
'')) {
1483 $uploadfolder = $conf->website->dir_output.
'/'.$websitekey;
1484 if ($_FILES[
'addedfile'][
'type'] !=
'image/png') {
1488 $filetoread = realpath(
dol_osencode($_FILES[
'addedfile'][
'tmp_name']));
1489 $filesize = getimagesize($filetoread);
1490 if ($filesize[0] != $filesize[1]) {
1492 setEventMessages($langs->trans(
'ErrorFaviconMustBeASquaredImage'), array(),
'errors');
1494 if (! $error && ($filesize[0] != 16 && $filesize[0] != 32 && $filesize[0] != 64)) {
1503 if (!GETPOSTISSET(
'updateandstay')) {
1504 $action =
'preview';
1506 $backtopage = preg_replace(
'/searchstring=[^&]*/',
'', $backtopage);
1507 header(
"Location: ".$backtopage);
1511 $action =
'editcss';
1530 $dataposted = trim(
GETPOST(
'WEBSITE_HTML_HEADER',
'none'));
1531 $dataposted = preg_replace(array(
'/<html>\n*/ims',
'/<\/html>\n*/ims'), array(
'',
''), $dataposted);
1532 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1535 $phpfullcodestringold =
'';
1539 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1541 if (!$errorphpcheck) {
1542 $htmlheadercontent =
'';
1554 $htmlheadercontent .= $dataposted.
"\n";
1569 $dataposted = trim(
GETPOST(
'WEBSITE_CSS_INLINE',
'none'));
1570 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1573 $phpfullcodestringold =
'';
1577 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1579 if (!$errorphpcheck) {
1582 $csscontent .=
"<?php // BEGIN PHP\n";
1583 $csscontent .=
'$websitekey=basename(__DIR__);'.
"\n";
1584 $csscontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded\n";
1585 $csscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
1586 $csscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
1587 $csscontent .=
"ob_start();\n";
1588 $csscontent .=
"if (! headers_sent()) { /* because file is included inline when in edit mode and we don't want warning */ \n";
1589 $csscontent .=
"header('Cache-Control: max-age=3600, public, must-revalidate');\n";
1590 $csscontent .=
"header('Content-type: text/css');\n";
1591 $csscontent .=
"}\n";
1592 $csscontent .=
"// END PHP ?>\n";
1594 $csscontent .= $dataposted.
"\n";
1596 $csscontent .=
'<?php // BEGIN PHP'.
"\n";
1597 $csscontent .=
'$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "css");'.
"\n";
1598 $csscontent .=
"// END PHP ?>\n";
1600 dol_syslog(
"Save css content into ".$filecss);
1612 $dataposted = trim(
GETPOST(
'WEBSITE_JS_INLINE',
'none'));
1613 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1616 $phpfullcodestringold =
'';
1620 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1622 if (!$errorphpcheck) {
1625 $jscontent .=
"<?php // BEGIN PHP\n";
1626 $jscontent .=
'$websitekey=basename(__DIR__);'.
"\n";
1627 $jscontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded\n";
1628 $jscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
1629 $jscontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
1630 $jscontent .=
"ob_start();\n";
1631 $jscontent .=
"header('Cache-Control: max-age=3600, public, must-revalidate');\n";
1632 $jscontent .=
"header('Content-type: application/javascript');\n";
1633 $jscontent .=
"// END PHP ?>\n";
1635 $jscontent .= $dataposted.
"\n";
1637 $jscontent .=
'<?php // BEGIN PHP'.
"\n";
1638 $jscontent .=
'$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "js");'.
"\n";
1639 $jscontent .=
"// END PHP ?>\n";
1650 $dataposted = trim(
GETPOST(
'WEBSITE_ROBOT',
'restricthtml'));
1651 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1654 $phpfullcodestringold =
'';
1658 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1660 if (!$errorphpcheck) {
1673 $robotcontent .= $dataposted.
"\n";
1688 $dataposted = trim(
GETPOST(
'WEBSITE_HTACCESS',
'restricthtml'));
1689 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1692 $phpfullcodestringold =
'';
1696 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1698 if (!$errorphpcheck) {
1699 $htaccesscontent =
'';
1700 $htaccesscontent .= $dataposted.
"\n";
1712 $dataposted = trim(
GETPOST(
'WEBSITE_MANIFEST_JSON',
'none'));
1713 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1716 $phpfullcodestringold =
'';
1720 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1722 if (!$errorphpcheck) {
1723 $manifestjsoncontent =
'';
1725 $manifestjsoncontent .=
"<?php // BEGIN PHP\n";
1726 $manifestjsoncontent .=
'$websitekey=basename(__DIR__);'.
"\n";
1727 $manifestjsoncontent .=
"if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded\n";
1728 $manifestjsoncontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
1729 $manifestjsoncontent .=
"require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
1730 $manifestjsoncontent .=
"ob_start();\n";
1731 $manifestjsoncontent .=
"header('Cache-Control: max-age=3600, public, must-revalidate');\n";
1732 $manifestjsoncontent .=
"header('Content-type: application/manifest+json');\n";
1733 $manifestjsoncontent .=
"// END PHP ?>\n";
1735 $manifestjsoncontent .= $dataposted.
"\n";
1737 $manifestjsoncontent .=
'<?php // BEGIN PHP'.
"\n";
1738 $manifestjsoncontent .=
'$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "manifest");'.
"\n";
1739 $manifestjsoncontent .=
"// END PHP ?>\n";
1744 setEventMessages(
'Failed to write file '.$filemanifestjson,
null,
'errors');
1750 $dataposted = trim(
GETPOST(
'WEBSITE_README',
'restricthtml'));
1751 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1754 $phpfullcodestringold =
'';
1758 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1760 if (!$errorphpcheck) {
1761 $readmecontent =
'';
1773 $readmecontent .= $dataposted.
"\n";
1788 $dataposted = trim(
GETPOST(
'WEBSITE_LICENSE',
'restricthtml'));
1789 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
1792 $phpfullcodestringold =
'';
1796 $errorphpcheck =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
1798 if (!$errorphpcheck) {
1799 $licensecontent =
'';
1811 $licensecontent .= $dataposted.
"\n";
1835 if (!GETPOSTISSET(
'updateandstay')) {
1836 $action =
'preview';
1838 $backtopage = preg_replace(
'/searchstring=[^&]*/',
'', $backtopage);
1839 header(
"Location: ".$backtopage);
1843 $action =
'editcss';
1850if ($action ==
'setashome' && $usercanedit) {
1852 $object->fetch(0, $websitekey);
1855 $object->fk_default_home = $pageid;
1856 $res = $object->update($user);
1865 $filetpl = $pathofwebsite.
'/page'.$pageid.
'.tpl.php';
1868 $result =
dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper, $object);
1876 $action =
'preview';
1883if ($action ==
'updatemeta' && $usercanedit) {
1886 $result = $object->fetch(0, $websitekey);
1889 $objectpage->fk_website = $object->id;
1892 if (!preg_match(
'/^[a-z0-9\-\_]+$/i',
GETPOST(
'WEBSITE_PAGENAME',
'alpha'))) {
1894 $langs->load(
"errors");
1895 setEventMessages($langs->transnoentities(
"ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities(
'WEBSITE_PAGENAME')),
null,
'errors');
1896 $action =
'editmeta';
1899 $res = $objectpage->fetch($pageid, $object->id);
1902 setEventMessages(
'Page not found '.$objectpage->error, $objectpage->errors,
'errors');
1906 if (!$error &&
GETPOST(
'WEBSITE_PAGENAME',
'alpha')) {
1908 $result = $websitepagetemp->fetch(-1 * $objectpage->id, $object->id,
GETPOST(
'WEBSITE_PAGENAME',
'alpha'));
1911 $langs->load(
"errors");
1912 setEventMessages($websitepagetemp->error, $websitepagetemp->errors,
'errors');
1913 $action =
'editmeta';
1917 $langs->load(
"errors");
1918 setEventMessages($langs->trans(
"ErrorAPageWithThisNameOrAliasAlreadyExists", $websitepagetemp->pageurl),
null,
'errors');
1919 $action =
'editmeta';
1923 $newaliasnames =
'';
1924 if (!$error &&
GETPOST(
'WEBSITE_ALIASALT',
'alpha')) {
1925 $arrayofaliastotest = explode(
',', str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_ALIASALT',
'alpha')));
1928 foreach ($arrayofaliastotest as $aliastotest) {
1929 $aliastotest = trim(preg_replace(
'/\.php$/i',
'', $aliastotest));
1932 if (preg_match(
'/^page\d+/i', $aliastotest)) {
1934 $langs->load(
"errors");
1936 $action =
'editmeta';
1939 $result = $websitepagetemp->fetch(-1 * $objectpage->id, $object->id, $aliastotest);
1942 $langs->load(
"errors");
1943 setEventMessages($websitepagetemp->error, $websitepagetemp->errors,
'errors');
1944 $action =
'editmeta';
1949 $langs->load(
"errors");
1950 setEventMessages($langs->trans(
"ErrorAPageWithThisNameOrAliasAlreadyExists", $websitepagetemp->pageurl),
null,
'errors');
1951 $action =
'editmeta';
1954 $newaliasnames .= ($newaliasnames ?
', ' :
'').$aliastotest;
1960 $objectpage->old_object = clone $objectpage;
1962 $objectpage->title = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_TITLE',
'alphanohtml'));
1963 $objectpage->type_container =
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'aZ09');
1964 $objectpage->pageurl =
GETPOST(
'WEBSITE_PAGENAME',
'alpha');
1965 $objectpage->aliasalt = $newaliasnames;
1966 $objectpage->lang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
1967 $objectpage->otherlang =
GETPOST(
'WEBSITE_OTHERLANG',
'aZ09comma');
1968 $objectpage->description = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml'));
1969 $objectpage->image =
GETPOST(
'WEBSITE_IMAGE',
'alpha');
1970 $objectpage->keywords = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_KEYWORDS',
'alphanohtml'));
1971 $objectpage->allowed_in_frames =
GETPOST(
'WEBSITE_ALLOWED_IN_FRAMES',
'aZ09');
1972 $objectpage->htmlheader = trim(
GETPOST(
'htmlheader',
'none'));
1973 $objectpage->fk_page = (
GETPOST(
'pageidfortranslation',
'int') > 0 ?
GETPOST(
'pageidfortranslation',
'int') : 0);
1974 $objectpage->author_alias = trim(
GETPOST(
'WEBSITE_AUTHORALIAS',
'alphanohtml'));
1975 $objectpage->object_type =
GETPOST(
'WEBSITE_OBJECTCLASS',
'alpha');
1976 $objectpage->fk_object =
GETPOST(
'WEBSITE_OBJECTID',
'aZ09');
1978 $newdatecreation =
dol_mktime(
GETPOST(
'datecreationhour',
'int'),
GETPOST(
'datecreationmin',
'int'),
GETPOST(
'datecreationsec',
'int'),
GETPOST(
'datecreationmonth',
'int'),
GETPOST(
'datecreationday',
'int'),
GETPOST(
'datecreationyear',
'int'));
1979 if ($newdatecreation) {
1980 $objectpage->date_creation = $newdatecreation;
1983 $res = $objectpage->update($user);
1985 $langs->load(
"errors");
1986 if ($db->lasterrno ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
1988 $langs->load(
"errors");
1989 setEventMessages($langs->trans(
"ErrorAPageWithThisNameOrAliasAlreadyExists"),
null,
'errors');
1990 $action =
'editmeta';
1993 $langs->load(
"errors");
1995 $action =
'editmeta';
2002 $categoriesarray =
GETPOST(
'categories',
'array');
2003 $result = $objectpage->setCategories($categoriesarray);
2017 $filemaster = $pathofwebsite.
'/master.inc.php';
2018 $fileoldalias = $pathofwebsite.
'/'.$objectpage->old_object->pageurl.
'.php';
2019 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
2030 if (!empty($fileoldalias)) {
2031 dol_syslog(
"We delete old alias page name=".$fileoldalias.
" to build a new alias page=".$filealias);
2035 if (empty($objectpage->lang) || !in_array($objectpage->lang, explode(
',', $object->otherlang))) {
2036 $dirname = dirname($fileoldalias);
2037 $filename = basename($fileoldalias);
2038 $sublangs = explode(
',', $object->otherlang);
2039 foreach ($sublangs as $sublang) {
2043 if (empty(trim($sublang)))
continue;
2044 $fileoldaliassub = $dirname.
'/'.$sublang.
'/'.$filename;
2050 if (!empty($objectpage->old_object->aliasalt)) {
2051 $tmpaltaliases = explode(
',', $objectpage->old_object->aliasalt);
2052 if (is_array($tmpaltaliases)) {
2053 foreach ($tmpaltaliases as $tmpaliasalt) {
2054 dol_syslog(
"We delete old alt alias pages name=".trim($tmpaliasalt));
2058 if (empty($objectpage->lang) || !in_array($objectpage->lang, explode(
',', $object->otherlang))) {
2059 $dirname = dirname($pathofwebsite.
'/'.trim($tmpaliasalt).
'.php');
2060 $filename = basename($pathofwebsite.
'/'.trim($tmpaliasalt).
'.php');
2061 $sublangs = explode(
',', $object->otherlang);
2062 foreach ($sublangs as $sublang) {
2066 if (empty(trim($sublang)))
continue;
2067 $fileoldaliassub = $dirname.
'/'.$sublang.
'/'.$filename;
2081 if (!empty($objectpage->aliasalt)) {
2082 $tmpaltaliases = explode(
',', $objectpage->aliasalt);
2083 if (is_array($tmpaltaliases)) {
2084 foreach ($tmpaltaliases as $tmpaliasalt) {
2085 if (trim($tmpaliasalt)) {
2086 $filealias = $pathofwebsite.
'/'.trim($tmpaliasalt).
'.php';
2089 setEventMessages(
'Failed to write file '.basename($filealias),
null,
'errors');
2102 if (!GETPOSTISSET(
'updateandstay')) {
2105 $action =
'preview';
2107 $action =
'editmeta';
2113 $action =
'preview';
2119if ($usercanedit && (($action ==
'updatesource' || $action ==
'updatecontent' || $action ==
'confirm_createfromclone' || $action ==
'confirm_createpagefromclone')
2120 || ($action ==
'preview' && (
GETPOST(
'refreshsite') ||
GETPOST(
'refreshpage') ||
GETPOST(
'preview'))))) {
2121 $object->fetch(0, $websitekey);
2124 if ($action ==
'confirm_createfromclone') {
2127 $objectnew =
new Website($db);
2128 $result = $objectnew->createFromClone($user,
GETPOST(
'id',
'int'),
GETPOST(
'siteref',
'aZ09'), (
GETPOST(
'newlang',
'aZ09') ?
GETPOST(
'newlang',
'aZ09') :
''));
2133 $action =
'preview';
2137 $object = $objectnew;
2139 $pageid = $object->fk_default_home;
2140 $websitekey =
GETPOST(
'siteref',
'aZ09');
2146 if ($action ==
'confirm_createpagefromclone') {
2147 $istranslation = (
GETPOST(
'is_a_translation',
'aZ09') ==
'on' ? 1 : 0);
2149 if ($istranslation) {
2150 if (
GETPOST(
'newlang',
'aZ09') == $objectpage->lang || !
GETPOST(
'newlang',
'aZ09')) {
2152 setEventMessages($langs->trans(
"LanguageMustNotBeSameThanClonedPage"),
null,
'errors');
2153 $action =
'preview';
2155 if (
GETPOST(
'newwebsite',
'int') != $object->id) {
2157 setEventMessages($langs->trans(
"WebsiteMustBeSameThanClonedPageIfTranslation"),
null,
'errors');
2158 $action =
'preview';
2165 $newwebsiteid =
GETPOST(
'newwebsite',
'int');
2166 $pathofwebsitenew = $pathofwebsite;
2168 $tmpwebsite =
new Website($db);
2169 if ($newwebsiteid > 0 && $newwebsiteid != $object->id) {
2170 $tmpwebsite->fetch($newwebsiteid);
2171 $pathofwebsitenew = $dolibarr_main_data_root.($conf->entity > 1 ?
'/'.$conf->entity :
'').
'/website/'.$tmpwebsite->ref;
2173 $tmpwebsite = $object;
2177 $resultpage = $objectpage->createFromClone($user, $pageid,
GETPOST(
'newpageurl',
'aZ09'), (
GETPOST(
'newlang',
'aZ09') ?
GETPOST(
'newlang',
'aZ09') :
''), $istranslation, $newwebsiteid,
GETPOST(
'newtitle',
'alphanohtml'));
2178 if ($resultpage < 0) {
2181 $action =
'createpagefromclone';
2185 $filetpl = $pathofwebsitenew.
'/page'.$resultpage->id.
'.tpl.php';
2186 $fileindex = $pathofwebsitenew.
'/index.php';
2187 $filewrapper = $pathofwebsitenew.
'/wrapper.php';
2196 if (empty($newwebsiteid) || $newwebsiteid == $object->id) {
2197 $pageid = $resultpage->id;
2209 $pathtomedias = DOL_DATA_ROOT.
'/medias';
2210 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
2212 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
2213 dol_mkdir(dirname($pathtomediasinwebsite));
2214 $result = symlink($pathtomedias, $pathtomediasinwebsite);
2223 $objectpage->fk_website = $object->id;
2226 $res = $objectpage->fetch($pageid);
2229 if ($object->fk_default_home > 0) {
2230 $res = $objectpage->fetch($object->fk_default_home);
2233 $res = $objectpage->fetch(0, $object->id);
2238 if (!$error && $res > 0) {
2239 if ($action ==
'updatesource' || $action ==
'updatecontent') {
2244 $objectpage->content =
GETPOST(
'PAGE_CONTENT',
'none');
2249 $error =
checkPHPCode($phpfullcodestringold, $phpfullcodestring);
2252 if ($action ==
'updatesource') {
2253 $action =
'editsource';
2255 if ($action ==
'updatecontent') {
2256 $action =
'editcontent';
2261 $objectpage->content = preg_replace(
'/<head>.*<\/head>/ims',
'', $objectpage->content);
2265 $res = $objectpage->update($user);
2269 if ($action ==
'updatesource') {
2270 $action =
'editsource';
2272 if ($action ==
'updatecontent') {
2273 $action =
'editcontent';
2280 $filemaster = $pathofwebsite.
'/master.inc.php';
2282 $filealias = $pathofwebsite.
'/'.$objectpage->pageurl.
'.php';
2290 setEventMessages(
'Failed to write the master file file '.$filemaster,
null,
'errors');
2314 setEventMessages(
'Failed to write the alias file '.basename($filealias),
null,
'errors');
2322 if (!GETPOSTISSET(
'updateandstay')) {
2324 header(
"Location: ".$backtopage);
2327 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$websitekey.
'&pageid='.$pageid);
2331 if ($action ==
'updatesource') {
2332 $action =
'editsource';
2334 if ($action ==
'updatecontent') {
2335 $action =
'editcontent';
2340 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$websitekey.
'&pageid='.$pageid);
2347 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$websitekey.
'&pageid='.$pageid);
2352 if (empty($websitekey) || $websitekey ==
'-1') {
2353 setEventMessages($langs->trans(
"NoWebSiteCreateOneFirst"),
null,
'warnings');
2356 setEventMessages($langs->trans(
"YouCanCreatePageOrImportTemplate"),
null,
'warnings');
2363if ($action ==
'exportsite' && !empty($user->rights->website->export)) {
2364 $fileofzip = $object->exportWebSite();
2367 $file_name = basename($fileofzip);
2369 header(
"Content-Type: application/zip");
2370 header(
"Content-Disposition: attachment; filename=".$file_name);
2371 header(
"Content-Length: ".filesize($fileofzip));
2373 readfile($fileofzip);
2377 $action =
'preview';
2382if ($action ==
'regeneratesite' && $usercanedit) {
2384 $pathtomedias = DOL_DATA_ROOT.
'/medias';
2385 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
2387 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
2388 dol_mkdir(dirname($pathtomediasinwebsite));
2389 $result = symlink($pathtomedias, $pathtomediasinwebsite);
2391 $langs->load(
"errors");
2392 setEventMessages($langs->trans(
"ErrorFailedToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias),
null,
'errors');
2393 $action =
'preview';
2397 $result = $object->rebuildWebSiteFiles();
2399 setEventMessages($langs->trans(
"PagesRegenerated", $result),
null,
'mesgs');
2400 $action =
'preview';
2403 $action =
'preview';
2408if ($action ==
'importsiteconfirm' && $usercanedit) {
2409 $dolibarrdataroot = preg_replace(
'/([\\/]+)$/i',
'', DOL_DATA_ROOT);
2410 $allowimportsite =
true;
2411 if (
dol_is_file($dolibarrdataroot.
'/installmodules.lock')) {
2412 $allowimportsite =
false;
2415 if ($allowimportsite) {
2416 if (empty($_FILES) && !GETPOSTISSET(
'templateuserfile')) {
2417 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"File")),
null,
'errors');
2418 $action =
'importsite';
2420 if (!empty($_FILES) || GETPOSTISSET(
'templateuserfile')) {
2422 $pathtomedias = DOL_DATA_ROOT.
'/medias';
2423 $pathtomediasinwebsite = $pathofwebsite.
'/medias';
2425 dol_syslog(
"Create symlink for ".$pathtomedias.
" into name ".$pathtomediasinwebsite);
2426 dol_mkdir(dirname($pathtomediasinwebsite));
2427 $result = symlink($pathtomedias, $pathtomediasinwebsite);
2429 $langs->load(
"errors");
2430 setEventMessages($langs->trans(
"ErrorFailedToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias),
null,
'errors');
2431 $action =
'importsite';
2436 if (GETPOSTISSET(
'templateuserfile')) {
2438 $fileofzip = DOL_DATA_ROOT.
'/doctemplates/websites/'.
GETPOST(
'templateuserfile',
'alpha');
2439 } elseif (!empty($_FILES) && is_array($_FILES[
'userfile'])) {
2441 if (is_array($_FILES[
'userfile'][
'tmp_name'])) {
2442 $userfiles = $_FILES[
'userfile'][
'tmp_name'];
2444 $userfiles = array($_FILES[
'userfile'][
'tmp_name']);
2448 foreach ($userfiles as $key => $userfile) {
2449 if (empty($_FILES[
'userfile'][
'tmp_name'][$key])) {
2451 if ($_FILES[
'userfile'][
'error'][$key] == 1 || $_FILES[
'userfile'][
'error'][$key] == 2) {
2453 $action =
'importsite';
2455 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"File")),
null,
'errors');
2456 $action =
'importsite';
2463 $upload_dir = DOL_DATA_ROOT.
'/doctemplates/websites/';
2477 $action =
'importsite';
2480 if (!$error && GETPOSTISSET(
'templateuserfile')) {
2481 $result = $object->importWebSite($fileofzip);
2485 $action =
'importsite';
2488 dolibarr_set_const($db,
'WEBSITE_SUBCONTAINERSINLINE', 1,
'chaine', 0,
'', $conf->entity);
2490 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?website='.$object->ref);
2499 $message = $langs->trans(
'InstallModuleFromWebHasBeenDisabledContactUs');
2502 $message = $langs->trans(
"InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.
'/installmodules.lock');
2508$domainname =
'0.0.0.0:8080';
2509$tempdir = $conf->website->dir_output.
'/'.$websitekey.
'/';
2512if ($action ==
'generatesitemaps' && $usercanedit) {
2514 if ($website->virtualhost) {
2515 $domainname = $website->virtualhost;
2517 if (! preg_match(
'/^http/i', $domainname)) {
2518 $domainname =
'https://'.$domainname;
2521 $domtree =
new DOMDocument(
'1.0',
'UTF-8');
2523 $root = $domtree->createElementNS(
'http://www.sitemaps.org/schemas/sitemap/0.9',
'urlset');
2524 $root->setAttributeNS(
'http://www.w3.org/2000/xmlns/',
'xmlns:xhtml',
'http://www.w3.org/1999/xhtml');
2526 $domtree->formatOutput =
true;
2529 $xmlname =
'sitemap.xml';
2531 $sql =
"SELECT wp.rowid, wp.type_container , wp.pageurl, wp.lang, wp.fk_page, wp.tms as tms,";
2532 $sql .=
" w.virtualhost, w.fk_default_home";
2533 $sql .=
" FROM ".MAIN_DB_PREFIX.
"website_page as wp, ".MAIN_DB_PREFIX.
"website as w";
2534 $sql .=
" WHERE wp.type_container IN ('page', 'blogpost')";
2535 $sql .=
" AND wp.fk_website = w.rowid";
2536 $sql .=
" AND wp.status = ".WebsitePage::STATUS_VALIDATED;
2537 $sql .=
" AND wp.pageurl NOT IN ('404', '500', '501', '503')";
2538 $sql .=
" AND w.ref = '".dol_escape_json($websitekey).
"'";
2539 $sql .=
" ORDER BY wp.tms DESC, wp.rowid DESC";
2540 $resql = $db->query($sql);
2542 $num_rows = $db->num_rows($resql);
2543 if ($num_rows > 0) {
2545 while ($i < $num_rows) {
2546 $objp = $db->fetch_object($resql);
2547 $url = $domtree->createElement(
'url');
2549 $shortlangcode =
'';
2551 $shortlangcode = substr($objp->lang, 0, 2);
2553 if (empty($shortlangcode)) {
2554 $shortlangcode = substr($object->lang, 0, 2);
2558 if ($objp->type_container ==
'blogpost') {
2563 $pageurl = $objp->pageurl.
'.php';
2564 if ($objp->fk_default_home == $objp->rowid) {
2567 if ($shortlangcode != substr($object->lang, 0, 2)) {
2568 $pageurl = $shortlangcode.
'/'.$pageurl;
2575 $loc = $domtree->createElement(
'loc', $domainname.
'/'.$pageurl);
2576 $lastmod = $domtree->createElement(
'lastmod',
dol_print_date($db->jdate($objp->tms),
'dayrfc',
'gmt'));
2577 $priority = $domtree->createElement(
'priority',
'1');
2579 $url->appendChild($loc);
2580 $url->appendChild($lastmod);
2582 if (!empty($conf->global->WEBSITE_SITEMAPS_ADD_WEEKLY_FREQ)) {
2583 $changefreq = $domtree->createElement(
'changefreq',
'weekly');
2584 $url->appendChild($changefreq);
2587 if ($objp->fk_default_home == $objp->rowid) {
2588 $url->appendChild($priority);
2592 if ($object->isMultiLang()) {
2593 $alternatefound = 0;
2596 $translationof = $objp->fk_page;
2597 if ($translationof) {
2599 $tmppage->fetch($translationof);
2600 if ($tmppage->id > 0) {
2601 $tmpshortlangcode =
'';
2602 if ($tmppage->lang) {
2603 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'', $tmppage->lang);
2605 if (empty($tmpshortlangcode)) {
2606 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'', $object->lang);
2608 if ($tmpshortlangcode != $shortlangcode) {
2609 $xhtmllink = $domtree->createElement(
'xhtml:link',
'');
2610 $xhtmllink->setAttribute(
"rel",
"alternate");
2611 $xhtmllink->setAttribute(
"hreflang", $tmpshortlangcode);
2612 $xhtmllink->setAttribute(
"href", $domainname.($objp->fk_default_home == $tmppage->id ?
'/' : (($tmpshortlangcode != substr($object->lang, 0, 2)) ?
'/'.$tmpshortlangcode :
'').
'/'.$tmppage->pageurl.
'.php'));
2613 $url->appendChild($xhtmllink);
2621 $sql =
'SELECT rowid as id, lang, pageurl from '.MAIN_DB_PREFIX.
'website_page';
2622 $sql .=
" WHERE status = ".((int) WebsitePage::STATUS_VALIDATED).
' AND fk_page IN ('.$db->sanitize($objp->rowid.($translationof ?
", ".$translationof :
"")).
")";
2623 $resqlhastrans = $db->query($sql);
2624 if ($resqlhastrans) {
2625 $num_rows_hastrans = $db->num_rows($resqlhastrans);
2626 if ($num_rows_hastrans > 0) {
2627 while ($objhastrans = $db->fetch_object($resqlhastrans)) {
2628 $tmpshortlangcode =
'';
2629 if ($objhastrans->lang) {
2630 $tmpshortlangcode = preg_replace(
'/[_-].*$/',
'', $objhastrans->lang);
2632 if ($tmpshortlangcode != $shortlangcode) {
2633 $xhtmllink = $domtree->createElement(
'xhtml:link',
'');
2634 $xhtmllink->setAttribute(
"rel",
"alternate");
2635 $xhtmllink->setAttribute(
"hreflang", $tmpshortlangcode);
2636 $xhtmllink->setAttribute(
"href", $domainname.($objp->fk_default_home == $objhastrans->id ?
'/' : (($tmpshortlangcode != substr($object->lang, 0, 2) ?
'/'.$tmpshortlangcode :
'')).
'/'.$objhastrans->pageurl.
'.php'));
2637 $url->appendChild($xhtmllink);
2647 if ($alternatefound) {
2649 $xhtmllink = $domtree->createElement(
'xhtml:link',
'');
2650 $xhtmllink->setAttribute(
"rel",
"alternate");
2651 $xhtmllink->setAttribute(
"hreflang", $shortlangcode);
2652 $xhtmllink->setAttribute(
"href", $domainname.
'/'.$pageurl);
2653 $url->appendChild($xhtmllink);
2669 $root->appendChild($url);
2675 if ($addrsswrapper &&
getDolGlobalInt(
'WEBSITE_ADD_RSS_FEED_INTO_SITEMAP')) {
2676 $url = $domtree->createElement(
'url');
2678 $pageurl =
'wrapper.php?rss=1';
2681 $loc = $domtree->createElement(
'loc', $domainname.
'/'.$pageurl);
2682 $lastmod = $domtree->createElement(
'lastmod',
dol_print_date($db->jdate(
dol_now()),
'dayrfc',
'gmt'));
2684 $url->appendChild($loc);
2685 $url->appendChild($lastmod);
2687 if (!empty($conf->global->WEBSITE_SITEMAPS_ADD_WEEKLY_FREQ)) {
2688 $changefreq = $domtree->createElement(
'changefreq',
'weekly');
2689 $url->appendChild($changefreq);
2692 $root->appendChild($url);
2695 $domtree->appendChild($root);
2697 if ($domtree->save($tempdir.$xmlname)) {
2699 setEventMessages($langs->trans(
"SitemapGenerated", $xmlname),
null,
'mesgs');
2709 $robotcontent = @file_get_contents($filerobot);
2710 $result = preg_replace(
'/<?php \/\/ BEGIN PHP[^?]END PHP ?>\n/ims',
'', $robotcontent);
2712 $robotcontent = $result;
2714 $robotsitemap =
"Sitemap: ".$domainname.
"/".$xmlname;
2715 $result = strpos($robotcontent,
'Sitemap: ');
2717 $result = preg_replace(
'/Sitemap:.*/', $robotsitemap, $robotcontent);
2718 $robotcontent = $result ? $result : $robotcontent;
2720 $robotcontent .= $robotsitemap.
"\n";
2727 $action =
'preview';
2735$form =
new Form($db);
2742if ($action ==
'confirmgeneratesitemaps') {
2743 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?website='.urlencode($website->ref), $langs->trans(
'ConfirmSitemapsCreation'), $langs->trans(
'ConfirmGenerateSitemaps', $object->ref),
'generatesitemaps',
'',
"yes", 1);
2744 $action =
'preview';
2746$helpurl =
'EN:Module_Website|FR:Module_Website_FR|ES:Módulo_Website';
2749 '/includes/ace/src/ace.js',
2750 '/includes/ace/src/ext-statusbar.js',
2751 '/includes/ace/src/ext-language_tools.js',
2755$arrayofcss = array();
2760$arrayofjs[] =
'includes/jquery/plugins/blockUI/jquery.blockUI.js';
2761$arrayofjs[] =
'core/js/blockUI.js';
2762if (empty($conf->global->MAIN_ECM_DISABLE_JS)) {
2763 $arrayofjs[] =
"includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js";
2766$moreheadjs .=
'<script type="text/javascript">'.
"\n";
2767$moreheadjs .=
'var indicatorBlockUI = \''.DOL_URL_ROOT.
"/theme/".$conf->theme.
"/img/working.gif".
'\';
'."\n";
2768$moreheadjs .= '</script>
'."\n";
2770llxHeader($moreheadcss.$moreheadjs, $langs->trans("Website").(empty($website->ref) ? '' : ' -
'.$website->ref), $helpurl, '', 0, 0, $arrayofjs, $arrayofcss, '', '', '<!-- Begin div
class=
"fiche" -->
'."\n".'<div
class=
"fichebutwithotherclass">
');
2773print '<!-- Open form
for all page -->
'."\n";
2774print '<form action=
"'.$_SERVER["PHP_SELF
"].($action == 'file_manager' ? '?uploadform=1': '').'" method=
"POST" enctype=
"multipart/form-data" class=
"websiteformtoolbar">
';
2775print '<input
type=
"hidden" name=
"token" value=
"'.newToken().'">
';
2776print '<input
type=
"hidden" name=
"backtopage" value=
"'.$backtopage.'">
';
2777print '<input
type=
"hidden" name=
"dol_openinpopup" value=
"'.$dol_openinpopup.'">
';
2779if ($action == 'createsite
') {
2780 print '<input
type=
"hidden" name=
"action" value=
"addsite">
';
2782if ($action == 'createcontainer
') {
2783 print '<input
type=
"hidden" name=
"action" value=
"addcontainer">
';
2785if ($action == 'editcss
') {
2786 print '<input
type=
"hidden" name=
"action" value=
"updatecss">
';
2788if ($action == 'editmenu
') {
2789 print '<input
type=
"hidden" name=
"action" value=
"updatemenu">
';
2791if ($action == 'setashome
') {
2792 print '<input
type=
"hidden" name=
"action" value=
"updateashome">
';
2794if ($action == 'editmeta
') {
2795 print '<input
type=
"hidden" name=
"action" value=
"updatemeta">
';
2797if ($action == 'editsource
') {
2798 print '<input
type=
"hidden" name=
"action" value=
"updatesource">
';
2800if ($action == 'editcontent
') {
2801 print '<input
type=
"hidden" name=
"action" value=
"updatecontent">
';
2803if ($action == 'edit
') {
2804 print '<input
type=
"hidden" name=
"action" value=
"update">
';
2806if ($action == 'importsite
') {
2807 print '<input
type=
"hidden" name=
"action" value=
"importsiteconfirm">
';
2809if ($action == 'file_manager
') {
2810 print '<input
type=
"hidden" name=
"action" value=
"file_manager">
';
2813 print '<input
type=
"hidden" name=
"mode" value=
"'.$mode.'">
';
2818// Add a margin under toolbar ?
2820if ($action != 'preview
' && $action != 'editcontent
' && $action != 'editsource
' && !GETPOST('createpagefromclone
', 'alphanohtml
')) {
2821 $style = ' margin-bottom: 5px;
';
2825if (!GETPOST('hide_websitemenu
')) {
2827 if (empty($user->rights->website->write)) {
2828 $disabled = ' disabled=
"disabled"';
2830 $disabledexport = '';
2831 if (empty($user->rights->website->export)) {
2832 $disabledexport = ' disabled=
"disabled"';
2837 $dataroot = DOL_DATA_ROOT.($conf->entity > 1 ? '/
'.$conf->entity : '').'/website/
'.$websitekey;
2838 if (!empty($object->virtualhost)) {
2839 $virtualurl = $object->virtualhost;
2844 if ($object->id > 0) {
2845 $array = $objectpage->fetchAll($object->id, 'ASC,ASC
', 'type_container,pageurl
');
2846 $object->lines = $array;
2848 if (!is_array($array) && $array < 0) {
2849 dol_print_error('', $objectpage->error, $objectpage->errors);
2851 $atleastonepage = (is_array($array) && count($array) > 0);
2853 $websitepage = new WebsitePage($db);
2855 $websitepage->fetch($pageid);
2859 //var_dump($objectpage);exit;
2860 print '<div
class=
"centpercent websitebar'.(GETPOST('dol_openinpopup', 'aZ09') ? ' hiddenforpopup' : '').'">
';
2863 // Toolbar for websites
2866 print '<!-- Toolbar
for website -->
';
2867 if ($action != 'file_manager
') {
2868 print '<div
class=
"websiteselection hideonsmartphoneimp minwidth75 tdoverflowmax100 inline-block">
';
2869 print $langs->trans("Website").':
';
2872 // Button Add new website
2873 $urltocreatenewwebsite = $_SERVER["PHP_SELF"].'?action=createsite
';
2874 print '<span
class=
"websiteselection paddingrightonly">
';
2875 print '<a href=
"'.$urltocreatenewwebsite.'" class=
""'.$disabled.' title=
"'.dol_escape_htmltag($langs->trans("AddWebsite
")).'"><span
class=
"fa fa-plus-circle valignmiddle btnTitle-icon"><span></a>
';
2879 print '<span
class=
"websiteselection nopaddingrightimp">
';
2882 $out .= '<select
name=
"website" class=
"minwidth100 width200 maxwidth150onsmartphone" id=
"website">
';
2883 if (empty($object->records)) {
2884 $out .= '<option value=
"-1"> </option>
';
2887 // Loop on each sites
2889 foreach ($object->records as $key => $valwebsite) {
2890 if (empty($websitekey)) {
2891 if ($action != 'createsite
') {
2892 $websitekey = $valwebsite->ref;
2896 $out .= '<option value=
"'.$valwebsite->ref.'"';
2897 if ($websitekey == $valwebsite->ref) {
2898 $out .= ' selected
'; // To preselect a value
2900 //$outoption = $valwebsite->getLibStatut(3).' '.$valwebsite->ref.' ';
2901 $outoption = (($valwebsite->status == $valwebsite::STATUS_DRAFT) ? '<span
class=
"opacitymedium">
' : '').$valwebsite->ref.(($valwebsite->status == $valwebsite::STATUS_DRAFT) ? '</span>
' : '');
2902 $out .= ' data-html=
"'.dol_escape_htmltag($outoption).'"';
2904 $out .= $valwebsite->ref;
2905 $out .= '</option>
';
2908 $out .= '</select>
';
2909 $out .= ajax_combobox('website
');
2911 if (!empty($conf->use_javascript_ajax)) {
2912 $out .= '<script
type=
"text/javascript">
';
2913 $out .= 'jQuery(document).ready(
function () {
';
2914 $out .= ' jQuery(
"#website").change(
function () {
';
2915 $out .= ' console.log(
"We select "+jQuery(
"#website option:selected").val());
';
2916 $out .= ' if (jQuery(
"#website option:selected").val() == \
'-2\') {';
2917 $out .=
' window.location.href = "'.dol_escape_js($urltocreatenewwebsite).
'";';
2918 $out .=
' } else {';
2919 $out .=
' window.location.href = "'.$_SERVER[
"PHP_SELF"].
'?website="+jQuery("#website option:selected").val();';
2923 $out .=
'</script>';
2930 if (!empty($conf->use_javascript_ajax)) {
2931 print
'<span class="websiteselection">';
2936 if ($website->status == $website::STATUS_DRAFT) {
2937 $text_off =
'Offline';
2938 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>';
2940 $text_off =
'Online';
2941 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>';
2947 if (empty($conf->use_javascript_ajax)) {
2948 print
'<span class="websiteselection">';
2949 print
'<input type="image" class="valignmiddle" src="'.img_picto(
'',
'refresh',
'', 0, 1).
'" name="refreshsite" value="'.$langs->trans(
"Load").
'">';
2954 print
'<span class="websiteselection">';
2956 if ($websitekey && $websitekey !=
'-1' && ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite')) {
2958 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?website='.urlencode($object->ref).
'&pageid='.((int) $pageid).
'&action=editcss&token='.newToken().
'" class="button bordertransp" title="'.
dol_escape_htmltag($langs->trans(
"EditCss")).
'"'.$disabled.
'><span class="fa fa-cog paddingrightonly"></span><span class="hideonsmartphone">'.
dol_escape_htmltag($langs->trans(
"EditCss")).
'</span></a>';
2961 $importlabel = $langs->trans(
"ImportSite");
2962 $exportlabel = $langs->trans(
"ExportSite");
2963 if (!empty($conf->dol_optimize_smallscreen)) {
2964 $importlabel = $langs->trans(
"Import");
2965 $exportlabel = $langs->trans(
"Export");
2968 if ($atleastonepage) {
2969 print
'<input type="submit" class="button bordertransp" disabled="disabled" value="'.dol_escape_htmltag($importlabel).
'" name="importsite">';
2971 print
'<input type="submit" class="button bordertransp"'.$disabled.
' value="'.
dol_escape_htmltag($importlabel).
'" name="importsite">';
2975 print
'<input type="submit" class="button bordertransp"'.$disabledexport.
' value="'.
dol_escape_htmltag($exportlabel).
'" name="exportsite">';
2978 print
'<input type="submit" class="button bordertransp"'.$disabled.
' value="'.
dol_escape_htmltag($langs->trans(
"CloneSite")).
'" name="createfromclone">';
2981 if (!$permissiontodelete) {
2982 $disabled =
' disabled="disabled"';
2983 $title = $langs->trans(
"NotEnoughPermissions");
2986 if ($website->status == $website::STATUS_VALIDATED) {
2987 $disabled =
' disabled="disabled"';
2988 $title = $langs->trans(
"WebsiteMustBeDisabled", $langs->transnoentitiesnoconv($website->LibStatut(0, 0)));
2992 $title = $langs->trans(
"Delete");
2993 $url = $_SERVER[
"PHP_SELF"].
'?action=deletesite&token='.newToken().
'&website='.urlencode($website->ref);
2996 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>';
2999 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>';
3002 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>';
3005 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=replacesite&website='.urlencode($website->ref).
'" class="button bordertransp"'.$disabled.
' title="'.
dol_escape_htmltag($langs->trans(
"ReplaceWebsiteContent")).
'"><span class="fa fa-search"></span></a>';
3010 if ($websitekey && $websitekey !=
'-1' && ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite')) {
3011 print
'<span class="websiteselection">';
3013 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);
3015 if (isModEnabled(
'categorie')) {
3017 print
dolButtonToOpenUrlInDialogPopup(
'categories', $langs->transnoentitiesnoconv(
"Categories"),
'<span class="fa fa-tags"></span>',
'/categories/index.php?leftmenu=website&nosearch=1&type=website_page&website='.urlencode($website->ref), $disabled);
3023 print
'<input type="hidden" name="website" id="website" value="'.$websitekey.
'">';
3027 print
'<span class="websitetools">';
3029 if ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite') {
3030 $urlext = $virtualurl;
3031 $urlint = $urlwithroot.
'/public/website/index.php?website='.$websitekey;
3033 print
'<span class="websiteinputurl valignmiddle" id="websiteinputurl">';
3034 $linktotestonwebserver =
'<a href="'.($virtualurl ? $virtualurl :
'#').
'" class="valignmiddle">';
3035 $linktotestonwebserver .=
'<span class="hideonsmartphone paddingrightonly">'.$langs->trans(
"TestDeployOnWeb", $virtualurl).
'</span>'.
img_picto(
'',
'globe');
3036 $linktotestonwebserver .=
'</a>';
3038 if (empty($object->fk_default_home)) {
3039 $htmltext .=
'<br><span class="error">'.$langs->trans(
"YouMustDefineTheHomePage").
'</span><br><br>';
3040 } elseif (empty($virtualurl)) {
3043 $htmltext .=
'<br><center>'.$langs->trans(
"GoTo").
' <a href="'.$virtualurl.
'" target="_website">'.$virtualurl.
'</a></center><br>';
3045 if (!empty($conf->global->WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER)) {
3046 $htmltext .=
'<!-- Message defined translate key set into WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER -->';
3047 $htmltext .=
'<br>'.$langs->trans($conf->global->WEBSITE_REPLACE_INFO_ABOUT_USAGE_WITH_WEBSERVER);
3049 $htmltext .= $langs->trans(
"SetHereVirtualHost", $dataroot);
3050 $htmltext .=
'<br>';
3051 $htmltext .=
'<br>'.$langs->trans(
"CheckVirtualHostPerms", $langs->transnoentitiesnoconv(
"ReadPerm"), DOL_DOCUMENT_ROOT);
3052 $htmltext .=
'<br>'.$langs->trans(
"CheckVirtualHostPerms", $langs->transnoentitiesnoconv(
"WritePerm"),
'{s1}');
3053 $htmltext = str_replace(
'{s1}', DOL_DATA_ROOT.
'/website<br>'.DOL_DATA_ROOT.
'/medias', $htmltext);
3055 $examplewithapache =
'#php_admin_value open_basedir /tmp/:'.DOL_DOCUMENT_ROOT.
':'.DOL_DATA_ROOT.
':/dev/urandom'.
"\n";
3056 $examplewithapache .=
'<Directory "'.DOL_DOCUMENT_ROOT.
'">'.
"\n";
3057 $examplewithapache .=
'AllowOverride FileInfo Options
3058 Options -Indexes -MultiViews -FollowSymLinks -ExecCGI
3061 <Directory "'.DOL_DATA_ROOT.
'/website">
3062 AllowOverride FileInfo Options
3063 Options -Indexes -MultiViews +FollowSymLinks -ExecCGI
3066 <Directory "'.DOL_DATA_ROOT.
'/medias">
3067 AllowOverride FileInfo Options
3068 Options -Indexes -MultiViews -FollowSymLinks -ExecCGI
3072 $htmltext .=
'<br>'.$langs->trans(
"ExampleToUseInApacheVirtualHostConfig").
':<br>';
3073 $htmltext .=
'<div class="centpercent exampleapachesetup">'.dol_nl2br(
dol_escape_htmltag($examplewithapache, 1, 1)).
'</div>';
3075 $htmltext .=
'<br>';
3076 $htmltext .= $langs->trans(
"YouCanAlsoTestWithPHPS", $dataroot);
3077 $htmltext .=
'<br>';
3078 $htmltext .=
'<br>';
3079 $htmltext .= $langs->trans(
"YouCanAlsoDeployToAnotherWHP");
3081 print $form->textwithpicto($linktotestonwebserver, $htmltext, 1,
'none',
'valignmiddle', 0, 3,
'helpvirtualhost');
3085 if (in_array($action, array(
'editcss',
'editmenu',
'file_manager',
'replacesiteconfirm')) || in_array($mode, array(
'replacesite'))) {
3086 if ($action ==
'editcss') {
3087 print
'<input type="submit" id="savefileandstay" class="button buttonforacesave hideonsmartphone small" value="'.dol_escape_htmltag($langs->trans(
"SaveAndStay")).
'" name="updateandstay">';
3089 if (preg_match(
'/^create/', $action) && $action !=
'file_manager' && $action !=
'replacesite' && $action !=
'replacesiteconfirm') {
3090 print
'<input type="submit" id="savefile" class="button buttonforacesave button-save small" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
3092 if (preg_match(
'/^edit/', $action) && $action !=
'file_manager' && $action !=
'replacesite' && $action !=
'replacesiteconfirm') {
3093 print
'<input type="submit" id="savefile" class="button buttonforacesave button-save small" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
3095 if ($action !=
'preview') {
3096 print
'<input type="submit" class="button button-cancel small" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'" name="cancel">';
3106 if ($websitekey && $websitekey !=
'-1' && (!in_array($action, array(
'editcss',
'editmenu',
'importsite',
'file_manager',
'replacesite',
'replacesiteconfirm'))) && (!in_array($mode, array(
'replacesite'))) && !$file_manager) {
3109 print
'<!-- Toolbar for websitepage -->';
3110 print
'<div class="centpercent websitebar"'.($style ?
' style="'.$style.
'"' :
'').
'>';
3112 print
'<div class="websiteselection hideonsmartphoneimp minwidth75 tdoverflowmax100 inline-block">';
3113 print $langs->trans(
"PageContainer").
': ';
3117 print
'<span class="websiteselection paddingrightonly">';
3118 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>';
3124 $s = $formwebsite->selectContainer($website,
'pageid', $pageid, 0, $action,
'minwidth100 maxwidth200onsmartphone');
3126 $out .=
'<span class="websiteselection nopaddingrightimp">';
3130 $urltocreatenewpage = $_SERVER[
"PHP_SELF"].
'?action=createcontainer&token='.newToken().
'&website='.urlencode($website->ref);
3132 if (!empty($conf->use_javascript_ajax)) {
3133 $out .=
'<script type="text/javascript">';
3134 $out .=
'jQuery(document).ready(function () {';
3135 $out .=
' jQuery("#pageid").change(function () {';
3136 $out .=
' console.log("We select "+jQuery("#pageid option:selected").val());';
3137 $out .=
' if (jQuery("#pageid option:selected").val() == \'-2\') {';
3138 $out .=
' window.location.href = "'.$urltocreatenewpage.
'";';
3139 $out .=
' } else {';
3140 $out .=
' window.location.href = "'.$_SERVER[
"PHP_SELF"].
'?website='.urlencode($website->ref).
'&pageid="+jQuery("#pageid option:selected").val();';
3144 $out .=
'</script>';
3149 if (!empty($conf->use_javascript_ajax)) {
3150 print
'<span class="websiteselection">';
3152 if ($object->status == $object::STATUS_DRAFT) {
3153 $text_off =
'SetWebsiteOnlineBefore';
3154 if ($websitepage->status == $websitepage::STATUS_DRAFT) {
3155 print
'<span class="valignmiddle disabled opacitymedium">'.img_picto($langs->trans($text_off),
'switch_off').
'</span>';
3157 print
'<span class="valignmiddle disabled opacitymedium">'.img_picto($langs->trans($text_off),
'switch_on').
'</span>';
3160 print
ajax_object_onoff($websitepage,
'status',
'status',
'Online',
'Offline', array(),
'valignmiddle inline-block'.(empty($websitepage->id) ?
' opacitymedium disabled' :
''),
'statuswebsitepage');
3166 print
'<span class="websiteselection">';
3168 print
'<input type="image" class="valignmiddle buttonwebsite" src="'.img_picto(
'',
'refresh',
'', 0, 1).
'" name="refreshpage" value="'.$langs->trans(
"Load").
'"'.(($action !=
'editsource') ?
'' :
' disabled="disabled"').
'>';
3171 $pagepreviousid = 0;
3174 $sql =
"SELECT MAX(rowid) as pagepreviousid FROM ".MAIN_DB_PREFIX.
"website_page WHERE rowid < ".((int) $pageid).
" AND fk_website = ".((int) $object->id);
3175 $resql = $db->query($sql);
3177 $obj = $db->fetch_object($resql);
3179 $pagepreviousid = $obj->pagepreviousid;
3184 $sql =
"SELECT MIN(rowid) as pagenextid FROM ".MAIN_DB_PREFIX.
"website_page WHERE rowid > ".((int) $pageid).
" AND fk_website = ".((int) $object->id);
3185 $resql = $db->query($sql);
3187 $obj = $db->fetch_object($resql);
3189 $pagenextid = $obj->pagenextid;
3196 if ($pagepreviousid) {
3197 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>';
3199 print
'<span class="valignmiddle opacitymedium">'.img_previous($langs->trans(
"PreviousContainer")).
'</span>';
3202 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>';
3204 print
'<span class="valignmiddle opacitymedium">'.img_next($langs->trans(
"NextContainer")).
'</span>';
3209 if ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite') {
3211 if (empty($user->rights->website->write)) {
3212 $disabled =
' disabled="disabled"';
3216 if ($action ==
'deletesite') {
3218 $formquestion = array(
3219 array(
'type' =>
'checkbox',
'name' =>
'delete_also_js',
'label' => $langs->trans(
"DeleteAlsoJs"),
'value' => 0),
3220 array(
'type' =>
'checkbox',
'name' =>
'delete_also_medias',
'label' => $langs->trans(
"DeleteAlsoMedias"),
'value' => 0),
3225 if ($atleastonepage) {
3226 $langs->load(
"errors");
3227 $formquestion[] = array(
'type' =>
'onecolumn',
'value' =>
'<div class="warning">'.$langs->trans(
"WarningPagesWillBeDeleted").
'</div>');
3230 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeleteWebsite'),
'',
'confirm_deletesite', $formquestion, 0, 1, 210 + ($atleastonepage ? 70 : 0), 580);
3236 if ($action ==
'createfromclone') {
3238 $formquestion = array(
3239 array(
'type' =>
'text',
'name' =>
'siteref',
'label'=> $langs->trans(
"WebSite"),
'value'=>
'copy_of_'.$object->ref)
3242 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'CloneSite'),
'',
'confirm_createfromclone', $formquestion, 0, 1, 200);
3247 if ($pageid > 0 && $atleastonepage) {
3249 if ($action ==
'createpagefromclone') {
3251 $preselectedlanguage =
GETPOST(
'newlang',
'aZ09') ?
GETPOST(
'newlang',
'aZ09') :
'';
3252 $onlylang = array();
3253 if ($website->otherlang) {
3254 if (!empty($website->lang)) {
3255 $onlylang[$website->lang] = $website->lang.
' ('.$langs->trans(
"Default").
')';
3257 foreach (explode(
',', $website->otherlang) as $langkey) {
3258 if (empty(trim($langkey)))
continue;
3259 $onlylang[$langkey] = $langkey;
3261 $textifempty = $langs->trans(
"Default");
3263 $onlylang[
'none'] =
'none';
3264 $textifempty = $langs->trans(
"Default");
3266 $formquestion = array(
3267 array(
'type' =>
'hidden',
'name' =>
'sourcepageurl',
'value'=> $objectpage->pageurl),
3268 array(
'type' =>
'other',
'tdclass'=>
'fieldrequired',
'name' =>
'newwebsite',
'label' => $langs->trans(
"WebSite"),
'value' => $formwebsite->selectWebsite($object->id,
'newwebsite', 0)),
3269 array(
'type' =>
'text',
'tdclass'=>
'maxwidth200 fieldrequired',
'moreattr'=>
'autofocus="autofocus"',
'name' =>
'newtitle',
'label'=> $langs->trans(
"WEBSITE_TITLE"),
'value'=> $langs->trans(
"CopyOf").
' '.$objectpage->title),
3270 array(
'type' =>
'text',
'tdclass'=>
'maxwidth200',
'name' =>
'newpageurl',
'label'=> $langs->trans(
"WEBSITE_PAGENAME"),
'value'=>
'')
3272 if (count($onlylang) > 1) {
3273 $formquestion[] = array(
'type' =>
'checkbox',
'tdclass'=>
'maxwidth200',
'name' =>
'is_a_translation',
'label' => $langs->trans(
"PageIsANewTranslation"),
'value' => 0,
'morecss'=>
'margintoponly');
3276 $value= $formadmin->select_language($preselectedlanguage,
'newlang', 0,
null, $textifempty, 0, 0,
'minwidth200', 1, 0, 0, $onlylang, 1);
3277 $formquestion[] = array(
'type' =>
'other',
'name' =>
'newlang',
'label' => $form->textwithpicto($langs->trans(
"Language"), $langs->trans(
"DefineListOfAltLanguagesInWebsiteProperties")),
'value' => $value);
3279 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?website='.$object->ref.
'&pageid='.$pageid, $langs->trans(
'ClonePage'),
'',
'confirm_createpagefromclone', $formquestion, 0, 1, 300, 550);
3284 print
'<span class="websiteselection">';
3287 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?website='.$object->ref.
'&pageid='.$pageid.
'&action=editmeta&token='.newToken().
'" class="button bordertransp" title="'.
dol_escape_htmltag($langs->trans(
"EditPageMeta")).
'"'.$disabled.
'><span class="fa fa-cog paddingrightonly"></span><span class="hideonsmartphone">'.
dol_escape_htmltag($langs->trans(
"EditPageMeta")).
'</span></a>';
3290 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?website='.$object->ref.
'&pageid='.$pageid.
'&action=editsource&token='.newToken().
'" class="button bordertransp"'.$disabled.
'>'.
dol_escape_htmltag($langs->trans($conf->dol_optimize_smallscreen ?
"HTML" :
"EditHTMLSource")).
'</a>';
3294 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?website='.$object->ref.
'&pageid='.$pageid.
'&action=editcontent&token='.newToken().
'" class="button bordertransp"'.$disabled.
'>'.
dol_escape_htmltag($langs->trans($conf->dol_optimize_smallscreen ?
"CKEditor" :
"CKEditor")).
'</a>';
3301 print
'<!-- button EditInLine and ShowSubcontainers -->'.
"\n";
3302 print
'<div class="websiteselectionsection inline-block">';
3304 print
'<div class="inline-block marginrightonly">';
3305 print $langs->trans(
"ShowSubcontainers");
3306 if (empty($conf->global->WEBSITE_SUBCONTAINERSINLINE)) {
3307 print
'<a class="nobordertransp nohoverborder marginleftonlyshort valignmiddle"'.$disabled.
' href="'.$_SERVER[
"PHP_SELF"].
'?website='.$object->ref.
'&pageid='.$websitepage->id.
'&action=setshowsubcontainers&token='.newToken().
'">'.
img_picto($langs->trans(
"ShowSubContainersOnOff", $langs->transnoentitiesnoconv(
"Off")),
'switch_off',
'',
false, 0, 0,
'',
'nomarginleft').
'</a>';
3309 print
'<a class="nobordertransp nohoverborder marginleftonlyshort valignmiddle"'.$disabled.
' href="'.$_SERVER[
"PHP_SELF"].
'?website='.$object->ref.
'&pageid='.$websitepage->id.
'&action=unsetshowsubcontainers&token='.newToken().
'">'.
img_picto($langs->trans(
"ShowSubContainersOnOff", $langs->transnoentitiesnoconv(
"On")),
'switch_on',
'',
false, 0, 0,
'',
'nomarginleft').
'</a>';
3313 print
'<div class="inline-block marginrightonly">';
3315 print
'<span id="switchckeditorinline">'.
"\n";
3316 print
'<!-- Code to enabled edit inline ckeditor -->'.
"\n";
3317 print
'<script type="text/javascript">
3318 $(document).ready(function() {
3319 var isEditingEnabled = '.(getDolGlobalString(
"WEBSITE_EDITINLINE") ?
'true' :
'false').
';
3320 if (isEditingEnabled)
3322 switchEditorOnline(true);
3325 $( "#switchckeditorinline" ).click(function() {
3326 switchEditorOnline();
3329 function switchEditorOnline(forceenable)
3331 if (! isEditingEnabled || forceenable)
3333 console.log("Enable inline edit");
3334 jQuery(\'section[contenteditable="true"],div[contenteditable="true"]\').each(function(idx){
3335 var idtouse = $(this).attr(\'id\');
3336 console.log("Enable inline edit for "+idtouse);
3337 CKEDITOR.inline(idtouse, {
3338 // Allow some non-standard markup that we used in the introduction.
3339 extraAllowedContent: \'span(*);cite(*);q(*);dl(*);dt(*);dd(*);ul(*);li(*);header(*);button(*);h1(*);h2(*);\',
3340 //extraPlugins: \'sourcedialog\',
3341 removePlugins: \'flash,stylescombo,exportpdf,scayt,wsc,pagebreak,iframe,smiley\',
3342 // Show toolbar on startup (optional).
3343 // startupFocus: true
3347 isEditingEnabled = true;
3350 console.log("Disable inline edit");
3351 for(name in CKEDITOR.instances)
3353 CKEDITOR.instances[name].destroy(true);
3355 isEditingEnabled = false;
3360 print $langs->trans(
"EditInLine");
3364 $disableeditinline = 0;
3365 if ($disableeditinline) {
3367 print
'<a class="nobordertransp opacitymedium nohoverborder marginleftonlyshort"'.$disabled.
' href="#" disabled="disabled" title="'.
dol_escape_htmltag($langs->trans(
"OnlyEditionOfSourceForGrabbedContent")).
'">'.
img_picto($langs->trans(
"OnlyEditionOfSourceForGrabbedContent"),
'switch_off',
'',
false, 0, 0,
'',
'nomarginleft').
'</a>';
3370 if (empty($conf->global->WEBSITE_EDITINLINE)) {
3371 print
'<a class="nobordertransp nohoverborder marginleftonlyshort valignmiddle"'.$disabled.
' href="'.$_SERVER[
"PHP_SELF"].
'?website='.$object->ref.
'&pageid='.$websitepage->id.
'&action=seteditinline&token='.newToken().
'">'.
img_picto($langs->trans(
"EditInLineOnOff", $langs->transnoentitiesnoconv(
"Off")),
'switch_off',
'',
false, 0, 0,
'',
'nomarginleft').
'</a>';
3373 print
'<a class="nobordertransp nohoverborder marginleftonlyshort valignmiddle"'.$disabled.
' href="'.$_SERVER[
"PHP_SELF"].
'?website='.$object->ref.
'&pageid='.$websitepage->id.
'&action=unseteditinline&token='.newToken().
'">'.
img_picto($langs->trans(
"EditInLineOnOff", $langs->transnoentitiesnoconv(
"On")),
'switch_on',
'',
false, 0, 0,
'',
'nomarginleft').
'</a>';
3382 print
'<span class="websiteselection">';
3383 if ($object->fk_default_home > 0 && $pageid == $object->fk_default_home) {
3387 print
'<a href="#" class="button bordertransp disabled" disabled="disabled" title="'.dol_escape_htmltag($langs->trans(
"SetAsHomePage")).
'"><span class="fa fa-home valignmiddle btnTitle-icon"></span></a>';
3391 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="fa fa-home valignmiddle btnTitle-icon"></span></a>';
3393 print
'<input type="submit" class="button bordertransp"'.$disabled.
' value="'.
dol_escape_htmltag($langs->trans(
"ClonePage")).
'" name="createpagefromclone">';
3396 if ($websitepage->status != $websitepage::STATUS_DRAFT) {
3397 $disabled =
' disabled="disabled"';
3398 $title = $langs->trans(
"WebpageMustBeDisabled", $langs->transnoentitiesnoconv($websitepage->LibStatut(0, 0)));
3403 $url = $_SERVER[
"PHP_SELF"].
'?action=delete&token='.newToken().
'&pageid='.((int) $websitepage->id).
'&website='.urlencode($website->ref);
3405 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>';
3412 print
'<span class="websitetools">';
3414 if (($pageid > 0 && $atleastonepage) && ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone' || $action ==
'deletesite')) {
3415 $realpage = $urlwithroot.
'/public/website/index.php?website='.$websitekey.
'&pageref='.$websitepage->pageurl;
3416 $pagealias = $websitepage->pageurl;
3418 $htmltext = $langs->trans(
"PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv(
"Page"), $langs->transnoentitiesnoconv(
"Page"), $realpage, $dataroot);
3419 $htmltext .=
'<br>'.$langs->trans(
"CheckVirtualHostPerms", $langs->transnoentitiesnoconv(
"ReadPerm"),
'{s1}');
3420 $htmltext = str_replace(
'{s1}', $dataroot.
'<br>'.DOL_DATA_ROOT.
'/medias<br>'.DOL_DOCUMENT_ROOT, $htmltext);
3424 print
'<div class="websiteinputurl inline-block paddingright">';
3425 print
'<a class="websitebuttonsitepreview inline-block" id="previewpage" href="'.$realpage.
'&nocache='.
dol_now().
'" class="button" target="tab'.$websitekey.
'" alt="'.
dol_escape_htmltag($htmltext).
'">';
3426 print $form->textwithpicto(
'', $htmltext, 1,
'preview');
3450 if (!in_array($mode, array(
'replacesite')) && !in_array($action, array(
'editcss',
'editmenu',
'file_manager',
'replacesiteconfirm',
'createsite',
'createcontainer',
'createfromclone',
'createpagefromclone',
'deletesite'))) {
3451 if ($action ==
'editsource' || $action ==
'editmeta') {
3452 print
'<input type="submit" id="savefileandstay" class="button buttonforacesave hideonsmartphone small" value="'.dol_escape_htmltag($langs->trans(
"SaveAndStay")).
'" name="updateandstay">';
3454 if (preg_match(
'/^create/', $action)) {
3455 print
'<input type="submit" id="savefile" class="button buttonforacesave button-save small" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
3457 if (preg_match(
'/^edit/', $action)) {
3458 print
'<input type="submit" id="savefile" class="button buttonforacesave button-save small" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'" name="update">';
3460 if ($action !=
'preview') {
3461 print
'<input type="submit" class="button button-cancel small" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'" name="cancel">';
3467 print
'<span class="websitehelp">';
3468 if ($action ==
'editsource' || $action ==
'editcontent' ||
GETPOST(
'editsource',
'alpha') ||
GETPOST(
'editcontent',
'alpha')) {
3469 $url =
'https://wiki.dolibarr.org/index.php/Module_Website';
3471 $htmltext = $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource", $url);
3472 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSource2", $url);
3473 $htmltext .= $langs->transnoentitiesnoconv(
"YouCanEditHtmlSourceMore", $url);
3474 $htmltext .=
'<br>';
3475 if ($conf->browser->layout ==
'phone') {
3476 print $form->textwithpicto(
'', $htmltext, 1,
'help',
'inline-block', 1, 2,
'tooltipsubstitution');
3479 print $form->textwithpicto($langs->trans(
"SyntaxHelp").
' '.
img_help(2, $langs->trans(
"SyntaxHelp")), $htmltext, 1,
'none',
'inline-block', 1, 2,
'tooltipsubstitution');
3485 if ($action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone') {
3487 if (!empty($conf->use_javascript_ajax)) {
3488 print
'<script type="text/javascript">
3489 jQuery(document).ready(function() {
3490 jQuery("#websiteinputurl").keyup(function() {
3491 console.log("Website external url modified "+jQuery("#previewsiteurl").val());
3492 if (jQuery("#previewsiteurl").val() != "" && jQuery("#previewsiteurl").val().startsWith("http"))
3494 jQuery("a.websitebuttonsitepreviewdisabled img").css({ opacity: 1 });
3496 else jQuery("a.websitebuttonsitepreviewdisabled img").css({ opacity: 0.2 });
3500 jQuery("#previewsiteext,#previewpageext").click(function() {
3502 newurl=jQuery("#previewsiteurl").val();
3503 if (! newurl.startsWith("http"))
3505 alert(\''.dol_escape_js($langs->trans(
"ErrorURLMustStartWithHttp")).
'\');
3509 newpage=jQuery(
"#previewsiteurl").val() +
"/" + jQuery(
"#previewpageurl").val() +
".php";
3510 console.log(
"Open url "+newurl);
3514 url:
"'.DOL_URL_ROOT.'/core/ajax/saveinplace.php",
3516 field: \
'editval_virtualhost\',
3517 element: \'website\',
3518 table_element: \'website\',
3519 fk_element: '.((int) $object->id).
',
3522 context: document.body
3525 jQuery("#previewsiteext").attr("href",newurl);
3526 jQuery("#previewpageext").attr("href",newpage);
3545if ($action ==
'editcss') {
3546 print
'<div class="fiche">';
3550 if (!GETPOSTISSET(
'WEBSITE_CSS_INLINE')) {
3551 $csscontent = @file_get_contents($filecss);
3553 $csscontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims',
'', $csscontent);
3555 $csscontent =
GETPOST(
'WEBSITE_CSS_INLINE',
'none');
3557 if (!trim($csscontent)) {
3558 $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;}";
3561 if (!GETPOSTISSET(
'WEBSITE_JS_INLINE')) {
3562 $jscontent = @file_get_contents($filejs);
3564 $jscontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims',
'', $jscontent);
3566 $jscontent =
GETPOST(
'WEBSITE_JS_INLINE',
'none');
3568 if (!trim($jscontent)) {
3569 $jscontent =
'/* JS content (all pages) */'.
"\n";
3572 if (!GETPOSTISSET(
'WEBSITE_HTML_HEADER')) {
3573 $htmlheadercontent = @file_get_contents($filehtmlheader);
3575 $htmlheadercontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims',
'', $htmlheadercontent);
3577 $htmlheadercontent =
GETPOST(
'WEBSITE_HTML_HEADER',
'none');
3579 if (!trim($htmlheadercontent)) {
3580 $htmlheadercontent =
"<html>\n";
3581 $htmlheadercontent .= $htmlheadercontentdefault;
3582 $htmlheadercontent .=
"</html>";
3584 $htmlheadercontent = preg_replace(
'/^\s*<html>/ims',
'', $htmlheadercontent);
3585 $htmlheadercontent = preg_replace(
'/<\/html>\s*$/ims',
'', $htmlheadercontent);
3586 $htmlheadercontent =
'<html>'.
"\n".trim($htmlheadercontent).
"\n".
'</html>';
3589 if (!GETPOSTISSET(
'WEBSITE_ROBOT')) {
3590 $robotcontent = @file_get_contents($filerobot);
3592 $robotcontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims',
'', $robotcontent);
3594 $robotcontent =
GETPOST(
'WEBSITE_ROBOT',
'nothtml');
3596 if (!trim($robotcontent)) {
3597 $robotcontent .=
"# Robot file. Generated with ".DOL_APPLICATION_TITLE.
"\n";
3598 $robotcontent .=
"User-agent: *\n";
3599 $robotcontent .=
"Allow: /public/\n";
3600 $robotcontent .=
"Disallow: /administrator/\n";
3603 if (!GETPOSTISSET(
'WEBSITE_HTACCESS')) {
3604 $htaccesscontent = @file_get_contents($filehtaccess);
3606 $htaccesscontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims',
'', $htaccesscontent);
3608 $htaccesscontent =
GETPOST(
'WEBSITE_HTACCESS',
'nohtml');
3610 if (!trim($htaccesscontent)) {
3611 $htaccesscontent .=
"# Order allow,deny\n";
3612 $htaccesscontent .=
"# Deny from all\n";
3616 if (!GETPOSTISSET(
'WEBSITE_MANIFEST_JSON')) {
3617 $manifestjsoncontent = @file_get_contents($filemanifestjson);
3619 $manifestjsoncontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims',
'', $manifestjsoncontent);
3621 $manifestjsoncontent =
GETPOST(
'WEBSITE_MANIFEST_JSON',
'restricthtml');
3623 if (!trim($manifestjsoncontent)) {
3627 if (!GETPOSTISSET(
'WEBSITE_README')) {
3628 $readmecontent = @file_get_contents($filereadme);
3630 $readmecontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims',
'', $readmecontent);
3632 $readmecontent =
GETPOST(
'WEBSITE_README',
'none');
3634 if (!trim($readmecontent)) {
3638 if (!GETPOSTISSET(
'WEBSITE_LICENSE')) {
3639 $licensecontent = @file_get_contents($filelicense);
3641 $licensecontent = preg_replace(
'/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims',
'', $licensecontent);
3643 $licensecontent =
GETPOST(
'WEBSITE_LICENSE',
'none');
3645 if (!trim($licensecontent)) {
3651 print
'<!-- Edit Website properties -->'.
"\n";
3652 print
'<table class="border centpercent">';
3655 print
'<tr><td class="titlefieldcreate fieldrequired">';
3656 print $langs->trans(
'WebSite');
3662 if ($action !=
'createcontainer') {
3663 if (empty($conf->use_javascript_ajax)) {
3664 print
'<!-- Status of web site page -->'.
"\n";
3665 print
'<tr><td class="fieldrequired">';
3666 print $langs->trans(
'Status');
3668 print $form->selectyesno(
'status', $object->status);
3674 print
'<tr><td class="tdtop fieldrequired">';
3676 print $form->textwithpicto($langs->trans(
'MainLanguage'), $htmltext, 1,
'help',
'', 0, 2,
'WEBSITE_LANG');
3678 print
img_picto(
'',
'language',
'class="picotfixedwidth"');
3679 print $formadmin->select_language((GETPOSTISSET(
'WEBSITE_LANG') ?
GETPOST(
'WEBSITE_LANG',
'aZ09comma') : ($object->lang ? $object->lang :
'0')),
'WEBSITE_LANG', 0, null, 1, 0, 0,
'minwidth300', 2, 0, 0, array(), 1);
3684 print
'<tr><td class="tdtop">';
3685 $htmltext = $langs->trans(
"Example").
': fr,de,sv,it,pt';
3686 print $form->textwithpicto($langs->trans(
'OtherLanguages'), $htmltext, 1,
'help',
'', 0, 2);
3688 print
img_picto(
'',
'language',
'class="picotfixedwidth"');
3689 print
'<input type="text" class="flat" value="'.(GETPOSTISSET(
'WEBSITE_OTHERLANG') ?
GETPOST(
'WEBSITE_OTHERLANG',
'alpha') : $object->otherlang).
'" name="WEBSITE_OTHERLANG">';
3694 print
'<tr><td class="tdtop">';
3696 $htmltext = $langs->trans(
"VirtualhostDesc");
3697 print $form->textwithpicto($langs->trans(
'Virtualhost'), $htmltext, 1,
'help',
'', 0, 2,
'virtualhosttooltip');
3699 print
'<input type="text" class="flat minwidth300" value="'.(GETPOSTISSET(
'virtualhost') ?
GETPOST(
'virtualhost',
'alpha') : $virtualurl).
'" name="virtualhost">';
3705 print $form->textwithpicto($langs->trans(
'ImportFavicon'), $langs->trans(
'FaviconTooltip'));
3708 $maxmin = $maxfilesizearray[
'maxmin'];
3710 print
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
3712 print
'<input type="file" class="flat minwidth300" name="addedfile" id="addedfile"/>';
3716 print
'<tr><td class="tdtop">';
3717 $htmlhelp = $langs->trans(
"CSSContentTooltipHelp");
3718 print $form->textwithpicto($langs->trans(
'WEBSITE_CSS_INLINE'), $htmlhelp, 1,
'help',
'', 0, 2,
'csstooltip');
3721 $poscursor = array(
'x'=>
GETPOST(
'WEBSITE_CSS_INLINE_x'),
'y'=>
GETPOST(
'WEBSITE_CSS_INLINE_y'));
3722 $doleditor =
new DolEditor(
'WEBSITE_CSS_INLINE', $csscontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'', $poscursor);
3723 print $doleditor->Create(1,
'',
true,
'CSS',
'css');
3728 print
'<tr><td class="tdtop">';
3729 $textwithhelp = $langs->trans(
'WEBSITE_JS_INLINE');
3730 $htmlhelp2 = $langs->trans(
"LinkAndScriptsHereAreNotLoadedInEditor").
'<br>';
3731 print $form->textwithpicto($textwithhelp, $htmlhelp2, 1,
'warning',
'', 0, 2,
'htmljstooltip2');
3735 $poscursor = array(
'x'=>
GETPOST(
'WEBSITE_JS_INLINE_x'),
'y'=>
GETPOST(
'WEBSITE_JS_INLINE_y'));
3736 $doleditor =
new DolEditor(
'WEBSITE_JS_INLINE', $jscontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'', $poscursor);
3737 print $doleditor->Create(1,
'',
true,
'JS',
'javascript');
3742 print
'<tr><td class="tdtop">';
3743 print $langs->trans(
'WEBSITE_HTML_HEADER');
3744 $htmlhelp = $langs->trans(
"Example").
' :<br>';
3746 $textwithhelp = $form->textwithpicto(
'', $htmlhelp, 1,
'help',
'', 0, 2,
'htmlheadertooltip');
3747 $htmlhelp2 = $langs->trans(
"LinkAndScriptsHereAreNotLoadedInEditor").
'<br>';
3748 print $form->textwithpicto($textwithhelp, $htmlhelp2, 1,
'warning',
'', 0, 2,
'htmlheadertooltip2');
3751 $poscursor = array(
'x'=>
GETPOST(
'WEBSITE_HTML_HEADER_x'),
'y'=>
GETPOST(
'WEBSITE_HTML_HEADER_y'));
3752 $doleditor =
new DolEditor(
'WEBSITE_HTML_HEADER', $htmlheadercontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'', $poscursor);
3753 print $doleditor->Create(1,
'',
true,
'HTML Header',
'html');
3758 print
'<tr><td class="tdtop">';
3759 print $langs->trans(
'WEBSITE_ROBOT');
3762 $poscursor = array(
'x'=>
GETPOST(
'WEBSITE_ROBOT_x'),
'y'=>
GETPOST(
'WEBSITE_ROBOT_y'));
3763 $doleditor =
new DolEditor(
'WEBSITE_ROBOT', $robotcontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'', $poscursor);
3764 print $doleditor->Create(1,
'',
true,
'Robot file',
'text');
3769 print
'<tr><td class="tdtop">';
3770 print $langs->trans(
'WEBSITE_HTACCESS');
3773 $poscursor = array(
'x'=>
GETPOST(
'WEBSITE_HTACCESS_x'),
'y'=>
GETPOST(
'WEBSITE_HTACCESS_y'));
3774 $doleditor =
new DolEditor(
'WEBSITE_HTACCESS', $htaccesscontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'', $poscursor);
3775 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' .htaccess',
'text');
3780 print
'<tr><td class="tdtop">';
3781 $htmlhelp = $langs->trans(
"Example").
' :<br>';
3782 $htmlhelp .=
'<small>'.dol_htmlentitiesbr($manifestjsoncontentdefault).
'</small>';
3783 print $form->textwithpicto($langs->trans(
'WEBSITE_MANIFEST_JSON'), $htmlhelp, 1,
'help',
'', 0, 2,
'manifestjsontooltip');
3785 print $langs->trans(
"UseManifest").
': '.$form->selectyesno(
'use_manifest', $website->use_manifest, 1).
'<br>';
3787 $poscursor = array(
'x'=>
GETPOST(
'WEBSITE_MANIFEST_JSON_x'),
'y'=>
GETPOST(
'WEBSITE_MANIFEST_JSON_y'));
3788 $doleditor =
new DolEditor(
'WEBSITE_MANIFEST_JSON', $manifestjsoncontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'', $poscursor);
3789 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' manifest.json',
'text');
3793 print
'<tr><td class="tdtop">';
3794 $htmlhelp = $langs->trans(
"EnterHereReadmeInformation");
3795 print $form->textwithpicto($langs->trans(
"File").
' README.md', $htmlhelp, 1,
'help',
'', 0, 2,
'readmetooltip');
3798 $poscursor = array(
'x'=>
GETPOST(
'WEBSITE_README_x'),
'y'=>
GETPOST(
'WEBSITE_README_y'));
3799 $doleditor =
new DolEditor(
'WEBSITE_README', $readmecontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'', $poscursor);
3800 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' README.md',
'text');
3805 print
'<tr><td class="tdtop">';
3806 $htmlhelp = $langs->trans(
"EnterHereLicenseInformation");
3807 print $form->textwithpicto($langs->trans(
"File").
' LICENSE', $htmlhelp, 1,
'help',
'', 0, 2,
'licensetooltip');
3810 $poscursor = array(
'x'=>
GETPOST(
'WEBSITE_LICENSE_x'),
'y'=>
GETPOST(
'WEBSITE_LICENSE_y'));
3811 $doleditor =
new DolEditor(
'WEBSITE_LICENSE', $licensecontent,
'',
'220',
'ace',
'In',
true,
false,
'ace', 0,
'100%',
'', $poscursor);
3812 print $doleditor->Create(1,
'',
true, $langs->trans(
"File").
' LICENSE',
'text');
3817 print
'<tr><td class="tdtop">';
3818 $htmlhelp = $langs->trans(
'RSSFeedDesc');
3819 print $form->textwithpicto($langs->trans(
'RSSFeed'), $htmlhelp, 1,
'help',
'', 0, 2,
'');
3821 print
'/wrapper.php?rss=1[&l=XX][&limit=123]';
3834if ($action ==
'createsite') {
3835 print
'<div class="fiche">';
3849 if ($action ==
'createcontainer') {
3853 print
'<!-- Add site -->'.
"\n";
3854 print
'<div class="tabBar tabBarWithBottom">';
3856 print
'<table class="border centpercent">';
3858 $siteref = $sitedesc = $sitelang = $siteotherlang =
'';
3860 $siteref =
GETPOST(
'WEBSITE_REF',
'aZ09');
3862 if (
GETPOST(
'WEBSITE_DESCRIPTION')) {
3863 $sitedesc =
GETPOST(
'WEBSITE_DESCRIPTION',
'alpha');
3865 if (
GETPOST(
'WEBSITE_LANG')) {
3866 $sitelang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
3868 if (
GETPOST(
'WEBSITE_OTHERLANG')) {
3869 $siteotherlang =
GETPOST(
'WEBSITE_OTHERLANG',
'aZ09comma');
3872 print
'<tr><td class="titlefieldcreate fieldrequired">';
3873 print $form->textwithpicto($langs->trans(
'WebsiteName'), $langs->trans(
"Example").
': MyPortal, www.mywebsite.com, ...');
3875 print
'<input type="text" class="flat maxwidth300" name="WEBSITE_REF" value="'.dol_escape_htmltag($siteref).
'" autofocus>';
3878 print
'<tr><td class="fieldrequired">';
3879 print $langs->trans(
'MainLanguage');
3881 $shortlangcode = preg_replace(
'/[_-].*$/',
'', trim($langs->defaultlang));
3882 print
img_picto(
'',
'language',
'class="pictofixedwidth"');
3883 print $formadmin->select_language((GETPOSTISSET(
'WEBSITE_LANG') ?
GETPOST(
'WEBSITE_LANG',
'aZ09comma') : $shortlangcode),
'WEBSITE_LANG', 0, null, 1, 0, 0,
'minwidth300', 2, 0, 0, array(), 1);
3887 $htmltext = $langs->trans(
"Example").
': fr,de,sv,it,pt';
3888 print $form->textwithpicto($langs->trans(
'OtherLanguages'), $htmltext, 1,
'help',
'', 0, 2);
3890 print
img_picto(
'',
'language',
'class="pictofixedwidth"');
3891 print
'<input type="text" class="flat minwidth300" name="WEBSITE_OTHERLANG" value="'.dol_escape_htmltag($siteotherlang).
'">';
3895 print $langs->trans(
'Description');
3897 print
'<input type="text" class="flat minwidth500" name="WEBSITE_DESCRIPTION" value="'.dol_escape_htmltag($sitedesc).
'">';
3902 $htmltext = $langs->trans(
"VirtualhostDesc");
3910 print $form->textwithpicto($langs->trans(
'Virtualhost'), $htmltext, 1,
'help',
'', 0, 2,
'');
3912 print
'<input type="text" class="flat minwidth300" name="virtualhost" value="'.dol_escape_htmltag(
GETPOST(
'virtualhost',
'alpha')).
'">';
3918 if ($action ==
'createsite') {
3919 print
'<div class="center">';
3921 print
'<input type="submit" class="button small" name="addcontainer" value="'.$langs->trans(
"Create").
'">';
3922 print
'<input class="button button-cancel small" type="submit" name="preview" value="'.$langs->trans(
"Cancel").
'">';
3937if ($action ==
'importsite') {
3938 print
'<div class="fiche">';
3946 print
'<span class="opacitymedium">'.$langs->trans(
"ZipOfWebsitePackageToImport").
'</span><br><br>';
3949 $dolibarrdataroot = preg_replace(
'/([\\/]+)$/i',
'', DOL_DATA_ROOT);
3950 $allowimportsite =
true;
3951 if (
dol_is_file($dolibarrdataroot.
'/installmodules.lock')) {
3952 $allowimportsite =
false;
3955 if ($allowimportsite) {
3957 $maxmin = $maxfilesizearray[
'maxmin'];
3959 print
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
3961 print
'<input class="flat minwidth400" type="file" name="userfile[]" accept=".zip">';
3962 print
'<input type="submit" class="button small" name="buttonsubmitimportfile" value="'.dol_escape_htmltag($langs->trans(
"Upload")).
'">';
3963 print
'<input type="submit" class="button button-cancel small" name="preview" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
3964 print
'<br><br><br>';
3968 $message = $langs->trans(
'InstallModuleFromWebHasBeenDisabledContactUs');
3971 $message = $langs->trans(
"InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.
'/installmodules.lock');
3977 print
'<span class="opacitymedium">'.$langs->trans(
"ZipOfWebsitePackageToLoad").
'</span><br><br>';
3988if ($action ==
'editmeta' || $action ==
'createcontainer') {
3989 print
'<div class="fiche">';
4003 if ($action ==
'createcontainer') {
4007 print
'<!-- Edit or create page/container -->'.
"\n";
4010 $hiddenfromfetchingafterload =
' hideobject';
4011 $hiddenmanuallyafterload =
' hideobject';
4012 if (
GETPOST(
'radiocreatefrom') ==
'checkboxcreatefromfetching') {
4013 $hiddenfromfetchingafterload =
'';
4015 if (
GETPOST(
'radiocreatefrom') ==
'checkboxcreatemanually') {
4016 $hiddenmanuallyafterload =
'';
4019 if ($action ==
'editmeta' || empty($conf->use_javascript_ajax)) {
4020 $hiddenfromfetchingafterload =
'';
4021 $hiddenmanuallyafterload =
'';
4024 if ($action ==
'createcontainer') {
4027 if (!empty($conf->use_javascript_ajax)) {
4028 print
'<input type="radio" name="radiocreatefrom" id="checkboxcreatemanually" value="checkboxcreatemanually"'.(GETPOST(
'radiocreatefrom') ==
'checkboxcreatemanually' ?
' checked' :
'').
'> ';
4030 print
'<label for="checkboxcreatemanually"><span class="opacitymediumxx">'.$langs->trans(
"OrEnterPageInfoManually").
'</span></label><br>';
4031 print
'<hr class="tablecheckboxcreatemanually'.$hiddenmanuallyafterload.
'">';
4034 print
'<table class="border tableforfield nobackground centpercent tablecheckboxcreatemanually'.$hiddenmanuallyafterload.
'">';
4036 if ($action !=
'createcontainer') {
4037 print
'<tr><td class="titlefield fieldrequired">';
4038 print $langs->trans(
'IDOfPage').
' - '.$langs->trans(
'InternalURLOfPage');
4046 print
' - ';
4047 print
'/public/website/index.php?website='.urlencode($websitekey).
'&pageid='.urlencode($pageid);
4051 $type_container = $objectpage->type_container;
4052 $pageurl = $objectpage->pageurl;
4053 $pagealiasalt = $objectpage->aliasalt;
4054 $pagetitle = $objectpage->title;
4055 $pagedescription = $objectpage->description;
4056 $pageimage = $objectpage->image;
4057 $pagekeywords = $objectpage->keywords;
4058 $pagelang = $objectpage->lang;
4059 $pageallowedinframes = $objectpage->allowed_in_frames;
4060 $pagehtmlheader = $objectpage->htmlheader;
4061 $pagedatecreation = $objectpage->date_creation;
4062 $pagedatemodification = $objectpage->date_modification;
4063 $pageauthorid = $objectpage->fk_user_creat;
4064 $pageusermodifid = $objectpage->fk_user_modif;
4065 $pageauthoralias = $objectpage->author_alias;
4066 $pagestatus = $objectpage->status;
4068 $type_container =
'page';
4072 $pagedescription =
'';
4076 $pageallowedinframes = 0;
4077 $pagehtmlheader =
'';
4078 $pagedatecreation =
dol_now();
4079 $pagedatemodification =
'';
4080 $pageauthorid = $user->id;
4081 $pageusermodifid = 0;
4082 $pageauthoralias =
'';
4085 if (
GETPOST(
'WEBSITE_TITLE',
'alpha')) {
4086 $pagetitle = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_TITLE',
'alphanohtml'));
4088 if (
GETPOST(
'WEBSITE_PAGENAME',
'alpha')) {
4089 $pageurl =
GETPOST(
'WEBSITE_PAGENAME',
'alpha');
4091 if (
GETPOST(
'WEBSITE_ALIASALT',
'alpha')) {
4092 $pagealiasalt = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_ALIASALT',
'alphanohtml'));
4094 if (
GETPOST(
'WEBSITE_DESCRIPTION',
'alpha')) {
4095 $pagedescription = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_DESCRIPTION',
'alphanohtml'));
4097 if (
GETPOST(
'WEBSITE_IMAGE',
'alpha')) {
4098 $pageimage =
GETPOST(
'WEBSITE_IMAGE',
'alpha');
4100 if (
GETPOST(
'WEBSITE_KEYWORDS',
'alpha')) {
4101 $pagekeywords = str_replace(array(
'<',
'>'),
'',
GETPOST(
'WEBSITE_KEYWORDS',
'alphanohtml'));
4103 if (
GETPOST(
'WEBSITE_LANG',
'aZ09')) {
4104 $pagelang =
GETPOST(
'WEBSITE_LANG',
'aZ09');
4106 if (
GETPOST(
'WEBSITE_ALLOWED_IN_FRAMES',
'aZ09')) {
4107 $pageallowedinframes =
GETPOST(
'WEBSITE_ALLOWED_IN_FRAMES',
'aZ09');
4109 if (
GETPOST(
'htmlheader',
'none')) {
4110 $pagehtmlheader =
GETPOST(
'htmlheader',
'none');
4113 if ($action !=
'createcontainer') {
4114 if (empty($conf->use_javascript_ajax)) {
4115 print
'<!-- Status of web site page -->'.
"\n";
4116 print
'<tr><td class="fieldrequired">';
4117 print $langs->trans(
'Status');
4119 print $form->selectyesno(
'status', $objectpage->status);
4125 print
'<tr><td class="titlefield fieldrequired">';
4126 print $langs->trans(
'WEBSITE_TYPE_CONTAINER');
4128 print
img_picto(
'',
'object_technic',
'class="paddingrightonly"').
' ';
4129 $formwebsite->selectTypeOfContainer(
'WEBSITE_TYPE_CONTAINER', (
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'alpha') ?
GETPOST(
'WEBSITE_TYPE_CONTAINER',
'alpha') : $type_container), 0,
'', 1);
4133 if ($action ==
'createcontainer') {
4134 print
'<tr><td class="titlefield fieldrequired">';
4135 print $langs->trans(
'WEBSITE_PAGE_EXAMPLE');
4137 print $formwebsite->selectSampleOfContainer(
'sample', (GETPOSTISSET(
'sample') ?
GETPOST(
'sample',
'alpha') :
'empty'), 0,
'', 1,
'minwidth300');
4142 print
'<tr><td class="fieldrequired">';
4143 print $langs->trans(
'WEBSITE_TITLE');
4145 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_TITLE" id="WEBSITE_TITLE" value="'.dol_escape_htmltag($pagetitle).
'" autofocus>';
4149 print
'<tr><td class="titlefieldcreate fieldrequired">';
4150 print $langs->trans(
'WEBSITE_PAGENAME');
4152 print
'<input type="text" class="flat minwidth300" name="WEBSITE_PAGENAME" id="WEBSITE_PAGENAME" value="'.dol_escape_htmltag($pageurl).
'">';
4155 print
'<tr><td class="titlefieldcreate">';
4156 $htmlhelp = $langs->trans(
"WEBSITE_ALIASALTDesc");
4157 print $form->textwithpicto($langs->trans(
'WEBSITE_ALIASALT'), $htmlhelp, 1,
'help',
'', 0, 2,
'aliastooltip');
4159 print
'<input type="text" class="flat minwidth500" name="WEBSITE_ALIASALT" value="'.dol_escape_htmltag($pagealiasalt).
'">';
4163 print $langs->trans(
'WEBSITE_DESCRIPTION');
4165 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_DESCRIPTION" value="'.dol_escape_htmltag($pagedescription).
'">';
4169 $htmlhelp = $langs->trans(
"WEBSITE_IMAGEDesc");
4170 print $form->textwithpicto($langs->trans(
'WEBSITE_IMAGE'), $htmlhelp, 1,
'help',
'', 0, 2,
'imagetooltip');
4172 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_IMAGE" value="'.dol_escape_htmltag($pageimage).
'">';
4177 $htmlhelp = $langs->trans(
"WEBSITE_KEYWORDSDesc");
4178 print $form->textwithpicto($langs->trans(
'WEBSITE_KEYWORDS'), $htmlhelp, 1,
'help',
'', 0, 2,
'keywordtooltip');
4180 print
'<input type="text" class="flat quatrevingtpercent" name="WEBSITE_KEYWORDS" value="'.dol_escape_htmltag($pagekeywords).
'">';
4184 print $langs->trans(
'Language');
4186 $onlykeys = array();
4187 if ($object->lang) {
4188 $onlykeys[$object->lang] = $object->lang;
4190 $onlykeys[$langs->defaultlang] = $langs->defaultlang;
4192 if ($object->otherlang) {
4193 $tmparray = explode(
',', $object->otherlang);
4194 foreach ($tmparray as $key) {
4195 $tmpkey = trim($key);
4196 if (strlen($key) == 2) {
4197 $tmpkey = strtolower($key);
4199 $onlykeys[$tmpkey] = $tmpkey;
4202 if (empty($object->lang) && empty($object->otherlang)) {
4205 print
img_picto(
'',
'language',
'class="pictofixedwidth"').$formadmin->select_language($pagelang ? $pagelang :
'',
'WEBSITE_LANG', 0, null,
'1', 0, 0,
'minwidth200', 0, 0, 0, $onlykeys, 1);
4206 $htmltext = $langs->trans(
"AvailableLanguagesAreDefinedIntoWebsiteProperties");
4207 print $form->textwithpicto(
'', $htmltext);
4213 print
'<!-- Translation of --><tr><td>';
4214 print $langs->trans(
'TranslationLinks');
4216 if ($action !=
'createcontainer') {
4218 $sql =
"SELECT rowid, lang from ".MAIN_DB_PREFIX.
"website_page where fk_page = ".((int) $objectpage->id);
4219 $resql = $db->query($sql);
4221 $num_rows = $db->num_rows($resql);
4222 if ($num_rows > 0) {
4223 print
'<span class="opacitymedium">'.$langs->trans(
'ThisPageHasTranslationPages').
':</span>';
4227 while ($obj = $db->fetch_object($resql)) {
4228 $result = $tmppage->fetch($obj->rowid);
4231 $tmpstring .=
'<br>';
4233 $tmpstring .= $tmppage->getNomUrl(1).
' ('.$tmppage->lang.
')';
4249 if (empty($translatedby) && ($action ==
'editmeta' || $action ==
'createcontainer' || $objectpage->fk_page > 0)) {
4251 $result = $sourcepage->fetch($objectpage->fk_page);
4254 } elseif ($result > 0) {
4255 $translationof = $objectpage->fk_page;
4256 print
'<span class="opacitymedium">'.$langs->trans(
'ThisPageIsTranslationOf').
'</span> ';
4257 print $formwebsite->selectContainer($website,
'pageidfortranslation', ($translationof ? $translationof : -1), 1, $action,
'minwidth300', array($objectpage->id));
4258 if ($translationof > 0 && $sourcepage->lang) {
4259 print $sourcepage->getNomUrl(2).
' ('.$sourcepage->lang.
')';
4267 print $langs->trans(
'AllowedInFrames');
4271 print
'<input type="checkbox" class="flat" name="WEBSITE_ALLOWED_IN_FRAMES" value="1"'.($pageallowedinframes ?
'checked="checked"' :
'').
'>';
4275 if (isModEnabled(
'categorie') && $user->hasRight(
'categorie',
'lire')) {
4276 $langs->load(
'categories');
4278 if (!GETPOSTISSET(
'categories')) {
4279 $cate_arbo = $form->select_all_categories(Categorie::TYPE_WEBSITE_PAGE,
'',
null,
null,
null, 1);
4281 $cats = $c->containing($objectpage->id, Categorie::TYPE_WEBSITE_PAGE);
4282 $arrayselected = array();
4283 if (is_array($cats)) {
4284 foreach ($cats as $cat) {
4285 $arrayselected[] = $cat->id;
4289 $cate_arbo = $form->select_all_categories(Categorie::TYPE_WEBSITE_PAGE,
'',
'parent',
null,
null, 1);
4292 print
'<tr><td class="toptd">'.$form->editfieldkey(
'Categories',
'categories',
'', $objectpage, 0).
'</td><td>';
4293 print
img_picto(
'',
'category',
'class="pictofixedwidth"');
4294 print $form->multiselectarray(
'categories', $cate_arbo, (GETPOSTISSET(
'categories') ?
GETPOST(
'categories',
'array') : $arrayselected), null, null,
'minwidth200 widthcentpercentminusxx');
4298 if (!empty($conf->global->WEBSITE_PAGE_SHOW_INTERNAL_LINKS_TO_OBJECT)) {
4299 print
'<tr><td class="titlefieldcreate">';
4300 print
'ObjectClass';
4302 print
'<input type="text" class="flat minwidth300" name="WEBSITE_OBJECTCLASS" placeholder="ClassName::/path/class/ObjectClass.class.php" >';
4305 print
'<tr><td class="titlefieldcreate">';
4308 print
'<input type="text" class="flat minwidth300" name="WEBSITE_OBJECTID" >';
4312 $fuser =
new User($db);
4315 print $langs->trans(
'Author');
4317 if ($pageauthorid > 0) {
4318 $fuser->fetch($pageauthorid);
4319 print $fuser->getNomUrl(1);
4321 print
'<span class="opacitymedium">'.$langs->trans(
"Unknown").
'</span>';
4326 print $langs->trans(
'PublicAuthorAlias');
4328 print
'<input type="text" class="flat minwidth300" name="WEBSITE_AUTHORALIAS" value="'.dol_escape_htmltag($pageauthoralias).
'" placeholder="Anonymous">';
4332 print $langs->trans(
'DateCreation');
4334 print $form->selectDate($pagedatecreation,
'datecreation', 1, 1, 0,
'', 1, 1);
4338 if ($action !=
'createcontainer') {
4340 print $langs->trans(
'UserModif');
4342 if ($pageusermodifid > 0) {
4343 $fuser->fetch($pageusermodifid);
4344 print $fuser->getNomUrl(1);
4349 print $langs->trans(
'DateModification');
4351 print
dol_print_date($pagedatemodification,
'dayhour',
'tzuser');
4355 print
'<tr><td class="tdhtmlheader tdtop">';
4356 $htmlhelp = $langs->trans(
"EditTheWebSiteForACommonHeader").
'<br><br>';
4357 $htmlhelp .= $langs->trans(
"Example").
' :<br>';
4359 print $form->textwithpicto($langs->trans(
'HtmlHeaderPage'), $htmlhelp, 1,
'help',
'', 0, 2,
'htmlheadertooltip');
4361 $poscursor = array(
'x'=>
GETPOST(
'htmlheader_x'),
'y'=>
GETPOST(
'htmlheader_y'));
4362 $doleditor =
new DolEditor(
'htmlheader', $pagehtmlheader,
'',
'120',
'ace',
'In',
true,
false,
'ace', ROWS_3,
'100%',
'', $poscursor);
4363 print $doleditor->Create(1,
'',
true,
'HTML Header',
'html');
4368 if ($action ==
'createcontainer') {
4369 print
'<div class="center tablecheckboxcreatemanually'.$hiddenmanuallyafterload.
'">';
4371 print
'<input type="submit" class="button small" name="addcontainer" value="'.$langs->trans(
"Create").
'">';
4372 print
'<input class="button button-cancel small" type="submit" name="preview" value="'.$langs->trans(
"Cancel").
'">';
4379 if (!empty($conf->use_javascript_ajax)) {
4380 print
'<input type="radio" name="radiocreatefrom" id="checkboxcreatefromfetching" value="checkboxcreatefromfetching"'.(GETPOST(
'radiocreatefrom') ==
'checkboxcreatefromfetching' ?
' checked' :
'').
'> ';
4382 print
'<label for="checkboxcreatefromfetching"><span class="opacitymediumxx">'.$langs->trans(
"CreateByFetchingExternalPage").
'</span></label><br>';
4383 print
'<hr class="tablecheckboxcreatefromfetching'.$hiddenfromfetchingafterload.
'">';
4384 print
'<table class="tableforfield centpercent tablecheckboxcreatefromfetching'.$hiddenfromfetchingafterload.
'">';
4385 print
'<tr><td class="titlefield">';
4386 print $langs->trans(
"URL");
4388 print
info_admin($langs->trans(
"OnlyEditionOfSourceForGrabbedContentFuture"), 0, 0,
'warning');
4389 print
'<input class="flat minwidth500" type="text" name="externalurl" value="'.dol_escape_htmltag(
GETPOST(
'externalurl',
'alpha')).
'" placeholder="https://externalsite/pagetofetch"> ';
4390 print
'<br><input class="flat paddingtop" type="checkbox" name="grabimages" value="1" checked="checked"> '.$langs->trans(
"GrabImagesInto");
4392 print $langs->trans(
"ImagesShouldBeSavedInto").
' ';
4393 $arraygrabimagesinto = array(
'root'=>$langs->trans(
"WebsiteRootOfImages"),
'subpage'=>$langs->trans(
"SubdirOfPage"));
4394 print $form->selectarray(
'grabimagesinto', $arraygrabimagesinto, GETPOSTISSET(
'grabimagesinto') ?
GETPOST(
'grabimagesinto') :
'root', 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
4397 print
'<input class="button small" style="margin-top: 5px" type="submit" name="fetchexternalurl" value="'.dol_escape_htmltag($langs->trans(
"FetchAndCreate")).
'">';
4398 print
'<input class="button button-cancel small" type="submit" name="preview" value="'.$langs->trans(
"Cancel").
'">';
4404 if ($action ==
'createcontainer') {
4405 print
'<script type="text/javascript">
4406 jQuery(document).ready(function() {
4407 var disableautofillofalias = 0;
4408 var selectedm = \'\';
4409 var selectedf = \'\';
4410 jQuery("#WEBSITE_TITLE").keyup(function() {
4411 if (disableautofillofalias == 0)
4413 var valnospecial = jQuery("#WEBSITE_TITLE").val();
4414 valnospecial = valnospecial.replace(/[éèê]/g, \'e\').replace(/[à ]/g, \'a\').replace(/[ù]/g, \'u\').replace(/[î]/g, \'i\');
4415 valnospecial = valnospecial.replace(/[ç]/g, \'c\').replace(/[ö]/g, \'o\');
4416 valnospecial = valnospecial.replace(/[^\w]/gi, \'-\').toLowerCase();
4417 valnospecial = valnospecial.replace(/\-+/g, \'-\').replace(/\-$/, \'\');
4418 console.log("disableautofillofalias=0 so we replace WEBSITE_TITLE with "+valnospecial);
4419 jQuery("#WEBSITE_PAGENAME").val(valnospecial);
4422 jQuery("#WEBSITE_PAGENAME").keyup(function() {
4423 disableautofillofalias = 1;
4426 jQuery("#checkboxcreatefromfetching,#checkboxcreatemanually").click(function() {
4427 console.log("we select a method to create a new container "+jQuery("#checkboxcreatefromfetching:checked").val())
4428 jQuery(".tablecheckboxcreatefromfetching").hide();
4429 jQuery(".tablecheckboxcreatemanually").hide();
4430 if (typeof(jQuery("#checkboxcreatefromfetching:checked").val()) != \'undefined\') {
4431 console.log("show a");
4432 if (selectedf != \'createfromfetching\') {
4433 jQuery(".tablecheckboxcreatefromfetching").show();
4434 selectedf = \'createfromfetching\';
4437 jQuery(".tablecheckboxcreatefromfetching").hide();
4441 if (typeof(jQuery("#checkboxcreatemanually:checked").val()) != \'undefined\') {
4442 console.log("show b");
4443 if (selectedm != \'createmanually\') {
4444 jQuery(".tablecheckboxcreatemanually").show();
4445 selectedm = \'createmanually\';
4448 jQuery(".tablecheckboxcreatemanually").hide();
4467if ($action ==
'preview') {
4471if ($action ==
'editfile' || $action ==
'file_manager' || $action ==
'convertimgwebp' || $action ==
'confirmconvertimgwebp') {
4472 print
'<!-- Edit Media -->'.
"\n";
4473 print
'<div class="fiche"><br>';
4478 $formalreadyopen = 2;
4480 $url = DOL_URL_ROOT.
'/website/index.php';
4482 include DOL_DOCUMENT_ROOT.
'/core/tpl/filemanager.tpl.php';
4487if ($action ==
'editmenu') {
4488 print
'<!-- Edit Menu -->'.
"\n";
4489 print
'<div class="center">'.$langs->trans(
"FeatureNotYetAvailable").
'</center>';
4492if ($action ==
'editsource') {
4495 $contentforedit =
'';
4499 $contentforedit .= $objectpage->content;
4501 $maxheightwin = 480;
4502 if (isset($_SESSION[
"dol_screenheight"])) {
4503 if ($_SESSION[
"dol_screenheight"] > 680) {
4504 $maxheightwin = $_SESSION[
"dol_screenheight"] - 400;
4506 if ($_SESSION[
"dol_screenheight"] > 800) {
4507 $maxheightwin = $_SESSION[
"dol_screenheight"] - 490;
4511 $poscursor = array(
'x'=>
GETPOST(
'PAGE_CONTENT_x'),
'y'=>
GETPOST(
'PAGE_CONTENT_y'));
4512 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
4513 $doleditor =
new DolEditor(
'PAGE_CONTENT', $contentforedit,
'', $maxheightwin,
'Full',
'',
true,
true,
'ace', ROWS_5,
'40%', 0, $poscursor);
4514 $doleditor->Create(0,
'',
false,
'HTML Source',
'php');
4517if ($action ==
'editcontent') {
4520 $contentforedit =
'';
4524 $contentforedit .= $objectpage->content;
4527 $contentforedit = preg_replace(
'/(<img.*src=")(?!http)/',
'\1'.DOL_URL_ROOT.
'/viewimage.php?modulepart=medias&file=', $contentforedit, -1, $nbrep);
4529 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
4530 $poscursor = array(
'x'=>
GETPOST(
'PAGE_CONTENT_x'),
'y'=>
GETPOST(
'PAGE_CONTENT_y'));
4531 $doleditor=
new DolEditor(
'PAGE_CONTENT', $contentforedit,
'', 500,
'Full',
'',
true,
true,
true, ROWS_5,
'90%', 0, $poscursor);
4532 $doleditor->Create(0,
'',
false);
4540if ($mode ==
'replacesite' || $massaction ==
'replace') {
4541 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4542 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4543 print
'<input type="hidden" name="action" value="replacesiteconfirm">';
4544 print
'<input type="hidden" name="mode" value="replacesite">';
4545 print
'<input type="hidden" name="website" value="'.$website->ref.
'">';
4548 print
'<!-- Search page and replace string -->'.
"\n";
4549 print
'<div class="fiche"><br>';
4551 print
load_fiche_titre($langs->trans(
"ReplaceWebsiteContent"),
'',
'search');
4553 print
'<div class="fichecenter"><div class="fichehalfleft">';
4555 print
'<div class="tagtable">';
4557 print
'<div class="tagtr">';
4558 print
'<div class="tagtd paddingrightonly opacitymedium">';
4559 print $langs->trans(
"SearchReplaceInto");
4561 print
'<div class="tagtd">';
4562 print
'<input type="checkbox" class="marginleftonly" id="checkboxoptioncontent" name="optioncontent" value="content"'.((!GETPOSTISSET(
'buttonreplacesitesearch') ||
GETPOST(
'optioncontent',
'aZ09')) ?
' checked' :
'').
'> <label for="checkboxoptioncontent" class="tdoverflowmax150onsmartphone inline-block valignmiddle">'.$langs->trans(
"Content").
'</label><br>';
4563 print
'<input type="checkbox" class="marginleftonly" id="checkboxoptionmeta" name="optionmeta" value="meta"'.(GETPOST(
'optionmeta',
'aZ09') ?
' checked' :
'').
'> <label for="checkboxoptionmeta" class="tdoverflowmax150onsmartphone inline-block valignmiddle">'.$langs->trans(
"Title").
' | '.$langs->trans(
"Description").
' | '.$langs->trans(
"Keywords").
'</label><br>';
4564 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>';
4568 print
'<div class="tagtr">';
4569 print
'<div class="tagtd paddingrightonly opacitymedium" style="padding-right: 10px !important">';
4570 print $langs->trans(
"SearchString");
4572 print
'<div class="tagtd">';
4573 print
'<input type="text" name="searchstring" value="'.dol_escape_htmltag($searchkey, 0, 0,
'', 1).
'" autofocus>';
4579 print
'</div><div class="fichehalfleft">';
4581 print
'<div class="tagtable">';
4583 print
'<div class="tagtr">';
4584 print
'<div class="tagtd paddingrightonly opacitymedium tdoverflowmax100onsmartphone" style="padding-right: 10px !important">';
4585 print $langs->trans(
"WEBSITE_TYPE_CONTAINER");
4587 print
'<div class="tagtd">';
4588 print
img_picto(
'',
'object_technic',
'class="paddingrightonly"').
' ';
4589 $formwebsite->selectTypeOfContainer(
'optioncontainertype', (
GETPOST(
'optioncontainertype',
'alpha') ?
GETPOST(
'optioncontainertype',
'alpha') :
''), 1,
'', 1,
'minwidth125 maxwidth400 widthcentpercentminusx');
4593 print
'<div class="tagtr">';
4594 print
'<div class="tagtd paddingrightonly opacitymedium tdoverflowmax100onsmartphone" style="padding-right: 10px !important">';
4595 print $langs->trans(
"Language");
4597 print
'<div class="tagtd">';
4598 print
img_picto(
'',
'language',
'class="paddingrightonly"').
' '.$formadmin->select_language(GETPOSTISSET(
'optionlanguage') ?
GETPOST(
'optionlanguage') :
'',
'optionlanguage', 0, null,
'1', 0, 0,
'minwidth125 maxwidth400 widthcentpercentminusx', 2, 0, 0, null, 1);
4603 if (isModEnabled(
'categorie') && $user->hasRight(
'categorie',
'lire')) {
4604 print
'<div class="tagtr">';
4605 print
'<div class="tagtd paddingrightonly marginrightonly opacitymedium tdoverflowmax100onsmartphone" style="padding-right: 10px !important">';
4606 print $langs->trans(
"Category");
4608 print
'<div class="tagtd">';
4609 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');
4610 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
4618 print
'<input type="submit" class="button margintoponly" name="buttonreplacesitesearch" value="'.dol_escape_htmltag($langs->trans(
"Search")).
'">';
4620 print
'</div></div>';
4622 if ($mode ==
'replacesite') {
4623 print
'<!-- List of search result -->'.
"\n";
4624 print
'<div class="rowsearchresult clearboth">';
4629 if ($listofpages[
'code'] ==
'OK') {
4630 $arrayofselected = is_array($toselect) ? $toselect : array();
4632 $nbtotalofrecords = count($listofpages[
'list']);
4634 $permissiontodelete = $user->hasRight(
'website',
'delete');
4637 $arrayofmassactions = array();
4638 if ($user->hasRight(
'website',
'writephp') && $searchkey) {
4639 $arrayofmassactions[
'replace'] =
img_picto(
'',
'replacement',
'class="pictofixedwidth"').$langs->trans(
"Replace");
4641 if ($user->hasRight(
'website',
'write')) {
4642 $arrayofmassactions[
'setcategory'] =
img_picto(
'',
'category',
'class="pictofixedwidth"').$langs->trans(
"ClassifyInCategory");
4644 if ($user->hasRight(
'website',
'write')) {
4645 $arrayofmassactions[
'delcategory'] =
img_picto(
'',
'category',
'class="pictofixedwidth"').$langs->trans(
"RemoveCategory");
4647 if ($permissiontodelete) {
4648 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
4650 if (
GETPOST(
'nomassaction',
'int') || in_array($massaction, array(
'presend',
'predelete'))) {
4651 $arrayofmassactions = array();
4654 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
4655 $massactionbutton .=
'<div class="massactionother massactionreplace hidden">';
4656 $massactionbutton .= $langs->trans(
"ReplaceString");
4657 $massactionbutton .=
' <input type="text" name="replacestring" value="'.dol_escape_htmltag(
GETPOST(
'replacestring',
'none')).
'">';
4658 $massactionbutton .=
'</div>';
4659 $massactionbutton .=
'<div class="massactionother massactionsetcategory massactiondelcategory hidden">';
4660 $massactionbutton .=
img_picto(
'',
'category').
' '.$langs->trans(
"Category");
4661 $massactionbutton .=
' '.$form->select_all_categories(Categorie::TYPE_WEBSITE_PAGE, GETPOSTISSET(
'setcategory') ?
GETPOST(
'setcategory') :
'',
'setcategory', 64, 0, 0, 0,
'minwidth300 alignstart');
4662 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
4664 $massactionbutton .=
'</div>';
4666 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
4669 $selectedfields =
'';
4670 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
4672 print_barre_liste($langs->trans(
"Results"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'generic', 0,
'',
'', $limit, 1, 1, 1);
4674 $topicmail =
"WebsitePageRef";
4675 $modelmail =
"websitepage_send";
4677 $trackid =
'wsp'.$object->id;
4678 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
4680 $param =
'mode=replacesite&website='.urlencode($website->ref);
4681 $param .=
'&searchstring='.urlencode($searchkey);
4682 if (
GETPOST(
'optioncontent')) {
4683 $param .=
'&optioncontent=content';
4686 $param .=
'&optionmeta=meta';
4688 if (
GETPOST(
'optionsitefiles')) {
4689 $param .=
'&optionsitefiles=optionsitefiles';
4691 if (
GETPOST(
'optioncontainertype')) {
4692 $param .=
'&optioncontainertype='.GETPOST(
'optioncontainertype',
'aZ09');
4694 if (
GETPOST(
'optionlanguage')) {
4695 $param .=
'&optionlanguage='.GETPOST(
'optionlanguage',
'aZ09');
4697 if (
GETPOST(
'optioncategory')) {
4698 $param .=
'&optioncategory='.GETPOST(
'optioncategory',
'aZ09');
4701 print
'<div class="div-table-responsive-no-min">';
4702 print
'<table class="noborder centpercent">';
4703 print
'<tr class="liste_titre">';
4704 print
getTitleFieldOfList(
"Type", 0, $_SERVER[
'PHP_SELF'],
'type_container',
'', $param,
'', $sortfield, $sortorder,
'').
"\n";
4705 print
getTitleFieldOfList(
"Page", 0, $_SERVER[
'PHP_SELF'],
'pageurl',
'', $param,
'', $sortfield, $sortorder,
'').
"\n";
4707 print
getTitleFieldOfList(
"Language", 0, $_SERVER[
'PHP_SELF'],
'lang',
'', $param,
'', $sortfield, $sortorder,
'center ').
"\n";
4709 print
getTitleFieldOfList(
"DateLastModification", 0, $_SERVER[
'PHP_SELF'],
'tms',
'', $param,
'', $sortfield, $sortorder,
'center ').
"\n";
4711 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
4714 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
4719 foreach ($listofpages[
'list'] as $answerrecord) {
4720 if (is_object($answerrecord) && get_class($answerrecord) ==
'WebsitePage') {
4724 print
'<td class="nowraponall">'.$langs->trans(
"Container").
' - ';
4725 print $langs->trans($answerrecord->type_container);
4730 print $answerrecord->getNomUrl(1);
4731 print
' <span class="opacitymedium">('.($answerrecord->title ? $answerrecord->title : $langs->trans(
"NoTitle")).
')</span>';
4735 print
'<span class="opacitymedium">'.$answerrecord->description.
'</span>';
4739 print
'<td class="center">';
4740 if (isModEnabled(
'categorie') && $user->hasRight(
'categorie',
'lire')) {
4742 $existing = $c->containing($answerrecord->id, Categorie::TYPE_WEBSITE_PAGE,
'object');
4743 if (is_array($existing)) {
4744 foreach ($existing as $tmpcategory) {
4746 print
img_object($langs->trans(
"Category").
' : '.$tmpcategory->label,
'category',
'style="padding-left: 2px; padding-right: 2px; color: #'.($tmpcategory->color !=
'' ? $tmpcategory->color :
'888').
'"');
4754 $param =
'?mode=replacesite';
4755 $param .=
'&websiteid='.$website->id;
4756 $param .=
'&optioncontent='.GETPOST(
'optioncontent',
'aZ09');
4757 $param .=
'&optionmeta='.GETPOST(
'optionmeta',
'aZ09');
4758 $param .=
'&optionsitefiles='.GETPOST(
'optionsitefiles',
'aZ09');
4759 $param .=
'&optioncontainertype='.GETPOST(
'optioncontainertype',
'aZ09');
4760 $param .=
'&optionlanguage='.GETPOST(
'optionlanguage',
'aZ09');
4761 $param .=
'&optioncategory='.GETPOST(
'optioncategory',
'aZ09');
4762 $param .=
'&searchstring='.urlencode($searchkey);
4765 print
'<td class="center">';
4770 print
'<td class="center nowraponall">';
4772 $characterMap =
'áà éèëÃóúüñùç0123456789';
4773 $nbofwords = str_word_count($textwithouthtml, 0, $characterMap);
4775 print $nbofwords.
' '.$langs->trans(
"words");
4776 $totalnbwords += $nbofwords;
4781 print
'<td class="center nowraponall">';
4782 print
dol_print_date($answerrecord->date_modification,
'dayhour');
4786 print
'<td class="tdwebsitesearchresult right nowraponall">';
4788 $urltoedithtmlsource = $_SERVER[
"PHP_SELF"].
'?action=editmeta&token='.newToken().
'&websiteid='.$website->id.
'&pageid='.$answerrecord->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].$param);
4789 if (empty($user->rights->website->write)) {
4790 $disabled =
' disabled';
4791 $urltoedithtmlsource =
'';
4793 print
'<a class="editfielda marginleftonly marginrightonly '.$disabled.
'" href="'.$urltoedithtmlsource.
'" title="'.$langs->trans(
"EditPageMeta").
'">'.
img_picto($langs->trans(
"EditPageMeta"),
'pencil-ruler').
'</a>';
4796 $urltoedithtmlsource = $_SERVER[
"PHP_SELF"].
'?action=editsource&token='.newToken().
'&websiteid='.$website->id.
'&pageid='.$answerrecord->id.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].$param);
4797 if (empty($user->rights->website->write)) {
4798 $disabled =
' disabled';
4799 $urltoedithtmlsource =
'';
4801 print
'<a class="editfielda marginleftonly marginrightonly '.$disabled.
'" href="'.$urltoedithtmlsource.
'" title="'.$langs->trans(
"EditHTMLSource").
'">'.
img_picto($langs->trans(
"EditHTMLSource"),
'edit').
'</a>';
4803 print
'<span class="marginleftonly marginrightonly"></span>';
4804 print
ajax_object_onoff($answerrecord,
'status',
'status',
'Enabled',
'Disabled', array(),
'valignmiddle inline-block');
4809 print
'<td class="nowrap center">';
4811 print
'<!-- Status of page -->'.
"\n";
4812 if ($massactionbutton || $massaction) {
4814 if (in_array($answerrecord->id, $arrayofselected)) {
4817 print
'<input id="'.$answerrecord->id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$answerrecord->id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
4827 $translateofrecordtype = array(
4828 'website_csscontent'=>
'WEBSITE_CSS_INLINE',
4829 'website_jscontent'=>
'WEBSITE_JS_INLINE',
4830 'website_robotcontent'=>
'WEBSITE_ROBOT',
4831 'website_htmlheadercontent'=>
'WEBSITE_HTML_HEADER',
4832 'website_htaccess'=>
'WEBSITE_HTACCESS',
4833 'website_readme'=>
'WEBSITE_README',
4834 'website_manifestjson'=>
'WEBSITE_MANIFEST_JSON'
4836 if (!empty($translateofrecordtype[$answerrecord[
'type']])) {
4837 print $langs->trans($translateofrecordtype[$answerrecord[
'type']]);
4839 print $answerrecord[
'type'];
4843 $param =
'?mode=replacesite';
4844 $param .=
'&websiteid='.$website->id;
4845 $param .=
'&optioncontent='.GETPOST(
'optioncontent',
'aZ09');
4846 $param .=
'&optionmeta='.GETPOST(
'optionmeta',
'aZ09');
4847 $param .=
'&optionsitefiles='.GETPOST(
'optionsitefiles',
'aZ09');
4848 $param .=
'&optioncontainertype='.GETPOST(
'optioncontainertype',
'aZ09');
4849 $param .=
'&optionlanguage='.GETPOST(
'optionlanguage',
'aZ09');
4850 $param .=
'&optioncategory='.GETPOST(
'optioncategory',
'aZ09');
4851 $param .=
'&searchstring='.urlencode($searchkey);
4855 $backtopageurl = $_SERVER[
"PHP_SELF"].$param;
4856 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=editcss&token='.newToken().
'&website='.urlencode($website->ref).
'&backtopage='.urlencode($backtopageurl).
'">'.$langs->trans(
"EditCss").
'</a>';
4872 print
'<td class="center nowraponall">';
4881 print
'<td class="nowrap center">';
4888 if (count($listofpages[
'list']) >= 2) {
4890 print
'<tr class="lite_titre">';
4894 print $langs->trans(
"Total");
4910 print
'<td class="center nowraponall">';
4911 print $totalnbwords.
' '.$langs->trans(
"words");
4923 print
'<td class="nowrap center">';
4933 print
'<div class="warning">'.$listofpages[
'message'].
'</div>';
4942if ((empty($action) || $action ==
'preview' || $action ==
'createfromclone' || $action ==
'createpagefromclone') && !in_array($mode, array(
'replacesite'))) {
4943 if ($pageid > 0 && $atleastonepage) {
4949 $objectpage->fetch($pageid);
4951 $jscontent = @file_get_contents($filejs);
4953 $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";
4962 $out .=
"\n<html><head>\n";
4963 $out .=
"<!-- htmlheader/style of page from database -->\n";
4966 $out .=
"<!-- htmlheader/style of website from files -->\n";
4984 $out .=
"</head>\n";
4988 $out .=
'<div id="websitecontentundertopmenu" class="websitecontentundertopmenu boostrap-iso">'.
"\n";
4992 $out .=
'<!-- style of website from file -->'.
"\n";
4993 $out .=
'<style scoped>'.
"\n";
4995 $tmpout .=
'/* Include website CSS file */'.
"\n";
4999 $csscontent = ob_get_contents();
5002 $tmpout .=
'/* Include style from the HTML header of page */'.
"\n";
5004 $tmp = preg_split(
'(<style[^>]*>|</style>)', $objectpage->htmlheader);
5005 $tmpstyleinheader =
'';
5007 foreach ($tmp as $valtmp) {
5010 $tmpstyleinheader .= $valtmp.
"\n";
5013 $tmpout .= $tmpstyleinheader.
"\n";
5015 $tmpout = preg_replace(
'/}[\s\n]*body\s*{[^}]+}/ims',
'}', $tmpout);
5017 $out .=
'</style>'.
"\n";
5024 $out .=
'<div id="divbodywebsite" class="bodywebsite bodywebpage-'.$objectpage->ref.
'">'.
"\n";
5026 $newcontent = $objectpage->content;
5029 if (!empty($conf->global->WEBSITE_SUBCONTAINERSINLINE)) {
5033 $filephp = $filetpl;
5036 $res = include $filephp;
5038 print
"ERROR: Failed to include file '".$filephp.
"'. Try to edit and re-save page ith this ID.";
5041 print $e->getMessage();
5043 $newcontent = ob_get_contents();
5048 if (empty($conf->global->WEBSITE_EDITINLINE)) {
5050 $newcontent = preg_replace(
'/(div|section)(\s[^>]*)contenteditable="true"/',
'\1\2', $newcontent);
5059 $out .=
'</div> <!-- End div id=websitecontentundertopmenu -->';
5065 $out .=
"\n</body></html>\n";
5067 $out .=
"\n".
'<!-- End page content '.$filetpl.
' -->'.
"\n\n";
5091 if (empty($websitekey) || $websitekey ==
'-1') {
5092 print
'<br><br><div class="center previewnotyetavailable"><span class="">'.$langs->trans(
"NoWebSiteCreateOneFirst").
'</span></div><br><br><br>';
5093 print
'<div class="center"><div class="logo_setup"></div></div>';
5095 print
'<br><br><div class="center previewnotyetavailable"><span class="">'.$langs->trans(
"PreviewOfSiteNotYetAvailable", $object->ref).
'</span></div><br><br><br>';
5096 print
'<div class="center"><div class="logo_setup"></div></div>';
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)
On/off button to change a property status of an object This uses the ajax service objectonoff....
Class to manage categories.
Class to manage a WYSIWYG editor.
lessphp v0.5.0 http://leafo.net/lessphp
Class to manage Dolibarr users.
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories)
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_is_file($pathoffile)
Return if path is a file.
dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesession=0, $varfiles='addedfile', $savingdocmask='', $link=null, $trackid='', $generatethumbs=1, $object=null)
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 informations (by default a local PHP server timestamp) Re...
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_help($usehelpcursor=1, $usealttitle=1)
Show help logo with cursor "?".
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.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dolChmod($filepath, $newmask='')
Change mod of a file.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
img_previous($titlealt='default', $moreatt='')
Show previous logo.
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.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
img_next($titlealt='default', $moreatt='')
Show next logo.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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.
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.
checkPHPCode($phpfullcodestringold, $phpfullcodestring)
Check a new string containing only php code (including <php tag)
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.
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 page content $tmp.
getPagesFromSearchCriterias($type, $algo, $searchstring, $max=25, $sortfield='date_creation', $sortorder='DESC', $langcode='', $otherfilters='null', $status=1)
Return list of containers object that match a criteria.
dolWebsiteReplacementOfLinks($website, $content, $removephppart=0, $contenttype='html', $containerid='')
Convert a page content to have correct links (based on DOL_URL_ROOT) into an html content.
dolStripPhpCode($str, $replacewith='')
Remove PHP code part from a string.
dolKeepOnlyPhpCode($str)
Keep only PHP code part from a HTML string page.