Debug module websites
This commit is contained in:
parent
8c287c02ca
commit
be09c911ce
@ -259,7 +259,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete
|
|||||||
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
|
if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
|
||||||
else { $rowidcol="rowid"; }
|
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);
|
$result = $db->query($sql);
|
||||||
|
|
||||||
$sql = "DELETE from ".MAIN_DB_PREFIX."website WHERE rowid ='".$rowid."'";
|
$sql = "DELETE from ".MAIN_DB_PREFIX."website WHERE rowid ='".$rowid."'";
|
||||||
|
|||||||
@ -497,7 +497,7 @@ ALTER TABLE llx_usergroup_rights ADD CONSTRAINT fk_usergroup_rights_fk_usergroup
|
|||||||
|
|
||||||
-- For new module website
|
-- For new module website
|
||||||
|
|
||||||
CREATE TABLE llx_website_pages
|
CREATE TABLE llx_website_page
|
||||||
(
|
(
|
||||||
rowid integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
|
rowid integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
|
||||||
fk_website integer NOT NULL,
|
fk_website integer NOT NULL,
|
||||||
@ -513,9 +513,9 @@ CREATE TABLE llx_website_pages
|
|||||||
tms timestamp
|
tms timestamp
|
||||||
) ENGINE=innodb;
|
) 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
|
-- For new module blockedlog
|
||||||
|
|||||||
@ -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);
|
||||||
|
|
||||||
@ -17,7 +17,7 @@
|
|||||||
-- ========================================================================
|
-- ========================================================================
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE llx_website_pages
|
CREATE TABLE llx_website_page
|
||||||
(
|
(
|
||||||
rowid integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
|
rowid integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
|
||||||
fk_website integer NOT NULL,
|
fk_website integer NOT NULL,
|
||||||
@ -4,6 +4,7 @@ WebsiteSetupDesc=Create here as much entry as number of different websites you n
|
|||||||
DeleteWebsite=Delete website
|
DeleteWebsite=Delete website
|
||||||
ConfirmDeleteWebsite=Are you sure you want to delete this web site. All its pages and content will also be removed.
|
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_PAGENAME=Page name/alias
|
||||||
|
WEBSITE_HTML_HEADER=HTML Header
|
||||||
WEBSITE_CSS_URL=URL of external CSS file
|
WEBSITE_CSS_URL=URL of external CSS file
|
||||||
WEBSITE_CSS_INLINE=CSS content
|
WEBSITE_CSS_INLINE=CSS content
|
||||||
PageNameAliasHelp=Name or alias of the page.<br>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 "<strong>%s</strong>" to edit this alias.
|
PageNameAliasHelp=Name or alias of the page.<br>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 "<strong>%s</strong>" to edit this alias.
|
||||||
|
|||||||
@ -129,7 +129,7 @@ class WebsitePage extends CommonObject
|
|||||||
$sql.= 'content,';
|
$sql.= 'content,';
|
||||||
$sql.= 'status,';
|
$sql.= 'status,';
|
||||||
$sql.= 'date_creation,';
|
$sql.= 'date_creation,';
|
||||||
$sql.= 'date_modification';
|
$sql.= 'tms';
|
||||||
$sql .= ') VALUES (';
|
$sql .= ') VALUES (';
|
||||||
$sql .= ' '.(! isset($this->fk_website)?'NULL':$this->fk_website).',';
|
$sql .= ' '.(! isset($this->fk_website)?'NULL':$this->fk_website).',';
|
||||||
$sql .= ' '.(! isset($this->pageurl)?'NULL':"'".$this->db->escape($this->pageurl)."'").',';
|
$sql .= ' '.(! isset($this->pageurl)?'NULL':"'".$this->db->escape($this->pageurl)."'").',';
|
||||||
|
|||||||
@ -129,6 +129,7 @@ if ($pageid > 0 && $action != 'add')
|
|||||||
|
|
||||||
global $dolibarr_main_data_root;
|
global $dolibarr_main_data_root;
|
||||||
$pathofwebsite=$dolibarr_main_data_root.'/websites/'.$website;
|
$pathofwebsite=$dolibarr_main_data_root.'/websites/'.$website;
|
||||||
|
$filehtmlheader=$pathofwebsite.'/header.html';
|
||||||
$filecss=$pathofwebsite.'/styles.css.php';
|
$filecss=$pathofwebsite.'/styles.css.php';
|
||||||
$filetpl=$pathofwebsite.'/page'.$pageid.'.tpl.php';
|
$filetpl=$pathofwebsite.'/page'.$pageid.'.tpl.php';
|
||||||
$fileindex=$pathofwebsite.'/index.php';
|
$fileindex=$pathofwebsite.'/index.php';
|
||||||
@ -240,25 +241,30 @@ if ($action == 'delete')
|
|||||||
// Update css
|
// Update css
|
||||||
if ($action == 'updatecss')
|
if ($action == 'updatecss')
|
||||||
{
|
{
|
||||||
//$db->begin();
|
|
||||||
|
|
||||||
$res = $object->fetch(0, $website);
|
$res = $object->fetch(0, $website);
|
||||||
|
|
||||||
/*
|
// Html header file
|
||||||
$res = $object->update($user);
|
$htmlheadercontent = '<!-- BEGIN DOLIBARR-WEBSITE-ADDED-HEADER -->'."\n";
|
||||||
if ($res > 0)
|
$htmlheadercontent.= '<!-- File generated to save common html header - YOU CAN MODIFY DIRECTLY THIS FILE. Change affects all pages of website. -->'."\n";
|
||||||
{
|
$htmlheadercontent.= '<!-- END -->'."\n";
|
||||||
$db->commit();
|
$htmlheadercontent.= GETPOST('WEBSITE_HTML_HEADER');
|
||||||
$action='';
|
|
||||||
}
|
dol_syslog("Save file css into ".$filehtmlheader);
|
||||||
else
|
|
||||||
|
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++;
|
$error++;
|
||||||
$db->rollback();
|
setEventMessages('Failed to write file '.$filehtmlheader, null, 'errors');
|
||||||
}*/
|
}
|
||||||
|
|
||||||
|
// Css file
|
||||||
$csscontent = '<!-- BEGIN DOLIBARR-WEBSITE-ADDED-HEADER -->'."\n";
|
$csscontent = '<!-- BEGIN DOLIBARR-WEBSITE-ADDED-HEADER -->'."\n";
|
||||||
$csscontent.= '<!-- File generated to wrap the css file - DO NOT MODIFY - It is just a copy of database css content -->'."\n";
|
$csscontent.= '<!-- File generated to wrap the css file - YOU CAN MODIFY DIRECTLY THIS FILE. Change affects all pages of website. -->'."\n";
|
||||||
$csscontent.= '<?php '."\n";
|
$csscontent.= '<?php '."\n";
|
||||||
$csscontent.= "header('Content-type: text/css');\n";
|
$csscontent.= "header('Content-type: text/css');\n";
|
||||||
$csscontent.= "?>"."\n";
|
$csscontent.= "?>"."\n";
|
||||||
@ -278,6 +284,7 @@ if ($action == 'updatecss')
|
|||||||
setEventMessages('Failed to write file '.$filecss, null, 'errors');
|
setEventMessages('Failed to write file '.$filecss, null, 'errors');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
setEventMessages($langs->trans("Saved"), null, 'mesgs');
|
setEventMessages($langs->trans("Saved"), null, 'mesgs');
|
||||||
@ -310,7 +317,7 @@ if ($action == 'setashome')
|
|||||||
dol_delete_file($fileindex);
|
dol_delete_file($fileindex);
|
||||||
|
|
||||||
$indexcontent = '<?php'."\n";
|
$indexcontent = '<?php'."\n";
|
||||||
$indexcontent.= '// File generated to wrap the home page - DO NOT MODIFY - It is just an include'."\n";
|
$indexcontent.= '// File generated to provide a shortcut to the Home Page - DO NOT MODIFY - It is just an include.'."\n";
|
||||||
$indexcontent.= "include_once './".basename($filetpl)."'\n";
|
$indexcontent.= "include_once './".basename($filetpl)."'\n";
|
||||||
$indexcontent.= '?>'."\n";
|
$indexcontent.= '?>'."\n";
|
||||||
$result = file_put_contents($fileindex, $indexcontent);
|
$result = file_put_contents($fileindex, $indexcontent);
|
||||||
@ -406,6 +413,7 @@ if ($action == 'updatemeta')
|
|||||||
$tplcontent.= '<?php require "./master.inc.php"; ?>'."\n";
|
$tplcontent.= '<?php require "./master.inc.php"; ?>'."\n";
|
||||||
$tplcontent.= '<html>'."\n";
|
$tplcontent.= '<html>'."\n";
|
||||||
$tplcontent.= '<header>'."\n";
|
$tplcontent.= '<header>'."\n";
|
||||||
|
$tplcontent.= '<title>'.dol_escape_htmltag($objectpage->title).'</title>'."\n";
|
||||||
$tplcontent.= '<meta http-equiv="content-type" content="text/html; charset=utf-8" />'."\n";
|
$tplcontent.= '<meta http-equiv="content-type" content="text/html; charset=utf-8" />'."\n";
|
||||||
$tplcontent.= '<meta name="robots" content="index, follow" />'."\n";
|
$tplcontent.= '<meta name="robots" content="index, follow" />'."\n";
|
||||||
$tplcontent.= '<meta name="viewport" content="width=device-width, initial-scale=0.8">'."\n";
|
$tplcontent.= '<meta name="viewport" content="width=device-width, initial-scale=0.8">'."\n";
|
||||||
@ -414,8 +422,10 @@ if ($action == 'updatemeta')
|
|||||||
$tplcontent.= '<meta name="title" content="'.dol_escape_htmltag($objectpage->title).'" />'."\n";
|
$tplcontent.= '<meta name="title" content="'.dol_escape_htmltag($objectpage->title).'" />'."\n";
|
||||||
$tplcontent.= '<meta name="description" content="'.dol_escape_htmltag($objectpage->description).'" />'."\n";
|
$tplcontent.= '<meta name="description" content="'.dol_escape_htmltag($objectpage->description).'" />'."\n";
|
||||||
$tplcontent.= '<meta name="generator" content="'.DOL_APPLICATION_TITLE.'" />'."\n";
|
$tplcontent.= '<meta name="generator" content="'.DOL_APPLICATION_TITLE.'" />'."\n";
|
||||||
|
$tplcontent.= '<!-- Include link to CSS file -->'."\n";
|
||||||
$tplcontent.= '<link rel="stylesheet" href="styles.css.php?websiteid='.$object->id.'" type="text/css" />'."\n";
|
$tplcontent.= '<link rel="stylesheet" href="styles.css.php?websiteid='.$object->id.'" type="text/css" />'."\n";
|
||||||
$tplcontent.= '<title>'.dol_escape_htmltag($objectpage->title).'</title>'."\n";
|
$tplcontent.= '<!-- Include common page header file -->'."\n";
|
||||||
|
$tplcontent.= '<?php print file_get_contents(DOL_DATA_ROOT."/websites/'.$object->ref.'/header.html"); ?>'."\n";
|
||||||
$tplcontent.= '</header>'."\n";
|
$tplcontent.= '</header>'."\n";
|
||||||
|
|
||||||
$tplcontent.= '<body>'."\n";
|
$tplcontent.= '<body>'."\n";
|
||||||
@ -561,6 +571,7 @@ if ($action == 'updatecontent' || GETPOST('refreshsite') || GETPOST('refreshpage
|
|||||||
$tplcontent.= "// END PHP ?>\n";
|
$tplcontent.= "// END PHP ?>\n";
|
||||||
$tplcontent.= '<html>'."\n";
|
$tplcontent.= '<html>'."\n";
|
||||||
$tplcontent.= '<header>'."\n";
|
$tplcontent.= '<header>'."\n";
|
||||||
|
$tplcontent.= '<title>'.dol_escape_htmltag($objectpage->title).'</title>'."\n";
|
||||||
$tplcontent.= '<meta http-equiv="content-type" content="text/html; charset=utf-8" />'."\n";
|
$tplcontent.= '<meta http-equiv="content-type" content="text/html; charset=utf-8" />'."\n";
|
||||||
$tplcontent.= '<meta name="robots" content="index, follow" />'."\n";
|
$tplcontent.= '<meta name="robots" content="index, follow" />'."\n";
|
||||||
$tplcontent.= '<meta name="viewport" content="width=device-width, initial-scale=0.8">'."\n";
|
$tplcontent.= '<meta name="viewport" content="width=device-width, initial-scale=0.8">'."\n";
|
||||||
@ -568,8 +579,10 @@ if ($action == 'updatecontent' || GETPOST('refreshsite') || GETPOST('refreshpage
|
|||||||
$tplcontent.= '<meta name="title" content="'.dol_escape_htmltag($objectpage->title).'" />'."\n";
|
$tplcontent.= '<meta name="title" content="'.dol_escape_htmltag($objectpage->title).'" />'."\n";
|
||||||
$tplcontent.= '<meta name="description" content="'.dol_escape_htmltag($objectpage->description).'" />'."\n";
|
$tplcontent.= '<meta name="description" content="'.dol_escape_htmltag($objectpage->description).'" />'."\n";
|
||||||
$tplcontent.= '<meta name="generator" content="'.DOL_APPLICATION_TITLE.'" />'."\n";
|
$tplcontent.= '<meta name="generator" content="'.DOL_APPLICATION_TITLE.'" />'."\n";
|
||||||
$tplcontent.= '<link rel="stylesheet" href="styles.css.php?websiteid='.$object->id.'" type="text/css" />'."\n";
|
$tplcontent.= '<!-- Include link to CSS file -->'."\n";
|
||||||
$tplcontent.= '<title>'.dol_escape_htmltag($objectpage->title).'</title>'."\n";
|
$tplcontent.= '<link rel="stylesheet" href="styles.css.php?websiteid='.$object->id.'" type="text/css" />'."\n";
|
||||||
|
$tplcontent.= '<!-- Include common page header file -->'."\n";
|
||||||
|
$tplcontent.= '<?php print file_get_contents(DOL_DATA_ROOT."/websites/'.$object->ref.'/header.html"); ?>'."\n";
|
||||||
$tplcontent.= '</header>'."\n";
|
$tplcontent.= '</header>'."\n";
|
||||||
|
|
||||||
$tplcontent.= '<body>'."\n";
|
$tplcontent.= '<body>'."\n";
|
||||||
@ -940,6 +953,11 @@ if ($action == 'editcss')
|
|||||||
|
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
|
||||||
|
$htmlheader = @file_get_contents($filehtmlheader);
|
||||||
|
// Clean the php css file to remove php code and get only html part
|
||||||
|
$htmlheader = preg_replace('/<!-- BEGIN DOLIBARR.*END -->/s', '', $htmlheader);
|
||||||
|
|
||||||
|
|
||||||
$csscontent = @file_get_contents($filecss);
|
$csscontent = @file_get_contents($filecss);
|
||||||
// Clean the php css file to remove php code and get only css part
|
// Clean the php css file to remove php code and get only css part
|
||||||
$csscontent = preg_replace('/<!-- BEGIN DOLIBARR.*END -->/s', '', $csscontent);
|
$csscontent = preg_replace('/<!-- BEGIN DOLIBARR.*END -->/s', '', $csscontent);
|
||||||
@ -958,11 +976,19 @@ if ($action == 'editcss')
|
|||||||
print '<tr><td class="tdtop">';
|
print '<tr><td class="tdtop">';
|
||||||
print $langs->trans('WEBSITE_CSS_INLINE');
|
print $langs->trans('WEBSITE_CSS_INLINE');
|
||||||
print '</td><td>';
|
print '</td><td>';
|
||||||
print '<textarea class="flat centpercent" rows="32" name="WEBSITE_CSS_INLINE">';
|
print '<textarea class="flat centpercent" rows="20" name="WEBSITE_CSS_INLINE">';
|
||||||
print $csscontent;
|
print $csscontent;
|
||||||
print '</textarea>';
|
print '</textarea>';
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
|
print '<tr><td class="tdtop">';
|
||||||
|
print $langs->trans('WEBSITE_HTML_HEADER');
|
||||||
|
print '</td><td>';
|
||||||
|
print '<textarea class="flat centpercent" rows="20" name="WEBSITE_HTML_HEADER">';
|
||||||
|
print $htmlheader;
|
||||||
|
print '</textarea>';
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
/*print '<tr><td>';
|
/*print '<tr><td>';
|
||||||
print $langs->trans('WEBSITE_CSS_URL');
|
print $langs->trans('WEBSITE_CSS_URL');
|
||||||
print '</td><td>';
|
print '</td><td>';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user