Debug module website

This commit is contained in:
Laurent Destailleur 2017-07-03 12:04:45 +02:00
parent 9e26e6b0a3
commit 8b91f4fb5e
3 changed files with 36 additions and 35 deletions

View File

@ -49,7 +49,7 @@ function llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0,
top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
print '<body id="mainbody">'; print '<body id="mainbody">';
// top menu and left menu area // top menu and left menu area
if (empty($conf->dol_hide_topmenu)) if (empty($conf->dol_hide_topmenu))
{ {
@ -108,7 +108,7 @@ if (empty($action)) $action='preview';
*/ */
if (GETPOST('refreshsite')) $pageid=0; // If we change the site, we reset the pageid. if (GETPOST('refreshsite')) $pageid=0; // If we change the site, we reset the pageid.
if (GETPOST('refreshpage')) $action='preview'; if (GETPOST('refreshpage')) $action='preview';
// Add a collab page // Add a collab page
@ -146,7 +146,7 @@ if ($action == 'add')
{ {
$db->rollback(); $db->rollback();
} }
$action = 'preview'; $action = 'preview';
$id = $objectpage->id; $id = $objectpage->id;
} }
@ -173,7 +173,7 @@ if ($action == 'delete')
{ {
$db->commit(); $db->commit();
setEventMessages($langs->trans("PageDeleted", $objectpage->pageurl, $website), null, 'mesgs'); setEventMessages($langs->trans("PageDeleted", $objectpage->pageurl, $website), null, 'mesgs');
header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website); header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website);
exit; exit;
} }
@ -218,7 +218,7 @@ print '<div class="centpercent websitebar">';
if (count($object->records) > 0) if (count($object->records) > 0)
{ {
// ***** Part for web sites // ***** Part for web sites
print '<div class="websiteselection hideonsmartphoneimp">'; print '<div class="websiteselection hideonsmartphoneimp">';
print $langs->trans("Website").': '; print $langs->trans("Website").': ';
print '</div>'; print '</div>';
@ -252,20 +252,20 @@ if (count($object->records) > 0)
$dataroot=DOL_DATA_ROOT.'/websites/'.$website; $dataroot=DOL_DATA_ROOT.'/websites/'.$website;
if (! empty($object->virtualhost)) $virtualurl=$object->virtualhost; if (! empty($object->virtualhost)) $virtualurl=$object->virtualhost;
} }
if ($website && $action == 'preview') if ($website && $action == 'preview')
{ {
$disabled=''; $disabled='';
if (empty($user->rights->websites->write)) $disabled=' disabled="disabled"'; if (empty($user->rights->websites->write)) $disabled=' disabled="disabled"';
print ' &nbsp; '; print ' &nbsp; ';
//print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("MediaFiles")).'" name="editmedia">'; //print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("MediaFiles")).'" name="editmedia">';
print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditCss")).'" name="editcss">'; print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditCss")).'" name="editcss">';
print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditMenu")).'" name="editmenu">'; print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditMenu")).'" name="editmenu">';
print '<input type="submit"'.$disabled.' class="button" value="'.dol_escape_htmltag($langs->trans("AddPage")).'" name="create">'; print '<input type="submit"'.$disabled.' class="button" value="'.dol_escape_htmltag($langs->trans("AddPage")).'" name="create">';
} }
print '</div>'; print '</div>';
// Button for websites // Button for websites
@ -279,7 +279,7 @@ if (count($object->records) > 0)
$htmltext=$langs->trans("SetHereVirtualHost", $dataroot); $htmltext=$langs->trans("SetHereVirtualHost", $dataroot);
print $form->textwithpicto('', $htmltext); print $form->textwithpicto('', $htmltext);
print '</div>'; print '</div>';
$urlext=$virtualurl; $urlext=$virtualurl;
$urlint=$urlwithroot.'/public/websites/index.php?website='.$website; $urlint=$urlwithroot.'/public/websites/index.php?website='.$website;
//if (! empty($object->virtualhost)) //if (! empty($object->virtualhost))
@ -288,7 +288,7 @@ if (count($object->records) > 0)
print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext'); print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext');
print '</a>'; print '</a>';
//} //}
print '<a class="websitebuttonsitepreview" id="previewsite" href="'.$urlwithroot.'/public/websites/index.php?website='.$website.'" target="tab'.$website.'" alt="'.dol_escape_htmltag($langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint)).'">'; print '<a class="websitebuttonsitepreview" id="previewsite" href="'.$urlwithroot.'/public/websites/index.php?website='.$website.'" target="tab'.$website.'" alt="'.dol_escape_htmltag($langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint)).'">';
print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint, $dataroot), 1, 'preview'); print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint, $dataroot), 1, 'preview');
print '</a>'; print '</a>';
@ -300,12 +300,12 @@ if (count($object->records) > 0)
if (preg_match('/^create/',$action)) print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">'; if (preg_match('/^create/',$action)) print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">';
if (preg_match('/^edit/',$action)) print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">'; if (preg_match('/^edit/',$action)) print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">';
} }
print '</div>'; print '</div>';
// ***** Part for pages // ***** Part for pages
if ($website) if ($website)
{ {
print '</div>'; print '</div>';
@ -313,13 +313,13 @@ if (count($object->records) > 0)
$array=$objectpage->fetchAll($object->id); $array=$objectpage->fetchAll($object->id);
if (! is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors); if (! is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors);
$atleastonepage=(is_array($array) && count($array) > 0); $atleastonepage=(is_array($array) && count($array) > 0);
print '<div class="centpercent websitebar"'.($style?' style="'.$style.'"':'').'">'; print '<div class="centpercent websitebar"'.($style?' style="'.$style.'"':'').'">';
print '<div class="websiteselection hideonsmartphoneimp">'; print '<div class="websiteselection hideonsmartphoneimp">';
print $langs->trans("Page").': '; print $langs->trans("Page").': ';
print '</div>'; print '</div>';
print '<div class="websiteselection">'; print '<div class="websiteselection">';
if ($action != 'add') if ($action != 'add')
{ {
$out=''; $out='';
@ -336,7 +336,7 @@ if (count($object->records) > 0)
} }
$pageid=$homepageid?$homepageid:$firstpageid; // We choose home page and if not defined yet, we take first page $pageid=$homepageid?$homepageid:$firstpageid; // We choose home page and if not defined yet, we take first page
} }
foreach($array as $key => $valpage) foreach($array as $key => $valpage)
{ {
$out.='<option value="'.$key.'"'; $out.='<option value="'.$key.'"';
@ -359,16 +359,16 @@ if (count($object->records) > 0)
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 ($action == 'preview') if ($action == 'preview')
{ {
$disabled=''; $disabled='';
if (empty($user->rights->websites->write)) $disabled=' disabled="disabled"'; if (empty($user->rights->websites->write)) $disabled=' disabled="disabled"';
if ($pageid > 0) if ($pageid > 0)
{ {
print ' &nbsp; '; print ' &nbsp; ';
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">';
@ -378,7 +378,7 @@ if (count($object->records) > 0)
print '<input type="submit" class="buttonDelete" name="delete" value="'.$langs->trans("Delete").'"'.($atleastonepage?'':' disabled="disabled"').'>'; print '<input type="submit" class="buttonDelete" name="delete" value="'.$langs->trans("Delete").'"'.($atleastonepage?'':' disabled="disabled"').'>';
} }
} }
print '</div>'; print '</div>';
print '<div class="websiteselection">'; print '<div class="websiteselection">';
print '</div>'; print '</div>';
@ -389,17 +389,17 @@ if (count($object->records) > 0)
{ {
$websitepage = new WebSitePage($db); $websitepage = new WebSitePage($db);
$websitepage->fetch($pageid); $websitepage->fetch($pageid);
$realpage=$urlwithroot.'/public/websites/index.php?website='.$website.'&page='.$pageid; $realpage=$urlwithroot.'/public/websites/index.php?website='.$website.'&page='.$pageid;
$pagealias = $websitepage->pageurl; $pagealias = $websitepage->pageurl;
print '<div class="websiteinputurl">'; print '<div class="websiteinputurl">';
print '<input type="text" id="previewpageurl" class="minwidth200imp" name="previewsite" value="'.$pagealias.'" disabled="disabled">'; 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").'">'; //print '<input type="submit" class="button" name="previewwebsite" target="tab'.$website.'" value="'.$langs->trans("ViewSiteInNewTab").'">';
$htmltext=$langs->trans("WEBSITE_PAGENAME", $pagealias); $htmltext=$langs->trans("WEBSITE_PAGENAME", $pagealias);
print $form->textwithpicto('', $htmltext); print $form->textwithpicto('', $htmltext);
print '</div>'; print '</div>';
if (! empty($object->virtualhost)) if (! empty($object->virtualhost))
{ {
$urlext=$virtualurl.'/'.$pagealias.'.php'; $urlext=$virtualurl.'/'.$pagealias.'.php';
@ -413,12 +413,12 @@ if (count($object->records) > 0)
print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext'); print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext');
print '</a>'; print '</a>';
} }
print '<a class="websitebuttonsitepreview" id="previewpage" href="'.$realpage.'&nocache='.dol_now().'" class="button" target="tab'.$website.'" alt="'.dol_escape_htmltag($langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage)).'">'; print '<a class="websitebuttonsitepreview" id="previewpage" href="'.$realpage.'&nocache='.dol_now().'" class="button" target="tab'.$website.'" alt="'.dol_escape_htmltag($langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage)).'">';
print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage, $dataroot), 1, 'preview'); print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage, $dataroot), 1, 'preview');
print '</a>'; // View page in new Tab print '</a>'; // View page in new Tab
//print '<input type="submit" class="button" name="previewpage" target="tab'.$website.'"value="'.$langs->trans("ViewPageInNewTab").'">'; //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 // 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')))
@ -427,7 +427,7 @@ if (count($object->records) > 0)
if (preg_match('/^create/',$action)) print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">'; if (preg_match('/^create/',$action)) print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">';
if (preg_match('/^edit/',$action)) print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">'; if (preg_match('/^edit/',$action)) print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'" name="update">';
} }
print '</div>'; print '</div>';
if ($action == 'preview') if ($action == 'preview')
@ -454,7 +454,7 @@ if (count($object->records) > 0)
}, },
context: document.body context: document.body
}); });
jQuery("#previewsiteext").attr("href",newurl); jQuery("#previewsiteext").attr("href",newurl);
jQuery("#previewpageext").attr("href",newpage); jQuery("#previewpageext").attr("href",newpage);
}); });
@ -483,15 +483,15 @@ if ($action == 'editcontent')
/* /*
* Editing global variables not related to a specific theme * Editing global variables not related to a specific theme
*/ */
$csscontent = @file_get_contents($filecss); $csscontent = @file_get_contents($filecss);
$contentforedit = ''; $contentforedit = '';
/*$contentforedit.='<style scoped>'."\n"; // "scoped" means "apply to parent element only". Not yet supported by browsers /*$contentforedit.='<style scoped>'."\n"; // "scoped" means "apply to parent element only". Not yet supported by browsers
$contentforedit.=$csscontent; $contentforedit.=$csscontent;
$contentforedit.='</style>'."\n";*/ $contentforedit.='</style>'."\n";*/
$contentforedit .= $objectpage->content; $contentforedit .= $objectpage->content;
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor=new DolEditor('PAGE_CONTENT',$contentforedit,'',500,'Full','',true,true,true,ROWS_5,'90%'); $doleditor=new DolEditor('PAGE_CONTENT',$contentforedit,'',500,'Full','',true,true,true,ROWS_5,'90%');
$doleditor->Create(0, '', false); $doleditor->Create(0, '', false);

