Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dolibarr
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software_Artifact_Infrastructure_Repository
dolibarr
Commits
54b47d7f
Commit
54b47d7f
authored
8 years ago
by
Laurent Destailleur
Browse files
Options
Downloads
Patches
Plain Diff
Fix edit of page in module website
Conflicts: htdocs/websites/class/website.class.php
parent
fb3f6972
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
htdocs/install/mysql/tables/llx_website.sql
+1
-0
1 addition, 0 deletions
htdocs/install/mysql/tables/llx_website.sql
htdocs/websites/class/website.class.php
+1
-0
1 addition, 0 deletions
htdocs/websites/class/website.class.php
htdocs/websites/index.php
+100
-11
100 additions, 11 deletions
htdocs/websites/index.php
with
102 additions
and
11 deletions
htdocs/install/mysql/tables/llx_website.sql
+
1
−
0
View file @
54b47d7f
...
...
@@ -25,6 +25,7 @@ CREATE TABLE llx_website
description
varchar
(
255
),
status
integer
,
fk_default_home
integer
,
virtualhost
varchar
(
255
),
date_creation
datetime
,
date_modification
datetime
,
tms
timestamp
...
...
This diff is collapsed.
Click to expand it.
htdocs/websites/class/website.class.php
+
1
−
0
View file @
54b47d7f
...
...
@@ -380,6 +380,7 @@ class Website extends CommonObject
$sql
.
=
' description = '
.
(
isset
(
$this
->
description
)
?
"'"
.
$this
->
db
->
escape
(
$this
->
description
)
.
"'"
:
"null"
)
.
','
;
$sql
.
=
' status = '
.
(
isset
(
$this
->
status
)
?
$this
->
status
:
"null"
)
.
','
;
$sql
.
=
' fk_default_home = '
.
((
$this
->
fk_default_home
>
0
)
?
$this
->
fk_default_home
:
"null"
)
.
','
;
$sql
.
=
' virtualhost = '
.
((
$this
->
virtualhost
!=
''
)
?
"'"
.
$this
->
db
->
escape
(
$this
->
virtualhost
)
.
"'"
:
"null"
)
.
','
;
$sql
.
=
' date_creation = '
.
(
!
isset
(
$this
->
date_creation
)
||
dol_strlen
(
$this
->
date_creation
)
!=
0
?
"'"
.
$this
->
db
->
idate
(
$this
->
date_creation
)
.
"'"
:
'null'
)
.
','
;
$sql
.
=
' date_modification = '
.
(
!
isset
(
$this
->
date_modification
)
||
dol_strlen
(
$this
->
date_modification
)
!=
0
?
"'"
.
$this
->
db
->
idate
(
$this
->
date_modification
)
.
"'"
:
'null'
)
.
','
;
$sql
.
=
' tms = '
.
(
dol_strlen
(
$this
->
tms
)
!=
0
?
"'"
.
$this
->
db
->
idate
(
$this
->
tms
)
.
"'"
:
"'"
.
$this
->
db
->
idate
(
dol_now
())
.
"'"
);
...
...
This diff is collapsed.
Click to expand it.
htdocs/websites/index.php
+
100
−
11
View file @
54b47d7f
...
...
@@ -125,6 +125,7 @@ global $dolibarr_main_data_root;
$pathofwebsite
=
$dolibarr_main_data_root
.
'/websites/'
.
$website
;
$filecss
=
$pathofwebsite
.
'/styles.css.php'
;
$filetpl
=
$pathofwebsite
.
'/page'
.
$pageid
.
'.tpl.php'
;
$fileindex
=
$pathofwebsite
.
'/index.php'
;
// Define $urlwithroot
$urlwithouturlroot
=
preg_replace
(
'/'
.
preg_quote
(
DOL_URL_ROOT
,
'/'
)
.
'$/i'
,
''
,
trim
(
$dolibarr_main_url_root
));
...
...
@@ -279,13 +280,16 @@ if ($action == 'updatecss')
$csscontent
=
'<?php'
.
"
\n
"
;
$csscontent
.
=
"header('Content-type: text/css');
\n
"
;
$csscontent
.
=
"?>"
.
"
\n
"
;
$csscontent
.
=
GETPOST
(
'WEBSITE_CSS_INLINE'
);
$csscontent
.
=
GETPOST
(
'WEBSITE_CSS_INLINE'
);
dol_mkdir
(
$pathofwebsite
);
file_put_contents
(
$filecss
,
$csscontent
);
$result
=
file_put_contents
(
$filecss
,
$csscontent
);
if
(
!
empty
(
$conf
->
global
->
MAIN_UMASK
))
@
chmod
(
$filecss
,
octdec
(
$conf
->
global
->
MAIN_UMASK
));
if
(
$result
)
setEventMessages
(
$langs
->
trans
(
"Saved"
),
null
,
'mesgs'
);
else
setEventMessages
(
'Failed to write file '
.
$fileindex
,
null
,
'errors'
);
$action
=
'preview'
;
}
...
...
@@ -306,7 +310,23 @@ if ($action == 'setashome')
if
(
!
$error
)
{
$db
->
commit
();
setEventMessages
(
$langs
->
trans
(
"Saved"
),
null
,
'mesgs'
);
// Generate the index.php page to be the home page
//-------------------------------------------------
dol_mkdir
(
$pathofwebsite
);
dol_delete_file
(
$fileindex
);
$indexcontent
=
'<?php'
.
"
\n
"
;
$indexcontent
.
=
'// File generated to wrap the home page'
.
"
\n
"
;
$indexcontent
.
=
"include_once './"
.
basename
(
$filetpl
)
.
"'
\n
"
;
$indexcontent
.
=
'?>'
.
"
\n
"
;
$result
=
file_put_contents
(
$fileindex
,
$indexcontent
);
if
(
!
empty
(
$conf
->
global
->
MAIN_UMASK
))
@
chmod
(
$fileindex
,
octdec
(
$conf
->
global
->
MAIN_UMASK
));
if
(
$result
)
setEventMessages
(
$langs
->
trans
(
"Saved"
),
null
,
'mesgs'
);
else
setEventMessages
(
'Failed to write file '
.
$fileindex
,
null
,
'errors'
);
$action
=
'preview'
;
}
else
...
...
@@ -326,6 +346,8 @@ if ($action == 'updatemeta')
$res
=
$objectpage
->
fetch
(
$pageid
,
$object
->
fk_website
);
if
(
$res
>
0
)
{
$oldobjectpage
=
clone
$objectpage
;
$objectpage
->
pageurl
=
GETPOST
(
'WEBSITE_PAGENAME'
);
$objectpage
->
title
=
GETPOST
(
'WEBSITE_TITLE'
);
$objectpage
->
description
=
GETPOST
(
'WEBSITE_DESCRIPTION'
);
...
...
@@ -341,7 +363,61 @@ if ($action == 'updatemeta')
if
(
!
$error
)
{
$db
->
commit
();
setEventMessages
(
$langs
->
trans
(
"Saved"
),
null
,
'mesgs'
);
$fileoldalias
=
$pathofwebsite
.
'/'
.
$oldobjectpage
->
pageurl
.
'.php'
;
$filealias
=
$pathofwebsite
.
'/'
.
$objectpage
->
pageurl
.
'.php'
;
// Generate the alias.php page
//-----------------------------
dol_mkdir
(
$pathofwebsite
);
dol_delete_file
(
$fileoldalias
);
$aliascontent
=
'<?php'
.
"
\n
"
;
$aliascontent
.
=
'// File generated to wrap the alias page'
.
"
\n
"
;
$aliascontent
.
=
"include_once './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
));
if
(
$result
)
setEventMessages
(
$langs
->
trans
(
"Saved"
),
null
,
'mesgs'
);
else
setEventMessages
(
'Failed to write file '
.
$filealias
,
null
,
'errors'
);
// Now create the .tpl file (duplicate code with actions updatecontent but we need this to save new header)
dol_mkdir
(
$pathofwebsite
);
dol_delete_file
(
$filetpl
);
$tplcontent
=
'<html>'
.
"
\n
"
;
$tplcontent
.
=
'<header>'
.
"
\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="viewport" content="width=device-width, initial-scale=0.8">'
.
"
\n
"
;
$tplcontent
.
=
'<meta name="keywords" content="'
.
join
(
', '
,
explode
(
','
,
$objectpage
->
keywords
))
.
'" />'
.
"
\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="generator" content="'
.
DOL_APPLICATION_TITLE
.
'" />'
.
"
\n
"
;
$tplcontent
.
=
'<link rel="stylesheet" href="styles.css.php?website='
.
$website
.
'" type="text/css" />'
.
"
\n
"
;
$tplcontent
.
=
'<title>'
.
dol_escape_htmltag
(
$objectpage
->
title
)
.
'</title>'
.
"
\n
"
;
$tplcontent
.
=
'</header>'
.
"
\n
"
;
$tplcontent
.
=
'<body>'
.
"
\n
"
;
$tplcontent
.
=
$objectpage
->
content
.
"
\n
"
;
$tplcontent
.
=
'</body>'
.
"
\n
"
;
//var_dump($filetpl);exit;
$result
=
file_put_contents
(
$filetpl
,
$tplcontent
);
if
(
!
empty
(
$conf
->
global
->
MAIN_UMASK
))
@
chmod
(
$filetpl
,
octdec
(
$conf
->
global
->
MAIN_UMASK
));
if
(
$result
)
{
//setEventMessages($langs->trans("Saved"), null, 'mesgs');
//header("Location: ".$_SERVER["PHP_SELF"].'?website='.$website.'&pageid='.$pageid);
//exit;
}
else
setEventMessages
(
'Failed to write file '
.
$filetpl
,
null
,
'errors'
);
$action
=
'preview'
;
}
else
...
...
@@ -384,25 +460,38 @@ if ($action == 'updatecontent')
$db
->
commit
();
// Now create the .tpl file
// TODO Keep a one time generate file or include a dynamicaly generated content ?
dol_mkdir
(
$pathofwebsite
);
dol_delete_file
(
$filetpl
);
$tplcontent
=
'<html>'
.
"
\n
"
;
$tplcontent
.
=
'<header>'
.
"
\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="viewport" content="width=device-width, initial-scale=0.8">'
.
"
\n
"
;
$tplcontent
.
=
'<meta name="keywords" content="'
.
join
(
', '
,
explode
(
','
,
$objectpage
->
keywords
))
.
'" />'
.
"
\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="generator" content="'
.
DOL_APPLICATION_TITLE
.
'" />'
.
"
\n
"
;
$tplcontent
.
=
'<link rel="stylesheet" href="styles.css.php?website='
.
$website
.
'" type="text/css" />'
.
"
\n
"
;
$tplcontent
.
=
'<title>'
.
dol_escape_htmltag
(
$objectpage
->
title
)
.
'</title>'
.
"
\n
"
;
$tplcontent
.
=
'</header>'
.
"
\n
"
;
$tplcontent
.
=
'<body>'
.
"
\n
"
;
$tplcontent
.
=
$objectpage
->
content
.
"
\n
"
;
$tplcontent
.
=
'</body>'
.
"
\n
"
;
//var_dump($filetpl);exit;
//var_dump($filetpl);exit;
$result
=
file_put_contents
(
$filetpl
,
$tplcontent
);
if
(
!
empty
(
$conf
->
global
->
MAIN_UMASK
))
@
chmod
(
$filetpl
,
octdec
(
$conf
->
global
->
MAIN_UMASK
));
setEventMessages
(
$langs
->
trans
(
"Saved"
),
null
,
'mesgs'
);
header
(
"Location: "
.
$_SERVER
[
"PHP_SELF"
]
.
'?website='
.
$website
.
'&pageid='
.
$pageid
);
exit
;
if
(
$result
)
{
setEventMessages
(
$langs
->
trans
(
"Saved"
),
null
,
'mesgs'
);
header
(
"Location: "
.
$_SERVER
[
"PHP_SELF"
]
.
'?website='
.
$website
.
'&pageid='
.
$pageid
);
exit
;
}
else
setEventMessages
(
'Failed to write file '
.
$filetpl
,
null
,
'errors'
);
}
else
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment