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.calendar.web;
35
36 import fr.paris.lutece.plugins.calendar.business.Event;
37 import fr.paris.lutece.plugins.calendar.business.MultiAgenda;
38 import fr.paris.lutece.plugins.calendar.business.MultiAgendaEvent;
39 import fr.paris.lutece.plugins.calendar.service.CalendarPlugin;
40 import fr.paris.lutece.plugins.calendar.service.Utils;
41 import fr.paris.lutece.plugins.calendar.service.search.CalendarSearchService;
42 import fr.paris.lutece.portal.service.plugin.Plugin;
43 import fr.paris.lutece.portal.service.plugin.PluginService;
44 import fr.paris.lutece.portal.service.template.AppTemplateService;
45 import fr.paris.lutece.util.html.HtmlTemplate;
46
47 import java.util.Date;
48 import java.util.HashMap;
49 import java.util.List;
50 import java.util.Map;
51
52 import javax.servlet.http.HttpServletRequest;
53
54
55
56
57
58 public class DayCalendarView implements CalendarView
59 {
60 private static final String TEMPLATE_VIEW_DAY = "skin/plugins/calendar/calendar_view_day.html";
61 private static final String TEMPLATE_VIEW_DAY_EVENT = "skin/plugins/calendar/calendar_view_day_event.html";
62
63
64
65
66
67
68
69
70
71
72
73 public String getCalendarView( String strDate, MultiAgenda agenda, CalendarUserOptions options,
74 HttpServletRequest request )
75 {
76 Map<String, Object> dayModel = new HashMap<String, Object>( );
77 StringBuffer sbEvents = new StringBuffer( );
78
79 if ( agenda.hasEvents( strDate ) )
80 {
81 Date date = Utils.getDate( strDate );
82 Plugin plugin = PluginService.getPlugin( CalendarPlugin.PLUGIN_NAME );
83 List<Event> listIndexedEvents = CalendarSearchService.getInstance( ).getSearchResults(
84 agenda.getAgendaIds( ), null, "", date, date, plugin );
85
86 for ( Event event : listIndexedEvents )
87 {
88 MultiAgendaEvent multiAgendaEvent = new MultiAgendaEvent( event,
89 String.valueOf( event.getIdCalendar( ) ) );
90 Map<String, Object> eventModel = new HashMap<String, Object>( );
91 HtmlUtils.fillEventTemplate( eventModel, multiAgendaEvent, strDate );
92
93 HtmlTemplate tEvent = AppTemplateService.getTemplate( TEMPLATE_VIEW_DAY_EVENT, options.getLocale( ),
94 eventModel );
95 sbEvents.append( tEvent.getHtml( ) );
96 }
97 }
98
99 dayModel.put( Constants.MARK_EVENTS, sbEvents.toString( ) );
100
101 HtmlTemplate tDay = AppTemplateService.getTemplate( TEMPLATE_VIEW_DAY, options.getLocale( ), dayModel );
102
103 return tDay.getHtml( );
104 }
105
106
107
108
109
110
111
112 public String getNext( String strDate )
113 {
114 return Utils.getNextDay( strDate );
115 }
116
117
118
119
120
121
122
123 public String getPrevious( String strDate )
124 {
125 return Utils.getPreviousDay( strDate );
126 }
127
128
129
130
131
132
133
134 public String getTitle( String strDate, CalendarUserOptions options )
135 {
136 return Utils.getDayLabel( strDate, options.getLocale( ) );
137 }
138
139
140
141
142
143
144
145 public String getPath( String strDate, CalendarUserOptions options )
146 {
147 return getTitle( strDate, options );
148 }
149
150
151
152
153
154 public int getType( )
155 {
156 return CalendarView.TYPE_DAY;
157 }
158 }