View File

@ -6,6 +6,7 @@ ConfirmDeleteWebsite=Are you sure you want to delete this web site. All its page
WEBSITE_PAGENAME=Page name/alias WEBSITE_PAGENAME=Page name/alias
WEBSITE_CSS_URL=URL of external CSS file WEBSITE_CSS_URL=URL of external CSS file
WEBSITE_CSS_INLINE=CSS content WEBSITE_CSS_INLINE=CSS content
PageNameAliasHelp=Name or alias of the page.<br>This alias is also used to forge a SEO URL when website is read from a Virtual host of a Web server (like Apacke, Nginx, ...). Use the button "<strong>%s</strong>" to edit this alias.
MediaFiles=Media library MediaFiles=Media library
EditCss=Edit Style/CSS EditCss=Edit Style/CSS
EditMenu=Edit menu EditMenu=Edit menu
@ -24,7 +25,7 @@ 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 can be done also using this direct web server access and not only using Dolibarr server. SetHereVirtualHost=If you can create, on your web server (Apache, Nginx, ...), a dedicated Virtual Host with PHP enabled and a Root directory on <strong>%s</strong><br>then enter here the virtual hostname you have created, so the preview can be done also using this direct web server access, and not only using Dolibarr server.
PreviewSiteServedByWebServer=Preview %s in a new tab.<br><br>The %s will be served by an external web server (like Apache, Nginx, IIS). You must install and setup this server before to point to directory:<br><strong>%s</strong><br>URL served by external server:<br><strong>%s</strong> PreviewSiteServedByWebServer=Preview %s in a new tab.<br><br>The %s will be served by an external web server (like Apache, Nginx, IIS). You must install and setup this server before to point to directory:<br><strong>%s</strong><br>URL served by external server:<br><strong>%s</strong>
PreviewSiteServedByDolibarr=Preview %s in a new tab.<br><br>The %s will be served by Dolibarr server so it does not need any extra web server (like Apache, Nginx, IIS) to be installed.<br>The inconvenient is that URL of pages are not user friendly and start with path of your Dolibarr.<br>URL served by Dolibarr:<br><strong>%s</strong><br><br>To use your own external web server to serve this web site, create a virtual host on your web server that point on directory<br><strong>%s</strong><br>then enter the name of this virtual server and click on the other preview button. PreviewSiteServedByDolibarr=Preview %s in a new tab.<br><br>The %s will be served by Dolibarr server so it does not need any extra web server (like Apache, Nginx, IIS) to be installed.<br>The inconvenient is that URL of pages are not user friendly and start with path of your Dolibarr.<br>URL served by Dolibarr:<br><strong>%s</strong><br><br>To use your own external web server to serve this web site, create a virtual host on your web server that point on directory<br><strong>%s</strong><br>then enter the name of this virtual server and click on the other preview button.
NoPageYet=No pages yet NoPageYet=No pages yet

