moved files from my branch. I hope it will not break too much :-)

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@25027 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Dave Wetzel 2007-04-13 18:32:02 +00:00
parent 47ace186dd
commit d92957ccb6
112 changed files with 7462 additions and 14165 deletions

View file

@ -95,6 +95,7 @@ GSWProjectBundle.m \
GSWSessionTimeOut.m \
GSWStats.m \
NSNonBlockingFileHandle.m \
NSDictionary+HTML.m \
GSWTransactionRecord.m \
GSWBundle.m \
NSString+Trimming.m \
@ -107,6 +108,7 @@ GSWContext.m \
GSWMultiKeyDictionary.m \
GSWDisplayGroup.m \
GSWDynamicElement.m \
GSWDynamicGroup.m \
GSWElement.m \
GSWMessage.m \
GSWRequest.m \
@ -235,6 +237,7 @@ GSWActionRequestHandler.h \
GSWDirectActionRequestHandler.h \
GSWDisplayGroup.h \
GSWDynamicElement.h \
GSWDynamicGroup.h \
GSWDynamicURLString.h \
GSWElement.h \
GSWElementID.h \
@ -299,6 +302,7 @@ GSWVBScript.h \
NSNonBlockingFileHandle.h \
NSString+HTML.h \
NSString+Trimming.h \
NSDictionary+HTML.h \
GSWConfig.h \
GSWConstants.h \
GSWDebug.h \

View file

@ -40,14 +40,13 @@ RCS_ID("$Id$")
//--------------------------------------------------------------------
-(id)initWithRequest:(GSWRequest*)aRequest
{
LOGObjectFnStart();
if ((self=[super init]))
{
_context = RETAIN([GSWApp createContextForRequest:aRequest]);
[GSWApp _setContext:_context]; //NDFN
[self _initializeRequestSessionIDInContext:_context];
};
LOGObjectFnStop();
return self;
};
@ -65,15 +64,14 @@ RCS_ID("$Id$")
};
//--------------------------------------------------------------------
-(GSWSession*)existingSession
{
//OK
GSWSession* session=nil;
BOOL hasSession=NO;
LOGObjectFnStart();
if (![_context isSessionDisabled])
if (![_context isSessionDisabled]) // TODO:check if wo does it like that.
{
hasSession=[_context hasSession];
if (hasSession)
@ -86,7 +84,6 @@ RCS_ID("$Id$")
{
NS_DURING
{
NSDebugMLLog(@"requests",@"sessionID=%@",sessionID);
session=[GSWApp restoreSessionWithID:sessionID
inContext:_context];
//No Exception if session can't be restored !
@ -103,8 +100,6 @@ RCS_ID("$Id$")
};
};
LOGObjectFnStop();
return session;
};
@ -115,8 +110,6 @@ RCS_ID("$Id$")
GSWSession* session=nil;
BOOL hasSession=NO;
LOGObjectFnStart();
if (![_context isSessionDisabled])
{
hasSession=[_context hasSession];
@ -128,7 +121,6 @@ RCS_ID("$Id$")
{
NS_DURING
{
NSDebugMLLog(@"requests",@"aSessionID=%@",aSessionID);
session=[GSWApp restoreSessionWithID:aSessionID
inContext:_context];
//No Exception if session can't be restored !
@ -136,7 +128,6 @@ RCS_ID("$Id$")
NS_HANDLER
{
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,@"in session create/restore");
LOGException(@"exception=%@",localException);
//No Exception if session can't be restored !
session=nil;
}
@ -145,61 +136,55 @@ RCS_ID("$Id$")
};
};
LOGObjectFnStop();
return session;
};
//--------------------------------------------------------------------
-(GSWSession*)session
{
BOOL hasSession=NO;
GSWSession* session=nil;
LOGObjectFnStart();
if (![_context isSessionDisabled])
{
hasSession=[_context hasSession];
if (hasSession)
session=[_context existingSession];
if (!session)
{
NSString* sessionID=nil;
sessionID=[[self request] sessionID];
if (sessionID)
{
NS_DURING
{
session=[GSWApp restoreSessionWithID:sessionID
inContext:_context];
}
NS_HANDLER
{
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,@"in session create/restore");
LOGException(@"exception=%@",localException);
[localException raise];
};
NS_ENDHANDLER;
if (!session)
{
ExceptionRaise(@"GSWAction",
@"Unable to restore sessionID %@.",
sessionID);
};
}
else
{
// No Session ID: Create a new Session
session=[_context session];
};
};
};
LOGObjectFnStop();
return session;
};
//-(GSWSession*)session
//{
// BOOL hasSession=NO;
// GSWSession* session=nil;
//
// if (![_context isSessionDisabled])
// {
// hasSession=[_context hasSession];
// if (hasSession)
// session=[_context existingSession];
// if (!session)
// {
// NSString* sessionID=nil;
// sessionID=[[self request] sessionID];
// if (sessionID)
// {
// NS_DURING
// {
// session=[GSWApp restoreSessionWithID:sessionID
// inContext:_context];
// }
// NS_HANDLER
// {
// localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,@"in session create/restore");
// LOGException(@"exception=%@",localException);
// [localException raise];
// };
// NS_ENDHANDLER;
// if (!session)
// {
// ExceptionRaise(@"GSWAction",
// @"Unable to restore sessionID %@.",
// sessionID);
// };
// }
// else
// {
// // No Session ID: Create a new Session
// session=[_context session];
// };
// };
// };
//
// return session;
//};
//--------------------------------------------------------------------
// application
@ -214,7 +199,7 @@ RCS_ID("$Id$")
{
//OK
GSWComponent* component=nil;
LOGObjectFnStart();
NS_DURING
{
NSAssert(_context,@"No Context");
@ -230,7 +215,7 @@ RCS_ID("$Id$")
[localException raise];
};
NS_ENDHANDLER;
LOGObjectFnStop();
return component;
};
@ -249,8 +234,9 @@ RCS_ID("$Id$")
NSString* actionSelName=nil;
SEL actionSel=NULL;
actionSelName=[actionName stringByAppendingString:@"Action"];
NSDebugMLLog(@"requests",@"actionSelName=%@",actionSelName);
actionSel=NSSelectorFromString(actionSelName);
return actionSel;
}
@ -290,10 +276,7 @@ RCS_ID("$Id$")
GSWRequest* request=nil;
NSString* sessionID=nil;
LOGObjectFnStart();
request=[aContext request];
NSDebugMLog(@"request=%@",request);
sessionID=[self sessionIDForRequest:request];
if (sessionID)
@ -301,7 +284,6 @@ RCS_ID("$Id$")
[aContext _setRequestSessionID:sessionID];
};
LOGObjectFnStop();
};
//--------------------------------------------------------------------
@ -316,15 +298,10 @@ RCS_ID("$Id$")
return [_context languages];
}
@end
//====================================================================
@implementation GSWAction (GSWActionA)
//--------------------------------------------------------------------
-(GSWContext*)context
{
return [self _context];
return _context;
};
-(GSWContext*)_context
@ -345,15 +322,10 @@ RCS_ID("$Id$")
return [_context session];
};
@end
//====================================================================
@implementation GSWAction (GSWDebugging)
//--------------------------------------------------------------------
-(void)logWithString:(NSString*)string
{
[GSWApplication logString:string];
[GSWApp logString:string];
};
//--------------------------------------------------------------------
@ -361,8 +333,8 @@ RCS_ID("$Id$")
{
va_list ap;
va_start(ap,aFormat);
[[GSWApplication application]logWithFormat:aFormat
arguments:ap];
[GSWApp logWithFormat:aFormat
arguments:ap];
va_end(ap);
};
@ -371,8 +343,8 @@ RCS_ID("$Id$")
{
va_list ap;
va_start(ap,aFormat);
[[GSWApplication application] logWithFormat:aFormat
arguments:ap];
[GSWApp logWithFormat:aFormat
arguments:ap];
va_end(ap);
};

View file

@ -118,7 +118,7 @@ RCS_ID("$Id$")
{
GSWResponse* response=nil;
GSWApplication* application=nil;
LOGObjectFnStart();
application=[GSWApplication application];
// Test if we should accept request
@ -151,7 +151,7 @@ RCS_ID("$Id$")
response=[self generateNullResponse];
[response _finalizeInContext:nil];
};
LOGObjectFnStop();
return response;
};
@ -175,19 +175,16 @@ RCS_ID("$Id$")
+(Class)_actionClassForName:(NSString*)name
{
Class class=Nil;
LOGObjectFnStart();
class=NSClassFromString(name);
NSDebugMLog(@"name=%@",name);
NSDebugMLog(@"class=%@",class);
NSDebugMLog(@"[GSWAction class]=%@",[GSWAction class]);
if (class)
{
[class description];//TODO: does this to force class init. Check this later
if (!GSObjCIsKindOf(class,[GSWAction class]))
class=Nil;
};
NSDebugMLog(@"class=%@",class);
LOGObjectFnStop();
return class;
}
@ -200,11 +197,7 @@ RCS_ID("$Id$")
int pathCount=0;
int i=0;
LOGObjectFnStart();
pathCount=[path count];
NSDebugMLog(@"path=%@",path);
NSDebugMLog(@"pathCount=%d",pathCount);
// remove empty last parts
for(i=pathCount-1;i>=0 && [[path objectAtIndex:i]length]==0;i--)
@ -213,14 +206,10 @@ RCS_ID("$Id$")
{
path=[path subarrayWithRange:NSMakeRange(0,pathCount)];
};
NSDebugMLog(@"path=%@",path);
NSDebugMLog(@"pathCount=%d",pathCount);
switch(pathCount)
{
case 0:
NSDebugMLog(@"_actionClassName=%@",_actionClassName);
NSDebugMLog(@"_actionClassClass=%@",_actionClassClass);
NSDebugMLog(@"_defaultActionName=%@",_defaultActionName);
*actionClassNamePtr = _actionClassName;
*actionClassPtr = _actionClassClass;
*actionNamePtr = _defaultActionName;
@ -228,16 +217,12 @@ RCS_ID("$Id$")
case 1:
{
NSString* testActionName=[path objectAtIndex:0];
NSDebugMLog(@"testActionName=%@",testActionName);
if ([GSWAction _isActionNamed:testActionName
actionOfClass:*actionClassPtr])
{
NSDebugMLog(@"_actionClassName=%@",_actionClassName);
if(!_actionClassClass)
_actionClassClass = [[self class]_actionClassForName:_actionClassName];
NSDebugMLog(@"_actionClassClass=%@",_actionClassClass);
NSDebugMLog(@"testActionName=%@",testActionName);
*actionClassNamePtr = _actionClassName;
*actionClassPtr = _actionClassClass;
*actionNamePtr = testActionName;
@ -245,22 +230,16 @@ RCS_ID("$Id$")
else
{
*actionClassPtr = [[self class]_actionClassForName:testActionName]; // is it a class ?
NSDebugMLog(@"*actionClassPtr=%@",*actionClassPtr);
if (*actionClassPtr)
{
*actionClassNamePtr = NSStringFromClass(*actionClassPtr);
*actionNamePtr = _defaultActionName;
NSDebugMLog(@"*actionClassNamePtr=%@",*actionClassNamePtr);
NSDebugMLog(@"*actionNamePtr=%@",*actionNamePtr);
}
else
{
*actionClassNamePtr = _actionClassName;
*actionClassPtr = _actionClassClass;
*actionNamePtr = testActionName;
NSDebugMLog(@"_actionClassName=%@",_actionClassName);
NSDebugMLog(@"_actionClassClass=%@",_actionClassClass);
NSDebugMLog(@"testActionName=%@",testActionName);
}
};
};
@ -270,25 +249,18 @@ RCS_ID("$Id$")
{
*actionClassNamePtr=[path objectAtIndex:0];
*actionNamePtr=NSStringWithObject([path objectAtIndex:1]);
NSDebugMLog(@"*actionClassNamePtr=%@",*actionClassNamePtr);
NSDebugMLog(@"*actionNamePtr=%@",*actionNamePtr);
if ([*actionNamePtr isEqual:*actionClassNamePtr])
{
*actionClassNamePtr = _actionClassName;
*actionClassPtr = _actionClassClass;
NSDebugMLog(@"*actionClassNamePtr=%@",*actionClassNamePtr);
NSDebugMLog(@"*actionClassPtr=%@",*actionClassPtr);
}
else
{
*actionClassPtr = [[self class]_actionClassForName:*actionClassNamePtr];
NSDebugMLog(@"*actionClassNamePtr=%@",*actionClassNamePtr);
NSDebugMLog(@"*actionClassPtr=%@",*actionClassPtr);
};
};
break;
};
LOGObjectFnStop();
};
//--------------------------------------------------------------------
@ -297,11 +269,7 @@ RCS_ID("$Id$")
{
GSWAction* action=nil;
LOGObjectFnStart();
action = AUTORELEASE([[actionClass alloc]initWithRequest:aRequest]);
LOGObjectFnStop();
action = AUTORELEASE([[actionClass alloc] initWithRequest:aRequest]);
return action;
}
@ -323,9 +291,7 @@ RCS_ID("$Id$")
NSException* exception=nil;
BOOL hasSession=NO;
LOGObjectFnStart();
application=[GSWApplication application];
application = GSWApp;
NS_DURING
{
@ -338,8 +304,6 @@ RCS_ID("$Id$")
[application awake];
requestHandlerPathArray=[self getRequestHandlerPathForRequest:aRequest];
NSDebugMLLog(@"requests",@"requestHandlerPathArray=%@",
requestHandlerPathArray);
// Parse path into actionClassName,actionClass and actionName
@ -350,9 +314,6 @@ RCS_ID("$Id$")
classInto:&actionClass
nameInto:&actionName
forPath:requestHandlerPathArray];
NSDebugMLLog(@"requests",@"className=%@",actionClassName);
NSDebugMLLog(@"requests",@"actionClass=%@",actionClass);
NSDebugMLLog(@"requests",@"actionName=%@",actionName);
}
NS_HANDLER
{
@ -466,10 +427,7 @@ RCS_ID("$Id$")
actionClass:actionClass
actionObject:action];
};
NSDebugMLog(@"Exception=%@",exception);
NSDebugMLog(@"Response=%@",response);
[exception raise]; // Will be caught be up level Exception
NSDebugMLog(@"Not raised ? Exception=%@",exception);
};
if ([application isCachingEnabled])
{
@ -479,7 +437,6 @@ RCS_ID("$Id$")
NS_HANDLER
{
LOGException(@"%@ (%@)",localException,[localException reason]);
NSDebugMLog(@"EXCEPTION localException=%@",localException);
if (!response)
{
if (!context)
@ -517,7 +474,6 @@ RCS_ID("$Id$")
};
NS_ENDHANDLER;
NSDebugMLLog(@"requests",@"response=%@",response);
RETAIN(response);
if (!context)
context=[GSWApp _context];
@ -528,7 +484,6 @@ RCS_ID("$Id$")
[application saveSessionForContext:context];
};
NSDebugMLLog(@"requests",@"response=%@",response);
AUTORELEASE(response);
AUTORELEASE(exception);
@ -551,7 +506,6 @@ RCS_ID("$Id$")
[application _setContext:nil];
};
LOGObjectFnStop();
return response;
};
@ -574,11 +528,6 @@ RCS_ID("$Id$")
return [self subclassResponsibility: _cmd];
};
@end
//====================================================================
@implementation GSWActionRequestHandler (GSWRequestHandlerClassA)
//--------------------------------------------------------------------
+(id)handler
{

View file

@ -36,43 +36,35 @@
//====================================================================
@interface GSWActiveImage: GSWInput
{
GSWAssociation* _imageMapFileName;
//GSWeb Additions {
GSWAssociation* _imageMapString;
GSWAssociation* _imageMapRegions;
GSWAssociation * _imageMapString;
GSWAssociation * _imageMapRegions;
// }
GSWAssociation* _action;
GSWAssociation* _href;
GSWAssociation* _src;
GSWAssociation* _xAssoc;
GSWAssociation* _yAssoc;
GSWAssociation* _target;
GSWAssociation* _filename;
GSWAssociation* _framework;
GSWAssociation* _data;
GSWAssociation* _mimeType;
GSWAssociation* _key;
GSWAssociation * _file; // this is imageMapFile
GSWAssociation * _action;
GSWAssociation * _href;
GSWAssociation * _src;
GSWAssociation * _xAssoc;
GSWAssociation * _yAssoc;
GSWAssociation * _target;
GSWAssociation * _filename;
GSWAssociation * _framework;
GSWAssociation * _data;
GSWAssociation * _mimeType;
GSWAssociation * _key;
GSWAssociation * _width;
GSWAssociation * _height;
GSWAssociation * _secure;
GSWAssociation * _actionClass;
GSWAssociation * _directActionName;
};
-(id)initWithName:(NSString*)name
associations:(NSDictionary*)associations
contentElements:(NSArray*)elements;
-(NSString*)elementName;
-(NSString*)description;
-(void)dealloc;
@end
//====================================================================
@interface GSWActiveImage (GSWActiveImageA)
-(GSWAssociation*)hitTestX:(int)x
y:(int)y
inRegions:(NSArray*)regions;
@end
//====================================================================
@interface GSWActiveImage (GSWActiveImageB)
-(void)appendToResponse:(GSWResponse*)response
inContext:(GSWContext*)aContext;
@ -82,22 +74,11 @@
inContext:(GSWContext*)aContext;
-(NSString*)frameworkNameInContext:(GSWContext*)aContext;
-(NSString*)imageSourceInContext:(GSWContext*)aContext; //NDFN
-(NSString*)hrefInContext:(GSWContext*)aContext; //NDFN
@end
//====================================================================
@interface GSWActiveImage (GSWActiveImageC)
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)response_
inContext:(GSWContext*)aContext;
@end
//====================================================================
@interface GSWActiveImage (GSWActiveImageD)
-(BOOL)appendStringAtRight:(id)unkwnon
withMapping:(char*)mapping;
-(BOOL)appendStringAtLeft:(id)unkwnon
withMapping:(char*)mapping;
-(void)_appendCGIActionURLToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext;
@end
#endif //_GSWActiveImage_h__

View file

@ -40,116 +40,177 @@ RCS_ID("$Id$")
//--------------------------------------------------------------------
-(id)initWithName:(NSString*)aName
associations:(NSDictionary*)Xassociations
contentElements:(NSArray*)elements
associations:(NSDictionary*)associations
template:(GSWElement*)template
{
//OK
NSMutableDictionary* tmpAssociations=nil;
LOGObjectFnStart();
NSDebugMLog(@"name=%@ Xassociations:%@ elements_=%@",
aName,Xassociations,elements);
tmpAssociations=[NSMutableDictionary dictionaryWithDictionary:Xassociations];
[tmpAssociations removeObjectForKey:imageMapFileName__Key];
if (!WOStrictFlag)
{
[tmpAssociations removeObjectForKey:imageMapString__Key];
[tmpAssociations removeObjectForKey:imageMapRegions__Key];
};
[tmpAssociations removeObjectForKey:action__Key];
[tmpAssociations removeObjectForKey:href__Key];
[tmpAssociations removeObjectForKey:src__Key];
[tmpAssociations removeObjectForKey:x__Key];
[tmpAssociations removeObjectForKey:y__Key];
[tmpAssociations removeObjectForKey:target__Key];
[tmpAssociations removeObjectForKey:filename__Key];
[tmpAssociations removeObjectForKey:framework__Key];
[tmpAssociations removeObjectForKey:data__Key];
[tmpAssociations removeObjectForKey:mimeType__Key];
[tmpAssociations removeObjectForKey:key__Key];
if ((self=[super initWithName:aName
associations:tmpAssociations
contentElements:elements]))
{
int imageMapDefNb=0;
_imageMapFileName = [[Xassociations objectForKey:imageMapFileName__Key
withDefaultObject:[_imageMapFileName autorelease]] retain];
if (_imageMapFileName)
imageMapDefNb++;
if (!WOStrictFlag)
{
_imageMapString = [[Xassociations objectForKey:imageMapString__Key
withDefaultObject:[_imageMapString autorelease]] retain];
if (_imageMapString)
imageMapDefNb++;
_imageMapRegions = [[Xassociations objectForKey:imageMapRegions__Key
withDefaultObject:[_imageMapRegions autorelease]] retain];
if (_imageMapRegions)
imageMapDefNb++;
if (imageMapDefNb>0)
{
ExceptionRaise(@"GSWActiveImage",@"you can't specify %@, %@ and %@",
imageMapFileName__Key,
imageMapString__Key,
imageMapRegions__Key);
};
};
_action = [[Xassociations objectForKey:action__Key
withDefaultObject:[_action autorelease]] retain];
_href = [[Xassociations objectForKey:href__Key
withDefaultObject:[_href autorelease]] retain];
_src = [[Xassociations objectForKey:src__Key
withDefaultObject:[_src autorelease]] retain];
_xAssoc = [[Xassociations objectForKey:x__Key
withDefaultObject:[_xAssoc autorelease]] retain];
if (_xAssoc && ![_xAssoc isValueSettable])
{
ExceptionRaise0(@"GSWActiveImage",@"'x' parameter must be settable");
};
_yAssoc = [[Xassociations objectForKey:y__Key
withDefaultObject:[_yAssoc autorelease]] retain];
if (_yAssoc && ![_yAssoc isValueSettable])
{
ExceptionRaise0(@"GSWActiveImage",@"'y' parameter must be settable");
};
_target = [[Xassociations objectForKey:target__Key
withDefaultObject:[_target autorelease]] retain];
_filename = [[Xassociations objectForKey:filename__Key
withDefaultObject:[_filename autorelease]] retain];
_framework = [[Xassociations objectForKey:framework__Key
withDefaultObject:[_framework autorelease]] retain];
_data = [[Xassociations objectForKey:data__Key
withDefaultObject:[_data autorelease]] retain];
NSDebugMLLog(@"gswdync",@"_data=%@",_data);
_action = [[Xassociations objectForKey:action__Key
withDefaultObject:[_action autorelease]] retain];
_mimeType = [[Xassociations objectForKey:mimeType__Key
withDefaultObject:[_mimeType autorelease]] retain];
_key = [[Xassociations objectForKey:key__Key
withDefaultObject:[_key autorelease]] retain];
};
self = [super initWithName:@"input" associations:associations template: nil];
if (!self) {
return nil;
}
ASSIGN(_file, [_associations objectForKey: imageMapFileName__Key]);
if (_file != nil) {
[_associations removeObjectForKey: imageMapFileName__Key];
}
if (!WOStrictFlag) {
ASSIGN(_imageMapString, [_associations objectForKey: imageMapString__Key]);
if (_imageMapString != nil) {
[_associations removeObjectForKey: imageMapString__Key];
}
ASSIGN(_imageMapRegions, [_associations objectForKey: imageMapRegions__Key]);
if (_imageMapRegions != nil) {
[_associations removeObjectForKey: imageMapRegions__Key];
}
};
ASSIGN(_action, [_associations objectForKey: action__Key]);
if (_action != nil) {
[_associations removeObjectForKey: action__Key];
}
ASSIGN(_href, [_associations objectForKey: href__Key]);
if (_href != nil) {
[_associations removeObjectForKey: href__Key];
}
ASSIGN(_src, [_associations objectForKey: src__Key]);
if (_src != nil) {
[_associations removeObjectForKey: src__Key];
}
ASSIGN(_xAssoc, [_associations objectForKey: x__Key]);
if (_xAssoc != nil) {
[_associations removeObjectForKey: x__Key];
}
ASSIGN(_yAssoc, [_associations objectForKey: y__Key]);
if (_yAssoc != nil) {
[_associations removeObjectForKey: y__Key];
}
ASSIGN(_target, [_associations objectForKey: target__Key]);
if (_target != nil) {
[_associations removeObjectForKey: target__Key];
}
ASSIGN(_filename, [_associations objectForKey: filename__Key]);
if (_filename != nil) {
[_associations removeObjectForKey: filename__Key];
}
ASSIGN(_framework, [_associations objectForKey: framework__Key]);
if (_framework != nil) {
[_associations removeObjectForKey: framework__Key];
}
ASSIGN(_data, [_associations objectForKey: data__Key]);
if (_data != nil) {
[_associations removeObjectForKey: data__Key];
}
ASSIGN(_mimeType, [_associations objectForKey: mimeType__Key]);
if (_mimeType != nil) {
[_associations removeObjectForKey: mimeType__Key];
}
ASSIGN(_key, [_associations objectForKey: key__Key]);
if (_key != nil) {
[_associations removeObjectForKey: key__Key];
}
if (_file != nil && _imageMapString != nil && _imageMapRegions != nil) {
[NSException raise:NSInvalidArgumentException
format:@"%s: you can't specify %@, %@ and %@",
__PRETTY_FUNCTION__,
imageMapFileName__Key,
imageMapString__Key,
imageMapRegions__Key];
};
if (_action != nil) {
if (_actionClass != nil || _directActionName != nil || _href != nil) {
[NSException raise:NSInvalidArgumentException
format:@"%s: If 'action' is specified, 'directActionName', 'actionClass', and 'href' must be nil.",
__PRETTY_FUNCTION__];
}
if ([_action isValueConstant]) {
[NSException raise:NSInvalidArgumentException
format:@"%s: 'action' must not be a constant.",
__PRETTY_FUNCTION__];
}
} else {
if (_href != nil) {
if (_actionClass != nil || _directActionName != nil) {
[NSException raise:NSInvalidArgumentException
format:@"%s: If 'directActionName' or 'actionClass' is specified, 'action' and 'href' must be nil.",
__PRETTY_FUNCTION__];
}
} else {
if (_actionClass == nil && _directActionName == nil) {
[NSException raise:NSInvalidArgumentException
format:@"%s: Either a component action or a direct action or 'href' must be specified.",
__PRETTY_FUNCTION__];
}
}
}
if (_filename != nil) {
if (_src != nil || _data != nil || _value != nil) {
[NSException raise:NSInvalidArgumentException
format:@"%s: If 'filename' is specified, 'src', 'data', and 'value' must be nil.",
__PRETTY_FUNCTION__];
}
} else {
if (_framework != nil) {
[NSException raise:NSInvalidArgumentException
format:@"%s: 'framework' should not be specified if 'filename' is nil.",
__PRETTY_FUNCTION__];
}
}
if (_data != nil) {
if (_mimeType == nil) {
[NSException raise:NSInvalidArgumentException
format:@"%s: 'mimeType' must be specified if 'data' is specified.",
__PRETTY_FUNCTION__];
}
if (_src != nil || _value != nil) {
[NSException raise:NSInvalidArgumentException
format:@"%s: If 'data' is specified, 'src', 'filename', and 'value' must be nil.",
__PRETTY_FUNCTION__];
}
} else
if (_value != nil) {
if ([_value isValueConstant]) {
[NSException raise:NSInvalidArgumentException
format:@"%s: 'value' must not be constant.",
__PRETTY_FUNCTION__];
}
if (_src != nil) {
[NSException raise:NSInvalidArgumentException
format:@"%s: If 'value' is specified, 'data', 'filename', and 'src' must be nil.",
__PRETTY_FUNCTION__];
}
} else {
if (_src == nil) {
[NSException raise:NSInvalidArgumentException
format:@"%s: One of 'filename', 'src', 'data', or 'value' must be specified.",
__PRETTY_FUNCTION__];
}
}
if (_xAssoc != nil && _yAssoc != nil) {
if ((![_xAssoc isValueSettable]) || (![_yAssoc isValueSettable])) {
[NSException raise:NSInvalidArgumentException
format:@"%s: 'x' and 'y' can not be constants.",
__PRETTY_FUNCTION__];
}
} else {
if (_xAssoc != nil || _yAssoc != nil) {
[NSException raise:NSInvalidArgumentException
format:@"%s: 'x' and 'y' must both be specified or both be nil.",
__PRETTY_FUNCTION__];
}
}
return self;
};
//--------------------------------------------------------------------
-(void)dealloc
{
DESTROY(_imageMapFileName);
DESTROY(_imageMapString);
DESTROY(_imageMapRegions);
DESTROY(_file);
DESTROY(_action);
DESTROY(_href);
DESTROY(_src);
@ -161,6 +222,12 @@ RCS_ID("$Id$")
DESTROY(_data);
DESTROY(_mimeType);
DESTROY(_key);
DESTROY(_width);
DESTROY(_height);
DESTROY(_secure);
DESTROY(_actionClass);
DESTROY(_directActionName);
[super dealloc];
}
@ -178,10 +245,6 @@ RCS_ID("$Id$")
(void*)self];
};
@end
//====================================================================
@implementation GSWActiveImage (GSWActiveImageA)
-(GSWAssociation*)hitTestX:(int)x
y:(int)y
inRegions:(NSArray*)regions
@ -196,20 +259,13 @@ RCS_ID("$Id$")
assoc=_action;
return assoc;
};
@end
//====================================================================
@implementation GSWActiveImage (GSWActiveImageB)
//--------------------------------------------------------------------
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)aContext
{
LOGObjectFnStart();
//Does nothing
LOGObjectFnStop();
};
}
//--------------------------------------------------------------------
-(GSWElement*)invokeActionForRequest:(GSWRequest*)request
@ -243,7 +299,7 @@ RCS_ID("$Id$")
//TODO
};
GSWContext_deleteLastElementIDComponent(aContext);
disabledInContext=[self disabledInContext:aContext];
disabledInContext=[self disabledInComponent:component];
if (!disabledInContext)
{
isInForm=[aContext isInForm];
@ -295,9 +351,9 @@ RCS_ID("$Id$")
{
GSWAssociation* actionAssociation=nil;
NSArray* regions=nil;
if (_imageMapFileName)
if (_file)
{
id imageMapFileNameValue=[_imageMapFileName valueInComponent:component];
id imageMapFileNameValue=[_file valueInComponent:component];
NSString* imageMapFilePath=[GSWContext_component(aContext)
pathForResourceNamed:imageMapFileNameValue
ofType:nil];
@ -402,218 +458,169 @@ RCS_ID("$Id$")
return element;
};
//--------------------------------------------------------------------
-(void)appendToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
-(void)appendAttributesToResponse:(GSWResponse*) response
inContext:(GSWContext*) context
{
//OK
//GSWRequest* _request=[aContext request];
//Unused now BOOL isFromClientComponent=[_request isFromClientComponent];
BOOL disabledInContext=[self disabledInContext:aContext];
BOOL isInForm=NO;
isInForm=[aContext isInForm]; //TODO
if (isInForm)
{
if (!disabledInContext)
GSWResponse_appendContentAsciiString(aResponse,@"<INPUT ");
else
GSWResponse_appendContentAsciiString(aResponse,@"<IMG ");
}
else
{
if (!disabledInContext)
{
NSString* hrefValue=nil;
GSWResponse_appendContentAsciiString(aResponse,@"<A HREF=\"");
if (_href)
hrefValue=[self hrefInContext:aContext];
else
hrefValue=(NSString*)[aContext componentActionURL];
GSWResponse_appendContentString(aResponse,hrefValue);
GSWResponse_appendContentAsciiString(aResponse,@"\">");
};
GSWResponse_appendContentAsciiString(aResponse,@"<IMG");
};
[super appendToResponse:aResponse
inContext:aContext];
if (!isInForm)
{
if (!disabledInContext)
{
GSWResponse_appendContentAsciiString(aResponse,@"</A>");
};
};
};
NSString * srcValue = nil;
GSWComponent * component = GSWContext_component(context);
GSWResourceManager * resourcemanager = [GSWApp resourceManager];
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response, @"border", @"0", NO);
//--------------------------------------------------------------------
-(NSString*)frameworkNameInContext:(GSWContext*)aContext
[self appendURLAttributesToResponse:response
inContext:context];
if (![self disabledInComponent:component]) {
if ([context isInForm]) {
GSWResponse_appendContentString(response, @" type=image");
} else {
GSWResponse_appendContentCharacter(response,' ');
GSWResponse_appendContentAsciiString(response,@"ismap");
}
}
if (_src != nil) {
srcValue = [_src valueInComponent:component];
}
if (_filename == nil) {
[GSWImage _appendImageSizetoResponse: response
inContext: context
width: _width
height: _height];
}
if (_filename != nil) {
[GSWImage _appendFilenameToResponse: response
inContext: context
framework: _framework
filename: _filename
width: _width
height: _height];
} else
if (_value != nil) {
[context appendZeroElementIDComponent];
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response,
@"src",
[context componentActionURL],
NO);
[context deleteLastElementIDComponent];
} else
if (srcValue != nil) {
if (([srcValue isRelativeURL]) && (! [srcValue isFragmentURL])) {
NSString * url = [context _urlForResourceNamed: srcValue
inFramework: nil];
if (url != nil) {
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response, @"src", url, NO);
} else {
GSWResponse_appendContentAsciiString(response, @" src=\"");
GSWResponse_appendContentAsciiString(response, [component baseURL]);
GSWResponse_appendContentCharacter(response,'/');
GSWResponse_appendContentString(response, srcValue);
GSWResponse_appendContentCharacter(response, '"');
}
} else {
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response, @"src", srcValue, NO);
}
} else {
if (_data != nil && _mimeType != nil) {
[GSWURLValuedElementData _appendDataURLToResponse: response
inContext: context
key: _key
data: _data
mimeType: _mimeType
urlAttributeName: @"src"
inComponent: component];
} else {
NSLog(@"%s: 'src' or 'data' or 'name' attribute evaluated to nil.", __PRETTY_FUNCTION__);
}
}
}
-(void)appendToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
{
//OK
NSString* frameworkName=nil;
GSWComponent* component=GSWContext_component(aContext);
NSDebugMLog(@"_framework=%@",_framework);
if (_framework)
frameworkName=[_framework valueInComponent:component];
else
frameworkName=[component frameworkName];
return frameworkName;
};
GSWComponent * component = GSWContext_component(context);
BOOL isInForm = NO;
if ([self disabledInComponent:component]) {
GSWResponse_appendContentAsciiString(response, @"<img");
} else {
isInForm = [context isInForm];
if (isInForm) {
GSWResponse_appendContentAsciiString(response, @"<input");
} else {
GSWResponse_appendContentAsciiString(response, @"<a");
if (_file == nil && (_actionClass != nil || _directActionName != nil)) {
[self _appendCGIActionURLToResponse: response
inContext: context];
} else {
if (_secure != nil) {
[context _generateCompleteURLs];
}
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response, @"href",
// pass this to _componentActionURL?
// (_secure != nil && [_secure boolValueInComponent: [context component]])
[context _componentActionURL],
NO);
//--------------------------------------------------------------------
//NDFN
-(NSString*)imageSourceInContext:(GSWContext*)aContext
if (_secure != nil) {
[context _generateRelativeURLs];
}
}
[self appendConstantAttributesToResponse:response
inContext:context];
[super _appendNameAttributeToResponse:response
inContext:context];
[self appendNonURLAttributesToResponse:response
inContext:context];
if (_target != nil) {
NSString * targetValue = [_target valueInComponent:component];
if (targetValue != nil) {
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response, @"target", targetValue, YES);
}
}
GSWResponse_appendContentAsciiString(response, @"><img");
[self appendAttributesToResponse:response
inContext:context];
GSWResponse_appendContentAsciiString(response, @"></a>");
return;
}
}
[self appendConstantAttributesToResponse:response
inContext:context];
[super _appendNameAttributeToResponse:response
inContext:context];
[self appendNonURLAttributesToResponse:response
inContext:context];
[self appendAttributesToResponse:response
inContext:context];
GSWResponse_appendContentCharacter(response,'>');
}
-(void) _appendCGIActionURLToResponse:(GSWResponse*) response
inContext:(GSWContext*) context
{
GSWComponent* component=nil;
NSString* imageSource=nil;
component=GSWContext_component(aContext);
imageSource=[_src valueInComponent:component];
return imageSource;
};
//--------------------------------------------------------------------
//NDFN
-(NSString*)hrefInContext:(GSWContext*)aContext
{
GSWComponent* component=nil;
NSString* hrefValue=nil;
component=GSWContext_component(aContext);
hrefValue=[_href valueInComponent:component];
return hrefValue;
};
@end
NSString * actionStr = [self computeActionStringWithActionClassAssociation: _actionClass
directActionNameAssociation: _directActionName
inContext: context];
//====================================================================
@implementation GSWActiveImage (GSWActiveImageC)
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
//OK
NSString* url=nil;
GSWComponent* component=nil;
id data=nil;
id mimeTypeValue=nil;
GSWURLValuedElementData* dataValue=nil;
GSWResourceManager* resourceManager=nil;
BOOL disabledInContext=NO;
BOOL isInForm=NO;
LOGObjectFnStartC("GSWActiveImage");
NSDebugMLLog(@"gswdync",@"elementID=%@",GSWContext_elementID(aContext));
component=GSWContext_component(aContext);
disabledInContext=[self disabledInContext:aContext];
isInForm=[aContext isInForm];
if (_secure != nil) {
[context _generateCompleteURLs];
}
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response, @"href",
// pass this to _componentActionURL?
// (_secure != nil && [_secure boolValueInComponent: [context component]])
[context _componentActionURL],
NO);
if (_secure != nil) {
[context _generateRelativeURLs];
}
}
if (!disabledInContext)
{
if (isInForm)
{
NSString* nameInContext=[self nameInContext:aContext];
GSWResponse_appendContentAsciiString(aResponse,@" type=image");
GSWResponse_appendContentAsciiString(aResponse,@" name=\"");
GSWResponse_appendContentHTMLAttributeValue(aResponse,nameInContext);
GSWResponse_appendContentCharacter(aResponse,'"');
}
else
{
GSWResponse_appendContentAsciiString(aResponse,@" ismap");
};
}
NSDebugMLLog(@"gswdync",@"_data=%@",_data);
NSDebugMLLog(@"gswdync",@"_filename=%@",_filename);
if (_key)
{
NSString* keyValue=[_key valueInComponent:component];
dataValue=[resourceManager _cachedDataForKey:keyValue];
};
if (!dataValue && _data)
{
data=[_data valueInComponent:component];
NSDebugMLLog(@"gswdync",@"data=%@",data);
mimeTypeValue=[_mimeType valueInComponent:component];
NSDebugMLLog(@"gswdync",@"_mimeType=%@",_mimeType);
NSDebugMLLog(@"gswdync",@"mimeTypeValue=%@",mimeTypeValue);
dataValue=[[[GSWURLValuedElementData alloc] initWithData:data
mimeType:mimeTypeValue
key:nil] autorelease];
NSDebugMLLog(@"gswdync",@"dataValue=%@",dataValue);
};
resourceManager=[[GSWApplication application]resourceManager];
if (_key || _data)
{
[resourceManager setURLValuedElementData:dataValue];
}
else if (_filename)
{
id filenameValue=nil;
id frameworkValue=nil;
GSWRequest* aRequest=nil;
NSArray* languages=nil;
NSDebugMLLog(@"gswdync",@"_filename=%@",_filename);
filenameValue=[_filename valueInComponent:component];
NSDebugMLLog(@"gswdync",@"filenameValue=%@",filenameValue);
frameworkValue=[self frameworkNameInContext:aContext];
NSDebugMLLog(@"gswdync",@"frameworkValue=%@",frameworkValue);
aRequest=[aContext request];
languages=[aContext languages];
url=[resourceManager urlForResourceNamed:filenameValue
inFramework:frameworkValue
languages:languages
request:aRequest];
if (!url)
{
LOGSeriousError(@"No URL for resource named: %@ in framework named: %@ for languages: %@",
filenameValue,
frameworkValue,
languages);
};
};
GSWResponse_appendContentAsciiString(aResponse,@" src=\"");
if (_key || _data)
{
[dataValue appendDataURLToResponse:aResponse
inContext:aContext];
}
else if (_filename)
{
GSWResponse_appendContentString(aResponse,url);
}
else if (_src)
{
NSString* srcValue=[self imageSourceInContext:aContext];
GSWResponse_appendContentString(aResponse,srcValue);
}
else
{
GSWDynamicURLString* componentActionURL=[aContext componentActionURL];
NSDebugMLLog(@"gswdync",@"componentActionURL=%@",componentActionURL);
GSWResponse_appendContentString(aResponse,(NSString*)componentActionURL);
};
GSWResponse_appendContentCharacter(aResponse,'"');
NSDebugMLLog(@"gswdync",@"elementID=%@",GSWContext_elementID(aContext));
LOGObjectFnStopC("GSWActiveImage");
};
@end
//====================================================================
@implementation GSWActiveImage (GSWActiveImageD)
//--------------------------------------------------------------------
-(BOOL)appendStringAtRight:(id)unkwnon
withMapping:(char*)mapping
{
LOGObjectFnNotImplemented(); //TODOFN
return NO;
};
//--------------------------------------------------------------------
-(BOOL)appendStringAtLeft:(id)unkwnon
withMapping:(char*)mapping
{
LOGObjectFnNotImplemented(); //TODOFN
return NO;
};
@end

View file

@ -805,11 +805,9 @@ static BOOL _dflt_init_applicationBaseURL = NO;
static NSString *_dflt_applicationBaseURL = nil;
+(NSString*)applicationBaseURL
{
LOGClassFnStart();
INIT_DFLT_OBJ(applicationBaseURL,
INIT_DFLT_OBJ(applicationBaseURL,
GSWOPT_ApplicationBaseURL[GSWebNamingConv]);
NSDebugMLLog(@"application",@"url=%@", _dflt_applicationBaseURL);
LOGClassFnStop();
return _dflt_applicationBaseURL;
};
@ -859,8 +857,7 @@ static BOOL _dflt_init_projectSearchPath = NO;
static NSArray *_dflt_projectSearchPath = nil;
+(NSArray*)projectSearchPath
{
LOGClassFnStart();
INIT_DFLT_OBJ(projectSearchPath,
GSWOPT_ProjectSearchPath);
@ -889,7 +886,6 @@ static NSArray *_dflt_projectSearchPath = nil;
NSDebugMLLog(@"application",@"projectSearchPath:%@",
_dflt_projectSearchPath);
LOGClassFnStop();
return _dflt_projectSearchPath;
};
@ -1148,22 +1144,17 @@ static BOOL _dflt_init_sessionTimeOut = NO;
static NSNumber *_dflt_sessionTimeOut = nil;
+(void)setSessionTimeOut:(NSNumber*)aTimeOut
{
LOGClassFnStart();
NSDebugMLLog(@"sessions",@"aTimeOut=%@",aTimeOut);
ASSIGNCOPY(_dflt_sessionTimeOut, aTimeOut);
_dflt_init_sessionTimeOut = YES;
LOGClassFnStop();
};
//--------------------------------------------------------------------
+(NSNumber*)sessionTimeOut
{
LOGClassFnStart();
INIT_DFLT_OBJ(sessionTimeOut,
INIT_DFLT_OBJ(sessionTimeOut,
GSWOPT_SessionTimeOut[GSWebNamingConv]);
NSDebugMLLog(@"sessions",@"sessionTimeOut=%@",
_dflt_sessionTimeOut);
LOGClassFnStop();
NSLog(@"%s returning %@",__PRETTY_FUNCTION__, _dflt_sessionTimeOut);
return _dflt_sessionTimeOut;
};
@ -1284,20 +1275,16 @@ static BOOL _dflt_init_lifebeatInterval = NO;
static NSTimeInterval _dflt_lifebeatInterval = 0.0;
+(NSTimeInterval)lifebeatInterval
{
LOGClassFnStart();
INIT_DFLT_FLT(lifebeatInterval,
INIT_DFLT_FLT(lifebeatInterval,
GSWOPT_LifebeatInterval[GSWebNamingConv]);
LOGClassFnStop();
return _dflt_lifebeatInterval;
};
//--------------------------------------------------------------------
+(void)setLifebeatInterval:(NSTimeInterval)interval
{
LOGClassFnStart();
_dflt_lifebeatInterval = interval;
_dflt_lifebeatInterval = interval;
_dflt_init_lifebeatInterval = YES;
LOGClassFnStop();
};
//--------------------------------------------------------------------
@ -1481,8 +1468,7 @@ static NSString *_dflt_recordingClassName = nil;
Class recordingClass = Nil;
NSString* recordingClassName = nil;
LOGClassFnStart();
recordingClassName = [self recordingClassName];
if (!recordingClassName)
recordingClassName=GSWClassName_DefaultRecording[GSWebNamingConv];
@ -1491,7 +1477,6 @@ static NSString *_dflt_recordingClassName = nil;
NSAssert1(recordingClass,@"No recording class named '%@'",
recordingClassName);
LOGClassFnStop();
return recordingClass;
};
@ -1500,21 +1485,17 @@ static NSString *_dflt_recordingClassName = nil;
+(void)setSessionTimeOutValue:(NSTimeInterval)aTimeOutValue
{
id number=nil;
LOGClassFnStart();
number = [NSNumber numberWithDouble: aTimeOutValue];
number = [NSNumber numberWithDouble: aTimeOutValue];
NSDebugMLLog(@"sessions",@"aTimeOutValue=%f",aTimeOutValue);
[(GSWAppClassDummy *)self setSessionTimeOut: number];
LOGClassFnStop();
};
//--------------------------------------------------------------------
+(NSTimeInterval)sessionTimeOutValue
{
id sessionTimeOut=nil;
LOGClassFnStart();
sessionTimeOut=[(GSWAppClassDummy *)self sessionTimeOut];
sessionTimeOut=[(GSWAppClassDummy *)self sessionTimeOut];
NSDebugMLLog(@"sessions",@"sessionTimeOut=%@",sessionTimeOut);
LOGClassFnStop();
return [sessionTimeOut doubleValue];
};
@ -1523,18 +1504,14 @@ static BOOL _dflt_init_defaultUndoStackLimit = NO;
static int _dflt_defaultUndoStackLimit = 0;
+(void)setDefaultUndoStackLimit:(int)limit
{
LOGClassFnStart();
_dflt_defaultUndoStackLimit = limit;
_dflt_defaultUndoStackLimit = limit;
_dflt_init_defaultUndoStackLimit = YES;
LOGClassFnStop();
};
+(int)defaultUndoStackLimit
{
LOGClassFnStart();
INIT_DFLT_INT(defaultUndoStackLimit,
INIT_DFLT_INT(defaultUndoStackLimit,
GSWOPT_DefaultUndoStackLimit[GSWebNamingConv]);
LOGClassFnStop();
return _dflt_defaultUndoStackLimit;
};

View file

@ -147,8 +147,8 @@ GSWEB_EXPORT BOOL WOStrictFlag;
-(NSString*)defaultRequestHandlerClassName;
-(Class)defaultRequestHandlerClass;
@end
//====================================================================
//
////====================================================================
@interface GSWApplication (GSWApplicationA)
-(void)becomesMultiThreaded;
@end
@ -169,8 +169,8 @@ GSWEB_EXPORT BOOL WOStrictFlag;
//====================================================================
@interface GSWApplication (GSWApplicationD)
-(GSWComponentDefinition*)componentDefinitionWithName:(NSString*)aName
languages:(NSArray*)languages;
-(GSWComponentDefinition*) _componentDefinitionWithName:(NSString*)aName
languages:(NSArray*)languages;
-(GSWComponentDefinition*)lockedComponentDefinitionWithName:(NSString*)aName
languages:(NSArray*)languages;
-(GSWComponentDefinition*)lockedLoadComponentDefinitionWithName:(NSString*)aName
@ -283,7 +283,6 @@ GSWEB_EXPORT BOOL WOStrictFlag;
-(GSWSession*)_restoreSessionWithID:(NSString*)aSessionID
inContext:(GSWContext*)aContext;
-(void)saveSessionForContext:(GSWContext*)aContext;
-(void)_saveSessionForContext:(GSWContext*)aContext;
@end
//====================================================================
@ -300,8 +299,6 @@ GSWEB_EXPORT BOOL WOStrictFlag;
-(GSWComponent*)pageWithName:(NSString*)aName
inContext:(GSWContext*)aContext;
-(NSString*)defaultPageName;//NDFN
-(GSWComponent*)_pageWithName:(NSString*)aName
inContext:(GSWContext*)aContext;
@end
//====================================================================

File diff suppressed because it is too large Load diff

View file

@ -54,6 +54,9 @@ At runtime, the GNUstepWeb parser scans an HTML template (.html) and it's declar
In the case value= "label", the string value will be a constant string "aLabel".
In the case value = label, the value came from method "label" or member "label" of the component (by valueForKey: mechanism).
In the case value = myMember.label, value came from method "label" or member "label" of the object returned by calling valueForKey:@"myMember" on the component.
NEW FEATURE: negate. add a "!" in front of your key path and the result will be negated.
**/
#ifndef _GSWAssociation_h__
@ -63,36 +66,43 @@ In the case value = myMember.label, value came from method "label" or member "la
@interface GSWAssociation : NSObject <NSCopying>
{
BOOL _debugEnabled;
BOOL _negate; // GSW addon.
NSString* _bindingName;
NSString* _declarationName;
NSString* _declarationType;
};
-(id)valueInComponent:(GSWComponent*)component;
- (BOOL) boolValueInComponent:(GSWComponent*)component;
-(void)setValue:(id)value
inComponent:(GSWComponent*)component;
-(BOOL)isValueConstant;
-(BOOL)isValueSettable;
-(BOOL)isValueSettableInComponent:(GSWComponent*) comp;
-(BOOL)isValueConstantInComponent:(GSWComponent*) comp;
// YES if we negate the result before returnig it.
-(BOOL)negate;
-(void) setNegate:(BOOL) yn;
-(NSString*)description;
-(NSString*)bindingName;
-(NSString*)declarationName;
-(NSString*)declarationType;
@end
//====================================================================
@interface GSWAssociation (GSWAssociationHandlers)
+(void)setClasse:(Class)class
forHandler:(NSString*)handler;
+(void)addLogHandlerClasse:(Class)class;
+(void)removeLogHandlerClasse:(Class)class;
@end
//====================================================================
@interface GSWAssociation (GSWAssociationCreation)
+(GSWAssociation*)associationWithValue:(id)value;
+(GSWAssociation*)associationWithKeyPath:(NSString*)keyPath;
//NDFN
+(GSWAssociation*)associationFromString:(NSString*)string;
@end
/*
//====================================================================
@interface GSWAssociation (GSWAssociationOldFn)
@ -103,14 +113,9 @@ In the case value = myMember.label, value came from method "label" or member "la
@end
*/
//====================================================================
@interface GSWAssociation (GSWAssociationA)
-(BOOL)isImplementedForComponent:(NSObject*)component;
@end
//====================================================================
@interface GSWAssociation (GSWAssociationB)
-(NSString*)keyPath;
-(void)logSynchronizeComponentToParentForValue:(id)value

View file

@ -51,6 +51,8 @@ static NSDictionary* localMinMaxDictionary=nil;
static NSMutableDictionary* associationsHandlerClasses=nil;
static NSLock* associationsLock=nil;
static NSMutableArray* associationsLogsHandlerClasses=nil;
static Class NSNumberClass = Nil;
static Class NSStringClass = Nil;
//====================================================================
@implementation GSWAssociation
@ -60,6 +62,8 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
if (self==[GSWAssociation class])
{
associationsLock=[NSLock new];
NSNumberClass = [NSNumber class];
NSStringClass = [NSString class];
if (!localMinMaxDictionary)
{
@ -106,6 +110,8 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
DESTROY(associationsHandlerClasses);
DESTROY(associationsLogsHandlerClasses);
DESTROY(associationsLock);
[super dealloc];
};
//--------------------------------------------------------------------
@ -115,6 +121,8 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
if ((self=[super init]))
{
};
_negate = NO;
return self;
};
@ -126,6 +134,23 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
[super dealloc];
};
// YES if we negate the result before returnig it.
-(BOOL)negate
{
return _negate;
}
-(void) setNegate:(BOOL) yn
{
_negate = yn;
}
- (BOOL)_hasBindingInParent:(GSWComponent*) parent
{
return YES;
}
//--------------------------------------------------------------------
-(id)copyWithZone:(NSZone*)zone;
{
@ -140,7 +165,6 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
//--------------------------------------------------------------------
-(NSString*)description
{
GSWLogAssertGood(self);
LOGObjectFnNotImplemented(); //TODOFN
return [super description];
};
@ -168,9 +192,7 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
-(BOOL)isValueConstant
{
//OK
[self subclassResponsibility:_cmd];
return NO;
return YES;
};
//--------------------------------------------------------------------
@ -178,10 +200,19 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
- (BOOL)isValueSettable
{
//OK
[self subclassResponsibility:_cmd];
return NO;
};
}
- (BOOL) isValueSettableInComponent:(GSWComponent*) comp
{
return [self isValueSettable];
}
- (BOOL) isValueConstantInComponent:(GSWComponent*) comp
{
return [self isValueConstant];
}
//--------------------------------------------------------------------
// setValue:inComponent:
@ -200,27 +231,83 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
return [self subclassResponsibility:_cmd];
};
// added in WO5?
// they call it booleanValueInComponent:
- (BOOL) boolValueInComponent:(GSWComponent*)component
{
id value = [self valueInComponent: component];
int length = 0;
int intVal = 0;
NSString * tmpStr = nil;
if (! value) {
if (_negate) {
return YES;
}
return NO;
}
if ([value isKindOfClass: NSNumberClass]) {
if (_negate) {
return (! [value boolValue]);
}
return [value boolValue];
}
if ([value isKindOfClass: NSStringClass]) {
length = [value length];
if ((length >= 2) && (length <= 5)) {
tmpStr = [value lowercaseString];
if ([tmpStr isEqual:@"no"] || [tmpStr isEqual:@"false"] || [tmpStr isEqual:@"nil"] || [tmpStr isEqual:@"null"]) {
if (_negate) {
return YES;
}
return NO;
}
}
if ([tmpStr isEqual:@"0"]) {
if (_negate) {
return YES;
}
return NO;
}
if (_negate) {
return NO;
}
return YES;
}
if (_negate) {
return NO;
}
return YES;
}
@end
//====================================================================
@implementation GSWAssociation (GSWAssociationCreation)
//--------------------------------------------------------------------
// associationWithKeyPath:
+(GSWAssociation*)associationWithKeyPath:(NSString*)keyPath
{
//OK
if (keyPath)
{
if ([keyPath hasPrefix:@"^"]
|| (!WOStrictFlag && [keyPath hasPrefix:@"~"]))
return [[[GSWBindingNameAssociation alloc]initWithKeyPath:keyPath] autorelease];
else
return [[[GSWKeyValueAssociation alloc]initWithKeyPath:keyPath] autorelease];
GSWAssociation * newAssoc = nil;
BOOL doNegate = NO;
NSString * newPath = keyPath;
if (newPath) {
doNegate = [newPath hasPrefix:@"!"];
if (doNegate) {
newPath = [newPath stringByDeletingPrefix:@"!"];
}
else
return nil;
if ([newPath hasPrefix:@"^"] || (!WOStrictFlag && [newPath hasPrefix:@"~"])) {
newAssoc = [[[GSWBindingNameAssociation alloc] initWithKeyPath: newPath] autorelease];
} else {
newAssoc = [[[GSWKeyValueAssociation alloc]initWithKeyPath: newPath] autorelease];
}
if (doNegate) {
[newAssoc setNegate:YES]; // default is NO so we may safe a call here
}
return newAssoc;
}
return nil;
};
@ -239,8 +326,7 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
+(GSWAssociation*)associationFromString:(NSString*)string
{
GSWAssociation* assoc=nil;
LOGClassFnStart();
NSDebugMLLog(@"associations",@"string=[%@]",string);
if ([string length]<=0)
assoc=[self associationWithValue:string];
else
@ -249,24 +335,20 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
if ([trimmedString isEqualToString:NSTYES])
{
assoc=[self associationWithValue:GSWNumberYes];
NSDebugMLLog(@"associations",@"assoc=[%@]",assoc);
}
else if ([trimmedString isEqualToString:NSTNO])
{
assoc=[self associationWithValue:GSWNumberNo];
NSDebugMLLog(@"associations",@"assoc=[%@]",assoc);
}
else if ([trimmedString hasPrefix:@"^"])
{
assoc=[self associationWithKeyPath:trimmedString];
NSDebugMLLog(@"associations",@"assoc=[%@]",assoc);
}
else if ([trimmedString hasPrefix:@"\""])
{
if ([trimmedString hasSuffix:@"\""])
{
assoc=[self associationWithValue:[[trimmedString stringByDeletingPrefix:@"\""] stringByDeletingSuffix:@"\""]];
NSDebugMLLog(@"associations",@"assoc=[%@]",assoc);
}
else
{
@ -279,11 +361,10 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
if ([trimmedString hasSuffix:@"\'"])
{
assoc=[self associationWithValue:[[trimmedString stringByDeletingPrefix:@"\'"] stringByDeletingSuffix:@"\'"]];
NSDebugMLLog(@"associations",@"assoc=[%@]",assoc);
}
else
{
ExceptionRaise(@"GSWAssociation",@"String '%@' start with a character ' but doesn't finish with a character '",
ExceptionRaise(@"GSWAssociation",@"String '%@' starts with a \"'\" but does not end with a \"'\"",
trimmedString);
};
}
@ -294,7 +375,6 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
const char* cString=[numberString cString];//TODO
char* endPtr=NULL;
int value=strtol(cString,&endPtr,16);
NSDebugMLLog(@"associations",@"value=[%d]",value);
if (endPtr && *endPtr)
{
ExceptionRaise(@"GSWAssociation",@"String '%@' start with a '#' but doesn't countain an hexadecimal number (on %dth Character)",
@ -306,11 +386,9 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
else
{
NSNumber* limit=[localMinMaxDictionary objectForKey:trimmedString];
NSDebugMLLog(@"associations",@"limit=[%@]",limit);
if (limit)
{
assoc=[self associationWithValue:limit];
NSDebugMLLog(@"associations",@"assoc=[%@]",assoc);
}
else
{
@ -318,12 +396,10 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
NSRange firstCharRange=[trimmedString rangeOfCharacterFromSet:cset
options:0
range:NSMakeRange(0,1)];
NSDebugMLLog(@"associations",@"firstCharRange.length=%d firstCharRange.location=%d ",
firstCharRange.length,firstCharRange.location);
if (firstCharRange.length==0 || firstCharRange.location!=0)
{
assoc=[self associationWithKeyPath:trimmedString];
NSDebugMLLog(@"associations",@"assoc=[%@]",assoc);
}
else
{
@ -331,11 +407,9 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
const char* cString=[trimmedString cString];//TODO
char* endPtr=NULL;
int value=strtol(cString,&endPtr,10);
NSDebugMLLog(@"associations",@"value=[%d]",value);
if (endPtr && *endPtr)
{
NSDebugMLLog(@"associations",@"endPtr=[%s]",endPtr);
NSDebugMLLog(@"associations",@"value=[%d]",value);
ExceptionRaise(@"GSWAssociation",
@"String '%@' must be a good number",
trimmedString);
@ -345,21 +419,13 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
};
};
};
NSDebugMLLog(@"associations",@"assoc=[%@]",assoc);
LOGClassFnStop();
return assoc;
};
@end
//====================================================================
@implementation GSWAssociation (GSWAssociationHandlers)
//--------------------------------------------------------------------
+(void)setClasse:(Class)class
forHandler:(NSString*)handler
{
LOGClassFnStart();
NSDebugMLLog(@"associations",@"class=%@",class);
NSDebugMLLog(@"associations",@"handler=%@",handler);
LoggedLockBeforeDate(associationsLock,GSW_LOCK_LIMIT);
if (!associationsHandlerClasses)
{
@ -372,14 +438,11 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
else if (associationsHandlerClasses)
[associationsHandlerClasses removeObjectForKey:handler];
LoggedUnlock(associationsLock);
LOGClassFnStop();
};
//--------------------------------------------------------------------
+(void)addLogHandlerClasse:(Class)class
{
LOGClassFnStart();
NSDebugMLLog(@"associations",@"class=%@",class);
LoggedLockBeforeDate(associationsLock,GSW_LOCK_LIMIT);
if (!associationsLogsHandlerClasses)
{
@ -389,14 +452,11 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
if (class)
[associationsLogsHandlerClasses addObject:class];
LoggedUnlock(associationsLock);
LOGClassFnStop();
};
//--------------------------------------------------------------------
+(void)removeLogHandlerClasse:(Class)class
{
LOGClassFnStart();
NSDebugMLLog(@"associations",@"class=%@",class);
LoggedLockBeforeDate(associationsLock,GSW_LOCK_LIMIT);
if (associationsHandlerClasses)
{
@ -404,10 +464,8 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
[associationsLogsHandlerClasses removeObject:class];
};
LoggedUnlock(associationsLock);
LOGClassFnStop();
};
@end
/*
//====================================================================
@implementation GSWAssociation (GSWAssociationOldFn)
@ -432,7 +490,6 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
@end
*/
//====================================================================
@implementation GSWAssociation (GSWAssociationA)
//--------------------------------------------------------------------
-(BOOL)isImplementedForComponent:(NSObject*)component
@ -440,10 +497,6 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
return YES;
};
@end
//====================================================================
@implementation GSWAssociation (GSWAssociationB)
//--------------------------------------------------------------------
-(NSString*)keyPath
@ -575,6 +628,7 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
};
//--------------------------------------------------------------------
-(void)setDebugEnabledForBinding:(NSString*)bindingName
declarationName:(NSString*)declarationName
declarationType:(NSString*)declarationType
@ -604,16 +658,11 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
#endif
};
id retValue=nil;
LOGClassFnStart();
NSDebugMLLog(@"associations",@"GSWAssociation: keyPath=%@ object=%p (class: %@. SuperClass=%@)",
keyPath,object,[object class],[object superclass]);
if (keyPath && object && object!=EONullNull)
{
#if HAVE_GDL2
NS_DURING
{
NSDebugMLLog(@"associations",@"GSWAssociation: keyPath=%@ object=%p (class: %@. SuperClass=%@)",
keyPath,object,[object class],[object superclass]);
retValue=[object valueForKeyPath:keyPath];
}
NS_HANDLER
@ -636,8 +685,6 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
// the same as on GDL2
NS_DURING
{
NSDebugMLLog(@"associations",@"GSWAssociation: keyPath=%@ object=%p (class: %@. SuperClass=%@)",
keyPath,object,[object class],[object superclass]);
retValue=[object valueForKeyPath:keyPath];
}
NS_HANDLER
@ -662,19 +709,12 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
Class handlerClass=Nil;
retValue=object;
NSAssert(retValue,@"No Component");
NSDebugMLLog(@"associations",@"GSWAssociation: keyPath=%@ object=%p (class: %@. SuperClass=%@)",
keyPath,object,[object class],[object superclass]);
while(retValue && [keys count]>0)
{
part=[keys objectAtIndex:0];
[keys removeObjectAtIndex:0];
if (retValue)
{
NSDebugMLLog(@"associations",@"object_get_class_name(retValue object)=%s",
object_get_class_name(retValue));
}
NSDebugMLLog(@"associations",@"part=%@",part);
NSDebugMLLog(@"associations",@"part class=%@",NSStringFromClass([part class]));
if ([part hasPrefix:@"\""])
{
part=[part stringByDeletingPrefix:@"\""];
@ -692,9 +732,8 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
part=[part stringByAppendingFormat:@".%@",tmpPart];
}
}
NSDebugMLLog(@"associations",@"part=%@",part);
handlerClass=[associationsHandlerClasses objectForKey:part];
NSDebugMLLog(@"associations",@"_handlerClass=%@",handlerClass);
if (handlerClass)
retValue=[handlerClass processValueInObject:retValue
forHandler:part
@ -707,7 +746,7 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
keyPath);
part=[keys objectAtIndex:0];
[keys removeObjectAtIndex:0];
NSDebugMLLog(@"associations",@"part=%@",part);
class=NSClassFromString(part);
NSAssert3(class>0,@"No class named %@ for handler %@ in %@",
part,
@ -734,9 +773,7 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
else
{
BOOL skipping = NO;
NSDebugMLLog(@"associations",@"call %@ valueForKey:%@",
[retValue class],
part);
NS_DURING
{
retValue=[retValue valueForKey:part];
@ -759,16 +796,7 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
#endif
#endif
};
if (retValue)
{
NSDebugMLLog(@"associations",@"retValue ptr=%p",retValue);
NSDebugMLLog(@"associations",@"retValue=%@",retValue);
}
else
{
NSDebugMLLog(@"associations",@"retValue=nil");
}
LOGClassFnStop();
return retValue;
};
@ -783,18 +811,6 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
id tmpObject = nil;
NSString *tmpKey = nil;
LOGClassFnStart();
NSDebugMLLog(@"associations",@"GSWAssociation: setValue:%@",value);
NSDebugMLLog(@"associations",@"value class:%@",[value class]);
NSDebugMLLog(@"associations",@"value String class:%@",NSStringFromClass([value class]));
NSDebugMLLog(@"associations",@"object String class:%@ superclass=%@",
NSStringFromClass([object class]),
NSStringFromClass([object superclass]));
NSDebugMLLog(@"associations",@"GSWAssociation: keyPath:%@",keyPath);
// NSLog(@"GSWAssociation: setValue:%@ inObject:%@ forKeyPath:%@",value,object,keyPath);
// ... GSWAssociation: setValue:<Color (0x87be648) name=blau nr=1> inObject:<CartListComponent 0x86fa708> forKeyPath:currentCartArticle.color
if (keyPath) {
NSRange r = [keyPath rangeOfString: @"."];
@ -811,8 +827,6 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
tmpObject = [object valueForKey: key];
tmpKey = [keyPath substringFromIndex: NSMaxRange(r)];
}
//NSLog(@"GSWAssociation: tmpKey:%@ tmpObject:%@",tmpKey,tmpObject);
if (tmpObject) //&& [object isKindOfClass:[GSWComponent class]]
{
NSException* exp = [tmpObject validateValue:&value
@ -820,6 +834,7 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
if (exp)
{
NSException* exception=nil;
exception=[NSException exceptionWithName:@"EOValidationException"
reason:[exp reason]
userInfo:[NSDictionary
@ -839,7 +854,6 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
}
}
}
LOGClassFnStop();
}
#else // GDL2 or GDL1
@ -848,14 +862,6 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
inComponent:(GSWComponent*)object
forKeyPath:(NSString*)keyPath
{
LOGClassFnStart();
NSDebugMLLog(@"associations",@"GSWAssociation: setValue:%@",value);
NSDebugMLLog(@"associations",@"value class:%@",[value class]);
NSDebugMLLog(@"associations",@"value String class:%@",NSStringFromClass([value class]));
NSDebugMLLog(@"associations",@"object String class:%@ superclass=%@",
NSStringFromClass([object class]),
NSStringFromClass([object superclass]));
NSDebugMLLog(@"associations",@"GSWAssociation: keyPath:%@",keyPath);
if ([keyPath length]==0)
{
[NSException raise:NSInvalidArgumentException
@ -876,8 +882,7 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
{
part=[keys objectAtIndex:0];
[keys removeObjectAtIndex:0];
NSDebugMLLog(@"associations",@"part=%@",part);
NSDebugMLLog(@"associations",@"part class=%@",NSStringFromClass([part class]));
if ([part hasPrefix:@"\""])
{
part=[part stringByDeletingPrefix:@"\""];
@ -895,10 +900,9 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
part=[part stringByAppendingFormat:@".%@",tmpPart];
}
}
NSDebugMLLog(@"associations",@"part=%@",part);
handlerClass=[associationsHandlerClasses objectForKey:part];
NSDebugMLLog(@"associations",@"handlerClass=%@",handlerClass);
if (handlerClass)
{
tmpObject=[handlerClass processSetValue:value
@ -918,7 +922,6 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
keyPath);
part=[keys objectAtIndex:0];
[keys removeObjectAtIndex:0];
NSDebugMLLog(@"associations",@"part=%@",part);
class=NSClassFromString(part);
NSAssert3(class>0,@"No class named %@ for handler %@ in %@",
part,
@ -940,8 +943,6 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
[tmpObject takeValue:value
forKey:part];
#ifdef HAVE_GDL2
NSDebugMLLog(@"associations",@"object class=%@",[object class]);
NSDebugMLLog(@"associations",@"tmpObject class=%@",[tmpObject class]);
// Turbocat
if (tmpObject && [tmpObject isKindOfClass:[GSWComponent class]])
{
@ -968,7 +969,6 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
};
};
#endif
LOGClassFnStop();
};
#endif
@ -995,17 +995,14 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
NSEnumerator* enumerator=nil;
id key=nil;
id association=nil;
LOGObjectFnStart();
enumerator = [self keyEnumerator];
while ((key = [enumerator nextObject]))
{
NSDebugMLLog(@"associations",@"key=%@",key);
association=[self objectForKey:key];
[association setDebugEnabledForBinding:@""
declarationName:key
declarationType:@""]; //TODO
};
LOGObjectFnStop();
};
-(void)associationsSetValuesFromObject:(id)from
@ -1015,34 +1012,21 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
id key=nil;
id varValue=nil;
id var=nil;
LOGObjectFnStart();
NSDebugMLLog(@"associations",@"from=%@",from);
NSDebugMLLog(@"associations",@"to=%@",to);
enumerator = [self keyEnumerator];
while ((key = [enumerator nextObject]))
{
NSDebugMLLog(@"associations",@"key=%@",key);
/* NSAssert2([key isKindOfClass:[GSWAssociation class]],
@"key is not an GSWAssociation but a %@: %@",
[key class],
key);*/
var=[self objectForKey:key];
NSDebugMLLog(@"associations",@"var=%@",var);
/* NSAssert2([var isKindOfClass:[GSWAssociation class]],
@"Variable is not an GSWAssociation but a %@: %@",
[var class],
var);*/
if ([var isKindOfClass:[GSWAssociation class]])
varValue=[var valueInComponent:from];
else
varValue=var;
NSDebugMLLog(@"associations",@"varValue=%@",varValue);
if (![key isKindOfClass:[GSWAssociation class]])
key=[GSWAssociation associationWithKeyPath:key];
[key setValue:varValue
inComponent:to];
};
LOGObjectFnStop();
};
//--------------------------------------------------------------------
@ -1055,27 +1039,23 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
id varKey=nil;
id varKeyAssociation=nil;
id value=nil;
LOGObjectFnStart();
newAssociation=(NSMutableDictionary*)[NSMutableDictionary dictionary];
enumerator = [self keyEnumerator];
while ((key = [enumerator nextObject]))
{
NSDebugMLLog(@"associations",@"key=%@",key);
if ([key hasPrefix:prefix])
{
value=[self objectForKey:key];
NSDebugMLLog(@"associations",@"value=%@",value);
varKey=[key stringByDeletingPrefix:prefix];
NSDebugMLLog(@"associations",@"varKey=%@",varKey);
varKeyAssociation=[GSWAssociation associationWithKeyPath:varKey];
NSDebugMLLog(@"associations",@"varKeyAssociation=%@",varKeyAssociation);
[newAssociation setObject:value
forKey:varKeyAssociation];
[removeFrom removeObjectForKey:key];
};
};
newAssociation=[NSDictionary dictionaryWithDictionary:newAssociation];
LOGObjectFnStop();
return newAssociation;
};
@ -1090,7 +1070,6 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
while ((key=[enumerator nextObject]))
{
value=[self objectForKey:key];
NSDebugMLog(@"key=%@ value=%@",key,value);
if ([value isKindOfClass:[NSString class]])
{
newValue=[GSWAssociation associationFromString:value];
@ -1128,7 +1107,6 @@ static NSMutableArray* associationsLogsHandlerClasses=nil;
for(i=0;i<count;i++)
{
value=[self objectAtIndex:i];
NSDebugMLog(@"i=%d value=%@",i,value);
if ([value isKindOfClass:[NSString class]])
{
newValue=[GSWAssociation associationFromString:value];

View file

@ -37,9 +37,6 @@
{
NSString* _parentBindingName;
NSString* _keyPath;
//GSWeb Additions {
BOOL _isNonMandatory;
// }
};
-(id)initWithKeyPath:(NSString*)keyPath;

View file

@ -40,11 +40,10 @@ RCS_ID("$Id$")
-(id)initWithKeyPath:(NSString*)aKeyPath
{
//OK
LOGObjectFnStart();
if ((self=[super init]))
{
NSArray* keys=nil;
NSDebugMLLog(@"associations",@"aKeyPath=%@",aKeyPath);
keys=[aKeyPath componentsSeparatedByString:@"."];
if ([keys count]>0)
{
@ -55,17 +54,14 @@ RCS_ID("$Id$")
else if (!WOStrictFlag && [aKeyPath hasPrefix:@"~"])
{
ASSIGNCOPY(_parentBindingName,[[keys objectAtIndex:0] stringByDeletingPrefix:@"~"]);
_isNonMandatory=YES;
};
if ([keys count]>1)
{
ASSIGN(_keyPath,[[keys subarrayWithRange:NSMakeRange(1,[keys count]-1)]componentsJoinedByString:@"."]);
};
};
NSDebugMLLog(@"associations",@"parentBindingName=%@",_parentBindingName);
NSDebugMLLog(@"associations",@"keyPath=%@",_keyPath);
};
LOGObjectFnStop();
return self;
};
@ -77,23 +73,28 @@ RCS_ID("$Id$")
[super dealloc];
};
- (BOOL) _hasBindingInParent:(GSWComponent *) component
{
return [component hasBinding:_parentBindingName];
}
//--------------------------------------------------------------------
-(id)copyWithZone:(NSZone*)zone;
{
GSWBindingNameAssociation* clone = [super copyWithZone:zone];
ASSIGN(clone->_parentBindingName,_parentBindingName);
ASSIGN(clone->_keyPath,_keyPath);
_isNonMandatory=_isNonMandatory;
return clone;
};
//--------------------------------------------------------------------
-(NSString*)description
{
return [NSString stringWithFormat:@"<%s %p - parentBindingName=%@ keyPath=%@>",
return [NSString stringWithFormat:@"<%s %p - parentBindingName=%@ negate:%d keyPath=%@>",
object_get_class_name(self),
(void*)self,
_parentBindingName,
_negate,
_keyPath];
};
@ -101,9 +102,8 @@ RCS_ID("$Id$")
-(BOOL)isImplementedForComponent:(GSWComponent*)object
{
BOOL isImplemented=NO;
LOGObjectFnStart();
isImplemented=(BOOL)[object hasBinding:_parentBindingName];
LOGObjectFnStop();
return isImplemented;
};
@ -111,10 +111,7 @@ RCS_ID("$Id$")
-(id)valueInComponent:(GSWComponent*)object
{
id value=nil;
LOGObjectFnStart();
NSDebugMLLog(@"associations",@"parentBindingName=%@",_parentBindingName);
NSDebugMLLog(@"associations",@"keyPath=%@",_keyPath);
NSDebugMLLog(@"associations",@"object=%@",object);
if (object)
{
/*
@ -131,17 +128,15 @@ RCS_ID("$Id$")
};
*/
value=[object valueForBinding:_parentBindingName];
NSDebugMLLog(@"associations",@"value=%@",value);
if (value && _keyPath)
{
value=[GSWAssociation valueInComponent:value
forKeyPath:_keyPath];
NSDebugMLLog(@"associations",@"value=%@",value);
};
};
NSDebugMLLog(@"associations",@"value=%@",value);
[self logTakeValue:value];
LOGObjectFnStop();
return value;
};
@ -149,9 +144,6 @@ RCS_ID("$Id$")
-(void)setValue:(id)value
inComponent:(GSWComponent*)object
{
LOGObjectFnStart();
NSDebugMLLog(@"associations",@"parentBindingName=%@",_parentBindingName);
NSDebugMLLog(@"associations",@"keyPath=%@",_keyPath);
if (object)
{
[object validateValue:&value
@ -181,7 +173,6 @@ RCS_ID("$Id$")
forBinding:_parentBindingName];
};
[self logSetValue:value];
LOGObjectFnStop();
};
//--------------------------------------------------------------------

View file

@ -37,57 +37,15 @@
{
GSWAssociation* _list;
GSWAssociation* _item;
//GSWeb Additions {
GSWAssociation* _index;
// }
GSWAssociation* _displayString;
GSWAssociation* _selections;
//GSWeb Additions {
GSWAssociation* _selectionValues;
// }
GSWAssociation* _selectedValues;
GSWAssociation* _size;
GSWAssociation* _multiple;
GSWAssociation* _escapeHTML;
BOOL _autoValue;//??
BOOL _loggedSlow;
};
-(void)dealloc;
-(id)initWithName:(NSString*)name
associations:(NSDictionary*)associations
contentElements:(NSArray*)elements;
-(NSString*)description;
-(NSString*)elementName;
@end
@interface GSWBrowser (GSWBrowserA)
-(void)appendToResponse:(GSWResponse*)response
inContext:(GSWContext*)context;
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context;
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context;
-(void)_slowTakeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context;
-(void)_fastTakeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context;
@end
@interface GSWBrowser (GSWBrowserB)
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)response
inContext:(GSWContext*)context;
-(void)appendValueToResponse:(GSWResponse*)response
inContext:(GSWContext*)context;
@end
@interface GSWBrowser (GSWBrowserC)
-(BOOL)appendStringAtRight:(id)unkwnon
withMapping:(char*)mapping;
@end
#endif //_GSWBrowser_h__

View file

@ -2,8 +2,8 @@
Copyright (C) 1999-2003 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Jan 1999
Written by: David Wetzel <dave@turbocat.de>
Date: Oct 2006
$Revision$
$Date$
@ -81,125 +81,96 @@ static SEL valueInComponentSEL = NULL;
};
//--------------------------------------------------------------------
-(id)initWithName:(NSString*)aName
associations:(NSDictionary*)associations
contentElements:(NSArray*)elements
{
//OK
NSMutableDictionary* tmpAssociations=nil;
LOGObjectFnStartC("GSWBrowser");
NSDebugMLLog(@"gswdync",@"aName=%@ associations:%@ elements=%@",
aName,associations,elements);
tmpAssociations=[NSMutableDictionary dictionaryWithDictionary:associations];
[tmpAssociations removeObjectForKey:list__Key];
[tmpAssociations removeObjectForKey:item__Key];
if (!WOStrictFlag)
{
[tmpAssociations removeObjectForKey:index__Key];
};
[tmpAssociations removeObjectForKey:displayString__Key];
[tmpAssociations removeObjectForKey:selections__Key];
if (!WOStrictFlag)
[tmpAssociations removeObjectForKey:selectionValues__Key];
[tmpAssociations removeObjectForKey:selectedValues__Key];
[tmpAssociations removeObjectForKey:size__Key];
[tmpAssociations removeObjectForKey:multiple__Key];
[tmpAssociations removeObjectForKey:escapeHTML__Key];
template:(GSWElement*)template
{
self = [super initWithName:@"select" associations:associations template: template];
if (!self) {
return nil;
}
if ((self=[super initWithName:aName
associations:tmpAssociations
contentElements:nil]))
{
_list=[[associations objectForKey:list__Key
withDefaultObject:[_list autorelease]] retain];
_loggedSlow = NO;
_item=[[associations objectForKey:item__Key
withDefaultObject:[_item autorelease]] retain];
if (_item && ![_item isValueSettable])
{
ExceptionRaise0(@"GSWBrowser",@"'item' parameter must be settable");
};
ASSIGN(_list, [_associations objectForKey: list__Key]);
if (_list != nil) {
[_associations removeObjectForKey: list__Key];
}
ASSIGN(_item, [_associations objectForKey: item__Key]);
if (_item != nil) {
[_associations removeObjectForKey: item__Key];
}
ASSIGN(_displayString, [_associations objectForKey: displayString__Key]);
if (_displayString != nil) {
[_associations removeObjectForKey: displayString__Key];
}
ASSIGN(_selections, [_associations objectForKey: selections__Key]);
if (_selections != nil) {
[_associations removeObjectForKey: selections__Key];
}
ASSIGN(_multiple, [_associations objectForKey: multiple__Key]);
if (_multiple != nil) {
[_associations removeObjectForKey: multiple__Key];
}
ASSIGN(_size, [_associations objectForKey: size__Key]);
if (_size != nil) {
[_associations removeObjectForKey: size__Key];
}
ASSIGN(_selectedValues, [_associations objectForKey: selectedValues__Key]);
if (_selectedValues != nil) {
[_associations removeObjectForKey: selectedValues__Key];
}
ASSIGN(_escapeHTML, [_associations objectForKey: escapeHTML__Key]);
if (_escapeHTML != nil) {
[_associations removeObjectForKey: escapeHTML__Key];
}
if ((_list == nil) || (_value != nil || _displayString != nil) &&
((_item == nil) || (![_item isValueSettable])) ||
((_selections != nil) && (![_selections isValueSettable]))) {
if (!WOStrictFlag)
{
_index = [[associations objectForKey:index__Key
withDefaultObject:[_index autorelease]] retain];
NSDebugMLLog(@"gswdync",@"index=%@",_index);
if (_index && ![_index isValueSettable])
{
ExceptionRaise0(@"GSWBrowser",@"'index' parameter must be settable");
};
};
_displayString=[[associations objectForKey:displayString__Key
withDefaultObject:[_displayString autorelease]] retain];
_selections=[[associations objectForKey:selections__Key
withDefaultObject:[_selections autorelease]] retain];
if (_selections && ![_selections isValueSettable])
{
ExceptionRaise0(@"GSWBrowser",@"'selections' parameter must be settable");
};
if (!WOStrictFlag)
{
_selectionValues=[[associations objectForKey:selectionValues__Key
withDefaultObject:[_selectionValues autorelease]] retain];
if (_selectionValues && ![_selectionValues isValueSettable])
{
ExceptionRaise0(@"GSWBrowser",@"'selectionValues' parameter must be settable");
};
};
_selectedValues=[[associations objectForKey:selectedValues__Key
withDefaultObject:[_selectedValues autorelease]] retain];
_size=[[associations objectForKey:size__Key
withDefaultObject:[_size autorelease]] retain];
_multiple=[[associations objectForKey:multiple__Key
withDefaultObject:[_multiple autorelease]] retain];
_escapeHTML=[[associations objectForKey:escapeHTML__Key
withDefaultObject:[_escapeHTML autorelease]] retain];
};
LOGObjectFnStopC("GSWBrowser");
[NSException raise:NSInvalidArgumentException
format:@"%s: 'list' must be present. 'item' must not be a constant if 'value' is present. Cannot have 'displayString' or 'value' without 'item'. 'selection' must not be a constant if present.",
__PRETTY_FUNCTION__];
}
if ((_selections != nil) && (_selectedValues != nil)) {
[NSException raise:NSInvalidArgumentException
format:@"%s: Cannot have both selections and selectedValues.",
__PRETTY_FUNCTION__];
}
return self;
};
}
//--------------------------------------------------------------------
-(void)dealloc
{
DESTROY(_list);
DESTROY(_item);
DESTROY(_index);
DESTROY(_displayString);
DESTROY(_selections);
DESTROY(_selectionValues);
DESTROY(_selectedValues);
DESTROY(_size);
DESTROY(_multiple);
DESTROY(_escapeHTML);
[super dealloc];
};
//--------------------------------------------------------------------
-(NSString*)description
-(id) description
{
return [NSString stringWithFormat:@"<%s %p>",
return [NSString stringWithFormat:@"<%s %p list:%@ item:%@ displayString:%@ selections:%@ selectedValues:%@ multiple:%@ size:%@ escapeHTML:%@>",
object_get_class_name(self),
(void*)self];
(void*)self,
_list, _item, _displayString, _selections, _selectedValues, _multiple,
_size, _escapeHTML];
};
//--------------------------------------------------------------------
-(NSString*)elementName
{
return @"SELECT";
};
@end
//====================================================================
@implementation GSWBrowser (GSWBrowserA)
/*
On WO it looks like that when value is not binded:
On WO it looks like that when value is not bound:
<SELECT name="4.2.7" size=5 multiple>
<OPTION value="0">blau</OPTION>
@ -211,453 +182,262 @@ static SEL valueInComponentSEL = NULL;
<OPTION value="6">weiss</OPTION></SELECT>
*/
-(void)appendToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
-(void) appendChildrenToResponse:(GSWResponse *) response
inContext:(GSWContext*) context
{
//OK
GSWRequest* request=nil;
BOOL isFromClientComponent=NO;
GSWComponent* component=nil;
NSArray* listValue=nil;
id selectionsValue=nil;
id selectedValuesValue=nil;
id valueValue=nil;
id itemValue=nil;
id displayStringValue=nil;
BOOL escapeHTMLBoolValue=YES;
id escapeHTMLValue=nil;
int i=0;
BOOL inOptGroup=NO;
int listValueCount=0;
#ifndef ENABLE_OPTGROUP
BOOL optGroupLabel=NO;
#endif
LOGObjectFnStartC("GSWBrowser");
NSArray * valueArray = nil;
NSArray * selectionsArray = nil;
int listCount = 0;
id obj = nil;
BOOL isSelected = NO;
id compoValue = nil;
int i = 0;
NSString * valueValue = nil;
NSString * s1 = nil;
id arrayObj = nil;
GSWComponent * component = GSWContext_component(context);
BOOL doEscape = YES;
if (_escapeHTML != nil) {
doEscape = [_escapeHTML boolValueInComponent:component];
}
compoValue = [_list valueInComponent:component];
if (compoValue != nil) {
if ([compoValue isKindOfClass:[NSArray class]]) {
valueArray = compoValue;
listCount = [valueArray count];
} else {
[NSException raise:NSInvalidArgumentException
format:@"%s: Evaluating 'list' binding returned a '%@' class and not a NSArray.",
__PRETTY_FUNCTION__, [compoValue class]];
}
}
request=[aContext request];
isFromClientComponent=[request isFromClientComponent];
component=GSWContext_component(aContext);
if (_selections != nil) {
selectionsArray = [_selections valueInComponent:component];
} else {
if (_selectedValues != nil) {
selectionsArray = [_selectedValues valueInComponent:component];
}
}
[super appendToResponse:aResponse
inContext:aContext];
for (i = 0; i < listCount; i++) {
valueValue = nil;
s1 = nil;
arrayObj = nil;
if (valueArray != nil) {
arrayObj = [valueArray objectAtIndex:i];
}
if ((_displayString != nil) || (_value != nil)) {
[_item setValue:arrayObj inComponent:component];
if (_displayString != nil) {
id obj5 = [_displayString valueInComponent:component];
if (obj5 != nil) {
s1 = obj5; // stringValue??
if (_value != nil) {
id obj7 = [_value valueInComponent:component];
if (obj7 != nil) {
valueValue = obj7; // stringValue?
}
} else {
valueValue = s1;
}
}
} else {
id obj6 = [_value valueInComponent:component];
if (obj6 != nil) {
valueValue = obj6; // stringValue?
s1 = valueValue;
}
}
} else {
s1 = arrayObj; // stringValue?
valueValue = s1;
}
GSWResponse_appendContentAsciiString(response,@"\n<option");
if (selectionsArray != nil) {
isSelected = (arrayObj == nil) ? NO : [selectionsArray containsObject:arrayObj];
} else {
if (_value != nil) {
isSelected = compoValue == nil ? NO : [compoValue isEqual: valueValue];
} else {
isSelected = [GSWIntToNSString(i) isEqual:compoValue];
}
}
if (isSelected) {
GSWResponse_appendContentCharacter(response,' ');
GSWResponse_appendContentAsciiString(response,@"selected");
}
if (_value != nil) {
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response, value__Key, valueValue, YES);
} else {
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response, value__Key, GSWIntToNSString(i), NO);
}
GSWResponse_appendContentCharacter(response,'>');
if (doEscape) {
GSWResponse_appendContentHTMLConvertString(response, s1);
} else {
GSWResponse_appendContentString(response, s1);
}
GSWResponse_appendContentAsciiString(response,@"</option>");
}
listValue=[_list valueInComponent:component];
NSDebugMLLog(@"gswdync",@"listValue=%@",listValue);
NSAssert3(!listValue || [listValue respondsToSelector:@selector(count)],
@"The list (%@) (%@ of class:%@) doesn't respond to 'count'",
_list,
listValue,
[listValue class]);
}
selectionsValue=[_selections valueInComponent:component];
NSDebugMLLog(@"gswdync",@"selections=%@",_selections);
NSDebugMLLog(@"gswdync",@"selectionsValue=%@",selectionsValue);
selectedValuesValue=[_selectedValues valueInComponent:component];
NSDebugMLLog(@"gswdync",@"selectedValues=%@",_selectedValues);
NSDebugMLLog(@"gswdync",@"selectedValuesValue=%@",selectedValuesValue);
-(void) _appendValueAttributeToResponse:(GSWResponse *) response
inContext:(GSWContext*) context
{
}
if (_escapeHTML)
{
escapeHTMLValue=[_escapeHTML valueInComponent:component];
escapeHTMLBoolValue=boolValueFor(escapeHTMLValue);
};
-(void) appendAttributesToResponse:(GSWResponse *) response
inContext:(GSWContext*) context
{
id sizeValue = nil;
int sizeInt = 5;
GSWComponent * component = GSWContext_component(context);
listValueCount=[listValue count];
[super appendAttributesToResponse:response
inContext:context];
if (listValueCount>0)
{
IMP listOAIIMP=[listValue methodForSelector:objectAtIndexSEL];
IMP itemSetValueIMP=[_item methodForSelector:setValueInComponentSEL];
IMP indexSetValueIMP=[_index methodForSelector:setValueInComponentSEL];
IMP valueValueIMP=[_value methodForSelector:valueInComponentSEL];
IMP displayStringValueIMP=[_displayString methodForSelector:valueInComponentSEL];
for(i=0;i<listValueCount;i++)
{
NSDebugMLLog(@"gswdync",@"inOptGroup=%s",(inOptGroup ? "YES" : "NO"));
if (_size != nil) {
sizeValue = [_size valueInComponent:component];
sizeInt = [sizeValue intValue];
sizeValue = GSWIntToNSString(sizeInt);
}
itemValue=(*listOAIIMP)(listValue,objectAtIndexSEL,i);
if (_size == nil || sizeValue == nil || (sizeInt < 2)) {
sizeValue = GSWIntToNSString(5);
}
if (_item)
(*itemSetValueIMP)(_item,setValueInComponentSEL,
itemValue,component);
NSDebugMLLog(@"gswdync",@"itemValue=%@",itemValue);
if (_index)
(*indexSetValueIMP)(_index,setValueInComponentSEL,
GSWIntNumber(i),component);
if (itemValue)
{
NSDebugMLLog(@"gswdync",@"_value (class: %@): %@",[_value class],_value);
// Value property of the INPUT tag
if (_value) // Binded Value
valueValue = (*valueValueIMP)(_value,valueInComponentSEL,component);
else // Auto Value
valueValue = GSWIntNumber(i);
NSDebugMLLog(@"gswdync",@"valueValue=%@",valueValue);
if (valueValue)
{
BOOL isEqual=NO;
NSDebugMLLog0(@"gswdync",@"Adding OPTION");
GSWResponse_appendContentAsciiString(aResponse,@"\n<OPTION");
NSDebugMLLog(@"gswdync",@"selectionsValue=%@",selectionsValue);
NSDebugMLLog(@"gswdync",@"selectionsValue classes=%@",[selectionsValue valueForKey:@"class"]);
NSDebugMLLog(@"gswdync",@"itemValue=%@",itemValue);
NSDebugMLLog(@"gswdync",@"itemValue class=%@",[itemValue class]);
if (selectionsValue)
{
isEqual = [selectionsValue containsObject:itemValue];
};
if (isEqual == NO && _selectedValues)
{
// selected values is selections but on valueValue not itemValue
isEqual = [selectionsValue containsObject:valueValue];
};
if (isEqual)
{
GSWResponse_appendContentCharacter(aResponse,' ');
GSWResponse_appendContentAsciiString(aResponse,@"selected");
};
GSWResponse_appendContentAsciiString(aResponse,@" value=\"");
GSWResponse_appendContentHTMLAttributeValue(aResponse,valueValue);
GSWResponse_appendContentCharacter(aResponse,'"');
GSWResponse_appendContentCharacter(aResponse,'>');
};
displayStringValue=nil;
if (_displayString)
{
NSDebugMLLog(@"gswdync",@"displayString=%@",_displayString);
displayStringValue=(*displayStringValueIMP)(_displayString,
valueInComponentSEL,component);
NSDebugMLLog(@"gswdync",@"displayStringValue=%@",displayStringValue);
};
if (displayStringValue)
{
if (!valueValue)
{
if (inOptGroup)
{
NSDebugMLLog0(@"gswdync",@"Adding /OPTGROUP");
#ifdef ENABLE_OPTGROUP
GSWResponse_appendContentAsciiString(aResponse,@"\n</OPTGROUP>");
#endif
inOptGroup=NO;
};
NSDebugMLLog0(@"gswdync",@"Adding OPTGROUP");
#ifdef ENABLE_OPTGROUP
GSWResponse_appendContentAsciiString(aResponse,@"\n<OPTGROUP label=\"");
#else
#if 0
GSWResponse_appendContentAsciiString(aResponse,@"\n<OPTION>-- ");
optGroupLabel=YES;
#else
GSWResponse_appendContentAsciiString(aResponse,@"\n<OPTION>");
#endif
optGroupLabel=YES;
#endif
inOptGroup=YES;
};
//<OPTGROUP label="PortMaster 3">
#ifndef ENABLE_OPTGROUP
if (optGroupLabel)
{
displayStringValue=[displayStringValue stringByAppendingString:@" --"];
};
#endif
if (escapeHTMLBoolValue)
GSWResponse_appendContentHTMLString(aResponse,displayStringValue);
else
GSWResponse_appendContentString(aResponse,displayStringValue);
};
if (valueValue)
{
// K2- No /OPTION TAG
//GSWResponse_appendContentAsciiString(aResponse,@"</OPTION>");
}
else
{
NSDebugMLLog0(@"gswdync",@"Adding > or </OPTION>");
#ifdef ENABLE_OPTGROUP
GSWResponse_appendContentAsciiString(aResponse,@"\">");
#else
if (optGroupLabel)
{
//GSWResponse_appendContentAsciiString(aResponse,@"</OPTION>");
optGroupLabel=NO;
};
#endif
};
};
};
};
if (inOptGroup)
{
#ifdef ENABLE_OPTGROUP
NSDebugMLLog0(@"gswdync",@"Adding /OPTGROUP");
GSWResponse_appendContentAsciiString(aResponse,@"\n</OPTGROUP>");
#endif
inOptGroup=NO;
};
GSWResponse_appendContentAsciiString(aResponse,@"</SELECT>");
LOGObjectFnStopC("GSWBrowser");
};
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response, size__Key, sizeValue, NO);
//--------------------------------------------------------------------
if (_multiple != nil && ([_multiple boolValueInComponent:component])) {
GSWResponse_appendContentCharacter(response,' ');
GSWResponse_appendContentAsciiString(response,@"multiple");
}
}
- (void)_slowTakeValuesFromRequest:(GSWRequest*) request
inContext:(GSWContext*) context
{
GSWComponent * component = GSWContext_component(context);
if ((_selections != nil) && (![self disabledInComponent:component]) && ([context _wasFormSubmitted])) {
NSString * ctxName = [self nameInContext:context];
NSArray * formValues = [request formValuesForKey: ctxName];
NSArray * listValue = nil;
BOOL multipe = NO;
int count = 0;
NSMutableArray * mutArray = [NSMutableArray array];
if (formValues != nil) {
int i = 0;
count = [formValues count];
if (count) {
if (_multiple != nil) {
multipe = [_multiple boolValueInComponent:component];
}
if (_list != nil) {
listValue = [_list valueInComponent:component];
if ([listValue isKindOfClass:[NSArray class]] == NO) {
[NSException raise:NSInvalidArgumentException
format:@"%s: Evaluating 'list' binding returned a '%@' class and not a NSArray.",
__PRETTY_FUNCTION__, [listValue class]];
}
for (i = 0; i < count; i++) {
id valueValue = nil;
id obj1 = [listValue objectAtIndex:i];
[_item setValue:obj1 inComponent: component];
valueValue = [_value valueInComponent:component];
if (valueValue != nil) {
if (![formValues containsObject:NSStringWithObject(valueValue)]) {
continue;
}
[mutArray addObject:obj1];
if (!multipe) {
break;
}
} else {
NSLog(@"%s: 'value' evaluated to null in component %@, %@",
__PRETTY_FUNCTION__, component, self);
}
} // for
} // _list != nil
}
}
[_selections setValue:mutArray inComponent: component];
}
}
- (void) _fastTakeValuesFromRequest:(GSWRequest*) request
inContext:(GSWContext*) context
{
GSWComponent * component = GSWContext_component(context);
if ((_selections != nil) && (![self disabledInComponent:component]) && ([context _wasFormSubmitted])) {
NSString * ctxName = [self nameInContext:context];
NSArray * formValues = [request formValuesForKey: ctxName];
NSArray * listValue = nil;
int count = 0;
int i = 0;
NSMutableArray * mutArray = nil;
NSArray * selectionsValue = nil;
if (formValues != nil) {
count = [formValues count];
mutArray = [NSMutableArray arrayWithCapacity:count];
if ((_list != nil) && (count > 0)) {
listValue = [_list valueInComponent:component];
if ([listValue isKindOfClass:[NSArray class]] == NO) {
[NSException raise:NSInvalidArgumentException
format:@"%s: Evaluating 'list' binding returned a '%@' class and not a NSArray.",
__PRETTY_FUNCTION__, [listValue class]];
}
}
for (i = 0; i < count; i++) {
id s1 = (NSString*) [formValues objectAtIndex:i];
int k = [s1 intValue];
id obj1 = nil;
if (listValue != nil) {
id valueValue = [listValue objectAtIndex:k];
[mutArray addObject:valueValue];
}
}
[_selections setValue:mutArray inComponent: component];
}
}
}
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)aContext
inContext:(GSWContext*)context
{
//OK
LOGObjectFnStartC("GSWPopUpButton");
[self _slowTakeValuesFromRequest:request
inContext:aContext];
LOGObjectFnStopC("GSWPopUpButton");
};
//--------------------------------------------------------------------
-(void)_slowTakeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)aContext
{
//OK
BOOL disabledValue=NO;
LOGObjectFnStartC("GSWPopUpButton");
disabledValue=[self disabledInContext:aContext];
if (!disabledValue)
{
BOOL wasFormSubmitted=[aContext _wasFormSubmitted];
if (wasFormSubmitted)
{
BOOL isMultiple=NO;
NSMutableArray* selectionsValue=nil;
NSMutableArray* selectionValuesValue=nil;
GSWComponent* component=nil;
NSArray* listValue=nil;
id valueValue=nil;
NSString* valueValueString=nil;
id itemValue=nil;
NSString* name=nil;
NSArray* formValues=nil;
component=GSWContext_component(aContext);
name=[self nameInContext:aContext];
NSDebugMLLog(@"gswdync",@"name=%@",name);
if (_multiple)
{
id multipleValue=[_multiple valueInComponent:component];
isMultiple=boolValueFor(multipleValue);
};
formValues=[request formValuesForKey:name];
NSDebugMLLog(@"gswdync",@"formValues=%@",formValues);
//NSLog(@"formValues=%@",formValues);
//NSLog(@"formValues class=%@",[formValues class]);
if (formValues && [formValues count])
{
BOOL found=NO;
int i=0;
int listValueCount=0;
listValue=[_list valueInComponent:component];
NSAssert3(!listValue || [listValue respondsToSelector:@selector(count)],
@"The list (%@) (%@ of class:%@) doesn't respond to 'count'",
_list,
listValue,
[listValue class]);
listValueCount=[listValue count];
if (listValueCount>0)
{
IMP listOAIIMP=[listValue methodForSelector:objectAtIndexSEL];
IMP itemSetValueIMP=[_item methodForSelector:setValueInComponentSEL];
IMP indexSetValueIMP=[_index methodForSelector:setValueInComponentSEL];
IMP valueValueIMP=[_value methodForSelector:valueInComponentSEL];
for(i=0;(!found || isMultiple) && i<listValueCount;i++)
{
itemValue=(*listOAIIMP)(listValue,objectAtIndexSEL,i);
NSDebugMLLog(@"gswdync",@"_itemValue=%@",itemValue);
NSDebugMLLog(@"gswdync",@"item=%@",_item);
if (_item)
(*itemSetValueIMP)(_item,setValueInComponentSEL,
itemValue,component);
if (_index)
(*indexSetValueIMP)(_index,setValueInComponentSEL,
GSWIntNumber(i),component);
NSDebugMLLog(@"gswdync",@"value=%@",_value);
if (_value) // Binded Value
{
valueValue = (*valueValueIMP)(_value,valueInComponentSEL,component);
valueValueString=NSStringWithObject(valueValue);
}
else // Auto Value
{
valueValue = GSWIntToNSString(i);
valueValueString=valueValue;
};
NSDebugMLLog(@"gswdync",@"valueValue=%@",valueValue);
if (valueValue)
{
// we compare (with object equality not pointer equality)
found=[formValues containsObject:valueValueString];
NSDebugMLLog(@"gswdync",@"found=%s",(found ? "YES" : "NO"));
if (found)
{
// We add list object
if (_selections)
{
if (!selectionsValue)
selectionsValue=[NSMutableArray array];
[selectionsValue addObject:itemValue];
};
// We add valueValue
if (_selectionValues)
{
if (!selectionValuesValue)
selectionValuesValue=[NSMutableArray array];
[selectionValuesValue addObject:valueValue];
};
};
};
};
};
NSDebugMLLog(@"gswdync",@"found=%s",(found ? "YES" : "NO"));
};
if (_selections)
{
NS_DURING
{
[_selections setValue:selectionsValue
inComponent:component];
};
NS_HANDLER
{
LOGException(@"GSWBrowser _selections=%@ selectionsValue=%@ exception=%@",
_selections,selectionsValue,localException);
if (WOStrictFlag)
{
[localException raise];
}
else
{
[self handleValidationException:localException
inContext:aContext];
};
}
NS_ENDHANDLER;
};
if (!WOStrictFlag && _selectionValues)
{
NS_DURING
{
[_selectionValues setValue:selectionValuesValue
inComponent:component];
};
NS_HANDLER
{
[self handleValidationException:localException
inContext:aContext];
}
NS_ENDHANDLER;
};
};
};
LOGObjectFnStopC("GSWPopUpButton");
};
//--------------------------------------------------------------------
-(void)_fastTakeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)aContext
{
LOGObjectFnNotImplemented(); //TODOFN
};
//--------------------------------------------------------------------
@end
//====================================================================
@implementation GSWBrowser (GSWBrowserB)
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
BOOL isMultiple=NO;
id sizeValue=nil;
GSWComponent* component=nil;
LOGObjectFnStartC("GSWPopUpButton");
[super appendGSWebObjectsAssociationsToResponse:aResponse
inContext:aContext];
component=GSWContext_component(aContext);
if (_size)
{
sizeValue=[_size valueInComponent:component];
// this will give us <WOConstantValueAssociation 0x1576680 - value=5 (class: NSCFNumber)>
sizeValue=GSWIntToNSString([sizeValue intValue]);
if (_value != nil) {
if (!_loggedSlow) {
NSLog(@"%s Warning: Avoid using the 'value' binding as it is much slower than omitting it, and it is just cosmetic.",
__PRETTY_FUNCTION__);
_loggedSlow = YES;
}
[self _slowTakeValuesFromRequest:request inContext:context];
} else {
sizeValue=@"5"; //Default is 5
[self _fastTakeValuesFromRequest:request inContext:context];
}
GSWResponse_appendContentAsciiString(aResponse,@" SIZE=");
GSWResponse_appendContentAsciiString(aResponse,sizeValue);
}
if (_multiple)
{
id multipleValue=nil;
multipleValue=[_multiple valueInComponent:component];
isMultiple=boolValueFor(multipleValue);
if (isMultiple)
GSWResponse_appendContentAsciiString(aResponse,@" MULTIPLE");
};
// GSWResponse_appendContentAsciiString(aResponse,@">");
LOGObjectFnStopC("GSWPopUpButton");
};
//--------------------------------------------------------------------
-(void)appendValueToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
//Does nothing because value is only printed in OPTION tag
};
//--------------------------------------------------------------------
@end
//====================================================================
@implementation GSWBrowser (GSWBrowserC)
-(BOOL)appendStringAtRight:(id)_unkwnon
withMapping:(char*)_mapping
{
LOGObjectFnNotImplemented(); //TODOFN
return NO;
};
//--------------------------------------------------------------------
@end

View file

@ -68,24 +68,16 @@
-(void)unlock;
-(void)lock;
@end
@interface GSWBundle (GSWBundleCache)
-(void)clearCache;
-(void)loadCache;
@end
@interface GSWBundle (GSWBundleA)
-(id)lockedResourceNamed:(NSString*)aName
ofType:(NSString*)aType
withLanguages:(NSArray*)languages
usingCache:(NSMutableDictionary*)cache
relativePath:(NSString**)relativePath
absolutePath:(NSString**)absolutePath;
@end
@interface GSWBundle (GSWResourceManagement)
-(void)initializeObject:(id)anObject
fromArchiveNamed:(NSString*)aName;
@ -142,11 +134,9 @@
-(NSDictionary*)lockedArchiveNamed:(NSString*)aName;
-(NSDictionary*)lockedApiNamed:(NSString*)aName;//NDFN
@end
@interface GSWBundle (GSWBundleC)
-(id)scriptedClassNameFromClassName:(NSString*)aName;
-(id)scriptPathNameFromScriptedClassName:(NSString*)aName;
@end
#endif //_GSWBundle_h__

View file

@ -539,9 +539,7 @@ objectForReference:(NSString*)keyPath
languages:(NSArray*)someLanguages
{
GSWElement* template=nil;
LOGObjectFnStart();
NSDebugMLLog(@"bundles",@"Name=%@",aName);
//OK
[self lock];
NS_DURING
{
@ -560,8 +558,7 @@ objectForReference:(NSString*)keyPath
};
NS_ENDHANDLER;
[self unlock];
NSDebugMLLog(@"bundles",@"template=%@",template);
LOGObjectFnStop();
return template;
};
@ -573,12 +570,7 @@ objectForReference:(NSString*)keyPath
GSWElement* template=nil;
NSString* relativeTemplatePath=nil;
NSString* absoluteTemplatePath=nil;
LOGObjectFnStart();
NSDebugMLLog(@"bundles",@"AName=%@",aName);
NSDebugMLLog(@"bundles",@"SomeLanguages=%@",someLanguages);
NSDebugMLLog(@"bundles",@"Path=%@",_path);
NSDebugMLLog(@"bundles",@"baseURL=%@",_baseURL);
NSDebugMLLog(@"bundles",@"frameworkName=%@",_frameworkName);
template=[self lockedResourceNamed:aName
ofType:GSWComponentTemplateSuffix
withLanguages:someLanguages
@ -586,9 +578,6 @@ objectForReference:(NSString*)keyPath
relativePath:&relativeTemplatePath
absolutePath:&absoluteTemplatePath];
NSDebugMLLog(@"bundles",@"relativeTemplatePath=%@",relativeTemplatePath);
NSDebugMLLog(@"bundles",@"absoluteTemplatePath=%@",absoluteTemplatePath);
if (!template)
{
if (!relativeTemplatePath)
@ -676,8 +665,6 @@ objectForReference:(NSString*)keyPath
};
NS_ENDHANDLER;
#endif
GSWLogC("TemplateParsed\n");
NSDebugMLLog(@"bundles",@"template=%@",template);
};
if ([[GSWApplication application] isCachingEnabled])
{
@ -694,8 +681,7 @@ objectForReference:(NSString*)keyPath
};
};
};
NSDebugMLLog(@"bundles",@"template=%@",template);
LOGObjectFnStop();
return template;
};

View file

@ -37,27 +37,8 @@
{
GSWAssociation* _checked;
GSWAssociation* _selection;
};
}
-(id)initWithName:(NSString*)name
associations:(NSDictionary*)associations
contentElements:(NSArray*)elements;
-(void)dealloc;
-(NSString*)description;
@end
//====================================================================
@interface GSWCheckBox (GSWCheckBoxA)
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)response
inContext:(GSWContext*)context;
@end
//====================================================================
@interface GSWCheckBox (GSWCheckBoxB)
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context;
@end

View file

@ -68,45 +68,39 @@ static Class standardClass = Nil;
//--------------------------------------------------------------------
-(id)initWithName:(NSString*)aName
associations:(NSDictionary*)associations
contentElements:(NSArray*)elements
template:(GSWElement*)template
{
NSMutableDictionary* tmpAssociations=[NSMutableDictionary dictionaryWithDictionary:associations];
LOGObjectFnStartC("GSWCheckBox");
NSDebugMLLog(@"gswdync",@"aName=%@ associations:%@ _elements=%@",aName,associations,elements);
[tmpAssociations setObject:[GSWAssociation associationWithValue:@"checkbox"]
forKey:@"type"];
[tmpAssociations removeObjectForKey:selection__Key];
[tmpAssociations removeObjectForKey:checked__Key];
if ((self=[super initWithName:aName
associations:tmpAssociations
contentElements:nil]))
{
//TODOV
_selection=[[associations objectForKey:selection__Key
withDefaultObject:[_selection autorelease]] retain];
if (_selection && ![_selection isValueSettable])
{
ExceptionRaise0(@"GSWCheckBox",@"'selection' parameter must be settable");
};
_checked=[[associations objectForKey:checked__Key
withDefaultObject:[_checked autorelease]] retain];
if (_checked && ![_checked isValueSettable])
{
ExceptionRaise0(@"GSWCheckBox",@"'checked' parameter must be settable");
};
if (!_checked)
{
if (!_value || !_selection)
{
ExceptionRaise0(@"GSWCheckBox",
@"If you don't specify 'checked' parameter, you have to specify 'value' and 'selection' parameter");
};
};
};
LOGObjectFnStopC("GSWCheckBox");
self = [super initWithName:@"input" associations:associations template: nil];
if (!self) {
return nil;
}
ASSIGN(_checked, [_associations objectForKey: checked__Key]);
if (_checked != nil) {
[_associations removeObjectForKey: checked__Key];
}
ASSIGN(_selection, [_associations objectForKey: selection__Key]);
if (_selection != nil) {
[_associations removeObjectForKey: selection__Key];
}
if (((_checked == nil) && (_value == nil)) ||
(((_checked != nil) && (_value != nil)) || ((_checked != nil) && (! [_checked isValueSettable])) ||
((_value != nil) && (_selection != nil)) && (![_selection isValueSettable]))) {
[NSException raise:NSInvalidArgumentException
format:@"%s: Bad attribute list.",
__PRETTY_FUNCTION__];
}
return self;
};
- (NSString *) type
{
return @"checkbox";
}
//--------------------------------------------------------------------
-(void)dealloc
{
@ -123,177 +117,81 @@ static Class standardClass = Nil;
(void*)self];
};
@end
//====================================================================
@implementation GSWCheckBox (GSWCheckBoxA)
//--------------------------------------------------------------------
/** return the value used in appendValueToResponse:inContext: **/
-(id)valueInContext:(GSWContext*)context
-(void)takeValuesFromRequest:(GSWRequest*) request
inContext:(GSWContext*) context
{
id value=nil;
LOGObjectFnStartC("GSWCheckBox");
// use _value evaluation or contextID
if (_value)
value=[super valueInContext:context];
else
value=GSWContext_elementID(context);
NSDebugMLLog(@"gswdync",@"value=%@",value);
LOGObjectFnStopC("GSWCheckBox");
return value;
};
//--------------------------------------------------------------------
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
//OK
GSWComponent* component=nil;
BOOL disabledInContext=NO;
BOOL isChecked=NO;
LOGObjectFnStartC("GSWCheckBox");
component=GSWContext_component(aContext);
disabledInContext=[self disabledInContext:aContext];
NSDebugMLLog(@"gswdync",@"disabledInContext=%d",disabledInContext);
[self appendValueToResponse:aResponse
inContext:aContext];
[self appendNameToResponse:aResponse
inContext:aContext];
NSDebugMLLog(@"gswdync",@"_value=%@",_value);
NSDebugMLLog(@"gswdync",@"_selection=%@",_selection);
NSDebugMLLog(@"gswdync",@"_checked=%@",_checked);
if (_value && _selection)
{
id valueValue=[_value valueInComponent:component];
NSDebugMLLog(@"gswdync",@"valueValue=%@",valueValue);
if (valueValue)
{
id selectionValue=[_selection valueInComponent:component];
NSDebugMLLog(@"gswdync",@"selectionValue=%@",selectionValue);
if (selectionValue)
{
NSString* valueValueString=NSStringWithObject(valueValue);
NSString* selectionValueString=NSStringWithObject(selectionValue);
isChecked=SBIsValueEqual(selectionValueString,valueValueString);
};
};
}
else if (_checked)
{
isChecked=GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_checked,aContext);
};
NSDebugMLLog(@"gswdync",@"isChecked=%s",(isChecked ? "YES" : "NO"));
GSWComponent * component = GSWContext_component(context);
id valueValue = nil;
id selectionValue = nil;
BOOL isChecked = NO;
if (isChecked)
GSWResponse_appendContentAsciiString(aResponse,@" checked");
if ((![self disabledInComponent: component]) && ([context _wasFormSubmitted])) {
NSString * nameCtx = [self nameInContext:context];
if (nameCtx != nil) {
NSArray* formValues = [request formValuesForKey: nameCtx];
if (disabledInContext)
GSWResponse_appendContentString(aResponse,@" disabled");
if (_value != nil) {
valueValue = [_value valueInComponent:component];
} else {
valueValue = [context elementID];
}
isChecked = [formValues containsObject: NSStringWithObject(valueValue)];
if ((_value != nil) && (_selection != nil)) {
if (isChecked) {
[_selection setValue: valueValue
inComponent: component];
} else {
selectionValue = [_selection valueInComponent:component];
if (selectionValue != nil) {
[_selection setValue: nil
inComponent: component];;
}
}
}
if (_checked != nil) {
[_checked setValue: (isChecked ? GSWNumberYes : GSWNumberNo)
inComponent: component];
LOGObjectFnStopC("GSWCheckBox");
}
}
}
};
@end
//====================================================================
@implementation GSWCheckBox (GSWCheckBoxB)
//--------------------------------------------------------------------
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)aContext
-(void) _appendCloseTagToResponse:(GSWResponse *) response
inContext:(GSWContext*) context
{
//OK
BOOL disabledInContext=NO;
LOGObjectFnStartC("GSWCheckBox");
GSWStartElement(aContext);
GSWAssertCorrectElementID(aContext);
disabledInContext=[self disabledInContext:aContext];
if (!disabledInContext)
{
if ([aContext _wasFormSubmitted])
{
GSWComponent* component=GSWContext_component(aContext);
NSString* name=nil;
NSArray* formValues=nil;
id valueValue=nil;
BOOL isChecked=NO;
name=[self nameInContext:aContext];
formValues=[request formValuesForKey:name];
NSDebugMLLog(@"gswdync",@"formValues for %@=%@",name,formValues);
// nothing!
}
NSDebugMLLog(@"gswdync",@"_value=%@",_value);
if (_value)
valueValue=[_value valueInComponent:component];
else
valueValue=GSWContext_elementID(aContext);
NSDebugMLLog(@"gswdync",@"valueValue=%@",valueValue);
if (formValues && [formValues count]>0 && valueValue)
{
NSString* valueValueString=NSStringWithObject(valueValue);
isChecked=[formValues containsObject:valueValueString];
};
NSDebugMLLog(@"gswdync",@"isChecked=%s",(isChecked ? "YES" : "NO"));
- (void) appendAttributesToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
{
GSWComponent * component = GSWContext_component(context);
id valueValue = nil;
id selectionValue = nil;
if (_value && _selection)
{
NS_DURING
{
[_selection setValue:(isChecked ? valueValue : nil)
inComponent:component];
};
NS_HANDLER
{
LOGException(@"GSWCheckBox _selection=%@ valueValue=%@ exception=%@",
_selection,valueValue,localException);
if (WOStrictFlag)
{
[localException raise];
}
else
{
[self handleValidationException:localException
inContext:aContext];
};
}
NS_ENDHANDLER;
}
[super appendAttributesToResponse:response inContext:context];
if (_value != nil) {
valueValue = [_value valueInComponent:component];
if (valueValue != nil && _selection != nil) {
selectionValue = [_selection valueInComponent:component];
if ((selectionValue != nil) && [selectionValue isEqual: valueValue]) {
GSWResponse_appendContentCharacter(response,' ');
GSWResponse_appendContentAsciiString(response,@"checked");
}
}
} else { // _value == nil
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response, value__Key, [context elementID], NO);
}
if ((_checked != nil) && [_checked boolValueInComponent:component]) {
GSWResponse_appendContentCharacter(response,' ');
GSWResponse_appendContentAsciiString(response,@"checked");
}
}
if (_checked)
{
NS_DURING
{
[_checked setValue:(isChecked ? GSWNumberYes : GSWNumberNo)
inComponent:component];
};
NS_HANDLER
{
LOGException(@"GSWCheckBox _checked=%@ exception=%@",
_checked,localException);
if (WOStrictFlag)
{
[localException raise];
}
else
{
[self handleValidationException:localException
inContext:aContext];
};
}
NS_ENDHANDLER;
};
};
};
GSWStopElement(aContext);
GSWAssertIsElementID(aContext);
LOGObjectFnStopC("GSWCheckBox");
};
@end

View file

@ -39,59 +39,14 @@
GSWAssociation* _item;
GSWAssociation* _index;
GSWAssociation* _selections;
//GSWeb Additions {
GSWAssociation* _selectionValues;
// }
GSWAssociation* _prefix;
GSWAssociation* _suffix;
GSWAssociation* _displayString;
GSWAssociation* _escapeHTML;
GSWAssociation* _itemDisabled;
BOOL _defaultEscapeHTML;
//GSWeb Additions {
GSWAssociation* _isDisplayStringBefore;
// }
};
BOOL _defaultEscapeHTML;
BOOL _loggedSlow;
-(id)initWithName:(NSString*)name
associations:(NSDictionary*)associations
contentElements:(NSArray*)elements;
-(void)dealloc;
}
-(NSString*)description;
-(NSString*)elementName;
@end
//====================================================================
@interface GSWCheckBoxList (GSWCheckBoxListA)
-(void)appendToResponse:(GSWResponse*)response
inContext:(GSWContext*)context;
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context;
-(void)_slowTakeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context;
-(void)_fastTakeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context;
@end
//====================================================================
@interface GSWCheckBoxList (GSWCheckBoxListB)
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)response
inContext:(GSWContext*)context;
@end
//====================================================================
@interface GSWCheckBoxList (GSWCheckBoxListC)
-(BOOL)appendStringAtRight:(id)unkwnon
withMapping:(char*)mapping;
-(BOOL)appendStringAtLeft:(id)unkwnon
withMapping:(char*)mapping;
-(BOOL)compactHTMLTags;
@end

View file

@ -84,475 +84,312 @@ static Class standardClass = Nil;
};
};
//--------------------------------------------------------------------
-(id)initWithName:(NSString*)aName
associations:(NSDictionary*)associations
contentElements:(NSArray*)elements_
{
NSMutableDictionary* tmpAssociations=[NSMutableDictionary dictionaryWithDictionary:associations];
LOGObjectFnStart();
NSDebugMLLog(@"gswdync",@"aName=%@ associations:%@ elements_=%@",aName,associations,elements_);
_defaultEscapeHTML=1;
[tmpAssociations removeObjectForKey:list__Key];
[tmpAssociations removeObjectForKey:item__Key];
[tmpAssociations removeObjectForKey:index__Key];
[tmpAssociations removeObjectForKey:prefix__Key];
[tmpAssociations removeObjectForKey:suffix__Key];
[tmpAssociations removeObjectForKey:selections__Key];
[tmpAssociations removeObjectForKey:displayString__Key];
[tmpAssociations removeObjectForKey:escapeHTML__Key];
if ((self=[super initWithName:aName
associations:tmpAssociations
contentElements:nil]))
{
_list = [[associations objectForKey:list__Key
withDefaultObject:[_list autorelease]] retain];
NSDebugMLLog(@"gswdync",@"list=%@",_list);
template:(GSWElement*)template
{
self = [super initWithName:aName associations:associations template: template];
if (!self) {
return nil;
}
_item = [[associations objectForKey:item__Key
withDefaultObject:[_item autorelease]] retain];
NSDebugMLLog(@"gswdync",@"item=%@",_item);
if (_item && ![_item isValueSettable])
{
ExceptionRaise0(@"GSWCheckBoxList",@"'item' parameter must be settable");
};
_loggedSlow = NO;
_value = [[associations objectForKey:value__Key
withDefaultObject:[_value autorelease]] retain];
NSDebugMLLog(@"gswdync",@"value=%@",_value);
ASSIGN(_list, [_associations objectForKey: list__Key]);
if (_list != nil) {
[_associations removeObjectForKey: list__Key];
}
ASSIGN(_item, [_associations objectForKey: item__Key]);
if (_item != nil) {
[_associations removeObjectForKey: item__Key];
}
ASSIGN(_index, [_associations objectForKey: index__Key]);
if (_index != nil) {
[_associations removeObjectForKey: index__Key];
}
ASSIGN(_selections, [_associations objectForKey: selections__Key]);
if (_selections != nil) {
[_associations removeObjectForKey: selections__Key];
}
ASSIGN(_prefix, [_associations objectForKey: prefix__Key]);
if (_prefix != nil) {
[_associations removeObjectForKey: prefix__Key];
}
ASSIGN(_suffix, [_associations objectForKey: suffix__Key]);
if (_suffix != nil) {
[_associations removeObjectForKey: suffix__Key];
}
ASSIGN(_displayString, [_associations objectForKey: displayString__Key]);
if (_displayString != nil) {
[_associations removeObjectForKey: displayString__Key];
}
ASSIGN(_escapeHTML, [_associations objectForKey: escapeHTML__Key]);
if (_escapeHTML != nil) {
[_associations removeObjectForKey: escapeHTML__Key];
}
_index = [[associations objectForKey:index__Key
withDefaultObject:[_index autorelease]] retain];
NSDebugMLLog(@"gswdync",@"index=%@",_index);
if (_index && ![_index isValueSettable])
{
ExceptionRaise0(@"GSWCheckBoxList",@"'index' parameter must be settable");
};
_prefix = [[associations objectForKey:prefix__Key
withDefaultObject:[_prefix autorelease]] retain];
NSDebugMLLog(@"gswdync",@"prefix=%@",_prefix);
if (_displayString == nil) {
ASSIGN(_displayString, [_associations objectForKey: value__Key]);
if (_displayString != nil) {
[_associations removeObjectForKey: value__Key];
}
_defaultEscapeHTML = NO;
} else {
_defaultEscapeHTML = YES;
}
_suffix = [[associations objectForKey:suffix__Key
withDefaultObject:[_suffix autorelease]] retain];
NSDebugMLLog(@"gswdync",@"suffix=%@",_suffix);
_selections = [[associations objectForKey:selections__Key
withDefaultObject:[_selections autorelease]] retain];
NSDebugMLLog(@"gswdync",@"selections=%@",_selections);
if (_selections && ![_selections isValueSettable])
{
ExceptionRaise0(@"GSWCheckBoxList",@"'selections' parameter must be settable");
};
if (!WOStrictFlag)
{
_selectionValues=[[associations objectForKey:selectionValues__Key
withDefaultObject:[_selectionValues autorelease]] retain];
if (_selectionValues && ![_selectionValues isValueSettable])
{
ExceptionRaise0(@"GSWCheckBoxList",@"'selectionValues' parameter must be settable");
};
};
if ((_list == nil) || (_value != nil || _displayString != nil) && ((_item == nil) || (![_item isValueSettable])) ||
(_selections != nil) && (![_selections isValueSettable])) {
_displayString = [[associations objectForKey:displayString__Key
withDefaultObject:[_displayString autorelease]] retain];
NSDebugMLLog(@"gswdync",@"displayString=%@",_displayString);
_escapeHTML = [[associations objectForKey:escapeHTML__Key
withDefaultObject:[_escapeHTML autorelease]] retain];
NSDebugMLLog(@"gswdync",@"escapeHTML=%@",_escapeHTML);
[NSException raise:NSInvalidArgumentException
format:@"%s: 'list' must be present. 'item' must not be a constant if 'displayString' or 'value' is present. 'selection' must not be a constant if present.",
__PRETTY_FUNCTION__];
}
if (!WOStrictFlag)
{
_isDisplayStringBefore=[[associations objectForKey:isDisplayStringBefore__Key
withDefaultObject:[_isDisplayStringBefore autorelease]] retain];
};
};
LOGObjectFnStop();
return self;
};
}
//--------------------------------------------------------------------
-(void)dealloc
{
DESTROY(_list);
DESTROY(_item);
DESTROY(_index);
DESTROY(_selections);
DESTROY(_selectionValues);//GSWeb Only
DESTROY(_prefix);
DESTROY(_suffix);
DESTROY(_displayString);
DESTROY(_itemDisabled);
DESTROY(_escapeHTML);
DESTROY(_isDisplayStringBefore);//GSWeb Only
[super dealloc];
}
//--------------------------------------------------------------------
-(NSString*)description
-(id) description
{
return [NSString stringWithFormat:@"<%s %p>",
return [NSString stringWithFormat:@"<%s %p list:%@ item:%@ index:%@ selections:%@ prefix:%@ suffix:%@ displayString:%@ escapeHTML:%@>",
object_get_class_name(self),
(void*)self];
};
(void*)self,
_list, _item, _index,
_selections, _prefix, _suffix, _displayString, _escapeHTML];
}
//--------------------------------------------------------------------
-(NSString*)elementName
{
return @"INPUT";
};
return @"input";
}
@end
//====================================================================
@implementation GSWCheckBoxList (GSWCheckBoxListA)
//--------------------------------------------------------------------
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context
{
//OK
LOGObjectFnStartC("GSWCheckBoxList");
[self _slowTakeValuesFromRequest:request
inContext:context];
LOGObjectFnStopC("GSWCheckBoxList");
};
//-----------------------------------------------------------------------------------
-(void)_slowTakeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context
{
//OK
BOOL disabledInContext=NO;
LOGObjectFnStartC("GSWCheckBoxList");
GSWComponent * component = GSWContext_component(context);
if ((_selections != nil) && (![self disabledInComponent:component]) && ([context _wasFormSubmitted])) {
NSString * ctxName = [self nameInContext:context];
NSArray * formValues = [request formValuesForKey: ctxName];
NSMutableArray * mutArray = nil;
int count = 0;
int count2 = 0;
int i = 0;
if ((formValues != nil) && (count = [formValues count])) {
mutArray = [NSMutableArray arrayWithCapacity:count];
} else {
mutArray = [NSMutableArray arrayWithCapacity:5];
}
disabledInContext=[self disabledInContext:context];
if (!disabledInContext)
{
if ([context _wasFormSubmitted])
{
GSWComponent* component=GSWContext_component(context);
NSArray* listValue=nil; // _list value
NSMutableArray* selectionsValue=nil;
NSMutableArray* selectionValuesValue=nil;
NSString* name=nil;
NSArray* formValues=nil;
id valueValue=nil; // _value value
NSString* valueValueString=nil; // _value value
id itemValue=nil; // _item value
int i=0;
int listValueCount=0;
if ((formValues != nil) && (count > 0)) {
id listValue = [_list valueInComponent:component];
if ([listValue isKindOfClass:[NSArray class]] == NO) {
[NSException raise:NSInvalidArgumentException
format:@"%s: Evaluating 'list' binding returned a '%@' class and not a NSArray.",
__PRETTY_FUNCTION__, [listValue class]];
}
count2 = [listValue count];
name=[self nameInContext:context];
NSDebugMLLog(@"gswdync",@"name=%@",name);
for (i = 0; i < count2; i++) {
id obj1 = [(NSArray*) listValue objectAtIndex:i];
id obj2 = nil;
formValues=[request formValuesForKey:name];
NSDebugMLLog(@"gswdync",@"formValues=%@",formValues);
NSDebugMLLog(@"gswdync",@"formValues class=%@",[formValues valueForKey:@"class"]);
[_item setValue:obj1 inComponent: component];
listValue=[_list valueInComponent:component];
NSAssert3(!listValue || [listValue respondsToSelector:@selector(count)],
@"The list (%@) (%@ of class:%@) doesn't respond to 'count'",
_list,
listValue,
[listValue class]);
NSDebugMLLog(@"gswdync",@"listValue=%@",listValue);
obj2= [_value valueInComponent:component];
if (obj2 != nil) {
if ([formValues containsObject:obj2]) {
[mutArray addObject:obj1];
}
} else {
NSLog(@"%s 'value' evaluated to nil in component %@.\nUnable to select item %@",
__PRETTY_FUNCTION__, self, obj1);
}
}
listValueCount=[listValue count];
}
[_selections setValue:mutArray inComponent: component];
}
}
for(i=0;i<listValueCount;i++)
{
NSDebugMLLog(@"gswdync",@"item=%@",_item);
NSDebugMLLog(@"gswdync",@"index=%@",_index);
itemValue=[listValue objectAtIndex:i];
if (_item)
[_item setValue:itemValue
inComponent:component];
if (_index)
[_index setValue:GSWIntNumber(i)
inComponent:component];
NSDebugMLLog(@"gswdync",@"value=%@",_value);
if (_value) // Binded Value
{
valueValue = [_value valueInComponent:component];
valueValueString=NSStringWithObject(valueValue);
}
else // Auto Value
{
valueValue = GSWIntToNSString(i);
valueValueString=valueValue;
};
NSDebugMLLog(@"gswdync",@"valueValue=%@",valueValue);
if (valueValue)
{
// we compare (with object equality not pointer equality)
BOOL found=[formValues containsObject:valueValueString];
NSDebugMLLog(@"gswdync",@"found=%s",(found ? "YES" : "NO"));
if (found)
{
if (_selections)
{
if (!selectionsValue)
selectionsValue=[NSMutableArray array];
// We add list object
[selectionsValue addObject:itemValue];
};
if (_selectionValues)
{
if (!selectionValuesValue)
selectionValuesValue=[NSMutableArray array];
// We add list object
[selectionValuesValue addObject:valueValue];
};
};
};
};
NSDebugMLLog(@"gswdync",@"component=%@",component);
NSDebugMLLog(@"gswdync",@"selectionsValue=%d",selectionsValue);
NSDebugMLLog(@"gswdync",@"selections=%@",_selections);
GSWLogAssertGood(component);
NS_DURING
{
[_selections setValue:selectionsValue
inComponent:component];
};
NS_HANDLER
{
LOGException(@"GSWCheckBoxList _selections=%@ selectionsValue=%@ exception=%@",
_selections,selectionsValue,localException);
if (WOStrictFlag)
{
[localException raise];
}
else
{
[self handleValidationException:localException
inContext:context];
};
}
NS_ENDHANDLER;
if (!WOStrictFlag && _selectionValues)
{
NS_DURING
{
[_selectionValues setValue:selectionValuesValue
inComponent:component];
};
NS_HANDLER
{
LOGException(@"GSWCheckBoxList _selectionValues=%@ selectionValuesValue=%@ exception=%@",
_selectionValues,selectionValuesValue,localException);
if (WOStrictFlag)
{
[localException raise];
}
else
{
[self handleValidationException:localException
inContext:context];
};
}
NS_ENDHANDLER;
};
};
};
LOGObjectFnStopC("GSWCheckBoxList");
};
//-----------------------------------------------------------------------------------
-(void)_fastTakeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context
{
LOGObjectFnStartC("GSWCheckBoxList");
LOGObjectFnNotImplemented(); //TODOFN
LOGObjectFnStopC("GSWCheckBoxList");
};
//-----------------------------------------------------------------------------------
-(void)appendToResponse:(GSWResponse*)aResponse
GSWComponent * component = GSWContext_component(context);
if ((_selections != nil) && (![self disabledInComponent:component]) && ([context _wasFormSubmitted])) {
NSString * ctxName = [self nameInContext:context];
NSArray * formValues = [request formValuesForKey: ctxName];
int count = 0;
int i = 0;
NSMutableArray * mutablearray;
count = (formValues == nil) ? 0 : [formValues count];
mutablearray = [NSMutableArray arrayWithCapacity:count];
if (count > 0) {
id listValue = [_list valueInComponent:component];
if ([listValue isKindOfClass:[NSArray class]] == NO) {
[NSException raise:NSInvalidArgumentException
format:@"%s: Evaluating 'list' binding returned a '%@' class and not a NSArray.",
__PRETTY_FUNCTION__, [listValue class]];
}
for (i = 0; i < count; i++) {
int j = [NSStringWithObject([formValues objectAtIndex:i]) intValue];
[mutablearray addObject:[listValue objectAtIndex:j]];
}
}
[_selections setValue:mutablearray inComponent: component];
}
}
-(void)appendToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
{
//OK
GSWRequest* request=nil;
BOOL isFromClientComponent=NO;
NSString* name=nil;
GSWComponent* component=nil;
NSArray* selectionsValue=nil;
NSArray* selectionValuesValue=nil;
int count = 0;
int j = 0;
GSWComponent * component = GSWContext_component(context);
BOOL doEscape;
NSString * ctxName = [self nameInContext:context];
id listValue = [_list valueInComponent:component];
id selectionsValue = nil;
doEscape = (_escapeHTML == nil) ? _defaultEscapeHTML : [_escapeHTML boolValueInComponent:component];
if ([listValue isKindOfClass:[NSArray class]] == NO) {
[NSException raise:NSInvalidArgumentException
format:@"%s: Evaluating 'list' binding returned a '%@' class and not a NSArray.",
__PRETTY_FUNCTION__, [listValue class]];
}
selectionsValue = _selections == nil ? nil : [_selections valueInComponent:component];
if (selectionsValue != nil) {
count = [selectionsValue count];
}
LOGObjectFnStartC("GSWCheckBoxList");
for (j = 0; j < count; j++) {
NSString * prefixStr = _prefix == nil ? nil : NSStringWithObject([_prefix valueInComponent:component]);
NSString * suffixStr = _suffix == nil ? nil : NSStringWithObject([_suffix valueInComponent:component]);
NSString * dispStr = nil;
id obj2 = nil;
id displayValue = nil;
id valueValue = nil;
request=[context request];
isFromClientComponent=[request isFromClientComponent];
name=[self nameInContext:context];
component=GSWContext_component(context);
selectionsValue=[_selections valueInComponent:component];
if (selectionsValue && ![selectionsValue isKindOfClass:[NSArray class]])
{
ExceptionRaise(@"GSWCheckBoxList",
@"GSWCheckBoxList: selections is not a NSArray: %@ %@",
selectionsValue,
[selectionsValue class]);
if (_index != nil) {
[_index setValue:GSWIntToNSString(j)
inComponent:component];
}
else
obj2 = [listValue objectAtIndex:j];
if ((_item != nil) && (_displayString != nil)) {
[_item setValue:obj2
inComponent:component];
displayValue = [_displayString valueInComponent:component];
if (displayValue == nil) {
dispStr = NSStringWithObject(obj2);
NSLog(@"%s: 'displayString' evaluated to nil in component %@. Using %@",
__PRETTY_FUNCTION__, component, dispStr);
} else {
dispStr = NSStringWithObject(displayValue);
}
} else {
dispStr = NSStringWithObject(obj2);
}
GSWResponse_appendContentAsciiString(response, @"<input name=\"");
GSWResponse_appendContentString(response,ctxName);
GSWResponse_appendContentAsciiString(response,@"\" type=checkbox value=\"");
if (_value != nil)
{
selectionValuesValue=[_selectionValues valueInComponent:component];
if (selectionValuesValue && ![selectionValuesValue isKindOfClass:[NSArray class]])
{
ExceptionRaise(@"GSWCheckBoxList",
@"GSWCheckBoxList: selectionValues is not a NSArray: %@ %@",
selectionValuesValue,
[selectionValuesValue class]);
}
else
{
int i=0;
id displayStringValue=nil;
id prefixValue=nil;
id suffixValue=nil;
id valueValue=nil;
id itemValue=nil;
BOOL disabledInContext=NO;
BOOL isDisplayStringBefore=NO;
NSArray* listValue=[_list valueInComponent:component];
int listValueCount=0;
NSAssert3(!listValue || [listValue respondsToSelector:@selector(count)],
@"The list (%@) (%@ of class:%@) doesn't respond to 'count'",
_list,
listValue,
[listValue class]);
listValueCount=[listValue count];
valueValue = [_value valueInComponent:component];
if (valueValue != nil) {
GSWResponse_appendContentHTMLConvertString(response, NSStringWithObject(valueValue));
} else {
NSLog(@"%s: 'value' evaluated to nil in component %@. Using to index.",
__PRETTY_FUNCTION__, self);
}
}
if (valueValue == nil) {
GSWResponse_appendContentAsciiString(response,GSWIntToNSString(j));
}
if ([selectionsValue containsObject:obj2]) {
GSWResponse_appendContentAsciiString(response,@"\" checked>");
} else {
GSWResponse_appendContentAsciiString(response,@"\">");
}
if (prefixStr != nil) {
GSWResponse_appendContentString(response,prefixStr);
}
if (doEscape)
{
GSWResponse_appendContentHTMLConvertString(response,dispStr);
} else {
GSWResponse_appendContentString(response,dispStr);
}
if (suffixStr != nil) {
GSWResponse_appendContentString(response,suffixStr);
}
} // for
for(i=0;i<listValueCount;i++)
{
BOOL isEqual=NO;
}
disabledInContext=[self disabledInContext:context];
itemValue=[listValue objectAtIndex:i];
[_item setValue:itemValue
inComponent:component];
prefixValue=[_prefix valueInComponent:component];
suffixValue=[_suffix valueInComponent:component];
[_index setValue:GSWIntNumber(i)
inComponent:component];
if (_isDisplayStringBefore)
isDisplayStringBefore=GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_isDisplayStringBefore,context);
displayStringValue=[_displayString valueInComponent:component];
if (isDisplayStringBefore)
GSWResponse_appendContentHTMLString(aResponse,displayStringValue);
GSWResponse_appendContentAsciiString(aResponse,@"<INPUT NAME=\"");
GSWResponse_appendContentString(aResponse,name);
GSWResponse_appendContentAsciiString(aResponse,@"\" TYPE=checkbox VALUE=\"");
NSDebugMLLog(@"gswdync",@"_value (class: %@): %@",[_value class],_value);
// Value property of the INPUT tag
if (_value) // Binded Value
{
valueValue = [_value valueInComponent:component];
NSDebugMLLog(@"gswdync",@"valueValue=%@",valueValue);
GSWResponse_appendContentHTMLAttributeValue(aResponse,valueValue);
}
else // Auto Value
{
valueValue = GSWIntToNSString(i);
NSDebugMLLog(@"gswdync",@"valueValue=%@",valueValue);
GSWResponse_appendContentAsciiString(aResponse,valueValue);
}
GSWResponse_appendContentCharacter(aResponse,'"');
NSDebugMLLog(@"gswdync",@"selectionsValue=%@",selectionsValue);
NSDebugMLLog(@"gswdync",@"selectionsValue classes=%@",[selectionsValue valueForKey:@"class"]);
NSDebugMLLog(@"gswdync",@"itemValue=%@",itemValue);
NSDebugMLLog(@"gswdync",@"itemValue class=%@",[itemValue class]);
if (_selections)
{
// we compare (with object equality not pointer equality) on list object, not valueValue !
isEqual = [selectionsValue containsObject:itemValue];
NSDebugMLLog(@"gswdync",@"isEqual=%s",(isEqual ? "YES" : "NO"));
}
NSDebugMLLog(@"gswdync",@"selectionValuesValue=%@",selectionValuesValue);
NSDebugMLLog(@"gswdync",@"selectionValuesValue classes=%@",[selectionValuesValue valueForKey:@"class"]);
NSDebugMLLog(@"gswdync",@"valueValue=%@",valueValue);
NSDebugMLLog(@"gswdync",@"valueValue class=%@",[valueValue class]);
if (isEqual==NO && _selectionValues)
{
// we compare (with object equality not pointer equality) on valueValue !
isEqual = [selectionValuesValue containsObject:valueValue];
NSDebugMLLog(@"gswdync",@"isEqual=%s",(isEqual ? "YES" : "NO"));
}
if(isEqual)
GSWResponse_appendContentAsciiString(aResponse,@" CHECKED");
if (disabledInContext)
GSWResponse_appendContentAsciiString(aResponse,@" DISABLED");
GSWResponse_appendContentCharacter(aResponse,'>');
GSWResponse_appendContentString(aResponse,prefixValue);
if (!isDisplayStringBefore)
GSWResponse_appendContentHTMLString(aResponse,displayStringValue);
GSWResponse_appendContentString(aResponse,suffixValue);
};
};
};
LOGObjectFnStopC("GSWCheckBoxList");
};
@end
//====================================================================
@implementation GSWCheckBoxList (GSWCheckBoxListB)
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
{
LOGObjectFnNotImplemented(); //TODOFN
};
@end
//====================================================================
@implementation GSWCheckBoxList (GSWCheckBoxListC)
-(BOOL)appendStringAtRight:(id)_unkwnon
withMapping:(char*)_mapping
{
LOGObjectFnNotImplemented(); //TODOFN
return NO;
};
}
-(BOOL)appendStringAtLeft:(id)_unkwnon
withMapping:(char*)_mapping
{
LOGObjectFnNotImplemented(); //TODOFN
return NO;
};
}
-(BOOL)compactHTMLTags
{
LOGObjectFnNotImplemented(); //TODOFN
return NO;
};
}
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context
{
if (_value != nil) {
if (!_loggedSlow) {
NSLog(@"%s Warning: Avoid using the 'value' binding as it is much slower than omitting it, and it is just cosmetic.",
__PRETTY_FUNCTION__);
_loggedSlow = YES;
}
[self _slowTakeValuesFromRequest:request inContext:context];
} else {
[self _fastTakeValuesFromRequest:request inContext:context];
}
}
@end

View file

@ -35,7 +35,7 @@
#define _GSWComponent_h__
@interface GSWComponent : GSWElement <NSCoding,NSCopying>
@interface GSWComponent : GSWElement <NSCopying>
{
//TODO ==> private @private
NSString* _name;
@ -44,8 +44,9 @@
GSWElement* _template;
GSWComponentDefinition* _componentDefinition;
GSWComponent* _parent;
NSArray* _associationsKeys;
NSArray* _associations;
NSMutableDictionary* _keyAssociations;
//NSArray* _associationsKeys; replaced by _keyAssociations
//NSArray* _associations;
GSWElement* _childTemplate;
GSWContext* _context;
GSWSession* _session;
@ -57,11 +58,12 @@
// }
BOOL _isPage;
BOOL _isCachingEnabled;
BOOL _isParentToComponentSynchronized;
BOOL _isComponentToParentSynchronized;
BOOL _isSynchronized;
};
- (id)initWithContext:(GSWContext *) aContext;
-(NSString*)description;
#if !GSWEB_STRICT
-(NSDictionary*)userDictionary;
@ -78,30 +80,18 @@
-(NSString*)name;
-(NSString*)path;
-(NSString*)_templateNameFromClass:(Class)_class;
@end
//====================================================================
@interface GSWComponent (GSWCachingPolicy)
-(BOOL)isCachingEnabled;
-(void)setCachingEnabled:(BOOL)flag;
@end
//====================================================================
@interface GSWComponent (GSWComponentA)
-(void)setParent:(GSWComponent*)parent
associationsKeys:(NSArray*)associationsKeys
associations:(NSArray*)associations
template:(GSWElement*)template;
-(void) _setParent:(GSWComponent*) parent
associations:(NSMutableDictionary *) assocdict
template:(GSWElement*) template;
-(void)synchronizeComponentToParent;
-(void)synchronizeParentToComponent;
-(GSWElement*)_childTemplate;
-(GSWElement*)_template;
-(GSWElement*) template;
-(GSWComponentDefinition*)_componentDefinition;
-(NSString*)_templateName;
-(NSString*)declarationName;
@ -109,20 +99,12 @@ associationsKeys:(NSArray*)associationsKeys
-(void)_setIsPage:(BOOL)isPage;
-(void)_setContext:(GSWContext*)aContext;
@end
//====================================================================
@interface GSWComponent (GSWResourceManagement)
-(GSWElement*)templateWithName:(NSString*)aName;
@end
//====================================================================
@interface GSWComponent (GSWComponentC)
-(GSWComponent*)subComponentForElementID:(NSString*)elementId;
-(void)setSubComponent:(GSWComponent*)component
forElementID:(NSString*)elementId;
// PRIVATE
-(void)_setSubcomponent:(GSWComponent*)component
forElementID:(NSString*)elementId;
//NDFN
-(void)makeParentsPerformSelectorIfPossible:(SEL)aSelector;
@ -144,27 +126,20 @@ associationsKeys:(NSArray*)associationsKeys
withObject:(id)object1
withObject:(id)object2;
@end
//====================================================================
@interface GSWComponent (GSWComponentD)
-(GSWAssociation*)_associationWithName:(NSString*)parentBindingName;
@end
//====================================================================
@interface GSWComponent (GSWSynchronizing)
-(BOOL)hasBinding:(NSString*)parentBindingName;
-(void)setValue:(id)value
forBinding:(NSString*)parentBindingName;
-(id)valueForBinding:(NSString*)parentBindingName;
-(BOOL)synchronizesVariablesWithBindings;
-(BOOL)synchronizesParentToComponentVariablesWithBindings;
-(BOOL)synchronizesComponentToParentVariablesWithBindings;
-(NSDictionary*)bindingAssociations;
@end
//-(BOOL)synchronizesComponentToParentVariablesWithBindings;
-(BOOL) isStateless;
-(void) reset;
-(NSDictionary*)bindingAssociations;
//====================================================================
@interface GSWComponent (GSWRequestHandling)
-(void)sleep;
-(void)sleepInContext:(GSWContext*)aContext;
-(void)appendToResponse:(GSWResponse*)aResponse
@ -182,33 +157,31 @@ associationsKeys:(NSArray*)associationsKeys
-(NSDictionary*)validationFailureMessages;
-(NSArray*)allValidationFailureMessages;
#endif
/*
Makes sure that the receiver is awake in aContext.
Call this method before using a component which was cached in a variable.
*/
-(void)ensureAwakeInContext:(GSWContext*)aContext;
-(void)awake;
-(void)awakeInContext:(GSWContext*)aContext;
@end
// PRIVATE
-(void)_awakeInContext:(GSWContext*)aContext;
//====================================================================
@interface GSWComponent (GSWActionInvocation)
-(id)performParentAction:(NSString*)attribute;
-(GSWComponent*)parent;
-(GSWComponent*)topParent;//NDFN
-(NSArray*)parents;//NDFN
-(NSArray*)parentsClasses;//NDFN
@end
//====================================================================
@interface GSWComponent (GSWConveniences)
-(GSWComponent*)pageWithName:(NSString*)aName;
-(GSWSession*)session;
-(BOOL)hasSession;
-(GSWContext*)context;
-(NSArray*)languages;//NDFN
-(GSWApplication*)application;
@end
//====================================================================
@interface GSWComponent (GSWLogging)
-(void)validationFailedWithException:(NSException*)exception
value:(id)_value
keyPath:(id)_keyPath;
@ -220,24 +193,15 @@ associationsKeys:(NSArray*)associationsKeys
arguments:(va_list)argList;
+(void)logWithFormat:(NSString*)format,...;
@end
//====================================================================
@interface GSWComponent (GSWComponentJ)
-(NSString*)_uniqueID;
@end
//====================================================================
@interface GSWComponent (GSWComponentK)
-(GSWResponse*)_generateResponseInContext:(GSWContext*)aContext;
-(id)validateValue:(id*)valuePtr
forKey:(id)key;
+(id)validateValue:(id*)valuePtr
forKey:(id)key;
@end
//====================================================================
@interface GSWComponent (GSWComponentL)
//+(id)validateValue:(id*)valuePtr
// forKey:(id)key;
-(NSString*)stringForKey:(id)key
inTableNamed:(NSString*)aName
withDefaultValue:(NSString*)defaultValue;
@ -281,43 +245,24 @@ associationsKeys:(NSArray*)associationsKeys
-(NSString*)pathForResourceNamed:(NSString*)aName
ofType:(NSString*)extension
inFramework:(NSString*)frameworkName;
@end
//====================================================================
@interface GSWComponent (GSWTemplateParsing)
+(GSWElement*)templateWithHTMLString:(NSString*)htmlString
declarationString:(NSString*)declarationString
languages:(NSArray*)languages;
@end
//====================================================================
@interface GSWComponent (GSWTemplateParsingOldFn)
+(GSWElement*)templateWithHTMLString:(NSString *)htmlString
declarationString:(NSString*)declarationString;//old
@end
//====================================================================
@interface GSWComponent (GSWActionResults) <GSWActionResults>
- (GSWResponse*)generateResponse;
@end
//====================================================================
@interface GSWComponent (GSWStatistics)
-(NSString*)descriptionForResponse:(GSWResponse*)response
inContext:(GSWContext*)aContext;
@end
//====================================================================
@interface GSWComponent (GSWComponentClassA)
+(void)_registerObserver:(id)observer;
@end
//====================================================================
@interface GSWComponent (GSWVerifyAPI)
-(void)validateAPIAssociations;
@end
#endif //_GSWComponent_h__

File diff suppressed because it is too large Load diff

View file

@ -46,9 +46,8 @@ RCS_ID("$Id$")
GSWComponent* component=nil;
GSWComponent* parent=nil;
GSWElement* childTemplate=nil;
GSWDeclareDebugElementIDsCount(aContext);
LOGObjectFnStart();
GSWDeclareDebugElementIDsCount(aContext);
GSWStartElement(aContext);
GSWSaveAppendToResponseElementID(aContext);//Debug Only
@ -61,13 +60,10 @@ RCS_ID("$Id$")
[childTemplate appendToResponse:response
inContext:aContext];
[aContext _setCurrentComponent:component];
NSDebugMLLog(@"gswdync",@"END ET=%@ declarationName=%@ id=%@",
[self class],[self declarationName],GSWContext_elementID(aContext));
GSWStopElement(aContext);
GSWAssertDebugElementIDsCount(aContext);
LOGObjectFnStop();
};
//--------------------------------------------------------------------
@ -81,16 +77,11 @@ RCS_ID("$Id$")
GSWElement* childTemplate=nil;
GSWDeclareDebugElementIDsCount(aContext);
LOGObjectFnStart();
GSWStartElement(aContext);
component=GSWContext_component(aContext);
NSDebugMLLog(@"gswdync",@"component=%@",component);
childTemplate=[component _childTemplate];
NSDebugMLLog(@"gswdync",@"childTemplate=%@",childTemplate);
parent=[component parent];
NSDebugMLLog(@"gswdync",@"parent=%@",parent);
[aContext _setCurrentComponent:parent];
element=[childTemplate invokeActionForRequest:request
inContext:aContext];
@ -104,8 +95,6 @@ RCS_ID("$Id$")
GSWStopElement(aContext);
GSWAssertDebugElementIDsCount(aContext);
LOGObjectFnStop();
return element;
};
@ -119,8 +108,6 @@ RCS_ID("$Id$")
GSWElement* childTemplate=nil;
GSWDeclareDebugElementIDsCount(aContext);
LOGObjectFnStart();
GSWStartElement(aContext);
GSWAssertCorrectElementID(aContext);// Debug Only
@ -132,13 +119,9 @@ RCS_ID("$Id$")
inContext:aContext];
[aContext _setCurrentComponent:component];
NSDebugMLLog(@"gswdync",@"END ET=%@ declarationName=%@ id=%@",
[self class],[self declarationName],GSWContext_elementID(aContext));
GSWStopElement(aContext);
GSWAssertDebugElementIDsCount(aContext);
LOGObjectFnStop();
};
@end

View file

@ -35,25 +35,41 @@
//====================================================================
@interface GSWComponentDefinition : NSObject <NSCoding,NSCopying>
{
NSString* _name;
GSWBundle* _bundle;
NSMutableArray* _observers;
NSString* _frameworkName;
NSString* _templateName;
NSString * _name;
NSString * _path; // _pathURL
NSString * _url;
NSString * _frameworkName;
NSString * _language;
NSString * _className;
Class _componentClass;
BOOL _isScriptedClass;
BOOL _isCachingEnabled;
BOOL _caching;
BOOL _isAwake;
GSWElement * _template;
NSString * _htmlPath;
NSString * _wodPath;
NSString * _wooPath;
// BOOL missingArchive; // NO "_" prefix?? dw
NSDictionary * _archive;
NSStringEncoding _encoding;
BOOL _isStateless;
GSWDeployedBundle * _bundle;
GSWComponent * _sharedInstance;
NSMutableArray * _instancePool;
BOOL _lockInstancePool;
BOOL _hasBeenAccessed;
BOOL _hasContextConstructor;
NSLock * _instancePoolLock;
};
-(id)initWithName:(NSString*)aName
path:(NSString*)aPath
baseURL:(NSString*)baseURL
frameworkName:(NSString*)aFrameworkName;
-(void)dealloc;
-(id)initWithCoder:(NSCoder*)coder;
-(void)encodeWithCoder:(NSCoder*)coder;
-(id)copyWithZone:(NSZone*)zone;
-(GSWComponent*)componentInstanceInContext:(GSWContext*)aContext;
-(Class) componentClass;
-(NSString*)frameworkName;
-(NSString*)baseURL;
@ -62,70 +78,26 @@
-(NSString*)description;
-(void)sleep;
-(void)awake;
@end
- (BOOL) isStateless;
// PRIVATE
+ (GSWContext *) TheTemporaryContext;
//====================================================================
@interface GSWComponentDefinition (GSWCacheManagement)
-(BOOL)isCachingEnabled;
-(void)setCachingEnabled:(BOOL)flag;
@end
//====================================================================
@interface GSWComponentDefinition (GSWComponentDefinitionA)
-(void)_clearCache;
@end
- (GSWElement *) template;
//====================================================================
@interface GSWComponentDefinition (GSWComponentDefinitionB)
-(GSWElement*)templateWithName:(NSString*)aName
languages:(NSArray*)languages;
/*
-(NSString*)stringForKey:(NSString*)key_
inTableNamed:(NSString*)aName
withDefaultValue:(NSString*)defaultValue_
languages:(NSArray*)languages;
//NDFN
-(NSDictionary*)stringsTableNamed:(NSString*)aName
withLanguages:(NSArray*)languages;
//NDFN
-(NSArray*)stringsTableArrayNamed:(NSString*)aName
withLanguages:(NSArray*)languages;
-(NSString*)urlForResourceNamed:(NSString*)aName
ofType:(NSString*)aType
languages:(NSArray*)languages
request:(GSWRequest*)aRequest;
*/
-(NSString*)pathForResourceNamed:(NSString*)aName
ofType:(NSString*)aType
languages:(NSArray*)languages;
@end
//====================================================================
@interface GSWComponentDefinition (GSWComponentDefinitionC)
-(GSWComponent*)componentInstanceInContext:(GSWContext*)aContext;
-(Class)componentClass;
-(Class)_componentClass;
-(GSWComponentReference*)componentReferenceWithAssociations:(NSDictionary*)associations
template:(GSWElement*)template;
- (GSWComponentReference*) componentReferenceWithAssociations:(NSDictionary*)associations
template:(GSWElement*)template;
-(NSDictionary*)componentAPI;
-(NSDictionary*)componentAPI;//NDFN
@end
//====================================================================
@interface GSWComponentDefinition (GSWComponentDefinitionD)
-(void)_finishInitializingComponent:(GSWComponent*)aComponent;
@end
//====================================================================
@interface GSWComponentDefinition (GSWComponentDefinitionE)
-(void)_notifyObserversForDyingComponent:(GSWComponent*)aComponent;
-(void)_awakeObserversForComponent:(GSWComponent*)aComponent;
-(void)_deallocForComponent:(GSWComponent*)aComponent;
-(void)_awakeForComponent:(GSWComponent*)aComponent;
-(void)_registerObserver:(id)observer;
+(void)_registerObserver:(id)observer;
@end

View file

@ -31,121 +31,178 @@
#include "GSWeb.h"
//====================================================================
/* Static variables */
static NSLock * ComponentConstructorLock;
static NSLock * TemplateLock;
static GSWContext * TheTemporaryContext;
static BOOL _IsEventLoggingEnabled; // needed?
@implementation GSWComponentDefinition
+ (void) initialize
{
if (self == [GSWComponentDefinition class]) {
ComponentConstructorLock = [[NSLock alloc] init];
TemplateLock = [[NSLock alloc] init];
TheTemporaryContext = nil;
}
}
// that Method is used INTERNAL.
+ (GSWContext *) TheTemporaryContext
{
return TheTemporaryContext;
}
//--------------------------------------------------------------------
#warning CHECKME: missing Languages?
// we my have a different name and class?
// aName StartPage
// aPath /Users/dave/projects/new/PBXBilling/trunk/PBX.gswa/Resources/StartPage.wo
// baseURL /WebObjects/PBX.gswa/Resources/StartPage.wo
-(id)initWithName:(NSString*)aName
path:(NSString*)aPath
baseURL:(NSString*)baseURL
frameworkName:(NSString*)aFrameworkName
{
LOGObjectFnStart();
if ((self=[super init]))
{
NSDebugMLLog(@"gswcomponents",@"aName=%@ aFrameworkName=%@",aName,aFrameworkName);
ASSIGN(_name,aName);
NSString * myBasePath = nil;
NSFileManager * defaultFileManager = nil;
[super init];
ASSIGN(_name, [aName stringByDeletingPathExtension]); // does it ever happen that
ASSIGN(_className, aName); // those are different? dw.
_componentClass = NSClassFromString(_className);
ASSIGN(_path, aPath);
ASSIGN(_url, baseURL);
ASSIGN(_frameworkName, aFrameworkName);
DESTROY(_language);
_hasBeenAccessed = NO;
_hasContextConstructor = NO;
_isStateless = NO;
DESTROY(_instancePool);
_instancePool = [NSMutableArray new];
_lockInstancePool = [GSWApp isConcurrentRequestHandlingEnabled];
if ((_name != nil) && (_frameworkName != nil)) {
NSBundle * nsbundle = [NSBundle bundleForClass:NSClassFromString(_className)];
if (nsbundle != nil) {
_componentClass = NSClassFromString(_className);
}
}
myBasePath = [aPath stringByAppendingPathComponent: aName];
ASSIGN(_htmlPath,[myBasePath stringByAppendingPathExtension:@"html"]);
ASSIGN(_wodPath,[myBasePath stringByAppendingPathExtension:GSWComponentDeclarationsSuffix[GSWebNamingConv]]);
ASSIGN(_wooPath,[myBasePath stringByAppendingPathExtension:GSWArchiveSuffix[GSWebNamingConv]]);
defaultFileManager = [NSFileManager defaultManager];
if (_componentClass == Nil) {
[self autorelease];
NSLog(@"%s: No component class for component named '%@' found", __PRETTY_FUNCTION__, _name);
return nil;
}
// if (([defaultFileManager fileExistsAtPath: _htmlPath] == NO) ||
// ([defaultFileManager fileExistsAtPath: _wodPath] == NO) ||
// ([defaultFileManager fileExistsAtPath: _wooPath] == NO) ||
// (_componentClass == Nil)) {
//
// [NSException raise:NSInvalidArgumentException
// format:@"%s: No template found for component named '%@'",
// __PRETTY_FUNCTION__, _name];
// }
_archive = nil;
_encoding = NSUTF8StringEncoding;
_template = nil;
[self setCachingEnabled:[[GSWApp class] isCachingEnabled]];
_isAwake = NO;
if (_frameworkName == nil) {
_bundle=[[GSWBundle alloc] initWithPath:aPath
baseURL:baseURL
inFrameworkNamed:aFrameworkName];
_observers=nil;
ASSIGN(_frameworkName,aFrameworkName);
NSDebugMLLog(@"gswcomponents",@"frameworkName=%@",_frameworkName);
ASSIGN(_templateName,aName);//TODOV
NSDebugMLLog(@"gswcomponents",@"templateName=%@",_templateName);
_componentClass=Nil;
_isScriptedClass=NO;
_isCachingEnabled=NO;
_isAwake=NO;
[self setCachingEnabled:[GSWApplication isCachingEnabled]];
};
LOGObjectFnStop();
inFrameworkNamed: nil];
} else {
_bundle=[[GSWBundle alloc] initWithPath:aPath
baseURL:baseURL
inFrameworkNamed: _frameworkName];
if (_bundle == nil)
{
[NSException raise:NSInvalidArgumentException
format:@"%s: No framework named '%@'",
__PRETTY_FUNCTION__, _frameworkName];
}
}
_instancePoolLock = [[NSLock alloc] init];
return self;
};
}
//--------------------------------------------------------------------
-(void)dealloc
{
GSWLogC("Dealloc GSWComponentDefinition");
GSWLogC("Dealloc GSWComponentDefinition: name");
DESTROY(_name);
GSWLogC("Dealloc GSWComponentDefinition: bundle");
DESTROY(_bundle);
GSWLogC("Dealloc GSWComponentDefinition: observers");
DESTROY(_observers);
GSWLogC("Dealloc GSWComponentDefinition: frameworkName");
DESTROY(_path);
DESTROY(_url);
DESTROY(_frameworkName);
GSWLogC("Dealloc GSWComponentDefinition: templateName");
DESTROY(_templateName);
GSWLogC("Dealloc GSWComponentDefinition: componentClass");
DESTROY(_componentClass);
GSWLogC("Dealloc GSWComponentDefinition Super");
DESTROY(_language);
DESTROY(_className);
_componentClass = Nil;
DESTROY(_template);
DESTROY(_htmlPath);
DESTROY(_wodPath);
DESTROY(_wooPath);
DESTROY(_archive);
DESTROY(_bundle);
DESTROY(_sharedInstance);
DESTROY(_instancePool);
[super dealloc];
GSWLogC("End Dealloc GSWComponentDefinition");
};
//--------------------------------------------------------------------
-(id)initWithCoder:(NSCoder*)coder
{
if ((self = [super init]))
{
[coder decodeValueOfObjCType:@encode(id)
at:&_name];
[coder decodeValueOfObjCType:@encode(id)
at:&_bundle];
[coder decodeValueOfObjCType:@encode(id)
at:&_observers]; //TODOV
[coder decodeValueOfObjCType:@encode(id)
at:&_frameworkName];
[coder decodeValueOfObjCType:@encode(id)
at:&_templateName];
[coder decodeValueOfObjCType:@encode(Class)
at:&_componentClass];
[coder decodeValueOfObjCType:@encode(BOOL)
at:&_isScriptedClass];
[coder decodeValueOfObjCType:@encode(BOOL)
at:&_isCachingEnabled];
[coder decodeValueOfObjCType:@encode(BOOL)
at:&_isAwake];
};
return self;
};
//--------------------------------------------------------------------
-(void)encodeWithCoder:(NSCoder*)coder
{
[coder encodeObject:_name];
[coder encodeObject:_bundle];
[coder encodeObject:_observers]; //TODOV
[coder encodeObject:_frameworkName];
[coder encodeObject:_templateName];
[coder encodeValueOfObjCType:@encode(Class)
at:&_componentClass];
[coder encodeValueOfObjCType:@encode(BOOL)
at:&_isScriptedClass];
[coder encodeValueOfObjCType:@encode(BOOL)
at:&_isCachingEnabled];
[coder encodeValueOfObjCType:@encode(BOOL)
at:&_isAwake];
};
//--------------------------------------------------------------------
-(id)copyWithZone:(NSZone*)zone
- (void) checkInComponentInstance:(GSWComponent*) component
{
GSWComponentDefinition* clone = [[isa allocWithZone:zone] init];
if (clone)
{
ASSIGNCOPY(clone->_name,_name);
ASSIGNCOPY(clone->_bundle,_bundle);
ASSIGNCOPY(clone->_observers,_observers);
ASSIGNCOPY(clone->_frameworkName,_frameworkName);
ASSIGNCOPY(clone->_templateName,_templateName);
clone->_componentClass=_componentClass;
clone->_isScriptedClass=_isScriptedClass;
clone->_isCachingEnabled=_isCachingEnabled;
clone->_isAwake=_isAwake;
};
return clone;
};
if (_sharedInstance == nil)
{
_sharedInstance = component;
} else
{
[_instancePool addObject:component];
}
}
- (void) _checkInComponentInstance:(GSWComponent*) component
{
BOOL locked = NO;
if (_lockInstancePool) {
NS_DURING
[_instancePoolLock lock];
locked = YES;
[self checkInComponentInstance: component];
locked = NO;
[_instancePoolLock unlock];
NS_HANDLER
if (locked) {
[_instancePoolLock unlock];
}
localException=[localException exceptionByAddingUserInfoFrameInfoFormat:@"In %s",
__PRETTY_FUNCTION__];
[localException raise];
NS_ENDHANDLER;
} else {
[self checkInComponentInstance: component];
}
}
//--------------------------------------------------------------------
-(NSString*)frameworkName
@ -156,13 +213,13 @@
//--------------------------------------------------------------------
-(NSString*)baseURL
{
return [_bundle baseURL];
};
return _url;
}
//--------------------------------------------------------------------
-(NSString*)path
{
return [_bundle path];
return _path;
};
//--------------------------------------------------------------------
@ -175,17 +232,14 @@
-(NSString*)description
{
//TODO
return [NSString stringWithFormat:@"<%s %p - name:[%@] bundle:[%@] observers=[%@] frameworkName=[%@] templateName=[%@] componentClass=[%@] isScriptedClass=[%s] isCachingEnabled=[%s] isAwake=[%s]>",
return [NSString stringWithFormat:@"<%s %p - name:[%@] bundle:[%@] frameworkName=[%@] componentClass=[%@] isCachingEnabled=[%s] isAwake=[%s]>",
object_get_class_name(self),
(void*)self,
_name,
_bundle,
_observers,
_frameworkName,
_templateName,
_componentClass,
_isScriptedClass ? "YES" : "NO",
_isCachingEnabled ? "YES" : "NO",
_caching ? "YES" : "NO",
_isAwake ? "YES" : "NO"];
};
@ -193,213 +247,232 @@
-(void)sleep
{
//OK
LOGObjectFnStart();
_isAwake=NO;
LOGObjectFnStop();
};
//--------------------------------------------------------------------
// dw
-(void)awake
{
//OK
BOOL isCachingEnabled=NO;
LOGObjectFnStart();
_isAwake=YES;
isCachingEnabled=[self isCachingEnabled];
if (!isCachingEnabled) //??
[self _clearCache];
//call self componentClass
LOGObjectFnNotImplemented(); //TODOFN
LOGObjectFnStop();
if (!_isAwake) {
_isAwake = YES;
if (! _caching) {
[self componentClass];
}
}
};
@end
//====================================================================
@implementation GSWComponentDefinition (GSWCacheManagement)
//--------------------------------------------------------------------
-(BOOL)isCachingEnabled
{
return _isCachingEnabled;
return _caching;
};
//--------------------------------------------------------------------
-(void)setCachingEnabled:(BOOL)flag
{
_isCachingEnabled=flag;
_caching = flag;
};
@end
//====================================================================
@implementation GSWComponentDefinition (GSWComponentDefinitionA)
//--------------------------------------------------------------------
-(void)_clearCache
{
//OK
LOGObjectFnStart();
[_bundle clearCache];
LOGObjectFnStop();
};
@end
//====================================================================
@implementation GSWComponentDefinition (GSWComponentDefinitionB)
//--------------------------------------------------------------------
-(GSWElement*)templateWithName:(NSString*)aName
languages:(NSArray*)languages
{
GSWElement* element=nil;
LOGObjectFnStart();
element=[_bundle templateNamed:aName
languages:languages];
NSDebugMLLog(@"gswcomponents",@"aName=%@ languages=%@ element=%@",aName,languages,element);
LOGObjectFnStop();
return element;
};
/*
//--------------------------------------------------------------------
-(NSString*)stringForKey:(NSString*)key
inTableNamed:(NSString*)aName
withDefaultValue:(NSString*)defaultValue
languages:(NSArray*)languages
{
NSString* string=nil;
LOGObjectFnStart();
string=[_bundle stringForKey:key
inTableNamed:aName
withDefaultValue:defaultValue
languages:languages];
LOGObjectFnStop();
return string;
};
//--------------------------------------------------------------------
//NDFN
-(NSDictionary*)stringsTableNamed:(NSString*)aName
withLanguages:(NSArray*)languages
{
NSDictionary* stringsTable=nil;
LOGObjectFnStart();
stringsTable=[bundle stringsTableNamed:aName
withLanguages:languages];
LOGObjectFnStop();
return stringsTable;
};
//--------------------------------------------------------------------
//NDFN
-(NSArray*)stringsTableArrayNamed:(NSString*)aName
withLanguages:(NSArray*)languages
{
NSArray* stringsTableArray=nil;
LOGObjectFnStart();
stringsTableArray=[bundle stringsTableArrayNamed:aName
withLanguages:languages];
LOGObjectFnStop();
return stringsTableArray;
};
//--------------------------------------------------------------------
-(NSString*)urlForResourceNamed:(NSString*)aName
ofType:(NSString*)type
languages:(NSArray*)languages
request:(GSWRequest*)request
{
NSString* url=nil;
LOGObjectFnStart();
url=[bundle urlForResourceNamed:aName
ofType:type
languages:languages
request:request];
LOGObjectFnStop();
return url;
};
*/
//--------------------------------------------------------------------
-(NSString*)pathForResourceNamed:(NSString*)aName
ofType:(NSString*)aType
languages:(NSArray*)languages
{
NSString* path=nil;
LOGObjectFnStart();
path=[_bundle pathForResourceNamed:aName
ofType:aType
languages:languages];
LOGObjectFnStop();
return path;
};
@end
//====================================================================
@implementation GSWComponentDefinition (GSWComponentDefinitionC)
#warning CHECKME
-(GSWComponent*) _componentInstanceInContext:(GSWContext*) aContext
{
Class myClass = [self componentClass];
GSWComponent * component = nil;
IMP instanceInitIMP = NULL;
IMP componentInitIMP = NULL;
GSWComponent * myInstance = nil;
BOOL locked = NO;
if ([myClass isKindOfClass: [GSWComponent class]]) {
[aContext _setComponentName:_className];
}
[aContext _setTempComponentDefinition:self];
NS_DURING
if (!_hasBeenAccessed) {
myInstance = [myClass alloc];
instanceInitIMP = [myInstance methodForSelector:@selector(init)];
componentInitIMP = [GSWComponent instanceMethodForSelector:@selector(init)];
if (instanceInitIMP != componentInitIMP) {
// NSLog(@"Class %s should implement initWithContext: and not init", object_get_class_name(myClass));
[ComponentConstructorLock lock];
locked = YES;
TheTemporaryContext = aContext;
component = AUTORELEASE([myInstance init]);
TheTemporaryContext = nil;
locked = NO;
_hasContextConstructor = NO;
[ComponentConstructorLock unlock];
} else {
component = AUTORELEASE([myInstance initWithContext: aContext]);
_hasContextConstructor = YES;
}
} else {
// check if we can use some intelligent caching here.
myInstance = [myClass alloc];
if (_hasContextConstructor == NO) {
[ComponentConstructorLock lock];
locked = YES;
TheTemporaryContext = aContext;
component = AUTORELEASE([myInstance init]);
TheTemporaryContext = nil;
locked = NO;
[ComponentConstructorLock unlock];
} else {
component = AUTORELEASE([myInstance initWithContext: aContext]);
}
}
NS_HANDLER
if (locked) {
[ComponentConstructorLock unlock];
}
localException=[localException exceptionByAddingUserInfoFrameInfoFormat:@"In %s",
__PRETTY_FUNCTION__];
LOGException(@"exception=%@",localException);
[localException raise];
NS_ENDHANDLER;
if ([component context] == nil) {
[NSException raise:NSInvalidArgumentException
format:@"Component '%@' was not properly initialized. Make sure [super initWithContext:] is called. In %s",
_className,
__PRETTY_FUNCTION__];
}
return component;
}
- (BOOL) isStateless
{
return _isStateless;
}
// this is called when we are already holding a lock.
-(GSWComponent*) _sharedInstanceInContext:(GSWContext*)aContext
{
GSWComponent * component = nil;
if (_sharedInstance != nil) {
component = _sharedInstance;
_sharedInstance = nil;
} else {
if ([_instancePool count] > 0) {
component = AUTORELEASE(RETAIN([_instancePool lastObject]));
[_instancePool removeLastObject];
} else {
component = [self _componentInstanceInContext:aContext];
}
}
return component;
}
//--------------------------------------------------------------------
-(GSWComponent*)componentInstanceInContext:(GSWContext*)aContext
{
//OK
GSWComponent* component=nil;
Class componentClass=nil;
NSMutableDictionary* threadDictionary=nil;
LOGObjectFnStart();
NSAssert(aContext,@"No Context");
NSDebugMLLog(@"gswcomponents",@"aContext=%@",aContext);
BOOL locked = NO;
// Get component class
componentClass=[self componentClass];
NSAssert1(componentClass,@"No componentClass for:%@",NSStringFromClass([self class]));
NSDebugMLLog(@"gswcomponents",@"componentClass=%p",(void*)componentClass);
if (aContext == nil) {
[NSException raise:NSInvalidArgumentException
format:@"Attempt to create component instance without a context. In %s",
__PRETTY_FUNCTION__];
}
// Put the component definition in the thread dictionary because we need it during component initialization
threadDictionary=GSCurrentThreadDictionary();
[threadDictionary setObject:self
forKey:GSWThreadKey_ComponentDefinition];
NS_DURING
{
// Now, create the component by allocation a new instance of the class.
component=[[componentClass new] autorelease];
}
if (!_hasBeenAccessed) {
component = [self _componentInstanceInContext: aContext];
_isStateless = [component isStateless];
_hasBeenAccessed = YES;
} else {
if (_isStateless) {
if (_lockInstancePool) {
[_instancePoolLock lock];
locked = YES;
component = [self _sharedInstanceInContext:aContext];
locked = NO;
[_instancePoolLock unlock];
} else {
component = [self _sharedInstanceInContext:aContext];
}
} else {
component = [self _componentInstanceInContext:aContext];
}
}
NS_HANDLER
{
LOGException(@"EXCEPTION:%@ (%@) [%s %d]",
localException,[localException reason],__FILE__,__LINE__);
[threadDictionary removeObjectForKey:GSWThreadKey_ComponentDefinition];
[localException raise];
};
localException=[localException exceptionByAddingUserInfoFrameInfoFormat:@"In %s",
__PRETTY_FUNCTION__];
LOGException(@"exception=%@",localException);
if (_lockInstancePool && locked) {
[_instancePoolLock unlock];
}
[localException raise];
NS_ENDHANDLER;
return component;
}
// Remove the component from the thread dictionary
[threadDictionary removeObjectForKey:GSWThreadKey_ComponentDefinition];
// [_component context];//so what ?
LOGObjectFnStop();
return component;
};
//--------------------------------------------------------------------
-(Class)componentClass
{
//OK
return [self _componentClass];
};
//--------------------------------------------------------------------
/** Find the class of the component **/
-(Class)_componentClass
{
//OK To Verify
Class componentClass=_componentClass;
LOGObjectFnStart();
NSDebugMLLog(@"gswcomponents",@"componentClass=%@",componentClass);
NSDebugMLLog(@"gswcomponents",@"name=%@",_name);
if (!componentClass)
-(Class) componentClass
{
Class componentClass = Nil;
if (_componentClass) {
return _componentClass;
}
componentClass = _componentClass;
if (!componentClass) {
componentClass=NSClassFromString(_name);//???
NSDebugMLLog(@"gswcomponents",@"componentClass=%@",componentClass);
NSDebugMLLog(@"gswcomponents",@"componentClass superclass=%@",[componentClass superclass]);
}
if (!componentClass) // There's no class with that name
{
BOOL createClassesOk=NO;
@ -408,9 +481,7 @@ languages:(NSArray*)languages
{
// Search component archive for a superclass (superClassName keyword)
NSDictionary* archive=[_bundle archiveNamed:_name];
NSDebugMLLog(@"gswcomponents",@"archive=%@",archive);
superClassName=[archive objectForKey:@"superClassName"];
NSDebugMLLog(@"gswcomponents",@"superClassName=%@",superClassName);
if (superClassName)
{
if (!NSClassFromString(superClassName))
@ -424,19 +495,16 @@ languages:(NSArray*)languages
// If we haven't found a superclass, use GSWComponent as the superclass
if (!superClassName)
superClassName=@"GSWComponent";
NSDebugMLLog(@"gswcomponents",@"_name=%@ superClassName=%@",_name,superClassName);
// Create class
createClassesOk=[GSWApplication createUnknownComponentClasses:[NSArray arrayWithObject:_name]
superClassName:superClassName];
// Use it
componentClass=NSClassFromString(_name);
NSDebugMLLog(@"gswcomponents",@"componentClass=%p",(void*)componentClass);
};
//call GSWApp isCaching
NSDebugMLLog(@"gswcomponents",@"componentClass=%@",componentClass);
LOGObjectFnStop();
_componentClass=componentClass;
return componentClass;
};
@ -459,33 +527,22 @@ languages:(NSArray*)languages
-(NSDictionary*)componentAPI
{
NSDictionary* componentAPI=nil;
LOGObjectFnStart();
componentAPI=[_bundle apiNamed:_name];
LOGObjectFnStop();
return componentAPI;
};
@end
//====================================================================
@implementation GSWComponentDefinition (GSWComponentDefinitionD)
//--------------------------------------------------------------------
-(void)_finishInitializingComponent:(GSWComponent*)component
-(void) finishInitializingComponent:(GSWComponent*)component
{
//OK
NSDictionary* archive=nil;
LOGObjectFnStart();
archive=[_bundle archiveNamed:_name];
[_bundle initializeObject:component
fromArchive:archive];
LOGObjectFnStop();
};
@end
//====================================================================
@implementation GSWComponentDefinition (GSWComponentDefinitionE)
//--------------------------------------------------------------------
-(void)_notifyObserversForDyingComponent:(GSWComponent*)aComponent
@ -523,4 +580,35 @@ languages:(NSArray*)languages
LOGClassFnNotImplemented(); //TODOFN
};
- (GSWElement *) template
{
BOOL htmlChangedOnDisk = NO;
BOOL wodChangedOnDisk = NO;
BOOL doCache = [self isCachingEnabled];
if (doCache == NO) {
htmlChangedOnDisk = YES; // todo compare last chage date with load date
if (_htmlPath != nil && !htmlChangedOnDisk) {
wodChangedOnDisk = YES; // todo compare last chage date with load date
}
}
if (_htmlPath != nil && (_template == nil || htmlChangedOnDisk || wodChangedOnDisk)) {
NS_DURING
[TemplateLock lock];
DESTROY(_template);
_template = RETAIN([_bundle templateNamed: _name
languages:nil]); // _language? array?
[TemplateLock unlock];
NS_HANDLER
DESTROY(_template);
[TemplateLock unlock];
[localException raise];
NS_ENDHANDLER
}
return _template;
}
@end

View file

@ -38,8 +38,7 @@
@interface GSWComponentReference: GSWDynamicElement
{
NSString* _name;
NSArray* _associationsKeys;
NSArray* _associations;
NSMutableDictionary* _keyAssociations;
GSWElement* _contentElement;
};
@ -52,16 +51,9 @@
template:(GSWElement*)template;
-(NSString*)description;
@end
//====================================================================
@interface GSWComponentReference (GSWComponentReferenceA)
-(void)popRefComponentInContext:(GSWContext*)aContext;
-(void)pushRefComponentInContext:(GSWContext*)aContext;
@end
//====================================================================
@interface GSWComponentReference (GSWRequestHandling)
-(void)appendToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext;

View file

@ -43,28 +43,13 @@ RCS_ID("$Id$")
associations:(NSDictionary*)associations
{
LOGObjectFnStart();
//OK
NSDebugMLLog(@"gswdync",@"aName:%@",aName);
NSDebugMLLog(@"gswdync",@"associations:%@",associations);
if ((self==[super initWithName:aName
associations:associations
template:nil]))
{
int associationsCount=[associations count];
ASSIGN(_name,aName);
if (associationsCount>0)
{
NSMutableArray* tmpArray=[NSMutableArray array];
int i=0;
ASSIGN(_associationsKeys,[associations allKeys]);
for(i=0;i<associationsCount;i++)
{
[tmpArray addObject:[associations objectForKey:[_associationsKeys objectAtIndex:i]]];
};
ASSIGN(_associations,[NSArray arrayWithArray:tmpArray]);
};
};
LOGObjectFnStop();
template:nil])) {
ASSIGN(_name,aName);
ASSIGN(_keyAssociations,[NSMutableDictionary dictionaryWithDictionary:associations]);
}
return self;
};
@ -73,172 +58,112 @@ RCS_ID("$Id$")
associations:(NSDictionary*)associations
template:(GSWElement*)template
{
LOGObjectFnStart();
NSDebugMLLog(@"gswdync",@"aName:%@",aName);
NSDebugMLLog(@"gswdync",@"associations:%@",associations);
NSDebugMLLog(@"gswdync",@"template:%@",template);
if ((self==[self initWithName:aName
associations:associations]))
{
ASSIGN(_contentElement,template);
};
LOGObjectFnStop();
return self;
};
//--------------------------------------------------------------------
-(void)dealloc
{
GSWLogC("Dealloc GSWComponentReference");
GSWLogC("Destroy name");
DESTROY(_name);
GSWLogC("Destroy associationsKeys");
DESTROY(_associationsKeys);
GSWLogC("Destroy associations");
DESTROY(_associations);
GSWLogC("Destroy contentElement");
DESTROY(_keyAssociations);
DESTROY(_contentElement);
GSWLogC("Dealloc GSWComponentReference Super");
[super dealloc];
GSWLogC("End Dealloc GSWComponentReference");
};
//--------------------------------------------------------------------
-(NSString*)description
{
return [NSString stringWithFormat:@"<%@ %p name:%@ associationsKeys:%@ associations:%@ contentElement:%@>",
return [NSString stringWithFormat:@"<%@ %p name:%@ associations:%@ contentElement:%@>",
[self class],
(void*)self,
_name,
_associationsKeys,
_associations,
_keyAssociations,
_contentElement];
};
@end
//====================================================================
@implementation GSWComponentReference (GSWComponentReferenceA)
-(void)popRefComponentInContext:(GSWContext*)context
-(void)_popComponentFromContext:(GSWContext*)context
{
//OK
GSWComponent* subComponent=nil;
GSWComponent* component=nil;
LOGObjectFnStart();
subComponent=GSWContext_component(context);
component=[subComponent parent];
[subComponent synchronizeComponentToParent];
[context _setCurrentComponent:component];
LOGObjectFnStop();
};
GSWComponent* component = GSWContext_component(context);
GSWComponent* parentcomp = [component parent];
[component pushValuesToParent];
[context _setCurrentComponent:parentcomp];
}
//--------------------------------------------------------------------
-(void)pushRefComponentInContext:(GSWContext*)context
-(void)_pushComponentInContext:(GSWContext*)context
{
//OK
GSWComponent* subComponent=nil;
GSWComponent* component = GSWContext_component(context);
GSWComponent* subComponent = nil;
NSString* elementID = GSWContext_elementID(context);
GSWComponentDefinition* subComponentDefinition=nil;
GSWComponent* component=nil;
NSString* elementID=nil;
LOGObjectFnStart();
component=GSWContext_component(context);
elementID=GSWContext_elementID(context);
NSDebugMLLog(@"gswdync",@"_elementID:%@",elementID);
subComponent=[component subComponentForElementID:elementID];
NSDebugMLLog(@"gswdync",@"subComponent:%@",subComponent);
if (!subComponent)
{
NSArray* languages=[context languages];
NSDebugMLLog(@"gswdync",@"name:%@",_name);
NSDebugMLLog(@"gswdync",@"pushRefComponentInContext comporef=%p parent=%p",
(void*)self,
(void*)component);
subComponentDefinition=[GSWApp componentDefinitionWithName:_name
languages:languages];
NSDebugMLLog(@"gswdync",@"subComponentDefinition=%@",subComponentDefinition);
if (subComponentDefinition)
{
subComponent=[subComponentDefinition componentInstanceInContext:context];
NSDebugMLLog(@"gswdync",@"subComponent:%@",subComponent);
if (subComponent)
{
NSDebugMLLog(@"gswdync",@"SETPARENT comporef=%p parent=%p component=%p",
(void*)self,
(void*)component,
(void*)subComponent);
[subComponent setParent:component
associationsKeys:_associationsKeys
associations:_associations
template:_contentElement];
}
else
{
ExceptionRaise(@"GSWComponentReference: subcomponent instance creation failed in '@'",
_name);
};
}
else
{
ExceptionRaise(@"GSWComponentReference: can't find subcomponent definition in '@'",
_name);
};
if (subComponent)
{
[component setSubComponent:subComponent
if (component != nil) {
subComponent = [component _subcomponentForElementWithID: elementID];
}
if (subComponent == nil) {
subComponentDefinition = [GSWApp _componentDefinitionWithName:_name languages:[context languages]];
subComponent = [subComponentDefinition componentInstanceInContext:context];
[subComponent _setParent:component
associations:_keyAssociations
template:_contentElement];
if (component != nil) {
[component _setSubcomponent:subComponent
forElementID:elementID];
[subComponent awakeInContext:context];
};
};
if (subComponent)
{
[subComponent synchronizeParentToComponent];
};
}
[subComponent _awakeInContext: context];
} else {
[subComponent _setParent:component
associations:_keyAssociations
template:_contentElement];
}
[subComponent pullValuesFromParent];
[context _setCurrentComponent:subComponent];
LOGObjectFnStop();
};
}
-(void)popRefComponentInContext:(GSWContext*)context
{
NSLog(@"WARNING: %s is deprecated. Use _popComponentFromContext instead.", __PRETTY_FUNCTION__);
[self _popComponentFromContext: context];
}
-(void) pushRefComponentInContext:(GSWContext*)context
{
NSLog(@"WARNING: %s is deprecated. Use _pushComponentInContext instead.", __PRETTY_FUNCTION__);
[self _pushComponentInContext: context];
}
@end
//====================================================================
@implementation GSWComponentReference (GSWRequestHandling)
//--------------------------------------------------------------------
-(void)appendToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
//OK
GSWComponent* component=nil;
GSWComponent* componentPrev=nil;
GSWDeclareDebugElementIDsCount(aContext);
LOGObjectFnStart();
[self _pushComponentInContext: aContext];
[GSWContext_component(aContext) appendToResponse:aResponse
inContext:aContext];
GSWStartElement(aContext);
GSWSaveAppendToResponseElementID(aContext);
[self _popComponentFromContext:aContext];
}
GSWResponse_appendDebugCommentContentString(aResponse,
([NSString stringWithFormat:@"declarationName=%@ ID=%@ name=%@",
[self declarationName],
GSWContext_elementID(aContext),
_name]));
componentPrev=GSWContext_component(aContext);
[self pushRefComponentInContext:aContext];
component=GSWContext_component(aContext);
if (component)
{
[component appendToResponse:aResponse
inContext:aContext];
[self popRefComponentInContext:aContext];
}
else
[aContext _setCurrentComponent:componentPrev];
GSWStopElement(aContext);
GSWAssertDebugElementIDsCount(aContext);
LOGObjectFnStop();
};
//--------------------------------------------------------------------
-(GSWElement*)invokeActionForRequest:(GSWRequest*)request
@ -247,44 +172,50 @@ RCS_ID("$Id$")
GSWElement* element=nil;
GSWComponent* component=nil;
GSWComponent* componentPrev=nil;
GSWDeclareDebugElementIDsCount(aContext);
LOGObjectFnStart();
GSWStartElement(aContext);
GSWAssertCorrectElementID(aContext);
NSDebugMLLog(@"gswdync",@"name=%@ senderId=%@",
_name,GSWContext_senderID(aContext));
componentPrev=GSWContext_component(aContext);
[self pushRefComponentInContext:aContext];
component=GSWContext_component(aContext);
if (component)
{
if ([self prefixMatchSenderIDInContext:aContext]) //Avoid trying to find action if we are not the good component
{
element=[component invokeActionForRequest:request
inContext:aContext];
NSAssert4(!element || [element isKindOfClass:[GSWElement class]],
@"Name= %@, from: %@, Element is a %@ not a GSWElement: %@",
_name,
component,
[element class],
element);
};
[self popRefComponentInContext:aContext];
}
else
[aContext _setCurrentComponent:componentPrev];
GSWStopElement(aContext);
GSWAssertDebugElementIDsCount(aContext);
LOGObjectFnStop();
[self _pushComponentInContext:aContext];
element = [GSWContext_component(aContext) invokeActionForRequest: request
inContext: aContext];
[self _popComponentFromContext:aContext];
return element;
// LOGObjectFnStart();
//
// GSWStartElement(aContext);
// GSWAssertCorrectElementID(aContext);
//
// NSDebugMLLog(@"gswdync",@"name=%@ senderId=%@",
// _name,GSWContext_senderID(aContext));
//
// componentPrev=GSWContext_component(aContext);
// [self _pushComponentInContext:aContext];
//
// component=GSWContext_component(aContext);
// if (component)
// {
// if ([self prefixMatchSenderIDInContext:aContext]) //Avoid trying to find action if we are not the good component
// {
// element=[component invokeActionForRequest:request
// inContext:aContext];
// NSAssert4(!element || [element isKindOfClass:[GSWElement class]],
// @"Name= %@, from: %@, Element is a %@ not a GSWElement: %@",
// _name,
// component,
// [element class],
// element);
// };
// [self _popComponentFromContext:aContext];
// }
// else
// [aContext _setCurrentComponent:componentPrev];
//
// GSWStopElement(aContext);
// GSWAssertDebugElementIDsCount(aContext);
//
// LOGObjectFnStop();
// return element;
};
//--------------------------------------------------------------------
@ -302,13 +233,13 @@ RCS_ID("$Id$")
GSWAssertCorrectElementID(aContext);
componentPrev=GSWContext_component(aContext);
[self pushRefComponentInContext:aContext];
[self _pushComponentInContext:aContext];
component=GSWContext_component(aContext);
if (component)
{
[component takeValuesFromRequest:request
inContext:aContext];
[self popRefComponentInContext:aContext];
[self _popComponentFromContext:aContext];
}
else
[aContext _setCurrentComponent:componentPrev];

View file

@ -46,7 +46,7 @@ RCS_ID("$Id$")
//OK
GSWResponse* response=nil;
GSWApplication* application=[GSWApplication application];
LOGObjectFnStart();
[application lockRequestHandling];
response=[self lockedHandleRequest:aRequest];
if (!response)
@ -57,8 +57,7 @@ RCS_ID("$Id$")
[response _finalizeInContext:nil]; //DO Call _finalizeInContext: !
};
[application unlockRequestHandling];
NSDebugMLLog(@"requests",@"response=%@",response);
LOGObjectFnStop();
return response;
};
@ -76,7 +75,7 @@ RCS_ID("$Id$")
GSWResponse* response=nil;
NSDictionary* requestHandlerValues=nil;
BOOL exceptionRaised=NO;
LOGObjectFnStart();
NS_DURING
{
requestHandlerValues=[GSWComponentRequestHandler _requestHandlerValuesForRequest:aRequest];
@ -103,20 +102,12 @@ RCS_ID("$Id$")
NSString* senderID=nil;
NSString* requestContextID=nil;
NSDebugMLLog(@"requests",@"requestHandlerValues=%@",requestHandlerValues);
//statisticsStore=[[GSWApplication application]statisticsStore];
// NSDebugMLLog(@"requests",@"statisticsStore=%@",statisticsStore);
//[statisticsStore applicationWillHandleComponentActionRequest];
aContext=[[GSWApplication application]createContextForRequest:aRequest];
NSDebugMLLog(@"requests",@"aContext=%@",aContext);
senderID=[requestHandlerValues objectForKey:GSWKey_ElementID[GSWebNamingConv]];
NSDebugMLLog(@"requests",@"AA senderID=%@",senderID);
[aContext _setSenderID:senderID];
requestContextID=[requestHandlerValues objectForKey:GSWKey_ContextID[GSWebNamingConv]];
NSDebugMLLog(@"requests",@"AA requestContextID=%@",requestContextID);
[aContext _setRequestContextID:requestContextID];
[application _setContext:aContext];
@ -173,10 +164,7 @@ RCS_ID("$Id$")
};
[application _setContext:nil];
//statisticsStore=[[GSWApplication application] statisticsStore];
//[statisticsStore applicationDidHandleComponentActionRequest];
NSDebugMLLog(@"requests",@"response=%@",response);
LOGObjectFnStop();
return response;
};
@ -190,11 +178,11 @@ RCS_ID("$Id$")
GSWResponse* errorResponse=nil;
GSWSession* session=nil;
NSString* sessionID=nil;
LOGObjectFnStart();
NS_DURING
{
sessionID=[elements objectForKey:GSWKey_SessionID[GSWebNamingConv]];
NSDebugMLLog(@"requests",@"sessionID=%@",sessionID);
if (sessionID)
{
session=[application restoreSessionWithID:sessionID
@ -209,7 +197,6 @@ RCS_ID("$Id$")
{
// check for refuseNewSessions
session=[application _initializeSessionInContext:aContext];
NSDebugMLLog(@"requests",@"session=%@",session);
}
}
NS_HANDLER
@ -225,7 +212,6 @@ RCS_ID("$Id$")
{
if (session)
{
NSDebugMLLog(@"requests",@"session=%@",session);
NS_DURING
{
response=[self lockedDispatchWithPreparedSession:session
@ -246,17 +232,12 @@ RCS_ID("$Id$")
//======LAST //CLEAN
if (response || errorResponse)
{
NSDebugMLLog(@"requests",@"response=%@",response);
NSDebugMLLog(@"requests",@"errorResponse=%@",errorResponse);
RETAIN(response);
[aContext _putAwakeComponentsToSleep];
[application saveSessionForContext:aContext];
NSDebugMLLog(@"requests",@"session=%@",session);
NSDebugMLLog(@"requests",@"sessionCount=%u",[session retainCount]);
NSDebugMLLog(@"requests",@"response=%@",response);
AUTORELEASE(response);
};
LOGObjectFnStop();
return response ? response : errorResponse;
};
@ -271,26 +252,16 @@ RCS_ID("$Id$")
GSWComponent* page=nil;
BOOL storesIDsInCookies=NO;
NSString* contextID=nil;
LOGObjectFnStart();
NSDebugMLLog(@"requests",@"aSession=%@",aSession);
NSDebugMLLog(@"requests",@"aContext=%@",aContext);
storesIDsInCookies=[aSession storesIDsInCookies]; //For What ?
NSDebugMLLog(@"requests",@"storesIDsInCookies=%s",(storesIDsInCookies ? "YES" : "NO"));
contextID=[elements objectForKey:GSWKey_ContextID[GSWebNamingConv]];//use aContext requestContextID instead ?
NSDebugMLLog(@"requests",@"contextID=%@",contextID);
if (contextID) // ??
{
NSAssert([contextID length]>0,@"contextID empty");
page=[self lockedRestorePageForContextID:contextID
inSession:aSession];
//??
NSDebugMLLog(@"requests",@"contextID=%@",contextID);
NSDebugMLLog(@"requests",@"aSession=%@",aSession);
NSDebugMLLog(@"requests",@"page=%@",page);
if (!page)
{
GSWApplication* application=[aSession application];
@ -301,7 +272,7 @@ RCS_ID("$Id$")
{
NSString* pageName=[elements objectForKey:GSWKey_PageName[GSWebNamingConv]];
NSException* exception=nil;
NSDebugMLLog(@"requests",@"pageName=%@",pageName);
NS_DURING
{
page=[[GSWApplication application] pageWithName:pageName
@ -345,8 +316,7 @@ RCS_ID("$Id$")
};
#endif
};
NSDebugMLLog(@"requests",@"response=%@",response);
LOGObjectFnStop();
return response ? response : errorResponse;
};
@ -372,24 +342,14 @@ RCS_ID("$Id$")
GSWRequest* responseRequest=nil;
NSString* matchingContextID=nil;
LOGObjectFnStart();
NSDebugMLLog(@"requests",@"aComponent=%@",aComponent);
request=[aContext request];
contextID=[elements objectForKey:GSWKey_ContextID[GSWebNamingConv]];
NSDebugMLLog(@"requests",@"contextID=%@",contextID);
response=[GSWApp createResponseInContext:aContext];
NSDebugMLLog(@"requests",@"response=%@",response);
NSDebugMLLog(@"requests",@"aSession=%@",aSession);
NSDebugMLLog(@"requests",@"aContext=%@",aContext);
senderID=GSWContext_senderID(aContext);
NSDebugMLLog(@"requests",@"AA senderID=%@",senderID);
NSDebugMLLog(@"requests",@"AA request=%@",request);
matchingContextID=[aSession _contextIDMatchingIDsInContext:aContext];
NSDebugMLLog(@"requests",@"matchingContextID=%@",matchingContextID);
httpVersion=[request httpVersion];
[response setHTTPVersion:httpVersion];
@ -403,10 +363,8 @@ RCS_ID("$Id$")
page = [self lockedRestorePageForContextID:matchingContextID
inSession:aSession];
[aContext _setPageElement:page];
[[GSWApplication application] appendToResponse:response
inContext:aContext];
NSDebugMLLog(@"requests",@"After appendToResponse GSWContext_elementID(aContext)=%@",
GSWContext_elementID(aContext));
[GSWApp appendToResponse:response
inContext:aContext];
}
else
{
@ -425,14 +383,10 @@ RCS_ID("$Id$")
};
if (hasFormValues)
{
NSDebugMLLog(@"requests",@"Before takeValues GSWContext_elementID(aContext)=%@",
GSWContext_elementID(aContext));
NSAssert([GSWContext_elementID(aContext) length]==0,
@"1 lockedDispatchWithPreparedPage elementID length>0");
[[GSWApplication application] takeValuesFromRequest:request
inContext:aContext];
NSDebugMLLog(@"requests",@"After takeValuesGSWContext_elementID(aContext)=%@",
GSWContext_elementID(aContext));
[GSWApp takeValuesFromRequest:request
inContext:aContext];
if (![GSWContext_elementID(aContext) length]==0)
{
LOGSeriousError0(@"2 lockedDispatchWithPreparedPage elementID length>0");
@ -446,16 +400,15 @@ RCS_ID("$Id$")
{
BOOL pageChanged=NO;
NSException* exception=nil;
NSDebugMLLog(@"requests",@"Before invokeAction GSWContext_elementID(aContext)=%@",
GSWContext_elementID(aContext));
NSAssert([GSWContext_elementID(aContext) length]==0,
@"3 lockedDispatchWithPreparedPage elementID length>0");
// Exception catching here ?
NS_DURING
{
responsePage=(GSWComponent*)[[GSWApplication application] invokeActionForRequest:request
inContext:aContext];
NSDebugMLLog(@"requests",@"After invokeAction GSWContext_elementID(aContext)=%@",GSWContext_elementID(aContext));
responsePage=(GSWComponent*)[GSWApp invokeActionForRequest:request
inContext:aContext];
NSAssert([GSWContext_elementID(aContext) length]==0,@"4 lockedDispatchWithPreparedPage elementID length>0");
}
NS_HANDLER
@ -476,8 +429,7 @@ RCS_ID("$Id$")
DESTROY(exception);
}
NS_ENDHANDLER;
// GSWContext_deleteAllElementIDComponents(aContext);//NDFN
NSDebugMLLog(@"requests",@"responsePage=%@",responsePage);
if (errorResponse)
{
response=errorResponse;
@ -489,10 +441,8 @@ RCS_ID("$Id$")
responsePage=page;
responseContext=[(GSWComponent*)responsePage context];//So what ?
NSDebugMLLog(@"requests",@"responseContext=%@",responseContext);
[responseContext _setPageReplaced:NO];
responsePageElement=(GSWComponent*)[responseContext _pageElement];
NSDebugMLLog(@"requests",@"responsePageElement=%@",responsePageElement);
pageChanged=(responsePage!=responsePageElement);
[responseContext _setPageChanged:pageChanged];//??
if (pageChanged)
@ -514,20 +464,13 @@ RCS_ID("$Id$")
{
NS_DURING
{
NSDebugMLLog(@"requests",@"response before appendToResponse=%@",response);
NSDebugMLLog(@"requests",@"responseContext=%@",responseContext);
NSAssert([GSWContext_elementID(aContext) length]==0,
@"5 lockedDispatchWithPreparedPage elementID length>0");
NSDebugMLLog(@"requests",@"Before appendToResponse GSWContext_elementID(aContext)=%@",
GSWContext_elementID(aContext));
[[GSWApplication application] appendToResponse:response
inContext:responseContext];
NSDebugMLLog(@"requests",@"After appendToResponse GSWContext_elementID(aContext)=%@",
GSWContext_elementID(aContext));
[GSWApp appendToResponse:response
inContext:responseContext];
NSAssert([GSWContext_elementID(aContext) length]==0,
@"6 lockedDispatchWithPreparedPage elementID length>0");
responseRequest=[responseContext request];//SoWhat ?
//Not used [responseRequest isFromClientComponent];//SoWhat
}
NS_HANDLER
{
@ -536,15 +479,13 @@ RCS_ID("$Id$")
[page name],
[page class]);
LOGException(@"exception=%@",localException);
NSDebugMLLog(@"requests",@"context=%@",aContext);
errorResponse=[[GSWApplication application] handleException:localException
inContext:aContext];
}
NS_ENDHANDLER;
};
};
NSDebugMLLog(@"requests",@"response=%@",response);
LOGObjectFnStop();
return errorResponse ? errorResponse : response;
};
@ -573,23 +514,19 @@ RCS_ID("$Id$")
{
//OK
NSDictionary* values=nil;
LOGClassFnStart();
NS_DURING
{
values=[aRequest uriOrFormOrCookiesElements];
NSDebugMLLog(@"requests",@"values=%@",values);
}
NS_HANDLER
{
LOGException(@"%@ (%@)",
localException,
[localException reason]);
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,@"In +_requestHandlerValuesForRequest:");
LOGException(@"exception=%@",localException);
[localException raise];
};
NS_ENDHANDLER;
LOGClassFnStop();
return values;
};

View file

@ -36,39 +36,12 @@
//====================================================================
@interface GSWConditional: GSWDynamicElement
@interface GSWConditional: GSWDynamicGroup
{
GSWAssociation* _condition;
//GSWeb Additions {
GSWAssociation* _value;
GSWAssociation* _conditionValue;
// }
GSWAssociation* _negate;
GSWHTMLStaticGroup* _childrenGroup;
};
-(id)initWithName:(NSString*)aName
associations:(NSDictionary*)associations
contentElements:(NSArray*)elements;
-(id)initWithName:(NSString*)aName
associations:(NSDictionary*)associations
template:(GSWElement*)templateElement;
-(NSString*)description;
-(void)dealloc;
@end
//====================================================================
@interface GSWConditional (GSWConditionalA)
-(void)appendToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext;
-(GSWElement*)invokeActionForRequest:(GSWRequest*)aRequest
inContext:(GSWContext*)aContext;
-(void)takeValuesFromRequest:(GSWRequest*)aRequest
inContext:(GSWContext*)aContext;
@end

View file

@ -41,13 +41,7 @@ Bindings
condition if evaluated to YES (or NO if negate evaluted to YES), the enclosed code is emitted/used
value if evaluated value is equal to conditionValue evaluated value, the enclosed code is
emitted/used (or not equal if negate evaluated to YES);
conditionValue if evaluated value is equal to conditionValue evaluated value, the enclosed code is
emitted/used (or not equal if negate evaluated to YES);
negate If evaluated to yes, negate the condition (defaut=NO)
negate If evaluated to yes, negate the condition (defaut=NO)
**/
static GSWIMP_BOOL standardEvaluateConditionInContextIMP = NULL;
@ -74,287 +68,89 @@ static Class standardClass = Nil;
associations:(NSDictionary*)someAssociations
template:(GSWElement*)templateElement
{
//OK
LOGObjectFnStart();
if ((self=[self initWithName:aName
associations:someAssociations
contentElements:templateElement ? [NSArray arrayWithObject:templateElement] : nil]))
{
};
LOGObjectFnStop();
self = [super initWithName:nil associations:nil template: templateElement];
if (!self) {
return nil;
}
// here, we do not need to remove associations
ASSIGN(_condition, [someAssociations objectForKey: condition__Key]);
ASSIGN(_negate, [someAssociations objectForKey: negate__Key]);
if (_condition == nil) {
[NSException raise:NSInvalidArgumentException
format:@"%s: Missing 'condition' attribute.",
__PRETTY_FUNCTION__];
}
return self;
};
//--------------------------------------------------------------------
-(id)initWithName:(NSString*)aName
associations:(NSDictionary*)associations
contentElements:(NSArray*)elements
{
LOGObjectFnStart();
if ((self=[super initWithName:aName
associations:nil
template:nil]))
{
if (elements)
_childrenGroup=[[GSWHTMLStaticGroup alloc]initWithContentElements:elements];
_condition = [[associations objectForKey:condition__Key
withDefaultObject:[_condition autorelease]] retain];
NSDebugMLLog(@"gswdync",@"GSWConditional condition=%@",_condition);
if (!WOStrictFlag)
{
_value = [[associations objectForKey:value__Key
withDefaultObject:[_value autorelease]] retain];
NSDebugMLLog(@"gswdync",@"GSWConditional value=%@",_value);
_conditionValue = [[associations objectForKey:conditionValue__Key
withDefaultObject:[_conditionValue autorelease]] retain];
NSDebugMLLog(@"gswdync",@"GSWConditional conditionValue=%@",_conditionValue);
if (_conditionValue && !_value)
ExceptionRaise0(@"GSWConditional",
@"'conditionValue' parameter need 'value' parameter");
if (_value && !_conditionValue)
ExceptionRaise0(@"GSWConditional",
@"'value' parameter need 'conditionValue' parameter");
if (_conditionValue && _condition)
ExceptionRaise0(@"GSWConditional",
@"You can't have 'condition' parameter with 'value' and 'conditionValue' parameters");
};
_negate = [[associations objectForKey:negate__Key
withDefaultObject:[_negate autorelease]] retain];
NSDebugMLLog(@"gswdync",@"GSWConditional negate=%@",_negate);
};
LOGObjectFnStop();
return self;
};
//--------------------------------------------------------------------
-(void)dealloc
{
DESTROY(_condition);
DESTROY(_value);
//GSWeb Additions {
DESTROY(_conditionValue);
DESTROY(_negate);
// }
DESTROY(_childrenGroup);
[super dealloc];
}
//--------------------------------------------------------------------
-(void)setDeclarationName:(NSString*)declarationName
{
[super setDeclarationName:declarationName];
if (declarationName && _childrenGroup)
[_childrenGroup setDeclarationName:[declarationName stringByAppendingString:@"-StaticGroup"]];
};
//--------------------------------------------------------------------
-(NSString*)description
{
return [NSString stringWithFormat:@"<%s %p>",
return [NSString stringWithFormat:@"<%s %p condition: %@ negate: %@>",
object_get_class_name(self),
(void*)self];
(void*)self, _condition, _negate];
};
@end
//====================================================================
@implementation GSWConditional (GSWConditionalA)
//--------------------------------------------------------------------
-(void)takeValuesFromRequest:(GSWRequest*)aRequest
inContext:(GSWContext*)aContext
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context
{
//OK
BOOL condition=NO;
BOOL negate=NO;
BOOL doIt=NO;
LOGObjectFnStart();
GSWStartElement(aContext);
GSWAssertCorrectElementID(aContext);
if (!WOStrictFlag && _conditionValue)
{
GSWComponent* component=GSWContext_component(aContext);
id conditionValueValue=[_conditionValue valueInComponent:component];
id valueValue=[_value valueInComponent:component];
NSDebugMLog(@"_conditionValue=%@ conditionValueValue=%@",
_conditionValue,conditionValueValue);
NSDebugMLog(@"_value=%@ valueValue=%@",
_value,valueValue);
condition=SBIsValueEqual(conditionValueValue,valueValue);
}
else
{
condition=GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_condition,aContext);
};
GSWComponent * component = GSWContext_component(context);
BOOL conVal = [_condition boolValueInComponent:component];
BOOL doNegate = NO;
if (_negate != nil) {
doNegate = [_negate boolValueInComponent:component];
}
if ((conVal && !doNegate) || (!conVal && doNegate)) {
[super takeValuesFromRequest:request inContext:context];
}
}
if (_negate)
{
negate=GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_negate,aContext);
};
doIt=condition;
NSDebugMLLog(@"gswdync",@"elementID=%@",GSWContext_elementID(aContext));
if (negate)
doIt=!doIt;
NSDebugMLLog(@"gswdync",@"declarationName=%@ condition=%@ negate=%@ evaluatedCondition=%s evaluatedNegate=%s doIt=%s",
[self declarationName],
_condition,
_negate,
(condition ? "YES" : "NO"),
(negate ? "YES" : "NO"),
(doIt ? "YES" : "NO"));
if (doIt)
{
//GSWRequest* _request=[aContext request];
//Deprecated BOOL isFromClientComponent=[_request isFromClientComponent];
GSWContext_appendZeroElementIDComponent(aContext);
[_childrenGroup takeValuesFromRequest:aRequest
inContext:aContext];
GSWContext_deleteLastElementIDComponent(aContext);
};
GSWStopElement(aContext);
GSWAssertIsElementID(aContext);
LOGObjectFnStop();
};
//--------------------------------------------------------------------
-(GSWElement*)invokeActionForRequest:(GSWRequest*)aRequest
inContext:(GSWContext*)aContext
-(GSWElement*)invokeActionForRequest:(GSWRequest*) request
inContext:(GSWContext*) context
{
//OK
GSWElement* element=nil;
BOOL condition=NO;
BOOL negate=NO;
BOOL doIt=NO;
LOGObjectFnStart();
GSWStartElement(aContext);
GSWAssertCorrectElementID(aContext);
if (!WOStrictFlag && _conditionValue)
{
GSWComponent* component=GSWContext_component(aContext);
id conditionValueValue=[_conditionValue valueInComponent:component];
id valueValue=[_value valueInComponent:component];
NSDebugMLog(@"_conditionValue=%@ conditionValueValue=%@",
_conditionValue,conditionValueValue);
NSDebugMLog(@"_value=%@ valueValue=%@",
_value,valueValue);
condition=SBIsValueEqual(conditionValueValue,valueValue);
}
else
{
condition=GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_condition,aContext);
};
GSWComponent * component = GSWContext_component(context);
BOOL conVal = [_condition boolValueInComponent:component];
BOOL doNegate = NO;
if (_negate != nil) {
doNegate = [_negate boolValueInComponent:component];
}
if ((conVal && !doNegate) || (!conVal && doNegate)) {
return [super invokeActionForRequest:request inContext:context];
} else {
return nil;
}
}
if (_negate)
{
negate=GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_negate,aContext);
};
doIt=condition;
if (negate)
doIt=!doIt;
NSDebugMLLog(@"gswdync",@"declarationName=%@ condition=%@ negate=%@ evaluatedCondition=%s evaluatedNegate=%s doIt=%s",
[self declarationName],
_condition,
_negate,
(condition ? "YES" : "NO"),
(negate ? "YES" : "NO"),
(doIt ? "YES" : "NO"));
if (doIt)
{
//GSWRequest* request=[aContext request];
//Deprecated BOOL isFromClientComponent=[request isFromClientComponent];
GSWContext_appendZeroElementIDComponent(aContext);
NSDebugMLLog(@"gswdync",@"childrenGroup=%@",_childrenGroup);
element=[_childrenGroup invokeActionForRequest:aRequest
inContext:aContext];
NSDebugMLLog(@"gswdync",@"element=%@",element);
NSAssert2(!element || [element isKindOfClass:[GSWElement class]],
@"Element is a %@ not a GSWElement: %@",
[element class],
element);
GSWContext_deleteLastElementIDComponent(aContext);
};
GSWStopElement(aContext);
GSWAssertIsElementID(aContext);
LOGObjectFnStop();
return element;
};
//--------------------------------------------------------------------
-(void)appendToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
-(void)appendToResponse:(GSWResponse*) response
inContext:(GSWContext*) context
{
//OK
BOOL condition=NO;
BOOL negate=NO;
BOOL doIt=NO;
LOGObjectFnStart();
GSWStartElement(aContext);
GSWSaveAppendToResponseElementID(aContext);
if (!WOStrictFlag && _conditionValue)
{
GSWComponent* component=GSWContext_component(aContext);
id conditionValueValue=[_conditionValue valueInComponent:component];
id valueValue=[_value valueInComponent:component];
NSDebugMLog(@"_conditionValue=%@ conditionValueValue=%@",
_conditionValue,conditionValueValue);
NSDebugMLog(@"_value=%@ valueValue=%@",
_value,valueValue);
condition=SBIsValueEqual(conditionValueValue,valueValue);
}
else
{
condition=GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_condition,aContext);
};
NSDebugMLLog(@"gswdync",@"condition=%s",condition ? "YES" : "NO");
if (_negate)
{
negate=GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_negate,aContext);
};
NSDebugMLLog(@"gswdync",@"negate=%s",negate ? "YES" : "NO");
doIt=condition;
if (negate)
doIt=!doIt;
NSDebugMLLog(@"gswdync",@"declarationName=%@ condition=%@ negate=%@ evaluatedCondition=%s evaluatedNegate=%s doIt=%s",
[self declarationName],
_condition,
_negate,
(condition ? "YES" : "NO"),
(negate ? "YES" : "NO"),
(doIt ? "YES" : "NO"));
if (doIt)
{
//GSWRequest* request=[aContext request];
//Deprecated BOOL isFromClientComponent=[request isFromClientComponent];
GSWContext_appendZeroElementIDComponent(aContext);
[_childrenGroup appendToResponse:aResponse
inContext:aContext];
GSWContext_deleteLastElementIDComponent(aContext);
};
GSWStopElement(aContext);
GSWAssertIsElementID(aContext);
LOGObjectFnStop();
};
GSWComponent * component = GSWContext_component(context);
BOOL conVal = [_condition boolValueInComponent:component];
BOOL doNegate = NO;
if (_negate != nil) {
doNegate = [_negate boolValueInComponent:component];
}
// GSWResponse_appendContentAsciiString(response,@"<!-- CON ( -->");
// NSLog(@"%@ doNegate:%d conVal:%d", self, doNegate, conVal);
if ((conVal && (!doNegate)) || ((!conVal) && doNegate)) {
// NSLog(@"append!");
[super appendChildrenToResponse:response inContext:context];
}
// GSWResponse_appendContentAsciiString(response,@"<!-- CON ) -->");
}
@end

View file

@ -296,7 +296,10 @@ GSWEB_EXPORT NSString* GSWTag_Name[2];
//====================================================================
// Components Keys
GSWEB_EXPORT id post__Key;
GSWEB_EXPORT id method__Key;
GSWEB_EXPORT id value__Key;
GSWEB_EXPORT id valueWhenEmpty__Key;
GSWEB_EXPORT id action__Key;
GSWEB_EXPORT id name__Key;
GSWEB_EXPORT id disabled__Key;
@ -362,6 +365,7 @@ GSWEB_EXPORT id directActionName__Key;
GSWEB_EXPORT id file__Key;
GSWEB_EXPORT id data__Key;
GSWEB_EXPORT id mimeType__Key;
GSWEB_EXPORT id type__Key;
GSWEB_EXPORT id key__Key;
GSWEB_EXPORT id selectedValue__Key;
GSWEB_EXPORT id noSelectionString__Key;
@ -392,6 +396,7 @@ GSWEB_EXPORT id pageDesign__Key;
GSWEB_EXPORT id imageMapString__Key;
GSWEB_EXPORT id imageMapRegions__Key;
GSWEB_EXPORT id handleValidationException__Key;
// at least this one exists on WO too. dave w.
GSWEB_EXPORT id selectedValues__Key;
GSWEB_EXPORT id startIndex__Key;
GSWEB_EXPORT id stopIndex__Key;

View file

@ -293,7 +293,10 @@ NSString* GSWTag_Name[2]={ @"gsweb", @"webobject" };
//====================================================================
// Components Keys
id post__Key = @"post";
id method__Key = @"method";
id value__Key = @"value";
id valueWhenEmpty__Key = @"valueWhenEmpty";
id action__Key = @"action";
id name__Key = @"name";
id disabled__Key = @"disabled";
@ -359,6 +362,7 @@ id directActionName__Key = @"directActionName";
id file__Key = @"file";
id data__Key = @"data";
id mimeType__Key = @"mimeType";
id type__Key = @"type";
id key__Key = @"key";
id selectedValue__Key = @"selectedValue";
id noSelectionString__Key = @"noSelectionString";

View file

@ -69,10 +69,13 @@ GSWEB_EXPORT BOOL GSWContext_isSenderIDSearchOver(GSWContext* aContext);
@interface GSWContext : NSObject <NSCopying>
{
@private
GSWResourceManager* _resourceManager;
unsigned _contextID;
NSString* _senderID;
NSString* _requestSessionID;
NSString* _requestContextID;
NSString* _componentName;
GSWComponentDefinition* _tempComponentDefinition;
GSWElementID* _elementID;
GSWSession* _session;
GSWRequest* _request;
@ -88,7 +91,7 @@ GSWEB_EXPORT BOOL GSWContext_isSenderIDSearchOver(GSWContext* aContext);
BOOL _pageChanged;
BOOL _pageReplaced;
BOOL _generateCompleteURLs;
BOOL _isInForm;
BOOL _inForm;
BOOL _isInEnabledForm;
BOOL _actionInvoked;
BOOL _formSubmitted;
@ -120,10 +123,16 @@ GSWEB_EXPORT BOOL GSWContext_isSenderIDSearchOver(GSWContext* aContext);
-(BOOL)isInForm;
-(void)setInEnabledForm:(BOOL)flag;
-(BOOL)isInEnabledForm;
- (GSWDynamicURLString*) _url;
-(void)_createElementID;
-(NSString*)elementID;
-(NSString*)contextAndElementID;
-(GSWComponent*)component;
-(NSString*) _componentName;
- (void) _setComponentName:(NSString*) newValue;
- (GSWComponentDefinition*) _tempComponentDefinition;
- (void) _setTempComponentDefinition:(GSWComponentDefinition*) newValue;
-(GSWComponent*)page;
-(GSWResponse*)response;
-(GSWRequest*)request;
@ -151,10 +160,7 @@ GSWEB_EXPORT BOOL GSWContext_isSenderIDSearchOver(GSWContext* aContext);
-(void)addDocStructureStep:(NSString*)stepLabel;
-(NSString*)docStructure;
#endif
@end
//====================================================================
@interface GSWContext (GSWURLGeneration)
-(GSWDynamicURLString*)directActionURLForActionNamed:(NSString*)actionName
urlPrefix:(NSString*)urlPrefix
queryDictionary:(NSDictionary*)queryDictionary;
@ -249,15 +255,9 @@ GSWEB_EXPORT BOOL GSWContext_isSenderIDSearchOver(GSWContext* aContext);
queryString:(NSString*)queryString
isSecure:(BOOL)isSecure
port:(int)port;
@end
//====================================================================
@interface GSWContext (GSWContextA)
-(id)_initWithContextID:(unsigned int)contextID;
@end
//====================================================================
@interface GSWContext (GSWContextB)
-(BOOL)_isMultipleSubmitForm;
-(void)_setIsMultipleSubmitForm:(BOOL)flag;
-(BOOL)_wasActionInvoked;
@ -309,6 +309,9 @@ GSWEB_EXPORT BOOL GSWContext_isSenderIDSearchOver(GSWContext* aContext);
queryDictionary:(NSDictionary*)dict
pathQueryDictionary:(NSDictionary*)pathQueryDictionary
url:(id)url;
-(GSWDynamicURLString*) _componentActionURL;
/** Returns array of languages
First try session languages, if none, try self language
If none, try request languages
@ -346,10 +349,7 @@ If none, try request languages
// context can add key/values in query dictionary
-(NSDictionary*)computeQueryDictionary:(NSDictionary*)queryDictionary;
-(NSDictionary*)computePathQueryDictionary:(NSDictionary*)queryDictionary;
@end
//====================================================================
@interface GSWContext (GSWContextElementID)
-(void)deleteAllElementIDComponents;
-(void)deleteLastElementIDComponent;
-(void)incrementLastElementIDComponent;
@ -359,20 +359,17 @@ If none, try request languages
-(BOOL)isParentSenderIDSearchOver;
-(BOOL)isSenderIDSearchOver;
-(int)elementIDElementsCount;
@end
//====================================================================
@interface GSWContext (GSWContextD)
-(NSString*)url;
-(NSString*)urlSessionPrefix;
-(int)urlApplicationNumber;
-(GSWApplication*)application;
-(void)setDistributionEnabled:(BOOL)flag;
-(BOOL)isDistributionEnabled;
@end
//====================================================================
@interface GSWContext (GSWContextGSWeb)
- (NSString*) _urlForResourceNamed: (NSString*)aName
inFramework: (NSString*)frameworkName;
-(BOOL)isValidate;
-(void)setValidate:(BOOL)isValidate;
@end

File diff suppressed because it is too large Load diff

View file

@ -61,10 +61,6 @@
-(void)setPool:(NSAutoreleasePool*)pool
destroyLast:(BOOL)destroy;
+(NSMutableArray*)completeLinesWithData:(NSMutableData*)data
returnedConsumedCount:(int*)consumedCount
returnedHeadersEndFlag:(BOOL*)headersEndFlag;
-(BOOL)readRequestReturnedRequestLine:(NSString**)requestLine
returnedHeaders:(NSDictionary**)headers
returnedData:(NSData**)data;

View file

@ -79,7 +79,6 @@ static NSData* lineFeedData=nil;
ASSIGN(_stream,stream);
_keepAlive=NO;
_isMultiThread=[adaptor isMultiThreadEnabled];
NSDebugDeepMLLog(@"info",@"isMultiThread=%d",(int)_isMultiThread);
};
return self;
};
@ -87,15 +86,11 @@ static NSData* lineFeedData=nil;
//--------------------------------------------------------------------
-(void)dealloc
{
GSWLogMemC("dealloc GSWDefaultAdaptorThread");
DESTROY(_stream);
GSWLogMemC("release dates");
DESTROY(_remoteAddress);
GSWLogMemC("release pool");
DESTROY(_pool);
GSWLogMemC("super dealloc");
[super dealloc];
GSWLogMemC("dealloc GSWDefaultAdaptorThread end");
};
//--------------------------------------------------------------------
@ -114,14 +109,9 @@ static NSData* lineFeedData=nil;
-(void)setPool:(NSAutoreleasePool*)pool
destroyLast:(BOOL)destroy
{
if (destroy)
{
GSWLogMemC("dealloc pool");
GSWLogMemCF("Destroy NSAutoreleasePool: %p. %@",
_pool, GSCurrentThread());
if (destroy) {
DESTROY(_pool);
GSWLogMemC("end dealloc pool");
};
};
_pool=pool;
};
@ -136,7 +126,6 @@ static NSData* lineFeedData=nil;
DESTROY(_pool);
_pool=[NSAutoreleasePool new];
GSWLogMemCF("New NSAutoreleasePool: %p",_pool);
#ifdef GSWDEBUG_DEEP
[GSWApplication logString:@"pool allocated!"];
#endif
@ -165,13 +154,11 @@ static NSData* lineFeedData=nil;
object:[NSThread currentThread]];
*/
};
NSDebugDeepMLLog(@"low",@"application:%@",_application);
NS_DURING
{
requestOk=[self readRequestReturnedRequestLine:&requestLine
returnedHeaders:&headers
returnedData:&data];
returnedData:&data];
}
NS_HANDLER
{
@ -187,10 +174,7 @@ static NSData* lineFeedData=nil;
{
GSWRequest* request=nil;
GSWResponse* response=nil;
NSDebugMLLog(@"info",@"GSWDefaultAdaptorThread: runWithStream requestLine=%@ headers=%@ data=%@",
requestLine,
headers,
data);
NS_DURING
{
request=[self createRequestFromRequestLine:requestLine
@ -199,7 +183,6 @@ static NSData* lineFeedData=nil;
}
NS_HANDLER
{
NSDebugMLog(@"localException=%@",localException);
LOGException(@"GSWDefaultAdaptorThread: createRequestFromData Exception:%@ (%@)",
localException,[localException reason]);
}
@ -208,7 +191,6 @@ static NSData* lineFeedData=nil;
{
//call application resourceRequestHandlerKey (retourne wr)
//call requets requestHandlerKey (retorune nil)
NSDebugMLLog(@"info",@"GSWDefaultAdaptorThread: run handleRequest:%@",request);
_beginDispatchRequestTS=GSWTime_now();
NS_DURING
{
@ -246,16 +228,10 @@ static NSData* lineFeedData=nil;
[localException userInfo]);
}
NS_ENDHANDLER;
NSDebugMLLog(@"low",@"application:%@",_application);
AUTORELEASE(response);
};
};
};
NSDebugMLog(@"GSWDefaultAdaptorThread: %@ run end",
GSCurrentThread());
NSDebugMLLog(@"low",@"application:%@",
_application);
LOGObjectFnStop();
#ifdef DEBUG
[GSWApplication statusLogString:@"threadWillExit START"];
#endif
@ -278,17 +254,12 @@ static NSData* lineFeedData=nil;
//--------------------------------------------------------------------
-(void)threadExited
{
// LOGObjectFnStart();
// NSDebugMLLog0(@"trace",@"GSWDefaultAdaptorThread: threadExited method");
// NSDebugMLLog(@"low",@"[_defaultAdaptorThread retainCount=%d",
// (int)[self retainCount]);
[_adaptor adaptorThreadExited:self];
GSWLogMemCF("Will Destroy NSAutoreleasePool: %p",_pool);
[self setPool:nil
destroyLast:YES];
[GSWApp debugAdaptorThreadExited];
// LOGObjectFnStop();
GSWLogDeepC("threadExited");
};
//--------------------------------------------------------------------
@ -297,15 +268,11 @@ static NSData* lineFeedData=nil;
NSThread* thread=nil;
NSMutableDictionary* threadDict=nil;
GSWDefaultAdaptorThread* adaptorThread=nil;
GSWLogDeepC("Start threadExited:");
NSAssert([NSThread isMultiThreaded],@"No MultiThread !");
NSDebugMLLog(@"low",@"notif=%@",notif);
thread=[notif object];
NSDebugMLLog(@"low",@"thread=%@",thread);
threadDict = [thread threadDictionary];
NSDebugMLLog(@"low",@"threadDict=%@",threadDict);
adaptorThread=[threadDict objectForKey:GSWThreadKey_DefaultAdaptorThread];
NSDebugMLLog(@"low",@"adaptorThread=%@",adaptorThread);
[threadDict removeObjectForKey:GSWThreadKey_DefaultAdaptorThread];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:NSThreadWillExitNotification
@ -315,61 +282,101 @@ static NSData* lineFeedData=nil;
object:_thread];
*/
[adaptorThread threadExited];
GSWLogDeepC("Stop threadExited:");
GSWLogDeepC("threadExited really exit");
return nil; //??
};
//--------------------------------------------------------------------
+(NSMutableArray*)completeLinesWithData:(NSMutableData*)data
returnedConsumedCount:(int*)consumedCount
returnedHeadersEndFlag:(BOOL*)headersEndFlag
NSMutableArray* unpackData(NSMutableData* data)
{
NSMutableArray* lines=nil;
int length=0;
LOGClassFnStart();
length=[data length];
if (length>0)
{
NSMutableArray* lines = [NSMutableArray new];
int length = [data length];
if (length>0) {
NSRange range=NSMakeRange(0,0);
int i=0;
int lastIndex=0;
NSString * tmpString = nil;
char* dataBytes=(char*)[data mutableBytes];
BOOL endHeaders=NO;
while(!endHeaders && i<length)
{
if (dataBytes[i]=='\n')
{
if (range.length>0)
{
NSString* tmpString=[[[NSString alloc]initWithData:[data subdataWithRange:range]
encoding:NSASCIIStringEncoding]autorelease];
if (!lines)
lines=[NSMutableArray array];
[lines addObject:tmpString];
}
else // End Header
{
endHeaders=YES;
};
range.location=i+1;
range.length=0;
if (dataBytes[i]=='\n') {
range.location=lastIndex;
range.length=(i-range.location);
lastIndex = i+1;
if (range.length > 1) {
tmpString=[[NSString alloc] initWithData: [data subdataWithRange:range]
encoding:NSASCIIStringEncoding];
[lines addObject: [tmpString stringByTrimmingSpaces]];
[tmpString release];
} else {
endHeaders=YES;
}
else
range.length++;
i++;
};
range.length=length-range.location;
if (range.length>0)
memcpy(dataBytes,dataBytes+range.location,range.length);
[data setLength:range.length];
if (consumedCount)
*consumedCount=length-range.length;
if (headersEndFlag)
*headersEndFlag=endHeaders;
};
LOGClassFnStop();
return lines;
};
} else {
i++;
}
}
}
return [lines autorelease];
}
- (NSDictionary*) unpackHeaders:(NSArray*) lines
{
NSMutableDictionary* headers = [NSMutableDictionary dictionary];
int count = 0;
int i = 0;
NSArray* prevValue = nil;
if ((lines) && ([lines count] > 1)) {
count = [lines count];
for (i=1;i<count-1;i++) {
NSString * tmpLine = [lines objectAtIndex:i];
NSArray * components = [tmpLine componentsSeparatedByString:@": "];
NSString * value = nil;
NSArray * newValue = nil;
NSString * key = nil;
if ((components) && ([components count] == 2)) {
value = [components objectAtIndex:1];
key = [components objectAtIndex:0];
key = [[key stringByTrimmingSpaces] lowercaseString];
if ([key isEqualToString:GSWHTTPHeader_AdaptorVersion[GSWNAMES_INDEX]]
|| [key isEqualToString:GSWHTTPHeader_ServerName[GSWNAMES_INDEX]]) {
_requestNamingConv=GSWNAMES_INDEX;
goto keyDone;
}
if ([key isEqualToString:GSWHTTPHeader_AdaptorVersion[WONAMES_INDEX]]
|| [key isEqualToString:GSWHTTPHeader_ServerName[WONAMES_INDEX]]) {
_requestNamingConv=WONAMES_INDEX;
goto keyDone;
}
keyDone:
prevValue=[headers objectForKey:key];
if (prevValue) {
newValue=[prevValue arrayByAddingObject:value];
} else {
newValue=[NSArray arrayWithObject:value];
}
[headers setObject: newValue
forKey: key];
}
}
}
return headers;
}
//--------------------------------------------------------------------
/** read request from crrent stream and put request line, headers and data in
@ -379,199 +386,117 @@ static NSData* lineFeedData=nil;
returnedHeaders:(NSDictionary**)headersPtr
returnedData:(NSData**)dataPtr
{
BOOL ok=NO;
LOGObjectFnStart();
NSMutableData* pendingData=nil;
NSData* dataBlock=nil;
NSData* dataBlock2=nil;
int totalBytes=0;
int tries=0;
int dataBlockLength=0;
int contentLength=-1;
BOOL newLineSeen=NO;
BOOL allDataRead=NO;
BOOL isElapsed=NO;
BOOL headersDone=NO;
NSArray *listItems = nil;
NSMutableData * allMimeData = nil;
NSDictionary * headerDict = nil;
#define MAX_HEADER_BYTES 1000
time_t starttime, now;
if (!_stream)
{
ExceptionRaise0(@"GSWDefaultAdaptorThread",@"no stream");
}
else
{
#define REQUEST_METHOD__UNKNOWN 0
#define REQUEST_METHOD__GET 1
#define REQUEST_METHOD__POST 2
NSMutableData* pendingData=nil;
NSDate* maxDate=[NSDate dateWithTimeIntervalSinceNow:360]; //360s
NSData* dataBlock=nil;
int readenBytesNb=0;
int headersBytesNb=0;
int dataBytesNb=0;
int dataBlockLength=0;
int contentLength=-1;
int requestMethod=REQUEST_METHOD__UNKNOWN;
BOOL isRequestLineSetted=NO;
BOOL isDataStep=NO;
BOOL isAllDataReaden=NO;
BOOL isElapsed=NO;
NSMutableDictionary* headers=nil;
NSString* userAgent=nil;
NSString* remoteAddr=nil;
NSDebugDeepMLog0(@"dataBlock try reading");
do
{
dataBlock=[_stream availableDataNonBlocking];
dataBlockLength=[dataBlock length];
NSDebugDeepMLog(@"dataBlockLength=%i",dataBlockLength);
if (dataBlockLength>0)
{
readenBytesNb+=dataBlockLength;
if (!pendingData)
pendingData=(NSMutableData*)[NSMutableData data];
[pendingData appendData:dataBlock];
if (isDataStep)
dataBytesNb=[pendingData length];
else
{
int newBytesCount=0;
NSMutableArray* newLines=[GSWDefaultAdaptorThread completeLinesWithData:pendingData
returnedConsumedCount:&newBytesCount
returnedHeadersEndFlag:&isDataStep];
NSDebugDeepMLLog(@"low",@"newLines=%p",newLines);
NSDebugDeepMLLog(@"low",@"newLines=%@",newLines);
NSDebugDeepMLLog(@"low",@"isDataStep=%s newBytesCount=%d",
isDataStep ? "YES" : "NO",
newBytesCount);
headersBytesNb+=newBytesCount;
if (newLines)
{
int i=0;
int newLinesCount=[newLines count];
for(i=0;i<newLinesCount;i++)
{
NSString* line=[newLines objectAtIndex:i];
NSDebugDeepMLLog(@"low",@"Line=%@",line);
NSAssert([line length]>0,@"No line length");
if (!isRequestLineSetted)
{
*requestLinePtr=line;
isRequestLineSetted=YES;
}
else
{
NSString* key=nil;
NSString* value=nil;
NSArray* newValue=nil;
NSArray* prevValue=nil;
NSRange keyRange=[line rangeOfString:@":"];
if (keyRange.length<=0)
{
key=line;
NSDebugDeepMLLog(@"low",@"key=%@",key);
value=[NSString string];
}
else
{
key=[line substringToIndex:keyRange.location];
NSDebugDeepMLLog(@"low",@"location=%d key=%@",
keyRange.location,
key);
key=[[key stringByTrimmingSpaces] lowercaseString];
NSDebugDeepMLLog(@"low",@"location=%d line length=%d key=%@",
keyRange.location,
[line length],
key);
if (keyRange.location+1<[line length])
{
value=[line substringFromIndex:keyRange.location+1];
NSDebugDeepMLLog(@"low",@"value lengt=%d value=*%@*",
[value length],
value);
value=[value stringByTrimmingSpaces];
NSDebugDeepMLLog(@"low",@"value=%@",
value);
}
else
value=[NSString string];
NSDebugDeepMLLog(@"low",@"value:%@",value);
};
NSDebugDeepMLLog(@"low",@"key:%@ value:%@",key,value);
if ([key isEqualToString:GSWHTTPHeader_ContentLength])
contentLength=[value intValue];
else if ([key isEqualToString:GSWHTTPHeader_Method[GSWNAMES_INDEX]]
|| [key isEqualToString:GSWHTTPHeader_Method[WONAMES_INDEX]])
{
if ([value isEqualToString:GSWHTTPHeader_MethodPost])
requestMethod=REQUEST_METHOD__POST;
else if ([value isEqualToString:GSWHTTPHeader_MethodGet])
requestMethod=REQUEST_METHOD__GET;
else
{
NSAssert1(NO,@"Unknown method %@",value);
};
}
else if ([key isEqualToString:GSWHTTPHeader_UserAgent])
userAgent=value;
else if ([key isEqualToString:GSWHTTPHeader_RemoteAddress[GSWNAMES_INDEX]]
||[key isEqualToString:GSWHTTPHeader_RemoteAddress[WONAMES_INDEX]])
remoteAddr=value;
if ([key isEqualToString:GSWHTTPHeader_AdaptorVersion[GSWNAMES_INDEX]]
|| [key isEqualToString:GSWHTTPHeader_ServerName[GSWNAMES_INDEX]])
_requestNamingConv=GSWNAMES_INDEX;
else if ([key isEqualToString:GSWHTTPHeader_AdaptorVersion[WONAMES_INDEX]]
|| [key isEqualToString:GSWHTTPHeader_ServerName[WONAMES_INDEX]])
_requestNamingConv=WONAMES_INDEX;
prevValue=[headers objectForKey:key];
NSDebugDeepMLLog(@"low",@"prevValue:%@",prevValue);
if (prevValue)
newValue=[prevValue arrayByAddingObject:value];
else
newValue=[NSArray arrayWithObject:value];
if (!headers)
headers=(NSMutableDictionary*)[NSMutableDictionary dictionary];
[headers setObject:newValue
forKey:key];
};
};
};
};
};
NSDebugDeepMLog(@"requestMethod=%d",requestMethod);
dataBytesNb=[pendingData length];
if (isDataStep)
{
if (requestMethod==REQUEST_METHOD__GET)
isAllDataReaden=YES;
else if (requestMethod==REQUEST_METHOD__POST)
isAllDataReaden=(dataBytesNb>=contentLength);
};
if (!isAllDataReaden)
{
/* Because +date returns (id) we use the variable
to insure the compiler finds the correct signature. */
NSDate *now = [NSDate date];
isElapsed =[now compare: maxDate]==NSOrderedDescending;
};
} while (!isAllDataReaden && !isElapsed);
ASSIGN(_remoteAddress,remoteAddr);
NSDebugDeepMLog(@"GSWDefaultAdaptor: userAgent=%@ remoteAddr=%@ isAllDataReaden=%s isElapsed=%s readenBytesNb=%d contentLength=%d dataBytesNb=%d headersBytesNb=%d",
userAgent,
remoteAddr,
isAllDataReaden ? "YES" : "NO",
isElapsed ? "YES" : "NO",
readenBytesNb,
contentLength,
dataBytesNb,
headersBytesNb);
ok=isAllDataReaden;
if (isAllDataReaden)
{
*headersPtr=[[headers copy] autorelease];
if ([pendingData length]>0)
*dataPtr=[pendingData copy];
else
*dataPtr=nil;
{
ExceptionRaise0(@"GSWDefaultAdaptorThread",@"no stream");
}
time(&starttime);
struct timeval timeout;
timeout.tv_sec = 5;
timeout.tv_usec = 0;
setsockopt([_stream fileDescriptor], SOL_SOCKET, SO_RCVTIMEO, &timeout,sizeof(timeout));
while (((allDataRead == NO) && (isElapsed == NO)) && (totalBytes < MAX_HEADER_BYTES)) {
char buffer[5];
dataBlock= [_stream readDataOfLength:1];
dataBlockLength=[dataBlock length];
if (dataBlockLength>0) {
[dataBlock getBytes:buffer];
if ((buffer[0] == 0xa)) {
if ((newLineSeen)) {
headersDone = YES;
}
newLineSeen = YES;
} else {
if ((buffer[0] != 0xd)) { // cr
newLineSeen = NO;
}
}
else
{
*requestLinePtr=nil;
*headersPtr=nil;
*dataPtr=nil;
};
}
LOGObjectFnStop();
return ok;
};
buffer[1] = '\0';
if (headersDone) {
NSArray * myArray = nil;
listItems = unpackData(pendingData);
headerDict = [self unpackHeaders:listItems];
*headersPtr = headerDict;
myArray = [headerDict objectForKey:@"content-length"];
if ((myArray) && ([myArray count])) {
contentLength = [[myArray objectAtIndex:0] intValue];
if (contentLength > 0) {
if (!allMimeData) {
allMimeData = (NSMutableData*)[NSMutableData data];
}
while ((contentLength > 0) && (! isElapsed)) {
dataBlock2 = [_stream readDataOfLength: contentLength];
[allMimeData appendData:dataBlock2];
contentLength = contentLength-[dataBlock2 length];
time(&now);
isElapsed = ((now - starttime) > 30);
}
}
}
allDataRead = YES;
} else {
totalBytes+=dataBlockLength;
if (!pendingData)
pendingData=(NSMutableData*)[NSMutableData data];
[pendingData appendData:dataBlock];
tries=0;
}
} else {
if (((totalBytes>2) && (tries>3)) && (newLineSeen)) {
allDataRead = YES;
}
tries++;
}
}
if (allMimeData) {
*dataPtr = [[allMimeData retain] autorelease];
}
// check headers for contents?
if (!headerDict) {
*requestLinePtr=nil;
*headersPtr=nil;
*dataPtr=nil;
return NO;
}
*requestLinePtr = [listItems objectAtIndex:0];
return YES;
}
//--------------------------------------------------------------------
/** return a created request build with 'requestLine', 'headers' and 'data' **/
@ -582,11 +507,6 @@ static NSData* lineFeedData=nil;
GSWRequest* request=nil;
int requestLineLength=0;
LOGObjectFnStart();
NSDebugDeepMLog0(@"GSWDefaultAdaptorThread: createRequestFromData");
NSDebugDeepMLLog(@"low",@"requestLine:%@",requestLine);
requestLineLength=[requestLine length];
if (requestLineLength==0)
{
@ -630,9 +550,6 @@ static NSData* lineFeedData=nil;
urlRange.length=spaceRange.location-urlRange.location;
url=[requestLine substringFromRange:urlRange];
NSDebugDeepMLLog(@"info",@"method=%@",method);
NSDebugDeepMLLog(@"info",@"url=%@",url);
NSDebugDeepMLLog(@"info",@"protocolString=%@",protocolString);
if ([protocol count]!=2)
{
ExceptionRaise0(@"GSWDefaultAdaptorThread",@"bad request first line (HTTP)");
@ -640,12 +557,9 @@ static NSData* lineFeedData=nil;
else
{
NSString* httpVersion=[protocol objectAtIndex:1];
//[GSWApplication statusLogWithFormat:@"RemoteAddress=%@ Method=%@ Protocol=%@ httpVersion=%@ uri=%@",
// _remoteAddress,method,protocolString,httpVersion,url];
/* if (isHeaderKeysEqual(method,GSWHTTPHeader_MethodPost))
{
*/
if ((httpVersion) && ([httpVersion length] > 3)) {
httpVersion = [httpVersion substringToIndex:3];
}
request=[_application createRequestWithMethod:method
uri:url
httpVersion:httpVersion
@ -658,7 +572,6 @@ static NSData* lineFeedData=nil;
};
};
LOGObjectFnStop();
return request;
};
@ -668,8 +581,6 @@ static NSData* lineFeedData=nil;
{
NSString* anHeader=nil;
LOGObjectFnStart();
_sendResponseTS=GSWTime_now();
// Based on requestTS
@ -689,7 +600,6 @@ static NSData* lineFeedData=nil;
withAdditionalHeaderLines:[NSArray arrayWithObject:anHeader]
withRemoteAddress:_remoteAddress];
ASSIGN(_stream,nil);
LOGObjectFnStop();
};
//--------------------------------------------------------------------
@ -703,8 +613,7 @@ withAdditionalHeaderLines:(NSArray*)addHeaders
withRemoteAddress:(NSString*)remoteAddress
{
BOOL ok=YES;
LOGObjectFnStart();
NSDebugDeepMLLog(@"low",@"response:%p",response);
[response willSend];
if (response)
{
@ -725,12 +634,8 @@ withAdditionalHeaderLines:(NSArray*)addHeaders
GSWHTTPHeader_Response_OK,
GSWHTTPHeader_Response_HeaderLineEnd[requestNamingConv]];
NSDebugDeepMLLog(@"low",@"head:%@",head);
NSDebugDeepMLLog(@"low",@"responseData:%@",responseData);
(*appendDataIMP)(responseData,appendDataSEL,
[head dataUsingEncoding:NSASCIIStringEncoding]);
NSDebugDeepMLLog(@"low",@"responseData:%@",responseData);
objectAtIndexIMP=[headerKeys methodForSelector:objectAtIndexSEL];
for(headerN=0;headerN<headerKeysCount;headerN++)
@ -747,9 +652,6 @@ withAdditionalHeaderLines:(NSArray*)addHeaders
(*appendDataIMP)(responseData,appendDataSEL,
[anHeader dataUsingEncoding:NSASCIIStringEncoding]);
NSDebugDeepMLLog(@"low",@"anHeader:%@",anHeader);
NSDebugDeepMLLog(@"low",@"responseData:%@",responseData);
};
};
@ -762,12 +664,8 @@ withAdditionalHeaderLines:(NSArray*)addHeaders
(*appendDataIMP)(responseData,appendDataSEL,lineFeedData);
};
NSDebugDeepMLLog(@"low",@"empty:%@",empty);
NSDebugDeepMLLog(@"low",@"responseData:%@",responseData);
// Headers/Content separator
(*appendDataIMP)(responseData,appendDataSEL,lineFeedData);
NSDebugDeepMLLog(@"low",@"responseData:%@",responseData);
NS_DURING
{
@ -794,38 +692,22 @@ withAdditionalHeaderLines:(NSArray*)addHeaders
[responseData setLength:responseContentLength];
[responseData setData:responseContent];
NSDebugDeepMLLog(@"low",@"responseContent:%@",responseContent);
NSDebugDeepMLLog(@"low",@"responseContentLength=%d",responseContentLength);
NSDebugDeepMLLog(@"low",@"Response content String NSASCIIStringEncoding:%@",
[[[NSString alloc] initWithData:responseContent
encoding:NSASCIIStringEncoding]
autorelease]);
NSDebugDeepMLLog(@"low",@"Response content String :%@",
[[[NSString alloc] initWithData:responseContent
encoding:[response contentEncoding]]
autorelease]);
NS_DURING
{
[aStream writeData:responseData];
//[GSWApplication statusLogString:@"\nResponse Sent\n"];
}
NS_HANDLER
{
ok=NO;
LOGException(@"GSWDefaultAdaptorThread: sendResponse Exception:%@ (%@)",
localException,[localException reason]);
NSDebugMLog(@"EXCEPTION GSWDefaultAdaptorThread: sendResponse Exception:%@ (%@)",
localException,[localException reason]);
[GSWApplication statusLogString:@"\nException while sending response\n"];
}
NS_ENDHANDLER;
NSDebugDeepMLLog0(@"info",@"Response content Written");
};
};
};
[aStream closeFile];
LOGObjectFnStop();
};
//--------------------------------------------------------------------
@ -841,10 +723,7 @@ withAdditionalHeaderLines:(NSArray*)addHeaders
{
time_t elapsedSeconds=GSWTime_secPart(GSWTime_now()-_creationTS);
BOOL isExpired=(elapsedSeconds>ADAPTOR_THREAD_TIME_OUT);
NSDebugDeepMLog(@"EXPIRED %@ %d isExpired=%d",
_creationTS,
elapsedSeconds,
isExpired);
return isExpired;
};
@ -866,21 +745,19 @@ withAdditionalHeaderLines:(NSArray*)addHeaders
GSWResponse* response=nil;
NSAutoreleasePool* pool=nil;
pool=[NSAutoreleasePool new];
GSWLogMemCF("New NSAutoreleasePool: %p",pool);
LOGDEEPClassFnStart();
response=[GSWResponse responseWithMessage:@"Temporary unavailable"
inContext:nil
forRequest:nil
forceFinalize:YES];
[response setStatus:503];//503=Service Unavailable
NSDebugDeepMLog0(@"sendResponse:");
[self sendResponse:response
toStream:stream
withNamingConv:GSWNAMES_INDEX
withAdditionalHeaderLines:nil
withRemoteAddress:nil];
LOGDEEPClassFnStop();
GSWLogMemCF("Destroy NSAutoreleasePool: %p",pool);
DESTROY(pool);
};
@ -891,21 +768,19 @@ withAdditionalHeaderLines:(NSArray*)addHeaders
GSWResponse* response=nil;
NSAutoreleasePool* pool=nil;
pool=[NSAutoreleasePool new];
GSWLogMemCF("New NSAutoreleasePool: %p",pool);
LOGDEEPClassFnStart();
response=[GSWResponse responseWithMessage:message
inContext:nil
forRequest:nil
forceFinalize:YES];
[response setStatus:503];//503=Service Unavailable
NSDebugDeepMLog0(@"sendResponse:");
[self sendResponse:response
toStream:stream
withNamingConv:GSWNAMES_INDEX
withAdditionalHeaderLines:nil
withRemoteAddress:nil];
LOGDEEPClassFnStop();
GSWLogMemCF("Destroy NSAutoreleasePool: %p",pool);
DESTROY(pool);
};

View file

@ -49,6 +49,39 @@ RCS_ID("$Id$")
return self;
};
- (NSString*) _submitButtonsActionPathFromRequest:(GSWRequest*) request
{
NSString * resStr = nil;
NSArray * formValues = nil;
if (_allowsContentInputStream) {
return nil;
}
formValues = [request formValuesForKey:@"WOSubmitAction"];
if (formValues != nil) {
int i = [formValues count];
int j = 0;
NSString * value = nil;
do {
if (j >= i) {
break;
}
value = [formValues objectAtIndex:j];
if ([request formValuesForKey:value] != nil) {
resStr = value;
break;
}
if ([request formValuesForKey:[value stringByAppendingString:@".x"]] != nil) {
resStr = value;
break;
}
j++;
} while (YES);
}
return resStr;
}
//--------------------------------------------------------------------
-(BOOL)defaultDisplayExceptionPages
{
@ -80,9 +113,8 @@ RCS_ID("$Id$")
{
NSArray* requestHandlerPath=nil;
id submitButtonsActionPathFromRequest=nil;
submitButtonsActionPathFromRequest=[self submitButtonsActionPathFromRequest:aRequest];
NSDebugMLLog(@"requests",@"submitButtonsActionPathFromRequest=%@",
submitButtonsActionPathFromRequest);
submitButtonsActionPathFromRequest=[self _submitButtonsActionPathFromRequest:aRequest];
if (submitButtonsActionPathFromRequest)
requestHandlerPath=[submitButtonsActionPathFromRequest componentsSeparatedByString:@"/"];
else
@ -90,38 +122,6 @@ RCS_ID("$Id$")
return requestHandlerPath;
}
//--------------------------------------------------------------------
-(NSString*)submitButtonsActionPathFromRequest:(GSWRequest*)aRequest
{
NSString* path=nil;
LOGObjectFnStart();
if (!_allowsContentInputStream)
{
NSArray* submitActions=[aRequest formValuesForKey:GSWKey_SubmitAction[GSWebNamingConv]];
if (submitActions)
{
int count=[submitActions count];
int i=0;
for(i=0;!path && i<count;i++)
{
NSString* submitAction=[submitActions objectAtIndex:i];
if ([aRequest formValuesForKey:submitAction])
path = submitAction;
else
{
// Try image buttons
NSString* imageButtonFormValueName=[submitAction stringByAppendingString:@".x"];
if ([aRequest formValuesForKey:imageButtonFormValueName])
path = submitAction;
};
}
};
};
LOGObjectFnStop();
return path;
};
//--------------------------------------------------------------------
-(GSWResponse*)generateNullResponse

View file

@ -42,10 +42,7 @@ GSWEB_EXPORT SEL evaluateConditionInContextSEL;
-(id)initWithName:(NSString*)name
associations:(NSDictionary*)associations
template:(GSWElement*)template;
@end
//====================================================================
@interface GSWDynamicElement (GSWDynamicElement)
-(BOOL) evaluateCondition:(id)condition
inContext:(GSWContext*)context
noConditionAssociationDefault:(BOOL)noConditionAssociationDefault

View file

@ -54,29 +54,22 @@ SEL evaluateConditionInContextSEL = NULL;
associations:(NSDictionary*)associations
template:(GSWElement*)template
{
//OK
if ((self=[super init]))
{
};
return self;
};
id ourid = [super init];
if (ourid) {
return ourid;
}
DESTROY(self);
return nil;
}
//--------------------------------------------------------------------
-(void)dealloc
{
GSWLogAssertGood(self);
GSWLogC("Dealloc GSWDynamicElement");
GSWLogC("Dealloc GSWDynamicElement: name");
GSWLogC("Dealloc GSWDynamicElement Super");
[super dealloc];
GSWLogC("End Dealloc GSWDynamicElement");
}
@end
//====================================================================
@implementation GSWDynamicElement (GSWDynamicElement)
//--------------------------------------------------------------------
-(BOOL) evaluateCondition:(id)condition
inContext:(GSWContext*)context
@ -85,27 +78,14 @@ SEL evaluateConditionInContextSEL = NULL;
{
//OK
BOOL result=noConditionAssociationDefault;
LOGObjectFnStart();
NSDebugMLLog(@"gswdync",@"condition_=%@ noConditionAssociationDefault=%s noConditionDefault=%s",
condition,(noConditionAssociationDefault ? "YES" : "NO"),
(noConditionDefault ? "YES" : "NO"));
if (condition)
{
GSWComponent* component=GSWContext_component(context);
id value=[condition valueInComponent:component];
NSDebugMLLog(@"gswdync",@"_value=%@ class=%@",value,[value class]);
#ifndef NDEBUG
if ([value respondsToSelector:@selector(unsignedCharValue)])
{
NSDebugMLLog(@"gswdync",@"unsignedCharValue=%d",(int)[value unsignedCharValue]);
};
#endif
result=boolValueWithDefaultFor(value,noConditionDefault);
};
NSDebugMLLog(@"gswdync",@"condition_=%@ noConditionAssociationDefault=%s noConditionDefault=%s ==> result=%s",
condition,(noConditionAssociationDefault ? "YES" : "NO"),
(noConditionDefault ? "YES" : "NO"),(result ? "YES" : "NO"));
LOGObjectFnStop();
return result;
};
@ -114,14 +94,12 @@ SEL evaluateConditionInContextSEL = NULL;
inContext:(GSWContext*)context
{
BOOL result=NO;
LOGObjectFnStart();
result=[self evaluateCondition:condition
inContext:context
noConditionAssociationDefault:NO
noConditionDefault:YES];
LOGObjectFnStop();
return result;
};
@end

View file

@ -87,16 +87,10 @@
-(NSString*)description;
-(void)forwardInvocation:(NSInvocation*)invocation;
-(NSMethodSignature*)methodSignatureForSelector:(SEL)selector;
@end
//====================================================================
@interface GSWDynamicURLString (GSWDynamicURLStringParsing)
-(void)_compose;
-(void)_parse;
@end
//====================================================================
@interface GSWDynamicURLString (GSWDynamicURLStringGet)
-(NSString*)urlRequestHandlerPath;
-(NSString*)urlQueryString;
-(NSString*)urlRequestHandlerKey;
@ -109,10 +103,7 @@
-(int)urlPort;//NDFN
-(NSString*)urlProtocolHostPort;//NDFN
-(void)checkURL;
@end
//====================================================================
@interface GSWDynamicURLString (GSWDynamicURLStringSet)
-(void)setURLRequestHandlerPath:(NSString*)aString;
-(void)setURLQueryString:(NSString*)aString;
-(void)setURLRequestHandlerKey:(NSString*)aString;

View file

@ -257,6 +257,11 @@ static SEL appendStringSel = NULL;
DESTROY(_requestHandlerKey);
DESTROY(_queryString);
DESTROY(_requestHandlerPath);
_urlASImp=NULL;
_urlBeginningASImp=NULL;
_flags.composed=NO;
[super dealloc];
};
@ -390,10 +395,6 @@ static SEL appendStringSel = NULL;
return [_url methodSignatureForSelector:selector];
};
@end
//====================================================================
@implementation GSWDynamicURLString (GSWDynamicURLStringParsing)
-(void)_compose
{
@ -713,10 +714,6 @@ static SEL appendStringSel = NULL;
//NSDebugMLLog(@"low",@"requestHandlerPath=%@",_requestHandlerPath);
};
@end
//====================================================================
@implementation GSWDynamicURLString (GSWDynamicURLStringGetGet)
/*
//--------------------------------------------------------------------
-(NSArray*)urlRequestHandlerPath
@ -749,6 +746,25 @@ static SEL appendStringSel = NULL;
return _applicationNumber;
};
// wo5?
- (NSString*) applicationNumber
{
// parse? compose?
return GSWIntToNSString(_applicationNumber);
}
- (void) setApplicationNumber: (NSString*) newNr
{
int intVal = [newNr intValue];
if (intVal != _applicationNumber) {
_applicationNumber = intVal;
_flags.beginningComposed = NO;
_flags.composed = NO;
}
}
//--------------------------------------------------------------------
-(NSString*)urlApplicationName
{
@ -836,10 +852,6 @@ static SEL appendStringSel = NULL;
return [NSString stringWithString:url];
};
@end
//====================================================================
@implementation GSWDynamicURLString (GSWDynamicURLStringSet)
-(void)setURLRequestHandlerPath:(NSString*)aString
{
LOGObjectFnStart();

View file

@ -71,7 +71,6 @@ GSWEB_EXPORT BYTE ElementsMap_attributeElement;
//Do nothing ifndef GSWELEMENT_HAS_DECLARATION_NAME
-(NSString*)declarationName;
-(void)setDeclarationName:(NSString*)declarationName;
@end
#if !defined(GSWDEBUG_ELEMENTSIDS) || defined(NDEBBUG)
@ -137,9 +136,6 @@ GSWEB_EXPORT BYTE ElementsMap_attributeElement;
#endif
//====================================================================
@interface GSWElement (GSWRequestHandling)
-(void)appendToResponse:(GSWResponse*)response
inContext:(GSWContext*)context;

View file

@ -27,6 +27,13 @@
</license>
**/
/*
Actually WOElement does really nothing.
*/
#include "config.h"
RCS_ID("$Id$")
@ -49,19 +56,11 @@ BYTE ElementsMap_attributeElement = (BYTE)0x41; // 'A'
{
NSString* elementID=nil;
LOGObjectFnStartC("GSWElement");
elementID=GSWContext_elementID(context);
NSDebugMLLog(@"GSWElement",@"self=%p declarationName=%@ elementID=%@ %p",self,[self declarationName],elementID,elementID);
ASSIGNCOPY(_appendToResponseElementID,elementID);
NSDebugMLLog(@"GSWElement",@"self=%p declarationName=%@ _appendToResponseElementID=%@ %p",
self,[self declarationName],
_appendToResponseElementID,_appendToResponseElementID);
GSWAssertIsElementID(context);
LOGObjectFnStopC("GSWElement");
};
};
@ -71,7 +70,6 @@ BYTE ElementsMap_attributeElement = (BYTE)0x41; // 'A'
file:(const char*)file
line:(int)line
{
LOGObjectFnStartC("GSWElement");
[self assertIsElementIDInContext:context
method:method
file:file
@ -92,8 +90,6 @@ BYTE ElementsMap_attributeElement = (BYTE)0x41; // 'A'
|| appendToResponseElementIDIsFirst!=elementIDIsFirst)
{
OK=[_appendToResponseElementID isEqualToString:elementID];
NSDebugMLLog(@"GSWElement",@"GSWContext_elementID(context)=%@ _appendToResponseElementID=%@ [_appendToResponseElementID length]=%d OK=%d [context isInLoop]=%d",
GSWContext_elementID(context),_appendToResponseElementID,[_appendToResponseElementID length],OK,[context isInLoop]);
};
if (!OK && ![context isInLoop])
{
@ -109,10 +105,8 @@ BYTE ElementsMap_attributeElement = (BYTE)0x41; // 'A'
_appendToResponseElementID,
_appendToResponseElementID];
//No: we may have multiple occurences NSAssert1(OK,@"%@",msg);
NSDebugMLog(@"ELEMENT ID WARNING %@",msg);
};
};
LOGObjectFnStopC("GSWElement");
};
//--------------------------------------------------------------------
@ -121,12 +115,6 @@ BYTE ElementsMap_attributeElement = (BYTE)0x41; // 'A'
file:(const char*)file
line:(int)line
{
LOGObjectFnStartC("GSWElement");
/* NSDebugMLLog(@"GSWElement",@"self=%p declarationName=%@ _appendToResponseElementID=%@ %p / GSWContext_elementID(context)=%@",
self,
[self declarationName],
_appendToResponseElementID,_appendToResponseElementID,GSWContext_elementID(context));
*/
if (_appendToResponseElementID
&& [_appendToResponseElementID length]==0
&& [GSWContext_elementID(context) length]>0)
@ -142,7 +130,6 @@ BYTE ElementsMap_attributeElement = (BYTE)0x41; // 'A'
_appendToResponseElementID];
NSAssert1(NO,@"%@",msg);
};
LOGObjectFnStopC("GSWElement");
};
//--------------------------------------------------------------------
@ -156,16 +143,6 @@ BYTE ElementsMap_attributeElement = (BYTE)0x41; // 'A'
NSString* senderID=GSWContext_senderID(aContext);
if (start)
[aContext addToDocStructureElement:self];
NSDebugMLLog(@"GSWElement",@"%s:.%d - %@ %s ELEMENT self=%p class=%@ defName=%@ id=%@ appendID:%@ %s%@",
file,line,NSStringFromSelector(method),
(start ? "START" : (stop ? "STOP" : "")),
self,
[self class],
[self declarationName],
GSWContext_elementID(aContext),
_appendToResponseElementID,
(senderID ? "senderID:" : ""),
(senderID ? senderID : @""));
};
#endif
@ -177,15 +154,11 @@ BYTE ElementsMap_attributeElement = (BYTE)0x41; // 'A'
//--------------------------------------------------------------------
-(void)dealloc
{
GSWLogAssertGood(self);
//GSWLogC("Dealloc GSWElement");
//GSWLogC("Dealloc GSWElement: _appendToResponseElementID");
DESTROY(_appendToResponseElementID);
//GSWLogC("Dealloc GSWElement: _name");
DESTROY(_declarationName);
//GSWLogC("Dealloc GSWElement Super");
[super dealloc];
//GSWLogC("End Dealloc GSWElement");
}
#endif
@ -203,18 +176,10 @@ BYTE ElementsMap_attributeElement = (BYTE)0x41; // 'A'
-(void)setDeclarationName:(NSString*)declarationName
{
#ifdef GSWELEMENT_HAS_DECLARATION_NAME
NSDebugMLLog(@"gswdync",@"setDeclarationName1 in %p: %p %@",
self,declarationName,declarationName);
ASSIGN(_declarationName,declarationName);
NSDebugMLLog(@"gswdync",@"setDeclarationName2 in %p: %p %@",
self,_declarationName,_declarationName);
#endif
};
@end
//====================================================================
@implementation GSWElement (GSWRequestHandling)
//--------------------------------------------------------------------
// takeValuesFromRequest:inContext:
@ -235,11 +200,7 @@ BYTE ElementsMap_attributeElement = (BYTE)0x41; // 'A'
-(GSWElement*)invokeActionForRequest:(GSWRequest*)request
inContext:(GSWContext*)context
{
GSWStartElement(context);
GSWAddElementToDocStructure(context);
GSWAssertCorrectElementID(context);// Debug Only
//Does Nothing
GSWStopElement(context);
return nil;
};
@ -249,8 +210,8 @@ BYTE ElementsMap_attributeElement = (BYTE)0x41; // 'A'
-(void)appendToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
{
GSWSaveAppendToResponseElementID(context);//Debug Only
GSWAddElementToDocStructure(context);
// GSWSaveAppendToResponseElementID(context);//Debug Only
// GSWAddElementToDocStructure(context);
//Does Nothing
};
@ -261,10 +222,9 @@ BYTE ElementsMap_attributeElement = (BYTE)0x41; // 'A'
BOOL match=NO;
NSString* senderID=GSWContext_senderID(aContext);
NSString* elementID=GSWContext_elementID(aContext);
NSDebugMLLog(@"gswdync",@" senderID=%@",senderID);
NSDebugMLLog(@"gswdync",@"elementID=%@",elementID);
match=([elementID hasPrefix:senderID] || [senderID hasPrefix:elementID]);
NSDebugMLLog(@"gswdync",@"match=%s",(match ? "YES" : "NO"));
return match;
};

View file

@ -239,9 +239,6 @@ New parts is stored id *partsPtr and new allocated parts count in *allocatedPart
**/
void GSWElementIDRealloc(GSWElementIDPart** partsPtr,int* allocatedPartsCountPtr,int allocPartsCount)
{
NSDebugFLLog(@"GSWElementID",
@"*partsPtr=%p *allocatedPartsCountPtr=%d allocPartsCount=%d",
*partsPtr,*allocatedPartsCountPtr,allocPartsCount);
//Really need ?
if (allocPartsCount>*allocatedPartsCountPtr)
@ -254,8 +251,6 @@ void GSWElementIDRealloc(GSWElementIDPart** partsPtr,int* allocatedPartsCountPtr
NSCAssert2(newParts,@"Can't alloc %d parts (allocSize bytes)",
allocPartsCount,
allocSize);
NSDebugFLLog(@"GSWElementID",@"allocSize=%d newParts=%p",
allocSize,newParts);
if ((*allocatedPartsCountPtr)>0)
{
@ -272,9 +267,6 @@ void GSWElementIDRealloc(GSWElementIDPart** partsPtr,int* allocatedPartsCountPtr
*allocatedPartsCountPtr=allocPartsCount;
*partsPtr=newParts;
NSDebugFLLog(@"GSWElementID",
@"==> *partsPtr=%p *allocatedPartsCountPtr=%d",
*partsPtr,*allocatedPartsCountPtr);
};
};
@ -328,9 +320,6 @@ partsCount is the number of parts to allocate
unichar* ptr=NULL;
unichar* stringEndPtr=NULL;
LOGObjectFnStart();
NSDebugMLLog(@"GSWElementID",@"string=%@",string);
length=[string length];
if (length>0)
@ -352,14 +341,11 @@ partsCount is the number of parts to allocate
ptr++;
};
NSDebugMLLog(@"GSWElementID",@"partsCount=%d",partsCount);
partsCount+=16; // keeps space for extensions
}
else
partsCount=GSWElementID_DefaultElementPartsCount;
NSDebugMLLog(@"GSWElementID",@"partsCount=%d",partsCount);
if ((self=[self initWithPartsCountCapacity:partsCount]))
{
if (stringChars)
@ -380,12 +366,6 @@ partsCount is the number of parts to allocate
ptr=startPartPtr;
endPartPtr=NULL; // end part pointer
NSDebugMLLog(@"GSWElementID",@"stringChars=%p stringEndPtr=%p length=%d startPartPtr=%p",
stringChars,stringEndPtr,length,startPartPtr);
NSDebugMLLog(@"GSWElementID",@"Starting partString=%@",
[NSString stringWithCharacters:startPartPtr
length:stringEndPtr-startPartPtr]);
while(ptr<stringEndPtr)
{
// End of part ?
@ -414,14 +394,6 @@ partsCount is the number of parts to allocate
// no '.' found ==> last part
if (!endPartPtr)
endPartPtr=stringEndPtr-1;
NSDebugMLLog(@"GSWElementID",@"startPartPtr=%p endPartPtr=%p",
startPartPtr,endPartPtr);
NSDebugMLLog(@"GSWElementID",@"part=%@ isAllNumeric=%d numericIndexPtr=%p number=%d",
[NSString stringWithCharacters:startPartPtr
length:endPartPtr-startPartPtr+1],
isAllNumeric,numericIndexPtr,number);
// Entirely numeric ?
if (isAllNumeric)
@ -443,8 +415,6 @@ partsCount is the number of parts to allocate
//We could also build part elementIDString but I'm not sure it's interesting as
//initializing GSWElementID from string is mainly to be used for 'statics' elementIDs
//Assigning _elementIDString at the end should be sufficient.
NSDebugMLLog(@"GSWElementID",@"Part #%d: %@",
_partsCount,GSWElementIDPartDescription(part));
_partsCount++;
part++;
@ -452,12 +422,8 @@ partsCount is the number of parts to allocate
};
};
};
NSDebugMLLog(@"GSWElementID",@"string: %@ => elementIDString=%@",
string,[self elementIDString]);
ASSIGN(_elementIDString,string);
LOGObjectFnStop();
return self;
};
@ -465,9 +431,6 @@ partsCount is the number of parts to allocate
/** dealloc object **/
-(void)dealloc
{
LOGObjectFnStart();
GSWLogAssertGood(self);
if (_allocatedPartsCount>0)
{
@ -489,7 +452,6 @@ partsCount is the number of parts to allocate
DESTROY(_isSearchOverLastSenderID);
[super dealloc];
GSWLogMemC("GSWElementID end of dealloc");
};
//--------------------------------------------------------------------
@ -552,11 +514,6 @@ For better performences, senderID should be an immutable string
{
BOOL over=NO;
LOGObjectFnStart();
NSDebugMLLog(@"GSWElementID",@"senderID=%@",senderID);
NSDebugMLLog(@"GSWElementID",@"onParentFlag=%d",onParentFlag);
if (senderID == nil)
[NSException raise:NSInvalidArgumentException
format:@"compare with nil"];
@ -574,12 +531,11 @@ For better performences, senderID should be an immutable string
else
{
senderElementID=[[self class]elementIDWithString:senderID];
NSDebugMLLog(@"GSWElementID",@"senderElementID=%@",senderElementID);
//Cache it if it is not mutable
if ([senderID isKindOfClass:[NSMutableString class]])
{
NSWarnLog(@"Performances: senderID passed to -isSearchOverForSenderID: is a mutable string");
// NSWarnLog(@"Performances: senderID passed to -isSearchOverForSenderID: is a mutable string");
}
else
{
@ -589,17 +545,11 @@ For better performences, senderID should be an immutable string
};
count=min((onParentFlag ? _partsCount-1 : _partsCount),senderElementID->_partsCount);
NSDebugMLog(@"count=%d",count);
for(i=0,selfElementPart=_parts,senderElementPart=senderElementID->_parts;
i<count && !over;
i++,selfElementPart++,senderElementPart++)
{
NSDebugMLLog(@"GSWElementID",@"selfElementPart #%d: %@",
i,GSWElementIDPartDescription(selfElementPart));
NSDebugMLLog(@"GSWElementID",@"senderElementPart #%d: %@",
i,GSWElementIDPartDescription(senderElementPart));
if (selfElementPart->_string)
{
if (senderElementPart->_string) // string & string
@ -640,18 +590,9 @@ For better performences, senderID should be an immutable string
// else continue
};
};
NSDebugMLLog(@"GSWElementID",@"Part #%d selfElementPart=%@ senderIDElementPart=%@ => over=%d",
i,
GSWElementIDPartDescription(selfElementPart),
GSWElementIDPartDescription(senderElementPart),
over);
};
NSDebugMLLog(@"GSWElementID",@"self=%@ senderID=%@ => over=%d",
[self elementIDString],senderID,over);
};
LOGObjectFnStop();
return over;
}
@ -691,11 +632,6 @@ For better performences, senderID should be an immutable string
@".60", @".61", @".62", @".63", @".64", @".65", @".66", @".67", @".68", @".69" };
static int preBuiltDotPlusNumCount = sizeof(preBuiltDotPlusNum)/sizeof(NSString*);
LOGObjectFnStart();
NSDebugMLLog(@"GSWElementID",@"_partsCount=%d _builtPartCount=%d",
_partsCount,_builtPartCount);
NSAssert1(_builtPartCount>=0,@"_builtPartCount=%d",_builtPartCount);
if (_partsCount>0)
@ -705,7 +641,6 @@ For better performences, senderID should be an immutable string
{
int i=0;
NSDebugMLLog(@"GSWElementID",@"_tmpString=%@",_tmpString);
// No working string created ?
if (!_tmpString)
{
@ -721,15 +656,8 @@ For better performences, senderID should be an immutable string
(_builtPartCount>0 ?
(NSString*)(part->_elementIDString) : (NSString*)@""));
NSDebugMLLog(@"GSWElementID",@"_tmpString=%@",_tmpString);
for(i=_builtPartCount,part=_parts+_builtPartCount;i<_partsCount;i++,part++)
{
NSDebugMLLog(@"GSWElementID",@"Part#%d _parts=%p part=%p",
i,_parts,part);
NSDebugMLLog(@"GSWElementID",@"Part #%d: %@",
i,GSWElementIDPartDescription(part));
if (part->_string)
{
if (i>0)
@ -777,10 +705,6 @@ For better performences, senderID should be an immutable string
};
};
NSDebugMLLog(@"GSWElementID",@"_tmpString=%@",_tmpString);
NSDebugMLLog(@"GSWElementID",@"Part #%d: %@",
i,GSWElementIDPartDescription(part));
if (part->_elementIDString)
{
(*part->_elementIDString_setStringIMP)(part->_elementIDString,
@ -793,20 +717,13 @@ For better performences, senderID should be an immutable string
part->_elementIDString_setStringIMP=[part->_elementIDString
methodForSelector:setStringSelector];
};
NSDebugMLLog(@"GSWElementID",@"part->_elementIDString=%@",part->_elementIDString);
};
_builtPartCount=_partsCount;
NSDebugMLLog(@"GSWElementID",@"_builtPartCount=%d",_builtPartCount);
};
part=_parts+_partsCount-1;
ASSIGN(_elementIDString,([NSString stringWithString:part->_elementIDString]));
NSDebugMLLog(@"GSWElementID",@"_elementIDString=%@",_elementIDString);
};
NSDebugMLLog(@"GSWElementID",@"_builtPartCount=%d _partsCount=%d",_builtPartCount,_partsCount);
LOGObjectFnStop();
};
//--------------------------------------------------------------------
@ -816,18 +733,13 @@ elements **/
{
NSString* elementIDString=@"";
//NSLog(@"ELEMENTID: [elementID elementIDString];");
NSDebugMLLog(@"GSWElementID",@"_partsCount=%d",_partsCount);
if (_partsCount>0)
{
NSDebugMLLog(@"GSWElementID",@"_elementIDString=%@",_elementIDString);
if (!_elementIDString) // Not alreday built ?
(*_buildElementPartsIMP)(self,buildElementPartsSelector);
elementIDString=_elementIDString;
AUTORELEASE(RETAIN(elementIDString));
};
NSDebugMLLog(@"GSWElementID",@"elementIDString=%@",elementIDString);
return elementIDString;
}
@ -839,11 +751,6 @@ elements **/
int i=0;
GSWElementIDPart* part=NULL;
LOGObjectFnStart();
NSDebugMLLog(@"GSWElementID",@"fromIndex=%d _partsCount=%d _builtPartCount=%d",
fromIndex,_partsCount,_builtPartCount);
NSAssert1(fromIndex>=0,@"fromIndex (%d) <0",
fromIndex);
NSAssert2(fromIndex<_partsCount,@"fromIndex (%d) >= _partsCount (%d)",
@ -862,10 +769,6 @@ elements **/
_partsCount=fromIndex;
NSDebugMLLog(@"GSWElementID",@"==>fromIndex=%d _partsCount=%d _builtPartCount=%d",
fromIndex,_partsCount,_builtPartCount);
LOGObjectFnStop();
}
@ -873,62 +776,52 @@ elements **/
/** empties elementID **/
-(void)deleteAllElementIDComponents
{
LOGObjectFnStart();
//NSLog(@"ELEMENTID: [elementID deleteAllElementIDComponents];");
if (_partsCount>0)
(*_deleteElementsFromIndexIMP)(self,deleteElementsFromIndexSelector,0);
LOGObjectFnStop();
};
//--------------------------------------------------------------------
/** Deletes last elementID part **/
-(void)deleteLastElementIDComponent
{
LOGObjectFnStart();
//NSLog(@"ELEMENTID: [elementID deleteLastElementIDComponent];");
if (_partsCount>0)
(*_deleteElementsFromIndexIMP)(self,deleteElementsFromIndexSelector,_partsCount-1);
LOGObjectFnStop();
};
//--------------------------------------------------------------------
/** Increments last elementID part **/
-(void)incrementLastElementIDComponent
{
LOGObjectFnStart();
//NSLog(@"ELEMENTID: [elementID incrementLastElementIDComponent];");
if (_partsCount<1)
{
NSWarnLog(@"Can't incrementLastElementIDComponent on an empty elementID");
#warning checkme!
return;
// NSWarnLog(@"Can't incrementLastElementIDComponent on an empty elementID");
[NSException raise:NSInvalidArgumentException
format:@"Can't incrementLastElementIDComponent on an empty elementID. In %s",
__PRETTY_FUNCTION__];
}
else
{
GSWElementIDPart* part=NULL;
NSDebugMLLog(@"GSWElementID",@"_partsCount=%d _builtPartCount=%d",
_partsCount,_builtPartCount);
// Update part number
part=_parts+_partsCount-1;
part->_number++;
NSDebugMLLog(@"GSWElementID",@"Part #%d: %@",
_partsCount-1,GSWElementIDPartDescription(part));
// update cache state information
if (_builtPartCount>=_partsCount)
_builtPartCount=_partsCount-1;
DESTROY(_elementIDString);
NSDebugMLLog(@"GSWElementID",@"==> _partsCount=%d _builtPartCount=%d",
_partsCount,_builtPartCount);
};
};
@ -938,13 +831,6 @@ elements **/
{
GSWElementIDPart* part=NULL;
LOGObjectFnStart();
//NSLog(@"ELEMENTID: [elementID appendZeroElementIDComponent];");
NSDebugMLLog(@"GSWElementID",@"_partsCount=%d _builtPartCount=%d",
_partsCount,_builtPartCount);
if (_partsCount>=_allocatedPartsCount)
GSWElementIDRealloc(&_parts,&_allocatedPartsCount,
_allocatedPartsCount+GSWElementID_DefaultElementPartsCount);
@ -952,8 +838,6 @@ elements **/
// Set to new part
part=_parts+_partsCount;
part->_number=0;
NSDebugMLLog(@"GSWElementID",@"Part #%d: %@",
_partsCount,GSWElementIDPartDescription(part));
// update cache state information
DESTROY(_elementIDString);
@ -961,10 +845,6 @@ elements **/
// Increments parts count
_partsCount++;
NSDebugMLLog(@"GSWElementID",@"==> _partsCount=%d _builtPartCount=%d",
_partsCount,_builtPartCount);
LOGObjectFnStop();
};
//--------------------------------------------------------------------
@ -976,10 +856,6 @@ You should avoid element ending with digits.
int elementLength=0;
GSWElementIDPart* part=NULL;
LOGObjectFnStart();
//NSLog(@"ELEMENTID: [elementID appendElementIDComponent:@\"%@\"];",element);
elementLength=[element length];
if (elementLength==0)
@ -988,16 +864,14 @@ You should avoid element ending with digits.
}
else
{
if (isdigit([element characterAtIndex:elementLength-1]))
{
NSWarnLog(@"You'll may get problems if you use anElementID which ends with digit(s) like you do: '%@'",
element);
};
// do we really need this stuff?? davew
// if (isdigit([element characterAtIndex:elementLength-1]))
// {
// NSWarnLog(@"You'll may get problems if you use anElementID which ends with digit(s) like you do: '%@'",
// element);
// };
}
NSDebugMLLog(@"GSWElementID",@"_partsCount=%d _builtPartCount=%d element=%@",
_partsCount,_builtPartCount,element);
if (_partsCount>=_allocatedPartsCount)
GSWElementIDRealloc(&_parts,&_allocatedPartsCount,
_allocatedPartsCount+GSWElementID_DefaultElementPartsCount);
@ -1016,10 +890,6 @@ You should avoid element ending with digits.
// Increments parts count
_partsCount++;
NSDebugMLLog(@"GSWElementID",@"==> _partsCount=%d _builtPartCount=%d",
_partsCount,_builtPartCount);
LOGObjectFnStop();
};
//--------------------------------------------------------------------

View file

@ -37,24 +37,22 @@
{
GSWAssociation* _data;
GSWAssociation* _filepath;
// these are new in 5.x
GSWAssociation* _mimeType;
GSWAssociation* _copyData;
GSWAssociation* _inputStream;
GSWAssociation* _outputStream;
GSWAssociation* _bufferSize;
GSWAssociation* _streamToFilePath;
GSWAssociation* _overwrite;
GSWAssociation* _finalFilePath;
};
-(id)initWithName:(NSString*)name
associations:(NSDictionary*)associations
contentElements:(NSArray*)elements;
-(void)dealloc;
@end
//====================================================================
@interface GSWFileUpload (GSWFileUploadA)
-(void)appendToResponse:(GSWResponse*)response
inContext:(GSWContext*)context;
-(GSWElement*)invokeActionForRequest:(GSWRequest*)request
inContext:(GSWContext*)context;
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context;
@end
#endif // _GSWFileUpload_h__

View file

@ -39,69 +39,104 @@ RCS_ID("$Id$")
//--------------------------------------------------------------------
-(id)initWithName:(NSString*)aName
associations:(NSDictionary*)associations
contentElements:(NSArray*)elements
template:(GSWElement*)template
{
NSMutableDictionary* tmpAssociations=[NSMutableDictionary dictionaryWithDictionary:associations];
LOGObjectFnStartC("GSWFileUpload");
NSDebugMLLog(@"gswdync",@"aName=%@ associations:%@ elements_=%@",
aName,associations,elements);
[tmpAssociations setObject:[GSWAssociation associationWithValue:@"file"]
forKey:@"type"];
[tmpAssociations removeObjectForKey:data__Key];
[tmpAssociations removeObjectForKey:filePath__Key];
if ((self=[super initWithName:aName
associations:tmpAssociations
contentElements:nil])) //No Childs!
{
_data = [[associations objectForKey:data__Key
withDefaultObject:[_data autorelease]] retain];
NSDebugMLLog(@"gswdync",@"GSWFileUpload: data=%@",_data);
self = [super initWithName:@"input" associations:associations template: nil];
if (!self) {
return nil;
}
if (!_data || ![_data isValueSettable])
{
//TODO
};
_filepath = [[associations objectForKey:filePath__Key
withDefaultObject:[_filepath autorelease]] retain];
NSDebugMLLog(@"gswdync",@"GSWFileUpload: filepath=%@",_filepath);
if (!_filepath || ![_filepath isValueSettable])
{
//TODO
};
};
LOGObjectFnStopC("GSWFileUpload");
ASSIGN(_data, [_associations objectForKey: data__Key]);
if (_data != nil) {
[_associations removeObjectForKey: data__Key];
}
ASSIGN(_filepath, [_associations objectForKey: filePath__Key]);
if (_filepath != nil) {
[_associations removeObjectForKey: filePath__Key];
}
/* // 5.x stuff....
ASSIGN(_mimeType, [_associations objectForKey: mimeType__Key]);
if (_mimeType != nil) {
[_associations removeObjectForKey: mimeType__Key];
}
ASSIGN(_copyData, [_associations objectForKey: copyData__Key]);
if (_copyData != nil) {
[_associations removeObjectForKey: copyData__Key];
}
ASSIGN(_inputStream, [_associations objectForKey: inputStream__Key]);
if (_inputStream != nil) {
[_associations removeObjectForKey: inputStream__Key];
}
ASSIGN(_outputStream, [_associations objectForKey: outputStream__Key]);
if (_outputStream != nil) {
[_associations removeObjectForKey: inputStream__Key];
}
ASSIGN(_bufferSize, [_associations objectForKey: bufferSize__Key]);
if (_bufferSize != nil) {
[_associations removeObjectForKey: bufferSize__Key];
}
ASSIGN(_streamToFilePath, [_associations objectForKey: streamToFilePath__Key]);
if (_streamToFilePath != nil) {
[_associations removeObjectForKey: streamToFilePath__Key];
}
ASSIGN(_overwrite, [_associations objectForKey: overwrite__Key]);
if (_overwrite != nil) {
[_associations removeObjectForKey: overwrite__Key];
}
ASSIGN(_finalFilePath, [_associations objectForKey: finalFilePath__Key]);
if (_finalFilePath != nil) {
[_associations removeObjectForKey: finalFilePath__Key];
}
*/
if (((_data == nil) && (_filepath == nil)) || ((_data != nil) && (![_data isValueSettable])) ||
((_filepath != nil) && (![_filepath isValueSettable]))) {
[NSException raise:NSInvalidArgumentException
format:@"%s: None of the 'data' or 'filePath' attributes is not present or is a constant. Only exacatly one of the two attributes is allowed.",
__PRETTY_FUNCTION__];
}
return self;
};
}
//--------------------------------------------------------------------
-(void)dealloc
{
DESTROY(_data);
DESTROY(_filepath);
DESTROY(_mimeType);
DESTROY(_copyData);
DESTROY(_inputStream);
DESTROY(_outputStream);
DESTROY(_bufferSize);
DESTROY(_streamToFilePath);
DESTROY(_overwrite);
DESTROY(_finalFilePath);
[super dealloc];
};
@end
//====================================================================
@implementation GSWFileUpload (GSWFileUploadA)
//--------------------------------------------------------------------
-(void)appendToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
- (NSString *) type
{
[super appendToResponse:response
inContext:context];
};
return @"file";
}
-(void) _appendValueAttributeToResponse:(GSWResponse *) response
inContext:(GSWContext*) context
{
// nothing!
}
-(void) _appendCloseTagToResponse:(GSWResponse *) response
inContext:(GSWContext*) context
{
// nothing!
}
//--------------------------------------------------------------------
-(GSWElement*)invokeActionForRequest:(GSWRequest*)request
inContext:(GSWContext*)context
{
GSWStartElement(context);
GSWAssertCorrectElementID(context);
//Bypass GSWInput
return nil;
};
@ -110,116 +145,89 @@ RCS_ID("$Id$")
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context
{
//OK
BOOL disabledValue=NO;
LOGObjectFnStartC("GSWFileUpload");
GSWStartElement(context);
GSWAssertCorrectElementID(context);
disabledValue=[self disabledInContext:context];
if (!disabledValue)
{
BOOL wasFormSubmitted=[context _wasFormSubmitted];
if (wasFormSubmitted)
{
GSWComponent* component=nil;
NSString* nameInContext=nil;
NSArray* fileDatas=nil;
NSString* fileNameFormValueName=nil;
NSString* fileNameValue=nil;
NSData* dataValue=nil;
int fileDatasCount=0;
NS_DURING
{
component=GSWContext_component(context);
nameInContext=[self nameInContext:context];
NSDebugMLLog(@"gswdync",@"nameInContext=%@",nameInContext);
fileDatas=[request formValuesForKey:nameInContext];
NSDebugMLLog(@"gswdync",@"value=%@",fileDatas);
fileDatasCount=[fileDatas count];
/*
if (_fileDatasCount!=1)
{
ExceptionRaise(@"GSWFileUpload",
@"GSWFileUpload: File Data Nb != 1 :%d",
_fileDatasCount);
};
*/
if (fileDatasCount==1)
{
dataValue=[fileDatas objectAtIndex:0];
NSDebugMLLog(@"gswdync",@"dataValue %p (class=%@)=%@",
dataValue,[dataValue class],dataValue);
if (dataValue)
{
if ([dataValue isKindOfClass:[NSData class]])
{
if ([dataValue length]==0)
{
LOGError(@"Empty Data: %@",dataValue);
};
}
else
{
if ([dataValue isKindOfClass:[NSString class]] && [dataValue length]==0)
{
LOGError(@"No Data: %@",dataValue);
NSDebugMLLog(@"gswdync",@"No Data: %p (class=%@)=%@",
dataValue,[dataValue class],dataValue);
dataValue=nil;
}
else
{
NSLog(@"content type request : %@",[request _contentType]);
NSLog(@"data class = %@",NSStringFromClass([dataValue class]));
NSDebugMLLog(@"gswdync",@"??Data: %p (class=%@)=%@",
dataValue,[dataValue class],dataValue);
/*if (![dataValue isMemberOfClass:[NSString class]]) {
ExceptionRaise(@"GSWFileUpload",
@"GSWFileUpload: bad data :%@",
dataValue);
dataValue=nil;
}*/
};
};
}
else
{
LOGError0(@"No Data:");
};
fileNameFormValueName=[NSString stringWithFormat:@"%@.filename",nameInContext];
NSDebugMLLog(@"gswdync",@"fileNameFormValueName=%@",fileNameFormValueName);
fileNameValue=[request formValueForKey:fileNameFormValueName];
NSDebugMLLog(@"gswdync",@"fileNameValue=%@",fileNameValue);
if (!fileNameValue || [fileNameValue length]==0)
{
LOGError(@"No fileName: %@",fileNameValue);
};
[_filepath setValue:fileNameValue
inComponent:component];
[_data setValue:dataValue
inComponent:component];
}
else
{
// bug in omniweb-browser if you click cancel in FileOpenPanel, it transmits incorrect datas
[_filepath setValue:nil
inComponent:component];
[_data setValue:nil
inComponent:component];
}
}
NS_HANDLER
{
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,
@"GSWFileUpload in takeValuesFromRequest");
LOGException(@"%@ (%@)",localException,[localException reason]);
[localException raise];
};
NS_ENDHANDLER;
};
};
LOGObjectFnStopC("GSWFileUpload");
GSWComponent * component = GSWContext_component(context);
if ((![self disabledInComponent: component]) && ([context _wasFormSubmitted])) {
GSWComponent* component=nil;
NSString* nameInContext=nil;
NSArray* fileDatas=nil;
NSString* fileNameFormValueName=nil;
NSString* fileNameValue=nil;
NSData* dataValue=nil;
int fileDatasCount=0;
NS_DURING
{
component=GSWContext_component(context);
nameInContext=[self nameInContext:context];
fileDatas=[request formValuesForKey:nameInContext];
fileDatasCount=[fileDatas count];
/*
if (_fileDatasCount!=1)
{
ExceptionRaise(@"GSWFileUpload",
@"GSWFileUpload: File Data Nb != 1 :%d",
_fileDatasCount);
};
*/
if (fileDatasCount==1)
{
dataValue=[fileDatas objectAtIndex:0];
if (dataValue)
{
if ([dataValue isKindOfClass:[NSData class]])
{
if ([dataValue length]==0)
{
LOGError(@"Empty Data: %@",dataValue);
};
}
else
{
if ([dataValue isKindOfClass:[NSString class]] && [dataValue length]==0)
{
LOGError(@"No Data: %@",dataValue);
dataValue=nil;
}
else
{
};
};
}
else
{
LOGError0(@"No Data:");
};
fileNameFormValueName=[NSString stringWithFormat:@"%@.filename",nameInContext];
fileNameValue=[request formValueForKey:fileNameFormValueName];
if (!fileNameValue || [fileNameValue length]==0)
{
LOGError(@"No fileName: %@",fileNameValue);
};
[_filepath setValue:fileNameValue
inComponent:component];
[_data setValue:dataValue
inComponent:component];
}
else
{
// bug in omniweb-browser if you click cancel in FileOpenPanel, it transmits incorrect datas
[_filepath setValue:nil
inComponent:component];
[_data setValue:nil
inComponent:component];
}
}
NS_HANDLER
{
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,
@"GSWFileUpload in takeValuesFromRequest");
LOGException(@"%@ (%@)",localException,[localException reason]);
[localException raise];
};
NS_ENDHANDLER;
};
};
@end

View file

@ -32,64 +32,29 @@
#ifndef _GSWForm_h__
#define _GSWForm_h__
//OK
@interface GSWForm: GSWHTMLDynamicElement
{
GSWAssociation* _action;
GSWAssociation* _href;
GSWAssociation* _multipleSubmit;
GSWAssociation* _actionClass;
GSWAssociation* _directActionName;
GSWAssociation* _queryDictionary;
//GSWeb Additions {
GSWAssociation* _disabled;
GSWAssociation* _enabled;
GSWAssociation* _fragmentIdentifier;
GSWAssociation* _displayDisabled;
NSDictionary* _otherPathQueryAssociations;
// }
NSDictionary* _otherQueryAssociations;
GSWAssociation * _action;
GSWAssociation * _href;
GSWAssociation * _multipleSubmit;
GSWAssociation * _actionClass;
GSWAssociation * _queryDictionary;
NSDictionary * _otherQueryAssociations;
GSWAssociation * _directActionName;
};
-(id)elementName;
-(id)initWithName:(NSString*)name
associations:(NSDictionary*)associations
contentElements:(NSArray*)elements;
@end
@interface GSWForm (GSWFormA)
#if !GSWEB_STRICT
-(BOOL)disabledInContext:(GSWContext*)context;
#endif
-(BOOL)compactHTMLTags;
-(void)appendToResponse:(GSWResponse*)response
inContext:(GSWContext*)context;
-(void)_appendHiddenFieldsToResponse:(GSWResponse*)response
inContext:(GSWContext*)context;
-(NSDictionary*)computeQueryDictionaryInContext:(GSWContext*)context;
-(NSString*)computeActionStringInContext:(GSWContext*)context;
-(GSWElement*)invokeActionForRequest:(GSWRequest*)request
inContext:(GSWContext*)context;
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context;
@end
@interface GSWForm (GSWFormB)
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)response
inContext:(GSWContext*)context;
-(void)_appendCGIActionToResponse:(GSWResponse*)response
inContext:(GSWContext*)context;
@end
@interface GSWForm (GSWFormC)
+(BOOL)hasGSWebObjectsAssociations;
@end
#endif //_GSWForm_h__

View file

@ -2,8 +2,8 @@
Copyright (C) 1999-2005 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Jan 1999
Written by: David Wetzel <dave@turbocat.de> http://www.turbocat.de/
Date: Jan 2006
$Revision$
$Date$
@ -52,607 +52,233 @@ static Class standardClass = Nil;
};
};
//--------------------------------------------------------------------
-(id)initWithName:(NSString*)aName
-(id)initWithName:(NSString*)name
associations:(NSDictionary*)associations
contentElements:(NSArray*)elements
template:(GSWElement*)template
{
NSMutableDictionary* tmpAssociations=[NSMutableDictionary dictionaryWithDictionary:associations];
LOGObjectFnStartC("GSWForm");
NSDebugMLLog(@"gswdync",@"aName=%@ associations:%@ elements=%@",aName,associations,elements);
if (![tmpAssociations objectForKey:@"method"])
{
if ([tmpAssociations objectForKey:@"get"])
[tmpAssociations setObject:[GSWAssociation associationWithValue:@"get"]
forKey:@"method"];
else
[tmpAssociations setObject:[GSWAssociation associationWithValue:@"post"]
forKey:@"method"];
};
[tmpAssociations removeObjectForKey:action__Key];
[tmpAssociations removeObjectForKey:href__Key];
[tmpAssociations removeObjectForKey:multipleSubmit__Key];
[tmpAssociations removeObjectForKey:actionClass__Key];
[tmpAssociations removeObjectForKey:directActionName__Key];
GSWConstantValueAssociation * methodAssoc = nil;
self = [super initWithName:@"form" associations:associations template:template];
if (!self) {
return nil;
}
DESTROY(_otherQueryAssociations);
_otherQueryAssociations = RETAIN([_associations extractObjectsForKeysWithPrefix:@"?" removePrefix: YES]);
if (!WOStrictFlag)
{
[tmpAssociations removeObjectForKey:disabled__Key];
[tmpAssociations removeObjectForKey:enabled__Key];
};
[tmpAssociations removeObjectForKey:queryDictionary__Key];
if ((_otherQueryAssociations != nil) && ([_otherQueryAssociations count] == 0)) {
DESTROY(_otherQueryAssociations);
}
ASSIGN(_action, [_associations objectForKey: action__Key]);
if (_action != nil) {
[_associations removeObjectForKey: action__Key];
}
ASSIGN(_href, [_associations objectForKey: href__Key]);
if (_href != nil) {
[_associations removeObjectForKey: href__Key];
}
ASSIGN(_multipleSubmit, [_associations objectForKey: multipleSubmit__Key]);
if (_multipleSubmit != nil) {
[_associations removeObjectForKey: multipleSubmit__Key];
}
ASSIGN(_actionClass, [_associations objectForKey: actionClass__Key]);
if (_actionClass != nil) {
[_associations removeObjectForKey: actionClass__Key];
}
ASSIGN(_queryDictionary, [_associations objectForKey: queryDictionary__Key]);
if (_queryDictionary != nil) {
[_associations removeObjectForKey: queryDictionary__Key];
}
ASSIGN(_directActionName, [_associations objectForKey: directActionName__Key]);
if (_directActionName != nil) {
[_associations removeObjectForKey: directActionName__Key];
}
if ((([_associations objectForKey:method__Key] == nil) &&
([_associations objectForKey:@"Method"] == nil)) &&
([_associations objectForKey:@"METHOD"] == nil)) {
//call isValueSettable sur value (return YES)
_action = [[associations objectForKey:action__Key
withDefaultObject:[_action autorelease]] retain];
NSDebugMLLog(@"gswdync",@"GSWForm: action=%@",_action);
methodAssoc = [[GSWConstantValueAssociation alloc] initWithValue:post__Key];
[_associations setObject: methodAssoc
forKey:method__Key];
DESTROY(methodAssoc);
}
if (((_action != nil) && (_href != nil)) ||
((_action != nil) && (_directActionName != nil)) ||
((_href != nil) && (_directActionName != nil)) ||
((_action != nil) && (_actionClass != nil)) ||
((_href != nil) && (_actionClass != nil))) {
_href = [[associations objectForKey:href__Key
withDefaultObject:[_href autorelease]] retain];
NSDebugMLLog(@"gswdync",@"GSWForm: href=%@",_href);
_multipleSubmit = [[associations objectForKey:multipleSubmit__Key
withDefaultObject:[_multipleSubmit autorelease]] retain];
NSDebugMLLog(@"gswdync",@"GSWForm: multipleSubmit=%@",_multipleSubmit);
_actionClass = [[associations objectForKey:actionClass__Key
withDefaultObject:[_actionClass autorelease]] retain];
NSDebugMLLog(@"gswdync",@"GSWForm: actionClass=%@",_actionClass);
_directActionName = [[associations objectForKey:directActionName__Key
withDefaultObject:[_directActionName autorelease]] retain];
NSDebugMLLog(@"gswdync",@"GSWForm: directActionName=%@",_directActionName);
if (!WOStrictFlag)
{
_disabled = [[associations objectForKey:disabled__Key
withDefaultObject:[_disabled autorelease]] retain];
NSDebugMLLog(@"gswdync",@"GSWForm disabled=%@",_disabled);
_enabled = [[associations objectForKey:enabled__Key
withDefaultObject:[_enabled autorelease]] retain];
NSDebugMLLog(@"gswdync",@"GSWForm enabled=%@",_enabled);
if (_disabled && _enabled)
{
ExceptionRaise(@"GSWForm",@"You can't specify 'disabled' and 'enabled' together. componentAssociations:%@",
associations);
};
_fragmentIdentifier = [[associations objectForKey:fragmentIdentifier__Key
withDefaultObject:[_fragmentIdentifier autorelease]] retain];
NSDebugMLLog(@"gswdync",@"fragmentIdentifier=%@",_fragmentIdentifier);
[tmpAssociations removeObjectForKey:fragmentIdentifier__Key];
_displayDisabled = [[associations objectForKey:displayDisabled__Key
withDefaultObject:[_displayDisabled autorelease]] retain];
NSDebugMLLog(@"gswdync",@"displayDisabled=%@",_displayDisabled);
[tmpAssociations removeObjectForKey:displayDisabled__Key];
};
_queryDictionary = [[associations objectForKey:queryDictionary__Key
withDefaultObject:[_queryDictionary autorelease]] retain];
NSDebugMLLog(@"gswdync",@"GSWForm: queryDictionary=%@",_queryDictionary);
if ([tmpAssociations count]>0)
{
ASSIGN(_otherQueryAssociations,([tmpAssociations extractObjectsForKeysWithPrefix:@"?"
removePrefix:YES]));
if ([_otherQueryAssociations count]==0)
DESTROY(_otherQueryAssociations);
if (!WOStrictFlag)
{
ASSIGN(_otherPathQueryAssociations,([tmpAssociations extractObjectsForKeysWithPrefix:@"!"
removePrefix:YES]));
if ([_otherPathQueryAssociations count]==0)
DESTROY(_otherPathQueryAssociations);
};
};
NSDebugMLLog(@"gswdync",@"_otherQueryAssociations=%@",_otherQueryAssociations);
NSDebugMLLog(@"gswdync",@"_otherPathQueryAssociations=%@",_otherPathQueryAssociations);
if ((self=[super initWithName:aName
attributeAssociations:tmpAssociations
contentElements:elements]))
{
};
[NSException raise:NSInvalidArgumentException
format:@"%s: At least two of these conflicting attributes are present: 'action', 'href', 'directActionName', 'actionClass'",
__PRETTY_FUNCTION__];
}
if ((_action != nil) && ([_action isValueConstant])) {
[NSException raise:NSInvalidArgumentException
format:@"%s: 'action' is a constant.",
__PRETTY_FUNCTION__];
}
return self;
};
}
//--------------------------------------------------------------------
-(void)dealloc
-(void) dealloc
{
DESTROY(_action);
DESTROY(_href);
DESTROY(_multipleSubmit);
DESTROY(_actionClass);
DESTROY(_directActionName);
DESTROY(_queryDictionary);
DESTROY(_disabled);
DESTROY(_enabled);
DESTROY(_fragmentIdentifier);
DESTROY(_displayDisabled);
DESTROY(_otherQueryAssociations);
DESTROY(_otherPathQueryAssociations);
DESTROY(_directActionName);
[super dealloc];
};
}
//--------------------------------------------------------------------
-(id)description
-(id) description
{
return [NSString stringWithFormat:@"<%s %p>",
return [NSString stringWithFormat:@"<%s %p action: %@ actionClass: %@ directActionName: %@ href:%@ multipleSubmit: %@ queryDictionary: %@ otherQueryAssociations: %@ >",
object_get_class_name(self),
(void*)self];
(void*)self, _action, _actionClass, _directActionName, _href, _multipleSubmit,
_queryDictionary, _otherQueryAssociations];
};
//--------------------------------------------------------------------
-(id)elementName
- (void) _enterFormInContext:(GSWContext *) context
{
//OK
return @"form";
};
[context setInForm:YES];
if ([[context elementID] isEqual:[context senderID]]) {
[context _setFormSubmitted:YES];
}
}
@end
//====================================================================
@implementation GSWForm (GSWFormA)
//GSWeb Additions {
//--------------------------------------------------------------------
-(BOOL)disabledInContext:(GSWContext*)context
- (void) _exitFormInContext:(GSWContext *) context
{
if (_enabled)
{
return !GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_enabled,context);
[context setInForm:NO];
[context _setFormSubmitted:NO];
}
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context;
{
[self _enterFormInContext:context];
[super takeValuesFromRequest:request
inContext:context];
[self _exitFormInContext:context];
}
-(GSWElement*)invokeActionForRequest:(GSWRequest*) request
inContext:(GSWContext*) context
{
id supervalue = nil;
[self _enterFormInContext:context];
[context _setActionInvoked:NO];
[context _setIsMultipleSubmitForm:(_multipleSubmit == nil ? NO : [_multipleSubmit boolValueInComponent:[context component]])];
supervalue = [super invokeActionForRequest:request inContext:context];
if ((![context _wasActionInvoked]) && ([context _wasFormSubmitted])) {
if (_action != nil) {
supervalue = [_action valueInComponent:[context component]];
}
else
{
return GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_disabled,context);
};
};
// }
//--------------------------------------------------------------------
-(BOOL)compactHTMLTags
if (supervalue == nil) {
supervalue = [context page];
}
}
[context _setIsMultipleSubmitForm:NO];
[self _exitFormInContext:context];
return supervalue;
}
-(void) _appendHiddenFieldsToResponse:(GSWResponse*) response
inContext:(GSWContext*) context
{
NSEnumerator * myEnumer = nil;
NSString * key = nil;
NSString * value = nil;
NSDictionary * queryDict = [self computeQueryDictionaryWithActionClassAssociation: _actionClass
directActionNameAssociation: _directActionName
queryDictionaryAssociation: _queryDictionary
otherQueryAssociations: _otherQueryAssociations
inContext: context];
if ([queryDict count] > 0) {
myEnumer = [queryDict keyEnumerator];
while ((key = [myEnumer nextObject])) {
value = [queryDict objectForKey:key];
GSWResponse_appendContentAsciiString(response,@"<input type=hidden");
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response, name__Key, key, NO);
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response, value__Key, value, NO);
GSWResponse_appendContentAsciiString(response,@">\n");
}
}
}
-(void) appendToResponse:(GSWResponse *) response
inContext:(GSWContext*) context
{
[context setInForm:YES];
[super appendToResponse: response inContext: context];
[context setInForm:NO];
}
-(void) appendChildrenToResponse:(GSWResponse *) response
inContext:(GSWContext*) context
{
[super appendChildrenToResponse:response
inContext:context];
[self _appendHiddenFieldsToResponse:response
inContext:context];
}
-(void) _appendCGIActionToResponse:(GSWResponse *) response
inContext:(GSWContext*) context
{
NSString *str = [self computeActionStringWithActionClassAssociation: _actionClass
directActionNameAssociation: _directActionName
inContext: context];
NSString * myActionURL = [context directActionURLForActionNamed: str
queryDictionary: nil];
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response, action__Key, myActionURL, NO);
}
-(void) appendAttributesToResponse:(GSWResponse *) response
inContext:(GSWContext*) context
{
NSString * value = nil;
GSWComponent * component = [context component];
[super appendAttributesToResponse:response inContext:context];
if (_href != nil) {
value = [_href valueInComponent:component];
}
if (_directActionName != nil || _actionClass != nil) {
[self _appendCGIActionToResponse:response inContext: context];
} else {
if (value != nil) {
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response, action__Key, value, NO);
} else {
if (_href == nil) {
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response,
action__Key, [context componentActionURL], NO);
} else {
NSLog(@"%s: action attribute evaluates to null. %@", __PRETTY_FUNCTION__, self);
}
}
}
}
+(BOOL)hasGSWebObjectsAssociations
{
LOGObjectFnNotImplemented(); //TODOFN
return NO;
};
//--------------------------------------------------------------------
-(void)_appendHiddenFieldsToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
NSDictionary* hiddenFields = nil;
LOGObjectFnStart();
hiddenFields = [self computeQueryDictionaryInContext:aContext];
if([hiddenFields count]>0)
{
NSEnumerator* enumerator=[hiddenFields keyEnumerator];
id key=nil;
while((key=[enumerator nextObject]))
{
id value=[hiddenFields objectForKey:key];
GSWResponse_appendContentAsciiString(aResponse,@"<input type=hidden");
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(aResponse,
@"name",
key,
NO);//Don't escape name
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(aResponse,
@"value",
value,
NO);//Don't escape value (should be escaped before !)
GSWResponse_appendContentCharacter(aResponse,'>');
};
};
LOGObjectFnStop();
};
//--------------------------------------------------------------------
-(NSDictionary*)computeQueryDictionaryInContext:(GSWContext*)context
{
NSDictionary* queryDictionary=nil;
LOGObjectFnStart();
queryDictionary=[self computeQueryDictionaryWithActionClassAssociation:_actionClass
directActionNameAssociation:_directActionName
queryDictionaryAssociation:_queryDictionary
otherQueryAssociations:_otherQueryAssociations
inContext:context];
LOGObjectFnStop();
return queryDictionary;
};
//--------------------------------------------------------------------
-(NSString*)computeActionStringInContext:(GSWContext*)context
{
NSString* actionString=nil;
LOGObjectFnStart();
actionString=[self computeActionStringWithActionClassAssociation:_actionClass
directActionNameAssociation:_directActionName
otherPathQueryAssociations:_otherPathQueryAssociations
inContext:context];
LOGObjectFnStop();
return actionString;
};
//--------------------------------------------------------------------
-(void)appendToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
//OK
BOOL disabledInContext=NO;
BOOL displayDisabledValue=YES;
GSWDeclareDebugElementIDsCount(aContext);
LOGObjectFnStartC("GSWForm");
GSWStartElement(aContext);
GSWSaveAppendToResponseElementID(aContext);
GSWResponse_appendDebugCommentContentString(aResponse,
([NSString stringWithFormat:@"declarationName=%@ ID=%@",
[self declarationName],
GSWContext_elementID(aContext)]));
if (!WOStrictFlag)
{
disabledInContext=[self disabledInContext:aContext];
[aContext setInForm:!disabledInContext];
if (!disabledInContext)
{
if ([aContext isInEnabledForm])
{
NSWarnLog(@"Enabled Form %@ ID=%@ in an enbled form. This usually doesn't works well",
[self declarationName],
GSWContext_elementID(aContext));
//GSWResponse_appendContentString(aResponse,@"FORM in a FORM"];//TEMP
[aContext setInEnabledForm:YES];
};
};
if (disabledInContext && _displayDisabled)
{
displayDisabledValue=GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_displayDisabled,aContext);
};
}
else
[aContext setInForm:YES];
if (!disabledInContext || displayDisabledValue)
{
[self appendToResponse:aResponse
inContext:aContext
elementsFromIndex:0
toIndex:[_elementsMap length]-2];
[self _appendHiddenFieldsToResponse:aResponse
inContext:aContext];
[self appendToResponse:aResponse
inContext:aContext
elementsFromIndex:[_elementsMap length]-1
toIndex:[_elementsMap length]-1];
[aContext setInForm:NO];
}
else
{
if ([_elementsMap length]>2)
{
[self appendToResponse:aResponse
inContext:aContext
elementsFromIndex:1 // omit <form>
toIndex:[_elementsMap length]-2]; // omit </form>
};
};
if (!disabledInContext)
{
[aContext setInForm:NO];
[aContext setInEnabledForm:NO];
};
GSWStopElement(aContext);
GSWAssertDebugElementIDsCount(aContext);
LOGObjectFnStopC("GSWForm");
};
//--------------------------------------------------------------------
-(GSWElement*)invokeActionForRequest:(GSWRequest*)request
inContext:(GSWContext*)aContext
{
//OK
GSWElement* element=nil;
NSString* senderID=nil;
NSString* elementID=nil;
BOOL isFormSubmited=NO;
BOOL multipleSubmitValue=NO;
GSWDeclareDebugElementIDsCount(aContext);
LOGObjectFnStartC("GSWForm");
GSWStartElement(aContext);
senderID=GSWContext_senderID(aContext);
elementID=GSWContext_elementID(aContext);
NSDebugMLLog(@"gswdync",@"senderId=%@",senderID);
NS_DURING
{
GSWAssertCorrectElementID(aContext);// Debug Only
if ([self prefixMatchSenderIDInContext:aContext]) //Avoid trying to find action if we are not the good component
{
isFormSubmited=[elementID isEqualToString:senderID];
NSDebugMLLog(@"gswdync",@"ET=%@ declarationName=%@ \n id=%@ \nsenderId=%@ \nisFormSubmited=%s",
[self class],
[self declarationName],
elementID,
senderID,
(isFormSubmited ? "YES" : "NO"));
if (!WOStrictFlag && isFormSubmited && [self disabledInContext:aContext])
isFormSubmited=NO;
if (isFormSubmited)
{
[aContext setInForm:YES];
[aContext setInEnabledForm:YES];
[aContext _setFormSubmitted:YES];
multipleSubmitValue=GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_multipleSubmit,aContext);
NSDebugMLLog(@"gswdync",@"ET=%@ declarationName=%@ \n id=%@ \nsenderId=%@ \nmultipleSubmit=%s",
[self class],
[self declarationName],
elementID,
senderID,
(multipleSubmitValue ? "YES" : "NO"));
[aContext _setIsMultipleSubmitForm:multipleSubmitValue];
};
NSDebugMLLog(@"gswdync",@"isFormSubmited=%d",isFormSubmited);
element=[super invokeActionForRequest:request
inContext:aContext];
NSAssert2(!element || [element isKindOfClass:[GSWElement class]],
@"Element is a %@ not a GSWElement: %@",
[element class],
element);
NSDebugMLLog(@"gswdync",@"isFormSubmited=%d",isFormSubmited);
NSDebugMLLog(@"gswdync",@"[aContext _wasActionInvoked]=%d",[aContext _wasActionInvoked]);
if (isFormSubmited)
{
NSDebugMLLog(@"gswdync",@"ET=%@ declarationName=%@ \n id=%@ \nsenderId=%@ \nmultipleSubmit=%s \n[aContext _wasActionInvoked]=%d",
[self class],
[self declarationName],
elementID,
senderID,
(multipleSubmitValue ? "YES" : "NO"),
[aContext _wasActionInvoked]);
if (_action && ![aContext _wasActionInvoked])
{
GSWComponent* component=GSWContext_component(aContext);
element = (GSWElement*)[_action valueInComponent:component];
[aContext _setActionInvoked:YES];
};
[aContext setInForm:NO];
[aContext setInEnabledForm:NO];
[aContext _setFormSubmitted:NO];
[aContext _setIsMultipleSubmitForm:NO];
};
elementID=GSWContext_elementID(aContext);
GSWStopElement(aContext);
};
GSWAssertDebugElementIDsCount(aContext);
}
NS_HANDLER
{
LOGException0(@"exception in GSWForm invokeActionForRequest:inContext");
LOGException(@"exception=%@",localException);
localException=ExceptionByAddingUserInfoObjectFrameInfo(localException,
@"In GSWForm invokeActionForRequest:inContext");
LOGException(@"exception=%@",localException);
[localException raise];
}
NS_ENDHANDLER;
if (![aContext _wasActionInvoked] && GSWContext_isSenderIDSearchOver(aContext))
{
LOGError(@"Action not invoked at the end of %@ (declarationName=%@) (id=%@) senderId=%@",
[self class],
[self declarationName],
GSWContext_elementID(aContext),
GSWContext_senderID(aContext));
};
LOGObjectFnStopC("GSWForm");
return element;
};
//--------------------------------------------------------------------
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)aContext
{
//OK
NSString* senderID=nil;
NSString* elementID=nil;
BOOL isFormSubmited=NO;
GSWDeclareDebugElementIDsCount(aContext);
LOGObjectFnStartC("GSWForm");
GSWStartElement(aContext);
GSWAssertCorrectElementID(aContext);
senderID=GSWContext_senderID(aContext);
elementID=GSWContext_elementID(aContext);
NSDebugMLLog(@"gswdync",@"senderID=%@",senderID);
if ([self prefixMatchSenderIDInContext:aContext]) //Avoid taking values if we are not the good form
{
isFormSubmited=[elementID isEqualToString:senderID];
NSDebugMLLog(@"gswdync",@"isFormSubmited=%d",(int)isFormSubmited);
if (!WOStrictFlag && isFormSubmited && [self disabledInContext:aContext])
isFormSubmited=NO;
NSDebugMLLog(@"gswdync",@"Starting GSWForm TV ET=%@ id=%@",[self class],GSWContext_elementID(aContext));
if (isFormSubmited)
{
[aContext setInForm:YES];
[aContext setInEnabledForm:YES];
[aContext _setFormSubmitted:YES];
};
NSDebugMLLog(@"gswdync",@"\n\ndynamicChildren=%@",_dynamicChildren);
NSDebugMLLog(@"gswdync",@"[dynamicChildren count]=%d",[_dynamicChildren count]);
[super takeValuesFromRequest:request
inContext:aContext];
if (isFormSubmited)
{
[aContext setInForm:NO];
[aContext setInEnabledForm:NO];
[aContext _setFormSubmitted:NO];
};
};
GSWStopElement(aContext);
GSWAssertDebugElementIDsCount(aContext);
LOGObjectFnStopC("GSWForm");
};
@end
//====================================================================
@implementation GSWForm (GSWFormB)
//--------------------------------------------------------------------
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
BOOL disabledInContext=NO;
LOGObjectFnStartC("GSWForm");
if (!WOStrictFlag)
{
disabledInContext=[self disabledInContext:aContext];
NSDebugMLLog(@"gswdync",@"disabledInContext=%s",(disabledInContext ? "YES" : "NO"));
};
if (disabledInContext)
{
// Mainly for debugginf purpose as it is not
// handled by browsers
GSWResponse_appendContentAsciiString(aResponse,@" disabled");
}
else
{
GSWComponent* component=GSWContext_component(aContext);
if (_href)
{
id actionValue=[_href valueInComponent:component];
if (_fragmentIdentifier)
{
id fragment=[_fragmentIdentifier valueInComponent:component];
NSDebugMLLog(@"gswdync",@"fragment=%@",fragment);
if (fragment)
{
if (actionValue)
actionValue=[NSStringWithObject(actionValue) stringByAppendingString:@"#"];
else
actionValue=@"#";
actionValue=[actionValue stringByAppendingString:NSStringWithObject(fragment)];
};
};
NSDebugMLLog(@"gswdync",@"actionValue=%@",actionValue);
//TODO emit a warning !
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(aResponse,
@"action",
actionValue,
NO);
}
else if (_directActionName || _actionClass)
{
[self _appendCGIActionToResponse:aResponse
inContext:aContext];
}
else
{
id actionValue=[aContext componentActionURL];
if (_fragmentIdentifier)
{
id fragment=[_fragmentIdentifier valueInComponent:component];
NSDebugMLLog(@"gswdync",@"fragment=%@",fragment);
if (fragment)
actionValue=[NSString stringWithFormat:@"%@#%@",
actionValue,fragment];
};
NSDebugMLLog(@"gswdync",@"actionValue=%@",actionValue);
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(aResponse,
@"action",
actionValue,
NO);
};
};
LOGObjectFnStopC("GSWForm");
};
//--------------------------------------------------------------------
-(void)_appendCGIActionToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
NSString* actionString=nil;
NSString* anUrl=nil;
LOGObjectFnStartC("GSWForm");
actionString=[self computeActionStringInContext:aContext];
NSDebugMLLog(@"gswdync",@"actionString=%@",actionString);
anUrl=(NSString*)[aContext directActionURLForActionNamed:actionString
queryDictionary:nil];
NSDebugMLLog(@"gswdync",@"anUrl=%@",anUrl);
if (_fragmentIdentifier)
{
id fragment=[_fragmentIdentifier valueInComponent:GSWContext_component(aContext)];
NSDebugMLLog(@"gswdync",@"fragment=%@",fragment);
if (fragment)
{
if (anUrl)
anUrl=[NSStringWithObject(anUrl) stringByAppendingString:@"#"];
else
anUrl=@"#";
anUrl=[anUrl stringByAppendingString:NSStringWithObject(fragment)];
};
};
NSDebugMLLog(@"gswdync",@"anUrl=%@",anUrl);
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(aResponse,
@"action",
anUrl,
NO);
LOGObjectFnStopC("GSWForm");
};
@end
//====================================================================
@implementation GSWForm (GSWFormC)
//--------------------------------------------------------------------
+(BOOL)hasGSWebObjectsAssociations
{
return YES;
};
@end

View file

@ -33,24 +33,30 @@ RCS_ID("$Id$")
#include "GSWeb.h"
static Class GSWHTMLBareStringClass = Nil;
//====================================================================
@implementation GSWGenericContainer
+ (void) initialize
{
if (self == [GSWGenericContainer class])
{
GSWHTMLBareStringClass = [GSWHTMLBareString class];
};
};
-(id)initWithName:(NSString*)aName
associations:(NSDictionary*)associations
template:(GSWElement*)templateElement
{
NSMutableDictionary* tmpAssociations=[NSMutableDictionary dictionaryWithDictionary:associations];
LOGObjectFnStartC("GSWForm");
NSDebugMLLog(@"gswdync",@"aName=%@ associations:%@ templateElement=%@",aName,associations,templateElement);
_elementName = [[associations objectForKey:elementName__Key
withDefaultObject:[_elementName autorelease]] retain];
NSDebugMLLog(@"gswdync",@"GSWGenericContainer: elementName=%@",_elementName);
_otherTagString = [[associations objectForKey:otherTagString__Key
withDefaultObject:[_otherTagString autorelease]] retain];
NSDebugMLLog(@"gswdync",@"GSWGenericContainer: otherTagString=%@",_otherTagString);
[tmpAssociations removeObjectForKey:elementName__Key];
[tmpAssociations removeObjectForKey:otherTagString__Key];
@ -59,7 +65,6 @@ RCS_ID("$Id$")
{
_omitElement = [[associations objectForKey:omitElement__Key
withDefaultObject:[_omitElement autorelease]] retain];
NSDebugMLLog(@"gswdync",@"GSWGenericContainer: omitElement=%@",_omitElement);
[tmpAssociations removeObjectForKey:omitElement__Key];
};
@ -160,8 +165,13 @@ RCS_ID("$Id$")
-(GSWElement*)invokeActionForRequest:(GSWRequest*)aRequest
inContext:(GSWContext*)aContext
{
return [_element invokeActionForRequest:aRequest
inContext:aContext];
if ([_element class] != GSWHTMLBareStringClass) {
return [_element invokeActionForRequest:aRequest
inContext:aContext];
}
return nil;
};
//--------------------------------------------------------------------

View file

@ -63,8 +63,10 @@
-(NSString*)userDefinedString;
-(id)userDefinedValue;
-(BOOL)hitTest:(NSPoint*)point;
-(BOOL)hitTestX:(int)x
y:(int)y;
+(GSWGeometricRegion*)hitTestX:(int)x
y:(int)y
inRegions:(NSArray*)regions;

View file

@ -36,72 +36,72 @@ RCS_ID("$Id$")
//====================================================================
@implementation GSWHTMLBareString
//--------------------------------------------------------------------
// we should ONLY support initWithString: ! dw
-(id)init
{
if ((self=[super init]))
{
};
return self;
};
[NSException raise:NSInvalidArgumentException
format:@"%s: use initWithString: to init",
__PRETTY_FUNCTION__];
return nil;
}
//--------------------------------------------------------------------
-(id)initWithString:(NSString*)aString
{
if ((self=[self init]))
if ((self=[super init]))
{
ASSIGN(_string,aString);
};
return self;
};
}
//--------------------------------------------------------------------
-(void)dealloc
{
DESTROY(_string);
[super dealloc];
}
//--------------------------------------------------------------------
-(NSString*)description
{
return [NSString stringWithFormat:@"<%s %p - String:[%@]>",
object_get_class_name(self),
(void*)self,
_string];
};
}
//--------------------------------------------------------------------
-(NSString*)string
{
return _string;
};
}
@end
//====================================================================
@implementation GSWHTMLBareString (GSWHTMLBareStringA)
//--------------------------------------------------------------------
-(void)appendToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
LOGObjectFnStart();
NSDebugMLLog(@"gswdync",@"ET=%@ id=%@",[self class],GSWContext_elementID(aContext));
GSWSaveAppendToResponseElementID(aContext);//Debug Only
GSWResponse_appendContentString(aResponse,_string);
NSDebugMLLog(@"gswdync",@"END ET=%@ id=%@",[self class],GSWContext_elementID(aContext));
LOGObjectFnStop();
};
GSWResponse_appendContentString(aResponse,_string);
}
@end
//====================================================================
@implementation GSWHTMLBareString (GSWHTMLBareStringB)
//--------------------------------------------------------------------
+(id)elementWithString:(NSString*)aString
{
return [[[GSWHTMLBareString alloc]initWithString:aString] autorelease];
};
}
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context
{
}
-(GSWElement*)invokeActionForRequest:(GSWRequest*)request
inContext:(GSWContext*)context
{
[NSException raise:NSInvalidArgumentException
format:@"%s: A BareString does not have any brain to think about actions. You should avoid calling this method to save CPU cycles.",
__PRETTY_FUNCTION__];
//Does Nothing
return nil;
}
@end

View file

@ -36,122 +36,49 @@
//====================================================================
@interface GSWHTMLDynamicElement: GSWDynamicElement
@interface GSWHTMLDynamicElement: GSWDynamicGroup
{
NSData* _elementsMap;
NSArray* _htmlBareStrings;
NSArray* _dynamicChildren;
NSArray* _attributeAssociations;
};
-(NSString*)elementName;
-(NSArray*)dynamicChildren;
-(NSArray*)htmlBareStrings;
-(NSData*)elementsMap;
-(NSArray*)attributeAssociations;
NSString * _elementName;
NSMutableDictionary * _nonURLAttributeAssociations;
NSMutableDictionary * _urlAttributeAssociations;
NSString * _constantAttributesRepresentation;
NSMutableDictionary * _associations;
BOOL _finishedInitialization;
}
-(id)_initWithElementsMap:(NSData*)elementsMap
htmlBareStrings:(NSArray*)htmlBareStrings
dynamicChildren:(NSArray*)dynamicChildren
attributeAssociations:(NSArray*)attributeAssociations;
- (NSDictionary*) computeQueryDictionaryWithActionClassAssociation: (GSWAssociation*)actionClass
directActionNameAssociation: (GSWAssociation*)directActionName
queryDictionaryAssociation: (GSWAssociation*)queryDictionary
otherQueryAssociations: (NSDictionary*)otherQueryAssociations
inContext: (GSWContext*)context;
-(id)initWithName:(NSString*)elementName
associations:(NSDictionary*)associations
contentElements:(NSArray*)elements;
-(id)initWithName:(NSString*)elementName
attributeAssociations:(NSDictionary*)attributeAssociations
contentElements:(NSArray*)elements;
-(id)initWithName:(NSString*)elementName
associations:(NSDictionary*)associations
template:(GSWElement*)templateElement;
-(void)dealloc;
-(void)_setEndOfHTMLTag:(unsigned int)unknown;
-(NSString*)description;
-(void)setHtmlBareStrings:(NSArray*)htmlBareStrings;
@end
//====================================================================
@interface GSWHTMLDynamicElement (GSWHTMLDynamicElementA)
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext;
-(unsigned int)GSWebObjectsAssociationsCount;
-(void)appendToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext;
-(void)appendToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
elementsFromIndex:(unsigned int)fromIndex
toIndex:(unsigned int)toIndex;
-(GSWElement*)invokeActionForRequest:(GSWRequest*)aRequest
inContext:(GSWContext*)aContext;
-(void)takeValuesFromRequest:(GSWRequest*)aRequest
inContext:(GSWContext*)aContext;
@end
//====================================================================
@interface GSWHTMLDynamicElement (GSWHTMLDynamicElementB)
-(BOOL)compactHTMLTags;
-(BOOL)appendStringAtRight:(id)unkwnon
withMapping:(char*)mapping;
-(BOOL)appendStringAtLeft:(id)unkwnon
withMapping:(char*)mapping;
-(BOOL)canBeFlattenedAtInitialization;
@end
//====================================================================
@interface GSWHTMLDynamicElement (GSWHTMLDynamicElementC)
+(void)setDynamicElementCompaction:(BOOL)flag;
+(BOOL)escapeHTML;
+(BOOL)hasGSWebObjectsAssociations;
@end
//====================================================================
@interface GSWHTMLDynamicElement (GSWHTMLDynamicElementD)
-(NSString*)computeActionStringWithActionClassAssociation:(GSWAssociation*)actionClass
directActionNameAssociation:(GSWAssociation*)directActionName
inContext:(GSWContext*)context;
-(NSString*)computeActionStringWithActionClassAssociation:(GSWAssociation*)actionClass
directActionNameAssociation:(GSWAssociation*)directActionName
otherPathQueryAssociations:(NSDictionary*)otherPathQueryAssociations
inContext:(GSWContext*)context;
-(NSString*)computeActionStringWithActionClassAssociation:(GSWAssociation*)actionClass
directActionNameAssociation:(GSWAssociation*)directActionName
pathQueryDictionaryAssociation:(GSWAssociation*)pathQueryDictionaryAssociation
otherPathQueryAssociations:(NSDictionary*)otherPathQueryAssociations
inContext:(GSWContext*)context;
-(NSDictionary*)computeQueryDictionaryWithActionClassAssociation:(GSWAssociation*)actionClass
directActionNameAssociation:(GSWAssociation*)directActionName
queryDictionaryAssociation:(GSWAssociation*)queryDictionary
otherQueryAssociations:(NSDictionary*)otherQueryAssociations
inContext:(GSWContext*)context;
@end
directActionNameAssociation:(GSWAssociation*)directActionName
inContext:(GSWContext*)context;
//====================================================================
@interface GSWHTMLDynamicElement (GSWHTMLDynamicElementCID)
-(void) appendNonURLAttributesToResponse:(GSWResponse*) response
inContext:(GSWContext*) context;
-(NSString*)addCIDElement:(NSDictionary*)cidElement
forKey:(NSString*)cidKeyValue
forCIDStoreAssociation:(GSWAssociation*)cidStore
inContext:(GSWContext*)aContext;
-(void) appendURLAttributesToResponse:(GSWResponse*) response
inContext:(GSWContext*) context;
-(void) appendConstantAttributesToResponse:(GSWResponse*) response
inContext:(GSWContext*)aContext;
-(NSString*)addURL:(NSString*)url
forCIDKeyAssociation:(GSWAssociation*)cidKey
CIDStoreAssociation:(GSWAssociation*)cidStore
inContext:(GSWContext*)aContext;
-(void) appendAttributesToResponse:(GSWResponse *) response
inContext:(GSWContext*) context;
-(void) _appendOpenTagToResponse:(GSWResponse *) response
inContext:(GSWContext*) context;
-(void) _appendCloseTagToResponse:(GSWResponse *) response
inContext:(GSWContext*) context;
- (NSString*) constantAttributesRepresentation;
- (NSString*) _frameworkNameForAssociation: (GSWAssociation*)association
inComponent: (GSWComponent *) component;
- (NSString*) elementName;
-(NSString*)addURLValuedElementData:(GSWURLValuedElementData*)data
forCIDKeyAssociation:(GSWAssociation*)cidKey
CIDStoreAssociation:(GSWAssociation*)cidStore
inContext:(GSWContext*)aContext;
-(NSString*)addPath:(NSString*)path
forCIDKeyAssociation:(GSWAssociation*)cidKey
CIDStoreAssociation:(GSWAssociation*)cidStore
inContext:(GSWContext*)aContext;
@end
#endif

File diff suppressed because it is too large Load diff

View file

@ -148,8 +148,6 @@ Call delegate -parser:didParseText:
**/
-(void)didParseText
{
LOGObjectFnStart();
// Is there some text ?
if(_textStopIndex>=_textStartIndex)
{
@ -157,9 +155,6 @@ Call delegate -parser:didParseText:
NSString* content=[NSString stringWithCharacters:_uniBuf+_textStartIndex
length:_textStopIndex-_textStartIndex+1];
NSDebugMLLog(@"GSWHTMLRawParser",@"GSWHTMLRawParser didParseText (length=%d): %@",
[content length],content);
// Call delegate -parser:didParseText:
[_delegate parser:self
didParseText:content];
@ -167,8 +162,6 @@ Call delegate -parser:didParseText:
// reset textStartIndex
_textStartIndex=_index;
};
LOGObjectFnStop();
}
@ -182,20 +175,14 @@ Call delegate -parser:didParseOpeningDynamicTagOfType:withProperties:
withProperties:(NSDictionary*)tagProperties
templateInfo:(NSString*)templateInfo
{
LOGObjectFnStart();
// Records previously parsed text
[self didParseText];
NSDebugMLLog(@"GSWHTMLRawParser",@"GSWHTMLRawParser startDynamicTagOfType:%d withProperties:%@",
tagType,tagProperties);
// Calls delegate -parser:didParseOpeningDynamicTagOfType:withProperties:
[_delegate parser:self
didParseOpeningDynamicTagOfType:tagType
withProperties:tagProperties
templateInfo:templateInfo];
LOGObjectFnStop();
}
//--------------------------------------------------------------------
@ -206,20 +193,13 @@ Call delegate -parser:didParseClosingDynamicTagOfType:
-(void)stopDynamicTagOfType:(GSWHTMLRawParserTagType)tagType
withTemplateInfo:(NSString*)templateInfo
{
LOGObjectFnStart();
// Records previously parsed text
[self didParseText];
NSDebugMLLog(@"GSWHTMLRawParser",@"GSWHTMLRawParser stopDynamicTagOfType:%d",
tagType);
// Calls delegate -parser:didParseClosingDynamicTagOfType:
[_delegate parser:self
didParseClosingDynamicTagOfType:tagType
withTemplateInfo:templateInfo];
LOGObjectFnStop();
}
//--------------------------------------------------------------------
@ -228,23 +208,16 @@ Call delegate -parser:didParseComment:
**/
-(void)didParseCommentWithContentString:(NSString*)contentString
{
LOGObjectFnStart();
// Records previously parsed text
[self didParseText];
// Is there comment text
if ([contentString length]>0)
{
NSDebugMLLog(@"GSWHTMLRawParser",@"GSWHTMLRawParser didParseComment (length=%d): %@",
[contentString length],contentString);
// Calls delegate -parser:didParseComment:
[_delegate parser:self
didParseComment:contentString];
};
LOGObjectFnStop();
}
//--------------------------------------------------------------------
@ -259,11 +232,7 @@ An exception is raised if the end quote is not found,...
index:(int*)indexPtr
stopIndex:(int)stopIndex
{
int startIndex=0;
LOGObjectFnStart();
//ParserDebugLogBuffer(_uniBuf,stopIndex+1,*indexPtr,stopIndex+1);
int startIndex=0;
NSAssert2(_uniBuf[*indexPtr]==quote,@"First character is not a '%c' but a '%c'",
(char)quote,(char)_uniBuf[*indexPtr]);
@ -285,8 +254,6 @@ An exception is raised if the end quote is not found,...
else
(*indexPtr)++;
}
NSDebugMLLog(@"GSWHTMLRawParser",@"startIndex=%d *indexPtr=%d _uniBuf[*indexPtr]='%c'",
startIndex,*indexPtr,(char)_uniBuf[*indexPtr]);
if (_uniBuf[*indexPtr]!=quote)
{
if (*indexPtr>stopIndex)
@ -305,11 +272,6 @@ An exception is raised if the end quote is not found,...
NSAssert2(_uniBuf[*indexPtr]==quote,@"Last character is not a '%c' but a '%c'",
(char)quote,(char)_uniBuf[*indexPtr]);
//ParserDebugLogBuffer(_uniBuf,stopIndex+1,*indexPtr,stopIndex+1);
NSDebugMLLog(@"GSWHTMLRawParser",@"startIndex=%d *indexPtr=%d _uniBuf[*indexPtr]='%c'",
startIndex,*indexPtr,(char)_uniBuf[*indexPtr]);
LOGObjectFnStop();
}
//--------------------------------------------------------------------
@ -327,13 +289,9 @@ An exception is raised if the end quote is not found,...
NSString* string=nil;
int startIndex=0;
LOGObjectFnStart();
NSAssert2(_uniBuf[*indexPtr]==quote,@"First character is not a '%c' but a '%c'",
(char)quote,(char)_uniBuf[*indexPtr]);
//ParserDebugLogBuffer(_uniBuf,stopIndex+1,*indexPtr,stopIndex+1);
startIndex=(*indexPtr);
[self _skipQuotedStringWithQuote:quote
@ -343,16 +301,9 @@ An exception is raised if the end quote is not found,...
NSAssert2(_uniBuf[*indexPtr]==quote,@"Last character is not a '%c' but a '%c'",
(char)quote,(char)_uniBuf[*indexPtr]);
//ParserDebugLogBuffer(_uniBuf,stopIndex+1,*indexPtr,stopIndex+1);
NSDebugMLLog(@"GSWHTMLRawParser",@"startIndex=%d *indexPtr=%d _uniBuf[*indexPtr]='%c'",
startIndex,*indexPtr,(char)_uniBuf[*indexPtr]);
string=[NSString stringWithCharacters:_uniBuf+startIndex+1 // +1: skip begining quote
length:*indexPtr-startIndex-1]; // -1 because -1 for begining quote, -1 for ending quote +1 for length
NSDebugMLLog(@"GSWHTMLRawParser",@"'string'='%@'",string);
LOGObjectFnStop();
return string;
}
@ -375,27 +326,22 @@ It skip starting blank spaces
{
NSString* string=nil;
int startIndex=0;
LOGObjectFnStart();
//ParserDebugLogBuffer(_uniBuf,stopIndex+1,*indexPtr,stopIndex+1);
while(*indexPtr<=stopIndex
&& _uniBuf[*indexPtr]==' ')
(*indexPtr)++;
startIndex=*indexPtr;
//ParserDebugLogBuffer(_uniBuf,stopIndex+1,startIndex,stopIndex+1);
if (*indexPtr<=stopIndex)
{
if (_uniBuf[*indexPtr]=='"'
|| _uniBuf[*indexPtr]=='\'')
{
//ParserDebugLogBuffer(_uniBuf,stopIndex+1,*indexPtr,stopIndex+1);
string=[self _parseQuotedStringWithQuote:_uniBuf[*indexPtr]
index:indexPtr
stopIndex:stopIndex];
NSDebugMLLog(@"GSWHTMLRawParser",@"indexPtr=%d 'string'='%@'",*indexPtr,string);
(*indexPtr)++; // skip last quote
}
else
@ -414,18 +360,12 @@ It skip starting blank spaces
else
(*indexPtr)++;
};
NSDebugMLLog(@"GSWHTMLRawParser",@"startIndex=%d stopIndex=%d *indexPtr=%d _uniBuf[*indexPtr]='%c'",
startIndex,stopIndex,*indexPtr,(char)_uniBuf[*indexPtr]);
if (*indexPtr>startIndex)
string=[NSString stringWithCharacters:_uniBuf+startIndex
length:*indexPtr-startIndex];
NSDebugMLLog(@"GSWHTMLRawParser",@"'string'='%@'",string);
};
};
NSDebugMLLog(@"GSWHTMLRawParser",@"'string'='%@'",string);
LOGObjectFnStop();
return string;
}
@ -451,8 +391,6 @@ if it is not the case but you'll have problems later...)
{
NSMutableDictionary* properties=nil;
LOGObjectFnStart();
//ParserDebugLogBuffer(_uniBuf,stopIndex+1,startIndex,stopIndex+1);
if (stopIndex>=startIndex)
{
int index=startIndex;
@ -467,7 +405,6 @@ if it is not the case but you'll have problems later...)
{
tagName=[NSString stringWithCharacters:_uniBuf+startIndex
length:index-startIndex+1];
NSDebugMLLog(@"GSWHTMLRawParser",@"tagName=%@",tagName);
};
break;
}
@ -478,7 +415,6 @@ if it is not the case but you'll have problems later...)
{
tagName=[NSString stringWithCharacters:_uniBuf+startIndex
length:index-startIndex];
NSDebugMLLog(@"GSWHTMLRawParser",@"tagName=%@",tagName);
};
if (tagName)
{
@ -508,7 +444,6 @@ if it is not the case but you'll have problems later...)
or:' '
index:&index
stopIndex:stopIndex];
NSDebugMLLog(@"GSWHTMLRawParser",@"'key'='%@'",key);
// Skip blank
while(index<=stopIndex
&& _uniBuf[index]==' ')
@ -530,7 +465,6 @@ if it is not the case but you'll have problems later...)
or:' '
index:&index
stopIndex:stopIndex];
NSDebugMLLog(@"GSWHTMLRawParser",@"'value'='%@'",value);
NSAssert(value,@"No value");
[properties setObject:value
forKey:key];
@ -548,8 +482,6 @@ if it is not the case but you'll have problems later...)
};
};
};
NSDebugMLLog(@"GSWHTMLRawParser",@"properties=%@",properties);
LOGObjectFnStop();
return properties;
};
@ -560,8 +492,6 @@ May raise exception.
-(void)parseHTML
{
// Object obj = null;
LOGObjectFnStart();
NSDebugMLLog(@"GSWHTMLRawParser",@"_string=%@",_string);
_length=[_string length];
_uniBuf = (unichar*)objc_malloc(sizeof(unichar)*(_length+1));
@ -571,26 +501,20 @@ May raise exception.
_index=0;
NSDebugMLLog(@"GSWHTMLRawParser",@"index=%d length=%d",_index,_length);
//ParserDebugLogBuffer(_uniBuf,_length,_index,_length);
_textStartIndex=_index;
while(_index<_length)
{
int previousIndex=_index;
//ParserDebugLogBuffer(_uniBuf,_length,_index,20);
switch(_uniBuf[_index])
{
case '<': // tagStart
{
int tagStartIndex=_index;
//ParserDebugLogBuffer(_uniBuf,_length,_index,20);
// skip '<'
_index++;
//ParserDebugLogBuffer(_uniBuf,_length,_index,20);
if (_index>=_length)
{
[NSException raise:NSInvalidArgumentException
@ -603,17 +527,13 @@ May raise exception.
GSWHTMLRawParserTagType tagType=GetTagType(_uniBuf,_length,&_index,&isClosingTag);
int tagPropertiesStartIndex=_index;
_textStopIndex=tagStartIndex-1;
NSDebugMLLog(@"GSWHTMLRawParser",@"tagType=%d isClosingTag=%s _textStartIndex=%d",tagType,(isClosingTag ? "YES" : "NO"),_textStartIndex);
if (_parserIsDynamicTagType(tagType))
{
//ParserDebugLogBuffer(_uniBuf,_length,_index,20);
// Find tag End;
while(_index<_length
&& _uniBuf[_index]!='>')
_index++;
//ParserDebugLogBuffer(_uniBuf,_length,_index,20);
if (_uniBuf[_index]!='>')
{
@ -626,8 +546,7 @@ May raise exception.
BOOL stopTag=NO;
int tagStopIndex=_index;
int tagPropertiesStopIndex=_index;
NSDebugMLLog(@"GSWHTMLRawParser",@"tagStartIndex=%d tagStopIndex=%d _textStartIndex=%d _textStopIndex=%d _length=%d _index=%d",
tagStartIndex,tagStopIndex,_textStartIndex,_textStopIndex,_length,_index);
if (isClosingTag)
{
[self stopDynamicTagOfType:tagType
@ -643,14 +562,13 @@ May raise exception.
stopTag=YES;
tagPropertiesStopIndex--;
};
NSDebugMLLog(@"GSWHTMLRawParser",@"stopTag=%d",stopTag);
tagPropertiesString=[NSString stringWithCharacters:_uniBuf+tagPropertiesStartIndex
length:tagPropertiesStopIndex-tagPropertiesStartIndex];
NSDebugMLLog(@"GSWHTMLRawParser",@"tagPropertiesString='%@'",tagPropertiesString);
tagProperties=[self tagPropertiesForType:tagType
betweenIndex:tagPropertiesStartIndex
andIndex:tagPropertiesStopIndex-1];
NSDebugMLLog(@"GSWHTMLRawParser",@"tagProperties='%@'",tagProperties);
[self startDynamicTagOfType:tagType
withProperties:tagProperties
templateInfo:[self lineAndColumnIndexesStringFromIndex:tagStartIndex]];
@ -658,12 +576,8 @@ May raise exception.
[self stopDynamicTagOfType:tagType
withTemplateInfo:[self lineAndColumnIndexesStringFromIndex:tagStartIndex]];
}
//ParserDebugLogBuffer(_uniBuf,_length,_index,20);
_index++;
//ParserDebugLogBuffer(_uniBuf,_length,_index,20);
_textStartIndex=_index;
NSDebugMLLog(@"GSWHTMLRawParser",@"_textStartIndex=%d _textStopIndex=%d _length=%d _index=%d",
_textStartIndex,_textStopIndex,_length,_index);
};
}
else if (_parserIsCommentTagType(tagType))
@ -694,8 +608,6 @@ May raise exception.
[self didParseCommentWithContentString:commentString];
_index++;
_textStartIndex=_index;
NSDebugMLLog(@"GSWHTMLRawParser",@"_textStartIndex=%d _textStopIndex=%d _length=%d _index=%d",
_textStartIndex,_textStopIndex,_length,_index);
};
};
};
@ -717,7 +629,6 @@ May raise exception.
};
_textStopIndex=_length-1;
[self didParseText];
//ParserDebugLogBuffer(_uniBuf,_length,_index,20);
}
NS_HANDLER
{
@ -729,7 +640,6 @@ May raise exception.
[localException raise];
};
NS_ENDHANDLER;
LOGObjectFnStop();
};

View file

@ -44,6 +44,8 @@
-(NSString*)elementName;
-(NSArray*)dynamicChildren;
-(NSArray*) childrenElements;
-(NSArray*)htmlBareStrings;
-(NSData*)elementsMap;
@ -65,10 +67,6 @@
-(NSString*)description;
@end
//====================================================================
@interface GSWHTMLStaticElement (GSWHTMLStaticElementA)
-(void)appendToResponse:(GSWResponse*)response
inContext:(GSWContext*)context;
@ -83,10 +81,6 @@
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context;
@end
//====================================================================
@interface GSWHTMLStaticElement (GSWHTMLStaticElementB)
-(BOOL)compactHTMLTags;
-(BOOL)appendStringAtRight:(id)unkwnon
withMapping:(char*)mapping;
@ -94,28 +88,17 @@
withMapping:(char*)mapping;
-(BOOL)canBeFlattenedAtInitialization;
@end
//====================================================================
@interface GSWHTMLStaticElement (GSWHTMLStaticElementC)
+(BOOL)charactersNeedingQuotes;
+(void)addURLAttribute:(id)attribute
forElementNamed:(NSString*)name;
+(id)urlsForElementNamed:(NSString*)name;
@end
//====================================================================
@interface GSWHTMLStaticElement (GSWHTMLStaticElementD)
+(NSDictionary*)attributeDictionaryForString:(NSString*)string;
+(NSString*)stringForAttributeDictionary:(NSDictionary*)attributeDictionary;
+(GSWElement*)elementWithName:(NSString*)name
attributeString:(NSString*)attributeString
contentElements:(NSArray*)elements;
@end
//====================================================================
@interface GSWHTMLStaticElement (GSWHTMLStaticElementE)
+(GSWElement*)elementWithName:(NSString*)name
attributeDictionary:(NSDictionary*)attributeDictionary
contentElements:(NSArray*)elements;

View file

@ -33,11 +33,19 @@ RCS_ID("$Id$")
#include "GSWeb.h"
static SEL objectAtIndexSEL = NULL;
/*
In WO 5 this class is WODynamicGroup I think.
In WO 4.5 WOHTMLStaticElement.
*/
static SEL objectAtIndexSEL = NULL;
static GSWIMP_BOOL standardEvaluateConditionInContextIMP = NULL;
static Class standardClass = Nil;
static Class GSWHTMLBareStringClass = Nil;
//====================================================================
@implementation GSWHTMLStaticElement
@ -48,6 +56,7 @@ static Class standardClass = Nil;
if (self == [GSWHTMLStaticElement class])
{
standardClass=[GSWHTMLStaticElement class];
GSWHTMLBareStringClass = [GSWHTMLBareString class];
objectAtIndexSEL=@selector(objectAtIndex:);
standardEvaluateConditionInContextIMP =
@ -266,6 +275,13 @@ static Class standardClass = Nil;
return _dynamicChildren;
};
// to be compatible with GSWDynamicGroup.
// do we have to add htmlBareStrings also? dw
-(NSArray*) childrenElements
{
return _dynamicChildren;
};
//--------------------------------------------------------------------
-(NSArray*)htmlBareStrings
{
@ -295,18 +311,21 @@ static Class standardClass = Nil;
};
//--------------------------------------------------------------------
- (BOOL) hasChildrenElements
{
return ([_elementsMap length] > 0);
}
-(NSString*)description
{
return [NSString stringWithFormat:@"<%@ %p elementsMap:%@>",
return [NSString stringWithFormat:@"<%@ %p elementName:%@ htmlBareStrings:%@ dynamicChildren:%@ elementsMap:%@>",
[self class],
(void*)self,
(void*)self, _elementName, _htmlBareStrings, _dynamicChildren,
_elementsMap];
};
@end
//====================================================================
@implementation GSWHTMLStaticElement (GSWHTMLStaticElementA)
//--------------------------------------------------------------------
-(void)appendToResponse:(GSWResponse*)response
@ -315,19 +334,23 @@ static Class standardClass = Nil;
int length=0;
//GSWRequest* request=[aContext request];
//not used BOOL isFromClientComponent=[request isFromClientComponent]; //bis repetitam
GSWStartElement(aContext);
GSWSaveAppendToResponseElementID(aContext);
// GSWStartElement(aContext);
// GSWSaveAppendToResponseElementID(aContext);
length=[_elementsMap length];
if (length>0)
{
[self appendToResponse:response
inContext:aContext
elementsFromIndex:0
toIndex:length-1];
};
GSWAssertIsElementID(aContext);
GSWStopElement(aContext);
[aContext appendZeroElementIDComponent];
if (length>0) {
[self appendToResponse:response
inContext:aContext
elementsFromIndex:0
toIndex:length-1];
};
[aContext deleteLastElementIDComponent];
// GSWAssertIsElementID(aContext);
// GSWStopElement(aContext);
};
//--------------------------------------------------------------------
@ -398,6 +421,7 @@ static Class standardClass = Nil;
};
//--------------------------------------------------------------------
-(GSWElement*)invokeActionForRequest:(GSWRequest*)request
inContext:(GSWContext*)aContext
{
@ -406,23 +430,23 @@ static Class standardClass = Nil;
NSString* senderID=nil;
int length=0;
LOGObjectFnStart();
GSWStartElement(aContext);
GSWAssertCorrectElementID(aContext);// Debug Only
senderID=GSWContext_senderID(aContext);
length=[_elementsMap length];
if (length>0)
{
if ([self hasChildrenElements]) {
IMP objectAtIndexIMP = NULL;
NSArray* aDynamicChildrensArray=[self dynamicChildren];
const BYTE* elements=[_elementsMap bytes];
BYTE elementIndic=0;
int elementsN[3]={0,0,0};
int elementN=0;
id currentEl = nil;
[aContext appendZeroElementIDComponent];
for(elementN=0;!element && !searchIsOver && elementN<length;elementN++)
{
elementIndic=(BYTE)elements[elementN];
@ -433,16 +457,21 @@ static Class standardClass = Nil;
if (!objectAtIndexIMP)
objectAtIndexIMP = [aDynamicChildrensArray methodForSelector:objectAtIndexSEL];
element=[(*objectAtIndexIMP)(aDynamicChildrensArray,objectAtIndexSEL,elementsN[1])
invokeActionForRequest:request
inContext:aContext];
currentEl = (*objectAtIndexIMP)(aDynamicChildrensArray,objectAtIndexSEL,elementsN[1]);
if ([currentEl class] != GSWHTMLBareStringClass) {
NSAssert3(!element || [element isKindOfClass:[GSWElement class]],
@"From: %@, Element is a %@ not a GSWElement: %@",
[aDynamicChildrensArray objectAtIndex:elementsN[1]],
[element class],
element);
if (![aContext _wasFormSubmitted] && GSWContext_isSenderIDSearchOver(aContext))
element=[currentEl invokeActionForRequest:request
inContext:aContext];
NSAssert3(!element || [element isKindOfClass:[GSWElement class]],
@"From: %@, Element is a %@ not a GSWElement: %@",
[aDynamicChildrensArray objectAtIndex:elementsN[1]],
[element class],
element);
}
// TODO: check if that is right.
// if (![aContext _wasFormSubmitted] && GSWContext_isSenderIDSearchOver(aContext))
if (![aContext _wasFormSubmitted] && (element))
{
searchIsOver=YES;
};
@ -456,13 +485,9 @@ static Class standardClass = Nil;
elementsN[2]++;
};
};
[aContext deleteLastElementIDComponent];
};
GSWAssertIsElementID(aContext);
GSWStopElement(aContext);
LOGObjectFnStop();
return element;
};
@ -477,8 +502,8 @@ static Class standardClass = Nil;
GSWAssertCorrectElementID(aContext);
length=[_elementsMap length];
if (length>0)
{
if ([self hasChildrenElements]) {
IMP objectAtIndexIMP = NULL;
int elementN=0;
NSArray* aDynamicChildrensArray=[self dynamicChildren];
@ -486,6 +511,8 @@ static Class standardClass = Nil;
BYTE elementIndic=0;
int elementsN[3]={0,0,0};
[aContext appendZeroElementIDComponent];
for(elementN=0;elementN<length;elementN++)
{
elementIndic=(BYTE)elements[elementN];
@ -509,16 +536,13 @@ static Class standardClass = Nil;
elementsN[2]++;
};
};
[aContext deleteLastElementIDComponent];
};
GSWAssertIsElementID(aContext);
GSWStopElement(aContext);
LOGObjectFnStop();
};
@end
//====================================================================
@implementation GSWHTMLStaticElement (GSWHTMLStaticElementB)
//--------------------------------------------------------------------
-(BOOL)compactHTMLTags
@ -550,11 +574,6 @@ static Class standardClass = Nil;
return NO;
};
@end
//====================================================================
@implementation GSWHTMLStaticElement (GSWHTMLStaticElementC)
//--------------------------------------------------------------------
+(BOOL)charactersNeedingQuotes
{
@ -576,11 +595,6 @@ static Class standardClass = Nil;
return nil;
};
@end
//====================================================================
@implementation GSWHTMLStaticElement (GSWHTMLStaticElementD)
//--------------------------------------------------------------------
+(NSDictionary*)attributeDictionaryForString:(NSString*)string
{
@ -604,11 +618,6 @@ static Class standardClass = Nil;
return nil;
};
@end
//====================================================================
@implementation GSWHTMLStaticElement (GSWHTMLStaticElementE)
//--------------------------------------------------------------------
+(GSWElement*)elementWithName:(NSString*)name
attributeDictionary:(NSDictionary*)attributeDictionary

View file

@ -46,11 +46,13 @@ RCS_ID("$Id$")
//OK
LOGObjectFnStart();
NSDebugMLLog(@"gswdync",@"elements:%@",elements);
if ([elements count]==1 && [[elements objectAtIndex:0] class]==[GSWHTMLStaticGroup class])
#warning checkme!
/* if ([elements count]==1 && [[elements objectAtIndex:0] class]==[GSWHTMLStaticGroup class])
self=[super initWithName:nil
attributeDictionary:nil
contentElements:[[elements objectAtIndex:0]dynamicChildren]];
else
*/
self=[super initWithName:nil
attributeDictionary:nil
contentElements:elements];
@ -58,6 +60,15 @@ RCS_ID("$Id$")
return self;
};
-(NSString*)description
{
return [NSString stringWithFormat:@"<%@ %p elementName:%@ htmlBareStrings:%@ dynamicChildren:%@ documentTypeString:%@ elementsMap:%@>",
[self class],
(void*)self, _elementName, _htmlBareStrings, _dynamicChildren, _documentTypeString,
_elementsMap];
};
//--------------------------------------------------------------------
-(void)dealloc
{
@ -75,7 +86,6 @@ RCS_ID("$Id$")
-(void)appendToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
LOGObjectFnStart();
GSWStartElement(aContext);
if (_documentTypeString)
{
@ -86,7 +96,6 @@ RCS_ID("$Id$")
[super appendToResponse:aResponse
inContext:aContext];
GSWStopElement(aContext);
LOGObjectFnStop();
};
@end

View file

@ -176,6 +176,9 @@ Creates a GSWTemporaryElement element, waiting for tag end
/** Called by parser when it has closed a dynamic tag
Creates a dynamic element from current temporary element element
**/
// templateInfo: (line: 5 column: 31)
-(void) parser:(GSWBaseParser*)parser
didParseClosingDynamicTagOfType:(GSWHTMLRawParserTagType)tagType
withTemplateInfo:(NSString*)templateInfo

View file

@ -35,51 +35,30 @@
@interface GSWHTMLURLValuedElement: GSWHTMLDynamicElement
{
GSWAssociation* _src;
GSWAssociation* _value;
GSWAssociation* _pageName;
//GSWeb Additions {
NSDictionary* _pageSetVarAssociations;
GSWAssociation* _pageSetVarAssociationsDynamic;
GSWAssociation* _cidStore;
GSWAssociation* _cidKey;
NSDictionary* _otherPathQueryAssociations;
// }
GSWAssociation* _filename;
GSWAssociation* _framework;
GSWAssociation* _data;
GSWAssociation* _mimeType;
GSWAssociation* _key;
GSWAssociation* _actionClass;
GSWAssociation* _directActionName;
GSWAssociation* _queryDictionary;
NSDictionary* _otherQueryAssociations;
GSWAssociation * _src;
GSWAssociation * _value;
GSWAssociation * _pageName;
GSWAssociation * _filename;
GSWAssociation * _framework;
GSWAssociation * _data;
GSWAssociation * _mimeType;
GSWAssociation * _key;
GSWAssociation * _queryDictionary;
GSWAssociation * _actionClass;
GSWAssociation * _directActionName;
NSDictionary * _otherQueryAssociations;
};
-(id)initWithName:(NSString*)aName
associations:(NSDictionary*)associations
contentElements:(NSArray*)elements;
template:(GSWElement*)template;
-(NSString*)valueAttributeName;
-(NSString*)urlAttributeName;
@end
@interface GSWHTMLURLValuedElement (GSWHTMLURLValuedElementA)
-(GSWElement*)invokeActionForRequest:(GSWRequest*)aRequest
inContext:(GSWContext*)aContext;
@end
@interface GSWHTMLURLValuedElement (GSWHTMLURLValuedElementB)
//NDFN
-(void)appendURLToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext;
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext;
-(void)_appendCGIActionURLToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext;
-(NSString*)computeActionStringInContext:(GSWContext*)aContext;
-(NSDictionary*)computeQueryDictionaryInContext:(GSWContext*)aContext;
-(NSString*)frameworkNameInContext:(GSWContext*)aContext;
@end
#endif // _GSWHTMLURLValuedElement_h__

View file

@ -37,124 +37,122 @@ RCS_ID("$Id$")
//====================================================================
@implementation GSWHTMLURLValuedElement
//--------------------------------------------------------------------
-(NSString*) valueAttributeName
{
return @"src";
}
-(NSString*) urlAttributeName
{
return @"value";
}
-(id)initWithName:(NSString*)aName
associations:(NSDictionary*)inAssociations
contentElements:(NSArray*)elements
associations:(NSDictionary*)associations
template:(GSWElement*)template
{
NSString* urlAttributeName=nil;
NSString* valueAttributeName=nil;
NSMutableDictionary* associations=nil;
LOGObjectFnStartC("GSWHTMLURLValuedElement");
urlAttributeName=[self urlAttributeName];//so what ?
valueAttributeName=[self valueAttributeName];//so what ?
associations=[NSMutableDictionary dictionaryWithDictionary:inAssociations];
_src = [[associations objectForKey:src__Key
withDefaultObject:[_src autorelease]] retain];
NSDebugMLLog(@"gswdync",@"src=%@",_src);
_value = [[associations objectForKey:value__Key
withDefaultObject:[_value autorelease]] retain];
NSDebugMLLog(@"gswdync",@"value=%@",_value);
_pageName = [[associations objectForKey:pageName__Key
withDefaultObject:[_pageName autorelease]] retain];
NSDebugMLLog(@"gswdync",@"pageName=%@",_pageName);
_filename = [[associations objectForKey:filename__Key
withDefaultObject:[_filename autorelease]] retain];
NSDebugMLLog(@"gswdync",@"filename=%@",_filename);
_framework = [[associations objectForKey:framework__Key
withDefaultObject:[_framework autorelease]] retain];
NSDebugMLLog(@"gswdync",@"framework=%@",_framework);
_data = [[associations objectForKey:data__Key
withDefaultObject:[_data autorelease]] retain];
NSDebugMLLog(@"gswdync",@"data=%@",_data);
_mimeType = [[associations objectForKey:mimeType__Key
withDefaultObject:[_mimeType autorelease]] retain];
NSDebugMLLog(@"gswdync",@"mimeType=%@",_mimeType);
_key = [[associations objectForKey:key__Key
withDefaultObject:[_key autorelease]] retain];
NSDebugMLLog(@"gswdync",@"key=%@",_key);
_actionClass = [[associations objectForKey:actionClass__Key
withDefaultObject:[_actionClass autorelease]] retain];
NSDebugMLLog(@"gswdync",@"actionClass=%@",_actionClass);
_directActionName = [[associations objectForKey:directActionName__Key
withDefaultObject:[_directActionName autorelease]] retain];
NSDebugMLLog(@"gswdync",@"directActionName=%@",_directActionName);
_queryDictionary = [[associations objectForKey:queryDictionary__Key
withDefaultObject:[_queryDictionary autorelease]] retain];
NSDebugMLLog(@"gswdync",@"queryDictionary=%@",_queryDictionary);
[associations removeObjectForKey:src__Key];
[associations removeObjectForKey:value__Key];
[associations removeObjectForKey:pageName__Key];
[associations removeObjectForKey:filename__Key];
[associations removeObjectForKey:framework__Key];
[associations removeObjectForKey:data__Key];
[associations removeObjectForKey:mimeType__Key];
[associations removeObjectForKey:key__Key];
[associations removeObjectForKey:actionClass__Key];
[associations removeObjectForKey:directActionName__Key];
[associations removeObjectForKey:queryDictionary__Key];
if (!WOStrictFlag)
{
//pageSetVarAssociations//GNUstepWeb only
NSDictionary* pageSetVarAssociations=[associations associationsWithoutPrefix:pageSetVar__Prefix__Key
removeFrom:associations];
if ([pageSetVarAssociations count]>0)
{
ASSIGN(_pageSetVarAssociations,pageSetVarAssociations);
};
_pageSetVarAssociationsDynamic=[[associations objectForKey:pageSetVars__Key
withDefaultObject:[_pageSetVarAssociationsDynamic autorelease]] retain];
NSDebugMLLog(@"gswdync",@"_pageSetVarAssociationsDynamic=%@",_pageSetVarAssociationsDynamic);
_cidStore = [[associations objectForKey:cidStore__Key
withDefaultObject:[_cidStore autorelease]] retain];
NSDebugMLLog(@"gswdync",@"cidStore=%@",_cidStore);
_cidKey = [[associations objectForKey:cidKey__Key
withDefaultObject:[_cidKey autorelease]] retain];
NSDebugMLLog(@"gswdync",@"cidKey=%@",_cidKey);
self=[super initWithName: aName
associations:associations
template:template];
if (!self) {
return nil;
}
urlAttributeName = [self urlAttributeName];
valueAttributeName = [self valueAttributeName];
[associations removeObjectForKey:pageSetVars__Key];
[associations removeObjectForKey:cidStore__Key];
[associations removeObjectForKey:cidKey__Key];
};
ASSIGN(_src, [_associations objectForKey: urlAttributeName]);
if (_src != nil) {
[_associations removeObjectForKey: urlAttributeName];
}
ASSIGN(_value, [_associations objectForKey: valueAttributeName]);
if (_value != nil) {
[_associations removeObjectForKey: valueAttributeName];
}
ASSIGN(_pageName, [_associations objectForKey: pageName__Key]);
if (_pageName != nil) {
[_associations removeObjectForKey: pageName__Key];
}
ASSIGN(_filename, [_associations objectForKey: filename__Key]);
if (_filename != nil) {
[_associations removeObjectForKey: filename__Key];
}
ASSIGN(_framework, [_associations objectForKey: framework__Key]);
if (_framework != nil) {
[_associations removeObjectForKey: framework__Key];
}
ASSIGN(_data, [_associations objectForKey: data__Key]);
if (_data != nil) {
[_associations removeObjectForKey: data__Key];
}
ASSIGN(_mimeType, [_associations objectForKey: mimeType__Key]);
if (_mimeType != nil) {
[_associations removeObjectForKey: mimeType__Key];
}
ASSIGN(_key, [_associations objectForKey: key__Key]);
if (_key != nil) {
[_associations removeObjectForKey: key__Key];
}
ASSIGN(_actionClass, [_associations objectForKey: actionClass__Key]);
if (_actionClass != nil) {
[_associations removeObjectForKey: actionClass__Key];
}
ASSIGN(_directActionName, [_associations objectForKey: directActionName__Key]);
if (_directActionName != nil) {
[_associations removeObjectForKey: directActionName__Key];
}
ASSIGN(_queryDictionary, [_associations objectForKey: queryDictionary__Key]);
if (_queryDictionary != nil) {
[_associations removeObjectForKey: queryDictionary__Key];
}
if ([associations count]>0)
{
ASSIGN(_otherQueryAssociations,([associations extractObjectsForKeysWithPrefix:@"?"
removePrefix:YES]));
if ([_otherQueryAssociations count]==0)
DESTROY(_otherQueryAssociations);
_otherQueryAssociations = RETAIN([_associations extractObjectsForKeysWithPrefix:@"?"
removePrefix: YES]);
if (!WOStrictFlag)
{
ASSIGN(_otherPathQueryAssociations,([associations extractObjectsForKeysWithPrefix:@"!"
removePrefix:YES]));
if ([_otherPathQueryAssociations count]==0)
DESTROY(_otherPathQueryAssociations);
};
};
if (_filename != nil) {
if ((_src != nil) || (_pageName != nil) || (_value != nil) || (_data != nil)) {
[NSException raise:NSInvalidArgumentException
format:@"%s: Can't have 'filename' and '%@', 'pageName', 'data', or '%@'.",
__PRETTY_FUNCTION__, [self urlAttributeName], [self valueAttributeName]];
}
} else {
if (_data != nil) {
if (_src != nil || _pageName != nil || _value != nil) {
[NSException raise:NSInvalidArgumentException
format:@"%s: Can't have 'data' and '%@', 'pageName', 'pageName', or '%@'.",
__PRETTY_FUNCTION__, [self urlAttributeName], [self valueAttributeName]];
}
if (_mimeType == nil) {
[NSException raise:NSInvalidArgumentException
format:@"%s: Missing 'mimeType' when 'data' is specified.",
__PRETTY_FUNCTION__];
}
} else {
if (((_pageName != nil) && (_src != nil)) || ((_pageName != nil) && (_value != nil)) || ((_src != nil) && (_value != nil))) {
[NSException raise:NSInvalidArgumentException
format:@"%s: dynamic element can not have two conflicting bindings: 'pageName' and '%@', or 'pageName' and '%@', or 'pageName', or '%@' and '%@'.",
__PRETTY_FUNCTION__,
[self urlAttributeName],
[self valueAttributeName],
[self urlAttributeName],
[self valueAttributeName]];
}
if (((_pageName == nil) && (_value == nil) && (_src == nil) && (_directActionName == nil)) &&
((_actionClass == nil) && (! [self isKindOfClass:[GSWBody class]]))) {
[NSException raise:NSInvalidArgumentException
format:@"%s: At least one of the following bindings is required for this dynamic element: 'directActionName', 'actionClass', 'filename', 'pageName', 'data', '%@' or '%@'.",
__PRETTY_FUNCTION__,[self urlAttributeName],
[self valueAttributeName]];
}
}
}
if ((self=[super initWithName:[self elementName]//NEW
attributeAssociations:associations
contentElements:elements]))
{
};
LOGObjectFnStopC("GSWHTMLURLValuedElement");
return self;
};
@ -164,37 +162,19 @@ RCS_ID("$Id$")
DESTROY(_src);
DESTROY(_value);
DESTROY(_pageName);
DESTROY(_pageSetVarAssociations);//GNUstepWeb only
DESTROY(_pageSetVarAssociationsDynamic);//GSWeb only
DESTROY(_filename);
DESTROY(_framework);
DESTROY(_data);
DESTROY(_mimeType);
DESTROY(_key);
DESTROY(_queryDictionary);
DESTROY(_actionClass);
DESTROY(_directActionName);
DESTROY(_queryDictionary);
DESTROY(_otherQueryAssociations);
DESTROY(_otherPathQueryAssociations);
DESTROY(_cidStore);//GSWeb only
DESTROY(_cidKey);//GSWeb only
[super dealloc];
}
//--------------------------------------------------------------------
-(NSString*)valueAttributeName
{
//Does nothing
return nil;
};
//--------------------------------------------------------------------
-(NSString*)urlAttributeName
{
//Does nothing
return nil;
};
//--------------------------------------------------------------------
-(NSString*)description
{
@ -203,382 +183,147 @@ RCS_ID("$Id$")
(void*)self];
};
@end
//====================================================================
@implementation GSWHTMLURLValuedElement (GSWHTMLURLValuedElementA)
//--------------------------------------------------------------------
-(GSWElement*)invokeActionForRequest:(GSWRequest*)aRequest
inContext:(GSWContext*)aContext
inContext:(GSWContext*)context
{
//OK
GSWElement* element=nil;
NSString* senderID=nil;
NSString* elementID=nil;
LOGObjectFnStartC("GSWHTMLURLValuedElement");
NSDebugMLLog(@"gswdync",@"ET=%@ id=%@",[self class],
GSWContext_elementID(aContext));
senderID=GSWContext_senderID(aContext);
elementID=GSWContext_elementID(aContext);
NSDebugMLLog(@"gswdync",@"senderID=%@",senderID);
NSDebugMLLog(@"gswdync",@"elementID=%@",elementID);
NSDebugMLLog(@"gswdync",@"[elementID isEqualToString:senderID]=%d",
(int)[elementID isEqualToString:senderID]);
if ([elementID isEqualToString:senderID])
{
GSWComponent* component=GSWContext_component(aContext);
if (_value)
{
element=[_value valueInComponent:component];
NSAssert4(!element || [element isKindOfClass:[GSWElement class]],
@"_value: %@ component: %@ Element is a %@ not a GSWElement: %@",
_value,
component,
[element class],
element);
GSWElement* element = nil;
NSString* senderID = nil;
NSString* elementID = nil;
GSWComponent * component = nil;
elementID = GSWContext_elementID(context);
senderID = GSWContext_senderID(context);
if (elementID != nil && senderID != nil && [elementID isEqual:senderID]) {
component = GSWContext_component(context);
if (_value != nil) {
element = [_value valueInComponent:component];
} else {
if (_pageName != nil) {
GSWElement* element1 = [_pageName valueInComponent:component];
if (element1 != nil) {
NSString * pageName = (NSString *) element1; // stringValue?
if (pageName != nil) {
element = [GSWApp pageWithName:pageName inContext:context];
}
}
else if (_pageName)
{
NSString* pageNameValue=[_pageName valueInComponent:component];
element=[GSWApp pageWithName:pageNameValue
inContext:aContext];
NSAssert3(!element || [element isKindOfClass:[GSWElement class]],
@"pageNameValue: %@ Element is a %@ not a GSWElement: %@",
pageNameValue,
[element class],
element);
if (!WOStrictFlag && element)//GNUstepWeb only
{
if (_pageSetVarAssociations)
{
[_pageSetVarAssociations associationsSetValuesFromObject:component
inObject:(GSWComponent*)element];
};
if (_pageSetVarAssociationsDynamic)
{
NSDictionary* assocs=[_pageSetVarAssociationsDynamic valueInComponent:component];
if (assocs)
{
if (![assocs isKindOfClass:[NSDictionary class]])
{
ExceptionRaise(@"GSWHTMLURLValuedElement",@"%@ (%@) must return a Dictionary, not a %@ like %@",
pageSetVars__Key,
_pageSetVarAssociationsDynamic,
[assocs class],
assocs);
}
else
{
[assocs associationsSetValuesFromObject:component
inObject:(GSWComponent*)element];
};
};
};
};
};
NSDebugMLLog(@"gswdync",@"GSWHTMLURLValuedElement invoke element=%@",element);
//the end ?
//TODOV
if (!element)
{
element=[aContext page];
NSAssert2(!element || [element isKindOfClass:[GSWElement class]],
@"Element is a %@ not a GSWElement: %@",
[element class],
element);
};
}
}
else
{
element=[super invokeActionForRequest:aRequest
inContext:aContext];
NSAssert2(!element || [element isKindOfClass:[GSWElement class]],
@"Element is a %@ not a GSWElement: %@",
[element class],
element);
};
NSDebugMLLog(@"gswdync",@"GSWHTMLURLValuedElement invoke element=%@",element);
NSDebugMLLog(@"gswdync",@"senderID=%@",GSWContext_senderID(aContext));
NSDebugMLLog(@"gswdync",@"elementID=%@",GSWContext_elementID(aContext));
NSDebugMLLog(@"gswdync",@"END ET=%@ id=%@",[self class],GSWContext_elementID(aContext));
LOGObjectFnStopC("GSWHTMLURLValuedElement");
} else {
element = [super invokeActionForRequest: aRequest inContext: context];
}
return element;
};
@end
//====================================================================
@implementation GSWHTMLURLValuedElement (GSWHTMLURLValuedElementB)
//--------------------------------------------------------------------
//NDFN
-(void)appendURLToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
- (NSString*) _imageURL:(GSWContext*) context
{
//OK
NSString* urlAttributeName=nil;
NSString* url=nil;
GSWComponent* component=nil;
NSString* keyValue=nil;
id data=nil;
id mimeTypeValue=nil;
id cidStoreValue=nil;
GSWURLValuedElementData* dataValue=nil;
GSWResourceManager* resourceManager=nil;
GSWComponent * component = GSWContext_component(context);
NSString * fname = [_filename valueInComponent: component];
NSString * fwname = [self _frameworkNameForAssociation: _framework
inComponent: component];
NSString * url = [context _urlForResourceNamed: fname
inFramework: fwname];
if (url == nil) {
url = [[GSWApp resourceManager] errorMessageUrlForResourceNamed:fname inFramework:fwname];
}
return url;
}
LOGObjectFnStartC("GSWHTMLURLValuedElement");
NS_DURING
{
NSDebugMLLog(@"gswdync",@"elementID=%@",GSWContext_elementID(aContext));
component=GSWContext_component(aContext);
NSDebugMLLog(@"gswdync",@"data=%@",_data);
NSDebugMLLog(@"gswdync",@"filename=%@",_filename);
NSDebugMLLog(@"gswdync",@"pageName=%@",_pageName);
- (void) _appendFilenameToResponse:(GSWResponse *) response
inContext:(GSWContext*) context
{
NSString * myurl = [self _imageURL:context];
cidStoreValue=[_cidStore valueInComponent:component];
NSDebugMLLog(@"gswdync",@"cidStoreValue=%@",cidStoreValue);
[response _appendTagAttribute: [self urlAttributeName]
value: myurl
escapingHTMLAttributeValue: NO];
}
resourceManager=[[GSWApplication application]resourceManager];
- (NSString*) CGIActionURL:(GSWContext*) context
{
if (_src)
{
url=[_src valueInComponent:component];
NSDebugMLLog(@"gswdync",@"url=%@",url);
if (cidStoreValue)
{
url=[self addURL:url
forCIDKeyAssociation:_cidKey
CIDStoreAssociation:_cidStore
inContext:aContext];
NSDebugMLLog(@"gswdync",@"url=%@",url);
};
}
else if (_actionClass || _directActionName)
{
url=(NSString*)[aContext componentActionURL];
NSDebugMLLog(@"gswdync",@"url=%@",url);
if (cidStoreValue)
{
url=[self addURL:url
forCIDKeyAssociation:_cidKey
CIDStoreAssociation:_cidStore
inContext:aContext];
NSDebugMLLog(@"gswdync",@"url=%@",url);
};
}
else
{
BOOL processed=NO;
if (_key)
{
keyValue=[_key valueInComponent:component];
NSDebugMLLog(@"gswdync",@"keyValue=%@",keyValue);
dataValue=[resourceManager _cachedDataForKey:keyValue];
NSDebugMLLog(@"gswdync",@"dataValue=%@",dataValue);
};
if (_data && !dataValue)
{
data=[_data valueInComponent:component];
NSDebugMLLog(@"gswdync",@"_data=%@",data);
mimeTypeValue=[_mimeType valueInComponent:component];
NSDebugMLLog(@"gswdync",@"mimeType=%@",_mimeType);
NSDebugMLLog(@"gswdync",@"mimeTypeValue=%@",mimeTypeValue);
dataValue=[[[GSWURLValuedElementData alloc] initWithData:data
mimeType:mimeTypeValue
key:nil] autorelease];
NSDebugMLLog(@"gswdync",@"dataValue=%@",dataValue);
[resourceManager setURLValuedElementData:dataValue];
processed=YES;
}
if (cidStoreValue && dataValue)
{
url=[self addURLValuedElementData:dataValue
forCIDKeyAssociation:_cidKey
CIDStoreAssociation:_cidStore
inContext:aContext];
NSDebugMLLog(@"gswdync",@"url=%@",url);
}
if (!processed && _filename)
{
//Exemple: Body with filename
id filenameValue=nil;
id frameworkValue=nil;
GSWRequest* request=nil;
NSArray* languages=nil;
NSDebugMLLog(@"gswdync",@"filename=%@",_filename);
filenameValue=[_filename valueInComponent:component];
NSDebugMLLog(@"gswdync",@"filenameValue=%@",filenameValue);
frameworkValue=[self frameworkNameInContext:aContext];
NSDebugMLLog(@"gswdync",@"frameworkValue=%@",frameworkValue);
request=[aContext request];
languages=[aContext languages];
if (cidStoreValue)
{
NSString* path=[resourceManager pathForResourceNamed:filenameValue
inFramework:frameworkValue
languages:languages];
if ([path length]==0)
NSWarnLog(@"No path (or empty one) for filenameValue: '%@' (association=%@) in %@ named %@",
filenameValue,_filename,[self className],[self declarationName]);
NSString * actionString = [self computeActionStringWithActionClassAssociation: _actionClass
directActionNameAssociation: _directActionName
inContext: context];
url=[self addPath:path
forCIDKeyAssociation:_cidKey
CIDStoreAssociation:_cidStore
inContext:aContext];
NSDictionary * queryDict = [self computeQueryDictionaryWithActionClassAssociation: _actionClass
directActionNameAssociation: _directActionName
queryDictionaryAssociation: _queryDictionary
otherQueryAssociations: _otherQueryAssociations
inContext: context];
NSDebugMLLog(@"gswdync",@"filenameValue=%@ url=%@",filenameValue,url);
return [context directActionURLForActionNamed: actionString
queryDictionary: queryDict];
if ([url length]==0)
NSWarnLog(@"No URL (or empty one) for filenameValue: '%@' (association=%@) in %@ named %@",
filenameValue,_filename,[self className],[self declarationName]);
}
- (void) appendAttributesToResponse:(GSWResponse*) response
inContext:(GSWContext*) context
{
NSString * src = nil;
GSWComponent * component = GSWContext_component(context);
[super appendAttributesToResponse:response
inContext:context];
if (_src != nil) {
src = [_src valueInComponent:component];
}
if (_directActionName != nil || _actionClass != nil) {
[response _appendTagAttribute:[self urlAttributeName]
value:[self CGIActionURL:context]
escapingHTMLAttributeValue:NO];
} else {
if (_filename != nil) {
[self _appendFilenameToResponse:response inContext:context];
} else {
if (_value != nil || _pageName != nil) {
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response,
[self urlAttributeName],
[context componentActionURL],
NO);
} else {
if (src != nil) {
if ([src isRelativeURL] && (![src isFragmentURL])) {
NSString * s1 = [context _urlForResourceNamed: src
inFramework: nil];
if (s1 != nil) {
[response _appendTagAttribute: [self urlAttributeName]
value: s1
escapingHTMLAttributeValue: NO];
} else {
GSWResponse_appendContentCharacter(response,' ');
GSWResponse_appendContentAsciiString(response, [self urlAttributeName]);
GSWResponse_appendContentCharacter(response,'=');
GSWResponse_appendContentCharacter(response,'"');
GSWResponse_appendContentAsciiString(response, [component baseURL]);
GSWResponse_appendContentCharacter(response,'/');
GSWResponse_appendContentString(response,src);
GSWResponse_appendContentCharacter(response,'"');
}
else
{
url=[resourceManager urlForResourceNamed:filenameValue
inFramework:frameworkValue
languages:languages
request:request];
NSDebugMLLog(@"gswdync",@"filenameValue=%@ url=%@",filenameValue,url);
if ([url length]==0)
NSWarnLog(@"No URL (or empty one) for filenameValue: '%@' (association=%@) in %@ named %@",
filenameValue,_filename,[self className],[self declarationName]);
};
};
};
GSWResponse_appendContentCharacter(aResponse,' ');
urlAttributeName=[self urlAttributeName];
if (urlAttributeName)
{
GSWResponse_appendContentAsciiString(aResponse,urlAttributeName);
GSWResponse_appendContentAsciiString(aResponse,@"=\"");
};
if (_src)
{
GSWResponse_appendContentString(aResponse,url);
}
else if (_actionClass || _directActionName)
{
GSWResponse_appendContentString(aResponse,url);
}
else
{
if (dataValue)//_key || _data)
} else {
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response,
[self urlAttributeName],
src,
NO);
}
} else
if (_data != nil && _mimeType != nil)
{
if (cidStoreValue)
GSWResponse_appendContentString(aResponse,url);
else
[dataValue appendDataURLToResponse:aResponse
inContext:aContext];
// TODO call _appendDataURLAttributeToResponse
[NSException raise:NSInvalidArgumentException
format:@"%s: you need to add a call to _appendDataURLAttributeToResponse in file '%s'",
__PRETTY_FUNCTION__,__FILE__];
}
else if (_filename)
{
NSDebugMLLog(@"gswdync",@"url = %@",url);
GSWResponse_appendContentString(aResponse,url);
};
};
if (urlAttributeName)
GSWResponse_appendContentCharacter(aResponse,'"');
NSDebugMLLog(@"gswdync",@"_elementID=%@",GSWContext_elementID(aContext));
}
}
NS_HANDLER
{
LOGException0(@"exception in GSWHTMLURLValuedElement appendToResponse:inContext");
LOGException(@"exception=%@",localException);
localException=ExceptionByAddingUserInfoObjectFrameInfo(localException,
@"In GSWHTMLURLValuedElement appendToResponse:inContext");
LOGException(@"exception=%@",localException);
[localException raise];
}
NS_ENDHANDLER;
LOGObjectFnStopC("GSWHTMLURLValuedElement");
};
}
}
//--------------------------------------------------------------------
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
//OK
LOGObjectFnStartC("GSWHTMLURLValuedElement");
[self appendURLToResponse:aResponse
inContext:aContext];
LOGObjectFnStopC("GSWHTMLURLValuedElement");
};
//--------------------------------------------------------------------
-(void)_appendCGIActionURLToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
//OK
NSString* actionString=nil;
NSDictionary* queryDictionary=nil;
NSString* anUrl=nil;
LOGObjectFnStart();
actionString=[self computeActionStringInContext:aContext];
NSDebugMLLog(@"gswdync",@"actionString=%@",actionString);
queryDictionary=[self computeQueryDictionaryInContext:aContext];
NSDebugMLLog(@"gswdync",@"queryDictionary=%@",queryDictionary);
anUrl=(NSString*)[aContext directActionURLForActionNamed:actionString
queryDictionary:queryDictionary];
NSDebugMLLog(@"gswdync",@"anUrl=%@",anUrl);
GSWResponse_appendContentString(aResponse,anUrl);
LOGObjectFnStop();
};
//--------------------------------------------------------------------
-(NSString*)computeActionStringInContext:(GSWContext*)aContext
{
NSString* actionString=nil;
LOGObjectFnStart();
actionString=[self computeActionStringWithActionClassAssociation:_actionClass
directActionNameAssociation:_directActionName
otherPathQueryAssociations:_otherPathQueryAssociations
inContext:aContext];
LOGObjectFnStop();
return actionString;
};
//--------------------------------------------------------------------
-(NSDictionary*)computeQueryDictionaryInContext:(GSWContext*)aContext
{
NSDictionary* queryDictionary=nil;
LOGObjectFnStart();
queryDictionary=[self computeQueryDictionaryWithActionClassAssociation:_actionClass
directActionNameAssociation:_directActionName
queryDictionaryAssociation:_queryDictionary
otherQueryAssociations:_otherQueryAssociations
inContext:aContext];
LOGObjectFnStop();
return queryDictionary;
};
//--------------------------------------------------------------------
-(NSString*)frameworkNameInContext:(GSWContext*)aContext
{
//OK
NSString* frameworkName=nil;
GSWComponent* component=GSWContext_component(aContext);
NSDebugMLog(@"framework=%@",_framework);
if (_framework)
frameworkName=[_framework valueInComponent:component];
else
frameworkName=[component frameworkName];
return frameworkName;
};
@end

View file

@ -33,68 +33,31 @@
#define _GSWHyperlink_h__
@interface GSWHyperlink: GSWDynamicElement
@interface GSWHyperlink: GSWHTMLDynamicElement
{
GSWAssociation* _action;
GSWAssociation* _string;
GSWAssociation* _pageName;
GSWAssociation* _href;
GSWAssociation* _disabled;
GSWAssociation* _fragmentIdentifier;
GSWAssociation* _secure;
GSWAssociation* _queryDictionary;
GSWAssociation* _actionClass;
GSWAssociation* _directActionName;
//GSWeb Additions {
GSWAssociation* _enabled;
GSWAssociation* _displayDisabled;
GSWAssociation* _redirectURL;
NSDictionary* _pageSetVarAssociations;
GSWAssociation* _pageSetVarAssociationsDynamic;
// }
NSDictionary* _otherQueryAssociations;
NSDictionary* _otherAssociations;
GSWAssociation * _action;
GSWAssociation * _string;
GSWAssociation * _pageName;
GSWAssociation * _href;
GSWAssociation * _disabled;
GSWAssociation * _fragmentIdentifier;
GSWAssociation * _secure;
GSWAssociation * _queryDictionary;
GSWAssociation * _actionClass;
GSWAssociation * _directActionName;
NSDictionary * _otherQueryAssociations;
}
//GSWeb Additions {
GSWAssociation* _filename;
GSWAssociation* _framework;
GSWAssociation* _data;
GSWAssociation* _mimeType;
GSWAssociation* _key;
NSDictionary* _otherPathQueryAssociations;
GSWAssociation* _urlPrefix;
GSWAssociation* _pathQueryDictionary;
GSWAssociation* _escapeHTML;
// }
GSWElement* _children;
};
-(id)initWithName:(NSString*)name
associations:(NSDictionary*)associations
template:(GSWElement*)templateElement;
@end
@interface GSWHyperlink (GSWHyperlinkA)
-(void)appendToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext;
#if !GSWEB_STRICT
-(NSString*)frameworkNameInContext:(GSWContext*)aContext;
#endif
-(void)_appendCGIActionURLToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext;
-(NSString*)computeActionStringInContext:(GSWContext*)aContext;
-(void)_appendQueryStringToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext;
-(NSDictionary*)computeQueryDictionaryInContext:(GSWContext*)aContext;
-(void)_appendFragmentToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext;
-(void)_appendContentStringToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext;
-(void)_appendChildrenToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext;
@end
@interface GSWHyperlink (GSWHyperlinkB)
-(GSWElement*)invokeActionForRequest:(GSWRequest*)aRequest
inContext:(GSWContext*)aContext;
@end

File diff suppressed because it is too large Load diff

View file

@ -40,12 +40,17 @@
}
-(id)initWithName:(NSString*)name
associations:(NSDictionary*)associations
contentElements:(NSArray*)elements;
-(void)dealloc;
template:(GSWElement*)template;
-(NSString*)valueAttributeName;
-(NSString*)urlAttributeName;
-(NSString*)elementName;
-(NSString*)description;
+ (void) _appendFilenameToResponse:(GSWResponse *) response
inContext:(GSWContext *) context
framework:(GSWAssociation*) framework
filename:(GSWAssociation*) filename
width:(GSWAssociation*) width
height:(GSWAssociation*) height;
@end

View file

@ -39,29 +39,28 @@ RCS_ID("$Id$")
//--------------------------------------------------------------------
-(id)initWithName:(NSString*)name
associations:(NSDictionary*)inAssociations
contentElements:(NSArray*)elements
associations:(NSDictionary*) associations
template:(GSWElement*)template
{
NSMutableDictionary* associations=nil;
LOGObjectFnStartC("GSWImage");
self = [super initWithName: @"img"
associations: associations
template: template];
associations=[NSMutableDictionary dictionaryWithDictionary:inAssociations];
if (!self) {
return nil;
}
_width = [[inAssociations objectForKey:width__Key
withDefaultObject:[_width autorelease]] retain];
NSDebugMLLog(@"gswdync",@"_width=%@",_width);
_height = [[inAssociations objectForKey:height__Key
withDefaultObject:[_height autorelease]] retain];
NSDebugMLLog(@"gswdync",@"_height=%@",_height);
[associations removeObjectForKey:width__Key];
[associations removeObjectForKey:height__Key];
if ((self=[super initWithName:name
associations:associations
contentElements:elements]))
{
};
if ([_associations objectForKey: filename__Key] != nil) {
ASSIGN(_width, [_associations objectForKey: width__Key]);
if (_width != nil) {
[_associations removeObjectForKey: width__Key];
}
ASSIGN(_height, [_associations objectForKey: height__Key]);
if (_height != nil) {
[_associations removeObjectForKey: height__Key];
}
}
return self;
};
@ -85,11 +84,6 @@ RCS_ID("$Id$")
return @"src";
};
//--------------------------------------------------------------------
-(NSString*)elementName
{
return @"IMG";
};
//--------------------------------------------------------------------
-(NSString*)description
@ -98,52 +92,231 @@ RCS_ID("$Id$")
object_get_class_name(self),
(void*)self];
};
// GSWImage._appendFilenameToResponseInContext(woresponse, wocontext, _framework, _filename, _width, _height);
//--------------------------------------------------------------------
+(BOOL)hasGSWebObjectsAssociations
+ (void) _appendFilenameToResponse:(GSWResponse *) response
inContext:(GSWContext *) context
framework:(GSWAssociation*) framework
filename:(GSWAssociation*) filename
width:(GSWAssociation*) width
height:(GSWAssociation*) height
{
return YES;
};
id widthValue = nil;
id heightValue = nil;
BOOL hasNoWidth = NO;
BOOL hasNoHeight = NO;
NSString * frameworkName;
//--------------------------------------------------------------------
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
GSWResourceManager * resourcemanager = [GSWApp resourceManager];
GSWComponent * component = GSWContext_component(context);
NSString* fileNameValue = [filename valueInComponent:component];
// i think we have to use component, because we are in a '+' method here. dw
frameworkName = [(GSWHTMLDynamicElement*) component _frameworkNameForAssociation: framework
inComponent: component];
NSString * resourceURL = [context _urlForResourceNamed:frameworkName inFramework: frameworkName];
if (resourceURL != nil) {
NSString * widthStr = nil;
NSString * heightStr = nil;
if (width != nil || height != nil) {
if (width != nil) {
widthValue = [width valueInComponent:component];
widthStr = widthValue != nil ? widthValue : nil; // stringValue?
hasNoWidth = (widthStr == nil || [widthStr isEqual:@"*"]);
}
if (height != nil) {
heightValue = [height valueInComponent:component];
heightStr = heightValue != nil ? heightValue : nil; // stringValue?
hasNoHeight = (heightStr == nil || [heightStr isEqual:@"*"]);
}
} else {
hasNoWidth = YES;
hasNoHeight = YES;
// do we really need that log? dw.
// NSLog("%@: No height or width information provided for '%@'. If possible, this information should be provided for best performance.", [self class], fileNameValue);
}
// GSWeb does not have that jet.
//
// if (hasNoWidth || hasNoHeight) {
// GSWImageInfo * imageinfo = [resourcemanager _imageInfoForUrl: resourceURL
// fileName: fileNameValue
// framework: frameworkName
// languages: [context _languages]]);
// if (imageinfo != nil) {
// if (hasNoWidth)
// {
// widthStr = imageinfo.widthString();
// }
// if (hasNoHeight)
// {
// heightStr = imageinfo.heightString();
// }
// } else
// {
// NSLog("%@: could not get height/width information for image at '%@/%@/%@'",
// [self class], resourceURL, fileNameValue, frameworkName);
// }
// }
[response _appendTagAttribute: @"src"
value: resourceURL
escapingHTMLAttributeValue: NO];
if (widthStr != nil) {
[response _appendTagAttribute: @"width"
value: widthStr
escapingHTMLAttributeValue: NO];
}
if (heightStr != nil) {
[response _appendTagAttribute: @"height"
value: heightStr
escapingHTMLAttributeValue: NO];
}
} else {
[response _appendTagAttribute:@"src"
value:[resourcemanager errorMessageUrlForResourceNamed: fileNameValue
inFramework: frameworkName]
escapingHTMLAttributeValue:NO];
}
}
// used from GSWActiveImage
// _appendImageSizetoResponseInContext
+ (void) _appendImageSizetoResponse:(GSWResponse *) response
inContext:(GSWContext *) context
width:(GSWAssociation *) width
height:(GSWAssociation *) height
{
//OK
LOGObjectFnStartC("GSWImage");
[super appendGSWebObjectsAssociationsToResponse:aResponse
inContext:aContext];
NSDebugMLLog(@"gswdync",@"_width=%@",_width);
NSDebugMLLog(@"gswdync",@"_height=%@",_height);
GSWComponent * component = GSWContext_component(context);
NSString * widthValue = nil;
NSString * heightValue = nil;
if (_width || _height)
{
GSWComponent* component=GSWContext_component(aContext);
if (_width)
{
id width=[_width valueInComponent:component];
NSDebugMLLog(@"gswdync",@"width=%@",width);
if (width)
{
GSWResponse_appendContentAsciiString(aResponse,@" width=\"");
GSWResponse_appendContentHTMLString(aResponse,width);
GSWResponse_appendContentCharacter(aResponse,'"');
};
};
if (_height)
{
id height=[_height valueInComponent:component];
NSDebugMLLog(@"gswdync",@"height=%@",height);
if (height)
{
GSWResponse_appendContentAsciiString(aResponse,@" height=\"");
GSWResponse_appendContentHTMLString(aResponse,height);
GSWResponse_appendContentCharacter(aResponse,'"');
};
};
};
LOGObjectFnStopC("GSWImage");
};
if (width) {
widthValue = [[width valueInComponent:component] description];
}
if (height) {
heightValue = [[height valueInComponent:component] description];
}
if (widthValue != nil) {
[response _appendTagAttribute: @"width"
value: widthValue
escapingHTMLAttributeValue: NO];
}
if (heightValue != nil) {
[response _appendTagAttribute: @"height"
value: heightValue
escapingHTMLAttributeValue: NO];
}
}
- (void) _appendFilenameToResponse:(GSWResponse *) response
inContext:(GSWContext *) context
{
id widthValue = nil;
id heightValue = nil;
BOOL hasNoWidth = NO;
BOOL hasNoHeight = NO;
GSWResourceManager * resourcemanager = [GSWApp resourceManager];
GSWComponent * component = GSWContext_component(context);
NSString* fileNameValue = [_filename valueInComponent:component];
NSString * frameworkName = [self _frameworkNameForAssociation: _framework
inComponent: component];
NSString * resourceURL = [context _urlForResourceNamed:frameworkName inFramework: frameworkName];
if (resourceURL != nil) {
NSString * widthStr = nil;
NSString * heightStr = nil;
NSLog(@"%s resourceURL:%@",__PRETTY_FUNCTION__, resourceURL);
if (_width != nil || _height != nil) {
if (_width != nil) {
widthValue = [_width valueInComponent:component];
widthStr = widthValue != nil ? NSStringWithObject(widthValue) : nil;
hasNoWidth = (widthStr == nil || [widthStr isEqual:@"*"]);
}
if (_height != nil) {
heightValue = [_height valueInComponent:component];
heightStr = heightValue != nil ? NSStringWithObject(heightValue) : nil; // stringValue?
hasNoHeight = (heightStr == nil || [heightStr isEqual:@"*"]);
}
} else {
hasNoWidth = YES;
hasNoHeight = YES;
// do we really need that log? dw.
// NSLog("%@: No height or width information provided for '%@'. If possible, this information should be provided for best performance.", [self class], fileNameValue);
}
// GSWeb does not have that jet.
//
// if (hasNoWidth || hasNoHeight) {
// GSWImageInfo * imageinfo = [resourcemanager _imageInfoForUrl: resourceURL
// fileName: fileNameValue
// framework: frameworkName
// languages: [context _languages]]);
// if (imageinfo != nil) {
// if (hasNoWidth)
// {
// widthStr = imageinfo.widthString();
// }
// if (hasNoHeight)
// {
// heightStr = imageinfo.heightString();
// }
// } else
// {
// NSLog("%@: could not get height/width information for image at '%@/%@/%@'",
// [self class], resourceURL, fileNameValue, frameworkName);
// }
// }
[response _appendTagAttribute: @"src"
value: resourceURL
escapingHTMLAttributeValue: NO];
if (widthStr != nil) {
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response,
width__Key,
widthStr,
NO);
}
if (heightStr != nil) {
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response,
height__Key,
heightStr,
NO);
}
} else { // resourceURL is nil
NSLog(@"%s resourceURL is nil self:%@",__PRETTY_FUNCTION__, self);
[response _appendTagAttribute:@"src"
value:[resourcemanager errorMessageUrlForResourceNamed: fileNameValue
inFramework: frameworkName]
escapingHTMLAttributeValue:NO];
}
}
-(void) _appendCloseTagToResponse:(GSWResponse *) response
inContext:(GSWContext*) context
{
// do nothing!
}
@end

View file

@ -54,28 +54,15 @@
GSWAssociation* _data;
GSWAssociation* _mimeType;
GSWAssociation* _key;
GSWAssociation* _width;
GSWAssociation* _height;
};
-(void)dealloc;
-(id)initWithName:(NSString*)name
associations:(NSDictionary*)associations
contentElements:(NSArray*)elements;
-(NSString*)description;
-(NSString*)elementName;
@end
//====================================================================
@interface GSWImageButton (GSWImageButtonA)
-(GSWAssociation*)hitTestX:(int)x
y:(int)y
inRegions:(NSArray*)regions;
@end
//====================================================================
@interface GSWImageButton (GSWImageButtonB)
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)response
inContext:(GSWContext*)context;
-(id)_imageURLInContext:(GSWContext*)context;
@ -92,14 +79,7 @@
inContext:(GSWContext*)context;
-(NSString*)frameworkNameInContext:(GSWContext*)context;
@end
//====================================================================
@interface GSWImageButton (GSWImageButtonC)
-(BOOL)appendStringAtRight:(id)unkwnon
withMapping:(char*)mapping;
-(BOOL)appendStringAtLeft:(id)unkwnon
withMapping:(char*)mapping;
@end
#endif //_GSWImageButton_h__

View file

@ -38,114 +38,184 @@ RCS_ID("$Id$")
//--------------------------------------------------------------------
-(id)initWithName:(NSString*)aName
associations:(NSDictionary*)associations
contentElements:(NSArray*)elements;
associations:(NSDictionary*)associations
template:(GSWElement*)template
{
//OK
NSMutableDictionary* tmpAssociations=nil;
LOGObjectFnStart();
NSDebugMLLog(@"gswdync",@"aName=%@ associations:%@ elements=%@",
aName,associations,elements);
tmpAssociations=[NSMutableDictionary dictionaryWithDictionary:associations];
[tmpAssociations removeObjectForKey:imageMapFileName__Key];
if (!WOStrictFlag)
{
[tmpAssociations removeObjectForKey:imageMapString__Key];
[tmpAssociations removeObjectForKey:imageMapRegions__Key];
[tmpAssociations removeObjectForKey:cidStore__Key];
[tmpAssociations removeObjectForKey:cidKey__Key];
};
[tmpAssociations removeObjectForKey:action__Key];
[tmpAssociations removeObjectForKey:actionClass__Key];
[tmpAssociations removeObjectForKey:directActionName__Key];
[tmpAssociations removeObjectForKey:x__Key];
[tmpAssociations removeObjectForKey:y__Key];
[tmpAssociations removeObjectForKey:filename__Key];
[tmpAssociations removeObjectForKey:framework__Key];
[tmpAssociations removeObjectForKey:src__Key];
[tmpAssociations removeObjectForKey:data__Key];
[tmpAssociations removeObjectForKey:mimeType__Key];
[tmpAssociations removeObjectForKey:key__Key];
if ((self=[super initWithName:aName
associations:tmpAssociations
contentElements:elements]))
{
int imageMapDefNb=0;
_action = [[associations objectForKey:action__Key
withDefaultObject:[_action autorelease]] retain];
NSDebugMLLog(@"gswdync",@"action=%@",_action);
if ([_action isValueConstant])
{
ExceptionRaise0(@"GSWImageButton",@"'Action' parameter can't be a constant association");
};
_imageMapFileName = [[associations objectForKey:imageMapFileName__Key
withDefaultObject:[_imageMapFileName autorelease]] retain];
if (_imageMapFileName)
imageMapDefNb++;
NSDebugMLLog(@"gswdync",@"imageMapFileName=%@",_imageMapFileName);
int imageMapDefNb=0;
if (!WOStrictFlag)
{
_imageMapString = [[associations objectForKey:imageMapString__Key
withDefaultObject:[_imageMapString autorelease]] retain];
if (_imageMapString)
imageMapDefNb++;
_imageMapRegions = [[associations objectForKey:imageMapRegions__Key
withDefaultObject:[_imageMapRegions autorelease]] retain];
if (_imageMapRegions)
imageMapDefNb++;
if (imageMapDefNb>0)
{
ExceptionRaise(@"GSWActiveImage",@"you can't specify %@, %@ and %@",
imageMapFileName__Key,
imageMapString__Key,
imageMapRegions__Key);
};
self = [super initWithName:@"input" associations:associations template: nil];
if (!self) {
return nil;
}
if ([_associations objectForKey: type__Key]) {
[_associations removeObjectForKey: type__Key];
NSLog(@"ImageButton: 'type' attribute ignored");
}
_cidStore = [[associations objectForKey:cidStore__Key
withDefaultObject:[_cidStore autorelease]] retain];
NSDebugMLLog(@"gswdync",@"cidStore=%@",_cidStore);
_cidKey = [[associations objectForKey:cidKey__Key
withDefaultObject:[_cidKey autorelease]] retain];
NSDebugMLLog(@"gswdync",@"cidKey=%@",_cidKey);
};
_actionClass = [[associations objectForKey:actionClass__Key
withDefaultObject:[_actionClass autorelease]] retain];
NSDebugMLLog(@"gswdync",@"actionClass=%@",_actionClass);
_directActionName = [[associations objectForKey:directActionName__Key
withDefaultObject:[_directActionName autorelease]] retain];
NSDebugMLLog(@"gswdync",@"directActionName=%@",_directActionName);
_xAssoc = [[associations objectForKey:x__Key
withDefaultObject:[_xAssoc autorelease]] retain];
ASSIGN(_action, [_associations objectForKey: action__Key]);
if (_action != nil) {
[_associations removeObjectForKey: action__Key];
}
ASSIGN(_imageMapFileName, [_associations objectForKey: imageMapFileName__Key]);
if (_imageMapFileName != nil) {
imageMapDefNb++;
[_associations removeObjectForKey: imageMapFileName__Key];
}
ASSIGN(_actionClass, [_associations objectForKey: actionClass__Key]);
if (_actionClass != nil) {
[_associations removeObjectForKey: actionClass__Key];
}
ASSIGN(_directActionName, [_associations objectForKey: directActionName__Key]);
if (_directActionName != nil) {
[_associations removeObjectForKey: directActionName__Key];
}
ASSIGN(_xAssoc, [_associations objectForKey: x__Key]);
if (_xAssoc != nil) {
[_associations removeObjectForKey: x__Key];
}
ASSIGN(_yAssoc, [_associations objectForKey: y__Key]);
if (_yAssoc != nil) {
[_associations removeObjectForKey: y__Key];
}
ASSIGN(_filename, [_associations objectForKey: filename__Key]);
if (_filename != nil) {
[_associations removeObjectForKey: filename__Key];
}
if (_filename != nil) {
ASSIGN(_width, [_associations objectForKey: width__Key]);
if (_width != nil) {
[_associations removeObjectForKey: width__Key];
}
ASSIGN(_height, [_associations objectForKey: height__Key]);
if (_height != nil) {
[_associations removeObjectForKey: height__Key];
}
}
ASSIGN(_framework, [_associations objectForKey: framework__Key]);
if (_framework != nil) {
[_associations removeObjectForKey: framework__Key];
}
ASSIGN(_src, [_associations objectForKey: src__Key]);
if (_src != nil) {
[_associations removeObjectForKey: src__Key];
}
ASSIGN(_data, [_associations objectForKey: data__Key]);
if (_data != nil) {
[_associations removeObjectForKey: data__Key];
}
ASSIGN(_mimeType, [_associations objectForKey: mimeType__Key]);
if (_mimeType != nil) {
[_associations removeObjectForKey: mimeType__Key];
}
ASSIGN(_key, [_associations objectForKey: key__Key]);
if (_key != nil) {
[_associations removeObjectForKey: key__Key];
}
_yAssoc = [[associations objectForKey:y__Key
withDefaultObject:[_yAssoc autorelease]] retain];
_filename = [[associations objectForKey:filename__Key
withDefaultObject:[_filename autorelease]] retain];
if (!WOStrictFlag) {
ASSIGN(_imageMapString, [_associations objectForKey: imageMapString__Key]);
if (_imageMapString != nil) {
imageMapDefNb++;
[_associations removeObjectForKey: imageMapString__Key];
}
ASSIGN(_imageMapRegions, [_associations objectForKey: imageMapRegions__Key]);
if (_imageMapRegions != nil) {
imageMapDefNb++;
[_associations removeObjectForKey: imageMapRegions__Key];
}
if (imageMapDefNb>0) { // sure that this is 0 and not 1? dw
ExceptionRaise(@"ImageButton",@"you can't specify %@, %@ and %@",
imageMapFileName__Key,
imageMapString__Key,
imageMapRegions__Key);
}
ASSIGN(_cidStore, [_associations objectForKey: cidStore__Key]);
if (_cidStore != nil) {
[_associations removeObjectForKey: cidStore__Key];
}
ASSIGN(_cidKey, [_associations objectForKey: cidKey__Key]);
if (_cidKey != nil) {
[_associations removeObjectForKey: cidKey__Key];
}
} // (!WOStrictFlag)
_framework = [[associations objectForKey:framework__Key
withDefaultObject:[_framework autorelease]] retain];
if (_action != nil) {
if (_actionClass != nil || _directActionName != nil) {
[NSException raise:NSInvalidArgumentException
format:@"%s: Neither 'directActionName' nor 'actionClass' should be specified if 'action' is specified.",
__PRETTY_FUNCTION__];
}
if ([_action isValueConstant]) {
[NSException raise:NSInvalidArgumentException
format:@"%s: 'action' must be a setable value and not a contant.",
__PRETTY_FUNCTION__];
}
} else {
if (_actionClass == nil && _directActionName == nil) {
[NSException raise:NSInvalidArgumentException
format:@"%s: Either a 'action' or a direct action must be specified.",
__PRETTY_FUNCTION__];
}
}
if (_filename != nil) {
if (_src != nil || _data != nil || _value != nil) {
[NSException raise:NSInvalidArgumentException
format:@"%s: If 'filename' is specified, 'value', 'data', and 'src' must be nil.",
__PRETTY_FUNCTION__];
}
} else { // _filename
if (_framework != nil) {
[NSException raise:NSInvalidArgumentException
format:@"%s: 'framework' should not be specified if 'filename' is nil.",
__PRETTY_FUNCTION__];
}
if (_data != nil) {
if (_mimeType == nil) {
[NSException raise:NSInvalidArgumentException
format:@"%s: 'mimeType' must be specified if 'data' is specified.",
__PRETTY_FUNCTION__];
}
if (_src != nil || _value != nil) {
[NSException raise:NSInvalidArgumentException
format:@"%s: If 'data' is specified, 'src', 'filename', and 'value' must be nil.",
__PRETTY_FUNCTION__];
}
} else
if (_value != nil) {
if ([_value isValueConstant]) {
[NSException raise:NSInvalidArgumentException
format:@"%s: 'value' must not be constant.",
__PRETTY_FUNCTION__];
}
if (_src != nil) {
[NSException raise:NSInvalidArgumentException
format:@"%s: If 'value' is specified, 'data', 'filename', and 'src' must be nil.",
__PRETTY_FUNCTION__];
}
} else {
if (_src == nil) {
[NSException raise:NSInvalidArgumentException
format:@"%s: One of 'filename', 'src', 'data', or 'value' must be specified.",
__PRETTY_FUNCTION__];
}
}
}
if (_xAssoc != nil && _yAssoc != nil) {
if ((![_xAssoc isValueSettable]) || (![_yAssoc isValueSettable])) {
[NSException raise:NSInvalidArgumentException
format:@"%s: 'x' and 'y' can not be constants.",
__PRETTY_FUNCTION__];
}
} else
if (_xAssoc != nil || _yAssoc != nil) {
[NSException raise:NSInvalidArgumentException
format:@"%s: 'x' and 'y' must both be specified or both be nil.",
__PRETTY_FUNCTION__];
}
_src = [[associations objectForKey:src__Key
withDefaultObject:[_src autorelease]] retain];
NSDebugMLLog(@"gswdync",@"src=%@",_src);
_data = [[associations objectForKey:data__Key
withDefaultObject:[_data autorelease]] retain];
NSDebugMLLog(@"gswdync",@"data=%@",_data);
_mimeType = [[associations objectForKey:mimeType__Key
withDefaultObject:[_mimeType autorelease]] retain];
_key = [[associations objectForKey:key__Key
withDefaultObject:[_key autorelease]] retain];
};
return self;
};
@ -168,26 +238,19 @@ RCS_ID("$Id$")
DESTROY(_data);
DESTROY(_mimeType);
DESTROY(_key);
DESTROY(_width);
DESTROY(_height);
[super dealloc];
};
//--------------------------------------------------------------------
-(NSString*)elementName
{
return nil;//@"ELEMENTCHOSENBYCONTEXT";//TODO
};
//--------------------------------------------------------------------
-(NSString*)description
{
return [NSString stringWithFormat:@"<%s %p>",
object_get_class_name(self),
(void*)self];
};
@end
//====================================================================
@implementation GSWImageButton (GSWImageButtonA)
-(GSWAssociation*)hitTestX:(int)x
y:(int)y
inRegions:(NSArray*)regions
@ -202,153 +265,8 @@ RCS_ID("$Id$")
assoc=_action;
return assoc;
};
@end
//====================================================================
@implementation GSWImageButton (GSWImageButtonB)
//--------------------------------------------------------------------
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
//OK
NSString* urlValue=nil;
NSString* name=nil;
BOOL disabledInContext=NO;
GSWComponent* component=nil;
GSWResourceManager* resourceManager=nil;
GSWURLValuedElementData* dataValue=nil;
NSString* keyValue=nil;
id cidStoreValue=nil;
LOGObjectFnStart();
disabledInContext=[self disabledInContext:aContext];
GSWResponse_appendContentAsciiString(aResponse,@" type=image");
name=[self nameInContext:aContext];
NSDebugMLLog(@"gswdync",@"declarationName=%@ name=%@",
[self declarationName],name);
GSWResponse_appendContentAsciiString(aResponse,@" name=\"");
GSWResponse_appendContentHTMLAttributeValue(aResponse,name);
GSWResponse_appendContentCharacter(aResponse,'"');
component=GSWContext_component(aContext);
cidStoreValue=[_cidStore valueInComponent:component];
NSDebugMLLog(@"gswdync",@"cidStoreValue=%@",cidStoreValue);
resourceManager=[[GSWApplication application]resourceManager];
if (_src)
{
urlValue=[_src valueInComponent:component];
if (cidStoreValue)
{
urlValue=[self addURL:urlValue
forCIDKeyAssociation:_cidKey
CIDStoreAssociation:_cidStore
inContext:aContext];
NSDebugMLLog(@"gswdync",@"urlValue=%@",urlValue);
};
}
else
{
if (_key)
{
keyValue=[_key valueInComponent:component];
dataValue=[resourceManager _cachedDataForKey:keyValue];
if (cidStoreValue && dataValue)
{
urlValue=[self addURLValuedElementData:dataValue
forCIDKeyAssociation:_cidKey
CIDStoreAssociation:_cidStore
inContext:aContext];
NSDebugMLLog(@"gswdync",@"urlValue=%@",urlValue);
}
};
if (!dataValue && _data)
{
id tmpDataValue=[_data valueInComponent:component];
id mimeTypeValue=[_mimeType valueInComponent:component];
dataValue=[[[GSWURLValuedElementData alloc] initWithData:tmpDataValue
mimeType:mimeTypeValue
key:keyValue] autorelease];
[resourceManager setURLValuedElementData:dataValue];
if (cidStoreValue && dataValue)
{
urlValue=[self addURLValuedElementData:dataValue
forCIDKeyAssociation:_cidKey
CIDStoreAssociation:_cidStore
inContext:aContext];
NSDebugMLLog(@"gswdync",@"urlValue=%@",urlValue);
}
}
else if (_filename)
{
id filenameValue=nil;
id frameworkValue=nil;
GSWRequest* request=nil;
NSArray* languages=nil;
NSDebugMLLog(@"gswdync",@"filename=%@",_filename);
filenameValue=[_filename valueInComponent:component];
NSDebugMLLog(@"gswdync",@"filenameValue=%@",filenameValue);
frameworkValue=[self frameworkNameInContext:aContext];
NSDebugMLLog(@"gswdync",@"frameworkValue=%@",frameworkValue);
request=[aContext request];
languages=[aContext languages];
if (cidStoreValue)
{
NSString* path=[resourceManager pathForResourceNamed:filenameValue
inFramework:frameworkValue
languages:languages];
urlValue=[self addPath:path
forCIDKeyAssociation:_cidKey
CIDStoreAssociation:_cidStore
inContext:aContext];
NSDebugMLLog(@"gswdync",@"urlValue=%@",urlValue);
}
else
{
urlValue=[resourceManager urlForResourceNamed:filenameValue
inFramework:frameworkValue
languages:languages
request:request];
};
};
};
GSWResponse_appendContentAsciiString(aResponse,@" src=\"");
if (_src)
{
GSWResponse_appendContentString(aResponse,urlValue);
}
else
{
if (_key || _data)
{
if (cidStoreValue)
GSWResponse_appendContentString(aResponse,urlValue);
else
[dataValue appendDataURLToResponse:aResponse
inContext:aContext];
}
else if (_filename)
{
GSWResponse_appendContentString(aResponse,urlValue);
}
else
{
GSWDynamicURLString* componentActionURL=[aContext componentActionURL];
NSDebugMLLog(@"gswdync",@"componentActionURL=%@",componentActionURL);
GSWResponse_appendContentString(aResponse,(NSString*)componentActionURL);
};
};
GSWResponse_appendContentCharacter(aResponse,'"');
LOGObjectFnStop();
};
//--------------------------------------------------------------------
-(id)_imageURLInContext:(GSWContext*)aContext
@ -358,43 +276,116 @@ RCS_ID("$Id$")
};
//--------------------------------------------------------------------
-(void)appendToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
-(void)_appendDirectActionToResponse:(GSWResponse*) response
inContext:(GSWContext*) context
{
//OK
//GSWRequest* request=[aContext request];
//Unused now BOOL isFromClientComponent=[request isFromClientComponent];
BOOL disabledInContext=[self disabledInContext:aContext];
GSWSaveAppendToResponseElementID(aContext);//Debug Only
if (disabledInContext)
{
//TODO
};
GSWResponse_appendContentAsciiString(aResponse,@"<INPUT");
[super appendToResponse:aResponse
inContext:aContext];
NSString * actionStr = [self computeActionStringWithActionClassAssociation: _actionClass
directActionNameAssociation: _directActionName
inContext: context];
GSWResponse_appendContentString(response, actionStr);
};
//--------------------------------------------------------------------
-(void)_appendDirectActionToResponse:(GSWResponse*)response
inContext:(GSWContext*)aContext
-(void)appendAttributesToResponse:(GSWResponse*) response
inContext:(GSWContext*) context
{
LOGObjectFnNotImplemented(); //TODOFN
GSWResourceManager * resourcemanager = [GSWApp resourceManager];
GSWComponent * component = GSWContext_component(context);
[self appendConstantAttributesToResponse:response
inContext:context];
[self appendNonURLAttributesToResponse:response
inContext:context];
[self appendURLAttributesToResponse:response
inContext:context];
if (! [self disabledInComponent: component]) {
GSWResponse_appendContentAsciiString(response, @" type=\"image\"");
NSString * nameCtx = [self nameInContext:context];
if (nameCtx != nil) {
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response, name__Key, nameCtx, YES);
}
}
if (_value != nil) {
[context appendZeroElementIDComponent];
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response, src__Key, [context componentActionURL], NO);
[context deleteLastElementIDComponent];
} else {
if (_data != nil && _mimeType != nil) {
[GSWURLValuedElementData _appendDataURLToResponse: response
inContext: context
key: _key
data: _data
mimeType: _mimeType
urlAttributeName: src__Key
inComponent: component];
} else {
if (_filename != nil) {
[GSWImage _appendFilenameToResponse: response
inContext: context
framework: _framework
filename: _filename
width: _width
height: _height];
} else {
NSString * srcValue = [_src valueInComponent:component];
if (srcValue == nil) {
srcValue = [resourcemanager errorMessageUrlForResourceNamed:@"/nil"
inFramework:@"nil"];
NSLog(@"%s: 'src' (full url) evaluated to nil in component '%@'. Inserted error resource in html tag.",
__PRETTY_FUNCTION__, component);
}
[response _appendTagAttribute:@"src"
value:srcValue
escapingHTMLAttributeValue:NO];
}
}
}
}
-(void)appendToResponse:(GSWResponse*) response
inContext:(GSWContext*) context
{
GSWComponent * component = GSWContext_component(context);
if ([self disabledInComponent: component]) {
GSWResponse_appendContentAsciiString(response,@"<img");
} else {
GSWResponse_appendContentAsciiString(response,@"<input");
}
[self appendAttributesToResponse:response
inContext:context];
GSWResponse_appendContentCharacter(response,'>');
if (_directActionName != nil || _actionClass != nil) {
GSWResponse_appendContentAsciiString(response,@"<input type=\"hidden\" name=\"GSWSubmitAction\" value=\"");
[self _appendDirectActionToResponse:response
inContext:context];
GSWResponse_appendContentCharacter(response,'>');
}
};
//--------------------------------------------------------------------
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)aContext
{
LOGObjectFnStart();
GSWAssertCorrectElementID(aContext);// Debug Only
//Does nothing ?
LOGObjectFnStop();
//Does nothing!
};
// todo: check if 100% compatible
//--------------------------------------------------------------------
-(GSWElement*)invokeActionForRequest:(GSWRequest*)request
inContext:(GSWContext*)aContext
@ -402,7 +393,6 @@ RCS_ID("$Id$")
GSWElement* element=nil;
NSString* senderID=nil;
NSString* elementID=nil;
BOOL disabledInContext=NO;
BOOL isInForm=NO;
BOOL XYValues=NO;
BOOL thisOne=NO;
@ -422,8 +412,7 @@ RCS_ID("$Id$")
//TODO
};
GSWContext_deleteLastElementIDComponent(aContext);
disabledInContext=[self disabledInContext:aContext];
if (!disabledInContext)
if (! [self disabledInComponent: component])
{
isInForm=[aContext isInForm];
if (isInForm)
@ -565,131 +554,6 @@ RCS_ID("$Id$")
};
//--------------------------------------------------------------------
/*
-(GSWElement*)invokeActionForRequest:(GSWRequest*)request
inContext:(GSWContext*)aContext
{
GSWElement* _element=nil;
BOOL disabledInContext=NO;
LOGObjectFnStart();
NSDebugMLLog(@"gswdync",@"ET=%@ id=%@ senderId=%@",
[self class],GSWContext_elementID(aContext),GSWContext_senderID(aContext));
GSWAssertCorrectElementID(aContext);// Debug Only
disabledInContext=[self disabledInContext:aContext];
if (!disabledInContext)
{
NSString* senderID=nil;
NSString* elementID=nil;
BOOL XYValues=NO;
GSWComponent* component=nil;
BOOL wasFormSubmitted=NO;
int x=0;
int y=0;
GSWAssociation* actionAssociation=nil;
NSArray* regions=nil;
component=GSWContext_component(aContext);
wasFormSubmitted=[aContext _wasFormSubmitted];
if (wasFormSubmitted)
{
NSString* nameInContext=[self nameInContext:aContext];
NSString* formValueX=[request formValueForKey:[NSString stringWithFormat:@"%@.x",
nameInContext]];
NSString* formValueY=[request formValueForKey:[NSString stringWithFormat:@"%@.y",
nameInContext]];
NSDebugMLLog(@"gswdync",@"formValueX=%@",formValueX);
NSDebugMLLog(@"gswdync",@"formValueY=%@",formValueY);
if (formValueX && formValueY)
{
x=[formValueX intValue];
y=[formValueY intValue];
XYValues=YES;
}
else
{
//TODO
};
if (_imageMapFileName)
{
id imageMapFileNameValue=[imageMapFileName valueInComponent:component];
NSString* imageMapFilePath=[component
pathForResourceNamed:imageMapFileNameValue
ofType:nil];
if (!imageMapFilePath)
{
GSWResourceManager* resourceManager=[[GSWApplication application]resourceManager];
NSArray* languages=[aContext languages];
imageMapFilePath=[resourceManager pathForResourceNamed:imageMapFileNameValue
inFramework:nil
languages:languages];
};
if (imageMapFilePath)
regions=[GSWGeometricRegion geometricRegionsWithFile:imageMapFilePath];
else
{
NSDebugMLLog0(@"gswdync",@"GSWActiveImage No image Map.");
};
}
else if (!WOStrictFlag && _imageMapString)
{
id imageMapValue=[_imageMapString valueInComponent:component];
regions=[GSWGeometricRegion geometricRegionsWithString:imageMapValue];
}
else if (!WOStrictFlag && _imageMapRegions)
{
regions=[_imageMapRegions valueInComponent:component];
};
if (_xAssoc)
[_xAssoc setValue:GSWIntNumber(x)
inComponent:component];
if (_yAssoc)
[_yAssoc setValue:GSWIntNumber(y)
inComponent:component];
actionAssociation=[self hitTestX:x
y:y
inRegions:regions];
if (actionAssociation)
{
[aContext _setActionInvoked:YES];
element=[actionAssociation valueInComponent:component];
if (element)
{
if (![element isKindOfClass:[GSWComponent class]]) //TODO GSWComponent or Element ?
{
ExceptionRaise0(@"GSWHyperlink",@"Invoked element return a not GSWComponent element");
} else {
// call awakeInContext when _element is sleeping deeply
[element ensureAwakeInContext:aContext];
//
// if (![element context]) {
// NSDebugMLLog(@"gswdync",@"_element sleeps, awake it = %@",_element);
// [element awakeInContext:aContext];
// }
}
}
}
else
{
NSDebugMLLog0(@"gswdync",@"GSWActiveImage Couldn't trigger action.");
};
if (!element)
element=[aContext page];
}
else
element=[super invokeActionForRequest:request
inContext:aContext];
}
else
element=[super invokeActionForRequest:request
inContext:aContext];
LOGObjectFnStop();
return element;
};
*/
//--------------------------------------------------------------------
-(NSString*)frameworkNameInContext:(GSWContext*)aContext
{
@ -703,27 +567,6 @@ inContext:(GSWContext*)aContext
frameworkName=[component frameworkName];
return frameworkName;
};
@end
//====================================================================
@implementation GSWImageButton (GSWImageButtonC)
//--------------------------------------------------------------------
-(BOOL)appendStringAtRight:(id)unkwnon
withMapping:(char*)mapping
{
LOGObjectFnNotImplemented(); //TODOFN
return NO;
};
//--------------------------------------------------------------------
-(BOOL)appendStringAtLeft:(id)unkwnon
withMapping:(char*)mapping
{
LOGObjectFnNotImplemented(); //TODOFN
return NO;
};
@end

View file

@ -1,10 +1,12 @@
/** GSWInput.h - <title>GSWeb: Class GSWInput</title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Copyright (C) 1999-2006 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Feb 1999
Written by: David Wetzel <dave@turbocat.de> http://www.turbocat.de/
Date: Jan 2006
$Revision$
$Date$
@ -36,89 +38,45 @@
//====================================================================
@interface GSWInput: GSWHTMLDynamicElement
{
GSWAssociation* _disabled;
//GSWeb Additions {
GSWAssociation* _enabled;
//}
GSWAssociation* _name;
GSWAssociation* _value;
//GSWeb Additions {
GSWAssociation* _handleValidationException;
// }
//GSWeb Additions {
GSWAssociation* _tcEscapeHTML;
// }
};
GSWAssociation * _disabled;
GSWAssociation * _name;
GSWAssociation * _value;
GSWAssociation * _escapeHTML;
}
-(id)initWithName:(NSString*)name
+ (void) _appendImageSizetoResponse:(GSWResponse *) response
inContext:(GSWContext *) context
width:(GSWAssociation *) width
height:(GSWAssociation *) height;
-(id)initWithName:(NSString*)aName
associations:(NSDictionary*)associations
contentElements:(NSArray*)elements;
contentElements:(NSMutableArray*) elements;
-(void)dealloc;
-(NSString*)elementName;
@end
- (BOOL) disabledInComponent:(GSWComponent*) component;
//====================================================================
@interface GSWInput (GSWInputA)
/** Return the name for html output.
If no name is binded, it return the context id **/
-(NSString*)nameInContext:(GSWContext*)context;
//--------------------------------------------------------------------
/** return the value used in appendValueToResponse:inContext: **/
-(id)valueInContext:(GSWContext*)context;
/** Return YES if element is disabled, NO otherwise,
depending on disabled/enabled binding
**/
-(BOOL)disabledInContext:(GSWContext*)context;
@end
//====================================================================
@interface GSWInput (GSWInputB)
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context;
@end
//====================================================================
@interface GSWInput (GSWInputC)
/** Append the following elements to response:
tag
name (by calling -appendNameToResponse:inContext:)
value (by calling -appendValueToResponse:inContext:)
and others specified tag properties
**/
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)response
inContext:(GSWContext*)context;
- (void) _appendNameAttributeToResponse:(GSWResponse *) response
inContext:(GSWContext*)context;
/** Append value property to response.
(Called by -appendGSWebObjectsAssociationsToResponse:inContext:)
**/
-(void)appendValueToResponse:(GSWResponse*)response
inContext:(GSWContext*)context;
/** Append name property to response.
name come from -nameInContext:
*/
-(void)appendNameToResponse:(GSWResponse*)response
inContext:(GSWContext*)context;
@end
//====================================================================
@interface GSWInput (GSWInputD)
+(BOOL)hasGSWebObjectsAssociations;
@end
//====================================================================
@interface GSWInput (GSWInputE)
#if !GSWEB_STRICT
-(void)handleValidationException:(NSException*)exception
inContext:(GSWContext*)context;
#endif
@end
#endif //GSWInput

View file

@ -29,6 +29,7 @@
**/
#include "GSWeb.h"
#include "GSWPrivate.h"
static GSWIMP_BOOL standardEvaluateConditionInContextIMP = NULL;
@ -52,347 +53,196 @@ static Class standardClass = Nil;
//--------------------------------------------------------------------
-(id)initWithName:(NSString*)aName
associations:(NSDictionary*)associations
contentElements:(NSArray*)elements
contentElements:(NSMutableArray*) elements
{
NSMutableDictionary* attributedAssociations=[[associations mutableCopy] autorelease];
LOGObjectFnStartC("GSWInput");
NSDebugMLLog(@"gswdync",@"aName=%@ associations:%@ elements=%@",aName,associations,elements);
[attributedAssociations removeObjectForKey:disabled__Key];
[attributedAssociations removeObjectForKey:enabled__Key];
[attributedAssociations removeObjectForKey:value__Key];
[attributedAssociations removeObjectForKey:name__Key];
if (!WOStrictFlag)
[attributedAssociations removeObjectForKey:handleValidationException__Key];
_value = [[associations objectForKey:value__Key
withDefaultObject:[_value autorelease]] retain];
NSDebugMLLog(@"gswdync",@"GSWInput: value=%@",_value);
if ((self=[super initWithName:aName
attributeAssociations:attributedAssociations
contentElements:elements]))
{
_disabled = [[associations objectForKey:disabled__Key
withDefaultObject:[_disabled autorelease]] retain];
NSDebugMLLog(@"gswdync",@"GSWInput: disabled=%@",_disabled);
if (!WOStrictFlag)
{
_enabled = [[associations objectForKey:enabled__Key
withDefaultObject:[_enabled autorelease]] retain];
NSDebugMLLog(@"gswdync",@"GSWInput: enabled=%@",_enabled);
if (_disabled && _enabled)
{
ExceptionRaise0(@"GSWInput",@"You can't use 'diabled' and 'enabled' parameters at the same time.");
};
};
_name = [[associations objectForKey:name__Key
withDefaultObject:[_name autorelease]] retain];
NSDebugMLLog(@"gswdync",@"GSWInput: name=%@",_name);
if (!WOStrictFlag)
{
_handleValidationException = [[associations objectForKey:handleValidationException__Key
withDefaultObject:[_handleValidationException autorelease]] retain];
NSDebugMLLog(@"gswdync",@"GSWInput: handleValidationException=%@",_handleValidationException);
// Turbocat Additions
// [attributedAssociations removeObjectForKey: escapeHTML__Key];
if ([associations objectForKey: escapeHTML__Key])
{
_tcEscapeHTML = [[associations objectForKey:escapeHTML__Key
withDefaultObject:nil] retain];
};
};
};
LOGObjectFnStopC("GSWInput");
self = [super initWithName:aName associations:associations contentElements: elements];
if (!self) {
return nil;
}
ASSIGN(_disabled, [_associations objectForKey: disabled__Key]);
if (_disabled != nil) {
[_associations removeObjectForKey: disabled__Key];
}
ASSIGN(_name, [_associations objectForKey: name__Key]);
if (_name != nil) {
[_associations removeObjectForKey: name__Key];
}
ASSIGN(_value, [_associations objectForKey: value__Key]);
if (_value != nil) {
[_associations removeObjectForKey: value__Key];
}
ASSIGN(_escapeHTML, [_associations objectForKey: escapeHTML__Key]);
if (_escapeHTML != nil) {
[_associations removeObjectForKey: escapeHTML__Key];
}
return self;
};
}
//--------------------------------------------------------------------
-(void)dealloc
-(id)initWithName:(NSString*)aName
associations:(NSDictionary*)associations
template:(GSWElement*)template
{
DESTROY(_disabled);
DESTROY(_enabled);//GSWeb Only
DESTROY(_name);
DESTROY(_value);
DESTROY(_handleValidationException);//GSWeb Only
DESTROY(_tcEscapeHTML);//GSWeb Only
[super dealloc];
};
self = [super initWithName:aName associations:associations template: template];
if (!self) {
return nil;
}
//--------------------------------------------------------------------
-(NSString*)elementName
ASSIGN(_disabled, [_associations objectForKey: disabled__Key]);
if (_disabled != nil) {
[_associations removeObjectForKey: disabled__Key];
}
ASSIGN(_name, [_associations objectForKey: name__Key]);
if (_name != nil) {
[_associations removeObjectForKey: name__Key];
}
ASSIGN(_value, [_associations objectForKey: value__Key]);
if (_value != nil) {
[_associations removeObjectForKey: value__Key];
}
ASSIGN(_escapeHTML, [_associations objectForKey: escapeHTML__Key]);
if (_escapeHTML != nil) {
[_associations removeObjectForKey: escapeHTML__Key];
}
return self;
}
-(NSString*) type
{
return @"INPUT";
};
return nil;
}
@end
- (NSString*) constantAttributesRepresentation
{
if (_constantAttributesRepresentation == nil) {
NSString * s = [self type];
if (s != nil) {
[super constantAttributesRepresentation];
NSMutableString * buffer = [NSMutableString stringWithCapacity:256];
if (_constantAttributesRepresentation != nil) {
[buffer appendString:_constantAttributesRepresentation];
}
[buffer appendString:@" "];
[buffer appendString:@"type"];
[buffer appendString:@"=\""];
[buffer appendString:s];
[buffer appendString:@"\""];
ASSIGN(_constantAttributesRepresentation,buffer);
}
}
return [super constantAttributesRepresentation];
}
//==============================================================================
@implementation GSWInput (GSWInputA)
- (BOOL) disabledInComponent:(GSWComponent*) component
{
return ((_disabled != nil) && ([_disabled boolValueInComponent: component]));
}
//--------------------------------------------------------------------
-(NSString*)nameInContext:(GSWContext*)context
{
GSWComponent* component=nil;
NSString* nameValue=nil;
LOGObjectFnStartC("GSWInput");
GSWAssertIsElementID(context);
if (_name)
{
component=GSWContext_component(context);
nameValue=NSStringWithObject([_name valueInComponent:component]);
NSString * s = nil;
if (_name != nil) {
GSWComponent * component = GSWContext_component(context);
id obj = [_name valueInComponent:component];
if (obj != nil) {
return obj; // stringValue?
}
else
{
nameValue=GSWContext_elementID(context);
};
NSDebugMLLog(@"gswdync",@"nameValue=%@",nameValue);
GSWAssertIsElementID(context);
LOGObjectFnStopC("GSWInput");
return nameValue;
};
}
s = [context elementID];
if (s != nil) {
return s;
} else {
[NSException raise:NSInvalidArgumentException
format:@"%s: Cannot evaluate 'name' attribute, and context element ID is nil.",
__PRETTY_FUNCTION__];
}
}
//--------------------------------------------------------------------
/** return the value used in appendValueToResponse:inContext: **/
-(id)valueInContext:(GSWContext*)context
{
id value=nil;
LOGObjectFnStartC("GSWInput");
if (_value)
{
GSWComponent* component=nil;
component=GSWContext_component(context);
value=[_value valueInComponent:component];
NSDebugMLLog(@"gswdync",@"value=%@",value);
};
LOGObjectFnStopC("GSWInput");
return value;
};
//--------------------------------------------------------------------
-(BOOL)disabledInContext:(GSWContext*)context
{
BOOL isDisabled=NO;
LOGObjectFnStartC("GSWInput");
NSDebugMLLog(@"gswdync",@"_enabled=%@ _disabled=%@",_enabled,_disabled);
if (!WOStrictFlag && _enabled)
{
return !GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_enabled,context);
}
else
{
return GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_disabled,context);
};
NSDebugMLLog(@"gswdync",@"isDisabled=%d",isDisabled);
LOGObjectFnStopC("GSWInput");
return isDisabled;
};
@end
//==============================================================================
@implementation GSWInput (GSWInputB)
//--------------------------------------------------------------------
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context
{
//OK
BOOL disabledInContext=NO;
LOGObjectFnStartC("GSWInput");
GSWStartElement(context);
GSWAssertCorrectElementID(context);
disabledInContext=[self disabledInContext:context]; //return 0
if (!disabledInContext)
{
BOOL wasFormSubmitted=[context _wasFormSubmitted];
if (wasFormSubmitted)
{
GSWComponent* component=GSWContext_component(context);
NSString* nameInContext=[self nameInContext:context];
NSString* valueValue=[request formValueForKey:nameInContext];
NSDebugMLLog(@"gswdync",@"nameInContext=%@",nameInContext);
NSDebugMLLog(@"gswdync",@"valueValue=%@",valueValue);
NS_DURING
{
[_value setValue:valueValue
id obj = nil;
GSWComponent * component = GSWContext_component(context);
if ((![self disabledInComponent: component]) && ([context _wasFormSubmitted])) {
NSString * s1 = [self nameInContext:context];
if (s1 != nil) {
NSString * s = [request stringFormValueForKey:s1];
[_value setValue: s
inComponent:component];
};
NS_HANDLER
{
LOGException(@"GSWInput _value=%@ valueValue=%@ exception=%@",
_value,valueValue,localException);
if (!WOStrictFlag)
{
[self handleValidationException:localException
inContext:context];
}
else
{
[localException raise];
};
}
NS_ENDHANDLER;
};
};
GSWAssertIsElementID(context);
LOGObjectFnStopC("GSWInput");
};
}
}
}
- (BOOL) _shouldEscapeHTML:(GSWComponent *) component
{
BOOL flag = YES;
if (_escapeHTML != nil) {
flag = [_escapeHTML boolValueInComponent:component];
}
return flag;
}
- (void) _appendNameAttributeToResponse:(GSWResponse *) response
inContext:(GSWContext*)context
{
GSWComponent * component = nil;
NSString * s = [self nameInContext:context];
if (s != nil) {
component = GSWContext_component(context);
[response _appendTagAttribute: name__Key
value: s
escapingHTMLAttributeValue: [self _shouldEscapeHTML:component]];
}
}
- (void) _appendValueAttributeToResponse:(GSWResponse *) response
inContext:(GSWContext*)context
{
GSWComponent * component = GSWContext_component(context);
if (_value != nil)
{
id obj = [_value valueInComponent:component];
id obj1 = nil;
if (obj != nil) {
NSString * s = obj; // stringValue??
[response _appendTagAttribute: value__Key
value: s
escapingHTMLAttributeValue: [self _shouldEscapeHTML:component]];
}
}
}
-(void) appendAttributesToResponse:(GSWResponse *) response
inContext:(GSWContext*) context
{
[super appendAttributesToResponse: response
inContext: context];
if ([self disabledInComponent:GSWContext_component(context)]) {
GSWResponse_appendContentCharacter(response,' ');
GSWResponse_appendContentAsciiString(response, disabled__Key);
}
[self _appendValueAttributeToResponse: response
inContext: context];
[self _appendNameAttributeToResponse: response
inContext: context];
}
-(void)dealloc
{
DESTROY(_disabled);
DESTROY(_name);
DESTROY(_value);
DESTROY(_escapeHTML);
[super dealloc];
}
@end
//====================================================================
@implementation GSWInput (GSWInputC)
//--------------------------------------------------------------------
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
BOOL disabledInContext=NO;
LOGObjectFnStartC("GSWInput");
disabledInContext=[self disabledInContext:aContext]; //return 0
if (disabledInContext)
GSWResponse_appendContentAsciiString(aResponse,@" disabled");
[self appendNameToResponse:aResponse
inContext:aContext];
[self appendValueToResponse:aResponse
inContext:aContext];
LOGObjectFnStopC("GSWInput");
};
//--------------------------------------------------------------------
-(void)appendValueToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
//OK
id valueValue=nil;
LOGObjectFnStartC("GSWInput");
valueValue=[self valueInContext:aContext];
NSDebugMLLog(@"gswdync",@"valueValue=%@",valueValue);
if (valueValue)
{
GSWResponse_appendContentCharacter(aResponse,' ');
GSWResponse_appendContentAsciiString(aResponse,@"value");
GSWResponse_appendContentCharacter(aResponse,'=');
GSWResponse_appendContentCharacter(aResponse,'"');
if (_tcEscapeHTML
&& GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_tcEscapeHTML,aContext) == NO)
{
GSWResponse_appendContentString(aResponse,valueValue);
}
else
{
GSWResponse_appendContentHTMLAttributeValue(aResponse,valueValue);
};
GSWResponse_appendContentCharacter(aResponse,'"');
};
LOGObjectFnStopC("GSWInput");
};
//--------------------------------------------------------------------
-(void)appendNameToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
//OK
NSString* name=nil;
LOGObjectFnStartC("GSWInput");
name=[self nameInContext:aContext];
NSDebugMLLog(@"gswdync",@"name=%@",name);
if (name)
{
GSWResponse_appendContentCharacter(aResponse,' ');
GSWResponse_appendContentAsciiString(aResponse,@"name");
GSWResponse_appendContentCharacter(aResponse,'=');
GSWResponse_appendContentCharacter(aResponse,'"');
GSWResponse_appendContentHTMLAttributeValue(aResponse,name);
GSWResponse_appendContentCharacter(aResponse,'"');
};
LOGObjectFnStopC("GSWInput");
};
@end
//====================================================================
@implementation GSWInput (GSWInputD)
//--------------------------------------------------------------------
+(BOOL)hasGSWebObjectsAssociations
{
return YES;
};
@end
//====================================================================
@implementation GSWInput (GSWInputE)
//GSWeb additions {
-(void)handleValidationException:(NSException*)exception
inContext:(GSWContext*)aContext
{
BOOL isValidationException=[exception isValidationException];
BOOL raise=YES;
LOGObjectFnStartC("GSWInput");
if (isValidationException)
{
GSWComponent* component=GSWContext_component(aContext);
id handleValidationException=[handleValidationException valueInComponent:component];
BOOL handle=NO;
if (!handleValidationException)
{
handleValidationException = [component handleValidationExceptionDefault];
};
if (handleValidationException)
{
if ([handleValidationException isEqualToString:@"handleAndRaise"])
{
handle=YES;
raise=YES;
}
else if ([handleValidationException isEqualToString:@"handle"])
{
handle=YES;
raise=NO;
}
else if ([handleValidationException isEqualToString:@"raise"])
{
handle=NO;
raise=YES;
}
else
{
NSDebugMLog(@"Unknown case for handleValidationException %@",handleValidationException);
};
};
if (handle)
{
NSDebugMLog(@"Handled validation exception %@",exception);
[component setValidationFailureMessage:[[exception userInfo]objectForKey:@"message"]
forElement:self];
}
else
{
NSDebugMLog(@"Unhandled validation exception %@",exception);
};
};
if (raise)
{
NSDebugMLog(@"Raise exception %@",exception);
exception=ExceptionByAddingUserInfoObjectFrameInfo0(exception,@"handleValidationException:inContext");
[exception raise];
};
LOGObjectFnStopC("GSWInput");
};
// }
@end

View file

@ -67,22 +67,18 @@ RCS_ID("$Id$")
};
//--------------------------------------------------------------------
-(id)valueInComponent:(GSWComponent*)object
// dw
-(id)valueInComponent:(GSWComponent*)component
{
id retValue=nil;
LOGObjectFnStart();
NSDebugMLLog(@"associations",@"self=%@ ",self);
NSDebugMLLog(@"associations",@"keyPath=%@ ",_keyPath);
NSDebugMLLog(@"associations",@"object=%@ ", object);
retValue=[GSWAssociation valueInComponent:object
forKeyPath:_keyPath];
NSDebugMLLog(@"associations",@"self=%@ retValue=%@ (%p) (class=%@)",
self,
retValue,
retValue,
NSStringFromClass([retValue class]));
[self logTakeValue:retValue];
LOGObjectFnStop();
// thats what WO does:
// retValue = [component valueForKeyPath: _keyPath];
// but we need:
retValue=[GSWAssociation valueInComponent: component
forKeyPath:_keyPath];
return retValue;
};
@ -90,13 +86,6 @@ RCS_ID("$Id$")
-(void)setValue:(id)aValue
inComponent:(GSWComponent*)object
{
LOGObjectFnStart();
NSDebugMLLog(@"associations",@"keyPath=%@ ",_keyPath);
NSDebugMLLog(@"associations",@"GSWAssociation: setValue:%@ (self=%@)",aValue,self);
if (aValue)
{
NSDebugMLLog(@"associations",@"value_ class:%@",NSStringFromClass([aValue class]));
}
if ([_keyPath length]==0)
{
[NSException raise:NSInvalidArgumentException
@ -111,8 +100,6 @@ RCS_ID("$Id$")
[GSWAssociation setValue:aValue
inComponent:object
forKeyPath:_keyPath];
[self logSetValue:aValue];
LOGObjectFnStop();
};
//--------------------------------------------------------------------

View file

@ -468,15 +468,14 @@ static __inline__ NSMutableData *_checkBody(GSWMessage *self) {
globalDefaultEncoding = WOStrictFlag ? NSISOLatin1StringEncoding : [NSString defaultCStringEncoding];
initGSWMessageDataCache();
};
};
}
}
//--------------------------------------------------------------------
// init
-(id)init
{
LOGObjectFnStart();
if ((self=[super init]))
{
GetGSWMessageIMPs(&_selfMsgIMPs,self);
@ -485,7 +484,6 @@ static __inline__ NSMutableData *_checkBody(GSWMessage *self) {
_contentEncoding=[[self class] defaultEncoding];
_checkBody(self);
};
LOGObjectFnStop();
return self;
};
@ -643,13 +641,9 @@ static __inline__ NSMutableData *_checkBody(GSWMessage *self) {
NSAssert(headers,@"No headers");
NSAssert(key,@"No header key");
NSDebugMLLog(@"GSWMessage",@"_headers=%@",_headers);
if (!_headers)
_headers=[NSMutableDictionary new];
NSDebugMLLog(@"GSWMessage",@"key=%@ headers=%@",key,headers);
[_headers setObject:headers
forKey:key];
};
@ -677,10 +671,6 @@ static __inline__ NSMutableData *_checkBody(GSWMessage *self) {
-(void)setHeaders:(NSDictionary*)headerDictionary
{
NSDebugMLLog(@"GSWMessage",@"headerDictionary=%@",headerDictionary);
NSDebugMLLog(@"GSWMessage",@"_headers=%@",_headers);
if (!_headers && [headerDictionary count]>0)
_headers=[NSMutableDictionary new];
@ -700,7 +690,6 @@ static __inline__ NSMutableData *_checkBody(GSWMessage *self) {
};
};
NSDebugMLLog(@"GSWMessage",@"_headers=%@",_headers);
};
//--------------------------------------------------------------------
@ -800,20 +789,14 @@ static __inline__ NSMutableData *_checkBody(GSWMessage *self) {
**/
-(void)setContent:(NSData*)contentData
{
LOGObjectFnStart();
DESTROY(_contentData);
GSWMessage_appendContentData(self,contentData);
LOGObjectFnStop();
};
//--------------------------------------------------------------------
// content
-(NSData*)content
{
LOGObjectFnStart();
LOGObjectFnStop();
return _contentData;
};
@ -822,8 +805,6 @@ static __inline__ NSMutableData *_checkBody(GSWMessage *self) {
{
NSString* contentString=nil;
LOGObjectFnStart();
NS_DURING
{
contentString=AUTORELEASE([[NSString alloc] initWithData:_contentData
@ -841,10 +822,6 @@ static __inline__ NSMutableData *_checkBody(GSWMessage *self) {
//--------------------------------------------------------------------
-(void)appendContentData:(NSData*)contentData
{
LOGObjectFnStart();
NSDebugMLLog(@"low",@"contentData:%@",contentData);
if (contentData)
{
_checkBody(self);
@ -859,16 +836,11 @@ static __inline__ NSMutableData *_checkBody(GSWMessage *self) {
};
#endif
};
LOGObjectFnStop();
}
//--------------------------------------------------------------------
- (void)appendContentString:(NSString *)aValue
{
LOGObjectFnStart();
NSDebugMLLog(@"low",@"aValue:%@",aValue);
// checking [aValue length] takes too long!
if (aValue)
@ -896,17 +868,11 @@ static __inline__ NSMutableData *_checkBody(GSWMessage *self) {
};
#endif
};
LOGObjectFnStop();
}
//--------------------------------------------------------------------
-(void)_appendContentAsciiString:(NSString*) aValue
{
LOGObjectFnStart();
NSDebugMLLog(@"low",@"aValue:%@",aValue);
// checking [aValue length] takes too long!
if (aValue)
{
@ -923,37 +889,8 @@ static __inline__ NSMutableData *_checkBody(GSWMessage *self) {
(*_currentCacheDataADImp)(_currentCacheData,appendDataSel,ad);
};
#endif
/*
NSData *myData = nil;
const char *lossyCString = NULL;
int length = 0;
int i = 0;
int ch = 0;
lossyCString = [aValue lossyCString];
length = strlen(lossyCString);
_checkBody(self);
for (i=0; i<length;i++)
{
ch = lossyCString[i];
myData=GSWMessageDataCache[ch];
(*_contentDataADImp)(_contentData,appendDataSel,myData);
#ifndef NO_GNUSTEP
// Caching management
if (_currentCacheData)
{
assertCurrentCacheDataADImp();
(*_currentCacheDataADImp)(_currentCacheData,appendDataSel,myData);
};
#endif
}
*/
};
LOGObjectFnStop();
}
//--------------------------------------------------------------------
@ -964,10 +901,6 @@ static __inline__ NSMutableData *_checkBody(GSWMessage *self) {
NSData *myData = nil;
int i = aChar;
LOGObjectFnStart();
NSDebugMLLog(@"low",@"aChar:%c",aChar);
myData=GSWMessageDataCache[i];
if (!myData)
@ -993,8 +926,6 @@ static __inline__ NSMutableData *_checkBody(GSWMessage *self) {
};
#endif
}
LOGObjectFnStop();
};
//--------------------------------------------------------------------
@ -1016,7 +947,6 @@ static __inline__ NSMutableData *_checkBody(GSWMessage *self) {
-(void)setContentEncoding:(NSStringEncoding)encoding
{
NSDebugMLLog(@"low",@"setContentEncoding:%d",(int)encoding);
_contentEncoding=encoding;
};
@ -1032,7 +962,6 @@ static __inline__ NSMutableData *_checkBody(GSWMessage *self) {
-(void)appendContentBytes:(const void*)bytes
length:(unsigned)length
{
LOGObjectFnStart();
if ((length>0) && (bytes != NULL))
{
[_contentData appendBytes:bytes
@ -1047,7 +976,6 @@ static __inline__ NSMutableData *_checkBody(GSWMessage *self) {
};
#endif
};
LOGObjectFnStop();
};
//--------------------------------------------------------------------
@ -1069,7 +997,6 @@ static __inline__ NSMutableData *_checkBody(GSWMessage *self) {
-(void)replaceContentData:(NSData*)replaceData
byData:(NSData*)byData
{
LOGObjectFnStart();
if ([replaceData length]>0) // is there something to replace ?
{
NSDebugMLog(@"[_contentData length]=%d",[_contentData length]);
@ -1080,7 +1007,6 @@ static __inline__ NSMutableData *_checkBody(GSWMessage *self) {
range:NSMakeRange(0,[_contentData length])];
};
};
LOGObjectFnStop();
};
@end
@ -1094,14 +1020,9 @@ static __inline__ NSMutableData *_checkBody(GSWMessage *self) {
-(void)appendContentHTMLAttributeValue:(NSString*)value
{
LOGObjectFnStart();
NSDebugMLLog(@"low",@"response=%p value=%@",self,value);
GSWMessage_appendContentString(self,
GSWMessage_stringByEscapingHTMLAttributeValue(self,value));
LOGObjectFnStop();
};
//--------------------------------------------------------------------
@ -1109,40 +1030,25 @@ static __inline__ NSMutableData *_checkBody(GSWMessage *self) {
-(void)appendContentHTMLString:(NSString*)aString
{
LOGObjectFnStart();
NSDebugMLLog(@"low",@"aString=%@",aString);
GSWMessage_appendContentString(self,
GSWMessage_stringByEscapingHTMLString(self,aString));
LOGObjectFnStop();
};
//--------------------------------------------------------------------
-(void)appendContentHTMLConvertString:(NSString*)aString
{
LOGObjectFnStart();
NSDebugMLLog(@"low",@"aString=%@",aString);
GSWMessage_appendContentString(self,
GSWMessage_stringByConvertingToHTML(self,aString));
LOGObjectFnStop();
};
//--------------------------------------------------------------------
-(void)appendContentHTMLEntitiesConvertString:(NSString*)aString
{
LOGObjectFnStart();
NSDebugMLLog(@"low",@"aString=%@",aString);
GSWMessage_appendContentString(self,
GSWMessage_stringByConvertingToHTMLEntities(self,aString));
LOGObjectFnStop();
};
//--------------------------------------------------------------------
@ -1194,22 +1100,21 @@ static __inline__ NSMutableData *_checkBody(GSWMessage *self) {
{
//OK
NSMutableArray* cookies=nil;
LOGObjectFnStart();
cookies=[self _initCookies];
if (cookie)
[cookies addObject:cookie];
LOGObjectFnStop();
};
//--------------------------------------------------------------------
-(void)removeCookie:(GSWCookie*)cookie
{
NSMutableArray* cookies=nil;
LOGObjectFnStart();
cookies=[self _initCookies];
if (cookie)
[cookies removeObject:cookie];
LOGObjectFnStop();
};
//--------------------------------------------------------------------
@ -1269,7 +1174,7 @@ static __inline__ NSMutableData *_checkBody(GSWMessage *self) {
if ([cookies count]>0)
{
id cookiesHeadersValues=[self cookiesHeadersValues];
NSDebugMLLog(@"low",@"cookiesHeadersValues=%@",cookiesHeadersValues);
[self setHeaders:cookiesHeadersValues
forKey:cookiesKey];
};
@ -1329,7 +1234,6 @@ static __inline__ NSMutableData *_checkBody(GSWMessage *self) {
-(int)startCache
{
int index=0;
LOGObjectFnStart();
if (!_cachesStack)
{
@ -1343,7 +1247,6 @@ static __inline__ NSMutableData *_checkBody(GSWMessage *self) {
index=[_cachesStack count]-1;
LOGObjectFnStop();
return index;
};
@ -1353,21 +1256,13 @@ static __inline__ NSMutableData *_checkBody(GSWMessage *self) {
NSMutableData* cachedData=nil;
int cacheStackCount=0;
LOGObjectFnStart();
NSDebugMLLog(@"GSWCacheElement",@"cacheIndex=%d",cacheIndex);
cacheStackCount=[_cachesStack count];
NSDebugMLLog(@"GSWCacheElement",@"cacheStackCount=%d",cacheStackCount);
if (cacheIndex<cacheStackCount)
{
cachedData=[_cachesStack objectAtIndex:cacheIndex];
AUTORELEASE(RETAIN(cachedData));
NSDebugMLLog(@"GSWCacheElement",@"cachedData=%@",cachedData);
// Last one ? (normal case)
if (cacheIndex==(cacheStackCount-1))
{
@ -1380,7 +1275,7 @@ static __inline__ NSMutableData *_checkBody(GSWMessage *self) {
while(cacheIndex<cacheStackCount)
{
NSData* tmp=[_cachesStack objectAtIndex:cacheIndex];
NSDebugMLLog(@"GSWCacheElement",@"tmp=%@",tmp);
[cachedData appendData:tmp];
[_cachesStack removeObjectAtIndex:cacheIndex];
};
@ -1404,10 +1299,6 @@ static __inline__ NSMutableData *_checkBody(GSWMessage *self) {
_currentCacheDataADImp=NULL;
};
};
NSDebugMLLog(@"GSWCacheElement",@"cachedData=%@",cachedData);
LOGObjectFnStop();
return cachedData;
}

View file

@ -127,10 +127,6 @@ treatNilValueAsGSWNull:(BOOL)treatNilValueAsGSWNull
//--------------------------------------------------------------------
@end
//====================================================================
@implementation GSWParam (GSWParamA)
-(GSWElement*)invokeActionForRequest:(GSWRequest*)aRequest
inContext:(GSWContext*)aContext
{
@ -154,45 +150,41 @@ treatNilValueAsGSWNull:(BOOL)treatNilValueAsGSWNull
return element;
};
@end
//====================================================================
@implementation GSWParam (GSWParamB)
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
[super appendGSWebObjectsAssociationsToResponse:aResponse
inContext:aContext];
if (_action)
{
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(aResponse,
@"value",
[aContext componentActionURL],
NO);// Don't escape
}
else
{
GSWComponent* component=GSWContext_component(aContext);
id value = [self valueInComponent:component];
if (value)
{
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(aResponse,
@"value",
value,
YES);
}
else if(_treatNilValueAsGSWNull)
{
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(aResponse,
@"value",
@"GSWNull",
NO);
}
else
NSWarnLog(@"GSWParam: nil 'value'");
};
};
//-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)aResponse
// inContext:(GSWContext*)aContext
//{
// [super appendGSWebObjectsAssociationsToResponse:aResponse
// inContext:aContext];
// if (_action)
// {
// GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(aResponse,
// @"value",
// [aContext componentActionURL],
// NO);// Don't escape
// }
// else
// {
// GSWComponent* component=GSWContext_component(aContext);
//
// id value = [self valueInComponent:component];
// if (value)
// {
// GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(aResponse,
// @"value",
// value,
// YES);
// }
// else if(_treatNilValueAsGSWNull)
// {
// GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(aResponse,
// @"value",
// @"GSWNull",
// NO);
// }
// else
// NSWarnLog(@"GSWParam: nil 'value'");
// };
//};
//--------------------------------------------------------------------
-(id)valueInComponent:(GSWComponent*)component
@ -211,10 +203,6 @@ treatNilValueAsGSWNull:(BOOL)treatNilValueAsGSWNull
return value;
};
@end
//====================================================================
@implementation GSWParam (GSWParamC)
//--------------------------------------------------------------------
+(BOOL)escapeHTML

View file

@ -35,9 +35,7 @@
//OK
//====================================================================
@interface GSWPasswordField: GSWInput
-(id)initWithName:(NSString*)name
associations:(NSDictionary*)associations
contentElements:(NSArray*)elements;
@end

View file

@ -35,24 +35,48 @@ RCS_ID("$Id$")
//====================================================================
@implementation GSWPasswordField
-(id)initWithName:(NSString*)aName
associations:(NSDictionary*)associations
contentElements:(NSArray*)elements
template:(GSWElement*)template
{
NSMutableDictionary* tmpAssociations=[NSMutableDictionary dictionaryWithDictionary:associations];
LOGObjectFnStartC("GSWPasswordField");
NSDebugMLLog(@"gswdync",@"aName=%@ associations:%@ elements=%@",
aName,associations,elements);
[tmpAssociations setObject:[GSWAssociation associationWithValue:@"password"]
forKey:@"type"];
if ((self=[super initWithName:aName
associations:tmpAssociations
contentElements:nil])) //No Childs!
{
};
LOGObjectFnStopC("GSWPasswordField");
return self;
};
self = [super initWithName:@"input" associations:associations template: template];
if (!self) {
return nil;
}
if ((_value == nil) || (![_value isValueSettable])) {
[NSException raise:NSInvalidArgumentException
format:@"%s: 'value' attribute not present or is a constant",
__PRETTY_FUNCTION__];
}
return self;
}
- (NSString*) type
{
return @"password";
}
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context
{
GSWComponent * component = GSWContext_component(context);
if ((![self disabledInComponent: component]) && ([context _wasFormSubmitted])) {
NSString * nameCtx = [self nameInContext:context];
if (nameCtx != nil) {
NSString* value = [request stringFormValueForKey: nameCtx];
[_value setValue: value
inComponent:component];
}
}
}
-(void) _appendCloseTagToResponse:(GSWResponse *) response
inContext:(GSWContext*) context
{
}
//--------------------------------------------------------------------
@end

View file

@ -35,53 +35,23 @@
@interface GSWPopUpButton: GSWInput
{
GSWAssociation* _list;
GSWAssociation* _item;
GSWAssociation* _displayString;
GSWAssociation* _selection;
//GSWeb Additions {
GSWAssociation* _selectionValue;
// }
GSWAssociation* _selectedValue;
GSWAssociation* _noSelectionString;
GSWAssociation* _escapeHTML;
//GSWeb Additions {
GSWAssociation* _count;
GSWAssociation* _index;
// }
GSWAssociation * _list;
GSWAssociation * _item;
GSWAssociation * _string;
GSWAssociation * _selection;
GSWAssociation * _selectedValue;
GSWAssociation * _noSelectionString;
BOOL _loggedSlow;
};
-(void)dealloc;
-(id)initWithName:(NSString*)name
associations:(NSDictionary*)associations
contentElements:(NSArray*)elements;
-(NSString*)description;
-(NSString*)elementName;
@end
@interface GSWPopUpButton (GSWPopUpButtonA)
-(void)appendToResponse:(GSWResponse*)response
inContext:(GSWContext*)context;
-(void)appendValueToResponse:(GSWResponse*)response
inContext:(GSWContext*)context;
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context;
-(void)_fastTakeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context;
-(void)_slowTakeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context;
@end
@interface GSWPopUpButton (GSWPopUpButtonB)
-(BOOL)appendStringAtRight:(id)unkwnon
withMapping:(char*)mapping;
@end
#endif //_GSWPopUpButton_h__

View file

@ -86,607 +86,296 @@ static SEL valueInComponentSEL = NULL;
//--------------------------------------------------------------------
-(id)initWithName:(NSString*)aName
associations:(NSDictionary*)associations
contentElements:(NSArray*)elements
{
//OK
NSMutableDictionary* tmpAssociations=nil;
LOGObjectFnStartC("GSWPopUpButton");
NSDebugMLLog(@"gswdync",@"aName=%@ associations:%@ _elements=%@",
aName,associations,elements);
tmpAssociations=[NSMutableDictionary dictionaryWithDictionary:associations];
[tmpAssociations removeObjectForKey:list__Key];
[tmpAssociations removeObjectForKey:item__Key];
if (!WOStrictFlag)
{
[tmpAssociations removeObjectForKey:count__Key];
[tmpAssociations removeObjectForKey:index__Key];
};
[tmpAssociations removeObjectForKey:displayString__Key];
[tmpAssociations removeObjectForKey:selection__Key];
if (!WOStrictFlag)
[tmpAssociations removeObjectForKey:selectionValue__Key];
[tmpAssociations removeObjectForKey:selectedValue__Key];
[tmpAssociations removeObjectForKey:noSelectionString__Key];
[tmpAssociations removeObjectForKey:escapeHTML__Key];
template:(GSWElement*)template
{
self = [super initWithName:@"select" associations:associations template: template];
if (!self) {
return nil;
}
if ((self=[super initWithName:aName
associations:tmpAssociations
contentElements:nil]))
{
_list=[[associations objectForKey:list__Key
withDefaultObject:[_list autorelease]] retain];
_item=[[associations objectForKey:item__Key
withDefaultObject:[_item autorelease]] retain];
_displayString=[[associations objectForKey:displayString__Key
withDefaultObject:[_displayString autorelease]] retain];
_selection=[[associations objectForKey:selection__Key
withDefaultObject:[_selection autorelease]] retain];
if (_selection && ![_selection isValueSettable])
{
ExceptionRaise0(@"GSWPopUpButton",@"'selection' parameter must be settable");
};
if (!WOStrictFlag)
{
_selectionValue=[[associations objectForKey:selectionValue__Key
withDefaultObject:[_selectionValue autorelease]] retain];
if (_selectionValue && ![_selectionValue isValueSettable])
{
ExceptionRaise0(@"GSWPopUpButton",@"'selectionValue' parameter must be settable");
};
};
_selectedValue=[[associations objectForKey:selectedValue__Key
withDefaultObject:[_selectedValue autorelease]] retain];
_noSelectionString=[[associations objectForKey:noSelectionString__Key
withDefaultObject:[_noSelectionString autorelease]] retain];
_escapeHTML=[[associations objectForKey:escapeHTML__Key
withDefaultObject:[_escapeHTML autorelease]] retain];
_loggedSlow = NO;
if (!WOStrictFlag)
{
_count=[[associations objectForKey:count__Key
withDefaultObject:[_count autorelease]] retain];
NSDebugMLLog(@"gswdync",@"count=%@",_count);
_index=[[associations objectForKey:index__Key
withDefaultObject:[_index autorelease]] retain];
NSDebugMLLog(@"gswdync",@"index=%@",_index);
if (_index && ![_index isValueSettable])
{
ExceptionRaise0(@"GSWPopUpButton",@"'index' parameter must be settable");
};
};
};
LOGObjectFnStopC("GSWPopUpButton");
ASSIGN(_list, [_associations objectForKey: list__Key]);
if (_list != nil) {
[_associations removeObjectForKey: list__Key];
}
ASSIGN(_item, [_associations objectForKey: item__Key]);
if (_item != nil) {
[_associations removeObjectForKey: item__Key];
}
ASSIGN(_string, [_associations objectForKey: displayString__Key]);
if (_string != nil) {
[_associations removeObjectForKey: displayString__Key];
}
ASSIGN(_selection, [_associations objectForKey: selection__Key]);
if (_selection != nil) {
[_associations removeObjectForKey: selection__Key];
}
ASSIGN(_noSelectionString, [_associations objectForKey: noSelectionString__Key]);
if (_noSelectionString != nil) {
[_associations removeObjectForKey: noSelectionString__Key];
}
ASSIGN(_selectedValue, [_associations objectForKey: selectedValue__Key]);
if (_selectedValue != nil) {
[_associations removeObjectForKey:selectedValue__Key];
}
if ((_list == nil) || (_value != nil || _string != nil) && ((_item == nil) || (![_item isValueSettable])) ||
(_selection != nil) && (![_selection isValueSettable])) {
[NSException raise:NSInvalidArgumentException
format:@"%s: 'list' must be present. 'item' must not be a constant if 'value' is present. Cannot have 'displayString' or 'value' without 'item'. 'selection' must not be a constant if present.",
__PRETTY_FUNCTION__];
}
if ((_selection != nil) && (_selectedValue != nil)) {
[NSException raise:NSInvalidArgumentException
format:@"%s: Cannot have both selections and selectedValues.",
__PRETTY_FUNCTION__];
}
return self;
};
//--------------------------------------------------------------------
-(void)dealloc
}
-(void) dealloc
{
DESTROY(_list);
DESTROY(_item);
DESTROY(_displayString);
DESTROY(_string);
DESTROY(_selection);
DESTROY(_selectionValue);//GSWeb Only
DESTROY(_selectedValue);
DESTROY(_noSelectionString);
DESTROY(_escapeHTML);
DESTROY(_count);//GSWeb Only
DESTROY(_index);//GSWeb Only
[super dealloc];
};
//--------------------------------------------------------------------
-(NSString*)elementName
}
-(id) description
{
return @"SELECT";
};
//--------------------------------------------------------------------
-(NSString*)description
{
return [NSString stringWithFormat:@"<%s %p>",
return [NSString stringWithFormat:@"<%s %p list:%@ item:%@ string:%@ selections:%@ selectedValue:%@ NoSelectionString:%@ >",
object_get_class_name(self),
(void*)self];
(void*)self,
_list, _item, _string, _selection, _selectedValue, _noSelectionString];
};
@end
//====================================================================
/*
On WO it looks like that when value is not binded:
<SELECT name="4.2.7">
<OPTION value="0">blau</OPTION>
<OPTION value="1">braun</OPTION>
<OPTION selected value="2">gruen</OPTION>
<OPTION value="3">marineblau</OPTION>
<OPTION value="4">schwarz</OPTION>
<OPTION value="5">silber</OPTION>
<OPTION value="6">weiss</OPTION></SELECT>
*/
@implementation GSWPopUpButton (GSWPopUpButtonA)
//#define ENABLE_OPTGROUP
//--------------------------------------------------------------------
-(void)appendToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
- (void)_slowTakeValuesFromRequest:(GSWRequest*) request
inContext:(GSWContext*) context
{
//OK
GSWRequest* request=nil;
BOOL isFromClientComponent=NO;
GSWComponent* component=nil;
NSArray* listValue=nil;
id selectionValue=nil;
id selectedValueValue=nil;
id valueValue=nil;
id itemValue=nil;
id displayStringValue=nil;
BOOL escapeHTMLBoolValue=YES;
id escapeHTMLValue=nil;
int i=0;
BOOL inOptGroup=NO;
#ifndef ENABLE_OPTGROUP
BOOL optGroupLabel=NO;
#endif
int countValue=0;
LOGObjectFnStartC("GSWPopUpButton");
GSWStartElement(aContext);
GSWSaveAppendToResponseElementID(aContext);
request=[aContext request];
isFromClientComponent=[request isFromClientComponent];
component=GSWContext_component(aContext);
[super appendToResponse:aResponse
inContext:aContext];
NSDebugMLLog(@"gswdync",@"_list=%@",_list);
if (_list)
{
listValue=[_list valueInComponent:component];
NSDebugMLLog(@"gswdync",@"listValue=%@",listValue);
NSAssert3(!listValue || [listValue respondsToSelector:@selector(count)],
@"The list (%@) (%@ of class:%@) doesn't respond to 'count'",
_list,
listValue,
[listValue class]);
countValue=[listValue count];
};
NSDebugMLLog(@"gswdync",@"_count=%@",_count);
if (_count)
{
id tmpCountValue=[_count valueInComponent:component];
int tmpCount=0;
NSAssert3(!tmpCountValue || [tmpCountValue respondsToSelector:@selector(intValue)],
@"The 'count' (%@) value %@ (of class:%@) doesn't respond to 'intValue'",
_count,
tmpCountValue,
[tmpCountValue class]);
tmpCount=[tmpCountValue intValue];
NSDebugMLog(@"tmpCount=%d",tmpCount);
if (_list)
countValue=min(tmpCount,countValue);
else
countValue=tmpCount;
GSWComponent * component = GSWContext_component(context);
if ((_selection != nil) && (![self disabledInComponent:component]) && ([context _wasFormSubmitted])) {
id obj = nil;
id itemValue = nil;
id valueValue = nil;
NSString * ctxName = [self nameInContext:context];
NSString * formValue = [request stringFormValueForKey: ctxName];
if (formValue != nil && (![formValue isEqual:@"WONoSelectionString"])) {
id compoValue = [_list valueInComponent:component];
if (compoValue != nil) {
if ([compoValue isKindOfClass:[NSArray class]]) {
NSArray * valueArray = (NSArray*)compoValue;
int i = [valueArray count];
int k = 0;
while (YES) {
if (k >= i) {
break;
}
itemValue = [valueArray objectAtIndex:k];
[_item setValue: itemValue inComponent:component]; // ???
valueValue = [_value valueInComponent:component];
if (valueValue != nil) {
if ([formValue isEqual:valueValue]) { // stringValue?
obj = itemValue;
break;
}
} else {
NSLog(@"%s:'value' evaluated to nil in component '%@'.\nUnable to select item '%@'",
__PRETTY_FUNCTION__,
component,
itemValue);
}
k++;
}
} else {
[NSException raise:NSInvalidArgumentException
format:@"%s: Evaluating 'list' binding returned a '%@' class and not a NSArray.",
__PRETTY_FUNCTION__, [compoValue class]];
}
}
}
selectionValue=[_selection valueInComponent:component];
NSDebugMLLog(@"gswdync",@"selection=%@",_selection);
NSDebugMLLog(@"gswdync",@"selectionValue=%@",selectionValue);
selectedValueValue=[_selectedValue valueInComponent:component];
NSDebugMLLog(@"gswdync",@"selectedValue=%@",_selectedValue);
NSDebugMLLog(@"gswdync",@"selectedValueValue=%@",selectedValueValue);
[_selection setValue:obj inComponent: component];
}
}
if (_escapeHTML)
{
escapeHTMLValue=[_escapeHTML valueInComponent:component];
escapeHTMLBoolValue=boolValueFor(escapeHTMLValue);
};
if (_noSelectionString)
{
id noSelectionStringValue=nil;
noSelectionStringValue=[_noSelectionString valueInComponent:component];
if (noSelectionStringValue)
{
GSWResponse_appendContentAsciiString(aResponse,@"\n<OPTION");
if (_selectedValue && !selectedValueValue)
GSWResponse_appendContentAsciiString(aResponse,@" selected value=\"\">");
else
GSWResponse_appendContentAsciiString(aResponse,@" value=\"\">");
if (escapeHTMLBoolValue)
noSelectionStringValue=GSWResponse_stringByEscapingHTMLString(aResponse,noSelectionStringValue);
GSWResponse_appendContentString(aResponse,noSelectionStringValue);
//GSWResponse_appendContentHTMLString(aResponse,_noSelectionStringValue];
// There is no close tag on OPTION
//GSWResponse_appendContentAsciiString(aResponse,@"</OPTION>"];
};
};
NSDebugMLLog(@"gswdync",@"countValue=%d",countValue);
if (countValue>0)
{
IMP listOAIIMP=[listValue methodForSelector:objectAtIndexSEL];
IMP itemSetValueIMP=[_item methodForSelector:setValueInComponentSEL];
IMP indexSetValueIMP=[_index methodForSelector:setValueInComponentSEL];
IMP valueValueIMP=[_value methodForSelector:valueInComponentSEL];
IMP displayStringValueIMP=[_displayString methodForSelector:valueInComponentSEL];
for(i=0;i<countValue;i++)
{
NSDebugMLLog(@"gswdync",@"inOptGroup=%s",(inOptGroup ? "YES" : "NO"));
if (listValue)
itemValue=(*listOAIIMP)(listValue,objectAtIndexSEL,i);
else
itemValue=GSWIntNumber(i);
if (_item)
(*itemSetValueIMP)(_item,setValueInComponentSEL,
itemValue,component);
if (_index)
(*indexSetValueIMP)(_index,setValueInComponentSEL,
GSWIntNumber(i),component);
NSDebugMLLog(@"gswdync",@"itemValue=%@",itemValue);
if (itemValue)
{
NSDebugMLLog(@"gswdync",@"_value (class: %@): %@",[_value class],_value);
// Value property of the INPUT tag
if (_value) // Binded Value
valueValue = (*valueValueIMP)(_value,valueInComponentSEL,component);
else // Auto Value
valueValue = GSWIntToNSString(i);
NSDebugMLLog(@"gswdync",@"valueValue=%@",valueValue);
if (valueValue)
{
BOOL isEqual=NO;
NSDebugMLLog0(@"gswdync",@"Adding OPTION");
GSWResponse_appendContentAsciiString(aResponse,@"\n<OPTION");
NSDebugMLLog(@"gswdync",@"selectionValue=%@",selectionValue);
NSDebugMLLog(@"gswdync",@"selectionValue=%@",selectionValue);
NSDebugMLLog(@"gswdync",@"selectionValue class=%@",[selectionValue class]);
NSDebugMLLog(@"gswdync",@"itemValue=%@",itemValue);
NSDebugMLLog(@"gswdync",@"itemValue class=%@",[itemValue class]);
if (selectionValue)
{
isEqual=SBIsValueEqual(itemValue,selectionValue);
NSDebugMLLog(@"gswdync",@"isEqual=%s",(isEqual ? "YES" : "NO"));
if (isEqual)
{
GSWResponse_appendContentAsciiString(aResponse,@" selected");
};
};
if (isEqual == NO && _selectedValue)
{
NSDebugMLLog(@"gswdync",@"selectedValueValue [%@]=%@",
[selectedValueValue class],selectedValueValue);
NSDebugMLLog(@"gswdync",@"valueValue [%@]=%@",
[valueValue class],valueValue);
// selected values is selections but on valueValue not itemValue
isEqual=SBIsValueEqual(valueValue,selectedValueValue);
NSDebugMLLog(@"gswdync",@"isEqual=%s",(isEqual ? "YES" : "NO"));
if (isEqual)
{
GSWResponse_appendContentCharacter(aResponse,' ');
GSWResponse_appendContentAsciiString(aResponse,@"selected");
};
};
GSWResponse_appendContentAsciiString(aResponse,@" value=\"");
GSWResponse_appendContentHTMLAttributeValue(aResponse,valueValue);
GSWResponse_appendContentCharacter(aResponse,'"');
GSWResponse_appendContentCharacter(aResponse,'>');
};
displayStringValue=nil;
if (_displayString)
{
NSDebugMLLog(@"gswdync",@"displayString=%@",_displayString);
displayStringValue=(*displayStringValueIMP)(_displayString,
valueInComponentSEL,component);
NSDebugMLLog(@"gswdync",@"displayStringValue=%@",displayStringValue);
}
else
{
displayStringValue = itemValue;
}
if (displayStringValue)
{
if (!valueValue)
{
if (inOptGroup)
{
NSDebugMLLog0(@"gswdync",@"Adding /OPTGROUP");
#ifdef ENABLE_OPTGROUP
GSWResponse_appendContentAsciiString(aResponse,@"\n</OPTGROUP>");
#endif
inOptGroup=NO;
};
NSDebugMLLog0(@"gswdync",@"Adding OPTGROUP");
#ifdef ENABLE_OPTGROUP
GSWResponse_appendContentAsciiString(aResponse,@"\n<OPTGROUP label=\"");
#else
#if 0
GSWResponse_appendContentAsciiString(aResponse,@"\n<OPTION>-- ");
optGroupLabel=YES;
#else
GSWResponse_appendContentAsciiString(aResponse,@"\n<OPTION>");
#endif
optGroupLabel=YES;
#endif
inOptGroup=YES;
};
//<OPTGROUP label="PortMaster 3">
if (escapeHTMLBoolValue)
displayStringValue=GSWResponse_stringByEscapingHTMLString(aResponse,displayStringValue);
NSDebugMLLog(@"gswdync",@"displayStringValue=%@",displayStringValue);
#ifndef ENABLE_OPTGROUP
if (optGroupLabel)
{
displayStringValue=NSStringWithObject(displayStringValue);
displayStringValue=[displayStringValue stringByAppendingString:@" --"];
};
#endif
GSWResponse_appendContentString(aResponse,displayStringValue);
//GSWResponse_appendContentHTMLString(aResponse,_displayStringValue);
};
if (valueValue)
{
// K2- No /OPTION TAG
//GSWResponse_appendContentAsciiString(aResponse,@"</OPTION>");
}
else
{
NSDebugMLLog0(@"gswdync",@"Adding > or </OPTION>");
#ifdef ENABLE_OPTGROUP
GSWResponse_appendContentAsciiString(aResponse,@"\">"];
#else
if (optGroupLabel)
{
//GSWResponse_appendContentAsciiString(aResponse,@"</OPTION>");
optGroupLabel=NO;
};
#endif
};
};
};
};
if (inOptGroup)
{
#ifdef ENABLE_OPTGROUP
NSDebugMLLog0(@"gswdync",@"Adding /OPTGROUP");
GSWResponse_appendContentAsciiString(aResponse,@"\n</OPTGROUP>");
#endif
inOptGroup=NO;
};
GSWResponse_appendContentAsciiString(aResponse,@"</SELECT>");
GSWStopElement(aContext);
GSWAssertIsElementID(aContext);
LOGObjectFnStopC("GSWPopUpButton");
};
//--------------------------------------------------------------------
-(void)appendValueToResponse:(GSWResponse*)response
inContext:(GSWContext*)aContext
- (void) _fastTakeValuesFromRequest:(GSWRequest*) request
inContext:(GSWContext*) context
{
//Does nothing because value is only printed in OPTION tag
};
GSWComponent * component = GSWContext_component(context);
if ((_selection != nil) && (![self disabledInComponent:component]) && ([context _wasFormSubmitted])) {
id obj = nil;
NSString * ctxName = [self nameInContext:context];
NSString * formValue = [request stringFormValueForKey: ctxName];
if (formValue != nil) {
formValue = [formValue stringByTrimmingSpaces];
if (![formValue isEqual:@"WONoSelectionString"]) {
int i = [formValue intValue];
id compoValue = [_list valueInComponent:component];
if (compoValue != nil) {
if ([compoValue isKindOfClass:[NSArray class]]) {
NSArray * valueArray = compoValue;
if ((i < [valueArray count]) && (i >= 0)) {
obj = [valueArray objectAtIndex:i];
}
} else {
[NSException raise:NSInvalidArgumentException
format:@"%s: Evaluating 'list' binding returned a '%@' class and not a NSArray.",
__PRETTY_FUNCTION__, [compoValue class]];
}
}
}
}
[_selection setValue:obj inComponent: component];
}
}
//--------------------------------------------------------------------
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)aContext
inContext:(GSWContext*)context
{
//OK
LOGObjectFnStartC("GSWPopUpButton");
GSWStartElement(aContext);
GSWAssertCorrectElementID(aContext);
[self _slowTakeValuesFromRequest:request
inContext:aContext];
GSWAssertIsElementID(aContext);
GSWStopElement(aContext);
LOGObjectFnStopC("GSWPopUpButton");
};
if (_value != nil) {
if (!_loggedSlow) {
NSLog(@"%s Warning: Avoid using the 'value' binding as it is much slower than omitting it, and it is just cosmetic.",
__PRETTY_FUNCTION__);
_loggedSlow = YES;
}
[self _slowTakeValuesFromRequest:request inContext:context];
} else {
[self _fastTakeValuesFromRequest:request inContext:context];
}
}
//--------------------------------------------------------------------
-(void)_fastTakeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)aContext
-(void) _appendValueAttributeToResponse:(GSWResponse *) response
inContext:(GSWContext*) context
{
LOGObjectFnNotImplemented(); //TODOFN
};
}
//--------------------------------------------------------------------
-(void)_slowTakeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)aContext
-(void) appendChildrenToResponse:(GSWResponse *) response
inContext:(GSWContext*) context
{
//OK
BOOL disabledValue=NO;
BOOL wasFormSubmitted=NO;
LOGObjectFnStartC("GSWPopUpButton");
GSWStartElement(aContext);
GSWAssertCorrectElementID(aContext);
disabledValue=[self disabledInContext:aContext];
if (!disabledValue)
{
wasFormSubmitted=[aContext _wasFormSubmitted];
if (wasFormSubmitted)
{
GSWComponent* component=nil;
NSArray* listValue=nil;
id valueValue=nil;
NSString* valueValueString=nil;
id itemValue=nil;
NSString* name=nil;
NSArray* formValues=nil;
id formValue=nil;
BOOL found=NO;
int i=0;
int countValue=0;
id itemValueToSet=nil; // Object from list found (==> _selection)
id valueValueToSet=nil; // Value Found (==> _selectionValue)
NSArray * valueArray = nil;
int j = 0;
id obj = nil;
BOOL isSelected = NO;
id compoValue = nil;
int i = 0;
NSString * valueValue = nil;
NSString * s1 = nil;
id arrayObj = nil;
GSWComponent * component = GSWContext_component(context);
BOOL doEscape = YES;
if (_escapeHTML != nil) {
doEscape = [_escapeHTML boolValueInComponent:component];
}
compoValue = [_list valueInComponent:component];
if (compoValue != nil) {
if ([compoValue isKindOfClass:[NSArray class]]) {
valueArray = compoValue;
j = [valueArray count];
} else {
[NSException raise:NSInvalidArgumentException
format:@"%s: Evaluating 'list' binding returned a '%@' class and not a NSArray.",
__PRETTY_FUNCTION__, [compoValue class]];
}
}
if (_noSelectionString != nil) {
id noSelectionValue = [_noSelectionString valueInComponent:component];
if (noSelectionValue != nil) {
GSWResponse_appendContentAsciiString(response,@"\n<option value=\"WONoSelectionString\">");
// wo seems to NOT do it right here. They escape always.
if (doEscape) {
GSWResponse_appendContentHTMLConvertString(response, [noSelectionValue description]);
} else {
GSWResponse_appendContentString(response, [noSelectionValue description]);
}
GSWResponse_appendContentAsciiString(response, @"</option>");
} else {
[NSException raise:NSInvalidArgumentException
format:@"%s: 'noSelectionString' evaluated to nil in component '%@'. Did not insert a WONoSelectionString.",
__PRETTY_FUNCTION__, component];
}
}
if (_selection != nil) {
obj = [_selection valueInComponent:component];
} else {
if (_selectedValue != nil) {
compoValue = [_selectedValue valueInComponent:component];
}
}
for (i = 0; i < j; i++) {
valueValue = nil;
s1 = nil;
arrayObj = nil;
if (valueArray != nil) {
arrayObj = [valueArray objectAtIndex:i];
}
if ((_string != nil) || (_value != nil)) {
[_item setValue:arrayObj inComponent:component];
if (_string != nil) {
id obj5 = [_string valueInComponent:component];
if (obj5 != nil) {
s1 = obj5; // stringValue??
if (_value != nil) {
id obj7 = [_value valueInComponent:component];
if (obj7 != nil) {
valueValue = obj7; // stringValue?
}
} else {
valueValue = s1;
}
}
} else {
id obj6 = [_value valueInComponent:component];
if (obj6 != nil) {
valueValue = obj6; // stringValue?
s1 = valueValue;
}
}
} else {
s1 = arrayObj; // stringValue?
valueValue = s1;
}
GSWResponse_appendContentAsciiString(response,@"\n<option");
if (_selection != nil) {
isSelected = (obj == nil) ? NO : [obj isEqual:arrayObj];
} else {
if (_selectedValue != nil) {
if (_value != nil) {
isSelected = compoValue == nil ? NO : [compoValue isEqual: valueValue];
} else {
isSelected = [GSWIntToNSString(i) isEqual:compoValue];
}
}
}
if (isSelected) {
GSWResponse_appendContentCharacter(response,' ');
GSWResponse_appendContentAsciiString(response,@"selected");
}
if (_value != nil) {
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response, value__Key, valueValue, YES);
} else {
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response, value__Key, GSWIntToNSString(i), NO);
}
GSWResponse_appendContentCharacter(response,'>');
if (doEscape) {
GSWResponse_appendContentHTMLConvertString(response, s1);
} else {
GSWResponse_appendContentString(response, s1);
}
GSWResponse_appendContentAsciiString(response,@"</option>");
}
component=GSWContext_component(aContext);
name=[self nameInContext:aContext];
NSDebugMLLog(@"gswdync",@"name=%@",name);
formValues=[request formValuesForKey:name];
NSDebugMLLog(@"gswdync",@"formValues=%@",formValues);
if (formValues && [formValues count]>0)
{
formValue=[formValues objectAtIndex:0];
NSDebugMLLog(@"gswdync",@"formValue=%@",formValue);
if (_list)
{
listValue=[_list valueInComponent:component];
NSAssert3(!listValue || [listValue respondsToSelector:@selector(count)],
@"The list (%@) (%@ of class:%@) doesn't respond to 'count'",
_list,
listValue,
[listValue class]);
countValue=[listValue count];
}
if (_count)
{
id tmpCountValue=[_count valueInComponent:component];
int tmpCount=0;
NSAssert3(!tmpCountValue || [tmpCountValue respondsToSelector:@selector(intValue)],
@"The 'count' (%@) value %@ (of class:%@) doesn't respond to 'intValue'",
_count,
tmpCountValue,
[tmpCountValue class]);
tmpCount=[tmpCountValue intValue];
NSDebugMLog(@"tmpCount=%d",tmpCount);
if (_list)
countValue=min(tmpCount,countValue);
else
countValue=tmpCount;
}
if (countValue>0)
{
IMP listOAIIMP=[listValue methodForSelector:objectAtIndexSEL];
IMP itemSetValueIMP=[_item methodForSelector:setValueInComponentSEL];
IMP indexSetValueIMP=[_index methodForSelector:setValueInComponentSEL];
IMP valueValueIMP=[_value methodForSelector:valueInComponentSEL];
for(i=0;!found && i<countValue;i++)
{
if (listValue)
itemValue=(*listOAIIMP)(listValue,objectAtIndexSEL,i);
else
itemValue=GSWIntNumber(i);
NSDebugMLLog(@"gswdync",@"_itemValue=%@",itemValue);
NSDebugMLLog(@"gswdync",@"_item=%@",_item);
if (_item)
(*itemSetValueIMP)(_item,setValueInComponentSEL,itemValue,component);
if (_index)
(*indexSetValueIMP)(_index,setValueInComponentSEL,GSWIntNumber(i),component);
NSDebugMLLog(@"gswdync",@"value=%@",_value);
if (_value) // Binded Value
{
valueValue = (*valueValueIMP)(_value,valueInComponentSEL,component);
valueValueString=NSStringWithObject(valueValue);
}
else // Auto Value
{
valueValue=GSWIntNumber(i);
valueValueString=GSWIntToNSString(i);
};
NSDebugMLLog(@"gswdync",@"valueValue=%@",valueValue);
if (valueValue)
{
// we compare (with object equality not pointer equality)
found=[formValues containsObject:valueValueString];
if (found)
{
itemValueToSet=itemValue;
valueValueToSet=valueValue;
}
};
};
};
};
if (_selection)
{
NS_DURING
{
NSDebugMLLog(@"gswdync",@"itemValue=%@",itemValue);
[_selection setValue:itemValueToSet
inComponent:component];
}
NS_HANDLER
{
LOGException(@"GSWPopUpButton _selection=%@ itemValueToSet=%@ exception=%@",
_selection,itemValueToSet,localException);
if (WOStrictFlag)
{
[localException raise];
}
else
{
[self handleValidationException:localException
inContext:aContext];
};
}
NS_ENDHANDLER;
};
NSDebugMLLog(@"gswdync",@"selectionValue=%@",_selectionValue);
if (!WOStrictFlag && _selectionValue)
{
NS_DURING
{
[_selectionValue setValue:valueValueToSet
inComponent:component];
}
NS_HANDLER
{
LOGException(@"GSWPopUpButton _selectionValue=%@ valueValueToSet=%@ exception=%@",
_selectionValue,valueValue,localException);
[self handleValidationException:localException
inContext:aContext];
}
NS_ENDHANDLER;
};
};
};
GSWStopElement(aContext);
GSWAssertIsElementID(aContext);
LOGObjectFnStopC("GSWPopUpButton");
};
}
@end
//====================================================================
@implementation GSWPopUpButton (GSWPopUpButtonB)
-(BOOL)appendStringAtRight:(id)unkwnon
withMapping:(char*)mapping
{
LOGObjectFnNotImplemented(); //TODOFN
return NO;
};
@end

View file

@ -45,5 +45,34 @@ static inline void GSWeb_appendStringWithImpPtr(NSMutableString* object,IMP* imp
};
};
@interface GSWComponentDefinition (PrivateDeclarations)
- (void) _checkInComponentInstance:(GSWComponent*) component;
- (void) finishInitializingComponent:(GSWComponent*)component;
- (void) _clearCache;
@end
@interface GSWApplication (PrivateDeclarations)
-(GSWComponentDefinition*) _componentDefinitionWithName:(NSString*)aName
languages:(NSArray*)languages;
@end
@interface GSWAssociation (PrivateDeclarations)
- (BOOL)_hasBindingInParent:(GSWComponent*) parent;
@end
@interface GSWInput (PrivateDeclarations)
- (void) _appendNameAttributeToResponse:(GSWResponse *) response
inContext:(GSWContext*)context;
@end
#endif // _GSWPrivate_h__

View file

@ -37,26 +37,8 @@
{
GSWAssociation* _checked;
GSWAssociation* _selection;
};
}
-(id)initWithName:(NSString*)name
associations:(NSDictionary*)associations
contentElements:(NSArray*)elements;
-(void)dealloc;
-(NSString*)description;
@end
//====================================================================
@interface GSWRadioButton (GSWRadioButtonA)
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)response
inContext:(GSWContext*)context;
@end
//====================================================================
@interface GSWRadioButton (GSWRadioButtonB)
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context;
@end

View file

@ -67,223 +67,142 @@ static Class standardClass = Nil;
};
};
//--------------------------------------------------------------------
-(id)initWithName:(NSString*)aName
associations:(NSDictionary*)associations
contentElements:(NSArray*)elements
template:(GSWElement*)template
{
NSMutableDictionary* tmpAssociations=[NSMutableDictionary dictionaryWithDictionary:associations];
LOGObjectFnStart();
NSDebugMLLog(@"gswdync",@"aName=%@ associations:%@ _elements=%@",
aName,associations,elements);
[tmpAssociations setObject:[GSWAssociation associationWithValue:@"radio"]
forKey:@"type"];
[tmpAssociations removeObjectForKey:selection__Key];
[tmpAssociations removeObjectForKey:checked__Key];
if ((self=[super initWithName:aName
associations:tmpAssociations
contentElements:nil]))
{
_selection=[[associations objectForKey:selection__Key
withDefaultObject:[_selection autorelease]] retain];
if (_selection && ![_selection isValueSettable])
{
ExceptionRaise0(@"GSWRadioButton",@"'selection' parameter must be settable");
};
self = [super initWithName:@"input" associations:associations template: template];
if (!self) {
return nil;
}
_checked=[[associations objectForKey:checked__Key
withDefaultObject:[_checked autorelease]] retain];
if (_checked && ![_checked isValueSettable])
{
ExceptionRaise0(@"GSWRadioButton",@"'checked' parameter must be settable");
};
if (!_checked)
{
if (!_value || !_selection)
{
ExceptionRaise0(@"GSWRadioButton",
@"if you don't specify 'checked' parameter, you have to specify 'value' and 'selection' parameter");
};
};
};
if ((_value != nil) && (![_value isValueSettable])) {
[NSException raise:NSInvalidArgumentException
format:@"%s: 'value' attribute is a constant",
__PRETTY_FUNCTION__];
}
ASSIGN(_selection, [_associations objectForKey: selection__Key]);
if (_selection != nil) {
[_associations removeObjectForKey: selection__Key];
}
if (_selection && ![_selection isValueSettable]) {
ExceptionRaise0(@"GSWRadioButton",@"'selection' parameter must be settable");
}
ASSIGN(_checked, [_associations objectForKey: checked__Key]);
if (_checked != nil) {
[_associations removeObjectForKey: checked__Key];
}
if (_checked && ![_checked isValueSettable]) {
ExceptionRaise0(@"GSWRadioButton",@"'checked' parameter must be settable");
};
if ((!_checked) && ((!_value) && (!_selection)))
{
ExceptionRaise0(@"GSWRadioButton",
@"if you don't specify 'checked' parameter, you have to specify 'value' and 'selection' parameter");
}
return self;
};
}
// [tmpAssociations removeObjectForKey:selection__Key];
// [tmpAssociations removeObjectForKey:checked__Key];
//--------------------------------------------------------------------
-(void)dealloc
{
DESTROY(_checked);
DESTROY(_selection);
[super dealloc];
};
}
//--------------------------------------------------------------------
-(NSString*)description
-(id) description
{
return [NSString stringWithFormat:@"<%s %p>",
return [NSString stringWithFormat:@"<%s %p checked:%@ selection:%@ disabled:%@ name:%@ value:%@>",
object_get_class_name(self),
(void*)self];
(void*)self,
_checked, _selection, _disabled, _name, _value];
};
@end
//====================================================================
@implementation GSWRadioButton (GSWRadioButtonA)
/** return the value used in appendValueToResponse:inContext: **/
-(id)valueInContext:(GSWContext*)context
- (NSString*) type
{
id value=nil;
LOGObjectFnStartC("GSWCheckBox");
// use _value evaluation or contextID
if (_value)
value=[super valueInContext:context];
else
value=GSWContext_elementID(context);
NSDebugMLLog(@"gswdync",@"value=%@",value);
LOGObjectFnStopC("GSWCheckBox");
return value;
};
return @"radio";
}
//--------------------------------------------------------------------
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
GSWComponent* component=GSWContext_component(aContext);
BOOL disabledInContext=[self disabledInContext:aContext];
if (!disabledInContext)
{
BOOL isChecked=NO;
[self appendValueToResponse:aResponse
inContext:aContext];
[self appendNameToResponse:aResponse
inContext:aContext];
NSDebugMLLog(@"gswdync",@"_value=%@",_value);
NSDebugMLLog(@"gswdync",@"_selection=%@",_selection);
NSDebugMLLog(@"gswdync",@"_checked=%@",_checked);
if (_value && _selection)
{
id valueValue=[_value valueInComponent:component];
NSDebugMLLog(@"gswdync",@"valueValue=%@",valueValue);
if (valueValue)
{
id selectionValue=[_selection valueInComponent:component];
NSDebugMLLog(@"gswdync",@"selectionValue=%@",selectionValue);
if (selectionValue)
{
NSString* valueValueString=NSStringWithObject(valueValue);
NSString* selectionValueString=NSStringWithObject(selectionValue);
isChecked=SBIsValueEqual(selectionValueString,valueValueString);
};
};
}
else if (_checked)
{
isChecked=GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_checked,aContext);
};
NSDebugMLLog(@"gswdync",@"isChecked=%s",(isChecked ? "YES" : "NO"));
if (isChecked)
GSWResponse_appendContentAsciiString(aResponse,@" checked");
};
};
@end
//====================================================================
@implementation GSWRadioButton (GSWRadioButtonB)
//--------------------------------------------------------------------
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)aContext
inContext:(GSWContext*)context
{
//OK
BOOL disabledInContext=NO;
LOGObjectFnStart();
GSWStartElement(aContext);
GSWAssertCorrectElementID(aContext);
disabledInContext=[self disabledInContext:aContext];
if (!disabledInContext)
{
if ([aContext _wasFormSubmitted])
{
GSWComponent* component=GSWContext_component(aContext);
NSString* name=nil;
id formValue=nil;
id valueValue=nil;
BOOL isChecked=NO;
name=[self nameInContext:aContext];
NSDebugMLLog(@"gswdync",@"name=%@",name);
formValue=[request formValueForKey:name];
NSDebugMLLog(@"gswdync",@"formValue for %@=%@",name,formValue);
GSWComponent* component = GSWContext_component(context);
BOOL isChecked = NO;
id valueValue = nil;
if (_value)
valueValue=[_value valueInComponent:component];
else
valueValue=GSWContext_elementID(aContext);
if (formValue && valueValue)
{
NSString* valueValueString=NSStringWithObject(valueValue);
isChecked=SBIsValueEqual(formValue,valueValueString);
};
NSDebugMLLog(@"gswdync",@"isChecked=%s",(isChecked ? "YES" : "NO"));
if ((![self disabledInComponent:component]) && ([context _wasFormSubmitted])) {
// as RadioButtons are usually grouped, don't set nil to selection when
// this radio button is not checked because we may erase previous
// checked radio button selection
if (_value && _selection && isChecked)
{
NS_DURING
{
[_selection setValue:(isChecked ? valueValue : nil)
inComponent:component];
};
NS_HANDLER
{
LOGException(@"GSWRadioButton _selection=%@ valueValue=%@ exception=%@",
_selection,valueValue,localException);
if (WOStrictFlag)
{
[localException raise];
}
else
{
[self handleValidationException:localException
inContext:aContext];
};
}
NS_ENDHANDLER;
}
NSString * nameCtx = [self nameInContext:context];
if (nameCtx != nil) {
NSString* value = [request stringFormValueForKey: nameCtx];
if (_value != nil) {
valueValue = [_value valueInComponent:component];
} else {
valueValue = [context elementID];
}
isChecked = [value isEqual:NSStringWithObject(valueValue)];
if (isChecked && _selection != nil && _value != nil) {
[_selection setValue: valueValue
inComponent: component];
}
if (_checked != nil) {
[_checked setValue: (isChecked ? GSWNumberYes : GSWNumberNo)
inComponent: component];
}
}
}
}
-(void) _appendCloseTagToResponse:(GSWResponse *) response
inContext:(GSWContext*) context
{
// nothing!
}
- (void) appendAttributesToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
{
GSWComponent * component = GSWContext_component(context);
id valueValue = nil;
id selectionValue = nil;
[super appendAttributesToResponse:response inContext:context];
if (_value != nil) {
valueValue = [_value valueInComponent:component];
if (valueValue != nil && _selection != nil) {
selectionValue = [_selection valueInComponent:component];
if ((selectionValue != nil) && [selectionValue isEqual: valueValue]) {
GSWResponse_appendContentCharacter(response,' ');
GSWResponse_appendContentAsciiString(response,@"checked");
}
}
} else { // _value == nil
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response, value__Key, [context elementID], NO);
}
if ((_checked != nil) && [_checked boolValueInComponent:component]) {
GSWResponse_appendContentCharacter(response,' ');
GSWResponse_appendContentAsciiString(response,@"checked");
}
}
if (_checked)
{
NS_DURING
{
[_checked setValue:(isChecked ? GSWNumberYes : GSWNumberNo)
inComponent:component];
};
NS_HANDLER
{
LOGException(@"GSWRadioButton _checked=%@ exception=%@",
_checked,localException);
if (WOStrictFlag)
{
[localException raise];
}
else
{
[self handleValidationException:localException
inContext:aContext];
};
}
NS_ENDHANDLER;
};
};
};
LOGObjectFnStop();
};
@end

View file

@ -39,53 +39,13 @@
GSWAssociation* _item;
GSWAssociation* _index;
GSWAssociation* _selection;
//GSWeb Additions {
GSWAssociation* _selectionValue;
// }
GSWAssociation* _prefix;
GSWAssociation* _suffix;
GSWAssociation* _displayString;
//GSWeb Additions {
GSWAssociation* _isDisplayStringBefore;
// }
GSWAssociation* _escapeHTML;
BOOL _defaultEscapeHTML;
BOOL _autoValue;
};
BOOL _defaultEscapeHTML;
BOOL _loggedSlow;
}
-(id)initWithName:(NSString*)name
associations:(NSDictionary*)associations
contentElements:(NSArray*)elements;
-(void)dealloc;
-(NSString*)description;
-(NSString*)elementName;
@end
//====================================================================
@interface GSWRadioButtonList (GSWRadioButtonListA)
-(void)appendToResponse:(GSWResponse*)response
inContext:(GSWContext*)context;
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context;
-(void)_slowTakeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context;
-(void)_fastTakeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context;
@end
//====================================================================
@interface GSWRadioButtonList (GSWRadioButtonListB)
-(BOOL)appendStringAtRight:(id)unkwnon
withMapping:(char*)mapping;
-(BOOL)appendStringAtLeft:(id)unkwnon
withMapping:(char*)mapping;
-(BOOL)compactHTMLTags;
@end

View file

@ -78,84 +78,85 @@ static Class standardClass = Nil;
if (self == [GSWRadioButtonList class])
{
standardClass=[GSWRadioButtonList class];
}
}
standardEvaluateConditionInContextIMP =
(GSWIMP_BOOL)[self instanceMethodForSelector:evaluateConditionInContextSEL];
};
};
//--------------------------------------------------------------------
-(id)initWithName:(NSString*)aName
associations:(NSDictionary*)associations
contentElements:(NSArray*)elements
{
//OK
NSMutableDictionary* tmpAssociations=[NSMutableDictionary dictionaryWithDictionary:associations];
LOGObjectFnStartC("GSWRadioButtonList");
NSDebugMLLog(@"gswdync",@"aName=%@ associations:%@ elements=%@",
aName,associations,elements);
_defaultEscapeHTML=1;
[tmpAssociations removeObjectForKey:list__Key];
[tmpAssociations removeObjectForKey:item__Key];
[tmpAssociations removeObjectForKey:index__Key];
[tmpAssociations removeObjectForKey:selection__Key];
if (!WOStrictFlag)
[tmpAssociations removeObjectForKey:selectionValue__Key];
[tmpAssociations removeObjectForKey:prefix__Key];
[tmpAssociations removeObjectForKey:suffix__Key];
[tmpAssociations removeObjectForKey:displayString__Key];
[tmpAssociations removeObjectForKey:escapeHTML__Key];
if ((self=[super initWithName:aName
associations:tmpAssociations
contentElements:nil]))
{
_list=[[associations objectForKey:list__Key
withDefaultObject:[_list autorelease]] retain];
_item=[[associations objectForKey:item__Key
withDefaultObject:[_item autorelease]] retain];
if (_item && ![_item isValueSettable])
{
ExceptionRaise0(@"GSWRadioButtonList",@"'item' parameter must be settable");
};
_index=[[associations objectForKey:index__Key
withDefaultObject:[_index autorelease]] retain];
if (_index && ![_index isValueSettable])
{
ExceptionRaise0(@"GSWRadioButtonList",@"'index' parameter must be settable");
};
_selection=[[associations objectForKey:selection__Key
withDefaultObject:[_selection autorelease]] retain];
if (_selection && ![_selection isValueSettable])
{
ExceptionRaise0(@"GSWRadioButtonList",@"'selection' parameter must be settable");
};
if (!WOStrictFlag)
{
_selectionValue=[[associations objectForKey:selectionValue__Key
withDefaultObject:[_selectionValue autorelease]] retain];
if (_selectionValue && ![_selectionValue isValueSettable])
{
ExceptionRaise0(@"GSWRadioButtonList",@"'selectionValue' parameter must be settable");
};
};
_prefix=[[associations objectForKey:prefix__Key
withDefaultObject:[_prefix autorelease]] retain];
_suffix=[[associations objectForKey:suffix__Key
withDefaultObject:[_suffix autorelease]] retain];
_displayString=[[associations objectForKey:displayString__Key
withDefaultObject:[_displayString autorelease]] retain];
template:(GSWElement*)template
{
GSWAssociation * valueAssoc = nil;
if (!WOStrictFlag)
{
_isDisplayStringBefore=[[associations objectForKey:isDisplayStringBefore__Key
withDefaultObject:[_isDisplayStringBefore autorelease]] retain];
};
_escapeHTML=[[associations objectForKey:escapeHTML__Key
withDefaultObject:[_escapeHTML autorelease]] retain];
};
self = [super initWithName:aName associations:associations template: template];
if (!self) {
return nil;
}
_loggedSlow = NO;
ASSIGN(_suffix, [_associations objectForKey: suffix__Key]);
if (_suffix != nil) {
[_associations removeObjectForKey: suffix__Key];
}
ASSIGN(_index, [_associations objectForKey: index__Key]);
if (_index != nil) {
[_associations removeObjectForKey: index__Key];
}
ASSIGN(_list, [_associations objectForKey: list__Key]);
if (_list != nil) {
[_associations removeObjectForKey: list__Key];
}
ASSIGN(_item, [_associations objectForKey: item__Key]);
if (_item != nil) {
[_associations removeObjectForKey: item__Key];
}
ASSIGN(_selection, [_associations objectForKey: selection__Key]);
if (_selection != nil) {
[_associations removeObjectForKey: item__Key];
}
ASSIGN(_prefix, [_associations objectForKey: prefix__Key]);
if (_prefix != nil) {
[_associations removeObjectForKey: prefix__Key];
}
ASSIGN(_displayString, [_associations objectForKey: displayString__Key]);
if (_displayString != nil) {
[_associations removeObjectForKey: displayString__Key];
}
ASSIGN(_escapeHTML, [_associations objectForKey: escapeHTML__Key]);
if (_escapeHTML != nil) {
[_associations removeObjectForKey: escapeHTML__Key];
}
if ((valueAssoc = [_associations objectForKey: value__Key])) {
[_associations removeObjectForKey: value__Key];
}
if (_displayString == nil)
{
ASSIGN(_displayString, valueAssoc);
_defaultEscapeHTML = NO;
} else {
_defaultEscapeHTML = YES;
}
if ((_list == nil) || (_displayString != nil || _value != nil) &&
(_item == nil || (![_item isValueSettable])) ||
(_selection != nil && (![_selection isValueSettable])))
{
[NSException raise:NSInvalidArgumentException
format:@"%s: 'list' must be present. 'item' must not be a constant if 'displayString' or 'value' is present. 'selections' must not be a constant if present.",
__PRETTY_FUNCTION__];
}
return self;
};
}
//-----------------------------------------------------------------------------------
-(void)dealloc
@ -164,22 +165,21 @@ static Class standardClass = Nil;
DESTROY(_item);
DESTROY(_index);
DESTROY(_selection);
DESTROY(_selectionValue);//GSWeb Only
DESTROY(_prefix);
DESTROY(_suffix);
DESTROY(_displayString);
DESTROY(_isDisplayStringBefore);//GSWeb Only
DESTROY(_escapeHTML);
[super dealloc];
}
//--------------------------------------------------------------------
-(NSString*)description
-(id) description
{
return [NSString stringWithFormat:@"<%s %p>",
return [NSString stringWithFormat:@"<%s %p list:%@ item:%@ index:%@ selection:%@ prefix:%@ suffix:%@ displayString:%@ escapeHTML:%@>",
object_get_class_name(self),
(void*)self];
};
(void*)self,
_list, _item, _index,
_selection, _prefix, _suffix, _displayString, _escapeHTML];
}
//--------------------------------------------------------------------
-(NSString*)elementName
@ -187,304 +187,188 @@ static Class standardClass = Nil;
return @"INPUT";
};
@end
//====================================================================
@implementation GSWRadioButtonList (GSWRadioButtonListA)
//-----------------------------------------------------------------------------------
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context
{
//OK
LOGObjectFnStartC("GSWRadioButtonList");
[self _slowTakeValuesFromRequest:request
inContext:context];
LOGObjectFnStopC("GSWRadioButtonList");
};
//-----------------------------------------------------------------------------------
-(void)_slowTakeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context
{
//OK
BOOL disabledInContext=NO;
LOGObjectFnStartC("GSWRadioButtonList");
GSWComponent * component = GSWContext_component(context);
disabledInContext=[self disabledInContext:context];
if (!disabledInContext)
{
if ([context _wasFormSubmitted])
{
GSWComponent* component=GSWContext_component(context);
NSArray* listValue=nil; // _list value
NSString* name=nil;
BOOL found=NO;
id formValue=nil;
id valueValue=nil; // _value value (or autoValue)
id itemValue=nil; // _item value
NSString* valueValueString=nil; // _value value as string
id itemValueToSet=nil; // item value to set to _selection
id valueValueToSet=nil; // valueValue to set to _selectionValue
int i=0;
int listValueCount=0;
if ((![self disabledInComponent:component]) && ([context _wasFormSubmitted])) {
NSString * ctxName = [self nameInContext:context];
NSString * formValue = [request stringFormValueForKey: ctxName];
int count = 0;
int i = 0;
id itemValue = nil;
id valueValue = nil;
id selValue = nil;
name=[self nameInContext:context];
NSDebugMLLog(@"gswdync",@"name=%@",name);
if (formValue != nil) {
NSArray* listValue = [_list valueInComponent:component];
formValue=[request formValueForKey:name];
NSDebugMLLog(@"gswdync",@"formValue=%@",formValue);
if ([listValue isKindOfClass:[NSArray class]] == NO) {
[NSException raise:NSInvalidArgumentException
format:@"%s: Evaluating 'list' binding returned a '%@' class and not a NSArray.",
__PRETTY_FUNCTION__, [listValue class]];
}
listValue=[_list valueInComponent:component];
NSAssert3(!listValue || [listValue respondsToSelector:@selector(count)],
@"The list (%@) (%@ of class:%@) doesn't respond to 'count'",
_list,
listValue,
[listValue class]);
NSDebugMLLog(@"gswdync",@"listValue=%@",listValue);
count = [listValue count];
for (i = 0; i < count; i++) {
itemValue = [listValue objectAtIndex:i];
[_item setValue:itemValue
inComponent:component];
valueValue = [_value valueInComponent:component];
if (valueValue == nil) {
continue;
}
if ([formValue isEqual:valueValue]) {
selValue = itemValue;
break;
}
NSLog(@"%s: 'value' evaluated to nil in component %@ Unable to select item %@",
__PRETTY_FUNCTION__,self,itemValue);
}
listValueCount=[listValue count];
for(i=0;i<listValueCount && !found;i++)
{
NSDebugMLLog(@"gswdync",@"item=%@",_item);
NSDebugMLLog(@"gswdync",@"index=%@",_index);
}
[_selection setValue:selValue
inComponent:component];
itemValue=[listValue objectAtIndex:i];
if (_item)
[_item setValue:itemValue
inComponent:component];
if (_index)
[_index setValue:GSWIntNumber(i)
inComponent:component];
NSDebugMLLog(@"gswdync",@"value=%@",_value);
if (_value) // Binded Value
{
valueValue = [_value valueInComponent:component];
valueValueString=NSStringWithObject(valueValue);
}
else // Auto Value
{
valueValue = GSWIntNumber(i);
valueValueString=GSWIntToNSString(i);
};
NSDebugMLLog(@"gswdync",@"valueValue=%@",valueValue);
if (valueValue)
{
// we compare (with object equality not pointer equality)
BOOL isEqual=SBIsValueEqual(valueValueString,formValue);
NSDebugMLLog(@"gswdync",@"isEqual=%s",(isEqual ? "YES" : "NO"));
if (isEqual)
{
itemValueToSet=itemValue;
valueValueToSet=valueValue;
found=YES;
};
};
};
NSDebugMLLog(@"gswdync",@"component=%@",component);
NSDebugMLLog(@"gswdync",@"found=%s",(found ? "YES" : "NO"));
NSDebugMLLog(@"gswdync",@"selection=%@",_selection);
GSWLogAssertGood(component);
NS_DURING
{
[_selection setValue:itemValueToSet
inComponent:component];
};
NS_HANDLER
{
LOGException(@"GSWRadioButtonList _selection=%@ itemValueToSet=%@ exception=%@",
_selection,itemValueToSet,localException);
if (WOStrictFlag)
{
[localException raise];
}
else
{
[self handleValidationException:localException
inContext:context];
};
}
NS_ENDHANDLER;
if (!WOStrictFlag && _selectionValue)
{
NS_DURING
{
[_selectionValue setValue:valueValueToSet
inComponent:component];
};
NS_HANDLER
{
LOGException(@"GSWRadioButtonList _selectionValue=%@ valueValueToSet=%@ exception=%@",
_selectionValue,valueValueToSet,localException);
if (WOStrictFlag)
{
[localException raise];
}
else
{
[self handleValidationException:localException
inContext:context];
};
}
NS_ENDHANDLER;
};
};
};
LOGObjectFnStopC("GSWRadioButtonList");
};
}
}
//-----------------------------------------------------------------------------------
-(void)_fastTakeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context
{
LOGObjectFnStartC("GSWRadioButtonList");
LOGObjectFnNotImplemented(); //TODOFN
LOGObjectFnStopC("GSWRadioButtonList");
};
GSWComponent * component = GSWContext_component(context);
if ((_selection != nil) && ((![self disabledInComponent:component]) && ([context _wasFormSubmitted]))) {
NSArray* listValue = nil;
id selValue = nil;
NSString * ctxName = [self nameInContext:context];
NSString * formValue = [request stringFormValueForKey: ctxName];
if (formValue != nil) {
NSArray* listValue = [_list valueInComponent:component];
if ([listValue isKindOfClass:[NSArray class]] == NO) {
[NSException raise:NSInvalidArgumentException
format:@"%s: Evaluating 'list' binding returned a '%@' class and not a NSArray.",
__PRETTY_FUNCTION__, [listValue class]];
}
selValue = [listValue objectAtIndex:[formValue intValue]];
}
[_selection setValue:selValue
inComponent:component];
}
}
//-----------------------------------------------------------------------------------
-(void)appendToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
-(void)appendToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
{
//OK
GSWRequest* request=nil;
BOOL isFromClientComponent=NO;
BOOL disabledInContext=NO;
NSString* name=nil;
GSWComponent* component=nil;
NSArray* listValue=nil;
id selectionValue=nil;
id selectionValueValue=nil;
int i=0;
id displayStringValue=nil;
BOOL isDisplayStringBefore=NO;
id prefixValue=nil;
id suffixValue=nil;
id valueValue=nil; // _value value (or auto value)
id itemValue=nil; // _item value
int listValueCount=0;
id selectionsValue = nil;
int i = 0;
int j = 0;
BOOL doEscape;
int count = 0;
GSWComponent * component = GSWContext_component(context);
NSString * ctxName = [self nameInContext:context];
id listValue = [_list valueInComponent:component];
id currentValue = nil;
id valueValue = nil;
LOGObjectFnStartC("GSWRadioButtonList");
if ([listValue isKindOfClass:[NSArray class]] == NO) {
[NSException raise:NSInvalidArgumentException
format:@"%s: Evaluating 'list' binding returned a '%@' class and not a NSArray.",
__PRETTY_FUNCTION__, [listValue class]];
}
request=[aContext request];
isFromClientComponent=[request isFromClientComponent];
name=[self nameInContext:aContext];
component=GSWContext_component(aContext);
doEscape = (_escapeHTML == nil) ? _defaultEscapeHTML : [_escapeHTML boolValueInComponent:component];
selectionValue=[_selection valueInComponent:component];
selectionValueValue=[_selectionValue valueInComponent:component];
listValue=[_list valueInComponent:component];
NSAssert3(!listValue || [listValue respondsToSelector:@selector(count)],
@"The list (%@) (%@ of class:%@) doesn't respond to 'count'",
_list,
listValue,
[listValue class]);
selectionsValue = _selection == nil ? nil : [_selection valueInComponent:component];
if (listValue != nil) {
count = [listValue count];
}
listValueCount=[listValue count];
for(i=0;i<listValueCount;i++)
for (j = 0; j < count; j++)
{
if (_index != nil) {
[_index setValue:GSWIntToNSString(j)
inComponent:component];
}
NSString * prefixStr = _prefix == nil ? nil : NSStringWithObject([_prefix valueInComponent:component]);
NSString * suffixStr = _suffix == nil ? nil : NSStringWithObject([_suffix valueInComponent:component]);
id displayValue = nil;
NSString * dispStr = nil;
valueValue = nil;
currentValue = [listValue objectAtIndex:j];
if ((_item != nil) && (_displayString != nil)) {
[_item setValue:currentValue inComponent:component];
displayValue = [_displayString valueInComponent:component];
if (displayValue == nil) {
dispStr = NSStringWithObject(currentValue);
NSLog(@"%s: 'displayString' evaluated to nil in component %@. Using %@",
__PRETTY_FUNCTION__, component, dispStr);
} else {
dispStr = NSStringWithObject(displayValue);
}
} else {
dispStr = NSStringWithObject(currentValue);
}
GSWResponse_appendContentAsciiString(response, @"<input name=\"");
GSWResponse_appendContentString(response,ctxName);
GSWResponse_appendContentAsciiString(response, @"\" type=radio value=\"");
if (_value != nil) {
valueValue = [_value valueInComponent:component];
if (valueValue != nil) {
GSWResponse_appendContentHTMLConvertString(response,NSStringWithObject(valueValue));
} else {
NSLog(@"%s: 'value' evaluated to nil in component %@. Using index",
__PRETTY_FUNCTION__, component);
}
}
if (valueValue == nil) {
GSWResponse_appendContentAsciiString(response,GSWIntToNSString(j));
}
if ((selectionsValue != nil) && ([selectionsValue isEqual:currentValue])) {
GSWResponse_appendContentAsciiString(response,@"\" checked>");
} else {
GSWResponse_appendContentAsciiString(response,@"\">");
}
if (prefixStr != nil) {
GSWResponse_appendContentString(response,prefixStr);
}
if (doEscape) {
GSWResponse_appendContentHTMLConvertString(response, dispStr);
} else {
GSWResponse_appendContentString(response,dispStr);
}
if (suffixStr != nil)
{
BOOL isEqual=NO;
GSWResponse_appendContentString(response,suffixStr);
}
}
disabledInContext=[self disabledInContext:aContext];
}
itemValue=[listValue objectAtIndex:i];
[_item setValue:itemValue
inComponent:component];
prefixValue=[_prefix valueInComponent:component];
suffixValue=[_suffix valueInComponent:component];
[_index setValue:GSWIntNumber(i)
inComponent:component];
if (_isDisplayStringBefore)
{
isDisplayStringBefore=GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_isDisplayStringBefore,aContext);
};
displayStringValue=[_displayString valueInComponent:component];
if (isDisplayStringBefore)
GSWResponse_appendContentHTMLString(aResponse,displayStringValue);
GSWResponse_appendContentString(aResponse,@"<INPUT NAME=\"");
GSWResponse_appendContentString(aResponse,name);
GSWResponse_appendContentString(aResponse,@"\" TYPE=radio VALUE=\"");
NSDebugMLLog(@"gswdync",@"_value (class: %@): %@",[_value class],_value);
// Value property of the INPUT tag
if (_value) // Binded Value
{
valueValue = [_value valueInComponent:component];
NSDebugMLLog(@"gswdync",@"valueValue=%@",valueValue);
GSWResponse_appendContentHTMLAttributeValue(aResponse,valueValue);
}
else // Auto Value
{
valueValue = GSWIntNumber(i);
NSDebugMLLog(@"gswdync",@"valueValue=%@",valueValue);
GSWResponse_appendContentAsciiString(aResponse,GSWIntToNSString(i));
};
GSWResponse_appendContentCharacter(aResponse,'"');
NSDebugMLLog(@"gswdync",@"selectionValue=%@",selectionValue);
NSDebugMLLog(@"gswdync",@"selectionValue class=%@",[selectionValue class]);
NSDebugMLLog(@"gswdync",@"itemValue=%@",itemValue);
NSDebugMLLog(@"gswdync",@"itemValue class=%@",[itemValue class]);
if (selectionValue)
{
isEqual=SBIsValueEqual(itemValue,selectionValue);
NSDebugMLLog(@"gswdync",@"isEqual=%s",(isEqual ? "YES" : "NO"));
}
NSDebugMLLog(@"gswdync",@"selectionValueValue=%@",selectionValueValue);
NSDebugMLLog(@"gswdync",@"selectionValueValue class=%@",[selectionValueValue class]);
NSDebugMLLog(@"gswdync",@"valueValue=%@",valueValue);
NSDebugMLLog(@"gswdync",@"valueValue class=%@",[valueValue class]);
if (isEqual==NO && selectionValueValue)
{
isEqual=SBIsValueEqual(valueValue,selectionValueValue);
NSDebugMLLog(@"gswdync",@"isEqual=%s",(isEqual ? "YES" : "NO"));
}
if (isEqual)
GSWResponse_appendContentString(aResponse,@" CHECKED");
if (disabledInContext)
GSWResponse_appendContentAsciiString(aResponse,@" DISABLED");
GSWResponse_appendContentCharacter(aResponse,'>');
GSWResponse_appendContentString(aResponse,prefixValue);
if (!isDisplayStringBefore)
GSWResponse_appendContentHTMLString(aResponse,displayStringValue);
GSWResponse_appendContentString(aResponse,suffixValue);
};
LOGObjectFnStopC("GSWRadioButtonList");
};
@end
//====================================================================
@implementation GSWRadioButtonList (GSWRadioButtonListB)
-(BOOL)appendStringAtRight:(id)unkwnon
withMapping:(char*)mapping
{
LOGObjectFnNotImplemented(); //TODOFN
return NO;
};
-(BOOL)appendStringAtLeft:(id)unkwnon
withMapping:(char*)mapping
{
LOGObjectFnNotImplemented(); //TODOFN
return NO;
};
@ -493,4 +377,19 @@ static Class standardClass = Nil;
return NO;
};
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context
{
if (_value != nil) {
if (!_loggedSlow) {
NSLog(@"%s Warning: Avoid using the 'value' binding as it is much slower than omitting it, and it is just cosmetic.",
__PRETTY_FUNCTION__);
_loggedSlow = YES;
}
[self _slowTakeValuesFromRequest:request inContext:context];
} else {
[self _fastTakeValuesFromRequest:request inContext:context];
}
}
@end

View file

@ -35,44 +35,21 @@
#define _GSWRepetition_h__
//====================================================================
@interface GSWRepetition: GSWDynamicElement
// NOTE: identifier is not used anywhere. There seems to be a documentation bug.
@interface GSWRepetition: GSWDynamicGroup
{
GSWAssociation* _list;
GSWAssociation* _item;
GSWAssociation* _identifier;
GSWAssociation* _count;
GSWAssociation* _index;
//GSWeb Additions {
GSWAssociation* _startIndex; /** Don't begin at 0 but at startIndex **/
GSWAssociation* _stopIndex; /** Don't end at count-1 or list count -1 but at stopIndex **/
//}
GSWHTMLStaticGroup* _childrenGroup;
};
-(id)initWithName:(NSString*)aName
associations:(NSDictionary*)associations
contentElements:(NSArray*)elements;
-(id)initWithName:(NSString*)aName
associations:(NSDictionary*)associations
template:(GSWElement*)templateElement;
@end
//====================================================================
@interface GSWRepetition (GSWRepetitionA)
-(void)appendToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext;
-(GSWElement*)invokeActionForRequest:(GSWRequest*)aRequest
inContext:(GSWContext*)aContext;
-(void)takeValuesFromRequest:(GSWRequest*)aRequest
inContext:(GSWContext*)aContext;
-(GSWElement*)_slowInvokeActionForRequest:(GSWRequest*)aRequest
inContext:(GSWContext*)aContext;
-(GSWElement*)_fastInvokeActionForRequest:(GSWRequest*)aRequest
inContext:(GSWContext*)aContext;
@end

View file

@ -54,615 +54,288 @@ static SEL setValueInComponentSEL = NULL;
};
//--------------------------------------------------------------------
-(id)initWithName:(NSString*)name
-(id)initWithName:(NSString*)aName
associations:(NSDictionary*)associations
contentElements:(NSArray*)elements
{
//OK
LOGObjectFnStart();
if ((self=[super initWithName:name
associations:nil
template:nil]))
{
_list=[[associations objectForKey:list__Key
withDefaultObject:[_list autorelease]] retain];
NSDebugMLLog(@"gswdync",@"list=%@",_list);
_item=[[associations objectForKey:item__Key
withDefaultObject:[_item autorelease]] retain];
NSDebugMLLog(@"gswdync",@"item=%@",_item);
if (_item && ![_item isValueSettable])
{
ExceptionRaise0(@"GSWRepetition",@"'item' parameter must be settable");
};
_identifier=[[associations objectForKey:identifier__Key
withDefaultObject:[_identifier autorelease]] retain];
NSDebugMLLog(@"gswdync",@"identifier=%@",_identifier);
_count=[[associations objectForKey:count__Key
withDefaultObject:[_count autorelease]] retain];
NSDebugMLLog(@"gswdync",@"count=%@",_count);
_index=[[associations objectForKey:index__Key
withDefaultObject:[_index autorelease]] retain];
NSDebugMLLog(@"gswdync",@"index=%@",_index);
if (_index && ![_index isValueSettable])
{
ExceptionRaise0(@"GSWRepetition",@"'index' parameter must be settable");
};
template:(GSWElement*)template
{
self = [super initWithName:nil associations:nil template: template];
if (!self) {
return nil;
}
if (!WOStrictFlag)
{
_startIndex=[[associations objectForKey:startIndex__Key
withDefaultObject:[_startIndex autorelease]] retain];
NSDebugMLLog(@"gswdync",@"startIndex=%@",_startIndex);
ASSIGN(_list, [associations objectForKey: list__Key]);
ASSIGN(_item, [associations objectForKey: item__Key]);
ASSIGN(_count, [associations objectForKey: count__Key]);
ASSIGN(_index, [associations objectForKey: index__Key]);
_stopIndex=[[associations objectForKey:stopIndex__Key
withDefaultObject:[_stopIndex autorelease]] retain];
NSDebugMLLog(@"gswdync",@"stopIndex=%@",_stopIndex);
};
if (!WOStrictFlag) {
ASSIGN(_startIndex, [associations objectForKey: startIndex__Key]);
ASSIGN(_stopIndex, [associations objectForKey: stopIndex__Key]);
}
if (_list == nil && _count == nil) {
[NSException raise:NSInvalidArgumentException
format:@"%s: Missing 'list' or 'count' attribute.",
__PRETTY_FUNCTION__];
}
if (_list != nil && _item == nil) {
[NSException raise:NSInvalidArgumentException
format:@"%s: Missing 'item' attribute with 'list' attribute.",
__PRETTY_FUNCTION__];
}
if (_list != nil && _count != nil) {
[NSException raise:NSInvalidArgumentException
format:@"%s: Illegal use of 'count' attribute with 'list' attribute.",
__PRETTY_FUNCTION__];
}
if (_count != nil && (_list != nil || _item != nil)) {
[NSException raise:NSInvalidArgumentException
format:@"%s: Illegal use of 'list' or 'item' attribute with 'count' attribute.",
__PRETTY_FUNCTION__];
}
if (_item != nil && (![_item isValueSettable])) {
[NSException raise:NSInvalidArgumentException
format:@"%s: The 'item' attribute must be settable.",
__PRETTY_FUNCTION__];
}
if (_index != nil && (![_index isValueSettable])) {
[NSException raise:NSInvalidArgumentException
format:@"%s: The 'index' attribute must be settable.",
__PRETTY_FUNCTION__];
}
if (elements)
{
_childrenGroup=[[GSWHTMLStaticGroup alloc]initWithContentElements:elements];
};
};
LOGObjectFnStop();
return self;
};
//--------------------------------------------------------------------
-(id)initWithName:(NSString*)name
associations:(NSDictionary*)associations
template:(GSWElement*)templateElement
{
LOGObjectFnStart();
self=[self initWithName:name
associations:associations
contentElements:templateElement ? [NSArray arrayWithObject:templateElement] : nil];
LOGObjectFnStop();
return self;
};
//--------------------------------------------------------------------
-(void)dealloc
{
DESTROY(_list);
DESTROY(_item);
DESTROY(_identifier);
DESTROY(_count);
DESTROY(_index);
DESTROY(_startIndex);
DESTROY(_stopIndex);
DESTROY(_childrenGroup);
[super dealloc];
}
//--------------------------------------------------------------------
-(void)setDeclarationName:(NSString*)declarationName
{
[super setDeclarationName:declarationName];
if (declarationName && _childrenGroup)
[_childrenGroup setDeclarationName:[declarationName stringByAppendingString:@"-StaticGroup"]];
};
//--------------------------------------------------------------------
-(NSString*)description
{
return [NSString stringWithFormat:@"<%s %p>",
return [NSString stringWithFormat:@"<%s %p list:%@ item:%@ count:%@ index:%@>",
object_get_class_name(self),
(void*)self];
(void*)self,
_list, _item, _count, _index];
};
@end
//====================================================================
@implementation GSWRepetition (GSWRepetitionA)
-(void)getParameterValuesReturnList:(NSArray**)listValuePtr
listCount:(int*)listCountPtr
count:(int*)countValuePtr
startIndex:(int*)startIndexValuePtr
stopIndex:(int*)stopIndexValuePtr
withComponent:(GSWComponent*)component
static inline void _prepareForIterationWithIndex(int i, int j, NSArray * array, GSWContext * context,
GSWComponent *component, GSWAssociation* item, GSWAssociation* index)
{
LOGObjectFnStart();
NSDebugMLLog(@"gswdync",@"_list=%@",_list);
if (_list)
{
*listValuePtr=[_list valueInComponent:component];
NSAssert2(!(*listValuePtr) || [(*listValuePtr) respondsToSelector:@selector(count)],
@"The list (%@) (of class:%@) doesn't respond to 'count'",
_list,
[(*listValuePtr) class]);
*listCountPtr=[(*listValuePtr) count];
*countValuePtr=*listCountPtr;
NSDebugMLLog(@"gswdync",@"list count=%d",*countValuePtr);
}
else
*listCountPtr=0;
NSDebugMLLog(@"gswdync",@"_count=%@",_count);
if (_count)
{
id tmpCountValue=[_count valueInComponent:component];
int tmpCount=0;
NSAssert3(!tmpCountValue || [tmpCountValue respondsToSelector:@selector(intValue)],
@"The 'count' (%@) value %@ (of class:%@) doesn't respond to 'intValue'",
_count,
tmpCountValue,
[tmpCountValue class]);
tmpCount=[tmpCountValue intValue];
NSDebugMLLog(@"gswdync",@"tmpCount=%d",tmpCount);
if (_list)
*countValuePtr=min(tmpCount,(*countValuePtr));
else
*countValuePtr=tmpCount;
};
if (WOStrictFlag)
*stopIndexValuePtr=(*countValuePtr)-1;
else
{
NSDebugMLLog(@"gswdync",@"_startIndex=%@",_startIndex);
if (_startIndex)
{
id tmpStartIndexValue=[_startIndex valueInComponent:component];
NSAssert3(!tmpStartIndexValue || [tmpStartIndexValue respondsToSelector:@selector(intValue)],
@"The 'startIndex' (%@) value %@ (of class:%@) doesn't respond to 'intValue'",
_count,
tmpStartIndexValue,
[tmpStartIndexValue class]);
*startIndexValuePtr=[tmpStartIndexValue intValue];
*startIndexValuePtr=max(0,(*startIndexValuePtr));
}
else
*startIndexValuePtr=0;
NSDebugMLLog(@"gswdync",@"*startIndexValuePtr=%d",(*startIndexValuePtr));
NSDebugMLLog(@"gswdync",@"_stopIndex=%@",_stopIndex);
if (_stopIndex)
{
id tmpStopIndexValue=[_stopIndex valueInComponent:component];
NSAssert3(!tmpStopIndexValue || [tmpStopIndexValue respondsToSelector:@selector(intValue)],
@"The 'startIndex' (%@) value %@ (of class:%@) doesn't respond to 'intValue'",
_count,
tmpStopIndexValue,
[tmpStopIndexValue class]);
*stopIndexValuePtr=[tmpStopIndexValue intValue];
NSDebugMLLog(@"gswdync",@"*stopIndexValuePtr=%d",(*stopIndexValuePtr));
if (_count) // if not count, just take start and stop index
{
if ((*countValuePtr)>((*stopIndexValuePtr)+1))
*countValuePtr=(*stopIndexValuePtr)+1;
else
*stopIndexValuePtr=(*countValuePtr)-1;
}
else
*countValuePtr=(*stopIndexValuePtr)+1;
NSDebugMLLog(@"gswdync",@"*stopIndexValuePtr=%d",(*stopIndexValuePtr));
NSDebugMLLog(@"gswdync",@"*countValuePtr=%d",(*countValuePtr));
}
else
*stopIndexValuePtr=(*countValuePtr)-1;
NSDebugMLLog(@"gswdync",@"*stopIndexValuePtr=%d",(*stopIndexValuePtr));
};
NSDebugMLLog(@"gswdync",@"PARAMETERS: list: %p startIndex: %d stopIndex: %d count: %d",
*listValuePtr,
*startIndexValuePtr,
*stopIndexValuePtr,
*countValuePtr);
LOGObjectFnStop();
};
if (item != nil) {
id obj = [array objectAtIndex:i];
[item setValue:obj
inComponent:component]; // _setValueNoValidation?
}
if (index != nil) {
[index setValue:[NSNumber numberWithInt:i]
inComponent:component]; // _setValueNoValidation?
}
if (i != 0) {
[context incrementLastElementIDComponent];
} else {
[context appendZeroElementIDComponent];
}
}
//--------------------------------------------------------------------
-(void)_prepareIterationWithIndex:(unsigned int)currentIndex
startIndex:(unsigned int)startIndex
stopIndex:(unsigned int)stopIndex
list:(NSArray*)list
listCount:(unsigned int)listCount
listObjectAtIndexIMP:(IMP)oaiIMP
itemSetValueIMP:(IMP)itemSetValueIMP
indexSetValueIMP:(IMP)indexSetValueIMP
component:(GSWComponent*)component
inContext:(GSWContext*)context
static inline void _cleanupAfterIteration(GSWContext * context,
GSWComponent * component, int i, GSWAssociation* item, GSWAssociation* index)
{
LOGObjectFnStart();
NS_DURING
{
NSDebugMLLog(@"gswdync",@"currentIndex=%d startIndex=%d stopIndex=%d",
currentIndex,startIndex,stopIndex);
NSDebugMLLog(@"gswdync",@"_index=%@",_index);
NSDebugMLLog(@"gswdync",@"_item=%@",_item);
if (_list && _item)
{
if (listCount>currentIndex)
{
NSDebugMLLog(@"gswdync",@"[list objectAtIndex:%d]=%@",currentIndex,[list objectAtIndex:currentIndex]);
(*itemSetValueIMP)(_item,setValueInComponentSEL,
(*oaiIMP)(list,objectAtIndexSEL,currentIndex),
component);
}
else
{
//NSLog(@"startOneIterationWithIndex SKIPPING setValue:inComponent index=%d list.count=%d",currentIndex, [list count]);
};
};
if (item != nil) {
[item setValue:nil
inComponent:component]; // _setValueNoValidation?
}
if (index != nil) {
[index setValue:[NSNumber numberWithInt:i]
inComponent:component]; // _setValueNoValidation?
}
[context deleteLastElementIDComponent];
}
if (_index)
(*indexSetValueIMP)(_index,setValueInComponentSEL,
GSWIntNumber(currentIndex),component);
if (currentIndex==startIndex)
GSWContext_appendZeroElementIDComponent(context);
else
GSWContext_incrementLastElementIDComponent(context);
}
NS_HANDLER
{
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,@"In startOneIterationWithIndex");
[localException raise];
}
NS_ENDHANDLER;
LOGObjectFnStop();
};
//--------------------------------------------------------------------
-(void)_cleanupAfterIterationsWithItemSetValueIMP:(IMP)itemSetValueIMP
indexSetValueIMP:(IMP)indexSetValueIMP
component:(GSWComponent*)component
inContext:(GSWContext*)context
{
LOGObjectFnStart();
NS_DURING
{
if (_list && _item)
(*itemSetValueIMP)(_item,setValueInComponentSEL,
nil,component);
if (_index)
(*indexSetValueIMP)(_index,setValueInComponentSEL,
GSWIntNumber(0),component);
GSWContext_deleteLastElementIDComponent(context);
}
NS_HANDLER
{
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,@"In cleanupAfterIterations");
[localException raise];
}
NS_ENDHANDLER;
LOGObjectFnStop();
};
//--------------------------------------------------------------------
-(void)appendToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
{
GSWComponent* component=nil;
NSArray* listValue=nil;
int listCount=0;
int i=0;
int countValue=0;
int startIndexValue = 0;
int stopIndexValue = 0;
GSWComponent * component = GSWContext_component(context);
NSArray * myArray = nil;
NSNumber * countValue = nil;
unsigned int count = 0;
unsigned int i = 0;
if (_list != nil) {
myArray = [_list valueInComponent:component];
if (myArray != nil)
count = [myArray count];
} else {
countValue = [_count valueInComponent:component];
if (countValue != nil) {
count = [countValue intValue];
}
}
for (i = 0; i < count; i++) {
_prepareForIterationWithIndex(i, count, myArray, context, component,_item, _index);
[super appendChildrenToResponse:response
inContext:context];
}
GSWDeclareDebugElementIDsCount(context);
GSWDeclareDebugElementID(context);
if (count > 0) {
_cleanupAfterIteration(context, component, count, _item, _index);
}
}
LOGObjectFnStart();
GSWStartElement(context);
GSWSaveAppendToResponseElementID(context);
static inline NSString* _indexStringForSenderAndElement(NSString * senderStr, NSString * elementStr)
{
int elementLen = [elementStr length]+ 1;
int senderLen = [senderStr length];
NSRange myRange = [senderStr rangeOfString:@"."
options:0
range:NSMakeRange(elementLen, (senderLen - elementLen))];
component=GSWContext_component(context);
// NSLog(@"elementLen:%d", elementLen);
// NSLog(@"senderLen:%d", senderLen);
[self getParameterValuesReturnList:&listValue
listCount:&listCount
count:&countValue
startIndex:&startIndexValue
stopIndex:&stopIndexValue
withComponent:component];
if (myRange.location == NSNotFound) {
return [senderStr substringFromIndex: elementLen];
} else {
// NSLog(@"found myRange.location:%d", myRange.location);
return [senderStr substringWithRange: NSMakeRange(elementLen, myRange.location-elementLen)];
}
return nil;
}
NSDebugMLLog(@"gswdync",@"countValue=%d",countValue);
if (startIndexValue<=stopIndexValue)
{
IMP prepareIterationIMP=[self methodForSelector:prepareIterationSEL];
IMP listOAIIMP=[listValue methodForSelector:objectAtIndexSEL];
IMP itemSetValueIMP=[_item methodForSelector:setValueInComponentSEL];
IMP indexSetValueIMP=[_index methodForSelector:setValueInComponentSEL];
[context incrementLoopLevel];
for(i=startIndexValue;i<=stopIndexValue;i++)
{
(*prepareIterationIMP)(self,prepareIterationSEL,
i,startIndexValue,stopIndexValue,
listValue,listCount,
listOAIIMP,
itemSetValueIMP,indexSetValueIMP,
component,context);
GSWContext_appendZeroElementIDComponent(context);
[_childrenGroup appendToResponse:response
inContext:context];
GSWContext_deleteLastElementIDComponent(context);
};
[self _cleanupAfterIterationsWithItemSetValueIMP:itemSetValueIMP
indexSetValueIMP:indexSetValueIMP
component:component
inContext:context];
[context decrementLoopLevel];
};
GSWStopElement(context);
GSWAssertDebugElementIDsCount(context);
GSWAssertDebugElementID(context);
LOGObjectFnStop();
};
//--------------------------------------------------------------------
-(GSWElement*)invokeActionForRequest:(GSWRequest*)request
inContext:(GSWContext*)context
{
//OK
GSWElement* element=nil;
BOOL isInForm=NO;
GSWDeclareDebugElementIDsCount(context);
LOGObjectFnStart();
GSWComponent * component = GSWContext_component(context);
GSWElement * element = nil;
NSString * indexStr = nil;
GSWStartElement(context);
NSString * senderID = [context senderID];
NSString * elementID = [context elementID];
NSArray * arrayValue = nil;
id currentValue = nil;
int count = 0;
int k = 0;
if ([senderID hasPrefix:elementID]) {
int i = [elementID length];
// code taken from http://www.unicode.org/charts/PDF/U0000.pdf
// '.'
if (([senderID length] > i) && ([senderID characterAtIndex:i] == 0x002e)) {
indexStr = _indexStringForSenderAndElement(senderID, elementID);
// NSLog(@"indexStr is '%@' senderID:'%@' elementID:'%@'", indexStr, senderID, elementID);
}
}
isInForm=[context isInForm];
NSDebugMLLog(@"gswdync",@"isInForm=%s",isInForm ? "YES" : "NO");
if (isInForm)
element=[self _slowInvokeActionForRequest:request
inContext:context];
else
element=[self _fastInvokeActionForRequest:request
inContext:context];
NSDebugMLLog(@"gswdync",@"element=%@",element);
if (indexStr != nil) {
int i = [indexStr intValue];
if (_list != nil) {
arrayValue = [_list valueInComponent:component];
GSWStopElement(context);
GSWAssertDebugElementIDsCount(context);
LOGObjectFnStop();
return element;
};
//--------------------------------------------------------------------
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context
{
GSWComponent* component=nil;
NSArray* listValue=nil;
int listCount=0;
int i=0;
int countValue=0;
int startIndexValue = 0;
int stopIndexValue = 0;
GSWDeclareDebugElementIDsCount(context);
GSWDeclareDebugElementID(context);
LOGObjectFnStart();
GSWStartElement(context);
GSWAssertCorrectElementID(context);
component=GSWContext_component(context);
[self getParameterValuesReturnList:&listValue
listCount:&listCount
count:&countValue
startIndex:&startIndexValue
stopIndex:&stopIndexValue
withComponent:component];
if (startIndexValue<=stopIndexValue)
{
IMP prepareIterationIMP=[self methodForSelector:prepareIterationSEL];
IMP listOAIIMP=[listValue methodForSelector:objectAtIndexSEL];
IMP itemSetValueIMP=[_item methodForSelector:setValueInComponentSEL];
IMP indexSetValueIMP=[_index methodForSelector:setValueInComponentSEL];
[context incrementLoopLevel];
for(i=startIndexValue;i<=stopIndexValue;i++)
{
(*prepareIterationIMP)(self,prepareIterationSEL,
i,startIndexValue,stopIndexValue,
listValue,listCount,
listOAIIMP,
itemSetValueIMP,indexSetValueIMP,
component,context);
GSWContext_appendZeroElementIDComponent(context);
[_childrenGroup takeValuesFromRequest:request
inContext:context];
GSWContext_deleteLastElementIDComponent(context);
};
[self _cleanupAfterIterationsWithItemSetValueIMP:itemSetValueIMP
indexSetValueIMP:indexSetValueIMP
component:component
inContext:context];
[context decrementLoopLevel];
};
GSWStopElement(context);
GSWAssertDebugElementIDsCount(context);
GSWAssertDebugElementID(context);
LOGObjectFnStop();
};
//--------------------------------------------------------------------
-(GSWElement*)_slowInvokeActionForRequest:(GSWRequest*)request
inContext:(GSWContext*)context
{
//OK
GSWElement* element=nil;
GSWComponent* component=nil;
NSArray* listValue=nil;
int listCount=0;
int i=0;
int countValue=0;
int startIndexValue = 0;
int stopIndexValue = 0;
GSWDeclareDebugElementIDsCount(context);
GSWDeclareDebugElementID(context);
LOGObjectFnStart();
GSWStartElement(context);
component=GSWContext_component(context);
[self getParameterValuesReturnList:&listValue
listCount:&listCount
count:&countValue
startIndex:&startIndexValue
stopIndex:&stopIndexValue
withComponent:component];
if (startIndexValue<=stopIndexValue)
{
IMP prepareIterationIMP=[self methodForSelector:prepareIterationSEL];
IMP listOAIIMP=[listValue methodForSelector:objectAtIndexSEL];
IMP itemSetValueIMP=[_item methodForSelector:setValueInComponentSEL];
IMP indexSetValueIMP=[_index methodForSelector:setValueInComponentSEL];
[context incrementLoopLevel];
for(i=startIndexValue;!element && i<=stopIndexValue;i++)
{
(*prepareIterationIMP)(self,prepareIterationSEL,
i,startIndexValue,stopIndexValue,
listValue,listCount,
listOAIIMP,
itemSetValueIMP,indexSetValueIMP,
component,context);
GSWContext_appendZeroElementIDComponent(context);
element=[_childrenGroup invokeActionForRequest:request
if (arrayValue != nil) {
if ((i >= 0) && (i < [arrayValue count])) {
currentValue = [arrayValue objectAtIndex:i];
}
if (_item != nil) {
[_item setValue:currentValue
inComponent:component]; // speedup? ?
}
}
}
if (_index != nil) {
[_index setValue:[NSNumber numberWithInt:i]
inComponent:component]; // speedup? ?
}
[context appendElementIDComponent: indexStr];
element = [super invokeActionForRequest:request
inContext:context];
NSAssert3(!element || [element isKindOfClass:[GSWElement class]],
@"_childrenGroup=%@ Element is a %@ not a GSWElement: %@",
_childrenGroup,
[element class],
element);
GSWContext_deleteLastElementIDComponent(context);
};
[context deleteLastElementIDComponent];
} else {
count = 0;
[self _cleanupAfterIterationsWithItemSetValueIMP:itemSetValueIMP
indexSetValueIMP:indexSetValueIMP
component:component
inContext:context];
[context decrementLoopLevel];
};
GSWStopElement(context);
GSWAssertDebugElementIDsCount(context);
GSWAssertDebugElementID(context);
LOGObjectFnStop();
if (_list != nil) {
arrayValue = [_list valueInComponent:component];
count = [arrayValue count];
} else {
id countValue = [_count valueInComponent:component];
if (countValue != nil) {
count = [countValue intValue]; // or first into a string?
} else {
NSLog(@"%s:'count' evaluated to nil in component %@. Repetition count reset to zero.",
__PRETTY_FUNCTION__, component);
}
}
for (k = 0; k < count && element == nil; k++) {
_prepareForIterationWithIndex(k, count, arrayValue, context, component, _item, _index);
element = [super invokeActionForRequest:request
inContext:context];
}
if (count > 0) {
_cleanupAfterIteration(context, component, count, _item, _index);
}
}
return element;
};
//--------------------------------------------------------------------
-(GSWElement*)_fastInvokeActionForRequest:(GSWRequest*)request
inContext:(GSWContext*)aContext
- (void) takeValuesFromRequest:(GSWRequest *) request
inContext:(GSWContext*)context
{
GSWElement* element=nil;
NSString* senderID=nil;
NSString* elementID=nil;
GSWDeclareDebugElementIDsCount(aContext);
GSWDeclareDebugElementID(aContext);
GSWComponent * component = GSWContext_component(context);
NSArray * arrayValue = nil;
id countValue = nil;
int i = 0;
LOGObjectFnStart();
int count = 0;
GSWStartElement(aContext);
if (_list != nil) {
arrayValue = [_list valueInComponent:component];
if (arrayValue != nil) {
count = [arrayValue count];
}
} else {
countValue = [_count valueInComponent:component];
if (countValue != nil) {
count = [countValue intValue]; // or first into a string?
} else {
NSLog(@"%s: 'count' evaluated to nil in %@. Resetting to zero. (%@)",
__PRETTY_FUNCTION__, component, _count);
}
}
for (i = 0; i < count; i++) {
senderID=GSWContext_senderID(aContext);
NSDebugMLLog(@"gswdync",@"senderID=%@",senderID);
_prepareForIterationWithIndex(i, count, arrayValue, context, component,_item, _index);
elementID=GSWContext_elementID(aContext);
[super takeValuesFromRequest:request
inContext:context];
}
if ([senderID hasPrefix:elementID])
{
int countValue=0;
NSArray* listValue=nil;
int listCount=0;
int startIndexValue = 0;
int stopIndexValue = 0;
int i=0;
GSWComponent* component=GSWContext_component(aContext);
[self getParameterValuesReturnList:&listValue
listCount:&listCount
count:&countValue
startIndex:&startIndexValue
stopIndex:&stopIndexValue
withComponent:component];
if (startIndexValue<=stopIndexValue)
{
IMP prepareIterationIMP=[self methodForSelector:prepareIterationSEL];
IMP listOAIIMP=[listValue methodForSelector:objectAtIndexSEL];
IMP itemSetValueIMP=[_item methodForSelector:setValueInComponentSEL];
IMP indexSetValueIMP=[_index methodForSelector:setValueInComponentSEL];
[aContext incrementLoopLevel];
for(i=startIndexValue;!element && i<=stopIndexValue;i++)
{
(*prepareIterationIMP)(self,prepareIterationSEL,
i,startIndexValue,stopIndexValue,
listValue,listCount,
listOAIIMP,
itemSetValueIMP,indexSetValueIMP,
component,aContext);
GSWContext_appendZeroElementIDComponent(aContext);
element=[_childrenGroup invokeActionForRequest:request
inContext:aContext];
NSDebugMLLog(@"gswdync",@"element=%@",element);
GSWContext_deleteLastElementIDComponent(aContext);
};
[self _cleanupAfterIterationsWithItemSetValueIMP:itemSetValueIMP
indexSetValueIMP:indexSetValueIMP
component:component
inContext:aContext];
[aContext decrementLoopLevel];
};
};
GSWStopElement(aContext);
GSWAssertDebugElementIDsCount(aContext);
GSWAssertDebugElementID(aContext);
LOGObjectFnStop();
return element;
};
if (count > 0)
{
_cleanupAfterIteration(context, component, count, _item, _index);
}
}

File diff suppressed because it is too large Load diff

View file

@ -174,10 +174,6 @@ bundle if none is found
bundle if none is found
**/
-(GSWDeployedBundle*)lockedCachedBundleForFrameworkNamed:(NSString*)name;
@end
//====================================================================
@interface GSWResourceManager (GSWURLValuedElementsDataCaching)
-(void)flushDataCache;
@ -191,11 +187,6 @@ bundle if none is found
-(void)removeDataForKey:(NSString*)key
session:(GSWSession*)session;
@end
//====================================================================
@interface GSWResourceManager (GSWResourceManagerA)
-(NSString*)pathForResourceNamed:(NSString*)name
inFramework:(NSString*)frameworkName
language:(NSString*)language;
@ -212,30 +203,24 @@ bundle if none is found
-(NSString*)contentTypeForResourcePath:(NSString*)path;
-(NSArray*)_frameworkClassPaths;
@end
//====================================================================
@interface GSWResourceManager (GSWResourceManagerOldFn)
-(NSString*)urlForResourceNamed:(NSString*)name
inFramework:(NSString*)frameworkName;
-(NSString*)pathForResourceNamed:(NSString*)name
inFramework:(NSString*)frameworkName;
@end
//====================================================================
@interface GSWResourceManager (GSWResourceManagerB)
-(void)_validateAPI;
@end
//====================================================================
@interface GSWResourceManager (GSWResourceManagerClassA)
+(NSString*)GSLanguageFromISOLanguage:(NSString*)ISOLanguage; //NDFN
+(NSArray*)GSLanguagesFromISOLanguages:(NSArray*)ISOlanguages; //NDFN
+(NSString*)ISOLanguageFromGSLanguage:(NSString*)GSLanguage; //NDFN
+(NSArray*)ISOLanguagesFromGSLanguages:(NSArray*)GSlanguages; //NDFN
+(GSWBundle*)_applicationGSWBundle;
- (NSString*) errorMessageUrlForResourceNamed:(NSString *) resourceName
inFramework:(NSString *) frameworkName;
- (void) _cacheData:(GSWURLValuedElementData *) aData;
@end
#endif //_GSWResourceManager_h__

View file

@ -78,20 +78,6 @@ NSString* localNotFoundMarker=@"NOTFOUND";
};
};
//--------------------------------------------------------------------
+(void)dealloc
{
GSWLogC("Dealloc GSWResourceManager Class");
DESTROY(globalAppGSWBundle);
DESTROY(globalAppProjectBundle);
DESTROY(globalMime);
DESTROY(globalMimePListPathName);
DESTROY(localGS2ISOLanguages);
DESTROY(localISO2GSLanguages);
DESTROY(globalLanguagesPListPathName);
GSWLogC("End Dealloc GSWResourceManager Class");
};
//--------------------------------------------------------------------
-(id)init
{
@ -152,10 +138,7 @@ NSString* localNotFoundMarker=@"NOTFOUND";
//--------------------------------------------------------------------
-(void)dealloc
{
GSWLogC("Dealloc GSWResourceManager");
GSWLogC("Dealloc GSWResourceManager: _frameworkProjectBundlesCache");
DESTROY(_frameworkProjectBundlesCache);
GSWLogC("Dealloc GSWResourceManager: _appURLs");
DESTROY(_appURLs);
DESTROY(_frameworkURLs);
DESTROY(_appPaths);
@ -165,11 +148,9 @@ NSString* localNotFoundMarker=@"NOTFOUND";
DESTROY(_stringsTableArraysByFrameworkByLanguageByName);
DESTROY(_frameworkClassPaths);
// DESTROY(_frameworkPathsToFrameworksNames);
GSWLogC("Dealloc GSWResourceManager: _selfLock");
DESTROY(_selfLock);
GSWLogC("Dealloc GSWResourceManager Super");
[super dealloc];
GSWLogC("End Dealloc GSWResourceManager");
};
//--------------------------------------------------------------------
@ -1250,10 +1231,6 @@ bundle if none is found
return bundle;
};
@end
//====================================================================
@implementation GSWResourceManager (GSWURLValuedElementsDataCaching)
//--------------------------------------------------------------------
-(void)flushDataCache
@ -1347,11 +1324,6 @@ bundle if none is found
LOGObjectFnStop();
};
@end
//====================================================================
@implementation GSWResourceManager (GSWResourceManagerA)
//--------------------------------------------------------------------
-(NSString*)pathForResourceNamed:(NSString*)resourceName
@ -1585,11 +1557,6 @@ bundle if none is found
return _frameworkClassPaths;
};
@end
//====================================================================
@implementation GSWResourceManager (GSWResourceManagerOldFn)
//--------------------------------------------------------------------
-(NSString*)urlForResourceNamed:(NSString*)resourceName
@ -1620,11 +1587,6 @@ bundle if none is found
return path;
};
@end
//====================================================================
@implementation GSWResourceManager (GSWResourceManagerB)
//--------------------------------------------------------------------
-(void)_validateAPI
@ -1633,10 +1595,6 @@ bundle if none is found
LOGObjectFnNotImplemented(); //TODOFN
};
@end
//====================================================================
@implementation GSWResourceManager (GSWResourceManagerClassA)
//--------------------------------------------------------------------
//NDFN
@ -1820,4 +1778,31 @@ bundle if none is found
return globalAppGSWBundle;
};
// wo
- (NSString*) errorMessageUrlForResourceNamed:(NSString *) resourceName
inFramework:(NSString *) frameworkName
{
NSString * url = nil;
if( resourceName == nil) {
resourceName = @"nil";
}
if (frameworkName != nil) {
url = [NSString stringWithFormat:@"/ERROR/NOT_FOUND/framework=%@/filename=%@", frameworkName, resourceName];
} else {
NSString * s3 = [GSWApp name];
url = [NSString stringWithFormat:@"/ERROR/NOT_FOUND/app=%@/filename=%@", s3, resourceName];
}
return url;
}
// checkme: locking?? davew
- (void) _cacheData:(GSWURLValuedElementData *) aData
{
if (aData != nil) {
[_urlValuedElementsData setObject: aData
forKey: [aData key]];
}
}
@end

View file

@ -360,23 +360,25 @@ void GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(GSWResponse*
};
//--------------------------------------------------------------------
// called _appendTagAttributeAndValue in WO 5
-(void)_appendTagAttribute:(NSString*)attributeName
value:(id)value
escapingHTMLAttributeValue:(BOOL)escape
{
LOGObjectFnStart();
GSWResponse_appendContentCharacter(self,' ');
GSWResponse_appendContentAsciiString(self,attributeName);
GSWResponse_appendContentAsciiString(self,@"=\"");
if (escape)
GSWResponse_appendContentAsciiString(self,
GSWResponse_stringByEscapingHTMLAttributeValue(self,value));
else
GSWResponse_appendContentAsciiString(self,value);
GSWResponse_appendContentCharacter(self,'"');
LOGObjectFnStop();
if (escape) {
GSWResponse_appendContentString(self,
GSWResponse_stringByEscapingHTMLAttributeValue(self,value));
} else {
GSWResponse_appendContentString(self,value);
}
GSWResponse_appendContentCharacter(self,'"');
};
@end

View file

@ -94,16 +94,9 @@
-(NSString*)description;
@end
//====================================================================
@interface GSWSession (GSWSessionA)
-(id)_initWithSessionID:(NSString*)aSessionID;
@end
//====================================================================
@interface GSWSession (GSWTermination)
// Termination
-(void)terminate;
-(void)_terminateByTimeout;
@ -111,42 +104,27 @@
-(void)setTimeOut:(NSTimeInterval)timeInterval;
-(NSTimeInterval)timeOut;
@end
//====================================================================
@interface GSWSession (GSWSessionDebugging)
// SessionDebugging
-(void)debugWithFormat:(NSString*)format,...;
@end
//====================================================================
@interface GSWSession (GSWSessionD)
// SessionD
-(void)_debugWithString:(NSString*)string;
@end
//====================================================================
@interface GSWSession (GSWPageManagement)
// PageManagement
-(void)savePage:(GSWComponent*)page;
-(GSWComponent*)restorePageForContextID:(NSString*)aContextID;
-(unsigned int)permanentPageCacheSize;
-(void)savePageInPermanentCache:(GSWComponent*)page;
@end
//====================================================================
@interface GSWSession (GSWSessionF)
// SessionF
-(void)clearCookieFromResponse:(GSWResponse*)aResponse;
-(void)appendCookieToResponse:(GSWResponse*)aResponse;
@end
//====================================================================
@interface GSWSession (GSWSessionG)
// SessionG
-(void)_releaseAutoreleasePool;
-(void)_createAutoreleasePool;
@ -158,8 +136,6 @@
stackIndex:(unsigned int*)pStackIndex
contextArrayIndex:(unsigned int*)pContextArrayIndex;
-(void)_replacePage:(GSWComponent*)page;
-(void)_savePage:(GSWComponent*)page
forChange:(BOOL)forChange;
-(unsigned int)pageCacheSize;
-(void)_saveCurrentPage;
-(int)_requestCounter;
@ -169,10 +145,7 @@
-(void)sleepInContext:(GSWContext*)aContext;
-(void)awakeInContext:(GSWContext*)aContext;
@end
//====================================================================
@interface GSWSession (GSWLocalization)
// Localization
-(void)setLanguages:(NSArray*)languages;
@ -195,10 +168,7 @@ Returns first element of languages or nil if languages is empty
**/
-(NSString*)firstLanguage;
@end
//====================================================================
@interface GSWSession (GSWComponentStateManagement)
// ComponentStateManagement
-(void)setObject:(id)object
forKey:(NSString*)key;
@ -206,18 +176,13 @@ Returns first element of languages or nil if languages is empty
-(id)objectForKey:(NSString*)key;
-(void)removeObjectForKey:(NSString*)key;
-(NSMutableDictionary*)componentState;//NDFN
@end
//====================================================================
@interface GSWSession (GSWEnterpriseObjects)
// EnterpriseObjects
-(EOEditingContext*)defaultEditingContext;
-(void)setDefaultEditingContext:(EOEditingContext*)editingContext;
@end
//====================================================================
@interface GSWSession (GSWRequestHandling)
// RequestHandling
-(GSWContext*)context;
-(void)awake;
@ -232,10 +197,7 @@ Returns first element of languages or nil if languages is empty
-(void)sleep;
@end
//====================================================================
@interface GSWSession (GSWStatistics)
// Statistics
-(NSArray*)statistics;
-(BOOL)_allowedToViewStatistics;
@ -246,34 +208,18 @@ Returns first element of languages or nil if languages is empty
-(NSString*)_formattedStatistics;
-(NSDate*)_birthDate;
-(void)_setBirthDate:(NSDate*)birthDate;
@end
//====================================================================
@interface GSWSession (GSWEvents)
-(BOOL)_allowedToViewEvents;
-(void)_allowToViewEvents;
-(void)_setAllowedToViewEvents:(BOOL)flag;
-(BOOL)validateEventsLogin:(NSString*)login
withPassword:(NSString*)password;
@end
//====================================================================
@interface GSWSession (GSWSessionN)
-(GSWApplication*)application;
@end
//====================================================================
@interface GSWSession (GSWSessionO)
-(void)_validateAPI;
@end
//====================================================================
@interface GSWSession (GSWSessionClassA)
+(void)__setContextCounterIncrementingEnabled:(BOOL)flag;
+(int)__counterIncrementingEnabledFlag;

File diff suppressed because it is too large Load diff

View file

@ -118,7 +118,7 @@ RCS_ID("$Id$")
GSWSessionTimeOut* entry=[_timeOutManager sessionTimeOutForSessionID:aSessionID];
NS_DURING
{
expirationTime=(int)[entry sessionTimeOut];//seconds
expirationTime=(int)[entry sessionTimeOutValue];//seconds
//NSLog(@"expirationTime=%d",(int)expirationTime);
isCheckedOut=[entry isCheckedOut]; // See if session is used
//NSLog(@"aSessionID=%@ isCheckedOut=%d",aSessionID,(int)isCheckedOut);

View file

@ -51,8 +51,8 @@
sessionTimeOut:(NSTimeInterval)aTimeOutInterval;
-(NSString*)description;
-(NSComparisonResult)compareTimeOutDate:(GSWSessionTimeOut*)timeOutObject;
-(NSTimeInterval)sessionTimeOut;
-(void)setSessionTimeOut:(NSTimeInterval)aTimeOutInterval;
-(NSTimeInterval)sessionTimeOutValue;
-(void)setSessionTimeOutValue:(NSTimeInterval)aTimeOutInterval;
-(NSString*)sessionID;
-(void)setLastAccessTime:(NSTimeInterval)aTime;
-(NSTimeInterval)lastAccessTime;

View file

@ -110,13 +110,14 @@ RCS_ID("$Id$")
};
//--------------------------------------------------------------------
-(NSTimeInterval)sessionTimeOut
// changed from sessionTimeOut to sessionTimeOutValue to avoid problems
-(NSTimeInterval)sessionTimeOutValue
{
return _timeOut;
};
//--------------------------------------------------------------------
-(void)setSessionTimeOut:(NSTimeInterval)aTimeOutInterval
-(void)setSessionTimeOutValue:(NSTimeInterval)aTimeOutInterval
{
_timeOut=aTimeOutInterval;
NSDebugMLLog(@"sessions",@"_timeOut=%f s",

View file

@ -62,10 +62,7 @@
-(void)unlock;
// Must not be locked
-(GSWSessionTimeOut*)sessionTimeOutForSessionID:(NSString*)sessionID;
@end
//====================================================================
@interface GSWSessionTimeOutManager (GSWSessionRefused)
-(void)startHandleTimerRefusingSessions;
-(void)handleTimerKillingApplication:(id)timer;

View file

@ -41,6 +41,7 @@ RCS_ID("$Id$")
//====================================================================
@implementation GSWSessionTimeOutManager
-(id)init
{
//OK
@ -53,6 +54,7 @@ RCS_ID("$Id$")
_sessionTimeOuts=[NSMutableDictionary new];
// selfLock=[NSRecursiveLock new];
_selfLock=[NSLock new];
_target=nil;
};
return self;
};
@ -84,7 +86,7 @@ RCS_ID("$Id$")
{
sessionTimeOut=[GSWSessionTimeOut timeOutWithSessionID:sessionID
lastAccessTime:[NSDate timeIntervalSinceReferenceDate]
sessionTimeOut:[GSWApplication sessionTimeOutValue]];
sessionTimeOut:[[GSWApp class] sessionTimeOutValue]];
[_sessionTimeOuts setObject:sessionTimeOut
forKey:sessionID];
[_sessionOrderedTimeOuts addObject:sessionTimeOut];
@ -147,8 +149,8 @@ RCS_ID("$Id$")
[sessionTimeOut setLastAccessTime:
[NSDate timeIntervalSinceReferenceDate]];
if (timeOut!=[sessionTimeOut sessionTimeOut])
[sessionTimeOut setSessionTimeOut:timeOut];
if (timeOut!=[sessionTimeOut sessionTimeOutValue])
[sessionTimeOut setSessionTimeOutValue:timeOut];
[_sessionOrderedTimeOuts addObject:sessionTimeOut];
@ -558,10 +560,6 @@ RCS_ID("$Id$")
LOGObjectFnStop();
};
@end
//====================================================================
@implementation GSWSessionTimeOutManager (GSWSessionRefused)
//--------------------------------------------------------------------
-(void)startHandleTimerRefusingSessions
@ -752,5 +750,20 @@ RCS_ID("$Id$")
//NSLog(@"-Stop HandleTimerRefusingSessions");
};
- (NSString*) description
{
NSString * desStr = [NSString stringWithFormat:@"<%s %p sessionOrderedTimeOuts:%@ sessionTimeOuts:%@ target:XX callback:%@ timer:%@ selfLock:%@>", object_get_class_name(self),
(void*)self,
_sessionOrderedTimeOuts,
_sessionTimeOuts,
//_target
NSStringFromSelector(_callback),
_timer,
_selfLock
];
return desStr;
}
@end

View file

@ -33,41 +33,31 @@
#define _GSWString_h__
@interface GSWString: GSWHTMLDynamicElement
@interface GSWString: GSWDynamicElement
{
GSWAssociation* _value;
GSWAssociation* _dateFormat;
GSWAssociation* _numberFormat;
GSWAssociation* _escapeHTML;
//GSWeb Additions {
GSWAssociation* _convertHTML;
GSWAssociation* _convertHTMLEntities;
// }
GSWAssociation* _formatter;
GSWAssociation * _dateFormat;
GSWAssociation * _numberFormat;
GSWAssociation * _formatter;
GSWAssociation * _value;
GSWAssociation * _escapeHTML;
GSWAssociation * _valueWhenEmpty;
BOOL _shouldFormat;
};
-(id)initWithName:(NSString*)name
associations:(NSDictionary*)associations
contentElements:(NSArray*)elements;
associations:(NSMutableDictionary*)associations
template:(GSWElement*)template;
-(void)appendToResponse:(GSWResponse*)response
inContext:(GSWContext*)context;
-(BOOL)appendStringAtRight:(id)unkwnon
withMapping:(char*)mapping;
// needed? dw.
//-(NSFormatter*)formatterForComponent:(GSWComponent*)component
// value:(id)value;
-(BOOL)appendStringAtLeft:(id)unkwnon
withMapping:(char*)mapping;
// needed? dw.
// -(NSString*)formattedValueInContext:(GSWContext*)context;
-(NSFormatter*)formatterForComponent:(GSWComponent*)component
value:(id)value;
-(NSString*)elementName;
-(NSString*)formattedValueInContext:(GSWContext*)context;
@end
//====================================================================
@interface GSWString (GSWInputA)
+(BOOL)hasGSWebObjectsAssociations;
@end
#endif //_GSWString_h__

View file

@ -60,65 +60,53 @@ static Class standardClass = Nil;
//--------------------------------------------------------------------
-(id)initWithName:(NSString*)aName
associations:(NSDictionary*)associations
contentElements:(NSArray*)elements
associations:(NSMutableDictionary*)associations
template:(GSWElement*)template
{
//OK
LOGObjectFnStartC("GSWString");
NSDebugMLLog(@"gswdync",@"aName=%@ associations:%@ elements=%@",
aName,associations,elements);
if ((self=[super initWithName:nil
associations:nil
contentElements:nil]))
{
_value = [[associations objectForKey:value__Key
withDefaultObject:[_value autorelease]] retain];
NSDebugMLLog(@"gswdync",@"GSWString: value=%@",_value);
_dateFormat = [[associations objectForKey:dateFormat__Key
withDefaultObject:[_dateFormat autorelease]] retain];
NSDebugMLLog(@"gswdync",@"GSWString: dateFormat=%@",_dateFormat);
_numberFormat = [[associations objectForKey:numberFormat__Key
withDefaultObject:[_numberFormat autorelease]] retain];
NSDebugMLLog(@"gswdync",@"GSWString: numberFormat=%@",_numberFormat);
_escapeHTML = [[associations objectForKey:escapeHTML__Key
withDefaultObject:[_escapeHTML autorelease]] retain];
NSDebugMLLog(@"gswdync",@"GSWString: escapeHTML=%@",_escapeHTML);
if (!WOStrictFlag)
{
_convertHTML = [[associations objectForKey:convertHTML__Key
withDefaultObject:[_convertHTML autorelease]] retain];
NSDebugMLLog(@"gswdync",@"GSWString: convertHTML=%@",_convertHTML);
_convertHTMLEntities = [[associations objectForKey:convertHTMLEntities__Key
withDefaultObject:[_convertHTMLEntities autorelease]] retain];
NSDebugMLLog(@"gswdync",@"GSWString: convertHTMLEntities=%@",_convertHTMLEntities);
};
self = [super initWithName:nil associations:nil template:nil];
if (!self) {
return nil;
}
ASSIGN(_value, [associations objectForKey: value__Key]);
if (_value == nil) {
[NSException raise:NSInvalidArgumentException
format:@"%s: no 'value' attribute specified.",
__PRETTY_FUNCTION__];
}
ASSIGN(_valueWhenEmpty, [associations objectForKey: valueWhenEmpty__Key]);
ASSIGN(_escapeHTML, [associations objectForKey: escapeHTML__Key]);
ASSIGN(_dateFormat, [associations objectForKey: dateFormat__Key]);
ASSIGN(_numberFormat, [associations objectForKey: numberFormat__Key]);
ASSIGN(_formatter, [associations objectForKey: formatter__Key]);
if ((_dateFormat != nil) || (_numberFormat != nil) || (_formatter != nil)) {
_shouldFormat = YES;
} else {
_shouldFormat = NO;
}
if ((_dateFormat != nil) && (_numberFormat != nil) || (_formatter != nil) &&
(_dateFormat != nil) || (_formatter != nil) && (_numberFormat != nil)) {
_formatter = [[associations objectForKey:formatter__Key
withDefaultObject:[_formatter autorelease]] retain];
NSDebugMLLog(@"gswdync",@"GSWString: formatter=%@",_formatter);
};
LOGObjectFnStopC("GSWString");
[NSException raise:NSInvalidArgumentException
format:@"%s: Cannot have 'dateFormat' and 'numberFormat' attributes at the same time.",
__PRETTY_FUNCTION__];
}
return self;
};
}
//--------------------------------------------------------------------
-(void)dealloc
{
DESTROY(_value);
DESTROY(_dateFormat);
DESTROY(_numberFormat);
DESTROY(_escapeHTML);
DESTROY(_convertHTML); //GSWeb Only
DESTROY(_convertHTMLEntities); //GSWeb Only
DESTROY(_formatter);
DESTROY(_value);
DESTROY(_escapeHTML);
DESTROY(_valueWhenEmpty);
[super dealloc];
};
}
//--------------------------------------------------------------------
-(NSString*)description
@ -133,113 +121,18 @@ static Class standardClass = Nil;
_formatter];
};
//--------------------------------------------------------------------
-(void)appendToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
{
//OK
NSString* formattedValue=nil;
GSWRequest* request=nil;
BOOL isFromClientComponent=NO;
GSWComponent* component=nil;
LOGObjectFnStartC("GSWString");
GSWStartElement(aContext);
GSWSaveAppendToResponseElementID(aContext);
request=[aContext request];
isFromClientComponent=[request isFromClientComponent];
component=GSWContext_component(aContext);
if (object_get_class(self)==standardClass)
formattedValue=(*standardFormattedValueInContextIMP)(self,formattedValueInContextSEL,aContext);
else
formattedValue=[self formattedValueInContext:aContext];
if (formattedValue)
{
BOOL escapeHTMLValue=YES;
BOOL convertHTMLValue=NO;
BOOL convertHTMLEntitiesValue=NO;
if (!WOStrictFlag && _convertHTML)
{
convertHTMLValue=GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_convertHTML,aContext);
};
if (!WOStrictFlag)
{
if (!convertHTMLValue)
{
if (_convertHTMLEntities)
{
convertHTMLEntitiesValue=GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_convertHTMLEntities,aContext);
};
if (!convertHTMLEntitiesValue)
{
if (_escapeHTML)
{
escapeHTMLValue=GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_escapeHTML,aContext);
};
};
};
}
else if (_escapeHTML)
{
escapeHTMLValue=GSWDynamicElement_evaluateValueInContext(self,standardClass,
standardEvaluateConditionInContextIMP,
_escapeHTML,aContext);
};
if (!WOStrictFlag && convertHTMLValue)
GSWResponse_appendContentHTMLConvertString(aResponse,formattedValue);
else if (!WOStrictFlag && convertHTMLEntitiesValue)
GSWResponse_appendContentHTMLEntitiesConvertString(aResponse,formattedValue);
else if (escapeHTMLValue)
GSWResponse_appendContentHTMLString(aResponse,formattedValue);
else
GSWResponse_appendContentString(aResponse,formattedValue);
};
GSWStopElement(aContext);
LOGObjectFnStopC("GSWString");
};
//--------------------------------------------------------------------
-(BOOL)appendStringAtRight:(id)unkwnon
withMapping:(char*)mapping
{
LOGObjectFnNotImplemented(); //TODOFN
return NO;
};
//--------------------------------------------------------------------
-(BOOL)appendStringAtLeft:(id)unkwnon
withMapping:(char*)mapping
{
LOGObjectFnNotImplemented(); //TODOFN
return NO;
};
// TODO: put that into a superclass, bulid a cache?
//--------------------------------------------------------------------
-(NSFormatter*)formatterForComponent:(GSWComponent*)component
value:(id)value
{
//OK
id formatValue = nil;
NSFormatter* formatter = nil;
LOGObjectFnStartC("GSWString");
id formatter = nil;
if (_dateFormat)
{
NSDebugMLLog(@"gswdync",@"DateFormat");
formatValue=[_dateFormat valueInComponent:component];
if (formatValue)
formatter=[[[NSDateFormatter alloc]initWithDateFormat:formatValue
@ -247,85 +140,78 @@ static Class standardClass = Nil;
}
else if (_numberFormat)
{
NSDebugMLLog(@"gswdync",@"NumberFormat");
formatValue=[_numberFormat valueInComponent:component];
if (formatValue)
{
//TODO
/* _formatter=[[NSNumberFormatter new]autorelease];
[_formatter setFormat:_formatValue];
/*
formatter=[[NSNumberFormatter new]autorelease];
[formatter setFormat:formatValue];
*/
};
}
else
{
NSDebugMLLog(@"gswdync",@"Formatter");
formatter=[_formatter valueInComponent:component];
};
NSDebugMLLog(@"gswdync",@"formatter=%@",formatter);
LOGObjectFnStopC("GSWString");
return formatter;
};
//--------------------------------------------------------------------
-(NSString*)elementName
{
LOGObjectFnNotImplemented(); //TODOFN
return nil;
};
//--------------------------------------------------------------------
// return formatted value
-(NSString*)formattedValueInContext:(GSWContext*)aContext
-(void)appendToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
{
GSWComponent* component = GSWContext_component(context);
NSString* formattedValue=nil;
GSWComponent* component=nil;
id valueValue = nil;
LOGObjectFnStartC("GSWString");
component=GSWContext_component(aContext);
NSDebugMLLog(@"gswdync",@"GSWString: value=%@",_value);
valueValue = [_value valueInComponent:component];
NSDebugMLLog(@"gswdync",@"GSWString: valueValue=%@",valueValue);
if (valueValue)
{
NSFormatter* formatter=[self formatterForComponent:component
value:valueValue];
if (!formatter)
{
formattedValue=valueValue;
// if we dont do this we get an exception on NSNumbers later. dave at turbocat.de
if ([formattedValue isKindOfClass:[NSNumber class]])
{
formattedValue = [(id)formattedValue stringValue];
}
}
else
{
formattedValue=[formatter stringForObjectValue:valueValue];
NSDebugMLLog(@"gswdync",@"valueValue=%@ formattedValue=%@",valueValue,formattedValue);
};
NSString * errorDscr = nil;
BOOL flag = YES;
if (_value != nil) {
valueValue = [_value valueInComponent:component];
if (_shouldFormat) {
NSFormatter* formatter=[self formatterForComponent:component];
if (formatter != nil) {
NS_DURING
formattedValue=[formatter stringForObjectValue:valueValue];
NS_HANDLER
formattedValue = nil;
NSLog(@"%s: value '%@' of class '%@' cannot be formatted.",
__PRETTY_FUNCTION__, valueValue, [valueValue class]);
NS_ENDHANDLER
}
}
if (formattedValue == nil) {
formattedValue = valueValue;
}
LOGObjectFnStopC("GSWString");
return formattedValue;
};
@end
//====================================================================
@implementation GSWString (GSWStringA)
//--------------------------------------------------------------------
+(BOOL)hasGSWebObjectsAssociations
{
return YES;
} else {
NSLog(@"%s:WARNING value binding is nil!", __PRETTY_FUNCTION__);
return;
}
if ((formattedValue != nil) && ([formattedValue isKindOfClass:[NSNumber class]])) {
// if we dont do this we get an exception on NSNumbers later.
formattedValue = [(id) formattedValue stringValue];
} else {
formattedValue = [(id) formattedValue description];
}
if ((formattedValue == nil || [formattedValue length] == 0) && _valueWhenEmpty != nil) {
formattedValue = [_valueWhenEmpty valueInComponent:component];
GSWResponse_appendContentString(response, formattedValue);
} else {
if (formattedValue != nil) {
if (_escapeHTML != nil) {
flag = [_escapeHTML boolValueInComponent:component];
}
if (flag) {
GSWResponse_appendContentHTMLConvertString(response, formattedValue);
} else {
GSWResponse_appendContentString(response, formattedValue);
}
}
}
};
@end

View file

@ -40,29 +40,16 @@
GSWAssociation* _directActionName;
};
-(id)initWithName:(NSString*)name
associations:(NSDictionary*)associations
contentElements:(NSArray*)elements;
-(void)dealloc;
@end
@interface GSWSubmitButton (GSWSubmitButtonA)
-(GSWElement*)invokeActionForRequest:(GSWRequest*)request
inContext:(GSWContext*)context;
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context;
-(void)appendNameToResponse:(GSWResponse*)response
inContext:(GSWContext*)context;
-(void)appendToResponse:(GSWResponse*)response
inContext:(GSWContext*)context;
-(void)_appendActionClassAndNameToResponse:(GSWResponse*)response
inContext:(GSWContext*)context;
@end
#endif //_GSWSubmitButton_h__

View file

@ -39,38 +39,39 @@ RCS_ID("$Id$")
//--------------------------------------------------------------------
-(id)initWithName:(NSString*)aName
associations:(NSDictionary*)associations
contentElements:(NSArray*)elements
template:(GSWElement*)template
{
NSMutableDictionary* tmpAssociations=[NSMutableDictionary dictionaryWithDictionary:associations];
LOGObjectFnStart();
NSDebugMLLog(@"gswdync",@"aName=%@ associations:%@ _elements=%@",
aName,associations,elements);
[tmpAssociations setObject:[GSWAssociation associationWithValue:@"submit"]
forKey:@"type"];
[tmpAssociations removeObjectForKey:action__Key];
[tmpAssociations removeObjectForKey:actionClass__Key];
if (_directActionName)
[tmpAssociations removeObjectForKey:_directActionName];
self = [super initWithName:@"input" associations:associations template: nil];
if (!self) {
return nil;
}
if (_value == nil) {
ASSIGN(_value, [[[GSWConstantValueAssociation alloc]initWithValue:@"Submit"] autorelease]);
}
ASSIGN(_action, [_associations objectForKey: action__Key]);
if (_action != nil) {
[_associations removeObjectForKey: action__Key];
}
ASSIGN(_actionClass, [_associations objectForKey: actionClass__Key]);
if (_actionClass != nil) {
[_associations removeObjectForKey: actionClass__Key];
}
ASSIGN(_directActionName, [_associations objectForKey: directActionName__Key]);
if (_directActionName != nil) {
[_associations removeObjectForKey: directActionName__Key];
}
if (![tmpAssociations objectForKey:value__Key])
[tmpAssociations setObject:[GSWAssociation associationWithValue:@"submit"]
forKey:value__Key];
if ((_action != nil) && ([_action isValueConstant])) {
[NSException raise:NSInvalidArgumentException
format:@"%s: 'action' attribute is a constant",
__PRETTY_FUNCTION__];
}
if (((_action != nil) && (_directActionName != nil)) || ((_action != nil) && (_actionClass != nil))) {
[NSException raise:NSInvalidArgumentException
format:@"%s: Either 'action' and 'directActionName' both exist, or 'action' and 'actionClass' both exist",
__PRETTY_FUNCTION__];
}
if ((self=[super initWithName:aName
associations:tmpAssociations
contentElements:nil]))
{
_action = [[associations objectForKey:action__Key
withDefaultObject:[_action autorelease]] retain];
NSDebugMLLog(@"gswdync",@"GSWSumbitButton: action=%@",_action);
_actionClass = [[associations objectForKey:actionClass__Key
withDefaultObject:[_actionClass autorelease]] retain];
NSDebugMLLog(@"gswdync",@"GSWSumbitButton: actionClass=%@",_actionClass);
_directActionName = [[associations objectForKey:directActionName__Key
withDefaultObject:[_directActionName autorelease]] retain];
NSDebugMLLog(@"gswdync",@"GSWSumbitButton: directActionName=%@",_directActionName);
};
LOGObjectFnStop();
return self;
};
@ -83,6 +84,64 @@ RCS_ID("$Id$")
[super dealloc];
};
- (NSString*) type
{
return @"submit";
}
-(id) description
{
return [NSString stringWithFormat:@"<%s %p action: %@ actionClass: %@ directActionName:%@ disabled:%@ >",
object_get_class_name(self),
(void*)self, _action, _actionClass, _directActionName,
_disabled];
};
//--------------------------------------------------------------------
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)aContext
{
//Does Nothing!
}
-(GSWElement*)invokeActionForRequest:(GSWRequest*) request
inContext:(GSWContext*) context
{
GSWComponent * component = GSWContext_component(context);
id actionValue=nil;
NS_DURING
if ((! [self disabledInComponent: component]) && ([context _wasFormSubmitted])) {
if ([context _isMultipleSubmitForm]) {
if ([request formValueForKey:[self nameInContext:context]] != nil) {
[context _setActionInvoked:YES];
if (_action != nil) {
actionValue = [_action valueInComponent:component];
}
if (actionValue == nil) {
actionValue = [context page];
}
}
} else {
[context _setActionInvoked:YES];
if (_action != nil) {
actionValue = [_action valueInComponent:component];
}
if (actionValue == nil) {
actionValue = [context page];
}
}
}
NS_HANDLER
localException=ExceptionByAddingUserInfoObjectFrameInfo(localException,
@"In GSWSubmitButton invokeActionForRequest:inContext");
LOGException(@"exception=%@",localException);
[localException raise];
NS_ENDHANDLER
return actionValue;
}
// PRIVATE used within dynamic elements
- (NSString*) _actionClassAndNameInContext:(GSWContext*) context
@ -94,182 +153,38 @@ RCS_ID("$Id$")
return s;
}
//--------------------------------------------------------------------
-(void)appendToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
- (void) _appendNameAttributeToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
{
//OK
LOGObjectFnStart();
GSWStartElement(context);
GSWSaveAppendToResponseElementID(context);
[super appendToResponse:response
inContext:context];
if ((_directActionName != nil) || (_actionClass != nil)) {
[response _appendTagAttribute: name__Key
value: [self _actionClassAndNameInContext:context]
escapingHTMLAttributeValue: NO];
} else {
[super _appendNameAttributeToResponse:response
inContext: context];
}
}
if (_actionClass != nil || _directActionName != nil)
{
GSWResponse_appendContentAsciiString(response,@"<input type=\"hidden\" name=\"");
GSWResponse_appendContentAsciiString(response,GSWKey_SubmitAction[GSWebNamingConv]);
GSWResponse_appendContentCharacter(response,'"');
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response,
@"value",
[self _actionClassAndNameInContext:context],
NO);
- (void) appendToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
{
[super appendToResponse:response inContext:context];
if ((_directActionName != nil) || (_actionClass != nil)) {
GSWResponse_appendContentAsciiString(response,@"<input type=\"hidden\" name=\"WOSubmitAction\"");
[response _appendTagAttribute: value__Key
value: [self _actionClassAndNameInContext:context]
escapingHTMLAttributeValue: NO];
GSWResponse_appendContentCharacter(response,'>');
}
GSWStopElement(context);
LOGObjectFnStop();
};
}
//--------------------------------------------------------------------
-(GSWElement*)invokeActionForRequest:(GSWRequest*)request
inContext:(GSWContext*)aContext
-(void) _appendCloseTagToResponse:(GSWResponse *) response
inContext:(GSWContext*) context
{
//OK
GSWElement* element=nil;
BOOL disabledValue=NO;
LOGObjectFnStart();
GSWStartElement(aContext);
NS_DURING
{
GSWAssertCorrectElementID(aContext);
disabledValue=[self disabledInContext:aContext];
NSDebugMLLog(@"gswdync",@"disabledValue=%s",(disabledValue ? "YES" : "NO"));
if (!disabledValue)
{
BOOL wasFormSubmitted=[aContext _wasFormSubmitted];
NSDebugMLLog(@"gswdync",@"wasFormSubmitted=%s",(wasFormSubmitted ? "YES" : "NO"));
if (wasFormSubmitted)
{
BOOL invoked=NO;
GSWComponent* component=GSWContext_component(aContext);
BOOL isMultipleSubmitForm=[aContext _isMultipleSubmitForm];
if (isMultipleSubmitForm)
{
NSString* nameInContext=[self nameInContext:aContext];
NSString* formValue=[request formValueForKey:nameInContext];
NSDebugMLLog(@"gswdync",@"formValue=%@",formValue);
if (formValue)
invoked=YES;
else
{
NSDebugMLLog(@"gswdync",@"[request formValueKeys]=%@",[request formValueKeys]);
};
}
else
invoked=YES;
if (invoked)
{
id actionValue=nil;
NSDebugMLLog0(@"gswdync",@"Invoked Object Found !!");
[aContext _setActionInvoked:1];
NS_DURING
{
NSDebugMLLog(@"gswdync",@"Invoked Object Found: action=%@",_action);
actionValue=[_action valueInComponent:component];
}
NS_HANDLER
{
LOGException0(@"exception in GSWSubmitButton invokeActionForRequest:inContext action");
LOGException(@"exception=%@",localException);
localException=ExceptionByAddingUserInfoObjectFrameInfo(localException,
@"In GSWSubmitButton invokeActionForRequest:inContext action %@",
_action);
LOGException(@"exception=%@",localException);
[localException raise];
}
NS_ENDHANDLER;
if (actionValue)
element=actionValue;
if (element)
{
if (![element isKindOfClass:[GSWComponent class]]) //TODO GSWComponent or Element ?
{
ExceptionRaise0(@"GSWSubmitButton",@"Invoked element return a not GSWComponent element");
}
else
{
// call awakeInContext when _element is sleeping deeply
[(GSWComponent*)element ensureAwakeInContext:aContext];
/*
if (![_element context]) {
NSDebugMLLog(@"gswdync",@"_element sleeps, awake it = %@",_element);
[_element awakeInContext:aContext];
} else {
[_element awakeInContext:aContext];
}
*/
}
}
/* ???
if (!_element)
_element=[aContext page];
*/
};
};
};
}
NS_HANDLER
{
LOGException0(@"exception in GSWSubmitButton invokeActionForRequest:inContext");
LOGException(@"exception=%@",localException);
localException=ExceptionByAddingUserInfoObjectFrameInfo(localException,
@"In GSWSubmitButton invokeActionForRequest:inContext");
LOGException(@"exception=%@",localException);
[localException raise];
}
NS_ENDHANDLER;
if (![aContext _wasActionInvoked] && GSWContext_isParentSenderIDSearchOver(aContext))
{
LOGError(@"Action not invoked at the end of %@ (id=%@) senderId=%@",
[self class],
GSWContext_elementID(aContext),
GSWContext_senderID(aContext));
};
GSWStopElement(aContext);
LOGObjectFnStop();
return element;
};
//--------------------------------------------------------------------
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)aContext
{
//Does Nothing ?
GSWStartElement(aContext);
GSWAssertCorrectElementID(aContext);
GSWStopElement(aContext);
};
//--------------------------------------------------------------------
// used within dynamic elements
-(void)appendNameToResponse:(GSWResponse*)response
inContext:(GSWContext*)aContext
{
if (_actionClass != nil || _directActionName != nil)
{
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response,
@"name",
[self _actionClassAndNameInContext: aContext],
NO);
}
else
{
[super appendNameToResponse:response
inContext:aContext];
}
};
//--------------------------------------------------------------------
-(void)_appendActionClassAndNameToResponse:(GSWResponse*)response
inContext:(GSWContext*)aContext
{
LOGObjectFnNotImplemented(); //TODOFN
};
}
@end

View file

@ -328,10 +328,15 @@ May raise exception if element can't be created
}
else
{
Class elementClass = Nil;
NSString* elementType=[declaration type];
NSDebugMLog(@"elementType=%@",elementType);
if ([elementType length]==0)
if (elementType != nil) {
elementClass = NSClassFromString(elementType);
}
if ((elementType == nil) || (elementClass == Nil)) //[elementType length]==0
{
[GSWDeclarationFormatException raise:GSWDFEMissingClassNameForElement
format:@"No class name for element named '%@' with declaration: %@. %@",
@ -339,7 +344,6 @@ May raise exception if element can't be created
}
else
{
Class elementClass = NSClassFromString(elementType);
NSDictionary* associations = nil;
NSDebugMLog(@"elementClass=%@",elementClass);

View file

@ -36,21 +36,6 @@
//====================================================================
@interface GSWText: GSWInput
-(id)initWithName:(NSString*)name
associations:(NSDictionary*)associations
contentElements:(NSArray*)elements;
-(NSString*)elementName;
-(void)appendToResponse:(GSWResponse*)response
inContext:(GSWContext*)context;
-(NSString*)_filterSoftReturnsFromString:(NSString*)string;
@end
//====================================================================
@interface GSWText (GSWTextA)
-(BOOL)appendStringAtRight:(id)unkwnon
withMapping:(char*)mapping;
@end
#endif //_GSWText_h__

View file

@ -37,17 +37,23 @@ RCS_ID("$Id$")
@implementation GSWText
//--------------------------------------------------------------------
-(id)initWithName:(NSString*)name
-(id)initWithName:(NSString*)aName
associations:(NSDictionary*)associations
contentElements:(NSArray*)elements
template:(GSWElement*)template
{
if ((self=[super initWithName:name
associations:associations
contentElements:nil]))
{
};
self = [super initWithName:@"textarea" associations:associations template: nil];
if (!self) {
return nil;
}
if ((_value == nil) || (![_value isValueSettable])) {
[NSException raise:NSInvalidArgumentException
format:@"%s: 'value' attribute not present or is a constant",
__PRETTY_FUNCTION__];
}
return self;
};
}
//--------------------------------------------------------------------
-(void)dealloc
@ -66,47 +72,69 @@ RCS_ID("$Id$")
//--------------------------------------------------------------------
-(NSString*)elementName
{
return @"TEXTAREA";
return @"textarea";
};
//--------------------------------------------------------------------
-(void)appendToResponse:(GSWResponse*)aResponse
inContext:(GSWContext*)aContext
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context
{
//OK
//GSWRequest* request=[aContext request];
NSString* valueValue=nil;
NSString* valueValueFiltered=nil;
//not used BOOL isFromClientComponent=[request isFromClientComponent];
GSWComponent* component=GSWContext_component(aContext);
[super appendToResponse:aResponse
inContext:aContext];
valueValue=[_value valueInComponent:component];
valueValueFiltered=[self _filterSoftReturnsFromString:valueValue];
GSWResponse_appendContentHTMLString(aResponse,valueValueFiltered);
GSWResponse_appendContentAsciiString(aResponse,@"</TEXTAREA>");
};
id resultValue = nil;
GSWComponent * component = GSWContext_component(context);
if ((![self disabledInComponent: component]) && ([context _wasFormSubmitted])) {
NSString * nameCtx = [self nameInContext:context];
if (nameCtx != nil) {
[_value setValue: [request stringFormValueForKey: nameCtx]
inComponent:component];
}
}
}
-(void) _appendValueAttributeToResponse:(GSWResponse *) response
inContext:(GSWContext*) context
{
// nothing!
}
//--------------------------------------------------------------------
// Replace \r\n by \n
-(NSString*)_filterSoftReturnsFromString:(NSString*)string
{
NSRange range=[string rangeOfString:@"\r\n"];
if (range.length>0)
string=[string stringByReplacingString:@"\r\n"
withString:@"\n"];
return string;
NSRange range;
NSMutableString * myTmpStr = nil;
unsigned len = 0;
if (!string) {
return nil;
}
len = [string length];
if (len<1) {
return string;
}
myTmpStr = [NSMutableString stringWithCapacity: len];
[myTmpStr setString: string];
while (YES) {
range = [myTmpStr rangeOfString:@"\r\n"];
if (range.length>0) {
[myTmpStr replaceCharactersInRange: range withString:@"\n"];
} else {
break;
}
}
return [NSString stringWithString: myTmpStr];
};
@end
//====================================================================
@implementation GSWText (GSWTextA)
-(BOOL)appendStringAtRight:(id)unkwnon
withMapping:(char*)mapping
-(void) appendChildrenToResponse:(GSWResponse*) response
inContext:(GSWContext*) context
{
LOGObjectFnNotImplemented(); //TODOFN
return NO;
};
id valueValue = [_value valueInComponent:GSWContext_component(context)];
if (valueValue != nil) {
GSWResponse_appendContentHTMLString(response, [self _filterSoftReturnsFromString:valueValue]);
}
}
@end

Some files were not shown because too many files have changed in this diff Show more