]> err.no Git - scalable-opengroupware.org/blob - UI/Scheduler/UIxCalDateSelector.m
git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1089 d1b88da0-ebda-0310...
[scalable-opengroupware.org] / UI / Scheduler / UIxCalDateSelector.m
1 /* UIxCalDateSelector.m - this file is part of SOGo
2  *
3  * Copyright (C) 2006 Inverse groupe conseil
4  *
5  * Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
6  *
7  * This file is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2, or (at your option)
10  * any later version.
11  *
12  * This file is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; see the file COPYING.  If not, write to
19  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22
23 #import <NGExtensions/NSCalendarDate+misc.h>
24
25 #import <SOGo/NSCalendarDate+SOGo.h>
26
27 #import "UIxCalDateSelector.h"
28
29 @implementation UIxCalDateSelector
30
31 /* binding accessors */
32
33 - (void) setSelectedDate: (NSCalendarDate *) _date
34 {
35   ASSIGN (selectedDate, _date);
36   [selectedDate setTimeZone: timeZone];
37 }
38
39 - (NSCalendarDate *) selectedDate
40 {
41   if (!selectedDate)
42     selectedDate = [super selectedDate];
43
44   return selectedDate;
45 }
46
47 - (NSString *) style
48 {
49   return style;
50 }
51
52 - (NSString *) headerStyle
53 {
54   return headerStyle;
55 }
56
57 - (NSString *) weekStyle
58 {
59   return weekStyle;
60 }
61
62 - (void) setTodayWeekStyle: (NSString *) _style
63 {
64   ASSIGN (todayWeekStyle, _style);
65 }
66
67 - (NSString *) todayWeekStyle
68 {
69   return ((todayWeekStyle)
70           ? todayWeekStyle
71           : [self weekStyle]);
72 }
73
74 - (NSString *) dayHeaderStyle
75 {
76   return dayHeaderStyle;
77 }
78
79 - (void) setSelectedDayExtraStyle: (NSString *) _style
80 {
81   ASSIGN(selectedDayExtraStyle, _style);
82 }
83
84 - (NSString *) selectedDayExtraStyle
85 {
86   return selectedDayExtraStyle;
87 }
88
89 /* date ranges */
90
91 - (NSCalendarDate *) startDate
92 {
93   return [[self selectedDate] firstDayOfMonth];
94 }
95
96 /* labels */
97
98 - (NSString *) headerMonthValue
99 {
100   NSCalendarDate *date;
101
102   date = [self startDate];
103
104   return [NSString stringWithFormat: @"%.2d", [date monthOfYear]];
105 }
106
107 - (NSString *) headerMonthString
108 {
109   NSCalendarDate *date;
110
111   date = [self startDate];
112
113   return [NSString stringWithFormat:@"%@",
114                    [self localizedNameForMonthOfYear: [date monthOfYear]]];
115 }
116
117 - (NSString *) headerYearString
118 {
119   NSCalendarDate *date;
120
121   date = [self startDate];
122
123   return [NSString stringWithFormat: @"%d", [date yearOfCommonEra]];
124 }
125
126 - (NSString *) localizedDayOfWeekName
127 {
128   return [self localizedAbbreviatedNameForDayOfWeek: [self dayOfWeek]];
129 }
130
131
132 /* stylesheets */
133
134 - (NSString *) currentWeekStyle
135 {
136   return (([currentWeekStart isDateInSameWeek:[NSCalendarDate date]] &&
137            [currentWeekStart isDateInSameMonth:[self selectedDate]])
138           ? [self todayWeekStyle]
139           : [self weekStyle]);
140 }
141
142 - (NSString *) contentStyle
143 {
144   return (([currentDay isToday]
145            && [currentDay isDateInSameMonth:[self selectedDate]])
146           ? @"dayOfToday"
147           : (([currentDay monthOfYear] != [[self startDate] monthOfYear])
148              ? @"inactiveDay"
149              :  @"activeDay"));
150 }
151
152 - (NSString *) extraStyle
153 {
154   return (([[self selectedDate] isDateOnSameDay: currentDay])
155           ? [self selectedDayExtraStyle]
156           : nil);
157 }
158
159 /* URLs */
160
161 - (NSDictionary *) currentMonthQueryParameters
162 {
163   return [self queryParametersBySettingSelectedDate: [self startDate]];
164 }
165
166 /* overriding */
167
168 - (NSArray *) fetchCoreInfos
169 {
170   return nil;
171 }
172
173 @end