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/WOResourceManager.h>
27 #import <NGObjWeb/WOSession.h>
28 #import <NGExtensions/NSObject+Logs.h>
30 @interface WOContext(WOExtensionsPrivate)
31 - (void)addActiveFormElement:(WOElement *)_element;
34 static inline id WOExtGetProperty(NSDictionary *_set, NSString *_name) {
35 id propValue = [_set objectForKey:_name];
38 propValue = [propValue retain];
39 [(NSMutableDictionary *)_set removeObjectForKey:_name];
44 static inline NSString *WEUriOfResource(NSString *_name, WOContext *_ctx) {
46 WOResourceManager *resourceManager;
52 languages = [_ctx hasSession]
53 ? [[_ctx session] languages]
54 : [[_ctx request] browserLanguages];
56 resourceManager = [[_ctx application] resourceManager];
58 uri = [resourceManager urlForResourceNamed:_name
61 request:[_ctx request]];
62 if ([uri rangeOfString:@"/missingresource?"].length > 0)
68 static inline void WEAppendFont(WOResponse *_resp,
73 [_resp appendContentString:@"<font"];
75 [_resp appendContentString:@" color=\""];
76 [_resp appendContentHTMLAttributeValue:_color];
77 [_resp appendContentCharacter:'"'];
80 [_resp appendContentString:@" face=\""];
81 [_resp appendContentHTMLAttributeValue:_face];
82 [_resp appendContentCharacter:'"'];
85 [_resp appendContentString:@" size=\""];
86 [_resp appendContentHTMLAttributeValue:_size];
87 [_resp appendContentCharacter:'"'];
89 [_resp appendContentCharacter:'>'];
92 static inline void WEAppendTD(WOResponse *_resp,
97 [_resp appendContentString:@"<td"];
99 [_resp appendContentString:@" bgcolor=\""];
100 [_resp appendContentHTMLAttributeValue:_bgColor];
101 [_resp appendContentCharacter:'"'];
104 [_resp appendContentString:@" align=\""];
105 [_resp appendContentHTMLAttributeValue:_align];
106 [_resp appendContentCharacter:'"'];
109 [_resp appendContentString:@" valign=\""];
110 [_resp appendContentHTMLAttributeValue:_valign];
111 [_resp appendContentCharacter:'"'];
113 [_resp appendContentCharacter:'>'];
116 static inline WOElement *WECreateElement(NSString *_className,
118 NSDictionary *_config,
119 WOElement *_template)
122 WOElement *result = nil;
123 NSMutableDictionary *config = nil;
125 if ((c = NSClassFromString(_className)) == Nil) {
126 NSLog(@"%s: missing '%@' class", __PRETTY_FUNCTION__, _className);
129 config = [NSMutableDictionary dictionaryWithCapacity:4];
131 NSEnumerator *keyEnum;
134 keyEnum = [_config keyEnumerator];
136 while ((key = [keyEnum nextObject])) {
139 a = [WOAssociation associationWithValue:[_config objectForKey:key]];
140 [config setObject:a forKey:key];
143 result = [[c alloc] initWithName:_name
146 return [result autorelease];
149 #define OWGetProperty WOExtGetProperty