diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index 452a9da08c7..ce7c7c01436 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -96,7 +96,7 @@ function dolWebsiteOutput($content) global $db, $langs, $conf, $user; global $dolibarr_main_url_root, $dolibarr_main_data_root; - dol_syslog("dolWebsiteOutput start (mode=".(defined('USEDOLIBARRSERVER')?'USEDOLIBARRSERVER':'').')'); + dol_syslog("dolWebsiteOutput start (USEDOLIBARRSERVER=".(defined('USEDOLIBARRSERVER')?'1':'')." (USEDOLIBARREDITOR=".(defined('USEDOLIBARREDITOR')?'1':'').')'); // Define $urlwithroot $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); @@ -104,8 +104,11 @@ function dolWebsiteOutput($content) //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current // Note: This seems never called when page is output inside the website editor (search 'REPLACEMENT OF LINKS When page called by website editor') - - if (defined('USEDOLIBARRSERVER')) // REPLACEMENT OF LINKS When page called from Dolibarr server + if (defined('USEDOLIBARREDITOR')) + { + // Do nothing + } + elseif (defined('USEDOLIBARRSERVER') || defined('USEDOLIBARREDITOR')) // REPLACEMENT OF LINKS When page called from Dolibarr server { global $website; @@ -536,7 +539,7 @@ function dolSaveMasterFile($filemaster) $mastercontent = ''."\n"; $result = file_put_contents($filemaster, $mastercontent); if (! empty($conf->global->MAIN_UMASK)) @@ -598,7 +601,7 @@ function dolSavePageContent($filetpl, $object, $objectpage) $tplcontent =''; $tplcontent.= "mycompany->dir_output."/".$original_file));'."\n"; $wrappercontent.= "else print 'Bad value for modulepart or file';\n"; diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 1629a698673..5852f201f1f 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -639,10 +639,11 @@ class Website extends CommonObject if (! $error) { $filetpl=$pathofwebsitenew.'/page'.$newidforhome.'.tpl.php'; + $filewrapper=$pathofwebsitenew.'/wrapper.php'; // Generate the index.php page to be the home page //------------------------------------------------- - $result = dolSaveIndexPage($pathofwebsitenew, $fileindex, $filetpl); + $result = dolSaveIndexPage($pathofwebsitenew, $fileindex, $filetpl, $filewrapper); } } diff --git a/htdocs/website/class/websitepage.class.php b/htdocs/website/class/websitepage.class.php index e60a0d2bcfe..ff4355e1c12 100644 --- a/htdocs/website/class/websitepage.class.php +++ b/htdocs/website/class/websitepage.class.php @@ -130,7 +130,7 @@ class WebsitePage extends CommonObject * Load object in memory from the database * * @param int $id Id object. - * - If this is 0, the value into $page will be used. If not found of $page not defined, the default page of website_id will be used or the first page found if not set. + * - If this is 0, the value into $page will be used. If not found or $page not defined, the default page of website_id will be used or the first page found if not set. * - If value is < 0, we must exclude this ID. * @param string $website_id Web site id (page name must also be filled if this parameter is used) * @param string $page Page name (website id must also be filled if this parameter is used) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 47f26bc7691..f1363dec514 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -109,7 +109,35 @@ if ($websitekey) } $website = $object; -// Define pageid if pageif and pageref not received as parameter +// Check pageid received as aprameter +if ($pageid < 0) $pageid = 0; +if (($pageid > 0 || $pageref) && $action != 'addcontainer') +{ + $res = $objectpage->fetch($pageid, ($object->id > 0 ? $object->id : null), $pageref); + + // Check if pageid is inside the new website, if not we reset param pageid + if ($res >= 0 && $object->id > 0) + { + if ($objectpage->fk_website != $object->id) // We have a bad page. + { + $res = $objectpage->fetch(0, $object->id, ''); // We search first page of web site + if ($res == 0) // Page was not found, we reset it + { + $objectpage=new WebsitePage($db); + } + else // We found a page, we set pageid to it. + { + $pageid = $objectpage->id; + } + } + else // We have a valid page. We force pageid for the case we got the page with a fetch on ref. + { + $pageid = $objectpage->id; + } + } +} + +// Define pageid if pageid and pageref not received as parameter or was wrong if (empty($pageid) && empty($pageref) && $object->id > 0 && $action != 'createcontainer') { $pageid = $object->fk_default_home; @@ -129,22 +157,6 @@ if (empty($pageid) && empty($pageref) && $object->id > 0 && $action != 'createco } } -if ($pageid < 0) $pageid = 0; -if (($pageid > 0 || $pageref) && $action != 'addcontainer') -{ - $res = $objectpage->fetch($pageid, ($object->id > 0 ? $object->id : null), $pageref); - - // Check if pageid is inside the new website, if not we reset param pageid - if ($object->id > 0 && ($objectpage->fk_website != $object->id)) - { - $res = $objectpage->fetch(0, $object->id, '');; - if ($res == 0) // Page was not found, we reset it - { - $objectpage=new WebsitePage($db); - } - } - $pageid = $objectpage->id; -} global $dolibarr_main_data_root; $pathofwebsite=$dolibarr_main_data_root.'/website/'.$websitekey; @@ -836,7 +848,7 @@ if ($action == 'updatecss') /* We disable php code since htmlheader is never executed as an include but only read by fgets_content. $htmlheadercontent.= "keywords; $pagelang=$objectpage->lang; $pagehtmlheader=$objectpage->htmlheader; + $pagedatecreation=$objectpage->date_creation; + $pagedatemodification=$objectpage->date_modification; + $pageauthorid=$objectpage->fk_user_create; } else { $type_container = 'page'; + $pagedatecreation=dol_now(); + $pageauthorid=$user->id; } if (GETPOST('WEBSITE_TITLE','alpha')) $pagetitle=GETPOST('WEBSITE_TITLE','alpha'); if (GETPOST('WEBSITE_PAGENAME','alpha')) $pageurl=GETPOST('WEBSITE_PAGENAME','alpha'); @@ -2452,6 +2469,30 @@ if ($action == 'editmeta' || $action == 'createcontainer') print ''; print ''; + $fuser=new User($db); + $fuser->fetch($pageauthorid); + + print ''; + print $langs->trans('Author'); + print ''; + if ($pageauthorid > 0) print $fuser->getNomUrl(1); + print ''; + + print ''; + print $langs->trans('DateCreation'); + print ''; + print dol_print_date($pagedatecreation, 'dayhour'); + print ''; + + if ($action != 'createcontainer') + { + print ''; + print $langs->trans('DateModification'); + print ''; + print dol_print_date($pagedatemodification, 'dayhour'); + print ''; + } + print ''; $htmlhelp=$langs->trans("EditTheWebSiteForACommonHeader").'

'; $htmlhelp=$langs->trans("Example").' :
'; @@ -2632,7 +2673,7 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa // If mode WEBSITE_SUBCONTAINERSINLINE is on if (! empty($conf->global->WEBSITE_SUBCONTAINERSINLINE)) { - define('USEDOLIBARRSERVER', 1); + define('USEDOLIBARREDITOR', 1); //var_dump($filetpl); $filephp = $filetpl; ob_start();