]> err.no Git - scalable-opengroupware.org/blob - UI/Common/UIxPageFrame.m
git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1170 d1b88da0-ebda-0310...
[scalable-opengroupware.org] / UI / Common / UIxPageFrame.m
1 /*
2   Copyright (C) 2004-2005 SKYRIX Software AG
3
4   This file is part of OpenGroupware.org.
5
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
9   later version.
10
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.
15
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
19   02111-1307, USA.
20 */
21
22 #import "common.h"
23 #import <NGObjWeb/SoComponent.h>
24 #import <NGObjWeb/WOComponent.h>
25
26 #import <SOGoUI/UIxComponent.h>
27 #import <SOGo/SOGoUser.h>
28
29 #import <Main/build.h>
30
31 #import "UIxPageFrame.h"
32
33 @implementation UIxPageFrame
34
35 - (id) init
36 {
37   if ((self = [super init]))
38     {
39       toolbar = nil;
40     }
41
42   return self;
43 }
44
45 - (void) dealloc
46 {
47   [item release];
48   [title release];
49   if (toolbar)
50     [toolbar release];
51   [super dealloc];
52 }
53
54 /* accessors */
55
56 - (void) setTitle: (NSString *) _value
57 {
58   ASSIGNCOPY(title, _value);
59 }
60
61 - (NSString *) title
62 {
63   if ([self isUIxDebugEnabled])
64     return title;
65
66   return [self labelForKey: @"SOGo"];
67 }
68
69 - (void) setItem: (id) _item
70 {
71   ASSIGN(item, _item);
72 }
73
74 - (id) item
75 {
76   return item;
77 }
78
79 - (NSString *) buildDate
80 {
81   return SOGoBuildDate;
82 }
83
84 - (NSString *) ownerInContext
85 {
86   return [[self clientObject] ownerInContext: nil];
87 }
88
89 - (NSString *) doctype
90 {
91   return (@"<?xml version=\"1.0\"?>\n"
92           @"<!DOCTYPE html"
93           @" PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\""
94           @" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">");
95 }
96
97 /* Help URL/target */
98
99 - (NSString *) helpURL
100 {
101   return [NSString stringWithFormat: @"help/%@.html", title];
102 }
103
104 - (NSString *) helpWindowTarget
105 {
106   return [NSString stringWithFormat: @"Help_%@", title];
107 }
108
109 /* notifications */
110
111 - (void) sleep
112 {
113   [item release];
114   item = nil;
115   [super sleep];
116 }
117
118 /* URL generation */
119 // TODO: I think all this should be done by the clientObject?!
120
121 - (NSString *) relativeHomePath
122 {
123   return [self relativePathToUserFolderSubPath: @""];
124 }
125
126 - (NSString *) relativeCalendarPath
127 {
128   return [self relativePathToUserFolderSubPath: @"Calendar/"];
129 }
130
131 - (NSString *) relativeContactsPath
132 {
133   return [self relativePathToUserFolderSubPath: @"Contacts/"];
134 }
135
136 - (NSString *) relativeMailPath
137 {
138   return [self relativePathToUserFolderSubPath: @"Mail/"];
139 }
140
141 - (NSString *) relativePreferencesPath
142 {
143   return [self relativePathToUserFolderSubPath: @"preferences"];
144 }
145
146 - (NSString *) logoffPath
147 {
148   return [self relativePathToUserFolderSubPath: @"logoff"];
149 }
150
151 /* popup handling */
152 - (void) setPopup: (BOOL) popup
153 {
154   isPopup = popup;
155 }
156
157 - (BOOL) isPopup
158 {
159   return isPopup;
160 }
161
162 - (NSString *) bodyClasses
163 {
164   return (isPopup ? @"popup" : @"main");
165 }
166
167 /* page based JavaScript */
168
169 - (NSString *) pageJavaScriptURL
170 {
171   WOComponent *page;
172   NSString *pageJSFilename;
173   
174   page     = [context page];
175   pageJSFilename = [NSString stringWithFormat: @"%@.js",
176                              NSStringFromClass([page class])];
177
178   return [self urlForResourceFilename: pageJSFilename];
179 }
180
181 - (NSString *) productJavaScriptURL
182 {
183   WOComponent *page;
184   NSString *fwJSFilename;
185
186   page = [context page];
187   fwJSFilename = [NSString stringWithFormat: @"%@.js",
188                            [page frameworkName]];
189   
190   return [self urlForResourceFilename: fwJSFilename];
191 }
192
193 - (NSString *) productFrameworkName
194 {
195   WOComponent *page;
196
197   page = [context page];
198
199   return [NSString stringWithFormat: @"%@.SOGo", [page frameworkName]];
200 }
201
202 - (BOOL) hasPageSpecificJavaScript
203 {
204   return ([[self pageJavaScriptURL] length] > 0);
205 }
206
207 - (BOOL) hasProductSpecificJavaScript
208 {
209   return ([[self productJavaScriptURL] length] > 0);
210 }
211
212 - (NSString *) pageCSSURL
213 {
214   WOComponent *page;
215   NSString *pageJSFilename;
216
217   page = [context page];
218   pageJSFilename = [NSString stringWithFormat: @"%@.css",
219                              NSStringFromClass([page class])];
220
221   return [self urlForResourceFilename: pageJSFilename];
222 }
223
224 - (NSString *) productCSSURL
225 {
226   WOComponent *page;
227   NSString *fwJSFilename;
228
229   page = [context page];
230   fwJSFilename = [NSString stringWithFormat: @"%@.css",
231                            [page frameworkName]];
232   
233   return [self urlForResourceFilename: fwJSFilename];
234 }
235
236 - (NSString *) thisPageURL
237 {
238   return [[context page] uri];
239 }
240
241 - (BOOL) hasPageSpecificCSS
242 {
243   return ([[self pageCSSURL] length] > 0);
244 }
245
246 - (BOOL) hasProductSpecificCSS
247 {
248   return ([[self productCSSURL] length] > 0);
249 }
250
251 - (void) setToolbar: (NSString *) newToolbar
252 {
253   ASSIGN (toolbar, newToolbar);
254 }
255
256 - (NSString *) toolbar
257 {
258   return toolbar;
259 }
260
261 @end /* UIxPageFrame */