From: helge Date: Mon, 7 Mar 2005 19:22:15 +0000 (+0000) Subject: added a flag to disable XML style generation of close tags X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=69950d75cc0349b666fbadbab7fbf68470e6b456;p=sope added a flag to disable XML style generation of close tags git-svn-id: http://svn.opengroupware.org/SOPE/trunk@630 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- diff --git a/GNUmakefile b/GNUmakefile index f85f2c0d..60b164aa 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,4 +1,4 @@ -# Note: could be that it may not fully compile 'inline' +# GNUstep makefile -include ./config.make include $(GNUSTEP_MAKEFILES)/common.make diff --git a/sope-appserver/NGObjWeb/ChangeLog b/sope-appserver/NGObjWeb/ChangeLog index 68813711..a3480ffe 100644 --- a/sope-appserver/NGObjWeb/ChangeLog +++ b/sope-appserver/NGObjWeb/ChangeLog @@ -1,5 +1,16 @@ 2005-03-07 Helge Hess + * v4.5.131 + + * WOElementID.h: lowered max element nesting to 126 due to limited + scope of ivar (hopefully doesn't trigger #1281) + + * DynamicElements: added support for empty non-XML tags (generate + empty tags without the " />") + + * WOContext.m: changed ivars (bumped class version to 8), added a flag + for generating XML empty elements (to be checked by dynamic elements) + * DynamicElements/WOForm.m: consume 'multipleSubmit' association for WO compatibility as requested by Stephane (v4.5.130) diff --git a/sope-appserver/NGObjWeb/DynamicElements/WOActiveImage.m b/sope-appserver/NGObjWeb/DynamicElements/WOActiveImage.m index c7b9df97..07574d18 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/WOActiveImage.m +++ b/sope-appserver/NGObjWeb/DynamicElements/WOActiveImage.m @@ -23,7 +23,7 @@ Not implemented yet. Sample (Client side): - + diff --git a/sope-appserver/NGObjWeb/DynamicElements/WOCheckBox.m b/sope-appserver/NGObjWeb/DynamicElements/WOCheckBox.m index 4767b17c..70c7f17b 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/WOCheckBox.m +++ b/sope-appserver/NGObjWeb/DynamicElements/WOCheckBox.m @@ -106,7 +106,13 @@ [self->otherTagString stringValueInComponent: [_ctx component]]); } - WOResponse_AddCString(_response, " />\n"); + + if (_ctx->wcFlags.xmlStyleEmptyElements) { + WOResponse_AddCString(_response, " />\n"); + } + else { + WOResponse_AddCString(_response, ">\n"); + } } } diff --git a/sope-appserver/NGObjWeb/DynamicElements/WOCheckBoxList.m b/sope-appserver/NGObjWeb/DynamicElements/WOCheckBoxList.m index 0f457c13..077f95fc 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/WOCheckBoxList.m +++ b/sope-appserver/NGObjWeb/DynamicElements/WOCheckBoxList.m @@ -190,8 +190,8 @@ [self->otherTagString stringValueInComponent: [_ctx component]]); } - WOResponse_AddCString(_response, " />"); - + WOResponse_AddEmptyCloseParens(_response, _ctx); + // the value in a checkbox list is the string besides the checkbox if (self->value) { WOResponse_AddHtmlString(_response, diff --git a/sope-appserver/NGObjWeb/DynamicElements/WOEmbeddedObject.m b/sope-appserver/NGObjWeb/DynamicElements/WOEmbeddedObject.m index 0ddd11c6..4a24a336 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/WOEmbeddedObject.m +++ b/sope-appserver/NGObjWeb/DynamicElements/WOEmbeddedObject.m @@ -186,7 +186,7 @@ [self->otherTagString stringValueInComponent: [_ctx component]]); } - WOResponse_AddCString(_response, " />"); + WOResponse_AddEmptyCloseParens(_response, _ctx); } } diff --git a/sope-appserver/NGObjWeb/DynamicElements/WOFileUpload.m b/sope-appserver/NGObjWeb/DynamicElements/WOFileUpload.m index c4ce1019..a0fd3dec 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/WOFileUpload.m +++ b/sope-appserver/NGObjWeb/DynamicElements/WOFileUpload.m @@ -176,7 +176,7 @@ static NGMimeType *multipartFormData = nil; [self->otherTagString stringValueInComponent: [_ctx component]]); } - WOResponse_AddCString(_response, " />"); + WOResponse_AddEmptyCloseParens(_response, _ctx); } /* description */ diff --git a/sope-appserver/NGObjWeb/DynamicElements/WOFrame.m b/sope-appserver/NGObjWeb/DynamicElements/WOFrame.m index 7ffaeebb..30ad7654 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/WOFrame.m +++ b/sope-appserver/NGObjWeb/DynamicElements/WOFrame.m @@ -169,7 +169,7 @@ [self->otherTagString stringValueInComponent: [_ctx component]]); } - WOResponse_AddCString(_response, " />"); + WOResponse_AddEmptyCloseParens(_response, _ctx); } // description diff --git a/sope-appserver/NGObjWeb/DynamicElements/WOGenericElement.m b/sope-appserver/NGObjWeb/DynamicElements/WOGenericElement.m index b2a32e14..429efb01 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/WOGenericElement.m +++ b/sope-appserver/NGObjWeb/DynamicElements/WOGenericElement.m @@ -236,7 +236,7 @@ typedef struct { [self->otherTagString stringValueInComponent: sComponent]); } - WOResponse_AddCString(_response, " />"); + WOResponse_AddEmptyCloseParens(_response, _ctx); } @end /* WOGenericElement */ diff --git a/sope-appserver/NGObjWeb/DynamicElements/WOHiddenField.m b/sope-appserver/NGObjWeb/DynamicElements/WOHiddenField.m index 49542a65..c4f8316e 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/WOHiddenField.m +++ b/sope-appserver/NGObjWeb/DynamicElements/WOHiddenField.m @@ -66,7 +66,7 @@ [self->otherTagString stringValueInComponent: [_ctx component]]); } - WOResponse_AddCString(_response, " />"); + WOResponse_AddEmptyCloseParens(_response, _ctx); } } } diff --git a/sope-appserver/NGObjWeb/DynamicElements/WOImage.m b/sope-appserver/NGObjWeb/DynamicElements/WOImage.m index 4a8c69ad..b483d8d9 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/WOImage.m +++ b/sope-appserver/NGObjWeb/DynamicElements/WOImage.m @@ -120,7 +120,7 @@ [_ctx component]]); } - WOResponse_AddCString(_response, " />"); + WOResponse_AddEmptyCloseParens(_response, _ctx); } @end /* WOImage */ diff --git a/sope-appserver/NGObjWeb/DynamicElements/WOImageButton.m b/sope-appserver/NGObjWeb/DynamicElements/WOImageButton.m index 8e3bd41b..77d25d3d 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/WOImageButton.m +++ b/sope-appserver/NGObjWeb/DynamicElements/WOImageButton.m @@ -242,7 +242,7 @@ [self->otherTagString stringValueInComponent: [_ctx component]]); } - WOResponse_AddCString(_response, " />"); + WOResponse_AddEmptyCloseParens(_response, _ctx); } /* description */ diff --git a/sope-appserver/NGObjWeb/DynamicElements/WOMetaRefresh.m b/sope-appserver/NGObjWeb/DynamicElements/WOMetaRefresh.m index abf8ed79..83fa4c4b 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/WOMetaRefresh.m +++ b/sope-appserver/NGObjWeb/DynamicElements/WOMetaRefresh.m @@ -229,7 +229,7 @@ [self->otherTagString stringValueInComponent: [_ctx component]]); } - WOResponse_AddCString(_response, " />"); + WOResponse_AddEmptyCloseParens(_response, _ctx); } /* description */ diff --git a/sope-appserver/NGObjWeb/DynamicElements/WOPasswordField.m b/sope-appserver/NGObjWeb/DynamicElements/WOPasswordField.m index 9d13b02d..f76d1976 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/WOPasswordField.m +++ b/sope-appserver/NGObjWeb/DynamicElements/WOPasswordField.m @@ -78,7 +78,7 @@ [self->otherTagString stringValueInComponent: [_ctx component]]); } - WOResponse_AddCString(_response, " />"); + WOResponse_AddEmptyCloseParens(_response, _ctx); } /* description */ diff --git a/sope-appserver/NGObjWeb/DynamicElements/WORadioButton.m b/sope-appserver/NGObjWeb/DynamicElements/WORadioButton.m index afba1d24..b5b479c0 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/WORadioButton.m +++ b/sope-appserver/NGObjWeb/DynamicElements/WORadioButton.m @@ -119,7 +119,7 @@ [self->otherTagString stringValueInComponent: sComponent]); } - WOResponse_AddCString(_response, " />"); + WOResponse_AddEmptyCloseParens(_response, _ctx); } /* description */ diff --git a/sope-appserver/NGObjWeb/DynamicElements/WORadioButtonList.m b/sope-appserver/NGObjWeb/DynamicElements/WORadioButtonList.m index bc6420ac..8c8980c2 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/WORadioButtonList.m +++ b/sope-appserver/NGObjWeb/DynamicElements/WORadioButtonList.m @@ -157,8 +157,8 @@ [self->otherTagString stringValueInComponent: [_ctx component]]); } - WOResponse_AddCString(_response, " />"); - + WOResponse_AddEmptyCloseParens(_response, _ctx); + // the value in a radio list is the string besides the button if (self->value) { NSString *s; diff --git a/sope-appserver/NGObjWeb/DynamicElements/WOResetButton.m b/sope-appserver/NGObjWeb/DynamicElements/WOResetButton.m index 44a082a3..e6cab87f 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/WOResetButton.m +++ b/sope-appserver/NGObjWeb/DynamicElements/WOResetButton.m @@ -56,7 +56,8 @@ [self->otherTagString stringValueInComponent: [_ctx component]]); } - WOResponse_AddCString(_response, " />"); + + WOResponse_AddEmptyCloseParens(_response, _ctx); } @end /* WOResetButton */ diff --git a/sope-appserver/NGObjWeb/DynamicElements/WOString.m b/sope-appserver/NGObjWeb/DynamicElements/WOString.m index 4f04ce62..4dbd5e89 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/WOString.m +++ b/sope-appserver/NGObjWeb/DynamicElements/WOString.m @@ -622,7 +622,9 @@ static WOAssociation *yesAssoc = nil; [_response performSelector:addSel withObject:obj]; } else { - [self _appendStringLines:obj withSeparator:@"
" + [self _appendStringLines:obj + withSeparator: + (_ctx->wcFlags.xmlStyleEmptyElements ? @"
" : @"
") contentSelector:addSel toResponse:_response inContext:_ctx]; } diff --git a/sope-appserver/NGObjWeb/DynamicElements/WOSubmitButton.m b/sope-appserver/NGObjWeb/DynamicElements/WOSubmitButton.m index db84b6c5..6314dd6c 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/WOSubmitButton.m +++ b/sope-appserver/NGObjWeb/DynamicElements/WOSubmitButton.m @@ -157,7 +157,7 @@ [self->otherTagString stringValueInComponent: [_ctx component]]); } - WOResponse_AddCString(_response, " />"); + WOResponse_AddEmptyCloseParens(_response, _ctx); } /* description */ diff --git a/sope-appserver/NGObjWeb/DynamicElements/WOTextField.m b/sope-appserver/NGObjWeb/DynamicElements/WOTextField.m index 14d54564..72aad322 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/WOTextField.m +++ b/sope-appserver/NGObjWeb/DynamicElements/WOTextField.m @@ -212,7 +212,7 @@ static inline NSFormatter *_getFormatter(WOTextField *self, WOContext *_ctx) { [self->otherTagString stringValueInComponent: [_ctx component]]); } - WOResponse_AddCString(_response, " />"); + WOResponse_AddEmptyCloseParens(_response, _ctx); } /* description */ diff --git a/sope-appserver/NGObjWeb/DynamicElements/_WOComplexHyperlink.m b/sope-appserver/NGObjWeb/DynamicElements/_WOComplexHyperlink.m index 61a0a25b..2509c16e 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/_WOComplexHyperlink.m +++ b/sope-appserver/NGObjWeb/DynamicElements/_WOComplexHyperlink.m @@ -249,7 +249,8 @@ static Class NSURLClass = Nil; WOResponse_AddChar(_resp, '"'); [self appendExtraAttributesToResponse:_resp inContext:_ctx]; - WOResponse_AddCString(_resp, " />"); + + WOResponse_AddEmptyCloseParens(_resp, _ctx); } - (void)appendToResponse:(WOResponse *)_response inContext:(WOContext *)_ctx { diff --git a/sope-appserver/NGObjWeb/DynamicElements/common.h b/sope-appserver/NGObjWeb/DynamicElements/common.h index dcfdf19f..03ec3435 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/common.h +++ b/sope-appserver/NGObjWeb/DynamicElements/common.h @@ -38,4 +38,15 @@ #include +static inline void WOResponse_AddEmptyCloseParens(WOResponse *r, + WOContext *ctx) +{ + if (ctx->wcFlags.xmlStyleEmptyElements) { + WOResponse_AddCString(r, " />"); + } + else { + WOResponse_AddChar(r, '>'); + } +} + #endif /* __NGObjWeb_DynElem_common_H__ */ diff --git a/sope-appserver/NGObjWeb/NGObjWeb/WOContext.h b/sope-appserver/NGObjWeb/NGObjWeb/WOContext.h index 9e064f45..e60bf4e9 100644 --- a/sope-appserver/NGObjWeb/NGObjWeb/WOContext.h +++ b/sope-appserver/NGObjWeb/NGObjWeb/WOContext.h @@ -67,15 +67,20 @@ id contentStack[NGObjWeb_MAX_COMPONENT_NESTING_DEPTH]; signed char componentStackCount; - /* FORM support */ - BOOL inForm; - id activeFormElement; - + /* misc */ + id activeFormElement; NSString *qpJoin; - /* tracking component actions */ - BOOL savePageRequired; +@public /* need fast access to generation flags */ + /* flags */ + struct { + int savePageRequired:1; /* tracking component actions */ + int inForm:1; + int xmlStyleEmptyElements:1; + int reserved:29; + } wcFlags; +@protected /* SOPE */ id clientObject; NSMutableArray *traversalStack; @@ -106,6 +111,9 @@ - (NSURL *)serverURL; - (NSURL *)urlForKey:(NSString *)_key; +- (void)setGenerateXMLStyleEmptyElements:(BOOL)_flag; +- (BOOL)generateXMLStyleEmptyElements; + /* variables */ - (void)setObject:(id)_obj forKey:(NSString *)_key; diff --git a/sope-appserver/NGObjWeb/Version b/sope-appserver/NGObjWeb/Version index 8e4d785c..c8be53a6 100644 --- a/sope-appserver/NGObjWeb/Version +++ b/sope-appserver/NGObjWeb/Version @@ -1,6 +1,6 @@ # version file -SUBMINOR_VERSION:=130 +SUBMINOR_VERSION:=131 # v4.5.122 requires libNGExtensions v4.5.153 # v4.5.91 requires libNGExtensions v4.5.134 diff --git a/sope-appserver/NGObjWeb/WOContext.m b/sope-appserver/NGObjWeb/WOContext.m index f6c5c0de..3e6f3cd9 100644 --- a/sope-appserver/NGObjWeb/WOContext.m +++ b/sope-appserver/NGObjWeb/WOContext.m @@ -49,7 +49,7 @@ static Class WOAppClass = Nil; @implementation WOContext + (int)version { - return 7; + return 8; } static Class WOContextClass = Nil; @@ -104,6 +104,9 @@ static NSString *WOApplicationSuffix = nil; sprintf(buf, "%03x%08x%08x", ++contextCount, (int)time(NULL), (int)self); self->ctxId = [[NSString alloc] initWithCString:buf]; + /* per default close tags in XML style */ + self->wcFlags.xmlStyleEmptyElements = 1; + self->elementID = [[WOElementID alloc] init]; self->awakeComponents = [[NSMutableSet alloc] initWithCapacity:64]; @@ -333,7 +336,7 @@ static NSString *WOApplicationSuffix = nil; } - (BOOL)savePageRequired { - return self->savePageRequired; + return self->wcFlags.savePageRequired ? YES : NO; } /* cursors */ @@ -561,10 +564,10 @@ void WOContext_leaveComponent(WOContext *self, WOComponent *_component) { /* forms */ - (void)setInForm:(BOOL)_form { - self->inForm = _form; + self->wcFlags.inForm = _form ? 1 : 0; } - (BOOL)isInForm { - return self->inForm; + return self->wcFlags.inForm ? YES : NO; } - (void)addActiveFormElement:(WOElement *)_formElement { @@ -706,6 +709,13 @@ void WOContext_leaveComponent(WOContext *self, WOComponent *_component) { return self->qpJoin; } +- (void)setGenerateXMLStyleEmptyElements:(BOOL)_flag { + self->wcFlags.xmlStyleEmptyElements = _flag ? 1 : 0; +} +- (BOOL)generateXMLStyleEmptyElements { + return self->wcFlags.xmlStyleEmptyElements ? YES : NO; +} + - (NSString *)queryStringFromDictionary:(NSDictionary *)_queryDict { NSEnumerator *keys; NSString *key; @@ -770,7 +780,7 @@ void WOContext_leaveComponent(WOContext *self, WOComponent *_component) { NSMutableString *qs; NSString *p; - self->savePageRequired = YES; + self->wcFlags.savePageRequired = 1; qs = [MutableStrClass stringWithCapacity:64]; [qs appendString:WORequestValueSenderID]; @@ -801,8 +811,8 @@ void WOContext_leaveComponent(WOContext *self, WOComponent *_component) { static NSMutableString *url = nil; // THREAD static IMP addStr = NULL; NSString *s; - - self->savePageRequired = YES; + + self->wcFlags.savePageRequired = 1; if (url == nil) { url = [[MutableStrClass alloc] initWithCapacity:256]; addStr = [url methodForSelector:@selector(appendString:)]; diff --git a/sope-appserver/NGObjWeb/WOElementID.h b/sope-appserver/NGObjWeb/WOElementID.h index e8a4ad8c..48eed23a 100644 --- a/sope-appserver/NGObjWeb/WOElementID.h +++ b/sope-appserver/NGObjWeb/WOElementID.h @@ -31,7 +31,7 @@ element-id. An element id is a "path" to an object kept in a tree. */ -#define NGObjWeb_MAX_ELEMENT_ID_COUNT 128 +#define NGObjWeb_MAX_ELEMENT_ID_COUNT 126 @class NSString, NSMutableString;