diff --git a/htdocs/admin/websites.php b/htdocs/admin/websites.php index 9a12441fbb3..66776220d32 100644 --- a/htdocs/admin/websites.php +++ b/htdocs/admin/websites.php @@ -259,7 +259,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } else { $rowidcol="rowid"; } - $sql = "DELETE from ".MAIN_DB_PREFIX."website_pages WHERE fk_website ='".$rowid."'"; + $sql = "DELETE from ".MAIN_DB_PREFIX."website_page WHERE fk_website ='".$rowid."'"; $result = $db->query($sql); $sql = "DELETE from ".MAIN_DB_PREFIX."website WHERE rowid ='".$rowid."'"; diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index ec3a945bb09..0137353f714 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -497,7 +497,7 @@ ALTER TABLE llx_usergroup_rights ADD CONSTRAINT fk_usergroup_rights_fk_usergroup -- For new module website -CREATE TABLE llx_website_pages +CREATE TABLE llx_website_page ( rowid integer AUTO_INCREMENT NOT NULL PRIMARY KEY, fk_website integer NOT NULL, @@ -513,9 +513,9 @@ CREATE TABLE llx_website_pages tms timestamp ) ENGINE=innodb; -ALTER TABLE llx_website_pages ADD UNIQUE INDEX uk_website_pages_url (fk_website,pageurl); +ALTER TABLE llx_website_page ADD UNIQUE INDEX uk_website_page_url (fk_website,pageurl); -ALTER TABLE llx_website_pages ADD CONSTRAINT fk_website_pages_website FOREIGN KEY (fk_website) REFERENCES llx_website (rowid); +ALTER TABLE llx_website_page ADD CONSTRAINT fk_website_page_website FOREIGN KEY (fk_website) REFERENCES llx_website (rowid); -- For new module blockedlog diff --git a/htdocs/install/mysql/tables/llx_website_pages.key.sql b/htdocs/install/mysql/tables/llx_website_page.key.sql similarity index 80% rename from htdocs/install/mysql/tables/llx_website_pages.key.sql rename to htdocs/install/mysql/tables/llx_website_page.key.sql index 00b9439d18b..14488e588dc 100644 --- a/htdocs/install/mysql/tables/llx_website_pages.key.sql +++ b/htdocs/install/mysql/tables/llx_website_page.key.sql @@ -16,7 +16,7 @@ -- -- =========================================================================== -ALTER TABLE llx_website_pages ADD UNIQUE INDEX uk_website_pages_url (fk_website,pageurl); +ALTER TABLE llx_website_page ADD UNIQUE INDEX uk_website_page_url (fk_website, pageurl); -ALTER TABLE llx_website_pages ADD CONSTRAINT fk_website_pages_website FOREIGN KEY (fk_website) REFERENCES llx_website (rowid); +ALTER TABLE llx_website_page ADD CONSTRAINT fk_website_page_website FOREIGN KEY (fk_website) REFERENCES llx_website (rowid); diff --git a/htdocs/install/mysql/tables/llx_website_pages.sql b/htdocs/install/mysql/tables/llx_website_page.sql similarity index 97% rename from htdocs/install/mysql/tables/llx_website_pages.sql rename to htdocs/install/mysql/tables/llx_website_page.sql index d45d8f06f56..69b6c417528 100644 --- a/htdocs/install/mysql/tables/llx_website_pages.sql +++ b/htdocs/install/mysql/tables/llx_website_page.sql @@ -17,7 +17,7 @@ -- ======================================================================== -CREATE TABLE llx_website_pages +CREATE TABLE llx_website_page ( rowid integer AUTO_INCREMENT NOT NULL PRIMARY KEY, fk_website integer NOT NULL, diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index abb7f7e56d3..cc2f31143ce 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -4,6 +4,7 @@ WebsiteSetupDesc=Create here as much entry as number of different websites you n DeleteWebsite=Delete website ConfirmDeleteWebsite=Are you sure you want to delete this web site. All its pages and content will also be removed. WEBSITE_PAGENAME=Page name/alias +WEBSITE_HTML_HEADER=HTML Header WEBSITE_CSS_URL=URL of external CSS file WEBSITE_CSS_INLINE=CSS content PageNameAliasHelp=Name or alias of the page.
This alias is also used to forge a SEO URL when website is read from a Virtual host of a Web server (like Apacke, Nginx, ...). Use the button "%s" to edit this alias. diff --git a/htdocs/websites/class/websitepage.class.php b/htdocs/websites/class/websitepage.class.php index 99fd4d64603..4f9dc58c615 100644 --- a/htdocs/websites/class/websitepage.class.php +++ b/htdocs/websites/class/websitepage.class.php @@ -129,7 +129,7 @@ class WebsitePage extends CommonObject $sql.= 'content,'; $sql.= 'status,'; $sql.= 'date_creation,'; - $sql.= 'date_modification'; + $sql.= 'tms'; $sql .= ') VALUES ('; $sql .= ' '.(! isset($this->fk_website)?'NULL':$this->fk_website).','; $sql .= ' '.(! isset($this->pageurl)?'NULL':"'".$this->db->escape($this->pageurl)."'").','; diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index b2b8662fe08..2c9c364edac 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -129,6 +129,7 @@ if ($pageid > 0 && $action != 'add') global $dolibarr_main_data_root; $pathofwebsite=$dolibarr_main_data_root.'/websites/'.$website; +$filehtmlheader=$pathofwebsite.'/header.html'; $filecss=$pathofwebsite.'/styles.css.php'; $filetpl=$pathofwebsite.'/page'.$pageid.'.tpl.php'; $fileindex=$pathofwebsite.'/index.php'; @@ -240,25 +241,30 @@ if ($action == 'delete') // Update css if ($action == 'updatecss') { - //$db->begin(); - $res = $object->fetch(0, $website); - /* - $res = $object->update($user); - if ($res > 0) - { - $db->commit(); - $action=''; - } - else + // Html header file + $htmlheadercontent = ''."\n"; + $htmlheadercontent.= ''."\n"; + $htmlheadercontent.= ''."\n"; + $htmlheadercontent.= GETPOST('WEBSITE_HTML_HEADER'); + + dol_syslog("Save file css 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) { $error++; - $db->rollback(); - }*/ + setEventMessages('Failed to write file '.$filehtmlheader, null, 'errors'); + } + // Css file $csscontent = ''."\n"; - $csscontent.= ''."\n"; + $csscontent.= ''."\n"; $csscontent.= '"."\n"; @@ -278,6 +284,7 @@ if ($action == 'updatecss') setEventMessages('Failed to write file '.$filecss, null, 'errors'); } + if (! $error) { setEventMessages($langs->trans("Saved"), null, 'mesgs'); @@ -310,7 +317,7 @@ if ($action == 'setashome') dol_delete_file($fileindex); $indexcontent = ''."\n"; $result = file_put_contents($fileindex, $indexcontent); @@ -406,6 +413,7 @@ if ($action == 'updatemeta') $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= '
'."\n"; + $tplcontent.= ''.dol_escape_htmltag($objectpage->title).''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; @@ -414,8 +422,10 @@ if ($action == 'updatemeta') $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; - $tplcontent.= ''.dol_escape_htmltag($objectpage->title).''."\n"; + $tplcontent.= ''."\n"; + $tplcontent.= 'ref.'/header.html"); ?>'."\n"; $tplcontent.= '
'."\n"; $tplcontent.= ''."\n"; @@ -561,6 +571,7 @@ if ($action == 'updatecontent' || GETPOST('refreshsite') || GETPOST('refreshpage $tplcontent.= "// END PHP ?>\n"; $tplcontent.= ''."\n"; $tplcontent.= '
'."\n"; + $tplcontent.= ''.dol_escape_htmltag($objectpage->title).''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; @@ -568,8 +579,10 @@ if ($action == 'updatecontent' || GETPOST('refreshsite') || GETPOST('refreshpage $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; - $tplcontent.= ''."\n"; - $tplcontent.= ''.dol_escape_htmltag($objectpage->title).''."\n"; + $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; + $tplcontent.= 'ref.'/header.html"); ?>'."\n"; $tplcontent.= '
'."\n"; $tplcontent.= ''."\n"; @@ -940,6 +953,11 @@ if ($action == 'editcss') print '
'; + $htmlheader = @file_get_contents($filehtmlheader); + // Clean the php css file to remove php code and get only html part + $htmlheader = preg_replace('//s', '', $htmlheader); + + $csscontent = @file_get_contents($filecss); // Clean the php css file to remove php code and get only css part $csscontent = preg_replace('//s', '', $csscontent); @@ -958,11 +976,19 @@ if ($action == 'editcss') print ''; print $langs->trans('WEBSITE_CSS_INLINE'); print ''; - print ''; print ''; + print ''; + print $langs->trans('WEBSITE_HTML_HEADER'); + print ''; + print ''; + print ''; + /*print ''; print $langs->trans('WEBSITE_CSS_URL'); print '';