diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php
index 336a82b4697..d5d4f2d3826 100644
--- a/htdocs/core/lib/website.lib.php
+++ b/htdocs/core/lib/website.lib.php
@@ -31,17 +31,17 @@
function dolWebsiteOutput($content)
{
global $db, $langs, $conf, $user;
- global $dolibarr_main_url_root;
+ global $dolibarr_main_url_root, $dolibarr_main_data_root;
dol_syslog("dolWebsiteOutput start");
+ // Define $urlwithroot
+ $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
+ $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
+ //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
+
if (! defined('USEDOLIBARRSERVER'))
{
- // Define $urlwithroot
- $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
- $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
- //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
-
$symlinktomediaexists=1;
// Make a change into HTML code to allow to include images from medias directory correct with direct link for virtual server
@@ -55,9 +55,17 @@ function dolWebsiteOutput($content)
}
else
{
- $content=preg_replace('/(
The %s will be serve
VirtualHostUrlNotDefined=URL of the virtual host served by external web server not defined
NoPageYet=No pages yet
SyntaxHelp=Help on code syntax
-YouCanEditHtmlSource=You can edit HTML source code using the "Source" button in editor. You can also include PHP code into this source using tags <?php ?>. The following global variables are available: $conf, $langs, $db, $mysoc, $user, $website.
You can also include content of another Page/Content with the following syntax: <?php dolIncludeHtmlContent($websitekey.'/contentaliastoinclude.php'); ?>
+YouCanEditHtmlSource=You can edit HTML source code using the "Source" button in editor. You can also include PHP code into this source using tags <?php ?>. The following global variables are available: $conf, $langs, $db, $mysoc, $user, $website.
You can also include content of another Page/Content with the following syntax: <?php dolIncludeHtmlContent($websitekey.'/contentaliastoinclude.php'); ?>
To include a link to download a file stored into the documents/medias directory, use syntax:
<a href="/document.php?modulepart=medias&file=filename.ext">.
diff --git a/htdocs/public/websites/index.php b/htdocs/public/websites/index.php
index a2dcbfc3dc6..84e0a72f9fd 100644
--- a/htdocs/public/websites/index.php
+++ b/htdocs/public/websites/index.php
@@ -49,6 +49,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$error=0;
$websitekey=GETPOST('website', 'alpha');
$pageid=GETPOST('page', 'alpha')?GETPOST('page', 'alpha'):GETPOST('pageid', 'alpha');
+$pageref=GETPOST('pageref', 'aZ09')?GETPOST('pageref', 'aZ09'):'';
$accessallowed = 1;
$type='';
@@ -70,7 +71,8 @@ if (empty($pageid))
$object=new Website($db);
$object->fetch(0, $websitekey);
- if (empty($object->id))
+
+ if (empty($object->id))
{
if (empty($pageid))
{
@@ -84,23 +86,34 @@ if (empty($pageid))
$objectpage=new WebsitePage($db);
- if ($object->fk_default_home > 0)
+ if ($pageref)
{
- $result=$objectpage->fetch($object->fk_default_home);
+ $result=$objectpage->fetch(0, $object->id, $pageref);
if ($result > 0)
- {
- $pageid = $objectpage->id;
- }
+ {
+ $pageid = $objectpage->id;
+ }
}
-
- if (empty($pageid))
+ else
{
- $array=$objectpage->fetchAll($object->id);
- if (is_array($array) && count($array) > 0)
- {
- $firstrep=reset($array);
- $pageid=$firstrep->id;
- }
+ if ($object->fk_default_home > 0)
+ {
+ $result=$objectpage->fetch($object->fk_default_home);
+ if ($result > 0)
+ {
+ $pageid = $objectpage->id;
+ }
+ }
+
+ if (empty($pageid))
+ {
+ $array=$objectpage->fetchAll($object->id);
+ if (is_array($array) && count($array) > 0)
+ {
+ $firstrep=reset($array);
+ $pageid=$firstrep->id;
+ }
+ }
}
}
if (empty($pageid))
@@ -177,7 +190,7 @@ if (! file_exists($original_file_osencoded))
// Output page content
define('USEDOLIBARRSERVER', 1);
-print "\n".''."\n";
+print ''."\n";
include_once $original_file_osencoded;
diff --git a/htdocs/websites/class/websitepage.class.php b/htdocs/websites/class/websitepage.class.php
index 7d99678fcb6..60661a1af02 100644
--- a/htdocs/websites/class/websitepage.class.php
+++ b/htdocs/websites/class/websitepage.class.php
@@ -181,9 +181,9 @@ class WebsitePage extends CommonObject
/**
* Load object in memory from the database
*
- * @param int $id Id object. If this is 0, the default page of website_id will be used, if not defined, the first one. found
- * @param string $website_id Web site id
- * @param string $page Page name
+ * @param int $id Id object. If this is 0, the default page of website_id will be used, if not defined, the first one found.
+ * @param string $website_id Web site id (page name must also be filled if this parameter is used)
+ * @param string $page Page name (website id must also be filled if this parameter is used)
*
* @return int <0 if KO, 0 if not found, >0 if OK
*/
@@ -205,12 +205,17 @@ class WebsitePage extends CommonObject
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
//$sql .= ' WHERE entity IN ('.getEntity('website').')'; // entity is on website level
$sql .= ' WHERE 1 = 1';
- if (null !== $website_id) {
- $sql .= " AND t.fk_website = '" . $this->db->escape($website_id) . "'";
- if ($page) $sql .= " AND t.pageurl = '" . $this->db->escape($page) . "'";
- } else {
+ if ($id > 0)
+ {
$sql .= ' AND t.rowid = ' . $id;
}
+ else
+ {
+ if (null !== $website_id) {
+ $sql .= " AND t.fk_website = '" . $this->db->escape($website_id) . "'";
+ if ($page) $sql .= " AND t.pageurl = '" . $this->db->escape($page) . "'";
+ }
+ }
$sql .= $this->db->plimit(1);
$resql = $this->db->query($sql);
diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php
index d9ea42096c7..1130d760649 100644
--- a/htdocs/websites/index.php
+++ b/htdocs/websites/index.php
@@ -48,7 +48,7 @@ function llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0,
// html header
top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss);
- print '