2 Copyright (C) 2004-2005 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
22 #include <SOGoUI/UIxComponent.h>
24 @interface UIxMailMainFrame : UIxComponent
28 NSString *userRootURL;
32 int hideFrame:1; /* completely disables all the frame around the comp. */
37 - (NSString *)rootURL;
38 - (NSString *)userRootURL;
39 - (NSString *)calendarRootURL;
43 @interface UIxMailPanelFrame : UIxMailMainFrame
47 #include <NGObjWeb/SoComponent.h>
49 @implementation UIxMailMainFrame
51 static NSString *treeRootClassName = nil;
54 NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
56 treeRootClassName = [[ud stringForKey:@"SOGoMailTreeRootClass"] copy];
57 if (treeRootClassName)
58 NSLog(@"Note: use class '%@' as root for mail tree.", treeRootClassName);
60 treeRootClassName = @"SOGoMailAccounts";
65 [self->title release];
66 [self->rootURL release];
67 [self->userRootURL release];
73 - (NSString *)treeRootClassName {
74 return treeRootClassName;
77 - (void)setHideFolderTree:(BOOL)_flag {
78 self->mmfFlags.hideFolderTree = _flag ? 1 : 0;
80 - (BOOL)hideFolderTree {
81 return self->mmfFlags.hideFolderTree ? YES : NO;
84 - (void)setHideFrame:(BOOL)_flag {
85 self->mmfFlags.hideFrame = _flag ? 1 : 0;
88 return self->mmfFlags.hideFrame ? YES : NO;
91 - (void)setTitle:(NSString *)_value {
92 ASSIGNCOPY(self->title, _value);
95 if ([self->title length] == 0)
96 return @"OpenGroupware.org";
101 - (void)setItem:(id)_item {
102 ASSIGN(self->item, _item);
108 - (NSString *)pageFormURL {
112 u = [[[self context] request] uri];
113 if ((r = [u rangeOfString:@"?"]).length > 0) {
114 /* has query parameters */
115 // TODO: this is ugly, create reusable link facility in SOPE
116 // TODO: remove 'search' and 'filterpopup', preserve sorting
121 qp = [[u substringFromIndex:(r.location + r.length)]
122 componentsSeparatedByString:@"&"];
124 ms = [NSMutableString stringWithCapacity:count * 12];
126 for (i = 0; i < count; i++) {
129 s = [qp objectAtIndex:i];
132 if ([s hasPrefix:@"search="]) continue;
133 if ([s hasPrefix:@"filterpopup="]) continue;
135 if ([ms length] > 0) [ms appendString:@"&"];
139 if ([ms length] == 0) {
140 /* no other query params */
141 u = [u substringToIndex:r.location];
144 u = [u substringToIndex:r.location + r.length];
145 u = [u stringByAppendingString:ms];
149 return [u hasSuffix:@"/"] ? @"view" : @"#";
152 - (BOOL)showLinkBanner {
155 - (NSString *)bannerToolbarStyle {
158 - (NSString *)bannerConsumeStyle {
165 [self->item release]; self->item = nil;
170 // TODO: I think all this should be done by the clientObject?!
171 // TODO: is the stuff below necessary at all in the mailer frame?
173 - (NSString *)rootURL {
175 NSArray *traversalObjects;
177 if (self->rootURL != nil)
178 return self->rootURL;
180 ctx = [self context];
181 traversalObjects = [ctx objectTraversalStack];
182 self->rootURL = [[[traversalObjects objectAtIndex:0]
183 rootURLInContext:ctx]
185 return self->rootURL;
188 - (NSString *)userRootURL {
190 NSArray *traversalObjects;
192 if (self->userRootURL)
193 return self->userRootURL;
195 ctx = [self context];
196 traversalObjects = [ctx objectTraversalStack];
197 self->userRootURL = [[[[traversalObjects objectAtIndex:1]
198 baseURLInContext:ctx]
199 stringByAppendingString:@"/"]
201 return self->userRootURL;
204 - (NSString *)calendarRootURL {
205 return [[self userRootURL] stringByAppendingString:@"Calendar/"];
207 - (NSString *)contactsRootURL {
208 return [[self userRootURL] stringByAppendingString:@"Contacts/"];
213 - (BOOL)hasErrorText {
214 return [[[[self context] request] formValueForKey:@"error"] length] > 0
217 - (NSString *)errorText {
218 return [[[self context] request] formValueForKey:@"error"];
221 - (NSString *)errorAlertJavaScript {
224 if ([(errorText = [self errorText]) length] == 0)
227 // TODO: proper JavaScript escaping
228 errorText = [errorText stringByEscapingHTMLString];
229 errorText = [errorText stringByReplacingString:@"\"" withString:@"'"];
231 return [NSString stringWithFormat:
232 @"<script language=\"JavaScript\">"
234 @"</script>", errorText];
239 - (NSString *)relativeHomePath {
240 return [self relativePathToUserFolderSubPath:@""];
243 - (NSString *)relativeCalendarPath {
244 return [self relativePathToUserFolderSubPath:@"Calendar/"];
247 - (NSString *)relativeContactsPath {
248 return [self relativePathToUserFolderSubPath:@"Contacts/"];
251 - (NSString *)relativeMailPath {
252 return [self relativePathToUserFolderSubPath:@"Mail/"];
255 @end /* UIxMailMainFrame */
257 @implementation UIxMailPanelFrame
259 - (BOOL)hideFolderTree {
262 - (BOOL)showLinkBanner {
266 @end /* UIxMailPanelFrame */