3 #include "UIxCalView.h"
5 #include "UIxAppointmentFormatter.h"
7 @implementation UIxCalView
10 [self->appointment release];
11 [self->appointments release];
12 [self->currentDay release];
18 - (void)setAppointments:(NSArray *)_apts {
19 ASSIGN(self->appointments, _apts);
21 - (NSArray *)appointments {
22 return self->appointments;
25 - (void)setAppointment:(id)_apt {
26 ASSIGN(self->appointment, _apt);
29 return self->appointment;
32 - (NSDictionary *)aptTypeDict {
36 - (NSString *)aptTypeLabel {
40 - (NSString *)aptTypeIcon {
44 - (NSString *)shortTextForApt {
45 NSCalendarDate *startDate;
48 startDate = [[self appointment] valueForKey:@"startDate"];
49 ms = [NSString stringWithFormat:@"%02i:%02i %@",
50 [startDate hourOfDay],
51 [startDate minuteOfHour],
52 [[self appointment] valueForKey:@"title"]];
56 - (NSString *)shortTitleForApt {
59 title = [self->appointment valueForKey:@"title"];
60 if([title length] > 12) {
61 title = [NSString stringWithFormat:@"%@...",
62 [title substringToIndex:11]];
67 - (NSCalendarDate *)referenceDateForFormatter {
68 return [self selectedDate];
71 /* current day related */
73 - (void)setCurrentDay:(NSCalendarDate *)_day {
74 ASSIGN(self->currentDay, _day);
76 - (NSCalendarDate *)currentDay {
77 return self->currentDay;
80 - (NSString *)currentDayName {
81 // TODO: this is slow, use locale dictionary to speed this up
82 return [self->currentDay descriptionWithCalendarFormat:@"%A"];
86 return [self hasHoldidayInfo] || ([[self allDayApts] count] != 0);
89 - (BOOL)hasHoldidayInfo {
93 - (NSArray *)allDayApts {
94 return [NSArray array];
101 - (BOOL)showFullNames {
105 - (BOOL)showAMPMDates {
112 - (NSString *)appointmentViewURL {
115 if ((pkey = [[self appointment] valueForKey:@"uid"]) == nil)
118 return [NSString stringWithFormat:@"%@/view", pkey];
124 /* resource URLs (TODO?) */
126 - (NSString *)resourcePath {
127 return @"/sogod.woa/WebServerResources/";
130 - (NSString *)favIconPath {
131 return [[self resourcePath] stringByAppendingPathComponent:@"favicon.ico"];
133 - (NSString *)cssPath {
136 // TODO: there should be reusable functionality for that!
137 #warning ZideStore specific?
138 path = @"ControlPanel/Products/ZideStoreUI/Resources/zidestoreui.css";
139 return [[self context] urlWithRequestHandlerKey:@"so"
144 - (NSString *)calCSSPath {
147 // TODO: there should be reusable functionality for that!
148 #warning ZideStore specific?
149 path = @"ControlPanel/Products/ZideStoreUI/Resources/calendar.css";
150 return [[self context] urlWithRequestHandlerKey:@"so"
157 - (NSCalendarDate *)startDate {
158 return [self selectedDate];
160 - (NSCalendarDate *)endDate {
161 return [[self startDate] tomorrow];
164 - (NSArray *)fetchCoreInfos {
165 if (self->appointments)
166 return self->appointments;
169 [[[self clientObject] fetchCoreInfosFrom:[self startDate]
170 to:[self endDate]] retain];
171 return self->appointments;
174 /* date selection & conversion */
177 - (NSDictionary *)todayQueryParameters {
178 NSCalendarDate *date;
180 date = [NSCalendarDate date]; /* today */
181 return [self queryParametersBySettingSelectedDate:date];
184 - (NSDictionary *)currentDayQueryParameters {
185 return [self queryParametersBySettingSelectedDate:self->currentDay];
188 - (NSDictionary *)queryParametersBySettingSelectedDate:(NSCalendarDate *)_date {
189 NSMutableDictionary *qp;
191 qp = [[self queryParameters] mutableCopy];
192 [self setSelectedDateQueryParameter:_date inDictionary:qp];
193 return [qp autorelease];
196 - (void)setSelectedDateQueryParameter:(NSCalendarDate *)_newDate
197 inDictionary:(NSMutableDictionary *)_qp;
200 [_qp setObject:[self dateStringForDate:_newDate]
203 [_qp removeObjectForKey:@"day"];
206 @end /* UIxCalView */