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) setJsFiles: (NSString *) newJSFiles
246 NSEnumerator *jsFiles;
247 NSString *currentFile, *filename;
249 [additionalJSFiles release];
250 additionalJSFiles = [NSMutableArray new];
252 jsFiles = [[newJSFiles componentsSeparatedByString: @","] objectEnumerator];
253 while ((currentFile = [jsFiles nextObject]))
255 filename = [self urlForResourceFilename:
256 [currentFile stringByTrimmingSpaces]];
257 [additionalJSFiles addObject: filename];
261 - (NSArray *) additionalJSFiles
263 return additionalJSFiles;
266 - (NSString *) pageCSSURL
269 NSString *pageJSFilename;
271 page = [context page];
272 pageJSFilename = [NSString stringWithFormat: @"%@.css",
273 NSStringFromClass([page class])];
275 return [self urlForResourceFilename: pageJSFilename];
278 - (NSString *) productCSSURL
281 NSString *fwJSFilename;
283 page = [context page];
284 fwJSFilename = [NSString stringWithFormat: @"%@.css",
285 [page frameworkName]];
287 return [self urlForResourceFilename: fwJSFilename];
290 - (NSString *) thisPageURL
292 return [[context page] uri];
295 - (BOOL) hasPageSpecificCSS
297 return ([[self pageCSSURL] length] > 0);
300 - (BOOL) hasProductSpecificCSS
302 return ([[self productCSSURL] length] > 0);
305 - (void) setToolbar: (NSString *) newToolbar
307 ASSIGN (toolbar, newToolbar);
310 - (NSString *) toolbar
315 /* browser/os identification */
317 - (BOOL) isCompatibleBrowser
319 WEClientCapabilities *cc;
321 cc = [[context request] clientCapabilities];
323 //NSLog(@"Browser = %@", [cc description]);
324 NSLog(@"User agent = %@", [cc userAgent]);
325 //NSLog(@"Browser major version = %i", [cc majorVersion]);
327 return (([[cc userAgentType] isEqualToString: @"IE"]
328 && [cc majorVersion] >= 7)
329 || ([[cc userAgentType] isEqualToString: @"Mozilla"]
330 && [cc majorVersion] >= 5)
331 || ([[cc userAgentType] isEqualToString: @"Safari"]
332 && [cc majorVersion] >= 4)
333 // ([[cc userAgentType] isEqualToString: @"Konqueror"])
337 - (BOOL) isIE7Compatible
339 WEClientCapabilities *cc;
341 cc = [[context request] clientCapabilities];
343 return ([cc isWindowsBrowser] &&
344 ([[cc userAgent] rangeOfString: @"NT 5.1"].location != NSNotFound ||
345 [[cc userAgent] rangeOfString: @"NT 6"].location != NSNotFound));
350 WEClientCapabilities *cc;
352 cc = [[context request] clientCapabilities];
354 return [cc isMacBrowser];
357 @end /* UIxPageFrame */