2 Copyright (C) 2000-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
21 // $Id: common.h 1 2004-08-20 10:08:27Z znek $
23 #ifndef __WEExtensions_common_H__
24 #define __WEExtensions_common_H__
26 #import <Foundation/Foundation.h>
27 #include <NGObjWeb/NGObjWeb.h>
28 #include <NGExtensions/NGExtensions.h>
30 #if NeXT_Foundation_LIBRARY || APPLE_Foundation_LIBRARY
31 # include <NGExtensions/NGObjectMacros.h>
34 @interface WOContext(WOExtensionsPrivate)
35 - (void)addActiveFormElement:(WOElement *)_element;
38 static inline id WOExtGetProperty(NSDictionary *_set, NSString *_name) {
39 id propValue = [_set objectForKey:_name];
42 propValue = [propValue retain];
43 [(NSMutableDictionary *)_set removeObjectForKey:_name];
48 static inline NSString *WEUriOfResource(NSString *_name, WOContext *_ctx) {
50 WOResourceManager *resourceManager;
56 languages = [_ctx hasSession]
57 ? [[_ctx session] languages]
58 : [[_ctx request] browserLanguages];
60 if ((resourceManager = [[_ctx component] resourceManager]) == nil)
61 resourceManager = [[_ctx application] resourceManager];
63 uri = [resourceManager urlForResourceNamed:_name
66 request:[_ctx request]];
67 if ([uri rangeOfString:@"/missingresource?"].length > 0)
73 static inline void WEAppendFont(WOResponse *_resp,
78 [_resp appendContentString:@"<font"];
80 [_resp appendContentString:@" color=\""];
81 [_resp appendContentHTMLAttributeValue:_color];
82 [_resp appendContentCharacter:'"'];
85 [_resp appendContentString:@" face=\""];
86 [_resp appendContentHTMLAttributeValue:_face];
87 [_resp appendContentCharacter:'"'];
90 [_resp appendContentString:@" size=\""];
91 [_resp appendContentHTMLAttributeValue:_size];
92 [_resp appendContentCharacter:'"'];
94 [_resp appendContentCharacter:'>'];
97 static inline void WEAppendTD(WOResponse *_resp,
102 [_resp appendContentString:@"<td"];
104 [_resp appendContentString:@" bgcolor=\""];
105 [_resp appendContentHTMLAttributeValue:_bgColor];
106 [_resp appendContentCharacter:'"'];
109 [_resp appendContentString:@" align=\""];
110 [_resp appendContentHTMLAttributeValue:_align];
111 [_resp appendContentCharacter:'"'];
114 [_resp appendContentString:@" valign=\""];
115 [_resp appendContentHTMLAttributeValue:_valign];
116 [_resp appendContentCharacter:'"'];
118 [_resp appendContentCharacter:'>'];
121 static inline WOElement *WECreateElement(NSString *_className,
123 NSDictionary *_config,
124 WOElement *_template)
127 WOElement *result = nil;
128 NSMutableDictionary *config = nil;
130 if ((c = NSClassFromString(_className)) == Nil) {
131 NSLog(@"%s: missing '%@' class", __PRETTY_FUNCTION__, _className);
134 config = [NSMutableDictionary dictionaryWithCapacity:4];
136 NSEnumerator *keyEnum;
139 keyEnum = [_config keyEnumerator];
141 while ((key = [keyEnum nextObject])) {
144 a = [WOAssociation associationWithValue:[_config objectForKey:key]];
145 [config setObject:a forKey:key];
148 result = [[c alloc] initWithName:_name
151 return [result autorelease];
154 #define OWGetProperty WOExtGetProperty
156 #endif /* __WEExtensions_common_H__ */