View File

@ -727,7 +727,7 @@ if (count($object->records) > 0)
print '<input type="text" id="previewsiteurl" class="minwidth200imp" name="previewsite" placeholder="'.$langs->trans("http://myvirtualhost").'" value="'.$virtualurl.'">'; print '<input type="text" id="previewsiteurl" class="minwidth200imp" name="previewsite" placeholder="'.$langs->trans("http://myvirtualhost").'" value="'.$virtualurl.'">';
//print '<input type="submit" class="button" name="previewwebsite" target="tab'.$website.'" value="'.$langs->trans("ViewSiteInNewTab").'">'; //print '<input type="submit" class="button" name="previewwebsite" target="tab'.$website.'" value="'.$langs->trans("ViewSiteInNewTab").'">';
$htmltext=$langs->trans("SetHereVirtualHost", $dataroot); $htmltext=$langs->trans("SetHereVirtualHost", $dataroot);
print $form->textwithpicto('', $htmltext); print $form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'helpvirtualhost');
print '</div>'; print '</div>';
$urlext=$virtualurl; $urlext=$virtualurl;
@ -846,8 +846,8 @@ if (count($object->records) > 0)
print '<div class="websiteinputurl">'; print '<div class="websiteinputurl">';
print '<input type="text" id="previewpageurl" class="minwidth200imp" name="previewsite" value="'.$pagealias.'" disabled="disabled">'; 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").'">'; //print '<input type="submit" class="button" name="previewwebsite" target="tab'.$website.'" value="'.$langs->trans("ViewSiteInNewTab").'">';
$htmltext=$langs->trans("WEBSITE_PAGENAME", $pagealias); $htmltext=$langs->trans("PageNameAliasHelp", $langs->transnoentitiesnoconv("EditPageMeta"));
print $form->textwithpicto('', $htmltext); print $form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'helppagealias');
print '</div>'; print '</div>';
if (! empty($object->virtualhost)) if (! empty($object->virtualhost))