2 Copyright (C) 2000-2004 SKYRIX Software AG
4 This file is part of OpenGroupware.org.
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
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.
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
23 #include "iCalPortalPage.h"
26 @interface iCalLabelDispatcher : NSObject
28 iCalPortalPage *component;
31 - (id)initWithComponent:(iCalPortalPage *)_comp;
35 @implementation iCalPortalPage
38 return [super version] + 0 /* v2 */;
41 NSAssert2([super version] == 2,
42 @"invalid superclass (%@) version %i !",
43 NSStringFromClass([self superclass]), [super version]);
52 - (iCalPortalDatabase *)database {
53 return [(id)[self application] database];
56 - (iCalPortalUser *)user {
57 if (![self hasSession])
60 return [[self session] objectForKey:@"user"];
65 - (BOOL)isSessionProtectedPage {
69 - (id<WOActionResults>)indexPage {
70 NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
73 if ((sn = [self existingSession])) {
74 [sn removeObjectForKey:@"user"];
78 if ([[ud objectForKey:@"DevMode"] boolValue]) {
79 return [[self pageWithName:@"iCalPortalWelcomePage"] performPage];
84 r = [WOResponse responseWithRequest:[[self context] request]];
87 [r setHeader:@"/en/index.xhtml" forKey:@"location"];
96 if ([self isSessionProtectedPage]) {
97 if (![self hasSession]) {
99 @"tried to access login protected page without session !"];
100 return [self indexPage];
116 return [[[iCalLabelDispatcher alloc] initWithComponent:self] autorelease];
119 - (NSString *)stringForKey:(NSString *)_key {
123 langs = [self hasSession]
124 ? [[self session] languages]
125 : [[[self context] request] browserLanguages];
127 s = [[self resourceManager]
128 stringForKey:_key inTableNamed:@"main" withDefaultValue:_key
133 - (NSString *)localizedTitle {
134 return [self stringForKey:[self name]];
137 @end /* iCalPortalPage */
139 @implementation iCalLabelDispatcher
141 - (id)initWithComponent:(iCalPortalPage *)_comp {
142 self->component = _comp;
146 - (id)valueForKey:(NSString *)_key {
147 if ([_key length] == 0)
150 return [self->component stringForKey:_key];
153 @end /* iCalLabelDispatcher */