]> err.no Git - scalable-opengroupware.org/blob - SOGo/UI/Common/UIxPageFrame.m
work on mailer
[scalable-opengroupware.org] / SOGo / UI / Common / UIxPageFrame.m
1 /*
2   Copyright (C) 2004 SKYRIX Software AG
3
4   This file is part of OpenGroupware.org.
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 <SOGoUI/UIxComponent.h>
24
25 @interface UIxPageFrame : UIxComponent
26 {
27   NSString *title;
28   NSString *rootURL;
29   NSString *userRootURL;
30   id item;
31 }
32
33 - (NSString *)rootURL;
34 - (NSString *)userRootURL;
35 - (NSString *)calendarRootURL;
36
37 @end
38
39 #include "common.h"
40 #include <NGObjWeb/SoComponent.h>
41
42 @implementation UIxPageFrame
43
44 - (void)dealloc {
45   [self->item        release];
46   [self->title       release];
47   [self->rootURL     release];
48   [self->userRootURL release];
49   [super dealloc];
50 }
51
52 /* accessors */
53
54 - (void)setTitle:(NSString *)_value {
55   ASSIGNCOPY(self->title, _value);
56 }
57 - (NSString *)title {
58   if ([self isUIxDebugEnabled])
59     return self->title;
60   
61   return [self labelForKey:@"OpenGroupware.org"];
62 }
63
64 - (void)setItem:(id)_item {
65   ASSIGN(self->item, _item);
66 }
67 - (id)item {
68   return self->item;
69 }
70
71 /* notifications */
72
73 - (void)sleep {
74   [self->item release]; self->item = nil;
75   [super sleep];
76 }
77
78 /* URL generation */
79
80 - (NSString *)rootURL {
81   WOContext *ctx;
82   NSArray   *traversalObjects;
83
84   if (self->rootURL != nil)
85     return self->rootURL;
86
87   ctx = [self context];
88   traversalObjects = [ctx objectTraversalStack];
89   self->rootURL = [[[traversalObjects objectAtIndex:0]
90                                       rootURLInContext:ctx]
91                                       copy];
92   return self->rootURL;
93 }
94
95 - (NSString *)userRootURL {
96   WOContext *ctx;
97   NSArray   *traversalObjects;
98
99   if (self->userRootURL)
100     return self->userRootURL;
101
102   ctx = [self context];
103   traversalObjects = [ctx objectTraversalStack];
104   self->userRootURL = [[[[traversalObjects objectAtIndex:1]
105                                            baseURLInContext:ctx]
106                                            stringByAppendingString:@"/"]
107                                            retain];
108   return self->userRootURL;
109 }
110
111 - (NSString *)calendarRootURL {
112   return [[self userRootURL] stringByAppendingString:@"Calendar/"];
113 }
114 - (NSString *)contactsRootURL {
115   return [[self userRootURL] stringByAppendingString:@"Contacts/"];
116 }
117
118 @end /* UIxPageFrame */