]> err.no Git - scalable-opengroupware.org/blob - UI/Common/UIxPageFrame.m
git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1036 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 *) logoffPath
135 {
136   return [self relativePathToUserFolderSubPath: @"logoff"];
137 }
138
139 /* popup handling */
140 - (void) setPopup: (BOOL) popup
141 {
142   isPopup = popup;
143 }
144
145 - (BOOL) isPopup
146 {
147   return isPopup;
148 }
149
150 - (NSString *) bodyClasses
151 {
152   return (isPopup ? @"popup" : @"main");
153 }
154
155 /* page based JavaScript */
156
157 - (NSString *) pageJavaScriptURL
158 {
159   WOComponent *page;
160   NSString *pageJSFilename;
161   
162   page     = [[self context] page];
163   pageJSFilename = [NSString stringWithFormat: @"%@.js",
164                              NSStringFromClass([page class])];
165
166   return [self urlForResourceFilename: pageJSFilename];
167 }
168
169 - (NSString *) productJavaScriptURL
170 {
171   WOComponent *page;
172   NSString *fwJSFilename;
173
174   page = [[self context] page];
175   fwJSFilename = [NSString stringWithFormat: @"%@.js",
176                            [page frameworkName]];
177   
178   return [self urlForResourceFilename: fwJSFilename];
179 }
180
181 - (NSString *) productFrameworkName
182 {
183   WOComponent *page;
184
185   page = [[self context] page];
186
187   return [NSString stringWithFormat: @"%@.SOGo", [page frameworkName]];
188 }
189
190 - (BOOL) hasPageSpecificJavaScript
191 {
192   return ([[self pageJavaScriptURL] length] > 0);
193 }
194
195 - (BOOL) hasProductSpecificJavaScript
196 {
197   return ([[self productJavaScriptURL] length] > 0);
198 }
199
200 - (NSString *) pageCSSURL
201 {
202   WOComponent *page;
203   NSString *pageJSFilename;
204
205   page = [[self context] page];
206   pageJSFilename = [NSString stringWithFormat: @"%@.css",
207                              NSStringFromClass([page class])];
208
209   return [self urlForResourceFilename: pageJSFilename];
210 }
211
212 - (NSString *) productCSSURL
213 {
214   WOComponent *page;
215   NSString *fwJSFilename;
216
217   page = [[self context] page];
218   fwJSFilename = [NSString stringWithFormat: @"%@.css",
219                            [page frameworkName]];
220   
221   return [self urlForResourceFilename: fwJSFilename];
222 }
223
224 - (NSString *) thisPageURL
225 {
226   return [[[self context] page] uri];
227 }
228
229 - (BOOL) hasPageSpecificCSS
230 {
231   return ([[self pageCSSURL] length] > 0);
232 }
233
234 - (BOOL) hasProductSpecificCSS
235 {
236   return ([[self productCSSURL] length] > 0);
237 }
238
239 - (void) setToolbar: (NSString *) newToolbar
240 {
241   ASSIGN (toolbar, newToolbar);
242 }
243
244 - (NSString *) toolbar
245 {
246   return toolbar;
247 }
248
249 @end /* UIxPageFrame */