diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php
index 37f01a0ffe3..336a82b4697 100644
--- a/htdocs/core/lib/website.lib.php
+++ b/htdocs/core/lib/website.lib.php
@@ -64,3 +64,38 @@ function dolWebsiteOutput($content)
print $content;
}
+
+/**
+ * Clean an HTML page to report only content, so we can include it into another page
+ * It outputs content of file sanitized from html and body part.
+ *
+ * @param string $contentfile Path to file to include (must include website root. Example: 'mywebsite/mypage.php')
+ * @return void
+ */
+function dolIncludeHtmlContent($contentfile)
+{
+ global $conf, $db, $langs, $mysoc, $user, $website;
+ global $includehtmlcontentopened;
+
+ $MAXLEVEL=20;
+
+ $fullpathfile=DOL_DATA_ROOT.'/websites/'.$contentfile;
+ //$content = file_get_contents($fullpathfile);
+ //print preg_replace(array('/^.*
]*>/ims','/<\/body>.*$/ims'), array('', ''), $content);*/
+
+ if (empty($includehtmlcontentopened)) $includehtmlcontentopened=0;
+ $includehtmlcontentopened++;
+ if ($includehtmlcontentopened > $MAXLEVEL)
+ {
+ print 'ERROR: RECURSIVE CONTENT LEVEL. Depth of recursive call is more than the limit of '.$MAXLEVEL.".\n";
+ return;
+ }
+ $res = include $fullpathfile; // Include because we want to execute code content
+ if (! $res)
+ {
+ print 'ERROR: FAILED TO INCLUDE PAGE '.$contentfile.".\n";
+ }
+
+ $includehtmlcontentopened--;
+}
+
diff --git a/htdocs/core/website.inc.php b/htdocs/core/website.inc.php
new file mode 100644
index 00000000000..65db787734a
--- /dev/null
+++ b/htdocs/core/website.inc.php
@@ -0,0 +1,28 @@
+
+ *
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see .
+* or see http://www.gnu.org/
+*/
+
+/**
+ * \file htdocs/core/website.inc.php
+ * \brief Common file loaded used by all website pages (after master.inc.php)
+ * The global variable $website must be defined.
+ */
+
+
+include_once DOL_DOCUMENT_ROOT.'/websites/class/website.class.php';
+$website=new Website($db);
+$website->fetch(0,$websitekey);
diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang
index 1eda648880d..b3af3d3e0fc 100644
--- a/htdocs/langs/en_US/website.lang
+++ b/htdocs/langs/en_US/website.lang
@@ -19,8 +19,9 @@ AddPage=Add page
HomePage=Home Page
PreviewOfSiteNotYetAvailable=Preview of your website %s not yet available. You must first add a page.
RequestedPageHasNoContentYet=Requested page with id %s has no content yet, or cache file .tpl.php was removed. Edit content of the page to solve this.
-PageDeleted=Page '%s' of website %s deleted
-PageAdded=Page '%s' added
+PageContent=Page/Content
+PageDeleted=Page/Content '%s' of website %s deleted
+PageAdded=Page/Content '%s' added
ViewSiteInNewTab=View site in new tab
ViewPageInNewTab=View page in new tab
SetAsHomePage=Set as Home page
@@ -29,4 +30,6 @@ ViewWebsiteInProduction=View web site using home URLs
SetHereVirtualHost=If you can create, on your web server (Apache, Nginx, ...), a dedicated Virtual Host with PHP enabled and a Root directory on %s 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.
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: %s URL served by external server: %s
PreviewSiteServedByDolibarr=Preview %s in a new tab.
The %s will be served by Dolibarr server so it does not need any extra web server (like Apache, Nginx, IIS) to be installed. The inconvenient is that URL of pages are not user friendly and start with path of your Dolibarr. URL served by Dolibarr: %s
To use your own external web server to serve this web site, create a virtual host on your web server that point on directory %s then enter the name of this virtual server and click on the other preview button.
-NoPageYet=No pages yet
\ No newline at end of file
+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'); ?>
\ No newline at end of file
diff --git a/htdocs/public/websites/index.php b/htdocs/public/websites/index.php
index 0bc85dce463..a2dcbfc3dc6 100644
--- a/htdocs/public/websites/index.php
+++ b/htdocs/public/websites/index.php
@@ -47,7 +47,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$error=0;
-$website=GETPOST('website', 'alpha');
+$websitekey=GETPOST('website', 'alpha');
$pageid=GETPOST('page', 'alpha')?GETPOST('page', 'alpha'):GETPOST('pageid', 'alpha');
$accessallowed = 1;
@@ -69,7 +69,7 @@ if (empty($pageid))
require_once DOL_DOCUMENT_ROOT.'/websites/class/websitepage.class.php';
$object=new Website($db);
- $object->fetch(0, $website);
+ $object->fetch(0, $websitekey);
if (empty($object->id))
{
if (empty($pageid))
@@ -125,11 +125,11 @@ if ($pageid == 'css') // No more used ?
//if (empty($dolibarr_nocache)) header('Cache-Control: max-age=3600, public, must-revalidate');
//else
header('Cache-Control: no-cache');
- $original_file=$dolibarr_main_data_root.'/websites/'.$website.'/styles.css.php';
+ $original_file=$dolibarr_main_data_root.'/websites/'.$websitekey.'/styles.css.php';
}
else
{
- $original_file=$dolibarr_main_data_root.'/websites/'.$website.'/page'.$pageid.'.tpl.php';
+ $original_file=$dolibarr_main_data_root.'/websites/'.$websitekey.'/page'.$pageid.'.tpl.php';
}
// Find the subdirectory name as the reference
diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php
index b82fd096cfe..7bd3d913782 100644
--- a/htdocs/theme/eldy/style.css.php
+++ b/htdocs/theme/eldy/style.css.php
@@ -3347,6 +3347,11 @@ a.websitebuttonsitepreview img {
width: 26px;
display: inline-block;
}
+.websitehelp {
+ vertical-align: middle;
+ float: right;
+ padding-top: 8px;
+}
/* ============================================================================== */
diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php
index fb774e8793b..b190a3fad67 100644
--- a/htdocs/theme/md/style.css.php
+++ b/htdocs/theme/md/style.css.php
@@ -3428,7 +3428,11 @@ a.websitebuttonsitepreview img {
.websiteiframenoborder {
border: 0px;
}
-
+.websitehelp {
+ vertical-align: middle;
+ float: right;
+ padding-top: 8px;
+}
/* ============================================================================== */
/* Module agenda */
diff --git a/htdocs/websites/class/website.class.php b/htdocs/websites/class/website.class.php
index a77079c94a6..7f973a15200 100644
--- a/htdocs/websites/class/website.class.php
+++ b/htdocs/websites/class/website.class.php
@@ -48,11 +48,6 @@ class Website extends CommonObject
*/
public $table_element = 'website';
- /**
- * @var WebsitePage[] Lines of all pages
- */
- public $lines = array();
-
/**
* @var int
*/
@@ -85,13 +80,7 @@ class Website extends CommonObject
* @var string
*/
public $virtualhost;
-
-
- public $records;
-
- /**
- */
-
+
/**
* Constructor
@@ -218,7 +207,7 @@ class Website extends CommonObject
$sql .= " t.tms";
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
if (null !== $ref) {
- $sql .= ' WHERE t.ref = ' . '\'' . $ref . '\'';
+ $sql .= " WHERE t.ref = '" . $this->db->escape($ref) . "'";
} else {
$sql .= ' WHERE t.rowid = ' . $id;
}
@@ -230,7 +219,7 @@ class Website extends CommonObject
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
-
+
$this->entity = $obj->entity;
$this->ref = $obj->ref;
$this->description = $obj->description;
@@ -297,7 +286,7 @@ class Website extends CommonObject
if (count($sqlwhere) > 0) {
$sql .= ' WHERE ' . implode(' '.$filtermode.' ', $sqlwhere);
}
-
+
if (!empty($sortfield)) {
$sql .= $this->db->order($sortfield,$sortorder);
}
@@ -314,7 +303,7 @@ class Website extends CommonObject
$line = new self($this->db);
$line->id = $obj->rowid;
-
+
$line->entity = $obj->entity;
$line->ref = $obj->ref;
$line->description = $obj->description;
@@ -354,7 +343,7 @@ class Website extends CommonObject
dol_syslog(__METHOD__, LOG_DEBUG);
// Clean parameters
-
+
if (isset($this->entity)) {
$this->entity = trim($this->entity);
}
@@ -552,7 +541,7 @@ class Website extends CommonObject
$result.= $link . $this->ref . $linkend;
return $result;
}
-
+
/**
* Retourne le libelle du status d'un user (actif, inactif)
*
@@ -607,8 +596,8 @@ class Website extends CommonObject
if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
}
}
-
-
+
+
/**
* Initialise object with example values
* Id must be 0 if object instance is a specimen
@@ -618,9 +607,9 @@ class Website extends CommonObject
public function initAsSpecimen()
{
global $user;
-
+
$this->id = 0;
-
+
$this->entity = 1;
$this->ref = 'myspecimenwebsite';
$this->description = 'A specimen website';
@@ -632,7 +621,7 @@ class Website extends CommonObject
$this->date_creation = dol_now();
$this->tms = dol_now();
-
+
}
}
diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php
index 2c9c364edac..535c1a063df 100644
--- a/htdocs/websites/index.php
+++ b/htdocs/websites/index.php
@@ -245,7 +245,7 @@ if ($action == 'updatecss')
// Html header file
$htmlheadercontent = ''."\n";
- $htmlheadercontent.= ''."\n";
+ $htmlheadercontent.= ''."\n";
$htmlheadercontent.= ''."\n";
$htmlheadercontent.= GETPOST('WEBSITE_HTML_HEADER');
@@ -264,7 +264,7 @@ if ($action == 'updatecss')
// Css file
$csscontent = ''."\n";
- $csscontent.= ''."\n";
+ $csscontent.= ''."\n";
$csscontent.= '"."\n";
@@ -372,12 +372,13 @@ if ($action == 'updatemeta')
// Now generate the master.inc.php page
- dol_syslog("We regenerate the master file");
+ dol_syslog("We regenerate the master file (because we update meta)");
dol_delete_file($filemaster);
$mastercontent = ''."\n";
$result = file_put_contents($filemaster, $mastercontent);
if (! empty($conf->global->MAIN_UMASK))
@@ -565,8 +566,10 @@ if ($action == 'updatecontent' || GETPOST('refreshsite') || GETPOST('refreshpage
$tplcontent ='';
$tplcontent.= "\n";
$tplcontent.= ''."\n";
@@ -746,12 +749,9 @@ if (count($object->records) > 0)
$urlext=$virtualurl;
$urlint=$urlwithroot.'/public/websites/index.php?website='.$website;
- //if (! empty($object->virtualhost))
- //{
- print 'transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext)).'">';
- print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext');
- print '';
- //}
+ print 'transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext)).'">';
+ print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext?$urlext:$langs->trans("VirtualHostUrlNotDefined")), 1, 'preview_ext');
+ print '';
print 'transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint)).'">';
print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint, $dataroot), 1, 'preview');
@@ -822,7 +822,6 @@ if (count($object->records) > 0)
}
print '';
- //print $form->selectarray('page', $array);
if ($action == 'preview')
{
@@ -843,8 +842,6 @@ if (count($object->records) > 0)
}
}
- print '';
- print '