From d41b2544af3c96a21d274e7621f415fa58b7e29b Mon Sep 17 00:00:00 2001 From: helge Date: Tue, 24 Aug 2004 12:36:20 +0000 Subject: [PATCH] added if-not WOx tag git-svn-id: http://svn.opengroupware.org/SOPE/trunk@49 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- .../NGObjWeb/Associations/WOAssociation.m | 1 - sope-appserver/NGObjWeb/ChangeLog | 8 +++ .../DynamicElements/WOComponentReference.m | 4 +- .../NGObjWeb/DynamicElements/WOConditional.m | 65 ++++++++++++++++++- .../DynamicElements/WOxControlElemBuilder.m | 8 ++- sope-appserver/NGObjWeb/Version | 2 +- sope-appserver/NGObjWeb/WODynamicElement.m | 14 ++-- 7 files changed, 88 insertions(+), 14 deletions(-) diff --git a/sope-appserver/NGObjWeb/Associations/WOAssociation.m b/sope-appserver/NGObjWeb/Associations/WOAssociation.m index 50fcfd72..2d024f50 100644 --- a/sope-appserver/NGObjWeb/Associations/WOAssociation.m +++ b/sope-appserver/NGObjWeb/Associations/WOAssociation.m @@ -18,7 +18,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id$ #include #include "WOValueAssociation.h" diff --git a/sope-appserver/NGObjWeb/ChangeLog b/sope-appserver/NGObjWeb/ChangeLog index efab340e..d8c860e8 100644 --- a/sope-appserver/NGObjWeb/ChangeLog +++ b/sope-appserver/NGObjWeb/ChangeLog @@ -1,5 +1,13 @@ 2004-08-24 Helge Hess + * v4.3.9 + + * DynamicElements/WOConditional.m: added specific WOx initializer to + support negative conditionals (if-not) + + * DynamicElements/WOxControlElemBuilder.m: mapped "if-not"/"ifnot" to + WOConditional + * SoObjects/WOContext+SoObjects.m: added missing -setObjectPermissionCache: method (v4.3.8) diff --git a/sope-appserver/NGObjWeb/DynamicElements/WOComponentReference.m b/sope-appserver/NGObjWeb/DynamicElements/WOComponentReference.m index 0d7b9bf3..5e4cd2aa 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/WOComponentReference.m +++ b/sope-appserver/NGObjWeb/DynamicElements/WOComponentReference.m @@ -18,7 +18,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id$ +// $Id: WOComponentReference.m 1 2004-08-20 10:08:27Z znek $ #include "WOComponentReference.h" #include "WOElement+private.h" @@ -138,7 +138,7 @@ _updateComponent(WOComponentReference *self, WOContext *_ctx) - (void)appendToResponse:(WOResponse *)_response inContext:(WOContext *)_ctx { WOComponent *parent; - + parent = [_ctx component]; _updateComponent(self, _ctx); diff --git a/sope-appserver/NGObjWeb/DynamicElements/WOConditional.m b/sope-appserver/NGObjWeb/DynamicElements/WOConditional.m index 619de108..d8b2c5fe 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/WOConditional.m +++ b/sope-appserver/NGObjWeb/DynamicElements/WOConditional.m @@ -18,7 +18,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id$ +// $Id: WOConditional.m 1 2004-08-20 10:08:27Z znek $ #include @@ -42,6 +42,8 @@ @end /* WOConditional */ +#include +#include #include "common.h" #include "WOElement+private.h" @@ -80,6 +82,67 @@ static int descriptiveIDs = -1; return self; } +- (id)initWithNegateElement:(id)_element + templateBuilder:(WOxElemBuilder *)_builder +{ + /* need an own -init so that we can patch the 'negate' association */ + NSString *name; + NSMutableDictionary *assocs; + NSArray *children; + id attrs; + unsigned count; + + name = [_element tagName]; + + /* construct associations */ + + assocs = nil; + attrs = [_element attributes]; + if ((count = [attrs length]) > 0) + assocs = [_builder associationsForAttributes:attrs]; + + if ([assocs objectForKey:@"negate"] != nil) { + // TODO: implement + [self logWithFormat:@"TODO: if-not with 'negate' binding not supported!"]; + [self release]; + return nil; + } + else { + static WOAssociation *yesAssoc = nil; + if (yesAssoc == nil) { + yesAssoc = [[WOAssociation associationWithValue: + [NSNumber numberWithBool:YES]] retain]; + } + [assocs setObject:yesAssoc forKey:@"negate"]; + } + + /* construct child elements */ + + if ([_element hasChildNodes]) { + /* look for var:binding tags ... */ + + children = [_builder buildNodes:[_element childNodes] + templateBuilder:_builder]; + } + else + children = nil; + + /* construct self ... */ + return [self initWithName:name associations:assocs contentElements:children]; +} + +- (id)initWithElement:(id)_element + templateBuilder:(WOxElemBuilder *)_builder +{ + NSString *tag; + + tag = [_element tagName]; + if ([tag isEqualToString:@"if-not"] || [tag isEqualToString:@"ifnot"]) + return [self initWithNegateElement:_element templateBuilder:_builder]; + + return [super initWithElement:_element templateBuilder:_builder]; +} + - (void)dealloc { [self->template release]; [self->value release]; diff --git a/sope-appserver/NGObjWeb/DynamicElements/WOxControlElemBuilder.m b/sope-appserver/NGObjWeb/DynamicElements/WOxControlElemBuilder.m index cbb5de34..aff0b81d 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/WOxControlElemBuilder.m +++ b/sope-appserver/NGObjWeb/DynamicElements/WOxControlElemBuilder.m @@ -18,9 +18,8 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id$ -#import +#include /* This builder builds control flow elements, eg conditionals and @@ -28,6 +27,7 @@ Supported tags: maps to WOConditional + maps to WOConditional maps to WORepetition maps to WOSetCursor */ @@ -55,12 +55,14 @@ tag = [_element tagName]; - if ([tag isEqualToString:@"if"]) { + if ([tag isEqualToString:@"if"] || + [tag isEqualToString:@"if-not"] || [tag isEqualToString:@"ifnot"]) { static Class clazz = Nil; if (clazz == Nil) clazz = NSClassFromString(@"WOConditional"); return clazz; } + if ([tag isEqualToString:@"foreach"] || [tag isEqualToString:@"for-each"]) { static Class clazz = Nil; if (clazz == Nil) diff --git a/sope-appserver/NGObjWeb/Version b/sope-appserver/NGObjWeb/Version index 6e2c2956..12b8a0d3 100644 --- a/sope-appserver/NGObjWeb/Version +++ b/sope-appserver/NGObjWeb/Version @@ -1,6 +1,6 @@ # version file -SUBMINOR_VERSION:=8 +SUBMINOR_VERSION:=9 # v4.2.413 requires libSaxObjC v4.2.33 # v4.2.341 requires libNGExtensions v4.2.77 diff --git a/sope-appserver/NGObjWeb/WODynamicElement.m b/sope-appserver/NGObjWeb/WODynamicElement.m index d62bd82d..1141b0a2 100644 --- a/sope-appserver/NGObjWeb/WODynamicElement.m +++ b/sope-appserver/NGObjWeb/WODynamicElement.m @@ -18,7 +18,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id$ +// $Id: WODynamicElement.m 1 2004-08-20 10:08:27Z znek $ #include #include "WOElement+private.h" @@ -324,12 +324,14 @@ static Class FormElementClass = Nil; The new DOM element init function for elements constructed from DOM element nodes. - The default method is defined on NSObject instead of WOElement, since some dynamic - elements are class clusters, which use temporary non-WOElement classes during - construction. + The default method is defined on NSObject instead of WOElement, since some + dynamic elements are class clusters, which use temporary non-WOElement + classes during construction. - The default construction process requires no support from existing NGObjWeb elements. - It maps all tag attributes to element associations and all child nodes to subelements. + The default construction process requires no support from existing NGObjWeb + elements. + It maps all tag attributes to element associations and all child nodes to + subelements. The tagname is used as the dynamic element name. */ -- 2.39.5