if ([self->disabled boolValueInComponent:[_ctx component]])
return;
-
+
currentId = OWFormElementName(self, _ctx);
-
+
if ((formValue = [_rq formValueForKey:currentId]) == nil)
return;
contentType = [[_rq httpRequest] contentType];
if (![contentType hasSameType:multipartFormData]) {
- NSLog(@"WARNING: tried to apply file-upload value of %@ from "
- @"a non multipart-form request (value=%@) !",
- [_ctx elementID], formValue);
+ [self warnWithFormat:
+ @"Tried to apply file-upload value of eid=%@ from "
+ @"a non multipart-form request (value=%@).",
+ [_ctx elementID], formValue];
return;
}
#if 0
NSLog(@"%@: value=%@ ..", [self elementID], formValue);
#endif
-
+
if ([self->data isValueSettable])
[self->data setValue:formValue inComponent:[_ctx component]];
-
+
+ /* the remainder is for locating the file path */
+
if (![self->filePath isValueSettable])
return;
[[DispClass alloc] initWithString:[disposition stringValue]];
disposition = [disposition autorelease];
}
-
+
formName = [(NGMimeContentDispositionHeaderField *)disposition name];
if ([formName isEqualToString:currentId]) {
- (void)takeValuesFromRequest:(WORequest *)_rq inContext:(WOContext *)_ctx {
/* links can take form values !!!! (for query-parameters) */
- if (self->queryParameters) {
+ if (self->queryParameters != nil) {
/* apply values to ?style parameters */
WOComponent *sComponent = [_ctx component];
NSEnumerator *keys;
NSString *key;
-
+
keys = [self->queryParameters keyEnumerator];
- while ((key = [keys nextObject])) {
+ while ((key = [keys nextObject]) != nil) {
id assoc, value;
-
+
assoc = [self->queryParameters objectForKey:key];
if ([assoc isValueSettable]) {
NSStringFromClass([self class]), self];
}
-@end /* WOElement */
-
-@implementation WOElement(QueryString)
+/* QueryString */
- (NSString *)queryStringForQueryDictionary:(NSDictionary *)_queryDict
andQueryParameters:(NSDictionary *)_paras
isFirst = YES;
paraKeys = [_paras allKeys];
-
+
/* ?style parameters */
keys = [_paras keyEnumerator];
- while ((key = [keys nextObject])) {
+ while ((key = [keys nextObject]) != nil) {
value = [[_paras objectForKey:key] stringValueInComponent:sComponent];
value = value ? [value stringByEscapingURL] : @"";
key = key ? [key stringByEscapingURL] : @"";
}
keys = [_queryDict keyEnumerator];
- while ((key = [keys nextObject])) {
- if(![paraKeys containsObject:key]) {
- value = [[_queryDict objectForKey:key] stringValue];
+ while ((key = [keys nextObject]) != nil) {
+ if([paraKeys containsObject:key])
+ /* overridden by a query parameter (?abc=abc) */
+ continue;
+
+ value = [_queryDict objectForKey:key];
+ if ([value isKindOfClass:[NSArray class]]) {
+ /* if we bind the queryDictionary to request.formValues */
+ NSArray *values;
+ unsigned i, count;
+
+ values = (NSArray *)value;
+ for (i = 0, count = [values count]; i < count; i++) {
+ value = [values objectAtIndex:i];
+ value = [value stringValue];
+ value = value ? [value stringByEscapingURL] : @"";
+ key = key ? [key stringByEscapingURL] : @"";
+
+ if (isFirst) isFirst = NO;
+ else [str appendString:@"&"];
+
+ [str appendString:key];
+ [str appendString:@"="];
+ [str appendString:value];
+ }
+ }
+ else {
+ value = [value stringValue];
value = value ? [value stringByEscapingURL] : @"";
key = key ? [key stringByEscapingURL] : @"";
if (isFirst) isFirst = NO;
else [str appendString:@"&"];
-
+
[str appendString:key];
[str appendString:@"="];
[str appendString:value];
return [str length] > 0 ? str : nil;
}
-@end /* WOElement(QueryString) */
+@end /* WOElement */
NGObjWeb_DECLARE id OWGetProperty(NSDictionary *_set, NSString *_name) {
register id propValue;