2 Copyright (C) 2000-2005 SKYRIX Software AG
4 This file is part of SOPE.
6 SOPE 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 SOPE 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 SOPE; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #ifndef __WEExtensions_common_H__
23 #define __WEExtensions_common_H__
25 #import <Foundation/Foundation.h>
27 #include <NGExtensions/NGExtensions.h>
28 #include <NGObjWeb/NGObjWeb.h>
31 #if NeXT_Foundation_LIBRARY || APPLE_Foundation_LIBRARY
32 # include <NGExtensions/NGObjectMacros.h>
35 @interface WOContext(WOExtensionsPrivate)
36 - (void)addActiveFormElement:(WOElement *)_element;
39 static inline id WOExtGetProperty(NSDictionary *_set, NSString *_name) {
40 id propValue = [_set objectForKey:_name];
43 propValue = [propValue retain];
44 [(NSMutableDictionary *)_set removeObjectForKey:_name];
49 static inline NSString *WEUriOfResource(NSString *_name, WOContext *_ctx) {
51 WOResourceManager *resourceManager;
57 languages = [_ctx resourceLookupLanguages];
59 if ((resourceManager = [[_ctx component] resourceManager]) == nil)
60 resourceManager = [[_ctx application] resourceManager];
62 uri = [resourceManager urlForResourceNamed:_name
65 request:[_ctx request]];
66 if ([uri rangeOfString:@"/missingresource?"].length > 0)
72 static inline void WEAppendFont(WOResponse *_resp,
77 [_resp appendContentString:@"<font"];
79 [_resp appendContentString:@" color=\""];
80 [_resp appendContentHTMLAttributeValue:_color];
81 [_resp appendContentCharacter:'"'];
84 [_resp appendContentString:@" face=\""];
85 [_resp appendContentHTMLAttributeValue:_face];
86 [_resp appendContentCharacter:'"'];
89 [_resp appendContentString:@" size=\""];
90 [_resp appendContentHTMLAttributeValue:_size];
91 [_resp appendContentCharacter:'"'];
93 [_resp appendContentCharacter:'>'];
96 static inline void WEAppendTD(WOResponse *_resp,
101 [_resp appendContentString:@"<td"];
103 [_resp appendContentString:@" bgcolor=\""];
104 [_resp appendContentHTMLAttributeValue:_bgColor];
105 [_resp appendContentCharacter:'"'];
108 [_resp appendContentString:@" align=\""];
109 [_resp appendContentHTMLAttributeValue:_align];
110 [_resp appendContentCharacter:'"'];
113 [_resp appendContentString:@" valign=\""];
114 [_resp appendContentHTMLAttributeValue:_valign];
115 [_resp appendContentCharacter:'"'];
117 [_resp appendContentCharacter:'>'];
120 static inline WOElement *WECreateElement(NSString *_className,
122 NSDictionary *_config,
123 WOElement *_template)
126 WOElement *result = nil;
127 NSMutableDictionary *config = nil;
129 if ((c = NSClassFromString(_className)) == Nil) {
130 NSLog(@"%s: missing '%@' class", __PRETTY_FUNCTION__, _className);
133 config = [NSMutableDictionary dictionaryWithCapacity:4];
135 NSEnumerator *keyEnum;
138 keyEnum = [_config keyEnumerator];
140 while ((key = [keyEnum nextObject])) {
143 a = [WOAssociation associationWithValue:[_config objectForKey:key]];
144 [config setObject:a forKey:key];
147 result = [[c alloc] initWithName:_name
150 return [result autorelease];
153 #define OWGetProperty WOExtGetProperty
155 #endif /* __WEExtensions_common_H__ */