From 71cbcce3a2bf4918c3495e55b5c52d5b1fa2a9dd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Feb 2018 18:10:11 +0100 Subject: [PATCH] NEW Can select sample to use when creating a new page --- htdocs/core/class/html.formwebsite.class.php | 45 +++++++++++++++++++ htdocs/langs/en_US/website.lang | 5 ++- htdocs/website/index.php | 15 ++++++- ...te.html => page-sample-corporatehome.html} | 0 htdocs/website/page-sample-empty.html | 10 +++++ 5 files changed, 72 insertions(+), 3 deletions(-) rename htdocs/website/{pagetemplate.html => page-sample-corporatehome.html} (100%) create mode 100644 htdocs/website/page-sample-empty.html diff --git a/htdocs/core/class/html.formwebsite.class.php b/htdocs/core/class/html.formwebsite.class.php index 4f92b2e9449..e7cd6d447a0 100644 --- a/htdocs/core/class/html.formwebsite.class.php +++ b/htdocs/core/class/html.formwebsite.class.php @@ -158,4 +158,49 @@ class FormWebsite } } + + /** + * Return a HTML select list of a dictionary + * + * @param string $htmlname Name of select zone + * @param string $selected Selected value + * @param int $useempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries. + * @param string $moreattrib More attributes on HTML select tag + * @return void + */ + function selectSampleOfContainer($htmlname, $selected='', $useempty=0, $moreattrib='') + { + global $langs, $conf, $user; + + $langs->load("admin"); + + $arrayofsamples=array('corporatehome'=>'CorporateHomePage', 'empty'=>'EmptyPage'); + + $out = ''; + + $out .= '"; + + return $out; + } + } diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index 6e67062b859..a4c7d9e0211 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_TYPE_CONTAINER=Type of page/container +WEBSITE_PAGE_EXAMPLE=Web page to use as example WEBSITE_PAGENAME=Page name/alias WEBSITE_CSS_URL=URL of external CSS file WEBSITE_CSS_INLINE=CSS file content (common to all pages) @@ -76,4 +77,6 @@ GrabImagesInto=Grab also images found into css and page. ImagesShouldBeSavedInto=Images should be saved into directory WebsiteRootOfImages=Root directory for website images SubdirOfPage=Sub-directory dedicated to page -AliasPageAlreadyExists=Alias page %s already exists \ No newline at end of file +AliasPageAlreadyExists=Alias page %s already exists +CorporateHomePage=Corporate Home page +EmptyPage=Empty page \ No newline at end of file diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 959529eb44e..084ef28c2d0 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -153,7 +153,7 @@ $htmlheadercontentdefault.=''."\n"; $htmlheadercontentdefault.=''."\n"; $htmlheadercontentdefault.=''."\n"; -$htmlheadercontentdefault.=''."\n"; +$htmlheadercontentdefault.=''."\n"; /* @@ -552,8 +552,13 @@ if ($action == 'addcontainer') $substitutionarray=array(); $substitutionarray['__WEBSITE_CREATE_BY__']=$user->getFullName($langs); + $sample = GETPOST('sample','alpha'); + if (empty($sample)) $sample='empty'; + + $pathtosample = DOL_DOCUMENT_ROOT.'/website/page-sample-'.$sample.'.html'; + // Init content with content into pagetemplate.html, blogposttempltate.html, ... - $objectpage->content = make_substitutions(@file_get_contents(DOL_DOCUMENT_ROOT.'/website/'.$objectpage->type_container.'template.html'), $substitutionarray); + $objectpage->content = make_substitutions(@file_get_contents($pathtosample), $substitutionarray); } if (! $error) @@ -2036,6 +2041,12 @@ if ($action == 'editmeta' || $action == 'createcontainer') print $formwebsite->selectTypeOfContainer('WEBSITE_TYPE_CONTAINER', (GETPOST('WEBSITE_TYPE_CONTAINER')?GETPOST('WEBSITE_TYPE_CONTAINER'):'page')); print ''; + print ''; + print $langs->trans('WEBSITE_PAGE_EXAMPLE'); + print ''; + print $formwebsite->selectSampleOfContainer('sample', (GETPOST('sample')?GETPOST('sample'):'corporatehomepage')); + print ''; + print ''; print $langs->trans('WEBSITE_PAGENAME'); print ''; diff --git a/htdocs/website/pagetemplate.html b/htdocs/website/page-sample-corporatehome.html similarity index 100% rename from htdocs/website/pagetemplate.html rename to htdocs/website/page-sample-corporatehome.html diff --git a/htdocs/website/page-sample-empty.html b/htdocs/website/page-sample-empty.html new file mode 100644 index 00000000000..313c398a86e --- /dev/null +++ b/htdocs/website/page-sample-empty.html @@ -0,0 +1,10 @@ +
+

__[MAIN_INFO_SOCIETE_NOM]__


+__(MyContainerTitle)__ +
+
+
+
+
Created by: __WEBSITE_CREATE_BY__
+
+