Work on module website
This commit is contained in:
parent
5146a0ce56
commit
4228a51f18
@ -22,4 +22,4 @@ ViewPageInNewTab=View page in new tab
|
|||||||
SetAsHomePage=Set as Home page
|
SetAsHomePage=Set as Home page
|
||||||
RealURL=Real URL
|
RealURL=Real URL
|
||||||
ViewWebsiteInProduction=View web site using home URLs
|
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 <strong>%s</strong>, 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 <strong>%s</strong>, define here the virtual hostname so the preview can be done also using this direct web server access and not only using Dolibarr server.
|
||||||
|
|||||||
BIN
htdocs/theme/eldy/img/preview.png
Normal file
BIN
htdocs/theme/eldy/img/preview.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 381 B |
BIN
htdocs/theme/eldy/img/preview_ext.png
Normal file
BIN
htdocs/theme/eldy/img/preview_ext.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 564 B |
@ -1397,7 +1397,9 @@ div.login a:hover {
|
|||||||
}
|
}
|
||||||
div.login_block_user {
|
div.login_block_user {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
<?php if (empty($conf->global->THEME_TOPMENU_DISABLE_IMAGE)) { ?>
|
||||||
min-width: 120px;
|
min-width: 120px;
|
||||||
|
<?php } ?>
|
||||||
}
|
}
|
||||||
div.login_block_other {
|
div.login_block_other {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
@ -3319,11 +3321,18 @@ td.hidden {
|
|||||||
}
|
}
|
||||||
.websitetools {
|
.websitetools {
|
||||||
float: right;
|
float: right;
|
||||||
padding-top: 2px;
|
}
|
||||||
|
.websiteinputurl {
|
||||||
|
display: inline-block;
|
||||||
|
vertical-align: top;
|
||||||
}
|
}
|
||||||
.websiteiframenoborder {
|
.websiteiframenoborder {
|
||||||
border: 0px;
|
border: 0px;
|
||||||
}
|
}
|
||||||
|
a.websitebuttonsitepreview img {
|
||||||
|
width: 26px;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ============================================================================== */
|
/* ============================================================================== */
|
||||||
|
|||||||
BIN
htdocs/theme/md/img/preview.png
Normal file
BIN
htdocs/theme/md/img/preview.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 381 B |
BIN
htdocs/theme/md/img/preview_ext.png
Normal file
BIN
htdocs/theme/md/img/preview_ext.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 564 B |
@ -183,7 +183,7 @@ class WebsitePage extends CommonObject
|
|||||||
* Load object in memory from the database
|
* Load object in memory from the database
|
||||||
*
|
*
|
||||||
* @param int $id Id object
|
* @param int $id Id object
|
||||||
* @param string $website_id Web site page
|
* @param string $website_id Web site id
|
||||||
* @param string $page Page name
|
* @param string $page Page name
|
||||||
*
|
*
|
||||||
* @return int <0 if KO, 0 if not found, >0 if OK
|
* @return int <0 if KO, 0 if not found, >0 if OK
|
||||||
|
|||||||
@ -177,6 +177,9 @@ if ($action == 'add')
|
|||||||
{
|
{
|
||||||
$db->rollback();
|
$db->rollback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$action = 'preview';
|
||||||
|
$id = $objectpage->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update page
|
// Update page
|
||||||
@ -516,7 +519,7 @@ $help_url='';
|
|||||||
|
|
||||||
llxHeader('', $langs->trans("WebsiteSetup"), $help_url);
|
llxHeader('', $langs->trans("WebsiteSetup"), $help_url);
|
||||||
|
|
||||||
print "\n".'<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
print "\n".'<form action="'.$_SERVER["PHP_SELF"].'" method="POST"><div>';
|
||||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
if ($action == 'create')
|
if ($action == 'create')
|
||||||
{
|
{
|
||||||
@ -590,47 +593,19 @@ if (count($object->records) > 0)
|
|||||||
$realurl=$urlwithroot.'/public/websites/index.php?website='.$website;
|
$realurl=$urlwithroot.'/public/websites/index.php?website='.$website;
|
||||||
$dataroot=DOL_DATA_ROOT.'/websites/'.$website;
|
$dataroot=DOL_DATA_ROOT.'/websites/'.$website;
|
||||||
if (! empty($object->virtualhost)) $realurl=$object->virtualhost;
|
if (! empty($object->virtualhost)) $realurl=$object->virtualhost;
|
||||||
// TODO If virtual url defined, we use it
|
}
|
||||||
|
|
||||||
/*print ' - '.$langs->trans("RealURL").' ';
|
if ($website && $action == 'preview')
|
||||||
print '<input type="text" name="realurl" value="'.$realurl.'"> ';
|
{
|
||||||
print '<a href="'.DOL_URL_ROOT.'/public/websites/index.php?website='.$website.'" target="tab'.$website.'">'.$langs->trans("ViewSiteInNewTab").'</a>';*/
|
$disabled='';
|
||||||
|
if (empty($user->rights->websites->create)) $disabled=' disabled="disabled"';
|
||||||
|
|
||||||
print ' ';
|
print ' ';
|
||||||
|
|
||||||
print $langs->trans("ViewWebsiteInProduction").': ';
|
//print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("MediaFiles")).'" name="editmedia">';
|
||||||
print '<input type="text" id="previewsiteurl" class="minwidth200imp" name="previewsite" value="'.$realurl.'">';
|
print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditCss")).'" name="editcss">';
|
||||||
//print '<input type="submit" class="button" name="previewwebsite" target="tab'.$website.'" value="'.$langs->trans("ViewSiteInNewTab").'">';
|
print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditMenu")).'" name="editmenu">';
|
||||||
$htmltext=$langs->trans("SetHereVirtualHost", $dataroot);
|
print '<input type="submit"'.$disabled.' class="button" value="'.dol_escape_htmltag($langs->trans("AddPage")).'" name="create">';
|
||||||
print $form->textwithpicto('', $htmltext);
|
|
||||||
print '<a class="button" id="previewsite" href="'.DOL_URL_ROOT.'/public/websites/index.php?website='.$website.'" target="tab'.$website.'">'.$langs->trans("ViewSiteInNewTab").'</a>';
|
|
||||||
|
|
||||||
// Example : Adding jquery code
|
|
||||||
if (! empty($conf->use_javascript_ajax))
|
|
||||||
{
|
|
||||||
print '<script type="text/javascript" language="javascript">
|
|
||||||
jQuery(document).ready(function() {
|
|
||||||
jQuery("#previewsite").click(function() {
|
|
||||||
newurl=jQuery("#previewsiteurl").val();
|
|
||||||
console.log("Open url "+newurl);
|
|
||||||
/* Save url */
|
|
||||||
jQuery.ajax({
|
|
||||||
method: "POST",
|
|
||||||
url: "'.DOL_URL_ROOT.'/core/ajax/saveinplace.php",
|
|
||||||
data: {
|
|
||||||
field: \'editval_virtualhost\',
|
|
||||||
element: \'websites\',
|
|
||||||
table_element: \'website\',
|
|
||||||
fk_element: '.$object->id.',
|
|
||||||
value: newurl,
|
|
||||||
},
|
|
||||||
context: document.body
|
|
||||||
});
|
|
||||||
$(this).attr("href",newurl);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
print '</div>';
|
print '</div>';
|
||||||
@ -640,13 +615,20 @@ if (count($object->records) > 0)
|
|||||||
|
|
||||||
if ($action == 'preview')
|
if ($action == 'preview')
|
||||||
{
|
{
|
||||||
$disabled='';
|
print '<div class="websiteinputurl">';
|
||||||
if (empty($user->rights->websites->create)) $disabled=' disabled="disabled"';
|
print '<input type="text" id="previewsiteurl" class="minwidth200imp" name="previewsite" value="'.$realurl.'">';
|
||||||
|
//print '<input type="submit" class="button" name="previewwebsite" target="tab'.$website.'" value="'.$langs->trans("ViewSiteInNewTab").'">';
|
||||||
|
$htmltext=$langs->trans("SetHereVirtualHost", $dataroot);
|
||||||
|
print $form->textwithpicto('', $htmltext);
|
||||||
|
print '</div>';
|
||||||
|
|
||||||
//print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("MediaFiles")).'" name="editmedia">';
|
print '<a class="websitebuttonsitepreview" id="previewsiteext" href="'.DOL_URL_ROOT.'/public/websites/index.php?website='.$website.'" target="tab'.$website.'" alt="'.dol_escape_htmltag($langs->trans("PreviewSiteServedByWebServer")).'">';
|
||||||
print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditCss")).'" name="editcss">';
|
print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer"), 1, 'preview_ext');
|
||||||
print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditMenu")).'" name="editmenu">';
|
print '</a>';
|
||||||
print '<input type="submit"'.$disabled.' class="button" value="'.dol_escape_htmltag($langs->trans("AddPage")).'" name="create">';
|
|
||||||
|
print '<a class="websitebuttonsitepreview" id="previewsite" href="'.DOL_URL_ROOT.'/public/websites/index.php?website='.$website.'" target="tab'.$website.'" alt="'.dol_escape_htmltag($langs->trans("PreviewSiteServedByDolibarr")).'">';
|
||||||
|
print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr"), 1, 'preview');
|
||||||
|
print '</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_array($action, array('editcss','editmenu','create')))
|
if (in_array($action, array('editcss','editmenu','create')))
|
||||||
@ -674,6 +656,9 @@ if (count($object->records) > 0)
|
|||||||
print $langs->trans("Page").': ';
|
print $langs->trans("Page").': ';
|
||||||
print '</div>';
|
print '</div>';
|
||||||
print '<div class="websiteselection">';
|
print '<div class="websiteselection">';
|
||||||
|
|
||||||
|
if ($action != 'add')
|
||||||
|
{
|
||||||
$out='';
|
$out='';
|
||||||
$out.='<select name="pageid">';
|
$out.='<select name="pageid">';
|
||||||
if ($atleastonepage)
|
if ($atleastonepage)
|
||||||
@ -702,25 +687,15 @@ if (count($object->records) > 0)
|
|||||||
else $out.='<option value="-1"> </option>';
|
else $out.='<option value="-1"> </option>';
|
||||||
$out.='</select>';
|
$out.='</select>';
|
||||||
print $out;
|
print $out;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $langs->trans("New");
|
||||||
|
}
|
||||||
|
|
||||||
print '<input type="submit" class="button" name="refreshpage" value="'.$langs->trans("Load").'"'.($atleastonepage?'':' disabled="disabled"').'>';
|
print '<input type="submit" class="button" name="refreshpage" value="'.$langs->trans("Load").'"'.($atleastonepage?'':' disabled="disabled"').'>';
|
||||||
//print $form->selectarray('page', $array);
|
//print $form->selectarray('page', $array);
|
||||||
|
|
||||||
if ($website && $pageid > 0)
|
|
||||||
{
|
|
||||||
print ' - '.$langs->trans("RealURL").' ';
|
|
||||||
$realurl=$urlwithroot.'/public/websites/index.php?website='.$website.'&page='.$pageid;
|
|
||||||
print '<input type="text" name="realurl" class="minwidth200imp" disabled="disabled" value="'.$realurl.'"> ';
|
|
||||||
print '<a href="'.$realurl.'&nocache='.dol_now().'" class="button" target="tab'.$website.'">'.$langs->trans("ViewPageInNewTab").'</a>'; // View page in new Tab
|
|
||||||
//print '<input type="submit" class="button" name="previewpage" target="tab'.$website.'"value="'.$langs->trans("ViewPageInNewTab").'">';
|
|
||||||
}
|
|
||||||
|
|
||||||
print '</div>';
|
|
||||||
print '<div class="websiteselection">';
|
|
||||||
print '</div>';
|
|
||||||
|
|
||||||
print '<div class="websitetools">';
|
|
||||||
|
|
||||||
if ($action == 'preview')
|
if ($action == 'preview')
|
||||||
{
|
{
|
||||||
$disabled='';
|
$disabled='';
|
||||||
@ -728,6 +703,8 @@ if (count($object->records) > 0)
|
|||||||
|
|
||||||
if ($pageid > 0)
|
if ($pageid > 0)
|
||||||
{
|
{
|
||||||
|
print ' ';
|
||||||
|
|
||||||
if ($object->fk_default_home > 0 && $pageid == $object->fk_default_home) print '<input type="submit" class="button" disabled="disabled" value="'.dol_escape_htmltag($langs->trans("SetAsHomePage")).'" name="setashome">';
|
if ($object->fk_default_home > 0 && $pageid == $object->fk_default_home) print '<input type="submit" class="button" disabled="disabled" value="'.dol_escape_htmltag($langs->trans("SetAsHomePage")).'" name="setashome">';
|
||||||
else print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("SetAsHomePage")).'" name="setashome">';
|
else print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("SetAsHomePage")).'" name="setashome">';
|
||||||
print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditPageMeta")).'" name="editmeta">';
|
print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditPageMeta")).'" name="editmeta">';
|
||||||
@ -738,6 +715,38 @@ if (count($object->records) > 0)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print '</div>';
|
||||||
|
print '<div class="websiteselection">';
|
||||||
|
print '</div>';
|
||||||
|
|
||||||
|
print '<div class="websitetools">';
|
||||||
|
|
||||||
|
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 '<div class="websiteinputurl">';
|
||||||
|
print '<input type="text" id="previewpageurl" class="minwidth200imp" name="previewsite" value="'.$pagealias.'" disabled="disabled">';
|
||||||
|
//print '<input type="submit" class="button" name="previewwebsite" target="tab'.$website.'" value="'.$langs->trans("ViewSiteInNewTab").'">';
|
||||||
|
$htmltext=$langs->trans("PageAlias", $pagealias);
|
||||||
|
print $form->textwithpicto('', $htmltext);
|
||||||
|
print '</div>';
|
||||||
|
|
||||||
|
print '<a class="websitebuttonsitepreview" id="previewpageext" href="'.$realurl.'/'.$pagealias.'.php" target="tab'.$website.'" alt="'.dol_escape_htmltag($langs->trans("PreviewSiteServedByWebServer")).'">';
|
||||||
|
print $form->textwithpicto('', $langs->trans("PreviewPageServedByWebServer"), 1, 'preview_ext');
|
||||||
|
print '</a>';
|
||||||
|
|
||||||
|
print '<a class="websitebuttonsitepreview" id="previewpage" href="'.$realpage.'&nocache='.dol_now().'" class="button" target="tab'.$website.'">';
|
||||||
|
print $form->textwithpicto('', $langs->trans("PreviewPageServedByDolibarr"), 1, 'preview');
|
||||||
|
print '</a>'; // View page in new Tab
|
||||||
|
//print '<input type="submit" class="button" name="previewpage" target="tab'.$website.'"value="'.$langs->trans("ViewPageInNewTab").'">';
|
||||||
|
|
||||||
|
// 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 (! in_array($action, array('editcss','editmenu','create')))
|
||||||
{
|
{
|
||||||
if ($action != 'preview') print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Cancel")).'" name="preview">';
|
if ($action != 'preview') print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Cancel")).'" name="preview">';
|
||||||
@ -747,6 +756,38 @@ if (count($object->records) > 0)
|
|||||||
|
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
|
if ($action == 'preview')
|
||||||
|
{
|
||||||
|
// Adding jquery code to change on the fly url of preview ext
|
||||||
|
if (! empty($conf->use_javascript_ajax))
|
||||||
|
{
|
||||||
|
print '<script type="text/javascript" language="javascript">
|
||||||
|
jQuery(document).ready(function() {
|
||||||
|
jQuery("#previewsiteext,#previewpageext").click(function() {
|
||||||
|
newurl=jQuery("#previewsiteurl").val();
|
||||||
|
newpage=jQuery("#previewsiteurl").val() + "/" + jQuery("#previewpageurl").val() + ".php";
|
||||||
|
console.log("Open url "+newurl);
|
||||||
|
/* Save url */
|
||||||
|
jQuery.ajax({
|
||||||
|
method: "POST",
|
||||||
|
url: "'.DOL_URL_ROOT.'/core/ajax/saveinplace.php",
|
||||||
|
data: {
|
||||||
|
field: \'editval_virtualhost\',
|
||||||
|
element: \'websites\',
|
||||||
|
table_element: \'website\',
|
||||||
|
fk_element: '.$object->id.',
|
||||||
|
value: newurl,
|
||||||
|
},
|
||||||
|
context: document.body
|
||||||
|
});
|
||||||
|
|
||||||
|
jQuery("#previewsiteext").attr("href",newurl);
|
||||||
|
jQuery("#previewpageext").attr("href",newpage);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -898,7 +939,7 @@ if ($action == 'editcontent')
|
|||||||
$doleditor->Create();
|
$doleditor->Create();
|
||||||
}
|
}
|
||||||
|
|
||||||
print '</form>';
|
print '</div></form>';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user