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 #include <NGObjWeb/WOHTMLDynamicElement.h>
23 #include "WOElement+private.h"
26 @implementation WOHTMLDynamicElement
28 static BOOL debugActionExecute = NO;
31 return [super version] + 0 /* v2 */;
37 NSAssert2([super version] == 2,
38 @"invalid superclass (%@) version %i !",
39 NSStringFromClass([self superclass]), [super version]);
41 ud = [NSUserDefaults standardUserDefaults];
42 debugActionExecute = [ud boolForKey:@"WODebugActions"];
47 - (id)executeAction:(WOAssociation *)_action inContext:(WOContext *)_ctx {
48 // TODO: I think this is deprectated?
53 if (debugActionExecute) {
54 [self logWithFormat:@"%@(%@): got no action to execute ..",
55 NSStringFromClass([self class]), _ctx];
60 if ((object = [_ctx component]) == nil) {
61 if (debugActionExecute) {
62 [self logWithFormat:@"%@(%@): got no object to execute action: %@",
63 NSStringFromClass([self class]), _ctx, _action];
68 if (![_action isValueConstant]) {
69 /* action specified like this: action = doIt; */
72 result = [_action valueInComponent:object];
73 if (debugActionExecute) {
74 [self logWithFormat:@"%@(%@): executed dynamic action, got: %@",
75 NSStringFromClass([self class]), _ctx, result];
78 if ([result respondsToSelector:@selector(ensureAwakeInContext:)]) {
79 if (debugActionExecute) {
80 [self logWithFormat:@"%@(%@): ensure result is awake in ctx",
81 NSStringFromClass([self class]), _ctx];
83 [result ensureAwakeInContext:_ctx];
88 /* action specified like this: action = "doIt"; */
91 debugWithFormat:@"WARNING: %@ used with 'string' action !", self];
93 act = NSSelectorFromString([_action stringValueInComponent:object]);
94 if ([object respondsToSelector:act])
95 return [object performSelector:act];
97 [[_ctx component] logWithFormat:
98 @"%@[0x%p]: %@ does not respond to action @%@",
99 NSStringFromClass([self class]), self,
101 NSStringFromSelector(act)];
105 @end /* WOHTMLDynamicElement */
107 NSDictionary *OWExtractQueryParameters(NSDictionary *_set) {
108 NSMutableDictionary *paras = nil;
109 NSMutableArray *paraKeys = nil;
113 /* locate query parameters */
114 keys = [_set keyEnumerator];
115 while ((key = [keys nextObject])) {
116 if ([key hasPrefix:@"?"]) {
117 WOAssociation *value;
119 if ([key isEqualToString:@"?wosid"])
122 value = [_set objectForKey:key];
124 if (paraKeys == nil) {
125 paraKeys = [NSMutableArray arrayWithCapacity:8];
126 paras = [NSMutableDictionary dictionaryWithCapacity:8];
129 [paraKeys addObject:key];
130 [paras setObject:value forKey:[key substringFromIndex:1]];
134 // remove query parameters
137 for (cnt = 0, count = [paraKeys count]; cnt < count; cnt++) {
138 [(NSMutableDictionary *)_set removeObjectForKey:
139 [paraKeys objectAtIndex:cnt]];