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
23 #import <NGObjWeb/SoComponent.h>
24 #import <NGObjWeb/WOComponent.h>
26 #import <SoObjects/SOGo/SOGoUser.h>
27 #import <SoObjects/SOGo/NSDictionary+Utilities.h>
29 #import <SOGoUI/UIxComponent.h>
31 #import <Main/build.h>
33 #import "UIxPageFrame.h"
35 @implementation UIxPageFrame
39 if ((self = [super init]))
44 additionalJSFiles = nil;
55 [additionalJSFiles release];
61 - (void) setTitle: (NSString *) _value
63 ASSIGN (title, _value);
68 if ([self isUIxDebugEnabled])
71 return [self labelForKey: @"SOGo"];
74 - (void) setItem: (id) _item
84 - (NSString *) buildDate
89 - (NSString *) ownerInContext
91 return [[self clientObject] ownerInContext: nil];
94 - (NSString *) doctype
96 return (@"<?xml version=\"1.0\"?>\n"
98 @" PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\""
99 @" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">");
102 /* Help URL/target */
104 - (NSString *) helpURL
106 return [NSString stringWithFormat: @"help/%@.html", title];
109 - (NSString *) helpWindowTarget
111 return [NSString stringWithFormat: @"Help_%@", title];
124 // TODO: I think all this should be done by the clientObject?!
126 - (NSString *) relativeHomePath
128 return [self relativePathToUserFolderSubPath: @""];
131 - (NSString *) relativeCalendarPath
133 return [self relativePathToUserFolderSubPath: @"Calendar/"];
136 - (NSString *) relativeContactsPath
138 return [self relativePathToUserFolderSubPath: @"Contacts/"];
141 - (NSString *) relativeMailPath
143 return [self relativePathToUserFolderSubPath: @"Mail/"];
146 - (NSString *) relativePreferencesPath
148 return [self relativePathToUserFolderSubPath: @"preferences"];
151 - (NSString *) logoffPath
153 return [self relativePathToUserFolderSubPath: @"logoff"];
157 - (void) setPopup: (BOOL) popup
167 - (NSString *) bodyClasses
169 return (isPopup ? @"popup" : @"main");
172 /* page based JavaScript */
174 - (NSString *) _stringsForFramework: (NSString *) framework
176 NSString *language, *frameworkName;
179 frameworkName = [NSString stringWithFormat: @"%@.SOGo",
180 (framework ? framework : [self frameworkName])];
181 language = [[context activeUser] language];
183 = [[self resourceManager] stringTableWithName: @"Localizable"
184 inFramework: frameworkName
185 languages: [NSArray arrayWithObject: language]];
187 /* table is not really an NSDictionary but a hackish variation thereof */
188 return [[NSDictionary dictionaryWithDictionary: table] jsonRepresentation];
191 - (NSString *) commonLocalizableStrings
193 return [NSString stringWithFormat: @"var clabels = %@;",
194 [self _stringsForFramework: nil]];
197 - (NSString *) productLocalizableStrings
199 NSString *frameworkName;
201 frameworkName = [[context page] frameworkName];
203 return [NSString stringWithFormat: @"var labels = %@;",
204 [self _stringsForFramework: frameworkName]];
207 - (NSString *) pageJavaScriptURL
210 NSString *pageJSFilename;
212 page = [context page];
213 pageJSFilename = [NSString stringWithFormat: @"%@.js",
214 NSStringFromClass([page class])];
216 return [self urlForResourceFilename: pageJSFilename];
219 - (NSString *) productJavaScriptURL
222 NSString *fwJSFilename;
224 page = [context page];
225 fwJSFilename = [NSString stringWithFormat: @"%@.js",
226 [page frameworkName]];
228 return [self urlForResourceFilename: fwJSFilename];
231 - (BOOL) hasPageSpecificJavaScript
233 return ([[self pageJavaScriptURL] length] > 0);
236 - (BOOL) hasProductSpecificJavaScript
238 return ([[self productJavaScriptURL] length] > 0);
241 - (void) setJsFiles: (NSString *) newJSFiles
243 NSEnumerator *jsFiles;
244 NSString *currentFile, *filename;
246 [additionalJSFiles release];
247 additionalJSFiles = [NSMutableArray new];
249 jsFiles = [[newJSFiles componentsSeparatedByString: @","] objectEnumerator];
250 while ((currentFile = [jsFiles nextObject]))
252 filename = [self urlForResourceFilename:
253 [currentFile stringByTrimmingSpaces]];
254 [additionalJSFiles addObject: filename];
258 - (NSArray *) additionalJSFiles
260 return additionalJSFiles;
263 - (NSString *) pageCSSURL
266 NSString *pageJSFilename;
268 page = [context page];
269 pageJSFilename = [NSString stringWithFormat: @"%@.css",
270 NSStringFromClass([page class])];
272 return [self urlForResourceFilename: pageJSFilename];
275 - (NSString *) productCSSURL
278 NSString *fwJSFilename;
280 page = [context page];
281 fwJSFilename = [NSString stringWithFormat: @"%@.css",
282 [page frameworkName]];
284 return [self urlForResourceFilename: fwJSFilename];
287 - (NSString *) thisPageURL
289 return [[context page] uri];
292 - (BOOL) hasPageSpecificCSS
294 return ([[self pageCSSURL] length] > 0);
297 - (BOOL) hasProductSpecificCSS
299 return ([[self productCSSURL] length] > 0);
302 - (void) setToolbar: (NSString *) newToolbar
304 ASSIGN (toolbar, newToolbar);
307 - (NSString *) toolbar
312 /* browser/os identification */
314 - (BOOL) isCompatibleBrowser
316 WEClientCapabilities *cc;
318 cc = [[context request] clientCapabilities];
320 //NSLog(@"Browser = %@", [cc description]);
321 NSLog(@"User agent = %@", [cc userAgent]);
322 //NSLog(@"Browser major version = %i", [cc majorVersion]);
324 return (([[cc userAgentType] isEqualToString: @"IE"]
325 && [cc majorVersion] >= 7)
326 || ([[cc userAgentType] isEqualToString: @"Mozilla"]
327 && [cc majorVersion] >= 5)
328 || ([[cc userAgentType] isEqualToString: @"Safari"]
329 && [cc majorVersion] >= 4)
330 // ([[cc userAgentType] isEqualToString: @"Konqueror"])
334 - (BOOL) isIE7Compatible
336 WEClientCapabilities *cc;
338 cc = [[context request] clientCapabilities];
340 return ([cc isWindowsBrowser] &&
341 ([[cc userAgent] rangeOfString: @"NT 5.1"].location != NSNotFound ||
342 [[cc userAgent] rangeOfString: @"NT 6"].location != NSNotFound));
347 WEClientCapabilities *cc;
349 cc = [[context request] clientCapabilities];
351 return [cc isMacBrowser];
354 @end /* UIxPageFrame */