diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index a3626c3c5df..bb86be1620c 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -22,4 +22,4 @@ ViewPageInNewTab=View page in new tab SetAsHomePage=Set as Home page RealURL=Real URL ViewWebsiteInProduction=View web site using home URLs -SetHereVirtualHost=If you can set, on your web server, a dedicated virtual host with a root directory on %s, define here the virtual hostname so the preview will be done using this direct access instead of Dolibarr URLs wrapper. +SetHereVirtualHost=If you can set, on your web server, a dedicated virtual host with a root directory on %s, define here the virtual hostname so the preview can be done also using this direct web server access and not only using Dolibarr server. diff --git a/htdocs/theme/eldy/img/preview.png b/htdocs/theme/eldy/img/preview.png new file mode 100644 index 00000000000..9040bf963f7 Binary files /dev/null and b/htdocs/theme/eldy/img/preview.png differ diff --git a/htdocs/theme/eldy/img/preview_ext.png b/htdocs/theme/eldy/img/preview_ext.png new file mode 100644 index 00000000000..8bf0c65a7c0 Binary files /dev/null and b/htdocs/theme/eldy/img/preview_ext.png differ diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 186b2bfd6c4..fa6d056c587 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -1397,7 +1397,9 @@ div.login a:hover { } div.login_block_user { display: inline-block; + global->THEME_TOPMENU_DISABLE_IMAGE)) { ?> min-width: 120px; + } div.login_block_other { display: inline-block; @@ -3319,11 +3321,18 @@ td.hidden { } .websitetools { float: right; - padding-top: 2px; +} +.websiteinputurl { + display: inline-block; + vertical-align: top; } .websiteiframenoborder { border: 0px; } +a.websitebuttonsitepreview img { + width: 26px; + display: inline-block; +} /* ============================================================================== */ diff --git a/htdocs/theme/md/img/preview.png b/htdocs/theme/md/img/preview.png new file mode 100644 index 00000000000..9040bf963f7 Binary files /dev/null and b/htdocs/theme/md/img/preview.png differ diff --git a/htdocs/theme/md/img/preview_ext.png b/htdocs/theme/md/img/preview_ext.png new file mode 100644 index 00000000000..8bf0c65a7c0 Binary files /dev/null and b/htdocs/theme/md/img/preview_ext.png differ diff --git a/htdocs/websites/class/websitepage.class.php b/htdocs/websites/class/websitepage.class.php index 65e56e030a1..79fe143f7a5 100644 --- a/htdocs/websites/class/websitepage.class.php +++ b/htdocs/websites/class/websitepage.class.php @@ -183,7 +183,7 @@ class WebsitePage extends CommonObject * Load object in memory from the database * * @param int $id Id object - * @param string $website_id Web site page + * @param string $website_id Web site id * @param string $page Page name * * @return int <0 if KO, 0 if not found, >0 if OK diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index 655bdd18e9f..60ec0475d71 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -177,6 +177,9 @@ if ($action == 'add') { $db->rollback(); } + + $action = 'preview'; + $id = $objectpage->id; } // Update page @@ -516,7 +519,7 @@ $help_url=''; llxHeader('', $langs->trans("WebsiteSetup"), $help_url); -print "\n".'
'; +print "\n".'
'; print ''; if ($action == 'create') { @@ -590,47 +593,19 @@ if (count($object->records) > 0) $realurl=$urlwithroot.'/public/websites/index.php?website='.$website; $dataroot=DOL_DATA_ROOT.'/websites/'.$website; if (! empty($object->virtualhost)) $realurl=$object->virtualhost; - // TODO If virtual url defined, we use it - - /*print ' - '.$langs->trans("RealURL").' '; - print ' '; - print ''.$langs->trans("ViewSiteInNewTab").'';*/ - + } + + if ($website && $action == 'preview') + { + $disabled=''; + if (empty($user->rights->websites->create)) $disabled=' disabled="disabled"'; + print '   '; - - print $langs->trans("ViewWebsiteInProduction").': '; - print ''; - //print ''; - $htmltext=$langs->trans("SetHereVirtualHost", $dataroot); - print $form->textwithpicto('', $htmltext); - print ''.$langs->trans("ViewSiteInNewTab").''; - // Example : Adding jquery code - if (! empty($conf->use_javascript_ajax)) - { - print ''; - } + //print ''; + print ''; + print ''; + print ''; } print '
'; @@ -640,13 +615,20 @@ if (count($object->records) > 0) if ($action == 'preview') { - $disabled=''; - if (empty($user->rights->websites->create)) $disabled=' disabled="disabled"'; - - //print ''; - print ''; - print ''; - print ''; + print '
'; + print ''; + //print ''; + $htmltext=$langs->trans("SetHereVirtualHost", $dataroot); + print $form->textwithpicto('', $htmltext); + print '
'; + + print ''; + print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer"), 1, 'preview_ext'); + print ''; + + print ''; + print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr"), 1, 'preview'); + print ''; } if (in_array($action, array('editcss','editmenu','create'))) @@ -674,60 +656,55 @@ if (count($object->records) > 0) print $langs->trans("Page").': '; print ''; print '
'; - $out=''; - $out.=''; + if ($atleastonepage) { - $firstpageid=0;$homepageid=0; + if (empty($pageid) && $action != 'create') // Page id is not defined, we try to take one + { + $firstpageid=0;$homepageid=0; + foreach($array as $key => $valpage) + { + if (empty($firstpageid)) $firstpageid=$valpage->id; + if ($object->fk_default_home && $key == $object->fk_default_home) $homepageid=$valpage->id; + } + $pageid=$homepageid?$homepageid:$firstpageid; // We choose home page and if not defined yet, we take first page + } + foreach($array as $key => $valpage) { - if (empty($firstpageid)) $firstpageid=$valpage->id; - if ($object->fk_default_home && $key == $object->fk_default_home) $homepageid=$valpage->id; + $out.=''; } - $pageid=$homepageid?$homepageid:$firstpageid; // We choose home page and if not defined yet, we take first page - } - - foreach($array as $key => $valpage) - { - $out.=''; } + else $out.=''; + $out.=''; + print $out; + } + else + { + print $langs->trans("New"); } - else $out.=''; - $out.=''; - print $out; print ''; //print $form->selectarray('page', $array); - if ($website && $pageid > 0) - { - print ' - '.$langs->trans("RealURL").' '; - $realurl=$urlwithroot.'/public/websites/index.php?website='.$website.'&page='.$pageid; - print ' '; - print ''.$langs->trans("ViewPageInNewTab").''; // View page in new Tab - //print ''; - } - - print '
'; - print '
'; - print '
'; - - print '
'; - if ($action == 'preview') { $disabled=''; if (empty($user->rights->websites->create)) $disabled=' disabled="disabled"'; - + if ($pageid > 0) { + print '   '; + if ($object->fk_default_home > 0 && $pageid == $object->fk_default_home) print ''; else print ''; print ''; @@ -738,15 +715,79 @@ if (count($object->records) > 0) } } + print '
'; + print '
'; + print '
'; + + print '
'; + + if ($website && $pageid > 0 && $action == 'preview') + { + $websitepage = new WebSitePage($db); + $websitepage->fetch($pageid); + + $realpage=$urlwithroot.'/public/websites/index.php?website='.$website.'&page='.$pageid; + $pagealias = $websitepage->pageurl; + + print '
'; + print ''; + //print ''; + $htmltext=$langs->trans("PageAlias", $pagealias); + print $form->textwithpicto('', $htmltext); + print '
'; + + print ''; + print $form->textwithpicto('', $langs->trans("PreviewPageServedByWebServer"), 1, 'preview_ext'); + print ''; + + print ''; + print $form->textwithpicto('', $langs->trans("PreviewPageServedByDolibarr"), 1, 'preview'); + print ''; // View page in new Tab + //print ''; + + // TODO Add js to save alias like we save virtual host name and use dynamic virtual host for url of id=previewpageext + } if (! in_array($action, array('editcss','editmenu','create'))) { if ($action != 'preview') print ''; if (preg_match('/^create/',$action)) print ''; if (preg_match('/^edit/',$action)) print ''; } - + print '
'; + if ($action == 'preview') + { + // Adding jquery code to change on the fly url of preview ext + if (! empty($conf->use_javascript_ajax)) + { + print ''; + } + } } } else @@ -898,7 +939,7 @@ if ($action == 'editcontent') $doleditor->Create(); } -print '
'; +print '';