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 language = [SOGoUser language];
186 = [[self resourceManager] stringTableWithName: @"Localizable"
187 inFramework: frameworkName
188 languages: [NSArray arrayWithObject: language]];
190 /* table is not really an NSDictionary but a hackish variation thereof */
191 return [[NSDictionary dictionaryWithDictionary: table] jsonRepresentation];
194 - (NSString *) commonLocalizableStrings
196 return [NSString stringWithFormat: @"var clabels = %@;",
197 [self _stringsForFramework: nil]];
200 - (NSString *) productLocalizableStrings
202 NSString *frameworkName;
204 frameworkName = [[context page] frameworkName];
206 return [NSString stringWithFormat: @"var labels = %@;",
207 [self _stringsForFramework: frameworkName]];
210 - (NSString *) pageJavaScriptURL
213 NSString *pageJSFilename;
215 page = [context page];
216 pageJSFilename = [NSString stringWithFormat: @"%@.js",
217 NSStringFromClass([page class])];
219 return [self urlForResourceFilename: pageJSFilename];
222 - (NSString *) productJavaScriptURL
225 NSString *fwJSFilename;
227 page = [context page];
228 fwJSFilename = [NSString stringWithFormat: @"%@.js",
229 [page frameworkName]];
231 return [self urlForResourceFilename: fwJSFilename];
234 - (BOOL) hasPageSpecificJavaScript
236 return ([[self pageJavaScriptURL] length] > 0);
239 - (BOOL) hasProductSpecificJavaScript
241 return ([[self productJavaScriptURL] length] > 0);
244 - (void) setCssFiles: (NSString *) newCSSFiles
246 NSEnumerator *cssFiles;
247 NSString *currentFile, *filename;
249 [additionalCSSFiles release];
250 additionalCSSFiles = [NSMutableArray new];
253 = [[newCSSFiles componentsSeparatedByString: @","] objectEnumerator];
254 while ((currentFile = [cssFiles nextObject]))
256 filename = [self urlForResourceFilename:
257 [currentFile stringByTrimmingSpaces]];
258 [additionalCSSFiles addObject: filename];
262 - (NSArray *) additionalCSSFiles
264 return additionalCSSFiles;
267 - (void) setJsFiles: (NSString *) newJSFiles
269 NSEnumerator *jsFiles;
270 NSString *currentFile, *filename;
272 [additionalJSFiles release];
273 additionalJSFiles = [NSMutableArray new];
275 jsFiles = [[newJSFiles componentsSeparatedByString: @","] objectEnumerator];
276 while ((currentFile = [jsFiles nextObject]))
278 filename = [self urlForResourceFilename:
279 [currentFile stringByTrimmingSpaces]];
280 [additionalJSFiles addObject: filename];
284 - (NSArray *) additionalJSFiles
286 return additionalJSFiles;
289 - (NSString *) pageCSSURL
292 NSString *pageJSFilename;
294 page = [context page];
295 pageJSFilename = [NSString stringWithFormat: @"%@.css",
296 NSStringFromClass([page class])];
298 return [self urlForResourceFilename: pageJSFilename];
301 - (NSString *) productCSSURL
304 NSString *fwJSFilename;
306 page = [context page];
307 fwJSFilename = [NSString stringWithFormat: @"%@.css",
308 [page frameworkName]];
310 return [self urlForResourceFilename: fwJSFilename];
313 - (NSString *) thisPageURL
315 return [[context page] uri];
318 - (BOOL) hasPageSpecificCSS
320 return ([[self pageCSSURL] length] > 0);
323 - (BOOL) hasProductSpecificCSS
325 return ([[self productCSSURL] length] > 0);
328 - (void) setToolbar: (NSString *) newToolbar
330 ASSIGN (toolbar, newToolbar);
333 - (NSString *) toolbar
342 user = [context activeUser];
344 return ([user respondsToSelector: @selector (isSuperUser)]
345 && [user isSuperUser]);
348 /* browser/os identification */
350 - (BOOL) isCompatibleBrowser
352 WEClientCapabilities *cc;
354 cc = [[context request] clientCapabilities];
356 //NSLog(@"Browser = %@", [cc description]);
357 NSLog(@"User agent = %@", [cc userAgent]);
358 //NSLog(@"Browser major version = %i", [cc majorVersion]);
360 return (([[cc userAgentType] isEqualToString: @"IE"]
361 && [cc majorVersion] >= 7)
362 || ([[cc userAgentType] isEqualToString: @"Mozilla"]
363 && [cc majorVersion] >= 5)
364 || ([[cc userAgentType] isEqualToString: @"Safari"]
365 && [cc majorVersion] >= 4)
366 // ([[cc userAgentType] isEqualToString: @"Konqueror"])
370 - (BOOL) isIE7Compatible
372 WEClientCapabilities *cc;
374 cc = [[context request] clientCapabilities];
376 return ([cc isWindowsBrowser] &&
377 ([[cc userAgent] rangeOfString: @"NT 5.1"].location != NSNotFound ||
378 [[cc userAgent] rangeOfString: @"NT 6"].location != NSNotFound));
383 WEClientCapabilities *cc;
385 cc = [[context request] clientCapabilities];
387 return [cc isMacBrowser];
390 @end /* UIxPageFrame */