';
print "\n";
}
diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php
index 9dc1b2c3863..197e050f48a 100644
--- a/htdocs/core/lib/website.lib.php
+++ b/htdocs/core/lib/website.lib.php
@@ -368,6 +368,238 @@ function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modify
$tmp = preg_replace('/'.preg_quote($regs[0][$key],'/').'/i', 'background'.$regs[1][$key].'url("'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file='.$filename.'")', $tmp);
}
}
-
}
+
+
+/**
+ * Save content of a page on disk
+ *
+ * @param string $filealias Full path of filename to generate
+ * @param Website $object Object website
+ * @param WebsitePage $objectpage Object websitepage
+ * @return boolean True if OK
+ */
+function dolSavePageAlias($filealias, $object, $objectpage)
+{
+ global $conf;
+
+ // Now create the .tpl file (duplicate code with actions updatesource or updatecontent but we need this to save new header)
+ dol_syslog("We regenerate the alias page filealias=".$filealias);
+
+ $aliascontent = 'id.'.tpl.php\'; ';
+ $aliascontent.= 'else require $dolibarr_main_data_root.\'/website/\'.$website->ref.\'/page'.$objectpage->id.'.tpl.php\';'."\n";
+ $aliascontent.= '?>'."\n";
+ $result = file_put_contents($filealias, $aliascontent);
+ if (! empty($conf->global->MAIN_UMASK))
+ @chmod($filealias, octdec($conf->global->MAIN_UMASK));
+
+ return ($result?true:false);
+}
+
+
+/**
+ * Save content of a page on disk
+ *
+ * @param string $filetpl Full path of filename to generate
+ * @param Website $object Object website
+ * @param WebsitePage $objectpage Object websitepage
+ * @return boolean True if OK
+ */
+function dolSavePageContent($filetpl, $object, $objectpage)
+{
+ global $conf;
+
+ // Now create the .tpl file (duplicate code with actions updatesource or updatecontent but we need this to save new header)
+ dol_syslog("We regenerate the tpl page filetpl=".$filetpl);
+
+ dol_delete_file($filetpl);
+
+ $shortlangcode = '';
+ if ($objectpage->lang) $shortlangcode=preg_replace('/[_-].*$/', '', $objectpage->lang); // en_US or en-US -> en
+
+ $tplcontent ='';
+ $tplcontent.= "\n";
+ $tplcontent.= ''."\n";
+ $tplcontent.= ''."\n";
+ $tplcontent.= ''.dol_string_nohtmltag($objectpage->title, 0, 'UTF-8').''."\n";
+ $tplcontent.= ''."\n";
+ $tplcontent.= ''."\n";
+ $tplcontent.= ''."\n";
+ $tplcontent.= ''."\n";
+ $tplcontent.= ''."\n";
+ $tplcontent.= ''."\n";
+ $tplcontent.= ''."\n";
+ $tplcontent.= ''."\n";
+ $tplcontent.= ''."\n";
+ $tplcontent.= ''."\n";
+ $tplcontent.= ''."\n";
+ $tplcontent.= 'ref.'/htmlheader.html"); ?>'."\n";
+ $tplcontent.= ''."\n";
+ $tplcontent.= $objectpage->htmlheader."\n";
+ $tplcontent.= ''."\n";
+
+ $tplcontent.= ''."\n";
+ $tplcontent.= ''."\n";
+ $tplcontent.= $objectpage->content."\n";
+ $tplcontent.= ''."\n";
+ $tplcontent.= ''."\n";
+
+ $tplcontent.= '"."\n";
+
+ //var_dump($filetpl);exit;
+ $result = file_put_contents($filetpl, $tplcontent);
+ if (! empty($conf->global->MAIN_UMASK))
+ @chmod($filetpl, octdec($conf->global->MAIN_UMASK));
+
+ return $result;
+}
+
+
+/**
+ * Save content of a page on disk
+ *
+ * @param string $filehtmlheader Full path of filename to generate
+ * @param string $htmlheadercontent Content of file
+ * @return boolean True if OK
+ */
+function dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent)
+{
+ global $conf, $pathofwebsite;
+
+ dol_syslog("Save html header into ".$filehtmlheader);
+
+ dol_mkdir($pathofwebsite);
+ $result = file_put_contents($filehtmlheader, $htmlheadercontent);
+ if (! empty($conf->global->MAIN_UMASK))
+ @chmod($filehtmlheader, octdec($conf->global->MAIN_UMASK));
+
+ if (! $result)
+ {
+ setEventMessages('Failed to write file '.$filehtmlheader, null, 'errors');
+ return false;
+ }
+
+ return true;
+}
+
+/**
+ * Save content of a page on disk
+ *
+ * @param string $filecss Full path of filename to generate
+ * @param string $csscontent Content of file
+ * @return boolean True if OK
+ */
+function dolSaveCssFile($filecss, $csscontent)
+{
+ global $conf, $pathofwebsite;
+
+ dol_syslog("Save css file 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)
+ {
+ setEventMessages('Failed to write file '.$filecss, null, 'errors');
+ return false;
+ }
+
+ return true;
+}
+
+/**
+ * Save content of a page on disk
+ *
+ * @param string $filejs Full path of filename to generate
+ * @param string $jscontent Content of file
+ * @return boolean True if OK
+ */
+function dolSaveJsFile($filejs, $jscontent)
+{
+ global $conf, $pathofwebsite;
+
+ dol_syslog("Save js file 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)
+ {
+ setEventMessages('Failed to write file '.$filejs, null, 'errors');
+ return false;
+ }
+
+ return true;
+}
+
+/**
+ * Save content of a page on disk
+ *
+ * @param string $filerobot Full path of filename to generate
+ * @param string $robotcontent Content of file
+ * @return boolean True if OK
+ */
+function dolSaveRobotFile($filerobot, $robotcontent)
+{
+ global $conf, $pathofwebsite;
+
+ dol_syslog("Save robot file 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)
+ {
+ setEventMessages('Failed to write file '.$filerobot, null, 'errors');
+ return false;
+ }
+
+ return true;
+}
+
+/**
+ * Save content of a page on disk
+ *
+ * @param string $filehtaccess Full path of filename to generate
+ * @param string $htaccess Content of file
+ * @return boolean True if OK
+ */
+function dolSaveHtaccessFile($filehtaccess, $htaccess)
+{
+ global $conf, $pathofwebsite;
+
+ dol_syslog("Save htaccess file into ".$filehtaccess);
+
+ dol_mkdir($pathofwebsite);
+ $result = file_put_contents($filehtaccess, $htaccess);
+ if (! empty($conf->global->MAIN_UMASK))
+ @chmod($filehtaccess, octdec($conf->global->MAIN_UMASK));
+
+ if (! $result)
+ {
+ setEventMessages('Failed to write file '.$filehtaccess, null, 'errors');
+ return false;
+ }
+
+ return true;
+}
+
+
diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang
index 326228b7e45..5b50bcc7ad3 100644
--- a/htdocs/langs/en_US/website.lang
+++ b/htdocs/langs/en_US/website.lang
@@ -5,14 +5,15 @@ DeleteWebsite=Delete website
ConfirmDeleteWebsite=Are you sure you want to delete this web site. All its pages and content will also be removed.
WEBSITE_TYPE_CONTAINER=Type of page/container
WEBSITE_PAGENAME=Page name/alias
-HtmlHeaderPage=HTML specific header for page
WEBSITE_CSS_URL=URL of external CSS file
WEBSITE_CSS_INLINE=CSS file content (common to all pages)
WEBSITE_JS_INLINE=Javascript file content (common to all pages)
WEBSITE_HTML_HEADER=Addition at bottom of HTML Header (common to all pages)
WEBSITE_ROBOT=Robot file (robots.txt)
WEBSITE_HTACCESS=Web site .htaccess file
-PageNameAliasHelp=Name or alias of the page. This alias is also used to forge a SEO URL when website is ran from a Virtual host of a Web server (like Apacke, Nginx, ...). Use the button "%s" to edit this alias.
+HtmlHeaderPage=HTML header (specific to this page only)
+PageNameAliasHelp=Name or alias of the page. This alias is also used to forge a SEO URL when website is ran from a Virtual host of a Web server (like Apacke, Nginx, ...). Use the button "%s" to edit this alias.
+EditTheWebSiteForACommonHeader=Note: If you want to define a personalized header for all pages, edit the header on the site level instead of on the page/container.
MediaFiles=Media library
EditCss=Edit Style/CSS or HTML header
EditMenu=Edit menu
@@ -59,4 +60,5 @@ BlogPost=Blog post
WebsiteAccount=Web site account
WebsiteAccounts=Web site accounts
AddWebsiteAccount=Create web site account
-BackToListOfThirdParty=Back to list for Third Party
\ No newline at end of file
+BackToListOfThirdParty=Back to list for Third Party
+DisableSiteFirst=Disable website first
\ No newline at end of file
diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php
index 2a1af0f2a80..1291e54840c 100644
--- a/htdocs/website/class/website.class.php
+++ b/htdocs/website/class/website.class.php
@@ -107,6 +107,8 @@ class Website extends CommonObject
*/
public function create(User $user, $notrigger = false)
{
+ global $conf;
+
dol_syslog(__METHOD__, LOG_DEBUG);
$error = 0;
@@ -129,7 +131,7 @@ class Website extends CommonObject
if (empty($this->date_modification)) $this->date_modification = $now;
// Check parameters
- // Put here code to add control on parameters values
+ if (empty($this->entity)) { $this->entity = $conf->entity; }
// Insert request
$sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '(';
diff --git a/htdocs/website/index.php b/htdocs/website/index.php
index d716fd4a9ad..3f50b9e9b4f 100644
--- a/htdocs/website/index.php
+++ b/htdocs/website/index.php
@@ -605,7 +605,7 @@ if ($action == 'addcontainer')
if (! dol_is_file($filehtmlheader))
{
- $htmlheadercontent = "";
+ $htmlheadercontent = "\n\n";
$result=dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent);
}
@@ -1616,7 +1616,7 @@ $head = array();
/*
- * Edit mode
+ * Edit Site HTML header of CSS
*/
if ($action == 'editcss')
@@ -1624,28 +1624,53 @@ if ($action == 'editcss')
print '
';
print ' ';
-
- $csscontent = @file_get_contents($filecss);
- // Clean the php css file to remove php code and get only css part
- $csscontent = preg_replace('/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims', '', $csscontent);
- $csscontent.= GETPOST('WEBSITE_CSS_INLINE');
+ if (GETPOST('editcss','alpha') || GETPOST('refreshpage','alpha'))
+ {
+ $csscontent = @file_get_contents($filecss);
+ // Clean the php css file to remove php code and get only css part
+ $csscontent = preg_replace('/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims', '', $csscontent);
+ }
+ else
+ {
+ $csscontent = GETPOST('WEBSITE_CSS_INLINE');
+ }
if (! trim($csscontent)) $csscontent='/* CSS content (all pages) */'."\n".'body.bodywebsite { margin: 0; }';
- $jscontent = @file_get_contents($filejs);
- // Clean the php js file to remove php code and get only js part
- $jscontent = preg_replace('/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims', '', $jscontent);
- $jscontent.= GETPOST('WEBSITE_JS_INLINE');
+ if (GETPOST('editcss','alpha') || GETPOST('refreshpage','alpha'))
+ {
+ $jscontent = @file_get_contents($filejs);
+ // Clean the php js file to remove php code and get only js part
+ $jscontent = preg_replace('/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims', '', $jscontent);
+ }
+ else
+ {
+ $jscontent = GETPOST('WEBSITE_JS_INLINE');
+ }
if (! trim($jscontent)) $jscontent='/* JS content (all pages) */'."\n";
- $htmlheader = @file_get_contents($filehtmlheader);
- // Clean the php htmlheader file to remove php code and get only html part
- $htmlheader = preg_replace('/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims', '', $htmlheader);
- if (! trim($htmlheader)) $htmlheader='';
+ if (GETPOST('editcss','alpha') || GETPOST('refreshpage','alpha'))
+ {
+ $htmlheader = @file_get_contents($filehtmlheader);
+ // Clean the php htmlheader file to remove php code and get only html part
+ $htmlheader = preg_replace('/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims', '', $htmlheader);
+ }
+ else
+ {
+ $htmlheader = GETPOST('WEBSITE_HTML_HEADER');
+ }
+ if (! trim($htmlheader)) $htmlheader="\n\n";
else $htmlheader=''."\n".trim($htmlheader)."\n".'';
- $robotcontent = @file_get_contents($filerobot);
- // Clean the php htmlheader file to remove php code and get only html part
- $robotcontent = preg_replace('/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims', '', $robotcontent);
+ if (GETPOST('editcss','alpha') || GETPOST('refreshpage','alpha'))
+ {
+ $robotcontent = @file_get_contents($filerobot);
+ // Clean the php htmlheader file to remove php code and get only html part
+ $robotcontent = preg_replace('/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims', '', $robotcontent);
+ }
+ else
+ {
+ $robotcontent = GETPOST('WEBSITE_ROBOT');
+ }
if (! trim($robotcontent))
{
$robotcontent.="# Robot file. Generated with ".DOL_APPLICATION_TITLE."\n";
@@ -1654,9 +1679,16 @@ if ($action == 'editcss')
$robotcontent.="Disallow: /administrator/\n";
}
- $htaccesscontent = @file_get_contents($filehtaccess);
- // Clean the php htaccesscontent file to remove php code and get only html part
- $htaccesscontent = preg_replace('/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims', '', $htaccesscontent);
+ if (GETPOST('editcss','alpha') || GETPOST('refreshpage','alpha'))
+ {
+ $htaccesscontent = @file_get_contents($filehtaccess);
+ // Clean the php htaccesscontent file to remove php code and get only html part
+ $htaccesscontent = preg_replace('/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims', '', $htaccesscontent);
+ }
+ else
+ {
+ $htaccesscontent = GETPOST('WEBSITE_HTACCESS');
+ }
if (! trim($htaccesscontent))
{
$htaccesscontent.="# Order allow,deny\n";
@@ -1926,7 +1958,12 @@ if ($action == 'editmeta' || $action == 'createcontainer')
print '';
print '