]> err.no Git - scalable-opengroupware.org/blob - SOGo/UI/Common/UIxPageFrame.m
3ff669631e08fada3a6011cb09aec0d4b2520199
[scalable-opengroupware.org] / SOGo / UI / Common / UIxPageFrame.m
1 // $Id$
2
3 #include <SOGoUI/UIxComponent.h>
4
5 @interface UIxPageFrame : UIxComponent
6 {
7     NSString *title;
8     NSString *rootURL;
9     NSString *userRootURL;
10 }
11
12 - (NSString *)rootURL;
13 - (NSString *)userRootURL;
14 - (NSString *)calendarRootURL;
15
16 @end
17
18 #include "common.h"
19 #include <NGObjWeb/SoComponent.h>
20
21 @implementation UIxPageFrame
22
23 - (void)dealloc {
24   [self->title release];
25   [self->rootURL release];
26   [self->userRootURL release];
27   [super dealloc];
28 }
29
30 /* accessors */
31
32 - (void)setTitle:(NSString *)_value {
33   ASSIGN(self->title, _value);
34 }
35 - (NSString *)title {
36   if([self isUIxDebugEnabled])
37     return self->title;
38     return [self labelForKey:@"OpenGroupware.org"];
39 }
40
41 /* URL generation */
42
43 - (NSString *)rootURL {
44   WOContext *ctx;
45   NSArray   *traversalObjects;
46
47   if (self->rootURL)
48     return self->rootURL;
49
50   ctx = [self context];
51   traversalObjects = [ctx objectTraversalStack];
52   self->rootURL = [[[traversalObjects objectAtIndex:0]
53                                       rootURLInContext:ctx]
54                                       retain];
55   return self->rootURL;
56 }
57
58 - (NSString *)userRootURL {
59   WOContext *ctx;
60   NSArray   *traversalObjects;
61
62   if (self->userRootURL)
63     return self->userRootURL;
64
65   ctx = [self context];
66   traversalObjects = [ctx objectTraversalStack];
67   self->userRootURL = [[[[traversalObjects objectAtIndex:1]
68                                            baseURLInContext:ctx]
69                                            stringByAppendingString:@"/"]
70                                            retain];
71   return self->userRootURL;
72 }
73
74 - (NSString *)calendarRootURL {
75   return [[self userRootURL] stringByAppendingString:@"Calendar/"];
76 }
77 - (NSString *)contactsRootURL {
78   return [[self userRootURL] stringByAppendingString:@"Contacts/"];
79 }
80
81 @end /* UIxPageFrame */