NEW Can select sample to use when creating a new page

This commit is contained in:
Laurent Destailleur 2018-02-20 18:10:11 +01:00
parent 809ef1bd00
commit 71cbcce3a2
5 changed files with 72 additions and 3 deletions

View File

@ -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 .= '<select id="select'.$htmlname.'" class="flat selectTypeOfContainer" name="'.$htmlname.'"'.($moreattrib?' '.$moreattrib:'').'>';
if ($useempty == 1 || ($useempty == 2 && $num > 1))
{
$out .= '<option value="-1">&nbsp;</option>';
}
foreach($arrayofsamples as $key => $val)
{
if ($selected == $key)
{
$out .= '<option value="'.$key.'" selected>';
}
else
{
$out .= '<option value="'.$key.'">';
}
$out .= $langs->trans($val);
$out .= '</option>';
$i++;
}
$out .= "</select>";
return $out;
}
}

View File

@ -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 <strong>%s</strong> already exists
AliasPageAlreadyExists=Alias page <strong>%s</strong> already exists
CorporateHomePage=Corporate Home page
EmptyPage=Empty page

View File

@ -153,7 +153,7 @@ $htmlheadercontentdefault.='<script src="//cdnjs.cloudflare.com/ajax/libs/jquery
$htmlheadercontentdefault.='<script src="//cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js"></script>'."\n";
$htmlheadercontentdefault.='<script src="//cdnjs.cloudflare.com/ajax/libs/popper.js/1.13.0/umd/popper.min.js"></script>'."\n";
$htmlheadercontentdefault.='<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>'."\n";
$htmlheadercontentdefault.='<script src="/document.php?modulepart=medias&file=relativepathtomyfile.js"></script>'."\n";
$htmlheadercontentdefault.='<script src="/document.php?modulepart=medias&file=js/myfile.js"></script>'."\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 '</td></tr>';
print '<tr><td class="titlefield fieldrequired">';
print $langs->trans('WEBSITE_PAGE_EXAMPLE');
print '</td><td>';
print $formwebsite->selectSampleOfContainer('sample', (GETPOST('sample')?GETPOST('sample'):'corporatehomepage'));
print '</td></tr>';
print '<tr><td class="titlefieldcreate fieldrequired">';
print $langs->trans('WEBSITE_PAGENAME');
print '</td><td>';

View File

@ -0,0 +1,10 @@
<div class="dolcontenteditable" contenteditable="true">
<div style="text-align: center"><h1>__[MAIN_INFO_SOCIETE_NOM]__</h1><br>
__(MyContainerTitle)__
</div>
</div>
<div class="dolcontenteditable" contenteditable="true">
<br>
<div style="text-align: center">Created by: __WEBSITE_CREATE_BY__</div>
<br>
</div>