#--
-- Check if the checkbox must be checked or not
-- @param code the checkbox code
-- @param referecen_list the default values list
-- @return the String 'checked="checked" if the checkbox must be checked, an empty String otherwise
-->
<#function getChecked code reference_list>
<#if reference_list?has_content>
<#list reference_list as reference_item>
<#if reference_item.code = code>
<#if reference_item.checked>
<#return true>
<#else>
<#return false>
#if>
#if>
#list>
#if>
<#return false>
#function>
<#--
-- Get the value of the parameter
-- @param code the code of the parameter
-- @param referecen_list the default values list
-- @return the value of the parameter
-->
<#function getName code reference_list default=''>
<#if reference_list?has_content>
<#list reference_list as reference_item>
<#if reference_item.code = code>
<#return reference_item.name>
#if>
#list>
#if>
<#return default>
#function>
<#--
-- Get the field from a given title
-- @param entry the entry
-- @param fieldTitle the title
-- @return the field
-->
<#function getField entry fieldTitle>
<#if entry.fields?? && entry.fields?has_content>
<#list entry.fields as field>
<#if field?? && field.title?? && field.title == fieldTitle>
<#return field>
#if>
#list>
#if>
#function>
<#--
-- Get the field from a given code
-- @param entry the entry
-- @param fieldCode the code
-- @return the field
-->
<#function getFieldByCode entry fieldCode>
<#if entry.fields?? && entry.fields?has_content>
<#list entry.fields as field>
<#if field?? && field.code?? && field.code == fieldCode>
<#return field>
#if>
#list>
#if>
#function>
<#--
-- Get the field value from a given entry and a given title
-- @param entry the entry
-- @param fieldTitle the title
-- @return the field
-->
<#function getFieldValue entry fieldTitle>
<#if getField( entry, fieldTitle )??>
<#assign field = getField( entry, fieldTitle )>
<#return field.value>
#if>
<#return "">
#function>
<#--
-- Get the field value from a given entry and a given title
-- @param entry the entry
-- @param fieldTitle the title
-- @return the field
-->
<#function getFieldValueByCode entry fieldCode>
<#if getFieldByCode( entry, fieldCode )??>
<#assign field = getFieldByCode( entry, fieldCode )>
<#return field.value>
#if>
<#return "">
#function>
<#--
-- Get the response containing the field with the given title
-- @param responses the list of responses
-- @param the fieldCode the code
-- @return the response
-->
<#function getResponseContainingTheFieldWithTitle responses fieldTitle>
<#if responses??>
<#list responses as response>
<#if response.field?? && response.field.title?? && response.field.title == fieldTitle >
<#return response />
#if>
#list>
#if>
#function>
<#--
-- Get the response containing the field with the given code
-- @param responses the list of responses
-- @param the fieldCode the code
-- @return the response
-->
<#function getResponseContainingTheFieldWithCode responses fieldCode>
<#if responses??>
<#list responses as response>
<#if response.field?? && response.field.code?? && response.field.code == fieldCode >
<#return response />
#if>
#list>
#if>
#function>
<#--
-- Get the response from a given entry
-- WARNING : use only if the entry has ONE response
-- @param responses the list of responses
-- @param entry the entry
-- @return the response entry
-->
<#function getResponse responses entry>
<#if responses??>
<#list responses as response>
<#if response.entry.idEntry == entry.idEntry>
<#return response />
#if>
#list>
#if>
#function>
<#--
-- Get the response entry from a given entry
-- @param responses the list of responses
-- @param entry the entry
-- @return the response entry
-->
<#function getResponseEntry responses entry>
<#if responses??>
<#list responses as response>
<#if response.entry.idEntry == entry.idEntry>
<#return response.entry />
#if>
#list>
#if>
#function>
<#--
-- Get the error for the given entry
-- @param responses the list of responses
-- @param entry the entry
-- @return the error
-->
<#function getError responses entry>
<#if getResponseEntry( responses, entry )??>
<#assign responseEntry = getResponseEntry( responses, entry ) >
<#return responseEntry.error />
#if>
#function>
<#--
-- Get the max files value of an entry
-- @param entry the entry
-- @return the number of max authorized uploaded files
-->
<#function getMaxFiles entry>
<#assign fieldMaxFiles = getFieldValueByCode( entry, "max_files" )>
<#if fieldMaxFiles?? && fieldMaxFiles != "">
<#return fieldMaxFiles>
#if>
<#return "1">
#function>
<#--
-- Get the max size an uploaded file is authorized to have
-- @param entry the entry
-- @return the max size
-->
<#function getFileMaxSize entry>
<#assign fieldFileMaxSize = getFieldValueByCode( entry, "file_max_size" )>
<#if fieldFileMaxSize?? && fieldFileMaxSize != "">
<#return fieldFileMaxSize>
<#else>
<#if getField( entry, "option" )??>
<#assign fieldFileMaxSize = getFieldByCode( entry, "option" )>
<#return fieldFileMaxSize.width>
#if>
#if>
<#return "5242880">
#function>
<#--
-- Check if the given entry must export the binary
-- @param entry the entry
-- @return true if it must export the binaries, false otherwise
-->
<#function exportBinary entry>
<#assign field = getFieldValueByCode( entry, "export_binary" ) />
<#if field?? && field = "true">
<#return true />
#if>
<#return false />
#function>
<#--
-- Build the entry name
-- @param entry the entry
-- @param entry_iteration_number the iteration number
-- @return the name
-->
<#function buildEntryName entry entry_iteration_number='' >
<#assign name = 'attribute' + entry.idEntry>
<#if entry_iteration_number?? && entry_iteration_number?has_content>
<#assign name = 'nIt' + entry_iteration_number + '_attribute' + entry.idEntry>
#if>
<#return name />
#function>
<#macro formEditor >
<#include "/admin/util/editor/editor.html" />
<#assign cssFiles="editor.css, page_template_styles.css" />
<#assign editorLocale="" />
<#-- We only have the language pack for French (France) installed in webapp/js/editors/tinymce/langs -->
<#-- Some lutece plugins pass locale.getLanguage() (="fr"), some pass the locale object (toString="fr_FR", or more complicated...) -->
<#-- Force it here because if it is a wrong value, tinyMCE does not load -->
<#if locale?? && (2 <= locale?string?length) && (locale?string?substring(0,2) == "fr")>
<#assign editorLocale="fr_FR" />
#if>
<@initEditor cssFiles=cssFiles />
#macro>
<#macro toastr infos warnings errors msg='' msgType='info' clickUrl=''>
#macro>
<#macro formBreadCrumb home='jsp/admin/plugins/forms/ManageForms.jsp'>
<@row>
<@breadcrumbs id='breadforms' params=' style="margin-bottom:1em; background-color:transparent;"'>
<@breadcrumbItem>
<@link href=home title='Retour liste des formulaires'>
<@icon style='home' />
@link>
@breadcrumbItem>
<#nested>
@breadcrumbs>
@row>
#macro>
<#macro formModal id='pubModal' title=''>
<@modal id='${id}'>
<#if token??>
<@input type='hidden' id='token' name='token' value='${token}' />
#if>
<@modalHeader />
@modal>
#macro>
<#macro headerButton name='view_manageForm' label='portal.admin.message.buttonCancel' validate=true>
<#if validate>
<#assign color = '' />
<#assign buttonIcon = 'check' />
<#else>
<#assign color = 'danger' />
<#assign buttonIcon = 'times' />
#if>
<@button type='submit' name='${name}' title='#i18n{${label}}' cancel=!validate buttonIcon=buttonIcon color=color />
#macro>
<#macro formsButton okAction='' viewAction='' rows=1>
<@button type='submit' id='action_${okAction}' name='action_${okAction}' buttonIcon='check' title='#i18n{portal.admin.message.buttonValidate}' />
<#nested>
<#if viewAction !=''>
<@button type='submit' name='view_${viewAction}' title='#i18n{portal.admin.message.buttonCancel}' cancel=true buttonIcon='times' />
#if>
#macro>
<#macro modalFrameScript formId actionId title modalId='qModal' iframeId='modalIframe' modalHeight=70 >
#macro>
<#macro formModel type='update'>
<#include "/admin/plugins/asynchronousupload/upload_commons.html" />
<@addRequiredJsFiles />
<@row>
<@columns md=7>
<@fieldSet legend='#i18n{forms.modify_form.labelDescription}'>
<@formGroup labelKey='#i18n{forms.modify_form.labelTitle}' helpKey='#i18n{forms.modify_form.labelTitle.help}' mandatory=true rows=2>
<@input type='text' name='title' value='${form.title!}' />
@formGroup>
<@formGroup labelKey='#i18n{forms.modify_form.labelDescription}' helpKey='#i18n{forms.modify_form.labelDescription.help}' rows=2>
<@input type='textarea' name='description'>${form.description!}@input>
@formGroup>
<@formGroup labelKey='#i18n{forms.modify_form.labelCategory}' helpKey='#i18n{forms.modify_form.labelCategory.help}' rows=2>
<@select name='id_category' items=categoryList default_value='${form.idCategory!}' />
@formGroup>
<@formGroup labelKey='#i18n{forms.modify_form.labelLogo}' helpKey='#i18n{forms.modify_form.labelLogo.help}' rows=2>
<@addFileInput fieldName="upload_logo" handler=uploadHandler submitBtnName='action_doSynchronousUploadDocument' cssClass='' multiple=true />
<#if !listFiles??><#assign listFiles = ''>#if>