]> err.no Git - sope/blob - sopex/Samples/WOxExtTest/MonthOverview.m
git-svn-id: http://svn.opengroupware.org/SOPE/trunk@1201 e4a50df8-12e2-0310-a44c...
[sope] / sopex / Samples / WOxExtTest / MonthOverview.m
1 /*
2   Copyright (C) 2000-2003 SKYRIX Software AG
3
4   This file is part of OGo
5
6   OGo is free software; you can redistribute it and/or modify it under
7   the terms of the GNU Lesser General Public License as published by the
8   Free Software Foundation; either version 2, or (at your option) any
9   later version.
10
11   OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12   WARRANTY; without even the implied warranty of MERCHANTABILITY or
13   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14   License for more details.
15
16   You should have received a copy of the GNU Lesser General Public
17   License along with OGo; see the file COPYING.  If not, write to the
18   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19   02111-1307, USA.
20 */
21 // $Id: MonthOverview.m 1 2004-08-20 11:17:52Z znek $
22
23 #include <NGObjWeb/WOComponent.h>
24
25 @class NSArray;
26
27 @interface MonthOverview: WOComponent
28 {
29   NSArray *list;
30 }
31 @end
32
33 #include "common.h"
34
35 @implementation MonthOverview
36
37 static inline void setDateWithKey(id obj, NSString *key) {
38   NSString *str;
39
40   str = [obj objectForKey:key];
41
42   if (str) {
43     NSCalendarDate *date;
44
45     date = [NSCalendarDate dateWithString:str
46                            calendarFormat:@"%Y-%m-%d %H:%M:%S %Z"];
47     [obj setObject:date forKey:key];
48   }
49 }
50
51 - (id)init {
52   if ((self = [super init])) {
53   }
54   return self;
55 }
56
57 - (void)dealloc {
58   RELEASE(self->list);
59   [super dealloc];
60 }
61
62 - (NSCalendarDate *)weekStart {
63   return [NSCalendarDate dateWithString:@"2000-11-06 00:00:00 +0100"
64                          calendarFormat:@"%Y-%m-%d %H:%M:%S %Z"];
65 }
66
67 - (NSArray *)list {
68   if (self->list == nil) {
69     WOResourceManager *rm;
70     NSString          *path;
71
72     rm = [[self application] resourceManager];
73     path = [rm pathForResourceNamed:@"appointments.plist"
74                inFramework:nil
75                languages:nil];
76
77     self->list = [[NSArray alloc] initWithContentsOfFile:path];
78
79     {
80       int i, cnt;
81       
82       for (i = 0, cnt = [self->list count]; i < cnt; i++) {
83         setDateWithKey([self->list objectAtIndex:i], @"startDate");
84         setDateWithKey([self->list objectAtIndex:i], @"endDate");
85       }
86     }
87   }
88   return self->list;
89 }
90
91 - (NSString *)contentColor {
92   NSCalendarDate *day = nil;
93
94   day = [self valueForKey:@"currentDay"];
95   return ([day monthOfYear] == 11) ? @"#CCCCCC" : @"EEEEEE";
96 }
97
98 @end