From 4228a51f18439e6f0cd93b86131acdbea093b8a4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 14 Sep 2016 23:23:22 +0200 Subject: [PATCH] Work on module website --- htdocs/langs/en_US/website.lang | 2 +- htdocs/theme/eldy/img/preview.png | Bin 0 -> 381 bytes htdocs/theme/eldy/img/preview_ext.png | Bin 0 -> 564 bytes htdocs/theme/eldy/style.css.php | 11 +- htdocs/theme/md/img/preview.png | Bin 0 -> 381 bytes htdocs/theme/md/img/preview_ext.png | Bin 0 -> 564 bytes htdocs/websites/class/websitepage.class.php | 2 +- htdocs/websites/index.php | 213 ++++++++++++-------- 8 files changed, 139 insertions(+), 89 deletions(-) create mode 100644 htdocs/theme/eldy/img/preview.png create mode 100644 htdocs/theme/eldy/img/preview_ext.png create mode 100644 htdocs/theme/md/img/preview.png create mode 100644 htdocs/theme/md/img/preview_ext.png 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 0000000000000000000000000000000000000000..9040bf963f71692719de25fe7aa61245704e70a6 GIT binary patch literal 381 zcmV-@0fPRCP)<-;cRN?Ix=92sb`&c zF)d_(qJpW;iZf@H)G(D%QXnSF_oe7d0mb|d@h$}vF;#9Wlfn>h62Q!iHU%<76zH%( z(YFXO;EqkadIub0=N+(!uJC2@Qh-XgB}>0mVr~K~z}7 z?Up@D12G)Ne=6ERMQ|2D4@BIwXi?C`QEd?i2VcOi;V6P2h@YaqOtymBp|om25OERh z=2s|HTdGUrU>e(Au6LR`c~6Ff|8qRQyW|oAzI^$r)-W+%5r(b6DZ~2sym5G?<#mWy z)8Yk!cqO()0bc2D;&c}(Y2N_R}Sl5 ziVNlL*3@@YJ#D&^L&}eEMUf(xEU4Oq`B9OjtHD>dab$kjrCbn)rT{^fN!!yCv?;`a zDL^1du#QE5b}TkXBRFzF{1BjP)rhDkz?eW-qE8@#j$=o}lZT@sOn^DU^fK!>uF*14 ziP&bu?X(dvPo5y~%nLmZ<4k?RF)M7b>3(e~!VL@L_+Xkl$FWVzJZRzz_9;q1j!|y8 z$Ku^_tdVYVl7D;o%`v3EU&nbf4u9iBAMeZ8|J5h{4amxDJBmI40000global->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 0000000000000000000000000000000000000000..9040bf963f71692719de25fe7aa61245704e70a6 GIT binary patch literal 381 zcmV-@0fPRCP)<-;cRN?Ix=92sb`&c zF)d_(qJpW;iZf@H)G(D%QXnSF_oe7d0mb|d@h$}vF;#9Wlfn>h62Q!iHU%<76zH%( z(YFXO;EqkadIub0=N+(!uJC2@Qh-XgB}>0mVr~K~z}7 z?Up@D12G)Ne=6ERMQ|2D4@BIwXi?C`QEd?i2VcOi;V6P2h@YaqOtymBp|om25OERh z=2s|HTdGUrU>e(Au6LR`c~6Ff|8qRQyW|oAzI^$r)-W+%5r(b6DZ~2sym5G?<#mWy z)8Yk!cqO()0bc2D;&c}(Y2N_R}Sl5 ziVNlL*3@@YJ#D&^L&}eEMUf(xEU4Oq`B9OjtHD>dab$kjrCbn)rT{^fN!!yCv?;`a zDL^1du#QE5b}TkXBRFzF{1BjP)rhDkz?eW-qE8@#j$=o}lZT@sOn^DU^fK!>uF*14 ziP&bu?X(dvPo5y~%nLmZ<4k?RF)M7b>3(e~!VL@L_+Xkl$FWVzJZRzz_9;q1j!|y8 z$Ku^_tdVYVl7D;o%`v3EU&nbf4u9iBAMeZ8|J5h{4amxDJBmI400000 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 '';