Debug module website

This commit is contained in:
Laurent Destailleur 2017-07-02 23:38:19 +02:00
parent b95dea3b50
commit 565de9bc8d
4 changed files with 130 additions and 115 deletions

View File

@ -25,4 +25,5 @@ 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 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.
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 clicking 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

View File

@ -12,9 +12,10 @@ if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't ne
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library
if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session)
// If you don't need session management (can't be logged if no session used). You must also set // If you don't need session management (can't be logged if no session used). You must also set
// NOCSRFCHECK, NOTOKENRENEWAL, NOLOGIN, // NOCSRFCHECK, NOTOKENRENEWAL, NOLOGIN
// Disable module with GETPOST('disablemodules') won't work. Variable 'dol_...' will not be set. // Disable module with GETPOST('disablemodules') won't work. Variable 'dol_...' will not be set.
// $_SESSION are then simple vars if sessions are not active. // $_SESSION are then simple vars if sessions are not active.
// TODO We can close session with session_write_close() as soon as we just need read access.
if (! defined("NOSESSION")) define("NOSESSION",'1'); if (! defined("NOSESSION")) define("NOSESSION",'1');
define('REQUIRE_JQUERY_MULTISELECT','select2'); define('REQUIRE_JQUERY_MULTISELECT','select2');

View File

@ -193,7 +193,6 @@ class WebsitePage extends CommonObject
$sql = 'SELECT'; $sql = 'SELECT';
$sql .= ' t.rowid,'; $sql .= ' t.rowid,';
$sql .= " t.fk_website,"; $sql .= " t.fk_website,";
$sql .= " t.pageurl,"; $sql .= " t.pageurl,";
$sql .= " t.title,"; $sql .= " t.title,";
@ -203,7 +202,6 @@ class WebsitePage extends CommonObject
$sql .= " t.status,"; $sql .= " t.status,";
$sql .= " t.date_creation,"; $sql .= " t.date_creation,";
$sql .= " t.tms as date_modification"; $sql .= " t.tms as date_modification";
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
//$sql .= ' WHERE entity IN ('.getEntity('website').')'; // entity is on website level //$sql .= ' WHERE entity IN ('.getEntity('website').')'; // entity is on website level
$sql .= ' WHERE 1 = 1'; $sql .= ' WHERE 1 = 1';

View File

@ -160,10 +160,17 @@ if ($action == 'add')
$objectpage->description = GETPOST('WEBSITE_DESCRIPTION'); $objectpage->description = GETPOST('WEBSITE_DESCRIPTION');
$objectpage->keywords = GETPOST('WEBSITE_KEYWORD'); $objectpage->keywords = GETPOST('WEBSITE_KEYWORD');
if (empty($objectpage->title)) if (empty($objectpage->pageurl))
{ {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WEBSITE_PAGENAME")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WEBSITE_PAGENAME")), null, 'errors');
$error++; $error++;
$action='create';
}
if (empty($objectpage->title))
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WEBSITE_TITLE")), null, 'errors');
$error++;
$action='create';
} }
if (! $error) if (! $error)
@ -186,8 +193,11 @@ if ($action == 'add')
$db->rollback(); $db->rollback();
} }
$action = 'preview'; if (! $error)
$id = $objectpage->id; {
$action = 'preview';
$id = $objectpage->id;
}
} }
// Update page // Update page
@ -456,12 +466,17 @@ if ($action == 'updatecontent' || GETPOST('refreshsite') || GETPOST('refreshpage
} }
else else
{ {
$res = $objectpage->fetch($object->fk_default_home); $res=0;
if (! $res > 0) if ($object->fk_default_home > 0)
{ {
$res = $objectpage->fetch(0, $object->fk_website); $res = $objectpage->fetch($object->fk_default_home);
}
if (! ($res > 0))
{
$res = $objectpage->fetch(0, $object->id);
} }
} }
if ($res > 0) if ($res > 0)
{ {
if ($action == 'updatecontent') if ($action == 'updatecontent')
@ -586,7 +601,7 @@ if ($action == 'updatecontent' || GETPOST('refreshsite') || GETPOST('refreshpage
} }
else else
{ {
dol_print_error($db, 'Page not found'); setEventMessages($langs->trans("NoPageYet"), null, 'warnings');
} }
} }