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
21 // $Id: common.h,v 1.1 2003/11/24 01:24:40 helge Exp $
23 #import <Foundation/Foundation.h>
25 #warning importing common.h is baaad
27 #if LIB_FOUNDATION_LIBRARY
28 # include <Foundation/exceptions/GeneralExceptions.h>
29 #elif NeXT_Foundation_LIBRARY || COCOA_Foundation_LIBRARY
30 # include <NGExtensions/NGObjectMacros.h>
31 # include <NGExtensions/NSString+Ext.h>
34 #include <NGExtensions/NGExtensions.h>
35 #include <NGObjWeb/NGObjWeb.h>
36 #include <NGObjWeb/SoObjects.h>
38 @interface WOContext(WOExtensionsPrivate)
39 - (void)addActiveFormElement:(WOElement *)_element;
42 static inline id WOExtGetProperty(NSDictionary *_set, NSString *_name) {
43 id propValue = [_set objectForKey:_name];
46 propValue = [propValue retain];
47 [(NSMutableDictionary *)_set removeObjectForKey:_name];
52 static inline NSString *WEUriOfResource(NSString *_name, WOContext *_ctx) {
54 WOResourceManager *resourceManager;
60 languages = [_ctx hasSession]
61 ? [[_ctx session] languages]
62 : [[_ctx request] browserLanguages];
64 resourceManager = [[_ctx application] resourceManager];
66 uri = [resourceManager urlForResourceNamed:_name
69 request:[_ctx request]];
70 if ([uri rangeOfString:@"/missingresource?"].length > 0)
76 static inline void WEAppendFont(WOResponse *_resp,
81 [_resp appendContentString:@"<font"];
83 [_resp appendContentString:@" color=\""];
84 [_resp appendContentHTMLAttributeValue:_color];
85 [_resp appendContentCharacter:'"'];
88 [_resp appendContentString:@" face=\""];
89 [_resp appendContentHTMLAttributeValue:_face];
90 [_resp appendContentCharacter:'"'];
93 [_resp appendContentString:@" size=\""];
94 [_resp appendContentHTMLAttributeValue:_size];
95 [_resp appendContentCharacter:'"'];
97 [_resp appendContentCharacter:'>'];
100 static inline void WEAppendTD(WOResponse *_resp,
105 [_resp appendContentString:@"<td"];
107 [_resp appendContentString:@" bgcolor=\""];
108 [_resp appendContentHTMLAttributeValue:_bgColor];
109 [_resp appendContentCharacter:'"'];
112 [_resp appendContentString:@" align=\""];
113 [_resp appendContentHTMLAttributeValue:_align];
114 [_resp appendContentCharacter:'"'];
117 [_resp appendContentString:@" valign=\""];
118 [_resp appendContentHTMLAttributeValue:_valign];
119 [_resp appendContentCharacter:'"'];
121 [_resp appendContentCharacter:'>'];
124 static inline WOElement *WECreateElement(NSString *_className,
126 NSDictionary *_config,
127 WOElement *_template)
130 WOElement *result = nil;
131 NSMutableDictionary *config = nil;
133 if ((c = NSClassFromString(_className)) == Nil) {
134 NSLog(@"%s: missing '%@' class", __PRETTY_FUNCTION__, _className);
137 config = [NSMutableDictionary dictionaryWithCapacity:4];
139 NSEnumerator *keyEnum;
142 keyEnum = [_config keyEnumerator];
144 while ((key = [keyEnum nextObject])) {
147 a = [WOAssociation associationWithValue:[_config objectForKey:key]];
148 [config setObject:a forKey:key];
151 result = [[c alloc] initWithName:_name
154 return [result autorelease];
157 #define OWGetProperty WOExtGetProperty