diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 588715b6567..4c4e51c4b13 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -516,7 +516,7 @@ class Form
* @param string $text Text to show
* @param string $htmltext Content of tooltip
* @param int $direction 1=Icon is after text, -1=Icon is before text, 0=no icon
- * @param string $type Type of picto ('info', 'help', 'warning', 'superadmin', 'mypicto@mymodule', ...) or image filepath
+ * @param string $type Type of picto ('info', 'help', 'warning', 'superadmin', 'mypicto@mymodule', ...) or image filepath or 'none'
* @param string $extracss Add a CSS style to td, div or span tag
* @param int $noencodehtmltext Do not encode into html entity the htmltext
* @param int $notabs 0=Include table and tr tags, 1=Do not include table and tr tags, 2=use div, 3=use span
@@ -557,12 +557,13 @@ class Form
if ($type == 'info' || $type == 'help') return $text;
}
+ $img='';
if ($type == 'info') $img = img_help(0, $alt);
elseif ($type == 'help') $img = img_help(($tooltiptrigger != '' ? 2 : 1), $alt);
elseif ($type == 'superadmin') $img = img_picto($alt, 'redstar');
elseif ($type == 'admin') $img = img_picto($alt, 'star');
elseif ($type == 'warning') $img = img_warning($alt);
- else $img = img_picto($alt, $type);
+ elseif ($type != 'none') $img = img_picto($alt, $type); // $type can be an image path
return $this->textwithtooltip($text, $htmltext, (($tooltiptrigger && ! $img)?3:2), $direction, $img, $extracss, $notabs, '', $noencodehtmltext, $tooltiptrigger, $forcenowrap);
}
diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang
index d5dd5827a70..f8250ebbc6b 100644
--- a/htdocs/langs/en_US/website.lang
+++ b/htdocs/langs/en_US/website.lang
@@ -39,11 +39,12 @@ ViewPageInNewTab=View page in new tab
SetAsHomePage=Set as Home page
RealURL=Real URL
ViewWebsiteInProduction=View web site using home URLs
-SetHereVirtualHost=Use with Apache/NGinx/...
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 dedicated web server access instead of only using Dolibarr server.
+SetHereVirtualHost=Use with Apache/NGinx/...
If you can create, on your web server (Apache, Nginx, ...), a dedicated Virtual Host with PHP enabled and a Root directory on
%s
then set the name of the virtual host you have created in the properties of web site, so the preview can be done also using this dedicated web server access instead of the internal Dolibarr server.
YouCanAlsoTestWithPHPS=Use with PHP embedded server
On develop environment, you may prefer to test the site with the PHP embedded web server (PHP 5.5 required) by running
php -S 0.0.0.0:8080 -t %s
CheckVirtualHostPerms=Check also that virtual host has permission %s on files into
%s
ReadPerm=Read
WritePerm=Write
+TestDeployOnWeb=Test/deploy on web
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.
VirtualHostUrlNotDefined=URL of the virtual host served by external web server not defined
diff --git a/htdocs/website/index.php b/htdocs/website/index.php
index 6824ae80360..88fb642d50a 100644
--- a/htdocs/website/index.php
+++ b/htdocs/website/index.php
@@ -298,7 +298,7 @@ if ($action == 'addsite')
$tmpobject=new Website($db);
$tmpobject->ref = GETPOST('WEBSITE_REF','alpha');
$tmpobject->description = GETPOST('WEBSITE_DESCRIPTION','alpha');
- $tmpobject->virtualhost = GETPOST('WEBSITE_VIRTUALHOST','alpha');
+ $tmpobject->virtualhost = GETPOST('virtualhost','alpha');
$result = $tmpobject->create($user);
if ($result <= 0)
@@ -867,180 +867,207 @@ if ($action == 'updatecss')
$res = $object->fetch(0, $websitekey);
$website = $object;
- // Save master.inc.php file
- $filemaster=$pathofwebsite.'/master.inc.php';
-
- dol_syslog("Save master file ".$filemaster);
-
- dol_mkdir($pathofwebsite);
-
- // Now generate the master.inc.php page
- $result = dolSaveMasterFile($filemaster);
- if (! $result) setEventMessages('Failed to write file '.$filemaster, null, 'errors');
-
-
- // Html header file
- $htmlheadercontent ='';
-
- /* We disable php code since htmlheader is never executed as an include but only read by fgets_content.
- $htmlheadercontent.= "\n";*/
-
- $htmlheadercontent.= preg_replace(array('/\n*/ims','/<\/html>\n*/ims'),array('',''),GETPOST('WEBSITE_HTML_HEADER', 'none'));
-
- /*$htmlheadercontent.= "\n".'"."\n";*/
-
- $htmlheadercontent = trim($htmlheadercontent)."\n";
-
- dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent);
-
-
- // Css file
- $csscontent ='';
-
- $csscontent.= "\n";
-
- $csscontent.= GETPOST('WEBSITE_CSS_INLINE', 'none');
-
- $csscontent.= "\n".'"."\n";
-
- dol_syslog("Save css content into ".$filecss);
-
- dol_mkdir($pathofwebsite);
- $result = file_put_contents($filecss, $csscontent);
- if (! empty($conf->global->MAIN_UMASK))
- @chmod($filecss, octdec($conf->global->MAIN_UMASK));
-
- if (! $result)
+ if (GETPOSTISSET('virtualhost'))
{
- $error++;
- setEventMessages('Failed to write file '.$filecss, null, 'errors');
+ if (GETPOST('virtualhost','alpha') && ! preg_match('/^http/',GETPOST('virtualhost','alpha')))
+ {
+ $error++;
+ setEventMessages('Error URL must start with http:// or https://', null, 'errors');
+ $action='editcss';
+ }
+
+ if (! $error)
+ {
+ $object->virtualhost = GETPOST('virtualhost','alpha');
+
+ $result = $object->update($user);
+ if ($result < 0)
+ {
+ $error++;
+ setEventMessages($object->error, $object->errors, 'errors');
+ $action='editcss';
+ }
+ }
}
-
- // Js file
- $jscontent ='';
-
- $jscontent.= "\n";
-
- $jscontent.= GETPOST('WEBSITE_JS_INLINE', 'none');
-
- $jscontent.= "\n".'"."\n";
-
- dol_syslog("Save js content into ".$filejs);
-
- dol_mkdir($pathofwebsite);
- $result = file_put_contents($filejs, $jscontent);
- if (! empty($conf->global->MAIN_UMASK))
- @chmod($filejs, octdec($conf->global->MAIN_UMASK));
-
- if (! $result)
- {
- $error++;
- setEventMessages('Failed to write file '.$filejs, null, 'errors');
- }
-
-
- // Robot file
- $robotcontent ='';
-
- /*$robotcontent.= "\n";*/
-
- $robotcontent.= GETPOST('WEBSITE_ROBOT', 'none');
-
- /*$robotcontent.= "\n".'"."\n";*/
-
- dol_syslog("Save file robot into ".$filerobot);
-
- dol_mkdir($pathofwebsite);
- $result = file_put_contents($filerobot, $robotcontent);
- if (! empty($conf->global->MAIN_UMASK))
- @chmod($filerobot, octdec($conf->global->MAIN_UMASK));
-
- if (! $result)
- {
- $error++;
- setEventMessages('Failed to write file '.$filerobot, null, 'errors');
- }
-
-
- // Css file
- $htaccesscontent ='';
-
- /*$htaccesscontent.= "\n";*/
-
- $htaccesscontent.= GETPOST('WEBSITE_HTACCESS', 'none');
-
- /*$htaccesscontent.= "\n".'"."\n";*/
-
- dol_syslog("Save file htaccess into ".$filehtaccess);
-
- dol_mkdir($pathofwebsite);
- $result = file_put_contents($filehtaccess, $htaccesscontent);
- if (! empty($conf->global->MAIN_UMASK))
- @chmod($filehtaccess, octdec($conf->global->MAIN_UMASK));
-
- if (! $result)
- {
- $error++;
- setEventMessages('Failed to write file '.$filehtaccess, null, 'errors');
- }
-
- // Message if no error
if (! $error)
{
- setEventMessages($langs->trans("Saved"), null, 'mesgs');
- }
+ // Save master.inc.php file
+ $filemaster=$pathofwebsite.'/master.inc.php';
- $action='preview';
+ dol_syslog("Save master file ".$filemaster);
+
+ dol_mkdir($pathofwebsite);
+
+ // Now generate the master.inc.php page
+ $result = dolSaveMasterFile($filemaster);
+ if (! $result) setEventMessages('Failed to write file '.$filemaster, null, 'errors');
+
+
+ // Html header file
+ $htmlheadercontent ='';
+
+ /* We disable php code since htmlheader is never executed as an include but only read by fgets_content.
+ $htmlheadercontent.= "\n";*/
+
+ $htmlheadercontent.= preg_replace(array('/\n*/ims','/<\/html>\n*/ims'),array('',''),GETPOST('WEBSITE_HTML_HEADER', 'none'));
+
+ /*$htmlheadercontent.= "\n".'"."\n";*/
+
+ $htmlheadercontent = trim($htmlheadercontent)."\n";
+
+ dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent);
+
+
+ // Css file
+ $csscontent ='';
+
+ $csscontent.= "\n";
+
+ $csscontent.= GETPOST('WEBSITE_CSS_INLINE', 'none');
+
+ $csscontent.= "\n".'"."\n";
+
+ dol_syslog("Save css content into ".$filecss);
+
+ dol_mkdir($pathofwebsite);
+ $result = file_put_contents($filecss, $csscontent);
+ if (! empty($conf->global->MAIN_UMASK))
+ @chmod($filecss, octdec($conf->global->MAIN_UMASK));
+
+ if (! $result)
+ {
+ $error++;
+ setEventMessages('Failed to write file '.$filecss, null, 'errors');
+ }
+
+
+ // Js file
+ $jscontent ='';
+
+ $jscontent.= "\n";
+
+ $jscontent.= GETPOST('WEBSITE_JS_INLINE', 'none');
+
+ $jscontent.= "\n".'"."\n";
+
+ dol_syslog("Save js content into ".$filejs);
+
+ dol_mkdir($pathofwebsite);
+ $result = file_put_contents($filejs, $jscontent);
+ if (! empty($conf->global->MAIN_UMASK))
+ @chmod($filejs, octdec($conf->global->MAIN_UMASK));
+
+ if (! $result)
+ {
+ $error++;
+ setEventMessages('Failed to write file '.$filejs, null, 'errors');
+ }
+
+
+ // Robot file
+ $robotcontent ='';
+
+ /*$robotcontent.= "\n";*/
+
+ $robotcontent.= GETPOST('WEBSITE_ROBOT', 'none');
+
+ /*$robotcontent.= "\n".'"."\n";*/
+
+ dol_syslog("Save file robot into ".$filerobot);
+
+ dol_mkdir($pathofwebsite);
+ $result = file_put_contents($filerobot, $robotcontent);
+ if (! empty($conf->global->MAIN_UMASK))
+ @chmod($filerobot, octdec($conf->global->MAIN_UMASK));
+
+ if (! $result)
+ {
+ $error++;
+ setEventMessages('Failed to write file '.$filerobot, null, 'errors');
+ }
+
+
+ // Css file
+ $htaccesscontent ='';
+
+ /*$htaccesscontent.= "\n";*/
+
+ $htaccesscontent.= GETPOST('WEBSITE_HTACCESS', 'none');
+
+ /*$htaccesscontent.= "\n".'"."\n";*/
+
+ dol_syslog("Save file htaccess into ".$filehtaccess);
+
+ dol_mkdir($pathofwebsite);
+ $result = file_put_contents($filehtaccess, $htaccesscontent);
+ if (! empty($conf->global->MAIN_UMASK))
+ @chmod($filehtaccess, octdec($conf->global->MAIN_UMASK));
+
+ if (! $result)
+ {
+ $error++;
+ setEventMessages('Failed to write file '.$filehtaccess, null, 'errors');
+ }
+
+
+ // Message if no error
+ if (! $error)
+ {
+ setEventMessages($langs->trans("Saved"), null, 'mesgs');
+ }
+
+ $action='preview';
+ }
}
}
@@ -1791,46 +1818,40 @@ if (! GETPOST('hide_websitemenu'))
$urlext=$virtualurl;
$urlint=$urlwithroot.'/public/website/index.php?website='.$websitekey;
- $htmltext = $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint, $dataroot);
- $htmltext.='
'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT);
- $htmltext.='
'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT.'/website
'.DOL_DATA_ROOT.'/medias');
- print '';
- print $form->textwithpicto('', $htmltext, 1, 'preview');
- print '';
-
print '