]> err.no Git - sope/blob - sope-appserver/samples/WOxExtTest/WeekOverview.m
include config.make in makefiles
[sope] / sope-appserver / samples / WOxExtTest / WeekOverview.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$
22
23 #include <NGObjWeb/WOComponent.h>
24
25 @class NSArray;
26
27 @interface WeekOverview : WOComponent
28 {
29   NSArray *list;
30 }
31 @end
32
33 #include "common.h"
34
35 @implementation WeekOverview
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 - (NSArray *)abList {
63   return [NSArray arrayWithObjects:@"a", @"b", nil];
64 }
65 - (NSArray *)cdList {
66   return [NSArray arrayWithObjects:@"c", @"d", nil];
67 }
68
69 - (NSCalendarDate *)weekStart {
70   NSCalendarDate *ws;
71   
72   ws = [NSCalendarDate dateWithString:@"2000-11-06 00:00:00 +0100"
73                        calendarFormat:@"%Y-%m-%d %H:%M:%S %z"];
74   if (ws == nil)
75     [self logWithFormat:@"couldn't create weekstart !"];
76   return ws;
77 }
78
79 - (NSArray *)list {
80   if (self->list == nil) {
81     WOResourceManager *rm;
82     NSString          *path;
83
84     rm = [[self application] resourceManager];
85     path = [rm pathForResourceNamed:@"appointments.plist"
86                inFramework:nil
87                languages:nil];
88     
89     self->list = [[NSArray alloc] initWithContentsOfFile:path];
90
91     {
92       int i, cnt;
93       
94       for (i = 0, cnt = [self->list count]; i < cnt; i++) {
95         setDateWithKey([self->list objectAtIndex:i], @"startDate");
96         setDateWithKey([self->list objectAtIndex:i], @"endDate");
97       }
98     }
99   }
100   return self->list;
101 }
102
103 @end /* WeekOverview */