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 {
153 if ([self hideFolderTree]) return NO;
156 - (NSString *)bannerToolbarStyle {
158 return [self showLinkBanner] ? @"top: 58px;" : nil /* fallback to CSS */;
160 return [self showLinkBanner] ? @"top: 58px;" : nil /* fallback to CSS */;
163 - (NSString *)bannerConsumeStyle {
165 return [self showLinkBanner] ? @"height: 116px;" : nil /* fallback to CSS */;
167 return [self showLinkBanner] ? @"height: 110px;" : nil /* fallback to CSS */;
174 [self->item release]; self->item = nil;
179 // TODO: I think all this should be done by the clientObject?!
180 // TODO: is the stuff below necessary at all in the mailer frame?
182 - (NSString *)rootURL {
184 NSArray *traversalObjects;
186 if (self->rootURL != nil)
187 return self->rootURL;
189 ctx = [self context];
190 traversalObjects = [ctx objectTraversalStack];
191 self->rootURL = [[[traversalObjects objectAtIndex:0]
192 rootURLInContext:ctx]
194 return self->rootURL;
197 - (NSString *)userRootURL {
199 NSArray *traversalObjects;
201 if (self->userRootURL)
202 return self->userRootURL;
204 ctx = [self context];
205 traversalObjects = [ctx objectTraversalStack];
206 self->userRootURL = [[[[traversalObjects objectAtIndex:1]
207 baseURLInContext:ctx]
208 stringByAppendingString:@"/"]
210 return self->userRootURL;
213 - (NSString *)calendarRootURL {
214 return [[self userRootURL] stringByAppendingString:@"Calendar/"];
216 - (NSString *)contactsRootURL {
217 return [[self userRootURL] stringByAppendingString:@"Contacts/"];
222 - (BOOL)hasErrorText {
223 return [[[[self context] request] formValueForKey:@"error"] length] > 0
226 - (NSString *)errorText {
227 return [[[self context] request] formValueForKey:@"error"];
230 - (NSString *)errorAlertJavaScript {
233 if ([(errorText = [self errorText]) length] == 0)
236 // TODO: proper JavaScript escaping
237 errorText = [errorText stringByEscapingHTMLString];
238 errorText = [errorText stringByReplacingString:@"\"" withString:@"'"];
240 return [NSString stringWithFormat:
241 @"<script language=\"JavaScript\">"
243 @"</script>", errorText];
248 - (NSString *)relativeHomePath {
249 return [self relativePathToUserFolderSubPath:@""];
252 - (NSString *)relativeCalendarPath {
253 return [self relativePathToUserFolderSubPath:@"Calendar/"];
256 - (NSString *)relativeContactsPath {
257 return [self relativePathToUserFolderSubPath:@"Contacts/"];
260 - (NSString *)relativeMailPath {
261 return [self relativePathToUserFolderSubPath:@"Mail/"];
264 @end /* UIxMailMainFrame */
266 @implementation UIxMailPanelFrame
268 - (BOOL)hideFolderTree {
271 - (BOOL)showLinkBanner {
275 @end /* UIxMailPanelFrame */