2 Copyright (C) 2004 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
22 #import <NGObjWeb/WOAssociation.h>
23 #import <NGObjWeb/WOContext+SoObjects.h>
24 #import <NGObjWeb/WODynamicElement.h>
25 #import <NGObjWeb/WORequest.h>
26 #import <NGObjWeb/WOResponse.h>
27 #import <NGObjWeb/WOResourceManager.h>
28 #import <NGObjWeb/WOSession.h>
29 #import <NGExtensions/NSObject+Logs.h>
31 @interface WOContext(WOExtensionsPrivate)
32 - (void)addActiveFormElement:(WOElement *)_element;
35 static inline id WOExtGetProperty(NSDictionary *_set, NSString *_name) {
36 id propValue = [_set objectForKey:_name];
39 propValue = [propValue retain];
40 [(NSMutableDictionary *)_set removeObjectForKey:_name];
45 static inline NSString *WEUriOfResource(NSString *_name, WOContext *_ctx) {
47 WOResourceManager *resourceManager;
53 languages = [_ctx hasSession]
54 ? [[_ctx session] languages]
55 : [[_ctx request] browserLanguages];
57 resourceManager = [[_ctx application] resourceManager];
59 uri = [resourceManager urlForResourceNamed:_name
62 request:[_ctx request]];
63 if ([uri rangeOfString:@"/missingresource?"].length > 0)
69 static inline void WEAppendFont(WOResponse *_resp,
74 [_resp appendContentString:@"<font"];
76 [_resp appendContentString:@" color=\""];
77 [_resp appendContentHTMLAttributeValue:_color];
78 [_resp appendContentCharacter:'"'];
81 [_resp appendContentString:@" face=\""];
82 [_resp appendContentHTMLAttributeValue:_face];
83 [_resp appendContentCharacter:'"'];
86 [_resp appendContentString:@" size=\""];
87 [_resp appendContentHTMLAttributeValue:_size];
88 [_resp appendContentCharacter:'"'];
90 [_resp appendContentCharacter:'>'];
93 static inline void WEAppendTD(WOResponse *_resp,
98 [_resp appendContentString:@"<td"];
100 [_resp appendContentString:@" bgcolor=\""];
101 [_resp appendContentHTMLAttributeValue:_bgColor];
102 [_resp appendContentCharacter:'"'];
105 [_resp appendContentString:@" align=\""];
106 [_resp appendContentHTMLAttributeValue:_align];
107 [_resp appendContentCharacter:'"'];
110 [_resp appendContentString:@" valign=\""];
111 [_resp appendContentHTMLAttributeValue:_valign];
112 [_resp appendContentCharacter:'"'];
114 [_resp appendContentCharacter:'>'];
117 static inline WOElement *WECreateElement(NSString *_className,
119 NSDictionary *_config,
120 WOElement *_template)
123 WOElement *result = nil;
124 NSMutableDictionary *config = nil;
126 if ((c = NSClassFromString(_className)) == Nil) {
127 NSLog(@"%s: missing '%@' class", __PRETTY_FUNCTION__, _className);
130 config = [NSMutableDictionary dictionaryWithCapacity:4];
132 NSEnumerator *keyEnum;
135 keyEnum = [_config keyEnumerator];
137 while ((key = [keyEnum nextObject])) {
140 a = [WOAssociation associationWithValue:[_config objectForKey:key]];
141 [config setObject:a forKey:key];
144 result = [[c alloc] initWithName:_name
147 return [result autorelease];
150 #define OWGetProperty WOExtGetProperty