1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package fr.paris.lutece.plugins.appointment.service.entrytype;
35
36 import java.util.HashMap;
37 import java.util.Locale;
38 import java.util.Map;
39
40 import javax.servlet.http.HttpServletRequest;
41
42 import org.apache.commons.lang3.StringUtils;
43
44 import fr.paris.lutece.plugins.genericattributes.business.Entry;
45 import fr.paris.lutece.plugins.genericattributes.business.Response;
46 import fr.paris.lutece.portal.service.template.AppTemplateService;
47 import fr.paris.lutece.portal.service.util.AppPathService;
48 import fr.paris.lutece.util.html.HtmlTemplate;
49
50
51
52
53
54
55
56
57 public final class EntryTypeImage extends EntryTypeFile
58 {
59
60
61
62 private static final String TEMPLATE_HTML_CODE = "skin/plugins/appointment/entries/html_code_entry_type_image.html";
63 private static final String TEMPLATE_HTML_CODE_ADMIN = "admin/plugins/appointment/entries/html_code_entry_type_image.html";
64 private static final String TEMPLATE_FILE_IMAGE = "skin/plugins/appointment/entries/recap_entry_type_image.html";
65
66 public static final String BEAN_NAME = "appointment.entryTypeImage";
67 private static final String MARK_FILE_NAME = "file_name";
68 private static final String MARK_IMG_URL = "img_url";
69
70
71
72
73 @Override
74 public String getTemplateHtmlForm( Entry entry, boolean bDisplayFront )
75 {
76 return bDisplayFront ? TEMPLATE_HTML_CODE : TEMPLATE_HTML_CODE_ADMIN;
77 }
78
79
80
81
82 @Override
83 protected boolean checkForImages( )
84 {
85 return true;
86 }
87
88
89
90
91 @Override
92 public String getUrlDownloadFile( int nResponseId, String strBaseUrl )
93 {
94 return getUrlDownloadImage( nResponseId, strBaseUrl );
95 }
96
97
98
99
100 @Override
101 public String getResponseValueForRecap( Entry entry, HttpServletRequest request, Response response, Locale locale )
102 {
103 if ( ( response.getFile( ) != null ) && StringUtils.isNotBlank( response.getFile( ).getTitle( ) ) )
104 {
105 if ( response.getIdResponse( ) > 0 )
106 {
107 Map<String, Object> model = new HashMap<>( );
108 model.put( MARK_FILE_NAME, response.getFile( ).getTitle( ) );
109 model.put( MARK_IMG_URL, getUrlDownloadFile( response.getIdResponse( ), AppPathService.getBaseUrl( request ) ) );
110
111 HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_FILE_IMAGE, locale, model );
112
113 return template.getHtml( );
114 }
115
116 return response.getFile( ).getTitle( );
117 }
118
119 return StringUtils.EMPTY;
120 }
121 }