2 Copyright (C) 2000-2005 SKYRIX Software AG
4 This file is part of SOPE.
6 SOPE 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 SOPE 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 SOPE; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #include "iCalPortalPage.h"
25 @interface iCalLabelDispatcher : NSObject
27 iCalPortalPage *component;
30 - (id)initWithComponent:(iCalPortalPage *)_comp;
34 @implementation iCalPortalPage
37 return [super version] + 0 /* v2 */;
40 NSAssert2([super version] == 2,
41 @"invalid superclass (%@) version %i !",
42 NSStringFromClass([self superclass]), [super version]);
51 - (iCalPortalDatabase *)database {
52 return [(id)[self application] database];
55 - (iCalPortalUser *)user {
56 if (![self hasSession])
59 return [[self session] objectForKey:@"user"];
64 - (BOOL)isSessionProtectedPage {
68 - (id<WOActionResults>)indexPage {
69 NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
72 if ((sn = [self existingSession])) {
73 [sn removeObjectForKey:@"user"];
77 if ([[ud objectForKey:@"DevMode"] boolValue]) {
78 return [[self pageWithName:@"iCalPortalWelcomePage"] performPage];
83 r = [WOResponse responseWithRequest:[[self context] request]];
86 [r setHeader:@"/en/index.xhtml" forKey:@"location"];
95 if ([self isSessionProtectedPage]) {
96 if (![self hasSession]) {
98 @"tried to access login protected page without session !"];
99 return [self indexPage];
115 return [[[iCalLabelDispatcher alloc] initWithComponent:self] autorelease];
118 - (NSString *)stringForKey:(NSString *)_key {
122 langs = [self hasSession]
123 ? [[self session] languages]
124 : [[[self context] request] browserLanguages];
126 s = [[self resourceManager]
127 stringForKey:_key inTableNamed:@"main" withDefaultValue:_key
132 - (NSString *)localizedTitle {
133 return [self stringForKey:[self name]];
136 @end /* iCalPortalPage */
138 @implementation iCalLabelDispatcher
140 - (id)initWithComponent:(iCalPortalPage *)_comp {
141 self->component = _comp;
145 - (id)valueForKey:(NSString *)_key {
146 if ([_key length] == 0)
149 return [self->component stringForKey:_key];
152 @end /* iCalLabelDispatcher */