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