]> err.no Git - scalable-opengroupware.org/blob - SOGo/UI/Common/UIxPageFrame.m
moved apt-editor validation to an own file
[scalable-opengroupware.org] / SOGo / 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 #include <SOGoUI/UIxComponent.h>
23
24 @interface UIxPageFrame : UIxComponent
25 {
26   NSString *title;
27   id       item;
28 }
29
30 @end
31
32 #include "common.h"
33 #include <NGObjWeb/SoComponent.h>
34
35 @implementation UIxPageFrame
36
37 - (void)dealloc {
38   [self->item  release];
39   [self->title release];
40   [super dealloc];
41 }
42
43 /* accessors */
44
45 - (void)setTitle:(NSString *)_value {
46   ASSIGNCOPY(self->title, _value);
47 }
48 - (NSString *)title {
49   if ([self isUIxDebugEnabled])
50     return self->title;
51
52   return [self labelForKey:@"OpenGroupware.org"];
53 }
54
55 - (void)setItem:(id)_item {
56   ASSIGN(self->item, _item);
57 }
58 - (id)item {
59   return self->item;
60 }
61
62 - (NSString *)ownerInContext {
63   return [[self clientObject] ownerInContext:[self context]];
64 }
65
66 /* Help URL/target */
67
68 - (NSString *)helpURL {
69   return [NSString stringWithFormat:@"help/%@.html", self->title];
70 }
71 - (NSString *)helpWindowTarget {
72   return [NSString stringWithFormat:@"Help_%@", self->title];
73 }
74
75
76 /* notifications */
77
78 - (void)sleep {
79   [self->item release]; self->item = nil;
80   [super sleep];
81 }
82
83 /* URL generation */
84 // TODO: I think all this should be done by the clientObject?!
85
86 - (NSString *)relativeHomePath {
87   return [self relativePathToUserFolderSubPath:@""];
88 }
89
90 - (NSString *)relativeCalendarPath {
91   return [self relativePathToUserFolderSubPath:@"Calendar/"];
92 }
93
94 - (NSString *)relativeContactsPath {
95   return [self relativePathToUserFolderSubPath:@"Contacts/"];
96 }
97
98 - (NSString *)relativeMailPath {
99   return [self relativePathToUserFolderSubPath:@"Mail/"];
100 }
101
102 /* page based JavaScript */
103
104 - (WOResourceManager *)pageResourceManager {
105   WOResourceManager *rm;
106   
107   if ((rm = [[[self context] page] resourceManager]) == nil)
108     rm = [[WOApplication application] resourceManager];
109   return rm;
110 }
111
112 - (NSString *)pageJavaScriptURL {
113   static NSMutableDictionary *pageToURL = nil;
114   WOResourceManager *rm;
115   WOComponent *page;
116   NSString    *jsname, *pageName;
117   NSString    *url;
118   
119   page     = [[self context] page];
120   pageName = NSStringFromClass([page class]);
121   // TODO: does not seem to work! (gets reset): pageName = [page name];
122   
123   if ((url = [pageToURL objectForKey:pageName]) != nil)
124     return [url isNotNull] ? url : nil;
125   
126   if (pageToURL == nil)
127     pageToURL = [[NSMutableDictionary alloc] initWithCapacity:32];
128   
129   rm     = [self pageResourceManager];
130   jsname = [pageName stringByAppendingString:@".js"];
131   
132   url = [rm urlForResourceNamed:jsname
133             inFramework:
134               [[NSBundle bundleForClass:[page class]] bundlePath]
135             languages:nil
136             request:[[self context] request]];
137   
138   /* cache */
139   [pageToURL setObject:(url ? url : (id)[NSNull null]) forKey:pageName];
140   return url;
141 }
142
143 - (BOOL)hasPageSpecificJavaScript {
144   return [[self pageJavaScriptURL] length] > 0 ? YES : NO;
145 }
146
147 @end /* UIxPageFrame */